@stowkit/three-loader 0.1.10 → 0.1.12

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
@@ -11,24 +11,20 @@ npm install @stowkit/three-loader three
11
11
  ## Quick Start
12
12
 
13
13
  ```typescript
14
- import * as THREE from 'three';
15
14
  import { StowKitLoader } from '@stowkit/three-loader';
16
15
 
17
- // Create loader (auto-configured with defaults)
18
- // Basis transcoder: /stowkit/basis/ (auto-included)
19
- // Draco decoder: /stowkit/draco/ (auto-included)
20
- const loader = new StowKitLoader();
16
+ // Load a pack (auto-initializes with defaults)
17
+ const pack = await StowKitLoader.load('assets.stow');
21
18
 
22
- // Optional: Override paths only if you have custom locations
23
- // loader.setTranscoderPath('/custom-basis-path/');
24
- // loader.setDracoDecoderPath('/custom-draco-path/');
19
+ // Load assets by name - simple and clean!
20
+ const mesh = await pack.loadMesh('models/character');
21
+ const texture = await pack.loadTexture('textures/wood');
22
+ const audio = await pack.loadAudio('sounds/bgm', audioListener);
25
23
 
26
- // Open a .stow pack file
27
- await loader.openPack('assets.stow');
28
-
29
- // Load a mesh with automatic textures and materials
30
- const scene = await loader.loadMesh('', 'models/character.mesh');
31
- threeScene.add(scene);
24
+ // Use in Three.js
25
+ scene.add(mesh);
26
+ material.map = texture;
27
+ audio.play();
32
28
  ```
33
29
 
34
30
  ## Features
@@ -45,114 +41,74 @@ threeScene.add(scene);
45
41
 
46
42
  ## API Reference
47
43
 
48
- ### Constructor
44
+ ### Loading Packs
49
45
 
50
- ```typescript
51
- new StowKitLoader(manager?: THREE.LoadingManager, parameters?: StowKitLoaderParameters)
52
- ```
46
+ #### `StowKitLoader.load(url: string, options?: StowKitLoaderOptions): Promise<StowKitPack>`
53
47
 
54
- **Parameters (all optional):**
48
+ Load a .stow pack file. Returns a `StowKitPack` instance for loading assets.
49
+
50
+ **Options (all optional):**
55
51
  ```typescript
56
- interface StowKitLoaderParameters {
57
- transcoderPath?: string; // Path to Basis Universal transcoder (default: '/basis/')
58
- wasmPath?: string; // Path to WASM reader module (default: '/stowkit_reader.wasm')
59
- reader?: StowKitReader; // Custom reader instance (advanced)
52
+ interface StowKitLoaderOptions {
53
+ basisPath?: string; // Path to Basis Universal transcoder (default: '/stowkit/basis/')
54
+ dracoPath?: string; // Path to Draco decoder (default: '/stowkit/draco/')
55
+ wasmPath?: string; // Path to WASM reader module (default: '/stowkit_reader.wasm')
60
56
  }
61
57
  ```
62
58
 
63
- **Example:**
59
+ **Examples:**
64
60
  ```typescript
65
- // Default configuration
66
- const loader = new StowKitLoader();
61
+ // Default paths (recommended)
62
+ const pack = await StowKitLoader.load('assets.stow');
67
63
 
68
64
  // Custom paths
69
- const loader = new StowKitLoader(undefined, {
70
- transcoderPath: '/my-basis-path/',
65
+ const pack = await StowKitLoader.load('game.stow', {
66
+ basisPath: '/custom/basis/',
67
+ dracoPath: '/custom/draco/',
71
68
  wasmPath: '/custom/stowkit_reader.wasm'
72
69
  });
73
70
  ```
74
71
 
75
- ### Opening Packs
76
-
77
- #### `openPack(url: string): Promise<void>`
78
-
79
- Open a .stow pack file from a URL. Call this once, then load multiple assets.
80
-
81
- ```typescript
82
- await loader.openPack('assets.stow');
83
- ```
84
-
85
- #### `open(fileOrBuffer: ArrayBuffer | File): Promise<boolean>`
72
+ ### StowKitPack Methods
86
73
 
