Three.js: add light to camera

情到浓时终转凉″ 提交于 2019-12-23 10:15:55

问题


I want to move and rotate the camera but keep a PointLight on the same position relative to the camera. I've read a bunch of threads saying that you can add the light object to the camera instead of the scene. Like so:

pointLight = new THREE.PointLight( 0xffffff );
pointLight.position.set(1,1,2);
camera.add(pointLight);

However this does not seem to work for me. Instead I now when the camera changes set the light's position by applying the cameras matrixWorld to my desired relative light position. This works, but adding the light to the camera seems like a cleaner solution.

I'm a doing something wrong or is adding light object to the camera deprecated?

Thanks!


回答1:


You need to add the camera to the scene if the camera has a child object, such as a `PointLight'.

scene.add( camera );

three.js r.68



来源:https://stackoverflow.com/questions/25740277/three-js-add-light-to-camera

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!