Переглянути джерело

Added cylinderPanel to GUI3d

David Catuhe 7 роки тому
батько
коміт
b221b17857

+ 2 - 1
Tools/Gulp/config.json

@@ -1731,7 +1731,8 @@
                     "../../gui/src/3D/controls/holographicButton.ts",
                     "../../gui/src/3D/controls/stackPanel3D.ts",
                     "../../gui/src/3D/controls/volumeBasedPanel.ts",
-                    "../../gui/src/3D/controls/spherePanel.ts"
+                    "../../gui/src/3D/controls/spherePanel.ts",
+                    "../../gui/src/3D/controls/cylinderPanel.ts"
                 ],
                 "shaderFiles": [
                     "../../gui/src/3D/materials/shaders/fluent.vertex.fx",

+ 66 - 0
gui/src/3D/controls/cylinderPanel.ts

@@ -0,0 +1,66 @@
+/// <reference path="../../../../dist/preview release/babylon.d.ts"/>
+
+module BABYLON.GUI {
+    /**
+     * Class used to create a container panel deployed on the surface of a cylinder
+     */
+    export class CylinderPanel extends VolumeBasedPanel {
+        private _radius = 5.0;
+
+        /**
+         * Gets or sets the radius of the cylinder where to project controls (5 by default)
+         */
+        public get radius(): float {
+            return this._radius;
+        }
+
+        public set radius(value: float) {
+            if (this._radius === value) {
+                return;
+            }
+
+            this._radius = value;
+
+            Tools.SetImmediate(() => {
+                this._arrangeChildren();               
+            });
+        }              
+
+        protected _mapGridNode(control: Control3D, nodePosition: Vector3) {            
+            let newPos = this._cylindricalMapping(nodePosition);
+            let mesh = control.mesh;
+
+            if (!mesh) {
+                return;
+            }
+
+            switch (this.orientation) {
+                case Container3D.FACEORIGIN_ORIENTATION:
+                    mesh.lookAt(new BABYLON.Vector3(-newPos.x, 0, -newPos.z));
+                    break;
+                case Container3D.FACEORIGINREVERSED_ORIENTATION:
+                    mesh.lookAt(new BABYLON.Vector3(newPos.x, 0, newPos.z));
+                    break;
+                case Container3D.FACEFORWARD_ORIENTATION:
+                    mesh.lookAt(new BABYLON.Vector3(0, 0, 1));
+                    break;
+                case Container3D.FACEFORWARDREVERSED_ORIENTATION:
+                    mesh.lookAt(new BABYLON.Vector3(0, 0, -1));
+                    break;
+            }
+            
+            control.position = newPos;
+        }
+
+        private _cylindricalMapping(source: Vector3)
+        {
+            let newPos = new Vector3(0, source.y, this._radius);
+
+            let yAngle = (source.x / this._radius);
+
+            Matrix.RotationYawPitchRollToRef(yAngle, 0, 0, Tmp.Matrix[0]);
+
+            return Vector3.TransformNormal(newPos, Tmp.Matrix[0]);
+        }
+    }
+}

+ 1 - 1
gui/src/3D/controls/spherePanel.ts

@@ -5,7 +5,7 @@ module BABYLON.GUI {
      * Class used to create a container panel deployed on the surface of a sphere
      */
     export class SpherePanel extends VolumeBasedPanel {
-        private _radius = 4.0;
+        private _radius = 5.0;
 
         /**
          * Gets or sets the radius of the sphere where to project controls (5 by default)