@needle-tools/materialx 1.0.1-next.2ca9014 → 1.0.1-next.31390e3

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.
@@ -2,5 +2,7 @@
2
2
  import { TypeStore } from "@needle-tools/engine"
3
3
 
4
4
  // Import types
5
+ import { MaterialXUniformUpdate } from "../src/loader/loader.needle.js";
5
6
 
6
7
  // Register types
8
+ TypeStore.add("MaterialXUniformUpdate", MaterialXUniformUpdate);
package/index.ts CHANGED
@@ -2,4 +2,4 @@ import { registerNeedleLoader } from "./src/loader/loader.needle.js";
2
2
 
3
3
  registerNeedleLoader();
4
4
 
5
- export { initializeMaterialX, getMaterialXEnvironment } from "./src/index.js";
5
+ export { ready, getMaterialXEnvironment } from "./src/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/materialx",
3
- "version": "1.0.1-next.2ca9014",
3
+ "version": "1.0.1-next.31390e3",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "exports": {
@@ -8,7 +8,11 @@
8
8
  "import": "./index.ts",
9
9
  "require": "./index.js"
10
10
  },
11
- "./package.json": "./package.json"
11
+ "./package.json": "./package.json",
12
+ "./codegen/register_types.ts": {
13
+ "import": "./codegen/register_types.ts",
14
+ "require": "./codegen/register_types.js"
15
+ }
12
16
  },
13
17
  "peerDependencies": {
14
18
  "@needle-tools/engine": "4.x",
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { initializeMaterialX, state } from "./materialx.js";
1
+ import { ready, state } from "./materialx.js";
2
2
 
3
3
  const getMaterialXEnvironment = () => state.materialXEnvironment;
4
4
 
5
- export { initializeMaterialX, getMaterialXEnvironment };
5
+ export { ready, getMaterialXEnvironment };
@@ -68,7 +68,7 @@ export class MaterialXLoaderPlugin implements INeedleGLTFExtensionPlugin {
68
68
  };
69
69
 
70
70
  onLoaded = (url: string, gltf: GLTF, _context: Context) => {
71
- if (debug) console.log("MaterialXLoaderPlugin: glTF loaded", url, gltf.scene);
71
+ if (debug) console.log("[MaterialX] MaterialXLoaderPlugin: glTF loaded", url, gltf.scene);
72
72
 
73
73
  // Set up onBeforeRender callbacks for objects with MaterialX materials
74
74
  // This ensures uniforms are updated properly during rendering
@@ -78,13 +78,13 @@ export class MaterialXLoaderPlugin implements INeedleGLTFExtensionPlugin {
78
78
  const material = mesh.material as Material;
79
79
 
80
80
  if (material?.userData?.updateUniforms) {
81
- if (debug) console.log("Adding MaterialX uniform update component to:", child.name);
81
+ if (debug) console.log("[MaterialX] Adding MaterialX uniform update component to:", child.name);
82
82
  child.addComponent(MaterialXUniformUpdate);
83
83
  }
84
84
  }
85
85
  });
86
86
 
87
- if (debug) console.log("Loaded: ", this.mtlxLoader);
87
+ if (debug) console.log("[MaterialX] Loaded: ", this.mtlxLoader);
88
88
 
89
89
  // Initialize MaterialX lighting system with scene data
90
90
  const environment = state.materialXEnvironment;
@@ -96,7 +96,7 @@ export class MaterialXLoaderPlugin implements INeedleGLTFExtensionPlugin {
96
96
  };
97
97
 
98
98
  onExport = (_exporter: GLTFExporter, _context: Context) => {
99
- console.log("TODO: MaterialXLoaderPlugin: Setting up export extensions");
99
+ console.log("[MaterialX] TODO: MaterialXLoaderPlugin: Setting up export extensions");
100
100
  // TODO: Add MaterialX export functionality if needed
101
101
  };
102
102
  }
@@ -2,7 +2,7 @@ import { Context } from "@needle-tools/engine";
2
2
  import { ShaderMaterial, Material, MeshStandardMaterial, LoadingManager, TextureLoader, Texture, NearestFilter, Matrix4, GLSL3, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, DoubleSide, Matrix3, Vector3, Object3D, Camera } from "three";
