@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
@@ -0,0 +1,240 @@
1
+ // Generated by pxr/usdImaging/hdEmscripten/bindgen/generate_bindings.py.
2
+ // Do not edit by hand; edit bindgen/core-bindings.json instead.
3
+
4
+ declare type MaybePromise<T> = T | Promise<T>
5
+
6
+ declare type IntVector = {
7
+ size(): number,
8
+ get(index: number): number,
9
+ delete(): void,
10
+ }
11
+
12
+ declare type DoubleVector = {
13
+ size(): number,
14
+ get(index: number): number,
15
+ delete(): void,
16
+ }
17
+
18
+ declare type StringVector = {
19
+ size(): number,
20
+ get(index: number): string,
21
+ delete(): void,
22
+ }
23
+
24
+ declare type USDPrimVector = {
25
+ size(): number,
26
+ get(index: number): USDPrim,
27
+ delete(): void,
28
+ }
29
+
30
+ declare type USDAttributeVector = {
31
+ size(): number,
32
+ get(index: number): USDAttribute,
33
+ delete(): void,
34
+ }
35
+
36
+ declare type USDRelationshipVector = {
37
+ size(): number,
38
+ get(index: number): USDRelationship,
39
+ delete(): void,
40
+ }
41
+
42
+ declare type USDLayerOffset = {
43
+ offset: number,
44
+ scale: number,
45
+ isIdentity: boolean,
46
+ }
47
+
48
+ declare type USDLayerInfo = {
49
+ identifier: string,
50
+ displayName: string,
51
+ realPath: string,
52
+ }
53
+
54
+ declare type USDSpecStackEntry = {
55
+ path: string,
56
+ layer: USDLayerInfo,
57
+ layerOffset?: USDLayerOffset,
58
+ metadata: Record<string, string>,
59
+ specifier?: string,
60
+ typeName?: string,
61
+ name?: string,
62
+ }
63
+
64
+ declare type USDSpecStack = USDSpecStackEntry[]
65
+
66
+ declare type USDResolveInfo = {
67
+ source: "None" | "Fallback" | "Default" | "TimeSamples" | "ValueClips" | "Spline" | "Unknown",
68
+ hasAuthoredValueOpinion: boolean,
69
+ hasAuthoredValue: boolean,
70
+ valueIsBlocked: boolean,
71
+ valueSourceMightBeTimeVarying: boolean,
72
+ hasNextWeakerInfo: boolean,
73
+ }
74
+
75
+ declare type USDPcpNode = {
76
+ arcType?: string,
77
+ path?: string,
78
+ pathAtIntroduction?: string,
79
+ layerStackIdentifier?: string,
80
+ children?: USDPcpNode[],
81
+ }
82
+
83
+ declare type USDPrimIndex = {
84
+ isValid: boolean,
85
+ rootNode?: USDPcpNode,
86
+ }
87
+
88
+ declare type USDCompositionArc = {
89
+ arcType: string,
90
+ targetLayer: USDLayerInfo,
91
+ targetPrimPath: string,
92
+ introducingLayer: USDLayerInfo,
93
+ introducingPrimPath: string,
94
+ isImplicit: boolean,
95
+ isAncestral: boolean,
96
+ hasSpecs: boolean,
97
+ isIntroducedInRootLayerStack: boolean,
98
+ isIntroducedInRootLayerPrimSpec: boolean,
99
+ }
100
+
101
+ declare type USDObjectsChangedNotice = {
102
+ resyncedPaths: string[],
103
+ changedInfoOnlyPaths: string[],
104
+ resolvedAssetPathsResyncedPaths: string[],
105
+ changedFields: Record<string, string[]>,
106
+ }
107
+
108
+ declare type USDLayer = {
109
+ GetIdentifier(): string,
110
+ GetDisplayName(): string,
111
+ GetRealPath(): string,
112
+ ExportToString(): string,
113
+ Export(path: string): boolean,
114
+ Save(): boolean,
115
+ }
116
+
117
+ declare type USDAttribute = {
118
+ IsValid(): boolean,
119
+ GetName(): string,
120
+ GetPath(): string,
121
+ GetTypeName(): string,
122
+ GetAllMetadata(): Record<string, string>,
123
+ GetMetadataString(key: string): string,
124
+ HasAuthoredMetadata(key: string): boolean,
125
+ GetValueString(): string,
126
+ GetValueStringAtTime(timeCode: number): string,
127
+ GetConnections(): StringVector,
128
+ GetResolveInfo(timeCode: number): USDResolveInfo,
129
+ HasAuthoredValue(): boolean,
130
+ HasAuthoredValueOpinion(): boolean,
131
+ GetNumTimeSamples(): number,
132
+ GetTimeSamples(): DoubleVector,
133
+ GetPropertyStack(timeCode: number): USDSpecStack,
134
+ GetPropertyStackWithLayerOffsets(timeCode: number): USDSpecStack,
135
+ SetBool(value: boolean, timeCode: number): boolean,
136
+ SetInt(value: number, timeCode: number): boolean,
137
+ SetFloat(value: number, timeCode: number): boolean,
138
+ SetDouble(value: number, timeCode: number): boolean,
139
+ SetString(value: string, timeCode: number): boolean,
140
+ SetToken(value: string, timeCode: number): boolean,
141
+ AddConnection(path: string): boolean,
142
+ SetColor3f(r: number, g: number, b: number, timeCode: number): boolean,
143
+ SetVec3f(x: number, y: number, z: number, timeCode: number): boolean,
144
+ SetVec3d(x: number, y: number, z: number, timeCode: number): boolean,
145
+ SetMatrix4d(m00: number, m01: number, m02: number, m03: number, m10: number, m11: number, m12: number, m13: number, m20: number, m21: number, m22: number, m23: number, m30: number, m31: number, m32: number, m33: number, timeCode: number): boolean,
146
+ }
147
+
148
+ declare type USDRelationship = {
149
+ IsValid(): boolean,
150
+ GetName(): string,
151
+ GetPath(): string,
152
+ GetAllMetadata(): Record<string, string>,
153
+ GetMetadataString(key: string): string,
154
+ HasAuthoredMetadata(key: string): boolean,
155
+ GetPropertyStack(timeCode: number): USDSpecStack,
156
+ GetPropertyStackWithLayerOffsets(timeCode: number): USDSpecStack,
157
+ GetTargets(): StringVector,
158
+ AddTarget(path: string): boolean,
159
+ ClearTargets(removeSpec: boolean): boolean,
160
+ }
161
+
162
+ declare type USDPrim = {
163
+ IsValid(): boolean,
164
+ GetName(): string,
165
+ GetPath(): string,
166
+ GetTypeName(): string,
167
+ GetDisplayName(): string,
168
+ GetAllMetadata(): Record<string, string>,
169
+ GetMetadataString(key: string): string,
170
+ HasAuthoredMetadata(key: string): boolean,
171
+ GetSpecifier(): string,
172
+ IsActive(): boolean,
173
+ SetActive(active: boolean): boolean,
174
+ ApplyAPI(schemaIdentifier: string): boolean,
175
+ IsDefined(): boolean,
176
+ IsAbstract(): boolean,
177
+ IsInstance(): boolean,
178
+ IsInPrototype(): boolean,
179
+ IsPrototype(): boolean,
180
+ IsLoaded(): boolean,
181
+ HasAuthoredPayloads(): boolean,
182
+ HasAuthoredReferences(): boolean,
183
+ HasAuthoredInherits(): boolean,
184
+ HasAuthoredSpecializes(): boolean,
185
+ HasAuthoredInstanceable(): boolean,
186
+ Load(): MaybePromise<void>,
187
+ Unload(): MaybePromise<void>,
188
+ AddPayload(assetPath: string, primPath: string): boolean,
189
+ GetParent(): USDPrim,
190
+ GetChildren(): USDPrimVector,
191
+ GetAttributes(): USDAttributeVector,
192
+ GetRelationships(): USDRelationshipVector,
193
+ GetPropertyNames(): StringVector,
194
+ GetPrimStack(): USDSpecStack,
195
+ GetPrimStackWithLayerOffsets(): USDSpecStack,
196
+ GetPrimIndex(): USDPrimIndex,
197
+ GetCompositionArcs(): USDCompositionArc[],
198
+ GetAttribute(name: string): USDAttribute,
199
+ CreateAttribute(name: string, typeName: string, custom: boolean): USDAttribute,
200
+ GetRelationship(name: string): USDRelationship,
201
+ CreateRelationship(name: string, custom: boolean): USDRelationship,
202
+ AddVariant(variantSetName: string, variantName: string): boolean,
203
+ SetVariantSelection(variantSetName: string, variantName: string): MaybePromise<boolean>,
204
+ GetVariantSelection(variantSetName: string): string,
205
+ ClearVariantSelection(variantSetName: string): boolean,
206
+ BlockVariantSelection(variantSetName: string): boolean,
207
+ GetVariantSetNames(): StringVector,
208
+ GetVariantNames(variantSetName: string): StringVector,
209
+ DefinePrimInVariant(variantSetName: string, variantName: string, path: string, typeName: string): USDPrim,
210
+ }
211
+
212
+ declare type USDStage = {
213
+ GetRootLayer(): USDLayer,
214
+ GetPseudoRoot(): USDPrim,
215
+ GetPrimAtPath(path: string): USDPrim,
216
+ DefinePrim(path: string, typeName: string): USDPrim,
217
+ Traverse(): USDPrimVector,
218
+ TraverseAll(): USDPrimVector,
219
+ GetLayerStack(includeSessionLayers: boolean): USDLayerInfo[],
220
+ GetUsedLayers(includeClipLayers: boolean): USDLayerInfo[],
221
+ GetCompositionErrors(): string[],
222
+ RegisterObjectsChanged(callback: (notice: USDObjectsChangedNotice) => void): number,
223
+ RevokeObjectsChanged(listenerId: number): boolean,
224
+ GetStartTimeCode(): number,
225
+ GetEndTimeCode(): number,
226
+ GetTimeCodesPerSecond(): number,
227
+ SetStartTimeCode(timeCode: number): void,
228
+ SetEndTimeCode(timeCode: number): void,
229
+ SetTimeCodesPerSecond(timeCodesPerSecond: number): void,
230
+ GetUpAxis(): number,
231
+ SetUpAxis(upAxis: string): boolean,
232
+ Export(path: string): boolean,
233
+ ExportToString(): string,
234
+ }
235
+
236
+ declare function CreateStage(path: string): USDStage
237
+ declare function OpenStage(path: string): MaybePromise<USDStage>
238
+ declare function ReleaseStage(stage: USDStage): boolean
239
+ declare function CreateUsdzPackage(assetPath: string, usdzPath: string): MaybePromise<boolean>
240
+ declare function ReadFile(path: string): Uint8Array
package/src/utils.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  /**
4
4
  * @param {ArrayBuffer} buffer
5
- * @returns {"usdz" | "usd" | "usda" | "unknown"}
5
+ * @returns {"usdz" | "usd" | "usda" | "usdc" | "unknown"}
6
6
  */
