Prechádzať zdrojové kódy

Merge pull request #9872 from Popov72/fix-increasevertices

Fix Mesh.increaseVertices not working with updatable buffers
David Catuhe 4 rokov pred
rodič
commit
b0e10c4885
1 zmenil súbory, kde vykonal 7 pridanie a 3 odobranie
  1. 7 3
      src/Meshes/mesh.ts

+ 7 - 3
src/Meshes/mesh.ts

@@ -2807,14 +2807,18 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
     public increaseVertices(numberPerEdge: number): void {
     public increaseVertices(numberPerEdge: number): void {
         var vertex_data = VertexData.ExtractFromMesh(this);
         var vertex_data = VertexData.ExtractFromMesh(this);
         var uvs = vertex_data.uvs;
         var uvs = vertex_data.uvs;
-        var currentIndices = vertex_data.indices;
-        var positions = vertex_data.positions;
-        var normals = vertex_data.normals;
+        var currentIndices = vertex_data.indices && !Array.isArray(vertex_data.indices) && Array.from ? Array.from(vertex_data.indices) : vertex_data.indices;
+        var positions = vertex_data.positions && !Array.isArray(vertex_data.positions) && Array.from ? Array.from(vertex_data.positions) : vertex_data.positions;
+        var normals = vertex_data.normals && !Array.isArray(vertex_data.normals) && Array.from ? Array.from(vertex_data.normals) : vertex_data.normals;
 
 
         if (!currentIndices || !positions || !normals || !uvs) {
         if (!currentIndices || !positions || !normals || !uvs) {
             Logger.Warn("VertexData contains null entries");
             Logger.Warn("VertexData contains null entries");
         }
         }
         else {
         else {
+            vertex_data.indices = currentIndices;
+            vertex_data.positions = positions;
+            vertex_data.normals = normals;
+
             var segments: number = numberPerEdge + 1; //segments per current facet edge, become sides of new facets
             var segments: number = numberPerEdge + 1; //segments per current facet edge, become sides of new facets
             var tempIndices: Array<Array<number>> = new Array();
             var tempIndices: Array<Array<number>> = new Array();
             for (var i = 0; i < segments + 1; i++) {
             for (var i = 0; i < segments + 1; i++) {