Skip to content

Instantly share code, notes, and snippets.

@jensarps
jensarps / tutorial.js
Created November 25, 2011 11:12
IDBWrapper tutorial, step 7
var onsuccess = function(){
console.log('now the store is clean again!');
}
var onerror = function(error){
console.log('Oh noes, sth went wrong!', error);
}
customers.clear(onsuccess, onerror);
@jensarps
jensarps / Ray.js
Created April 8, 2012 15:59
Modifying the three.js Ray class
// modify this:
} else if ( object instanceof THREE.Mesh ) {
// to:
} else if ( object.matrixWorld && object.geometry ) {
@jensarps
jensarps / add_from_children.js
Created April 8, 2012 16:01
Modifying the object added to the scene
onModelLoaded: function(collada){
var object = collada.scene;
// some stuff here
var mesh = object.children.filter(function(child){
return child instanceof THREE.Mesh;
})[0];
object.geometry = mesh.geometry;
@jensarps
jensarps / dieassert.js
Created May 10, 2012 08:50 — forked from jeromeetienne/dieassert.js
a console.assert which actually stop the execution
/**
* [Forked from https://gist.github.com/2651899]
*
* A console.assert which actually stop the exectution.
* default console.assert() is a plain display, such as console.log() or console.error();
* It doesnt stop the execution like assert() is meant to do. This is a little code to
* "workaround this limitation" :)
*
* Usage:
* console.assert(foo === bar); // Will throw if not equal
@jensarps
jensarps / skybox.js
Created June 29, 2012 10:13
Ascent skybox code
function(scene, options){
var opts = tools.mixin({
folder: 'textures/skybox/default/',
filetype: 'png',
size: 1000000
}, options || {});
var urls = [];
['x','y','z'].forEach(function(axis){
@jensarps
jensarps / connect.js
Created August 9, 2012 11:07
Mouse-Picking Collada Models with THREE.js
container.addEventListener('click', function (evt) {
// The user has clicked; let's note this event
// and the click's coordinates so that we can
// react to it in the render loop
clickInfo.userHasClicked = true;
clickInfo.x = evt.clientX;
clickInfo.y = evt.clientY;
}, false);
@jensarps
jensarps / iterate-with-keyrange.js
Created November 13, 2012 14:03
Code for IDBWrapper Tutorial, Part 2
customers.iterate(onItem, {
index: 'lastname',
keyRange: myKeyRange,
order: 'ASC',
filterDuplicates: false,
writeAccess: false,
onEnd: onEndCallback,
onError: onErrorCallback
});
@jensarps
jensarps / example-1.js
Created November 13, 2012 14:16
Examples for IDBWrapper Tutorial, Part 2
var onItem = function (item) {
console.log('got item:', item);
};
var onEnd = function (item) {
console.log('All done.');
};
customers.iterate(onItem, {
order: 'DESC',
onEnd: onEnd
@jensarps
jensarps / puntMany.js
Created February 27, 2013 09:59
A putAll / putMany convenience method for IDBWrapper
/**
* Takes an array of data objects to store and calls IDBWrapper's batch() method
*
* @param {Array} dataArray An array of objects to be stored
* @param {Function} [onSuccess] Gets called if the operation was successful
* @param {onError} [onError] Gets called if an error occurred
*/
function putMany (dataArray, onSuccess, onError) {
var preparedData = dataArray.map(function(dataObject){
var SPEECH = 'speech';
var bindings = {
/* ... */
fullSpeed: {
device: SPEECH,
inputId: 'full speed'
},
stop: {