Created
March 22, 2015 19:48
-
-
Save rezoner/362b5da4f3d6e01c9442 to your computer and use it in GitHub Desktop.
Playground with Three.js - draft 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = playground({ | |
create: function() { | |
this.renderer = new THREE.WebGLRenderer(); | |
document.body.appendChild(app.renderer.domElement); | |
}, | |
resize: function() { | |
this.renderer.setSize(this.width, this.height); | |
}, | |
ready: function() { | |
this.setState(this.game); | |
} | |
}); | |
app.game = { | |
create: function() { | |
this.scene = new THREE.Scene(); | |
this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); | |
this.camera.position.z = 5; | |
/* add simple box */ | |
var geometry = new THREE.BoxGeometry(1, 1, 1); | |
var material = new THREE.MeshBasicMaterial({ | |
color: 0x00ff00 | |
}); | |
var cube = new THREE.Mesh(geometry, material); | |
this.scene.add(cube); | |
}, | |
resize: function() { | |
this.camera.aspect = app.width / app.height; | |
this.camera.updateProjectionMatrix(); | |
}, | |
render: function() { | |
app.renderer.render(this.scene, this.camera); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment