@stowkit/three-loader 0.1.11 → 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.
Files changed (2) hide show
  1. package/README.md +22 -63
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -69,87 +69,46 @@ const pack = await StowKitLoader.load('game.stow', {
69
69
  });
70
70
  ```
71
71
 
72
- ### Opening Packs
72
+ ### StowKitPack Methods
73
73
 
74
- #### `openPack(url: string): Promise<void>`
75
-
76
- Open a .stow pack file from a URL. Call this once, then load multiple assets.
77
-
78
- ```typescript
79
- await loader.openPack('assets.stow');
80
- ```
81
-
82
- #### `open(fileOrBuffer: ArrayBuffer | File): Promise<boolean>`
83
-
84
- Open a pack from a File or ArrayBuffer.
85
-
86
- ```typescript
87
- // From file input
88
- const file = input.files[0];
89
- await loader.open(file);
90
-
91
- // From fetch
92
- const response = await fetch('assets.stow');
93
- const buffer = await response.arrayBuffer();
94
- await loader.open(buffer);
95
- ```
74
+ Once you have a pack loaded, use these methods to load assets:
96
75
 
97
76
  ### Loading Meshes
98
77
 
99
- #### `loadMesh(url: string, assetPath: string, onLoad?, onProgress?, onError?): Promise<THREE.Group>`
100
-
101
- Load a mesh asset with automatic texture and material loading.
78
+ #### `pack.loadMesh(assetPath: string): Promise<THREE.Group>`
102
79
 
103
- **Parameters:**
104
- - `url` - URL to .stow file (empty string if already opened)
105
- - `assetPath` - Canonical path to mesh within pack
106
- - `onLoad` - Optional callback when loading completes
107
- - `onProgress` - Optional progress callback
108
- - `onError` - Optional error callback
80
+ Load a mesh by its canonical path/name. Automatically loads and applies textures and materials.
109
81
 
110
- **Returns:** `THREE.Group` containing the mesh hierarchy
111
-
112
- **Example:**
113
82
  ```typescript
114
- // Simple async/await
115
- const mesh = await loader.loadMesh('', 'models/character.mesh');
116
- 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');
117
86
 
118
- // With callbacks (Three.js style)
119
- loader.loadMesh('assets.stow', 'models/tree.mesh',
120
- (scene) => {
121
- threeScene.add(scene);
122
- },
123
- (progress) => console.log('Loading...', progress),
124
- (error) => console.error('Failed:', error)
125
- );
87
+ scene.add(character);
88
+ scene.add(tree);
89
+ scene.add(building);
126
90
  ```
127
91
 
128
92
  **What you get:**
129
- - Complete scene hierarchy with nodes
130
- - All geometries (vertices, normals, UVs, indices)
131
- - Materials with properties applied (colors, etc.)
132
- - Textures automatically loaded and applied to materials
133
- - 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
134
98
 
135
99
  ### Loading Textures
136
100
 
137
- #### `loadTexture(url: string, assetPath: string, onLoad?, onProgress?, onError?): Promise<THREE.CompressedTexture>`
101
+ #### `pack.loadTexture(assetPath: string): Promise<THREE.CompressedTexture>`
138
102
 
139
- Load a texture asset (KTX2 format).
103
+ Load a KTX2 texture by its canonical path/name.
140
104
 
141
105
  ```typescript
142
- const texture = await loader.loadTexture('', 'textures/wood.ktx2');
143
- material.map = texture;
144
- material.needsUpdate = true;
145
- ```
146
-
147
- #### `loadTextureByIndex(index: number, onLoad?, onProgress?, onError?): Promise<THREE.CompressedTexture>`
106
+ const wood = await pack.loadTexture('textures/wood');
107
+ const metal = await pack.loadTexture('textures/metal');
148
108
 
149
- Load a texture by its asset index (when you don't have the path).
150
-
151
- ```typescript
152
- const texture = await loader.loadTextureByIndex(5);
109
+ material.map = wood;
110
+ material.roughnessMap = metal;
111
+ material.needsUpdate = true;
153
112
  ```
154
113
 
155
114
  ### Loading Audio
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stowkit/three-loader",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Three.js loader for StowKit asset packs",
5
5
  "main": "dist/stowkit-three-loader.js",
6
6
  "module": "dist/stowkit-three-loader.esm.js",