@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.
- package/README.md +22 -63
- 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
|
-
###
|
|
72
|
+
### StowKitPack Methods
|
|
73
73
|
|
|
74
|
-
|
|
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(
|
|
100
|
-
|
|
101
|
-
Load a mesh asset with automatic texture and material loading.
|
|
78
|
+
#### `pack.loadMesh(assetPath: string): Promise<THREE.Group>`
|
|
102
79
|
|
|
103
|
-
|
|
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
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
-
|
|
131
|
-
- Materials with properties applied
|
|
132
|
-
- Textures automatically loaded and applied
|
|
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(
|
|
101
|
+
#### `pack.loadTexture(assetPath: string): Promise<THREE.CompressedTexture>`
|
|
138
102
|
|
|
139
|
-
Load a texture
|
|
103
|
+
Load a KTX2 texture by its canonical path/name.
|
|
140
104
|
|
|
141
105
|
```typescript
|
|
142
|
-
const
|
|
143
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|