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
| zoomAll() { | |
| // Placeholder for calculating the bounding box of all nodes | |
| let bounds = { | |
| top: Infinity, | |
| left: Infinity, | |
| bottom: -Infinity, | |
| right: -Infinity | |
| }; |
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.renderCanvas({ | |
| target: webglrendertarget | |
| }); | |
| let frameBuffer = webglrendertarget.__webglFramebuffer; | |
| gl.bindFramebuffer( gl.FRAMEBUFFER, frameBuffer ); | |
| gl.viewport( 0, 0, 400, 400 ); | |
| gl.readPixels( 0, 0, 400, 400, gl.RGBA, gl.UNSIGNED_BYTE, pixelBuffer ); | |
| gl.bindFramebuffer( gl.FRAMEBUFFER, null ); |
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
| function copyUIntToImageData( uint, imageData ) { | |
| for( let i = 0; i < uint.length; i += 4 ) { | |
| let index = uint.length - i; // flip how data is read | |
| imageData.data[ index ] = uint[ i ]; //red | |
| imageData.data[ index + 1 ] = uint[ i + 1 ]; //green | |
| imageData.data[ index + 2 ] = uint[ i + 2 ]; //blue | |
| imageData.data[ index + 3 ] = uint[ i + 3 ]; //alpha | |
| } |
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
| function without( obj, ...keys ) { | |
| return Object.keys( obj ).reduce( ( memo, key ) => { | |
| if( keys.indexOf( key ) === -1 ) { | |
| memo[ key ] = obj[ key ]; | |
| } | |
| return memo; | |
| }, {} ); | |
| } |
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
| return <group | |
| position={ position } | |
| rotation={ new THREE.Euler().setFromQuaternion( rotation ) } | |
| scale={ scale } | |
| > | |
| <mesh | |
| position={ offset } | |
| ref="mesh" | |
| castShadow |
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
| function getFrustrumAt( camera, fov, aspect, distanceFromCamera ) { | |
| var frustumHeight = 2.0 * distanceFromCamera * Math.tan(fov * 0.5 * ( Math.PI / 180 ) ), | |
| var box = new THREE.Box2(); | |
| var size = new THREE.Vector2( frustumHeight * aspect, frustumHeight ); | |
| box.width = size.x; | |
| box.height = size.y; | |
| return box.setFromCenterAndSize( camera.position, new THREE.Vector2( | |
| frustumHeight * aspect |
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
| [14:40:39] Requiring external module babel-core/register | |
| ./react-three-renderer/node_modules/babel-plugin-runtime/lib/index.js:23 | |
| return new Plugin("runtime", { | |
| ^ | |
| TypeError: Plugin is not a function |
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
| [16:16:15] Requiring external module babel-core/register | |
| ./react-three-renderer/node_modules/babel-plugin-runtime/lib/index.js:23 | |
| return new Plugin("runtime", { | |
| ^ | |
| TypeError: Plugin is not a function |
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
| // Bad! Not normalized, nested | |
| classrooms: [{ | |
| id: 1, | |
| name: 'Math', | |
| students: [{ | |
| id: 1, | |
| name: 'Sally' | |
| }] | |
| }] |
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 forceZ = 0; | |
| ... | |
| // Is space pressed? | |
| if( KeyCodes.SPACE in keysDown ) { | |
| // Are we touching a wall / floor we can jump off of? | |
| if( Object.keys( jumpableWalls ).length ) { | |
| forceZ -= 5; |