Skip to content

Instantly share code, notes, and snippets.

@rezoner
Last active August 29, 2015 14:17
Show Gist options
  • Save rezoner/c8e0e9be86d74b36b2aa to your computer and use it in GitHub Desktop.
Save rezoner/c8e0e9be86d74b36b2aa to your computer and use it in GitHub Desktop.
Playground.js + Three.js - draft 3
/*
I've decided there will be two levels of integration
1) You get loaders only. You have to create renderers and scenes manually.
2) You get loaders and magically bootstrapped Three.js
Below is level 2 integration example which renders a textured cube:
*/
var app = playground({
create: function() {
this.loadTexture("bricks");
},
ready: function() {
this.setState(app.game);
}
});
app.game = {
create: function() {
var geometry = new THREE.BoxGeometry(1, 1, 1);
var material = new THREE.MeshBasicMaterial({ map: app.textures.bricks });
this.cube = new THREE.Mesh(geometry, material);
this.scene.add(this.cube);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment