Skip to content

Instantly share code, notes, and snippets.

commit 38dd0a599411d0d75f48ba1011314f5a6c0b79cd
Author: Mr.doob <info@mrdoob.com>
Date: Wed Dec 30 14:24:09 2015 +0000
Moved TextGeometry back to core. Removed typeface_js hack.
examples/js/utils/FontUtils.js | 276 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 file changed, 276 deletions(-)
@AndrewRayCode
AndrewRayCode / compare.sh
Last active February 13, 2016 07:24
Compare the occurrence / frequency of words used in two files with bash and (g)awk
# Note, on osx, brew install gawk
# Replace FILE1 and FILE2 with your files
# Multi line, commented:
gawk \
# This gawk program lowercases both words and counts how many times they\
# appear in each file\
'FNR == NR\
{ a[tolower($0)]++; next }\
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"modules": true
},
},
"env": {
"node": true,
// ...
render() {
const { field, someCondition } = this.state;
let component = null;
if( someCondition ) {
component = <MyChild
field={ field }
/>;
import React, { PropTypes, Component } from 'react';
import React3 from 'react-three-renderer';
import { Shrink } from '../';
import THREE from 'three';
export default class CreatePreviewObject extends Component {
static propTypes = {
createType: PropTypes.string.isRequired,
createPreviewPosition: PropTypes.object.isRequired,
@AndrewRayCode
AndrewRayCode / easing.js
Created March 13, 2016 05:01
ES6 module-ified easing functions, based on https://gist.github.com/gre/1650294
// based on https://gist.github.com/gre/1650294
// no easing, no acceleration
export function linear( t ) {
return t;
}
// accelerating from zero velocity
export function easeInQuad( t ) {
return t * t;
export function reduceState( props, oldState, initialState, ...reducers ) {
let index = 0;
const next = ( newState ) => {
index = index + 1;
return reducers[ index ]( props, oldState, newState, next );
};
return reducers[ 0 ]( props, oldState, initialState, next );
var emitter = new SPE.Emitter({
type: 3,
maxAge: {
value: 1
},
position: {
value: new THREE.Vector3( 0, 0, 0 ),
radius: 5,
},

Designing a game loop: How to interact with a safe, and animate its door opening over time?

Note the code in these examples is intentionally verbose to explain things fully.

First let's look at our data only, not visuals. Our world is set up as a Javascript object:

var world = {
    player: {
        position: { x: 1, y: 1 }
// Declarative data
const legAnimations = {
Idle: {
weight: 0,
percent: 0,
},
Walk: {
weight: 1,
percent: 0.5
},