@needle-tools/materialx
Version:
Web runtime support to load and display MaterialX materials in Needle Engine and three.js via the MaterialX WebAssembly library. glTF files containing the `NEEDLE_materials_mtlx` extension can be loaded with this package. There is also experimental suppor
63 lines (51 loc) • 2.05 kB
TypeScript
import { Light, Scene, Texture, WebGLRenderer } from "three";
import type { MaterialX as MX } from "./materialx.types.js";
export function preloadWasm(trigger: "immediately" | "network_idle"): Promise<void>;
export type MaterialXContext = {
getTime?(): number;
getFrame?(): number;
}
type EnvironmentTextureSet = {
radianceTexture: Texture | null;
irradianceTexture: Texture | null;
}
export declare const state: {
materialXModule: MX.MODULE | null;
materialXGenerator: any | null;
materialXGenContext: any | null;
materialXStdLib: any | null;
materialXInitPromise: Promise<void> | null;
};
/**
* Wait for the MaterialX WASM module to be ready.
*/
export declare function ready(): Promise<void>;
/**
* MaterialXEnvironment manages the environment settings for MaterialX materials.
*/
export declare class MaterialXEnvironment {
static get(scene: Scene): MaterialXEnvironment | null;
private static _environments: WeakMap<Scene, MaterialXEnvironment>;
private static getEnvironment(scene: Scene): MaterialXEnvironment;
private _lights: Array<Light>;
private _lightData: any[] | null;
private _lightCount: number;
private _initializePromise: Promise<boolean> | null;
private _isInitialized: boolean;
private _lastUpdateFrame: number;
private _scene: Scene;
constructor(_scene: Scene);
initialize(renderer: WebGLRenderer): Promise<boolean>;
update(frame: number, scene: Scene, renderer: WebGLRenderer): void;
reset(): void;
get lights(): Array<Light>;
get lightData(): any[] | null;
get lightCount(): number;
getTextures(material: any): EnvironmentTextureSet;
private _pmremGenerator: any | null;
private _renderer: WebGLRenderer | null;
private _texturesCache: Map<Texture | null, EnvironmentTextureSet>;
private _initialize(renderer: WebGLRenderer): Promise<boolean>;
private _getTextures(texture: Texture | null | undefined): EnvironmentTextureSet;
private updateLighting(collectLights?: boolean): void;
}