@stowkit/three-loader 0.1.2
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 +163 -0
- package/dist/MeshParser.d.ts +70 -0
- package/dist/MeshParser.d.ts.map +1 -0
- package/dist/StowKitLoader.d.ts +206 -0
- package/dist/StowKitLoader.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/stowkit-three-loader.esm.js +1012 -0
- package/dist/stowkit-three-loader.esm.js.map +1 -0
- package/dist/stowkit-three-loader.js +1034 -0
- package/dist/stowkit-three-loader.js.map +1 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# @stowkit/three-loader
|
|
2
|
+
|
|
3
|
+
Three.js loader for StowKit asset packs. Provides an easy-to-use API for loading meshes, textures, and audio from `.stow` files into Three.js scenes.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @stowkit/three-loader three
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Basic Mesh Loading
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import * as THREE from 'three';
|
|
17
|
+
import { StowKitLoader } from '@stowkit/three-loader';
|
|
18
|
+
|
|
19
|
+
const loader = new StowKitLoader();
|
|
20
|
+
loader.setTranscoderPath('/basis/'); // Path to Basis Universal transcoder
|
|
21
|
+
|
|
22
|
+
// Load a mesh
|
|
23
|
+
const scene = await loader.loadMesh('assets.stow', 'models/character.mesh');
|
|
24
|
+
threeScene.add(scene);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Loading Multiple Assets from Same Pack
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
const loader = new StowKitLoader();
|
|
31
|
+
loader.setTranscoderPath('/basis/');
|
|
32
|
+
|
|
33
|
+
// Open pack once
|
|
34
|
+
await loader.openPack('assets.stow');
|
|
35
|
+
|
|
36
|
+
// Load multiple assets (no need to pass URL again)
|
|
37
|
+
const character = await loader.loadMesh('', 'models/character.mesh');
|
|
38
|
+
const weapon = await loader.loadMesh('', 'models/weapon.mesh');
|
|
39
|
+
const texture = await loader.loadTexture('', 'textures/diffuse.ktx2');
|
|
40
|
+
|
|
41
|
+
threeScene.add(character);
|
|
42
|
+
threeScene.add(weapon);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Loading Textures
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
const loader = new StowKitLoader();
|
|
49
|
+
loader.setTranscoderPath('/basis/');
|
|
50
|
+
|
|
51
|
+
const texture = await loader.loadTexture('assets.stow', 'textures/wood.ktx2');
|
|
52
|
+
material.map = texture;
|
|
53
|
+
material.needsUpdate = true;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Loading Audio
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
const listener = new THREE.AudioListener();
|
|
60
|
+
camera.add(listener);
|
|
61
|
+
|
|
62
|
+
const loader = new StowKitLoader();
|
|
63
|
+
const audio = await loader.loadAudio('assets.stow', 'sounds/bgm.ogg', listener);
|
|
64
|
+
audio.play();
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### With Callbacks (Three.js style)
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
loader.loadMesh(
|
|
71
|
+
'assets.stow',
|
|
72
|
+
'models/tree.mesh',
|
|
73
|
+
(scene) => {
|
|
74
|
+
// onLoad
|
|
75
|
+
threeScene.add(scene);
|
|
76
|
+
},
|
|
77
|
+
(progress) => {
|
|
78
|
+
// onProgress
|
|
79
|
+
console.log('Loading...', progress);
|
|
80
|
+
},
|
|
81
|
+
(error) => {
|
|
82
|
+
// onError
|
|
83
|
+
console.error('Failed to load:', error);
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Getting Metadata
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
// Get texture info
|
|
92
|
+
const texInfo = loader.getTextureMetadata('textures/wood.ktx2');
|
|
93
|
+
console.log(`Texture: ${texInfo.width}x${texInfo.height}`);
|
|
94
|
+
|
|
95
|
+
// Get audio info
|
|
96
|
+
const audioInfo = loader.getAudioMetadata('sounds/bgm.ogg');
|
|
97
|
+
console.log(`Duration: ${audioInfo.durationMs}ms`);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Listing Assets
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
await loader.openPack('assets.stow');
|
|
104
|
+
const assets = loader.listAssets();
|
|
105
|
+
|
|
106
|
+
assets.forEach(asset => {
|
|
107
|
+
console.log(`${asset.name} (${asset.type}): ${asset.dataSize} bytes`);
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Features
|
|
112
|
+
|
|
113
|
+
- ✅ **Automatic texture loading** - Materials with `mainTex` properties automatically load and apply textures
|
|
114
|
+
- ✅ **Material schema support** - Reads tint colors, texture references, and other material properties
|
|
115
|
+
- ✅ **KTX2/Basis Universal** - Compressed texture support with GPU transcoding
|
|
116
|
+
- ✅ **Scene hierarchy** - Preserves node transforms and parent-child relationships
|
|
117
|
+
- ✅ **Multi-material meshes** - Supports meshes with multiple materials/submeshes
|
|
118
|
+
- ✅ **Type-safe** - Full TypeScript definitions
|
|
119
|
+
|
|
120
|
+
## API Reference
|
|
121
|
+
|
|
122
|
+
### StowKitLoader
|
|
123
|
+
|
|
124
|
+
#### Constructor
|
|
125
|
+
```typescript
|
|
126
|
+
new StowKitLoader(manager?: THREE.LoadingManager, parameters?: StowKitLoaderParameters)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Methods
|
|
130
|
+
|
|
131
|
+
##### `setTranscoderPath(path: string): this`
|
|
132
|
+
Set the path to the Basis Universal transcoder (required for KTX2 textures).
|
|
133
|
+
|
|
134
|
+
##### `detectSupport(renderer: THREE.WebGLRenderer): this`
|
|
135
|
+
Detect GPU compressed texture format support.
|
|
136
|
+
|
|
137
|
+
##### `openPack(url: string): Promise<void>`
|
|
138
|
+
Open a .stow pack file. Call this once when loading multiple assets from the same pack.
|
|
139
|
+
|
|
140
|
+
##### `loadMesh(url, assetPath, onLoad?, onProgress?, onError?): Promise<THREE.Group>`
|
|
141
|
+
Load a mesh asset. Returns a Three.js Group containing the mesh hierarchy.
|
|
142
|
+
|
|
143
|
+
##### `loadTexture(url, assetPath, onLoad?, onProgress?, onError?): Promise<THREE.CompressedTexture>`
|
|
144
|
+
Load a texture asset. Returns a Three.js CompressedTexture.
|
|
145
|
+
|
|
146
|
+
##### `loadAudio(url, assetPath, listener, onLoad?, onProgress?, onError?): Promise<THREE.Audio>`
|
|
147
|
+
Load an audio asset. Returns a Three.js Audio object.
|
|
148
|
+
|
|
149
|
+
##### `getTextureMetadata(assetPath): object | null`
|
|
150
|
+
Get texture metadata (width, height, format, etc.).
|
|
151
|
+
|
|
152
|
+
##### `getAudioMetadata(assetPath): object | null`
|
|
153
|
+
Get audio metadata (sample rate, channels, duration).
|
|
154
|
+
|
|
155
|
+
##### `listAssets(): array`
|
|
156
|
+
List all assets in the opened pack.
|
|
157
|
+
|
|
158
|
+
##### `dispose(): void`
|
|
159
|
+
Clean up resources and free memory.
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
MIT
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
export interface MeshGeometryInfo {
|
|
3
|
+
vertexCount: number;
|
|
4
|
+
indexCount: number;
|
|
5
|
+
vertexBufferOffset: number;
|
|
6
|
+
indexBufferOffset: number;
|
|
7
|
+
normalBufferOffset: number;
|
|
8
|
+
uvBufferOffset: number;
|
|
9
|
+
vertexBufferSize: number;
|
|
10
|
+
indexBufferSize: number;
|
|
11
|
+
normalBufferSize: number;
|
|
12
|
+
uvBufferSize: number;
|
|
13
|
+
materialIndex: number;
|
|
14
|
+
}
|
|
15
|
+
export interface Node {
|
|
16
|
+
name: string;
|
|
17
|
+
parentIndex: number;
|
|
18
|
+
position: [number, number, number];
|
|
19
|
+
rotation: [number, number, number, number];
|
|
20
|
+
scale: [number, number, number];
|
|
21
|
+
meshCount: number;
|
|
22
|
+
firstMeshIndex: number;
|
|
23
|
+
}
|
|
24
|
+
export interface MaterialPropertyValue {
|
|
25
|
+
fieldName: string;
|
|
26
|
+
value: [number, number, number, number];
|
|
27
|
+
textureId: string;
|
|
28
|
+
}
|
|
29
|
+
export interface MaterialData {
|
|
30
|
+
name: string;
|
|
31
|
+
schemaId: string;
|
|
32
|
+
propertyCount: number;
|
|
33
|
+
properties: MaterialPropertyValue[];
|
|
34
|
+
}
|
|
35
|
+
export interface MeshMetadata {
|
|
36
|
+
meshGeometryCount: number;
|
|
37
|
+
materialCount: number;
|
|
38
|
+
nodeCount: number;
|
|
39
|
+
stringId: string;
|
|
40
|
+
}
|
|
41
|
+
export declare class MeshParser {
|
|
42
|
+
/**
|
|
43
|
+
* Parse mesh metadata from binary data
|
|
44
|
+
*/
|
|
45
|
+
static parseMeshMetadata(data: Uint8Array): MeshMetadata;
|
|
46
|
+
/**
|
|
47
|
+
* Parse complete mesh data including geometry, materials, and nodes
|
|
48
|
+
*/
|
|
49
|
+
static parseMeshData(metadataBlob: Uint8Array, dataBlob: Uint8Array): {
|
|
50
|
+
metadata: MeshMetadata;
|
|
51
|
+
geometries: MeshGeometryInfo[];
|
|
52
|
+
materials: THREE.Material[];
|
|
53
|
+
materialData: MaterialData[];
|
|
54
|
+
nodes: Node[];
|
|
55
|
+
meshIndices: Uint32Array;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Create Three.js BufferGeometry from mesh data
|
|
59
|
+
*/
|
|
60
|
+
static createGeometry(geoInfo: MeshGeometryInfo, dataBlob: Uint8Array): THREE.BufferGeometry;
|
|
61
|
+
/**
|
|
62
|
+
* Build Three.js scene from parsed mesh data
|
|
63
|
+
*/
|
|
64
|
+
static buildScene(parsedData: ReturnType<typeof MeshParser.parseMeshData>, dataBlob: Uint8Array): THREE.Group;
|
|
65
|
+
/**
|
|
66
|
+
* Read null-terminated string from buffer
|
|
67
|
+
*/
|
|
68
|
+
private static readString;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=MeshParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MeshParser.d.ts","sourceRoot":"","sources":["../src/MeshParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,WAAW,gBAAgB;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,IAAI;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,E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LoaderParameters {
|
|
4
|
+
/**
|
|
5
|
+
* Path to basis transcoder for KTX2 texture loading
|
|
6
|
+
* @default '/basis/'
|
|
7
|
+
*/
|
|
8
|
+
transcoderPath?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Path to WASM reader module
|
|
11
|
+
* @default '/stowkit_reader.wasm'
|
|
12
|
+
*/
|
|
13
|
+
wasmPath?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Custom StowKitReader instance (optional)
|
|
16
|
+
*/
|
|
17
|
+
reader?: StowKitReader;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Three.js loader for StowKit asset packs (.stow files)
|
|
21
|
+
*
|
|
22
|
+
* Usage:
|
|
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
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class StowKitLoader extends THREE.Loader {
|
|
34
|
+
private reader;
|
|
35
|
+
private ktx2Loader;
|
|
36
|
+
private ownedReader;
|
|
37
|
+
constructor(manager?: THREE.LoadingManager, parameters?: StowKitLoaderParameters);
|
|
38
|
+
/**
|
|
39
|
+
* Set the path to the Basis Universal transcoder
|
|
40
|
+
*/
|
|
41
|
+
setTranscoderPath(path: string): this;
|
|
42
|
+
/**
|
|
43
|
+
* Detect WebGL support for compressed textures
|
|
44
|
+
*/
|
|
45
|
+
detectSupport(renderer: THREE.WebGLRenderer): this;
|
|
46
|
+
/**
|
|
47
|
+
* Open a .stow pack file (call this first if loading multiple assets)
|
|
48
|
+
* @param url - URL to the .stow file
|
|
49
|
+
*/
|
|
50
|
+
openPack(url: string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Load and parse a mesh asset from a StowKit pack
|
|
53
|
+
* @param url - URL to the .stow file (or omit if already opened with openPack)
|
|
54
|
+
* @param assetPath - Path to the mesh asset within the pack
|
|
55
|
+
* @param onLoad - Callback when loading completes
|
|
56
|
+
* @param onProgress - Progress callback
|
|
57
|
+
* @param onError - Error callback
|
|
58
|
+
*/
|
|
59
|
+
loadMesh(url: string, assetPath: string, onLoad?: (scene: THREE.Group) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: Error) => void): Promise<THREE.Group>;
|
|
60
|
+
/**
|
|
61
|
+
* Load textures for materials
|
|
62
|
+
*/
|
|
63
|
+
private loadMaterialTextures;
|
|
64
|
+
/**
|
|
65
|
+
* Load a KTX2 texture from binary data
|
|
66
|
+
*/
|
|
67
|
+
private loadKTX2Texture;
|
|
68
|
+
/**
|
|
69
|
+
* Apply texture to appropriate material property
|
|
70
|
+
*/
|
|
71
|
+
private applyTextureToMaterial;
|
|
72
|
+
/**
|
|
73
|
+
* Load a texture asset from a StowKit pack
|
|
74
|
+
* @param url - URL to the .stow file (or omit if already opened with openPack)
|
|
75
|
+
* @param assetPath - Path to the texture asset within the pack
|
|
76
|
+
* @param onLoad - Callback when loading completes
|
|
77
|
+
* @param onProgress - Progress callback
|
|
78
|
+
* @param onError - Error callback
|
|
79
|
+
*/
|
|
80
|
+
loadTexture(url: string, assetPath: string, onLoad?: (texture: THREE.CompressedTexture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: Error) => void): Promise<THREE.CompressedTexture>;
|
|
81
|
+
/**
|
|
82
|
+
* Load a texture asset by its index in the pack
|
|
83
|
+
* @param index - Asset index
|
|
84
|
+
* @param onLoad - Callback when loading completes
|
|
85
|
+
* @param onProgress - Progress callback
|
|
86
|
+
* @param onError - Error callback
|
|
87
|
+
*/
|
|
88
|
+
loadTextureByIndex(index: number, onLoad?: (texture: THREE.CompressedTexture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: Error) => void): Promise<THREE.CompressedTexture>;
|
|
89
|
+
/**
|
|
90
|
+
* Load an audio asset from a StowKit pack
|
|
91
|
+
* @param url - URL to the .stow file (or omit if already opened with openPack)
|
|
92
|
+
* @param assetPath - Path to the audio asset within the pack
|
|
93
|
+
* @param listener - THREE.AudioListener to attach to
|
|
94
|
+
* @param onLoad - Callback when loading completes
|
|
95
|
+
* @param onProgress - Progress callback
|
|
96
|
+
* @param onError - Error callback
|
|
97
|
+
*/
|
|
98
|
+
loadAudio(url: string, assetPath: string, listener: THREE.AudioListener, onLoad?: (audio: THREE.Audio) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: Error) => void): Promise<THREE.Audio>;
|
|
99
|
+
/**
|
|
100
|
+
* Get metadata for an audio asset
|
|
101
|
+
* @param assetPath - Path to the audio asset within the pack
|
|
102
|
+
*/
|
|
103
|
+
getAudioMetadata(assetPath: string): {
|
|
104
|
+
stringId: string;
|
|
105
|
+
sampleRate: number;
|
|
106
|
+
channels: number;
|
|
107
|
+
durationMs: number;
|
|
108
|
+
} | null;
|
|
109
|
+
/**
|
|
110
|
+
* Get metadata for a texture asset
|
|
111
|
+
* @param assetPath - Path to the texture asset within the pack
|
|
112
|
+
*/
|
|
113
|
+
getTextureMetadata(assetPath: string): {
|
|
114
|
+
width: number;
|
|
115
|
+
height: number;
|
|
116
|
+
channels: number;
|
|
117
|
+
isKtx2: boolean;
|
|
118
|
+
channelFormat: number;
|
|
119
|
+
stringId: string;
|
|
120
|
+
} | null;
|
|
121
|
+
/**
|
|
122
|
+
* Load material schema information by index
|
|
123
|
+
* @param index - Asset index
|
|
124
|
+
*/
|
|
125
|
+
loadMaterialSchemaByIndex(index: number): {
|
|
126
|
+
stringId: string;
|
|
127
|
+
schemaName: string;
|
|
128
|
+
fields: Array<{
|
|
129
|
+
name: string;
|
|
130
|
+
type: 'Texture' | 'Color' | 'Float' | 'Vec2' | 'Vec3' | 'Vec4' | 'Int';
|
|
131
|
+
previewFlag: 'None' | 'MainTex' | 'Tint';
|
|
132
|
+
defaultValue: [number, number, number, number];
|
|
133
|
+
}>;
|
|
134
|
+
} | null;
|
|
135
|
+
/**
|
|
136
|
+
* Load material schema information by path
|
|
137
|
+
* @param assetPath - Path to the material schema asset
|
|
138
|
+
*/
|
|
139
|
+
loadMaterialSchema(assetPath: string): {
|
|
140
|
+
stringId: string;
|
|
141
|
+
schemaName: string;
|
|
142
|
+
fields: Array<{
|
|
143
|
+
name: string;
|
|
144
|
+
type: 'Texture' | 'Color' | 'Float' | 'Vec2' | 'Vec3' | 'Vec4' | 'Int';
|
|
145
|
+
previewFlag: 'None' | 'MainTex' | 'Tint';
|
|
146
|
+
defaultValue: [number, number, number, number];
|
|
147
|
+
}>;
|
|
148
|
+
} | null;
|
|
149
|
+
/**
|
|
150
|
+
* Get material information from a loaded mesh
|
|
151
|
+
* Returns material data including properties and texture references
|
|
152
|
+
*/
|
|
153
|
+
getMeshMaterials(assetPath: string): Array<{
|
|
154
|
+
name: string;
|
|
155
|
+
schemaId: string;
|
|
156
|
+
properties: Array<{
|
|
157
|
+
fieldName: string;
|
|
158
|
+
value: [number, number, number, number];
|
|
159
|
+
textureId: string;
|
|
160
|
+
}>;
|
|
161
|
+
}> | null;
|
|
162
|
+
/**
|
|
163
|
+
* Open a .stow file from a File or ArrayBuffer
|
|
164
|
+
*/
|
|
165
|
+
open(fileOrBuffer: ArrayBuffer | File): Promise<boolean>;
|
|
166
|
+
/**
|
|
167
|
+
* Get the total number of assets
|
|
168
|
+
*/
|
|
169
|
+
getAssetCount(): number;
|
|
170
|
+
/**
|
|
171
|
+
* Get info about a specific asset
|
|
172
|
+
*/
|
|
173
|
+
getAssetInfo(index: number): any;
|
|
174
|
+
/**
|
|
175
|
+
* Read asset data by index
|
|
176
|
+
*/
|
|
177
|
+
readAssetData(index: number): Uint8Array | null;
|
|
178
|
+
/**
|
|
179
|
+
* Read asset metadata by index
|
|
180
|
+
*/
|
|
181
|
+
readAssetMetadata(index: number): Uint8Array | null;
|
|
182
|
+
/**
|
|
183
|
+
* Parse texture metadata
|
|
184
|
+
*/
|
|
185
|
+
parseTextureMetadata(metadataBytes: Uint8Array): any;
|
|
186
|
+
/**
|
|
187
|
+
* Create an HTML audio element for preview
|
|
188
|
+
* @param index - Asset index
|
|
189
|
+
*/
|
|
190
|
+
createAudioPreview(index: number): Promise<HTMLAudioElement>;
|
|
191
|
+
/**
|
|
192
|
+
* List all assets in the opened pack
|
|
193
|
+
*/
|
|
194
|
+
listAssets(): Array<{
|
|
195
|
+
index: number;
|
|
196
|
+
name?: string;
|
|
197
|
+
type: number;
|
|
198
|
+
dataSize: number;
|
|
199
|
+
metadataSize: number;
|
|
200
|
+
}>;
|
|
201
|
+
/**
|
|
202
|
+
* Dispose of resources
|
|
203
|
+
*/
|
|
204
|
+
dispose(): void;
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=StowKitLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StowKitLoader.d.ts","sourceRoot":"","sources":["../src/StowKitLoader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,WAAW,uBAAuB;IACpC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,aAAc,SAAQ,KAAK,CAAC,MAAM;IAC3C,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,WAAW,CAAkB;gBAEzB,OAAO,CAAC,EAAE,KAAK,CAAC,cAAc,EAAE,UAAU,CAAC,EAAE,uBAAuB;IAyBhF;;OAEG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKrC;;OAEG;IACH,aAAa,C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lE;;OAEG;IACH,UAAU,IAAI,KAAK,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;KACxB,CAAC;IAIF;;OAEG;IACH,OAAO,IAAI,IAAI;CAMlB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @stowkit/three-loader
|
|
3
|
+
* Three.js loader for StowKit asset packs
|
|
4
|
+
*/
|
|
5
|
+
export { StowKitLoader } from './StowKitLoader';
|
|
6
|
+
export { MeshParser } from './MeshParser';
|
|
7
|
+
export type { MeshGeometryInfo, MaterialPropertyValue, MaterialData, Node, MeshMetadata } from './MeshParser';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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"}
|