|
@@ -2749,8 +2749,9 @@
|
|
|
* @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
|
|
|
* @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
|
|
|
* @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
|
|
|
+ * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
|
|
|
*/
|
|
|
- public static MergeMeshes(meshes: Array<Mesh>, disposeSource = true, allow32BitsIndices?: boolean, meshSubclass?: Mesh): Mesh {
|
|
|
+ public static MergeMeshes(meshes: Array<Mesh>, disposeSource = true, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Mesh {
|
|
|
var index: number;
|
|
|
if (!allow32BitsIndices) {
|
|
|
var totalVertices = 0;
|
|
@@ -2771,7 +2772,7 @@
|
|
|
// Merge
|
|
|
var vertexData: VertexData;
|
|
|
var otherVertexData: VertexData;
|
|
|
-
|
|
|
+ var indiceArray: Array<number> = new Array<number>();
|
|
|
var source: Mesh;
|
|
|
for (index = 0; index < meshes.length; index++) {
|
|
|
if (meshes[index]) {
|
|
@@ -2785,6 +2786,10 @@
|
|
|
vertexData = otherVertexData;
|
|
|
source = meshes[index];
|
|
|
}
|
|
|
+
|
|
|
+ if (subdivideWithSubMeshes) {
|
|
|
+ indiceArray.push(meshes[index].getTotalIndices());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2806,6 +2811,22 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Subdivide
|
|
|
+ if (subdivideWithSubMeshes) {
|
|
|
+
|
|
|
+ //-- Suppresions du submesh global
|
|
|
+ meshSubclass.releaseSubMeshes();
|
|
|
+ index = 0;
|
|
|
+ var offset = 0;
|
|
|
+
|
|
|
+ //-- aplique la subdivision en fonction du tableau d'indices
|
|
|
+ while (index < indiceArray.length) {
|
|
|
+ BABYLON.SubMesh.CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
|
|
|
+ offset += indiceArray[index];
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return meshSubclass;
|
|
|
}
|
|
|
}
|