threeVR icon indicating copy to clipboard operation
threeVR copied to clipboard

[Question] How to keep manual drag rotation on touchend?

Open crlngn opened this issue 9 years ago • 5 comments

Hello, I hope it is ok to post a question here.

In my application, I need to keep the rotation around Y axis when the user drags manually and releases on mobile, but I'm having problems understanding how to add the rotation difference using quaternions.

If I edit the updateDeviceMove on DeviceOrientationController.js to add the code below, it almost works... for vertical axis, but the others are messed up.

// this variable is a boolean flag set to true on touchend if( manuallyMoved) { objY = rotation.setFromQuaternion( objQuat, 'YXZ' ).y; realY = rotation.setFromQuaternion( deviceQuat, 'YXZ' ).y; manQuat = new THREE.Quaternion().setFromAxisAngle( new THREE.Vector3(0,1,0), (objY - realY) ); deviceQuat.multiply( manQuat ); manuallyMoved = false; }else{ deviceQuat.multiply( manQuat ); this.object.quaternion.slerp( deviceQuat, 0.07 ); } //this.object.quaternion.slerp( deviceQuat, 0.07 ); // smoothing //this.object.quaternion.copy( deviceQuat );

I put together a very basic example for testing. It's here: http://ec2-54-207-23-212.sa-east-1.compute.amazonaws.com/tests/360/

Can somebody point me in the right direction? Thanks.

crlngn avatar Oct 02 '15 20:10 crlngn

Hello, this problem can you solve it, can you give suggestions? thanks

liuxiaoyue avatar Nov 21 '15 15:11 liuxiaoyue

Because I had some urgency I gave up on threeVR, and used the standard DeviceOrientationControls.js from ThreeJS adding a button to switch mode to orbitControls. Not the best UX but it was what I could do at the moment. I think it's only a matter of understanding the math though, quaternions are not for the uninitiated...

crlngn avatar Nov 22 '15 20:11 crlngn

@carolinex thanks! I try to solve this problem,i find that updateDevice and updateManual functions are modified camera quaternion, i want to handle quaternion,use slerp, but updateDevice is failured,@richtr ,can you give suggestions? thanks....

liuxiaoyue avatar Nov 25 '15 03:11 liuxiaoyue

+1 for this

tristangemus avatar Jun 23 '17 13:06 tristangemus

+1 Anyone got something close?

TommyySin avatar Mar 21 '19 19:03 TommyySin