@needle-tools/materialx 1.4.4 → 1.4.6-next.5f948f6

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/README.md CHANGED
@@ -1,10 +1,15 @@
1
- # Needle MaterialX
1
+ # Needle MaterialX – MaterialX Materials for three.js & the Web
2
2
 
3
- 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 support for loading raw MaterialX XML files.
3
+ Web runtime for [MaterialX](https://materialx.org/) materials in [Needle Engine](https://needle.tools) and [three.js](https://threejs.org/). Renders physically based MaterialX shaders in the browser using WebAssembly load `.mtlx` files or glTF assets with the `NEEDLE_materials_mtlx` extension.
4
+
5
+ - MaterialX to WebGL/WebGPU shader generation via WASM
6
+ - glTF extension for embedding MaterialX materials in `.glb`/`.gltf` files
7
+ - Experimental support for loading raw MaterialX XML (`.mtlx`) files
8
+ - Works standalone with three.js or as a Needle Engine module
4
9
 
5
10
  [Learn more in the Needle Engine documentation](https://engine.needle.tools/docs/how-to-guides/export/materialx.html)
6
11
 
7
- [![](https://cloud.needle.tools/-/media/Xc99R6zbaD-kpoTw1cMRKA.gif)](https://engine.needle.tools/samples/material-x)
12
+ [![MaterialX material rendered in the browser with Needle Engine](https://cloud.needle.tools/-/media/Xc99R6zbaD-kpoTw1cMRKA.gif)](https://engine.needle.tools/samples/material-x)
8
13
 
9
14
 
10
15
  ## Installation
@@ -15,9 +20,27 @@ Web runtime support to load and display MaterialX materials in Needle Engine and
15
20
 
16
21
  ## How to use
17
22
 
23
+ ### Use with Needle Engine
24
+
25
+ **Needle Engine has built in support for MaterialX shaders.** No changes to your code are necessary. The MaterialX module will import lazily when needed.
26
+
27
+ ### Use with three.js
28
+
29
+ ```ts
30
+ import { useNeedleMaterialX } from "@needle-tools/materialx";
31
+ // Call the function with your GLTFLoader instance
32
+ useNeedleMaterialX(<yourGltfLoaderInstance>);
33
+ ```
34
+
35
+ ## WASM
36
+
37
+ ### Default (CDN)
38
+
39
+ By default, MaterialX WASM files are loaded from the Needle CDN at `https://cdn.needle.tools/static/materialx/<version>/`. No configuration needed.
40
+
18
41
  ### Custom WASM Location
19
42
 
20
- By default, MaterialX WASM files are loaded from `https://cdn.needle.tools/static/materialx/<version>/`. You can override this by setting `globalThis.NEEDLE_MATERIALX_LOCATION` **before** any MaterialX code runs.
43
+ You can override the WASM location by setting `globalThis.NEEDLE_MATERIALX_LOCATION` **before** MaterialX loads (for example in global scope in a root script).
21
44
 
22
45
  #### Package-local files
23
46
 
@@ -43,27 +66,8 @@ To use a custom base URL (for self-hosted deployments, air-gapped environments,
43
66
  globalThis.NEEDLE_MATERIALX_LOCATION = "/assets/materialx/";
44
67
  ```
45
68
 
46
- The value must end with a trailing slash (`/`).
69
+ IMPORTANT: The value must end with a trailing slash (`/`).
47
70
 
48
- #### Default (CDN)
49
-
50
- By default, MaterialX WASM files are loaded from the Needle CDN. No configuration needed.
51
-
52
- ### Use with Needle Engine
53
-
54
- ```ts
55
- import { useNeedleMaterialX } from "@needle-tools/materialx/needle";
56
- // Simply call this function in global scope as soon as possible
57
- useNeedleMaterialX();
58
- ```
59
-
60
- ### Use with three.js
61
-
62
- ```ts
63
- import { useNeedleMaterialX } from "@needle-tools/materialx";
64
- // Call the function with your GLTFLoader instance
65
- useNeedleMaterialX(<yourGltfLoaderInstance>);
66
- ```
67
71
 
68
72
  ## glTF Extension: NEEDLE_materials_mtlx
69
73
 
@@ -93,7 +97,7 @@ Materials can also contain the `NEEDLE_materials_mtlx` extension, which referenc
93
97
  "name": "Perforated_Metal_normal"
94
98
  }
95
99
  ],
96
- "shaders": [ // optional ]
100
+ "shaders": [] ← optional
97
101
  }
98
102
  ]
99
103
  }
@@ -124,7 +128,7 @@ Materials can also contain the `NEEDLE_materials_mtlx` extension, which referenc
124
128
  # Contact ✒️
125
129
  <b>[🌵 Needle](https://needle.tools)</b> •
126
130
  [Github](https://github.com/needle-tools) •
127
- [Twitter](https://twitter.com/NeedleTools) •
131
+ [X](https://x.com/NeedleTools) •
128
132
  [Discord](https://discord.needle.tools) •
129
133
  [Forum](https://forum.needle.tools) •
130
134
  [Youtube](https://www.youtube.com/@needle-tools)
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@needle-tools/materialx",
3
- "version": "1.4.4",
3
+ "description": "MaterialX material support for three.js and Needle Engine – render physically based MaterialX shaders in the browser via WebAssembly",
4
+ "version": "1.4.6-next.5f948f6",
4
5
  "type": "module",
5
6
  "main": "index.js",
6
7
  "types": "index.d.ts",
@@ -57,7 +58,12 @@
57
58
  "threejs",
58
59
  "three.js",
59
60
  "webgl",
61
+ "webgpu",
60
62
  "mtlx",
61
- "rendering"
63
+ "rendering",
64
+ "gltf",
65
+ "pbr",
66
+ "3d",
67
+ "wasm"
62
68
  ]
63
69
  }
package/src/constants.js CHANGED
@@ -1,3 +1,6 @@
1
- import pkg from '../package.json' with { type: 'json' };
1
+ // Avoid `import ... with { type: 'json' }` (import attributes) since
2
+ // it requires esbuild 0.18+ / Vite 5+. A default JSON import works in
3
+ // all major bundlers (Vite, Webpack, Rollup) without extra config.
4
+ import pkg from '../package.json';
2
5
 
3
- export const VERSION = pkg.version;
6
+ export const VERSION = pkg.version;