3
3
  import { GLTFLoaderPlugin, GLTFParser } from "three/examples/jsm/loaders/GLTFLoader.js";
4
4
  import { getUniformValues } from "../helper.js";
5
- import { initializeMaterialX, MaterialXEnvironment, state } from "../materialx.js";
5
+ import { ready, MaterialXEnvironment, state } from "../materialx.js";
6
6
  import { debug } from "../utils.js";
7
7
 
8
8
  // TypeScript interfaces matching the C# data structures
@@ -37,22 +37,22 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
37
37
  private async initializeEnvironment(): Promise<void> {
38
38
  if (this.environmentInitialized) return;
39
39
 
40
- if (debug) console.log("MaterialXLoader: Initializing MaterialX environment...");
40
+ if (debug) console.log("[MaterialX] MaterialXLoader: Initializing MaterialX environment...");
41
41
 
42
42
  // Ensure MaterialX is initialized first
43
- await initializeMaterialX();
43
+ await ready();
44
44
 
45
45
  // Set up environment with context
46
46
  const environment = state.materialXEnvironment;
47
- environment.setContext(this.context);
47
+ environment.context = this.context;
48
48
 
49
49
  // Initialize the environment from context (properly awaited)
50
50
  try {
51
51
  await environment.initializeFromContext();
52
52
  this.environmentInitialized = true;
53
- if (debug) console.log("MaterialXLoader: Environment initialized successfully");
53
+ if (debug) console.log("[MaterialX] MaterialXLoader: Environment initialized successfully");
54
54
  } catch (error) {
55
- console.warn("MaterialXLoader: Failed to initialize MaterialX environment:", error);
55
+ console.warn("[MaterialX] MaterialXLoader: Failed to initialize MaterialX environment:", error);
56
56
  }
57
57
  }
58
58
 
@@ -62,7 +62,7 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
62
62
 
63
63
  const gltfExtensions = this.parser.json.extensions;
