Parcourir la source

Merge pull request #7422 from RaananW/pointer-move-constantly

pointer move should be triggered constantly
David Catuhe il y a 5 ans
Parent
commit
bb80731fa0

+ 1 - 1
dist/preview release/what's new.md

@@ -188,7 +188,7 @@
 - Camera's API is Babylon-conform (position, rotationQuaternion, world matrix, direction etc') ([#7239](https://github.com/BabylonJS/Babylon.js/issues/7239)) ([RaananW](https://github.com/RaananW/))
 - XR Input now using standard profiles and completely separated from the gamepad class ([#7348](https://github.com/BabylonJS/Babylon.js/issues/7348)) ([RaananW](https://github.com/RaananW/))
 - Teleportation and controller selection are now WebXR features. ([#7290](https://github.com/BabylonJS/Babylon.js/issues/7290)) ([RaananW](https://github.com/RaananW/))
-- Teleportation allows selecting direction before teleporting when using thumbstick/touchpad. ([#7290](https://github.com/BabylonJS/Babylon.js/issues/7290)) ([RaananW](https://github.com/RaananW/))
+- Teleportation allows selecting direction before teleporting when using thumbstick / touchpad. ([#7290](https://github.com/BabylonJS/Babylon.js/issues/7290)) ([RaananW](https://github.com/RaananW/))
 - It is now possible to force a certain profile type for the controllers ([#7348](https://github.com/BabylonJS/Babylon.js/issues/7375)) ([RaananW](https://github.com/RaananW/))
 - WebXR camera is initialized on the first frame ([#7389](https://github.com/BabylonJS/Babylon.js/issues/7389)) ([RaananW](https://github.com/RaananW/))
 - Selection has gaze mode (which can be forced) and touch-screen support ([#7395](https://github.com/BabylonJS/Babylon.js/issues/7395)) ([RaananW](https://github.com/RaananW/))

+ 6 - 10
src/Cameras/XR/features/WebXRControllerPointerSelection.ts

@@ -311,8 +311,6 @@ export class WebXRControllerPointerSelection implements IWebXRFeature {
                         // pointer up right after down, if disable on touch out
                         if (this._options.disablePointerUpOnTouchOut) {
                             this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
-                        } else {
-                            this._scene.simulatePointerMove(controllerData.pick, { pointerId: controllerData.id });
                         }
                         discMesh.isVisible = false;
                     } else {
@@ -333,6 +331,8 @@ export class WebXRControllerPointerSelection implements IWebXRFeature {
                 timer = 0;
             }
 
+            this._scene.simulatePointerMove(controllerData.pick, { pointerId: controllerData.id });
+
             oldPick = controllerData.pick;
         });
         xrController.onDisposeObservable.addOnce(() => {
@@ -375,8 +375,6 @@ export class WebXRControllerPointerSelection implements IWebXRFeature {
             controllerData.selectionComponent = xrController.gamepadController.getMainComponent();
         }
 
-        let observer: Nullable<Observer<XRFrame>> = null;
-
         controllerData.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(() => {
             if (controllerData.selectionComponent && controllerData.selectionComponent.pressed) {
                 (<StandardMaterial>controllerData.selectionMesh.material).emissiveColor = this.selectionMeshPickedColor;
@@ -385,6 +383,10 @@ export class WebXRControllerPointerSelection implements IWebXRFeature {
                 (<StandardMaterial>controllerData.selectionMesh.material).emissiveColor = this.selectionMeshDefaultColor;
                 (<StandardMaterial>controllerData.laserPointer.material).emissiveColor = this.lasterPointerDefaultColor;
             }
+
+            if (controllerData.pick) {
+                this._scene.simulatePointerMove(controllerData.pick, { pointerId: controllerData.id });
+            }
         });
 
         controllerData.onButtonChangedObserver = controllerData.selectionComponent.onButtonStateChanged.add((component) => {
@@ -393,13 +395,7 @@ export class WebXRControllerPointerSelection implements IWebXRFeature {
                 if (controllerData.pick) {
                     if (pressed) {
                         this._scene.simulatePointerDown(controllerData.pick, { pointerId: controllerData.id });
-                        observer = this._xrSessionManager.onXRFrameObservable.add(() => {
-                            if (controllerData.pick) {
-                                this._scene.simulatePointerMove(controllerData.pick, { pointerId: controllerData.id });
-                            }
-                        });
                     } else {
-                        this._xrSessionManager.onXRFrameObservable.remove(observer);
                         this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
                     }
                 }