@needle-tools/usd 0.0.2-next.de2e82b → 1.0.0-next.52b4773

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/README.md +245 -28
  3. package/package.json +46 -10
  4. package/src/bindings/emHdBindings.js +5 -12227
  5. package/src/bindings/emHdBindings.wasm +0 -0
  6. package/src/bindings/index.js +130 -47
  7. package/src/bindings/openusd-build-info.json +40 -0
  8. package/src/create.three.js +368 -53
  9. package/src/hydra/ThreeJsRenderDelegate.js +1133 -80
  10. package/src/plugins/index.js +1 -2
  11. package/src/plugins/needle.js +38 -2
  12. package/src/types/bindings.d.ts +296 -3
  13. package/src/types/create.three.d.ts +87 -7
  14. package/src/types/hydra.d.ts +7 -5
  15. package/src/types/plugins.d.ts +7 -0
  16. package/src/types/usd-core-bindings.d.ts +240 -0
  17. package/src/utils.js +3 -3
  18. package/src/vite/index.js +13 -1
  19. package/examples/index.html +0 -58
  20. package/examples/package-lock.json +0 -1548
  21. package/examples/package.json +0 -24
  22. package/examples/public/HttpReferences copy.usda +0 -46
  23. package/examples/public/HttpReferences.usda +0 -44
  24. package/examples/public/gingerbread/GingerbreadHouse.usda +0 -35
  25. package/examples/public/gingerbread/house/GingerBreadHouse.usdc +0 -0
  26. package/examples/public/gingerbread/house/textures/color.jpg +0 -0
  27. package/examples/public/gingerbread/house/textures/metallic_roughness.jpg +0 -0
  28. package/examples/public/gingerbread/house/textures/normal.jpg +0 -0
  29. package/examples/public/gingerbread/snowman/Snowman.usdc +0 -0
  30. package/examples/public/gingerbread/snowman/textures/color.jpg +0 -0
  31. package/examples/public/gingerbread/snowman/textures/metallic_roughness.jpg +0 -0
  32. package/examples/public/gingerbread/snowman/textures/normal.jpg +0 -0
  33. package/examples/public/test.usdz +0 -0
  34. package/examples/public/vite.svg +0 -1
  35. package/examples/src/fileHandling.ts +0 -256
  36. package/examples/src/main.ts +0 -167
  37. package/examples/src/three.ts +0 -140
  38. package/examples/src/vite-env.d.ts +0 -1
  39. package/examples/tsconfig.json +0 -23
  40. package/examples/vite.config.js +0 -21
  41. package/src/bindings/emHdBindings.data +0 -19331
  42. package/src/bindings/emHdBindings.worker.js +0 -124
package/CHANGELOG.md CHANGED
@@ -4,5 +4,40 @@ All notable changes to this package will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.0.0-next.1] - 2026-06-29
8
+ ### Added
9
+ - Added optional material readiness policy support for loaders that need to wait for asynchronous material generation and texture loading before reporting completion.
10
+ - Added matrix coverage for USD Working Group assets, Needle Engine runtime shapes, public viewer lifecycle cleanup, authored USD concepts, and culling/material edge cases.
11
+
12
+ ### Changed
13
+ - Improved the existing Needle Engine integration so the Engine loader/component path uses the updated USD runtime, readiness, and cleanup behavior alongside the direct three.js Hydra path.
14
+ - Updated the public viewer examples so original glTF samples use the regular glTF loader path instead of wrapping glTF assets in USD.
15
+
16
+ ### Fixed
17
+ - Fixed Hydra lifecycle cleanup when switching assets so stale RPrim/SPrim state and three.js resources are destroyed instead of accumulating across loads.
18
+ - Addressed repeated-load resource leaks that could cause out-of-memory failures after cycling between large USDZ assets.
19
+ - Improved browser asset resolution for nested package paths, authored relative paths, parent-directory references, USDZ-embedded textures, GLB-embedded texture assets, and MaterialX texture assets.
20
+ - Fixed known MaterialX and UsdPreviewSurface texture regressions, including separate metallic/roughness/occlusion maps, packed texture updates after async loads, texture transforms, procedural texture fixtures, and noise/bricks sample coverage.
21
+ - Fixed material culling so materials are only cloned when the same authored material is used with conflicting sidedness, preserving animation bindings for the common shared-material path.
22
+ - Fixed USD-authored normals/interpolation handling to better match OpenUSD/usdview flat-vs-smooth behavior.
23
+ - Fixed single-sided/double-sided rendering for USD meshes and added shared-material culling tests.
24
+ - Fixed variant and payload switching so old selections are removed instead of double-rendering alongside the new composed result.
25
+ - Fixed up-axis setup before the first Hydra draw and across repeated stage loads so one asset cannot leak orientation state into the next.
26
+ - Fixed camera/light SPrim routing and expanded coverage for visibility, purpose switching, native instances, point instancers, and nested package references.
27
+ - Fixed Needle Engine loader timing and readiness so USD stages, materials, and animations initialize consistently through the Engine loader path.
28
+ - Fixed three.js/Needle Engine import compatibility across vanilla three.js and Engine-provided three.js runtime mappings.
29
+ - Fixed animated HTTP/USD package loads so playback time updates cannot dirty Hydra while an async initial draw is still in progress.
30
+
31
+ ## [1.0.0-next.0] - 2026-06-25
32
+ - Modernized the wasm runtime to upstream OpenUSD 26.05 with Hydra imaging enabled for the three.js render delegate.
33
+ - Added the Adobe glTF file-format plugin, MaterialX support through Hydra material documents, and OpenSubdiv-enabled builds.
34
+ - Added generated TypeScript declarations and usdview-style inspection/change APIs for programmatic stage interaction.
35
+ - Switched the client MaterialX shader path to `@needle-tools/materialx@1.7.0`.
36
+ - Added explicit package entrypoints for `@needle-tools/usd/three`, `@needle-tools/usd/plugins`, and `@needle-tools/usd/vite`.
37
+ - Added a Needle Engine browser matrix that validates the USD package through Engine `dist` and package-module runtime shapes.
38
+ - Added a technical demo render-host switch for viewing the same USD samples through plain three.js or a Needle Engine `Context`.
39
+ - Read stage metadata from the live `UsdStage` API so up-axis state remains stable across referenced asset reloads.
40
+ - Changed the license to PolyForm Noncommercial 1.0.0.
41
+
7
42
  ## [0.0.1-alpha] - 2025-05-14
8
- - initial release
43
+ - initial release
package/README.md CHANGED
@@ -1,51 +1,269 @@
1
1
  # Needle USD
2
2
 
3
- USD wasm runtime and three.js hydra delegate.
4
- Developed & maintained by [Needle](https://needle.tools)
5
- For commercial use please contact hi@needle.tools
3
+ USD wasm runtime and three.js Hydra delegate.
4
+ Developed & maintained by [Needle](https://needle.tools).
5
+
6
+ For commercial use, please contact [hi@needle.tools](mailto:hi@needle.tools).
6
7
 
7
8
  ## Install
8
- `npm install @needle-tools/usd`
9
9
 
10
+ ```sh
11
+ npm install @needle-tools/usd@1.0.0 three
12
+ ```
10
13
 
14
+ Version 1.0 uses upstream OpenUSD 26.05 and ships a Hydra imaging bridge for
15
+ three.js. The wasm bundle includes Adobe `usdGltf`, MaterialX, and OpenSubdiv
16
+ support.
11
17
 
12
- ## Use with Needle Engine
18
+ ## Runtime Requirements
13
19
 
20
+ This package ships a threaded Emscripten/OpenUSD wasm build. Browser pages that
21
+ use it must be served in a cross-origin isolated context so `SharedArrayBuffer`
22
+ and pthread workers are available:
14
23
 
15
- ```ts
16
- import { get } from "svelte/store";
17
- import { activeFiles } from "..";
18
- import { addPluginForNeedleEngine } from "@needle-tools/usd/plugins";
24
+ ```js
25
+ res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
26
+ res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
27
+ ```
28
+
29
+ For Vite projects, use the package plugin to set these headers during local
30
+ development:
31
+
32
+ ```js
33
+ import { needleUSD } from "@needle-tools/usd/vite";
34
+
35
+ export default {
36
+ plugins: [needleUSD()],
37
+ };
38
+ ```
39
+
40
+ The modern Emscripten output contains `emHdBindings.js` and
41
+ `emHdBindings.wasm`. It does not ship a separate `emHdBindings.worker.js`; the
42
+ pthread workers load the main generated JavaScript entrypoint directly.
43
+
44
+ ## Minimal Examples
19
45
 
20
- export function addUsdPlugin() {
21
- return addPluginForNeedleEngine({
22
- // USD files to load (first file must be the main file)
23
- getFiles: () => { return get(activeFiles) as Array<File & { path: string }> }
24
- })
46
+ All browser examples must be served with the COOP/COEP headers from
47
+ ["Runtime Requirements"](#runtime-requirements). The import-map examples use
48
+ same-origin `/vendor/...` URLs so the threaded wasm worker can load the
49
+ Emscripten JavaScript from the page origin; replace those URLs with your own
50
+ served package paths.
51
+
52
+ ### three.js With Import Map
53
+
54
+ `index.html`
55
+
56
+ ```html
57
+ <!doctype html>
58
+ <html>
59
+ <body style="margin:0">
60
+ <script type="importmap">
61
+ {
62
+ "imports": {
63
+ "three": "/vendor/three/build/three.module.js",
64
+ "three/addons/": "/vendor/three/examples/jsm/",
65
+ "@needle-tools/materialx": "/vendor/@needle-tools/materialx/index.js",
66
+ "@needle-tools/usd": "/vendor/@needle-tools/usd/src/index.js",
67
+ "@needle-tools/usd/three": "/vendor/@needle-tools/usd/src/create.three.js"
68
+ }
69
+ }
70
+ </script>
71
+ <script type="module">
72
+ import * as THREE from "three";
73
+ import { getUsdModule } from "@needle-tools/usd";
74
+ import { createThreeHydra } from "@needle-tools/usd/three";
75
+
76
+ const scene = new THREE.Scene();
77
+ const camera = new THREE.PerspectiveCamera(45, innerWidth / innerHeight, 0.01, 1000);
78
+ camera.position.set(0, 1.5, 4);
79
+
80
+ const renderer = new THREE.WebGLRenderer({ antialias: true });
81
+ renderer.setSize(innerWidth, innerHeight);
82
+ document.body.append(renderer.domElement);
83
+
84
+ const usd = await getUsdModule();
85
+ const handle = await createThreeHydra({
86
+ USD: usd,
87
+ scene,
88
+ url: "./model.usdz"
89
+ });
90
+ await handle.ready();
91
+ // By default ready() waits for the stage and first Hydra draw, but not for
92
+ // async material generation. Pass waitForMaterials: true when correctness
93
+ // requires a material/texture barrier, or await handle.materialsReady().
94
+
95
+ let last = performance.now();
96
+ renderer.setAnimationLoop((time) => {
97
+ const dt = (time - last) / 1000;
98
+ last = time;
99
+ handle.update(dt);
100
+ renderer.render(scene, camera);
101
+ });
102
+ </script>
103
+ </body>
104
+ </html>
105
+ ```
106
+
107
+ ### three.js With Package Install
108
+
109
+ `package.json`
110
+
111
+ ```json
112
+ {
113
+ "type": "module",
114
+ "scripts": {
115
+ "dev": "vite --host 127.0.0.1"
116
+ },
117
+ "dependencies": {
118
+ "@needle-tools/usd": "1.0.0",
119
+ "three": "^0.185.0",
120
+ "vite": "^8.1.0"
121
+ }
25
122
  }
26
123
  ```
27
124
 
125
+ `index.html`
126
+
127
+ ```html
128
+ <!doctype html>
129
+ <html>
130
+ <body style="margin:0">
131
+ <script type="module">
132
+ import * as THREE from "three";
133
+ import { getUsdModule } from "@needle-tools/usd";
134
+ import { createThreeHydra } from "@needle-tools/usd/three";
28
135
 
29
- ### Use with other three.js based viewers
136
+ const scene = new THREE.Scene();
137
+ const camera = new THREE.PerspectiveCamera(45, innerWidth / innerHeight, 0.01, 1000);
138
+ camera.position.set(0, 1.5, 4);
30
139
 
140
+ const renderer = new THREE.WebGLRenderer({ antialias: true });
141
+ renderer.setSize(innerWidth, innerHeight);
142
+ document.body.append(renderer.domElement);
31
143
 
32
- See full example in [examples](./examples/src/main.ts)
144
+ const usd = await getUsdModule();
145
+ const handle = await createThreeHydra({
146
+ USD: usd,
147
+ scene,
148
+ url: "./model.usdz"
149
+ });
150
+ await handle.ready();
151
+
152
+ let last = performance.now();
153
+ renderer.setAnimationLoop((time) => {
154
+ const dt = (time - last) / 1000;
155
+ last = time;
156
+ handle.update(dt);
157
+ renderer.render(scene, camera);
158
+ });
159
+ </script>
160
+ </body>
161
+ </html>
162
+ ```
163
+
164
+ For Vite projects, add the `needleUSD()` plugin shown above so dev serving uses
165
+ the required COOP/COEP headers.
166
+
167
+ ### Needle Engine With Import Map
168
+
169
+ `index.html`
170
+
171
+ ```html
172
+ <!doctype html>
173
+ <html>
174
+ <body style="margin:0">
175
+ <script type="importmap">
176
+ {
177
+ "imports": {
178
+ "three": "/vendor/@needle-tools/engine/dist/three.min.js",
179
+ "three/addons/": "/vendor/@needle-tools/three/examples/jsm/",
180
+ "@needle-tools/engine": "/vendor/@needle-tools/engine/dist/needle-engine.min.js",
181
+ "@needle-tools/materialx": "/vendor/@needle-tools/materialx/index.js",
182
+ "@needle-tools/usd": "/vendor/@needle-tools/usd/src/index.js",
183
+ "@needle-tools/usd/three": "/vendor/@needle-tools/usd/src/create.three.js",
184
+ "@needle-tools/usd/plugins": "/vendor/@needle-tools/usd/src/plugins/index.js"
185
+ }
186
+ }
187
+ </script>
188
+ <script type="module">
189
+ import "@needle-tools/engine";
190
+ import { addPluginForNeedleEngine } from "@needle-tools/usd/plugins";
191
+
192
+ await addPluginForNeedleEngine({
193
+ // Defaults to non-blocking materials. Set waitForMaterials: true if the
194
+ // Needle loader should not report ready until materials/textures settle.
195
+ getFiles: () => []
196
+ });
197
+
198
+ document.body.insertAdjacentHTML(
199
+ "beforeend",
200
+ '<needle-engine src="./model.usdz" camera-controls contactshadows="0.7"></needle-engine>'
201
+ );
202
+ </script>
203
+ </body>
204
+ </html>
205
+ ```
206
+
207
+ ### Needle Engine With Package Install
208
+
209
+ `package.json`
210
+
211
+ ```json
212
+ {
213
+ "type": "module",
214
+ "scripts": {
215
+ "dev": "vite --host 127.0.0.1"
216
+ },
217
+ "dependencies": {
218
+ "@needle-tools/engine": "^5.1.2",
219
+ "@needle-tools/usd": "1.0.0",
220
+ "three": "npm:@needle-tools/three@^0.169.19",
221
+ "vite": "^8.1.0"
222
+ }
223
+ }
224
+ ```
225
+
226
+ `index.html`
227
+
228
+ ```html
229
+ <!doctype html>
230
+ <html>
231
+ <body style="margin:0">
232
+ <script type="module">
233
+ import "@needle-tools/engine";
234
+ import { addPluginForNeedleEngine } from "@needle-tools/usd/plugins";
235
+
236
+ await addPluginForNeedleEngine({
237
+ // Defaults to non-blocking materials. Set waitForMaterials: true if the
238
+ // Needle loader should not report ready until materials/textures settle.
239
+ getFiles: () => []
240
+ });
241
+
242
+ document.body.insertAdjacentHTML(
243
+ "beforeend",
244
+ '<needle-engine src="./model.usdz" camera-controls contactshadows="0.7"></needle-engine>'
245
+ );
246
+ </script>
247
+ </body>
248
+ </html>
249
+ ```
250
+
251
+ For folder/drop workflows, return the active file set from `getFiles()`. The
252
+ first file must be the root USD file, and each file should have a stable `path`
253
+ property so USD references can resolve.
254
+
255
+ ## Public Entrypoints
33
256
 
34
257
  ```js
35
- // Load the USD module
36
- const usd = await getUsdModule();
37
- // Load a USD file to be rendered by threejs
38
- const handle = await createThreeHydra({
39
- USD: usd,
40
- scene: ctx.scene,
41
- usdz: "http://localhost:8081/v1/public/89aa693/89aa693/ImageTrackingNeedleSample.usdz",
42
- })
43
- // Call handle.update(dt) in your threejs update loop
258
+ import { getUsdModule, loadOpenUsdBuildInfo } from "@needle-tools/usd";
259
+ import { createThreeHydra } from "@needle-tools/usd/three";
260
+ import { addPluginForNeedleEngine } from "@needle-tools/usd/plugins";
261
+ import { needleUSD } from "@needle-tools/usd/vite";
44
262
  ```
45
263
 
46
264
 
47
265
 
48
- ## Low Level
266
+ ## Low Level Usage
49
267
 
50
268
  ### Import
51
269
  ```js
@@ -85,7 +303,7 @@ driver.Draw();
85
303
 
86
304
  ## Useful References
87
305
 
88
- Uses Asyncify to handle async calls in emscripten.
306
+ Uses `Asyncify` to handle async calls in emscripten.
89
307
  > A synchronous call in C that waits for an asynchronous operation in JS to complete.
90
308
  https://emscripten.org/docs/porting/asyncify.html
91
309
 
@@ -97,4 +315,3 @@ https://emscripten.org/docs/porting/asyncify.html
97
315
  [Discord](https://discord.needle.tools) •
98
316
  [Forum](https://forum.needle.tools) •
99
317
  [Youtube](https://www.youtube.com/@needle-tools)
100
-
package/package.json CHANGED
@@ -1,20 +1,32 @@
1
1
  {
2
2
  "name": "@needle-tools/usd",
3
- "version": "0.0.2-next.de2e82b",
3
+ "version": "1.0.0-next.52b4773",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {
9
- "import": "./src/index.js",
10
- "require": "./src/index.cjs"
9
+ "types": "./src/index.d.ts",
10
+ "import": "./src/index.js"
11
+ },
12
+ "./three": {
13
+ "types": "./src/types/create.three.d.ts",
14
+ "import": "./src/create.three.js"
11
15
  },
12
16
  "./plugins": {
13
- "import": "./src/plugins/index.js",
14
- "require": "./src/plugins/index.cjs",
15
- "types": "./src/types/plugins.d.ts"
17
+ "types": "./src/types/plugins.d.ts",
18
+ "import": "./src/plugins/index.js"
19
+ },
20
+ "./vite": {
21
+ "types": "./src/types/vite.d.ts",
22
+ "import": "./src/vite/index.js"
16
23
  }
17
24
  },
25
+ "files": [
26
+ "src",
27
+ "README.md",
28
+ "CHANGELOG.md"
29
+ ],
18
30
  "keywords": [
19
31
  "needle",
20
32
  "usd",
@@ -23,6 +35,7 @@
23
35
  "webgl"
24
36
  ],
25
37
  "homepage": "https://needle.tools",
38
+ "license": "PolyForm-Noncommercial-1.0.0",
26
39
  "author": {
27
40
  "name": "Needle",
28
41
  "email": "hi@needle.tools",
@@ -36,15 +49,38 @@
36
49
  "url": "https://github.com/needle-tools/usd-viewer/issues"
37
50
  },
38
51
  "peerDependencies": {
39
- "three": "^0.164.1",
40
- "@needle-tools/engine": ">= 4.6.0-0"
52
+ "@needle-tools/engine": ">=5.0.0",
53
+ "three": ">=0.160.0"
54
+ },
55
+ "peerDependenciesMeta": {
56
+ "@needle-tools/engine": {
57
+ "optional": true
58
+ }
59
+ },
60
+ "scripts": {
61
+ "needle-engine-matrix:cache": "node scripts/cache-needle-engine-matrix.mjs",
62
+ "three-matrix:cache": "node scripts/cache-three-matrix.mjs",
63
+ "test:bindings": "node --test tests/bindings/*.test.mjs",
64
+ "test:needle-engine-matrix": "npm run needle-engine-matrix:cache && playwright test -c tests/needle-engine-matrix/playwright.config.ts",
65
+ "test:public-viewer-lifecycle": "playwright test -c tests/public-viewer/playwright.config.ts",
66
+ "test:three-matrix": "node scripts/run-three-matrix.mjs",
67
+ "test:viewer-visual": "playwright test -c tests/viewer-visual/playwright.config.ts"
41
68
  },
42
69
  "devDependencies": {
43
- "vite": "^5.2.13",
44
- "@types/three": "^0.164.1"
70
+ "@needle-tools/engine": "^5.1.2-canary.1782735768.reasonable-ramen.4c74c99",
71
+ "@needle-tools/three-test-matrix": "^0.1.0",
72
+ "@playwright/test": "^1.60.0",
73
+ "@types/three": "^0.164.1",
74
+ "vite": "^8.1.0"
45
75
  },
46
76
  "publishConfig": {
47
77
  "access": "public",
48
78
  "registry": "https://registry.npmjs.org/"
79
+ },
80
+ "dependencies": {
81
+ "@needle-tools/materialx": "1.7.0-next.57183d6"
82
+ },
83
+ "overrides": {
84
+ "@needle-tools/materialx": "1.7.0-next.57183d6"
49
85
  }
50
86
  }