|
@@ -37,7 +37,6 @@ export interface IWebXRControllerOptions {
|
|
* Represents an XR controller
|
|
* Represents an XR controller
|
|
*/
|
|
*/
|
|
export class WebXRInputSource {
|
|
export class WebXRInputSource {
|
|
- private _tmpQuaternion = new Quaternion();
|
|
|
|
private _tmpVector = new Vector3();
|
|
private _tmpVector = new Vector3();
|
|
private _uniqueId: string;
|
|
private _uniqueId: string;
|
|
|
|
|
|
@@ -94,6 +93,8 @@ export class WebXRInputSource {
|
|
this.grip.rotationQuaternion = new Quaternion();
|
|
this.grip.rotationQuaternion = new Quaternion();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this._tmpVector.set(0, 0, (this._scene.useRightHandedSystem ? -1.0 : 1.0));
|
|
|
|
+
|
|
// for now only load motion controllers if gamepad object available
|
|
// for now only load motion controllers if gamepad object available
|
|
if (this.inputSource.gamepad) {
|
|
if (this.inputSource.gamepad) {
|
|
WebXRMotionControllerManager.GetMotionControllerWithXRInput(inputSource, _scene, this._options.forceControllerProfile).then((motionController) => {
|
|
WebXRMotionControllerManager.GetMotionControllerWithXRInput(inputSource, _scene, this._options.forceControllerProfile).then((motionController) => {
|
|
@@ -149,12 +150,13 @@ export class WebXRInputSource {
|
|
*/
|
|
*/
|
|
public getWorldPointerRayToRef(result: Ray, gripIfAvailable: boolean = false) {
|
|
public getWorldPointerRayToRef(result: Ray, gripIfAvailable: boolean = false) {
|
|
const object = gripIfAvailable && this.grip ? this.grip : this.pointer;
|
|
const object = gripIfAvailable && this.grip ? this.grip : this.pointer;
|
|
- let worldMatrix = object.computeWorldMatrix();
|
|
|
|
- worldMatrix.decompose(undefined, this._tmpQuaternion, undefined);
|
|
|
|
- this._tmpVector.set(0, 0, (this._scene.useRightHandedSystem ? -1.0 : 1.0));
|
|
|
|
- this._tmpVector.rotateByQuaternionToRef(this._tmpQuaternion, this._tmpVector);
|
|
|
|
|
|
+ Vector3.TransformNormalToRef(
|
|
|
|
+ this._tmpVector,
|
|
|
|
+ object.getWorldMatrix(),
|
|
|
|
+ result.direction
|
|
|
|
+ );
|
|
|
|
+ result.direction.normalize();
|
|
result.origin.copyFrom(object.absolutePosition);
|
|
result.origin.copyFrom(object.absolutePosition);
|
|
- result.direction.copyFrom(this._tmpVector);
|
|
|
|
result.length = 1000;
|
|
result.length = 1000;
|
|
}
|
|
}
|
|
|
|
|