@needle-tools/materialx 1.0.0-next.85f6ffd → 1.0.0-next.a660bbe

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.
package/package.json CHANGED
@@ -1,17 +1,24 @@
1
1
  {
2
2
  "name": "@needle-tools/materialx",
3
- "version": "1.0.0-next.85f6ffd",
3
+ "version": "1.0.0-next.a660bbe",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
- "dependencies": {},
6
+ "exports": {
7
+ ".": {
8
+ "import": "./index.ts",
9
+ "require": "./index.js"
10
+ },
11
+ "./package.json": "./package.json"
12
+ },
7
13
  "peerDependencies": {
8
14
  "@needle-tools/engine": "4.x",
9
15
  "three": "npm:@needle-tools/three@^0.169.5"
10
16
  },
11
17
  "devDependencies": {
12
18
  "@needle-tools/engine": "4.x",
19
+ "@types/three": "0.169.0",
13
20
  "three": "npm:@needle-tools/three@^0.169.5",
14
- "@types/three": "0.169.0"
21
+ "vite": "^7.0.3"
15
22
  },
16
23
  "publishConfig": {
17
24
  "access": "public",
package/src/materialx.ts CHANGED
@@ -5,6 +5,16 @@ import { renderPMREMToEquirect } from "./textureHelper.js";
5
5
  import { Light, MeshBasicMaterial, Object3D, PMREMGenerator } from "three";
6
6
  import { registerLights } from "./helper.js";
7
7
 
8
+ const coreWasmUrl = new URL('../bin/JsMaterialXCore.wasm', import.meta.url).href;
9
+ const shaderDataUrl = new URL('../bin/JsMaterialXGenShader.data', import.meta.url).href;
10
+ const shaderWasmUrl = new URL('../bin/JsMaterialXGenShader.wasm', import.meta.url).href;
11
+
12
+ // const moduleUrls = import.meta.glob('../bin/JsMaterialXCore.wasm', {
13
+ // query: '?url',
14
+ // import: 'default',
15
+ // })
16
+ // import jsMaterialCoreUrl from "../bin/JsMaterialXCore.wasm?url";
17
+
8
18
  // Configure MaterialX with the correct path for its data files
9
19
  const materialXConfig = {
10
20
  locateFile: (path: string, scriptDirectory: string) => {
@@ -12,9 +22,19 @@ const materialXConfig = {
12
22
 
13
23
  // Return the correct path for MaterialX data files
14
24
  if (path.endsWith('.data') || path.endsWith('.wasm')) {
25
+ if(path.includes("JsMaterialXCore.wasm")) {
26
+ return coreWasmUrl; // Use the URL for the core WASM file
27
+ }
28
+ else if (path.includes("JsMaterialXGenShader.data")) {
29
+ return shaderDataUrl; // Use the URL for the shader data file
30
+ }
31
+ else if (path.includes("JsMaterialXGenShader.wasm")) {
32
+ return shaderWasmUrl; // Use the URL for the shader WASM file
33
+ }
15
34
  // For Vite dev server, we need to use the correct module path
16
- const correctPath = new URL(`../bin/${path}`, import.meta.url).href;
17
- if (debug) console.log("Resolved path:", correctPath);
35
+ const url = new URL(`../bin/${path}?url`, import.meta.url);
36
+ const correctPath = url.href;
37
+ if (debug) console.debug("MaterialX locateFile resolved:", correctPath, { url, meta_url: import.meta.url });
18
38
  return correctPath;
19
39
  }
20
40
  return scriptDirectory + path;
package/bin/README.md DELETED
@@ -1,5 +0,0 @@
1
- Source: https://github.com/AcademySoftwareFoundation/MaterialX/tree/gh-pages
2
-
3
- Edits:
4
-
5
- - `JsMaterialXGenShader.js` added `export default MaterialX;` at bottom