|
@@ -420,6 +420,10 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
discMesh.parent = controllerData.selectionMesh;
|
|
|
let timer = 0;
|
|
|
let downTriggered = false;
|
|
|
+ const pointerEventInit: PointerEventInit = {
|
|
|
+ pointerId: controllerData.id,
|
|
|
+ pointerType: "xr",
|
|
|
+ };
|
|
|
controllerData.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(() => {
|
|
|
if (!controllerData.pick) {
|
|
|
return;
|
|
@@ -434,11 +438,11 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
|
|
|
timer += this._scene.getEngine().getDeltaTime();
|
|
|
if (timer >= timeToSelect) {
|
|
|
- this._scene.simulatePointerDown(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerDown(controllerData.pick, pointerEventInit);
|
|
|
downTriggered = true;
|
|
|
// pointer up right after down, if disable on touch out
|
|
|
if (this._options.disablePointerUpOnTouchOut) {
|
|
|
- this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerUp(controllerData.pick, pointerEventInit);
|
|
|
}
|
|
|
discMesh.isVisible = false;
|
|
|
} else {
|
|
@@ -448,7 +452,7 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
} else {
|
|
|
if (downTriggered) {
|
|
|
if (!this._options.disablePointerUpOnTouchOut) {
|
|
|
- this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerUp(controllerData.pick, pointerEventInit);
|
|
|
}
|
|
|
}
|
|
|
downTriggered = false;
|
|
@@ -459,7 +463,7 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
timer = 0;
|
|
|
}
|
|
|
|
|
|
- this._scene.simulatePointerMove(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerMove(controllerData.pick, pointerEventInit);
|
|
|
|
|
|
oldPick = controllerData.pick;
|
|
|
});
|
|
@@ -470,7 +474,7 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
if (xrController) {
|
|
|
xrController.onDisposeObservable.addOnce(() => {
|
|
|
if (controllerData.pick && !this._options.disablePointerUpOnTouchOut && downTriggered) {
|
|
|
- this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerUp(controllerData.pick, pointerEventInit);
|
|
|
}
|
|
|
discMesh.dispose();
|
|
|
});
|
|
@@ -480,23 +484,27 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
private _attachScreenRayMode(xrController: WebXRInputSource) {
|
|
|
const controllerData = this._controllers[xrController.uniqueId];
|
|
|
let downTriggered = false;
|
|
|
+ const pointerEventInit: PointerEventInit = {
|
|
|
+ pointerId: controllerData.id,
|
|
|
+ pointerType: "xr",
|
|
|
+ };
|
|
|
controllerData.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(() => {
|
|
|
if (!controllerData.pick || (this._options.disablePointerUpOnTouchOut && downTriggered)) {
|
|
|
return;
|
|
|
}
|
|
|
if (!downTriggered) {
|
|
|
- this._scene.simulatePointerDown(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerDown(controllerData.pick, pointerEventInit);
|
|
|
downTriggered = true;
|
|
|
if (this._options.disablePointerUpOnTouchOut) {
|
|
|
- this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerUp(controllerData.pick, pointerEventInit);
|
|
|
}
|
|
|
} else {
|
|
|
- this._scene.simulatePointerMove(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerMove(controllerData.pick, pointerEventInit);
|
|
|
}
|
|
|
});
|
|
|
xrController.onDisposeObservable.addOnce(() => {
|
|
|
if (controllerData.pick && downTriggered && !this._options.disablePointerUpOnTouchOut) {
|
|
|
- this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerUp(controllerData.pick, pointerEventInit);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -506,12 +514,16 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
if (this._options.forceGazeMode) {
|
|
|
return this._attachGazeMode(xrController);
|
|
|
}
|
|
|
+ const pointerEventInit: PointerEventInit = {
|
|
|
+ pointerId: controllerData.id,
|
|
|
+ pointerType: "xr",
|
|
|
+ };
|
|
|
controllerData.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(() => {
|
|
|
(<StandardMaterial>controllerData.laserPointer.material).disableLighting = this.disablePointerLighting;
|
|
|
(<StandardMaterial>controllerData.selectionMesh.material).disableLighting = this.disableSelectionMeshLighting;
|
|
|
|
|
|
if (controllerData.pick) {
|
|
|
- this._scene.simulatePointerMove(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerMove(controllerData.pick, pointerEventInit);
|
|
|
}
|
|
|
});
|
|
|
if (xrController.inputSource.gamepad) {
|
|
@@ -529,11 +541,11 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
if (controllerData.pick) {
|
|
|
if (this._options.enablePointerSelectionOnAllControllers || xrController.uniqueId === this._attachedController) {
|
|
|
if (pressed) {
|
|
|
- this._scene.simulatePointerDown(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerDown(controllerData.pick, pointerEventInit);
|
|
|
(<StandardMaterial>controllerData.selectionMesh.material).emissiveColor = this.selectionMeshPickedColor;
|
|
|
(<StandardMaterial>controllerData.laserPointer.material).emissiveColor = this.laserPointerPickedColor;
|
|
|
} else {
|
|
|
- this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerUp(controllerData.pick, pointerEventInit);
|
|
|
(<StandardMaterial>controllerData.selectionMesh.material).emissiveColor = this.selectionMeshDefaultColor;
|
|
|
(<StandardMaterial>controllerData.laserPointer.material).emissiveColor = this.laserPointerDefaultColor;
|
|
|
}
|
|
@@ -556,7 +568,7 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
// use the select and squeeze events
|
|
|
const selectStartListener = (event: XRInputSourceEvent) => {
|
|
|
if (controllerData.xrController && event.inputSource === controllerData.xrController.inputSource && controllerData.pick) {
|
|
|
- this._scene.simulatePointerDown(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerDown(controllerData.pick, pointerEventInit);
|
|
|
(<StandardMaterial>controllerData.selectionMesh.material).emissiveColor = this.selectionMeshPickedColor;
|
|
|
(<StandardMaterial>controllerData.laserPointer.material).emissiveColor = this.laserPointerPickedColor;
|
|
|
}
|
|
@@ -564,7 +576,7 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
|
|
|
|
|
|
const selectEndListener = (event: XRInputSourceEvent) => {
|
|
|
if (controllerData.xrController && event.inputSource === controllerData.xrController.inputSource && controllerData.pick) {
|
|
|
- this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ this._scene.simulatePointerUp(controllerData.pick, pointerEventInit);
|
|
|
(<StandardMaterial>controllerData.selectionMesh.material).emissiveColor = this.selectionMeshDefaultColor;
|
|
|
(<StandardMaterial>controllerData.laserPointer.material).emissiveColor = this.laserPointerDefaultColor;
|
|
|
}
|