@babylonjs/core 7.30.0 → 7.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/Engines/WebGPU/webgpuCacheBindGroups.js +13 -2
  2. package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
  3. package/Engines/WebGPU/webgpuCacheSampler.js +2 -3
  4. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  5. package/Engines/abstractEngine.js +2 -2
  6. package/Engines/abstractEngine.js.map +1 -1
  7. package/Materials/Background/backgroundMaterial.js +1 -11
  8. package/Materials/Background/backgroundMaterial.js.map +1 -1
  9. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +8 -0
  10. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +43 -34
  11. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  12. package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.d.ts +32 -0
  13. package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.js +64 -0
  14. package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.js.map +1 -0
  15. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.d.ts +48 -0
  16. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +102 -0
  17. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -0
  18. package/Materials/Node/Blocks/GaussianSplatting/index.d.ts +3 -0
  19. package/Materials/Node/Blocks/GaussianSplatting/index.js +4 -0
  20. package/Materials/Node/Blocks/GaussianSplatting/index.js.map +1 -0
  21. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.d.ts +40 -0
  22. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +96 -0
  23. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -0
  24. package/Materials/Node/Blocks/Input/inputBlock.js +6 -0
  25. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  26. package/Materials/Node/Blocks/index.d.ts +1 -0
  27. package/Materials/Node/Blocks/index.js +1 -0
  28. package/Materials/Node/Blocks/index.js.map +1 -1
  29. package/Materials/Node/Enums/nodeMaterialModes.d.ts +3 -1
  30. package/Materials/Node/Enums/nodeMaterialModes.js +2 -0
  31. package/Materials/Node/Enums/nodeMaterialModes.js.map +1 -1
  32. package/Materials/Node/index.d.ts +1 -0
  33. package/Materials/Node/index.js +1 -0
  34. package/Materials/Node/index.js.map +1 -1
  35. package/Materials/Node/nodeMaterialDefault.d.ts +6 -0
  36. package/Materials/Node/nodeMaterialDefault.js +53 -0
  37. package/Materials/Node/nodeMaterialDefault.js.map +1 -0
  38. package/Materials/PBR/pbrBaseMaterial.js +1 -11
  39. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  40. package/Materials/Textures/texture.js +7 -3
  41. package/Materials/Textures/texture.js.map +1 -1
  42. package/Materials/Textures/textureSampler.d.ts +1 -1
  43. package/Materials/Textures/textureSampler.js.map +1 -1
  44. package/Materials/material.d.ts +5 -1
  45. package/Materials/material.js +19 -1
  46. package/Materials/material.js.map +1 -1
  47. package/Materials/materialPluginManager.js +2 -2
  48. package/Materials/materialPluginManager.js.map +1 -1
  49. package/Materials/pushMaterial.d.ts +1 -1
  50. package/Materials/pushMaterial.js +2 -2
  51. package/Materials/pushMaterial.js.map +1 -1
  52. package/Materials/standardMaterial.js +1 -11
  53. package/Materials/standardMaterial.js.map +1 -1
  54. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +11 -0
  55. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +264 -61
  56. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  57. package/Meshes/Node/Blocks/Set/aggregatorBlock.d.ts +76 -0
  58. package/Meshes/Node/Blocks/Set/aggregatorBlock.js +210 -0
  59. package/Meshes/Node/Blocks/Set/aggregatorBlock.js.map +1 -0
  60. package/Meshes/Node/Blocks/booleanGeometryBlock.d.ts +6 -0
  61. package/Meshes/Node/Blocks/booleanGeometryBlock.js +16 -4
  62. package/Meshes/Node/Blocks/booleanGeometryBlock.js.map +1 -1
  63. package/Meshes/Node/Blocks/geometryTransformBlock.d.ts +6 -0
  64. package/Meshes/Node/Blocks/geometryTransformBlock.js +14 -2
  65. package/Meshes/Node/Blocks/geometryTransformBlock.js.map +1 -1
  66. package/Meshes/Node/index.d.ts +1 -0
  67. package/Meshes/Node/index.js +1 -0
  68. package/Meshes/Node/index.js.map +1 -1
  69. package/Meshes/Node/nodeGeometry.d.ts +1 -1
  70. package/Meshes/Node/nodeGeometry.js +14 -1
  71. package/Meshes/Node/nodeGeometry.js.map +1 -1
  72. package/Meshes/Node/nodeGeometryBlock.d.ts +4 -0
  73. package/Meshes/Node/nodeGeometryBlock.js +6 -0
  74. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  75. package/Meshes/csg.d.ts +1 -0
  76. package/Meshes/csg.js +1 -0
  77. package/Meshes/csg.js.map +1 -1
  78. package/Meshes/csg2.d.ts +131 -0
  79. package/Meshes/csg2.js +355 -0
  80. package/Meshes/csg2.js.map +1 -0
  81. package/Meshes/index.d.ts +1 -0
  82. package/Meshes/index.js +1 -0
  83. package/Meshes/index.js.map +1 -1
  84. package/Meshes/mesh.js +3 -1
  85. package/Meshes/mesh.js.map +1 -1
  86. package/Meshes/mesh.vertexData.d.ts +66 -1
  87. package/Meshes/mesh.vertexData.js.map +1 -1
  88. package/Misc/dumpTools.js +1 -0
  89. package/Misc/dumpTools.js.map +1 -1
  90. package/Misc/tools.d.ts +2 -1
  91. package/Misc/tools.internals.d.ts +13 -0
  92. package/Misc/tools.internals.js +48 -0
  93. package/Misc/tools.internals.js.map +1 -0
  94. package/Misc/tools.js +13 -4
  95. package/Misc/tools.js.map +1 -1
  96. package/Morph/morphTarget.js +1 -0
  97. package/Morph/morphTarget.js.map +1 -1
  98. package/Shaders/ShadersInclude/gaussianSplatting.d.ts +5 -0
  99. package/Shaders/ShadersInclude/gaussianSplatting.js +33 -0
  100. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -0
  101. package/Shaders/ShadersInclude/gaussianSplattingFragmentDeclaration.d.ts +7 -0
  102. package/Shaders/ShadersInclude/gaussianSplattingFragmentDeclaration.js +19 -0
  103. package/Shaders/ShadersInclude/gaussianSplattingFragmentDeclaration.js.map +1 -0
  104. package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js +1 -1
  105. package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
  106. package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -2
  107. package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
  108. package/Shaders/gaussianSplatting.fragment.d.ts +1 -2
  109. package/Shaders/gaussianSplatting.fragment.js +5 -10
  110. package/Shaders/gaussianSplatting.fragment.js.map +1 -1
  111. package/Shaders/gaussianSplatting.vertex.d.ts +1 -0
  112. package/Shaders/gaussianSplatting.vertex.js +4 -21
  113. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  114. package/Shaders/lod.fragment.js +1 -1
  115. package/Shaders/lod.fragment.js.map +1 -1
  116. package/package.json +1 -1
