Bladeren bron

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

David Catuhe 8 jaren geleden
bovenliggende
commit
5a35eee0cc

+ 2 - 0
Tools/Gulp/config.json

@@ -218,6 +218,8 @@
       "../../src/Tools/HDR/babylon.tools.pmremgenerator.js",
       "../../src/Materials/Textures/babylon.hdrCubeTexture.js",
       "../../src/Debug/babylon.skeletonViewer.js",
+      "../../src/Debug/babylon.axesViewer.js",
+      "../../src/Debug/babylon.boneAxesViewer.js",
       "../../src/Materials/Textures/babylon.colorGradingTexture.js",
       "../../src/Materials/babylon.colorCurves.js",
       "../../src/Materials/babylon.pbrMaterial.js",      

+ 2 - 2
src/Bones/babylon.bone.ts

@@ -619,7 +619,7 @@
 
             this._skeleton.computeAbsoluteTransforms();
             
-            var mat = BABYLON.Tmp.Matrix[0];
+            var mat = Tmp.Matrix[0];
 
             mat.copyFrom(this.getAbsoluteTransform());
 
@@ -635,7 +635,7 @@
 
         public getRotation(space = Space.LOCAL, mesh?: AbstractMesh): Vector3 {
 
-            var result = BABYLON.Vector3.Zero();
+            var result = Vector3.Zero();
 
             this.getRotationToRef(space, mesh, result);
             

+ 4 - 4
src/Cameras/babylon.camera.ts

@@ -705,16 +705,16 @@
             return SerializationHelper.Clone(Camera.GetConstructorFromName(this.getTypeName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
         }
 
-        public getDirection(localAxis:BABYLON.Vector3): BABYLON.Vector3 {
-            var result = BABYLON.Vector3.Zero();
+        public getDirection(localAxis:Vector3): Vector3 {
+            var result = Vector3.Zero();
 
             this.getDirectionToRef(localAxis, result);
             
             return result;
         }
 
-        public getDirectionToRef(localAxis:BABYLON.Vector3, result:BABYLON.Vector3): void {
-            BABYLON.Vector3.TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
+        public getDirectionToRef(localAxis:Vector3, result:Vector3): void {
+            Vector3.TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
         }
 
         static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance: number = 0, isStereoscopicSideBySide: boolean = true): () => Camera {

+ 96 - 0
src/Debug/babylon.axesViewer.ts

@@ -0,0 +1,96 @@
+module BABYLON.Debug {
+
+    export class AxesViewer {
+        
+        private _xline = [Vector3.Zero(), Vector3.Zero()];
+        private _yline = [Vector3.Zero(), Vector3.Zero()];
+        private _zline = [Vector3.Zero(), Vector3.Zero()];
+
+        private _xmesh: LinesMesh;
+        private _ymesh: LinesMesh;
+        private _zmesh: LinesMesh;
+
+        public scene: Scene;
+        public scaleLines = 1;
+
+        constructor(scene: Scene, scaleLines = 1) {
+
+            this.scaleLines = scaleLines;
+
+            this._xmesh = Mesh.CreateLines("xline", this._xline, scene, true);
+            this._ymesh = Mesh.CreateLines("yline", this._yline, scene, true);
+            this._zmesh = Mesh.CreateLines("zline", this._zline, scene, true);
+
+            this._xmesh.renderingGroupId = 2;
+            this._ymesh.renderingGroupId = 2;
+            this._zmesh.renderingGroupId = 2;
+
+            this._xmesh.material.checkReadyOnlyOnce = true;
+            this._xmesh.color = new BABYLON.Color3(1, 0, 0);
+            this._ymesh.material.checkReadyOnlyOnce = true;
+            this._ymesh.color = new BABYLON.Color3(0, 1, 0);
+            this._zmesh.material.checkReadyOnlyOnce = true;
+            this._zmesh.color = new BABYLON.Color3(0, 0, 1);
+
+            this.scene = scene;
+
+        }
+
+        public update (position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void {
+
+            var scaleLines = this.scaleLines;
+
+            var point1 = this._xline[0];
+            var point2 = this._xline[1];
+            point1.x = position.x;
+            point1.y = position.y;
+            point1.z = position.z;
+            point2.x = point1.x + xaxis.x * scaleLines;
+            point2.y = point1.y + xaxis.y * scaleLines;
+            point2.z = point1.z + xaxis.z * scaleLines;
+            Mesh.CreateLines(null, this._xline, null, null, this._xmesh);
+
+            point1 = this._yline[0];
+            point2 = this._yline[1];
+            point1.x = position.x;
+            point1.y = position.y;
+            point1.z = position.z;
+            point2.x = point1.x + yaxis.x * scaleLines;
+            point2.y = point1.y + yaxis.y * scaleLines;
+            point2.z = point1.z + yaxis.z * scaleLines;
+            Mesh.CreateLines(null, this._yline, null, null, this._ymesh);
+
+            point1 = this._zline[0];
+            point2 = this._zline[1];
+            point1.x = position.x;
+            point1.y = position.y;
+            point1.z = position.z;
+            point2.x = point1.x + zaxis.x * scaleLines;
+            point2.y = point1.y + zaxis.y * scaleLines;
+            point2.z = point1.z + zaxis.z * scaleLines;
+            Mesh.CreateLines(null, this._zline, null, null, this._zmesh);
+
+        }
+
+        public dispose() {
+
+            if (this._xmesh) {
+                this._xmesh.dispose();
+                this._ymesh.dispose();
+                this._zmesh.dispose();
+
+                this._xmesh = null;
+                this._ymesh = null;
+                this._zmesh = null;
+
+                this._xline = null;
+                this._yline = null;
+                this._zline = null;
+
+                this.scene = null;
+            }
+
+        }
+
+    }
+}

+ 53 - 0
src/Debug/babylon.boneAxesViewer.ts

@@ -0,0 +1,53 @@
+module BABYLON.Debug {
+
+    export class BoneAxesViewer extends Debug.AxesViewer {
+
+        public mesh:Mesh;
+        public bone:Bone;
+
+        public pos = Vector3.Zero();
+        public xaxis = Vector3.Zero();
+        public yaxis = Vector3.Zero();
+        public zaxis = Vector3.Zero();
+
+        constructor(scene: Scene, bone:Bone, mesh: Mesh, scaleLines = 1) {
+
+            super(scene, scaleLines);
+
+            this.mesh = mesh;
+            this.bone = bone;
+
+        }
+
+        public update (): void {
+
+            var bone = this.bone;
+            bone.getAbsolutePositionToRef(this.mesh, this.pos);
+            bone.getDirectionToRef(Axis.X, this.mesh, this.xaxis);
+            bone.getDirectionToRef(Axis.Y, this.mesh, this.yaxis);
+            bone.getDirectionToRef(Axis.Z, this.mesh, this.zaxis);
+
+            super.update(this.pos, this.xaxis, this.yaxis, this.zaxis);
+
+        }
+
+        public dispose() {
+
+            if(this.pos){
+
+                this.pos = null;
+
+                this.xaxis = null;
+                this.yaxis = null;
+                this.zaxis = null;
+
+                this.mesh = null;
+                this.bone = null;
+
+                super.dispose();
+            
+            }
+        }
+
+    }
+}

+ 4 - 4
src/Mesh/babylon.abstractMesh.ts

@@ -1207,16 +1207,16 @@
             super.dispose();
         }
 
-        public getDirection(localAxis:BABYLON.Vector3): BABYLON.Vector3 {
-            var result = BABYLON.Vector3.Zero();
+        public getDirection(localAxis:Vector3): Vector3 {
+            var result = Vector3.Zero();
 
             this.getDirectionToRef(localAxis, result);
             
             return result;
         }
 
-        public getDirectionToRef(localAxis:BABYLON.Vector3, result:BABYLON.Vector3): void {
-            BABYLON.Vector3.TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
+        public getDirectionToRef(localAxis:Vector3, result:Vector3): void {
+            Vector3.TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
         }
 
     }