Browse Source

Merge pull request #180 from clementlevasseur/patch-1

Bugfix getNormal of PickingInfo
deltakosh 11 năm trước cách đây
mục cha
commit
ce7646693f
1 tập tin đã thay đổi với 4 bổ sung4 xóa
  1. 4 4
      Babylon/Collisions/babylon.pickingInfo.js

+ 4 - 4
Babylon/Collisions/babylon.pickingInfo.js

@@ -24,9 +24,9 @@ var BABYLON = BABYLON || {};
         var indices = this.pickedMesh.getIndices();
         var normals = this.pickedMesh.getVerticesData(BABYLON.VertexBuffer.NormalKind);
 
-        var normal0 = BABYLON.Vector3.FromArray(normals , indices[this.faceId]);
-        var normal1 = BABYLON.Vector3.FromArray(normals, indices[this.faceId + 1]);
-        var normal2 = BABYLON.Vector3.FromArray(normals, indices[this.faceId + 2]);
+        var normal0 = BABYLON.Vector3.FromArray(normals , indices[this.faceId * 3] * 3);
+        var normal1 = BABYLON.Vector3.FromArray(normals, indices[this.faceId * 3 + 1] * 3);
+        var normal2 = BABYLON.Vector3.FromArray(normals, indices[this.faceId * 3 + 2] * 3);
 
         normal0 = normal0.scale(this.bu);
         normal1 = normal1.scale(this.bv);
@@ -34,4 +34,4 @@ var BABYLON = BABYLON || {};
 
         return new BABYLON.Vector3(normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);
     };
-})();
+})();