@vpmedia/phaser 1.105.0 → 1.106.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/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -18
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +10 -0
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/index.ts +8 -0
- package/src/phaser/core/animation.ts +10 -2
- package/src/phaser/core/animation_manager.ts +9 -3
- package/src/phaser/core/device.ts +24 -24
- package/src/phaser/core/input.ts +8 -4
- package/src/phaser/core/input_handler.ts +16 -2
- package/src/phaser/core/input_mspointer.ts +16 -16
- package/src/phaser/core/input_pointer.ts +48 -48
- package/src/phaser/core/loader.ts +11 -0
- package/src/phaser/core/loader_parser.ts +22 -4
- package/src/phaser/core/scene.ts +2 -2
- package/src/phaser/core/signal.ts +7 -1
- package/src/phaser/core/signal_binding.ts +8 -1
- package/src/phaser/core/sound.ts +7 -1
- package/src/phaser/core/sound_sprite.ts +7 -7
- package/src/phaser/core/time.ts +28 -28
- package/src/phaser/core/tween.ts +24 -4
- package/src/phaser/core/tween_manager.ts +5 -5
- package/src/phaser/display/button.ts +13 -1
- package/src/phaser/display/canvas/buffer.ts +4 -4
- package/src/phaser/display/canvas/util.ts +9 -1
- package/src/phaser/display/graphics_data.ts +19 -11
- package/src/phaser/display/image.ts +7 -1
- package/src/phaser/display/sprite_util.ts +15 -3
- package/src/phaser/display/webgl/blend_manager.ts +2 -2
- package/src/phaser/display/webgl/earcut.ts +19 -2
- package/src/phaser/display/webgl/fast_sprite_batch.ts +15 -15
- package/src/phaser/display/webgl/filter_manager.ts +3 -3
- package/src/phaser/display/webgl/filter_texture.ts +4 -4
- package/src/phaser/display/webgl/graphics.ts +8 -1
- package/src/phaser/display/webgl/graphics_data.ts +9 -9
- package/src/phaser/display/webgl/render_texture.ts +7 -1
- package/src/phaser/display/webgl/shader/complex.ts +5 -5
- package/src/phaser/display/webgl/shader/fast.ts +6 -6
- package/src/phaser/display/webgl/shader/normal.ts +10 -10
- package/src/phaser/display/webgl/shader/primitive.ts +5 -5
- package/src/phaser/display/webgl/shader/strip.ts +5 -5
- package/src/phaser/display/webgl/shader_manager.ts +10 -10
- package/src/phaser/display/webgl/sprite_batch.ts +16 -16
- package/src/phaser/display/webgl/stencil_manager.ts +18 -6
- package/src/phaser/display/webgl/texture.ts +6 -1
- package/src/phaser/display/webgl/util.ts +8 -4
- package/src/phaser/geom/util/point.ts +8 -1
- package/src/phaser/geom/util/rectangle.ts +8 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { clone } from './graphics_data_util.js';
|
|
2
2
|
|
|
3
3
|
export class GraphicsData {
|
|
4
|
-
lineWidth!: any;
|
|
5
|
-
lineColor!: any;
|
|
6
|
-
lineAlpha!: any;
|
|
7
|
-
_lineTint!: any;
|
|
8
|
-
fillColor!: any;
|
|
9
|
-
fillAlpha!: any;
|
|
10
|
-
_fillTint!: any;
|
|
11
|
-
fill!: any;
|
|
12
|
-
shape!: any;
|
|
13
|
-
type!: any;
|
|
4
|
+
lineWidth!: any;
|
|
5
|
+
lineColor!: any;
|
|
6
|
+
lineAlpha!: any;
|
|
7
|
+
_lineTint!: any;
|
|
8
|
+
fillColor!: any;
|
|
9
|
+
fillAlpha!: any;
|
|
10
|
+
_fillTint!: any;
|
|
11
|
+
fill!: any;
|
|
12
|
+
shape!: any;
|
|
13
|
+
type!: any;
|
|
14
14
|
/**
|
|
15
15
|
* Creates a new GraphicsData object.
|
|
16
16
|
* @param {number} lineWidth - The line width.
|
|
@@ -21,7 +21,15 @@ type!: any;
|
|
|
21
21
|
* @param {boolean} fill - Whether to fill the shape.
|
|
22
22
|
* @param {object} shape - The shape to draw.
|
|
23
23
|
*/
|
|
24
|
-
constructor(
|
|
24
|
+
constructor(
|
|
25
|
+
lineWidth: number,
|
|
26
|
+
lineColor: number,
|
|
27
|
+
lineAlpha: number,
|
|
28
|
+
fillColor: number,
|
|
29
|
+
fillAlpha: number,
|
|
30
|
+
fill: boolean,
|
|
31
|
+
shape: any
|
|
32
|
+
) {
|
|
25
33
|
this.lineWidth = lineWidth;
|
|
26
34
|
this.lineColor = lineColor;
|
|
27
35
|
this.lineAlpha = lineAlpha;
|
|
@@ -35,7 +35,13 @@ export class Image extends DisplayObject {
|
|
|
35
35
|
* @param {string | number | Texture} key - The texture key or texture to use.
|
|
36
36
|
* @param {string | number} frame - The frame identifier (name or index) to use.
|
|
37
37
|
*/
|
|
38
|
-
constructor(
|
|
38
|
+
constructor(
|
|
39
|
+
game: import('../core/game.js').Game,
|
|
40
|
+
x: number,
|
|
41
|
+
y: number,
|
|
42
|
+
key: string | number | Texture,
|
|
43
|
+
frame: string | number = 0
|
|
44
|
+
) {
|
|
39
45
|
super(game);
|
|
40
46
|
/** @type {number} */
|
|
41
47
|
this.type = IMAGE;
|
|
@@ -8,7 +8,11 @@ import { getTintedTexture } from './canvas/tinter.js';
|
|
|
8
8
|
* @param {import('./webgl/texture.js').Texture} texture - The new texture to set.
|
|
9
9
|
* @param {boolean} destroyBase - Whether to destroy the base texture.
|
|
10
10
|
*/
|
|
11
|
-
export const setTexture = (
|
|
11
|
+
export const setTexture = (
|
|
12
|
+
target: import('./image.js').Image,
|
|
13
|
+
texture: import('./webgl/texture.js').Texture,
|
|
14
|
+
destroyBase: boolean = false
|
|
15
|
+
) => {
|
|
12
16
|
if (destroyBase) {
|
|
13
17
|
target.texture.baseTexture.destroy();
|
|
14
18
|
}
|
|
@@ -127,7 +131,11 @@ export const getLocalBounds = (target: import('./image.js').Image) => {
|
|
|
127
131
|
* @param {object} renderSession - The render session object.
|
|
128
132
|
* @param {import('../geom/matrix.js').Matrix | null | undefined} matrix - The transformation matrix.
|
|
129
133
|
*/
|
|
130
|
-
export const renderWebGL = (
|
|
134
|
+
export const renderWebGL = (
|
|
135
|
+
target: import('./image.js').Image,
|
|
136
|
+
renderSession: any,
|
|
137
|
+
matrix: import('../geom/matrix.js').Matrix | null | undefined = null
|
|
138
|
+
) => {
|
|
131
139
|
// if the sprite is not visible or the alpha is 0 then no need to render this element
|
|
132
140
|
if (!target.visible || target.alpha <= 0 || !target.renderable) {
|
|
133
141
|
return;
|
|
@@ -176,7 +184,11 @@ export const renderWebGL = (target: import('./image.js').Image, renderSession: a
|
|
|
176
184
|
* @param {object} renderSession - The render session object.
|
|
177
185
|
* @param {import('../geom/matrix.js').Matrix | null | undefined} matrix - The transformation matrix.
|
|
178
186
|
*/
|
|
179
|
-
export const renderCanvas = (
|
|
187
|
+
export const renderCanvas = (
|
|
188
|
+
target: import('./image.js').Image,
|
|
189
|
+
renderSession: any,
|
|
190
|
+
matrix: import('../geom/matrix.js').Matrix | null | undefined = null
|
|
191
|
+
) => {
|
|
180
192
|
// If the sprite is not visible or the alpha is 0 then no need to render this element
|
|
181
193
|
if (
|
|
182
194
|
!target.visible ||
|
|
@@ -147,7 +147,16 @@ export function getLeftmost(start: any) {
|
|
|
147
147
|
* @param {number} py - TBD.
|
|
148
148
|
* @returns {object} TBD.
|
|
149
149
|
*/
|
|
150
|
-
export function pointInTriangle(
|
|
150
|
+
export function pointInTriangle(
|
|
151
|
+
ax: number,
|
|
152
|
+
ay: number,
|
|
153
|
+
bx: number,
|
|
154
|
+
by: number,
|
|
155
|
+
cx: number,
|
|
156
|
+
cy: number,
|
|
157
|
+
px: number,
|
|
158
|
+
py: number
|
|
159
|
+
) {
|
|
151
160
|
return (
|
|
152
161
|
(cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
|
|
153
162
|
(ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
|
|
@@ -599,7 +608,15 @@ export function splitEarcut(start: any, triangles: any, dim: number, minX: numbe
|
|
|
599
608
|
* @param {number} size - The size of the bounding box.
|
|
600
609
|
* @param {object} pass - The pass information for triangulation.
|
|
601
610
|
*/
|
|
602
|
-
export function earcutLinked(
|
|
611
|
+
export function earcutLinked(
|
|
612
|
+
ear: any,
|
|
613
|
+
triangles: any,
|
|
614
|
+
dim: number,
|
|
615
|
+
minX?: number,
|
|
616
|
+
minY?: number,
|
|
617
|
+
size?: number,
|
|
618
|
+
pass?: any
|
|
619
|
+
) {
|
|
603
620
|
if (!ear) return;
|
|
604
621
|
// interlink polygon nodes in z-order
|
|
605
622
|
if (!pass && size) indexCurve(ear, minX, minY, size);
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export class FastSpriteBatch {
|
|
2
2
|
[key: string]: any;
|
|
3
|
-
vertSize!: any;
|
|
4
|
-
maxSize!: any;
|
|
5
|
-
size!: any;
|
|
6
|
-
vertices!: any;
|
|
7
|
-
indices!: any;
|
|
8
|
-
vertexBuffer!: any;
|
|
9
|
-
indexBuffer!: any;
|
|
10
|
-
lastIndexCount!: any;
|
|
11
|
-
drawing!: any;
|
|
12
|
-
currentBatchSize!: any;
|
|
13
|
-
currentBaseTexture!: any;
|
|
14
|
-
currentBlendMode!: any;
|
|
15
|
-
renderSession!: any;
|
|
16
|
-
shader!: any;
|
|
17
|
-
matrix!: any;
|
|
3
|
+
vertSize!: any;
|
|
4
|
+
maxSize!: any;
|
|
5
|
+
size!: any;
|
|
6
|
+
vertices!: any;
|
|
7
|
+
indices!: any;
|
|
8
|
+
vertexBuffer!: any;
|
|
9
|
+
indexBuffer!: any;
|
|
10
|
+
lastIndexCount!: any;
|
|
11
|
+
drawing!: any;
|
|
12
|
+
currentBatchSize!: any;
|
|
13
|
+
currentBaseTexture!: any;
|
|
14
|
+
currentBlendMode!: any;
|
|
15
|
+
renderSession!: any;
|
|
16
|
+
shader!: any;
|
|
17
|
+
matrix!: any;
|
|
18
18
|
/**
|
|
19
19
|
* Creates a new FastSpriteBatch instance.
|
|
20
20
|
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
@@ -2,10 +2,10 @@ import { SCALE_LINEAR } from '../../core/const.js';
|
|
|
2
2
|
|
|
3
3
|
export class FilterTexture {
|
|
4
4
|
[key: string]: any;
|
|
5
|
-
gl!: any;
|
|
6
|
-
frameBuffer!: any;
|
|
7
|
-
texture!: any;
|
|
8
|
-
renderBuffer!: any;
|
|
5
|
+
gl!: any;
|
|
6
|
+
frameBuffer!: any;
|
|
7
|
+
texture!: any;
|
|
8
|
+
renderBuffer!: any;
|
|
9
9
|
/**
|
|
10
10
|
* Creates a new FilterTexture instance.
|
|
11
11
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
@@ -269,7 +269,14 @@ export const buildRectangle = (graphicsData: any, webGLData: GraphicsData) => {
|
|
|
269
269
|
* @param {number} toY - The ending y-coordinate.
|
|
270
270
|
* @returns {number[]} The calculated points for the quadratic bezier curve.
|
|
271
271
|
*/
|
|
272
|
-
export const quadraticBezierCurve = (
|
|
272
|
+
export const quadraticBezierCurve = (
|
|
273
|
+
fromX: number,
|
|
274
|
+
fromY: number,
|
|
275
|
+
cpX: number,
|
|
276
|
+
cpY: number,
|
|
277
|
+
toX: number,
|
|
278
|
+
toY: number
|
|
279
|
+
) => {
|
|
273
280
|
let xa;
|
|
274
281
|
let ya;
|
|
275
282
|
let xb;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export class GraphicsData {
|
|
2
2
|
[key: string]: any;
|
|
3
|
-
gl!: any;
|
|
4
|
-
color!: any;
|
|
5
|
-
points!: any;
|
|
6
|
-
indices!: any;
|
|
7
|
-
buffer!: any;
|
|
8
|
-
indexBuffer!: any;
|
|
9
|
-
mode!: any;
|
|
10
|
-
alpha!: any;
|
|
11
|
-
dirty!: any;
|
|
3
|
+
gl!: any;
|
|
4
|
+
color!: any;
|
|
5
|
+
points!: any;
|
|
6
|
+
indices!: any;
|
|
7
|
+
buffer!: any;
|
|
8
|
+
indexBuffer!: any;
|
|
9
|
+
mode!: any;
|
|
10
|
+
alpha!: any;
|
|
11
|
+
dirty!: any;
|
|
12
12
|
/**
|
|
13
13
|
* Creates a new GraphicsData instance.
|
|
14
14
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
@@ -26,7 +26,13 @@ export class RenderTexture extends Texture {
|
|
|
26
26
|
* @param {number} scaleMode - The scale mode to use.
|
|
27
27
|
* @param {number} resolution - The resolution to use.
|
|
28
28
|
*/
|
|
29
|
-
constructor(
|
|
29
|
+
constructor(
|
|
30
|
+
width: number,
|
|
31
|
+
height: number,
|
|
32
|
+
renderer: import('./renderer.js').WebGLRenderer | import('../canvas/renderer.js').CanvasRenderer,
|
|
33
|
+
scaleMode: number,
|
|
34
|
+
resolution: number = 1
|
|
35
|
+
) {
|
|
30
36
|
const w = width || 100;
|
|
31
37
|
const h = height || 100;
|
|
32
38
|
const res = resolution || 1;
|
|
@@ -5,11 +5,11 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
|
|
6
6
|
export class ComplexPrimitiveShader {
|
|
7
7
|
[key: string]: any;
|
|
8
|
-
gl!: any;
|
|
9
|
-
_UID!: any;
|
|
10
|
-
program!: any;
|
|
11
|
-
fragmentSrc!: any;
|
|
12
|
-
vertexSrc!: any;
|
|
8
|
+
gl!: any;
|
|
9
|
+
_UID!: any;
|
|
10
|
+
program!: any;
|
|
11
|
+
fragmentSrc!: any;
|
|
12
|
+
vertexSrc!: any;
|
|
13
13
|
/**
|
|
14
14
|
* Creates a new ComplexShader instance.
|
|
15
15
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
@@ -5,12 +5,12 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
|
|
6
6
|
export class FastShader {
|
|
7
7
|
[key: string]: any;
|
|
8
|
-
gl!: any;
|
|
9
|
-
_UID!: any;
|
|
10
|
-
program!: any;
|
|
11
|
-
textureCount!: any;
|
|
12
|
-
fragmentSrc!: any;
|
|
13
|
-
vertexSrc!: any;
|
|
8
|
+
gl!: any;
|
|
9
|
+
_UID!: any;
|
|
10
|
+
program!: any;
|
|
11
|
+
textureCount!: any;
|
|
12
|
+
fragmentSrc!: any;
|
|
13
|
+
vertexSrc!: any;
|
|
14
14
|
/**
|
|
15
15
|
* Creates a new FastShader instance.
|
|
16
16
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
@@ -25,16 +25,16 @@ const defaultVertexSrc = [
|
|
|
25
25
|
|
|
26
26
|
export class NormalShader {
|
|
27
27
|
[key: string]: any;
|
|
28
|
-
gl!: any;
|
|
29
|
-
_UID!: any;
|
|
30
|
-
program!: any;
|
|
31
|
-
fragmentSrc!: any;
|
|
32
|
-
vertexSrc!: any;
|
|
33
|
-
textureCount!: any;
|
|
34
|
-
firstRun!: any;
|
|
35
|
-
dirty!: any;
|
|
36
|
-
uniforms!: any;
|
|
37
|
-
attributes!: any;
|
|
28
|
+
gl!: any;
|
|
29
|
+
_UID!: any;
|
|
30
|
+
program!: any;
|
|
31
|
+
fragmentSrc!: any;
|
|
32
|
+
vertexSrc!: any;
|
|
33
|
+
textureCount!: any;
|
|
34
|
+
firstRun!: any;
|
|
35
|
+
dirty!: any;
|
|
36
|
+
uniforms!: any;
|
|
37
|
+
attributes!: any;
|
|
38
38
|
/**
|
|
39
39
|
* Creates a new NormalShader instance.
|
|
40
40
|
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
@@ -5,11 +5,11 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
|
|
6
6
|
export class PrimitiveShader {
|
|
7
7
|
[key: string]: any;
|
|
8
|
-
gl!: any;
|
|
9
|
-
_UID!: any;
|
|
10
|
-
program!: any;
|
|
11
|
-
fragmentSrc!: any;
|
|
12
|
-
vertexSrc!: any;
|
|
8
|
+
gl!: any;
|
|
9
|
+
_UID!: any;
|
|
10
|
+
program!: any;
|
|
11
|
+
fragmentSrc!: any;
|
|
12
|
+
vertexSrc!: any;
|
|
13
13
|
/**
|
|
14
14
|
* Creates a new PrimitiveShader instance.
|
|
15
15
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
@@ -5,11 +5,11 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
|
|
6
6
|
export class StripShader {
|
|
7
7
|
[key: string]: any;
|
|
8
|
-
gl!: any;
|
|
9
|
-
_UID!: any;
|
|
10
|
-
program!: any;
|
|
11
|
-
fragmentSrc!: any;
|
|
12
|
-
vertexSrc!: any;
|
|
8
|
+
gl!: any;
|
|
9
|
+
_UID!: any;
|
|
10
|
+
program!: any;
|
|
11
|
+
fragmentSrc!: any;
|
|
12
|
+
vertexSrc!: any;
|
|
13
13
|
/**
|
|
14
14
|
* Creates a new StripShader instance.
|
|
15
15
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
@@ -6,16 +6,16 @@ import { StripShader } from './shader/strip.js';
|
|
|
6
6
|
|
|
7
7
|
export class WebGLShaderManager {
|
|
8
8
|
[key: string]: any;
|
|
9
|
-
gl!: any;
|
|
10
|
-
primitiveShader!: any;
|
|
11
|
-
complexPrimitiveShader!: any;
|
|
12
|
-
defaultShader!: any;
|
|
13
|
-
fastShader!: any;
|
|
14
|
-
stripShader!: any;
|
|
15
|
-
maxAttibs!: any;
|
|
16
|
-
attribState!: any;
|
|
17
|
-
tempAttribState!: any;
|
|
18
|
-
stack!: any;
|
|
9
|
+
gl!: any;
|
|
10
|
+
primitiveShader!: any;
|
|
11
|
+
complexPrimitiveShader!: any;
|
|
12
|
+
defaultShader!: any;
|
|
13
|
+
fastShader!: any;
|
|
14
|
+
stripShader!: any;
|
|
15
|
+
maxAttibs!: any;
|
|
16
|
+
attribState!: any;
|
|
17
|
+
tempAttribState!: any;
|
|
18
|
+
stack!: any;
|
|
19
19
|
/**
|
|
20
20
|
* Initializes the shader manager with a WebGL context.
|
|
21
21
|
*/
|
|
@@ -3,22 +3,22 @@ import { NormalShader } from './shader/normal.js';
|
|
|
3
3
|
|
|
4
4
|
export class WebGLSpriteBatch {
|
|
5
5
|
[key: string]: any;
|
|
6
|
-
vertSize!: any;
|
|
7
|
-
size!: any;
|
|
8
|
-
vertices!: any;
|
|
9
|
-
positions!: any;
|
|
10
|
-
colors!: any;
|
|
11
|
-
indices!: any;
|
|
12
|
-
lastIndexCount!: any;
|
|
13
|
-
drawing!: any;
|
|
14
|
-
currentBatchSize!: any;
|
|
15
|
-
currentBaseTexture!: any;
|
|
16
|
-
dirty!: any;
|
|
17
|
-
textures!: any;
|
|
18
|
-
blendModes!: any;
|
|
19
|
-
shaders!: any;
|
|
20
|
-
sprites!: any;
|
|
21
|
-
defaultShader!: any;
|
|
6
|
+
vertSize!: any;
|
|
7
|
+
size!: any;
|
|
8
|
+
vertices!: any;
|
|
9
|
+
positions!: any;
|
|
10
|
+
colors!: any;
|
|
11
|
+
indices!: any;
|
|
12
|
+
lastIndexCount!: any;
|
|
13
|
+
drawing!: any;
|
|
14
|
+
currentBatchSize!: any;
|
|
15
|
+
currentBaseTexture!: any;
|
|
16
|
+
dirty!: any;
|
|
17
|
+
textures!: any;
|
|
18
|
+
blendModes!: any;
|
|
19
|
+
shaders!: any;
|
|
20
|
+
sprites!: any;
|
|
21
|
+
defaultShader!: any;
|
|
22
22
|
/**
|
|
23
23
|
* Creates a new SpriteBatch instance.
|
|
24
24
|
*/
|
|
@@ -2,9 +2,9 @@ import { hex2rgb } from '../../util/math.js';
|
|
|
2
2
|
|
|
3
3
|
export class WebGLStencilManager {
|
|
4
4
|
[key: string]: any;
|
|
5
|
-
stencilStack!: any;
|
|
6
|
-
reverse!: any;
|
|
7
|
-
count!: any;
|
|
5
|
+
stencilStack!: any;
|
|
6
|
+
reverse!: any;
|
|
7
|
+
count!: any;
|
|
8
8
|
/**
|
|
9
9
|
* Initializes the stencil manager.
|
|
10
10
|
*/
|
|
@@ -36,7 +36,11 @@ count!: any;
|
|
|
36
36
|
* @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
|
|
37
37
|
* @param {object} renderSession - The rendering session.
|
|
38
38
|
*/
|
|
39
|
-
pushStencil(
|
|
39
|
+
pushStencil(
|
|
40
|
+
graphics: import('../graphics.js').Graphics,
|
|
41
|
+
webGLData: import('./graphics_data.js').GraphicsData,
|
|
42
|
+
renderSession: any
|
|
43
|
+
) {
|
|
40
44
|
const gl = renderSession.gl;
|
|
41
45
|
this.bindGraphics(graphics, webGLData, renderSession);
|
|
42
46
|
if (this.stencilStack.length === 0) {
|
|
@@ -94,7 +98,11 @@ count!: any;
|
|
|
94
98
|
* @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
|
|
95
99
|
* @param {object} renderSession - The rendering session.
|
|
96
100
|
*/
|
|
97
|
-
bindGraphics(
|
|
101
|
+
bindGraphics(
|
|
102
|
+
graphics: import('../graphics.js').Graphics,
|
|
103
|
+
webGLData: import('./graphics_data.js').GraphicsData,
|
|
104
|
+
renderSession: any
|
|
105
|
+
) {
|
|
98
106
|
// if(this._currentGraphics === graphics)return;
|
|
99
107
|
// this._currentGraphics = graphics;
|
|
100
108
|
const gl = renderSession.gl;
|
|
@@ -141,7 +149,11 @@ count!: any;
|
|
|
141
149
|
* @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
|
|
142
150
|
* @param {object} renderSession - The rendering session.
|
|
143
151
|
*/
|
|
144
|
-
popStencil(
|
|
152
|
+
popStencil(
|
|
153
|
+
graphics: import('../graphics.js').Graphics,
|
|
154
|
+
webGLData: import('./graphics_data.js').GraphicsData,
|
|
155
|
+
renderSession: any
|
|
156
|
+
) {
|
|
145
157
|
const gl = renderSession.gl;
|
|
146
158
|
this.stencilStack.pop();
|
|
147
159
|
this.count -= 1;
|
|
@@ -56,7 +56,12 @@ export class Texture {
|
|
|
56
56
|
* @param {Rectangle | null | undefined} crop - The crop rectangle.
|
|
57
57
|
* @param {Rectangle | null | undefined} trim - The trim rectangle.
|
|
58
58
|
*/
|
|
59
|
-
constructor(
|
|
59
|
+
constructor(
|
|
60
|
+
baseTexture: import('./base_texture.js').BaseTexture,
|
|
61
|
+
frame: Rectangle | null | undefined = null,
|
|
62
|
+
crop: Rectangle | null | undefined = null,
|
|
63
|
+
trim: Rectangle | null | undefined = null
|
|
64
|
+
) {
|
|
60
65
|
this.noFrame = false;
|
|
61
66
|
if (!frame) {
|
|
62
67
|
this.noFrame = true;
|
|
@@ -60,7 +60,7 @@ export const initDefaultShaders = () => {};
|
|
|
60
60
|
* @param {object} shaderType - The type of shader to compile.
|
|
61
61
|
* @returns {WebGLShader} The compiled WebGL shader or null if compilation failed.
|
|
62
62
|
*/
|
|
63
|
-
export const compileShader = (gl: WebGLRenderingContext, shaderSrc: string[]|string, shaderType: any) => {
|
|
63
|
+
export const compileShader = (gl: WebGLRenderingContext, shaderSrc: string[] | string, shaderType: any) => {
|
|
64
64
|
const src = Array.isArray(shaderSrc) ? shaderSrc.join('\n') : shaderSrc;
|
|
65
65
|
const shader = gl.createShader(shaderType);
|
|
66
66
|
gl.shaderSource(shader, src);
|
|
@@ -81,7 +81,7 @@ export const compileShader = (gl: WebGLRenderingContext, shaderSrc: string[]|str
|
|
|
81
81
|
* @param {string[]|string} shaderSrc - The vertex shader source code.
|
|
82
82
|
* @returns {WebGLShader} The compiled WebGL vertex shader or null if compilation failed.
|
|
83
83
|
*/
|
|
84
|
-
export const compileVertexShader = (gl: WebGLRenderingContext, shaderSrc: string[]|string) => {
|
|
84
|
+
export const compileVertexShader = (gl: WebGLRenderingContext, shaderSrc: string[] | string) => {
|
|
85
85
|
return compileShader(gl, shaderSrc, gl.VERTEX_SHADER);
|
|
86
86
|
};
|
|
87
87
|
|
|
@@ -91,7 +91,7 @@ export const compileVertexShader = (gl: WebGLRenderingContext, shaderSrc: string
|
|
|
91
91
|
* @param {string[]|string} shaderSrc - The fragment shader source code.
|
|
92
92
|
* @returns {WebGLShader} The compiled WebGL fragment shader or null if compilation failed.
|
|
93
93
|
*/
|
|
94
|
-
export const compileFragmentShader = (gl: WebGLRenderingContext, shaderSrc: string[]|string) => {
|
|
94
|
+
export const compileFragmentShader = (gl: WebGLRenderingContext, shaderSrc: string[] | string) => {
|
|
95
95
|
return compileShader(gl, shaderSrc, gl.FRAGMENT_SHADER);
|
|
96
96
|
};
|
|
97
97
|
|
|
@@ -102,7 +102,11 @@ export const compileFragmentShader = (gl: WebGLRenderingContext, shaderSrc: stri
|
|
|
102
102
|
* @param {string[]|string} fragmentSrc - The fragment shader source code.
|
|
103
103
|
* @returns {WebGLProgram} The compiled WebGL shader program or null if compilation failed.
|
|
104
104
|
*/
|
|
105
|
-
export const compileProgram = (
|
|
105
|
+
export const compileProgram = (
|
|
106
|
+
gl: WebGLRenderingContext,
|
|
107
|
+
vertexSrc: string[] | string,
|
|
108
|
+
fragmentSrc: string[] | string
|
|
109
|
+
) => {
|
|
106
110
|
const fragmentShader = compileFragmentShader(gl, fragmentSrc);
|
|
107
111
|
const vertexShader = compileVertexShader(gl, vertexSrc);
|
|
108
112
|
|
|
@@ -217,7 +217,14 @@ export const normalize = (a: Point, output: Point = null) => {
|
|
|
217
217
|
* @param {number | null | undefined} dist - The distance to rotate from (default: null).
|
|
218
218
|
* @returns {Point} The rotated point instance for chaining.
|
|
219
219
|
*/
|
|
220
|
-
export const rotate = (
|
|
220
|
+
export const rotate = (
|
|
221
|
+
a: Point,
|
|
222
|
+
x: number,
|
|
223
|
+
y: number,
|
|
224
|
+
ang: number,
|
|
225
|
+
asDegrees: boolean,
|
|
226
|
+
dist: number | null | undefined
|
|
227
|
+
) => {
|
|
221
228
|
if (asDegrees) {
|
|
222
229
|
ang *= Math.PI / 180;
|
|
223
230
|
}
|
|
@@ -162,7 +162,14 @@ export const intersection = (a: Rectangle, b: Rectangle, output: Rectangle = nul
|
|
|
162
162
|
* @param {number} tolerance - Optional tolerance value for intersection.
|
|
163
163
|
* @returns {boolean} True if the rectangle intersects with the area, false otherwise.
|
|
164
164
|
*/
|
|
165
|
-
export const intersectsRaw = (
|
|
165
|
+
export const intersectsRaw = (
|
|
166
|
+
a: Rectangle,
|
|
167
|
+
left: number,
|
|
168
|
+
right: number,
|
|
169
|
+
top: number,
|
|
170
|
+
bottom: number,
|
|
171
|
+
tolerance: number = 0
|
|
172
|
+
) => {
|
|
166
173
|
return !(
|
|
167
174
|
left > a.right + tolerance ||
|
|
168
175
|
right < a.left - tolerance ||
|