如何使用three.js使用跟踪球控制来控制场景的旋转

时间:2014-09-09 08:12:38

标签: javascript 3d three.js

我正在使用three.js和webgl在3D中构建建筑物,我已经将飞机,天空,建筑物放置在飞机上,我使用了TrackballControls来旋转相机 - 它非常适合变焦,平移但计划旋转颠倒,因为我正在构建平面规划器,我不想显示下方,我尝试使用OrbitControls和固定旋转为此,但平移和缩放选项不灵活,因为TrackballControls 以下是我的TrackballControls代码

   `controls = new THREE.TrackballControls( camera );  
    controls.userPan = true;
    controls.userPanSpeed = 0.0;        
    controls.userZoom  = true;
    controls.userZoomSpeed  = 2.0;      
    controls.userRotate  = true;
    controls.userRotateSpeed  = 1.0;
    controls.minDistance = 1.0; // how far can you zoom in
    controls.maxDistance = 1500.0; // how far can you zoom out      
    controls.maxPolarAngle = Math.PI *0.495;        
    controls.minPolarAngle = Math.PI/8;
    controls.rotation = Math.PI / 12;
    controls.minPolarAngle =  Math.PI *0.495;` 

和OrbitControls

   `controls = new THREE.OrbitControls( camera );       
    controls.userPan = true;
    controls.userPanSpeed = 0.0;        
    controls.userZoom  = true;
    controls.userZoomSpeed  = 2.0;      
    controls.userRotate  = true;
    controls.userRotateSpeed  = 2.0;
    controls.minDistance = 1.0; // how far can you zoom in
    controls.maxDistance = 1500.0; // how far can you zoom out      
    controls.maxPolarAngle = Math.PI * 0.495;`

我觉得TrackballControls是用户友好的,但需要单独修复旋转,任何人都可以指导我。 提前致谢

0 个答案:

没有答案