Skip to content

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

Description

@crlngn

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions