Trevor Baron пре 7 година
родитељ
комит
bc44c82871
2 измењених фајлова са 19 додато и 15 уклоњено
  1. 1 1
      dist/preview release/what's new.md
  2. 18 14
      src/Gizmos/babylon.boundingBoxGizmo.ts

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

@@ -25,7 +25,7 @@
 - UtilityLayer class to render another scene as a layer on top of an existing scene ([TrevorDev](https://github.com/TrevorDev))
 - AnimationGroup has now onAnimationGroupEnd observable ([RaananW](https://github.com/RaananW))
 - Pointer drag behavior to enable drag and drop with mouse or 6dof controller on a mesh ([TrevorDev](https://github.com/TrevorDev))
-- Gizmo and GizmoManager classes used to manipulate meshes in a scene. position, rotation, scale, and boudning box gizmos ([TrevorDev](https://github.com/TrevorDev))
+- Gizmo and GizmoManager classes used to manipulate meshes in a scene. Position, rotation, scale, and boudning box gizmos ([TrevorDev](https://github.com/TrevorDev))
 - Added a new `mesh.ignoreNonUniformScaling` to turn off non uniform scaling compensation ([Deltakosh](https://github.com/deltakosh))
 - AssetsManager tasks will only run when their state is INIT. It is now possible to remove a task from the assets manager ([RaananW](https://github.com/RaananW))
 

+ 18 - 14
src/Gizmos/babylon.boundingBoxGizmo.ts

@@ -143,19 +143,7 @@ module BABYLON {
 
             // Update bounding box positions
             this._renderObserver = this.gizmoLayer.originalScene.onBeforeRenderObservable.add(()=>{
-                if(this.attachedMesh){
-                    var boundingInfo = this.attachedMesh.getBoundingInfo().boundingBox;
-                    var boundBoxDimensions = boundingInfo.maximum.subtract(boundingInfo.minimum).multiplyInPlace(this.attachedMesh.scaling);
-                    this._boundingDimensions.copyFrom(boundBoxDimensions);
-                    this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
-                    if(!this.attachedMesh.rotationQuaternion){
-                        this.attachedMesh.rotationQuaternion = new BABYLON.Quaternion();
-                    }
-                    this._lineBoundingBox.rotationQuaternion!.copyFrom(this.attachedMesh.rotationQuaternion);
-                    this._rotateSpheresParent.rotationQuaternion!.copyFrom(this.attachedMesh.rotationQuaternion);
-                    this._scaleBoxesParent.rotationQuaternion!.copyFrom(this.attachedMesh.rotationQuaternion);
-                    this._updateBoundingBox();
-                }
+                this._updateBoundingBox();
             })
             this._updateBoundingBox();
         }
@@ -167,7 +155,22 @@ module BABYLON {
             })
         }
 
-        private _updateBoundingBox(){            
+        private _updateBoundingBox(){   
+            if(this.attachedMesh){
+                // Update bounding dimensions/positions
+                var boundingInfo = this.attachedMesh.getBoundingInfo().boundingBox;
+                var boundBoxDimensions = boundingInfo.maximum.subtract(boundingInfo.minimum).multiplyInPlace(this.attachedMesh.scaling);
+                this._boundingDimensions.copyFrom(boundBoxDimensions);
+                this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
+                if(!this.attachedMesh.rotationQuaternion){
+                    this.attachedMesh.rotationQuaternion = new BABYLON.Quaternion();
+                }
+                this._lineBoundingBox.rotationQuaternion!.copyFrom(this.attachedMesh.rotationQuaternion);
+                this._rotateSpheresParent.rotationQuaternion!.copyFrom(this.attachedMesh.rotationQuaternion);
+                this._scaleBoxesParent.rotationQuaternion!.copyFrom(this.attachedMesh.rotationQuaternion);
+            }
+
+            // Update rotation sphere locations
             var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
             for(var i=0;i<3;i++){
                 for(var j=0;j<2;j++){
@@ -192,6 +195,7 @@ module BABYLON {
                 }
             }
 
+            // Update scale box locations
             var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
             for(var i=0;i<2;i++){
                 for(var j=0;j<2;j++){