87
- Open a pack from a File or ArrayBuffer.
88
-
89
- ```typescript
90
- // From file input
91
- const file = input.files[0];
92
- await loader.open(file);
93
-
94
- // From fetch
95
- const response = await fetch('assets.stow');
96
- const buffer = await response.arrayBuffer();
97
- await loader.open(buffer);
98
- ```
74
+ Once you have a pack loaded, use these methods to load assets:
99
75
 
100
76
  ### Loading Meshes
101
77
 
102
- #### `loadMesh(url: string, assetPath: string, onLoad?, onProgress?, onError?): Promise<THREE.Group>`
103
-
104
- Load a mesh asset with automatic texture and material loading.
78
+ #### `pack.loadMesh(assetPath: string): Promise<THREE.Group>`
105
79
 
106
- **Parameters:**
107
- - `url` - URL to .stow file (empty string if already opened)
108
- - `assetPath` - Canonical path to mesh within pack
109
- - `onLoad` - Optional callback when loading completes
110
- - `onProgress` - Optional progress callback
111
- - `onError` - Optional error callback
80
+ Load a mesh by its canonical path/name. Automatically loads and applies textures and materials.
112
81
 
113
- **Returns:** `THREE.Group` containing the mesh hierarchy
114
-
115
- **Example:**
116
82
  ```typescript
117
- // Simple async/await
118
- const mesh = await loader.loadMesh('', 'models/character.mesh');
119
- scene.add(mesh);
83
+ const character = await pack.loadMesh('models/character');
84
+ const tree = await pack.loadMesh('models/tree');
85
+ const building = await pack.loadMesh('models/building');
120
86
 
121
- // With callbacks (Three.js style)
122
- loader.loadMesh('assets.stow', 'models/tree.mesh',
123
- (scene) => {
124
- threeScene.add(scene);
125
- },
126
- (progress) => console.log('Loading...', progress),
127
- (error) => console.error('Failed:', error)
128
- );
87
+ scene.add(character);
88
+ scene.add(tree);
89
+ scene.add(building);
129
90
  ```
130
91
 
131
92
  **What you get:**
132
- - Complete scene hierarchy with nodes
133
- - All geometries (vertices, normals, UVs, indices)
134
- - Materials with properties applied (colors, etc.)
135
- - Textures automatically loaded and applied to materials
136
- - Transforms (position, rotation, scale) preserved
93
+ - Complete scene hierarchy with nodes
94
+ - Draco-decompressed geometry (vertices, normals, UVs, indices)
95
+ - Materials with colors, properties applied
96
+ - Textures automatically loaded and applied
97
+ - Transforms (position, rotation, scale) preserved
137
98
 
138
99
  ### Loading Textures
139
100
 
140
- #### `loadTexture(url: string, assetPath: string, onLoad?, onProgress?, onError?): Promise<THREE.CompressedTexture>`
101
+ #### `pack.loadTexture(assetPath: string): Promise<THREE.CompressedTexture>`
141
102
 
142
- Load a texture asset (KTX2 format).
103
+ Load a KTX2 texture by its canonical path/name.
143
104
 
144
105
  ```typescript
145
- const texture = await loader.loadTexture('', 'textures/wood.ktx2');
146
- material.map = texture;
147
- material.needsUpdate = true;
148
- ```
106
+ const wood = await pack.loadTexture('textures/wood');
107
+ const metal = await pack.loadTexture('textures/metal');
149
108
 
