Browse Source

Integrating PR

David Catuhe 9 years ago
parent
commit
5ff62f9205

File diff suppressed because it is too large
+ 478 - 470
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 29 - 22
dist/preview release/babylon.js


File diff suppressed because it is too large
+ 39 - 12
dist/preview release/babylon.max.js


File diff suppressed because it is too large
+ 28 - 21
dist/preview release/babylon.noworker.js


+ 38 - 11
src/Mesh/babylon.mesh.js

@@ -1974,6 +1974,34 @@ var BABYLON;
         };
         // Skeletons
         /**
+         * @returns original positions used for CPU skinning.  Useful for integrating Morphing with skeletons in same mesh.
+         */
+        Mesh.prototype.setPositionsForCPUSkinning = function () {
+            var source;
+            if (!this._sourcePositions) {
+                source = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
+                this._sourcePositions = new Float32Array(source);
+                if (!this.getVertexBuffer(BABYLON.VertexBuffer.PositionKind).isUpdatable()) {
+                    this.setVerticesData(BABYLON.VertexBuffer.PositionKind, source, true);
+                }
+            }
+            return this._sourcePositions;
+        };
+        /**
+         * @returns original normals used for CPU skinning.  Useful for integrating Morphing with skeletons in same mesh.
+         */
+        Mesh.prototype.setNormalsForCPUSkinning = function () {
+            var source;
+            if (!this._sourceNormals) {
+                source = this.getVerticesData(BABYLON.VertexBuffer.NormalKind);
+                this._sourceNormals = new Float32Array(source);
+                if (!this.getVertexBuffer(BABYLON.VertexBuffer.NormalKind).isUpdatable()) {
+                    this.setVerticesData(BABYLON.VertexBuffer.NormalKind, source, true);
+                }
+            }
+            return this._sourceNormals;
+        };
+        /**
          * Update the vertex buffers by applying transformation from the bones
          * @param {skeleton} skeleton to apply
          */
@@ -1990,23 +2018,22 @@ var BABYLON;
             if (!this.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)) {
                 return this;
             }
-            var source;
             if (!this._sourcePositions) {
-                source = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
-                this._sourcePositions = new Float32Array(source);
-                if (!this.getVertexBuffer(BABYLON.VertexBuffer.PositionKind).isUpdatable()) {
-                    this.setVerticesData(BABYLON.VertexBuffer.PositionKind, source, true);
-                }
+                this.setPositionsForCPUSkinning();
             }
             if (!this._sourceNormals) {
-                source = this.getVerticesData(BABYLON.VertexBuffer.NormalKind);
-                this._sourceNormals = new Float32Array(source);
-                if (!this.getVertexBuffer(BABYLON.VertexBuffer.NormalKind).isUpdatable()) {
-                    this.setVerticesData(BABYLON.VertexBuffer.NormalKind, source, true);
-                }
+                this.setNormalsForCPUSkinning();
             }
+            // positionsData checks for not being Float32Array will only pass at most once
             var positionsData = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
+            if (!(positionsData instanceof Float32Array)) {
+                positionsData = new Float32Array(positionsData);
+            }
+            // normalsData checks for not being Float32Array will only pass at most once
             var normalsData = this.getVerticesData(BABYLON.VertexBuffer.NormalKind);
+            if (!(normalsData instanceof Float32Array)) {
+                normalsData = new Float32Array(normalsData);
+            }
             var matricesIndicesData = this.getVerticesData(BABYLON.VertexBuffer.MatricesIndicesKind);
             var matricesWeightsData = this.getVerticesData(BABYLON.VertexBuffer.MatricesWeightsKind);
             var skeletonMatrices = skeleton.getTransformMatrices();

+ 10 - 9
src/Mesh/babylon.mesh.ts

@@ -293,7 +293,7 @@
             return this._geometry.getTotalIndices();
         }
 
-        public getIndices(copyWhenShared?: boolean): number[]{
+        public getIndices(copyWhenShared?: boolean): number[] {
             if (!this._geometry) {
                 return [];
             }
@@ -2276,7 +2276,7 @@
                     vertexData.indices.push(currentVertexDataIndex);
                     vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
                     vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
-                    (<number []>vertexData.uvs).push(0.5 + vertex.position.x / size.x);
+                    (<number[]>vertexData.uvs).push(0.5 + vertex.position.x / size.x);
                     (<number[]>vertexData.uvs).push(0.5 + vertex.position.y / size.y);
 
                     currentVertexDataIndex++;
@@ -2297,12 +2297,12 @@
         /**
          * @returns original positions used for CPU skinning.  Useful for integrating Morphing with skeletons in same mesh.
          */
-        public setPositionsForCPUSkinning() : Float32Array {
+        public setPositionsForCPUSkinning(): Float32Array {
             var source: number[] | Float32Array;
             if (!this._sourcePositions) {
                 source = this.getVerticesData(VertexBuffer.PositionKind);
 
-                this._sourcePositions = new Float32Array(<any>source); 
+                this._sourcePositions = new Float32Array(<any>source);
 
                 if (!this.getVertexBuffer(VertexBuffer.PositionKind).isUpdatable()) {
                     this.setVerticesData(VertexBuffer.PositionKind, source, true);
@@ -2314,12 +2314,12 @@
         /**
          * @returns original normals used for CPU skinning.  Useful for integrating Morphing with skeletons in same mesh.
          */
-        public setNormalsForCPUSkinning() : Float32Array {
+        public setNormalsForCPUSkinning(): Float32Array {
             var source: number[] | Float32Array;
             if (!this._sourceNormals) {
                 source = this.getVerticesData(VertexBuffer.NormalKind);
 
-                this._sourceNormals = new Float32Array(<any>source); 
+                this._sourceNormals = new Float32Array(<any>source);
 
                 if (!this.getVertexBuffer(VertexBuffer.NormalKind).isUpdatable()) {
                     this.setVerticesData(VertexBuffer.NormalKind, source, true);
@@ -2345,7 +2345,7 @@
             if (!this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind)) {
                 return this;
             }
-            
+
             if (!this._sourcePositions) {
                 this.setPositionsForCPUSkinning();
             }
@@ -2356,13 +2356,13 @@
 
             // positionsData checks for not being Float32Array will only pass at most once
             var positionsData = this.getVerticesData(VertexBuffer.PositionKind);
-            if (!(positionsData instanceof Float32Array)){
+            if (!(positionsData instanceof Float32Array)) {
                 positionsData = new Float32Array(positionsData);
             }
             
             // normalsData checks for not being Float32Array will only pass at most once
             var normalsData = this.getVerticesData(VertexBuffer.NormalKind);
-            if (!(normalsData instanceof Float32Array)){
+            if (!(normalsData instanceof Float32Array)) {
                 normalsData = new Float32Array(normalsData);
             }
 
@@ -2514,3 +2514,4 @@
 
 
 
+