Skip to content

Instantly share code, notes, and snippets.

@vincent
vincent / moveAlong.js
Last active February 1, 2019 18:30
Move a Three.js object along a path, or an array of THREE.Vector3
var noop = function(){};
function moveAlong ( object, shape, options ) {
options = _.merge({
from: 0,
to: 1,
duration: null,
speed: 50,
start: true,
yoyo: false,
@vincent
vincent / underscore-query-scored.js
Last active August 29, 2015 14:13
Example usage of a "scored" query with underscore-query
var collection = [
{ name:'dress', color:'red', price:100 },
{ name:'shoes', color:'black', price:120 },
{ name:'jacket', color:'blue', price:150 },
];
var results = _.scored( collection, { price: {$lt:140}, color: {$any:['red', 'blue'] });
// [ { name:'dress', _score:1, ... }, { name:'shoes', _score:0.3, ... } ]
// dress got a score of 1, because it matchs all statements
// shoes got a score of 0.5, because it matchs half the statements
@vincent
vincent / THREE.CamControls.js
Last active December 28, 2015 09:49
A Three.js camera control experiment
THREE.CamControls = function ( object, domElement ) {
this.object = object;
this.domElement = ( domElement !== undefined ) ? domElement : document;
if ( domElement ) this.domElement.setAttribute( 'tabindex', -1 );
// API
this.enabled = true;
this.mouseEnabled = true;