Bladeren bron

Merge pull request #5251 from TrevorDev/gizmoConsistency

Gizmo better consistency with maya
David Catuhe 7 jaren geleden
bovenliggende
commit
e4048ba45d

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

@@ -14,7 +14,7 @@
   - Gizmo manager's internal gizmos are now public ([TrevorDev](https://github.com/TrevorDev))
   - Ability to customize meshes on gizmos ([TrevorDev](https://github.com/TrevorDev))
   - Added ignoreChildren field to bounding box to save performance when using heavily nested meshes ([TrevorDev](https://github.com/TrevorDev))
-  - Add uniform scaling drag support to scale gizmo ([TrevorDev](https://github.com/TrevorDev))
+  - Add uniform scaling drag support to the scale gizmo ([TrevorDev](https://github.com/TrevorDev))
   - Support interacting with child elements ([TrevorDev](https://github.com/TrevorDev))
   - BoundingBox gizmo support for including/excluding descendants when computing the bounding box ([TrevorDev](https://github.com/TrevorDev))
   - Drag start and stop events for bounding box drag and uniform scale drag ([TrevorDev](https://github.com/TrevorDev))

+ 0 - 2
src/Gizmos/babylon.gizmoManager.ts

@@ -96,7 +96,6 @@ module BABYLON {
             if(value){
                 if(!this.gizmos.positionGizmo){
                     this.gizmos.positionGizmo = new PositionGizmo();
-                    this.gizmos.positionGizmo.updateGizmoRotationToMatchAttachedMesh = false;
                 }
                 this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
             }else if(this.gizmos.positionGizmo){
@@ -114,7 +113,6 @@ module BABYLON {
             if(value){
                 if(!this.gizmos.rotationGizmo){
                     this.gizmos.rotationGizmo = new RotationGizmo();
-                    this.gizmos.rotationGizmo.updateGizmoRotationToMatchAttachedMesh = false;
                 }
                 this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
             }else if(this.gizmos.rotationGizmo){

+ 2 - 2
src/Gizmos/babylon.positionGizmo.ts

@@ -29,8 +29,8 @@ module BABYLON {
          */
         constructor(gizmoLayer:UtilityLayerRenderer=UtilityLayerRenderer.DefaultUtilityLayer){
             super(gizmoLayer);
-            this.xGizmo = new AxisDragGizmo(new Vector3(1,0,0), BABYLON.Color3.Green().scale(0.5), gizmoLayer);
-            this.yGizmo = new AxisDragGizmo(new Vector3(0,1,0), BABYLON.Color3.Red().scale(0.5), gizmoLayer);
+            this.xGizmo = new AxisDragGizmo(new Vector3(1,0,0), BABYLON.Color3.Red().scale(0.5), gizmoLayer);
+            this.yGizmo = new AxisDragGizmo(new Vector3(0,1,0), BABYLON.Color3.Green().scale(0.5), gizmoLayer);
             this.zGizmo = new AxisDragGizmo(new Vector3(0,0,1), BABYLON.Color3.Blue().scale(0.5), gizmoLayer);
             this.attachedMesh = null;
         }

+ 2 - 2
src/Gizmos/babylon.rotationGizmo.ts

@@ -29,8 +29,8 @@ module BABYLON {
          */
         constructor(gizmoLayer:UtilityLayerRenderer=UtilityLayerRenderer.DefaultUtilityLayer){
             super(gizmoLayer);
-            this.xGizmo = new PlaneRotationGizmo(new Vector3(1,0,0), BABYLON.Color3.Green().scale(0.5), gizmoLayer);
-            this.yGizmo = new PlaneRotationGizmo(new Vector3(0,1,0), BABYLON.Color3.Red().scale(0.5), gizmoLayer);
+            this.xGizmo = new PlaneRotationGizmo(new Vector3(1,0,0), BABYLON.Color3.Red().scale(0.5), gizmoLayer);
+            this.yGizmo = new PlaneRotationGizmo(new Vector3(0,1,0), BABYLON.Color3.Green().scale(0.5), gizmoLayer);
             this.zGizmo = new PlaneRotationGizmo(new Vector3(0,0,1), BABYLON.Color3.Blue().scale(0.5), gizmoLayer);
             this.attachedMesh = null;
         }

+ 10 - 3
src/Gizmos/babylon.scaleGizmo.ts

@@ -35,22 +35,29 @@ module BABYLON {
          */
         constructor(gizmoLayer:UtilityLayerRenderer=UtilityLayerRenderer.DefaultUtilityLayer){
             super(gizmoLayer);
-            this.xGizmo = new AxisScaleGizmo(new Vector3(1,0,0), BABYLON.Color3.Green().scale(0.5), gizmoLayer);
-            this.yGizmo = new AxisScaleGizmo(new Vector3(0,1,0), BABYLON.Color3.Red().scale(0.5), gizmoLayer);
+            this.xGizmo = new AxisScaleGizmo(new Vector3(1,0,0), BABYLON.Color3.Red().scale(0.5), gizmoLayer);
+            this.yGizmo = new AxisScaleGizmo(new Vector3(0,1,0), BABYLON.Color3.Green().scale(0.5), gizmoLayer);
             this.zGizmo = new AxisScaleGizmo(new Vector3(0,0,1), BABYLON.Color3.Blue().scale(0.5), gizmoLayer);
 
             // Create uniform scale gizmo
             this.uniformScaleGizmo = new AxisScaleGizmo(new Vector3(0,1,0), BABYLON.Color3.Yellow().scale(0.5), gizmoLayer);
             this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
             this.uniformScaleGizmo.uniformScaling = true
+            var uniformScalingMesh = BABYLON.Mesh.CreatePolyhedron("", {type: 1}, this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
+            uniformScalingMesh.scaling.scaleInPlace(0.02);
+            uniformScalingMesh.visibility = 0;
             var octahedron = BABYLON.Mesh.CreatePolyhedron("", {type: 1}, this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
             octahedron.scaling.scaleInPlace(0.007);
-            this.uniformScaleGizmo.setCustomMesh(octahedron, true);
+            uniformScalingMesh.addChild(octahedron);
+            this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
             
             this.attachedMesh = null;
         }
 
         public set updateGizmoRotationToMatchAttachedMesh(value:boolean){
+            if(!value){
+                Tools.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
+            }
             if(this.xGizmo){
                 this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
                 this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;