UNPKG

@three.ez/instanced-mesh

Version:

Enhanced InstancedMesh with frustum culling, fast raycasting (using BVH), sorting, visibility management and more.

125 lines 5.21 kB
import { BufferGeometry, Material } from 'three'; import { InstancedMesh2 } from '../InstancedMesh2.js'; /** * Represents information about Level of Detail (LOD). * @template TData Type for additional instance data. */ export interface LODInfo<TData = {}> { /** * Render settings for the LOD. */ render: LODRenderList<TData>; /** * Shadow rendering settings for the LOD. */ shadowRender: LODRenderList<TData>; /** * List of `InstancedMesh2` associated to LODs. */ objects: InstancedMesh2<TData>[]; } /** * Represents a list of render levels for LOD. * @template TData Type for additional instance data. */ export interface LODRenderList<TData = {}> { /** * Array of LOD levels. */ levels: LODLevel<TData>[]; /** * Array of instance counts per LOD level, used internally. */ count: number[]; } /** * Represents a single LOD level. * @template TData Type for additional instance data. */ export interface LODLevel<TData = {}> { /** * The squared distance at which this LOD level becomes active. */ distance: number; /** * Hysteresis value to prevent LOD flickering when transitioning. */ hysteresis: number; /** * The `InstancedMesh2` object associated with this LOD level. */ object: InstancedMesh2<TData>; } declare module '../InstancedMesh2.js' { interface InstancedMesh2 { /** * Retrieves the index of the LOD level for a given distance. * @param levels The array of LOD levels. * @param distance The squared distance from the camera to the object. * @returns The index of the LOD level that should be used. */ getObjectLODIndexForDistance(levels: LODLevel[], distance: number): number; /** * Sets the first LOD (using current geometry) distance. * @param distance The distance for the first LOD. * @returns The current `InstancedMesh2` instance. */ setFirstLODDistance(distance: number): this; /** * Adds a new LOD level with the given geometry, material, and distance. * @param geometry The geometry for the LOD level. * @param material The material for the LOD level. * @param distance The distance for this LOD level. * @param hysteresis The hysteresis value for this LOD level. * @returns The current `InstancedMesh2` instance. */ addLOD(geometry: BufferGeometry, material: Material | Material[], distance?: number, hysteresis?: number): this; /** * Adds a shadow-specific LOD level with the given geometry and distance. * @param geometry The geometry for the shadow LOD. * @param distance The distance for this LOD level. * @param hysteresis The hysteresis value for this LOD level. * @returns The current `InstancedMesh2` instance. */ addShadowLOD(geometry: BufferGeometry, distance?: number, hysteresis?: number): this; /** * Updates the LOD settings for a specific level. * @param levelIndex The index of the LOD to update. * @param distance The distance at which this LOD level becomes active. * @param hysteresis The hysteresis value to prevent LOD flickering when transitioning. * @returns The current `InstancedMesh2` instance. */ updateLOD(levelIndex: number, distance?: number, hysteresis?: number): this; /** * Updates the shadow LOD settings for a specific level. * @param levelIndex The index of the LOD to update. * @param distance The distance at which this LOD level becomes active. * @param hysteresis The hysteresis value to prevent LOD flickering when transitioning. * @returns The current `InstancedMesh2` instance. */ updateShadowLOD(levelIndex: number, distance?: number, hysteresis?: number): this; /** * Updates the LOD settings for all levels. * @param distances The array of distances for each LOD level. * @param hysteresis The hysteresis value(s) for each LOD level. * @returns The current `InstancedMesh2` instance. */ updateAllLOD(distances?: number[], hysteresis?: number | number[]): this; /** * Updates the shadow LOD settings for all levels. * @param distances The array of distances for each LOD level. * @param hysteresis The hysteresis value(s) for each LOD level. * @returns The current `InstancedMesh2` instance. */ updateAllShadowLOD(distances?: number[], hysteresis?: number | number[]): this; /** * Removes a specific LOD level by its index. * If the same geometry is reused by other levels, pass removeObject=false. * @param levelIndex The index of the LOD level to remove. * @param removeObject Also remove the child InstancedMesh2 object. Default true. * @returns The current `InstancedMesh2` instance. */ removeLOD(levelIndex: number, removeObject?: boolean): this; } } //# sourceMappingURL=LOD.d.ts.map