Skip to content

Instantly share code, notes, and snippets.

View robksawyer's full-sized avatar
🎯
Focusing

Rob Sawyer robksawyer

🎯
Focusing
View GitHub Profile
@robksawyer
robksawyer / audioLoading.jsx
Created August 13, 2022 19:07
This snippet shows how to load audio with Three JS
const [sound, setSound] = useState()
const [listener, setListener] = useState()
const [analyser, setAnalyser] = useState()
const [data, setData] = useState(1)
// load a sound and set it as the Audio object's buffer
useEffect(() => {
const listener = new THREE.AudioListener()
setListener(listener)
const sound = new THREE.PositionalAudio(listener)
setSound(sound)
@robksawyer
robksawyer / shader-noise.glsl
Created August 1, 2022 14:07
A bunch of noise functions
//
// Description : Array and textureless GLSL 2D/3D/4D simplex
// noise functions.
// Author : Ian McEwan, Ashima Arts.
// Maintainer : stegu
// Lastmod : 20110822 (ijm)
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
// Distributed under the MIT License. See LICENSE file.
// https://github.com/ashima/webgl-noise
// https://github.com/stegu/webgl-noise
@robksawyer
robksawyer / CustomEffect.js
Last active July 29, 2022 04:00
Example template for a custom postprocessing effect.
import * as React from 'react';
import { Uniform } from 'three';
import { Effect } from 'postprocessing';
const fragmentShader = `
void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
if (uv.y < .5) discard;
outputColor = vec4(vec3(average(inputColor.rgb)), inputColor.a);
}`;
let Web3 = require("web3");
// Replace value of rpc with https://rpc-mumbai.matic.today for Mumbai
let rpc = "https://rpc-mainnet.matic.network";
const provider = new Web3.providers.HttpProvider(rpc);
const web3 = new Web3(provider);
// Add your private key
web3.eth.accounts.wallet.add("pvt-key");
#define SHADER_NAME PolyhedronMaterial
precision highp float;
uniform sampler2D map;
uniform vec2 uvDisp;
uniform float time;
varying float smoothShading;
// varying vec3 viewPos;
varying vec2 vUV;
@robksawyer
robksawyer / effects.jsx
Last active November 30, 2020 15:18
react-three-fiber post-processing trial & errors
import React, { useEffect, useMemo } from 'react'
import { useFrame, useThree, extend, useLoader } from 'react-three-fiber'
import * as THREE from 'three'
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer'
import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass'
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass'
// import { UnrealBloomPass } from 'three/examples/jsm/postprocessing/UnrealBloomPass'
import { FXAAShader } from 'three/examples/jsm/shaders/FXAAShader'
@robksawyer
robksawyer / excludedActivityTypes.swift
Last active December 12, 2024 10:37
A list of UIActivity.ActivityType for modern apps.
let excludedActivityTypes = [
UIActivity.ActivityType.print,
UIActivity.ActivityType.openInIBooks,
UIActivity.ActivityType.copyToPasteboard,
UIActivity.ActivityType.addToReadingList,
UIActivity.ActivityType.assignToContact,
UIActivity.ActivityType.copyToPasteboard,
UIActivity.ActivityType.mail,
UIActivity.ActivityType.markupAsPDF,
UIActivity.ActivityType.postToFacebook,
_this.pass = new NukePass("ExperienceOverlay", {
unique: "exp_overlay",
uOverlay: {
value: 0
},
tNormal: {
value: null,
getTexture: Utils3D.getRepeatTexture
},
uLightStr: {
@robksawyer
robksawyer / SoundIcon.js
Created September 25, 2020 11:04
Code for an animated audio toggle.
Class((function SoundIcon() {
Inherit(this, Element);
const _this = this,
$this = _this.element,
_bars = [];
var _audioCtrl, _analyser, _analyserArray;
const RANGE = [255, 100, 140];
function hover({
action: action
Class((function GazeCamera(_input, _group) {
Inherit(this, BaseCamera);
const _this = this;
var _strength = {
v: 1
},
_move = new Vector3,
_position = new Vector3,
_wobble = new Vector3,
_rotation = 0,