问题如下:如果我将renderer.domElement添加到我的相机属性中,GUI工作正常,但是mousedown操作不起作用。
相反,如果我删除了renderer.domElement,则mousedown动作可以正常工作,但是在我徘徊之后,GUI X-会随着我的鼠标移动而缩放。
以下是代码:
function init()
{
// scene
scene = new THREE.Scene();
// camera
var SCREEN_WIDTH = window.innerWidth, SCREEN_HEIGHT = window.innerHeight;
var VIEW_ANGLE = 45, ASPECT = SCREEN_WIDTH / SCREEN_HEIGHT, NEAR = 0.1, FAR = 20000;
camera = new THREE.PerspectiveCamera( VIEW_ANGLE, ASPECT, NEAR, FAR);
camera.lookAt(scene.position);
var distance = 1000;
camera.position;y = 150;
camera.position.z = 1500;
scene.add(camera);
// renderer
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
// controls
controls = new THREE.TrackballControls( camera);
我该如何解决呢?
感谢。
答案 0 :(得分:0)
试试这个:
controls = new THREE.TrackballControls( camera, renderer.domElement );