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
import*as THREE from "https://threejs.org/build/three.module.js" | |
class InstanceCache { | |
constructor(geometry, material, startingCount) { | |
const mesh = (this.mesh = new THREE.InstancedMesh( | |
geometry.clone(), | |
material.clone(), | |
startingCount | |
)); | |
mesh.userData.max = startingCount; |
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
/** | |
* Use the Web Storage API to save camera position and target between page refreshes. | |
* | |
* @param {Object} options | |
* @param {*} options.camera - The camera you want to store the position of. | |
* @param {*} [options.controls] - A controls object with a `.target` property. | |
* @param {String} [options.name="main"] - An optional label. Useful if you want to store multiple cameras. | |
* @param {Boolean} [options.session=true] - Indicates if you want to use local or session storage. | |
* See https://developer.mozilla.org/en-US/docs/Web/API/Storage | |
*/ |
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
class Easing { | |
} | |
Easing.fns = function() { | |
var x = Math.pow | |
, C = Math.sqrt | |
, T = Math.sin | |
, q = Math.cos | |
, B = Math.PI |
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
/******** CANVAS RECORDER | |
Invoke with: | |
import CanvasRecorder from "./canvasrecorder.js" | |
CanvasRecorder( yourCanvas ) | |
*/ |
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
let wichmann_hill_rng = (s1=100,s2=100,s3=100)=>()=>((s1 = (171 * s1) % 30269) / 30269 + (s2 = (172 * s1) % 30307) / 30307 + (s3 = (170 * s1) % 30323) / 30323) % 1 | |
let rng = wichmann_hill_rng() | |
for (let i = 0; i < 1000; i++) console.log(rng()) |
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
class vec3 { | |
set(x=0, y=0, z=0) { | |
this.x = x; | |
this.y = y; | |
this.z = z; | |
return this; | |
} | |
copy(v) { | |
return this.set(v.x, v.y, v.z) | |
} |
NewerOlder