UNPKG

@luma.gl/engine

Version:

3D Engine Components for luma.gl

69 lines 3.33 kB
import { Buffer, Device, type RenderPass } from '@luma.gl/core'; import { type NumericArray } from '@math.gl/core'; import type { DirectionalLight, Light, PointLight, SpotLight } from '@luma.gl/shadertools'; import { Model, type ModelProps } from "../model/model.js"; import type { Geometry } from "../geometry/geometry.js"; export type LightModelBounds = [[number, number, number], [number, number, number]]; export type BaseLightModelProps = Omit<ModelProps, 'geometry' | 'modules' | 'shaderInputs' | 'source' | 'vs' | 'fs' | 'instanceCount'> & { lights: ReadonlyArray<Light>; viewMatrix: NumericArray; projectionMatrix: NumericArray; bounds?: LightModelBounds; markerScale?: number; }; export type PointLightModelProps = BaseLightModelProps & { pointLightRadius?: number; }; export type SpotLightModelProps = BaseLightModelProps & { spotLightLength?: number; }; export type DirectionalLightModelProps = BaseLightModelProps & { directionalLightLength?: number; }; export type LightMarkerInstanceData = { instanceCount: number; instancePositions: Float32Array; instanceDirections: Float32Array; instanceScales: Float32Array; instanceColors: Float32Array; }; type ManagedInstanceBuffers = Record<'instancePosition' | 'instanceDirection' | 'instanceScale' | 'instanceColor', Buffer>; type LightMarkerAnchorMode = 'centered' | 'apex'; type LightMarkerModelOptions<PropsT extends BaseLightModelProps> = { anchorMode: LightMarkerAnchorMode; buildInstanceData: (props: PropsT) => LightMarkerInstanceData; geometry: Geometry; idPrefix: string; sizePropNames: Array<keyof PropsT>; }; export declare abstract class BaseLightModel<PropsT extends BaseLightModelProps> extends Model { protected lightModelProps: PropsT; protected _instanceData: LightMarkerInstanceData; protected _managedBuffers: ManagedInstanceBuffers; private readonly buildInstanceData; private readonly sizePropNames; constructor(device: Device, props: PropsT, options: LightMarkerModelOptions<PropsT>); destroy(): void; draw(renderPass: RenderPass): boolean; setProps(props: Partial<PropsT>): void; private rebuildInstanceData; } export declare function buildPointLightInstanceData(props: PointLightModelProps): LightMarkerInstanceData; export declare function buildSpotLightInstanceData(props: SpotLightModelProps): LightMarkerInstanceData; export declare function buildDirectionalLightInstanceData(props: DirectionalLightModelProps): LightMarkerInstanceData; export declare function getPointLights(lights: ReadonlyArray<Light>): PointLight[]; export declare function getSpotLights(lights: ReadonlyArray<Light>): SpotLight[]; export declare function getDirectionalLights(lights: ReadonlyArray<Light>): DirectionalLight[]; export declare function getLightMarkerContext(props: BaseLightModelProps): { bounds: LightModelBounds; markerScale: number; sceneCenter: [number, number, number]; sceneScale: number; }; export declare function getDisplayColor(light: { color?: Readonly<[number, number, number]>; intensity?: number; }): [number, number, number, number]; export declare function normalizeDirection(direction?: Readonly<[number, number, number]>): [number, number, number]; export {}; //# sourceMappingURL=light-model-utils.d.ts.map