@openusd-wasm/three-loader 0.0.2 → 0.0.3
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 +12 -0
- package/dist/openusd_three_loader.d.ts +7 -27
- package/dist/openusd_three_loader.js +387 -846
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -74,6 +74,18 @@ When the entry layer references a known asset root, such as `resource/` or
|
|
|
74
74
|
pass `files` to `parseAsync` for explicit virtual filesystem entries, or set
|
|
75
75
|
`autoResolveAssets: false` to disable this behavior.
|
|
76
76
|
|
|
77
|
+
When generating USDA files that reference assets written next to the layer, use
|
|
78
|
+
`toLayerRelativeAssetPath` before authoring the reference. OpenUSD treats
|
|
79
|
+
`@assets/model.usdz@` as a search-path asset, while `@./assets/model.usdz@`
|
|
80
|
+
is anchored to the current layer directory and packages without transient
|
|
81
|
+
`0/model.usdz` remap warnings.
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { toLayerRelativeAssetPath } from '@openusd-wasm/utils'
|
|
85
|
+
|
|
86
|
+
refs.AddReference(toLayerRelativeAssetPath('assets/gearbox.usdz'), '')
|
|
87
|
+
```
|
|
88
|
+
|
|
77
89
|
## Textures
|
|
78
90
|
|
|
79
91
|
USD asset paths do not always map directly to browser URLs. The loader creates
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Pxr } from "@openusd-wasm/pxr";
|
|
2
2
|
import * as THREE from "three";
|
|
3
3
|
import { Loader, LoadingManager } from "three";
|
|
4
|
+
import { USDAssetValue, USDTextureResolver as USDTextureResolver$1, USDTextureResolverContext as USDTextureResolverContext$1 } from "@openusd-wasm/utils";
|
|
4
5
|
|
|
5
6
|
//#region src/types.d.ts
|
|
6
7
|
type USDSourceInput = string | ArrayBuffer | ArrayBufferView | Blob;
|
|
@@ -13,9 +14,9 @@ interface USDStageInfo {
|
|
|
13
14
|
rootLayerIdentifier: string;
|
|
14
15
|
defaultPrim: string | null;
|
|
15
16
|
upAxis: string;
|
|
16
|
-
startTimeCode
|
|
17
|
-
endTimeCode
|
|
18
|
-
timeCodesPerSecond
|
|
17
|
+
startTimeCode: number;
|
|
18
|
+
endTimeCode: number;
|
|
19
|
+
timeCodesPerSecond: number;
|
|
19
20
|
}
|
|
20
21
|
interface USDViewPrim {
|
|
21
22
|
path: string;
|
|
@@ -110,17 +111,8 @@ interface ExtractUSDModelDataOptions {
|
|
|
110
111
|
sourcePath?: string;
|
|
111
112
|
rootLayerIdentifier?: string;
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
material?: USDMaterialInfo;
|
|
116
|
-
shader?: USDShaderInfo;
|
|
117
|
-
}
|
|
118
|
-
interface USDAssetValue {
|
|
119
|
-
path?: string;
|
|
120
|
-
resolvedPath?: string;
|
|
121
|
-
url?: string;
|
|
122
|
-
}
|
|
123
|
-
type USDTextureResolver = (asset: USDAssetValue, context: USDTextureResolverContext) => string | null | undefined;
|
|
114
|
+
type USDTextureResolverContext = USDTextureResolverContext$1<USDMaterialInfo, USDShaderInfo>;
|
|
115
|
+
type USDTextureResolver = USDTextureResolver$1<USDMaterialInfo, USDShaderInfo>;
|
|
124
116
|
interface BuildUSDObjectOptions {
|
|
125
117
|
sourcePath?: string;
|
|
126
118
|
convertZUp?: boolean;
|
|
@@ -233,18 +225,6 @@ declare class USDManipulationControls {
|
|
|
233
225
|
private restoreHighlight;
|
|
234
226
|
}
|
|
235
227
|
//#endregion
|
|
236
|
-
//#region src/asset-resolver.d.ts
|
|
237
|
-
declare function autoResolveAssetFiles(rootData: Uint8Array, options: USDLoaderParseOptions): Promise<Record<string, Uint8Array>>;
|
|
238
|
-
declare function autoResolveTextureFiles(metadata: USDModelData, existingFiles: Record<string, Uint8Array>, options: USDLoaderParseOptions): Promise<Record<string, Uint8Array>>;
|
|
239
|
-
declare function createTextureResolverFromEntries(entries: Map<string, Uint8Array>): {
|
|
240
|
-
resolve: USDTextureResolver;
|
|
241
|
-
urls: Map<string, string>;
|
|
242
|
-
} | null;
|
|
243
|
-
declare function createPackageTextureResolver(data: Uint8Array): {
|
|
244
|
-
resolve: USDTextureResolver;
|
|
245
|
-
urls: Map<string, string>;
|
|
246
|
-
} | null;
|
|
247
|
-
//#endregion
|
|
248
228
|
//#region src/metadata.d.ts
|
|
249
229
|
declare function extractUSDModelData(pxr: Pxr, stage: PxrObject, options?: ExtractUSDModelDataOptions): USDModelData;
|
|
250
230
|
//#endregion
|
|
@@ -252,4 +232,4 @@ declare function extractUSDModelData(pxr: Pxr, stage: PxrObject, options?: Extra
|
|
|
252
232
|
declare function buildUSDObject(data: USDModelData, options?: BuildUSDObjectOptions): THREE.Group;
|
|
253
233
|
declare function createUSDLoadedModel(data: USDModelData, pxr: USDLoadedModel['pxr'], rootLayerIdentifier: string, options?: BuildUSDObjectOptions, stage?: unknown): USDLoadedModel;
|
|
254
234
|
//#endregion
|
|
255
|
-
export { type BuildUSDObjectOptions, type ExtractUSDModelDataOptions, type PxrObject, type USDAnimationInfo, type USDAssetValue, type USDFileExtension, type USDJointDriveInfo, type USDJointInfo, type USDLoadedModel, USDLoader, type USDLoaderOptions, type USDLoaderParseOptions, type USDManipulationChangeEvent, USDManipulationControls, type USDManipulationControlsOptions, type USDManipulationHoverEvent, type USDMaterialInfo, type USDMeshElement, type USDMeshGeometryData, type USDModelData, type USDShaderInfo, type USDSourceInput, type USDStageInfo, type USDTextureResolver, type USDTextureResolverContext, type USDTransformAnimation, type USDTransformAnimationSample, type USDVector2, type USDVector3, type USDVector4, type USDViewPrim,
|
|
235
|
+
export { type BuildUSDObjectOptions, type ExtractUSDModelDataOptions, type PxrObject, type USDAnimationInfo, type USDAssetValue, type USDFileExtension, type USDJointDriveInfo, type USDJointInfo, type USDLoadedModel, USDLoader, type USDLoaderOptions, type USDLoaderParseOptions, type USDManipulationChangeEvent, USDManipulationControls, type USDManipulationControlsOptions, type USDManipulationHoverEvent, type USDMaterialInfo, type USDMeshElement, type USDMeshGeometryData, type USDModelData, type USDShaderInfo, type USDSourceInput, type USDStageInfo, type USDTextureResolver, type USDTextureResolverContext, type USDTransformAnimation, type USDTransformAnimationSample, type USDVector2, type USDVector3, type USDVector4, type USDViewPrim, buildUSDObject, createUSDLoadedModel, extractUSDModelData };
|