触摸轨迹球控制

时间:2012-08-21 14:39:16

标签: three.js

我尝试进行触控。我想在TrackballControls.js中制作它,所以我这样做:

this.domElement.addEventListener( 'touchmove', touchmove, false );
this.domElement.addEventListener( 'touchstart', touchstart, false );
this.domElement.addEventListener( 'touchend', mouseup, false );

function touchstart( event ) {
    if (event.touches.length != 1) return;

    var touch = event.touches[0];
    event['clientX'] = touch.clientX;
    event['clientY'] = touch.clientY;
    event['button'] = 0;
    userLog('touchstart');
    mousedown( event ); 
}
function touchmove( event ) {
    if (event.touches.length != 1) return;

    var touch = event.touches[0];
    event['clientX'] = touch.clientX;
    event['clientY'] = touch.clientY;

    mousemove( event ); 
}

我已经开始接受工作了。页面分为几个区域。 Canvas init在“工作区” enter image description here 但是在ipad之后,任何触摸都被视为“工作区”中的触摸。如果它有用,我可以发布init()函数或其他任何东西

1 个答案:

答案 0 :(得分:1)

controls = new THREE.TrackballControls( camera, renderer.domElement );

renderer.domElement - 您需要的工作区域