@babylonjs/core 8.24.1 → 8.25.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/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engineFactory.d.ts +4 -1
- package/Engines/engineFactory.js.map +1 -1
- package/Gizmos/positionGizmo.js +3 -3
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.js +3 -3
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.js +3 -3
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +21 -0
- package/Meshes/abstractMesh.hotSpot.js +37 -25
- package/Meshes/abstractMesh.hotSpot.js.map +1 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/instancedMesh.d.ts +1 -0
- package/Meshes/instancedMesh.js +3 -0
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +0 -19
- package/Meshes/mesh.js +0 -19
- package/Meshes/mesh.js.map +1 -1
- package/package.json +1 -1
|
@@ -106,6 +106,7 @@ export declare class InstancedMesh extends AbstractMesh {
|
|
|
106
106
|
copyVerticesData(kind: string, vertexData: {
|
|
107
107
|
[kind: string]: Float32Array;
|
|
108
108
|
}): void;
|
|
109
|
+
getVertexBuffer(kind: string, bypassInstanceData?: boolean): Nullable<VertexBuffer>;
|
|
109
110
|
/**
|
|
110
111
|
* Sets the vertex data of the mesh geometry for the requested `kind`.
|
|
111
112
|
* If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
|
package/Meshes/instancedMesh.js
CHANGED
|
@@ -191,6 +191,9 @@ export class InstancedMesh extends AbstractMesh {
|
|
|
191
191
|
copyVerticesData(kind, vertexData) {
|
|
192
192
|
this._sourceMesh.copyVerticesData(kind, vertexData);
|
|
193
193
|
}
|
|
194
|
+
getVertexBuffer(kind, bypassInstanceData) {
|
|
195
|
+
return this._sourceMesh.getVertexBuffer(kind, bypassInstanceData);
|
|
196
|
+
}
|
|
194
197
|
/**
|
|
195
198
|
* Sets the vertex data of the mesh geometry for the requested `kind`.
|
|
196
199
|
* If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instancedMesh.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/instancedMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIxC,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;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,IAAI,CAAC,qBAAqB,GAAG,CAAC,IAAY,EAAE,IAAU,EAAiB,EAAE;IACrE,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAE/C,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,QAAQ,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAE/B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtC,QAAQ,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAChE,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAEF;;GAEG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AAC,OAAO,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;YACxD,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QACpE,CAAC;IACL,CAAC;IAED,IAAI,CAAC,oCAAoC,EAAE,CAAC;IAE5C,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;AAC/B,CAAC,CAAC;AAEF,sBAAsB;AACtB,aAAa,CAAC,uBAAuB,EAAE,aAAa,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 type { IMeshDataOptions } from \"../Meshes/abstractMesh\";\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\nimport { Tools } from \"../Misc/tools\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport type { Geometry } from \"./geometry\";\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 /** @internal */\r\n public _indexInSourceMeshInstanceArray = -1;\r\n /** @internal */\r\n public _distanceToCamera: number = 0;\r\n /** @internal */\r\n public _previousWorldMatrix: Nullable<Matrix>;\r\n\r\n /**\r\n * Creates a new InstancedMesh object from the mesh source.\r\n * @param name defines the name of the instance\r\n * @param source the mesh to create the instance from\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 if (!source.skeleton && !source.morphTargetManager && source.hasBoundingInfo) {\r\n // without skeleton or morphTargetManager, use bounding info of source mesh directly\r\n const boundingInfo = source.getBoundingInfo();\r\n this.buildBoundingInfo(boundingInfo.minimum, boundingInfo.maximum);\r\n } else {\r\n this.refreshBoundingInfo(true, true);\r\n }\r\n this._syncSubMeshes();\r\n }\r\n\r\n /**\r\n * @returns the string \"InstancedMesh\".\r\n */\r\n public override getClassName(): string {\r\n return \"InstancedMesh\";\r\n }\r\n\r\n /** Gets the list of lights affecting that mesh */\r\n public override get lightSources(): Light[] {\r\n return this._sourceMesh._lightSources;\r\n }\r\n\r\n public override _resyncLightSources(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n public override _resyncLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n public override _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 override get receiveShadows(): boolean {\r\n return this._sourceMesh.receiveShadows;\r\n }\r\n\r\n public override set receiveShadows(_value: boolean) {\r\n if (this._sourceMesh?.receiveShadows !== _value) {\r\n Tools.Warn(\"Setting receiveShadows on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * The material of the source mesh\r\n */\r\n public override get material(): Nullable<Material> {\r\n return this._sourceMesh.material;\r\n }\r\n\r\n public override set material(_value: Nullable<Material>) {\r\n if (this._sourceMesh?.material !== _value) {\r\n Tools.Warn(\"Setting material on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * Visibility of the source mesh\r\n */\r\n public override get visibility(): number {\r\n return this._sourceMesh.visibility;\r\n }\r\n\r\n public override set visibility(_value: number) {\r\n if (this._sourceMesh?.visibility !== _value) {\r\n Tools.Warn(\"Setting visibility on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * Skeleton of the source mesh\r\n */\r\n public override get skeleton(): Nullable<Skeleton> {\r\n return this._sourceMesh.skeleton;\r\n }\r\n\r\n public override set skeleton(_value: Nullable<Skeleton>) {\r\n if (this._sourceMesh?.skeleton !== _value) {\r\n Tools.Warn(\"Setting skeleton on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * Rendering ground id of the source mesh\r\n */\r\n public override get renderingGroupId(): number {\r\n return this._sourceMesh.renderingGroupId;\r\n }\r\n\r\n public override 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 override 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 override 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 * Gets the mesh internal Geometry object\r\n */\r\n public override get geometry(): Nullable<Geometry> {\r\n return this._sourceMesh._geometry;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh object from the mesh model.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/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 * @returns {boolean} is it ready\r\n */\r\n public override 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 * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is\r\n * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.\r\n */\r\n public override getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray> {\r\n return this._sourceMesh.getVerticesData(kind, copyWhenShared, forceCopy);\r\n }\r\n\r\n public override copyVerticesData(kind: string, vertexData: { [kind: string]: Float32Array }): void {\r\n this._sourceMesh.copyVerticesData(kind, vertexData);\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 defines vertex data kind\r\n * @param data defines the data source\r\n * @param updatable defines if the data must be flagged as updatable (false as default)\r\n * @param stride defines the vertex stride (optional)\r\n * @returns the current mesh\r\n */\r\n public override 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 defines vertex data kind\r\n * @param data defines the data source\r\n * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for \"position\" kind\r\n * @param makeItUnique defines it the updated vertex buffer must be flagged as unique (false by default)\r\n * @returns the source mesh\r\n */\r\n public override 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 the source data\r\n * @param totalVertices defines the total number of vertices referenced by indices (could be null)\r\n * @returns source mesh\r\n */\r\n public override 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 defines which buffer to check (positions, indices, normals, etc). 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 * @returns true if data kind is present\r\n */\r\n public override 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 override getIndices(): Nullable<IndicesArray> {\r\n return this._sourceMesh.getIndices();\r\n }\r\n\r\n public override get _positions(): Nullable<Vector3[]> {\r\n return this._sourceMesh._positions;\r\n }\r\n\r\n public override refreshBoundingInfo(applySkeletonOrOptions: boolean | IMeshDataOptions = false, applyMorph: boolean = false): InstancedMesh {\r\n if (this.hasBoundingInfo && this.getBoundingInfo().isLocked) {\r\n return this;\r\n }\r\n\r\n let options: IMeshDataOptions;\r\n if (typeof applySkeletonOrOptions === \"object\") {\r\n options = applySkeletonOrOptions;\r\n } else {\r\n options = {\r\n applySkeleton: applySkeletonOrOptions,\r\n applyMorph: applyMorph,\r\n };\r\n }\r\n\r\n const bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;\r\n this._refreshBoundingInfo(this._sourceMesh._getData(options, null, VertexBuffer.PositionKind), bias);\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n public override _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 * @internal\r\n */\r\n public override _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 /** @internal */\r\n public override _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 override getWorldMatrix(): Matrix {\r\n if (\r\n this._currentLOD &&\r\n this._currentLOD !== this._sourceMesh &&\r\n this._currentLOD.billboardMode !== TransformNode.BILLBOARDMODE_NONE &&\r\n this._currentLOD._masterMesh !== this\r\n ) {\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 override 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 defines the camera to use to pick the LOD level\r\n * @returns a Mesh or `null` if no LOD is associated with the AbstractMesh\r\n */\r\n public override 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 * @internal\r\n */\r\n public override _preActivateForIntermediateRendering(renderId: number): Mesh {\r\n return this.sourceMesh._preActivateForIntermediateRendering(renderId);\r\n }\r\n\r\n /** @internal */\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 /** @internal */\r\n public override _generatePointsArray(): boolean {\r\n return this._sourceMesh._generatePointsArray();\r\n }\r\n\r\n /** @internal */\r\n public override _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 *\r\n * Returns the clone.\r\n * @param name the cloned mesh name\r\n * @param newParent the optional Node to parent the clone to.\r\n * @param doNotCloneChildren if `true` the model children aren't cloned.\r\n * @param newSourceMesh if set this mesh will be used as the source mesh instead of ths instance's one\r\n * @returns the clone\r\n */\r\n public override clone(name: string, newParent: Nullable<Node> = null, doNotCloneChildren?: boolean, newSourceMesh?: Mesh): InstancedMesh {\r\n const result = (newSourceMesh || 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 \"geometry\",\r\n ],\r\n []\r\n );\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 Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public override 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 * @internal\r\n */\r\n public override _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\n * Instantiate (when possible) or clone that node with its hierarchy\r\n * @param newParent defines the new parent to use for the instance (or clone)\r\n * @param options defines options to configure how copy is done\r\n * @param options.doNotInstantiate defines if the model must be instantiated or just cloned\r\n * @param options.newSourcedMesh newSourcedMesh the new source mesh for the instance (or clone)\r\n * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created\r\n * @returns an instance (or a clone) of the current node with its hierarchy\r\n */\r\n public override instantiateHierarchy(\r\n newParent: Nullable<TransformNode> = null,\r\n options?: { doNotInstantiate: boolean | ((node: TransformNode) => boolean); newSourcedMesh?: Mesh },\r\n onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void\r\n ): Nullable<TransformNode> {\r\n const clone = this.clone(\"Clone of \" + (this.name || this.id), newParent || this.parent, true, options && options.newSourcedMesh);\r\n\r\n if (clone) {\r\n if (onNewNodeCreated) {\r\n onNewNodeCreated(this, clone);\r\n }\r\n }\r\n\r\n for (const child of this.getChildTransformNodes(true)) {\r\n child.instantiateHierarchy(clone, options, onNewNodeCreated);\r\n }\r\n\r\n return clone;\r\n }\r\n}\r\n\r\ndeclare module \"./mesh\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface Mesh {\r\n /**\r\n * Register a custom buffer that will be instanced\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/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 /** @internal */\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 renderPasses?: {\r\n [renderPassId: number]: { [kind: string]: Nullable<VertexBuffer> };\r\n };\r\n };\r\n }\r\n}\r\n\r\ndeclare module \"./abstractMesh\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\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/features/featuresDeepDive/mesh/copies/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\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 // 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: Nullable<InstancedMesh[]>, renderSelf: boolean) {\r\n const instanceCount = visibleInstances ? visibleInstances.length : 0;\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() as ThinEngine).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 for (const renderPassId in this._instanceDataStorage.renderPasses) {\r\n this._instanceDataStorage.renderPasses[renderPassId].instancesBuffer?.dispose();\r\n }\r\n this._instanceDataStorage.renderPasses = {};\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\r\n// Register Class Name\r\nRegisterClass(\"BABYLON.InstancedMesh\", InstancedMesh);\r\n"]}
|
|
1
|
+
{"version":3,"file":"instancedMesh.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/instancedMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIxC,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;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,IAAI,CAAC,qBAAqB,GAAG,CAAC,IAAY,EAAE,IAAU,EAAiB,EAAE;IACrE,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAE/C,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,QAAQ,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAE/B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtC,QAAQ,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAChE,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAY;IAY3C;;;;OAIG;IACH,YAAY,IAAY,EAAE,MAAY;QAClC,KAAK,CAAC,IAAI,EAAE,MAAM,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AAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;YACxD,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QACpE,CAAC;IACL,CAAC;IAED,IAAI,CAAC,oCAAoC,EAAE,CAAC;IAE5C,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;AAC/B,CAAC,CAAC;AAEF,sBAAsB;AACtB,aAAa,CAAC,uBAAuB,EAAE,aAAa,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 type { IMeshDataOptions } from \"../Meshes/abstractMesh\";\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\nimport { Tools } from \"../Misc/tools\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport type { Geometry } from \"./geometry\";\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 /** @internal */\r\n public _indexInSourceMeshInstanceArray = -1;\r\n /** @internal */\r\n public _distanceToCamera: number = 0;\r\n /** @internal */\r\n public _previousWorldMatrix: Nullable<Matrix>;\r\n\r\n /**\r\n * Creates a new InstancedMesh object from the mesh source.\r\n * @param name defines the name of the instance\r\n * @param source the mesh to create the instance from\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 if (!source.skeleton && !source.morphTargetManager && source.hasBoundingInfo) {\r\n // without skeleton or morphTargetManager, use bounding info of source mesh directly\r\n const boundingInfo = source.getBoundingInfo();\r\n this.buildBoundingInfo(boundingInfo.minimum, boundingInfo.maximum);\r\n } else {\r\n this.refreshBoundingInfo(true, true);\r\n }\r\n this._syncSubMeshes();\r\n }\r\n\r\n /**\r\n * @returns the string \"InstancedMesh\".\r\n */\r\n public override getClassName(): string {\r\n return \"InstancedMesh\";\r\n }\r\n\r\n /** Gets the list of lights affecting that mesh */\r\n public override get lightSources(): Light[] {\r\n return this._sourceMesh._lightSources;\r\n }\r\n\r\n public override _resyncLightSources(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n public override _resyncLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n public override _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 override get receiveShadows(): boolean {\r\n return this._sourceMesh.receiveShadows;\r\n }\r\n\r\n public override set receiveShadows(_value: boolean) {\r\n if (this._sourceMesh?.receiveShadows !== _value) {\r\n Tools.Warn(\"Setting receiveShadows on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * The material of the source mesh\r\n */\r\n public override get material(): Nullable<Material> {\r\n return this._sourceMesh.material;\r\n }\r\n\r\n public override set material(_value: Nullable<Material>) {\r\n if (this._sourceMesh?.material !== _value) {\r\n Tools.Warn(\"Setting material on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * Visibility of the source mesh\r\n */\r\n public override get visibility(): number {\r\n return this._sourceMesh.visibility;\r\n }\r\n\r\n public override set visibility(_value: number) {\r\n if (this._sourceMesh?.visibility !== _value) {\r\n Tools.Warn(\"Setting visibility on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * Skeleton of the source mesh\r\n */\r\n public override get skeleton(): Nullable<Skeleton> {\r\n return this._sourceMesh.skeleton;\r\n }\r\n\r\n public override set skeleton(_value: Nullable<Skeleton>) {\r\n if (this._sourceMesh?.skeleton !== _value) {\r\n Tools.Warn(\"Setting skeleton on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * Rendering ground id of the source mesh\r\n */\r\n public override get renderingGroupId(): number {\r\n return this._sourceMesh.renderingGroupId;\r\n }\r\n\r\n public override 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 override 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 override 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 * Gets the mesh internal Geometry object\r\n */\r\n public override get geometry(): Nullable<Geometry> {\r\n return this._sourceMesh._geometry;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh object from the mesh model.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/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 * @returns {boolean} is it ready\r\n */\r\n public override 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 * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is\r\n * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.\r\n */\r\n public override getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray> {\r\n return this._sourceMesh.getVerticesData(kind, copyWhenShared, forceCopy);\r\n }\r\n\r\n public override copyVerticesData(kind: string, vertexData: { [kind: string]: Float32Array }): void {\r\n this._sourceMesh.copyVerticesData(kind, vertexData);\r\n }\r\n\r\n public override getVertexBuffer(kind: string, bypassInstanceData?: boolean): Nullable<VertexBuffer> {\r\n return this._sourceMesh.getVertexBuffer(kind, bypassInstanceData);\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 defines vertex data kind\r\n * @param data defines the data source\r\n * @param updatable defines if the data must be flagged as updatable (false as default)\r\n * @param stride defines the vertex stride (optional)\r\n * @returns the current mesh\r\n */\r\n public override 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 defines vertex data kind\r\n * @param data defines the data source\r\n * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for \"position\" kind\r\n * @param makeItUnique defines it the updated vertex buffer must be flagged as unique (false by default)\r\n * @returns the source mesh\r\n */\r\n public override 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 the source data\r\n * @param totalVertices defines the total number of vertices referenced by indices (could be null)\r\n * @returns source mesh\r\n */\r\n public override 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 defines which buffer to check (positions, indices, normals, etc). 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 * @returns true if data kind is present\r\n */\r\n public override 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 override getIndices(): Nullable<IndicesArray> {\r\n return this._sourceMesh.getIndices();\r\n }\r\n\r\n public override get _positions(): Nullable<Vector3[]> {\r\n return this._sourceMesh._positions;\r\n }\r\n\r\n public override refreshBoundingInfo(applySkeletonOrOptions: boolean | IMeshDataOptions = false, applyMorph: boolean = false): InstancedMesh {\r\n if (this.hasBoundingInfo && this.getBoundingInfo().isLocked) {\r\n return this;\r\n }\r\n\r\n let options: IMeshDataOptions;\r\n if (typeof applySkeletonOrOptions === \"object\") {\r\n options = applySkeletonOrOptions;\r\n } else {\r\n options = {\r\n applySkeleton: applySkeletonOrOptions,\r\n applyMorph: applyMorph,\r\n };\r\n }\r\n\r\n const bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;\r\n this._refreshBoundingInfo(this._sourceMesh._getData(options, null, VertexBuffer.PositionKind), bias);\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n public override _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 * @internal\r\n */\r\n public override _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 /** @internal */\r\n public override _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 override getWorldMatrix(): Matrix {\r\n if (\r\n this._currentLOD &&\r\n this._currentLOD !== this._sourceMesh &&\r\n this._currentLOD.billboardMode !== TransformNode.BILLBOARDMODE_NONE &&\r\n this._currentLOD._masterMesh !== this\r\n ) {\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 override 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 defines the camera to use to pick the LOD level\r\n * @returns a Mesh or `null` if no LOD is associated with the AbstractMesh\r\n */\r\n public override 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 * @internal\r\n */\r\n public override _preActivateForIntermediateRendering(renderId: number): Mesh {\r\n return this.sourceMesh._preActivateForIntermediateRendering(renderId);\r\n }\r\n\r\n /** @internal */\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 /** @internal */\r\n public override _generatePointsArray(): boolean {\r\n return this._sourceMesh._generatePointsArray();\r\n }\r\n\r\n /** @internal */\r\n public override _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 *\r\n * Returns the clone.\r\n * @param name the cloned mesh name\r\n * @param newParent the optional Node to parent the clone to.\r\n * @param doNotCloneChildren if `true` the model children aren't cloned.\r\n * @param newSourceMesh if set this mesh will be used as the source mesh instead of ths instance's one\r\n * @returns the clone\r\n */\r\n public override clone(name: string, newParent: Nullable<Node> = null, doNotCloneChildren?: boolean, newSourceMesh?: Mesh): InstancedMesh {\r\n const result = (newSourceMesh || 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 \"geometry\",\r\n ],\r\n []\r\n );\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 Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public override 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 * @internal\r\n */\r\n public override _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\n * Instantiate (when possible) or clone that node with its hierarchy\r\n * @param newParent defines the new parent to use for the instance (or clone)\r\n * @param options defines options to configure how copy is done\r\n * @param options.doNotInstantiate defines if the model must be instantiated or just cloned\r\n * @param options.newSourcedMesh newSourcedMesh the new source mesh for the instance (or clone)\r\n * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created\r\n * @returns an instance (or a clone) of the current node with its hierarchy\r\n */\r\n public override instantiateHierarchy(\r\n newParent: Nullable<TransformNode> = null,\r\n options?: { doNotInstantiate: boolean | ((node: TransformNode) => boolean); newSourcedMesh?: Mesh },\r\n onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void\r\n ): Nullable<TransformNode> {\r\n const clone = this.clone(\"Clone of \" + (this.name || this.id), newParent || this.parent, true, options && options.newSourcedMesh);\r\n\r\n if (clone) {\r\n if (onNewNodeCreated) {\r\n onNewNodeCreated(this, clone);\r\n }\r\n }\r\n\r\n for (const child of this.getChildTransformNodes(true)) {\r\n child.instantiateHierarchy(clone, options, onNewNodeCreated);\r\n }\r\n\r\n return clone;\r\n }\r\n}\r\n\r\ndeclare module \"./mesh\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface Mesh {\r\n /**\r\n * Register a custom buffer that will be instanced\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/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 /** @internal */\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 renderPasses?: {\r\n [renderPassId: number]: { [kind: string]: Nullable<VertexBuffer> };\r\n };\r\n };\r\n }\r\n}\r\n\r\ndeclare module \"./abstractMesh\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\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/features/featuresDeepDive/mesh/copies/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\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 // 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: Nullable<InstancedMesh[]>, renderSelf: boolean) {\r\n const instanceCount = visibleInstances ? visibleInstances.length : 0;\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() as ThinEngine).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 for (const renderPassId in this._instanceDataStorage.renderPasses) {\r\n this._instanceDataStorage.renderPasses[renderPassId].instancesBuffer?.dispose();\r\n }\r\n this._instanceDataStorage.renderPasses = {};\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\r\n// Register Class Name\r\nRegisterClass(\"BABYLON.InstancedMesh\", InstancedMesh);\r\n"]}
|
package/Meshes/mesh.d.ts
CHANGED
|
@@ -485,25 +485,6 @@ export declare class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
|
485
485
|
copyVerticesData(kind: string, vertexData: {
|
|
486
486
|
[kind: string]: Float32Array;
|
|
487
487
|
}): void;
|
|
488
|
-
/**
|
|
489
|
-
* Returns the mesh VertexBuffer object from the requested `kind`
|
|
490
|
-
* @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
|
|
491
|
-
* - VertexBuffer.PositionKind
|
|
492
|
-
* - VertexBuffer.NormalKind
|
|
493
|
-
* - VertexBuffer.UVKind
|
|
494
|
-
* - VertexBuffer.UV2Kind
|
|
495
|
-
* - VertexBuffer.UV3Kind
|
|
496
|
-
* - VertexBuffer.UV4Kind
|
|
497
|
-
* - VertexBuffer.UV5Kind
|
|
498
|
-
* - VertexBuffer.UV6Kind
|
|
499
|
-
* - VertexBuffer.ColorKind
|
|
500
|
-
* - VertexBuffer.MatricesIndicesKind
|
|
501
|
-
* - VertexBuffer.MatricesIndicesExtraKind
|
|
502
|
-
* - VertexBuffer.MatricesWeightsKind
|
|
503
|
-
* - VertexBuffer.MatricesWeightsExtraKind
|
|
504
|
-
* @param bypassInstanceData defines a boolean indicating that the function should not take into account the instance data (applies only if the mesh has instances). Default: false
|
|
505
|
-
* @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
|
|
506
|
-
*/
|
|
507
488
|
getVertexBuffer(kind: string, bypassInstanceData?: boolean): Nullable<VertexBuffer>;
|
|
508
489
|
/**
|
|
509
490
|
* Tests if a specific vertex buffer is associated with this mesh
|
package/Meshes/mesh.js
CHANGED
|
@@ -848,25 +848,6 @@ export class Mesh extends AbstractMesh {
|
|
|
848
848
|
this._geometry.copyVerticesData(kind, vertexData);
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
|
-
/**
|
|
852
|
-
* Returns the mesh VertexBuffer object from the requested `kind`
|
|
853
|
-
* @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
|
|
854
|
-
* - VertexBuffer.PositionKind
|
|
855
|
-
* - VertexBuffer.NormalKind
|
|
856
|
-
* - VertexBuffer.UVKind
|
|
857
|
-
* - VertexBuffer.UV2Kind
|
|
858
|
-
* - VertexBuffer.UV3Kind
|
|
859
|
-
* - VertexBuffer.UV4Kind
|
|
860
|
-
* - VertexBuffer.UV5Kind
|
|
861
|
-
* - VertexBuffer.UV6Kind
|
|
862
|
-
* - VertexBuffer.ColorKind
|
|
863
|
-
* - VertexBuffer.MatricesIndicesKind
|
|
864
|
-
* - VertexBuffer.MatricesIndicesExtraKind
|
|
865
|
-
* - VertexBuffer.MatricesWeightsKind
|
|
866
|
-
* - VertexBuffer.MatricesWeightsExtraKind
|
|
867
|
-
* @param bypassInstanceData defines a boolean indicating that the function should not take into account the instance data (applies only if the mesh has instances). Default: false
|
|
868
|
-
* @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
|
|
869
|
-
*/
|
|
870
851
|
getVertexBuffer(kind, bypassInstanceData) {
|
|
871
852
|
if (!this._geometry) {
|
|
872
853
|
return null;
|