@vpmedia/phaser 1.95.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 +29 -0
- package/package.json +9 -9
- package/src/phaser/core/animation.js +61 -56
- package/src/phaser/core/animation_manager.js +55 -55
- 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 +34 -18
- package/src/phaser/core/loader.js +170 -170
- package/src/phaser/core/loader_parser.js +22 -22
- package/src/phaser/core/raf.js +1 -1
- 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 +30 -30
- package/src/phaser/core/timer.js +64 -64
- package/src/phaser/core/timer_event.js +9 -9
- package/src/phaser/core/tween.js +90 -90
- package/src/phaser/core/tween_data.js +30 -30
- package/src/phaser/core/tween_manager.js +29 -24
- package/src/phaser/core/world.js +4 -3
- package/src/phaser/display/bitmap_text.js +61 -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 +16 -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 +112 -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 +50 -50
- package/src/phaser/display/image.js +54 -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 +212 -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 +20 -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 +69 -69
- package/src/phaser/geom/ellipse.js +28 -28
- package/src/phaser/geom/line.js +93 -93
- package/src/phaser/geom/matrix.js +54 -54
- package/src/phaser/geom/point.js +96 -96
- package/src/phaser/geom/polygon.js +22 -22
- package/src/phaser/geom/rectangle.js +132 -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 +61 -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/cache.d.ts +154 -154
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +43 -43
- 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 +52 -19
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +170 -170
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +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 +30 -30
- package/types/phaser/core/timer.d.ts +64 -64
- package/types/phaser/core/timer_event.d.ts +9 -9
- package/types/phaser/core/tween.d.ts +90 -90
- package/types/phaser/core/tween_data.d.ts +30 -30
- package/types/phaser/core/tween_manager.d.ts +29 -24
- 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 +59 -52
- 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/renderer.d.ts +16 -16
- 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 +101 -101
- package/types/phaser/display/graphics_data.d.ts +10 -10
- package/types/phaser/display/group.d.ts +47 -47
- package/types/phaser/display/image.d.ts +42 -40
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +207 -184
- 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 +9 -9
- 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_data.d.ts +4 -4
- package/types/phaser/display/webgl/render_texture.d.ts +16 -16
- package/types/phaser/display/webgl/renderer.d.ts +20 -20
- 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/geom/circle.d.ts +69 -69
- package/types/phaser/geom/ellipse.d.ts +28 -28
- package/types/phaser/geom/line.d.ts +93 -93
- package/types/phaser/geom/matrix.d.ts +54 -54
- package/types/phaser/geom/point.d.ts +96 -96
- package/types/phaser/geom/polygon.d.ts +22 -22
- package/types/phaser/geom/rectangle.d.ts +132 -132
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
- package/pnpm-workspace.yaml +0 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export class AbstractFilter {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param {string[]} fragmentSrc -
|
|
5
|
-
* @param {object} uniforms -
|
|
3
|
+
* Creates a new AbstractFilter instance.
|
|
4
|
+
* @param {string[]} fragmentSrc - The fragment shader source.
|
|
5
|
+
* @param {object} uniforms - The uniform variables for the shader.
|
|
6
6
|
*/
|
|
7
7
|
constructor(fragmentSrc, uniforms) {
|
|
8
8
|
this.passes = [this];
|
|
@@ -14,7 +14,7 @@ export class AbstractFilter {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Initializes the filter.
|
|
18
18
|
*/
|
|
19
19
|
syncUniforms() {
|
|
20
20
|
for (let i = 0, j = this.shaders.length; i < j; i += 1) {
|
|
@@ -2,9 +2,9 @@ import { removeByCanvas } from '../canvas/pool.js';
|
|
|
2
2
|
|
|
3
3
|
export class BaseTexture {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {HTMLCanvasElement} source -
|
|
7
|
-
* @param {number} [scaleMode] -
|
|
5
|
+
* Updates the base texture with a new source.
|
|
6
|
+
* @param {HTMLCanvasElement} source - The new canvas element to use as the texture source.
|
|
7
|
+
* @param {number} [scaleMode] - The scale mode to use for the texture.
|
|
8
8
|
*/
|
|
9
9
|
constructor(source, scaleMode) {
|
|
10
10
|
this.resolution = 1;
|
|
@@ -30,9 +30,9 @@ export class BaseTexture {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
* @param {number} width -
|
|
35
|
-
* @param {number} height -
|
|
33
|
+
* Updates the base texture with new dimensions.
|
|
34
|
+
* @param {number} width - The new width of the texture.
|
|
35
|
+
* @param {number} height - The new height of the texture.
|
|
36
36
|
*/
|
|
37
37
|
forceLoaded(width, height) {
|
|
38
38
|
this.hasLoaded = true;
|
|
@@ -42,7 +42,7 @@ export class BaseTexture {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Destroys the texture.
|
|
46
46
|
*/
|
|
47
47
|
destroy() {
|
|
48
48
|
if (this.source) {
|
|
@@ -53,7 +53,7 @@ export class BaseTexture {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* Marks the texture as dirty.
|
|
57
57
|
*/
|
|
58
58
|
dirty() {
|
|
59
59
|
for (let i = 0; i < this._glTextures.length; i += 1) {
|
|
@@ -62,7 +62,7 @@ export class BaseTexture {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* Unloads the texture from the GPU.
|
|
66
66
|
*/
|
|
67
67
|
unloadFromGPU() {
|
|
68
68
|
this.dirty();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export class WebGLBlendModeManager {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Creates a new BlendModeManager instance.
|
|
4
4
|
*/
|
|
5
5
|
constructor() {
|
|
6
6
|
this.gl = null;
|
|
@@ -8,17 +8,17 @@ export class WebGLBlendModeManager {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {WebGLRenderingContext} gl -
|
|
11
|
+
* Initializes the blend mode manager with a WebGL context.
|
|
12
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
13
13
|
*/
|
|
14
14
|
setContext(gl) {
|
|
15
15
|
this.gl = gl;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {number} blendMode -
|
|
21
|
-
* @returns {boolean}
|
|
19
|
+
* Sets the blend mode for the specified WebGL context.
|
|
20
|
+
* @param {number} blendMode - The blend mode to set.
|
|
21
|
+
* @returns {boolean} True if the blend mode was set successfully, false otherwise.
|
|
22
22
|
*/
|
|
23
23
|
setBlendMode(blendMode) {
|
|
24
24
|
if (this.currentBlendMode === blendMode) {
|
|
@@ -33,7 +33,7 @@ export class WebGLBlendModeManager {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Sets the blend mode for the WebGL context.
|
|
37
37
|
*/
|
|
38
38
|
destroy() {
|
|
39
39
|
this.gl = null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Node } from './earcut_node.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {object} list -
|
|
6
|
-
* @returns {object}
|
|
4
|
+
* Calculates the area of a triangle defined by three points.
|
|
5
|
+
* @param {object} list - The list of points to process.
|
|
6
|
+
* @returns {object} The processed earcut data structure.
|
|
7
7
|
*/
|
|
8
8
|
export function sortLinked(list) {
|
|
9
9
|
let i;
|
|
@@ -67,23 +67,23 @@ export function sortLinked(list) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
71
|
-
* @param {object} a -
|
|
72
|
-
* @param {object} b -
|
|
73
|
-
* @returns {number}
|
|
70
|
+
* Calculates the area of a triangle defined by three points.
|
|
71
|
+
* @param {object} a - The first point of the triangle.
|
|
72
|
+
* @param {object} b - The second point of the triangle.
|
|
73
|
+
* @returns {number} The calculated area of the triangle.
|
|
74
74
|
*/
|
|
75
75
|
export function compareX(a, b) {
|
|
76
76
|
return a.x - b.x;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
81
|
-
* @param {number} x -
|
|
82
|
-
* @param {number} y -
|
|
83
|
-
* @param {number} minX -
|
|
84
|
-
* @param {number} minY -
|
|
85
|
-
* @param {number} size -
|
|
86
|
-
* @returns {number}
|
|
80
|
+
* Determines if a point is inside a triangle.
|
|
81
|
+
* @param {number} x - The x-coordinate of the point to test.
|
|
82
|
+
* @param {number} y - The y-coordinate of the point to test.
|
|
83
|
+
* @param {number} minX - The minimum x-coordinate of the bounding box.
|
|
84
|
+
* @param {number} minY - The minimum y-coordinate of the bounding box.
|
|
85
|
+
* @param {number} size - The size of the bounding box.
|
|
86
|
+
* @returns {number} The calculated distance from the point to the triangle edge.
|
|
87
87
|
*/
|
|
88
88
|
export function zOrder(x, y, minX, minY, size) {
|
|
89
89
|
// coords are transformed into non-negative 15-bit integer range
|
|
@@ -101,11 +101,11 @@ export function zOrder(x, y, minX, minY, size) {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
105
|
-
* @param {object} start -
|
|
106
|
-
* @param {number} minX -
|
|
107
|
-
* @param {number} minY -
|
|
108
|
-
* @param {number} size -
|
|
104
|
+
* Calculates the orientation of three points (clockwise, counterclockwise, or collinear).
|
|
105
|
+
* @param {object} start - The starting point of the triangle edge.
|
|
106
|
+
* @param {number} minX - The minimum x-coordinate of the bounding box.
|
|
107
|
+
* @param {number} minY - The minimum y-coordinate of the bounding box.
|
|
108
|
+
* @param {number} size - The size of the bounding box.
|
|
109
109
|
*/
|
|
110
110
|
export function indexCurve(start, minX, minY, size) {
|
|
111
111
|
let p = start;
|
|
@@ -123,7 +123,7 @@ export function indexCurve(start, minX, minY, size) {
|
|
|
123
123
|
/**
|
|
124
124
|
* TBD.
|
|
125
125
|
* @param {object} start - TBD.
|
|
126
|
-
* @returns {object}
|
|
126
|
+
* @returns {object} The calculated point that is the closest to the triangle edge.
|
|
127
127
|
*/
|
|
128
128
|
export function getLeftmost(start) {
|
|
129
129
|
let p = start;
|
|
@@ -136,7 +136,7 @@ export function getLeftmost(start) {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
139
|
+
* Determines if a point is inside the triangle defined by three points.
|
|
140
140
|
* @param {number} ax - TBD.
|
|
141
141
|
* @param {number} ay - TBD.
|
|
142
142
|
* @param {number} bx - TBD.
|
|
@@ -168,31 +168,31 @@ export function area(p, q, r) {
|
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
170
|
* TBD.
|
|
171
|
-
* @param {object} p1 -
|
|
172
|
-
* @param {object} p2 -
|
|
173
|
-
* @returns {boolean}
|
|
171
|
+
* @param {object} p1 - The first point of the triangle.
|
|
172
|
+
* @param {object} p2 - The second point of the triangle.
|
|
173
|
+
* @returns {boolean} True if the point is inside the triangle, false otherwise.
|
|
174
174
|
*/
|
|
175
175
|
export function equals(p1, p2) {
|
|
176
176
|
return p1.x === p2.x && p1.y === p2.y;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
|
-
*
|
|
181
|
-
* @param {object} p1 -
|
|
182
|
-
* @param {object} q1 -
|
|
183
|
-
* @param {object} p2 -
|
|
184
|
-
* @param {object} q2 -
|
|
185
|
-
* @returns {boolean}
|
|
180
|
+
* Determines if two line segments intersect.
|
|
181
|
+
* @param {object} p1 - The first point of the first line segment.
|
|
182
|
+
* @param {object} q1 - The second point of the first line segment.
|
|
183
|
+
* @param {object} p2 - The first point of the second line segment.
|
|
184
|
+
* @param {object} q2 - The second point of the second line segment.
|
|
185
|
+
* @returns {boolean} True if the line segments intersect, false otherwise.
|
|
186
186
|
*/
|
|
187
187
|
export function intersects(p1, q1, p2, q2) {
|
|
188
188
|
return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
|
-
*
|
|
193
|
-
* @param {object} a -
|
|
194
|
-
* @param {object} b -
|
|
195
|
-
* @returns {boolean}
|
|
192
|
+
* Determines if two line segments intersect.
|
|
193
|
+
* @param {object} a - The first point of the line segment.
|
|
194
|
+
* @param {object} b - The second point of the line segment.
|
|
195
|
+
* @returns {boolean} True if the points are collinear, false otherwise.
|
|
196
196
|
*/
|
|
197
197
|
export function intersectsPolygon(a, b) {
|
|
198
198
|
let p = a;
|
|
@@ -204,10 +204,10 @@ export function intersectsPolygon(a, b) {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
/**
|
|
207
|
-
*
|
|
208
|
-
* @param {object} a -
|
|
209
|
-
* @param {object} b -
|
|
210
|
-
* @returns {object}
|
|
207
|
+
* Calculates the cross product of three points.
|
|
208
|
+
* @param {object} a - The first point of the cross product.
|
|
209
|
+
* @param {object} b - The second point of the cross product.
|
|
210
|
+
* @returns {object} The calculated cross product result.
|
|
211
211
|
*/
|
|
212
212
|
export function locallyInside(a, b) {
|
|
213
213
|
return area(a.prev, a, a.next) < 0
|
|
@@ -216,10 +216,10 @@ export function locallyInside(a, b) {
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
/**
|
|
219
|
-
*
|
|
220
|
-
* @param {object} a -
|
|
221
|
-
* @param {object} b -
|
|
222
|
-
* @returns {boolean}
|
|
219
|
+
* Determines if a point is inside the triangle defined by three points.
|
|
220
|
+
* @param {object} a - The first point of the triangle.
|
|
221
|
+
* @param {object} b - The second point of the triangle.
|
|
222
|
+
* @returns {boolean} True if the point is inside the triangle, false otherwise.
|
|
223
223
|
*/
|
|
224
224
|
export function middleInside(a, b) {
|
|
225
225
|
let p = a;
|
|
@@ -236,10 +236,10 @@ export function middleInside(a, b) {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
/**
|
|
239
|
-
*
|
|
240
|
-
* @param {object} a -
|
|
241
|
-
* @param {object} b -
|
|
242
|
-
* @returns {boolean}
|
|
239
|
+
* Determines if a point is inside the triangle defined by three points.
|
|
240
|
+
* @param {object} a - The first point of the triangle.
|
|
241
|
+
* @param {object} b - The second point of the triangle.
|
|
242
|
+
* @returns {boolean} True if the point is inside the triangle, false otherwise.
|
|
243
243
|
*/
|
|
244
244
|
export function isValidDiagonal(a, b) {
|
|
245
245
|
return (
|
|
@@ -254,7 +254,7 @@ export function isValidDiagonal(a, b) {
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
/**
|
|
257
|
-
*
|
|
257
|
+
* Calculates the distance from a point to a triangle edge.
|
|
258
258
|
* @param {object} a - TBD.
|
|
259
259
|
* @param {object} b - TBD.
|
|
260
260
|
* @returns {object} TBD.
|
|
@@ -383,12 +383,12 @@ export function isEarHashed(ear, minX, minY, size) {
|
|
|
383
383
|
|
|
384
384
|
/**
|
|
385
385
|
* TBD.
|
|
386
|
-
* @param {object} data -
|
|
387
|
-
* @param {number} start -
|
|
388
|
-
* @param {number} end -
|
|
389
|
-
* @param {number} dim -
|
|
390
|
-
* @param {boolean} clockwise -
|
|
391
|
-
* @returns {object}
|
|
386
|
+
* @param {object} data - The earcut data structure containing the points.
|
|
387
|
+
* @param {number} start - The starting index in the data structure.
|
|
388
|
+
* @param {number} end - The ending index in the data structure.
|
|
389
|
+
* @param {number} dim - The dimension of the data (2 or 3).
|
|
390
|
+
* @param {boolean} clockwise - Whether the triangles should be clockwise or counterclockwise.
|
|
391
|
+
* @returns {object} The processed earcut data structure with triangulation information.
|
|
392
392
|
*/
|
|
393
393
|
export function linkedList(data, start, end, dim, clockwise) {
|
|
394
394
|
let sum = 0;
|
|
@@ -410,10 +410,10 @@ export function linkedList(data, start, end, dim, clockwise) {
|
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
/**
|
|
413
|
-
*
|
|
414
|
-
* @param {object} start -
|
|
415
|
-
* @param {object} end -
|
|
416
|
-
* @returns {object}
|
|
413
|
+
* Calculates the minimum and maximum coordinates of a set of points.
|
|
414
|
+
* @param {object} start - The starting point in the data structure.
|
|
415
|
+
* @param {object} end - The ending point in the data structure.
|
|
416
|
+
* @returns {object} The calculated bounding box with min and max coordinates.
|
|
417
417
|
*/
|
|
418
418
|
export function filterPoints(start, end) {
|
|
419
419
|
if (!start) return start;
|
|
@@ -436,10 +436,10 @@ export function filterPoints(start, end) {
|
|
|
436
436
|
}
|
|
437
437
|
|
|
438
438
|
/**
|
|
439
|
-
*
|
|
440
|
-
* @param {object} hole -
|
|
441
|
-
* @param {object} outerNode -
|
|
442
|
-
* @returns {object}
|
|
439
|
+
* Calculates the minimum and maximum coordinates of a set of points.
|
|
440
|
+
* @param {object} hole - The hole to process.
|
|
441
|
+
* @param {object} outerNode - The outer node that contains the hole.
|
|
442
|
+
* @returns {object} The processed hole data structure.
|
|
443
443
|
*/
|
|
444
444
|
export function findHoleBridge(hole, outerNode) {
|
|
445
445
|
let p = outerNode;
|
|
@@ -486,9 +486,9 @@ export function findHoleBridge(hole, outerNode) {
|
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
/**
|
|
489
|
-
*
|
|
490
|
-
* @param {object} hole -
|
|
491
|
-
* @param {object} outerNode -
|
|
489
|
+
* Processes a hole in the triangulation data structure.
|
|
490
|
+
* @param {object} hole - The hole to process.
|
|
491
|
+
* @param {object} outerNode - The outer node that contains the hole.
|
|
492
492
|
*/
|
|
493
493
|
export function eliminateHole(hole, outerNode) {
|
|
494
494
|
outerNode = findHoleBridge(hole, outerNode);
|
|
@@ -499,12 +499,12 @@ export function eliminateHole(hole, outerNode) {
|
|
|
499
499
|
}
|
|
500
500
|
|
|
501
501
|
/**
|
|
502
|
-
*
|
|
503
|
-
* @param {object} data -
|
|
504
|
-
* @param {object} holeIndices -
|
|
505
|
-
* @param {object} outerNode -
|
|
506
|
-
* @param {object} dim -
|
|
507
|
-
* @returns {object}
|
|
502
|
+
* Calculates the centroid of a polygon.
|
|
503
|
+
* @param {object} data - The earcut data structure containing the points.
|
|
504
|
+
* @param {object} holeIndices - The indices of the holes in the data structure.
|
|
505
|
+
* @param {object} outerNode - The outer node that contains the holes.
|
|
506
|
+
* @param {object} dim - The dimension of the data (2 or 3).
|
|
507
|
+
* @returns {object} The processed earcut data structure with holes included.
|
|
508
508
|
*/
|
|
509
509
|
export function eliminateHoles(data, holeIndices, outerNode, dim) {
|
|
510
510
|
const queue = [];
|
|
@@ -530,11 +530,11 @@ export function eliminateHoles(data, holeIndices, outerNode, dim) {
|
|
|
530
530
|
}
|
|
531
531
|
|
|
532
532
|
/**
|
|
533
|
-
*
|
|
534
|
-
* @param {object} start -
|
|
535
|
-
* @param {object} triangles -
|
|
536
|
-
* @param {number} dim -
|
|
537
|
-
* @returns {object}
|
|
533
|
+
* Calculates the centroid of a polygon.
|
|
534
|
+
* @param {object} start - The starting point in the data structure.
|
|
535
|
+
* @param {object} triangles - The triangles to process.
|
|
536
|
+
* @param {number} dim - The dimension of the data (2 or 3).
|
|
537
|
+
* @returns {object} The processed triangulation data structure.
|
|
538
538
|
*/
|
|
539
539
|
export function cureLocalIntersections(start, triangles, dim) {
|
|
540
540
|
let p = start;
|
|
@@ -558,13 +558,13 @@ export function cureLocalIntersections(start, triangles, dim) {
|
|
|
558
558
|
}
|
|
559
559
|
|
|
560
560
|
/**
|
|
561
|
-
*
|
|
562
|
-
* @param {object} start -
|
|
563
|
-
* @param {object} triangles -
|
|
564
|
-
* @param {number} dim -
|
|
565
|
-
* @param {number} minX -
|
|
566
|
-
* @param {number} minY -
|
|
567
|
-
* @param {number} size -
|
|
561
|
+
* Calculates the centroid of a polygon.
|
|
562
|
+
* @param {object} start - The starting point in the data structure.
|
|
563
|
+
* @param {object} triangles - The triangles to process.
|
|
564
|
+
* @param {number} dim - The dimension of the data (2 or 3).
|
|
565
|
+
* @param {number} minX - The minimum x-coordinate of the bounding box.
|
|
566
|
+
* @param {number} minY - The minimum y-coordinate of the bounding box.
|
|
567
|
+
* @param {number} size - The size of the bounding box.
|
|
568
568
|
*/
|
|
569
569
|
export function splitEarcut(start, triangles, dim, minX, minY, size) {
|
|
570
570
|
// look for a valid diagonal that divides the polygon into two
|
|
@@ -590,14 +590,14 @@ export function splitEarcut(start, triangles, dim, minX, minY, size) {
|
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
/**
|
|
593
|
-
*
|
|
594
|
-
* @param {object} ear -
|
|
595
|
-
* @param {object} triangles -
|
|
596
|
-
* @param {number} dim -
|
|
597
|
-
* @param {number} minX -
|
|
598
|
-
* @param {number} minY -
|
|
599
|
-
* @param {number} size -
|
|
600
|
-
* @param {object} pass -
|
|
593
|
+
* Calculates the centroid of a polygon.
|
|
594
|
+
* @param {object} ear - The ear to process.
|
|
595
|
+
* @param {object} triangles - The triangles to process.
|
|
596
|
+
* @param {number} dim - The dimension of the data (2 or 3).
|
|
597
|
+
* @param {number} minX - The minimum x-coordinate of the bounding box.
|
|
598
|
+
* @param {number} minY - The minimum y-coordinate of the bounding box.
|
|
599
|
+
* @param {number} size - The size of the bounding box.
|
|
600
|
+
* @param {object} pass - The pass information for triangulation.
|
|
601
601
|
*/
|
|
602
602
|
export function earcutLinked(ear, triangles, dim, minX, minY, size, pass) {
|
|
603
603
|
if (!ear) return;
|
|
@@ -641,11 +641,11 @@ export function earcutLinked(ear, triangles, dim, minX, minY, size, pass) {
|
|
|
641
641
|
}
|
|
642
642
|
|
|
643
643
|
/**
|
|
644
|
-
*
|
|
645
|
-
* @param {object} data -
|
|
646
|
-
* @param {object} holeIndices -
|
|
647
|
-
* @param {number} dim -
|
|
648
|
-
* @returns {object}
|
|
644
|
+
* Calculates the centroid of a polygon.
|
|
645
|
+
* @param {object} data - The earcut data structure containing the points.
|
|
646
|
+
* @param {object} holeIndices - The indices of the holes in the data structure.
|
|
647
|
+
* @param {number} dim - The dimension of the data (2 or 3).
|
|
648
|
+
* @returns {object} The processed earcut data structure with triangulation information.
|
|
649
649
|
*/
|
|
650
650
|
export function triangulate(data, holeIndices, dim) {
|
|
651
651
|
dim = dim || 2;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export class Node {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param {number} i -
|
|
5
|
-
* @param {number} x -
|
|
6
|
-
* @param {number} y -
|
|
3
|
+
* Creates a new Node instance.
|
|
4
|
+
* @param {number} i - The vertice index in coordinates array.
|
|
5
|
+
* @param {number} x - The x coordinate of the vertex.
|
|
6
|
+
* @param {number} y - The y coordinate of the vertex.
|
|
7
7
|
*/
|
|
8
8
|
constructor(i, x, y) {
|
|
9
9
|
// vertice index in coordinates array
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export class FastSpriteBatch {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param {WebGLRenderingContext & { id: number }} gl -
|
|
3
|
+
* Creates a new FastSpriteBatch instance.
|
|
4
|
+
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
5
5
|
*/
|
|
6
6
|
constructor(gl) {
|
|
7
7
|
this.vertSize = 10;
|
|
@@ -35,8 +35,8 @@ export class FastSpriteBatch {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
* @param {WebGLRenderingContext & { id: number }} gl -
|
|
38
|
+
* Sets the WebGL context for this batch.
|
|
39
|
+
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
40
40
|
*/
|
|
41
41
|
setContext(gl) {
|
|
42
42
|
this.gl = gl;
|
|
@@ -52,9 +52,9 @@ export class FastSpriteBatch {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
56
|
-
* @param {object} spriteBatch -
|
|
57
|
-
* @param {object} renderSession -
|
|
55
|
+
* Renders a sprite batch using WebGL.
|
|
56
|
+
* @param {object} spriteBatch - The sprite batch to render.
|
|
57
|
+
* @param {object} renderSession - The render session to use.
|
|
58
58
|
*/
|
|
59
59
|
begin(spriteBatch, renderSession) {
|
|
60
60
|
this.renderSession = renderSession;
|
|
@@ -64,15 +64,15 @@ export class FastSpriteBatch {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* Updates the sprite batch.
|
|
68
68
|
*/
|
|
69
69
|
end() {
|
|
70
70
|
this.flush();
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @param {object} spriteBatch -
|
|
74
|
+
* Flushes the sprite batch to WebGL.
|
|
75
|
+
* @param {object} spriteBatch - The sprite batch to flush.
|
|
76
76
|
*/
|
|
77
77
|
render(spriteBatch) {
|
|
78
78
|
const children = spriteBatch.children;
|
|
@@ -95,8 +95,8 @@ export class FastSpriteBatch {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
*
|
|
99
|
-
* @param {import('../../display/image.js').Image} sprite -
|
|
98
|
+
* Renders a sprite using WebGL.
|
|
99
|
+
* @param {import('../../display/image.js').Image} sprite - The sprite to render.
|
|
100
100
|
*/
|
|
101
101
|
renderSprite(sprite) {
|
|
102
102
|
if (!sprite.visible) {
|
|
@@ -202,7 +202,7 @@ export class FastSpriteBatch {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
/**
|
|
205
|
-
*
|
|
205
|
+
* Binds the sprite batch to the WebGL context.
|
|
206
206
|
*/
|
|
207
207
|
flush() {
|
|
208
208
|
// If the batch is length 0 then return as there is nothing to draw
|
|
@@ -231,14 +231,14 @@ export class FastSpriteBatch {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
/**
|
|
234
|
-
*
|
|
234
|
+
* Renders a sprite using the sprite batch.
|
|
235
235
|
*/
|
|
236
236
|
stop() {
|
|
237
237
|
this.flush();
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
/**
|
|
241
|
-
*
|
|
241
|
+
* Sets up the sprite batch for WebGL rendering.
|
|
242
242
|
*/
|
|
243
243
|
start() {
|
|
244
244
|
const gl = this.gl;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export class WebGLFilterManager {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Creates a new FilterManager instance.
|
|
4
4
|
*/
|
|
5
5
|
constructor() {
|
|
6
6
|
this.filterStack = [];
|
|
@@ -9,8 +9,8 @@ export class WebGLFilterManager {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @param {WebGLRenderingContext} gl -
|
|
12
|
+
* Initializes the filter manager with a WebGL context.
|
|
13
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
14
14
|
*/
|
|
15
15
|
setContext(gl) {
|
|
16
16
|
this.gl = gl;
|
|
@@ -19,42 +19,42 @@ export class WebGLFilterManager {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Applies a filter to the specified texture.
|
|
23
23
|
*/
|
|
24
24
|
begin() {
|
|
25
25
|
// TODO
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Updates the filter texture for the specified size.
|
|
30
30
|
*/
|
|
31
31
|
pushFilter() {
|
|
32
32
|
// TODO
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Resizes the filter manager to the specified dimensions.
|
|
37
37
|
*/
|
|
38
38
|
popFilter() {
|
|
39
39
|
// TODO
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* Destroys this filter manager and cleans up resources.
|
|
44
44
|
*/
|
|
45
45
|
applyFilterPass() {
|
|
46
46
|
// TODO
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* Initializes the filter manager.
|
|
51
51
|
*/
|
|
52
52
|
initShaderBuffers() {
|
|
53
53
|
// TODO
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Sets up the filter manager for WebGL rendering.
|
|
58
58
|
*/
|
|
59
59
|
destroy() {
|
|
60
60
|
// TODO
|
|
@@ -2,11 +2,11 @@ import { SCALE_LINEAR } from '../../core/const.js';
|
|
|
2
2
|
|
|
3
3
|
export class FilterTexture {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {WebGLRenderingContext} gl -
|
|
7
|
-
* @param {number} width -
|
|
8
|
-
* @param {number} height -
|
|
9
|
-
* @param {number} scaleMode -
|
|
5
|
+
* Creates a new FilterTexture instance.
|
|
6
|
+
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
7
|
+
* @param {number} width - The width of the filter texture.
|
|
8
|
+
* @param {number} height - The height of the filter texture.
|
|
9
|
+
* @param {number} scaleMode - The scale mode to use.
|
|
10
10
|
*/
|
|
11
11
|
constructor(gl, width, height, scaleMode) {
|
|
12
12
|
this.gl = gl;
|
|
@@ -29,7 +29,7 @@ export class FilterTexture {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Destroys this filter texture and cleans up resources.
|
|
33
33
|
*/
|
|
34
34
|
clear() {
|
|
35
35
|
const gl = this.gl;
|
|
@@ -38,9 +38,9 @@ export class FilterTexture {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @param {number} width -
|
|
43
|
-
* @param {number} height -
|
|
41
|
+
* Updates the size of this filter texture.
|
|
42
|
+
* @param {number} width - The new width of the filter texture.
|
|
43
|
+
* @param {number} height - The new height of the filter texture.
|
|
44
44
|
*/
|
|
45
45
|
resize(width, height) {
|
|
46
46
|
if (this.width === width && this.height === height) {
|
|
@@ -57,7 +57,7 @@ export class FilterTexture {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* Updates the resolution of this filter texture.
|
|
61
61
|
*/
|
|
62
62
|
destroy() {
|
|
63
63
|
const gl = this.gl;
|