@vpmedia/phaser 1.124.0 → 1.126.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.
Files changed (81) hide show
  1. package/dist/index.js +312 -309
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  4. package/dist/phaser/core/device_util.d.ts.map +1 -1
  5. package/dist/phaser/core/dom.d.ts.map +1 -1
  6. package/dist/phaser/core/frame_data.d.ts.map +1 -1
  7. package/dist/phaser/core/game.d.ts.map +1 -1
  8. package/dist/phaser/core/input.d.ts.map +1 -1
  9. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  10. package/dist/phaser/core/loader.d.ts.map +1 -1
  11. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  12. package/dist/phaser/core/sound.d.ts.map +1 -1
  13. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  14. package/dist/phaser/core/tween.d.ts.map +1 -1
  15. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  16. package/dist/phaser/display/display_object.d.ts +2 -2
  17. package/dist/phaser/display/display_object.d.ts.map +1 -1
  18. package/dist/phaser/display/graphics.d.ts +1 -1
  19. package/dist/phaser/display/graphics.d.ts.map +1 -1
  20. package/dist/phaser/display/group.d.ts.map +1 -1
  21. package/dist/phaser/display/image.d.ts.map +1 -1
  22. package/dist/phaser/display/text.d.ts.map +1 -1
  23. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  24. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  25. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  26. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  27. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  28. package/dist/phaser/util/math.d.ts.map +1 -1
  29. package/package.json +1 -1
  30. package/src/phaser/core/animation.ts +7 -7
  31. package/src/phaser/core/animation_manager.ts +2 -2
  32. package/src/phaser/core/animation_parser.ts +11 -15
  33. package/src/phaser/core/array_set.ts +2 -2
  34. package/src/phaser/core/cache.ts +4 -4
  35. package/src/phaser/core/device_util.ts +7 -4
  36. package/src/phaser/core/dom.ts +24 -19
  37. package/src/phaser/core/frame_data.ts +2 -5
  38. package/src/phaser/core/game.test.ts +131 -0
  39. package/src/phaser/core/game.ts +17 -12
  40. package/src/phaser/core/input.ts +4 -3
  41. package/src/phaser/core/input_handler.ts +14 -13
  42. package/src/phaser/core/input_mouse.ts +4 -4
  43. package/src/phaser/core/input_pointer.ts +1 -1
  44. package/src/phaser/core/loader.ts +38 -50
  45. package/src/phaser/core/scale_manager.ts +10 -9
  46. package/src/phaser/core/scene_manager.ts +2 -2
  47. package/src/phaser/core/signal.ts +2 -2
  48. package/src/phaser/core/sound.ts +25 -32
  49. package/src/phaser/core/sound_manager.ts +12 -16
  50. package/src/phaser/core/sound_sprite.ts +1 -1
  51. package/src/phaser/core/stage.ts +3 -3
  52. package/src/phaser/core/timer.ts +1 -1
  53. package/src/phaser/core/tween.ts +6 -11
  54. package/src/phaser/display/bitmap_text.ts +3 -3
  55. package/src/phaser/display/button.ts +12 -12
  56. package/src/phaser/display/canvas/graphics.ts +2 -2
  57. package/src/phaser/display/canvas/pool.ts +3 -3
  58. package/src/phaser/display/canvas/renderer.ts +6 -5
  59. package/src/phaser/display/canvas/tinter.ts +1 -1
  60. package/src/phaser/display/canvas/util.ts +2 -2
  61. package/src/phaser/display/display_object.ts +13 -14
  62. package/src/phaser/display/graphics.test.ts +2 -2
  63. package/src/phaser/display/graphics.ts +9 -11
  64. package/src/phaser/display/group.ts +10 -9
  65. package/src/phaser/display/image.ts +7 -6
  66. package/src/phaser/display/sprite_util.ts +1 -1
  67. package/src/phaser/display/text.ts +35 -44
  68. package/src/phaser/display/webgl/abstract_filter.ts +1 -1
  69. package/src/phaser/display/webgl/earcut.ts +46 -42
  70. package/src/phaser/display/webgl/graphics.ts +2 -2
  71. package/src/phaser/display/webgl/renderer.ts +3 -3
  72. package/src/phaser/display/webgl/shader/normal.ts +6 -6
  73. package/src/phaser/display/webgl/shader_manager.ts +1 -1
  74. package/src/phaser/display/webgl/sprite_batch.ts +2 -2
  75. package/src/phaser/display/webgl/texture.ts +2 -1
  76. package/src/phaser/display/webgl/util.ts +3 -3
  77. package/src/phaser/geom/polygon.ts +2 -2
  78. package/src/phaser/geom/rectangle.ts +1 -2
  79. package/src/phaser/geom/util/circle.ts +6 -10
  80. package/src/phaser/geom/util/point.ts +5 -7
  81. package/src/phaser/util/math.ts +2 -3
