Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / tutorial.js
Created November 25, 2011 11:06
IDBWrapper tutorial, step 6
var id = 1;
var onsuccess = function(result){
if(result !== false){
console.log('deletion successful!');
}
}
var onerror = function(error){
console.log('Oh noes, sth went wrong!', error);
}
@jensarps
jensarps / tutorial.js
Created November 25, 2011 10:53
IDBWrapper tutorial, step 5
var onsuccess = function(data){
console.log('Here is what we have in store ('+data.length+' items in total):');
data.forEach(function(item){
console.log(item);
});
}
var onerror = function(error){
console.log('Oh noes, sth went wrong!', error);
}
@jensarps
jensarps / turorial.js
Created November 25, 2011 10:28
IDBWrapper tutorial, step 4
var updatedDude = {
id: 1, // or whatever id our dude has
firstname: 'John',
lastname: 'Doe',
age: 53, // dude is now a year older
emails: [
'johndoe@example.com',
'jd@example.com'
]
};
@jensarps
jensarps / turorial.js
Created November 24, 2011 14:41
IDBWrapper tutorial, step 2
var dude = {
firstname: 'John',
lastname: 'Doe',
age: 52,
emails: [
'johndoe@example.com',
'jd@example.com'
]
};
@jensarps
jensarps / tutorial.js
Created November 24, 2011 14:54
IDBWrapper tutorial, step 3
var id = 1; // Or whatever you got returned.
var onsuccess = function(data){
console.log('here is our dude:', data);
}
var onerror = function(error){
console.log('Oh noes, sth went wrong!', error);
}
customers.get(id, onsuccess, onerror);
@jensarps
jensarps / index.html
Created November 24, 2011 14:13
IDBWrapper tutorial, step 1
<!DOCTYPE html>
<html>
<head>
<title>IDBWrapper Tutorial, Step 1</title>
</head>
<body>
<script type="text/javascript" src="IDBStore.js"></script>
<script type="text/javascript" src="tutorial.js"></script>
</body>
</html>