Created
December 9, 2013 05:47
-
-
Save joates/7867816 to your computer and use it in GitHub Desktop.
e̶n̶c̶a̶p̶s̶u̶l̶a̶t̶e̶s̶ ̶a̶ ̶T̶H̶R̶E̶E̶.̶j̶s̶ ̶s̶c̶e̶n̶e̶ ̶o̶b̶j̶e̶c̶t̶.. [deprecated] see -> https://gist.github.com/joates/8722084
This file contains 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
// scene.js | |
// by joates (8-Dec-2013) | |
function onWindowResize() { | |
scene.WIDTH = window.innerWidth | |
scene.HEIGHT = window.innerHeight | |
scene.camera.aspect = scene.WIDTH / scene.HEIGHT | |
scene.camera.updateProjectionMatrix() | |
scene.renderer.setSize(scene.WIDTH, scene.HEIGHT) | |
} | |
scene = { | |
init: function() { | |
this.WIDTH = window.innerWidth; | |
this.HEIGHT = window.innerHeight; | |
this.world = new THREE.Scene(); | |
this.camera = new THREE.PerspectiveCamera(40, this.WIDTH/this.HEIGHT, 0.1, 10000); | |
this.camera.position.set(0, 20, 20); | |
this.camera.lookAt(this.world.position); | |
this.controls = new THREE.OrbitControls(this.camera); | |
this.world.add(new THREE.AmbientLight(0x2a2a20)); | |
var light = new THREE.DirectionalLight(0xffffff, 1.5); | |
light.position.set(0, 0, 0); | |
this.world.add(light); | |
//material = new THREE.MeshLambertMaterial({ | |
// vertexColors: THREE.VertexColors | |
//}); | |
var axis = new THREE.AxisHelper(16); | |
this.world.add(axis); | |
this.renderer = new THREE.WebGLRenderer({ antialias: true }); | |
this.renderer.setSize(this.WIDTH, this.HEIGHT); | |
this.renderer.setClearColor(0x000000, 1); | |
document.body.appendChild(this.renderer.domElement); | |
window.addEventListener('resize', onWindowResize, false); | |
}, | |
update: function() { | |
this.controls.update(); | |
}, | |
render: function() { | |
this.renderer.render(this.world, this.camera) | |
} | |
} | |
module.exports = scene; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment