UNPKG

@shopware-ag/dive

Version:

Shopware Spatial Framework

119 lines (118 loc) 3.52 kB
import { Scene, WebGPURenderer } from 'three/webgpu'; export type DIVEEnvironmentSettings = { /** * Whether to enable the image-based lighting. * * @default true */ enabled: boolean; /** * The URL of the HDR image. * * @default defaultEnvUrl from assets/maps/env/default.hdr */ imageUrl: string; /** * Whether to use the HDR image as a background image. * * @default false */ useAsBackground: boolean; /** * The intensity of the environment lighting. * * @default 1 */ globalEnvIntensity: number; /** * The exposure of the HDR image. * * @default 1 */ exposure: number; /** * The rotation of the HDR image in radians. * * @default 0 */ rotateY: number; /** * Whether to replace the existing lights (can be restored via `restoreLights`). * * @default false */ replaceLights?: boolean; }; export declare const DIVEEnvironmentDefaultSettings: DIVEEnvironmentSettings; /** * Manages an image-based lighting setup with optional Y-rotation. * * Rotation is achieved by rendering the equirect HDR to a skybox that is * rotated around Y, capturing it into a cubemap with CubeCamera, and then * generating a PMREM for scene.environment. */ export declare class DIVEEnvironment { private originalBackground; private _webgpurenderer; private scene; private pmrem; private currentEnvRT; private currentBackgroundCube; private sourceImage; private options; private _loadPromise; private _initPromise; private _sourceImageLoadId; private _initRequested; private _disposed; constructor(renderer: WebGPURenderer, scene: Scene, options?: Partial<DIVEEnvironmentSettings>); initAsync(): Promise<void>; /** * Disposes the environment. */ dispose(): void; private clearEnvironment; /** * Updates the environment. * * - Creates a sky scene with a large inward-facing sphere with equirectangular mapping for correct UVs. * - Renders the equirect HDR to a cubemap with CubeCamera. * - Generates a PMREM from the cubemap. * - Updates the scene environment with the PMREM. * - Handles background image replacement logic. * - Early-returns if the source image is not loaded. */ update(): void; /** * Sets the renderer and rebinds the PMREM generator. Use this only when rebuilding the renderer. * * @param renderer - The renderer. */ setRenderer(renderer: WebGPURenderer): void; /** * Sets the URL of the HDR image. * * @param url - The URL of the HDR image. If null, the default environment image will be used. */ setImageUrl(url: string | null): Promise<void>; /** * Sets the rotation of the HDR image in radians. * * @param radians - The rotation of the HDR image in radians. */ setRotationY(radians: number): void; /** * Sets whether to use the HDR image as a background. * @param useAsBackground - Whether to use the HDR image as a background. */ setUseAsBackground(useAsBackground: boolean): void; /** * Loads equirectangular HDR image from URL. * Sets the mapping to EquirectangularReflectionMapping. * * @param url - The URL of the HDR image. * @returns The loaded equirectangular HDR texture. */ private loadHDRImage; private _loadSourceImage; }