7
7
  export function tryDetermineFileFormat(buffer) {
8
8
 
@@ -14,11 +14,11 @@ export function tryDetermineFileFormat(buffer) {
14
14
  }
15
15
  // USD
16
16
  if (bytes[0] == 80 && bytes[1] == 88 && bytes[2] == 82 && bytes[3] == 45 && bytes[4] == 85 && bytes[5] == 83 && bytes[6] == 68 && bytes[7] == 67) {
17
- return "usd";
17
+ return "usdc";
18
18
  }
19
19
  if (bytes[0] === 35 && bytes[1] === 117 && bytes[2] === 115 && bytes[3] === 100) {
20
20
  return "usda";
21
21
  }
22
22
 
23
23
  return "unknown";
24
- }
24
+ }
package/src/vite/index.js CHANGED
@@ -1,7 +1,19 @@
1
+ const packageRoot = decodeURIComponent(new URL('../..', import.meta.url).pathname);
1
2
 
2
3
  /** @type {import('vite').Plugin} */
3
4
  const crossOriginIsolatedPlugin = {
4
5
  name: 'needle:usd-crossoriginisolated',
6
+ config: (config) => {
7
+ const cwd = typeof process !== 'undefined' && process.cwd ? process.cwd() : '/';
8
+ const allow = config.server?.fs?.allow ?? [cwd];
9
+ return {
10
+ server: {
11
+ fs: {
12
+ allow: [...new Set([...allow, packageRoot])],
13
+ },
14
+ },
15
+ };
16
+ },
5
17
  configureServer: (server) => {
6
18
  server.middlewares.use((_req, res, next) => {
7
19
  res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
@@ -19,4 +31,4 @@ const crossOriginIsolatedPlugin = {
19
31
  */
20
32
  export function needleUSD() {
21
33
  return [crossOriginIsolatedPlugin]
22
- }
34
+ }
@@ -1,58 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
7
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
- <title>Vite + TS</title>
9
- <style>
10
- body {
11
- margin: 0;
12
- padding: 0;
13
- }
14
- canvas {
15
- position: absolute;
16
- left: 0;
17
- top: 0;
18
- right: 0;
19
- bottom: 0;
20
- }
21
- .test-buttons {
22
- position: absolute;
23
- top: 0;
24
- left: 0;
25
- padding: 10px;
26
- background-color: rgba(0,0,0,0.5);
27
- color: white;
28
- z-index: 1000;
29
- }
30
-
31
- .test-buttons button {
32
- margin: 3px;
33
- color: white;
34
- background-color: rgb(63, 107, 18);
35
- border: none;
36
- outline: none;
37
- border-radius: 10px;
38
- cursor: pointer;
39
- padding: 3px 8px;
40
- }
41
-
42
- .test-buttons button:hover {
43
- background-color: rgba(224, 224, 224, 0.8);
44
- color: black;
45
- }
46
-
47
- .options button {
48
- background-color: rgb(75, 75, 75);
49
- }
50
- </style>
51
- </head>
52
-
53
- <body>
54
- <div id="app"></div>
55
- <script type="module" src="./src/main.ts"></script>
56
- </body>
57
-
58
- </html>