@three.ez/instanced-mesh
Version:
Enhanced InstancedMesh with frustum culling, fast raycasting (using BVH), sorting, visibility management and more.
45 lines • 2.09 kB
TypeScript
import { InstancedEntity } from '../InstancedEntity.js';
/**
* Represents an extended entity type with custom data.
*/
export type Entity<T> = InstancedEntity & T;
/**
* A callback function used to update or initialize an entity.
*/
export type UpdateEntityCallback<T = InstancedEntity> = (obj: Entity<T>, index: number) => void;
declare module '../InstancedMesh2.js' {
interface InstancedMesh2<TData = {}> {
/**
* Updates instances by applying a callback function to each instance. It calls `updateMatrix` for each instance.
* @param onUpdate A callback function to update each entity.
* @returns The current `InstancedMesh2` instance.
*/
updateInstances(onUpdate: UpdateEntityCallback<Entity<TData>>): this;
/**
* Updates instances position by applying a callback function to each instance. It calls `updateMatrixPosition` for each instance.
* This method updates only the position attributes of the matrix.
* @param onUpdate A callback function to update each entity.
* @returns The current `InstancedMesh2` instance.
*/
updateInstancesPosition(onUpdate: UpdateEntityCallback<Entity<TData>>): this;
/**
* Adds new instances and optionally initializes them using a callback function.
* @param count The number of new instances to add.
* @param onCreation An optional callback to initialize each new entity.
* @returns The current `InstancedMesh2` instance.
*/
addInstances(count: number, onCreation?: UpdateEntityCallback<Entity<TData>>): this;
/**
* Removes instances by their ids.
* @param ids The ids of the instances to remove.
* @returns The current `InstancedMesh2` instance.
*/
removeInstances(...ids: number[]): this;
/**
* Clears all instances and resets the instance count.
* @returns The current `InstancedMesh2` instance.
*/
clearInstances(): this;
}
}
//# sourceMappingURL=Instances.d.ts.map