소스 검색

Merge pull request #6226 from TrevorDev/unparentBeforeRotation

unparent attached mesh before rotation
David Catuhe 6 년 전
부모
커밋
93d6b14259
2개의 변경된 파일13개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      dist/preview release/what's new.md
  2. 12 0
      src/Gizmos/planeRotationGizmo.ts

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

@@ -217,7 +217,7 @@
 - CannonJS ignores connectedPivot joint parameter ([TrevorDev](https://github.com/TrevorDev))
 - Fix case sensitive paths ([mrdunk](https://github.com))
 - Fix more case sensitive paths ([mrdunk](https://github.com))
-- Attaching a BoundingBoxGizmo on a child node shouldn't remove its parent ([TrevorDev](https://github.com/TrevorDev))
+- Attaching a BoundingBoxGizmo on a child node shouldn't remove its parent, rotation gizmo should work on object with parent ([TrevorDev](https://github.com/TrevorDev))
 - AmmoJS fix include issue caused after modules update and use world contact point to be consistent with Oimo and Cannon ([TrevorDev](https://github.com/TrevorDev))
 - Warn of motor with maxForce in Oimo plugin and set default force to be consistent with others, cannonJS support no impostor, cannonJS cylinder axis, ammoJS wake up impostor when apply force/impulse ([TrevorDev](https://github.com/TrevorDev))
 - Utility layer should render on last active camera ([TrevorDev](https://github.com/TrevorDev))

+ 12 - 0
src/Gizmos/planeRotationGizmo.ts

@@ -98,6 +98,13 @@ export class PlaneRotationGizmo extends Gizmo {
                 if (!this.attachedMesh.rotationQuaternion) {
                     this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
                 }
+
+                // Remove parent priort to rotating
+                var attachedMeshParent = this.attachedMesh.parent;
+                if (attachedMeshParent) {
+                    this.attachedMesh.setParent(null);
+                }
+
                 // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
                 var newVector = event.dragPlanePoint.subtract(this.attachedMesh.absolutePosition).normalize();
                 var originalVector = lastDragPosition.subtract(this.attachedMesh.absolutePosition).normalize();
@@ -169,6 +176,11 @@ export class PlaneRotationGizmo extends Gizmo {
                     tmpSnapEvent.snapDistance = angle;
                     this.onSnapObservable.notifyObservers(tmpSnapEvent);
                 }
+
+                // Restore parent
+                if (attachedMeshParent) {
+                    this.attachedMesh.setParent(attachedMeshParent);
+                }
             }
         });