@babylonjs/core 8.55.0 → 8.55.1
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/webgpuEngine.js +1 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.d.ts +8 -1
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js +9 -0
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js.map +1 -1
- package/Layers/thinSelectionOutlineLayer.js +10 -0
- package/Layers/thinSelectionOutlineLayer.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.js +3 -1
- package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
- package/Meshes/instancedMesh.js +51 -8
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.js +6 -0
- package/Meshes/mesh.js.map +1 -1
- package/Misc/tools.js +1 -1
- package/Misc/tools.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clusteredLightContainer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Lights/Clustered/clusteredLightContainer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,uCAAmC;AAG3D,OAAO,EAAE,SAAS,EAAE,mCAA+B;AAInD,OAAO,EAAE,cAAc,EAAE,0CAAsC;AAC/D,OAAO,EAAE,UAAU,EAAE,+CAA2C;AAChE,OAAO,EAAE,mBAAmB,EAAE,wDAAoD;AAClF,OAAO,EAAE,aAAa,EAAE,yCAAqC;AAC7D,OAAO,EAAE,SAAS,EAAE,kCAA8B;AAClD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,mCAA+B;AAC7D,OAAO,EAAE,WAAW,EAAE,8CAA0C;AAEhE,OAAO,EAAE,SAAS,EAAE,iCAA6B;AACjD,OAAO,EAAE,WAAW,EAAE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G,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC3E,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACH,MAAO,CAAC,gBAAgB,CAAC,gBAAgB,GAAG,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACjG,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,UAAU,CAAC,iBAAiB,GAAG,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,4BAA4B,CAAC,OAAe;QACxD,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,2BAA2B,CAAC,OAAY,EAAE,UAAkB;QACxE,OAAO,CAAC,YAAY,GAAG,UAAU,CAAC,GAAG,IAAI,CAAC;QAC1C,OAAO,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;QAC9C,OAAO,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;IACrD,CAAC;IAEe,QAAQ;QACpB,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;;AApfD,gBAAgB;AACF,qDAA6B,GAA2B,GAAG,EAAE;IACvE,MAAM,WAAW,CAAC,iCAAiC,CAAC,CAAC;AACzD,CAAC,AAF0C,CAEzC;AAsCF;IADC,SAAS,EAAE;8DAGX;AAiBD;IADC,SAAS,EAAE;4DAGX;AAmDD;IADC,SAAS,EAAE;uDAGX;AAoYL,sBAAsB;AACtB,aAAa,CAAC,iCAAiC,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import { StorageBuffer } from \"core/Buffers/storageBuffer\";\nimport type { Camera } from \"core/Cameras/camera\";\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\nimport { Constants } from \"core/Engines/constants\";\nimport type { WebGPUEngine } from \"core/Engines/webgpuEngine\";\nimport type { Effect } from \"core/Materials/effect\";\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\nimport { ShaderMaterial } from \"core/Materials/shaderMaterial\";\nimport { RawTexture } from \"core/Materials/Textures/rawTexture\";\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\nimport { UniformBuffer } from \"core/Materials/uniformBuffer\";\nimport { TmpColors } from \"core/Maths/math.color\";\nimport { TmpVectors, Vector3 } from \"core/Maths/math.vector\";\nimport { CreatePlane } from \"core/Meshes/Builders/planeBuilder\";\nimport type { Mesh } from \"core/Meshes/mesh\";\nimport { serialize } from \"core/Misc/decorators\";\nimport { _WarnImport } from \"core/Misc/devTools\";\nimport { Logger } from \"core/Misc/logger\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { Node } from \"core/node\";\nimport type { Scene } from \"core/scene\";\nimport type { Nullable } from \"core/types\";\n\nimport { Light } from \"../light\";\nimport { LightConstants } from \"../lightConstants\";\nimport type { PointLight } from \"../pointLight\";\nimport type { SpotLight } from \"../spotLight\";\nimport type { RenderTargetWrapper } from \"../../Engines/renderTargetWrapper\";\n\nimport \"core/Meshes/thinInstanceMesh\";\n\nNode.AddNodeConstructor(\"Light_Type_5\", (name, scene) => {\n return () => new ClusteredLightContainer(name, [], scene);\n});\n\nconst DefaultDepthSlices = 16;\n\n/**\n * A special light that renders all its associated spot or point lights using a clustered or forward+ system.\n */\nexport class ClusteredLightContainer extends Light {\n private static _GetEngineBatchSize(engine: AbstractEngine): number {\n const caps = engine._caps;\n if (!caps.texelFetch) {\n return 0;\n } else if (engine.isWebGPU) {\n // On WebGPU we use atomic writes to storage textures\n return 32;\n } else if (engine.version > 1) {\n // On WebGL 2 we use additive float blending as the light mask\n if (!caps.colorBufferFloat || !caps.blendFloat) {\n return 0;\n }\n // Due to the use of floats we want to limit lights to the precision of floats\n return caps.shaderFloatPrecision;\n } else {\n // WebGL 1 is not supported due to lack of dynamic for loops\n return 0;\n }\n }\n\n /**\n * Checks if the clustered lighting system supports the given light with its current parameters.\n * This will also check if the light's associated engine supports clustered lighting.\n *\n * @param light The light to test\n * @returns true if the light and its engine is supported\n */\n public static IsLightSupported(light: Light): boolean {\n if (ClusteredLightContainer._GetEngineBatchSize(light.getEngine()) === 0) {\n return false;\n }\n\n if (light.shadowEnabled && light._scene.shadowsEnabled && light.getShadowGenerators()) {\n // Shadows are not supported\n return false;\n }\n\n if (light.falloffType !== Light.FALLOFF_DEFAULT) {\n // Only the default falloff is supported\n return false;\n }\n\n if (light.getTypeID() === LightConstants.LIGHTTYPEID_POINTLIGHT) {\n return true;\n }\n\n if (light.getTypeID() === LightConstants.LIGHTTYPEID_SPOTLIGHT) {\n // Extra texture bindings per light are not supported\n return !(<SpotLight>light).projectionTexture && !(<SpotLight>light).iesProfileTexture;\n }\n\n // Currently only point and spot lights are supported\n return false;\n }\n\n /** @internal */\n public static _SceneComponentInitialization: (scene: Scene) => void = () => {\n throw _WarnImport(\"ClusteredLightingSceneComponent\");\n };\n\n private readonly _batchSize: number;\n\n /**\n * True if clustered lighting is supported.\n */\n public get isSupported(): boolean {\n return this._batchSize > 0;\n }\n\n private readonly _lights: Light[] = [];\n /**\n * Gets the current list of lights added to this clustering system.\n */\n public get lights(): readonly Light[] {\n return this._lights;\n }\n\n private _camera: Nullable<Camera> = null;\n\n // The lights sorted by depth\n private readonly _sortedLights: (PointLight | SpotLight)[] = [];\n\n private _lightDataBuffer: Float32Array;\n private _lightDataTexture: RawTexture;\n private _lightDataRenderId = -1;\n\n private _tileMaskBatches = -1;\n private _tileMaskTexture: RenderTargetTexture;\n private _tileMaskBuffer: Nullable<StorageBuffer>;\n\n private _horizontalTiles = 64;\n /**\n * The number of tiles in the horizontal direction to cluster lights into.\n * A lower value will reduce memory and make the clustering step faster, while a higher value increases memory and makes the rendering step faster.\n */\n @serialize()\n public get horizontalTiles(): number {\n return this._horizontalTiles;\n }\n\n public set horizontalTiles(horizontal: number) {\n if (this._horizontalTiles === horizontal) {\n return;\n }\n this._horizontalTiles = horizontal;\n // Force the batch data to be recreated\n this._tileMaskBatches = -1;\n }\n\n private _verticalTiles = 64;\n /**\n * The number of tiles in the vertical direction to cluster lights into.\n * A lower value will reduce memory and make the clustering step faster, while a higher value increases memory and makes the rendering step faster.\n */\n @serialize()\n public get verticalTiles(): number {\n return this._verticalTiles;\n }\n\n public set verticalTiles(vertical: number) {\n if (this._verticalTiles === vertical) {\n return;\n }\n this._verticalTiles = vertical;\n // Force the batch data to be recreated\n this._tileMaskBatches = -1;\n }\n\n private _sliceScale = 0;\n private _sliceBias = 0;\n // List of vec2's that keep track of the min and max index per slice\n private _sliceRanges: Float32Array<ArrayBuffer>;\n\n private _depthSlices = DefaultDepthSlices;\n /**\n * The number of slices to split the depth range by and cluster lights into.\n */\n public get depthSlices(): number {\n return this._depthSlices;\n }\n\n public set depthSlices(slices: number) {\n if (this._depthSlices === slices) {\n return;\n }\n this._depthSlices = slices;\n this._sliceRanges = new Float32Array(slices * 2);\n\n // UBO size depends on the number of depth slices\n this._uniformBuffer.dispose();\n this._uniformBuffer = new UniformBuffer(this.getEngine(), undefined, undefined, this.name);\n this._buildUniformLayout();\n\n // CLUSTLIGHT_SLICES is a shader define that sizes the vSliceRanges array in the UBO.\n // Materials must recompile when depthSlices changes so the shader layout matches the rebuilt UBO.\n // Otherwise, if depthSlices is reduced, the rebuilt UBO can be smaller than what the previously compiled shader expects, causing rendering to fail.\n this._markMeshesAsLightDirty();\n }\n\n private readonly _proxyMaterial: ShaderMaterial;\n private readonly _proxyMesh: Mesh;\n\n private _maxRange = 16383;\n private _minInverseSquaredRange = 1 / (this._maxRange * this._maxRange);\n /**\n * This limits the range of all the added lights, so even lights with extreme ranges will still have bounds for clustering.\n */\n @serialize()\n public get maxRange(): number {\n return this._maxRange;\n }\n\n public set maxRange(range: number) {\n if (this._maxRange === range) {\n return;\n }\n this._maxRange = range;\n this._minInverseSquaredRange = 1 / (range * range);\n }\n\n /**\n * Creates a new clustered light system with an initial set of lights.\n *\n * @param name The name of the clustered light container\n * @param lights The initial set of lights to add\n * @param scene The scene the clustered light container belongs to\n */\n constructor(name: string, lights: Light[] = [], scene?: Scene) {\n super(name, scene);\n const engine = this.getEngine();\n this._batchSize = ClusteredLightContainer._GetEngineBatchSize(engine);\n\n const proxyShader = { vertex: \"lightProxy\", fragment: \"lightProxy\" };\n const defines = [`CLUSTLIGHT_BATCH ${this._batchSize}`];\n if (this._scene.useRightHandedSystem) {\n defines.push(\"#define RIGHT_HANDED\");\n }\n this._proxyMaterial = new ShaderMaterial(\"ProxyMaterial\", this._scene, proxyShader, {\n attributes: [\"position\"],\n uniforms: [\"view\", \"projection\", \"tileMaskResolution\"],\n samplers: [\"lightDataTexture\"],\n uniformBuffers: [\"Scene\"],\n storageBuffers: [\"tileMaskBuffer\"],\n defines,\n shaderLanguage: engine.isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\n extraInitializationsAsync: async () => {\n if (engine.isWebGPU) {\n await Promise.all([import(\"../../ShadersWGSL/lightProxy.vertex\"), import(\"../../ShadersWGSL/lightProxy.fragment\")]);\n } else {\n await Promise.all([import(\"../../Shaders/lightProxy.vertex\"), import(\"../../Shaders/lightProxy.fragment\")]);\n }\n },\n });\n\n // Additive blending is for merging masks on WebGL\n this._proxyMaterial.transparencyMode = ShaderMaterial.MATERIAL_ALPHABLEND;\n this._proxyMaterial.alphaMode = Constants.ALPHA_ADD;\n this._proxyMaterial.sideOrientation = Constants.MATERIAL_CounterClockWiseSideOrientation;\n\n this._proxyMesh = CreatePlane(\"ProxyMesh\", { size: 2 }, this._scene);\n // Make sure it doesn't render for the default scene\n this._scene.removeMesh(this._proxyMesh);\n this._proxyMesh.material = this._proxyMaterial;\n\n this._updateBatches();\n\n this._sliceRanges = new Float32Array(this._depthSlices * 2);\n\n if (this._batchSize > 0) {\n ClusteredLightContainer._SceneComponentInitialization(this._scene);\n for (const light of lights) {\n this.addLight(light);\n }\n }\n }\n\n public override getClassName(): string {\n return \"ClusteredLightContainer\";\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public override getTypeID(): number {\n return LightConstants.LIGHTTYPEID_CLUSTERED_CONTAINER;\n }\n\n /** @internal */\n public _updateBatches(camera: Nullable<Camera> = null): RenderTargetTexture {\n this._camera = camera;\n this._proxyMesh.isVisible = this._sortedLights.length > 0;\n\n // Ensure space for atleast 1 batch\n const batches = Math.max(Math.ceil(this._sortedLights.length / this._batchSize), 1);\n if (this._tileMaskBatches >= batches) {\n this._proxyMesh.thinInstanceCount = this._sortedLights.length;\n return this._tileMaskTexture;\n }\n const engine = this.getEngine();\n // Round up to a batch size so we don't have to reallocate as often\n const maxLights = batches * this._batchSize;\n\n this._lightDataBuffer = new Float32Array(20 * maxLights);\n this._lightDataTexture?.dispose();\n this._lightDataTexture = new RawTexture(\n this._lightDataBuffer,\n 5,\n maxLights,\n Constants.TEXTUREFORMAT_RGBA,\n this._scene,\n false,\n false,\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\n Constants.TEXTURETYPE_FLOAT\n );\n this._lightDataTexture.name = \"LightDataTexture_clustered_\" + this.name;\n this._proxyMaterial.setTexture(\"lightDataTexture\", this._lightDataTexture);\n\n this._tileMaskTexture?.dispose();\n const textureSize = { width: this._horizontalTiles, height: this._verticalTiles };\n if (!engine.isWebGPU) {\n // In WebGL we shift the light proxy by the batch number\n textureSize.height *= batches;\n }\n this._tileMaskTexture = new RenderTargetTexture(\"TileMaskTexture\", textureSize, this._scene, {\n // We don't write anything on WebGPU so make it as small as possible\n type: engine.isWebGPU ? Constants.TEXTURETYPE_UNSIGNED_BYTE : Constants.TEXTURETYPE_FLOAT,\n format: Constants.TEXTUREFORMAT_RED,\n generateDepthBuffer: false,\n });\n\n this._tileMaskTexture.renderParticles = false;\n this._tileMaskTexture.renderSprites = false;\n this._tileMaskTexture.noPrePassRenderer = true;\n this._tileMaskTexture.renderList = [this._proxyMesh];\n\n let currentRenderTarget: Nullable<RenderTargetWrapper> = null;\n\n this._tileMaskTexture.onBeforeBindObservable.add(() => {\n currentRenderTarget = engine._currentRenderTarget;\n this._updateLightData();\n });\n\n this._tileMaskTexture.onAfterUnbindObservable.add(() => {\n if (engine._currentRenderTarget !== currentRenderTarget) {\n if (!currentRenderTarget) {\n engine.restoreDefaultFramebuffer();\n } else {\n engine.bindFramebuffer(currentRenderTarget);\n }\n }\n });\n\n this._tileMaskTexture.onClearObservable.add(() => {\n if (engine.isWebGPU) {\n // Clear the storage buffer for WebGPU\n this._tileMaskBuffer?.clear();\n } else {\n // Only clear the texture on WebGL\n engine.clear({ r: 0, g: 0, b: 0, a: 1 }, true, false);\n }\n });\n\n if (engine.isWebGPU) {\n // WebGPU also needs a storage buffer to write to\n this._tileMaskBuffer?.dispose();\n const bufferSize = this._horizontalTiles * this._verticalTiles * batches * 4;\n this._tileMaskBuffer = new StorageBuffer(<WebGPUEngine>engine, bufferSize);\n this._proxyMaterial.setStorageBuffer(\"tileMaskBuffer\", this._tileMaskBuffer);\n }\n\n this._proxyMaterial.setVector3(\"tileMaskResolution\", new Vector3(this._horizontalTiles, this.verticalTiles, batches));\n\n // We don't actually use the matrix data but we need enough capacity for the lights\n this._proxyMesh.thinInstanceSetBuffer(\"matrix\", new Float32Array(maxLights * 16));\n this._proxyMesh.thinInstanceCount = this._sortedLights.length;\n this._tileMaskBatches = batches;\n return this._tileMaskTexture;\n }\n\n private _getSliceIndex(camera: Camera, depth: number): number {\n if (depth < camera.minZ) {\n // Prevent calling log on small or negative values\n return -1;\n }\n return Math.floor(Math.log(depth) * this._sliceScale + this._sliceBias);\n }\n\n private _updateLightData(): void {\n const camera = this._camera || this._scene.activeCamera;\n const renderId = this._scene.getRenderId();\n if (!camera || this._lightDataRenderId === renderId) {\n return;\n }\n this._lightDataRenderId = renderId;\n\n // Resort lights based on distance from camera\n const view = camera.getViewMatrix();\n for (const light of this._sortedLights) {\n const position = light.computeTransformedInformation() ? light.transformedPosition : light.position;\n const viewPosition = Vector3.TransformCoordinatesToRef(position, view, TmpVectors.Vector3[0]);\n light._currentViewDepth = this._scene.useRightHandedSystem ? -viewPosition.z : viewPosition.z;\n }\n this._sortedLights.sort((a, b) => a._currentViewDepth - b._currentViewDepth);\n\n // DOOM 2016 subdivision scheme, copied from: https://www.aortiz.me/2018/12/21/CG.html\n const logFarNear = Math.log(camera.maxZ / camera.minZ);\n this._sliceScale = this._depthSlices / logFarNear;\n this._sliceBias = -(this._depthSlices * Math.log(camera.minZ)) / logFarNear;\n\n this._sliceRanges.fill(0);\n // Last slice which had had its min index updated\n let minSlice = -1;\n\n const buf = this._lightDataBuffer;\n const offset = this._scene.floatingOriginOffset;\n\n for (let i = 0; i < this._sortedLights.length; i += 1) {\n const light = this._sortedLights[i];\n const off = i * 20;\n const computed = light.computeTransformedInformation();\n const scaledIntensity = light.getScaledIntensity();\n\n const position = computed ? light.transformedPosition : light.position;\n const diffuse = light.diffuse.scaleToRef(scaledIntensity, TmpColors.Color3[0]);\n const specular = light.specular.scaleToRef(scaledIntensity, TmpColors.Color3[1]);\n const range = Math.min(light.range, this.maxRange);\n const inverseSquaredRange = Math.max(light._inverseSquaredRange, this._minInverseSquaredRange);\n\n // vLightData\n buf[off + 0] = position.x - offset.x;\n buf[off + 1] = position.y - offset.y;\n buf[off + 2] = position.z - offset.z;\n buf[off + 3] = 0;\n // vLightDiffuse\n buf[off + 4] = diffuse.r;\n buf[off + 5] = diffuse.g;\n buf[off + 6] = diffuse.b;\n buf[off + 7] = range;\n // vLightSpecular\n buf[off + 8] = specular.r;\n buf[off + 9] = specular.g;\n buf[off + 10] = specular.b;\n buf[off + 11] = light.radius;\n // vLightDirection\n buf[off + 12] = 0;\n buf[off + 13] = 0;\n buf[off + 14] = 0;\n buf[off + 15] = -1;\n // vLightFalloff\n buf[off + 16] = range;\n buf[off + 17] = inverseSquaredRange;\n buf[off + 18] = 0;\n buf[off + 19] = 0;\n\n if (light.getTypeID() === LightConstants.LIGHTTYPEID_SPOTLIGHT) {\n const spotLight = <SpotLight>light;\n const direction = Vector3.NormalizeToRef(computed ? spotLight.transformedDirection : spotLight.direction, TmpVectors.Vector3[0]);\n\n // vLightData.a\n buf[off + 3] = spotLight.exponent;\n // vLightDirection\n buf[off + 12] = direction.x;\n buf[off + 13] = direction.y;\n buf[off + 14] = direction.z;\n buf[off + 15] = spotLight._cosHalfAngle;\n // vLightFalloff.zw\n buf[off + 18] = spotLight._lightAngleScale;\n buf[off + 19] = spotLight._lightAngleOffset;\n }\n\n // Update the depth slices that include this light\n const firstSlice = this._getSliceIndex(camera, light._currentViewDepth - range);\n const lastSlice = this._getSliceIndex(camera, light._currentViewDepth + range);\n for (let j = firstSlice; j <= lastSlice; j += 1) {\n if (j < 0 || j >= this._depthSlices) {\n continue;\n } else if (j > minSlice) {\n // Update min index\n this._sliceRanges[j * 2] = i;\n minSlice = j;\n }\n // Update max index\n this._sliceRanges[j * 2 + 1] = i;\n }\n }\n\n const engine = this.getEngine();\n if (engine.isWebGPU) {\n // Whenever the light data changes we have to flush pending WebGPU command buffers so that\n // previous render passes use the old data and later render passes use the new data.\n engine.flushFramebuffer();\n }\n this._lightDataTexture.update(this._lightDataBuffer);\n }\n\n public override dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void {\n for (const light of this._lights) {\n light.dispose(doNotRecurse, disposeMaterialAndTextures);\n }\n this._lightDataTexture.dispose();\n this._tileMaskTexture.dispose();\n this._tileMaskBuffer?.dispose();\n this._proxyMesh.dispose(doNotRecurse, disposeMaterialAndTextures);\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\n }\n\n /**\n * Adds a light to the clustering system.\n * @param light The light to add\n */\n public addLight(light: Light): void {\n if (!ClusteredLightContainer.IsLightSupported(light)) {\n Logger.Warn(\"Attempting to add a light to cluster that does not support clustering\");\n return;\n }\n this._scene.removeLight(light);\n this._lights.push(light);\n this._sortedLights.push(<PointLight | SpotLight>light);\n\n this._proxyMesh.isVisible = true;\n this._proxyMesh.thinInstanceCount = this._sortedLights.length;\n }\n\n /**\n * Removes a light from the clustering system.\n * @param light The light to remove\n * @returns the index where the light was in the light list\n */\n public removeLight(light: Light): number {\n // Convert to `Light` array without cast so `indexOf` has correct typing\n const sortedLights: Light[] = this._sortedLights;\n const sortedIndex = sortedLights.indexOf(light);\n if (sortedIndex !== -1) {\n sortedLights.splice(sortedIndex, 1);\n\n this._proxyMesh.thinInstanceCount = sortedLights.length;\n if (sortedLights.length === 0) {\n this._proxyMesh.isVisible = false;\n }\n }\n\n const index = this._lights.indexOf(light);\n if (index !== -1) {\n this._lights.splice(index, 1);\n // We treat the unsorted array as the \"real\" one so only add back to the scene if it was found in that\n this._scene.addLight(light);\n }\n return index;\n }\n\n protected override _buildUniformLayout(): void {\n this._uniformBuffer.addUniform(\"vLightData\", 4);\n this._uniformBuffer.addUniform(\"vLightDiffuse\", 4);\n this._uniformBuffer.addUniform(\"vLightSpecular\", 4);\n this._uniformBuffer.addUniform(\"vSliceData\", 2);\n // _depthSlices might not be initialized yet\n this._uniformBuffer.addUniform(\"vSliceRanges\", 2, this._depthSlices ?? DefaultDepthSlices);\n this._uniformBuffer.addUniform(\"shadowsInfo\", 3);\n this._uniformBuffer.addUniform(\"depthValues\", 2);\n this._uniformBuffer.create();\n }\n\n public override transferToEffect(effect: Effect, lightIndex: string): Light {\n const engine = this.getEngine();\n const hscale = this._horizontalTiles / engine.getRenderWidth();\n const vscale = this._verticalTiles / engine.getRenderHeight();\n this._uniformBuffer.updateFloat4(\"vLightData\", hscale, vscale, this._verticalTiles, this._tileMaskBatches, lightIndex);\n this._uniformBuffer.updateFloat2(\"vSliceData\", this._sliceScale, this._sliceBias, lightIndex);\n this._uniformBuffer.updateFloatArray(\"vSliceRanges\", this._sliceRanges, lightIndex);\n return this;\n }\n\n public override transferTexturesToEffect(effect: Effect, lightIndex: string): Light {\n const engine = this.getEngine();\n effect.setTexture(\"lightDataTexture\" + lightIndex, this._lightDataTexture);\n if (engine.isWebGPU) {\n (<WebGPUEngine>engine).setStorageBuffer(\"tileMaskBuffer\" + lightIndex, this._tileMaskBuffer);\n } else {\n effect.setTexture(\"tileMaskTexture\" + lightIndex, this._tileMaskTexture);\n }\n return this;\n }\n\n public override transferToNodeMaterialEffect(_effect: Effect): Light {\n return this;\n }\n\n public override prepareLightSpecificDefines(defines: any, lightIndex: number): void {\n defines[\"CLUSTLIGHT\" + lightIndex] = true;\n defines[\"CLUSTLIGHT_BATCH\"] = this._batchSize;\n defines[\"CLUSTLIGHT_SLICES\"] = this._depthSlices;\n }\n\n public override _isReady(): boolean {\n this._updateBatches();\n return this._proxyMesh.isReady(true, true);\n }\n}\n\n// Register Class Name\nRegisterClass(\"BABYLON.ClusteredLightContainer\", ClusteredLightContainer);\n"]}
|
|
1
|
+
{"version":3,"file":"clusteredLightContainer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Lights/Clustered/clusteredLightContainer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,uCAAmC;AAG3D,OAAO,EAAE,SAAS,EAAE,mCAA+B;AAInD,OAAO,EAAE,cAAc,EAAE,0CAAsC;AAC/D,OAAO,EAAE,UAAU,EAAE,+CAA2C;AAChE,OAAO,EAAE,mBAAmB,EAAE,wDAAoD;AAClF,OAAO,EAAE,aAAa,EAAE,yCAAqC;AAC7D,OAAO,EAAE,SAAS,EAAE,kCAA8B;AAClD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,mCAA+B;AAC7D,OAAO,EAAE,WAAW,EAAE,8CAA0C;AAEhE,OAAO,EAAE,SAAS,EAAE,iCAA6B;AACjD,OAAO,EAAE,WAAW,EAAE,+BAA2B;AACjD,OAAO,EAAE,MAAM,EAAE,6BAAyB;AAC1C,OAAO,EAAE,aAAa,EAAE,gCAA4B;AACpD,OAAO,EAAE,IAAI,EAAE,sBAAkB;AAIjC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKnD,0CAAsC;AAEtC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AAC,gBAAgB,GAAG,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACjG,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,UAAU,CAAC,iBAAiB,GAAG,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,4BAA4B,CAAC,OAAe;QACxD,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,2BAA2B,CAAC,OAAY,EAAE,UAAkB;QACxE,OAAO,CAAC,YAAY,GAAG,UAAU,CAAC,GAAG,IAAI,CAAC;QAC1C,OAAO,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;QAC9C,OAAO,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;IACrD,CAAC;IAEe,QAAQ;QACpB,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;;AApfD,gBAAgB;AACF,qDAA6B,GAA2B,GAAG,EAAE;IACvE,MAAM,WAAW,CAAC,iCAAiC,CAAC,CAAC;AACzD,CAAC,AAF0C,CAEzC;AAsCF;IADC,SAAS,EAAE;8DAGX;AAiBD;IADC,SAAS,EAAE;4DAGX;AAmDD;IADC,SAAS,EAAE;uDAGX;AAoYL,sBAAsB;AACtB,aAAa,CAAC,iCAAiC,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import { StorageBuffer } from \"core/Buffers/storageBuffer\";\nimport type { Camera } from \"core/Cameras/camera\";\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\nimport { Constants } from \"core/Engines/constants\";\nimport type { WebGPUEngine } from \"core/Engines/webgpuEngine\";\nimport type { Effect } from \"core/Materials/effect\";\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\nimport { ShaderMaterial } from \"core/Materials/shaderMaterial\";\nimport { RawTexture } from \"core/Materials/Textures/rawTexture\";\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\nimport { UniformBuffer } from \"core/Materials/uniformBuffer\";\nimport { TmpColors } from \"core/Maths/math.color\";\nimport { TmpVectors, Vector3 } from \"core/Maths/math.vector\";\nimport { CreatePlane } from \"core/Meshes/Builders/planeBuilder\";\nimport type { Mesh } from \"core/Meshes/mesh\";\nimport { serialize } from \"core/Misc/decorators\";\nimport { _WarnImport } from \"core/Misc/devTools\";\nimport { Logger } from \"core/Misc/logger\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { Node } from \"core/node\";\nimport type { Scene } from \"core/scene\";\nimport type { Nullable } from \"core/types\";\n\nimport { Light } from \"../light\";\nimport { LightConstants } from \"../lightConstants\";\nimport type { PointLight } from \"../pointLight\";\nimport type { SpotLight } from \"../spotLight\";\nimport type { RenderTargetWrapper } from \"../../Engines/renderTargetWrapper\";\n\nimport \"core/Meshes/thinInstanceMesh\";\n\nNode.AddNodeConstructor(\"Light_Type_5\", (name, scene) => {\n return () => new ClusteredLightContainer(name, [], scene);\n});\n\nconst DefaultDepthSlices = 16;\nconst MobileClusteredLightBatchSize = 8;\n\n/**\n * A special light that renders all its associated spot or point lights using a clustered or forward+ system.\n */\nexport class ClusteredLightContainer extends Light {\n private static _GetEngineBatchSize(engine: AbstractEngine): number {\n const caps = engine._caps;\n if (!caps.texelFetch) {\n return 0;\n } else if (engine.isWebGPU) {\n // On WebGPU we use atomic writes to storage textures\n return 32;\n } else if (engine.version > 1) {\n // On WebGL 2 we use additive float blending as the light mask\n if (!caps.colorBufferFloat || !caps.blendFloat) {\n return 0;\n }\n // Due to the use of floats we want to limit lights to the precision of floats\n // The reduced precision for mobiles is because some devices (like Samsung Galaxy) report support for R32F but actually create the texture with less precision.\n return engine.hostInformation.isMobile ? MobileClusteredLightBatchSize : caps.shaderFloatPrecision;\n } else {\n // WebGL 1 is not supported due to lack of dynamic for loops\n return 0;\n }\n }\n\n /**\n * Checks if the clustered lighting system supports the given light with its current parameters.\n * This will also check if the light's associated engine supports clustered lighting.\n *\n * @param light The light to test\n * @returns true if the light and its engine is supported\n */\n public static IsLightSupported(light: Light): boolean {\n if (ClusteredLightContainer._GetEngineBatchSize(light.getEngine()) === 0) {\n return false;\n }\n\n if (light.shadowEnabled && light._scene.shadowsEnabled && light.getShadowGenerators()) {\n // Shadows are not supported\n return false;\n }\n\n if (light.falloffType !== Light.FALLOFF_DEFAULT) {\n // Only the default falloff is supported\n return false;\n }\n\n if (light.getTypeID() === LightConstants.LIGHTTYPEID_POINTLIGHT) {\n return true;\n }\n\n if (light.getTypeID() === LightConstants.LIGHTTYPEID_SPOTLIGHT) {\n // Extra texture bindings per light are not supported\n return !(<SpotLight>light).projectionTexture && !(<SpotLight>light).iesProfileTexture;\n }\n\n // Currently only point and spot lights are supported\n return false;\n }\n\n /** @internal */\n public static _SceneComponentInitialization: (scene: Scene) => void = () => {\n throw _WarnImport(\"ClusteredLightingSceneComponent\");\n };\n\n private readonly _batchSize: number;\n\n /**\n * True if clustered lighting is supported.\n */\n public get isSupported(): boolean {\n return this._batchSize > 0;\n }\n\n private readonly _lights: Light[] = [];\n /**\n * Gets the current list of lights added to this clustering system.\n */\n public get lights(): readonly Light[] {\n return this._lights;\n }\n\n private _camera: Nullable<Camera> = null;\n\n // The lights sorted by depth\n private readonly _sortedLights: (PointLight | SpotLight)[] = [];\n\n private _lightDataBuffer: Float32Array;\n private _lightDataTexture: RawTexture;\n private _lightDataRenderId = -1;\n\n private _tileMaskBatches = -1;\n private _tileMaskTexture: RenderTargetTexture;\n private _tileMaskBuffer: Nullable<StorageBuffer>;\n\n private _horizontalTiles = 64;\n /**\n * The number of tiles in the horizontal direction to cluster lights into.\n * A lower value will reduce memory and make the clustering step faster, while a higher value increases memory and makes the rendering step faster.\n */\n @serialize()\n public get horizontalTiles(): number {\n return this._horizontalTiles;\n }\n\n public set horizontalTiles(horizontal: number) {\n if (this._horizontalTiles === horizontal) {\n return;\n }\n this._horizontalTiles = horizontal;\n // Force the batch data to be recreated\n this._tileMaskBatches = -1;\n }\n\n private _verticalTiles = 64;\n /**\n * The number of tiles in the vertical direction to cluster lights into.\n * A lower value will reduce memory and make the clustering step faster, while a higher value increases memory and makes the rendering step faster.\n */\n @serialize()\n public get verticalTiles(): number {\n return this._verticalTiles;\n }\n\n public set verticalTiles(vertical: number) {\n if (this._verticalTiles === vertical) {\n return;\n }\n this._verticalTiles = vertical;\n // Force the batch data to be recreated\n this._tileMaskBatches = -1;\n }\n\n private _sliceScale = 0;\n private _sliceBias = 0;\n // List of vec2's that keep track of the min and max index per slice\n private _sliceRanges: Float32Array<ArrayBuffer>;\n\n private _depthSlices = DefaultDepthSlices;\n /**\n * The number of slices to split the depth range by and cluster lights into.\n */\n public get depthSlices(): number {\n return this._depthSlices;\n }\n\n public set depthSlices(slices: number) {\n if (this._depthSlices === slices) {\n return;\n }\n this._depthSlices = slices;\n this._sliceRanges = new Float32Array(slices * 2);\n\n // UBO size depends on the number of depth slices\n this._uniformBuffer.dispose();\n this._uniformBuffer = new UniformBuffer(this.getEngine(), undefined, undefined, this.name);\n this._buildUniformLayout();\n\n // CLUSTLIGHT_SLICES is a shader define that sizes the vSliceRanges array in the UBO.\n // Materials must recompile when depthSlices changes so the shader layout matches the rebuilt UBO.\n // Otherwise, if depthSlices is reduced, the rebuilt UBO can be smaller than what the previously compiled shader expects, causing rendering to fail.\n this._markMeshesAsLightDirty();\n }\n\n private readonly _proxyMaterial: ShaderMaterial;\n private readonly _proxyMesh: Mesh;\n\n private _maxRange = 16383;\n private _minInverseSquaredRange = 1 / (this._maxRange * this._maxRange);\n /**\n * This limits the range of all the added lights, so even lights with extreme ranges will still have bounds for clustering.\n */\n @serialize()\n public get maxRange(): number {\n return this._maxRange;\n }\n\n public set maxRange(range: number) {\n if (this._maxRange === range) {\n return;\n }\n this._maxRange = range;\n this._minInverseSquaredRange = 1 / (range * range);\n }\n\n /**\n * Creates a new clustered light system with an initial set of lights.\n *\n * @param name The name of the clustered light container\n * @param lights The initial set of lights to add\n * @param scene The scene the clustered light container belongs to\n */\n constructor(name: string, lights: Light[] = [], scene?: Scene) {\n super(name, scene);\n const engine = this.getEngine();\n this._batchSize = ClusteredLightContainer._GetEngineBatchSize(engine);\n\n const proxyShader = { vertex: \"lightProxy\", fragment: \"lightProxy\" };\n const defines = [`CLUSTLIGHT_BATCH ${this._batchSize}`];\n if (this._scene.useRightHandedSystem) {\n defines.push(\"#define RIGHT_HANDED\");\n }\n this._proxyMaterial = new ShaderMaterial(\"ProxyMaterial\", this._scene, proxyShader, {\n attributes: [\"position\"],\n uniforms: [\"view\", \"projection\", \"tileMaskResolution\"],\n samplers: [\"lightDataTexture\"],\n uniformBuffers: [\"Scene\"],\n storageBuffers: [\"tileMaskBuffer\"],\n defines,\n shaderLanguage: engine.isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\n extraInitializationsAsync: async () => {\n if (engine.isWebGPU) {\n await Promise.all([import(\"../../ShadersWGSL/lightProxy.vertex\"), import(\"../../ShadersWGSL/lightProxy.fragment\")]);\n } else {\n await Promise.all([import(\"../../Shaders/lightProxy.vertex\"), import(\"../../Shaders/lightProxy.fragment\")]);\n }\n },\n });\n\n // Additive blending is for merging masks on WebGL\n this._proxyMaterial.transparencyMode = ShaderMaterial.MATERIAL_ALPHABLEND;\n this._proxyMaterial.alphaMode = Constants.ALPHA_ADD;\n this._proxyMaterial.sideOrientation = Constants.MATERIAL_CounterClockWiseSideOrientation;\n\n this._proxyMesh = CreatePlane(\"ProxyMesh\", { size: 2 }, this._scene);\n // Make sure it doesn't render for the default scene\n this._scene.removeMesh(this._proxyMesh);\n this._proxyMesh.material = this._proxyMaterial;\n\n this._updateBatches();\n\n this._sliceRanges = new Float32Array(this._depthSlices * 2);\n\n if (this._batchSize > 0) {\n ClusteredLightContainer._SceneComponentInitialization(this._scene);\n for (const light of lights) {\n this.addLight(light);\n }\n }\n }\n\n public override getClassName(): string {\n return \"ClusteredLightContainer\";\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public override getTypeID(): number {\n return LightConstants.LIGHTTYPEID_CLUSTERED_CONTAINER;\n }\n\n /** @internal */\n public _updateBatches(camera: Nullable<Camera> = null): RenderTargetTexture {\n this._camera = camera;\n this._proxyMesh.isVisible = this._sortedLights.length > 0;\n\n // Ensure space for atleast 1 batch\n const batches = Math.max(Math.ceil(this._sortedLights.length / this._batchSize), 1);\n if (this._tileMaskBatches >= batches) {\n this._proxyMesh.thinInstanceCount = this._sortedLights.length;\n return this._tileMaskTexture;\n }\n const engine = this.getEngine();\n // Round up to a batch size so we don't have to reallocate as often\n const maxLights = batches * this._batchSize;\n\n this._lightDataBuffer = new Float32Array(20 * maxLights);\n this._lightDataTexture?.dispose();\n this._lightDataTexture = new RawTexture(\n this._lightDataBuffer,\n 5,\n maxLights,\n Constants.TEXTUREFORMAT_RGBA,\n this._scene,\n false,\n false,\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\n Constants.TEXTURETYPE_FLOAT\n );\n this._lightDataTexture.name = \"LightDataTexture_clustered_\" + this.name;\n this._proxyMaterial.setTexture(\"lightDataTexture\", this._lightDataTexture);\n\n this._tileMaskTexture?.dispose();\n const textureSize = { width: this._horizontalTiles, height: this._verticalTiles };\n if (!engine.isWebGPU) {\n // In WebGL we shift the light proxy by the batch number\n textureSize.height *= batches;\n }\n this._tileMaskTexture = new RenderTargetTexture(\"TileMaskTexture\", textureSize, this._scene, {\n // We don't write anything on WebGPU so make it as small as possible\n type: engine.isWebGPU ? Constants.TEXTURETYPE_UNSIGNED_BYTE : Constants.TEXTURETYPE_FLOAT,\n format: Constants.TEXTUREFORMAT_RED,\n generateDepthBuffer: false,\n });\n\n this._tileMaskTexture.renderParticles = false;\n this._tileMaskTexture.renderSprites = false;\n this._tileMaskTexture.noPrePassRenderer = true;\n this._tileMaskTexture.renderList = [this._proxyMesh];\n\n let currentRenderTarget: Nullable<RenderTargetWrapper> = null;\n\n this._tileMaskTexture.onBeforeBindObservable.add(() => {\n currentRenderTarget = engine._currentRenderTarget;\n this._updateLightData();\n });\n\n this._tileMaskTexture.onAfterUnbindObservable.add(() => {\n if (engine._currentRenderTarget !== currentRenderTarget) {\n if (!currentRenderTarget) {\n engine.restoreDefaultFramebuffer();\n } else {\n engine.bindFramebuffer(currentRenderTarget);\n }\n }\n });\n\n this._tileMaskTexture.onClearObservable.add(() => {\n if (engine.isWebGPU) {\n // Clear the storage buffer for WebGPU\n this._tileMaskBuffer?.clear();\n } else {\n // Only clear the texture on WebGL\n engine.clear({ r: 0, g: 0, b: 0, a: 1 }, true, false);\n }\n });\n\n if (engine.isWebGPU) {\n // WebGPU also needs a storage buffer to write to\n this._tileMaskBuffer?.dispose();\n const bufferSize = this._horizontalTiles * this._verticalTiles * batches * 4;\n this._tileMaskBuffer = new StorageBuffer(<WebGPUEngine>engine, bufferSize);\n this._proxyMaterial.setStorageBuffer(\"tileMaskBuffer\", this._tileMaskBuffer);\n }\n\n this._proxyMaterial.setVector3(\"tileMaskResolution\", new Vector3(this._horizontalTiles, this.verticalTiles, batches));\n\n // We don't actually use the matrix data but we need enough capacity for the lights\n this._proxyMesh.thinInstanceSetBuffer(\"matrix\", new Float32Array(maxLights * 16));\n this._proxyMesh.thinInstanceCount = this._sortedLights.length;\n this._tileMaskBatches = batches;\n return this._tileMaskTexture;\n }\n\n private _getSliceIndex(camera: Camera, depth: number): number {\n if (depth < camera.minZ) {\n // Prevent calling log on small or negative values\n return -1;\n }\n return Math.floor(Math.log(depth) * this._sliceScale + this._sliceBias);\n }\n\n private _updateLightData(): void {\n const camera = this._camera || this._scene.activeCamera;\n const renderId = this._scene.getRenderId();\n if (!camera || this._lightDataRenderId === renderId) {\n return;\n }\n this._lightDataRenderId = renderId;\n\n // Resort lights based on distance from camera\n const view = camera.getViewMatrix();\n for (const light of this._sortedLights) {\n const position = light.computeTransformedInformation() ? light.transformedPosition : light.position;\n const viewPosition = Vector3.TransformCoordinatesToRef(position, view, TmpVectors.Vector3[0]);\n light._currentViewDepth = this._scene.useRightHandedSystem ? -viewPosition.z : viewPosition.z;\n }\n this._sortedLights.sort((a, b) => a._currentViewDepth - b._currentViewDepth);\n\n // DOOM 2016 subdivision scheme, copied from: https://www.aortiz.me/2018/12/21/CG.html\n const logFarNear = Math.log(camera.maxZ / camera.minZ);\n this._sliceScale = this._depthSlices / logFarNear;\n this._sliceBias = -(this._depthSlices * Math.log(camera.minZ)) / logFarNear;\n\n this._sliceRanges.fill(0);\n // Last slice which had had its min index updated\n let minSlice = -1;\n\n const buf = this._lightDataBuffer;\n const offset = this._scene.floatingOriginOffset;\n\n for (let i = 0; i < this._sortedLights.length; i += 1) {\n const light = this._sortedLights[i];\n const off = i * 20;\n const computed = light.computeTransformedInformation();\n const scaledIntensity = light.getScaledIntensity();\n\n const position = computed ? light.transformedPosition : light.position;\n const diffuse = light.diffuse.scaleToRef(scaledIntensity, TmpColors.Color3[0]);\n const specular = light.specular.scaleToRef(scaledIntensity, TmpColors.Color3[1]);\n const range = Math.min(light.range, this.maxRange);\n const inverseSquaredRange = Math.max(light._inverseSquaredRange, this._minInverseSquaredRange);\n\n // vLightData\n buf[off + 0] = position.x - offset.x;\n buf[off + 1] = position.y - offset.y;\n buf[off + 2] = position.z - offset.z;\n buf[off + 3] = 0;\n // vLightDiffuse\n buf[off + 4] = diffuse.r;\n buf[off + 5] = diffuse.g;\n buf[off + 6] = diffuse.b;\n buf[off + 7] = range;\n // vLightSpecular\n buf[off + 8] = specular.r;\n buf[off + 9] = specular.g;\n buf[off + 10] = specular.b;\n buf[off + 11] = light.radius;\n // vLightDirection\n buf[off + 12] = 0;\n buf[off + 13] = 0;\n buf[off + 14] = 0;\n buf[off + 15] = -1;\n // vLightFalloff\n buf[off + 16] = range;\n buf[off + 17] = inverseSquaredRange;\n buf[off + 18] = 0;\n buf[off + 19] = 0;\n\n if (light.getTypeID() === LightConstants.LIGHTTYPEID_SPOTLIGHT) {\n const spotLight = <SpotLight>light;\n const direction = Vector3.NormalizeToRef(computed ? spotLight.transformedDirection : spotLight.direction, TmpVectors.Vector3[0]);\n\n // vLightData.a\n buf[off + 3] = spotLight.exponent;\n // vLightDirection\n buf[off + 12] = direction.x;\n buf[off + 13] = direction.y;\n buf[off + 14] = direction.z;\n buf[off + 15] = spotLight._cosHalfAngle;\n // vLightFalloff.zw\n buf[off + 18] = spotLight._lightAngleScale;\n buf[off + 19] = spotLight._lightAngleOffset;\n }\n\n // Update the depth slices that include this light\n const firstSlice = this._getSliceIndex(camera, light._currentViewDepth - range);\n const lastSlice = this._getSliceIndex(camera, light._currentViewDepth + range);\n for (let j = firstSlice; j <= lastSlice; j += 1) {\n if (j < 0 || j >= this._depthSlices) {\n continue;\n } else if (j > minSlice) {\n // Update min index\n this._sliceRanges[j * 2] = i;\n minSlice = j;\n }\n // Update max index\n this._sliceRanges[j * 2 + 1] = i;\n }\n }\n\n const engine = this.getEngine();\n if (engine.isWebGPU) {\n // Whenever the light data changes we have to flush pending WebGPU command buffers so that\n // previous render passes use the old data and later render passes use the new data.\n engine.flushFramebuffer();\n }\n this._lightDataTexture.update(this._lightDataBuffer);\n }\n\n public override dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void {\n for (const light of this._lights) {\n light.dispose(doNotRecurse, disposeMaterialAndTextures);\n }\n this._lightDataTexture.dispose();\n this._tileMaskTexture.dispose();\n this._tileMaskBuffer?.dispose();\n this._proxyMesh.dispose(doNotRecurse, disposeMaterialAndTextures);\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\n }\n\n /**\n * Adds a light to the clustering system.\n * @param light The light to add\n */\n public addLight(light: Light): void {\n if (!ClusteredLightContainer.IsLightSupported(light)) {\n Logger.Warn(\"Attempting to add a light to cluster that does not support clustering\");\n return;\n }\n this._scene.removeLight(light);\n this._lights.push(light);\n this._sortedLights.push(<PointLight | SpotLight>light);\n\n this._proxyMesh.isVisible = true;\n this._proxyMesh.thinInstanceCount = this._sortedLights.length;\n }\n\n /**\n * Removes a light from the clustering system.\n * @param light The light to remove\n * @returns the index where the light was in the light list\n */\n public removeLight(light: Light): number {\n // Convert to `Light` array without cast so `indexOf` has correct typing\n const sortedLights: Light[] = this._sortedLights;\n const sortedIndex = sortedLights.indexOf(light);\n if (sortedIndex !== -1) {\n sortedLights.splice(sortedIndex, 1);\n\n this._proxyMesh.thinInstanceCount = sortedLights.length;\n if (sortedLights.length === 0) {\n this._proxyMesh.isVisible = false;\n }\n }\n\n const index = this._lights.indexOf(light);\n if (index !== -1) {\n this._lights.splice(index, 1);\n // We treat the unsorted array as the \"real\" one so only add back to the scene if it was found in that\n this._scene.addLight(light);\n }\n return index;\n }\n\n protected override _buildUniformLayout(): void {\n this._uniformBuffer.addUniform(\"vLightData\", 4);\n this._uniformBuffer.addUniform(\"vLightDiffuse\", 4);\n this._uniformBuffer.addUniform(\"vLightSpecular\", 4);\n this._uniformBuffer.addUniform(\"vSliceData\", 2);\n // _depthSlices might not be initialized yet\n this._uniformBuffer.addUniform(\"vSliceRanges\", 2, this._depthSlices ?? DefaultDepthSlices);\n this._uniformBuffer.addUniform(\"shadowsInfo\", 3);\n this._uniformBuffer.addUniform(\"depthValues\", 2);\n this._uniformBuffer.create();\n }\n\n public override transferToEffect(effect: Effect, lightIndex: string): Light {\n const engine = this.getEngine();\n const hscale = this._horizontalTiles / engine.getRenderWidth();\n const vscale = this._verticalTiles / engine.getRenderHeight();\n this._uniformBuffer.updateFloat4(\"vLightData\", hscale, vscale, this._verticalTiles, this._tileMaskBatches, lightIndex);\n this._uniformBuffer.updateFloat2(\"vSliceData\", this._sliceScale, this._sliceBias, lightIndex);\n this._uniformBuffer.updateFloatArray(\"vSliceRanges\", this._sliceRanges, lightIndex);\n return this;\n }\n\n public override transferTexturesToEffect(effect: Effect, lightIndex: string): Light {\n const engine = this.getEngine();\n effect.setTexture(\"lightDataTexture\" + lightIndex, this._lightDataTexture);\n if (engine.isWebGPU) {\n (<WebGPUEngine>engine).setStorageBuffer(\"tileMaskBuffer\" + lightIndex, this._tileMaskBuffer);\n } else {\n effect.setTexture(\"tileMaskTexture\" + lightIndex, this._tileMaskTexture);\n }\n return this;\n }\n\n public override transferToNodeMaterialEffect(_effect: Effect): Light {\n return this;\n }\n\n public override prepareLightSpecificDefines(defines: any, lightIndex: number): void {\n defines[\"CLUSTLIGHT\" + lightIndex] = true;\n defines[\"CLUSTLIGHT_BATCH\"] = this._batchSize;\n defines[\"CLUSTLIGHT_SLICES\"] = this._depthSlices;\n }\n\n public override _isReady(): boolean {\n this._updateBatches();\n return this._proxyMesh.isReady(true, true);\n }\n}\n\n// Register Class Name\nRegisterClass(\"BABYLON.ClusteredLightContainer\", ClusteredLightContainer);\n"]}
|
package/Meshes/instancedMesh.js
CHANGED
|
@@ -562,8 +562,16 @@ export class InstancedMesh extends AbstractMesh {
|
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
564
|
Mesh.prototype.registerInstancedBuffer = function (kind, stride) {
|
|
565
|
-
// Remove existing one
|
|
565
|
+
// Remove existing one (shared VBO)
|
|
566
566
|
this._userInstancedBuffersStorage?.vertexBuffers[kind]?.dispose();
|
|
567
|
+
// Remove existing per-pass VBOs (WebGPU)
|
|
568
|
+
if (this._userInstancedBuffersStorage?.renderPasses) {
|
|
569
|
+
for (const passId in this._userInstancedBuffersStorage.renderPasses) {
|
|
570
|
+
const passVBOs = this._userInstancedBuffersStorage.renderPasses[passId];
|
|
571
|
+
passVBOs[kind]?.dispose();
|
|
572
|
+
delete passVBOs[kind];
|
|
573
|
+
}
|
|
574
|
+
}
|
|
567
575
|
// Creates the instancedBuffer field if not present
|
|
568
576
|
if (!this.instancedBuffers) {
|
|
569
577
|
this.instancedBuffers = {};
|
|
@@ -585,7 +593,10 @@ Mesh.prototype.registerInstancedBuffer = function (kind, stride) {
|
|
|
585
593
|
this._userInstancedBuffersStorage.strides[kind] = stride;
|
|
586
594
|
this._userInstancedBuffersStorage.sizes[kind] = stride * 32; // Initial size
|
|
587
595
|
this._userInstancedBuffersStorage.data[kind] = new Float32Array(this._userInstancedBuffersStorage.sizes[kind]);
|
|
588
|
-
|
|
596
|
+
// In WebGPU, per-pass VBOs are used instead of a shared one (created on demand in _processInstancedBuffers)
|
|
597
|
+
this._userInstancedBuffersStorage.vertexBuffers[kind] = this._instanceDataStorage.useMonoDataStorageRenderPass
|
|
598
|
+
? new VertexBuffer(this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true)
|
|
599
|
+
: null;
|
|
589
600
|
for (const instance of this.instances) {
|
|
590
601
|
instance.instancedBuffers[kind] = null;
|
|
591
602
|
}
|
|
@@ -594,6 +605,21 @@ Mesh.prototype.registerInstancedBuffer = function (kind, stride) {
|
|
|
594
605
|
};
|
|
595
606
|
Mesh.prototype._processInstancedBuffers = function (visibleInstances, renderSelf) {
|
|
596
607
|
const instanceCount = visibleInstances ? visibleInstances.length : 0;
|
|
608
|
+
// In WebGPU, queue.writeBuffer() writes are all applied before the command buffer executes,
|
|
609
|
+
// so a shared VBO written by multiple render passes (e.g. effect layer + main scene) will
|
|
610
|
+
// only reflect the last write for ALL passes. Use per-render-pass VBOs instead.
|
|
611
|
+
const usePerPassStorage = !this._instanceDataStorage.useMonoDataStorageRenderPass;
|
|
612
|
+
let perPassVertexBuffers;
|
|
613
|
+
if (usePerPassStorage) {
|
|
614
|
+
const currentRenderPassId = this._instanceDataStorage.engine.currentRenderPassId;
|
|
615
|
+
if (!this._userInstancedBuffersStorage.renderPasses) {
|
|
616
|
+
this._userInstancedBuffersStorage.renderPasses = {};
|
|
617
|
+
}
|
|
618
|
+
if (!this._userInstancedBuffersStorage.renderPasses[currentRenderPassId]) {
|
|
619
|
+
this._userInstancedBuffersStorage.renderPasses[currentRenderPassId] = {};
|
|
620
|
+
}
|
|
621
|
+
perPassVertexBuffers = this._userInstancedBuffersStorage.renderPasses[currentRenderPassId];
|
|
622
|
+
}
|
|
597
623
|
for (const kind in this.instancedBuffers) {
|
|
598
624
|
let size = this._userInstancedBuffersStorage.sizes[kind];
|
|
599
625
|
const stride = this._userInstancedBuffersStorage.strides[kind];
|
|
@@ -605,7 +631,13 @@ Mesh.prototype._processInstancedBuffers = function (visibleInstances, renderSelf
|
|
|
605
631
|
if (this._userInstancedBuffersStorage.data[kind].length != size) {
|
|
606
632
|
this._userInstancedBuffersStorage.data[kind] = new Float32Array(size);
|
|
607
633
|
this._userInstancedBuffersStorage.sizes[kind] = size;
|
|
608
|
-
if (
|
|
634
|
+
if (usePerPassStorage) {
|
|
635
|
+
if (perPassVertexBuffers[kind]) {
|
|
636
|
+
perPassVertexBuffers[kind].dispose();
|
|
637
|
+
perPassVertexBuffers[kind] = null;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
else if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {
|
|
609
641
|
this._userInstancedBuffersStorage.vertexBuffers[kind].dispose();
|
|
610
642
|
this._userInstancedBuffersStorage.vertexBuffers[kind] = null;
|
|
611
643
|
}
|
|
@@ -640,13 +672,24 @@ Mesh.prototype._processInstancedBuffers = function (visibleInstances, renderSelf
|
|
|
640
672
|
}
|
|
641
673
|
offset += stride;
|
|
642
674
|
}
|
|
643
|
-
// Update vertex buffer
|
|
644
|
-
if (
|
|
645
|
-
|
|
646
|
-
|
|
675
|
+
// Update vertex buffer (per-pass in WebGPU, shared in WebGL)
|
|
676
|
+
if (usePerPassStorage) {
|
|
677
|
+
if (!perPassVertexBuffers[kind]) {
|
|
678
|
+
perPassVertexBuffers[kind] = new VertexBuffer(this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true);
|
|
679
|
+
this._invalidateInstanceVertexArrayObject();
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
perPassVertexBuffers[kind].updateDirectly(data, 0);
|
|
683
|
+
}
|
|
647
684
|
}
|
|
648
685
|
else {
|
|
649
|
-
this._userInstancedBuffersStorage.vertexBuffers[kind]
|
|
686
|
+
if (!this._userInstancedBuffersStorage.vertexBuffers[kind]) {
|
|
687
|
+
this._userInstancedBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true);
|
|
688
|
+
this._invalidateInstanceVertexArrayObject();
|
|
689
|
+
}
|
|
690
|
+
else {
|
|
691
|
+
this._userInstancedBuffersStorage.vertexBuffers[kind].updateDirectly(data, 0);
|
|
692
|
+
}
|
|
650
693
|
}
|
|
651
694
|
}
|
|
652
695
|
};
|
|
@@ -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,GAA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AC,CAAC;AAEF,IAAI,CAAC,SAAS,CAAC,4BAA4B,GAAG;IAC1C,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,oBAAoB,CAAC,YAAY,EAAE,CAAC;QAChE,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,eAAe,EAAE,OAAO,EAAE,CAAC;IACpF,CAAC;IACD,IAAI,CAAC,oBAAoB,CAAC,YAAY,GAAG,EAAE,CAAC;IAC5C,IAAI,CAAC,oBAAoB,CAAC,qBAAqB,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC;IAE5E,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,SAAS,CAAC,CAAC,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 /** @internal */\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 /** @internal */\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 /** @internal */\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 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 /** @internal */\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 /** @internal */\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 /** @internal */\r\n public override get _positions(): Nullable<Vector3[]> {\r\n return this._sourceMesh._positions;\r\n }\r\n\r\n /** @internal */\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 /** @internal */\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 /** @internal */\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 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 /** @internal */\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 /** @internal */\r\n data: { [key: string]: Float32Array };\r\n /** @internal */\r\n sizes: { [key: string]: number };\r\n /** @internal */\r\n vertexBuffers: { [key: string]: Nullable<VertexBuffer> };\r\n /** @internal */\r\n strides: { [key: string]: number };\r\n /** @internal */\r\n vertexArrayObjects?: { [key: string]: WebGLVertexArrayObject };\r\n /** @internal */\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 /** @internal */\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] ?? 0;\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] ?? 0;\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 this._instanceDataStorage.dataStorageRenderPass?.instancesBuffer?.dispose();\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,iBAAi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I,CAAC,oBAAoB,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,eAAe,EAAE,OAAO,EAAE,CAAC;IACpF,CAAC;IACD,IAAI,CAAC,oBAAoB,CAAC,YAAY,GAAG,EAAE,CAAC;IAC5C,IAAI,CAAC,oBAAoB,CAAC,qBAAqB,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC;IAE5E,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,SAAS,CAAC,CAAC,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 /** @internal */\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 /** @internal */\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 /** @internal */\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 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 /** @internal */\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 /** @internal */\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 /** @internal */\r\n public override get _positions(): Nullable<Vector3[]> {\r\n return this._sourceMesh._positions;\r\n }\r\n\r\n /** @internal */\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 /** @internal */\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 /** @internal */\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 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 /** @internal */\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 /** @internal */\r\n data: { [key: string]: Float32Array };\r\n /** @internal */\r\n sizes: { [key: string]: number };\r\n /** @internal */\r\n vertexBuffers: { [key: string]: Nullable<VertexBuffer> };\r\n /** @internal */\r\n strides: { [key: string]: number };\r\n /** @internal */\r\n vertexArrayObjects?: { [key: string]: WebGLVertexArrayObject };\r\n /** @internal */\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 /** @internal */\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 (shared VBO)\r\n this._userInstancedBuffersStorage?.vertexBuffers[kind]?.dispose();\r\n\r\n // Remove existing per-pass VBOs (WebGPU)\r\n if (this._userInstancedBuffersStorage?.renderPasses) {\r\n for (const passId in this._userInstancedBuffersStorage.renderPasses) {\r\n const passVBOs = this._userInstancedBuffersStorage.renderPasses[passId];\r\n passVBOs[kind]?.dispose();\r\n delete passVBOs[kind];\r\n }\r\n }\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 // In WebGPU, per-pass VBOs are used instead of a shared one (created on demand in _processInstancedBuffers)\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = this._instanceDataStorage.useMonoDataStorageRenderPass\r\n ? new VertexBuffer(this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true)\r\n : null;\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 // In WebGPU, queue.writeBuffer() writes are all applied before the command buffer executes,\r\n // so a shared VBO written by multiple render passes (e.g. effect layer + main scene) will\r\n // only reflect the last write for ALL passes. Use per-render-pass VBOs instead.\r\n const usePerPassStorage = !this._instanceDataStorage.useMonoDataStorageRenderPass;\r\n let perPassVertexBuffers: { [kind: string]: Nullable<VertexBuffer> } | undefined;\r\n if (usePerPassStorage) {\r\n const currentRenderPassId = this._instanceDataStorage.engine.currentRenderPassId;\r\n if (!this._userInstancedBuffersStorage.renderPasses) {\r\n this._userInstancedBuffersStorage.renderPasses = {};\r\n }\r\n if (!this._userInstancedBuffersStorage.renderPasses[currentRenderPassId]) {\r\n this._userInstancedBuffersStorage.renderPasses[currentRenderPassId] = {};\r\n }\r\n perPassVertexBuffers = this._userInstancedBuffersStorage.renderPasses[currentRenderPassId];\r\n }\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 (usePerPassStorage) {\r\n if (perPassVertexBuffers![kind]) {\r\n perPassVertexBuffers![kind]!.dispose();\r\n perPassVertexBuffers![kind] = null;\r\n }\r\n } else 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] ?? 0;\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] ?? 0;\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 (per-pass in WebGPU, shared in WebGL)\r\n if (usePerPassStorage) {\r\n if (!perPassVertexBuffers![kind]) {\r\n perPassVertexBuffers![kind] = new VertexBuffer(this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true);\r\n this._invalidateInstanceVertexArrayObject();\r\n } else {\r\n perPassVertexBuffers![kind]!.updateDirectly(data, 0);\r\n }\r\n } else {\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\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 this._instanceDataStorage.dataStorageRenderPass?.instancesBuffer?.dispose();\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.js
CHANGED
|
@@ -2008,6 +2008,12 @@ export class Mesh extends AbstractMesh {
|
|
|
2008
2008
|
delete this._instanceDataStorage.renderPasses[id];
|
|
2009
2009
|
}
|
|
2010
2010
|
if (this._userInstancedBuffersStorage?.renderPasses) {
|
|
2011
|
+
const passVBOs = this._userInstancedBuffersStorage.renderPasses[id];
|
|
2012
|
+
if (passVBOs) {
|
|
2013
|
+
for (const kind in passVBOs) {
|
|
2014
|
+
passVBOs[kind]?.dispose();
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2011
2017
|
delete this._userInstancedBuffersStorage.renderPasses[id];
|
|
2012
2018
|
}
|
|
2013
2019
|
}
|