|
@@ -173140,6 +173140,7 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
// REMOVE the controller
|
|
|
_this._detachController(controller.uniqueId);
|
|
|
});
|
|
|
+ this._scene.constantlyUpdateMeshUnderPointer = true;
|
|
|
return true;
|
|
|
};
|
|
|
/**
|
|
@@ -173319,47 +173320,68 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
};
|
|
|
WebXRControllerPointerSelection.prototype._attachTrackedPointerRayMode = function (xrController) {
|
|
|
var _this = this;
|
|
|
- xrController.onMotionControllerInitObservable.add(function (motionController) {
|
|
|
- if (_this._options.forceGazeMode) {
|
|
|
- return _this._attachGazeMode(xrController);
|
|
|
- }
|
|
|
- var controllerData = _this._controllers[xrController.uniqueId];
|
|
|
- if (_this._options.overrideButtonId) {
|
|
|
- controllerData.selectionComponent = motionController.getComponent(_this._options.overrideButtonId);
|
|
|
- }
|
|
|
- if (!controllerData.selectionComponent) {
|
|
|
- controllerData.selectionComponent = motionController.getMainComponent();
|
|
|
+ var controllerData = this._controllers[xrController.uniqueId];
|
|
|
+ if (this._options.forceGazeMode) {
|
|
|
+ return this._attachGazeMode(xrController);
|
|
|
+ }
|
|
|
+ controllerData.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function () {
|
|
|
+ controllerData.laserPointer.isVisible = _this.displayLaserPointer;
|
|
|
+ controllerData.laserPointer.material.disableLighting = _this.disablePointerLighting;
|
|
|
+ controllerData.selectionMesh.material.disableLighting = _this.disableSelectionMeshLighting;
|
|
|
+ if (controllerData.pick) {
|
|
|
+ _this._scene.simulatePointerMove(controllerData.pick, { pointerId: controllerData.id });
|
|
|
}
|
|
|
- controllerData.onFrameObserver = _this._xrSessionManager.onXRFrameObservable.add(function () {
|
|
|
- if (controllerData.selectionComponent && controllerData.selectionComponent.pressed) {
|
|
|
+ });
|
|
|
+ if (xrController.inputSource.gamepad) {
|
|
|
+ xrController.onMotionControllerInitObservable.add(function (motionController) {
|
|
|
+ if (_this._options.overrideButtonId) {
|
|
|
+ controllerData.selectionComponent = motionController.getComponent(_this._options.overrideButtonId);
|
|
|
+ }
|
|
|
+ if (!controllerData.selectionComponent) {
|
|
|
+ controllerData.selectionComponent = motionController.getMainComponent();
|
|
|
+ }
|
|
|
+ controllerData.onButtonChangedObserver = controllerData.selectionComponent.onButtonStateChangedObservable.add(function (component) {
|
|
|
+ if (component.changes.pressed) {
|
|
|
+ var pressed = component.changes.pressed.current;
|
|
|
+ if (controllerData.pick) {
|
|
|
+ if (pressed) {
|
|
|
+ _this._scene.simulatePointerDown(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ controllerData.selectionMesh.material.emissiveColor = _this.selectionMeshPickedColor;
|
|
|
+ controllerData.laserPointer.material.emissiveColor = _this.laserPointerPickedColor;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ _this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ controllerData.selectionMesh.material.emissiveColor = _this.selectionMeshDefaultColor;
|
|
|
+ controllerData.laserPointer.material.emissiveColor = _this.lasterPointerDefaultColor;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // use the select and squeeze events
|
|
|
+ var selectStartListener = function (event) {
|
|
|
+ if (event.inputSource === controllerData.xrController.inputSource && controllerData.pick) {
|
|
|
+ _this._scene.simulatePointerDown(controllerData.pick, { pointerId: controllerData.id });
|
|
|
controllerData.selectionMesh.material.emissiveColor = _this.selectionMeshPickedColor;
|
|
|
controllerData.laserPointer.material.emissiveColor = _this.laserPointerPickedColor;
|
|
|
}
|
|
|
- else {
|
|
|
+ };
|
|
|
+ var selectEndListener = function (event) {
|
|
|
+ if (event.inputSource === controllerData.xrController.inputSource && controllerData.pick) {
|
|
|
+ _this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
|
|
|
controllerData.selectionMesh.material.emissiveColor = _this.selectionMeshDefaultColor;
|
|
|
controllerData.laserPointer.material.emissiveColor = _this.lasterPointerDefaultColor;
|
|
|
}
|
|
|
- controllerData.laserPointer.isVisible = _this.displayLaserPointer;
|
|
|
- controllerData.laserPointer.material.disableLighting = _this.disablePointerLighting;
|
|
|
- controllerData.selectionMesh.material.disableLighting = _this.disableSelectionMeshLighting;
|
|
|
- if (controllerData.pick) {
|
|
|
- _this._scene.simulatePointerMove(controllerData.pick, { pointerId: controllerData.id });
|
|
|
- }
|
|
|
- });
|
|
|
- controllerData.onButtonChangedObserver = controllerData.selectionComponent.onButtonStateChangedObservable.add(function (component) {
|
|
|
- if (component.changes.pressed) {
|
|
|
- var pressed = component.changes.pressed.current;
|
|
|
- if (controllerData.pick) {
|
|
|
- if (pressed) {
|
|
|
- _this._scene.simulatePointerDown(controllerData.pick, { pointerId: controllerData.id });
|
|
|
- }
|
|
|
- else {
|
|
|
- _this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
+ };
|
|
|
+ controllerData.eventListeners = {
|
|
|
+ selectend: selectEndListener,
|
|
|
+ selectstart: selectStartListener
|
|
|
+ };
|
|
|
+ this._xrSessionManager.session.addEventListener('selectstart', selectStartListener);
|
|
|
+ this._xrSessionManager.session.addEventListener('selectend', selectEndListener);
|
|
|
+ }
|
|
|
};
|
|
|
WebXRControllerPointerSelection.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
|
|
|
if (normal) {
|
|
@@ -173371,6 +173393,7 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
return normal;
|
|
|
};
|
|
|
WebXRControllerPointerSelection.prototype._detachController = function (xrControllerUniqueId) {
|
|
|
+ var _this = this;
|
|
|
var controllerData = this._controllers[xrControllerUniqueId];
|
|
|
if (!controllerData) {
|
|
|
return;
|
|
@@ -173383,6 +173406,14 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
if (controllerData.onFrameObserver) {
|
|
|
this._xrSessionManager.onXRFrameObservable.remove(controllerData.onFrameObserver);
|
|
|
}
|
|
|
+ if (controllerData.eventListeners) {
|
|
|
+ Object.keys(controllerData.eventListeners).forEach(function (eventName) {
|
|
|
+ var func = controllerData.eventListeners && controllerData.eventListeners[eventName];
|
|
|
+ if (func) {
|
|
|
+ _this._xrSessionManager.session.removeEventListener(eventName, func);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
controllerData.selectionMesh.dispose();
|
|
|
controllerData.laserPointer.dispose();
|
|
|
// remove from the map
|