Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
crlgn opened this issue Oct 2, 2015 · 5 comments
Open

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

crlgn opened this issue Oct 2, 2015 · 5 comments

Comments

@crlgn
Copy link

crlgn commented Oct 2, 2015

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.

@crlgn crlgn changed the title [Question] How to keep manual drag rotation ou touchend? [Question] How to keep manual drag rotation on touchend? Oct 2, 2015
@liuxiaoyue
Copy link

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

@crlgn
Copy link
Author

crlgn commented Nov 22, 2015

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...

@liuxiaoyue
Copy link

@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....

@tristangemus
Copy link

+1 for this

@TommyySin
Copy link

+1 Anyone got something close?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants