فهرست منبع

Merge pull request #5261 from TrevorDev/gizmoManagerMultipleScenes

add more tesselation to rotation gizmo, support multiple scenes with …
David Catuhe 7 سال پیش
والد
کامیت
6cd15c9111
3فایلهای تغییر یافته به همراه14 افزوده شده و 6 حذف شده
  1. 1 1
      dist/preview release/what's new.md
  2. 12 4
      src/Gizmos/babylon.gizmoManager.ts
  3. 1 1
      src/Gizmos/babylon.planeRotationGizmo.ts

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

@@ -11,7 +11,7 @@
   - New GUI control: [InputPassword](https://doc.babylonjs.com/how_to/gui#inputpassword) ([theom](https://github.com/theom))
   - New GUI container [SelectionPanel](http://doc.babylonjs.com/how_to/selector) ([JohnK](https://github.com/BabylonJSGuide))
 - Gizmo Support ([TrevorDev](https://github.com/TrevorDev))
-  - Gizmo and GizmoManager classes used to manipulate meshes in a scene. Gizmo types include: position, scale, rotation and bounding box. [Doc](http://doc.babylonjs.com/how_to/gizmo) ([TrevorDev](https://github.com/TrevorDev))
+  - Gizmo and GizmoManager classes used to manipulate meshes in a scene. Gizmo types include: position, scale, rotation and bounding box [Doc](http://doc.babylonjs.com/how_to/gizmo) ([TrevorDev](https://github.com/TrevorDev))
   - New behaviors: PointerDragBehavior, SixDofDragBehavior and MultiPointerScaleBehavior to enable smooth drag and drop/scaling with mouse or 6dof controller on a mesh. [Doc](http://doc.babylonjs.com/how_to/meshbehavior) ([TrevorDev](https://github.com/TrevorDev))
   - Added attachToBoxBehavior to attach UI to a bounding box ([TrevorDev](https://github.com/TrevorDev))
   - Gizmo manager's internal gizmos are now public ([TrevorDev](https://github.com/TrevorDev))

+ 12 - 4
src/Gizmos/babylon.gizmoManager.ts

@@ -11,6 +11,8 @@ module BABYLON {
         private _pointerObserver:Nullable<Observer<PointerInfo>> = null;
         private _attachedMesh:Nullable<AbstractMesh> = null;
         private _boundingBoxColor = BABYLON.Color3.FromHexString("#0984e3");
+        private _defaultUtilityLayer:UtilityLayerRenderer;
+        private _defaultKeepDepthUtilityLayer:UtilityLayerRenderer;
         /**
          * When bounding box gizmo is enabled, this can be used to track drag/end events
          */
@@ -29,6 +31,10 @@ module BABYLON {
          * @param scene the scene to overlay the gizmos on top of
          */
         constructor(private scene:Scene){
+            this._defaultKeepDepthUtilityLayer = new UtilityLayerRenderer(scene);
+            this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
+            this._defaultUtilityLayer = new UtilityLayerRenderer(scene);
+            
             this.gizmos = {positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null};
 
             // Instatiate/dispose gizmos based on pointer actions
@@ -95,7 +101,7 @@ module BABYLON {
         public set positionGizmoEnabled(value:boolean){
             if(value){
                 if(!this.gizmos.positionGizmo){
-                    this.gizmos.positionGizmo = new PositionGizmo();
+                    this.gizmos.positionGizmo = new PositionGizmo(this._defaultUtilityLayer);
                 }
                 this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
             }else if(this.gizmos.positionGizmo){
@@ -112,7 +118,7 @@ module BABYLON {
         public set rotationGizmoEnabled(value:boolean){
             if(value){
                 if(!this.gizmos.rotationGizmo){
-                    this.gizmos.rotationGizmo = new RotationGizmo();
+                    this.gizmos.rotationGizmo = new RotationGizmo(this._defaultUtilityLayer);
                 }
                 this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
             }else if(this.gizmos.rotationGizmo){
@@ -128,7 +134,7 @@ module BABYLON {
          */
         public set scaleGizmoEnabled(value:boolean){
             if(value){
-                this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new ScaleGizmo();
+                this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new ScaleGizmo(this._defaultUtilityLayer);
                 this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
             }else if(this.gizmos.scaleGizmo){
                 this.gizmos.scaleGizmo.attachedMesh = null;
@@ -143,7 +149,7 @@ module BABYLON {
          */
         public set boundingBoxGizmoEnabled(value:boolean){
             if(value){
-                this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new BoundingBoxGizmo(this._boundingBoxColor);
+                this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new BoundingBoxGizmo(this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
                 this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
                 if(this._attachedMesh){
                     this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
@@ -169,6 +175,8 @@ module BABYLON {
                     gizmo.dispose();
                 }
             }
+            this._defaultKeepDepthUtilityLayer.dispose();
+            this._defaultUtilityLayer.dispose();
             this.boundingBoxDragBehavior.detach();
         }
     }

+ 1 - 1
src/Gizmos/babylon.planeRotationGizmo.ts

@@ -41,7 +41,7 @@ module BABYLON {
             var parentMesh = new BABYLON.AbstractMesh("", gizmoLayer.utilityLayerScene);
 
             // Create circle out of lines
-            var tessellation = 20;
+            var tessellation = 64;
             var radius = 0.8;
             var points = new Array<Vector3>();
             for(var i = 0;i < tessellation;i++){