View ec.js
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 R from 'ramda'; | |
import * as Perf from '../cpcs/performance'; | |
import fast from '../../node_modules/fast.js/index'; | |
/** | |
* @return {string} | |
*/ | |
function newId(){ | |
let d = new Date().getTime(); | |
let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { |
View stateevents.js
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 R from 'ramda'; | |
import * as Debug from './debug'; | |
export function create(){ | |
const events = { | |
componentCreations: [], | |
componentChanges: [], | |
componentDeletions: [] | |
}; |
View ec.js
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 R from 'ramda'; | |
function newId(){ | |
let d = new Date().getTime(); | |
let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
const r = (d + Math.random()*16)%16 | 0; | |
d = Math.floor(d/16); | |
return (c=='x' ? r : (r&0x3|0x8)).toString(16); | |
}); | |
return uuid; |
View ec.js
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 R from 'ramda'; | |
function newId(){ | |
let d = new Date().getTime(); | |
let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
const r = (d + Math.random()*16)%16 | 0; | |
d = Math.floor(d/16); | |
return (c=='x' ? r : (r&0x3|0x8)).toString(16); | |
}); | |
return uuid; |
View three.js localstorage camera
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
// save camera views | |
const savedCamera = JSON.parse( localStorage.getItem( 'savedCamera' ) ); | |
if( savedCamera ){ | |
camera.position.copy( savedCamera.cameraPosition ); | |
orbitControls.target.copy( savedCamera.targetPosition ); | |
} | |
$(window).unload( function(){ | |
localStorage.savedCamera = JSON.stringify({ | |
cameraPosition: camera.position, |
View fixgrouptoshapes.js
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 fixGroupToShapes( g ){ | |
var bb = g.getBoundingClientRect(); | |
var cx = bb.width * 0.5 + bb.left; | |
var cy = bb.height * 0.5 + bb.top; | |
g.center(); | |
g.translation.x = cx; | |
g.translation.y = cy; | |
} |
View twojshack.js
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
/* | |
Goes after | |
Polygon.MakeObservable(Polygon.prototype); | |
//... | |
*/ | |
var Text = Two.Text = function( text ) { |
View Two.js group traversal
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 traverseGroup( group, fn ){ | |
for( var i in group.children ){ | |
var child = group.children[ i ]; | |
fn( child ); | |
traverseGroup( child, fn ); | |
} | |
} |
View isometric unproject
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
Phaser.Plugin.Isometric.Projector.prototype.unproject = function (point, out) { | |
if (typeof out === "undefined") { | |
out = new Phaser.Plugin.Isometric.Point3(); | |
} | |
var px = point.x; | |
var py = point.y; | |
px *= this.projectionRatio; |
View gist:86dac07cdc6a16baafe1
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
ForceGPULoad = (function(){ | |
var renderer; | |
var scene; | |
var camera; | |
return { | |
buffer: function( object3D ){ | |
// push | |
var originalPosition = object3D.position.clone(); | |
object3D.position.set( 0,0,0 ); |