@vpmedia/phaser 1.103.0 → 1.104.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.js +1035 -18
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +47 -1
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +9 -0
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +8 -0
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts +23 -0
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/event_manager.d.ts +16 -0
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +1 -0
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/frame_data.d.ts +2 -0
- package/dist/phaser/core/frame_data.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts +56 -0
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +51 -0
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +41 -0
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +16 -0
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +44 -0
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +17 -0
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +28 -0
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/scale_manager.d.ts +55 -0
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +2 -0
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +15 -0
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +93 -0
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +17 -0
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +6 -0
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +4 -0
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +27 -0
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +20 -0
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts +9 -0
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +46 -0
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +24 -0
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +4 -0
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +13 -0
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +28 -0
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts +4 -0
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts +13 -0
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +57 -1
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +18 -0
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts +10 -0
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts +28 -0
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +39 -1
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts +6 -0
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts +12 -0
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +2 -0
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +15 -0
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +3 -0
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +4 -0
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts +9 -0
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts +10 -0
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +17 -0
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +5 -0
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +6 -0
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +10 -0
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +5 -0
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +5 -0
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +10 -0
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +16 -0
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +3 -0
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +20 -0
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/phaser/core/animation.ts +50 -4
- package/src/phaser/core/animation_manager.ts +9 -0
- package/src/phaser/core/cache.ts +8 -0
- package/src/phaser/core/device.ts +23 -0
- package/src/phaser/core/event_manager.ts +16 -0
- package/src/phaser/core/factory.ts +1 -0
- package/src/phaser/core/frame_data.ts +2 -0
- package/src/phaser/core/game.ts +60 -4
- package/src/phaser/core/input.ts +51 -0
- package/src/phaser/core/input_handler.ts +41 -0
- package/src/phaser/core/input_mouse.ts +23 -0
- package/src/phaser/core/input_mspointer.ts +16 -0
- package/src/phaser/core/input_pointer.ts +44 -0
- package/src/phaser/core/input_touch.ts +17 -0
- package/src/phaser/core/loader.ts +28 -0
- package/src/phaser/core/scale_manager.ts +55 -0
- package/src/phaser/core/scene.ts +2 -0
- package/src/phaser/core/scene_manager.ts +15 -0
- package/src/phaser/core/sound.ts +100 -7
- package/src/phaser/core/sound_manager.ts +17 -0
- package/src/phaser/core/sound_sprite.ts +6 -0
- package/src/phaser/core/stage.ts +4 -0
- package/src/phaser/core/time.ts +27 -0
- package/src/phaser/core/timer.ts +20 -0
- package/src/phaser/core/timer_event.ts +9 -0
- package/src/phaser/core/tween.ts +49 -3
- package/src/phaser/core/tween_data.ts +24 -0
- package/src/phaser/core/tween_manager.ts +4 -0
- package/src/phaser/display/bitmap_text.ts +13 -0
- package/src/phaser/display/button.ts +28 -0
- package/src/phaser/display/canvas/buffer.ts +4 -0
- package/src/phaser/display/canvas/renderer.ts +13 -0
- package/src/phaser/display/display_object.ts +91 -31
- package/src/phaser/display/graphics.ts +18 -0
- package/src/phaser/display/graphics_data.ts +10 -0
- package/src/phaser/display/group.ts +28 -0
- package/src/phaser/display/image.ts +44 -6
- package/src/phaser/display/webgl/abstract_filter.ts +6 -0
- package/src/phaser/display/webgl/base_texture.ts +12 -0
- package/src/phaser/display/webgl/blend_manager.ts +2 -0
- package/src/phaser/display/webgl/fast_sprite_batch.ts +15 -0
- package/src/phaser/display/webgl/filter_manager.ts +3 -0
- package/src/phaser/display/webgl/filter_texture.ts +4 -0
- package/src/phaser/display/webgl/graphics_data.ts +9 -0
- package/src/phaser/display/webgl/render_texture.ts +10 -0
- package/src/phaser/display/webgl/renderer.ts +17 -0
- package/src/phaser/display/webgl/shader/complex.ts +5 -0
- package/src/phaser/display/webgl/shader/fast.ts +6 -0
- package/src/phaser/display/webgl/shader/normal.ts +10 -0
- package/src/phaser/display/webgl/shader/primitive.ts +5 -0
- package/src/phaser/display/webgl/shader/strip.ts +5 -0
- package/src/phaser/display/webgl/shader_manager.ts +10 -0
- package/src/phaser/display/webgl/sprite_batch.ts +16 -0
- package/src/phaser/display/webgl/stencil_manager.ts +3 -0
- package/src/phaser/display/webgl/texture.ts +20 -0
|
@@ -7,6 +7,62 @@ import { PI_2 } from '../util/math.js';
|
|
|
7
7
|
import { renderCanvas, renderWebGL } from './sprite_util.js';
|
|
8
8
|
|
|
9
9
|
export class DisplayObject {
|
|
10
|
+
/** @type {boolean} */
|
|
11
|
+
exists = true;
|
|
12
|
+
/** @type {boolean} */
|
|
13
|
+
renderable = false;
|
|
14
|
+
/** @type {boolean} */
|
|
15
|
+
visible = true;
|
|
16
|
+
/** @type {Point} */
|
|
17
|
+
position;
|
|
18
|
+
/** @type {Point} */
|
|
19
|
+
scale;
|
|
20
|
+
/** @type {Point} */
|
|
21
|
+
pivot;
|
|
22
|
+
/** @type {Point} */
|
|
23
|
+
anchor;
|
|
24
|
+
/** @type {number} */
|
|
25
|
+
rotation = 0;
|
|
26
|
+
/** @type {number} */
|
|
27
|
+
alpha = 1;
|
|
28
|
+
/** @type {Rectangle} */
|
|
29
|
+
hitArea = null;
|
|
30
|
+
/** @type {DisplayObject} */
|
|
31
|
+
parent = null;
|
|
32
|
+
/** @type {number} */
|
|
33
|
+
worldAlpha = 1;
|
|
34
|
+
/** @type {Matrix} */
|
|
35
|
+
worldTransform;
|
|
36
|
+
/** @type {Point} */
|
|
37
|
+
worldScale;
|
|
38
|
+
/** @type {Rectangle} */
|
|
39
|
+
filterArea = null;
|
|
40
|
+
/** @type {number} */
|
|
41
|
+
_sr = 0;
|
|
42
|
+
/** @type {number} */
|
|
43
|
+
_cr = 1;
|
|
44
|
+
/** @type {Rectangle} */
|
|
45
|
+
cachedBounds;
|
|
46
|
+
/** @type {Rectangle} */
|
|
47
|
+
currentBounds = null;
|
|
48
|
+
/** @type {import('./graphics.js').Graphics} */
|
|
49
|
+
_mask = null;
|
|
50
|
+
/** @type {object[]} */
|
|
51
|
+
_filters = null;
|
|
52
|
+
/** @type {object} */
|
|
53
|
+
_filterBlock = null;
|
|
54
|
+
/** @type {DisplayObject[]} */
|
|
55
|
+
children;
|
|
56
|
+
/** @type {boolean} */
|
|
57
|
+
ignoreChildInput = false;
|
|
58
|
+
/** @type {string | null} */
|
|
59
|
+
name = null;
|
|
60
|
+
/** @type {object | null} */
|
|
61
|
+
data = null;
|
|
62
|
+
/** @type {import('../core/game.js').Game} */
|
|
63
|
+
game;
|
|
64
|
+
/** @type {number} */
|
|
65
|
+
type;
|
|
10
66
|
/**
|
|
11
67
|
* Creates a new DisplayObject instance.
|
|
12
68
|
* @param {import('../core/game.js').Game} game - The game instance this display object belongs to.
|
|
@@ -38,10 +94,10 @@ export class DisplayObject {
|
|
|
38
94
|
this.worldAlpha = 1;
|
|
39
95
|
/** @type {Matrix} */
|
|
40
96
|
this.worldTransform = new Matrix();
|
|
41
|
-
//
|
|
97
|
+
// This.worldPosition = new Point(0, 0);
|
|
42
98
|
/** @type {Point} */
|
|
43
99
|
this.worldScale = new Point(1, 1);
|
|
44
|
-
//
|
|
100
|
+
// This.worldRotation = 0;
|
|
45
101
|
/** @type {Rectangle} */
|
|
46
102
|
this.filterArea = null;
|
|
47
103
|
/** @type {number} */
|
|
@@ -86,7 +142,7 @@ export class DisplayObject {
|
|
|
86
142
|
this.visible = false;
|
|
87
143
|
// TODO: investigate how to clean up properly object references without breaking delayed tween cleanups.
|
|
88
144
|
/*
|
|
89
|
-
|
|
145
|
+
This.position = null;
|
|
90
146
|
this.scale = null;
|
|
91
147
|
this.pivot = null;
|
|
92
148
|
this.anchor = null;
|
|
@@ -94,7 +150,7 @@ export class DisplayObject {
|
|
|
94
150
|
this.hitArea = null;
|
|
95
151
|
this.parent = null;
|
|
96
152
|
this.worldTransform = null;
|
|
97
|
-
//
|
|
153
|
+
// This.worldPosition = null;
|
|
98
154
|
this.worldScale = null;
|
|
99
155
|
this.filterArea = null;
|
|
100
156
|
this.cachedBounds = null;
|
|
@@ -175,8 +231,8 @@ export class DisplayObject {
|
|
|
175
231
|
throw new Error('The supplied index is out of bounds');
|
|
176
232
|
}
|
|
177
233
|
const currentIndex = this.getChildIndex(child);
|
|
178
|
-
this.children.splice(currentIndex, 1); //
|
|
179
|
-
this.children.splice(index, 0, child); //
|
|
234
|
+
this.children.splice(currentIndex, 1); // Remove from old position
|
|
235
|
+
this.children.splice(index, 0, child); // Add at new position
|
|
180
236
|
}
|
|
181
237
|
|
|
182
238
|
/**
|
|
@@ -270,37 +326,37 @@ export class DisplayObject {
|
|
|
270
326
|
} else if (!this.parent) {
|
|
271
327
|
p = this.game.world;
|
|
272
328
|
}
|
|
273
|
-
//
|
|
329
|
+
// Create some matrix refs for easy access
|
|
274
330
|
const pt = p.worldTransform;
|
|
275
331
|
const wt = this.worldTransform;
|
|
276
|
-
//
|
|
332
|
+
// Temporary matrix variables
|
|
277
333
|
let a;
|
|
278
334
|
let b;
|
|
279
335
|
let c;
|
|
280
336
|
let d;
|
|
281
337
|
let tx;
|
|
282
338
|
let ty;
|
|
283
|
-
//
|
|
339
|
+
// So if rotation is between 0 then we can simplify the multiplication process..
|
|
284
340
|
if (this.rotation % PI_2) {
|
|
285
|
-
//
|
|
341
|
+
// Check to see if the rotation is the same as the previous render. This means we only need to use sin and cos when rotation actually changes
|
|
286
342
|
if (this.rotation !== this.rotationCache) {
|
|
287
343
|
this.rotationCache = this.rotation;
|
|
288
344
|
this._sr = Math.sin(this.rotation);
|
|
289
345
|
this._cr = Math.cos(this.rotation);
|
|
290
346
|
}
|
|
291
|
-
//
|
|
347
|
+
// Get the matrix values of the displayobject based on its transform properties..
|
|
292
348
|
a = this._cr * this.scale.x;
|
|
293
349
|
b = this._sr * this.scale.x;
|
|
294
350
|
c = -this._sr * this.scale.y;
|
|
295
351
|
d = this._cr * this.scale.y;
|
|
296
352
|
tx = this.position.x;
|
|
297
353
|
ty = this.position.y;
|
|
298
|
-
//
|
|
354
|
+
// Check for pivot.. not often used so geared towards that fact!
|
|
299
355
|
if (this.pivot.x || this.pivot.y) {
|
|
300
356
|
tx -= this.pivot.x * a + this.pivot.y * c;
|
|
301
357
|
ty -= this.pivot.x * b + this.pivot.y * d;
|
|
302
358
|
}
|
|
303
|
-
//
|
|
359
|
+
// Concat the parent matrix with the objects transform.
|
|
304
360
|
wt.a = a * pt.a + b * pt.c;
|
|
305
361
|
wt.b = a * pt.b + b * pt.d;
|
|
306
362
|
wt.c = c * pt.a + d * pt.c;
|
|
@@ -308,7 +364,7 @@ export class DisplayObject {
|
|
|
308
364
|
wt.tx = tx * pt.a + ty * pt.c + pt.tx;
|
|
309
365
|
wt.ty = tx * pt.b + ty * pt.d + pt.ty;
|
|
310
366
|
} else {
|
|
311
|
-
//
|
|
367
|
+
// Lets do the fast version as we know there is no rotation..
|
|
312
368
|
a = this.scale.x;
|
|
313
369
|
d = this.scale.y;
|
|
314
370
|
tx = this.position.x - this.pivot.x * a;
|
|
@@ -322,13 +378,13 @@ export class DisplayObject {
|
|
|
322
378
|
}
|
|
323
379
|
// Set the World values
|
|
324
380
|
this.worldAlpha = this.alpha * p.worldAlpha;
|
|
325
|
-
//
|
|
381
|
+
// This.worldPosition.setTo(wt.tx, wt.ty);
|
|
326
382
|
this.worldScale.setTo(
|
|
327
383
|
this.scale.x * Math.sqrt(wt.a * wt.a + wt.c * wt.c),
|
|
328
384
|
this.scale.y * Math.sqrt(wt.b * wt.b + wt.d * wt.d)
|
|
329
385
|
);
|
|
330
386
|
this.worldRotation = Math.atan2(-wt.c, wt.d);
|
|
331
|
-
//
|
|
387
|
+
// Reset the bounds each time this is called!
|
|
332
388
|
this.currentBounds = null;
|
|
333
389
|
// Custom callback?
|
|
334
390
|
if (this.transformCallback) {
|
|
@@ -392,13 +448,13 @@ export class DisplayObject {
|
|
|
392
448
|
const w1 = bounds.width + bounds.x;
|
|
393
449
|
const h0 = bounds.y;
|
|
394
450
|
const h1 = bounds.height + bounds.y;
|
|
395
|
-
const worldTransform = this
|
|
396
|
-
const a = worldTransform
|
|
397
|
-
const b = worldTransform
|
|
398
|
-
const c = worldTransform
|
|
399
|
-
const d = worldTransform
|
|
400
|
-
const tx = worldTransform
|
|
401
|
-
const ty = worldTransform
|
|
451
|
+
const { worldTransform } = this;
|
|
452
|
+
const { a } = worldTransform;
|
|
453
|
+
const { b } = worldTransform;
|
|
454
|
+
const { c } = worldTransform;
|
|
455
|
+
const { d } = worldTransform;
|
|
456
|
+
const { tx } = worldTransform;
|
|
457
|
+
const { ty } = worldTransform;
|
|
402
458
|
const x1 = a * w1 + c * h1 + tx;
|
|
403
459
|
const y1 = d * h1 + b * w1 + ty;
|
|
404
460
|
const x2 = a * w0 + c * h1 + tx;
|
|
@@ -475,7 +531,7 @@ export class DisplayObject {
|
|
|
475
531
|
}
|
|
476
532
|
let i;
|
|
477
533
|
if (this._mask || this._filters) {
|
|
478
|
-
//
|
|
534
|
+
// Push filter first as we need to ensure the stencil buffer is correct for any masking
|
|
479
535
|
if (this._filters) {
|
|
480
536
|
renderSession.spriteBatch.flush();
|
|
481
537
|
renderSession.filterManager.pushFilter(this._filterBlock);
|
|
@@ -489,8 +545,12 @@ export class DisplayObject {
|
|
|
489
545
|
this.children[i].renderWebGL(renderSession);
|
|
490
546
|
}
|
|
491
547
|
renderSession.spriteBatch.stop();
|
|
492
|
-
if (this._mask)
|
|
493
|
-
|
|
548
|
+
if (this._mask) {
|
|
549
|
+
renderSession.maskManager.popMask(this._mask, renderSession);
|
|
550
|
+
}
|
|
551
|
+
if (this._filters) {
|
|
552
|
+
renderSession.filterManager.popFilter();
|
|
553
|
+
}
|
|
494
554
|
renderSession.spriteBatch.start();
|
|
495
555
|
} else {
|
|
496
556
|
for (i = 0; i < this.children.length; i += 1) {
|
|
@@ -522,21 +582,21 @@ export class DisplayObject {
|
|
|
522
582
|
* Called before the update cycle for this display object.
|
|
523
583
|
*/
|
|
524
584
|
preUpdate() {
|
|
525
|
-
//
|
|
585
|
+
// Override
|
|
526
586
|
}
|
|
527
587
|
|
|
528
588
|
/**
|
|
529
589
|
* Called during the update cycle for this display object.
|
|
530
590
|
*/
|
|
531
591
|
update() {
|
|
532
|
-
//
|
|
592
|
+
// Override
|
|
533
593
|
}
|
|
534
594
|
|
|
535
595
|
/**
|
|
536
596
|
* Called after the update cycle for this display object.
|
|
537
597
|
*/
|
|
538
598
|
postUpdate() {
|
|
539
|
-
//
|
|
599
|
+
// Override
|
|
540
600
|
}
|
|
541
601
|
|
|
542
602
|
/**
|
|
@@ -621,7 +681,7 @@ export class DisplayObject {
|
|
|
621
681
|
* @param {number} value - The new width in pixels.
|
|
622
682
|
*/
|
|
623
683
|
set width(value) {
|
|
624
|
-
const width = this.getLocalBounds()
|
|
684
|
+
const { width } = this.getLocalBounds();
|
|
625
685
|
if (width !== 0) {
|
|
626
686
|
this.scale.x = value / width;
|
|
627
687
|
} else {
|
|
@@ -643,7 +703,7 @@ export class DisplayObject {
|
|
|
643
703
|
* @param {number} value - The new height in pixels.
|
|
644
704
|
*/
|
|
645
705
|
set height(value) {
|
|
646
|
-
const height = this.getLocalBounds()
|
|
706
|
+
const { height } = this.getLocalBounds();
|
|
647
707
|
if (height !== 0) {
|
|
648
708
|
this.scale.y = value / height;
|
|
649
709
|
} else {
|
|
@@ -26,6 +26,24 @@ import { renderGraphics as renderWebGLGraphics } from './webgl/graphics.js';
|
|
|
26
26
|
import { textureFromCanvas } from './webgl/texture_util.js';
|
|
27
27
|
|
|
28
28
|
export class Graphics extends DisplayObject {
|
|
29
|
+
type;
|
|
30
|
+
renderable;
|
|
31
|
+
fillAlpha;
|
|
32
|
+
lineWidth;
|
|
33
|
+
lineColor;
|
|
34
|
+
graphicsData;
|
|
35
|
+
tint;
|
|
36
|
+
blendMode;
|
|
37
|
+
currentPath;
|
|
38
|
+
_webGL;
|
|
39
|
+
isMask;
|
|
40
|
+
boundsPadding;
|
|
41
|
+
_localBounds;
|
|
42
|
+
dirty;
|
|
43
|
+
_boundsDirty;
|
|
44
|
+
_cacheAsBitmap;
|
|
45
|
+
webGLDirty;
|
|
46
|
+
cachedSpriteDirty;
|
|
29
47
|
/**
|
|
30
48
|
* Creates a new Graphics object.
|
|
31
49
|
* @param {import('../core/game.js').Game} game - The game instance.
|
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
import { clone } from './graphics_data_util.js';
|
|
3
3
|
|
|
4
4
|
export class GraphicsData {
|
|
5
|
+
lineWidth;
|
|
6
|
+
lineColor;
|
|
7
|
+
lineAlpha;
|
|
8
|
+
_lineTint;
|
|
9
|
+
fillColor;
|
|
10
|
+
fillAlpha;
|
|
11
|
+
_fillTint;
|
|
12
|
+
fill;
|
|
13
|
+
shape;
|
|
14
|
+
type;
|
|
5
15
|
/**
|
|
6
16
|
* Creates a new GraphicsData object.
|
|
7
17
|
* @param {number} lineWidth - The line width.
|
|
@@ -8,6 +8,34 @@ export const SORT_ASCENDING = -1;
|
|
|
8
8
|
export const SORT_DESCENDING = 1;
|
|
9
9
|
|
|
10
10
|
export class Group extends DisplayObject {
|
|
11
|
+
/** @type {number} */
|
|
12
|
+
z;
|
|
13
|
+
/** @type {boolean} */
|
|
14
|
+
ignoreDestroy;
|
|
15
|
+
/** @type {boolean} */
|
|
16
|
+
pendingDestroy;
|
|
17
|
+
/** @type {Function} */
|
|
18
|
+
classType;
|
|
19
|
+
/** @type {DisplayObject | null} */
|
|
20
|
+
cursor;
|
|
21
|
+
/** @type {boolean} */
|
|
22
|
+
inputEnableChildren;
|
|
23
|
+
/** @type {Signal} */
|
|
24
|
+
onChildInputDown;
|
|
25
|
+
/** @type {Signal} */
|
|
26
|
+
onChildInputUp;
|
|
27
|
+
/** @type {Signal} */
|
|
28
|
+
onChildInputOver;
|
|
29
|
+
/** @type {Signal} */
|
|
30
|
+
onChildInputOut;
|
|
31
|
+
/** @type {Signal} */
|
|
32
|
+
onDestroy;
|
|
33
|
+
/** @type {number} */
|
|
34
|
+
cursorIndex;
|
|
35
|
+
/** @type {string} */
|
|
36
|
+
_sortProperty;
|
|
37
|
+
/** @type {object[] | null} */
|
|
38
|
+
filters;
|
|
11
39
|
/**
|
|
12
40
|
* Creates a new Group object.
|
|
13
41
|
* @param {import('../core/game.js').Game} game - The game instance this group belongs to.
|
|
@@ -9,6 +9,44 @@ import { getBounds, getLocalBounds, renderCanvas, renderWebGL, setTexture } from
|
|
|
9
9
|
import { Texture } from './webgl/texture.js';
|
|
10
10
|
|
|
11
11
|
export class Image extends DisplayObject {
|
|
12
|
+
/** @type {string | number | Texture} */
|
|
13
|
+
key;
|
|
14
|
+
/** @type {Texture} */
|
|
15
|
+
texture;
|
|
16
|
+
/** @type {number} */
|
|
17
|
+
_width;
|
|
18
|
+
/** @type {number} */
|
|
19
|
+
_height;
|
|
20
|
+
/** @type {number} */
|
|
21
|
+
tint;
|
|
22
|
+
/** @type {number} */
|
|
23
|
+
cachedTint;
|
|
24
|
+
/** @type {Texture | null} */
|
|
25
|
+
tilingTexture;
|
|
26
|
+
/** @type {Texture | null} */
|
|
27
|
+
tintedTexture;
|
|
28
|
+
/** @type {number} */
|
|
29
|
+
blendMode;
|
|
30
|
+
/** @type {object | null} */
|
|
31
|
+
shader;
|
|
32
|
+
/** @type {import('../core/frame.js').Frame | null} */
|
|
33
|
+
_frame;
|
|
34
|
+
/** @type {boolean} */
|
|
35
|
+
pendingDestroy;
|
|
36
|
+
/** @type {EventManager} */
|
|
37
|
+
events;
|
|
38
|
+
/** @type {AnimationManager} */
|
|
39
|
+
animations;
|
|
40
|
+
/** @type {boolean} */
|
|
41
|
+
customRender;
|
|
42
|
+
/** @type {Rectangle | null} */
|
|
43
|
+
cropRect;
|
|
44
|
+
/** @type {Rectangle | null} */
|
|
45
|
+
_crop;
|
|
46
|
+
/** @type {boolean} */
|
|
47
|
+
refreshTexture;
|
|
48
|
+
/** @type {number} */
|
|
49
|
+
renderOrderID;
|
|
12
50
|
/**
|
|
13
51
|
* Creates a new Image instance.
|
|
14
52
|
* @param {import('../core/game.js').Game} game - The game instance this image belongs to.
|
|
@@ -33,7 +71,7 @@ export class Image extends DisplayObject {
|
|
|
33
71
|
/** @type {number} */
|
|
34
72
|
this._height = 0;
|
|
35
73
|
/** @type {number} */
|
|
36
|
-
this.tint =
|
|
74
|
+
this.tint = 0xff_ff_ff;
|
|
37
75
|
/** @type {number} */
|
|
38
76
|
this.cachedTint = -1;
|
|
39
77
|
/** @type {Texture | null} */
|
|
@@ -46,7 +84,7 @@ export class Image extends DisplayObject {
|
|
|
46
84
|
this._frame = null;
|
|
47
85
|
/** @type {boolean} */
|
|
48
86
|
this.pendingDestroy = false;
|
|
49
|
-
/*
|
|
87
|
+
/* If (this.texture.baseTexture.hasLoaded) {
|
|
50
88
|
this.onTextureUpdate();
|
|
51
89
|
} */
|
|
52
90
|
this.position.setTo(x, y);
|
|
@@ -65,7 +103,7 @@ export class Image extends DisplayObject {
|
|
|
65
103
|
this.key = null;
|
|
66
104
|
this.data = null;
|
|
67
105
|
this.texture = null;
|
|
68
|
-
this.tint =
|
|
106
|
+
this.tint = 0xff_ff_ff;
|
|
69
107
|
this.cachedTint = -1;
|
|
70
108
|
this.tintedTexture = null;
|
|
71
109
|
this.shader = null;
|
|
@@ -113,7 +151,7 @@ export class Image extends DisplayObject {
|
|
|
113
151
|
* @param {string | number | null | undefined} frame - The frame identifier (name or index) to use.
|
|
114
152
|
* @param {boolean} stopAnimation - Whether to stop the animation when changing textures.
|
|
115
153
|
*/
|
|
116
|
-
loadTexture(key, frame = 0, stopAnimation = true) {
|
|
154
|
+
loadTexture(key, frame: string | number | null = 0, stopAnimation = true) {
|
|
117
155
|
if (key === PENDING_ATLAS) {
|
|
118
156
|
key = frame;
|
|
119
157
|
frame = 0;
|
|
@@ -125,7 +163,7 @@ export class Image extends DisplayObject {
|
|
|
125
163
|
}
|
|
126
164
|
this.key = key;
|
|
127
165
|
this.customRender = false;
|
|
128
|
-
const cache = this.game
|
|
166
|
+
const { cache } = this.game;
|
|
129
167
|
const smoothed = !this.texture.baseTexture.scaleMode;
|
|
130
168
|
let setFrame = true;
|
|
131
169
|
if (key instanceof Texture) {
|
|
@@ -342,7 +380,7 @@ export class Image extends DisplayObject {
|
|
|
342
380
|
* Called when the texture of this image is updated.
|
|
343
381
|
*/
|
|
344
382
|
onTextureUpdate() {
|
|
345
|
-
//
|
|
383
|
+
// So if _width is 0 then width was not set..
|
|
346
384
|
if (this._width) {
|
|
347
385
|
this.scale.x = this._width / this.texture.frame.width;
|
|
348
386
|
}
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
import { removeByCanvas } from '../canvas/pool.js';
|
|
3
3
|
|
|
4
4
|
export class BaseTexture {
|
|
5
|
+
resolution;
|
|
6
|
+
width;
|
|
7
|
+
height;
|
|
8
|
+
scaleMode;
|
|
9
|
+
hasLoaded;
|
|
10
|
+
source;
|
|
11
|
+
premultipliedAlpha;
|
|
12
|
+
_glTextures;
|
|
13
|
+
mipmap;
|
|
14
|
+
skipRender;
|
|
15
|
+
_powerOf2;
|
|
16
|
+
_dirty;
|
|
5
17
|
/**
|
|
6
18
|
* Updates the base texture with a new source.
|
|
7
19
|
* @param {HTMLCanvasElement} source - The new canvas element to use as the texture source.
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
export class FastSpriteBatch {
|
|
3
|
+
vertSize;
|
|
4
|
+
maxSize;
|
|
5
|
+
size;
|
|
6
|
+
vertices;
|
|
7
|
+
indices;
|
|
8
|
+
vertexBuffer;
|
|
9
|
+
indexBuffer;
|
|
10
|
+
lastIndexCount;
|
|
11
|
+
drawing;
|
|
12
|
+
currentBatchSize;
|
|
13
|
+
currentBaseTexture;
|
|
14
|
+
currentBlendMode;
|
|
15
|
+
renderSession;
|
|
16
|
+
shader;
|
|
17
|
+
matrix;
|
|
3
18
|
/**
|
|
4
19
|
* Creates a new FastSpriteBatch instance.
|
|
5
20
|
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
@@ -8,6 +8,16 @@ import { FilterTexture } from './filter_texture.js';
|
|
|
8
8
|
import { Texture } from './texture.js';
|
|
9
9
|
|
|
10
10
|
export class RenderTexture extends Texture {
|
|
11
|
+
width;
|
|
12
|
+
height;
|
|
13
|
+
resolution;
|
|
14
|
+
frame;
|
|
15
|
+
crop;
|
|
16
|
+
renderer;
|
|
17
|
+
textureBuffer;
|
|
18
|
+
render;
|
|
19
|
+
projection;
|
|
20
|
+
valid;
|
|
11
21
|
/**
|
|
12
22
|
* Creates a new RenderTexture instance.
|
|
13
23
|
* @param {number} width - The width of the render texture.
|
|
@@ -33,6 +33,23 @@ import { WebGLStencilManager } from './stencil_manager.js';
|
|
|
33
33
|
import { getWebGLContextErrorCode, getWebGLContextErrorName } from './util.js';
|
|
34
34
|
|
|
35
35
|
export class WebGLRenderer {
|
|
36
|
+
type;
|
|
37
|
+
resolution;
|
|
38
|
+
autoResize;
|
|
39
|
+
contextLost;
|
|
40
|
+
clearBeforeRender;
|
|
41
|
+
width;
|
|
42
|
+
height;
|
|
43
|
+
view;
|
|
44
|
+
_contextOptions;
|
|
45
|
+
projection;
|
|
46
|
+
offset;
|
|
47
|
+
shaderManager;
|
|
48
|
+
spriteBatch;
|
|
49
|
+
filterManager;
|
|
50
|
+
stencilManager;
|
|
51
|
+
blendModeManager;
|
|
52
|
+
renderSession;
|
|
36
53
|
/**
|
|
37
54
|
* Creates a new WebGLRenderer instance.
|
|
38
55
|
* @param {import('../../core/game.js').Game} game - The game instance.
|
|
@@ -5,6 +5,11 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
// the next one is used for rendering triangle strips
|
|
6
6
|
|
|
7
7
|
export class ComplexPrimitiveShader {
|
|
8
|
+
gl;
|
|
9
|
+
_UID;
|
|
10
|
+
program;
|
|
11
|
+
fragmentSrc;
|
|
12
|
+
vertexSrc;
|
|
8
13
|
/**
|
|
9
14
|
* Creates a new ComplexShader instance.
|
|
10
15
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
@@ -5,6 +5,12 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
// this shader is used for the fast sprite rendering
|
|
6
6
|
|
|
7
7
|
export class FastShader {
|
|
8
|
+
gl;
|
|
9
|
+
_UID;
|
|
10
|
+
program;
|
|
11
|
+
textureCount;
|
|
12
|
+
fragmentSrc;
|
|
13
|
+
vertexSrc;
|
|
8
14
|
/**
|
|
9
15
|
* Creates a new FastShader instance.
|
|
10
16
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
@@ -25,6 +25,16 @@ const defaultVertexSrc = [
|
|
|
25
25
|
// this shader is used for the default sprite rendering
|
|
26
26
|
|
|
27
27
|
export class NormalShader {
|
|
28
|
+
gl;
|
|
29
|
+
_UID;
|
|
30
|
+
program;
|
|
31
|
+
fragmentSrc;
|
|
32
|
+
vertexSrc;
|
|
33
|
+
textureCount;
|
|
34
|
+
firstRun;
|
|
35
|
+
dirty;
|
|
36
|
+
uniforms;
|
|
37
|
+
attributes;
|
|
28
38
|
/**
|
|
29
39
|
* Creates a new NormalShader instance.
|
|
30
40
|
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
@@ -5,6 +5,11 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
// the next one is used for rendering primitives
|
|
6
6
|
|
|
7
7
|
export class PrimitiveShader {
|
|
8
|
+
gl;
|
|
9
|
+
_UID;
|
|
10
|
+
program;
|
|
11
|
+
fragmentSrc;
|
|
12
|
+
vertexSrc;
|
|
8
13
|
/**
|
|
9
14
|
* Creates a new PrimitiveShader instance.
|
|
10
15
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
@@ -5,6 +5,11 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
// the next one is used for rendering triangle strips
|
|
6
6
|
|
|
7
7
|
export class StripShader {
|
|
8
|
+
gl;
|
|
9
|
+
_UID;
|
|
10
|
+
program;
|
|
11
|
+
fragmentSrc;
|
|
12
|
+
vertexSrc;
|
|
8
13
|
/**
|
|
9
14
|
* Creates a new StripShader instance.
|
|
10
15
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
@@ -6,6 +6,16 @@ import { PrimitiveShader } from './shader/primitive.js';
|
|
|
6
6
|
import { StripShader } from './shader/strip.js';
|
|
7
7
|
|
|
8
8
|
export class WebGLShaderManager {
|
|
9
|
+
gl;
|
|
10
|
+
primitiveShader;
|
|
11
|
+
complexPrimitiveShader;
|
|
12
|
+
defaultShader;
|
|
13
|
+
fastShader;
|
|
14
|
+
stripShader;
|
|
15
|
+
maxAttibs;
|
|
16
|
+
attribState;
|
|
17
|
+
tempAttribState;
|
|
18
|
+
stack;
|
|
9
19
|
/**
|
|
10
20
|
* Initializes the shader manager with a WebGL context.
|
|
11
21
|
*/
|
|
@@ -3,6 +3,22 @@ import { AbstractFilter } from './abstract_filter.js';
|
|
|
3
3
|
import { NormalShader } from './shader/normal.js';
|
|
4
4
|
|
|
5
5
|
export class WebGLSpriteBatch {
|
|
6
|
+
vertSize;
|
|
7
|
+
size;
|
|
8
|
+
vertices;
|
|
9
|
+
positions;
|
|
10
|
+
colors;
|
|
11
|
+
indices;
|
|
12
|
+
lastIndexCount;
|
|
13
|
+
drawing;
|
|
14
|
+
currentBatchSize;
|
|
15
|
+
currentBaseTexture;
|
|
16
|
+
dirty;
|
|
17
|
+
textures;
|
|
18
|
+
blendModes;
|
|
19
|
+
shaders;
|
|
20
|
+
sprites;
|
|
21
|
+
defaultShader;
|
|
6
22
|
/**
|
|
7
23
|
* Creates a new SpriteBatch instance.
|
|
8
24
|
*/
|