最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Reasons for adding a camera to a scene in Three.js? - Stack Overflow

programmeradmin1浏览0评论

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 );

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 );
Share Improve this question edited May 2, 2017 at 21:16 Damjan Pavlica 34.2k10 gold badges75 silver badges78 bronze badges asked Sep 1, 2012 at 22:09 MatthiasMatthias 7,5276 gold badges57 silver badges90 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

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./mrdoob/three.js/issues/1046

发布评论

评论列表(0)

  1. 暂无评论