Setaper
Setaper

Reputation: 171

Touch Trackball Control

I try to make touch control. And i whant to make it in TrackballControls.js, so i make it like this:

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 ); 
}

And i have come to bat with the work spase. Page is divided into several areas. Canvas init in "Working Area" enter image description here But after than on ipad any touch treated as touch in "Working Area". If it will be usefull i can post init() function, or anything else

Upvotes: 3

Views: 2378

Answers (1)

Setaper
Setaper

Reputation: 171

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

renderer.domElement - working area, which you need

Upvotes: 1

Related Questions