{"version":3,"file":"webgl.cjs","sources":["../../src/core/BatchedMeshBVH.ts","../../src/core/MultiDrawRenderList.ts","../../src/core/SquareDataTexture.ts","../../src/core/feature/ComputeBVH.ts","../../src/utils/SortingUtils.ts","../../src/core/feature/FrustumCulling.ts","../../src/core/feature/GetPositionAt.ts","../../src/core/feature/LOD.ts","../../src/core/feature/Raycasting.ts","../../src/core/feature/Uniforms.common.ts","../../src/patch/PatchBatchedMeshMaterial.webgl.ts","../../src/core/feature/Uniforms.webgl.ts","../../src/patch/ExtendBatchedMeshPrototype.common.ts","../../src/patch/ExtendBatchedMeshPrototype.webgl.ts","../../src/utils/CountUtils.ts"],"sourcesContent":["import { box3ToArray, BVH, BVHNode, HybridBuilder, onFrustumIntersectionCallback, onIntersectionCallback, onIntersectionRayCallback, vec3ToArray, WebGLCoordinateSystem, WebGPUCoordinateSystem } from 'bvh.js';\nimport { BatchedMesh, Box3, CoordinateSystem, Matrix4, Raycaster } from 'three';\n\n// TODO implement getBBoxFromBSphere (add property to geometryInfo)\n// TODO implement frustumCullingLOD?\n\n/**\n * Class to manage BVH (Bounding Volume Hierarchy) for `BatchedMesh`.\n * Provides methods for managing bounding volumes, frustum culling, raycasting, and bounding box computation.\n */\nexport class BatchedMeshBVH {\n  /**\n   * The target `BatchedMesh` object that the BVH is managing.\n   */\n  public target: BatchedMesh;\n  /**\n   * The BVH instance used to organize bounding volumes.\n   */\n  public bvh: BVH<{}, number>;\n  /**\n   * A map that stores the BVH nodes for each instance.\n   */\n  public nodesMap = new Map<number, BVHNode<{}, number>>();\n  /**\n   * Enables accurate frustum culling by checking intersections without applying margin to the bounding box.\n   */\n  public accurateCulling: boolean;\n  protected _margin: number;\n  protected _origin = new Float32Array(3);\n  protected _dir = new Float32Array(3);\n  protected _cameraPos = new Float32Array(3);\n  protected _boxArray = new Float32Array(6);\n\n  /**\n   * @param target The target `BatchedMesh`.\n   * @param margin The margin applied for bounding box calculations (default is 0).\n   * @param accurateCulling Flag to enable accurate frustum culling without considering margin (default is true).\n   */\n  constructor(target: BatchedMesh, coordinateSystem: CoordinateSystem, margin = 0, accurateCulling = true) {\n    this.target = target;\n    this.accurateCulling = accurateCulling;\n    this._margin = margin;\n\n    this.bvh = new BVH(new HybridBuilder(), coordinateSystem === 2000 ? WebGLCoordinateSystem : WebGPUCoordinateSystem); // TODO fix in BVH.js\n  }\n\n  /**\n   * Builds the BVH from the target mesh's instances using a top-down construction method.\n   * This approach is more efficient and accurate compared to incremental methods, which add one instance at a time.\n   */\n  public create(): void {\n    const count = this.target.instanceCount;\n    const instancesArrayCount = this.target._instanceInfo.length; // TODO this may change.. don't like it too much\n    const instancesInfo = this.target._instanceInfo;\n    const boxes: Float32Array[] = new Array(count); // test if single array and recreation inside node creation is faster due to memory location\n    const objects = new Uint32Array(count);\n    let index = 0;\n\n    this.clear();\n\n    for (let i = 0; i < instancesArrayCount; i++) {\n      if (!instancesInfo[i].active) continue;\n      boxes[index] = this.getBox(i, new Float32Array(6));\n      objects[index] = i;\n      index++;\n    }\n\n    this.bvh.createFromArray(objects as unknown as number[], boxes, (node) => {\n      this.nodesMap.set(node.object, node);\n    }, this._margin);\n  }\n\n  /**\n   * Inserts an instance into the BVH.\n   * @param id The id of the instance to insert.\n   */\n  public insert(id: number): void {\n    const node = this.bvh.insert(id, this.getBox(id, new Float32Array(6)), this._margin);\n    this.nodesMap.set(id, node);\n  }\n\n  /**\n   * Inserts a range of instances into the BVH.\n   * @param ids An array of ids to insert.\n   */\n  public insertRange(ids: number[]): void {\n    const count = ids.length;\n    const boxes: Float32Array[] = new Array(count);\n\n    for (let i = 0; i < count; i++) {\n      boxes[i] = this.getBox(ids[i], new Float32Array(6));\n    }\n\n    this.bvh.insertRange(ids, boxes, this._margin, (node) => {\n      this.nodesMap.set(node.object, node);\n    });\n  }\n\n  /**\n   * Moves an instance within the BVH.\n   * @param id The id of the instance to move.\n   */\n  public move(id: number): void {\n    const node = this.nodesMap.get(id);\n    if (!node) return;\n    this.getBox(id, node.box as Float32Array); // this also updates box\n    this.bvh.move(node, this._margin);\n  }\n\n  /**\n   * Deletes an instance from the BVH.\n   * @param id The id of the instance to delete.\n   */\n  public delete(id: number): void {\n    const node = this.nodesMap.get(id);\n    if (!node) return;\n    this.bvh.delete(node);\n    this.nodesMap.delete(id);\n  }\n\n  /**\n   * Clears the BVH.\n   */\n  public clear(): void {\n    this.bvh.clear();\n    this.nodesMap.clear();\n  }\n\n  /**\n   * Performs frustum culling to determine which instances are visible based on the provided projection matrix.\n   * @param projScreenMatrix The projection screen matrix for frustum culling.\n   * @param onFrustumIntersection Callback function invoked when an instance intersects the frustum.\n   */\n  public frustumCulling(projScreenMatrix: Matrix4, onFrustumIntersection: onFrustumIntersectionCallback<{}, number>): void {\n    if (this._margin > 0 && this.accurateCulling) {\n      this.bvh.frustumCulling(projScreenMatrix.elements, (node, frustum, mask) => {\n        if (frustum.isIntersectedMargin(node.box, mask, this._margin)) {\n          onFrustumIntersection(node);\n        }\n      });\n    } else {\n      this.bvh.frustumCulling(projScreenMatrix.elements, onFrustumIntersection);\n    }\n  }\n\n  /**\n   * Performs raycasting to check if a ray intersects any instances.\n   * @param raycaster The raycaster used for raycasting.\n   * @param onIntersection Callback function invoked when a ray intersects an instance.\n   */\n  public raycast(raycaster: Raycaster, onIntersection: onIntersectionRayCallback<number>): void {\n    const ray = raycaster.ray;\n    const origin = this._origin;\n    const dir = this._dir;\n\n    vec3ToArray(ray.origin, origin);\n    vec3ToArray(ray.direction, dir);\n\n    // TODO should we add margin check? maybe is not worth it\n    this.bvh.rayIntersections(dir, origin, onIntersection, raycaster.near, raycaster.far);\n  }\n\n  /**\n   * Checks if a given box intersects with any instance bounding box.\n   * @param target The target bounding box.\n   * @param onIntersection Callback function invoked when an intersection occurs.\n   * @returns `True` if there is an intersection, otherwise `false`.\n   */\n  public intersectBox(target: Box3, onIntersection: onIntersectionCallback<number>): boolean {\n    const array = this._boxArray;\n    box3ToArray(target, array);\n    return this.bvh.intersectsBox(array, onIntersection);\n  }\n\n  protected getBox(id: number, array: Float32Array): Float32Array {\n    const target = this.target;\n    const geometryId = target._instanceInfo[id].geometryIndex;\n    target.getBoundingBoxAt(geometryId, _box3).applyMatrix4(target.getMatrixAt(id, _matrix));\n    box3ToArray(_box3, array);\n    return array;\n  }\n}\n\nconst _box3 = new Box3();\nconst _matrix = new Matrix4();\n","export type MultiDrawRenderItem = { start: number; count: number; z: number; zSort?: number; index?: number };\n\n/**\n * A class that creates and manages a list of render items, used to determine the rendering order based on depth.\n * @internal\n */\nexport class MultiDrawRenderList {\n  public array: MultiDrawRenderItem[] = [];\n  protected pool: MultiDrawRenderItem[] = [];\n\n  public push(instanceId: number, depth: number, start: number, count: number): void {\n    const pool = this.pool;\n    const list = this.array;\n    const index = list.length;\n\n    if (index >= pool.length) {\n      pool.push({ start: null, count: null, z: null, zSort: null, index: null });\n    }\n\n    const item = pool[index];\n    item.index = instanceId;\n    item.start = start;\n    item.count = count;\n    item.z = depth;\n\n    list.push(item);\n  }\n\n  public reset(): void {\n    this.array.length = 0;\n  }\n}\n","import { Color, ColorManagement, DataTexture, FloatType, IntType, Matrix3, Matrix4, NoColorSpace, PixelFormat, RedFormat, RedIntegerFormat, RGBAFormat, RGBAIntegerFormat, RGFormat, RGIntegerFormat, TextureDataType, TypedArray, UnsignedIntType, Vector2, Vector3, Vector4, WebGLRenderer, WebGLUtils } from 'three';\n\n/**\n * Represents the number of elements per pixel.\n */\nexport type ChannelSize = 1 | 2 | 3 | 4;\n/**\n * A constructor signature for creating TypedArray.\n */\nexport type TypedArrayConstructor = new (count: number) => TypedArray;\n/**\n * Represents the texture information including its data, size, format, and data type.\n */\nexport type TextureInfo = { array: TypedArray; size: number; format: PixelFormat; type: TextureDataType };\n/**\n * Represents information for updating rows in the texture, including the row index and number of rows.\n */\nexport type UpdateRowInfo = { row: number; count: number };\n/**\n * Defines the possible types of uniforms that can be used in shaders.\n */\nexport type UniformType = 'float' | 'vec2' | 'vec3' | 'vec4' | 'mat3' | 'mat4';\n/**\n * Represents a value that can be used as a uniform.\n */\nexport type UniformValueObj = Vector2 | Vector3 | Vector4 | Matrix3 | Matrix4 | Color;\n/**\n * Defines a uniform value as either a number or a compatible Three.js object.\n */\nexport type UniformValue = number | UniformValueObj;\n/**\n * Represents the schema for a uniform, defining its offset, size, and type.\n */\nexport type UniformMapType = { offset: number; size: number; type: UniformType };\n/**\n * Represents a map of uniform names to their schema definitions.\n */\nexport type UniformMap = Map<string, UniformMapType>;\n\n/**\n * Calculates the square texture size based on the capacity and pixels per instance.\n * This ensures the texture is large enough to store all instances in a square layout.\n * @param capacity The maximum number of instances allowed in the texture.\n * @param pixelsPerInstance The number of pixels required for each instance.\n * @returns The size of the square texture needed to store all the instances.\n */\nexport function getSquareTextureSize(capacity: number, pixelsPerInstance: number): number {\n  return Math.max(pixelsPerInstance, Math.ceil(Math.sqrt(capacity / pixelsPerInstance)) * pixelsPerInstance);\n}\n\n/**\n * Generates texture information (size, format, type) for a square texture based on the provided parameters.\n * @param arrayType The constructor for the TypedArray.\n * @param channels The number of channels in the texture.\n * @param pixelsPerInstance The number of pixels required for each instance.\n * @param capacity The maximum number of instances allowed in the texture.\n * @returns An object containing the texture's array, size, format, and data type.\n */\nexport function getSquareTextureInfo(arrayType: TypedArrayConstructor, channels: ChannelSize, pixelsPerInstance: number, capacity: number): TextureInfo {\n  if (channels === 3) {\n    console.warn('\"channels\" cannot be 3. Set to 4. More info: https://github.com/mrdoob/three.js/pull/23228');\n    channels = 4;\n  }\n\n  const size = getSquareTextureSize(capacity, pixelsPerInstance);\n  const array = new arrayType(size * size * channels);\n  const isFloat = arrayType.name.includes('Float');\n  const isUnsignedInt = arrayType.name.includes('Uint');\n  const type: TextureDataType = isFloat ? FloatType : (isUnsignedInt ? UnsignedIntType : IntType);\n  let format: PixelFormat;\n\n  switch (channels) {\n    case 1:\n      format = isFloat ? RedFormat : RedIntegerFormat;\n      break;\n    case 2:\n      format = isFloat ? RGFormat : RGIntegerFormat;\n      break;\n    case 4:\n      format = isFloat ? RGBAFormat : RGBAIntegerFormat;\n      break;\n  }\n\n  return { array, size, type, format };\n}\n\n/**\n * A class that extends `DataTexture` to manage a square texture optimized for instances rendering.\n * It supports dynamic resizing, partial update based on rows, and allows setting/getting uniforms per instance.\n */\nexport class SquareDataTexture extends DataTexture {\n  /**\n   * Whether to enable partial texture updates by row. If `false`, the entire texture will be updated.\n   * @default true.\n   */\n  public partialUpdate = true;\n  /**\n   * The maximum number of update calls per frame.\n   * @default Infinity\n   */\n  public maxUpdateCalls = Infinity;\n  /** @internal */ _data: TypedArray; // TODO make it public or remove it?\n  protected _channels: ChannelSize;\n  protected _pixelsPerInstance: number;\n  protected _stride: number;\n  protected _rowToUpdate: boolean[];\n  protected _uniformMap: UniformMap;\n  protected _fetchUniformsInFragmentShader: boolean;\n  protected _utils: WebGLUtils = null; // TODO add it to renderer instead of creating for each texture\n  protected _needsUpdate: boolean = false;\n  protected _lastWidth: number = null;\n\n  // Read-only accessors for TSL/WGSL integrations\n  public get pixelsPerInstance(): number { return this._pixelsPerInstance; }\n  public get channels(): ChannelSize { return this._channels; }\n  public get uniformMap(): UniformMap { return this._uniformMap; }\n\n  /**\n   * @param arrayType The constructor for the TypedArray.\n   * @param channels The number of channels in the texture.\n   * @param pixelsPerInstance The number of pixels required for each instance.\n   * @param capacity The total number of instances.\n   * @param uniformMap Optional map for handling uniform values.\n   * @param fetchInFragmentShader Optional flag that determines if uniform values should be fetched in the fragment shader instead of the vertex shader.\n   */\n  constructor(arrayType: TypedArrayConstructor, channels: ChannelSize, pixelsPerInstance: number, capacity: number, uniformMap?: UniformMap, fetchInFragmentShader?: boolean) {\n    if (channels === 3) channels = 4;\n    const { array, format, size, type } = getSquareTextureInfo(arrayType, channels, pixelsPerInstance, capacity);\n    super(array, size, size, format, type);\n    this._data = array;\n    this._channels = channels;\n    this._pixelsPerInstance = pixelsPerInstance;\n    this._stride = pixelsPerInstance * channels;\n    this._rowToUpdate = new Array(size);\n    this._uniformMap = uniformMap;\n    this._fetchUniformsInFragmentShader = fetchInFragmentShader;\n    this.needsUpdate = true; // necessary to init texture\n  }\n\n  /**\n   * Resizes the texture to accommodate a new number of instances.\n   * @param count The new total number of instances.\n   */\n  public resize(count: number): void {\n    const size = getSquareTextureSize(count, this._pixelsPerInstance);\n    if (size === this.image.width) return;\n\n    const currentData = this._data;\n    const channels = this._channels;\n    this._rowToUpdate.length = size;\n    const arrayType = (currentData as any).constructor;\n\n    const data = new arrayType(size * size * channels);\n    const minLength = Math.min(currentData.length, data.length);\n    data.set(new arrayType(currentData.buffer, 0, minLength));\n\n    this.dispose();\n    this.image = { data, height: size, width: size };\n    this._data = data;\n  }\n\n  /**\n   * Marks a row of the texture for update during the next render cycle.\n   * This helps in optimizing texture updates by only modifying the rows that have changed.\n   * @param index The index of the instance to update.\n   */\n  public enqueueUpdate(index: number): void {\n    this._needsUpdate = true;\n    if (!this.partialUpdate) return;\n\n    const elementsPerRow = this.image.width / this._pixelsPerInstance;\n    const rowIndex = Math.floor(index / elementsPerRow);\n    this._rowToUpdate[rowIndex] = true;\n  }\n\n  /**\n   * Updates the texture data based on the rows that need updating.\n   * This method is optimized to only update the rows that have changed, improving performance.\n   * @param renderer The renderer used for rendering. Supports WebGLRenderer and WebGPURenderer.\n   */\n  public update(renderer: any): void {\n    // WebGPU fallback: trigger full texture update via public API\n    if (renderer?.isWebGPURenderer) {\n      if (this._needsUpdate) {\n        this.needsUpdate = true; // let Three.js handle the upload via WebGPU path\n        this._lastWidth = this.image.width;\n        this._needsUpdate = false;\n        this._rowToUpdate.fill(false);\n      }\n      return;\n    }\n\n    // WebGL partial updates\n    const glRenderer = renderer as WebGLRenderer;\n    const textureProperties: any = glRenderer.properties.get(this);\n    const versionChanged = this.version > 0 && textureProperties.__version !== this.version;\n    const sizeChanged = this._lastWidth !== null && this._lastWidth !== this.image.width;\n    if (!this._needsUpdate || !textureProperties.__webglTexture || versionChanged || sizeChanged) {\n      this._lastWidth = this.image.width;\n      this._needsUpdate = false;\n      return;\n    }\n\n    this._needsUpdate = false;\n\n    if (!this.partialUpdate) {\n      this.needsUpdate = true; // three.js will update the whole texture\n      return;\n    }\n\n    const rowsInfo = this.getUpdateRowsInfo();\n    if (rowsInfo.length === 0) return;\n\n    if (rowsInfo.length > this.maxUpdateCalls) {\n      this.needsUpdate = true; // three.js will update the whole texture\n    } else {\n      this.updateRows(textureProperties, glRenderer, rowsInfo);\n    }\n\n    this._rowToUpdate.fill(false);\n  }\n\n  // TODO reuse same objects to prevent memory leak\n  protected getUpdateRowsInfo(): UpdateRowInfo[] {\n    const rowsToUpdate = this._rowToUpdate;\n    const result: UpdateRowInfo[] = [];\n\n    for (let i = 0, l = rowsToUpdate.length; i < l; i++) {\n      if (rowsToUpdate[i]) {\n        const row = i;\n        for (; i < l; i++) {\n          if (!rowsToUpdate[i]) break;\n        }\n        result.push({ row, count: i - row });\n      }\n    }\n\n    return result;\n  }\n\n  protected updateRows(textureProperties: any, renderer: WebGLRenderer, info: UpdateRowInfo[]): void {\n    const state = renderer.state;\n    const gl = renderer.getContext() as WebGL2RenderingContext;\n    // @ts-expect-error Expected 2 arguments, but got 3.\n    this._utils ??= new WebGLUtils(gl, renderer.extensions, renderer.capabilities); // third argument is necessary for older three versions\n    const glFormat = this._utils.convert(this.format);\n    const glType = this._utils.convert(this.type);\n    const { data, width } = this.image;\n    const channels = this._channels;\n\n    state.bindTexture(gl.TEXTURE_2D, textureProperties.__webglTexture);\n\n    const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);\n    const texturePrimaries = this.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(this.colorSpace);\n    const unpackConversion = this.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? gl.NONE : gl.BROWSER_DEFAULT_WEBGL;\n\n    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this.flipY);\n    gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha);\n    gl.pixelStorei(gl.UNPACK_ALIGNMENT, this.unpackAlignment);\n    gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);\n\n    for (const { count, row } of info) {\n      gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, row, width, count, glFormat, glType, data, row * width * channels);\n    }\n\n    if (this.onUpdate) this.onUpdate(this);\n  }\n\n  /**\n   * Sets a uniform value at the specified instance ID in the texture.\n   * @param id The instance ID to set the uniform for.\n   * @param name The name of the uniform.\n   * @param value The value to set for the uniform.\n   */\n  public setUniformAt(id: number, name: string, value: UniformValue): void {\n    const { offset, size } = this._uniformMap.get(name);\n    const stride = this._stride;\n\n    if (size === 1) {\n      this._data[id * stride + offset] = value as number;\n    } else {\n      (value as UniformValueObj).toArray(this._data, id * stride + offset);\n    }\n  }\n\n  /**\n   * Retrieves a uniform value at the specified instance ID from the texture.\n   * @param id The instance ID to retrieve the uniform from.\n   * @param name The name of the uniform.\n   * @param target Optional target object to store the uniform value.\n   * @returns The uniform value for the specified instance.\n   */\n  public getUniformAt(id: number, name: string, target?: UniformValueObj): UniformValue {\n    const { offset, size } = this._uniformMap.get(name);\n    const stride = this._stride;\n\n    if (size === 1) {\n      return this._data[id * stride + offset];\n    }\n\n    return target.fromArray(this._data, id * stride + offset);\n  }\n\n  /**\n   * Generates the GLSL code for accessing the uniform data stored in the texture.\n   * @param textureName The name of the texture in the GLSL shader.\n   * @param indexName The name of the index in the GLSL shader.\n   * @param indexType The type of the index in the GLSL shader.\n   * @returns An object containing the GLSL code for the vertex and fragment shaders.\n   */\n  public getUniformsGLSL(textureName: string, indexName: string, indexType: string): { vertex: string; fragment: string } {\n    const vertex = this.getUniformsVertexGLSL(textureName, indexName, indexType);\n    const fragment = this.getUniformsFragmentGLSL(textureName, indexName, indexType);\n    return { vertex, fragment };\n  }\n\n  protected getUniformsVertexGLSL(textureName: string, indexName: string, indexType: string): string {\n    if (this._fetchUniformsInFragmentShader) {\n      return `\n        flat varying ${indexType} ez_v${indexName}; \n        void main() {\n          ez_v${indexName} = ${indexName};`;\n    }\n\n    const texelsFetch = this.texelsFetchGLSL(textureName, indexName);\n    const getFromTexels = this.getFromTexelsGLSL();\n    const { assignVarying, declareVarying } = this.getVarying();\n\n    return `\n      uniform highp sampler2D ${textureName};  \n      ${declareVarying}\n      void main() {\n        ${texelsFetch}\n        ${getFromTexels}\n        ${assignVarying}`;\n  }\n\n  protected getUniformsFragmentGLSL(textureName: string, indexName: string, indexType: string): string {\n    if (!this._fetchUniformsInFragmentShader) {\n      const { declareVarying, getVarying } = this.getVarying();\n\n      return `\n      ${declareVarying}\n      void main() {\n        ${getVarying}`;\n    }\n\n    const texelsFetch = this.texelsFetchGLSL(textureName, `ez_v${indexName}`);\n    const getFromTexels = this.getFromTexelsGLSL();\n\n    return `\n      uniform highp sampler2D ${textureName};  \n      flat varying ${indexType} ez_v${indexName};\n      void main() {\n        ${texelsFetch}\n        ${getFromTexels}`;\n  }\n\n  protected texelsFetchGLSL(textureName: string, indexName: string): string {\n    const pixelsPerInstance = this._pixelsPerInstance;\n\n    let texelsFetch = `\n      int size = textureSize(${textureName}, 0).x;\n      int j = int(${indexName}) * ${pixelsPerInstance};\n      int x = j % size;\n      int y = j / size;\n    `;\n\n    for (let i = 0; i < pixelsPerInstance; i++) {\n      texelsFetch += `vec4 ez_texel${i} = texelFetch(${textureName}, ivec2(x + ${i}, y), 0);\\n`;\n    }\n\n    return texelsFetch;\n  }\n\n  protected getFromTexelsGLSL(): string {\n    const uniforms = this._uniformMap;\n    let getFromTexels = '';\n\n    for (const [name, { type, offset, size }] of uniforms) {\n      const tId = Math.floor(offset / this._channels);\n\n      if (type === 'mat3') {\n        getFromTexels += `mat3 ${name} = mat3(ez_texel${tId}.rgb, vec3(ez_texel${tId}.a, ez_texel${tId + 1}.rg), vec3(ez_texel${tId + 1}.ba, ez_texel${tId + 2}.r));\\n`;\n      } else if (type === 'mat4') {\n        getFromTexels += `mat4 ${name} = mat4(ez_texel${tId}, ez_texel${tId + 1}, ez_texel${tId + 2}, ez_texel${tId + 3});\\n`;\n      } else {\n        const components = this.getUniformComponents(offset, size);\n        getFromTexels += `${type} ${name} = ez_texel${tId}.${components};\\n`;\n      }\n    }\n\n    return getFromTexels;\n  }\n\n  protected getVarying(): { declareVarying: string; assignVarying: string; getVarying: string } {\n    const uniforms = this._uniformMap;\n    let declareVarying = '';\n    let assignVarying = '';\n    let getVarying = '';\n\n    for (const [name, { type }] of uniforms) {\n      declareVarying += `flat varying ${type} ez_v${name};\\n`;\n      assignVarying += `ez_v${name} = ${name};\\n`;\n      getVarying += `${type} ${name} = ez_v${name};\\n`;\n    }\n\n    return { declareVarying, assignVarying, getVarying };\n  }\n\n  protected getUniformComponents(offset: number, size: number): string {\n    const startIndex = offset % this._channels;\n    let components = '';\n\n    for (let i = 0; i < size; i++) {\n      components += componentsArray[startIndex + i];\n    }\n\n    return components;\n  }\n\n  public override copy(source: SquareDataTexture): this {\n    super.copy(source);\n\n    this.partialUpdate = source.partialUpdate;\n    this.maxUpdateCalls = source.maxUpdateCalls;\n    this._channels = source._channels;\n    this._pixelsPerInstance = source._pixelsPerInstance;\n    this._stride = source._stride;\n    this._rowToUpdate = source._rowToUpdate;\n    this._uniformMap = source._uniformMap;\n    this._fetchUniformsInFragmentShader = source._fetchUniformsInFragmentShader;\n\n    return this;\n  }\n}\n\nconst componentsArray = ['r', 'g', 'b', 'a'];\n","import { BatchedMesh, CoordinateSystem } from 'three';\nimport { BatchedMeshBVH } from '../BatchedMeshBVH.js';\n\n/**\n * Parameters for configuring the BVH (Bounding Volume Hierarchy).\n */\nexport interface BVHParams {\n  /**\n   * Margin applied to accommodate animated or moving objects.\n   * Improves BVH update performance but slows down frustum culling and raycasting.\n   * For static objects, set to 0 to optimize culling and raycasting efficiency.\n   * @default 0\n   */\n  margin?: number;\n  /**\n   * Enables accurate frustum culling by checking intersections without applying margin to the bounding box.\n   * @default true\n   */\n  accurateCulling?: boolean;\n}\n\ndeclare module 'three' {\n  interface BatchedMesh {\n    /**\n     * BVH structure for optimized culling and intersection testing.\n     * It's possible to create the BVH using the `computeBVH` method. Once created it will be updated automatically.\n     */\n    bvh?: BatchedMeshBVH;\n    /**\n     * Creates and computes the BVH (Bounding Volume Hierarchy) for the instances.\n     * It's recommended to create it when all the instance matrices have been assigned.\n     * Once created it will be updated automatically.\n     * @param coordinateSystem The coordinate system (webgl or webgpu) in which the BVH is computed.\n     * @param config Optional configuration parameters object. See `BVHParams` for details.\n     */\n    computeBVH(coordinateSystem: CoordinateSystem, config?: BVHParams): void;\n  }\n}\n\nexport function computeBVH(this: BatchedMesh, coordinateSystem: CoordinateSystem, config: BVHParams = {}): void {\n  this.bvh = new BatchedMeshBVH(this, coordinateSystem, config.margin, config.accurateCulling);\n  this.bvh.create();\n}\n","import { BatchedMesh } from 'three';\nimport { radixSort, RadixSortOptions } from 'three/addons/utils/SortUtils.js';\nimport { MultiDrawRenderItem } from '../core/MultiDrawRenderList.js';\n\ntype radixSortCallback = (list: MultiDrawRenderItem[]) => void;\n\n/**\n * Creates a radix sort function specifically for sorting `BatchedMesh` instances.\n * The sorting is based on the `depth` property of each `MultiDrawRenderItem`.\n * This function dynamically adjusts for transparent materials by reversing the sort order if necessary.\n * @param target The `BatchedMesh` instance that contains the instances to be sorted.\n * @returns A radix sort function.\n * @reference https://github.com/mrdoob/three.js/blob/master/examples/webgl_mesh_batch.html#L291\n */\nexport function createRadixSort(target: BatchedMesh): radixSortCallback {\n  const options: RadixSortOptions<MultiDrawRenderItem> = {\n    get: (el) => el.zSort,\n    aux: new Array(target.maxInstanceCount),\n    reversed: null\n  };\n\n  return function sortFunction(list: MultiDrawRenderItem[]): void {\n    options.reversed = target.material.transparent;\n\n    if (target.maxInstanceCount > options.aux.length) {\n      options.aux.length = target.maxInstanceCount;\n    }\n\n    let minZ = Infinity;\n    let maxZ = -Infinity;\n\n    for (const { z } of list) {\n      if (z > maxZ) maxZ = z;\n      if (z < minZ) minZ = z;\n    }\n\n    const depthDelta = maxZ - minZ;\n    const factor = (2 ** 32 - 1) / depthDelta;\n\n    for (const item of list) {\n      item.zSort = (item.z - minZ) * factor;\n    }\n\n    radixSort(list, options);\n  };\n}\n\n/** @internal */\nexport function sortOpaque(a: MultiDrawRenderItem, b: MultiDrawRenderItem): number {\n  return a.z - b.z;\n}\n\n/** @internal */\nexport function sortTransparent(a: MultiDrawRenderItem, b: MultiDrawRenderItem): number {\n  return b.z - a.z;\n}\n","import { BVHNode } from 'bvh.js';\nimport { BatchedMesh, BufferGeometry, Camera, Frustum, Material, Matrix4, OrthographicCamera, PerspectiveCamera, Scene, Sphere, Vector3, WebGLRenderer } from 'three';\nimport { MultiDrawRenderItem, MultiDrawRenderList } from '../MultiDrawRenderList.js';\nimport { sortOpaque, sortTransparent } from '../../utils/SortingUtils.js';\n\n// TODO: fix LOD if no sorting and  no culling\n// TODO: viewSize can be calculate better\n\n/**\n * A custom sorting callback for render items.\n */\nexport type CustomSortCallback = (list: MultiDrawRenderItem[]) => void;\n\n/**\n * Callback invoked when an instance is within the frustum.\n * @param index The index of the instance.\n * @param camera The camera used for rendering.\n * @param cameraLOD The camera used for LOD calculations (provided only if LODs are initialized).\n * @param LODIndex The LOD level of the instance (provided only if LODs are initialized and `sortObjects` is false).\n * @returns True if the instance should be rendered, false otherwise.\n */\nexport type OnFrustumEnterCallback = (index: number, camera: Camera, cameraLOD?: Camera, LODIndex?: number) => boolean;\n\ndeclare module 'three' {\n  interface BatchedMesh {\n    /**\n     * Callback function called if an instance is inside the frustum.\n     */\n    onFrustumEnter?: OnFrustumEnterCallback;\n\n    /**\n     * Performs frustum culling and sorting.\n     * @param camera The main camera used for rendering.\n     * @param cameraLOD The camera used for LOD calculations (provided only if LODs are initialized).\n     */\n    frustumCulling(camera: Camera, cameraLOD?: Camera): void;\n    /**\n     * Updates the index array for indirect rendering.\n     */\n    updateIndexArray(): void;\n    /**\n     * Updates the render list based on the current visibility and sorting settings.\n     */\n    updateRenderList(): void;\n    /**\n     * Performs BVH frustum culling.\n     * @param camera The main camera used for rendering.\n     * @param cameraLOD The camera used for LOD calculations (provided only if LODs are initialized).\n     */\n    BVHCulling(camera: Camera, cameraLOD: Camera): void;\n    /**\n     * Performs linear frustum culling.\n     * @param camera The main camera used for rendering.\n     * @param cameraLOD The camera used for LOD calculations (provided only if LODs are initialized).\n     */\n    linearCulling(camera: Camera, cameraLOD: Camera): void;\n  }\n}\n\nconst _frustum = new Frustum();\nconst _renderList = new MultiDrawRenderList();\nconst _projScreenMatrix = new Matrix4();\nconst _invMatrixWorld = new Matrix4();\nconst _forward = new Vector3();\nconst _cameraPos = new Vector3();\nconst _cameraLODPos = new Vector3();\nconst _position = new Vector3();\nconst _sphere = new Sphere();\n\n// TODO move it\nexport function onBeforeRender(this: BatchedMesh, renderer: WebGLRenderer, scene: Scene, camera: Camera, geometry: BufferGeometry, material: Material, group: any): void {\n  // TODO check if nothing changed\n  this.frustumCulling(camera);\n  this.uniformsTexture?.update(renderer);\n}\n\nexport function frustumCulling(this: BatchedMesh, camera: Camera, cameraLOD = camera): void {\n  if (!this._visibilityChanged && !this.perObjectFrustumCulled && !this.sortObjects) {\n    return;\n  }\n\n  this._indirectTexture.needsUpdate = true;\n  this._visibilityChanged = false;\n\n  const sortObjects = this.sortObjects;\n  const perObjectFrustumCulled = this.perObjectFrustumCulled;\n\n  if (!perObjectFrustumCulled && !sortObjects) {\n    this.updateIndexArray();\n    return;\n  }\n\n  _invMatrixWorld.copy(this.matrixWorld).invert();\n  _cameraPos.setFromMatrixPosition(camera.matrixWorld).applyMatrix4(_invMatrixWorld);\n  _cameraLODPos.setFromMatrixPosition(cameraLOD.matrixWorld).applyMatrix4(_invMatrixWorld);\n  _forward.set(0, 0, -1).transformDirection(camera.matrixWorld).transformDirection(_invMatrixWorld);\n\n  if (!perObjectFrustumCulled) {\n    this.updateRenderList();\n  } else {\n    _projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse).multiply(this.matrixWorld);\n\n    if (this.bvh) this.BVHCulling(camera, cameraLOD);\n    else this.linearCulling(camera, cameraLOD);\n  }\n\n  if (sortObjects) {\n    const index = this.geometry.getIndex();\n    const bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;\n    const multiDrawStarts = this._multiDrawStarts;\n    const multiDrawCounts = this._multiDrawCounts;\n    const indirectArray = this._indirectTexture.image.data as unknown as number[];\n    const customSort = this.customSort as unknown as CustomSortCallback;\n\n    if (customSort === null) {\n      _renderList.array.sort(!this.material.transparent ? sortOpaque : sortTransparent);\n    } else {\n      customSort(_renderList.array); // TODO fix and remove second useless parameter... make a PR on main repo\n    }\n\n    const list = _renderList.array;\n    const count = list.length;\n    for (let i = 0; i < count; i++) {\n      const item = list[i];\n      multiDrawStarts[i] = item.start * bytesPerElement; // TODO multiply bytesPerElement in the renderList?\n      multiDrawCounts[i] = item.count;\n      indirectArray[i] = item.index;\n    }\n\n    _renderList.reset();\n  }\n}\n\nexport function updateIndexArray(this: BatchedMesh): void {\n  if (!this._visibilityChanged) return;\n\n  const index = this.geometry.getIndex();\n  const bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;\n  const instanceInfo = this._instanceInfo;\n  const geometryInfoList = this._geometryInfo;\n  const multiDrawStarts = this._multiDrawStarts;\n  const multiDrawCounts = this._multiDrawCounts;\n  const indirectArray = this._indirectTexture.image.data as unknown as number[];\n  let count = 0;\n\n  for (let i = 0, l = instanceInfo.length; i < l; i++) {\n    const instance = instanceInfo[i];\n    if (instance.visible && instance.active) {\n      const geometryId = instance.geometryIndex;\n      const geometryInfo = geometryInfoList[geometryId];\n\n      multiDrawStarts[count] = geometryInfo.start * bytesPerElement;\n      multiDrawCounts[count] = geometryInfo.count;\n      indirectArray[count] = i;\n      count++;\n    }\n  }\n\n  this._multiDrawCount = count;\n}\n\nexport function updateRenderList(this: BatchedMesh): void {\n  const instanceInfo = this._instanceInfo;\n  const geometryInfoList = this._geometryInfo;\n\n  for (let i = 0, l = instanceInfo.length; i < l; i++) {\n    const instance = instanceInfo[i];\n    if (instance.visible && instance.active) {\n      const geometryId = instance.geometryIndex;\n      const geometryInfo = geometryInfoList[geometryId];\n      const depth = this.getPositionAt(i).sub(_cameraPos).dot(_forward); // getPosition instead of _sphere.center\n      _renderList.push(i, depth, geometryInfo.start, geometryInfo.count);\n    }\n  }\n\n  this._multiDrawCount = _renderList.array.length;\n}\n\nexport function BVHCulling(this: BatchedMesh, camera: Camera, cameraLOD: Camera): void {\n  const index = this.geometry.getIndex();\n  const bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;\n  const instanceInfo = this._instanceInfo;\n  const geometryInfoList = this._geometryInfo;\n  const sortObjects = this.sortObjects;\n  const multiDrawStarts = this._multiDrawStarts;\n  const multiDrawCounts = this._multiDrawCounts;\n  const indirectArray = this._indirectTexture.image.data as unknown as number[];\n  const onFrustumEnter = this.onFrustumEnter;\n  let instancesCount = 0;\n\n  const orthographicCamera = camera as OrthographicCamera;\n  const viewSize = (orthographicCamera.top - orthographicCamera.bottom) / orthographicCamera.zoom;\n  const perspectiveCamera = camera as PerspectiveCamera;\n  const invProj = (Math.tan(perspectiveCamera.fov * 0.5 * (Math.PI / 180))) ** 2;\n  const useDistanceForLOD = this.useDistanceForLOD;\n  const isPerspectiveCamera = perspectiveCamera.isPerspectiveCamera;\n\n  this.bvh.frustumCulling(_projScreenMatrix, (node: BVHNode<{}, number>) => {\n    const index = node.object;\n    const instance = instanceInfo[index];\n\n    // we don't check if active because we remove inactive instances from BVH\n    if (!instance.visible) return;\n\n    const geometryId = instance.geometryIndex;\n    const geometryInfo = geometryInfoList[geometryId];\n    const LOD = geometryInfo.LOD;\n    let start: number;\n    let count: number;\n\n    if (LOD) {\n      _sphere.radius = geometryInfo.boundingSphere.radius;\n\n      let metric: number;\n      if (isPerspectiveCamera) {\n        const distance = this.getPositionAt(index).distanceToSquared(_cameraLODPos);\n        metric = getLODMetricPerspective(useDistanceForLOD, _sphere, invProj, distance);\n      } else {\n        metric = getLODMetricOrthographic(useDistanceForLOD, _sphere, viewSize);\n      }\n      const LODIndex = this.getLODIndex(LOD, metric, isPerspectiveCamera);\n\n      if (onFrustumEnter && !onFrustumEnter(index, camera, cameraLOD, LODIndex)) return;\n      start = LOD[LODIndex].start;\n      count = LOD[LODIndex].count;\n    } else {\n      if (onFrustumEnter && !onFrustumEnter(index, camera)) return;\n      start = geometryInfo.start;\n      count = geometryInfo.count;\n    }\n\n    // TODO don't reuse getPositionAt for sort\n    // TODO LOD optimized if bvh and sort?\n\n    if (sortObjects) {\n      const depth = this.getPositionAt(index).sub(_cameraPos).dot(_forward);\n      _renderList.push(index, depth, start, count);\n    } else {\n      multiDrawStarts[instancesCount] = start * bytesPerElement;\n      multiDrawCounts[instancesCount] = count;\n      indirectArray[instancesCount] = index;\n      instancesCount++;\n    }\n  });\n\n  this._multiDrawCount = sortObjects ? _renderList.array.length : instancesCount;\n}\n\nfunction getLODMetricPerspective(useDistanceForLOD: boolean, sphere: Sphere, invProj: number, distance: number): number {\n  return useDistanceForLOD ? distance : ((sphere.radius ** 2) / (distance * invProj));\n}\n\nfunction getLODMetricOrthographic(useDistanceForLOD: boolean, sphere: Sphere, viewHeight: number): number {\n  // TODO refactor\n  if (useDistanceForLOD) throw new Error('BatchedMesh: useDistanceForLOD cannot be used with orthographic camera.');\n  return sphere.radius * 2 / viewHeight;\n}\n\nexport function linearCulling(this: BatchedMesh, camera: Camera, cameraLOD: Camera): void {\n  const index = this.geometry.getIndex();\n  const bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;\n  const instanceInfo = this._instanceInfo;\n  const geometryInfoList = this._geometryInfo;\n  const sortObjects = this.sortObjects;\n  const multiDrawStarts = this._multiDrawStarts;\n  const multiDrawCounts = this._multiDrawCounts;\n  const indirectArray = this._indirectTexture.image.data as unknown as number[];\n  const onFrustumEnter = this.onFrustumEnter;\n  let instancesCount = 0;\n\n  _frustum.setFromProjectionMatrix(_projScreenMatrix);\n\n  const orthographicCamera = camera as OrthographicCamera;\n  const viewSize = (orthographicCamera.top - orthographicCamera.bottom) / orthographicCamera.zoom;\n  const perspectiveCamera = camera as PerspectiveCamera;\n  const invProj = (Math.tan(perspectiveCamera.fov * 0.5 * (Math.PI / 180))) ** 2;\n  const useDistanceForLOD = this.useDistanceForLOD;\n  const isPerspectiveCamera = perspectiveCamera.isPerspectiveCamera;\n\n  for (let i = 0, l = instanceInfo.length; i < l; i++) {\n    const instance = instanceInfo[i];\n    if (!instance.visible || !instance.active) continue;\n\n    const geometryId = instance.geometryIndex;\n    const geometryInfo = geometryInfoList[geometryId];\n    const LOD = geometryInfo.LOD;\n    let start: number;\n    let count: number;\n\n    const bSphere = geometryInfo.boundingSphere;\n    const radius = bSphere.radius;\n    const center = bSphere.center;\n    const geometryCentered = center.x === 0 && center.y === 0 && center.z === 0; // TODO add to geometryInfo?\n\n    if (geometryCentered) {\n      const maxScale = this.getPositionAndMaxScaleOnAxisAt(i, _sphere.center);\n      _sphere.radius = radius * maxScale;\n    } else {\n      this.applyMatrixAtToSphere(i, _sphere, center, radius);\n    }\n\n    if (!_frustum.intersectsSphere(_sphere)) continue;\n\n    if (LOD) {\n      let metric: number;\n      if (isPerspectiveCamera) {\n        const distance = _sphere.center.distanceToSquared(_cameraLODPos);\n        metric = getLODMetricPerspective(useDistanceForLOD, _sphere, invProj, distance);\n      } else {\n        metric = getLODMetricOrthographic(useDistanceForLOD, _sphere, viewSize);\n      }\n      const LODIndex = this.getLODIndex(LOD, metric, isPerspectiveCamera);\n\n      if (onFrustumEnter && !onFrustumEnter(i, camera, cameraLOD, LODIndex)) continue;\n      start = LOD[LODIndex].start;\n      count = LOD[LODIndex].count;\n    } else {\n      if (onFrustumEnter && !onFrustumEnter(i, camera)) continue;\n      start = geometryInfo.start;\n      count = geometryInfo.count;\n    }\n\n    // TODO LOD optimized if sort?\n\n    if (sortObjects) {\n      const depth = _position.subVectors(_sphere.center, _cameraPos).dot(_forward);\n      _renderList.push(i, depth, start, count);\n    } else {\n      multiDrawStarts[instancesCount] = start * bytesPerElement;\n      multiDrawCounts[instancesCount] = count;\n      indirectArray[instancesCount] = i;\n      instancesCount++;\n    }\n  }\n\n  this._multiDrawCount = sortObjects ? _renderList.array.length : instancesCount;\n}\n","import { BatchedMesh, Sphere, Vector3 } from 'three';\n\ndeclare module 'three' {\n  interface BatchedMesh {\n    /**\n     * Retrieves the position of a specific instance.\n     * @param index The index of the instance.\n     * @param target Optional `Vector3` to store the result.\n     * @returns The position of the instance as a `Vector3`.\n     */\n    getPositionAt(index: number, target?: Vector3): Vector3;\n    /**\n     * Retrieves the position and maximum scale on any axis of a specific instance.\n     * @param index The index of the instance.\n     * @param position Optional `Vector3` to store the position result.\n     * @returns The maximum scale on any axis.\n     */\n    getPositionAndMaxScaleOnAxisAt(index: number, position: Vector3): number;\n    /**\n     * Applies the transformation matrix of a specific instance to a sphere.\n     * @param index The index of the instance.\n     * @param sphere The sphere to transform.\n     * @param center TODO\n     * @param radius TODO\n     */\n    applyMatrixAtToSphere(index: number, sphere: Sphere, center: Vector3, radius: number): void;\n  }\n}\n\nconst _position = new Vector3();\n\nexport function getPositionAt(this: BatchedMesh, index: number, target = _position): Vector3 {\n  const offset = index * 16;\n  const array = this._matricesTexture.image.data as unknown as number[];\n\n  target.x = array[offset + 12];\n  target.y = array[offset + 13];\n  target.z = array[offset + 14];\n\n  return target;\n}\n\nexport function getPositionAndMaxScaleOnAxisAt(this: BatchedMesh, index: number, position: Vector3): number {\n  const offset = index * 16;\n  const array = this._matricesTexture.image.data as unknown as number[];\n\n  const te0 = array[offset + 0];\n  const te1 = array[offset + 1];\n  const te2 = array[offset + 2];\n  const scaleXSq = te0 * te0 + te1 * te1 + te2 * te2;\n\n  const te4 = array[offset + 4];\n  const te5 = array[offset + 5];\n  const te6 = array[offset + 6];\n  const scaleYSq = te4 * te4 + te5 * te5 + te6 * te6;\n\n  const te8 = array[offset + 8];\n  const te9 = array[offset + 9];\n  const te10 = array[offset + 10];\n  const scaleZSq = te8 * te8 + te9 * te9 + te10 * te10;\n\n  position.x = array[offset + 12];\n  position.y = array[offset + 13];\n  position.z = array[offset + 14];\n\n  return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));\n}\n\nexport function applyMatrixAtToSphere(this: BatchedMesh, index: number, sphere: Sphere, center: Vector3, radius: number): void {\n  const offset = index * 16;\n  const array = this._matricesTexture.image.data as unknown as number[];\n\n  const te0 = array[offset + 0];\n  const te1 = array[offset + 1];\n  const te2 = array[offset + 2];\n  const te3 = array[offset + 3];\n  const te4 = array[offset + 4];\n  const te5 = array[offset + 5];\n  const te6 = array[offset + 6];\n  const te7 = array[offset + 7];\n  const te8 = array[offset + 8];\n  const te9 = array[offset + 9];\n  const te10 = array[offset + 10];\n  const te11 = array[offset + 11];\n  const te12 = array[offset + 12];\n  const te13 = array[offset + 13];\n  const te14 = array[offset + 14];\n  const te15 = array[offset + 15];\n\n  const position = sphere.center;\n  const x = center.x;\n  const y = center.y;\n  const z = center.z;\n  const w = 1 / (te3 * x + te7 * y + te11 * z + te15);\n\n  position.x = (te0 * x + te4 * y + te8 * z + te12) * w;\n  position.y = (te1 * x + te5 * y + te9 * z + te13) * w;\n  position.z = (te2 * x + te6 * y + te10 * z + te14) * w;\n\n  const scaleXSq = te0 * te0 + te1 * te1 + te2 * te2;\n  const scaleYSq = te4 * te4 + te5 * te5 + te6 * te6;\n  const scaleZSq = te8 * te8 + te9 * te9 + te10 * te10;\n\n  sphere.radius = radius * Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));\n}\n","import { BatchedMesh, BufferGeometry, TypedArray } from 'three';\n\n// TODO: add optional distance and first load function like InstancedMesh2\n// TODO: improve and fix comments\n// TODO: should we use an internal different metood instead of adding a flag in getLODIndex?\n// TODO: if we use distance for LOD, should we update the LOD0 metric infinity to 0\n\nexport type LODInfo = { start: number; count: number; metric: number; metricSquared: number };\n\ndeclare module 'three' {\n  interface BatchedMesh {\n    /**\n     * If `true`, LOD uses camera distance; otherwise it uses screen size.\n     * @default undefined\n     */\n    useDistanceForLOD?: boolean;\n    /**\n     * Adds a Level of Detail (LOD) geometry to the BatchedMesh.\n     * @param geometryId The ID of the geometry to which the LOD is being added.\n     * @param geometryOrIndex The BufferGeometry to be added as LOD or the index array.\n     * @param metric The screen-space metric (e.g., fraction of screen height) at which this LOD should be used.\n     */\n    addGeometryLOD(geometryId: number, geometryOrIndex: BufferGeometry | TypedArray, metric: number): void;\n    /**\n     * Retrieves the LOD index for a given screen-space metric.\n     * @param LOD The array of LOD information.\n     * @param metric The calculated screen-space metric for the object.\n     * @param useDistSquared Whether to use the squared distance for LOD calculations.\n     * @returns The index of the appropriate LOD\n     */\n    getLODIndex(LOD: LODInfo[], metric: number, useDistSquared?: boolean): number;\n  }\n}\n\nexport function addGeometryLOD(this: BatchedMesh, geometryId: number, geoOrIndex: BufferGeometry | TypedArray, metric: number): void {\n  const geometryInfo = this._geometryInfo[geometryId];\n  const srcIndexArray = (geoOrIndex as BufferGeometry).isBufferGeometry ? (geoOrIndex as BufferGeometry).index.array : geoOrIndex as TypedArray;\n  const metricSquared = metric ** 2;\n\n  geometryInfo.LOD ??= [{ start: geometryInfo.start, count: geometryInfo.count, metric: Infinity, metricSquared: Infinity }];\n\n  const LOD = geometryInfo.LOD;\n  const lastLOD = LOD[LOD.length - 1];\n  const start = lastLOD.start + lastLOD.count;\n  const count = srcIndexArray.length;\n\n  if ((start - geometryInfo.start) + count > geometryInfo.reservedIndexCount) {\n    throw new Error('BatchedMesh LOD: Reserved space request exceeds the maximum buffer size.');\n  }\n\n  LOD.push({ start, count, metric, metricSquared });\n\n  const dstIndex = this.geometry.getIndex();\n  const dstIndexArray = dstIndex.array;\n  const vertexStart = geometryInfo.vertexStart;\n\n  for (let i = 0; i < count; i++) {\n    dstIndexArray[start + i] = srcIndexArray[i] + vertexStart;\n  }\n\n  dstIndex.needsUpdate = true;\n}\n\nexport function getLODIndex(this: BatchedMesh, LODs: LODInfo[], metric: number, useDistSquared = false): number {\n  const metricKey: keyof LODInfo = useDistSquared ? 'metricSquared' : 'metric';\n\n  if (this.useDistanceForLOD) {\n    for (let i = LODs.length - 1; i > 0; i--) {\n      const level = LODs[i];\n      const distance = level[metricKey];\n      if (metric >= distance) return i;\n    }\n\n    return 0;\n  }\n\n  for (let i = LODs.length - 1; i > 0; i--) {\n    const level = LODs[i];\n    const screenSize = level[metricKey];\n    if (metric <= screenSize) return i;\n  }\n\n  return 0;\n}\n","import { BatchedMesh, Box3, Intersection, Matrix4, Mesh, Ray, Raycaster, Sphere, Vector3 } from 'three';\nimport { } from 'three-mesh-bvh'; // include only types\n\ndeclare module 'three' {\n  interface BatchedMesh {\n    checkInstanceIntersection(raycaster: Raycaster, objectIndex: number, result: Intersection[]): void;\n  }\n}\n\nconst _intersections: Intersection[] = [];\nconst _mesh = new Mesh();\nconst _ray = new Ray();\nconst _direction = new Vector3();\nconst _worldScale = new Vector3();\nconst _invMatrixWorld = new Matrix4();\n\nexport function raycast(this: BatchedMesh, raycaster: Raycaster, result: Intersection[]): void {\n  if (!this.material || this.instanceCount === 0) return;\n\n  _mesh.geometry = this.geometry;\n  _mesh.material = this.material;\n\n  _mesh.geometry.boundingBox ??= new Box3();\n  _mesh.geometry.boundingSphere ??= new Sphere();\n\n  const originalRay = raycaster.ray;\n  const originalNear = raycaster.near;\n  const originalFar = raycaster.far;\n\n  _invMatrixWorld.copy(this.matrixWorld).invert();\n\n  _worldScale.setFromMatrixScale(this.matrixWorld);\n  _direction.copy(raycaster.ray.direction).multiply(_worldScale);\n  const scaleFactor = _direction.length();\n\n  raycaster.ray = _ray.copy(raycaster.ray).applyMatrix4(_invMatrixWorld);\n  raycaster.near /= scaleFactor;\n  raycaster.far /= scaleFactor;\n\n  if (this.bvh) {\n    this.bvh.raycast(raycaster, (instanceId) => this.checkInstanceIntersection(raycaster, instanceId, result));\n  } else {\n    if (this.boundingSphere === null) this.computeBoundingSphere();\n\n    if (raycaster.ray.intersectsSphere(this.boundingSphere)) {\n      for (let i = 0, l = this._instanceInfo.length; i < l; i++) {\n        this.checkInstanceIntersection(raycaster, i, result);\n      }\n    }\n  }\n\n  raycaster.ray = originalRay;\n  raycaster.near = originalNear;\n  raycaster.far = originalFar;\n}\n\nexport function checkInstanceIntersection(this: BatchedMesh, raycaster: Raycaster, instanceId: number, result: Intersection[]): void {\n  const info = this._instanceInfo[instanceId];\n  if (!info.active || !info.visible) return;\n\n  const geometryId = info.geometryIndex;\n  const geometryInfo = this._geometryInfo[geometryId];\n\n  this.getMatrixAt(instanceId, _mesh.matrixWorld);\n\n  _mesh.geometry.boundsTree = this.boundsTrees ? this.boundsTrees[geometryId] : undefined; // three-mesh-bvh compatibility\n\n  if (!_mesh.geometry.boundsTree) {\n    this.getBoundingBoxAt(geometryId, _mesh.geometry.boundingBox);\n    this.getBoundingSphereAt(geometryId, _mesh.geometry.boundingSphere);\n    _mesh.geometry.setDrawRange(geometryInfo.start, geometryInfo.count);\n  }\n\n  _mesh.raycast(raycaster, _intersections);\n\n  for (const intersect of _intersections) {\n    intersect.batchId = instanceId;\n    intersect.object = this;\n    result.push(intersect);\n  }\n\n  _intersections.length = 0;\n}\n","import { BatchedMesh } from 'three';\nimport { ChannelSize, SquareDataTexture, UniformMap, UniformMapType, UniformType, UniformValue, UniformValueObj } from '../SquareDataTexture.js';\n\nexport type UniformSchema = { [x: string]: UniformType };\nexport type UniformSchemaShader = { vertex?: UniformSchema; fragment?: UniformSchema };\n\nexport type UniformSchemaResult = {\n  channels: ChannelSize;\n  pixelsPerInstance: number;\n  uniformMap: UniformMap;\n  fetchInFragmentShader: boolean;\n};\n\ndeclare module 'three' {\n  interface BatchedMesh {\n    /**\n     * Texture storing custom uniforms per instance.\n     */\n    uniformsTexture?: SquareDataTexture;\n    /**\n     * Retrieves a uniform value for a specific instance.\n     * @param id The index of the instance.\n     * @param name The name of the uniform.\n     * @param target Optional target object to store the uniform value.\n     * @returns The uniform value for the specified instance.\n     */\n    getUniformAt(id: number, name: string, target?: UniformValueObj): UniformValue;\n    /**\n     * Sets a uniform value for a specific instance.\n     * @param id The index of the instance.\n     * @param name The name of the uniform.\n     * @param value The value to set for the uniform.\n     */\n    setUniformAt(id: number, name: string, value: UniformValue): void;\n    /**\n     * Initializes per-instance uniforms using a schema.\n     * @param schema The schema defining the uniforms.\n     */\n    initUniformsPerInstance(schema: UniformSchemaShader): void;\n  }\n}\n\nexport function getUniformAt(this: BatchedMesh, id: number, name: string, target?: UniformValueObj): UniformValue {\n  if (!this.uniformsTexture) {\n    throw new Error('Before get/set uniform, it\\'s necessary to use \"initUniformsPerInstance\".');\n  }\n  return this.uniformsTexture.getUniformAt(id, name, target);\n}\n\nexport function setUniformAt(this: BatchedMesh, id: number, name: string, value: UniformValue): void {\n  if (!this.uniformsTexture) {\n    throw new Error('Before get/set uniform, it\\'s necessary to use \"initUniformsPerInstance\".');\n  }\n  this.uniformsTexture.setUniformAt(id, name, value);\n  this.uniformsTexture.enqueueUpdate(id);\n}\n\nexport function getUniformSchemaResult(schema: UniformSchemaShader): UniformSchemaResult {\n  let totalSize = 0;\n  const uniformMap = new Map<string, UniformMapType>();\n  const uniforms: { type: UniformType; name: string; size: number }[] = [];\n  const vertexSchema = schema.vertex ?? {};\n  const fragmentSchema = schema.fragment ?? {};\n  let fetchInFragmentShader = true;\n\n  for (const name in vertexSchema) {\n    const type = vertexSchema[name];\n    const size = getUniformSize(type);\n    totalSize += size;\n    uniforms.push({ name, type, size });\n    fetchInFragmentShader = false;\n  }\n\n  for (const name in fragmentSchema) {\n    if (!vertexSchema[name]) {\n      const type = fragmentSchema[name];\n      const size = getUniformSize(type);\n      totalSize += size;\n      uniforms.push({ name, type, size });\n    }\n  }\n\n  uniforms.sort((a, b) => b.size - a.size);\n\n  const tempOffset: number[] = [];\n  for (const { name, size, type } of uniforms) {\n    const offset = getUniformOffset(size, tempOffset);\n    uniformMap.set(name, { offset, size, type });\n  }\n\n  const pixelsPerInstance = Math.ceil(totalSize / 4);\n  const channels = Math.min(totalSize, 4) as ChannelSize;\n\n  return { channels, pixelsPerInstance, uniformMap, fetchInFragmentShader };\n}\n\nexport function getUniformOffset(size: number, tempOffset: number[]): number {\n  if (size < 4) {\n    for (let i = 0; i < tempOffset.length; i++) {\n      if (tempOffset[i] + size <= 4) {\n        const offset = i * 4 + tempOffset[i];\n        tempOffset[i] += size;\n        return offset;\n      }\n    }\n  }\n\n  const offset = tempOffset.length * 4;\n  for (; size > 0; size -= 4) {\n    tempOffset.push(size);\n  }\n\n  return offset;\n}\n\nexport function getUniformSize(type: UniformType): number {\n  switch (type) {\n    case 'float': return 1;\n    case 'vec2': return 2;\n    case 'vec3': return 3;\n    case 'vec4': return 4;\n    case 'mat3': return 9;\n    case 'mat4': return 16;\n    default:\n      throw new Error(`Invalid uniform type: ${type}`);\n  }\n}\n","import { BatchedMesh } from 'three';\n\nexport function patchBatchedMeshMaterial(batchedMesh: BatchedMesh): void {\n  const material: any = batchedMesh.material;\n\n  const onBeforeCompileBase = material.onBeforeCompile.bind(material);\n\n  material.onBeforeCompile = (shader: any, renderer: any) => {\n    if ((batchedMesh as any).uniformsTexture) {\n      shader.uniforms.uniformsTexture = { value: (batchedMesh as any).uniformsTexture };\n      const { vertex, fragment } = (batchedMesh as any).uniformsTexture.getUniformsGLSL(\n        'uniformsTexture',\n        'batchIndex',\n        'float'\n      );\n      shader.vertexShader = shader.vertexShader.replace('void main() {', vertex);\n      shader.fragmentShader = shader.fragmentShader.replace('void main() {', fragment);\n\n      shader.vertexShader = shader.vertexShader.replace(\n        'void main() {',\n        'void main() { float batchIndex = getIndirectIndex( gl_DrawID );'\n      );\n    }\n\n    onBeforeCompileBase(shader, renderer);\n  };\n}\n","import { BatchedMesh } from 'three';\nimport { patchBatchedMeshMaterial } from '../../patch/PatchBatchedMeshMaterial.webgl.js';\nimport { SquareDataTexture } from '../SquareDataTexture.js';\nimport { getUniformSchemaResult, UniformSchemaShader } from './Uniforms.common.js';\n\nexport function initUniformsPerInstance(this: BatchedMesh, schema: UniformSchemaShader): void {\n  if (this.uniformsTexture) throw new Error('\"initUniformsPerInstance\" must be called only once.');\n\n  const { channels, pixelsPerInstance, uniformMap, fetchInFragmentShader } = getUniformSchemaResult(schema);\n  this.uniformsTexture = new SquareDataTexture(Float32Array, channels, pixelsPerInstance, this.maxInstanceCount, uniformMap, fetchInFragmentShader);\n\n  patchBatchedMeshMaterial(this);\n}\n","import { BatchedMesh } from 'three';\nimport { computeBVH } from '../core/feature/ComputeBVH.js';\nimport { BVHCulling, frustumCulling, linearCulling, onBeforeRender, updateIndexArray, updateRenderList } from '../core/feature/FrustumCulling.js';\nimport { applyMatrixAtToSphere, getPositionAndMaxScaleOnAxisAt, getPositionAt } from '../core/feature/GetPositionAt.js';\nimport { addGeometryLOD, getLODIndex } from '../core/feature/LOD.js';\nimport { checkInstanceIntersection, raycast } from '../core/feature/Raycasting.js';\n\n/**\n * @internal\n * Enhances the BatchedMesh prototype with additional methods.\n */\nexport function extendBatchedMeshPrototypeCommon(): void {\n  BatchedMesh.prototype.computeBVH = computeBVH;\n\n  BatchedMesh.prototype.onBeforeRender = onBeforeRender;\n  BatchedMesh.prototype.frustumCulling = frustumCulling;\n  BatchedMesh.prototype.updateIndexArray = updateIndexArray;\n  BatchedMesh.prototype.updateRenderList = updateRenderList;\n  BatchedMesh.prototype.BVHCulling = BVHCulling;\n  BatchedMesh.prototype.linearCulling = linearCulling;\n\n  BatchedMesh.prototype.getPositionAt = getPositionAt;\n  BatchedMesh.prototype.getPositionAndMaxScaleOnAxisAt = getPositionAndMaxScaleOnAxisAt;\n  BatchedMesh.prototype.applyMatrixAtToSphere = applyMatrixAtToSphere;\n\n  BatchedMesh.prototype.addGeometryLOD = addGeometryLOD;\n  BatchedMesh.prototype.getLODIndex = getLODIndex;\n\n  BatchedMesh.prototype.raycast = raycast;\n  BatchedMesh.prototype.checkInstanceIntersection = checkInstanceIntersection;\n}\n","import { BatchedMesh } from 'three';\nimport { getUniformAt, setUniformAt } from '../core/feature/Uniforms.common.js';\nimport { initUniformsPerInstance } from '../core/feature/Uniforms.webgl.js';\nimport { extendBatchedMeshPrototypeCommon } from './ExtendBatchedMeshPrototype.common.js';\n\n/**\n * Enhances the BatchedMesh prototype with additional methods.\n */\nexport function extendBatchedMeshPrototype(): void {\n  extendBatchedMeshPrototypeCommon();\n\n  BatchedMesh.prototype.getUniformAt = getUniformAt;\n  BatchedMesh.prototype.setUniformAt = setUniformAt;\n  BatchedMesh.prototype.initUniformsPerInstance = initUniformsPerInstance;\n}\n","import { BufferGeometry } from 'three';\n\nexport type VertexIndexCount = { vertexCount: number; indexCount: number };\nexport type VertexIndexLODCount = { vertexCount: number; indexCount: number; LODIndexCount: number[] };\n\nexport function getBatchedMeshCount(geometries: BufferGeometry[]): VertexIndexCount {\n  let vertexCount = 0;\n  let indexCount = 0;\n\n  for (const geometry of geometries) {\n    vertexCount += geometry.attributes.position.count;\n    indexCount += geometry.index.count;\n  }\n\n  return { vertexCount, indexCount };\n}\n\nexport function getBatchedMeshLODCount(geometryLOD: BufferGeometry[][]): VertexIndexLODCount {\n  const LODIndexCount: number[] = [];\n  let vertexCount = 0;\n  let indexCount = 0;\n\n  for (const geometries of geometryLOD) {\n    let sum = 0;\n\n    for (const geometry of geometries) {\n      const count = geometry.index.count;\n      indexCount += count;\n      sum += count;\n      vertexCount += geometry.attributes.position.count;\n    }\n\n    LODIndexCount.push(sum);\n  }\n\n  return { vertexCount, indexCount, LODIndexCount };\n}\n"],"names":["BatchedMeshBVH","target","coordinateSystem","margin","accurateCulling","BVH","HybridBuilder","WebGLCoordinateSystem","WebGPUCoordinateSystem","count","instancesArrayCount","instancesInfo","boxes","objects","index","i","node","id","ids","projScreenMatrix","onFrustumIntersection","frustum","mask","raycaster","onIntersection","ray","origin","dir","vec3ToArray","array","box3ToArray","geometryId","_box3","_matrix","Box3","Matrix4","MultiDrawRenderList","instanceId","depth","start","pool","list","item","getSquareTextureSize","capacity","pixelsPerInstance","getSquareTextureInfo","arrayType","channels","size","isFloat","isUnsignedInt","type","FloatType","UnsignedIntType","IntType","format","RedFormat","RedIntegerFormat","RGFormat","RGIntegerFormat","RGBAFormat","RGBAIntegerFormat","SquareDataTexture","DataTexture","uniformMap","fetchInFragmentShader","currentData","data","minLength","elementsPerRow","rowIndex","renderer","glRenderer","textureProperties","versionChanged","sizeChanged","rowsInfo","rowsToUpdate","result","l","row","info","state","gl","WebGLUtils","glFormat","glType","width","workingPrimaries","ColorManagement","texturePrimaries","NoColorSpace","unpackConversion","name","value","offset","stride","textureName","indexName","indexType","vertex","fragment","texelsFetch","getFromTexels","assignVarying","declareVarying","getVarying","uniforms","tId","components","startIndex","componentsArray","source","computeBVH","config","createRadixSort","options","el","minZ","maxZ","z","depthDelta","factor","radixSort","sortOpaque","a","b","sortTransparent","_frustum","Frustum","_renderList","_projScreenMatrix","_invMatrixWorld","_forward","Vector3","_cameraPos","_cameraLODPos","_position","_sphere","Sphere","onBeforeRender","scene","camera","geometry","material","group","_a","frustumCulling","cameraLOD","sortObjects","perObjectFrustumCulled","bytesPerElement","multiDrawStarts","multiDrawCounts","indirectArray","customSort","updateIndexArray","instanceInfo","geometryInfoList","instance","geometryInfo","updateRenderList","BVHCulling","onFrustumEnter","instancesCount","orthographicCamera","viewSize","perspectiveCamera","invProj","useDistanceForLOD","isPerspectiveCamera","LOD","metric","distance","getLODMetricPerspective","getLODMetricOrthographic","LODIndex","sphere","viewHeight","linearCulling","bSphere","radius","center","maxScale","getPositionAt","getPositionAndMaxScaleOnAxisAt","position","te0","te1","te2","scaleXSq","te4","te5","te6","scaleYSq","te8","te9","te10","scaleZSq","applyMatrixAtToSphere","te3","te7","te11","te12","te13","te14","te15","x","y","addGeometryLOD","geoOrIndex","srcIndexArray","metricSquared","lastLOD","dstIndex","dstIndexArray","vertexStart","getLODIndex","LODs","useDistSquared","metricKey","screenSize","_intersections","_mesh","Mesh","_ray","Ray","_direction","_worldScale","raycast","_b","originalRay","originalNear","originalFar","scaleFactor","checkInstanceIntersection","intersect","getUniformAt","setUniformAt","getUniformSchemaResult","schema","totalSize","vertexSchema","fragmentSchema","getUniformSize","tempOffset","getUniformOffset","patchBatchedMeshMaterial","batchedMesh","onBeforeCompileBase","shader","initUniformsPerInstance","extendBatchedMeshPrototypeCommon","BatchedMesh","extendBatchedMeshPrototype","getBatchedMeshCount","geometries","vertexCount","indexCount","getBatchedMeshLODCount","geometryLOD","LODIndexCount","sum"],"mappings":"2KAUO,MAAMA,CAAe,CA4B1B,YAAYC,EAAqBC,EAAoCC,EAAS,EAAGC,EAAkB,GAAM,CAhBlG,KAAA,aAAe,IAMZ,KAAA,QAAU,IAAI,aAAa,CAAC,EAC5B,KAAA,KAAO,IAAI,aAAa,CAAC,EACzB,KAAA,WAAa,IAAI,aAAa,CAAC,EAC/B,KAAA,UAAY,IAAI,aAAa,CAAC,EAQtC,KAAK,OAASH,EACd,KAAK,gBAAkBG,EACvB,KAAK,QAAUD,EAEV,KAAA,IAAM,IAAIE,EAAAA,IAAI,IAAIC,EAAAA,cAAiBJ,IAAqB,IAAOK,EAAA,sBAAwBC,wBAAsB,CAAA,CAO7G,QAAe,CACd,MAAAC,EAAQ,KAAK,OAAO,cACpBC,EAAsB,KAAK,OAAO,cAAc,OAChDC,EAAgB,KAAK,OAAO,cAC5BC,EAAwB,IAAI,MAAMH,CAAK,EACvCI,EAAU,IAAI,YAAYJ,CAAK,EACrC,IAAIK,EAAQ,EAEZ,KAAK,MAAM,EAEX,QAASC,EAAI,EAAGA,EAAIL,EAAqBK,IAClCJ,EAAcI,CAAC,EAAE,SAChBH,EAAAE,CAAK,EAAI,KAAK,OAAOC,EAAG,IAAI,aAAa,CAAC,CAAC,EACjDF,EAAQC,CAAK,EAAIC,EACjBD,KAGF,KAAK,IAAI,gBAAgBD,EAAgCD,EAAQI,GAAS,CACxE,KAAK,SAAS,IAAIA,EAAK,OAAQA,CAAI,CAAA,EAClC,KAAK,OAAO,CAAA,CAOV,OAAOC,EAAkB,CAC9B,MAAMD,EAAO,KAAK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