UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

303 lines • 7.64 kB
export class LightManager { /** * Number of cluster slices along each dimension * @type {Vector3} * @private */ private __tiles_resolution; __cluster_texture_precision: number; __cluster_texture_needs_rebuild: boolean; /** * Texel layout: * - R: offset into lookup texture for lights * - G: light count * - B: offset into lookup texture for decals * - A: decal count * @type {DataTexture3D} * @private */ private __cluster_texture; /** * * @type {TextureBackedMemoryRegion} * @readonly * @private */ private readonly __lookup_data; /** * * @type {TextureBackedMemoryRegion} * @readonly * @private */ private readonly __light_data; /** * @type {DataTexture} * @readonly * @private */ private readonly __decal_atlas_texture; /** * * @type {AbstractTextureAtlas} * @readonly * @private */ private readonly __decal_atlas; /** * * @type {ReferencedTextureAtlas} * @private */ private __decal_patch_references; /** * * @type {Map<Decal, Reference<AtlasPatch>>} * @private */ private __decal_references; /** * * @type {IncrementalDeltaSet<LightRenderMetadata>} * @readonly * @private */ private readonly __visible_lights; /** * * @type {IncrementalDeltaSet<LightRenderMetadata>} * @readonly * @private */ private readonly __visible_decals; /** * * @type {LightRenderMetadata[]} * @private */ private __sorted_visible_lights; /** * * @type {BinaryUint32BVH} * @private */ private __visible_bvh_lights; /** * * @type {BinaryUint32BVH} * @private */ private __visible_bvh_decals; /** * * @type {Frustum} * @private */ private __view_frustum; /** * Corner points of the view frustum * @type {Float32Array} * @private */ private __view_frustum_points; /** * * @type {Float32Array|mat4|number[]} * @private */ private __projection_matrix; /** * Accelerated data structure with pre-computed plane normals for clusters in each dimensions. Order: X, Y, Z * @type {Float32Array} * @private */ private __cluster_planes; /** * Accelerated data structure with pre-computed corner coordinates of each cluster's frustum * @type {Float32Array} * @private */ private __cluster_frustum_points; /** * Data needs to be re-written into the data texture * Usually set when source lights change * @type {boolean} * @private */ private __light_data_needs_update; /** * * @type {boolean} * @private */ private __visible_bvh_needs_update; requestDataUpdate(): void; /** * Please set this to false if you have a lot of overlapping decals in the scene * Overlapping decals can provide filtering artifacts due to incorrect mipmap level detection by WebGL * see article: https://0fps.net/2013/07/09/texture-atlases-wrapping-and-mip-mapping/ * NOTE: the technique mentioned in the article above is not implemented, as it would require significant increase in number of texture fetches * @param {boolean} v */ set decal_filtering_enabled(arg: boolean); /** * * @return {boolean} */ get decal_filtering_enabled(): boolean; __update_decal_atlas_texture(): void; /** * Sometimes light lookup table can get quite large, to make sure we can store these addresses in the cluster texture, * we may need to switch to a larger data type, such as Uint8->Uint16 or Uint16->Uint32 * @param {number} bit_count How many bits should be addressable from the cluster content * @returns {boolean} true if texture was rebuilt (underlying type change), false otherwise * @private */ private __set_cluster_addressable_bit_range; __update_cluster_texture(): void; __build_cluster_texture(): void; /** * * @param {number} size * @returns {boolean} * @private */ private __ensure_lookup_size; /** * * @returns {DataTexture} */ getTextureLookup(): DataTexture; /** * * @returns {DataTexture} */ getTextureData(): DataTexture; /** * @returns {DataTexture3D} */ getTextureClusters(): DataTexture3D; /** * @returns {DataTexture} */ getTextureDecalAtlas(): DataTexture; /** * NOTE: do not modify the value * @returns {Readonly<Vector3>} */ getResolution(): Readonly<Vector3>; /** * * @private */ private __handle_light_dimensions_change; /** * * @param {LightRenderMetadata} data * @private */ private __handle_visible_decal_added; /** * * @param {LightRenderMetadata} data * @private */ private __handle_visible_decal_removed; /** * * @param {LightRenderMetadata} data * @private */ private __handle_visible_light_added; /** * * @param {LightRenderMetadata} data * @private */ private __handle_visible_light_removed; /** * * @param {LightRenderMetadata} light * @returns {number} * @protected */ protected __sort_visible_light_score(light: LightRenderMetadata): number; /** * DEBUG method * @param {LightRenderMetadata} lights * @param {number} count * @returns {number} lower = better sorting score * @private */ private __assess_sorting_score; /** * Sort lights for better data locality * @private */ private __sort_visible_light; __update_visible_bvh(): void; /** * * @param {Camera} camera * @private */ private __build_view_frustum; __build_visible_light_list(): void; __write_light_data_texture(): void; /** * Perform cluster assignment where each cluster is filled with overlapping lights * @private */ private __assign_lights_to_clusters; /** * * @private */ private __build_cluster_frustum_planes; /** * * @private */ private __build_view_frustum_points; /** * * @private */ private __build_cluster_frustum_points; /** * Build light tile texture * @param {Camera|THREE.PerspectiveCamera} camera */ buildTiles(camera: Camera | THREE.PerspectiveCamera): void; dispose(): void; /** * Set resolution of the cluster texture, higher resolution will result in less load on the GPU, but will take up more RAM to represent and more time to build the clusters each frame * @param {number} x * @param {number} y * @param {number} z */ setTileMapResolution(x: number, y: number, z: number): void; /** * * @param {AbstractLight} light * @returns {boolean} */ hasLight(light: AbstractLight): boolean; /** * * @param {AbstractLight} light */ addLight(light: AbstractLight): void; /** * * @param {AbstractLight} light * @returns {boolean} */ removeLight(light: AbstractLight): boolean; #private; } import { DataTexture } from "three"; import { DataTexture3D } from "three"; import Vector3 from "../../../../core/geom/Vector3.js"; import { LightRenderMetadata } from "./LightRenderMetadata.js"; //# sourceMappingURL=LightManager.d.ts.map