本文介绍了ThreeJS r69 轨迹球控制、相机和定向光的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将轨迹球控件和相机与定向灯同步.

I need to sync trackball controls and camera with the directional light.

我的案例:用相机、灯光和控件初始化一个空场景.加载一个 bufferGeometry obj,获取它的质心并设置相机并控制相对于 obj 质心的位置和目标.基本上我只是简单地设置相机位置和 control.target :

My case scenario:Init an empty scene with camera, lights and controls.Load a bufferGeometry obj, get its centroid and set camera and controls position and target relative to the obj centroid.Basically I simply set camera position and controls.target with:

camera.lookAt( position );
camera.position = position;
controls.target.copy( position );

其中 position 是一个 Three.Vector3 对象.

where position is a Three.Vector3 obj.

定向光必须与控件自动同步.

Directional light has to sync automatically with controls.

我使用threejs r66做到了:

I did it using threejs r66:

function init(){
...
directionalLight.position = controls.object.position;
directionalLight.target.position = controls.target;
...
}

其中控件是一个 THREE.TrackballControls 对象.

where controls is a THREE.TrackballControls object.

使用threejs r69 不再起作用.有什么建议吗?

With threejs r69 does not work anymore.Any suggestions?

谢谢,

西蒙

使用 pointLight 而不是 directionalLight 解决.

Solved using a pointLight instead a directionalLight.

var pointLight = new THREE.PointLight(0xffffff, 1, 100);相机.添加(点光源);

var pointLight = new THREE.PointLight( 0xffffff, 1, 100 );camera.add( pointLight );

感谢大家的帮助

推荐答案

解决方案(感谢 WestLangley)是:

The solution ( thanks to WestLangley ) is:

var pointLight = new THREE.PointLight( 0xffffff, 1, 100 );
camera.add( pointLight );

这篇关于ThreeJS r69 轨迹球控制、相机和定向光的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 00:31