package/Meshes/csg2.js ADDED
@@ -0,0 +1,355 @@
1
+ import { Mesh } from "./mesh.js";
2
+ import { VertexData } from "./mesh.vertexData.js";
3
+ import { VertexBuffer } from "../Buffers/buffer.js";
4
+ import { Logger } from "../Misc/logger.js";
5
+ import { MultiMaterial } from "../Materials/multiMaterial.js";
6
+ import { SubMesh } from "./subMesh.js";
7
+ import { _LoadScriptModuleAsync } from "../Misc/tools.internals.js";
8
+ import { Vector3 } from "../Maths/math.vector.js";
9
+ /**
10
+ * Main manifold library
11
+ */
12
+ // eslint-disable-next-line @typescript-eslint/naming-convention
13
+ let Manifold;
14
+ /**
15
+ * Manifold mesh
16
+ */
17
+ // eslint-disable-next-line @typescript-eslint/naming-convention
18
+ let ManifoldMesh;
19
+ /**
20
+ * First ID to use for materials indexing
21
+ */
22
+ // eslint-disable-next-line @typescript-eslint/naming-convention
23
+ let FirstID;
24
+ /**
25
+ * Wrapper around the Manifold library
26
+ * https://manifoldcad.org/
27
+ * Use this class to perform fast boolean operations on meshes
28
+ * #IW43EB#15 - basic operations
29
+ * #JUKXQD#6104 - skull vs box
30
+ * #JUKXQD#6111 - skull vs vertex data
31
+ */
32
+ export class CSG2 {
33
+ /**
34
+ * Return the size of a vertex (at least 3 for the position)
35
+ */
36
+ get numProp() {
37
+ return this._numProp;
38
+ }
39
+ constructor(manifold, numProp, vertexStructure) {
40
+ this._manifold = manifold;
41
+ this._numProp = numProp;
42
+ this._vertexStructure = vertexStructure;
43
+ }
44
+ _process(operation, csg) {
45
+ if (this.numProp !== csg.numProp) {
46
+ throw new Error("CSG must have the same number of properties");
47
+ }
48
+ return new CSG2(Manifold[operation](this._manifold, csg._manifold), this.numProp, this._vertexStructure);
49
+ }
50
+ /**
51
+ * Run a difference operation between two CSG
52
+ * @param csg defines the CSG to use to create the difference
53
+ * @returns a new csg
54
+ */
55
+ subtract(csg) {
56
+ return this._process("difference", csg);
57
+ }
58
+ /**
59
+ * Run an intersection operation between two CSG
60
+ * @param csg defines the CSG to use to create the intersection
61
+ * @returns a new csg
62
+ */
63
+ intersect(csg) {
64
+ return this._process("intersection", csg);
65
+ }
66
+ /**
67
+ * Run an union operation between two CSG
68
+ * @param csg defines the CSG to use to create the union
69
+ * @returns a new csg
70
+ */
71
+ add(csg) {
72
+ return this._process("union", csg);
73
+ }
74
+ /**
75
+ * Print debug information about the CSG
76
+ */
77
+ printDebug() {
78
+ Logger.Log("Genus:" + this._manifold.genus());
79
+ const properties = this._manifold.getProperties();
80
+ Logger.Log("Volume:" + properties.volume);
81
+ Logger.Log("surface area:" + properties.surfaceArea);
82
+ }
83
+ /**
84
+ * Generate a vertex data from the CSG
85
+ * @param options defines the options to use to rebuild the vertex data
86
+ * @returns a new vertex data
87
+ */
88
+ toVertexData(options) {
89
+ const localOptions = {
90
+ rebuildNormals: false,
91
+ ...options,
92
+ };
93
+ const vertexData = new VertexData();
94
+ const normalComponent = this._vertexStructure.find((c) => c.kind === VertexBuffer.NormalKind);
95
+ const manifoldMesh = this._manifold.getMesh(localOptions.rebuildNormals && normalComponent ? [3, 4, 5] : undefined);
96
+ vertexData.indices = manifoldMesh.triVerts.length > 65535 ? new Uint32Array(manifoldMesh.triVerts) : new Uint16Array(manifoldMesh.triVerts);
97
+ for (let i = 0; i < manifoldMesh.triVerts.length; i += 3) {
98
+ vertexData.indices[i] = manifoldMesh.triVerts[i + 2];
99
+ vertexData.indices[i + 1] = manifoldMesh.triVerts[i + 1];
100
+ vertexData.indices[i + 2] = manifoldMesh.triVerts[i];
101
+ }
102
+ const vertexCount = manifoldMesh.vertProperties.length / manifoldMesh.numProp;
103
+ // Attributes
104
+ let offset = 0;
105
+ for (let componentIndex = 0; componentIndex < this._vertexStructure.length; componentIndex++) {
106
+ const component = this._vertexStructure[componentIndex];
107
+ const data = new Float32Array(vertexCount * component.stride);
108
+ for (let i = 0; i < vertexCount; i++) {
109
+ for (let strideIndex = 0; strideIndex < component.stride; strideIndex++) {
110
+ data[i * component.stride + strideIndex] = manifoldMesh.vertProperties[i * manifoldMesh.numProp + offset + strideIndex];
111
+ }
112
+ }
113
+ vertexData.set(data, component.kind);
114
+ offset += component.stride;
115
+ }
116
+ // Rebuild mesh from vertex data
117
+ return vertexData;
118
+ }
119
+ /**
120
+ * Generate a mesh from the CSG
121
+ * @param name defines the name of the mesh
122
+ * @param scene defines the scene to use to create the mesh
123
+ * @param options defines the options to use to rebuild the mesh
124
+ * @returns a new Mesh
125
+ */
126
+ toMesh(name, scene, options) {
127
+ const localOptions = {
128
+ rebuildNormals: false,
129
+ centerMesh: true,
130
+ ...options,
131
+ };
132
+ const vertexData = this.toVertexData({ rebuildNormals: localOptions.rebuildNormals });
133
+ const normalComponent = this._vertexStructure.find((c) => c.kind === VertexBuffer.NormalKind);
134
+ const manifoldMesh = this._manifold.getMesh(localOptions.rebuildNormals && normalComponent ? [3, 4, 5] : undefined);
135
+ const vertexCount = manifoldMesh.vertProperties.length / manifoldMesh.numProp;
136
+ // Rebuild mesh from vertex data
137
+ const output = new Mesh(name, scene);
138
+ vertexData.applyToMesh(output);
139
+ // Center mesh
140
+ if (localOptions.centerMesh) {
141
+ const extents = output.getBoundingInfo().boundingSphere.center;
142
+ output.position.set(-extents.x, -extents.y, -extents.z);
143
+ output.bakeCurrentTransformIntoVertices();
144
+ }
145
+ // Submeshes
146
+ let id = manifoldMesh.runOriginalID[0];
147
+ let start = manifoldMesh.runIndex[0];
148
+ let materialIndex = 0;
149
+ const materials = [];
150
+ scene = output.getScene();
151
+ for (let run = 0; run < manifoldMesh.numRun; ++run) {
152
+ const nextID = manifoldMesh.runOriginalID[run + 1];
153
+ if (nextID !== id) {
154
+ const end = manifoldMesh.runIndex[run + 1];
155
+ new SubMesh(materialIndex, 0, vertexCount, start, end - start, output);
156
+ materials.push(scene.getMaterialByUniqueID(id - FirstID) || scene.defaultMaterial);
157
+ id = nextID;
158
+ start = end;
159
+ materialIndex++;
160
+ }
161
+ }
162
+ if (localOptions.materialToUse) {
163
+ output.material = localOptions.materialToUse;
164
+ }
165
+ else {
166
+ if (materials.length > 1) {
167
+ const multiMaterial = new MultiMaterial(name, scene);
168
+ multiMaterial.subMaterials = materials;
169
+ output.material = multiMaterial;
170
+ }
171
+ else {
172
+ output.material = materials[0];
173
+ }
174
+ }
175
+ return output;
176
+ }
177
+ /**
178
+ * Dispose the CSG resources
179
+ */
180
+ dispose() {
181
+ if (this._manifold) {
182
+ this._manifold.delete();
183
+ this._manifold = null;
184
+ }
185
+ }
186
+ static _ProcessData(vertexCount, triVerts, structure, numProp, runIndex, runOriginalID) {
187
+ const vertProperties = new Float32Array(vertexCount * structure.reduce((acc, cur) => acc + cur.stride, 0));
188
+ for (let i = 0; i < vertexCount; i++) {
189
+ let offset = 0;
190
+ for (let idx = 0; idx < structure.length; idx++) {
191
+ const component = structure[idx];
192
+ for (let strideIndex = 0; strideIndex < component.stride; strideIndex++) {
193
+ vertProperties[i * numProp + offset + strideIndex] = component.data[i * component.stride + strideIndex];
194
+ }
195
+ offset += component.stride;
196
+ }
197
+ }
198
+ const manifoldMesh = new ManifoldMesh({ numProp: numProp, vertProperties, triVerts, runIndex, runOriginalID });
199
+ manifoldMesh.merge();
200
+ try {
201
+ return new CSG2(new Manifold(manifoldMesh), numProp, structure);
202
+ }
203
+ catch (e) {
204
+ throw new Error("Error while creating the CSG: " + e.message);
205
+ }
206
+ }
207
+ static _Construct(data, worldMatrix, runIndex, runOriginalID) {
208
+ // Create the MeshGL for I/O with Manifold library.
209
+ const triVerts = new Uint32Array(data.indices.length);
210
+ // Revert order
211
+ for (let i = 0; i < data.indices.length; i += 3) {
212
+ triVerts[i] = data.indices[i + 2];
213
+ triVerts[i + 1] = data.indices[i + 1];
214
+ triVerts[i + 2] = data.indices[i];
215
+ }
216
+ const tempVector3 = new Vector3();
217
+ let numProp = 3;
218
+ const structure = [{ stride: 3, kind: VertexBuffer.PositionKind }];
219
+ if (!worldMatrix) {
220
+ structure[0].data = data.positions;
221
+ }
222
+ else {
223
+ const positions = new Float32Array(data.positions.length);
224
+ for (let i = 0; i < data.positions.length; i += 3) {
225
+ Vector3.TransformCoordinatesFromFloatsToRef(data.positions[i], data.positions[i + 1], data.positions[i + 2], worldMatrix, tempVector3);
226
+ tempVector3.toArray(positions, i);
227
+ }
228
+ structure[0].data = positions;
229
+ }
230
+ // Normals
231
+ const sourceNormals = data.normals;
232
+ if (sourceNormals) {
233
+ numProp += 3;
234
+ structure.push({ stride: 3, kind: VertexBuffer.NormalKind });
235
+ if (!worldMatrix) {
236
+ structure[1].data = sourceNormals;
237
+ }
238
+ else {
239
+ const normals = new Float32Array(sourceNormals.length);
240
+ for (let i = 0; i < sourceNormals.length; i += 3) {
241
+ Vector3.TransformNormalFromFloatsToRef(sourceNormals[i], sourceNormals[i + 1], sourceNormals[i + 2], worldMatrix, tempVector3);
242
+ tempVector3.toArray(normals, i);
243
+ }
244
+ structure[1].data = normals;
245
+ }
246
+ }
247
+ // UVs
248
+ for (const kind of [VertexBuffer.UVKind, VertexBuffer.UV2Kind, VertexBuffer.UV3Kind, VertexBuffer.UV4Kind, VertexBuffer.UV5Kind, VertexBuffer.UV6Kind]) {
249
+ const sourceUV = data[kind === VertexBuffer.UVKind ? "uvs" : kind];
250
+ if (sourceUV) {
251
+ numProp += 2;
252
+ structure.push({ stride: 2, kind: kind, data: sourceUV });
253
+ }
254
+ }
255
+ // Colors
256
+ const sourceColors = data.colors;
257
+ if (sourceColors) {
258
+ numProp += 4;
259
+ structure.push({ stride: 4, kind: VertexBuffer.ColorKind, data: sourceColors });
260
+ }
261
+ return this._ProcessData(data.positions.length / 3, triVerts, structure, numProp, runIndex, runOriginalID);
262
+ }
263
+ /**
264
+ * Create a new Constructive Solid Geometry from a vertexData
265
+ * @param vertexData defines the vertexData to use to create the CSG
266
+ * @returns a new CSG2 class
267
+ */
268
+ static FromVertexData(vertexData) {
269
+ const sourceVertices = vertexData.positions;
270
+ const sourceIndices = vertexData.indices;
271
+ if (!sourceVertices || !sourceIndices) {
272
+ throw new Error("The vertexData must at least have positions and indices");
273
+ }
274
+ return this._Construct(vertexData, null);
275
+ }
276
+ /**
277
+ * Create a new Constructive Solid Geometry from a mesh
278
+ * @param mesh defines the mesh to use to create the CSG
279
+ * @param ignoreWorldMatrix defines if the world matrix should be ignored
280
+ * @returns a new CSG2 class
281
+ */
282
+ static FromMesh(mesh, ignoreWorldMatrix = false) {
283
+ const sourceVertices = mesh.getVerticesData(VertexBuffer.PositionKind);
284
+ const sourceIndices = mesh.getIndices();
285
+ const worldMatrix = mesh.computeWorldMatrix(true);
286
+ if (!sourceVertices || !sourceIndices) {
287
+ throw new Error("The mesh must at least have positions and indices");
288
+ }
289
+ // Create a triangle run for each submesh (material)
290
+ const starts = [...Array(mesh.subMeshes.length)].map((_, idx) => mesh.subMeshes[idx].indexStart);
291
+ // Map the materials to ID.
292
+ const sourceMaterial = mesh.material || mesh.getScene().defaultMaterial;
293
+ const isMultiMaterial = sourceMaterial.getClassName() === "MultiMaterial";
294
+ const originalIDs = [...Array(mesh.subMeshes.length)].map((_, idx) => {
295
+ if (isMultiMaterial) {
296
+ return FirstID + sourceMaterial.subMaterials[mesh.subMeshes[idx].materialIndex].uniqueId;
297
+ }
298
+ return FirstID + sourceMaterial.uniqueId;
299
+ });
300
+ // List the runs in sequence.
301
+ const indices = Array.from(starts.keys());
302
+ indices.sort((a, b) => starts[a] - starts[b]);
303
+ const runIndex = new Uint32Array(indices.map((i) => starts[i]));
304
+ const runOriginalID = new Uint32Array(indices.map((i) => originalIDs[i]));
305
+ // Process
306
+ const data = {
307
+ positions: sourceVertices,
308
+ indices: sourceIndices,
309
+ normals: mesh.getVerticesData(VertexBuffer.NormalKind),
310
+ colors: mesh.getVerticesData(VertexBuffer.ColorKind),
311
+ uvs: mesh.getVerticesData(VertexBuffer.UVKind),
312
+ uvs2: mesh.getVerticesData(VertexBuffer.UV2Kind),
313
+ uvs3: mesh.getVerticesData(VertexBuffer.UV3Kind),
314
+ uvs4: mesh.getVerticesData(VertexBuffer.UV4Kind),
315
+ uvs5: mesh.getVerticesData(VertexBuffer.UV5Kind),
316
+ uvs6: mesh.getVerticesData(VertexBuffer.UV6Kind),
317
+ };
318
+ return this._Construct(data, ignoreWorldMatrix ? null : worldMatrix, runIndex, runOriginalID);
319
+ }
320
+ }
321
+ /**
322
+ * Checks if the Manifold library is ready
323
+ * @returns true if the Manifold library is ready
324
+ */
325
+ export function IsCSG2Ready() {
326
+ return Manifold !== undefined;
327
+ }
328
+ /**
329
+ * Initialize the Manifold library
330
+ * @param options defines the options to use to initialize the library
331
+ */
332
+ export async function InitializeCSG2Async(options) {
333
+ const localOptions = {
334
+ manifoldUrl: "https://unpkg.com/manifold-3d@2.5.1",
335
+ ...options,
336
+ };
337
+ if (localOptions.manifoldInstance) {
338
+ Manifold = localOptions.manifoldInstance;
339
+ ManifoldMesh = localOptions.manifoldMeshInstance;
340
+ }
341
+ else {
342
+ const result = await _LoadScriptModuleAsync(`
343
+ import Module from '${localOptions.manifoldUrl}/manifold.js';
344
+ const wasm = await Module();
345
+ wasm.setup();
346
+ const {Manifold, Mesh} = wasm;
347
+ const returnedValue = {Manifold, Mesh};
348
+ `);
349
+ Manifold = result.Manifold;
350
+ ManifoldMesh = result.Mesh;
351
+ }
352
+ // Reserve IDs for materials (we consider that there will be no more than 65536 materials)
353
+ FirstID = Manifold.reserveIDs(65536);
354
+ }
355
+ //# sourceMappingURL=csg2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csg2.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/csg2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,0BAAyB;AAC1C,OAAO,EAAE,aAAa,EAAE,sCAAqC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,sBAAsB,EAAE,mCAAkC;AAGnE,OAAO,EAAE,OAAO,EAAE,gCAA+B;AAEjD;;GAEG;AACH,gEAAgE;AAChE,IAAI,QAAa,CAAC;AAElB;;GAEG;AACH,gEAAgE;AAChE,IAAI,YAAiB,CAAC;AAEtB;;GAEG;AACH,gEAAgE;AAChE,IAAI,OAAe,CAAC;AA+DpB;;;;;;;GAOG;AACH,MAAM,OAAO,IAAI;IAKb;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,YAAoB,QAAa,EAAE,OAAe,EAAE,eAA2C;QAC3F,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG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G,MAAM,CAAC,QAAQ,CAAC;QAC3B,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC;KAC9B;IAED,0FAA0F;IAC1F,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { Mesh } from \"./mesh\";\r\nimport type { IDisposable, Scene } from \"core/scene\";\r\nimport type { IVertexDataLike } from \"./mesh.vertexData\";\r\nimport { VertexData } from \"./mesh.vertexData\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { MultiMaterial } from \"core/Materials/multiMaterial\";\r\nimport { SubMesh } from \"./subMesh\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { _LoadScriptModuleAsync } from \"core/Misc/tools.internals\";\r\nimport type { FloatArray, Nullable } from \"core/types\";\r\nimport type { Matrix } from \"core/Maths/math.vector\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * Main manifold library\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet Manifold: any;\r\n\r\n/**\r\n * Manifold mesh\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet ManifoldMesh: any;\r\n\r\n/**\r\n * First ID to use for materials indexing\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet FirstID: number;\r\n\r\n/**\r\n * Interface to customize the Manifold library import\r\n */\r\nexport interface ICSG2Options {\r\n /**\r\n * Custom manifold URL\r\n */\r\n manifoldUrl?: string;\r\n /**\r\n * Custom manifold instance\r\n */\r\n manifoldInstance: any;\r\n /**\r\n * Custom manifold mesh instance\r\n */\r\n manifoldMeshInstance: any;\r\n}\r\n\r\n/**\r\n * Interface to customize the mesh rebuild options\r\n */\r\nexport interface IMeshRebuildOptions {\r\n /**\r\n * Rebuild normals\r\n */\r\n rebuildNormals?: boolean;\r\n /**\r\n * True to center the mesh on 0,0,0\r\n */\r\n centerMesh?: boolean;\r\n /**\r\n * Defines a material to use for that mesh. When not defined the system will either reuse the one from the source or create a multimaterial if several materials were involved\r\n */\r\n materialToUse?: Material;\r\n}\r\n\r\n/**\r\n * Interface to customize the vertex data rebuild options\r\n */\r\nexport interface IVertexDataRebuildOptions {\r\n /**\r\n * Rebuild normals\r\n */\r\n rebuildNormals?: boolean;\r\n}\r\n\r\ninterface IManifoldMesh {\r\n numProp: number;\r\n vertProperties: Float32Array;\r\n triVerts: Uint32Array;\r\n runIndex: Uint32Array;\r\n runOriginalID: Uint32Array;\r\n numRun: number;\r\n}\r\n\r\ninterface IManifoldVertexComponent {\r\n stride: number;\r\n kind: string;\r\n data?: FloatArray;\r\n}\r\n\r\n/**\r\n * Wrapper around the Manifold library\r\n * https://manifoldcad.org/\r\n * Use this class to perform fast boolean operations on meshes\r\n * #IW43EB#15 - basic operations\r\n * #JUKXQD#6104 - skull vs box\r\n * #JUKXQD#6111 - skull vs vertex data\r\n */\r\nexport class CSG2 implements IDisposable {\r\n private _manifold: any;\r\n private _numProp: number;\r\n private _vertexStructure: IManifoldVertexComponent[];\r\n\r\n /**\r\n * Return the size of a vertex (at least 3 for the position)\r\n */\r\n public get numProp() {\r\n return this._numProp;\r\n }\r\n\r\n private constructor(manifold: any, numProp: number, vertexStructure: IManifoldVertexComponent[]) {\r\n this._manifold = manifold;\r\n this._numProp = numProp;\r\n this._vertexStructure = vertexStructure;\r\n }\r\n\r\n private _process(operation: \"difference\" | \"intersection\" | \"union\", csg: CSG2) {\r\n if (this.numProp !== csg.numProp) {\r\n throw new Error(\"CSG must have the same number of properties\");\r\n }\r\n return new CSG2(Manifold[operation](this._manifold, csg._manifold), this.numProp, this._vertexStructure);\r\n }\r\n\r\n /**\r\n * Run a difference operation between two CSG\r\n * @param csg defines the CSG to use to create the difference\r\n * @returns a new csg\r\n */\r\n public subtract(csg: CSG2) {\r\n return this._process(\"difference\", csg);\r\n }\r\n\r\n /**\r\n * Run an intersection operation between two CSG\r\n * @param csg defines the CSG to use to create the intersection\r\n * @returns a new csg\r\n */\r\n public intersect(csg: CSG2) {\r\n return this._process(\"intersection\", csg);\r\n }\r\n\r\n /**\r\n * Run an union operation between two CSG\r\n * @param csg defines the CSG to use to create the union\r\n * @returns a new csg\r\n */\r\n public add(csg: CSG2) {\r\n return this._process(\"union\", csg);\r\n }\r\n\r\n /**\r\n * Print debug information about the CSG\r\n */\r\n public printDebug() {\r\n Logger.Log(\"Genus:\" + this._manifold.genus());\r\n const properties = this._manifold.getProperties();\r\n Logger.Log(\"Volume:\" + properties.volume);\r\n Logger.Log(\"surface area:\" + properties.surfaceArea);\r\n }\r\n\r\n /**\r\n * Generate a vertex data from the CSG\r\n * @param options defines the options to use to rebuild the vertex data\r\n * @returns a new vertex data\r\n */\r\n public toVertexData(options?: Partial<IVertexDataRebuildOptions>): VertexData {\r\n const localOptions = {\r\n rebuildNormals: false,\r\n ...options,\r\n };\r\n const vertexData = new VertexData();\r\n const normalComponent = this._vertexStructure.find((c) => c.kind === VertexBuffer.NormalKind);\r\n const manifoldMesh: IManifoldMesh = this._manifold.getMesh(localOptions.rebuildNormals && normalComponent ? [3, 4, 5] : undefined);\r\n\r\n vertexData.indices = manifoldMesh.triVerts.length > 65535 ? new Uint32Array(manifoldMesh.triVerts) : new Uint16Array(manifoldMesh.triVerts);\r\n\r\n for (let i = 0; i < manifoldMesh.triVerts.length; i += 3) {\r\n vertexData.indices[i] = manifoldMesh.triVerts[i + 2];\r\n vertexData.indices[i + 1] = manifoldMesh.triVerts[i + 1];\r\n vertexData.indices[i + 2] = manifoldMesh.triVerts[i];\r\n }\r\n\r\n const vertexCount = manifoldMesh.vertProperties.length / manifoldMesh.numProp;\r\n\r\n // Attributes\r\n let offset = 0;\r\n for (let componentIndex = 0; componentIndex < this._vertexStructure.length; componentIndex++) {\r\n const component = this._vertexStructure[componentIndex];\r\n\r\n const data = new Float32Array(vertexCount * component.stride);\r\n for (let i = 0; i < vertexCount; i++) {\r\n for (let strideIndex = 0; strideIndex < component.stride; strideIndex++) {\r\n data[i * component.stride + strideIndex] = manifoldMesh.vertProperties[i * manifoldMesh.numProp + offset + strideIndex];\r\n }\r\n }\r\n vertexData.set(data, component.kind);\r\n offset += component.stride;\r\n }\r\n\r\n // Rebuild mesh from vertex data\r\n return vertexData;\r\n }\r\n\r\n /**\r\n * Generate a mesh from the CSG\r\n * @param name defines the name of the mesh\r\n * @param scene defines the scene to use to create the mesh\r\n * @param options defines the options to use to rebuild the mesh\r\n * @returns a new Mesh\r\n */\r\n public toMesh(name: string, scene?: Scene, options?: Partial<IMeshRebuildOptions>): Mesh {\r\n const localOptions = {\r\n rebuildNormals: false,\r\n centerMesh: true,\r\n ...options,\r\n };\r\n const vertexData = this.toVertexData({ rebuildNormals: localOptions.rebuildNormals });\r\n const normalComponent = this._vertexStructure.find((c) => c.kind === VertexBuffer.NormalKind);\r\n const manifoldMesh: IManifoldMesh = this._manifold.getMesh(localOptions.rebuildNormals && normalComponent ? [3, 4, 5] : undefined);\r\n const vertexCount = manifoldMesh.vertProperties.length / manifoldMesh.numProp;\r\n\r\n // Rebuild mesh from vertex data\r\n const output = new Mesh(name, scene);\r\n vertexData.applyToMesh(output);\r\n\r\n // Center mesh\r\n if (localOptions.centerMesh) {\r\n const extents = output.getBoundingInfo().boundingSphere.center;\r\n output.position.set(-extents.x, -extents.y, -extents.z);\r\n output.bakeCurrentTransformIntoVertices();\r\n }\r\n\r\n // Submeshes\r\n let id = manifoldMesh.runOriginalID[0];\r\n let start = manifoldMesh.runIndex[0];\r\n let materialIndex = 0;\r\n const materials: Material[] = [];\r\n scene = output.getScene();\r\n for (let run = 0; run < manifoldMesh.numRun; ++run) {\r\n const nextID = manifoldMesh.runOriginalID[run + 1];\r\n if (nextID !== id) {\r\n const end = manifoldMesh.runIndex[run + 1];\r\n new SubMesh(materialIndex, 0, vertexCount, start, end - start, output);\r\n materials.push(scene.getMaterialByUniqueID(id - FirstID) || scene.defaultMaterial);\r\n id = nextID;\r\n start = end;\r\n materialIndex++;\r\n }\r\n }\r\n\r\n if (localOptions.materialToUse) {\r\n output.material = localOptions.materialToUse;\r\n } else {\r\n if (materials.length > 1) {\r\n const multiMaterial = new MultiMaterial(name, scene);\r\n multiMaterial.subMaterials = materials;\r\n output.material = multiMaterial;\r\n } else {\r\n output.material = materials[0];\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Dispose the CSG resources\r\n */\r\n public dispose() {\r\n if (this._manifold) {\r\n this._manifold.delete();\r\n this._manifold = null;\r\n }\r\n }\r\n\r\n private static _ProcessData(\r\n vertexCount: number,\r\n triVerts: Uint32Array,\r\n structure: IManifoldVertexComponent[],\r\n numProp: number,\r\n runIndex?: Uint32Array,\r\n runOriginalID?: Uint32Array\r\n ) {\r\n const vertProperties = new Float32Array(vertexCount * structure.reduce((acc, cur) => acc + cur.stride, 0));\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n let offset = 0;\r\n for (let idx = 0; idx < structure.length; idx++) {\r\n const component = structure[idx];\r\n\r\n for (let strideIndex = 0; strideIndex < component.stride; strideIndex++) {\r\n vertProperties[i * numProp + offset + strideIndex] = component.data![i * component.stride + strideIndex];\r\n }\r\n offset += component.stride;\r\n }\r\n }\r\n\r\n const manifoldMesh = new ManifoldMesh({ numProp: numProp, vertProperties, triVerts, runIndex, runOriginalID });\r\n manifoldMesh.merge();\r\n\r\n try {\r\n return new CSG2(new Manifold(manifoldMesh), numProp, structure);\r\n } catch (e) {\r\n throw new Error(\"Error while creating the CSG: \" + e.message);\r\n }\r\n }\r\n\r\n private static _Construct(data: IVertexDataLike, worldMatrix: Nullable<Matrix>, runIndex?: Uint32Array, runOriginalID?: Uint32Array) {\r\n // Create the MeshGL for I/O with Manifold library.\r\n const triVerts = new Uint32Array(data.indices!.length);\r\n\r\n // Revert order\r\n for (let i = 0; i < data.indices!.length; i += 3) {\r\n triVerts[i] = data.indices![i + 2];\r\n triVerts[i + 1] = data.indices![i + 1];\r\n triVerts[i + 2] = data.indices![i];\r\n }\r\n\r\n const tempVector3 = new Vector3();\r\n let numProp = 3;\r\n const structure: IManifoldVertexComponent[] = [{ stride: 3, kind: VertexBuffer.PositionKind }];\r\n\r\n if (!worldMatrix) {\r\n structure[0].data = data.positions!;\r\n } else {\r\n const positions = new Float32Array(data.positions!.length);\r\n for (let i = 0; i < data.positions!.length; i += 3) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(data.positions![i], data.positions![i + 1], data.positions![i + 2], worldMatrix, tempVector3);\r\n tempVector3.toArray(positions, i);\r\n }\r\n structure[0].data = positions;\r\n }\r\n\r\n // Normals\r\n const sourceNormals = data.normals!;\r\n if (sourceNormals) {\r\n numProp += 3;\r\n structure.push({ stride: 3, kind: VertexBuffer.NormalKind });\r\n if (!worldMatrix) {\r\n structure[1].data = sourceNormals;\r\n } else {\r\n const normals = new Float32Array(sourceNormals.length);\r\n for (let i = 0; i < sourceNormals.length; i += 3) {\r\n Vector3.TransformNormalFromFloatsToRef(sourceNormals[i], sourceNormals[i + 1], sourceNormals[i + 2], worldMatrix, tempVector3);\r\n tempVector3.toArray(normals, i);\r\n }\r\n structure[1].data = normals;\r\n }\r\n }\r\n\r\n // UVs\r\n for (const kind of [VertexBuffer.UVKind, VertexBuffer.UV2Kind, VertexBuffer.UV3Kind, VertexBuffer.UV4Kind, VertexBuffer.UV5Kind, VertexBuffer.UV6Kind]) {\r\n const sourceUV = (data as any)[kind === VertexBuffer.UVKind ? \"uvs\" : kind];\r\n if (sourceUV) {\r\n numProp += 2;\r\n structure.push({ stride: 2, kind: kind, data: sourceUV });\r\n }\r\n }\r\n\r\n // Colors\r\n const sourceColors = data.colors;\r\n if (sourceColors) {\r\n numProp += 4;\r\n structure.push({ stride: 4, kind: VertexBuffer.ColorKind, data: sourceColors });\r\n }\r\n\r\n return this._ProcessData(data.positions!.length / 3, triVerts, structure, numProp, runIndex, runOriginalID);\r\n }\r\n\r\n /**\r\n * Create a new Constructive Solid Geometry from a vertexData\r\n * @param vertexData defines the vertexData to use to create the CSG\r\n * @returns a new CSG2 class\r\n */\r\n public static FromVertexData(vertexData: VertexData): CSG2 {\r\n const sourceVertices = vertexData.positions;\r\n const sourceIndices = vertexData.indices;\r\n\r\n if (!sourceVertices || !sourceIndices) {\r\n throw new Error(\"The vertexData must at least have positions and indices\");\r\n }\r\n\r\n return this._Construct(vertexData, null);\r\n }\r\n\r\n /**\r\n * Create a new Constructive Solid Geometry from a mesh\r\n * @param mesh defines the mesh to use to create the CSG\r\n * @param ignoreWorldMatrix defines if the world matrix should be ignored\r\n * @returns a new CSG2 class\r\n */\r\n public static FromMesh(mesh: Mesh, ignoreWorldMatrix = false): any {\r\n const sourceVertices = mesh.getVerticesData(VertexBuffer.PositionKind);\r\n const sourceIndices = mesh.getIndices();\r\n const worldMatrix = mesh.computeWorldMatrix(true);\r\n\r\n if (!sourceVertices || !sourceIndices) {\r\n throw new Error(\"The mesh must at least have positions and indices\");\r\n }\r\n\r\n // Create a triangle run for each submesh (material)\r\n const starts = [...Array(mesh.subMeshes.length)].map((_, idx) => mesh.subMeshes[idx].indexStart);\r\n\r\n // Map the materials to ID.\r\n const sourceMaterial = mesh.material || mesh.getScene().defaultMaterial;\r\n const isMultiMaterial = sourceMaterial.getClassName() === \"MultiMaterial\";\r\n const originalIDs = [...Array(mesh.subMeshes.length)].map((_, idx) => {\r\n if (isMultiMaterial) {\r\n return FirstID + (sourceMaterial as MultiMaterial).subMaterials[mesh.subMeshes[idx].materialIndex]!.uniqueId;\r\n }\r\n\r\n return FirstID + sourceMaterial.uniqueId;\r\n });\r\n\r\n // List the runs in sequence.\r\n const indices = Array.from(starts.keys());\r\n indices.sort((a, b) => starts[a] - starts[b]);\r\n const runIndex = new Uint32Array(indices.map((i) => starts[i]));\r\n const runOriginalID = new Uint32Array(indices.map((i) => originalIDs[i]));\r\n\r\n // Process\r\n const data = {\r\n positions: sourceVertices,\r\n indices: sourceIndices,\r\n normals: mesh.getVerticesData(VertexBuffer.NormalKind),\r\n colors: mesh.getVerticesData(VertexBuffer.ColorKind),\r\n uvs: mesh.getVerticesData(VertexBuffer.UVKind),\r\n uvs2: mesh.getVerticesData(VertexBuffer.UV2Kind),\r\n uvs3: mesh.getVerticesData(VertexBuffer.UV3Kind),\r\n uvs4: mesh.getVerticesData(VertexBuffer.UV4Kind),\r\n uvs5: mesh.getVerticesData(VertexBuffer.UV5Kind),\r\n uvs6: mesh.getVerticesData(VertexBuffer.UV6Kind),\r\n };\r\n return this._Construct(data, ignoreWorldMatrix ? null : worldMatrix, runIndex, runOriginalID);\r\n }\r\n}\r\n\r\n/**\r\n * Checks if the Manifold library is ready\r\n * @returns true if the Manifold library is ready\r\n */\r\nexport function IsCSG2Ready() {\r\n return Manifold !== undefined;\r\n}\r\n\r\n/**\r\n * Initialize the Manifold library\r\n * @param options defines the options to use to initialize the library\r\n */\r\nexport async function InitializeCSG2Async(options?: Partial<ICSG2Options>) {\r\n const localOptions = {\r\n manifoldUrl: \"https://unpkg.com/manifold-3d@2.5.1\",\r\n ...options,\r\n };\r\n\r\n if (localOptions.manifoldInstance) {\r\n Manifold = localOptions.manifoldInstance;\r\n ManifoldMesh = localOptions.manifoldMeshInstance;\r\n } else {\r\n const result = await _LoadScriptModuleAsync(\r\n `\r\n import Module from '${localOptions.manifoldUrl}/manifold.js';\r\n const wasm = await Module();\r\n wasm.setup();\r\n const {Manifold, Mesh} = wasm;\r\n const returnedValue = {Manifold, Mesh};\r\n `\r\n );\r\n\r\n Manifold = result.Manifold;\r\n ManifoldMesh = result.Mesh;\r\n }\r\n\r\n // Reserve IDs for materials (we consider that there will be no more than 65536 materials)\r\n FirstID = Manifold.reserveIDs(65536);\r\n}\r\n"]}
package/Meshes/index.d.ts CHANGED
@@ -30,6 +30,7 @@ export * from "./WebGPU/webgpuDataBuffer";
30
30
  export * from "./GreasedLine/greasedLineMesh";
