This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* springFactory | |
* | |
* Generate a physically realistic easing curve for a damped mass-spring system. | |
* | |
* Required: | |
* damping (zeta): [0, 1) | |
* halfcycles: 0...inf | |
* | |
* Optional: | |
* initial_position: -1..1, default 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getViewSize = () => { | |
const fov = THREE.Math.degToRad(camera.fov); | |
const dist = camera.position.z - plane.position.z; | |
const height = 2 * Math.tan(fov / 2) * dist; | |
const width = height * camera.aspect; | |
return [width, height]; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* this.bufferGeometry.setAttribute( | |
"uv", | |
new THREE.BufferAttribute(uvArray, 2) | |
); | |
*/ | |
createUV(mesh) { | |
const box = new THREE.Box3().setFromObject(mesh); | |
const size = new THREE.Vector3(); | |
box.getSize(size); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.material.onBeforeCompile = (shader) => { | |
shader.uniforms.time = { value: 0 }; | |
shader.uniforms.texture = { value: texture }; | |
/******************** Vertex Shader ********************/ | |
shader.vertexShader = ` | |
#define TAU 6.28318530718 | |
uniform float time; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (let i = 0; i < gridLength; i++) { | |
for (let j = 0; j < gridLength; j++) { | |
const x = c.width / (gridLength + 1) * (j + 1); | |
const y = c.height / (gridLength + 1) * (i + 1); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isEmpty = (texture) => { | |
const canvas = document.createElement("canvas"); | |
const ctx = canvas.getContext("2d"); | |
ctx.drawImage(texture.image, 0, 0); | |
const data = ctx.getImageData(0, 0, texture.image.width, texture.image.height); | |
const lengthData = data.data.length | |
let numVisible = 0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float fog(vec2 coord, float multiplier){ | |
vec2 newCoord = coord * multiplier; | |
float motion = fbm(newCoord + vec2(uTime * -.5, uTime * -.5) ); | |
return fbm(newCoord + motion); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float rand (vec2 st) { | |
return fract(sin(dot(st.xy, | |
vec2(12.9898,78.233)))* | |
43758.5453123); | |
} | |
float noise(vec2 p){ | |
vec2 ip = floor(p); | |
vec2 u = fract(p); | |
u = u*u*(3.0-2.0*u); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const map = (value, inMin, inMax, outMin, outMax) => { | |
return ( (value - inMin) / ( inMax - inMin ) * ( outMax - outMin ) ) + outMin; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vec2 uv = vTextureCoord; | |
vec2 m = uMouse / uReso; | |
vec3 lightAmbient = vec3(.2, .2, .2 ); | |
vec4 lightColor = vec4(1., 1., 1., 1.3); | |
vec3 lightPos = vec3(uv - m, .1); | |
vec3 color = texture2D(texture0, uv).xyz; | |
vec3 normalMap = texture2D(map, uv).xyz - .5; |
NewerOlder