Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reasons for adding a camera to a scene in Three.js?

Why should I add a camera to a scene, although I am already passing it to my render method? Every example I have seen in the repository adds the camera to the scene, e.g. weggl_geometries. But after removing scene.add( camera ) it still works...

init function

camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
camera.position.y = 400;
scene.add( camera );

render function

renderer.render( scene, camera );
like image 372
Matthias Avatar asked Sep 01 '12 22:09

Matthias


1 Answers

When you render without the camera added to the scene, it's automatically added. The point to have it in the scene is that in the more recent versions of the library you can add the camera as a child of another object (eventually animated) of the scene.

Here is some question answering from the Three.js developers https://github.com/mrdoob/three.js/issues/1046

like image 187
pangon Avatar answered Oct 24 '22 11:10

pangon