@vpmedia/phaser 1.94.0 → 1.96.0
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/CHANGELOG.md +41 -0
- package/package.json +11 -11
- package/src/phaser/core/animation.js +79 -56
- package/src/phaser/core/animation_manager.js +55 -55
- package/src/phaser/core/animation_parser.js +2 -2
- package/src/phaser/core/cache.js +154 -154
- package/src/phaser/core/device.js +2 -1
- package/src/phaser/core/device_util.js +27 -27
- package/src/phaser/core/dom.js +43 -43
- package/src/phaser/core/event_manager.js +63 -63
- package/src/phaser/core/factory.js +47 -47
- package/src/phaser/core/frame.js +30 -30
- package/src/phaser/core/frame_data.js +30 -28
- package/src/phaser/core/frame_util.js +8 -8
- package/src/phaser/core/game.js +35 -19
- package/src/phaser/core/input_pointer.js +18 -0
- package/src/phaser/core/loader.js +171 -171
- package/src/phaser/core/loader_parser.js +22 -22
- package/src/phaser/core/raf.js +1 -1
- package/src/phaser/core/scale_manager.js +3 -2
- package/src/phaser/core/scene.js +16 -10
- package/src/phaser/core/scene_manager.js +51 -43
- package/src/phaser/core/signal.js +56 -52
- package/src/phaser/core/sound.js +54 -54
- package/src/phaser/core/sound_manager.js +49 -49
- package/src/phaser/core/stage.js +16 -16
- package/src/phaser/core/time.js +54 -30
- package/src/phaser/core/timer.js +82 -64
- package/src/phaser/core/timer_event.js +9 -9
- package/src/phaser/core/tween.js +106 -90
- package/src/phaser/core/tween_data.js +30 -30
- package/src/phaser/core/tween_manager.js +32 -24
- package/src/phaser/core/world.js +4 -3
- package/src/phaser/display/bitmap_text.js +72 -54
- package/src/phaser/display/button.js +48 -47
- package/src/phaser/display/canvas/buffer.js +8 -8
- package/src/phaser/display/canvas/graphics.js +8 -8
- package/src/phaser/display/canvas/masker.js +5 -5
- package/src/phaser/display/canvas/pool.js +18 -18
- package/src/phaser/display/canvas/renderer.js +17 -16
- package/src/phaser/display/canvas/tinter.js +22 -22
- package/src/phaser/display/canvas/util.js +42 -42
- package/src/phaser/display/display_object.js +119 -108
- package/src/phaser/display/graphics.js +129 -112
- package/src/phaser/display/graphics_data.js +10 -10
- package/src/phaser/display/graphics_data_util.js +3 -3
- package/src/phaser/display/group.js +63 -50
- package/src/phaser/display/image.js +68 -50
- package/src/phaser/display/sprite_batch.js +2 -2
- package/src/phaser/display/sprite_util.js +19 -19
- package/src/phaser/display/text.js +217 -187
- package/src/phaser/display/webgl/abstract_filter.js +4 -4
- package/src/phaser/display/webgl/base_texture.js +9 -9
- package/src/phaser/display/webgl/blend_manager.js +7 -7
- package/src/phaser/display/webgl/earcut.js +95 -95
- package/src/phaser/display/webgl/earcut_node.js +4 -4
- package/src/phaser/display/webgl/fast_sprite_batch.js +15 -15
- package/src/phaser/display/webgl/filter_manager.js +9 -9
- package/src/phaser/display/webgl/filter_texture.js +10 -10
- package/src/phaser/display/webgl/graphics.js +37 -37
- package/src/phaser/display/webgl/graphics_data.js +4 -4
- package/src/phaser/display/webgl/mask_manager.js +6 -6
- package/src/phaser/display/webgl/render_texture.js +16 -16
- package/src/phaser/display/webgl/renderer.js +21 -20
- package/src/phaser/display/webgl/shader/complex.js +4 -4
- package/src/phaser/display/webgl/shader/fast.js +4 -4
- package/src/phaser/display/webgl/shader/normal.js +8 -8
- package/src/phaser/display/webgl/shader/primitive.js +4 -4
- package/src/phaser/display/webgl/shader/strip.js +4 -4
- package/src/phaser/display/webgl/shader_manager.js +9 -9
- package/src/phaser/display/webgl/sprite_batch.js +18 -18
- package/src/phaser/display/webgl/stencil_manager.js +16 -16
- package/src/phaser/display/webgl/texture.js +13 -13
- package/src/phaser/display/webgl/texture_util.js +8 -8
- package/src/phaser/display/webgl/util.js +25 -25
- package/src/phaser/geom/circle.js +74 -69
- package/src/phaser/geom/ellipse.js +33 -28
- package/src/phaser/geom/line.js +96 -93
- package/src/phaser/geom/matrix.js +61 -54
- package/src/phaser/geom/point.js +99 -96
- package/src/phaser/geom/polygon.js +27 -22
- package/src/phaser/geom/rectangle.js +137 -132
- package/src/phaser/geom/rounded_rectangle.js +12 -12
- package/src/phaser/geom/util/circle.js +33 -33
- package/src/phaser/geom/util/ellipse.js +5 -5
- package/src/phaser/geom/util/line.js +26 -26
- package/src/phaser/geom/util/matrix.js +8 -8
- package/src/phaser/geom/util/point.js +97 -97
- package/src/phaser/geom/util/polygon.js +4 -4
- package/src/phaser/geom/util/rectangle.js +74 -74
- package/src/phaser/geom/util/rounded_rectangle.js +4 -4
- package/src/phaser/util/math.js +81 -81
- package/types/phaser/core/animation.d.ts +79 -56
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +55 -55
- package/types/phaser/core/animation_parser.d.ts +3 -2
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/cache.d.ts +154 -154
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +51 -44
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +63 -63
- package/types/phaser/core/factory.d.ts +47 -47
- package/types/phaser/core/frame.d.ts +30 -30
- package/types/phaser/core/frame_data.d.ts +28 -27
- package/types/phaser/core/frame_data.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +54 -21
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +18 -0
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +175 -172
- package/types/phaser/core/loader.d.ts.map +1 -1
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +1 -1
- package/types/phaser/core/scale_manager.d.ts +6 -5
- package/types/phaser/core/scale_manager.d.ts.map +1 -1
- package/types/phaser/core/scene.d.ts +15 -9
- package/types/phaser/core/scene.d.ts.map +1 -1
- package/types/phaser/core/scene_manager.d.ts +51 -43
- package/types/phaser/core/scene_manager.d.ts.map +1 -1
- package/types/phaser/core/signal.d.ts +54 -51
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/sound.d.ts +54 -54
- package/types/phaser/core/sound_manager.d.ts +49 -49
- package/types/phaser/core/stage.d.ts +10 -10
- package/types/phaser/core/time.d.ts +54 -30
- package/types/phaser/core/time.d.ts.map +1 -1
- package/types/phaser/core/timer.d.ts +82 -64
- package/types/phaser/core/timer.d.ts.map +1 -1
- package/types/phaser/core/timer_event.d.ts +9 -9
- package/types/phaser/core/tween.d.ts +106 -90
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +30 -30
- package/types/phaser/core/tween_manager.d.ts +35 -67
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/core/world.d.ts +4 -3
- package/types/phaser/core/world.d.ts.map +1 -1
- package/types/phaser/display/bitmap_text.d.ts +76 -53
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +47 -46
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +8 -8
- package/types/phaser/display/canvas/graphics.d.ts +3 -3
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +6 -3
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +18 -17
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts +6 -6
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +119 -108
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +118 -102
- package/types/phaser/display/graphics.d.ts.map +1 -1
- package/types/phaser/display/graphics_data.d.ts +10 -10
- package/types/phaser/display/group.d.ts +59 -47
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +58 -45
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +237 -188
- package/types/phaser/display/text.d.ts.map +1 -1
- package/types/phaser/display/webgl/abstract_filter.d.ts +4 -4
- package/types/phaser/display/webgl/base_texture.d.ts +10 -10
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/blend_manager.d.ts +6 -6
- package/types/phaser/display/webgl/earcut.d.ts +95 -95
- package/types/phaser/display/webgl/earcut_node.d.ts +4 -4
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +15 -15
- package/types/phaser/display/webgl/filter_manager.d.ts +8 -8
- package/types/phaser/display/webgl/filter_texture.d.ts +10 -10
- package/types/phaser/display/webgl/graphics.d.ts +2 -2
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +4 -4
- package/types/phaser/display/webgl/render_texture.d.ts +16 -16
- package/types/phaser/display/webgl/renderer.d.ts +21 -20
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +4 -4
- package/types/phaser/display/webgl/shader/fast.d.ts +4 -4
- package/types/phaser/display/webgl/shader/normal.d.ts +8 -8
- package/types/phaser/display/webgl/shader/primitive.d.ts +4 -4
- package/types/phaser/display/webgl/shader/strip.d.ts +4 -4
- package/types/phaser/display/webgl/shader_manager.d.ts +8 -8
- package/types/phaser/display/webgl/sprite_batch.d.ts +17 -17
- package/types/phaser/display/webgl/stencil_manager.d.ts +15 -15
- package/types/phaser/display/webgl/texture.d.ts +12 -12
- package/types/phaser/display/webgl/texture_util.d.ts +4 -2
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +74 -69
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +33 -28
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +96 -93
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +61 -54
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +99 -96
- package/types/phaser/geom/point.d.ts.map +1 -1
- package/types/phaser/geom/polygon.d.ts +29 -23
- package/types/phaser/geom/polygon.d.ts.map +1 -1
- package/types/phaser/geom/rectangle.d.ts +137 -132
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
- package/types/phaser/geom/util/point.d.ts +1 -1
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/pnpm-workspace.yaml +0 -4
|
@@ -3,7 +3,7 @@ import { NormalShader } from './shader/normal.js';
|
|
|
3
3
|
|
|
4
4
|
export class WebGLSpriteBatch {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Creates a new SpriteBatch instance.
|
|
7
7
|
*/
|
|
8
8
|
constructor() {
|
|
9
9
|
this.vertSize = 5;
|
|
@@ -45,8 +45,8 @@ export class WebGLSpriteBatch {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
49
|
-
* @param {WebGLRenderingContext & { id: number }} gl -
|
|
48
|
+
* Renders a sprite using WebGL.
|
|
49
|
+
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
50
50
|
*/
|
|
51
51
|
setContext(gl) {
|
|
52
52
|
this.gl = gl;
|
|
@@ -68,8 +68,8 @@ export class WebGLSpriteBatch {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
72
|
-
* @param {object} renderSession -
|
|
71
|
+
* Renders the sprite batch using WebGL.
|
|
72
|
+
* @param {object} renderSession - The render session to use.
|
|
73
73
|
*/
|
|
74
74
|
begin(renderSession) {
|
|
75
75
|
this.renderSession = renderSession;
|
|
@@ -78,16 +78,16 @@ export class WebGLSpriteBatch {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
81
|
+
* Updates the sprite batch.
|
|
82
82
|
*/
|
|
83
83
|
end() {
|
|
84
84
|
this.flush();
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
89
|
-
* @param {import('../../display/image.js').Image} sprite -
|
|
90
|
-
* @param {import('../../geom/matrix.js').Matrix} matrix -
|
|
88
|
+
* Renders a sprite using the sprite batch.
|
|
89
|
+
* @param {import('../../display/image.js').Image} sprite - The sprite to render.
|
|
90
|
+
* @param {import('../../geom/matrix.js').Matrix} matrix - The transformation matrix.
|
|
91
91
|
*/
|
|
92
92
|
render(sprite, matrix) {
|
|
93
93
|
const texture = sprite.texture;
|
|
@@ -187,14 +187,14 @@ export class WebGLSpriteBatch {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
/**
|
|
190
|
-
*
|
|
190
|
+
* Binds the sprite batch to the WebGL context.
|
|
191
191
|
*/
|
|
192
192
|
renderTilingSprite() {
|
|
193
193
|
// TODO
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
/**
|
|
197
|
-
*
|
|
197
|
+
* Updates the sprite batch.
|
|
198
198
|
*/
|
|
199
199
|
flush() {
|
|
200
200
|
// If the batch is length 0 then return as there is nothing to draw
|
|
@@ -293,10 +293,10 @@ export class WebGLSpriteBatch {
|
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
/**
|
|
296
|
-
*
|
|
297
|
-
* @param {import('./base_texture.js').BaseTexture} texture -
|
|
298
|
-
* @param {number} size -
|
|
299
|
-
* @param {number} startIndex -
|
|
296
|
+
* Updates the sprite batch with a new texture.
|
|
297
|
+
* @param {import('./base_texture.js').BaseTexture} texture - The texture to use.
|
|
298
|
+
* @param {number} size - The size of the batch.
|
|
299
|
+
* @param {number} startIndex - The start index in the batch.
|
|
300
300
|
*/
|
|
301
301
|
renderBatch(texture, size, startIndex) {
|
|
302
302
|
if (size === 0) {
|
|
@@ -320,7 +320,7 @@ export class WebGLSpriteBatch {
|
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
/**
|
|
323
|
-
*
|
|
323
|
+
* Destroys this sprite batch and cleans up resources.
|
|
324
324
|
*/
|
|
325
325
|
stop() {
|
|
326
326
|
this.flush();
|
|
@@ -328,14 +328,14 @@ export class WebGLSpriteBatch {
|
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
/**
|
|
331
|
-
*
|
|
331
|
+
* Renders the sprite batch using Canvas.
|
|
332
332
|
*/
|
|
333
333
|
start() {
|
|
334
334
|
this.dirty = true;
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
/**
|
|
338
|
-
*
|
|
338
|
+
* Destroys the sprite batch instance.
|
|
339
339
|
*/
|
|
340
340
|
destroy() {
|
|
341
341
|
this.vertices = null;
|
|
@@ -2,7 +2,7 @@ import { hex2rgb } from '../../util/math.js';
|
|
|
2
2
|
|
|
3
3
|
export class WebGLStencilManager {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Initializes the stencil manager.
|
|
6
6
|
*/
|
|
7
7
|
constructor() {
|
|
8
8
|
this.stencilStack = [];
|
|
@@ -11,15 +11,15 @@ export class WebGLStencilManager {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @param {WebGLRenderingContext} gl -
|
|
14
|
+
* Binds the stencil buffer for rendering.
|
|
15
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
16
16
|
*/
|
|
17
17
|
setContext(gl) {
|
|
18
18
|
this.gl = gl;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Sets up the stencil buffer for rendering.
|
|
23
23
|
*/
|
|
24
24
|
destroy() {
|
|
25
25
|
this.stencilStack = null;
|
|
@@ -27,10 +27,10 @@ export class WebGLStencilManager {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @param {import('../graphics.js').Graphics} graphics -
|
|
32
|
-
* @param {import('./graphics_data.js').GraphicsData} webGLData -
|
|
33
|
-
* @param {object} renderSession -
|
|
30
|
+
* Renders the stencil buffer for graphics.
|
|
31
|
+
* @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
|
|
32
|
+
* @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
|
|
33
|
+
* @param {object} renderSession - The rendering session.
|
|
34
34
|
*/
|
|
35
35
|
pushStencil(graphics, webGLData, renderSession) {
|
|
36
36
|
const gl = renderSession.gl;
|
|
@@ -85,10 +85,10 @@ export class WebGLStencilManager {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
89
|
-
* @param {import('../graphics.js').Graphics} graphics -
|
|
90
|
-
* @param {import('./graphics_data.js').GraphicsData} webGLData -
|
|
91
|
-
* @param {object} renderSession -
|
|
88
|
+
* Renders the stencil buffer for graphics.
|
|
89
|
+
* @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
|
|
90
|
+
* @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
|
|
91
|
+
* @param {object} renderSession - The rendering session.
|
|
92
92
|
*/
|
|
93
93
|
bindGraphics(graphics, webGLData, renderSession) {
|
|
94
94
|
// if(this._currentGraphics === graphics)return;
|
|
@@ -132,10 +132,10 @@ export class WebGLStencilManager {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
|
-
*
|
|
136
|
-
* @param {import('../graphics.js').Graphics} graphics -
|
|
137
|
-
* @param {import('./graphics_data.js').GraphicsData} webGLData -
|
|
138
|
-
* @param {object} renderSession -
|
|
135
|
+
* Renders the stencil buffer for graphics.
|
|
136
|
+
* @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
|
|
137
|
+
* @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
|
|
138
|
+
* @param {object} renderSession - The rendering session.
|
|
139
139
|
*/
|
|
140
140
|
popStencil(graphics, webGLData, renderSession) {
|
|
141
141
|
const gl = renderSession.gl;
|
|
@@ -2,7 +2,7 @@ import { Rectangle } from '../../geom/rectangle.js';
|
|
|
2
2
|
|
|
3
3
|
export class TextureUvs {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Creates a new Texture instance.
|
|
6
6
|
*/
|
|
7
7
|
constructor() {
|
|
8
8
|
this.x0 = 0;
|
|
@@ -18,11 +18,11 @@ export class TextureUvs {
|
|
|
18
18
|
|
|
19
19
|
export class Texture {
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @param {import('./base_texture.js').BaseTexture} baseTexture -
|
|
23
|
-
* @param {Rectangle | null | undefined} frame -
|
|
24
|
-
* @param {Rectangle | null | undefined} crop -
|
|
25
|
-
* @param {Rectangle | null | undefined} trim -
|
|
21
|
+
* Creates a new Texture instance.
|
|
22
|
+
* @param {import('./base_texture.js').BaseTexture} baseTexture - The base texture to use.
|
|
23
|
+
* @param {Rectangle | null | undefined} frame - The frame rectangle.
|
|
24
|
+
* @param {Rectangle | null | undefined} crop - The crop rectangle.
|
|
25
|
+
* @param {Rectangle | null | undefined} trim - The trim rectangle.
|
|
26
26
|
*/
|
|
27
27
|
constructor(baseTexture, frame = null, crop = null, trim = null) {
|
|
28
28
|
this.noFrame = false;
|
|
@@ -63,7 +63,7 @@ export class Texture {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* Destroys this texture and cleans up resources.
|
|
67
67
|
*/
|
|
68
68
|
onBaseTextureLoaded() {
|
|
69
69
|
if (this.noFrame) {
|
|
@@ -73,8 +73,8 @@ export class Texture {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
77
|
-
* @param {boolean} destroyBase -
|
|
76
|
+
* Destroys this texture and cleans up resources.
|
|
77
|
+
* @param {boolean} destroyBase - Whether to destroy the base texture as well.
|
|
78
78
|
*/
|
|
79
79
|
destroy(destroyBase = false) {
|
|
80
80
|
if (destroyBase) {
|
|
@@ -84,9 +84,9 @@ export class Texture {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
88
|
-
* @param {Rectangle} frame -
|
|
89
|
-
* @throws {Error}.
|
|
87
|
+
* Sets the frame of this texture.
|
|
88
|
+
* @param {Rectangle} frame - The new frame rectangle.
|
|
89
|
+
* @throws {Error} If the operation fails.
|
|
90
90
|
*/
|
|
91
91
|
setFrame(frame) {
|
|
92
92
|
this.noFrame = false;
|
|
@@ -124,7 +124,7 @@ export class Texture {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
-
*
|
|
127
|
+
* Updates the texture UVs based on the crop frame.
|
|
128
128
|
*/
|
|
129
129
|
_updateUvs() {
|
|
130
130
|
if (!this._uvs) {
|
|
@@ -2,10 +2,10 @@ import { BaseTexture } from './base_texture.js';
|
|
|
2
2
|
import { Texture } from './texture.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {HTMLCanvasElement} canvas -
|
|
7
|
-
* @param {number} scaleMode -
|
|
8
|
-
* @returns {
|
|
5
|
+
* Creates a new BaseTexture from a canvas element.
|
|
6
|
+
* @param {HTMLCanvasElement} canvas - The canvas element to use as the texture source.
|
|
7
|
+
* @param {number} [scaleMode] - The scale mode to use for the texture.
|
|
8
|
+
* @returns {BaseTexture} The newly created BaseTexture instance.
|
|
9
9
|
*/
|
|
10
10
|
export const baseTextureFromCanvas = (canvas, scaleMode) => {
|
|
11
11
|
if (canvas.width === 0) {
|
|
@@ -18,10 +18,10 @@ export const baseTextureFromCanvas = (canvas, scaleMode) => {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @param {HTMLCanvasElement} canvas -
|
|
23
|
-
* @param {number} scaleMode -
|
|
24
|
-
* @returns {
|
|
21
|
+
* Creates a new Texture from a canvas element.
|
|
22
|
+
* @param {HTMLCanvasElement} canvas - The canvas element to use as the texture source.
|
|
23
|
+
* @param {number} [scaleMode] - The scale mode to use for the texture.
|
|
24
|
+
* @returns {Texture} The newly created Texture instance.
|
|
25
25
|
*/
|
|
26
26
|
export const textureFromCanvas = (canvas, scaleMode) => {
|
|
27
27
|
return new Texture(baseTextureFromCanvas(canvas, scaleMode));
|
|
@@ -14,18 +14,18 @@ export const OUT_OF_MEMORY = 0x0505;
|
|
|
14
14
|
export const CONTEXT_LOST_WEBGL = 0x9242;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {WebGLRenderingContext} gl -
|
|
19
|
-
* @returns {number}
|
|
17
|
+
* Gets the WebGL context error code.
|
|
18
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
19
|
+
* @returns {number} The error code from the WebGL context.
|
|
20
20
|
*/
|
|
21
21
|
export const getWebGLContextErrorCode = (gl) => {
|
|
22
22
|
return gl?.getError() ?? 0;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @param {number} errorCode -
|
|
28
|
-
* @returns {string}
|
|
26
|
+
* Gets the WebGL context error name from an error code.
|
|
27
|
+
* @param {number} errorCode - The error code to look up.
|
|
28
|
+
* @returns {string} The name of the WebGL error.
|
|
29
29
|
*/
|
|
30
30
|
export const getWebGLContextErrorName = (errorCode) => {
|
|
31
31
|
switch (errorCode) {
|
|
@@ -49,16 +49,16 @@ export const getWebGLContextErrorName = (errorCode) => {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* Initializes default shaders.
|
|
53
53
|
*/
|
|
54
54
|
export const initDefaultShaders = () => {};
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @param {WebGLRenderingContext} gl -
|
|
59
|
-
* @param {string[]|string} shaderSrc -
|
|
60
|
-
* @param {object} shaderType -
|
|
61
|
-
* @returns {WebGLShader}
|
|
57
|
+
* Compiles a WebGL shader.
|
|
58
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
59
|
+
* @param {string[]|string} shaderSrc - The shader source code.
|
|
60
|
+
* @param {object} shaderType - The type of shader to compile.
|
|
61
|
+
* @returns {WebGLShader} The compiled WebGL shader or null if compilation failed.
|
|
62
62
|
*/
|
|
63
63
|
export const compileShader = (gl, shaderSrc, shaderType) => {
|
|
64
64
|
const src = Array.isArray(shaderSrc) ? shaderSrc.join('\n') : shaderSrc;
|
|
@@ -76,31 +76,31 @@ export const compileShader = (gl, shaderSrc, shaderType) => {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
*
|
|
80
|
-
* @param {WebGLRenderingContext} gl -
|
|
81
|
-
* @param {string[]|string} shaderSrc -
|
|
82
|
-
* @returns {WebGLShader}
|
|
79
|
+
* Compiles a WebGL vertex shader.
|
|
80
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
81
|
+
* @param {string[]|string} shaderSrc - The vertex shader source code.
|
|
82
|
+
* @returns {WebGLShader} The compiled WebGL vertex shader or null if compilation failed.
|
|
83
83
|
*/
|
|
84
84
|
export const compileVertexShader = (gl, shaderSrc) => {
|
|
85
85
|
return compileShader(gl, shaderSrc, gl.VERTEX_SHADER);
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
90
|
-
* @param {WebGLRenderingContext} gl -
|
|
91
|
-
* @param {string[]|string} shaderSrc -
|
|
92
|
-
* @returns {WebGLShader}
|
|
89
|
+
* Compiles a WebGL fragment shader.
|
|
90
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
91
|
+
* @param {string[]|string} shaderSrc - The fragment shader source code.
|
|
92
|
+
* @returns {WebGLShader} The compiled WebGL fragment shader or null if compilation failed.
|
|
93
93
|
*/
|
|
94
94
|
export const compileFragmentShader = (gl, shaderSrc) => {
|
|
95
95
|
return compileShader(gl, shaderSrc, gl.FRAGMENT_SHADER);
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
*
|
|
100
|
-
* @param {WebGLRenderingContext} gl -
|
|
101
|
-
* @param {string[]|string} vertexSrc -
|
|
102
|
-
* @param {string[]|string} fragmentSrc -
|
|
103
|
-
* @returns {WebGLProgram}
|
|
99
|
+
* Compiles a WebGL shader program.
|
|
100
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
101
|
+
* @param {string[]|string} vertexSrc - The vertex shader source code.
|
|
102
|
+
* @param {string[]|string} fragmentSrc - The fragment shader source code.
|
|
103
|
+
* @returns {WebGLProgram} The compiled WebGL shader program or null if compilation failed.
|
|
104
104
|
*/
|
|
105
105
|
export const compileProgram = (gl, vertexSrc, fragmentSrc) => {
|
|
106
106
|
const fragmentShader = compileFragmentShader(gl, fragmentSrc);
|