64
64
  if (gltfExtensions?.[this.name]) {
65
- if (debug) console.log("MaterialX extension found in root:", gltfExtensions[this.name]);
65
+ if (debug) console.log("[MaterialX] extension found in root:", gltfExtensions[this.name]);
66
66
 
67
67
  const materialXExtension = gltfExtensions[this.name];
68
68
  this.rootMaterialXData = materialXExtension as MaterialXData;
@@ -79,13 +79,13 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
79
79
  this.documentParsePromise = (async () => {
80
80
  if (this.parsedDocument) return this.parsedDocument;
81
81
 
82
- if (debug) console.log("Parsing MaterialX root document...");
82
+ if (debug) console.log("[MaterialX] Parsing MaterialX root document...");
83
83
 
84
84
  // Ensure MaterialX is initialized
85
- await initializeMaterialX();
85
+ await ready();
86
86
 
87
87
  if (!state.materialXModule) {
88
- throw new Error("MaterialX module failed to initialize");
88
+ throw new Error("[MaterialX] module failed to initialize");
89
89
  }
90
90
 
91
91
  // Create MaterialX document and parse ALL the XML data from root
@@ -94,11 +94,11 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
94
94
 
95
95
  // Parse all MaterialX XML strings from the root data
96
96
  if (this.rootMaterialXData) {
97
- if (debug) console.log(`Parsing MaterialX XML for: ${this.rootMaterialXData.name}`);
97
+ if (debug) console.log(`[MaterialX] Parsing XML for: ${this.rootMaterialXData.name}`);
98
98
  await state.materialXModule.readFromXmlString(doc, this.rootMaterialXData.mtlx, "");
99
99
  }
100
100
 
101
- if (debug) console.log("MaterialX root document parsed successfully");
101
+ if (debug) console.log("[MaterialX] root document parsed successfully");
102
102
 
103
103
  this.parsedDocument = doc;
104
104
  return doc;
@@ -122,7 +122,7 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
122
122
  this.initializeRootData();
123
123
 
124
124
  const materialDef = this.parser.json.materials?.[materialIndex];
125
- if (debug) console.log("MaterialX extension found in material:", materialDef.extensions[this.name]);
125
+ if (debug) console.log("[MaterialX] extension found in material:", materialDef.extensions[this.name]);
126
126
 
127
127
  // Handle different types of MaterialX data
128
128
  const dataIndex = materialDef.extensions[this.name] as MaterialXDataIndex;
@@ -144,7 +144,7 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
144
144
  if (debug) console.log(`Creating MaterialX material: ${materialXData.name}`);
145
145
 
146
146
  // Ensure MaterialX is initialized and document is parsed
147
- await initializeMaterialX();
147
+ await ready();
148
148
 
149
149
  if (!this.rootDocument) {
150
150
  this.rootDocument = this.parseRootDocument();
@@ -152,7 +152,7 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
152
152
  const doc = await this.rootDocument;
153
153
 
154
154
  if (!state.materialXModule || !state.materialXGenerator || !state.materialXGenContext) {
155
- console.warn("MaterialX WASM module not ready, returning fallback material");
155
+ console.warn("[MaterialX] WASM module not ready, returning fallback material");
156
156
  const fallbackMaterial = new MeshStandardMaterial();
157
157
  fallbackMaterial.userData.materialX = materialXData;
158
158
  fallbackMaterial.name = `MaterialX_Fallback_${materialXData.name}`;
@@ -163,11 +163,11 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
163
163
  let renderableElement = null;
164
164
  let foundRenderable = false;
165
165
 
166
- if (debug) console.log("Mtlx doc", doc);
166
+ if (debug) console.log("[MaterialX] document", doc);
167
167
 
168
168
  // Search for material nodes first (following the reference pattern)
169
169
  const materialNodes = doc.getMaterialNodes();
170
- if (debug) console.log(`Found ${materialNodes.length} material nodes in document`, materialNodes);
170
+ if (debug) console.log(`[MaterialX] Found ${materialNodes.length} material nodes in document`, materialNodes);
171
171
 
172
172
  // Handle both array and vector-like APIs
173
173
  const materialNodesLength = materialNodes.length;
@@ -175,13 +175,13 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
175
175
  const materialNode = materialNodes[i];
176
176
  if (materialNode) {
177
177
  const materialName = materialNode.getNamePath();
178
- if (debug) console.log('Scan material: ', i, materialName);
178
+ if (debug) console.log('[MaterialX] Scan material: ', i, materialName);
179
179
 
180
180
  // Find the matching material
181
181
  if (materialName == materialXData.name) {
182
182
  renderableElement = materialNode;
183
183
  foundRenderable = true;
184
- if (debug) console.log('-- add material: ', materialName);
184
+ if (debug) console.log('[MaterialX] -- add material: ', materialName);
185
185
  break;
186
186
  }
187
187
  }
@@ -235,21 +235,21 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
235
235
  */
236
236
 
237
237
  if (!renderableElement) {
238
- console.warn("No renderable element found in MaterialX document");
238
+ console.warn("[MaterialX] No renderable element found in MaterialX document");
239
239
  const fallbackMaterial = new MeshStandardMaterial();
240
240
  fallbackMaterial.userData.materialX = materialXData;
241
241
  fallbackMaterial.name = `MaterialX_NoRenderable_${materialXData.name}`;
242
242
  return fallbackMaterial;
243
243
  }
244
244
 
245
- if (debug) console.log("Using renderable element for shader generation");
245
+ if (debug) console.log("[MaterialX] Using renderable element for shader generation");
246
246
 
247
247
  // Check transparency and set context options like the reference
248
248
  let isTransparent = state.materialXModule.isTransparentSurface(renderableElement, state.materialXGenerator.getTarget());
249
249
  state.materialXGenContext.getOptions().hwTransparency = isTransparent;
250
250
 
251
251
  // Generate shaders using the element's name path
252
- if (debug) console.log("Generating MaterialX shaders...");
252
+ if (debug) console.log("[MaterialX] Generating MaterialX shaders...");
253
253
  const elementName = (renderableElement as any).getNamePath ? (renderableElement as any).getNamePath() : (renderableElement as any).getName();
254
254
 
255
255
  const shader = state.materialXGenerator.generate(elementName, renderableElement, state.materialXGenContext);
@@ -302,7 +302,7 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
302
302
  #include <colorspace_fragment>`);
303
303
 
304
304
  if (debug) {
305
- console.group("Material: ", materialXData.name);
305
+ console.group("[MaterialX]: ", materialXData.name);
306
306
  console.log("Vertex shader length:", vertexShader.length, vertexShader);
307
307
  console.log("Fragment shader length:", fragmentShader.length, fragmentShader);
308
308
  console.groupEnd();
@@ -341,17 +341,17 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
341
341
  const textures = ext?.textures || [];
342
342
 
343
343
  const index = textures.findIndex(tex => {
344
- if (debug) console.log("Checking texture:", tex.name, "against URL:", filenameWithoutExt);
344
+ if (debug) console.log("[MaterialX] Checking texture:", tex.name, "against URL:", filenameWithoutExt);
345
345
  return tex.name === filenameWithoutExt;
346
346
  });
347
347
 
348
348
  if (index < 0) {
349
- console.warn("Texture not found in parser:", filenameWithoutExt, this.parser.json);
349
+ console.warn("[MaterialX] Texture not found in parser:", filenameWithoutExt, this.parser.json);
350
350
  onError?.(new Error(`Texture not found: ${filenameWithoutExt}`));
351
351
  return;
352
352
  }
353
353
  this.parser.getDependency("texture", index).then(tex => {
354
- if (debug) console.log("Texture loaded:", tex);
354
+ if (debug) console.log("[MaterialX] Texture loaded:", tex);
355
355
  // update the checkerboard texture with the loaded texture
356
356
  checkerboardTexture.image = tex.image;
357
357
  checkerboardTexture.needsUpdate = true;
@@ -396,7 +396,7 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
396
396
  }
397
397
 
398
398
  const mips = Math.trunc(Math.log2(Math.max(radianceTexture?.width ?? 0, radianceTexture?.height ?? 0))) + 1;
399
- if (debug) console.log("Radiance texture mips:", mips, "for texture size:", radianceTexture?.width, "x", radianceTexture?.height);
399
+ if (debug) console.log("[MaterialX] Radiance texture mips:", mips, "for texture size:", radianceTexture?.width, "x", radianceTexture?.height);
400
400
  Object.assign(uniforms, {
401
401
  u_envMatrix: { value: getLightRotation() },
402
402
  u_envRadiance: { value: radianceTexture, type: 't' },
@@ -485,7 +485,7 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
485
485
  shaderMaterial.name = `MaterialX_Generated_${materialXData.name}`;
486
486
 
487
487
  // Add debugging to see if the material compiles correctly
488
- if (debug) console.log("MaterialX material created successfully:", shaderMaterial.name);
488
+ if (debug) console.log("[MaterialX] material created successfully:", shaderMaterial.name);
489
489
  // if (debug) console.log("Material uniforms keys:", Object.keys(shaderMaterial.uniforms || {}));
490
490
  // if (debug) console.log("Material transparent:", shaderMaterial.transparent);
491
491
  // if (debug) console.log("Material side:", shaderMaterial.side);
@@ -497,7 +497,7 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
497
497
 
498
498
  } catch (error) {
499
499
  // This is a wasm error (an int) that we need to resolve
500
- console.error("Error creating MaterialX material:", error);
500
+ console.error("[MaterialX] Error creating MaterialX material:", error);
501
501
  // Return a fallback material with stored MaterialX data
502
502
  const fallbackMaterial = new MeshStandardMaterial();
503
503
  fallbackMaterial.userData.materialX = materialXData;
@@ -516,7 +516,7 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
516
516
  const radianceTexture = environment.getRadianceTexture() || null;
517
517
  const irradianceTexture = environment.getIrradianceTexture() || null;
518
518
 
519
- if (debug) console.log(`Updating lighting for ${this.generatedMaterials.length} MaterialX materials`, {
519
+ if (debug) console.log(`[MaterialX] Updating lighting for ${this.generatedMaterials.length} MaterialX materials`, {
520
520
  lightData, radianceTexture, irradianceTexture,
521
521
  });
522
522
 
@@ -535,7 +535,7 @@ export class MaterialXLoader implements GLTFLoaderPlugin {
535
535
  material.uniforms.u_lightData = { value: null };
536
536
  }
537
537
  material.uniforms.u_lightData.value = lightData;
538
- if (debug) console.log("Updated light data for material", material.name, lightData, material.uniforms, );
538
+ if (debug) console.log("[MaterialX] Updated light data for material", material.name, lightData, material.uniforms, );
539
539
  }
540
540
 
541
541
  // Update environment uniforms
package/src/materialx.ts CHANGED
@@ -8,7 +8,7 @@ import { registerLights } from "./helper.js";
8
8
 
9
9
  // Global MaterialX module instance - initialized lazily
10
10
  export const state = new class {
11
- materialXModule: any = null;
11
+ materialXModule: typeof MaterialX | null = null;
12
12
  materialXGenerator: any = null;
13
13
  materialXGenContext: any = null;
14
14
  materialXStdLib: any = null;
@@ -23,13 +23,13 @@ export const state = new class {
23
23
  }
24
24
 
25
25
  // Initialize MaterialX WASM module lazily
26
- export async function initializeMaterialX(): Promise<void> {
26
+ export async function ready(): Promise<void> {
27
27
  if (state.materialXInitPromise) {
28
28
  return state.materialXInitPromise;
29
29
  }
30
30
  return state.materialXInitPromise = (async () => {
31
31
  if (state.materialXModule) return; // Already initialized
32
- if (debug) console.log("Initializing MaterialX WASM module...");
32
+ if (debug) console.log("[MaterialX] Initializing WASM module...");
33
33
  try {
34
34
 
35
35
  const urls: Array<string> = await Promise.all([
@@ -44,7 +44,7 @@ export async function initializeMaterialX(): Promise<void> {
44
44
 
45
45
  const module = await MaterialX({
46
46
  locateFile: (path: string, scriptDirectory: string) => {
47
- if (debug) console.debug("MaterialX locateFile called:", { path, scriptDirectory });
47
+ if (debug) console.debug("[MaterialX] locateFile called:", { path, scriptDirectory });
48
48
 
49
49
  if (path.includes("JsMaterialXCore.wasm")) {
50
50
  return JsMaterialXCore; // Use the URL for the core WASM file
@@ -59,7 +59,7 @@ export async function initializeMaterialX(): Promise<void> {
59
59
  return scriptDirectory + path;
60
60
  },
61
61
  });
62
- if (debug) console.log("MaterialXLoader module loaded", module);
62
+ if (debug) console.log("[MaterialX] module loaded", module);
63
63
  state.materialXModule = module;
64
64
 
65
65
  // Initialize shader generator and context
@@ -74,12 +74,12 @@ export async function initializeMaterialX(): Promise<void> {
74
74
  // TODO ShaderInterfaceType.SHADER_INTERFACE_REDUCED would be better, but doesn't actually seem to be supported in the MaterialX javascript bindings
75
75
  const options = state.materialXGenContext.getOptions();
76
76
  state.materialXGenContext.getOptions().shaderInterfaceType = state.materialXModule.ShaderInterfaceType.SHADER_INTERFACE_COMPLETE;
77
-
77
+
78
78
  // SPECULAR_ENVIRONMENT_NONE: Do not use specular environment maps.
79
79
  // SPECULAR_ENVIRONMENT_FIS: Use Filtered Importance Sampling for specular environment/indirect lighting.
80
80
  // SPECULAR_ENVIRONMENT_PREFILTER: Use pre-filtered environment maps for specular environment/indirect lighting.
81
81
  state.materialXGenContext.getOptions().hwSpecularEnvironmentMethod = state.materialXModule.HwSpecularEnvironmentMethod.SPECULAR_ENVIRONMENT_FIS;
82
-
82
+
83
83
  // TRANSMISSION_REFRACTION: Use a refraction approximation for transmission rendering.
84
84
  // TRANSMISSION_OPACITY: Use opacity for transmission rendering.
85
85
  // state.materialXGenContext.getOptions().hwTransmissionRenderMethod = state.materialXModule.HwTransmissionRenderMethod.TRANSMISSION_REFRACTION;
@@ -98,9 +98,9 @@ export async function initializeMaterialX(): Promise<void> {
98
98
  // This prewarms the shader generation context to have all light types
99
99
  await registerLights(state.materialXModule, [], state.materialXGenContext);
100
100
 
101
- if (debug) console.log("MaterialX generator initialized successfully");
101
+ if (debug) console.log("[MaterialX] generator initialized successfully");
102
102
  } catch (error) {
103
- console.error("Failed to load MaterialX module:", error);
103
+ console.error("[MaterialX] Failed to load MaterialX module:", error);
104
104
  throw error;
105
105
  }
106
106
  })();
@@ -108,42 +108,39 @@ export async function initializeMaterialX(): Promise<void> {
108
108
 
109
109
  // MaterialX Environment Manager - handles lighting and environment setup
110
110
  export class MaterialXEnvironment {
111
+ context: Context | null = null;
112
+
111
113
  private lightData: any = null;
112
114
  private lightCount: number = 0;
113
115
  private radianceTexture: any = null;
114
116
  private irradianceTexture: any = null;
115
- private context: Context | null = null;
116
117
  private initialized: boolean = false;
117
118
 
118
119
  constructor() {
119
- if (debug) console.log("MaterialX Environment created");
120
- }
121
-
122
- setContext(context: Context) {
123
- this.context = context;
120
+ if (debug) console.log("[MaterialX] Environment created");
124
121
  }
125
122
 
126
123
  // Initialize with Needle Engine context
127
124
  async initializeFromContext(): Promise<void> {
128
125
  if (!this.context) {
129
- console.warn("No Needle context available for MaterialX environment initialization");
126
+ console.warn("[MaterialX] No Needle context available for environment initialization");
130
127
  return;
131
128
  }
132
129
 
133
130
  // Prevent multiple initializations
134
131
  if (this.initialized) {
135
- if (debug) console.log("MaterialX environment already initialized, skipping");
132
+ if (debug) console.log("[MaterialX] environment already initialized, skipping");
136
133
  return;
137
134
  }
138
135
 
139
136
  // Clean up previous textures if they exist
140
137
  if (this.radianceTexture) {
141
- if (debug) console.log("Disposing previous radiance texture");
138
+ if (debug) console.log("[MaterialX] Disposing previous radiance texture");
142
139
  this.radianceTexture.dispose();
143
140
  this.radianceTexture = null;
144
141
  }
145
142
  if (this.irradianceTexture) {
146
- if (debug) console.log("Disposing previous irradiance texture");
143
+ if (debug) console.log("[MaterialX] Disposing previous irradiance texture");
147
144
  this.irradianceTexture.dispose();
148
145
  this.irradianceTexture = null;
149
146
  }
@@ -175,20 +172,19 @@ export class MaterialXEnvironment {
175
172
  console.log({ radiance: this.radianceTexture, irradiance: this.irradianceTexture });
176
173
  // Show both of them on cubes in the scene
177
174
  const unlitMat = new MeshBasicMaterial();
175
+ unlitMat.side = 2;
178
176
  const radianceMat = unlitMat.clone();
179
177
  radianceMat.map = this.radianceTexture;
180
- const radianceCube = ObjectUtils.createPrimitive("Cube", { material: radianceMat });
178
+ const radianceCube = ObjectUtils.createPrimitive("Quad", { material: radianceMat });
181
179
  const irradianceMat = unlitMat.clone();
182
180
  irradianceMat.map = this.irradianceTexture;
183
- const irradianceCube = ObjectUtils.createPrimitive("Cube", { material: irradianceMat });
181
+ const irradianceCube = ObjectUtils.createPrimitive("Quad", { material: irradianceMat });
184
182
  this.context.scene.add(radianceCube);
185
183
  this.context.scene.add(irradianceCube);
186
184
  radianceCube.position.set(2, 0, 0);
187
- radianceCube.scale.y = 0.00001;
188
185
  irradianceCube.position.set(-2, 0, 0);
189
- irradianceCube.scale.y = 0.00001;
190
186
  // await this.initializeLighting(defaultLightRigXml, renderer);
191
- console.log("MaterialX environment initialized from Needle context", this, this.context.scene);
187
+ console.log("[MaterialX] environment initialized from Needle context", this, this.context.scene);
192
188
  }
193
189
 
194
190
  // Find lights in scene
@@ -216,7 +212,7 @@ export class MaterialXEnvironment {
216
212
 
217
213
  // Reset the environment to allow re-initialization
218
214
  reset() {
219
- if (debug) console.log("Resetting MaterialX environment");
215
+ if (debug) console.log("[MaterialX] Resetting environment");
220
216
  if (this.radianceTexture) {
221
217
  this.radianceTexture.dispose();
222
218
  this.radianceTexture = null;