31
31
  export * from "./GreasedLine/greasedLineRibbonMesh";
32
32
  export * from "./GreasedLine/greasedLineBaseMesh";
33
+ export * from "./csg2";
33
34
  import "./thinInstanceMesh";
34
35
  export * from "./thinInstanceMesh";
35
36
  export * from "./Node/index";
package/Meshes/index.js CHANGED
@@ -32,6 +32,7 @@ export * from "./WebGPU/webgpuDataBuffer.js";
32
32
  export * from "./GreasedLine/greasedLineMesh.js";
33
33
  export * from "./GreasedLine/greasedLineRibbonMesh.js";
34
34
  export * from "./GreasedLine/greasedLineBaseMesh.js";
35
+ export * from "./csg2.js";
35
36
  import "./thinInstanceMesh.js";
36
37
  // eslint-disable-next-line no-duplicate-imports
37
38
  export * from "./thinInstanceMesh.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,+CAA+C;AAC/C,cAAc,gBAAgB,CAAC;AAC/B,OAAO,yBAAyB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,OAAO,CAAC;AACtB,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,OAAO,oBAAoB,CAAC;AAC5B,gDAAgD;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,2CAA2C,CAAC;AAE1D,WAAW;AACX,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAE5C,sBAAsB;AACtB,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,kDAAkD,CAAC;AACjE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,iDAAiD,CAAC;AAChE,cAAc,mDAAmD,CAAC;AAClE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC","sourcesContent":["/* eslint-disable import/export */\r\n/* eslint-disable import/no-internal-modules */\r\nexport * from \"./abstractMesh\";\r\nimport \"./abstractMesh.decalMap\";\r\nexport * from \"./abstractMesh.hotSpot\";\r\nexport * from \"./Compression/index\";\r\nexport * from \"./csg\";\r\nexport * from \"./meshUVSpaceRenderer\";\r\nexport * from \"./geometry\";\r\nexport * from \"./groundMesh\";\r\nexport * from \"./goldbergMesh\";\r\nexport * from \"./trailMesh\";\r\nexport * from \"./instancedMesh\";\r\nexport * from \"./linesMesh\";\r\nexport * from \"./mesh\";\r\nexport * from \"./mesh.vertexData\";\r\nexport * from \"./meshBuilder\";\r\nexport * from \"./meshSimplification\";\r\nexport * from \"./meshSimplificationSceneComponent\";\r\nexport * from \"./meshUtils\";\r\nexport * from \"./polygonMesh\";\r\nexport * from \"./geodesicMesh\";\r\nexport * from \"./subMesh\";\r\nexport * from \"./subMesh.project\";\r\nexport * from \"./lattice\";\r\nexport * from \"./lattice.material\";\r\nexport * from \"./meshLODLevel\";\r\nexport * from \"./transformNode\";\r\nexport * from \"./Builders/index\";\r\nexport * from \"./WebGL/webGLDataBuffer\";\r\nexport * from \"./WebGPU/webgpuDataBuffer\";\r\nexport * from \"./GreasedLine/greasedLineMesh\";\r\nexport * from \"./GreasedLine/greasedLineRibbonMesh\";\r\nexport * from \"./GreasedLine/greasedLineBaseMesh\";\r\nimport \"./thinInstanceMesh\";\r\n// eslint-disable-next-line no-duplicate-imports\r\nexport * from \"./thinInstanceMesh\";\r\nexport * from \"./Node/index\";\r\nexport * from \"./GaussianSplatting/gaussianSplattingMesh\";\r\n\r\n// LineMesh\r\nexport * from \"../Shaders/color.fragment\";\r\nexport * from \"../Shaders/color.vertex\";\r\nexport * from \"../ShadersWGSL/color.fragment\";\r\nexport * from \"../ShadersWGSL/color.vertex\";\r\n\r\n// MeshUVSPaceRenderer\r\nexport * from \"../Shaders/meshUVSpaceRenderer.vertex\";\r\nexport * from \"../Shaders/meshUVSpaceRenderer.fragment\";\r\nexport * from \"../Shaders/meshUVSpaceRendererMasker.vertex\";\r\nexport * from \"../Shaders/meshUVSpaceRendererMasker.fragment\";\r\nexport * from \"../Shaders/meshUVSpaceRendererFinaliser.fragment\";\r\nexport * from \"../Shaders/meshUVSpaceRendererFinaliser.vertex\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRenderer.vertex\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRenderer.fragment\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererMasker.vertex\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererMasker.fragment\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererFinaliser.fragment\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererFinaliser.vertex\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,+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AAC;AAC9D,cAAc,kDAAkD,CAAC;AACjE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,iDAAiD,CAAC;AAChE,cAAc,mDAAmD,CAAC;AAClE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC","sourcesContent":["/* eslint-disable import/export */\r\n/* eslint-disable import/no-internal-modules */\r\nexport * from \"./abstractMesh\";\r\nimport \"./abstractMesh.decalMap\";\r\nexport * from \"./abstractMesh.hotSpot\";\r\nexport * from \"./Compression/index\";\r\nexport * from \"./csg\";\r\nexport * from \"./meshUVSpaceRenderer\";\r\nexport * from \"./geometry\";\r\nexport * from \"./groundMesh\";\r\nexport * from \"./goldbergMesh\";\r\nexport * from \"./trailMesh\";\r\nexport * from \"./instancedMesh\";\r\nexport * from \"./linesMesh\";\r\nexport * from \"./mesh\";\r\nexport * from \"./mesh.vertexData\";\r\nexport * from \"./meshBuilder\";\r\nexport * from \"./meshSimplification\";\r\nexport * from \"./meshSimplificationSceneComponent\";\r\nexport * from \"./meshUtils\";\r\nexport * from \"./polygonMesh\";\r\nexport * from \"./geodesicMesh\";\r\nexport * from \"./subMesh\";\r\nexport * from \"./subMesh.project\";\r\nexport * from \"./lattice\";\r\nexport * from \"./lattice.material\";\r\nexport * from \"./meshLODLevel\";\r\nexport * from \"./transformNode\";\r\nexport * from \"./Builders/index\";\r\nexport * from \"./WebGL/webGLDataBuffer\";\r\nexport * from \"./WebGPU/webgpuDataBuffer\";\r\nexport * from \"./GreasedLine/greasedLineMesh\";\r\nexport * from \"./GreasedLine/greasedLineRibbonMesh\";\r\nexport * from \"./GreasedLine/greasedLineBaseMesh\";\r\nexport * from \"./csg2\";\r\nimport \"./thinInstanceMesh\";\r\n// eslint-disable-next-line no-duplicate-imports\r\nexport * from \"./thinInstanceMesh\";\r\nexport * from \"./Node/index\";\r\nexport * from \"./GaussianSplatting/gaussianSplattingMesh\";\r\n\r\n// LineMesh\r\nexport * from \"../Shaders/color.fragment\";\r\nexport * from \"../Shaders/color.vertex\";\r\nexport * from \"../ShadersWGSL/color.fragment\";\r\nexport * from \"../ShadersWGSL/color.vertex\";\r\n\r\n// MeshUVSPaceRenderer\r\nexport * from \"../Shaders/meshUVSpaceRenderer.vertex\";\r\nexport * from \"../Shaders/meshUVSpaceRenderer.fragment\";\r\nexport * from \"../Shaders/meshUVSpaceRendererMasker.vertex\";\r\nexport * from \"../Shaders/meshUVSpaceRendererMasker.fragment\";\r\nexport * from \"../Shaders/meshUVSpaceRendererFinaliser.fragment\";\r\nexport * from \"../Shaders/meshUVSpaceRendererFinaliser.vertex\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRenderer.vertex\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRenderer.fragment\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererMasker.vertex\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererMasker.fragment\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererFinaliser.fragment\";\r\nexport * from \"../ShadersWGSL/meshUVSpaceRendererFinaliser.vertex\";\r\n"]}
package/Meshes/mesh.js CHANGED
@@ -3010,7 +3010,9 @@ export class Mesh extends AbstractMesh {
3010
3010
  * @returns a new InstancedMesh
3011
3011
  */
3012
3012
  createInstance(name) {
3013
- return Mesh._instancedMeshFactory(name, this);
3013
+ const instance = Mesh._instancedMeshFactory(name, this);
3014
+ instance.parent = this.parent;
3015
+ return instance;
3014
3016
  }
3015
3017
  /**
3016
3018
  * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.