150
- #### `loadTextureByIndex(index: number, onLoad?, onProgress?, onError?): Promise<THREE.CompressedTexture>`
151
-
152
- Load a texture by its asset index (when you don't have the path).
153
-
154
- ```typescript
155
- const texture = await loader.loadTextureByIndex(5);
109
+ material.map = wood;
110
+ material.roughnessMap = metal;
111
+ material.needsUpdate = true;
156
112
  ```
157
113
 
158
114
  ### Loading Audio
@@ -1,219 +1,44 @@
1
- import * as THREE from 'three';
2
- import { StowKitReader } from '@stowkit/reader';
3
- export interface StowKitLoaderParameters {
1
+ import { StowKitPack } from './StowKitPack';
2
+ export interface StowKitLoaderOptions {
4
3
  /**
5
4
  * Path to basis transcoder for KTX2 texture loading
6
- * @default '/basis/'
5
+ * @default '/stowkit/basis/'
7
6
  */
8
- transcoderPath?: string;
7
+ basisPath?: string;
8
+ /**
9
+ * Path to Draco decoder for mesh decompression
10
+ * @default '/stowkit/draco/'
11
+ */
12
+ dracoPath?: string;
9
13
  /**
10
14
  * Path to WASM reader module
11
15
  * @default '/stowkit_reader.wasm'
12
16
  */
13
17
  wasmPath?: string;
14
- /**
15
- * Custom StowKitReader instance (optional)
16
- */
17
- reader?: StowKitReader;
18
18
  }
19
19
  /**
20
- * Three.js loader for StowKit asset packs (.stow files)
20
+ * Three.js loader for StowKit asset packs
21
21
  *
22
22
  * Usage:
23
23
  * ```typescript
24
- * const loader = new StowKitLoader();
25
- * loader.setTranscoderPath('/basis/');
26
- *
27
- * // Load a mesh asset
28
- * loader.loadMesh('assets.stow', 'path/to/mesh', (scene) => {
29
- * threeScene.add(scene);
30
- * });
24
+ * const pack = await StowKitLoader.load('assets.stow');
25
+ * const mesh = await pack.loadMesh('models/character');
26
+ * const texture = await pack.loadTexture('textures/diffuse');
27
+ * const audio = await pack.loadAudio('sounds/bgm', listener);
31
28
  * ```
32
29
  */
33
- export declare class StowKitLoader extends THREE.Loader {
34
- private reader;
35
- private ktx2Loader;
36
- private dracoLoader;
37
- private ownedReader;
38
- constructor(manager?: THREE.LoadingManager, parameters?: StowKitLoaderParameters);
39
- /**
40
- * Set the path to the Draco decoder
41
- */
42
- setDracoDecoderPath(path: string): this;
43
- /**
44
- * Set the path to the Basis Universal transcoder
45
- */
46
- setTranscoderPath(path: string): this;
47
- /**
48
- * Detect WebGL support for compressed textures
49
- */
50
- detectSupport(renderer: THREE.WebGLRenderer): this;
51
- /**
52
- * Open a .stow pack file (call this first if loading multiple assets)
53
- * @param url - URL to the .stow file
54
- */
55
- openPack(url: string): Promise<void>;
56
- /**
57
- * Load and parse a mesh asset by its index
58
- * @param index - Asset index
59
- * @param onLoad - Callback when loading completes
60
- * @param onProgress - Progress callback
61
- * @param onError - Error callback
62
- */
63
- loadMeshByIndex(index: number, onLoad?: (scene: THREE.Group) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: Error) => void): Promise<THREE.Group>;
64
- /**
65
- * Load and parse a mesh asset from a StowKit pack
66
- * @param url - URL to the .stow file (or omit if already opened with openPack)
67
- * @param assetPath - Path to the mesh asset within the pack
68
- * @param onLoad - Callback when loading completes
69
- * @param onProgress - Progress callback
70
- * @param onError - Error callback
71
- */
72
- loadMesh(url: string, assetPath: string, onLoad?: (scene: THREE.Group) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: Error) => void): Promise<THREE.Group>;
73
- /**
74
- * Load textures for materials
75
- */
76
- private loadMaterialTextures;
77
- /**
78
- * Load a KTX2 texture from binary data
79
- */
80
- private loadKTX2Texture;
81
- /**
82
- * Apply texture to appropriate material property
83
- */
84
- private applyTextureToMaterial;
85
- /**
86
- * Load a texture asset from a StowKit pack
87
- * @param url - URL to the .stow file (or omit if already opened with openPack)
88
- * @param assetPath - Path to the texture asset within the pack
89
- * @param onLoad - Callback when loading completes
90
- * @param onProgress - Progress callback
91
- * @param onError - Error callback
92
- */
93
- loadTexture(url: string, assetPath: string, onLoad?: (texture: THREE.CompressedTexture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: Error) => void): Promise<THREE.CompressedTexture>;
94
- /**
95
- * Load a texture asset by its index in the pack
96
- * @param index - Asset index
97
- * @param onLoad - Callback when loading completes
98
- * @param onProgress - Progress callback
99
- * @param onError - Error callback
100
- */
101
- loadTextureByIndex(index: number, onLoad?: (texture: THREE.CompressedTexture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: Error) => void): Promise<THREE.CompressedTexture>;
102
- /**
103
- * Load an audio asset from a StowKit pack
104
- * @param url - URL to the .stow file (or omit if already opened with openPack)
105
- * @param assetPath - Path to the audio asset within the pack
106
- * @param listener - THREE.AudioListener to attach to
107
- * @param onLoad - Callback when loading completes
108
- * @param onProgress - Progress callback
109
- * @param onError - Error callback
110
- */
111
- loadAudio(url: string, assetPath: string, listener: THREE.AudioListener, onLoad?: (audio: THREE.Audio) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: Error) => void): Promise<THREE.Audio>;
112
- /**
113
- * Get metadata for an audio asset
114
- * @param assetPath - Path to the audio asset within the pack
115
- */
116
- getAudioMetadata(assetPath: string): {
117
- stringId: string;
118
- sampleRate: number;
119
- channels: number;
120
- durationMs: number;
121
- } | null;
122
- /**
123
- * Get metadata for a texture asset
124
- * @param assetPath - Path to the texture asset within the pack
125
- */
126
- getTextureMetadata(assetPath: string): {
127
- width: number;
128
- height: number;
129
- channels: number;
130
- isKtx2: boolean;
131
- channelFormat: number;
132
- stringId: string;
133
- } | null;
134
- /**
135
- * Load material schema information by index
136
- * @param index - Asset index
137
- */
138
- loadMaterialSchemaByIndex(index: number): {
139
- stringId: string;
140
- schemaName: string;
141
- fields: Array<{
142
- name: string;
143
- type: 'Texture' | 'Color' | 'Float' | 'Vec2' | 'Vec3' | 'Vec4' | 'Int';
144
- previewFlag: 'None' | 'MainTex' | 'Tint';
145
- defaultValue: [number, number, number, number];
146
- }>;
147
- } | null;
148
- /**
149
- * Load material schema information by path
150
- * @param assetPath - Path to the material schema asset
151
- */
152
- loadMaterialSchema(assetPath: string): {
153
- stringId: string;
154
- schemaName: string;
155
- fields: Array<{
156
- name: string;
157
- type: 'Texture' | 'Color' | 'Float' | 'Vec2' | 'Vec3' | 'Vec4' | 'Int';
158
- previewFlag: 'None' | 'MainTex' | 'Tint';
159
- defaultValue: [number, number, number, number];
160
- }>;
161
- } | null;
162
- /**
163
- * Get material information from a loaded mesh
164
- * Returns material data including properties and texture references
165
- */
166
- getMeshMaterials(assetPath: string): Array<{
167
- name: string;
168
- schemaId: string;
169
- properties: Array<{
170
- fieldName: string;
171
- value: [number, number, number, number];
172
- textureId: string;
173
- }>;
174
- }> | null;
175
- /**
176
- * Open a .stow file from a File or ArrayBuffer
177
- */
178
- open(fileOrBuffer: ArrayBuffer | File): Promise<boolean>;
179
- /**
180
- * Get the total number of assets
181
- */
182
- getAssetCount(): number;
183
- /**
184
- * Get info about a specific asset
185
- */
186
- getAssetInfo(index: number): any;
187
- /**
188
- * Read asset data by index
189
- */
190
- readAssetData(index: number): Uint8Array | null;
191
- /**
192
- * Read asset metadata by index
193
- */
194
- readAssetMetadata(index: number): Uint8Array | null;
195
- /**
196
- * Parse texture metadata
197
- */
198
- parseTextureMetadata(metadataBytes: Uint8Array): any;
199
- /**
200
- * Create an HTML audio element for preview
201
- * @param index - Asset index
202
- */
203
- createAudioPreview(index: number): Promise<HTMLAudioElement>;
30
+ export declare class StowKitLoader {
31
+ private static reader;
32
+ private static ktx2Loader;
33
+ private static dracoLoader;
34
+ private static initialized;
204
35
  /**
205
- * List all assets in the opened pack
36
+ * Load a .stow pack file
206
37
  */
207
- listAssets(): Array<{
208
- index: number;
209
- name?: string;
210
- type: number;
211
- dataSize: number;
212
- metadataSize: number;
213
- }>;
38
+ static load(url: string, options?: StowKitLoaderOptions): Promise<StowKitPack>;
214
39
  /**
215
- * Dispose of resources
40
+ * Initialize the loader (called automatically on first load)
216
41
  */
217
- dispose(): void;
42
+ private static initialize;
218
43
  }
