import type { Mesh, Material, TextureSourceOptions, Engine, Renderer } from '@galacean/effects'; import { spec, Texture } from '@galacean/effects'; import type { ModelSkyboxComponentData, ModelSkyboxOptions } from '../index'; import { PEntity } from './object'; import { PMaterialBase } from './material'; import type { PSceneManager } from './scene'; import type { ModelSkyboxComponent } from '../plugin/model-item'; /** * 天空盒类,支持天空盒的渲染和 IBL 光照效果 */ export declare class PSkybox extends PEntity { /** * 所属的天空盒组件 */ owner?: ModelSkyboxComponent; /** * 是否渲染 */ renderable: boolean; /** * 强度 */ intensity: number; /** * 反射强度 */ reflectionsIntensity: number; /** * 辐射照度系数 */ irradianceCoeffs?: number[][]; /** * 漫反射贴图 */ diffuseImage?: Texture; /** * 高光贴图 */ specularImage: Texture; /** * 高光贴图大小 */ specularImageSize: number; /** * 高光贴图 Mip 层数目 */ specularMipCount: number; /** * BRDF 查询纹理 */ brdfLUT?: Texture; /** * 优先级 */ priority: number; /** * 天空盒 Mesh */ skyboxMesh?: Mesh; /** * 天空盒材质 */ skyboxMaterial?: PMaterialSkyboxFilter; /** * 是否构建过 */ isBuilt: boolean; /** * 构造函数 * @param name - 名称 * @param data - 天空盒参数 * @param owner - 所属天空盒组件元素 */ constructor(name: string, data: ModelSkyboxComponentData, owner?: ModelSkyboxComponent); /** * 设置 BRDF 查询纹理 * @param brdfLUT - 纹理 */ setup(brdfLUT?: Texture): void; /** * 构建天空盒,创建天空盒材质,从场景缓存中创建天空盒 Mesh * @param sceneCache - 场景缓存 * @returns */ build(scene: PSceneManager): void; /** * 渲染天空盒 * @param scene - 场景 * @param renderer - 渲染器 */ render(scene: PSceneManager, renderer: Renderer): void; /** * 销毁 */ dispose(): void; private updateMaterial; /** * 是否可用,根据内部的强度、辐射照度系数、漫反射贴图和高光贴图状态 */ get available(): boolean; /** * 当前强度,如果不可见返回 0 */ get currentIntensity(): number; /** * 当前反射强度,如果不可见返回 0 */ get currentReflectionsIntensity(): number; /** * 是否有漫反射贴图 */ get hasDiffuseImage(): boolean; /** * 是否有辐射照度系数 */ get hasIrradianceCoeffs(): boolean; } /** * 天空盒材质类 */ export declare class PMaterialSkyboxFilter extends PMaterialBase { /** * 强度 */ intensity: number; /** * 反射强度 */ reflectionsIntensity: number; /** * BRDF 查询纹理 */ brdfLUT?: Texture; /** * 辐射照度系数 */ irradianceCoeffs?: number[][]; /** * 漫反射贴图 */ diffuseImage?: Texture; /** * 高光贴图 */ specularImage: Texture; /** * 高光贴图 Mip 数目 */ specularMipCount: number; /** * 创建天空盒材质,从天空盒对象 * @param skybox - 天空盒对象 */ create(skybox: PSkybox): void; /** * 销毁,需要解除资源引用 */ dispose(): void; /** * 获取着色器特性列表 * @returns */ getShaderFeatures(): string[]; /** * 更新着色器 Uniform 数据 * @param material - 对应的 Core 层材质 */ updateUniforms(material: Material): void; /** * 设置对应的材质状态 * @param material - 对应的 Core 层材质 */ setMaterialStates(material: Material): void; } /** * 图像缓冲区数据接口 */ export interface PImageBufferData { /** * 类型,总是 buffer */ type: 'buffer'; /** * 数组 */ data: Uint8Array; /** * MIME 类型 */ mimeType: string; } /** * 图像数据类型,字符串(URL)或者图像缓冲区数据 */ export type PImageData = string | PImageBufferData; /** * 天空盒基础参数接口 */ export interface PSkyboxBaseParams { /** * 是否渲染 */ renderable: boolean; /** * 强度 */ intensity: number; /** * 反射强度 */ reflectionsIntensity: number; /** * 辐射照度系数 */ irradianceCoeffs?: number[]; /** * 高光贴图 Mip 层数 */ specularMipCount: number; /** * 高光贴图大小 */ specularImageSize: number; } /** * 天空盒 URL 参数接口 */ export interface PSkyboxURLParams extends PSkyboxBaseParams { /** * 类型,总是 url */ type: 'url'; /** * 漫反射贴图 URL 列表 */ diffuseImage?: string[]; /** * 高光贴图 URL 二级列表 */ specularImage: string[][]; } /** * 天空盒缓冲区参数接口 */ export interface PSkyboxBufferParams extends PSkyboxBaseParams { /** * 类型,总是 buffer */ type: 'buffer'; /** * 漫反射贴图列表 */ diffuseImage?: PImageBufferData[]; /** * 高光贴图二级列表 */ specularImage: PImageBufferData[][]; } /** * 天空盒参数类型 */ export type PSkyboxParams = PSkyboxURLParams | PSkyboxBufferParams; export declare enum PSkyboxType { NFT = 0, FARM = 1 } /** * 天空盒创建类 */ export declare class PSkyboxCreator { /** * 获取 BRDF 查询纹理选项 * @returns 纹理源选项 */ static getBrdfLutTextureOptions(): Promise; /** * 创建 BRDF 查询纹理 * @param engine - 引擎 * @returns 纹理 */ static createBrdfLutTexture(engine: Engine): Promise; /** * 创建天空盒选项 * @param engine - 引擎 * @param params - 天空盒参数 * @returns 天空盒选项 */ static createSkyboxOptions(engine: Engine, params: PSkyboxParams): Promise; /** * 创建天空盒选项 * @param engine - 引擎 * @param params - 天空盒参数 * @returns 天空盒选项 */ static createSkyboxComponentData(params: PSkyboxParams): { imageList: spec.Image[]; textureOptionsList: TextureSourceOptions[]; component: spec.SkyboxComponentData; }; /** * 创建高光 Cube Map 纹理 * @param engine - 引擎 * @param params - 天空盒参数 * @returns 纹理 */ static createSpecularCubeMap(engine: Engine, params: PSkyboxParams): Promise; static getSpecularCubeMapData(params: PSkyboxParams): { images: spec.Image[]; textureOptions: TextureSourceOptions; }; /** * 创建漫反射纹理 * @param engine - 引擎 * @param params - 天空盒参数 * @returns 纹理或未定义 */ static createDiffuseCubeMap(engine: Engine, params: PSkyboxParams): Promise; static getDiffuseCubeMapData(params: PSkyboxParams): { images: spec.Image[]; textureOptions: TextureSourceOptions; } | undefined; /** * 创建天空盒参数 * @param skyboxType - 天空盒类型 * @returns 天空盒参数 */ static getSkyboxParams(skyboxType?: PSkyboxType): PSkyboxURLParams; private checkCubeMapImage; private static getIrradianceCoeffs; private static getDiffuseImageList; private static getSpecularImageList; private static getSpecularImageListNFT; private static getSpecularImageListAntFarm; }