Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Touch Trackball Control

Tags:

three.js

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

like image 682
Setaper Avatar asked Apr 14 '26 14:04

Setaper


1 Answers

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

renderer.domElement - working area, which you need

like image 167
Setaper Avatar answered Apr 17 '26 19:04

Setaper