|
@@ -1,3 +1,4 @@
|
|
|
|
+import { Vector3 } from '../../math/Vector3.js';
|
|
import { Group } from '../../objects/Group.js';
|
|
import { Group } from '../../objects/Group.js';
|
|
|
|
|
|
const _moveEvent = { type: 'move' };
|
|
const _moveEvent = { type: 'move' };
|
|
@@ -36,6 +37,10 @@ class WebXRController {
|
|
this._targetRay = new Group();
|
|
this._targetRay = new Group();
|
|
this._targetRay.matrixAutoUpdate = false;
|
|
this._targetRay.matrixAutoUpdate = false;
|
|
this._targetRay.visible = false;
|
|
this._targetRay.visible = false;
|
|
|
|
+ this._targetRay.hasLinearVelocity = false;
|
|
|
|
+ this._targetRay.linearVelocity = new Vector3();
|
|
|
|
+ this._targetRay.hasAngularVelocity = false;
|
|
|
|
+ this._targetRay.angularVelocity = new Vector3();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -50,6 +55,10 @@ class WebXRController {
|
|
this._grip = new Group();
|
|
this._grip = new Group();
|
|
this._grip.matrixAutoUpdate = false;
|
|
this._grip.matrixAutoUpdate = false;
|
|
this._grip.visible = false;
|
|
this._grip.visible = false;
|
|
|
|
+ this._grip.hasLinearVelocity = false;
|
|
|
|
+ this._grip.linearVelocity = new Vector3();
|
|
|
|
+ this._grip.hasAngularVelocity = false;
|
|
|
|
+ this._grip.angularVelocity = new Vector3();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -128,7 +137,29 @@ class WebXRController {
|
|
targetRay.matrix.fromArray( inputPose.transform.matrix );
|
|
targetRay.matrix.fromArray( inputPose.transform.matrix );
|
|
targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );
|
|
targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );
|
|
|
|
|
|
- this.dispatchEvent( _moveEvent );
|
|
|
|
|
|
+ if ( inputPose.linearVelocity !== null ) {
|
|
|
|
+
|
|
|
|
+ targetRay.hasLinearVelocity = true;
|
|
|
|
+ targetRay.linearVelocity.copy( inputPose.linearVelocity );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ targetRay.hasLinearVelocity = false;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( inputPose.angularVelocity !== null ) {
|
|
|
|
+
|
|
|
|
+ targetRay.hasAngularVelocity = true;
|
|
|
|
+ targetRay.angularVelocity.copy( inputPose.angularVelocity );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ targetRay.hasAngularVelocity = false;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.dispatchEvent( _moveEvent );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -210,6 +241,28 @@ class WebXRController {
|
|
grip.matrix.fromArray( gripPose.transform.matrix );
|
|
grip.matrix.fromArray( gripPose.transform.matrix );
|
|
grip.matrix.decompose( grip.position, grip.rotation, grip.scale );
|
|
grip.matrix.decompose( grip.position, grip.rotation, grip.scale );
|
|
|
|
|
|
|
|
+ if ( gripPose.linearVelocity !== null ) {
|
|
|
|
+
|
|
|
|
+ grip.hasLinearVelocity = true;
|
|
|
|
+ grip.linearVelocity.copy( gripPose.linearVelocity );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ grip.hasLinearVelocity = false;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( gripPose.angularVelocity !== null ) {
|
|
|
|
+
|
|
|
|
+ grip.hasAngularVelocity = true;
|
|
|
|
+ grip.angularVelocity.copy( gripPose.angularVelocity );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ grip.hasAngularVelocity = false;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|