Skip to content

Commit

Permalink
KJSL: support deviceorientation
Browse files Browse the repository at this point in the history
  • Loading branch information
kevleyski committed Jul 30, 2024
1 parent b6faaa3 commit a726319
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions vendor/three/DeviceOrientationControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ class DeviceOrientationControls extends EventDispatcher {
this.alphaOffset = 0; // radians

const onDeviceOrientationChangeEvent = function (event) {
const kevdebug = document.getElementById('kevdebug');
if (kevdebug) {
kevdebug.innerHTML = `KEVS pitch=${parseInt(event.alpha, 10)} roll=${parseInt(event.beta, 10)} yaw=${parseInt(event.gamma, 10)}`;
}

scope.deviceOrientation = event;
};

Expand Down Expand Up @@ -127,13 +124,13 @@ class DeviceOrientationControls extends EventDispatcher {

const orient = scope.screenOrientation ? MathUtils.degToRad( scope.screenOrientation ) : 0; // O

setObjectQuaternion( scope.object.quaternion, alpha, beta, gamma, orient );

if ( 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {

lastQuaternion.copy( scope.object.quaternion );
scope.dispatchEvent( _changeEvent );
return true;
if (alpha !== 0 && beta !== 0 && gamma !== 0) {
setObjectQuaternion(scope.object.quaternion, alpha, beta, gamma, orient);
if (8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS) {
lastQuaternion.copy(scope.object.quaternion);
scope.dispatchEvent(_changeEvent);
return true;
}
}

}
Expand Down

0 comments on commit a726319

Please sign in to comment.