Pārlūkot izejas kodu

Merge pull request #9841 from PolygonalSun/PolygonalSun/release-drag-check

Added check for PointerDragBehavior to reenable camera controls, if not reenabled before behavior is disabled
David Catuhe 4 gadi atpakaļ
vecāks
revīzija
97f6316715

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

@@ -120,6 +120,7 @@
 - Fix crash when cloning material in `AssetContainer.instantiateModelsToScene` when mesh is an instanced mesh ([Popov72](https://github.com/Popov72))
 - Fix issue with NinePatch displaying half pixel gaps between slices on Firefox browsers. ([Pryme8](https://github.com/Pryme8))
 - Fix issue when canvas loses focus while holding a pointer button ([PolygonalSun](https://github.com/PolygonalSun))
+- Fix issue where camera controls stay detached if PointerDragBehavior is disabled prematurely ([PolygonalSun](https://github.com/PolygonalSun))
 
 ## Breaking changes
 

+ 5 - 0
src/Behaviors/Meshes/pointerDragBehavior.ts

@@ -187,6 +187,11 @@ export class PointerDragBehavior implements Behavior<AbstractMesh> {
 
         this._pointerObserver = this._scene.onPointerObservable.add((pointerInfo, eventState) => {
             if (!this.enabled) {
+                // If behavior is disabled before releaseDrag is ever called, call it now.
+                if (this._attachedToElement) {
+                    this.releaseDrag();
+                }
+
                 return;
             }