This file contains 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 pnts = [ | |
-2,0,-2, | |
-2,0,2, | |
2,0,2, | |
4,0,1, | |
]; | |
const poly = roundedline( pnts ); | |
const buf = new Vec3Buffer( poly ); |
This file contains 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
/* | |
NOTES | |
https://blog.scottlogic.com/2019/11/18/drawing-lines-with-webgl.html | |
EXAMPLE | |
const pnts = [ | |
-2,0,-2, | |
-2,0,2, | |
2,0,2, | |
4,0,0, |
This file contains 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 pnts = [-2,0,-2,-2,0,2,2,0,2,2,0,-2]; | |
for( let v of iterFlatVec3Buf( pnts ) ) console.log( v ); | |
instead of | |
const v = [0,0,0]; | |
for( let i=0; i < pnts.length; i+=3 ){ | |
v[0] = pnts[i+0]; | |
v[1] = pnts[i+1]; |
This file contains 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
function nanoID( t=21 ){ | |
const r = crypto.getRandomValues( new Uint8Array( t ) ); | |
let n, e = ''; | |
for( ;t--; ){ | |
n = 63 & r[ t ]; | |
e += ( n < 36 )? n.toString( 36 ) : | |
( n < 62 )? ( n - 26 ).toString( 36 ).toUpperCase() : | |
( n < 63 )? '_' : '-'; | |
} | |
return e; |
This file contains 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
function KeyboardEvents(){ | |
let self; | |
const keys = new Map(); // State of a key press, lets user hold down multiple buttons | |
// #region HANDLERS | |
const onKeyDown = e=>{ keys.set( e.key, true ); }; | |
const onKeyUp = e=>{ keys.set( e.key, false ); }; | |
// #endregion | |
// #region MAIN |
This file contains 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 'three'; | |
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'; | |
/* | |
const App = useThreeWebGL2(); | |
App.scene.add( facedCube( [0,3,0], 6 ) ); | |
App | |
.sphericalLook( 45, 35, 40 ) | |
.renderLoop(); | |
*/ |
This file contains 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 { ShaderChunk } from 'three'; | |
/* | |
USAGE | |
const geo = new THREE.BoxGeometry( 1, 1, 1 ); | |
const mat = new THREE.PointsMaterial( { size: 0.5, vertexColors: true } ); | |
const mesh = new THREE.Points( geo, mat ); | |
resolvedShaderPromise( mat ). | |
then( sh => console.log( sh ) ); | |
*/ |
This file contains 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
function nanoID( t=21 ){ | |
const r = crypto.getRandomValues( new Uint8Array( t ) ); | |
let n, e = ''; | |
for( ;t--; ){ | |
n = 63 & r[ t ]; | |
e += ( n < 36 )? n.toString( 36 ) : | |
( n < 62 )? ( n - 26 ).toString( 36 ).toUpperCase() : | |
( n < 63 )? '_' : '-'; | |
} | |
return e; |
This file contains 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
/* [ NOTES ] ============================================================ | |
BigInt has 64 bits, since its signed there is only 63 bits to work with. | |
First 5 bits are reserved to store the Level value, which results the max value of 31 | |
63bits - 5bits = 58 bits for quadrant information | |
Each quadrant needs 2bits to store its information | |
So 58 / 2 = 29, which is the max level to generate ids from |
This file contains 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
jntCount = ChainPose.count; | |
angles[] = new Array( jntCount ).fill( 0 ) | |
loop | |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
// Get world space transform (pos,rot,scl) of each bone in the chain | |
// Then preallocate space for the jacobian matrix | |
transforms[] = compute_WorldSpace_Transforms( ChainPose ); | |
jacobian = Array( transforms.length * 3 * 3 ); // Each Joint gets 3 floats for 3 axes | |