瀏覽代碼

Merge pull request #3608 from CarlosLanderas/lande/vrhelper-selectedMeshUnselected

VRHelper - Notify unselected mesh when ray predicate doesn't hit
David Catuhe 7 年之前
父節點
當前提交
4fab9ca0a6
共有 2 個文件被更改,包括 12 次插入6 次删除
  1. 2 0
      dist/preview release/what's new.md
  2. 10 6
      src/Cameras/VR/babylon.vrExperienceHelper.ts

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

@@ -26,6 +26,8 @@
 - `AssetsManager` will now clear its `tasks` list from all successfully loaded tasks ([deltakosh](https://github.com/deltakosh))
 - Added documentation to WebVRCamera and VRExperienceHelper ([trevordev](https://github.com/trevordev))
 - Introduced `isStroke` on `HighlightLayerOptions` which makes the highlight solid ([PixelsCommander](https://github.com/pixelscommander))
+- VRHelper will notify now onSelectedMeshUnselected observable to subscribers when the applied ray selection predicate does not produce a hit and a mesh compliant with the meshSelectionPredicate was previously selected
+   ([carloslanderas](https://github.com/carloslanderas))
 
 ## Bug fixes
 

+ 10 - 6
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -1487,9 +1487,8 @@ module BABYLON {
                     // Moving the teleportation area to this targetted point
 
                     //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
-                    if (this._currentMeshSelected &&
-                        !this._isTeleportationFloor(this._currentMeshSelected)) {
-                        this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
+                    if (this._currentMeshSelected && !this._isTeleportationFloor(this._currentMeshSelected)) {
+                        this._notifySelectedMeshUnselected();
                     }
 
                     this._currentMeshSelected = null;
@@ -1522,9 +1521,7 @@ module BABYLON {
                         }
                     }
                     else {
-                        if (this._currentMeshSelected) {
-                            this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
-                        }
+                        this._notifySelectedMeshUnselected();
                         this._currentMeshSelected = null;
                         this.changeGazeColor(new Color3(0.7, 0.7, 0.7));
                         this.changeLaserColor(new Color3(0.7, 0.7, 0.7));
@@ -1533,6 +1530,7 @@ module BABYLON {
             }
             else {
                 this._currentHit = null;
+                this._notifySelectedMeshUnselected();
                 this._currentMeshSelected = null;
                 this._teleportationAllowed = false;
                 this._hideTeleportationTarget();
@@ -1540,6 +1538,12 @@ module BABYLON {
                 this.changeLaserColor(new Color3(0.7, 0.7, 0.7));
             }
         }
+        
+        private _notifySelectedMeshUnselected( ) {
+            if(this._currentMeshSelected) {
+                this.onSelectedMeshUnselected.notifyObservers(this._currentMeshSelected);
+            }
+        }
 
         /**
          * Sets the color of the laser ray from the vr controllers.