@series-inc/stowkit-phaser-loader 0.1.18
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 +267 -0
- package/dist/BasisTranscoder.d.ts +40 -0
- package/dist/BasisTranscoder.d.ts.map +1 -0
- package/dist/StowKitPhaserLoader.d.ts +53 -0
- package/dist/StowKitPhaserLoader.d.ts.map +1 -0
- package/dist/StowKitPhaserPack.d.ts +75 -0
- package/dist/StowKitPhaserPack.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/stowkit-phaser-loader.esm.js +623 -0
- package/dist/stowkit-phaser-loader.esm.js.map +1 -0
- package/dist/stowkit-phaser-loader.js +638 -0
- package/dist/stowkit-phaser-loader.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# @series-inc/stowkit-phaser-loader
|
|
2
|
+
|
|
3
|
+
Phaser.js loader for StowKit asset packs. Supports loading compressed textures (KTX2/Basis Universal) and audio from `.stow` files.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Compressed Texture Support** - Automatically decodes KTX2 textures to GPU-compressed formats (BC3/DXT5, BC1/DXT1, ASTC, ETC2, etc.)
|
|
8
|
+
- **Audio Loading** - Loads audio assets as Web Audio buffers or HTML5 audio elements
|
|
9
|
+
- **Multiple Packs** - Load multiple .stow files simultaneously with isolated state
|
|
10
|
+
- **Phaser Integration** - Textures are registered with Phaser's texture manager and work with all Phaser game objects
|
|
11
|
+
- **Efficient** - Textures remain compressed on the GPU, reducing memory usage
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @series-inc/stowkit-phaser-loader phaser
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import Phaser from 'phaser';
|
|
23
|
+
import { StowKitPhaserLoader } from '@series-inc/stowkit-phaser-loader';
|
|
24
|
+
|
|
25
|
+
class GameScene extends Phaser.Scene {
|
|
26
|
+
constructor() {
|
|
27
|
+
super('GameScene');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async create() {
|
|
31
|
+
const pack = await StowKitPhaserLoader.load('/assets/game.stow', {
|
|
32
|
+
basisPath: '/basis/',
|
|
33
|
+
wasmPath: '/stowkit/stowkit_reader.wasm'
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await pack.loadTexture('characters/player', this);
|
|
37
|
+
await pack.loadTexture('ui/button', this);
|
|
38
|
+
|
|
39
|
+
const player = this.add.sprite(400, 300, 'characters/player');
|
|
40
|
+
const button = this.add.image(100, 50, 'ui/button');
|
|
41
|
+
|
|
42
|
+
const bgmBuffer = await pack.loadAudio('sounds/bgm');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const config = {
|
|
47
|
+
type: Phaser.WEBGL,
|
|
48
|
+
width: 800,
|
|
49
|
+
height: 600,
|
|
50
|
+
scene: GameScene
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const game = new Phaser.Game(config);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## API Reference
|
|
57
|
+
|
|
58
|
+
### Exports
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
export { StowKitPhaserLoader } from '@series-inc/stowkit-phaser-loader';
|
|
62
|
+
export { StowKitPhaserPack } from '@series-inc/stowkit-phaser-loader';
|
|
63
|
+
export { BasisTranscoder } from '@series-inc/stowkit-phaser-loader';
|
|
64
|
+
export { AssetType, PerfLogger } from '@series-inc/stowkit-phaser-loader';
|
|
65
|
+
|
|
66
|
+
export type { StowKitPhaserLoaderOptions } from '@series-inc/stowkit-phaser-loader';
|
|
67
|
+
export type { TextureData } from '@series-inc/stowkit-phaser-loader';
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### StowKitPhaserLoader
|
|
71
|
+
|
|
72
|
+
Static loader class for opening `.stow` pack files.
|
|
73
|
+
|
|
74
|
+
#### `StowKitPhaserLoader.load(url, options?)`
|
|
75
|
+
|
|
76
|
+
Loads a `.stow` pack from a URL.
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const pack = await StowKitPhaserLoader.load('/assets/game.stow', {
|
|
80
|
+
basisPath: '/basis/',
|
|
81
|
+
wasmPath: '/stowkit/stowkit_reader.wasm'
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Options:**
|
|
86
|
+
- `basisPath` (string) - Path to Basis Universal transcoder files (default: `'/basis/'`)
|
|
87
|
+
- `wasmPath` (string) - Path to StowKit WASM module (default: `'/stowkit/stowkit_reader.wasm'`)
|
|
88
|
+
- `gl` (WebGLRenderingContext | WebGL2RenderingContext) - WebGL context to use. If not provided, a temporary canvas is created.
|
|
89
|
+
|
|
90
|
+
**Returns:** `Promise<StowKitPhaserPack>`
|
|
91
|
+
|
|
92
|
+
#### `StowKitPhaserLoader.loadFromMemory(data, options?)`
|
|
93
|
+
|
|
94
|
+
Loads a `.stow` pack from memory.
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
const response = await fetch('/assets/game.stow');
|
|
98
|
+
const buffer = await response.arrayBuffer();
|
|
99
|
+
const pack = await StowKitPhaserLoader.loadFromMemory(buffer);
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Parameters:**
|
|
103
|
+
- `data` (ArrayBuffer | Blob | File) - The `.stow` file data
|
|
104
|
+
- `options` (StowKitPhaserLoaderOptions, optional) - Loader options
|
|
105
|
+
|
|
106
|
+
**Returns:** `Promise<StowKitPhaserPack>`
|
|
107
|
+
|
|
108
|
+
#### `StowKitPhaserLoader.dispose()`
|
|
109
|
+
|
|
110
|
+
Dispose of shared resources (Basis transcoder and temporary WebGL context if one was created).
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
StowKitPhaserLoader.dispose();
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### StowKitPhaserPack
|
|
117
|
+
|
|
118
|
+
Represents an opened `.stow` pack file.
|
|
119
|
+
|
|
120
|
+
#### `pack.loadTexture(assetPath, scene)`
|
|
121
|
+
|
|
122
|
+
Loads a texture by its canonical path and registers it with Phaser's texture manager.
|
|
123
|
+
|
|
124
|
+
**Parameters:**
|
|
125
|
+
- `assetPath` (string) - The canonical path of the texture (e.g., `"characters/player"`)
|
|
126
|
+
- `scene` (Phaser.Scene) - The Phaser scene instance
|
|
127
|
+
|
|
128
|
+
**Returns:** `Promise<Phaser.Textures.Texture>`
|
|
129
|
+
|
|
130
|
+
Must be called after the Phaser scene is initialized (in or after `create()`).
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
await pack.loadTexture('textures/player', this);
|
|
134
|
+
this.add.sprite(100, 100, 'textures/player');
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### `pack.getPhaserTexture(index, scene)`
|
|
138
|
+
|
|
139
|
+
Loads a texture by index (useful for asset browsing/previews).
|
|
140
|
+
|
|
141
|
+
**Parameters:**
|
|
142
|
+
- `index` (number) - Asset index
|
|
143
|
+
- `scene` (Phaser.Scene) - The Phaser scene instance
|
|
144
|
+
|
|
145
|
+
**Returns:** `Promise<Phaser.Textures.Texture>`
|
|
146
|
+
|
|
147
|
+
#### `pack.loadAudio(assetPath, audioContext?)`
|
|
148
|
+
|
|
149
|
+
Loads audio by path as an AudioBuffer.
|
|
150
|
+
|
|
151
|
+
**Parameters:**
|
|
152
|
+
- `assetPath` (string) - The canonical path of the audio asset
|
|
153
|
+
- `audioContext` (AudioContext, optional) - Web Audio context to use
|
|
154
|
+
|
|
155
|
+
**Returns:** `Promise<AudioBuffer>`
|
|
156
|
+
|
|
157
|
+
#### `pack.loadAudioByIndex(index, audioContext?)`
|
|
158
|
+
|
|
159
|
+
Loads audio by index as an AudioBuffer.
|
|
160
|
+
|
|
161
|
+
**Parameters:**
|
|
162
|
+
- `index` (number) - Asset index
|
|
163
|
+
- `audioContext` (AudioContext, optional) - Web Audio context to use
|
|
164
|
+
|
|
165
|
+
**Returns:** `Promise<AudioBuffer>`
|
|
166
|
+
|
|
167
|
+
#### `pack.createAudioPreview(index)`
|
|
168
|
+
|
|
169
|
+
Creates an HTML5 audio element for preview.
|
|
170
|
+
|
|
171
|
+
**Returns:** `Promise<HTMLAudioElement>`
|
|
172
|
+
|
|
173
|
+
#### `pack.listAssets()`
|
|
174
|
+
|
|
175
|
+
Returns array of all assets in the pack.
|
|
176
|
+
|
|
177
|
+
#### `pack.getAssetCount(): number`
|
|
178
|
+
|
|
179
|
+
Returns total number of assets.
|
|
180
|
+
|
|
181
|
+
#### `pack.getAssetInfo(index)`
|
|
182
|
+
|
|
183
|
+
Get asset info by index.
|
|
184
|
+
|
|
185
|
+
#### `pack.getTextureMetadata(index)`
|
|
186
|
+
|
|
187
|
+
Get texture metadata (dimensions, format, tags, etc.) using WASM parsing.
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
const texData = pack.getTextureMetadata(index);
|
|
191
|
+
console.log(`${texData.width}x${texData.height}, ${texData.channels} channels`);
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
#### `pack.getAudioMetadata(index)`
|
|
195
|
+
|
|
196
|
+
Get audio metadata using WASM parsing.
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
const audioData = pack.getAudioMetadata(index);
|
|
200
|
+
console.log(`${audioData.sampleRate}Hz, ${audioData.durationMs}ms`);
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### `pack.dispose()`
|
|
204
|
+
|
|
205
|
+
Closes the pack and frees resources.
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
pack.dispose();
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Loading Multiple Packs
|
|
212
|
+
|
|
213
|
+
Each pack is fully isolated with its own WASM reader instance. You can load multiple packs simultaneously:
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
class GameScene extends Phaser.Scene {
|
|
217
|
+
async create() {
|
|
218
|
+
const [uiPack, levelPack, characterPack] = await Promise.all([
|
|
219
|
+
StowKitPhaserLoader.load('/assets/ui.stow'),
|
|
220
|
+
StowKitPhaserLoader.load('/assets/level1.stow'),
|
|
221
|
+
StowKitPhaserLoader.load('/assets/characters.stow')
|
|
222
|
+
]);
|
|
223
|
+
|
|
224
|
+
await uiPack.loadTexture('button', this);
|
|
225
|
+
await levelPack.loadTexture('background', this);
|
|
226
|
+
await characterPack.loadTexture('player', this);
|
|
227
|
+
|
|
228
|
+
this.add.image(100, 50, 'button');
|
|
229
|
+
this.add.image(0, 0, 'background');
|
|
230
|
+
this.add.sprite(400, 300, 'player');
|
|
231
|
+
|
|
232
|
+
console.log(`UI Pack: ${uiPack.getAssetCount()} assets`);
|
|
233
|
+
console.log(`Level Pack: ${levelPack.getAssetCount()} assets`);
|
|
234
|
+
console.log(`Character Pack: ${characterPack.getAssetCount()} assets`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Dispose packs when no longer needed:
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
uiPack.dispose();
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Compressed Texture Formats
|
|
246
|
+
|
|
247
|
+
The loader automatically transcodes KTX2 textures to the best format supported by the device:
|
|
248
|
+
|
|
249
|
+
**Desktop (DXT/BC formats):**
|
|
250
|
+
- BC7 (BPTC) - Highest quality for UASTC textures with alpha (requires WebGL2 + `EXT_texture_compression_bptc`)
|
|
251
|
+
- BC3 (DXT5) - High quality for textures with alpha
|
|
252
|
+
- BC1 (DXT1) - For textures without alpha or ETC1S encoded textures
|
|
253
|
+
|
|
254
|
+
**Mobile:**
|
|
255
|
+
- ASTC 4x4 - Highest quality (iOS, Android with GPU support)
|
|
256
|
+
- ETC2 - Good quality (WebGL2 required)
|
|
257
|
+
- ETC1 - Legacy Android support
|
|
258
|
+
- PVRTC - iOS fallback
|
|
259
|
+
|
|
260
|
+
**Fallback:**
|
|
261
|
+
- RGBA32 - Uncompressed fallback if no compressed formats are supported
|
|
262
|
+
|
|
263
|
+
## Limitations
|
|
264
|
+
|
|
265
|
+
- **No 3D Model Support** - This loader only handles 2D textures and audio. For 3D models, use `@series-inc/stowkit-three-loader`.
|
|
266
|
+
- **Phaser 3.60+** - Compressed texture support requires Phaser 3.60 or later.
|
|
267
|
+
- **Scene Required** - Textures must be loaded within or after a Phaser scene is initialized.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BasisTranscoder - Manually decode KTX2 textures to WebGL textures
|
|
3
|
+
* Used for Phaser which doesn't have built-in KTX2 support
|
|
4
|
+
*/
|
|
5
|
+
export interface TranscodedTexture {
|
|
6
|
+
data: Uint8Array;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
format: number;
|
|
10
|
+
internalFormat?: number;
|
|
11
|
+
compressed: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class BasisTranscoder {
|
|
14
|
+
private module;
|
|
15
|
+
private initialized;
|
|
16
|
+
private initPromise;
|
|
17
|
+
private basisPath;
|
|
18
|
+
constructor(basisPath?: string);
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the Basis Universal transcoder
|
|
21
|
+
*/
|
|
22
|
+
init(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Load the basis transcoder module
|
|
25
|
+
*/
|
|
26
|
+
private loadBasisModule;
|
|
27
|
+
/**
|
|
28
|
+
* Transcode KTX2 data to a WebGL-compatible format
|
|
29
|
+
*/
|
|
30
|
+
transcodeKTX2(data: Uint8Array, gl: WebGLRenderingContext | WebGL2RenderingContext): Promise<TranscodedTexture>;
|
|
31
|
+
/**
|
|
32
|
+
* Detect the best compression format supported by the device
|
|
33
|
+
*/
|
|
34
|
+
private detectBestFormat;
|
|
35
|
+
/**
|
|
36
|
+
* Dispose resources
|
|
37
|
+
*/
|
|
38
|
+
dispose(): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=BasisTranscoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasisTranscoder.d.ts","sourceRoot":"","sources":["../src/BasisTranscoder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgFH,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;CACvB;AAED,qBAAa,eAAe;IACxB,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,SAAS,CAAS;gBAEd,SAAS,GAAE,MAAkB;IAIzC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB3B;;OAEG;YACW,eAAe;IAyB7B;;OAEG;IACG,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,qBAAqB,GAAG,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAoFrH;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAsGxB;;OAEG;IACH,OAAO,IAAI,IAAI;CAKlB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { StowKitPhaserPack } from './StowKitPhaserPack';
|
|
2
|
+
export interface StowKitPhaserLoaderOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Path to basis transcoder for KTX2 texture loading
|
|
5
|
+
* @default '/basis/'
|
|
6
|
+
*/
|
|
7
|
+
basisPath?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Path to WASM reader module
|
|
10
|
+
* @default '/stowkit/stowkit_reader.wasm'
|
|
11
|
+
*/
|
|
12
|
+
wasmPath?: string;
|
|
13
|
+
/**
|
|
14
|
+
* WebGL context to use for texture loading
|
|
15
|
+
* If not provided, a temporary canvas will be created
|
|
16
|
+
*/
|
|
17
|
+
gl?: WebGLRenderingContext | WebGL2RenderingContext;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Phaser loader for StowKit asset packs
|
|
21
|
+
* Supports images and audio only (no 3D models)
|
|
22
|
+
*
|
|
23
|
+
* Usage:
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const pack = await StowKitPhaserLoader.load('assets.stow');
|
|
26
|
+
* const texture = await pack.loadTexture('textures/player');
|
|
27
|
+
* const audio = await pack.loadAudio('sounds/bgm');
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class StowKitPhaserLoader {
|
|
31
|
+
private static transcoder;
|
|
32
|
+
private static initialized;
|
|
33
|
+
private static gl;
|
|
34
|
+
private static ownGl;
|
|
35
|
+
private static wasmPath;
|
|
36
|
+
/**
|
|
37
|
+
* Load a .stow pack file from a URL
|
|
38
|
+
*/
|
|
39
|
+
static load(url: string, options?: StowKitPhaserLoaderOptions): Promise<StowKitPhaserPack>;
|
|
40
|
+
/**
|
|
41
|
+
* Load a .stow pack from memory (ArrayBuffer, Blob, or File)
|
|
42
|
+
*/
|
|
43
|
+
static loadFromMemory(data: ArrayBuffer | Blob | File, options?: StowKitPhaserLoaderOptions): Promise<StowKitPhaserPack>;
|
|
44
|
+
/**
|
|
45
|
+
* Initialize the loader (called automatically on first load)
|
|
46
|
+
*/
|
|
47
|
+
private static initialize;
|
|
48
|
+
/**
|
|
49
|
+
* Dispose of shared resources
|
|
50
|
+
*/
|
|
51
|
+
static dispose(): void;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=StowKitPhaserLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StowKitPhaserLoader.d.ts","sourceRoot":"","sources":["../src/StowKitPhaserLoader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,WAAW,0BAA0B;IACvC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,EAAE,CAAC,EAAE,qBAAqB,GAAG,sBAAsB,CAAC;CACvD;AAED;;;;;;;;;;GAUG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAgC;IACzD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAS;IACnC,OAAO,CAAC,MAAM,CAAC,EAAE,CAA+D;IAChF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAS;IAC7B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA0C;IAEjE;;OAEG;WACU,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAuBhG;;OAEG;WACU,cAAc,CACvB,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,EAC/B,OAAO,CAAC,EAAE,0BAA0B,GACrC,OAAO,CAAC,iBAAiB,CAAC;IA2B7B;;OAEG;mBACkB,UAAU;IA8B/B;;OAEG;IACH,MAAM,CAAC,OAAO,IAAI,IAAI;CAiBzB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { StowKitReader } from '@series-inc/stowkit-reader';
|
|
2
|
+
import { BasisTranscoder } from './BasisTranscoder';
|
|
3
|
+
export interface TextureData {
|
|
4
|
+
texture: WebGLTexture;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Represents an opened StowKit pack for Phaser
|
|
10
|
+
* Supports loading images and audio only (no 3D models)
|
|
11
|
+
*/
|
|
12
|
+
export declare class StowKitPhaserPack {
|
|
13
|
+
reader: StowKitReader;
|
|
14
|
+
private transcoder;
|
|
15
|
+
private tempGl;
|
|
16
|
+
private textureCache;
|
|
17
|
+
private transcodedDataCache;
|
|
18
|
+
constructor(reader: StowKitReader, transcoder: BasisTranscoder, gl: WebGLRenderingContext | WebGL2RenderingContext);
|
|
19
|
+
/**
|
|
20
|
+
* Load a texture by its canonical path/name
|
|
21
|
+
* Returns a Phaser texture
|
|
22
|
+
*/
|
|
23
|
+
loadTexture(assetPath: string, scene: any): Promise<any>;
|
|
24
|
+
/**
|
|
25
|
+
* Get a Phaser texture by index (for previews/demos)
|
|
26
|
+
* Creates compressed texture directly in Phaser's GL context
|
|
27
|
+
*/
|
|
28
|
+
getPhaserTexture(index: number, scene: any): Promise<any>;
|
|
29
|
+
/**
|
|
30
|
+
* Load texture by index into a specific GL context
|
|
31
|
+
*/
|
|
32
|
+
private loadTextureInContext;
|
|
33
|
+
/**
|
|
34
|
+
* Load uncompressed image (PNG, JPEG) as WebGL texture in a specific context
|
|
35
|
+
*/
|
|
36
|
+
private loadUncompressedTextureInContext;
|
|
37
|
+
/**
|
|
38
|
+
* Load audio by its canonical path/name
|
|
39
|
+
* Returns an AudioBuffer
|
|
40
|
+
*/
|
|
41
|
+
loadAudio(assetPath: string, audioContext?: AudioContext): Promise<AudioBuffer>;
|
|
42
|
+
/**
|
|
43
|
+
* Load audio by index
|
|
44
|
+
*/
|
|
45
|
+
loadAudioByIndex(index: number, audioContext?: AudioContext): Promise<AudioBuffer>;
|
|
46
|
+
/**
|
|
47
|
+
* Create an HTML audio element for preview
|
|
48
|
+
*/
|
|
49
|
+
createAudioPreview(index: number): Promise<HTMLAudioElement>;
|
|
50
|
+
/**
|
|
51
|
+
* Get list of all assets in pack
|
|
52
|
+
*/
|
|
53
|
+
listAssets(): import("@series-inc/stowkit-reader").AssetListItem[];
|
|
54
|
+
/**
|
|
55
|
+
* Get asset count
|
|
56
|
+
*/
|
|
57
|
+
getAssetCount(): number;
|
|
58
|
+
/**
|
|
59
|
+
* Get asset info by index
|
|
60
|
+
*/
|
|
61
|
+
getAssetInfo(index: number): import("@series-inc/stowkit-reader").AssetInfo | null;
|
|
62
|
+
/**
|
|
63
|
+
* Get texture metadata
|
|
64
|
+
*/
|
|
65
|
+
getTextureMetadata(index: number): any;
|
|
66
|
+
/**
|
|
67
|
+
* Get audio metadata
|
|
68
|
+
*/
|
|
69
|
+
getAudioMetadata(index: number): any;
|
|
70
|
+
/**
|
|
71
|
+
* Close the pack and free resources
|
|
72
|
+
*/
|
|
73
|
+
dispose(): void;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=StowKitPhaserPack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StowKitPhaserPack.d.ts","sourceRoot":"","sources":["../src/StowKitPhaserPack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAyB,MAAM,4BAA4B,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,qBAAa,iBAAiB;IACnB,MAAM,EAAE,aAAa,CAAC;IAC7B,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,MAAM,CAAiD;IAC/D,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,mBAAmB,CAA6I;gBAGpK,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,eAAe,EAC3B,EAAE,EAAE,qBAAqB,GAAG,sBAAsB;IAOtD;;;OAGG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAyD9D;;;OAGG;IACG,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IA4C/D;;OAEG;YACW,oBAAoB;IAiElC;;OAEG;YACW,gCAAgC;IAiD9C;;;OAGG;IACG,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAgBrF;;OAEG;IACG,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAgBxF;;OAEG;IACG,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAoBlE;;OAEG;IACH,UAAU;IAIV;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM;IAI1B;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,MAAM;IAIhC;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM;IAI9B;;OAEG;IACH,OAAO,IAAI,IAAI;CAQlB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @series-inc/stowkit-phaser-loader
|
|
3
|
+
* Phaser loader for StowKit asset packs (images and audio only)
|
|
4
|
+
*/
|
|
5
|
+
export { StowKitPhaserLoader } from './StowKitPhaserLoader';
|
|
6
|
+
export { StowKitPhaserPack } from './StowKitPhaserPack';
|
|
7
|
+
export { BasisTranscoder } from './BasisTranscoder';
|
|
8
|
+
export { PerfLogger } from '@series-inc/stowkit-reader';
|
|
9
|
+
export type { StowKitPhaserLoaderOptions } from './StowKitPhaserLoader';
|
|
10
|
+
export type { TextureData } from './StowKitPhaserPack';
|
|
11
|
+
export { AssetType } from '@series-inc/stowkit-reader';
|
|
12
|
+
//# 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,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,YAAY,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACxE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC"}
|