Selaa lähdekoodia

Merge pull request #4619 from quocsinh/fixbug

Fix bug parse matricesIndices data when load binary mesh.
David Catuhe 7 vuotta sitten
vanhempi
commit
37f60752d1
2 muutettua tiedostoa jossa 10 lisäystä ja 1 poistoa
  1. 1 0
      dist/preview release/what's new.md
  2. 9 1
      src/Mesh/babylon.geometry.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -96,6 +96,7 @@
 - Node's setParent(node.parent) will no longer throw an exception when parent is undefined and will behave the same as setParent(null) ([TrevorDev](https://github.com/TrevorDev))
 - Mesh.MergeMeshes flips triangles on meshes with negative scaling ([SvenFrankson](http://svenfrankson.com))
 - Avoid firing button events multiple times when calling vrController.attachMesh() ([TrevorDev]
+- Parse geometry when load binary mesh ([SinhNQ](https://github.com/quocsinh))
 
 ### Core Engine
 

+ 9 - 1
src/Mesh/babylon.geometry.ts

@@ -1144,7 +1144,15 @@
 
                 if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
                     var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
-                    mesh.setVerticesData(VertexBuffer.MatricesIndicesKind, matricesIndicesData, false);
+                    var floatIndices = [];
+                    for (var i = 0; i < matricesIndicesData.length; i++) {
+                        var index = matricesIndicesData[i];
+                        floatIndices.push(index & 0x000000FF);
+                        floatIndices.push((index & 0x0000FF00) >> 8);
+                        floatIndices.push((index & 0x00FF0000) >> 16);
+                        floatIndices.push(index >> 24);
+                    }
+                    mesh.setVerticesData(VertexBuffer.MatricesIndicesKind, floatIndices, false);
                 }
 
                 if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {