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"
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
controls = new THREE.TrackballControls( camera, renderer.domElement );
renderer.domElement - working area, which you need
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With