219
44
  //# sourceMappingURL=StowKitLoader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StowKitLoader.d.ts","sourceRoot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,CAAC;IAIF;;OAEG;IACH,OAAO,IAAI,IAAI;CAOlB"}
1
+ {"version":3,"file":"StowKitLoader.d.ts","sourceRoot":"","sources":["../src/StowKitLoader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,WAAW,oBAAoB;IACjC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAC,MAAM,CAA8B;IACnD,OAAO,CAAC,MAAM,CAAC,UAAU,CAA2B;IACpD,OAAO,CAAC,MAAM,CAAC,WAAW,CAA4B;IACtD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAS;IAEnC;;OAEG;WACU,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;IAqBpF;;OAEG;mBACkB,UAAU;CAwBlC"}
@@ -0,0 +1,132 @@
1
+ import * as THREE from 'three';
2
+ import { KTX2Loader } from 'three/examples/jsm/loaders/KTX2Loader.js';
3
+ import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
4
+ import { StowKitReader } from '@stowkit/reader';
5
+ /**
6
+ * Represents an opened StowKit pack with methods to load assets by name
7
+ */
8
+ export declare class StowKitPack {
9
+ private reader;
10
+ private ktx2Loader;
11
+ private dracoLoader;
12
+ constructor(reader: StowKitReader, ktx2Loader: KTX2Loader, dracoLoader: DRACOLoader);
13
+ /**
14
+ * Load a mesh by its canonical path/name
15
+ */
16
+ loadMesh(assetPath: string): Promise<THREE.Group>;
17
+ /**
18
+ * Load a texture by its canonical path/name
19
+ */
20
+ loadTexture(assetPath: string): Promise<THREE.CompressedTexture>;
21
+ /**
22
+ * Load audio by its canonical path/name
23
+ */
24
+ loadAudio(assetPath: string, listener: THREE.AudioListener): Promise<THREE.Audio>;
25
+ /**
26
+ * Get list of all assets in pack
27
+ */
28
+ listAssets(): import("@stowkit/reader").AssetListItem[];
29
+ /**
30
+ * Get asset count
31
+ */
32
+ getAssetCount(): number;
33
+ /**
34
+ * Get asset info by index
35
+ */
36
+ getAssetInfo(index: number): any;
37
+ /**
38
+ * Read asset data by index
39
+ */
40
+ readAssetData(index: number): Uint8Array | null;
41
+ /**
42
+ * Read asset metadata by index
43
+ */
44
+ readAssetMetadata(index: number): Uint8Array | null;
45
+ /**
46
+ * Parse texture metadata
47
+ */
48
+ parseTextureMetadata(metadataBytes: Uint8Array): any;
49
+ /**
50
+ * Load mesh by index
51
+ */
52
+ loadMeshByIndex(index: number): Promise<THREE.Group>;
53
+ /**
54
+ * Load texture by index
55
+ */
56
+ loadTextureByIndex(index: number): Promise<THREE.CompressedTexture>;
57
+ /**
58
+ * Create HTML audio preview element
59
+ */
60
+ createAudioPreview(index: number): Promise<HTMLAudioElement>;
61
+ /**
62
+ * Get audio metadata by path
63
+ */
64
+ getAudioMetadata(assetPath: string): {
65
+ stringId: string;
66
+ sampleRate: number;
67
+ channels: number;
68
+ durationMs: number;
69
+ } | null;
70
+ /**
71
+ * Load material schema by index
72
+ */
73
+ loadMaterialSchemaByIndex(index: number): {
74
+ stringId: string;
75
+ schemaName: string;
76
+ fields: {
77
+ name: string;
78
+ type: "Texture" | "Color" | "Float" | "Vec2" | "Vec3" | "Vec4" | "Int";
79
+ previewFlag: "None" | "MainTex" | "Tint";
80
+ defaultValue: [number, number, number, number];
81
+ }[];
82
+ } | null;
83
+ /**
84
+ * Get mesh materials by index
85
+ */
86
+ getMeshMaterialsByIndex(index: number): {
87
+ name: string;
88
+ schemaId: string;
89
+ propertyCount: number;
90
+ properties: Array<{
91
+ fieldName: string;
92
+ value: [number, number, number, number];
93
+ textureId: string;
94
+ }>;
95
+ }[] | null;
96
+ /**
97
+ * Get material schema information
98
+ */
99
+ getMaterialSchema(assetPath: string): {
100
+ stringId: string;
101
+ schemaName: string;
102
+ fields: {
103
+ name: string;
104
+ type: "Texture" | "Color" | "Float" | "Vec2" | "Vec3" | "Vec4" | "Int";
105
+ previewFlag: "None" | "MainTex" | "Tint";
106
+ defaultValue: [number, number, number, number];
107
+ }[];
108
+ } | null;
109
+ /**
110
+ * Get mesh materials information
111
+ */
112
+ getMeshMaterials(assetPath: string): {
113
+ name: string;
114
+ schemaId: string;
115
+ propertyCount: number;
116
+ properties: Array<{
117
+ fieldName: string;
118
+ value: [number, number, number, number];
119
+ textureId: string;
120
+ }>;
121
+ }[] | null;
122
+ /**
123
+ * Close the pack and free resources
124
+ */
125
+ dispose(): void;
126
+ private loadMaterialTextures;
127
+ private loadKTX2Texture;
128
+ private applyTextureToMaterial;
129
+ private loadMaterialSchemaByIndex_internal;
130
+ private getMeshMaterialsByIndex_internal;
131
+ }
132
+ //# sourceMappingURL=StowKitPack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StowKitPack.d.ts","sourceRoot":"","sources":["../src/StowKitPack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;GAEG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,WAAW,CAAc;gBAErB,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW;IAMnF;;OAEG;IACG,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;IA+BvD;;OAEG;IACG,WAAW,C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MAAM;;;;;;;;;;IAOnC;;OAEG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM;cA4JpB,MAAM;kBACF,MAAM;uBACD,MAAM;oBACT,KAAK,CAAC;YACd,SAAS,EAAE,MAAM,CAAC;YAClB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;YACxC,SAAS,EAAE,MAAM,CAAC;SACrB,CAAC;;IA5JV;;OAEG;IACH,OAAO,IAAI,IAAI;YAKD,oBAAoB;YA8BpB,eAAe;IA2B7B,OAAO,CAAC,sBAAsB;IAuB9B,OAAO,CAAC,kCAAkC;IA8C1C,OAAO,CAAC,gCAAgC;CA+D3C"}
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * Three.js loader for StowKit asset packs
4
4
  */
5
5
  export { StowKitLoader } from './StowKitLoader';
6
- export { MeshParser } from './MeshParser';
6
+ export { StowKitPack } from './StowKitPack';
7
+ export type { StowKitLoaderOptions } from './StowKitLoader';
7
8
  export type { MeshGeometryInfo, MaterialPropertyValue, MaterialData, Node, MeshMetadata } from './MeshParser';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EACR,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,IAAI,EACJ,YAAY,EACf,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EACR,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,IAAI,EACJ,YAAY,EACf,MAAM,cAAc,CAAC"}