@@ -80,7 +80,7 @@ export class BitmapText extends DisplayObject {
80
80
  return;
81
81
  }
82
82
 
83
- if (!this.exists || !this.parent?.exists) {
83
+ if (!this.exists || this.parent?.exists !== true) {
84
84
  this.renderOrderID = -1;
85
85
  return;
86
86
  }
@@ -150,7 +150,7 @@ export class BitmapText extends DisplayObject {
150
150
  // What will the line width be if we add this character to it?
151
151
  c = (kerning + (charData.texture?.width ?? 0) + charData.xOffset) * scale;
152
152
  // Do we need to line-wrap?
153
- if (maxWidth && w + c >= maxWidth && lastSpace > -1) {
153
+ if (maxWidth !== null && w + c >= maxWidth && lastSpace > -1) {
154
154
  // The last space was at "lastSpace" which was "i - lastSpace" characters ago
155
155
  return {
156
156
  width: wrappedWidth || w,
@@ -463,7 +463,7 @@ export class BitmapText extends DisplayObject {
463
463
  * @returns {boolean} True if smoothing is enabled, false otherwise.
464
464
  */
465
465
  public get smoothed(): boolean {
466
- return !this._data?.base.scaleMode;
466
+ return this._data?.base.scaleMode === 0;
467
467
  }
468
468
 
469
469
  /**
@@ -93,7 +93,7 @@ export class Button extends Image {
93
93
  this._onDownFrame = null;
94
94
  this._onUpFrame = null;
95
95
  this._onDisabledFrame = null;
96
- if (this.onInputOver) {
96
+ if (this.onInputOver !== null) {
97
97
  this.onInputOver.dispose();
98
98
  this.onInputOut.dispose();
99
99
  this.onInputDown.dispose();
@@ -103,7 +103,7 @@ export class Button extends Image {
103
103
  this.onInputOut = null!;
104
104
  this.onInputDown = null!;
105
105
  this.onInputUp = null!;
106
- if (this.input) {
106
+ if (this.input !== null) {
107
107
  this.input.destroy();
108
108
  }
109
109
  this.input = null!;
@@ -148,7 +148,7 @@ export class Button extends Image {
148
148
  */
149
149
  public setStateFrame(state: string, frame: string | null, switchImmediately = false): void {
150
150
  const frameKey: `_on${string}Frame` = `_on${state}Frame`;
151
- if (frame) {
151
+ if (frame !== null) {
152
152
  this[frameKey] = frame;
153
153
  if (switchImmediately) {
154
154
  this.changeStateFrame(state);
@@ -167,7 +167,7 @@ export class Button extends Image {
167
167
  if (this.freezeFrames) {
168
168
  return false;
169
169
  }
170
- const state = this.input.enabled || !this._onDisabledFrame ? newState : STATE_DISABLED;
170
+ const state = this.input.enabled || this._onDisabledFrame === null ? newState : STATE_DISABLED;
171
171
  const frameKey: `_on${string}Frame` = `_on${state}Frame`;
172
172
  const frame = this[frameKey];
173
173
  if (typeof frame === 'string') {
@@ -199,7 +199,7 @@ export class Button extends Image {
199
199
  this.setStateFrame(STATE_OUT, outFrame, !this.input.pointerOver());
200
200
  this.setStateFrame(STATE_DOWN, downFrame, this.input.pointerDown());
201
201
  this.setStateFrame(STATE_UP, upFrame, this.input.pointerUp());
202
- if (disabledFrame) {
202
+ if (disabledFrame !== null) {
203
203
  this.setStateFrame(STATE_DISABLED, disabledFrame, !this.input.enabled);
204
204
  }
205
205
  }
@@ -218,7 +218,7 @@ export class Button extends Image {
218
218
  if (this.onOverMouseOnly && !pointer.isMouse) {
219
219
  return;
220
220
  }
221
- if (this.onInputOver) {
221
+ if (this.onInputOver !== null) {
222
222
  this.onInputOver.dispatch(this, pointer);
223
223
  }
224
224
  }
@@ -230,7 +230,7 @@ export class Button extends Image {
230
230
  */
231
231
  public onInputOutHandler(_sprite: Image, pointer: Pointer): void {
232
232
  this.changeStateFrame(STATE_OUT);
233
- if (this.onInputOut) {
233
+ if (this.onInputOut !== null) {
234
234
  this.onInputOut.dispatch(this, pointer);
235
235
  }
236
236
  }
@@ -242,7 +242,7 @@ export class Button extends Image {
242
242
  */
243
243
  public onInputDownHandler(_sprite: Image, pointer: Pointer): void {
244
244
  this.changeStateFrame(STATE_DOWN);
245
- if (this.onInputDown) {
245
+ if (this.onInputDown !== null) {
246
246
  this.onInputDown.dispatch(this, pointer);
247
247
  }
248
248
  }
@@ -254,7 +254,7 @@ export class Button extends Image {
254
254
  * @param {boolean} isOver - Whether the pointer is currently over the button (default: true).
255
255
  */
256
256
  public onInputUpHandler(_sprite: Image, pointer: Pointer, isOver: boolean): void {
257
- if (this.onInputUp) {
257
+ if (this.onInputUp !== null) {
258
258
  this.onInputUp.dispatch(this, pointer, isOver);
259
259
  }
260
260
  if (this.freezeFrames) {
@@ -281,7 +281,7 @@ export class Button extends Image {
281
281
  * @returns {boolean} True if input is enabled, false otherwise.
282
282
  */
283
283
  public get inputEnabled(): boolean {
284
- return this.input && this.input.enabled;
284
+ return this.input !== null && this.input.enabled;
285
285
  }
286
286
 
287
287
  /**
@@ -293,10 +293,10 @@ export class Button extends Image {
293
293
  if (this.input === null) {
294
294
  this.input = new InputHandler(this);
295
295
  this.input.start();
296
- } else if (this.input && !this.input.enabled) {
296
+ } else if (this.input !== null && !this.input.enabled) {
297
297
  this.input.start();
298
298
  }
299
- } else if (this.input && this.input.enabled) {
299
+ } else if (this.input !== null && this.input.enabled) {
300
300
  this.input.stop();
301
301
  }
302
302
  }
@@ -71,7 +71,7 @@ export const renderGraphics = (graphics: Graphics, context: CanvasRenderingConte
71
71
  context.stroke();
72
72
  }
73
73
  } else if (shape instanceof Rectangle) {
74
- if (data.fillColor || data.fillColor === 0) {
74
+ if (data.fillColor !== null) {
75
75
  context.globalAlpha = data.fillAlpha * worldAlpha;
76
76
  context.fillStyle = `#${`00000${Math.trunc(fillColor ?? 0).toString(16)}`.slice(-6)}`;
77
77
  context.fillRect(shape.x, shape.y, shape.width, shape.height);
@@ -144,7 +144,7 @@ export const renderGraphics = (graphics: Graphics, context: CanvasRenderingConte
144
144
  context.lineTo(rx + radius, ry);
145
145
  context.quadraticCurveTo(rx, ry, rx, ry + radius);
146
146
  context.closePath();
147
- if (data.fillColor || data.fillColor === 0) {
147
+ if (data.fillColor !== null) {
148
148
  context.globalAlpha = data.fillAlpha * worldAlpha;
149
149
  context.fillStyle = `#${`00000${Math.trunc(fillColor ?? 0).toString(16)}`.slice(-6)}`;
150
150
  context.fill();
@@ -16,7 +16,7 @@ export const getPool = (): CanvasPoolEntry[] => {
16
16
  export const getFirst = (): number => {
17
17
  const pool = getPool();
18
18
  for (let i = 0; i < pool.length; i += 1) {
19
- if (!pool[i]!.parent) {
19
+ if (pool[i]!.parent === null) {
20
20
  return i;
21
21
  }
22
22
  }
@@ -61,7 +61,7 @@ export const getTotal = (): number => {
61
61
  const pool = getPool();
62
62
  let c = 0;
63
63
  for (const entry of pool) {
64
- if (entry.parent) {
64
+ if (entry.parent !== null) {
65
65
  c += 1;
66
66
  }
67
67
  }
@@ -76,7 +76,7 @@ export const getFree = (): number => {
76
76
  const pool = getPool();
77
77
  let c = 0;
78
78
  for (const entry of pool) {
79
- if (!entry.parent) {
79
+ if (entry.parent === null) {
80
80
  c += 1;
81
81
  }
82
82
  }
@@ -28,6 +28,7 @@ import { detectCapabilities } from './tinter.js';
28
28
  import { getSmoothingPrefix, setSmoothing } from './util.js';
29
29
  import type { DisplayObject } from '../display_object.js';
30
30
  import type { RenderSession } from '../render_session.js';
31
+ import type { StageBackgroundColor } from '../../core/stage.js';
31
32
 
32
33
  export class CanvasRenderer {
33
34
  public type!: number;
@@ -64,7 +65,7 @@ export class CanvasRenderer {
64
65
  willReadFrequently: false,
65
66
  alpha: this.transparent,
66
67
  })!;
67
- if (!this.context) {
68
+ if (!(this.context as CanvasRenderingContext2D | undefined)) {
68
69
  throw new Error(ENGINE_ERROR_CREATING_CANVAS_2D_CONTEXT);
69
70
  }
70
71
  this.refresh = true;
@@ -86,7 +87,7 @@ export class CanvasRenderer {
86
87
  * @param {Stage} root - The root stage to render.
87
88
  */
88
89
  public render(root: Stage): void {
89
- if (!this.context) {
90
+ if (!(this.context as CanvasRenderingContext2D | undefined)) {
90
91
  return;
91
92
  }
92
93
  this.context.setTransform(1, 0, 0, 1, 0, 0);
@@ -98,7 +99,7 @@ export class CanvasRenderer {
98
99
  if (this.clearBeforeRender) {
99
100
  if (this.transparent) {
100
101
  this.context.clearRect(0, 0, this.width, this.height);
101
- } else if (root._bgColor) {
102
+ } else if (root._bgColor as StageBackgroundColor | undefined) {
102
103
  this.context.fillStyle = root._bgColor.rgba;
103
104
  this.context.fillRect(0, 0, this.width, this.height);
104
105
  }
@@ -130,7 +131,7 @@ export class CanvasRenderer {
130
131
  this.view.style.width = `${this.width / this.resolution}px`;
131
132
  this.view.style.height = `${this.height / this.resolution}px`;
132
133
  }
133
- if (this.renderSession.smoothProperty) {
134
+ if (this.renderSession.smoothProperty !== null) {
134
135
  setSmoothing(this.context, this.renderSession.smoothProperty, this.renderSession.scaleMode === SCALE_LINEAR);
135
136
  }
136
137
  }
@@ -151,7 +152,7 @@ export class CanvasRenderer {
151
152
  * Maps blend modes to canvas rendering operations.
152
153
  */
153
154
  public mapBlendModes(): void {
154
- if (globalThis.PhaserRegistry.blendModesCanvas) {
155
+ if (globalThis.PhaserRegistry.blendModesCanvas as GlobalCompositeOperation[] | undefined) {
155
156
  return;
156
157
  }
157
158
  const b: GlobalCompositeOperation[] = [];
@@ -179,7 +179,7 @@ export const canUseNewCanvasBlendModes = (): boolean => {
179
179
  context.globalCompositeOperation = 'multiply';
180
180
  context.drawImage(magenta, 0, 0);
181
181
  context.drawImage(yellow, 2, 0);
182
- if (!context.getImageData(2, 0, 1, 1)) {
182
+ if (context.getImageData(2, 0, 1, 1) === null) {
183
183
  return false;
184
184
  }
185
185
  const { data } = context.getImageData(2, 0, 1, 1);
@@ -141,7 +141,7 @@ export const getSmoothingPrefix = (context: CanvasRenderingContext2D): string |
141
141
  const smoothingFlags = context as unknown as Record<string, boolean | undefined>;
142
142
  for (const vendor of VENDORS) {
143
143
  const flag = `${vendor}mageSmoothingEnabled`;
144
- if (smoothingFlags[flag]) {
144
+ if (smoothingFlags[flag] !== undefined) {
145
145
  return flag;
146
146
  }
147
147
  }
@@ -166,7 +166,7 @@ export const setSmoothing = (context: CanvasRenderingContext2D, property: string
166
166
  */
167
167
  export const setSmoothingEnabled = (context: CanvasRenderingContext2D, value: boolean): CanvasRenderingContext2D => {
168
168
  const s = getSmoothingPrefix(context);
169
- if (s) {
169
+ if (s !== null) {
170
170
  setSmoothing(context, s, value);
171
171
  }
172
172
  return context;
@@ -10,6 +10,7 @@ import type { UserData } from '../core/callback.js';
10
10
  import type { EventManager } from '../core/event_manager.js';
11
11
  import type { Image } from './image.js';
12
12
  import type { RenderSession } from './render_session.js';
13
+ import type { IdentifiedWebGLRenderingContext } from './webgl/util.js';
13
14
 
14
15
  export class DisplayObject {
15
16
  /** @type {boolean} */
@@ -127,7 +128,7 @@ export class DisplayObject {
127
128
  * @param {boolean} _destroyTexture - Whether the subclass should destroy its texture too.
128
129
  */
129
130
  public destroy(_destroyChildren = true, _destroyTexture = false): void {
130
- if (this.children) {
131
+ if (this.children as DisplayObject[] | undefined) {
131
132
  let i = this.children.length;
132
133
  while (i) {
133
134
  i -= 1;
@@ -284,12 +285,12 @@ export class DisplayObject {
284
285
  * @returns {DisplayObject[]} The array of removed child display objects.
285
286
  * @throws {Error} If the range is invalid.
286
287
  */
287
- public removeChildren(beginIndex: number, endIndex: number): DisplayObject[] {
288
- beginIndex ??= 0;
289
- endIndex ??= this.children.length;
290
- const range = endIndex - beginIndex;
291
- if (range > 0 && range <= endIndex) {
292
- const removed = this.children.splice(beginIndex, range);
288
+ public removeChildren(beginIndex?: number, endIndex?: number): DisplayObject[] {
289
+ const begin = beginIndex ?? 0;
290
+ const end = endIndex ?? this.children.length;
291
+ const range = end - begin;
292
+ if (range > 0 && range <= end) {
293
+ const removed = this.children.splice(begin, range);
293
294
  for (const child of removed) {
294
295
  child.parent = null;
295
296
  }
@@ -310,7 +311,7 @@ export class DisplayObject {
310
311
  if (!parent && !this.parent) {
311
312
  return this;
312
313
  }
313
- if (!this.game || !this.visible) {
314
+ if (!(this.game as Game | undefined) || !this.visible) {
314
315
  return this;
315
316
  }
316
317
  const p = parent ?? this.parent ?? this.game.world;
@@ -607,12 +608,10 @@ export class DisplayObject {
607
608
  * @param {DisplayObject} from - The display object to convert from (defaults to this).
608
609
  * @returns {Point} The converted local position.
609
610
  */
610
- public toLocal(position: Point, from: DisplayObject): Point {
611
- if (from) {
612
- position = from.toGlobal(position);
613
- }
611
+ public toLocal(position: Point, from: DisplayObject | null): Point {
612
+ const global = from ? from.toGlobal(position) : position;
614
613
  this.updateTransform();
615
- return this.worldTransform.applyInverse(position);
614
+ return this.worldTransform.applyInverse(global);
616
615
  }
617
616
 
618
617
  /**
@@ -624,7 +623,7 @@ export class DisplayObject {
624
623
  return;
625
624
  }
626
625
  this._cachedSprite.worldAlpha = this.worldAlpha;
627
- if (renderSession.gl) {
626
+ if (renderSession.gl as IdentifiedWebGLRenderingContext | undefined) {
628
627
  renderWebGL(this._cachedSprite, renderSession);
629
628
  } else {
630
629
  renderCanvas(this._cachedSprite, renderSession);
@@ -135,13 +135,13 @@ describe('Graphics', (): void => {
135
135
  describe('drawTriangles', (): void => {
136
136
  it('reads a flat coordinate list as triangles', (): void => {
137
137
  const graphics = createGraphics();
138
- graphics.drawTriangles([0, 0, 10, 0, 0, 10, 20, 20, 30, 20, 20, 30], null as unknown as number[]);
138
+ graphics.drawTriangles([0, 0, 10, 0, 0, 10, 20, 20, 30, 20, 20, 30], null);
139
139
  expect(graphics.graphicsData).toHaveLength(2);
140
140
  });
141
141
 
142
142
  it('reads a point list as triangles', (): void => {
143
143
  const graphics = createGraphics();
144
- graphics.drawTriangles([new Point(0, 0), new Point(10, 0), new Point(0, 10)], null as unknown as number[]);
144
+ graphics.drawTriangles([new Point(0, 0), new Point(10, 0), new Point(0, 10)], null);
145
145
  expect(graphics.graphicsData).toHaveLength(1);
146
146
  });
147
147
 
@@ -343,19 +343,17 @@ export class Graphics extends DisplayObject {
343
343
  if (startAngle === endAngle) {
344
344
  return this;
345
345
  }
346
- if (!anticlockwise && endAngle <= startAngle) {
347
- endAngle += Math.PI * 2;
348
- } else if (anticlockwise && startAngle <= endAngle) {
349
- startAngle += Math.PI * 2;
350
- }
351
- const sweep = anticlockwise ? (startAngle - endAngle) * -1 : endAngle - startAngle;
346
+ const fullTurn = Math.PI * 2;
347
+ const from = anticlockwise && startAngle <= endAngle ? startAngle + fullTurn : startAngle;
348
+ const to = !anticlockwise && endAngle <= startAngle ? endAngle + fullTurn : endAngle;
349
+ const sweep = anticlockwise ? (from - to) * -1 : to - from;
352
350
  const segs = Math.ceil(Math.abs(sweep) / (Math.PI * 2)) * segments;
353
351
  // Sweep check - moved here because we don't want to do the moveTo below if the arc fails
354
352
  if (sweep === 0) {
355
353
  return this;
356
354
  }
357
- const startX = cx + Math.cos(startAngle) * radius;
358
- const startY = cy + Math.sin(startAngle) * radius;
355
+ const startX = cx + Math.cos(from) * radius;
356
+ const startY = cy + Math.sin(from) * radius;
359
357
  if (anticlockwise && this.filling) {
360
358
  this.moveTo(cx, cy);
361
359
  } else {
@@ -371,7 +369,7 @@ export class Graphics extends DisplayObject {
371
369
  const remainder = (segMinus % 1) / segMinus;
372
370
  for (let i = 0; i <= segMinus; i += 1) {
373
371
  const real = i + remainder * i;
374
- const angle = theta + startAngle + theta2 * real;
372
+ const angle = theta + from + theta2 * real;
375
373
  const c = Math.cos(angle);
376
374
  const s = -Math.sin(angle);
377
375
  points.push((cTheta * c + sTheta * s) * radius + cx, (cTheta * -s + sTheta * c) * radius + cy);
@@ -915,10 +913,10 @@ export class Graphics extends DisplayObject {
915
913
  * @param {number[]} indices - The indices of the vertices to use.
916
914
  * @param {boolean} cull - Whether to perform backface culling.
917
915
  */
918
- public drawTriangles(vertices: Point[] | number[], indices: number[], cull = false): void {
916
+ public drawTriangles(vertices: Point[] | number[], indices: number[] | null, cull = false): void {
919
917
  let points: Point[] = [];
920
918
  let i;
921
- if (!indices) {
919
+ if (indices === null) {
922
920
  if (vertices[0] instanceof Point) {
923
921
  const corners = vertices as Point[];
924
922
  for (i = 0; i < corners.length / 3; i += 1) {
@@ -3,6 +3,7 @@ import { Signal } from '../core/signal.js';
3
3
  import { DisplayObject } from './display_object.js';
4
4
  import { Image } from './image.js';
5
5
  import type { Game } from '../core/game.js';
6
+ import type { EventManager } from '../core/event_manager.js';
6
7
 
7
8
  export const SORT_ASCENDING = -1;
8
9
  export const SORT_DESCENDING = 1;
@@ -33,7 +34,7 @@ export class Group extends DisplayObject {
33
34
  super(game);
34
35
  /** @type {number} */
35
36
  this.type = GROUP;
36
- parent ??= game.world;
37
+ const target = parent ?? game.world;
37
38
  /** @type {string} */
38
39
  this.name = name ?? 'group';
39
40
  /** @type {number} */
@@ -41,9 +42,9 @@ export class Group extends DisplayObject {
41
42
  if (addToStage) {
42
43
  this.game.stage.addChild(this);
43
44
  this.z = this.game.stage.children.length;
44
- } else if (parent) {
45
- parent.addChild(this);
46
- this.z = parent.children.length;
45
+ } else if (target as DisplayObject | undefined) {
46
+ target.addChild(this);
47
+ this.z = target.children.length;
47
48
  }
48
49
  /** @type {boolean} */
49
50
  this.ignoreDestroy = false;
@@ -112,10 +113,10 @@ export class Group extends DisplayObject {
112
113
  this.updateZ();
113
114
  }
114
115
  const inputChild = child as T & { input?: unknown; inputEnabled?: boolean };
115
- if (this.inputEnableChildren && (!inputChild.input || inputChild.inputEnabled)) {
116
+ if (this.inputEnableChildren && (inputChild.input === undefined || inputChild.inputEnabled === true)) {
116
117
  inputChild.inputEnabled = true;
117
118
  }
118
- if (!silent && child.events) {
119
+ if (!silent && (child.events as EventManager | undefined)) {
119
120
  child.events.onAddedToGroup$dispatch(child, this);
120
121
  }
121
122
  this.cursor ??= child;
@@ -252,7 +253,7 @@ export class Group extends DisplayObject {
252
253
  this.destroy();
253
254
  return;
254
255
  }
255
- if (!this.exists || !this.parent?.exists) {
256
+ if (!this.exists || this.parent?.exists !== true) {
256
257
  this.renderOrderID = -1;
257
258
  return;
258
259
  }
@@ -292,7 +293,7 @@ export class Group extends DisplayObject {
292
293
  if (this.children.length === 0 || !this.children.includes(child)) {
293
294
  return false;
294
295
  }
295
- if (!silent && child.events) {
296
+ if (!silent && (child.events as EventManager | undefined)) {
296
297
  child.events.onRemovedFromGroup$dispatch(child, this);
297
298
  }
298
299
  const removed = this.removeChild(child);
@@ -318,7 +319,7 @@ export class Group extends DisplayObject {
318
319
  }
319
320
  do {
320
321
  const first = this.children[0]!;
321
- if (!silent && first.events) {
322
+ if (!silent && (first.events as EventManager | undefined)) {
322
323
  first.events.onRemovedFromGroup$dispatch(first, this);
323
324
  }
324
325
  const removed = this.removeChild(first);
@@ -11,6 +11,7 @@ import { Frame } from '../core/frame.js';
11
11
  import type { Matrix } from '../geom/matrix.js';
12
12
  import type { RenderSession } from './render_session.js';
13
13
  import type { AbstractFilter } from './webgl/abstract_filter.js';
14
+ import type { ImageCacheEntry } from '../core/cache.js';
14
15
 
15
16
  export class Image extends DisplayObject {
16
17
  public key!: string | number | Texture | null;
@@ -99,11 +100,11 @@ export class Image extends DisplayObject {
99
100
  this.tintedTexture = null;
100
101
  this.shader = null;
101
102
  this._frame = null;
102
- if (this.events) {
103
+ if (this.events as EventManager | undefined) {
103
104
  this.events.destroy();
104
105
  }
105
106
  this.events = null!;
106
- if (this.animations) {
107
+ if (this.animations as AnimationManager | undefined) {
107
108
  this.animations.destroy();
108
109
  }
109
110
  this.animations = null!;
@@ -118,7 +119,7 @@ export class Image extends DisplayObject {
118
119
  this.destroy();
119
120
  return;
120
121
  }
121
- if (!this.exists || !this.parent?.exists) {
122
+ if (!this.exists || this.parent?.exists !== true) {
122
123
  this.renderOrderID = -1;
123
124
  return;
124
125
  }
@@ -126,7 +127,7 @@ export class Image extends DisplayObject {
126
127
  this.game.stage.currentRenderOrderID += 1;
127
128
  this.renderOrderID = this.game.stage.currentRenderOrderID;
128
129
  }
129
- if (this.animations) {
130
+ if (this.animations as AnimationManager | undefined) {
130
131
  this.animations.update();
131
132
  }
132
133
  for (const child of this.children) {
@@ -162,7 +163,7 @@ export class Image extends DisplayObject {
162
163
  this.setTexture(textureKey);
163
164
  } else {
164
165
  const img = cache.getImage(textureKey ?? undefined, true);
165
- if (img) {
166
+ if (img as ImageCacheEntry | undefined) {
166
167
  this.key = img.key;
167
168
  this.setTexture(new Texture(img.base));
168
169
  this.texture.baseTexture.skipRender = textureKey === '__default';
@@ -283,7 +284,7 @@ export class Image extends DisplayObject {
283
284
  * @param {boolean} copy - Whether to copy the rect or use it directly.
284
285
  */
285
286
  public crop(rect: Rectangle, copy = false): void {
286
- if (rect) {
287
+ if (rect as Rectangle | undefined) {
287
288
  if (copy && this.cropRect !== null) {
288
289
  this.cropRect.setTo(rect.x, rect.y, rect.width, rect.height);
289
290
  } else if (copy && this.cropRect === null) {
@@ -222,7 +222,7 @@ export const renderCanvas = (
222
222
  renderSession.context.globalAlpha = target.worldAlpha;
223
223
 
224
224
  // If smoothingEnabled is supported and we need to change the smoothing property for this texture
225
- if (renderSession.smoothProperty && renderSession.scaleMode !== target.texture.baseTexture.scaleMode) {
225
+ if (renderSession.smoothProperty !== null && renderSession.scaleMode !== target.texture.baseTexture.scaleMode) {
226
226
  renderSession.scaleMode = target.texture.baseTexture.scaleMode;
227
227
  setSmoothing(renderSession.context, renderSession.smoothProperty, renderSession.scaleMode === SCALE_LINEAR);
228
228
  }