Bläddra i källkod

Fix bug with glTF loader morph target tangents

Gary Hsu 7 år sedan
förälder
incheckning
bacc324209
2 ändrade filer med 5 tillägg och 3 borttagningar
  1. 1 1
      loaders/src/glTF/2.0/babylon.glTFLoader.ts
  2. 4 2
      src/Mesh/babylon.mesh.vertexData.ts

+ 1 - 1
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -568,7 +568,7 @@ module BABYLON.GLTF2 {
                 for (var index = 0; index < numTargets; index++) {
                     var vertexData = new VertexData();
                     for (var primitive of mesh.primitives) {
-                        vertexData.merge(primitive.targetsVertexData[index]);
+                        vertexData.merge(primitive.targetsVertexData[index], { tangentLength: 3 });
                     }
 
                     var target = morphTargetManager.getTarget(index);

+ 4 - 2
src/Mesh/babylon.mesh.vertexData.ts

@@ -294,7 +294,9 @@
          * Merges the passed VertexData into the current one.  
          * Returns the modified VertexData.  
          */
-        public merge(other: VertexData): VertexData {
+        public merge(other: VertexData, options?: { tangentLength?: number }): VertexData {
+            options = options || {};
+
             if (other.indices) {
                 if (!this.indices) {
                     this.indices = [];
@@ -312,7 +314,7 @@
             var count = this.positions.length / 3;
 
             this.normals = this._mergeElement(this.normals, other.normals, count * 3);
-            this.tangents = this._mergeElement(this.tangents, other.tangents, count * 4);
+            this.tangents = this._mergeElement(this.tangents, other.tangents, count * (options.tangentLength || 4));
             this.uvs = this._mergeElement(this.uvs, other.uvs, count * 2);
             this.uvs2 = this._mergeElement(this.uvs2, other.uvs2, count * 2);
             this.uvs3 = this._mergeElement(this.uvs3, other.uvs3, count * 2);