@babylonjs/core 5.11.0 → 5.13.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.
- package/Bones/skeleton.d.ts +1 -1
- package/Bones/skeleton.js +4 -4
- package/Bones/skeleton.js.map +1 -1
- package/Cameras/camera.js +5 -1
- package/Cameras/camera.js.map +1 -1
- package/Debug/boneAxesViewer.js +0 -1
- package/Debug/boneAxesViewer.js.map +1 -1
- package/DeviceInput/InputDevices/webDeviceInputSystem.d.ts +2 -0
- package/DeviceInput/InputDevices/webDeviceInputSystem.js +26 -3
- package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js +16 -3
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.query.js +1 -1
- package/Engines/Extensions/engine.query.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +64 -8
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/ICanvas.d.ts +5 -0
- package/Engines/ICanvas.js.map +1 -1
- package/Engines/WebGPU/webgpuConstants.d.ts +1 -1
- package/Engines/WebGPU/webgpuConstants.js +5 -5
- package/Engines/WebGPU/webgpuConstants.js.map +1 -1
- package/Engines/engine.d.ts +3 -2
- package/Engines/nativeEngine.d.ts +1 -1
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.d.ts +1 -1
- package/Engines/nullEngine.js +1 -1
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +2 -2
- package/Engines/thinEngine.js +12 -9
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +1 -1
- package/Engines/webgpuEngine.js +1 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/Events/deviceInputEvents.d.ts +1 -1
- package/Events/deviceInputEvents.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js +0 -5
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Lights/light.js +4 -1
- package/Lights/light.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +33 -8
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +2 -1
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.d.ts +3 -3
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.js +4 -4
- package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.js +2 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +6 -1
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseSimpleMaterial.d.ts +1 -1
- package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.d.ts +1 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
- package/Materials/PBR/pbrSpecularGlossinessMaterial.d.ts +1 -1
- package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
- package/Materials/Textures/texture.d.ts +1 -1
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/effect.d.ts +5 -0
- package/Materials/effect.js +5 -0
- package/Materials/effect.js.map +1 -1
- package/Materials/material.js +1 -0
- package/Materials/material.js.map +1 -1
- package/Materials/materialPluginBase.d.ts +3 -1
- package/Materials/materialPluginBase.js +3 -1
- package/Materials/materialPluginBase.js.map +1 -1
- package/Materials/materialPluginEvent.d.ts +1 -0
- package/Materials/materialPluginEvent.js.map +1 -1
- package/Materials/materialPluginManager.js +1 -1
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +17 -2
- package/Materials/shaderMaterial.js +65 -4
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.js +5 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Maths/math.vector.d.ts +7 -0
- package/Maths/math.vector.js +43 -11
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/shapeBuilder.d.ts +12 -0
- package/Meshes/Builders/shapeBuilder.js +48 -10
- package/Meshes/Builders/shapeBuilder.js.map +1 -1
- package/Meshes/instancedMesh.d.ts +5 -0
- package/Meshes/instancedMesh.js +9 -0
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.js +9 -3
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/transformNode.js +4 -5
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/iInspectable.d.ts +1 -1
- package/Misc/iInspectable.js.map +1 -1
- package/Misc/screenshotTools.js +31 -14
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/tools.d.ts +16 -0
- package/Misc/tools.js +44 -30
- package/Misc/tools.js.map +1 -1
- package/Rendering/depthRenderer.js +28 -0
- package/Rendering/depthRenderer.js.map +1 -1
- package/Shaders/depth.fragment.d.ts +2 -0
- package/Shaders/depth.fragment.js +3 -1
- package/Shaders/depth.fragment.js.map +1 -1
- package/Shaders/depth.vertex.d.ts +2 -0
- package/Shaders/depth.vertex.js +3 -1
- package/Shaders/depth.vertex.js.map +1 -1
- package/XR/webXRCamera.js +11 -0
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRExperienceHelper.js +2 -1
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/node.d.ts +7 -0
- package/node.js +9 -0
- package/node.js.map +1 -1
- package/package.json +2 -2
|
@@ -18,6 +18,8 @@ import { Mesh } from "../mesh";
|
|
|
18
18
|
* * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
|
|
19
19
|
* * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
|
|
20
20
|
* * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
|
|
21
|
+
* * The optional parameter `firstNormal` (Vector3) defines the direction of the first normal of the supplied path. Consider using this for any path that is straight, and particular for paths in the xy plane.
|
|
22
|
+
* * The optional `adjustFrame` (boolean, default false) will cause the internally generated Path3D tangents, normals, and binormals to be adjusted so that a) they are always well-defined, and b) they do not reverse from one path point to the next. This prevents the extruded shape from being flipped and/or rotated with resulting mesh self-intersections. This is primarily useful for straight paths that can reverse direction.
|
|
21
23
|
* @param name defines the name of the mesh
|
|
22
24
|
* @param options defines the options used to create the mesh
|
|
23
25
|
* @param options.shape
|
|
@@ -33,6 +35,8 @@ import { Mesh } from "../mesh";
|
|
|
33
35
|
* @param options.backUVs
|
|
34
36
|
* @param options.instance
|
|
35
37
|
* @param options.invertUV
|
|
38
|
+
* @param options.firstNormal
|
|
39
|
+
* @param options.adjustFrame
|
|
36
40
|
* @param scene defines the hosting scene
|
|
37
41
|
* @returns the extruded shape mesh
|
|
38
42
|
* @see https://doc.babylonjs.com/how_to/parametric_shapes
|
|
@@ -52,6 +56,8 @@ export declare function ExtrudeShape(name: string, options: {
|
|
|
52
56
|
backUVs?: Vector4;
|
|
53
57
|
instance?: Mesh;
|
|
54
58
|
invertUV?: boolean;
|
|
59
|
+
firstNormal?: Vector3;
|
|
60
|
+
adjustFrame?: boolean;
|
|
55
61
|
}, scene?: Nullable<Scene>): Mesh;
|
|
56
62
|
/**
|
|
57
63
|
* Creates an custom extruded shape mesh.
|
|
@@ -73,6 +79,8 @@ export declare function ExtrudeShape(name: string, options: {
|
|
|
73
79
|
* * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
|
|
74
80
|
* * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
|
|
75
81
|
* * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
|
|
82
|
+
* * The optional parameter `firstNormal` (Vector3) defines the direction of the first normal of the supplied path. It should be supplied when the path is in the xy plane, and particularly if these sections are straight, because the underlying Path3D object will pick a normal in the xy plane that causes the extrusion to be collapsed into the plane. This should be used for any path that is straight.
|
|
83
|
+
* * The optional `adjustFrame` (boolean, default false) will cause the internally generated Path3D tangents, normals, and binormals to be adjusted so that a) they are always well-defined, and b) they do not reverse from one path point to the next. This prevents the extruded shape from being flipped and/or rotated with resulting mesh self-intersections. This is primarily useful for straight paths that can reverse direction.
|
|
76
84
|
* @param name defines the name of the mesh
|
|
77
85
|
* @param options defines the options used to create the mesh
|
|
78
86
|
* @param options.shape
|
|
@@ -90,6 +98,8 @@ export declare function ExtrudeShape(name: string, options: {
|
|
|
90
98
|
* @param options.backUVs
|
|
91
99
|
* @param options.instance
|
|
92
100
|
* @param options.invertUV
|
|
101
|
+
* @param options.firstNormal
|
|
102
|
+
* @param options.adjustFrame
|
|
93
103
|
* @param scene defines the hosting scene
|
|
94
104
|
* @returns the custom extruded shape mesh
|
|
95
105
|
* @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
|
|
@@ -116,6 +126,8 @@ export declare function ExtrudeShapeCustom(name: string, options: {
|
|
|
116
126
|
backUVs?: Vector4;
|
|
117
127
|
instance?: Mesh;
|
|
118
128
|
invertUV?: boolean;
|
|
129
|
+
firstNormal?: Vector3;
|
|
130
|
+
adjustFrame?: boolean;
|
|
119
131
|
}, scene?: Nullable<Scene>): Mesh;
|
|
120
132
|
/**
|
|
121
133
|
* Class containing static functions to help procedurally build meshes
|
|
@@ -17,6 +17,8 @@ import { Path3D } from "../../Maths/math.path.js";
|
|
|
17
17
|
* * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
|
|
18
18
|
* * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
|
|
19
19
|
* * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
|
|
20
|
+
* * The optional parameter `firstNormal` (Vector3) defines the direction of the first normal of the supplied path. Consider using this for any path that is straight, and particular for paths in the xy plane.
|
|
21
|
+
* * The optional `adjustFrame` (boolean, default false) will cause the internally generated Path3D tangents, normals, and binormals to be adjusted so that a) they are always well-defined, and b) they do not reverse from one path point to the next. This prevents the extruded shape from being flipped and/or rotated with resulting mesh self-intersections. This is primarily useful for straight paths that can reverse direction.
|
|
20
22
|
* @param name defines the name of the mesh
|
|
21
23
|
* @param options defines the options used to create the mesh
|
|
22
24
|
* @param options.shape
|
|
@@ -32,6 +34,8 @@ import { Path3D } from "../../Maths/math.path.js";
|
|
|
32
34
|
* @param options.backUVs
|
|
33
35
|
* @param options.instance
|
|
34
36
|
* @param options.invertUV
|
|
37
|
+
* @param options.firstNormal
|
|
38
|
+
* @param options.adjustFrame
|
|
35
39
|
* @param scene defines the hosting scene
|
|
36
40
|
* @returns the extruded shape mesh
|
|
37
41
|
* @see https://doc.babylonjs.com/how_to/parametric_shapes
|
|
@@ -50,7 +54,7 @@ export function ExtrudeShape(name, options, scene) {
|
|
|
50
54
|
var invertUV = options.invertUV || false;
|
|
51
55
|
var closeShape = options.closeShape || false;
|
|
52
56
|
var closePath = options.closePath || false;
|
|
53
|
-
return _ExtrudeShapeGeneric(name, shape, path, scale, rotation, null, null, closePath, closeShape, cap, false, scene, updatable ? true : false, sideOrientation, instance, invertUV, options.frontUVs || null, options.backUVs || null);
|
|
57
|
+
return _ExtrudeShapeGeneric(name, shape, path, scale, rotation, null, null, closePath, closeShape, cap, false, scene, updatable ? true : false, sideOrientation, instance, invertUV, options.frontUVs || null, options.backUVs || null, options.firstNormal || null, options.adjustFrame ? true : false);
|
|
54
58
|
}
|
|
55
59
|
/**
|
|
56
60
|
* Creates an custom extruded shape mesh.
|
|
@@ -72,6 +76,8 @@ export function ExtrudeShape(name, options, scene) {
|
|
|
72
76
|
* * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
|
|
73
77
|
* * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
|
|
74
78
|
* * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
|
|
79
|
+
* * The optional parameter `firstNormal` (Vector3) defines the direction of the first normal of the supplied path. It should be supplied when the path is in the xy plane, and particularly if these sections are straight, because the underlying Path3D object will pick a normal in the xy plane that causes the extrusion to be collapsed into the plane. This should be used for any path that is straight.
|
|
80
|
+
* * The optional `adjustFrame` (boolean, default false) will cause the internally generated Path3D tangents, normals, and binormals to be adjusted so that a) they are always well-defined, and b) they do not reverse from one path point to the next. This prevents the extruded shape from being flipped and/or rotated with resulting mesh self-intersections. This is primarily useful for straight paths that can reverse direction.
|
|
75
81
|
* @param name defines the name of the mesh
|
|
76
82
|
* @param options defines the options used to create the mesh
|
|
77
83
|
* @param options.shape
|
|
@@ -89,6 +95,8 @@ export function ExtrudeShape(name, options, scene) {
|
|
|
89
95
|
* @param options.backUVs
|
|
90
96
|
* @param options.instance
|
|
91
97
|
* @param options.invertUV
|
|
98
|
+
* @param options.firstNormal
|
|
99
|
+
* @param options.adjustFrame
|
|
92
100
|
* @param scene defines the hosting scene
|
|
93
101
|
* @returns the custom extruded shape mesh
|
|
94
102
|
* @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
|
|
@@ -111,18 +119,48 @@ export function ExtrudeShapeCustom(name, options, scene) {
|
|
|
111
119
|
var ribbonClosePath = options.closeShape || options.ribbonClosePath || false;
|
|
112
120
|
var cap = options.cap === 0 ? 0 : options.cap || Mesh.NO_CAP;
|
|
113
121
|
var updatable = options.updatable;
|
|
122
|
+
var firstNormal = options.firstNormal || null;
|
|
123
|
+
var adjustFrame = options.adjustFrame || false;
|
|
114
124
|
var sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);
|
|
115
125
|
var instance = options.instance;
|
|
116
126
|
var invertUV = options.invertUV || false;
|
|
117
|
-
return _ExtrudeShapeGeneric(name, shape, path, null, null, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, true, scene, updatable ? true : false, sideOrientation, instance || null, invertUV, options.frontUVs || null, options.backUVs || null);
|
|
127
|
+
return _ExtrudeShapeGeneric(name, shape, path, null, null, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, true, scene, updatable ? true : false, sideOrientation, instance || null, invertUV, options.frontUVs || null, options.backUVs || null, firstNormal, adjustFrame);
|
|
118
128
|
}
|
|
119
|
-
function _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
|
|
129
|
+
function _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs, firstNormal, adjustFrame) {
|
|
120
130
|
// extrusion geometry
|
|
121
|
-
var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
|
|
131
|
+
var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom, adjustFrame) {
|
|
122
132
|
var tangents = path3D.getTangents();
|
|
123
133
|
var normals = path3D.getNormals();
|
|
124
134
|
var binormals = path3D.getBinormals();
|
|
125
135
|
var distances = path3D.getDistances();
|
|
136
|
+
if (adjustFrame) {
|
|
137
|
+
/* fix tangents,normals, binormals */
|
|
138
|
+
for (var i = 0; i < tangents.length; i++) {
|
|
139
|
+
if (tangents[i].x == 0 && tangents[i].y == 0 && tangents[i].z == 0) {
|
|
140
|
+
tangents[i].copyFrom(tangents[i - 1]);
|
|
141
|
+
}
|
|
142
|
+
if (normals[i].x == 0 && normals[i].y == 0 && normals[i].z == 0) {
|
|
143
|
+
normals[i].copyFrom(normals[i - 1]);
|
|
144
|
+
}
|
|
145
|
+
if (binormals[i].x == 0 && binormals[i].y == 0 && binormals[i].z == 0) {
|
|
146
|
+
binormals[i].copyFrom(binormals[i - 1]);
|
|
147
|
+
}
|
|
148
|
+
if (i > 0) {
|
|
149
|
+
var v = tangents[i - 1];
|
|
150
|
+
if (Vector3.Dot(v, tangents[i]) < 0) {
|
|
151
|
+
tangents[i].scaleInPlace(-1);
|
|
152
|
+
}
|
|
153
|
+
v = normals[i - 1];
|
|
154
|
+
if (Vector3.Dot(v, normals[i]) < 0) {
|
|
155
|
+
normals[i].scaleInPlace(-1);
|
|
156
|
+
}
|
|
157
|
+
v = binormals[i - 1];
|
|
158
|
+
if (Vector3.Dot(v, binormals[i]) < 0) {
|
|
159
|
+
binormals[i].scaleInPlace(-1);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
126
164
|
var angle = 0;
|
|
127
165
|
var returnScale = function () {
|
|
128
166
|
return scale !== null ? scale : 1;
|
|
@@ -138,10 +176,10 @@ function _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction
|
|
|
138
176
|
var shapePath = new Array();
|
|
139
177
|
var angleStep = rotate(i, distances[i]);
|
|
140
178
|
var scaleRatio = scl(i, distances[i]);
|
|
179
|
+
Matrix.RotationAxisToRef(tangents[i], angle, rotationMatrix);
|
|
141
180
|
for (var p = 0; p < shape.length; p++) {
|
|
142
|
-
Matrix.RotationAxisToRef(tangents[i], angle, rotationMatrix);
|
|
143
181
|
var planed = tangents[i].scale(shape[p].z).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y));
|
|
144
|
-
var rotated =
|
|
182
|
+
var rotated = Vector3.Zero();
|
|
145
183
|
Vector3.TransformCoordinatesToRef(planed, rotationMatrix, rotated);
|
|
146
184
|
rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
|
|
147
185
|
shapePath[p] = rotated;
|
|
@@ -191,16 +229,16 @@ function _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction
|
|
|
191
229
|
if (instance) {
|
|
192
230
|
// instance update
|
|
193
231
|
var storage = instance._creationDataStorage;
|
|
194
|
-
path3D = storage.path3D.update(curve);
|
|
195
|
-
pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
|
|
232
|
+
path3D = firstNormal ? storage.path3D.update(curve, firstNormal) : storage.path3D.update(curve);
|
|
233
|
+
pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom, adjustFrame);
|
|
196
234
|
instance = CreateRibbon("", { pathArray: pathArray, closeArray: false, closePath: false, offset: 0, updatable: false, sideOrientation: 0, instance: instance }, scene || undefined);
|
|
197
235
|
return instance;
|
|
198
236
|
}
|
|
199
237
|
// extruded shape creation
|
|
200
|
-
path3D = new Path3D(curve);
|
|
238
|
+
path3D = firstNormal ? new Path3D(curve, firstNormal) : new Path3D(curve);
|
|
201
239
|
var newShapePaths = new Array();
|
|
202
240
|
cap = cap < 0 || cap > 3 ? 0 : cap;
|
|
203
|
-
pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
|
|
241
|
+
pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom, adjustFrame);
|
|
204
242
|
var extrudedGeneric = CreateRibbon(name, {
|
|
205
243
|
pathArray: pathArray,
|
|
206
244
|
closeArray: rbCA,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shapeBuilder.js","sourceRoot":"","sources":["../../../../../../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AAe;QAChC,QAAQ,EAAE,QAAQ;QAClB,SAAS,EAAE,SAAS;KACvB,CAAC;IAEF,OAAO,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Vector4 } from \"../../Maths/math.vector\";\r\nimport { Vector3, TmpVectors, Matrix } from \"../../Maths/math.vector\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { CreateRibbon } from \"./ribbonBuilder\";\r\nimport { Path3D } from \"../../Maths/math.path\";\r\n\r\n/**\r\n * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.\r\n * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.\r\n * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.\r\n * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.\r\n * * The parameter `scale` (float, default 1) is the value to scale the shape.\r\n * * The parameter `closeShape` (boolean, default false) closes the shape when true, since v5.0.0.\r\n * * The parameter `closePath` (boolean, default false) closes the path when true and no caps, since v5.0.0.\r\n * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL\r\n * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape\r\n * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.\r\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation\r\n * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param options.shape\r\n * @param options.path\r\n * @param options.scale\r\n * @param options.rotation\r\n * @param options.closeShape\r\n * @param options.closePath\r\n * @param options.cap\r\n * @param options.updatable\r\n * @param options.sideOrientation\r\n * @param options.frontUVs\r\n * @param options.backUVs\r\n * @param options.instance\r\n * @param options.invertUV\r\n * @param scene defines the hosting scene\r\n * @returns the extruded shape mesh\r\n * @see https://doc.babylonjs.com/how_to/parametric_shapes\r\n * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes\r\n */\r\nexport function ExtrudeShape(\r\n name: string,\r\n options: {\r\n shape: Vector3[];\r\n path: Vector3[];\r\n scale?: number;\r\n rotation?: number;\r\n closeShape?: boolean;\r\n closePath?: boolean;\r\n cap?: number;\r\n updatable?: boolean;\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n instance?: Mesh;\r\n invertUV?: boolean;\r\n },\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const path = options.path;\r\n const shape = options.shape;\r\n const scale = options.scale || 1;\r\n const rotation = options.rotation || 0;\r\n const cap = options.cap === 0 ? 0 : options.cap || Mesh.NO_CAP;\r\n const updatable = options.updatable;\r\n const sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n const instance = options.instance || null;\r\n const invertUV = options.invertUV || false;\r\n const closeShape = options.closeShape || false;\r\n const closePath = options.closePath || false;\r\n\r\n return _ExtrudeShapeGeneric(\r\n name,\r\n shape,\r\n path,\r\n scale,\r\n rotation,\r\n null,\r\n null,\r\n closePath,\r\n closeShape,\r\n cap,\r\n false,\r\n scene,\r\n updatable ? true : false,\r\n sideOrientation,\r\n instance,\r\n invertUV,\r\n options.frontUVs || null,\r\n options.backUVs || null\r\n );\r\n}\r\n\r\n/**\r\n * Creates an custom extruded shape mesh.\r\n * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.\r\n * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.\r\n * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.\r\n * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the beginning of the path\r\n * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.\r\n * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the beginning of the path\r\n * * It must returns a float value that will be the scale value applied to the shape on each path point\r\n * * The parameter `closeShape` (boolean, default false) closes the shape when true, since v5.0.0.\r\n * * The parameter `closePath` (boolean, default false) closes the path when true and no caps, since v5.0.0.\r\n * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray` - depreciated in favor of closeShape\r\n * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray` - depreciated in favor of closePath\r\n * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL\r\n * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape\r\n * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape\r\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation\r\n * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param options.shape\r\n * @param options.path\r\n * @param options.scaleFunction\r\n * @param options.rotationFunction\r\n * @param options.ribbonCloseArray\r\n * @param options.ribbonClosePath\r\n * @param options.closeShape\r\n * @param options.closePath\r\n * @param options.cap\r\n * @param options.updatable\r\n * @param options.sideOrientation\r\n * @param options.frontUVs\r\n * @param options.backUVs\r\n * @param options.instance\r\n * @param options.invertUV\r\n * @param scene defines the hosting scene\r\n * @returns the custom extruded shape mesh\r\n * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes\r\n * @see https://doc.babylonjs.com/how_to/parametric_shapes\r\n * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes\r\n */\r\nexport function ExtrudeShapeCustom(\r\n name: string,\r\n options: {\r\n shape: Vector3[];\r\n path: Vector3[];\r\n scaleFunction?: Nullable<{ (i: number, distance: number): number }>;\r\n rotationFunction?: Nullable<{ (i: number, distance: number): number }>;\r\n ribbonCloseArray?: boolean;\r\n ribbonClosePath?: boolean;\r\n closeShape?: boolean;\r\n closePath?: boolean;\r\n cap?: number;\r\n updatable?: boolean;\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n instance?: Mesh;\r\n invertUV?: boolean;\r\n },\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const path = options.path;\r\n const shape = options.shape;\r\n const scaleFunction =\r\n options.scaleFunction ||\r\n (() => {\r\n return 1;\r\n });\r\n const rotationFunction =\r\n options.rotationFunction ||\r\n (() => {\r\n return 0;\r\n });\r\n const ribbonCloseArray = options.closePath || options.ribbonCloseArray || false;\r\n const ribbonClosePath = options.closeShape || options.ribbonClosePath || false;\r\n const cap = options.cap === 0 ? 0 : options.cap || Mesh.NO_CAP;\r\n const updatable = options.updatable;\r\n const sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n const instance = options.instance;\r\n const invertUV = options.invertUV || false;\r\n return _ExtrudeShapeGeneric(\r\n name,\r\n shape,\r\n path,\r\n null,\r\n null,\r\n scaleFunction,\r\n rotationFunction,\r\n ribbonCloseArray,\r\n ribbonClosePath,\r\n cap,\r\n true,\r\n scene,\r\n updatable ? true : false,\r\n sideOrientation,\r\n instance || null,\r\n invertUV,\r\n options.frontUVs || null,\r\n options.backUVs || null\r\n );\r\n}\r\n\r\nfunction _ExtrudeShapeGeneric(\r\n name: string,\r\n shape: Vector3[],\r\n curve: Vector3[],\r\n scale: Nullable<number>,\r\n rotation: Nullable<number>,\r\n scaleFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rotateFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rbCA: boolean,\r\n rbCP: boolean,\r\n cap: number,\r\n custom: boolean,\r\n scene: Nullable<Scene>,\r\n updtbl: boolean,\r\n side: number,\r\n instance: Nullable<Mesh>,\r\n invertUV: boolean,\r\n frontUVs: Nullable<Vector4>,\r\n backUVs: Nullable<Vector4>\r\n): Mesh {\r\n // extrusion geometry\r\n const extrusionPathArray = (\r\n shape: Vector3[],\r\n curve: Vector3[],\r\n path3D: Path3D,\r\n shapePaths: Vector3[][],\r\n scale: Nullable<number>,\r\n rotation: Nullable<number>,\r\n scaleFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rotateFunction: Nullable<{ (i: number, distance: number): number }>,\r\n cap: number,\r\n custom: boolean\r\n ) => {\r\n const tangents = path3D.getTangents();\r\n const normals = path3D.getNormals();\r\n const binormals = path3D.getBinormals();\r\n const distances = path3D.getDistances();\r\n\r\n let angle = 0;\r\n const returnScale = () => {\r\n return scale !== null ? scale : 1;\r\n };\r\n const returnRotation = () => {\r\n return rotation !== null ? rotation : 0;\r\n };\r\n const rotate: { (i: number, distance: number): number } = custom && rotateFunction ? rotateFunction : returnRotation;\r\n const scl: { (i: number, distance: number): number } = custom && scaleFunction ? scaleFunction : returnScale;\r\n let index = cap === Mesh.NO_CAP || cap === Mesh.CAP_END ? 0 : 2;\r\n const rotationMatrix: Matrix = TmpVectors.Matrix[0];\r\n\r\n for (let i = 0; i < curve.length; i++) {\r\n const shapePath = new Array<Vector3>();\r\n const angleStep = rotate(i, distances[i]);\r\n const scaleRatio = scl(i, distances[i]);\r\n for (let p = 0; p < shape.length; p++) {\r\n Matrix.RotationAxisToRef(tangents[i], angle, rotationMatrix);\r\n const planed = tangents[i].scale(shape[p].z).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y));\r\n const rotated = shapePath[p] ? shapePath[p] : Vector3.Zero();\r\n Vector3.TransformCoordinatesToRef(planed, rotationMatrix, rotated);\r\n rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);\r\n shapePath[p] = rotated;\r\n }\r\n shapePaths[index] = shapePath;\r\n angle += angleStep;\r\n index++;\r\n }\r\n // cap\r\n const capPath = (shapePath: Vector3[]) => {\r\n const pointCap = Array<Vector3>();\r\n const barycenter = Vector3.Zero();\r\n let i: number;\r\n for (i = 0; i < shapePath.length; i++) {\r\n barycenter.addInPlace(shapePath[i]);\r\n }\r\n barycenter.scaleInPlace(1.0 / shapePath.length);\r\n for (i = 0; i < shapePath.length; i++) {\r\n pointCap.push(barycenter);\r\n }\r\n return pointCap;\r\n };\r\n switch (cap) {\r\n case Mesh.NO_CAP:\r\n break;\r\n case Mesh.CAP_START:\r\n shapePaths[0] = capPath(shapePaths[2]);\r\n shapePaths[1] = shapePaths[2];\r\n break;\r\n case Mesh.CAP_END:\r\n shapePaths[index] = shapePaths[index - 1];\r\n shapePaths[index + 1] = capPath(shapePaths[index - 1]);\r\n break;\r\n case Mesh.CAP_ALL:\r\n shapePaths[0] = capPath(shapePaths[2]);\r\n shapePaths[1] = shapePaths[2];\r\n shapePaths[index] = shapePaths[index - 1];\r\n shapePaths[index + 1] = capPath(shapePaths[index - 1]);\r\n break;\r\n default:\r\n break;\r\n }\r\n return shapePaths;\r\n };\r\n let path3D;\r\n let pathArray;\r\n if (instance) {\r\n // instance update\r\n const storage = instance._creationDataStorage!;\r\n path3D = storage.path3D.update(curve);\r\n pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);\r\n instance = CreateRibbon(\"\", { pathArray, closeArray: false, closePath: false, offset: 0, updatable: false, sideOrientation: 0, instance }, scene || undefined);\r\n\r\n return instance;\r\n }\r\n // extruded shape creation\r\n path3D = <any>new Path3D(curve);\r\n const newShapePaths = new Array<Array<Vector3>>();\r\n cap = cap < 0 || cap > 3 ? 0 : cap;\r\n pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);\r\n const extrudedGeneric = CreateRibbon(\r\n name,\r\n {\r\n pathArray: pathArray,\r\n closeArray: rbCA,\r\n closePath: rbCP,\r\n updatable: updtbl,\r\n sideOrientation: side,\r\n invertUV: invertUV,\r\n frontUVs: frontUVs || undefined,\r\n backUVs: backUVs || undefined,\r\n },\r\n scene\r\n );\r\n extrudedGeneric._creationDataStorage!.pathArray = pathArray;\r\n extrudedGeneric._creationDataStorage!.path3D = path3D;\r\n extrudedGeneric._creationDataStorage!.cap = cap;\r\n\r\n return extrudedGeneric;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated please use the functions directly from the module\r\n */\r\nexport const ShapeBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ExtrudeShape,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ExtrudeShapeCustom,\r\n};\r\n\r\n(Mesh as any).ExtrudeShape = (\r\n name: string,\r\n shape: Vector3[],\r\n path: Vector3[],\r\n scale: number,\r\n rotation: number,\r\n cap: number,\r\n scene: Nullable<Scene> = null,\r\n updatable?: boolean,\r\n sideOrientation?: number,\r\n instance?: Mesh\r\n): Mesh => {\r\n const options = {\r\n shape: shape,\r\n path: path,\r\n scale: scale,\r\n rotation: rotation,\r\n cap: cap === 0 ? 0 : cap || Mesh.NO_CAP,\r\n sideOrientation: sideOrientation,\r\n instance: instance,\r\n updatable: updatable,\r\n };\r\n\r\n return ExtrudeShape(name, options, scene);\r\n};\r\n\r\n(Mesh as any).ExtrudeShapeCustom = (\r\n name: string,\r\n shape: Vector3[],\r\n path: Vector3[],\r\n scaleFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rotationFunction: Nullable<{ (i: number, distance: number): number }>,\r\n ribbonCloseArray: boolean,\r\n ribbonClosePath: boolean,\r\n cap: number,\r\n scene: Scene,\r\n updatable?: boolean,\r\n sideOrientation?: number,\r\n instance?: Mesh\r\n): Mesh => {\r\n const options = {\r\n shape: shape,\r\n path: path,\r\n scaleFunction: scaleFunction,\r\n rotationFunction: rotationFunction,\r\n ribbonCloseArray: ribbonCloseArray,\r\n ribbonClosePath: ribbonClosePath,\r\n cap: cap === 0 ? 0 : cap || Mesh.NO_CAP,\r\n sideOrientation: sideOrientation,\r\n instance: instance,\r\n updatable: updatable,\r\n };\r\n\r\n return ExtrudeShapeCustom(name, options, scene);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"shapeBuilder.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Meshes/Builders/shapeBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C;;;;;;;;;;;;;;;;;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C,eAAe,EAAE,eAAe;QAChC,QAAQ,EAAE,QAAQ;QAClB,SAAS,EAAE,SAAS;KACvB,CAAC;IAEF,OAAO,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAC9C,CAAC,CAAC;AAED,IAAY,CAAC,kBAAkB,GAAG,UAC/B,IAAY,EACZ,KAAgB,EAChB,IAAe,EACf,aAAkE,EAClE,gBAAqE,EACrE,gBAAyB,EACzB,eAAwB,EACxB,GAAW,EACX,KAAY,EACZ,SAAmB,EACnB,eAAwB,EACxB,QAAe;IAEf,IAAM,OAAO,GAAG;QACZ,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,IAAI;QACV,aAAa,EAAE,aAAa;QAC5B,gBAAgB,EAAE,gBAAgB;QAClC,gBAAgB,EAAE,gBAAgB;QAClC,eAAe,EAAE,eAAe;QAChC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM;QACvC,eAAe,EAAE,eAAe;QAChC,QAAQ,EAAE,QAAQ;QAClB,SAAS,EAAE,SAAS;KACvB,CAAC;IAEF,OAAO,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Vector4 } from \"../../Maths/math.vector\";\r\nimport { Vector3, TmpVectors, Matrix } from \"../../Maths/math.vector\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { CreateRibbon } from \"./ribbonBuilder\";\r\nimport { Path3D } from \"../../Maths/math.path\";\r\n\r\n/**\r\n * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.\r\n * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.\r\n * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.\r\n * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.\r\n * * The parameter `scale` (float, default 1) is the value to scale the shape.\r\n * * The parameter `closeShape` (boolean, default false) closes the shape when true, since v5.0.0.\r\n * * The parameter `closePath` (boolean, default false) closes the path when true and no caps, since v5.0.0.\r\n * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL\r\n * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape\r\n * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.\r\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation\r\n * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.\r\n * * The optional parameter `firstNormal` (Vector3) defines the direction of the first normal of the supplied path. Consider using this for any path that is straight, and particular for paths in the xy plane.\r\n * * The optional `adjustFrame` (boolean, default false) will cause the internally generated Path3D tangents, normals, and binormals to be adjusted so that a) they are always well-defined, and b) they do not reverse from one path point to the next. This prevents the extruded shape from being flipped and/or rotated with resulting mesh self-intersections. This is primarily useful for straight paths that can reverse direction.\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param options.shape\r\n * @param options.path\r\n * @param options.scale\r\n * @param options.rotation\r\n * @param options.closeShape\r\n * @param options.closePath\r\n * @param options.cap\r\n * @param options.updatable\r\n * @param options.sideOrientation\r\n * @param options.frontUVs\r\n * @param options.backUVs\r\n * @param options.instance\r\n * @param options.invertUV\r\n * @param options.firstNormal\r\n * @param options.adjustFrame\r\n * @param scene defines the hosting scene\r\n * @returns the extruded shape mesh\r\n * @see https://doc.babylonjs.com/how_to/parametric_shapes\r\n * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes\r\n */\r\nexport function ExtrudeShape(\r\n name: string,\r\n options: {\r\n shape: Vector3[];\r\n path: Vector3[];\r\n scale?: number;\r\n rotation?: number;\r\n closeShape?: boolean;\r\n closePath?: boolean;\r\n cap?: number;\r\n updatable?: boolean;\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n instance?: Mesh;\r\n invertUV?: boolean;\r\n firstNormal?: Vector3;\r\n adjustFrame?: boolean;\r\n },\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const path = options.path;\r\n const shape = options.shape;\r\n const scale = options.scale || 1;\r\n const rotation = options.rotation || 0;\r\n const cap = options.cap === 0 ? 0 : options.cap || Mesh.NO_CAP;\r\n const updatable = options.updatable;\r\n const sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n const instance = options.instance || null;\r\n const invertUV = options.invertUV || false;\r\n const closeShape = options.closeShape || false;\r\n const closePath = options.closePath || false;\r\n\r\n return _ExtrudeShapeGeneric(\r\n name,\r\n shape,\r\n path,\r\n scale,\r\n rotation,\r\n null,\r\n null,\r\n closePath,\r\n closeShape,\r\n cap,\r\n false,\r\n scene,\r\n updatable ? true : false,\r\n sideOrientation,\r\n instance,\r\n invertUV,\r\n options.frontUVs || null,\r\n options.backUVs || null,\r\n options.firstNormal || null,\r\n options.adjustFrame ? true : false\r\n );\r\n}\r\n\r\n/**\r\n * Creates an custom extruded shape mesh.\r\n * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.\r\n * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.\r\n * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.\r\n * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the beginning of the path\r\n * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.\r\n * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the beginning of the path\r\n * * It must returns a float value that will be the scale value applied to the shape on each path point\r\n * * The parameter `closeShape` (boolean, default false) closes the shape when true, since v5.0.0.\r\n * * The parameter `closePath` (boolean, default false) closes the path when true and no caps, since v5.0.0.\r\n * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray` - depreciated in favor of closeShape\r\n * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray` - depreciated in favor of closePath\r\n * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL\r\n * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape\r\n * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape\r\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation\r\n * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * * The optional parameter `firstNormal` (Vector3) defines the direction of the first normal of the supplied path. It should be supplied when the path is in the xy plane, and particularly if these sections are straight, because the underlying Path3D object will pick a normal in the xy plane that causes the extrusion to be collapsed into the plane. This should be used for any path that is straight.\r\n * * The optional `adjustFrame` (boolean, default false) will cause the internally generated Path3D tangents, normals, and binormals to be adjusted so that a) they are always well-defined, and b) they do not reverse from one path point to the next. This prevents the extruded shape from being flipped and/or rotated with resulting mesh self-intersections. This is primarily useful for straight paths that can reverse direction.\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param options.shape\r\n * @param options.path\r\n * @param options.scaleFunction\r\n * @param options.rotationFunction\r\n * @param options.ribbonCloseArray\r\n * @param options.ribbonClosePath\r\n * @param options.closeShape\r\n * @param options.closePath\r\n * @param options.cap\r\n * @param options.updatable\r\n * @param options.sideOrientation\r\n * @param options.frontUVs\r\n * @param options.backUVs\r\n * @param options.instance\r\n * @param options.invertUV\r\n * @param options.firstNormal\r\n * @param options.adjustFrame\r\n * @param scene defines the hosting scene\r\n * @returns the custom extruded shape mesh\r\n * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes\r\n * @see https://doc.babylonjs.com/how_to/parametric_shapes\r\n * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes\r\n */\r\nexport function ExtrudeShapeCustom(\r\n name: string,\r\n options: {\r\n shape: Vector3[];\r\n path: Vector3[];\r\n scaleFunction?: Nullable<{ (i: number, distance: number): number }>;\r\n rotationFunction?: Nullable<{ (i: number, distance: number): number }>;\r\n ribbonCloseArray?: boolean;\r\n ribbonClosePath?: boolean;\r\n closeShape?: boolean;\r\n closePath?: boolean;\r\n cap?: number;\r\n updatable?: boolean;\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n instance?: Mesh;\r\n invertUV?: boolean;\r\n firstNormal?: Vector3;\r\n adjustFrame?: boolean;\r\n },\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const path = options.path;\r\n const shape = options.shape;\r\n const scaleFunction =\r\n options.scaleFunction ||\r\n (() => {\r\n return 1;\r\n });\r\n const rotationFunction =\r\n options.rotationFunction ||\r\n (() => {\r\n return 0;\r\n });\r\n const ribbonCloseArray = options.closePath || options.ribbonCloseArray || false;\r\n const ribbonClosePath = options.closeShape || options.ribbonClosePath || false;\r\n const cap = options.cap === 0 ? 0 : options.cap || Mesh.NO_CAP;\r\n const updatable = options.updatable;\r\n const firstNormal = options.firstNormal || null;\r\n const adjustFrame = options.adjustFrame || false;\r\n const sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n const instance = options.instance;\r\n const invertUV = options.invertUV || false;\r\n return _ExtrudeShapeGeneric(\r\n name,\r\n shape,\r\n path,\r\n null,\r\n null,\r\n scaleFunction,\r\n rotationFunction,\r\n ribbonCloseArray,\r\n ribbonClosePath,\r\n cap,\r\n true,\r\n scene,\r\n updatable ? true : false,\r\n sideOrientation,\r\n instance || null,\r\n invertUV,\r\n options.frontUVs || null,\r\n options.backUVs || null,\r\n firstNormal,\r\n adjustFrame\r\n );\r\n}\r\n\r\nfunction _ExtrudeShapeGeneric(\r\n name: string,\r\n shape: Vector3[],\r\n curve: Vector3[],\r\n scale: Nullable<number>,\r\n rotation: Nullable<number>,\r\n scaleFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rotateFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rbCA: boolean,\r\n rbCP: boolean,\r\n cap: number,\r\n custom: boolean,\r\n scene: Nullable<Scene>,\r\n updtbl: boolean,\r\n side: number,\r\n instance: Nullable<Mesh>,\r\n invertUV: boolean,\r\n frontUVs: Nullable<Vector4>,\r\n backUVs: Nullable<Vector4>,\r\n firstNormal: Nullable<Vector3>,\r\n adjustFrame: boolean\r\n): Mesh {\r\n // extrusion geometry\r\n const extrusionPathArray = (\r\n shape: Vector3[],\r\n curve: Vector3[],\r\n path3D: Path3D,\r\n shapePaths: Vector3[][],\r\n scale: Nullable<number>,\r\n rotation: Nullable<number>,\r\n scaleFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rotateFunction: Nullable<{ (i: number, distance: number): number }>,\r\n cap: number,\r\n custom: boolean,\r\n adjustFrame: boolean\r\n ) => {\r\n const tangents = path3D.getTangents();\r\n const normals = path3D.getNormals();\r\n const binormals = path3D.getBinormals();\r\n const distances = path3D.getDistances();\r\n if (adjustFrame) {\r\n /* fix tangents,normals, binormals */\r\n for (let i = 0; i < tangents.length; i++) {\r\n if (tangents[i].x == 0 && tangents[i].y == 0 && tangents[i].z == 0) {\r\n tangents[i].copyFrom(tangents[i - 1]);\r\n }\r\n if (normals[i].x == 0 && normals[i].y == 0 && normals[i].z == 0) {\r\n normals[i].copyFrom(normals[i - 1]);\r\n }\r\n if (binormals[i].x == 0 && binormals[i].y == 0 && binormals[i].z == 0) {\r\n binormals[i].copyFrom(binormals[i - 1]);\r\n }\r\n if (i > 0) {\r\n let v = tangents[i - 1];\r\n if (Vector3.Dot(v, tangents[i]) < 0) {\r\n tangents[i].scaleInPlace(-1);\r\n }\r\n v = normals[i - 1];\r\n if (Vector3.Dot(v, normals[i]) < 0) {\r\n normals[i].scaleInPlace(-1);\r\n }\r\n v = binormals[i - 1];\r\n if (Vector3.Dot(v, binormals[i]) < 0) {\r\n binormals[i].scaleInPlace(-1);\r\n }\r\n }\r\n }\r\n }\r\n let angle = 0;\r\n const returnScale = () => {\r\n return scale !== null ? scale : 1;\r\n };\r\n const returnRotation = () => {\r\n return rotation !== null ? rotation : 0;\r\n };\r\n const rotate: { (i: number, distance: number): number } = custom && rotateFunction ? rotateFunction : returnRotation;\r\n const scl: { (i: number, distance: number): number } = custom && scaleFunction ? scaleFunction : returnScale;\r\n let index = cap === Mesh.NO_CAP || cap === Mesh.CAP_END ? 0 : 2;\r\n const rotationMatrix: Matrix = TmpVectors.Matrix[0];\r\n\r\n for (let i = 0; i < curve.length; i++) {\r\n const shapePath = new Array<Vector3>();\r\n const angleStep = rotate(i, distances[i]);\r\n const scaleRatio = scl(i, distances[i]);\r\n Matrix.RotationAxisToRef(tangents[i], angle, rotationMatrix);\r\n for (let p = 0; p < shape.length; p++) {\r\n const planed = tangents[i].scale(shape[p].z).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y));\r\n const rotated = Vector3.Zero();\r\n Vector3.TransformCoordinatesToRef(planed, rotationMatrix, rotated);\r\n rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);\r\n shapePath[p] = rotated;\r\n }\r\n shapePaths[index] = shapePath;\r\n angle += angleStep;\r\n index++;\r\n }\r\n // cap\r\n const capPath = (shapePath: Vector3[]) => {\r\n const pointCap = Array<Vector3>();\r\n const barycenter = Vector3.Zero();\r\n let i: number;\r\n for (i = 0; i < shapePath.length; i++) {\r\n barycenter.addInPlace(shapePath[i]);\r\n }\r\n barycenter.scaleInPlace(1.0 / shapePath.length);\r\n for (i = 0; i < shapePath.length; i++) {\r\n pointCap.push(barycenter);\r\n }\r\n return pointCap;\r\n };\r\n switch (cap) {\r\n case Mesh.NO_CAP:\r\n break;\r\n case Mesh.CAP_START:\r\n shapePaths[0] = capPath(shapePaths[2]);\r\n shapePaths[1] = shapePaths[2];\r\n break;\r\n case Mesh.CAP_END:\r\n shapePaths[index] = shapePaths[index - 1];\r\n shapePaths[index + 1] = capPath(shapePaths[index - 1]);\r\n break;\r\n case Mesh.CAP_ALL:\r\n shapePaths[0] = capPath(shapePaths[2]);\r\n shapePaths[1] = shapePaths[2];\r\n shapePaths[index] = shapePaths[index - 1];\r\n shapePaths[index + 1] = capPath(shapePaths[index - 1]);\r\n break;\r\n default:\r\n break;\r\n }\r\n return shapePaths;\r\n };\r\n let path3D;\r\n let pathArray;\r\n if (instance) {\r\n // instance update\r\n const storage = instance._creationDataStorage!;\r\n path3D = firstNormal ? storage.path3D.update(curve, firstNormal) : storage.path3D.update(curve);\r\n pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom, adjustFrame);\r\n instance = CreateRibbon(\"\", { pathArray, closeArray: false, closePath: false, offset: 0, updatable: false, sideOrientation: 0, instance }, scene || undefined);\r\n\r\n return instance;\r\n }\r\n // extruded shape creation\r\n path3D = firstNormal ? new Path3D(curve, firstNormal) : new Path3D(curve);\r\n const newShapePaths = new Array<Array<Vector3>>();\r\n cap = cap < 0 || cap > 3 ? 0 : cap;\r\n pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom, adjustFrame);\r\n const extrudedGeneric = CreateRibbon(\r\n name,\r\n {\r\n pathArray: pathArray,\r\n closeArray: rbCA,\r\n closePath: rbCP,\r\n updatable: updtbl,\r\n sideOrientation: side,\r\n invertUV: invertUV,\r\n frontUVs: frontUVs || undefined,\r\n backUVs: backUVs || undefined,\r\n },\r\n scene\r\n );\r\n extrudedGeneric._creationDataStorage!.pathArray = pathArray;\r\n extrudedGeneric._creationDataStorage!.path3D = path3D;\r\n extrudedGeneric._creationDataStorage!.cap = cap;\r\n\r\n return extrudedGeneric;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated please use the functions directly from the module\r\n */\r\nexport const ShapeBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ExtrudeShape,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ExtrudeShapeCustom,\r\n};\r\n\r\n(Mesh as any).ExtrudeShape = (\r\n name: string,\r\n shape: Vector3[],\r\n path: Vector3[],\r\n scale: number,\r\n rotation: number,\r\n cap: number,\r\n scene: Nullable<Scene> = null,\r\n updatable?: boolean,\r\n sideOrientation?: number,\r\n instance?: Mesh\r\n): Mesh => {\r\n const options = {\r\n shape: shape,\r\n path: path,\r\n scale: scale,\r\n rotation: rotation,\r\n cap: cap === 0 ? 0 : cap || Mesh.NO_CAP,\r\n sideOrientation: sideOrientation,\r\n instance: instance,\r\n updatable: updatable,\r\n };\r\n\r\n return ExtrudeShape(name, options, scene);\r\n};\r\n\r\n(Mesh as any).ExtrudeShapeCustom = (\r\n name: string,\r\n shape: Vector3[],\r\n path: Vector3[],\r\n scaleFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rotationFunction: Nullable<{ (i: number, distance: number): number }>,\r\n ribbonCloseArray: boolean,\r\n ribbonClosePath: boolean,\r\n cap: number,\r\n scene: Scene,\r\n updatable?: boolean,\r\n sideOrientation?: number,\r\n instance?: Mesh\r\n): Mesh => {\r\n const options = {\r\n shape: shape,\r\n path: path,\r\n scaleFunction: scaleFunction,\r\n rotationFunction: rotationFunction,\r\n ribbonCloseArray: ribbonCloseArray,\r\n ribbonClosePath: ribbonClosePath,\r\n cap: cap === 0 ? 0 : cap || Mesh.NO_CAP,\r\n sideOrientation: sideOrientation,\r\n instance: instance,\r\n updatable: updatable,\r\n };\r\n\r\n return ExtrudeShapeCustom(name, options, scene);\r\n};\r\n"]}
|
|
@@ -220,6 +220,11 @@ export declare class InstancedMesh extends AbstractMesh {
|
|
|
220
220
|
* @param disposeMaterialAndTextures
|
|
221
221
|
*/
|
|
222
222
|
dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
|
|
223
|
+
/**
|
|
224
|
+
* @param serializationObject
|
|
225
|
+
* @hidden
|
|
226
|
+
*/
|
|
227
|
+
_serializeAsParent(serializationObject: any): void;
|
|
223
228
|
}
|
|
224
229
|
declare module "./mesh" {
|
|
225
230
|
interface Mesh {
|
package/Meshes/instancedMesh.js
CHANGED
|
@@ -505,6 +505,15 @@ var InstancedMesh = /** @class */ (function (_super) {
|
|
|
505
505
|
this._sourceMesh.removeInstance(this);
|
|
506
506
|
_super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
|
|
507
507
|
};
|
|
508
|
+
/**
|
|
509
|
+
* @param serializationObject
|
|
510
|
+
* @hidden
|
|
511
|
+
*/
|
|
512
|
+
InstancedMesh.prototype._serializeAsParent = function (serializationObject) {
|
|
513
|
+
_super.prototype._serializeAsParent.call(this, serializationObject);
|
|
514
|
+
serializationObject.parentId = this._sourceMesh.uniqueId;
|
|
515
|
+
serializationObject.parentInstanceIndex = this._indexInSourceMeshInstanceArray;
|
|
516
|
+
};
|
|
508
517
|
return InstancedMesh;
|
|
509
518
|
}(AbstractMesh));
|
|
510
519
|
export { InstancedMesh };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instancedMesh.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Meshes/instancedMesh.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,IAAI,CAAC,qBAAqB,GAAG,UAAC,IAAY,EAAE,IAAU;IAClD,IAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAE/C,IAAI,IAAI,CAAC,gBAAgB,EAAE;QACvB,QAAQ,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAE/B,KAAK,IAAM,GAAG,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACrC,QAAQ,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;SAC/D;KACJ;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAEF;;GAEG;AACH;IAAmC,iCAAY;IAY3C,uBAAY,IAAY,EAAE,MAAY;QAAtC,Y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AAC,aAAa,CAAC,IAAI,CAAC,EAAE;YACvD,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,IAAI,CAAE,CAAC,OAAO,EAAE,CAAC;SACpE;KACJ;IAED,IAAI,CAAC,oCAAoC,EAAE,CAAC;IAE5C,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;AAC/B,CAAC,CAAC","sourcesContent":["import type { Nullable, FloatArray, IndicesArray } from \"../types\";\r\nimport type { Vector3 } from \"../Maths/math.vector\";\r\nimport { Matrix, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Node } from \"../node\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport type { Skeleton } from \"../Bones/skeleton\";\r\nimport { DeepCopier } from \"../Misc/deepCopier\";\r\nimport { TransformNode } from \"./transformNode\";\r\nimport type { Light } from \"../Lights/light\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\n\r\nMesh._instancedMeshFactory = (name: string, mesh: Mesh): InstancedMesh => {\r\n const instance = new InstancedMesh(name, mesh);\r\n\r\n if (mesh.instancedBuffers) {\r\n instance.instancedBuffers = {};\r\n\r\n for (const key in mesh.instancedBuffers) {\r\n instance.instancedBuffers[key] = mesh.instancedBuffers[key];\r\n }\r\n }\r\n\r\n return instance;\r\n};\r\n\r\n/**\r\n * Creates an instance based on a source mesh.\r\n */\r\nexport class InstancedMesh extends AbstractMesh {\r\n private _sourceMesh: Mesh;\r\n private _currentLOD: Mesh;\r\n private _billboardWorldMatrix: Matrix;\r\n\r\n /** @hidden */\r\n public _indexInSourceMeshInstanceArray = -1;\r\n /** @hidden */\r\n public _distanceToCamera: number = 0;\r\n /** @hidden */\r\n public _previousWorldMatrix: Nullable<Matrix>;\r\n\r\n constructor(name: string, source: Mesh) {\r\n super(name, source.getScene());\r\n\r\n source.addInstance(this);\r\n\r\n this._sourceMesh = source;\r\n\r\n this._unIndexed = source._unIndexed;\r\n\r\n this.position.copyFrom(source.position);\r\n this.rotation.copyFrom(source.rotation);\r\n this.scaling.copyFrom(source.scaling);\r\n\r\n if (source.rotationQuaternion) {\r\n this.rotationQuaternion = source.rotationQuaternion.clone();\r\n }\r\n\r\n this.animations = source.animations.slice();\r\n for (const range of source.getAnimationRanges()) {\r\n if (range != null) {\r\n this.createAnimationRange(range.name, range.from, range.to);\r\n }\r\n }\r\n\r\n this.infiniteDistance = source.infiniteDistance;\r\n\r\n this.setPivotMatrix(source.getPivotMatrix());\r\n\r\n this.refreshBoundingInfo(true, true);\r\n this._syncSubMeshes();\r\n }\r\n\r\n /**\r\n * Returns the string \"InstancedMesh\".\r\n */\r\n public getClassName(): string {\r\n return \"InstancedMesh\";\r\n }\r\n\r\n /** Gets the list of lights affecting that mesh */\r\n public get lightSources(): Light[] {\r\n return this._sourceMesh._lightSources;\r\n }\r\n\r\n public _resyncLightSources(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n public _resyncLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n public _removeLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n // Methods\r\n /**\r\n * If the source mesh receives shadows\r\n */\r\n public get receiveShadows(): boolean {\r\n return this._sourceMesh.receiveShadows;\r\n }\r\n\r\n /**\r\n * The material of the source mesh\r\n */\r\n public get material(): Nullable<Material> {\r\n return this._sourceMesh.material;\r\n }\r\n\r\n /**\r\n * Visibility of the source mesh\r\n */\r\n public get visibility(): number {\r\n return this._sourceMesh.visibility;\r\n }\r\n\r\n /**\r\n * Skeleton of the source mesh\r\n */\r\n public get skeleton(): Nullable<Skeleton> {\r\n return this._sourceMesh.skeleton;\r\n }\r\n\r\n /**\r\n * Rendering ground id of the source mesh\r\n */\r\n public get renderingGroupId(): number {\r\n return this._sourceMesh.renderingGroupId;\r\n }\r\n\r\n public set renderingGroupId(value: number) {\r\n if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {\r\n return;\r\n }\r\n\r\n //no-op with warning\r\n Logger.Warn(\"Note - setting renderingGroupId of an instanced mesh has no effect on the scene\");\r\n }\r\n\r\n /**\r\n * Returns the total number of vertices (integer).\r\n */\r\n public getTotalVertices(): number {\r\n return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0;\r\n }\r\n\r\n /**\r\n * Returns a positive integer : the total number of indices in this mesh geometry.\r\n * @returns the number of indices or zero if the mesh has no geometry.\r\n */\r\n public getTotalIndices(): number {\r\n return this._sourceMesh.getTotalIndices();\r\n }\r\n\r\n /**\r\n * The source mesh of the instance\r\n */\r\n public get sourceMesh(): Mesh {\r\n return this._sourceMesh;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh object from the mesh model.\r\n * @see https://doc.babylonjs.com/how_to/how_to_use_instances\r\n * @param name defines the name of the new instance\r\n * @returns a new InstancedMesh\r\n */\r\n public createInstance(name: string): InstancedMesh {\r\n return this._sourceMesh.createInstance(name);\r\n }\r\n\r\n /**\r\n * Is this node ready to be used/rendered\r\n * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)\r\n * @return {boolean} is it ready\r\n */\r\n public isReady(completeCheck = false): boolean {\r\n return this._sourceMesh.isReady(completeCheck, true);\r\n }\r\n\r\n /**\r\n * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.\r\n * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)\r\n * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.\r\n * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.\r\n */\r\n public getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray> {\r\n return this._sourceMesh.getVerticesData(kind, copyWhenShared);\r\n }\r\n\r\n /**\r\n * Sets the vertex data of the mesh geometry for the requested `kind`.\r\n * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.\r\n * The `data` are either a numeric array either a Float32Array.\r\n * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.\r\n * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).\r\n * Note that a new underlying VertexBuffer object is created each call.\r\n * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.\r\n *\r\n * Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n *\r\n * Returns the Mesh.\r\n * @param kind\r\n * @param data\r\n * @param updatable\r\n * @param stride\r\n */\r\n public setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.setVerticesData(kind, data, updatable, stride);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Updates the existing vertex data of the mesh geometry for the requested `kind`.\r\n * If the mesh has no geometry, it is simply returned as it is.\r\n * The `data` are either a numeric array either a Float32Array.\r\n * No new underlying VertexBuffer object is created.\r\n * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.\r\n * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.\r\n *\r\n * Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n *\r\n * Returns the Mesh.\r\n * @param kind\r\n * @param data\r\n * @param updateExtends\r\n * @param makeItUnique\r\n */\r\n public updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Sets the mesh indices.\r\n * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).\r\n * If the mesh has no geometry, a new Geometry object is created and set to the mesh.\r\n * This method creates a new index buffer each call.\r\n * Returns the Mesh.\r\n * @param indices\r\n * @param totalVertices\r\n */\r\n public setIndices(indices: IndicesArray, totalVertices: Nullable<number> = null): Mesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.setIndices(indices, totalVertices);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Boolean : True if the mesh owns the requested kind of data.\r\n * @param kind\r\n */\r\n public isVerticesDataPresent(kind: string): boolean {\r\n return this._sourceMesh.isVerticesDataPresent(kind);\r\n }\r\n\r\n /**\r\n * Returns an array of indices (IndicesArray).\r\n */\r\n public getIndices(): Nullable<IndicesArray> {\r\n return this._sourceMesh.getIndices();\r\n }\r\n\r\n public get _positions(): Nullable<Vector3[]> {\r\n return this._sourceMesh._positions;\r\n }\r\n\r\n /**\r\n * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.\r\n * This means the mesh underlying bounding box and sphere are recomputed.\r\n * @param applySkeleton defines whether to apply the skeleton before computing the bounding info\r\n * @param applyMorph defines whether to apply the morph target before computing the bounding info\r\n * @returns the current mesh\r\n */\r\n public refreshBoundingInfo(applySkeleton: boolean = false, applyMorph: boolean = false): InstancedMesh {\r\n if (this.hasBoundingInfo && this.getBoundingInfo().isLocked) {\r\n return this;\r\n }\r\n\r\n const bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;\r\n this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton, applyMorph), bias);\r\n return this;\r\n }\r\n\r\n /** @hidden */\r\n public _preActivate(): InstancedMesh {\r\n if (this._currentLOD) {\r\n this._currentLOD._preActivate();\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @param renderId\r\n * @param intermediateRendering\r\n * @hidden\r\n */\r\n public _activate(renderId: number, intermediateRendering: boolean): boolean {\r\n super._activate(renderId, intermediateRendering);\r\n\r\n if (!this._sourceMesh.subMeshes) {\r\n Logger.Warn(\"Instances should only be created for meshes with geometry.\");\r\n }\r\n\r\n if (this._currentLOD) {\r\n const differentSign = this._currentLOD._getWorldMatrixDeterminant() >= 0 !== this._getWorldMatrixDeterminant() >= 0;\r\n if (differentSign) {\r\n this._internalAbstractMeshDataInfo._actAsRegularMesh = true;\r\n return true;\r\n }\r\n this._internalAbstractMeshDataInfo._actAsRegularMesh = false;\r\n\r\n this._currentLOD._registerInstanceForRenderId(this, renderId);\r\n\r\n if (intermediateRendering) {\r\n if (!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate) {\r\n this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = true;\r\n return true;\r\n }\r\n } else {\r\n if (!this._currentLOD._internalAbstractMeshDataInfo._isActive) {\r\n this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances = true;\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /** @hidden */\r\n public _postActivate(): void {\r\n if (this._sourceMesh.edgesShareWithInstances && this._sourceMesh._edgesRenderer && this._sourceMesh._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {\r\n // we are using the edge renderer of the source mesh\r\n this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer);\r\n this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix());\r\n } else if (this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {\r\n // we are using the edge renderer defined for this instance\r\n this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer);\r\n }\r\n }\r\n\r\n public getWorldMatrix(): Matrix {\r\n if (this._currentLOD && this._currentLOD.billboardMode !== TransformNode.BILLBOARDMODE_NONE && this._currentLOD._masterMesh !== this) {\r\n if (!this._billboardWorldMatrix) {\r\n this._billboardWorldMatrix = new Matrix();\r\n }\r\n const tempMaster = this._currentLOD._masterMesh;\r\n this._currentLOD._masterMesh = this;\r\n TmpVectors.Vector3[7].copyFrom(this._currentLOD.position);\r\n this._currentLOD.position.set(0, 0, 0);\r\n this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(true));\r\n this._currentLOD.position.copyFrom(TmpVectors.Vector3[7]);\r\n this._currentLOD._masterMesh = tempMaster;\r\n return this._billboardWorldMatrix;\r\n }\r\n\r\n return super.getWorldMatrix();\r\n }\r\n\r\n public get isAnInstance(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Returns the current associated LOD AbstractMesh.\r\n * @param camera\r\n */\r\n public getLOD(camera: Camera): AbstractMesh {\r\n if (!camera) {\r\n return this;\r\n }\r\n\r\n const sourceMeshLODLevels = this.sourceMesh.getLODLevels();\r\n if (!sourceMeshLODLevels || sourceMeshLODLevels.length === 0) {\r\n this._currentLOD = this.sourceMesh;\r\n } else {\r\n const boundingInfo = this.getBoundingInfo();\r\n this._currentLOD = <Mesh>this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);\r\n }\r\n\r\n return this._currentLOD;\r\n }\r\n\r\n /**\r\n * @param renderId\r\n * @hidden\r\n */\r\n public _preActivateForIntermediateRendering(renderId: number): Mesh {\r\n return <Mesh>this.sourceMesh._preActivateForIntermediateRendering(renderId);\r\n }\r\n\r\n /** @hidden */\r\n public _syncSubMeshes(): InstancedMesh {\r\n this.releaseSubMeshes();\r\n if (this._sourceMesh.subMeshes) {\r\n for (let index = 0; index < this._sourceMesh.subMeshes.length; index++) {\r\n this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n /** @hidden */\r\n public _generatePointsArray(): boolean {\r\n return this._sourceMesh._generatePointsArray();\r\n }\r\n\r\n /** @hidden */\r\n public _updateBoundingInfo(): AbstractMesh {\r\n if (this.hasBoundingInfo) {\r\n this.getBoundingInfo().update(this.worldMatrixFromCache);\r\n } else {\r\n this.buildBoundingInfo(this.absolutePosition, this.absolutePosition, this.worldMatrixFromCache);\r\n }\r\n this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);\r\n return this;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh from the current mesh.\r\n * - name (string) : the cloned mesh name\r\n * - newParent (optional Node) : the optional Node to parent the clone to.\r\n * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.\r\n *\r\n * Returns the clone.\r\n * @param name\r\n * @param newParent\r\n * @param doNotCloneChildren\r\n */\r\n public clone(name: string, newParent: Nullable<Node> = null, doNotCloneChildren?: boolean): InstancedMesh {\r\n const result = this._sourceMesh.createInstance(name);\r\n\r\n // Deep copy\r\n DeepCopier.DeepCopy(\r\n this,\r\n result,\r\n [\r\n \"name\",\r\n \"subMeshes\",\r\n \"uniqueId\",\r\n \"parent\",\r\n \"lightSources\",\r\n \"receiveShadows\",\r\n \"material\",\r\n \"visibility\",\r\n \"skeleton\",\r\n \"sourceMesh\",\r\n \"isAnInstance\",\r\n \"facetNb\",\r\n \"isFacetDataEnabled\",\r\n \"isBlocked\",\r\n \"useBones\",\r\n \"hasInstances\",\r\n \"collider\",\r\n \"edgesRenderer\",\r\n \"forward\",\r\n \"up\",\r\n \"right\",\r\n \"absolutePosition\",\r\n \"absoluteScaling\",\r\n \"absoluteRotationQuaternion\",\r\n \"isWorldMatrixFrozen\",\r\n \"nonUniformScaling\",\r\n \"behaviors\",\r\n \"worldMatrixFromCache\",\r\n \"hasThinInstances\",\r\n \"hasBoundingInfo\",\r\n ],\r\n []\r\n );\r\n\r\n // Bounding info\r\n this.refreshBoundingInfo();\r\n\r\n // Parent\r\n if (newParent) {\r\n result.parent = newParent;\r\n }\r\n\r\n if (!doNotCloneChildren) {\r\n // Children\r\n for (let index = 0; index < this.getScene().meshes.length; index++) {\r\n const mesh = this.getScene().meshes[index];\r\n\r\n if (mesh.parent === this) {\r\n mesh.clone(mesh.name, result);\r\n }\r\n }\r\n }\r\n\r\n result.computeWorldMatrix(true);\r\n\r\n this.onClonedObservable.notifyObservers(result);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Disposes the InstancedMesh.\r\n * Returns nothing.\r\n * @param doNotRecurse\r\n * @param disposeMaterialAndTextures\r\n */\r\n public dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {\r\n // Remove from mesh\r\n this._sourceMesh.removeInstance(this);\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n}\r\n\r\ndeclare module \"./mesh\" {\r\n export interface Mesh {\r\n /**\r\n * Register a custom buffer that will be instanced\r\n * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers\r\n * @param kind defines the buffer kind\r\n * @param stride defines the stride in floats\r\n */\r\n registerInstancedBuffer(kind: string, stride: number): void;\r\n\r\n /**\r\n * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).\r\n */\r\n _invalidateInstanceVertexArrayObject(): void;\r\n\r\n /**\r\n * true to use the edge renderer for all instances of this mesh\r\n */\r\n edgesShareWithInstances: boolean;\r\n\r\n /** @hidden */\r\n _userInstancedBuffersStorage: {\r\n data: { [key: string]: Float32Array };\r\n sizes: { [key: string]: number };\r\n vertexBuffers: { [key: string]: Nullable<VertexBuffer> };\r\n strides: { [key: string]: number };\r\n vertexArrayObjects?: { [key: string]: WebGLVertexArrayObject };\r\n };\r\n }\r\n}\r\n\r\ndeclare module \"./abstractMesh\" {\r\n export interface AbstractMesh {\r\n /**\r\n * Object used to store instanced buffers defined by user\r\n * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers\r\n */\r\n instancedBuffers: { [key: string]: any };\r\n }\r\n}\r\n\r\nMesh.prototype.registerInstancedBuffer = function (kind: string, stride: number): void {\r\n // Remove existing one\r\n this._userInstancedBuffersStorage?.vertexBuffers[kind]?.dispose();\r\n\r\n // Creates the instancedBuffer field if not present\r\n if (!this.instancedBuffers) {\r\n this.instancedBuffers = {};\r\n\r\n for (const instance of this.instances) {\r\n instance.instancedBuffers = {};\r\n }\r\n\r\n if (!this._userInstancedBuffersStorage) {\r\n this._userInstancedBuffersStorage = {\r\n data: {},\r\n vertexBuffers: {},\r\n strides: {},\r\n sizes: {},\r\n vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : undefined,\r\n };\r\n }\r\n }\r\n\r\n // Creates an empty property for this kind\r\n this.instancedBuffers[kind] = null;\r\n\r\n this._userInstancedBuffersStorage.strides[kind] = stride;\r\n this._userInstancedBuffersStorage.sizes[kind] = stride * 32; // Initial size\r\n this._userInstancedBuffersStorage.data[kind] = new Float32Array(this._userInstancedBuffersStorage.sizes[kind]);\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true);\r\n\r\n for (const instance of this.instances) {\r\n instance.instancedBuffers[kind] = null;\r\n }\r\n\r\n this._invalidateInstanceVertexArrayObject();\r\n\r\n this._markSubMeshesAsAttributesDirty();\r\n};\r\n\r\nMesh.prototype._processInstancedBuffers = function (visibleInstances: InstancedMesh[], renderSelf: boolean) {\r\n const instanceCount = visibleInstances.length;\r\n\r\n for (const kind in this.instancedBuffers) {\r\n let size = this._userInstancedBuffersStorage.sizes[kind];\r\n const stride = this._userInstancedBuffersStorage.strides[kind];\r\n\r\n // Resize if required\r\n const expectedSize = (instanceCount + 1) * stride;\r\n\r\n while (size < expectedSize) {\r\n size *= 2;\r\n }\r\n\r\n if (this._userInstancedBuffersStorage.data[kind].length != size) {\r\n this._userInstancedBuffersStorage.data[kind] = new Float32Array(size);\r\n this._userInstancedBuffersStorage.sizes[kind] = size;\r\n if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind]!.dispose();\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = null;\r\n }\r\n }\r\n\r\n const data = this._userInstancedBuffersStorage.data[kind];\r\n\r\n // Update data buffer\r\n let offset = 0;\r\n if (renderSelf) {\r\n const value = this.instancedBuffers[kind];\r\n\r\n if (value.toArray) {\r\n value.toArray(data, offset);\r\n } else if (value.copyToArray) {\r\n value.copyToArray(data, offset);\r\n } else {\r\n data[offset] = value;\r\n }\r\n\r\n offset += stride;\r\n }\r\n\r\n for (let instanceIndex = 0; instanceIndex < instanceCount; instanceIndex++) {\r\n const instance = visibleInstances[instanceIndex]!;\r\n\r\n const value = instance.instancedBuffers[kind];\r\n\r\n if (value.toArray) {\r\n value.toArray(data, offset);\r\n } else if (value.copyToArray) {\r\n value.copyToArray(data, offset);\r\n } else {\r\n data[offset] = value;\r\n }\r\n\r\n offset += stride;\r\n }\r\n\r\n // Update vertex buffer\r\n if (!this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = new VertexBuffer(\r\n this.getEngine(),\r\n this._userInstancedBuffersStorage.data[kind],\r\n kind,\r\n true,\r\n false,\r\n stride,\r\n true\r\n );\r\n this._invalidateInstanceVertexArrayObject();\r\n } else {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind]!.updateDirectly(data, 0);\r\n }\r\n }\r\n};\r\n\r\nMesh.prototype._invalidateInstanceVertexArrayObject = function () {\r\n if (!this._userInstancedBuffersStorage || this._userInstancedBuffersStorage.vertexArrayObjects === undefined) {\r\n return;\r\n }\r\n\r\n for (const kind in this._userInstancedBuffersStorage.vertexArrayObjects) {\r\n this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[kind]);\r\n }\r\n\r\n this._userInstancedBuffersStorage.vertexArrayObjects = {};\r\n};\r\n\r\nMesh.prototype._disposeInstanceSpecificData = function () {\r\n if (this._instanceDataStorage.instancesBuffer) {\r\n this._instanceDataStorage.instancesBuffer.dispose();\r\n this._instanceDataStorage.instancesBuffer = null;\r\n }\r\n\r\n while (this.instances.length) {\r\n this.instances[0].dispose();\r\n }\r\n\r\n for (const kind in this.instancedBuffers) {\r\n if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind]!.dispose();\r\n }\r\n }\r\n\r\n this._invalidateInstanceVertexArrayObject();\r\n\r\n this.instancedBuffers = {};\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"instancedMesh.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Meshes/instancedMesh.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,IAAI,CAAC,qBAAqB,GAAG,UAAC,IAAY,EAAE,IAAU;IAClD,IAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAE/C,IAAI,IAAI,CAAC,gBAAgB,EAAE;QACvB,QA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AA4B,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;KACzG;IAED,IAAI,CAAC,4BAA4B,CAAC,kBAAkB,GAAG,EAAE,CAAC;AAC9D,CAAC,CAAC;AAEF,IAAI,CAAC,SAAS,CAAC,4BAA4B,GAAG;IAC1C,IAAI,IAAI,CAAC,oBAAoB,CAAC,eAAe,EAAE;QAC3C,IAAI,CAAC,oBAAoB,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QACpD,IAAI,CAAC,oBAAoB,CAAC,eAAe,GAAG,IAAI,CAAC;KACpD;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;QAC1B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;KAC/B;IAED,KAAK,IAAM,IAAI,IAAI,IAAI,CAAC,gBAAgB,EAAE;QACtC,IAAI,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;YACvD,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,IAAI,CAAE,CAAC,OAAO,EAAE,CAAC;SACpE;KACJ;IAED,IAAI,CAAC,oCAAoC,EAAE,CAAC;IAE5C,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;AAC/B,CAAC,CAAC","sourcesContent":["import type { Nullable, FloatArray, IndicesArray } from \"../types\";\r\nimport type { Vector3 } from \"../Maths/math.vector\";\r\nimport { Matrix, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Node } from \"../node\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport type { Skeleton } from \"../Bones/skeleton\";\r\nimport { DeepCopier } from \"../Misc/deepCopier\";\r\nimport { TransformNode } from \"./transformNode\";\r\nimport type { Light } from \"../Lights/light\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\n\r\nMesh._instancedMeshFactory = (name: string, mesh: Mesh): InstancedMesh => {\r\n const instance = new InstancedMesh(name, mesh);\r\n\r\n if (mesh.instancedBuffers) {\r\n instance.instancedBuffers = {};\r\n\r\n for (const key in mesh.instancedBuffers) {\r\n instance.instancedBuffers[key] = mesh.instancedBuffers[key];\r\n }\r\n }\r\n\r\n return instance;\r\n};\r\n\r\n/**\r\n * Creates an instance based on a source mesh.\r\n */\r\nexport class InstancedMesh extends AbstractMesh {\r\n private _sourceMesh: Mesh;\r\n private _currentLOD: Mesh;\r\n private _billboardWorldMatrix: Matrix;\r\n\r\n /** @hidden */\r\n public _indexInSourceMeshInstanceArray = -1;\r\n /** @hidden */\r\n public _distanceToCamera: number = 0;\r\n /** @hidden */\r\n public _previousWorldMatrix: Nullable<Matrix>;\r\n\r\n constructor(name: string, source: Mesh) {\r\n super(name, source.getScene());\r\n\r\n source.addInstance(this);\r\n\r\n this._sourceMesh = source;\r\n\r\n this._unIndexed = source._unIndexed;\r\n\r\n this.position.copyFrom(source.position);\r\n this.rotation.copyFrom(source.rotation);\r\n this.scaling.copyFrom(source.scaling);\r\n\r\n if (source.rotationQuaternion) {\r\n this.rotationQuaternion = source.rotationQuaternion.clone();\r\n }\r\n\r\n this.animations = source.animations.slice();\r\n for (const range of source.getAnimationRanges()) {\r\n if (range != null) {\r\n this.createAnimationRange(range.name, range.from, range.to);\r\n }\r\n }\r\n\r\n this.infiniteDistance = source.infiniteDistance;\r\n\r\n this.setPivotMatrix(source.getPivotMatrix());\r\n\r\n this.refreshBoundingInfo(true, true);\r\n this._syncSubMeshes();\r\n }\r\n\r\n /**\r\n * Returns the string \"InstancedMesh\".\r\n */\r\n public getClassName(): string {\r\n return \"InstancedMesh\";\r\n }\r\n\r\n /** Gets the list of lights affecting that mesh */\r\n public get lightSources(): Light[] {\r\n return this._sourceMesh._lightSources;\r\n }\r\n\r\n public _resyncLightSources(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n public _resyncLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n public _removeLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n // Methods\r\n /**\r\n * If the source mesh receives shadows\r\n */\r\n public get receiveShadows(): boolean {\r\n return this._sourceMesh.receiveShadows;\r\n }\r\n\r\n /**\r\n * The material of the source mesh\r\n */\r\n public get material(): Nullable<Material> {\r\n return this._sourceMesh.material;\r\n }\r\n\r\n /**\r\n * Visibility of the source mesh\r\n */\r\n public get visibility(): number {\r\n return this._sourceMesh.visibility;\r\n }\r\n\r\n /**\r\n * Skeleton of the source mesh\r\n */\r\n public get skeleton(): Nullable<Skeleton> {\r\n return this._sourceMesh.skeleton;\r\n }\r\n\r\n /**\r\n * Rendering ground id of the source mesh\r\n */\r\n public get renderingGroupId(): number {\r\n return this._sourceMesh.renderingGroupId;\r\n }\r\n\r\n public set renderingGroupId(value: number) {\r\n if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {\r\n return;\r\n }\r\n\r\n //no-op with warning\r\n Logger.Warn(\"Note - setting renderingGroupId of an instanced mesh has no effect on the scene\");\r\n }\r\n\r\n /**\r\n * Returns the total number of vertices (integer).\r\n */\r\n public getTotalVertices(): number {\r\n return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0;\r\n }\r\n\r\n /**\r\n * Returns a positive integer : the total number of indices in this mesh geometry.\r\n * @returns the number of indices or zero if the mesh has no geometry.\r\n */\r\n public getTotalIndices(): number {\r\n return this._sourceMesh.getTotalIndices();\r\n }\r\n\r\n /**\r\n * The source mesh of the instance\r\n */\r\n public get sourceMesh(): Mesh {\r\n return this._sourceMesh;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh object from the mesh model.\r\n * @see https://doc.babylonjs.com/how_to/how_to_use_instances\r\n * @param name defines the name of the new instance\r\n * @returns a new InstancedMesh\r\n */\r\n public createInstance(name: string): InstancedMesh {\r\n return this._sourceMesh.createInstance(name);\r\n }\r\n\r\n /**\r\n * Is this node ready to be used/rendered\r\n * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)\r\n * @return {boolean} is it ready\r\n */\r\n public isReady(completeCheck = false): boolean {\r\n return this._sourceMesh.isReady(completeCheck, true);\r\n }\r\n\r\n /**\r\n * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.\r\n * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)\r\n * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.\r\n * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.\r\n */\r\n public getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray> {\r\n return this._sourceMesh.getVerticesData(kind, copyWhenShared);\r\n }\r\n\r\n /**\r\n * Sets the vertex data of the mesh geometry for the requested `kind`.\r\n * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.\r\n * The `data` are either a numeric array either a Float32Array.\r\n * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.\r\n * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).\r\n * Note that a new underlying VertexBuffer object is created each call.\r\n * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.\r\n *\r\n * Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n *\r\n * Returns the Mesh.\r\n * @param kind\r\n * @param data\r\n * @param updatable\r\n * @param stride\r\n */\r\n public setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.setVerticesData(kind, data, updatable, stride);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Updates the existing vertex data of the mesh geometry for the requested `kind`.\r\n * If the mesh has no geometry, it is simply returned as it is.\r\n * The `data` are either a numeric array either a Float32Array.\r\n * No new underlying VertexBuffer object is created.\r\n * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.\r\n * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.\r\n *\r\n * Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n *\r\n * Returns the Mesh.\r\n * @param kind\r\n * @param data\r\n * @param updateExtends\r\n * @param makeItUnique\r\n */\r\n public updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Sets the mesh indices.\r\n * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).\r\n * If the mesh has no geometry, a new Geometry object is created and set to the mesh.\r\n * This method creates a new index buffer each call.\r\n * Returns the Mesh.\r\n * @param indices\r\n * @param totalVertices\r\n */\r\n public setIndices(indices: IndicesArray, totalVertices: Nullable<number> = null): Mesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.setIndices(indices, totalVertices);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Boolean : True if the mesh owns the requested kind of data.\r\n * @param kind\r\n */\r\n public isVerticesDataPresent(kind: string): boolean {\r\n return this._sourceMesh.isVerticesDataPresent(kind);\r\n }\r\n\r\n /**\r\n * Returns an array of indices (IndicesArray).\r\n */\r\n public getIndices(): Nullable<IndicesArray> {\r\n return this._sourceMesh.getIndices();\r\n }\r\n\r\n public get _positions(): Nullable<Vector3[]> {\r\n return this._sourceMesh._positions;\r\n }\r\n\r\n /**\r\n * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.\r\n * This means the mesh underlying bounding box and sphere are recomputed.\r\n * @param applySkeleton defines whether to apply the skeleton before computing the bounding info\r\n * @param applyMorph defines whether to apply the morph target before computing the bounding info\r\n * @returns the current mesh\r\n */\r\n public refreshBoundingInfo(applySkeleton: boolean = false, applyMorph: boolean = false): InstancedMesh {\r\n if (this.hasBoundingInfo && this.getBoundingInfo().isLocked) {\r\n return this;\r\n }\r\n\r\n const bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;\r\n this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton, applyMorph), bias);\r\n return this;\r\n }\r\n\r\n /** @hidden */\r\n public _preActivate(): InstancedMesh {\r\n if (this._currentLOD) {\r\n this._currentLOD._preActivate();\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @param renderId\r\n * @param intermediateRendering\r\n * @hidden\r\n */\r\n public _activate(renderId: number, intermediateRendering: boolean): boolean {\r\n super._activate(renderId, intermediateRendering);\r\n\r\n if (!this._sourceMesh.subMeshes) {\r\n Logger.Warn(\"Instances should only be created for meshes with geometry.\");\r\n }\r\n\r\n if (this._currentLOD) {\r\n const differentSign = this._currentLOD._getWorldMatrixDeterminant() >= 0 !== this._getWorldMatrixDeterminant() >= 0;\r\n if (differentSign) {\r\n this._internalAbstractMeshDataInfo._actAsRegularMesh = true;\r\n return true;\r\n }\r\n this._internalAbstractMeshDataInfo._actAsRegularMesh = false;\r\n\r\n this._currentLOD._registerInstanceForRenderId(this, renderId);\r\n\r\n if (intermediateRendering) {\r\n if (!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate) {\r\n this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = true;\r\n return true;\r\n }\r\n } else {\r\n if (!this._currentLOD._internalAbstractMeshDataInfo._isActive) {\r\n this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances = true;\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /** @hidden */\r\n public _postActivate(): void {\r\n if (this._sourceMesh.edgesShareWithInstances && this._sourceMesh._edgesRenderer && this._sourceMesh._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {\r\n // we are using the edge renderer of the source mesh\r\n this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer);\r\n this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix());\r\n } else if (this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {\r\n // we are using the edge renderer defined for this instance\r\n this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer);\r\n }\r\n }\r\n\r\n public getWorldMatrix(): Matrix {\r\n if (this._currentLOD && this._currentLOD.billboardMode !== TransformNode.BILLBOARDMODE_NONE && this._currentLOD._masterMesh !== this) {\r\n if (!this._billboardWorldMatrix) {\r\n this._billboardWorldMatrix = new Matrix();\r\n }\r\n const tempMaster = this._currentLOD._masterMesh;\r\n this._currentLOD._masterMesh = this;\r\n TmpVectors.Vector3[7].copyFrom(this._currentLOD.position);\r\n this._currentLOD.position.set(0, 0, 0);\r\n this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(true));\r\n this._currentLOD.position.copyFrom(TmpVectors.Vector3[7]);\r\n this._currentLOD._masterMesh = tempMaster;\r\n return this._billboardWorldMatrix;\r\n }\r\n\r\n return super.getWorldMatrix();\r\n }\r\n\r\n public get isAnInstance(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Returns the current associated LOD AbstractMesh.\r\n * @param camera\r\n */\r\n public getLOD(camera: Camera): AbstractMesh {\r\n if (!camera) {\r\n return this;\r\n }\r\n\r\n const sourceMeshLODLevels = this.sourceMesh.getLODLevels();\r\n if (!sourceMeshLODLevels || sourceMeshLODLevels.length === 0) {\r\n this._currentLOD = this.sourceMesh;\r\n } else {\r\n const boundingInfo = this.getBoundingInfo();\r\n this._currentLOD = <Mesh>this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);\r\n }\r\n\r\n return this._currentLOD;\r\n }\r\n\r\n /**\r\n * @param renderId\r\n * @hidden\r\n */\r\n public _preActivateForIntermediateRendering(renderId: number): Mesh {\r\n return <Mesh>this.sourceMesh._preActivateForIntermediateRendering(renderId);\r\n }\r\n\r\n /** @hidden */\r\n public _syncSubMeshes(): InstancedMesh {\r\n this.releaseSubMeshes();\r\n if (this._sourceMesh.subMeshes) {\r\n for (let index = 0; index < this._sourceMesh.subMeshes.length; index++) {\r\n this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n /** @hidden */\r\n public _generatePointsArray(): boolean {\r\n return this._sourceMesh._generatePointsArray();\r\n }\r\n\r\n /** @hidden */\r\n public _updateBoundingInfo(): AbstractMesh {\r\n if (this.hasBoundingInfo) {\r\n this.getBoundingInfo().update(this.worldMatrixFromCache);\r\n } else {\r\n this.buildBoundingInfo(this.absolutePosition, this.absolutePosition, this.worldMatrixFromCache);\r\n }\r\n this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);\r\n return this;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh from the current mesh.\r\n * - name (string) : the cloned mesh name\r\n * - newParent (optional Node) : the optional Node to parent the clone to.\r\n * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.\r\n *\r\n * Returns the clone.\r\n * @param name\r\n * @param newParent\r\n * @param doNotCloneChildren\r\n */\r\n public clone(name: string, newParent: Nullable<Node> = null, doNotCloneChildren?: boolean): InstancedMesh {\r\n const result = this._sourceMesh.createInstance(name);\r\n\r\n // Deep copy\r\n DeepCopier.DeepCopy(\r\n this,\r\n result,\r\n [\r\n \"name\",\r\n \"subMeshes\",\r\n \"uniqueId\",\r\n \"parent\",\r\n \"lightSources\",\r\n \"receiveShadows\",\r\n \"material\",\r\n \"visibility\",\r\n \"skeleton\",\r\n \"sourceMesh\",\r\n \"isAnInstance\",\r\n \"facetNb\",\r\n \"isFacetDataEnabled\",\r\n \"isBlocked\",\r\n \"useBones\",\r\n \"hasInstances\",\r\n \"collider\",\r\n \"edgesRenderer\",\r\n \"forward\",\r\n \"up\",\r\n \"right\",\r\n \"absolutePosition\",\r\n \"absoluteScaling\",\r\n \"absoluteRotationQuaternion\",\r\n \"isWorldMatrixFrozen\",\r\n \"nonUniformScaling\",\r\n \"behaviors\",\r\n \"worldMatrixFromCache\",\r\n \"hasThinInstances\",\r\n \"hasBoundingInfo\",\r\n ],\r\n []\r\n );\r\n\r\n // Bounding info\r\n this.refreshBoundingInfo();\r\n\r\n // Parent\r\n if (newParent) {\r\n result.parent = newParent;\r\n }\r\n\r\n if (!doNotCloneChildren) {\r\n // Children\r\n for (let index = 0; index < this.getScene().meshes.length; index++) {\r\n const mesh = this.getScene().meshes[index];\r\n\r\n if (mesh.parent === this) {\r\n mesh.clone(mesh.name, result);\r\n }\r\n }\r\n }\r\n\r\n result.computeWorldMatrix(true);\r\n\r\n this.onClonedObservable.notifyObservers(result);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Disposes the InstancedMesh.\r\n * Returns nothing.\r\n * @param doNotRecurse\r\n * @param disposeMaterialAndTextures\r\n */\r\n public dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {\r\n // Remove from mesh\r\n this._sourceMesh.removeInstance(this);\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * @param serializationObject\r\n * @hidden\r\n */\r\n public _serializeAsParent(serializationObject: any) {\r\n super._serializeAsParent(serializationObject);\r\n\r\n serializationObject.parentId = this._sourceMesh.uniqueId;\r\n serializationObject.parentInstanceIndex = this._indexInSourceMeshInstanceArray;\r\n }\r\n}\r\n\r\ndeclare module \"./mesh\" {\r\n export interface Mesh {\r\n /**\r\n * Register a custom buffer that will be instanced\r\n * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers\r\n * @param kind defines the buffer kind\r\n * @param stride defines the stride in floats\r\n */\r\n registerInstancedBuffer(kind: string, stride: number): void;\r\n\r\n /**\r\n * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).\r\n */\r\n _invalidateInstanceVertexArrayObject(): void;\r\n\r\n /**\r\n * true to use the edge renderer for all instances of this mesh\r\n */\r\n edgesShareWithInstances: boolean;\r\n\r\n /** @hidden */\r\n _userInstancedBuffersStorage: {\r\n data: { [key: string]: Float32Array };\r\n sizes: { [key: string]: number };\r\n vertexBuffers: { [key: string]: Nullable<VertexBuffer> };\r\n strides: { [key: string]: number };\r\n vertexArrayObjects?: { [key: string]: WebGLVertexArrayObject };\r\n };\r\n }\r\n}\r\n\r\ndeclare module \"./abstractMesh\" {\r\n export interface AbstractMesh {\r\n /**\r\n * Object used to store instanced buffers defined by user\r\n * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers\r\n */\r\n instancedBuffers: { [key: string]: any };\r\n }\r\n}\r\n\r\nMesh.prototype.registerInstancedBuffer = function (kind: string, stride: number): void {\r\n // Remove existing one\r\n this._userInstancedBuffersStorage?.vertexBuffers[kind]?.dispose();\r\n\r\n // Creates the instancedBuffer field if not present\r\n if (!this.instancedBuffers) {\r\n this.instancedBuffers = {};\r\n\r\n for (const instance of this.instances) {\r\n instance.instancedBuffers = {};\r\n }\r\n\r\n if (!this._userInstancedBuffersStorage) {\r\n this._userInstancedBuffersStorage = {\r\n data: {},\r\n vertexBuffers: {},\r\n strides: {},\r\n sizes: {},\r\n vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : undefined,\r\n };\r\n }\r\n }\r\n\r\n // Creates an empty property for this kind\r\n this.instancedBuffers[kind] = null;\r\n\r\n this._userInstancedBuffersStorage.strides[kind] = stride;\r\n this._userInstancedBuffersStorage.sizes[kind] = stride * 32; // Initial size\r\n this._userInstancedBuffersStorage.data[kind] = new Float32Array(this._userInstancedBuffersStorage.sizes[kind]);\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true);\r\n\r\n for (const instance of this.instances) {\r\n instance.instancedBuffers[kind] = null;\r\n }\r\n\r\n this._invalidateInstanceVertexArrayObject();\r\n\r\n this._markSubMeshesAsAttributesDirty();\r\n};\r\n\r\nMesh.prototype._processInstancedBuffers = function (visibleInstances: InstancedMesh[], renderSelf: boolean) {\r\n const instanceCount = visibleInstances.length;\r\n\r\n for (const kind in this.instancedBuffers) {\r\n let size = this._userInstancedBuffersStorage.sizes[kind];\r\n const stride = this._userInstancedBuffersStorage.strides[kind];\r\n\r\n // Resize if required\r\n const expectedSize = (instanceCount + 1) * stride;\r\n\r\n while (size < expectedSize) {\r\n size *= 2;\r\n }\r\n\r\n if (this._userInstancedBuffersStorage.data[kind].length != size) {\r\n this._userInstancedBuffersStorage.data[kind] = new Float32Array(size);\r\n this._userInstancedBuffersStorage.sizes[kind] = size;\r\n if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind]!.dispose();\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = null;\r\n }\r\n }\r\n\r\n const data = this._userInstancedBuffersStorage.data[kind];\r\n\r\n // Update data buffer\r\n let offset = 0;\r\n if (renderSelf) {\r\n const value = this.instancedBuffers[kind];\r\n\r\n if (value.toArray) {\r\n value.toArray(data, offset);\r\n } else if (value.copyToArray) {\r\n value.copyToArray(data, offset);\r\n } else {\r\n data[offset] = value;\r\n }\r\n\r\n offset += stride;\r\n }\r\n\r\n for (let instanceIndex = 0; instanceIndex < instanceCount; instanceIndex++) {\r\n const instance = visibleInstances[instanceIndex]!;\r\n\r\n const value = instance.instancedBuffers[kind];\r\n\r\n if (value.toArray) {\r\n value.toArray(data, offset);\r\n } else if (value.copyToArray) {\r\n value.copyToArray(data, offset);\r\n } else {\r\n data[offset] = value;\r\n }\r\n\r\n offset += stride;\r\n }\r\n\r\n // Update vertex buffer\r\n if (!this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = new VertexBuffer(\r\n this.getEngine(),\r\n this._userInstancedBuffersStorage.data[kind],\r\n kind,\r\n true,\r\n false,\r\n stride,\r\n true\r\n );\r\n this._invalidateInstanceVertexArrayObject();\r\n } else {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind]!.updateDirectly(data, 0);\r\n }\r\n }\r\n};\r\n\r\nMesh.prototype._invalidateInstanceVertexArrayObject = function () {\r\n if (!this._userInstancedBuffersStorage || this._userInstancedBuffersStorage.vertexArrayObjects === undefined) {\r\n return;\r\n }\r\n\r\n for (const kind in this._userInstancedBuffersStorage.vertexArrayObjects) {\r\n this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[kind]);\r\n }\r\n\r\n this._userInstancedBuffersStorage.vertexArrayObjects = {};\r\n};\r\n\r\nMesh.prototype._disposeInstanceSpecificData = function () {\r\n if (this._instanceDataStorage.instancesBuffer) {\r\n this._instanceDataStorage.instancesBuffer.dispose();\r\n this._instanceDataStorage.instancesBuffer = null;\r\n }\r\n\r\n while (this.instances.length) {\r\n this.instances[0].dispose();\r\n }\r\n\r\n for (const kind in this.instancedBuffers) {\r\n if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind]!.dispose();\r\n }\r\n }\r\n\r\n this._invalidateInstanceVertexArrayObject();\r\n\r\n this.instancedBuffers = {};\r\n};\r\n"]}
|
package/Meshes/mesh.js
CHANGED
|
@@ -2699,7 +2699,7 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
2699
2699
|
// Updating vertex buffers
|
|
2700
2700
|
for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
|
|
2701
2701
|
kind = kinds[kindIndex];
|
|
2702
|
-
this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
|
|
2702
|
+
this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable(), vbs[kind].getStrideSize());
|
|
2703
2703
|
}
|
|
2704
2704
|
// Updating submeshes
|
|
2705
2705
|
this.releaseSubMeshes();
|
|
@@ -3099,7 +3099,7 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
3099
3099
|
serializationObject.overrideMaterialSideOrientation = this.overrideMaterialSideOrientation;
|
|
3100
3100
|
// Parent
|
|
3101
3101
|
if (this.parent) {
|
|
3102
|
-
|
|
3102
|
+
this.parent._serializeAsParent(serializationObject);
|
|
3103
3103
|
}
|
|
3104
3104
|
// Geometry
|
|
3105
3105
|
serializationObject.isUnIndexed = this.isUnIndexed;
|
|
@@ -3174,7 +3174,7 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
3174
3174
|
scaling: instance.scaling.asArray()
|
|
3175
3175
|
};
|
|
3176
3176
|
if (instance.parent) {
|
|
3177
|
-
|
|
3177
|
+
instance.parent._serializeAsParent(serializationInstance);
|
|
3178
3178
|
}
|
|
3179
3179
|
if (instance.rotationQuaternion) {
|
|
3180
3180
|
serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
|
|
@@ -3374,6 +3374,9 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
3374
3374
|
if (parsedMesh.parentId !== undefined) {
|
|
3375
3375
|
mesh._waitingParentId = parsedMesh.parentId;
|
|
3376
3376
|
}
|
|
3377
|
+
if (parsedMesh.parentInstanceIndex !== undefined) {
|
|
3378
|
+
mesh._waitingParentInstanceIndex = parsedMesh.parentInstanceIndex;
|
|
3379
|
+
}
|
|
3377
3380
|
// Actions
|
|
3378
3381
|
if (parsedMesh.actions !== undefined) {
|
|
3379
3382
|
mesh._waitingData.actions = parsedMesh.actions;
|
|
@@ -3508,6 +3511,9 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
3508
3511
|
if (parsedInstance.parentId !== undefined) {
|
|
3509
3512
|
instance._waitingParentId = parsedInstance.parentId;
|
|
3510
3513
|
}
|
|
3514
|
+
if (parsedInstance.parentInstanceIndex !== undefined) {
|
|
3515
|
+
instance._waitingParentInstanceIndex = parsedInstance.parentInstanceIndex;
|
|
3516
|
+
}
|
|
3511
3517
|
if (parsedInstance.isEnabled !== undefined && parsedInstance.isEnabled !== null) {
|
|
3512
3518
|
instance.setEnabled(parsedInstance.isEnabled);
|
|
3513
3519
|
}
|