javascript - Three.js camera rotation error -


firebug throwing error saying "three not defined" on var camera , cannot see why. error doesn't make sense me because see it; there defined 3 right on right hand of equals sign.

        init();         animate();          function init()         {             var camera = new three.perspectivecamera( 75, window.innerwidth / window.innerheight, 0.1, 1000 );             camera.position.z = 500;              var controls = new three.trackballcontrols( camera );             controls.addeventlistener('change', render);              var scene = new three.scene();              var geometry = new three.boxgeometry(100, 100, 100);             var material = new three.meshbasicmaterial();              var mesh = new three.mesh( geometry, material );             scene.add(mesh);              var renderer = new three.webglrenderer();             renderer.setsize(window.innerwidth, window.innerheight);             document.body.appendchild( renderer.domelement );         }          function animate()         {             requestanimationframe( animate );             controls.update();         }          function render()         {             renderer.render( scene, camera );         } 

your code except you're defining variable inside init() function means variables local init() function , not recognized outside of it.

declare variables outside function , should solve problem. example:

var camera, controls, scene, geometry, material, mesh, renderer;  init(); animate();  function init() {     camera = new three.perspectivecamera( 75, window.innerwidth / window.innerheight, 0.1, 1000 );     camera.position.z = 500; ... 

Comments

Popular posts from this blog

c++ - OpenMP unpredictable overhead -

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

javascript - Wordpress slider, not displayed 100% width -