@needle-tools/materialx 1.1.1-next.714bc32 → 1.1.1-next.8761111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ # ensure LF line endings
2
+ *.data binary
3
+ *.data.txt binary
4
+ *.wasm binary
package/bin/README.md ADDED
@@ -0,0 +1,6 @@
1
+ Source: https://github.com/AcademySoftwareFoundation/MaterialX/tree/gh-pages
2
+
3
+ Edits:
4
+
5
+ - In `JsMaterialXGenShader.js` added `export default MaterialX;` at bottom
6
+ - Renamed `JsMaterialXGenShader.data` to `JsMaterialXGenShader.data.txt` so it can be loaded by vite etc
@@ -1,2 +1,2 @@
1
1
  export * from "./src/index.js";
2
- export { useNeedleMaterialX } from "./src/loader/loader.three.js";
2
+ export { useNeedleMaterialX } from "./src/loader/loader.three.js";
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./src/index.js";
2
+ export { useNeedleMaterialX } from "./src/loader/loader.three.js";
@@ -1,2 +1,2 @@
1
1
  export * from "./src/index.js";
2
- export { useNeedleMaterialX } from "./src/loader/loader.needle.js";
2
+ export { useNeedleMaterialX } from "./src/loader/loader.needle.js";
package/needle.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./src/index.js";
2
+ export { useNeedleMaterialX } from "./src/loader/loader.needle.js";
package/package.json CHANGED
@@ -1,32 +1,46 @@
1
1
  {
2
2
  "name": "@needle-tools/materialx",
3
- "version": "1.1.1-next.714bc32",
3
+ "version": "1.1.1-next.8761111",
4
4
  "type": "module",
5
- "main": "index.ts",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
6
7
  "exports": {
7
8
  ".": {
8
- "import": "./index.ts",
9
- "require": "./index.js"
9
+ "import": "./index.js",
10
+ "require": "./index.js",
11
+ "types": "./index.d.ts"
12
+ },
13
+ "./needle": {
14
+ "import": "./needle.js",
15
+ "require": "./needle.js",
16
+ "types": "./needle.d.ts"
10
17
  },
11
18
  "./package.json": "./package.json",
12
19
  "./codegen/register_types.ts": {
13
20
  "import": "./codegen/register_types.ts",
14
21
  "require": "./codegen/register_types.js"
15
- },
16
- "./needle": {
17
- "import": "./needle.ts",
18
- "require": "./needle.js"
19
22
  }
20
23
  },
21
24
  "peerDependencies": {
22
- "@needle-tools/engine": "4.x || ^4.6.0-0",
23
- "three": ">=0.169.0"
25
+ "three": ">=0.160.0"
24
26
  },
25
27
  "devDependencies": {
26
28
  "@needle-tools/engine": "4.x",
27
29
  "@types/three": "0.169.0",
28
30
  "three": "npm:@needle-tools/three@^0.169.5"
29
31
  },
32
+ "files": [
33
+ "index.js",
34
+ "index.d.ts",
35
+ "needle.js",
36
+ "needle.d.ts",
37
+ "src/",
38
+ "bin/",
39
+ "codegen/",
40
+ "README.md",
41
+ "CHANGELOG.md",
42
+ "package.needle.json"
43
+ ],
30
44
  "publishConfig": {
31
45
  "access": "public",
32
46
  "registry": "https://registry.npmjs.org/"
package/src/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export { ready, type MaterialXContext } from "./materialx.js";
2
+ export { MaterialXMaterial } from "./materialx.material.js";
3
+ export { MaterialXLoader } from "./loader/loader.three.js";
4
+
5
+ import { createMaterialXMaterial } from "./loader/loader.three.js";
6
+
7
+ declare const Experimental_API: {
8
+ createMaterialXMaterial: typeof createMaterialXMaterial;
9
+ };
10
+
11
+ export { Experimental_API };
@@ -1,13 +1,11 @@
1
- export { ready, type MaterialXContext } from "./materialx.js";
1
+ export { ready } from "./materialx.js";
2
2
  export { MaterialXMaterial } from "./materialx.material.js";
3
3
  export { MaterialXLoader } from "./loader/loader.three.js";
4
4
 
5
-
6
5
  import { createMaterialXMaterial } from "./loader/loader.three.js";
7
6
 
8
7
  const Experimental_API = {
9
8
  createMaterialXMaterial
10
9
  }
11
10
 
12
-
13
- export { Experimental_API }
11
+ export { Experimental_API }
@@ -0,0 +1,15 @@
1
+ import { Context, GLTF, INeedleGLTFExtensionPlugin } from "@needle-tools/engine";
2
+ import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
3
+ import { GLTFExporter } from "three/examples/jsm/exporters/GLTFExporter.js";
4
+ import { MaterialXLoader } from "./loader.three.js";
5
+
6
+ export declare class MaterialXLoaderPlugin implements INeedleGLTFExtensionPlugin {
7
+ readonly name: "MaterialXLoaderPlugin";
8
+ private loader: MaterialXLoader | null;
9
+
10
+ onImport(loader: GLTFLoader, url: string, context: Context): void;
11
+ onLoaded(url: string, gltf: GLTF, _context: Context): void;
12
+ onExport(_exporter: GLTFExporter, _context: Context): void;
13
+ }
14
+
15
+ export declare function useNeedleMaterialX(): Promise<void>;
@@ -0,0 +1,62 @@
1
+ import { addCustomExtensionPlugin, Context } from "@needle-tools/engine";
2
+ import { useNeedleMaterialX as _useNeedleMaterialX } from "./loader.three.js";
3
+ import { debug } from "../utils.js";
4
+
5
+ /**
6
+ * @typedef {import("@needle-tools/engine").INeedleGLTFExtensionPlugin} INeedleGLTFExtensionPlugin
7
+ */
8
+
9
+ /**
10
+ * MaterialX Loader Plugin for Needle Engine
11
+ * @implements {INeedleGLTFExtensionPlugin}
12
+ */
13
+ export class MaterialXLoaderPlugin {
14
+ /** @readonly */
15
+ name = "MaterialXLoaderPlugin";
16
+
17
+ /** @type {import("./loader.three.d.ts").MaterialXLoader | null} */
18
+ loader = null;
19
+
20
+ /**
21
+ * @param {import('three/examples/jsm/loaders/GLTFLoader.js').GLTFLoader} loader
22
+ * @param {string} url
23
+ * @param {Context} context
24
+ */
25
+ onImport = (loader, url, context) => {
26
+ if (debug) console.log("MaterialXLoaderPlugin: Registering MaterialX extension for", url);
27
+ _useNeedleMaterialX(loader, {
28
+ cacheKey: url,
29
+ parameters: {
30
+ precision: /** @type {import('three').MaterialParameters["precision"]} */ (context.renderer.capabilities.getMaxPrecision("highp")),
31
+ }
32
+ }, {
33
+ getTime: () => context.time.time,
34
+ getFrame: () => context.time.frame,
35
+ });
36
+ };
37
+
38
+ /**
39
+ * @param {string} url
40
+ * @param {import("@needle-tools/engine").GLTF} gltf
41
+ * @param {Context} _context
42
+ */
43
+ onLoaded = (url, gltf, _context) => {
44
+ if (debug) console.log("[MaterialX] MaterialXLoaderPlugin: glTF loaded", { url, scene: gltf.scene, materialX_root_data: this.loader?.materialX_root_data });
45
+ };
46
+
47
+ /**
48
+ * @param {import('three/examples/jsm/exporters/GLTFExporter.js').GLTFExporter} _exporter
49
+ * @param {Context} _context
50
+ */
51
+ onExport = (_exporter, _context) => {
52
+ console.warn("[MaterialX] Export is not supported");
53
+ };
54
+ }
55
+
56
+ /**
57
+ * Add the MaterialXLoaderPlugin to the Needle Engine.
58
+ * @returns {Promise<void>}
59
+ */
60
+ export async function useNeedleMaterialX() {
61
+ addCustomExtensionPlugin(new MaterialXLoaderPlugin());
62
+ }
@@ -0,0 +1,71 @@
1
+ import { Material, MaterialParameters } from "three";
2
+ import { GLTFLoader, GLTFLoaderPlugin, GLTFParser } from "three/examples/jsm/loaders/GLTFLoader.js";
3
+ import { MaterialXContext } from "../materialx.js";
4
+ import { MaterialXMaterial } from "../materialx.material.js";
5
+ import { Callbacks } from "../materialx.helper.js";
6
+
7
+ export interface MaterialX_root_extension {
8
+ /** e.g. 1.39 */
9
+ version: string;
10
+ /** e.g. "Material" */
11
+ name: string;
12
+ /** MaterialX xml content */
13
+ mtlx: string;
14
+ /** MaterialX texture pointers */
15
+ textures: Array<{ name: string, pointer: string }>;
16
+ shaders?: Array<{
17
+ /** The materialx node name */
18
+ name: string;
19
+ /** The original name of the shader */
20
+ originalName: string;
21
+ }>;
22
+ }
23
+
24
+ export interface MaterialX_material_extension {
25
+ /** The MaterialX material name */
26
+ name: string;
27
+ /** The index of the shader in the shaders array of the root extension. */
28
+ shader?: number;
29
+ }
30
+
31
+ export interface MaterialXLoaderOptions {
32
+ /** The URL of the GLTF file being loaded */
33
+ cacheKey?: string;
34
+ /** Parameters for the MaterialX loader */
35
+ parameters?: Pick<MaterialParameters, "precision">;
36
+ }
37
+
38
+ export declare class MaterialXLoader implements GLTFLoaderPlugin {
39
+ readonly name: "NEEDLE_materials_mtlx";
40
+ private readonly _generatedMaterials: MaterialXMaterial[];
41
+ private _documentReadyPromise: Promise<any> | null;
42
+ private parser: GLTFParser;
43
+ private options: MaterialXLoaderOptions;
44
+ private context: MaterialXContext;
45
+
46
+ get materialX_root_data(): MaterialX_root_extension | null;
47
+ get materials(): MaterialXMaterial[];
48
+
49
+ constructor(
50
+ parser: GLTFParser,
51
+ options: MaterialXLoaderOptions,
52
+ context: MaterialXContext
53
+ );
54
+
55
+ loadMaterial(materialIndex: number): Promise<Material> | null;
56
+ private _loadMaterialAsync(materialIndex: number): Promise<Material>;
57
+ }
58
+
59
+ export declare function useNeedleMaterialX(
60
+ loader: GLTFLoader,
61
+ options?: MaterialXLoaderOptions,
62
+ context?: MaterialXContext
63
+ ): void;
64
+
65
+ export declare function createMaterialXMaterial(
66
+ mtlx: string,
67
+ materialNodeName: string,
68
+ loaders: Callbacks,
69
+ options?: MaterialXLoaderOptions,
70
+ context?: MaterialXContext
71
+ ): Promise<Material>;
@@ -1,61 +1,38 @@
1
- import { Material, MeshStandardMaterial, DoubleSide, FrontSide, MaterialParameters } from "three";
2
- import { GLTFLoader, GLTFLoaderPlugin, GLTFParser } from "three/examples/jsm/loaders/GLTFLoader.js";
3
- import { ready, state, MaterialXContext } from "../materialx.js";
1
+ import { Material, MeshStandardMaterial, DoubleSide, FrontSide } from "three";
2
+ import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
3
+ import { ready, state } from "../materialx.js";
4
4
  import { debug } from "../utils.js";
5
5
  import { MaterialXMaterial } from "../materialx.material.js";
6
- import { Callbacks as callbacks } from "../materialx.helper.js";
7
-
8
- // TypeScript interfaces matching the C# data structures
9
- export type MaterialX_root_extension = {
10
- /** e.g. 1.39 */
11
- version: string;
12
- /** e.g. "Material" */
13
- name: string;
14
- /** MaterialX xml content */
15
- mtlx: string;
16
- /** MaterialX texture pointers */
17
- textures: Array<{ name: string, pointer: string }>;
18
- shaders?: Array<{
19
- /** The materialx node name */
20
- name: string,
21
- /** The original name of the shader */
22
- originalName: string,
23
- }>,
24
- }
25
6
 
26
- export type MaterialX_material_extension = {
27
- /** The MaterialX material name */
28
- name: string;
29
- /** The index of the shader in the shaders array of the root extension. */
30
- shader?: number;
31
- }
7
+ /**
8
+ * @import { MaterialX_root_extension, MaterialX_material_extension, MaterialXLoaderOptions } from "./loader.three.d.ts"
9
+ */
32
10
 
33
- type MaterialDefinition = {
34
- name?: string; // Optional name for the material
35
- doubleSided?: boolean; // Whether the material is double-sided
36
- extensions?: {
37
- [key: string]: any; // Extensions for the material, including MaterialX
38
- },
39
- }
11
+ /**
12
+ * @typedef {Object} MaterialDefinition
13
+ * @property {string} [name] - Optional name for the material
14
+ * @property {boolean} [doubleSided] - Whether the material is double-sided
15
+ * @property {Object<string, any>} [extensions] - Extensions for the material, including MaterialX
16
+ */
40
17
 
41
- // init.context.getRenderer().capabilities.getMaxPrecision("highp")
42
- export type MaterialXLoaderOptions = {
43
- /** The URL of the GLTF file being loaded */
44
- cacheKey?: string;
45
- /** Parameters for the MaterialX loader */
46
- parameters?: Pick<MaterialParameters, "precision">;
47
- }
18
+ /**
19
+ * @typedef {Object} MaterialXMaterialOptions
20
+ * @property {import('three').MaterialParameters} [parameters]
21
+ */
48
22
 
49
23
  // MaterialX loader extension for js GLTFLoader
50
- export class MaterialXLoader implements GLTFLoaderPlugin {
51
- readonly name = "NEEDLE_materials_mtlx";
24
+ export class MaterialXLoader {
25
+ /** @readonly */
26
+ name = "NEEDLE_materials_mtlx";
52
27
 
53
- private readonly _generatedMaterials: MaterialXMaterial[] = [];
28
+ /** @type {MaterialXMaterial[]} */
29
+ _generatedMaterials = [];
54
30
 
55
- private _documentReadyPromise: Promise<any> | null = null;
31
+ /** @type {Promise<any> | null} */
32
+ _documentReadyPromise = null;
56
33
 
57
34
  get materialX_root_data() {
58
- return this.parser.json.extensions?.[this.name] as MaterialX_root_extension | null;
35
+ return /** @type {MaterialX_root_extension | null} */ (this.parser.json.extensions?.[this.name]) || null;
59
36
  }
60
37
 
61
38
  /** Generated materialX materials */
@@ -65,15 +42,15 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
65
42
 
66
43
  /**
67
44
  * MaterialXLoader constructor
68
- * @param parser The GLTFParser instance
69
- * @param cacheKey The URL of the GLTF file
70
- * @param context The context for the GLTF loading process
45
+ * @param {import('three/examples/jsm/loaders/GLTFLoader.js').GLTFParser} parser - The GLTFParser instance
46
+ * @param {MaterialXLoaderOptions} options - The loader options
47
+ * @param {import('../materialx.js').MaterialXContext} context - The context for the GLTF loading process
71
48
  */
72
- constructor(
73
- private parser: GLTFParser,
74
- private options: MaterialXLoaderOptions,
75
- private context: MaterialXContext
76
- ) {
49
+ constructor(parser, options, context) {
50
+ this.parser = parser;
51
+ this.options = options;
52
+ this.context = context;
53
+
77
54
  if (debug) console.log("MaterialXLoader created for parser");
78
55
  // Start loading of MaterialX environment if the root extension exists
79
56
  if (this.materialX_root_data) {
@@ -81,8 +58,11 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
81
58
  }
82
59
  }
83
60
 
84
-
85
- loadMaterial(materialIndex: number): Promise<Material> | null {
61
+ /**
62
+ * @param {number} materialIndex
63
+ * @returns {Promise<Material> | null}
64
+ */
65
+ loadMaterial(materialIndex) {
86
66
  const materialDef = this.parser.json.materials?.[materialIndex];
87
67
  if (!materialDef?.extensions?.[this.name]) {
88
68
  return null;
@@ -91,20 +71,27 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
91
71
  return this._loadMaterialAsync(materialIndex);
92
72
  }
93
73
 
74
+ /**
75
+ * @private
76
+ * @param {number} materialIndex
77
+ * @returns {Promise<Material>}
78
+ */
79
+ async _loadMaterialAsync(materialIndex) {
94
80
 
95
- private async _loadMaterialAsync(materialIndex: number): Promise<Material> {
96
-
97
- const materialDef = this.parser.json.materials?.[materialIndex] as MaterialDefinition;
81
+ /** @type {MaterialDefinition} */
82
+ const materialDef = this.parser.json.materials?.[materialIndex];
98
83
  if (debug) console.log("[MaterialX] extension found in material:", materialDef.extensions?.[this.name]);
99
84
 
100
85
  // Handle different types of MaterialX data
101
- const ext = materialDef.extensions?.[this.name] as MaterialX_material_extension;
86
+ /** @type {MaterialX_material_extension} */
87
+ const ext = materialDef.extensions?.[this.name];
102
88
 
103
89
  const mtlx = this.materialX_root_data?.mtlx;
104
90
 
105
91
  if (ext && mtlx) {
106
92
 
107
- const materialOptions: MaterialXMaterialOptions = {
93
+ /** @type {MaterialXMaterialOptions} */
94
+ const materialOptions = {
108
95
  ...this.options,
109
96
  }
110
97
 
@@ -162,29 +149,27 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
162
149
  fallbackMaterial.name = "MaterialX_Fallback";
163
150
  return fallbackMaterial;
164
151
  }
165
-
166
- }
167
-
168
-
169
- type MaterialXMaterialOptions = {
170
- parameters?: MaterialParameters;
171
152
  }
172
153
 
173
154
  /**
174
155
  * Add the MaterialXLoader to the GLTFLoader instance.
156
+ * @param {GLTFLoader} loader
157
+ * @param {MaterialXLoaderOptions} [options]
158
+ * @param {import('../materialx.js').MaterialXContext} [context]
175
159
  */
176
- export function useNeedleMaterialX(loader: GLTFLoader, options?: MaterialXLoaderOptions, context?: MaterialXContext) {
160
+ export function useNeedleMaterialX(loader, options, context) {
177
161
  loader.register(p => {
178
162
  const loader = new MaterialXLoader(p, options || {}, context || {});
179
163
  return loader;
180
164
  });
181
165
  }
182
166
 
183
-
184
-
185
-
186
- // Parse the MaterialX document once and cache it
187
- async function load(mtlx: string): Promise<any> {
167
+ /**
168
+ * Parse the MaterialX document once and cache it
169
+ * @param {string} mtlx
170
+ * @returns {Promise<any>}
171
+ */
172
+ async function load(mtlx) {
188
173
  // Ensure MaterialX is initialized
189
174
  await ready();
190
175
  if (!state.materialXModule) {
@@ -199,7 +184,15 @@ async function load(mtlx: string): Promise<any> {
199
184
  return doc;
200
185
  }
201
186
 
202
- export async function createMaterialXMaterial(mtlx: string, materialNodeName: string, loaders: callbacks, options?: MaterialXLoaderOptions, context?: MaterialXContext): Promise<Material> {
187
+ /**
188
+ * @param {string} mtlx
189
+ * @param {string} materialNodeName
190
+ * @param {import('../materialx.helper.js').Callbacks} loaders
191
+ * @param {MaterialXLoaderOptions} [options]
192
+ * @param {import('../materialx.js').MaterialXContext} [context]
193
+ * @returns {Promise<Material>}
194
+ */
195
+ export async function createMaterialXMaterial(mtlx, materialNodeName, loaders, options, context) {
203
196
  try {
204
197
  if (debug) console.log(`Creating MaterialX material: ${materialNodeName}`);
205
198
 
@@ -213,7 +206,7 @@ export async function createMaterialXMaterial(mtlx: string, materialNodeName: st
213
206
  }
214
207
 
215
208
  // Find the renderable element following MaterialX example pattern exactly
216
- let renderableElement: any = null;
209
+ let renderableElement = null;
217
210
  let foundRenderable = false;
218
211
 
219
212
  if (debug) console.log("[MaterialX] document", doc);
@@ -288,10 +281,10 @@ export async function createMaterialXMaterial(mtlx: string, materialNodeName: st
288
281
  */
289
282
 
290
283
  if (!renderableElement) {
291
- console.warn(`[MaterialX] No renderable element found in MaterialX document (${name})`);
284
+ console.warn(`[MaterialX] No renderable element found in MaterialX document (${materialNodeName})`);
292
285
  const fallbackMaterial = new MeshStandardMaterial();
293
286
  fallbackMaterial.color.set(0xff00ff);
294
- fallbackMaterial.name = `MaterialX_NoRenderable_${name}`;
287
+ fallbackMaterial.name = `MaterialX_NoRenderable_${materialNodeName}`;
295
288
  return fallbackMaterial;
296
289
  }
297
290
 
@@ -303,7 +296,7 @@ export async function createMaterialXMaterial(mtlx: string, materialNodeName: st
303
296
 
304
297
  // Generate shaders using the element's name path
305
298
  if (debug) console.log("[MaterialX] Generating MaterialX shaders...");
306
- const elementName = (renderableElement as any).getNamePath ? (renderableElement as any).getNamePath() : (renderableElement as any).getName();
299
+ const elementName = renderableElement.getNamePath ? renderableElement.getNamePath() : renderableElement.getName();
307
300
 
308
301
  const shader = state.materialXGenerator.generate(elementName, renderableElement, state.materialXGenContext);
309
302
 
@@ -331,11 +324,11 @@ export async function createMaterialXMaterial(mtlx: string, materialNodeName: st
331
324
 
332
325
  } catch (error) {
333
326
  // This is a wasm error (an int) that we need to resolve
334
- console.error(`[MaterialX] Error creating MaterialX material (${name}):`, error);
327
+ console.error(`[MaterialX] Error creating MaterialX material (${materialNodeName}):`, error);
335
328
  // Return a fallback material with stored MaterialX data
336
329
  const fallbackMaterial = new MeshStandardMaterial();
337
330
  fallbackMaterial.color.set(0xff00ff);
338
- fallbackMaterial.name = `MaterialX_Error_${name}`;
331
+ fallbackMaterial.name = `MaterialX_Error_${materialNodeName}`;
339
332
  return fallbackMaterial;
340
333
  }
341
- }
334
+ }
@@ -0,0 +1,60 @@
1
+ import { Light, Scene, Texture, WebGLRenderer } from "three";
2
+ import type { MaterialX as MX } from "./materialx.types.js";
3
+
4
+ export type MaterialXContext = {
5
+ getTime?(): number;
6
+ getFrame?(): number;
7
+ }
8
+
9
+ type EnvironmentTextureSet = {
10
+ radianceTexture: Texture | null;
11
+ irradianceTexture: Texture | null;
12
+ }
13
+
14
+ export declare const state: {
15
+ materialXModule: MX.MODULE | null;
16
+ materialXGenerator: any | null;
17
+ materialXGenContext: any | null;
18
+ materialXStdLib: any | null;
19
+ materialXInitPromise: Promise<void> | null;
20
+ };
21
+
22
+ /**
23
+ * Wait for the MaterialX WASM module to be ready.
24
+ */
25
+ export declare function ready(): Promise<void>;
26
+
27
+ /**
28
+ * MaterialXEnvironment manages the environment settings for MaterialX materials.
29
+ */
30
+ export declare class MaterialXEnvironment {
31
+ static get(scene: Scene): MaterialXEnvironment | null;
32
+ private static _environments: WeakMap<Scene, MaterialXEnvironment>;
33
+ private static getEnvironment(scene: Scene): MaterialXEnvironment;
34
+
35
+ private _lights: Array<Light>;
36
+ private _lightData: any[] | null;
37
+ private _lightCount: number;
38
+ private _initializePromise: Promise<boolean> | null;
39
+ private _isInitialized: boolean;
40
+ private _lastUpdateFrame: number;
41
+ private _scene: Scene;
42
+
43
+ constructor(_scene: Scene);
44
+
45
+ initialize(renderer: WebGLRenderer): Promise<boolean>;
46
+ update(frame: number, scene: Scene, renderer: WebGLRenderer): void;
47
+ reset(): void;
48
+
49
+ get lights(): Array<Light>;
50
+ get lightData(): any[] | null;
51
+ get lightCount(): number;
52
+ getTextures(material: any): EnvironmentTextureSet;
53
+
54
+ private _pmremGenerator: any | null;
55
+ private _renderer: WebGLRenderer | null;
56
+ private _texturesCache: Map<Texture | null, EnvironmentTextureSet>;
57
+ private _initialize(renderer: WebGLRenderer): Promise<boolean>;
58
+ private _getTextures(texture: Texture | null | undefined): EnvironmentTextureSet;
59
+ private updateLighting(collectLights?: boolean): void;
60
+ }
@@ -0,0 +1,31 @@
1
+ import * as THREE from 'three';
2
+
3
+ export interface Callbacks {
4
+ readonly cacheKey?: string;
5
+ readonly getTexture: (path: string) => Promise<THREE.Texture | null | void>;
6
+ }
7
+
8
+ export interface LightData {
9
+ type: number;
10
+ position: THREE.Vector3;
11
+ direction: THREE.Vector3;
12
+ color: THREE.Color;
13
+ intensity: number;
14
+ decay_rate: number;
15
+ inner_angle: number;
16
+ outer_angle: number;
17
+ }
18
+
19
+ export function prepareEnvTexture(texture: THREE.Texture, capabilities: any): THREE.Texture;
20
+
21
+ export function getLightRotation(): THREE.Matrix4;
22
+
23
+ export function findLights(doc: any): Array<any>;
24
+
25
+ export function registerLights(mx: any, genContext: any): Promise<void>;
26
+
27
+ export function getLightData(lights: Array<THREE.Light>, genContext: any): { lightData: LightData[], lightCount: number };
28
+
29
+ export function getUniformValues(shaderStage: any, loaders: Callbacks, searchPath: string): Record<string, THREE.Uniform>;
30
+
31
+ export function generateMaterialPropertiesForUniforms(material: THREE.ShaderMaterial, shaderStage: any): void;