@series-inc/stowkit-phaser-loader 0.1.18 → 0.1.20

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
@@ -1,267 +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.
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.
@@ -50,7 +50,7 @@ export declare class StowKitPhaserPack {
50
50
  /**
51
51
  * Get list of all assets in pack
52
52
  */
53
- listAssets(): import("@series-inc/stowkit-reader").AssetListItem[];
53
+ listAssets(): any;
54
54
  /**
55
55
  * Get asset count
56
56
  */
@@ -58,7 +58,7 @@ export declare class StowKitPhaserPack {
58
58
  /**
59
59
  * Get asset info by index
60
60
  */
61
- getAssetInfo(index: number): import("@series-inc/stowkit-reader").AssetInfo | null;
61
+ getAssetInfo(index: number): any;
62
62
  /**
63
63
  * Get texture metadata
64
64
  */
@@ -1 +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,M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a,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"}
@@ -290,6 +290,17 @@ class StowKitPhaserPack {
290
290
  format: transcoded.internalFormat
291
291
  };
292
292
  const phaserTexture = scene.textures.addCompressedTexture(key, compressedTextureData);
293
+ // Apply nearest filtering if metadata specifies it
294
+ const metadata = this.reader.parseTextureMetadata(assetIndex);
295
+ if (metadata?.filtering === 1) {
296
+ const glTexture = phaserTexture?.source?.[0]?.glTexture;
297
+ if (glTexture) {
298
+ gl.bindTexture(gl.TEXTURE_2D, glTexture);
299
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
300
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
301
+ gl.bindTexture(gl.TEXTURE_2D, null);
302
+ }
303
+ }
293
304
  this.textureCache.set(assetPath, phaserTexture);
294
305
  PerfLogger.log(`[Perf] ===== Total Phaser texture load: ${(performance.now() - totalStart).toFixed(2)}ms =====`);
295
306
  return phaserTexture;
@@ -362,8 +373,10 @@ class StowKitPhaserPack {
362
373
  }
363
374
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
364
375
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
365
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
366
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
376
+ // Apply nearest filtering if metadata specifies it (filtering === 1)
377
+ const useNearest = metadata?.filtering === 1;
378
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, useNearest ? gl.NEAREST : gl.LINEAR);
379
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, useNearest ? gl.NEAREST : gl.LINEAR);
367
380
  gl.bindTexture(gl.TEXTURE_2D, null);
368
381
  return {
369
382
  texture,