pixi.js 7.2.2 → 7.2.3

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/pixi.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * pixi.js - v7.2.2
3
- * Compiled Tue, 21 Mar 2023 12:27:22 UTC
2
+ * pixi.js - v7.2.3
3
+ * Compiled Fri, 24 Mar 2023 19:53:04 UTC
4
4
  *
5
5
  * pixi.js is licensed under the MIT License.
6
6
  * http://www.opensource.org/licenses/mit-license
@@ -3477,16 +3477,14 @@ Deprecated since v${version}`);
3477
3477
  return this.toHex() + "00".substring(0, 2 - alphaString.length) + alphaString;
3478
3478
  }
3479
3479
  setAlpha(alpha) {
3480
- this._components[3] = alpha;
3480
+ this._components[3] = this._clamp(alpha);
3481
3481
  return this;
3482
3482
  }
3483
- round(step) {
3483
+ round(steps) {
3484
3484
  const [r, g, b] = this._components;
3485
- this._components.set([
3486
- Math.min(255, r / step * step),
3487
- Math.min(255, g / step * step),
3488
- Math.min(255, b / step * step)
3489
- ]);
3485
+ this._components[0] = Math.round(r * steps) / steps;
3486
+ this._components[1] = Math.round(g * steps) / steps;
3487
+ this._components[2] = Math.round(b * steps) / steps;
3490
3488
  this.refreshInt();
3491
3489
  this._value = null;
3492
3490
  return this;
@@ -3510,10 +3508,12 @@ Deprecated since v${version}`);
3510
3508
  (int & 255) / 255,
3511
3509
  1
3512
3510
  ];
3513
- } else if ((Array.isArray(value) || value instanceof Float32Array) && value.length >= 3 && value.length <= 4 && value.every((v) => v <= 1 && v >= 0)) {
3511
+ } else if ((Array.isArray(value) || value instanceof Float32Array) && value.length >= 3 && value.length <= 4) {
3512
+ value = this._clamp(value);
3514
3513
  const [r, g, b, a = 1] = value;
3515
3514
  components = [r, g, b, a];
3516
3515
  } else if ((value instanceof Uint8Array || value instanceof Uint8ClampedArray) && value.length >= 3 && value.length <= 4) {
3516
+ value = this._clamp(value, 0, 255);
3517
3517
  const [r, g, b, a = 255] = value;
3518
3518
  components = [r / 255, g / 255, b / 255, a / 255];
3519
3519
  } else if (typeof value === "string" || typeof value === "object") {
@@ -3537,10 +3537,19 @@ Deprecated since v${version}`);
3537
3537
  }
3538
3538
  }
3539
3539
  refreshInt() {
3540
- this._components.forEach((value, i) => this._components[i] = Math.min(Math.max(value, 0), 1));
3540
+ this._clamp(this._components);
3541
3541
  const [r, g, b] = this._components;
3542
3542
  this._int = (r * 255 << 16) + (g * 255 << 8) + (b * 255 | 0);
3543
3543
  }
3544
+ _clamp(value, min = 0, max = 1) {
3545
+ if (typeof value === "number") {
3546
+ return Math.min(Math.max(value, min), max);
3547
+ }
3548
+ value.forEach((v, i) => {
3549
+ value[i] = Math.min(Math.max(v, min), max);
3550
+ });
3551
+ return value;
3552
+ }
3544
3553
  };
3545
3554
  let Color = _Color;
3546
3555
  Color.shared = new _Color();
@@ -10391,7 +10400,7 @@ ${this.fragmentSrc}`;
10391
10400
  const { renderer } = this;
10392
10401
  renderer.runners.init.emit(renderer.options);
10393
10402
  if (options.hello) {
10394
- console.log(`PixiJS ${"7.2.2"} - ${renderer.rendererLogId} - https://pixijs.com`);
10403
+ console.log(`PixiJS ${"7.2.3"} - ${renderer.rendererLogId} - https://pixijs.com`);
10395
10404
  }
10396
10405
  renderer.resize(renderer.screen.width, renderer.screen.height);
10397
10406
  }
@@ -12577,7 +12586,7 @@ ${this.fragmentSrc}`;
12577
12586
  }
12578
12587
  }
12579
12588
 
12580
- const VERSION = "7.2.2";
12589
+ const VERSION = "7.2.3";
12581
12590
 
12582
12591
  class Bounds {
12583
12592
  constructor() {
@@ -15169,7 +15178,7 @@ ${this.fragmentSrc}`;
15169
15178
  this.eventPool = /* @__PURE__ */ new Map();
15170
15179
  this._allInteractiveElements = [];
15171
15180
  this._hitElements = [];
15172
- this._collectInteractiveElements = false;
15181
+ this._isPointerMoveEvent = false;
15173
15182
  this.rootTarget = rootTarget;
15174
15183
  this.hitPruneFn = this.hitPruneFn.bind(this);
15175
15184
  this.hitTestFn = this.hitTestFn.bind(this);
@@ -15221,7 +15230,9 @@ ${this.fragmentSrc}`;
15221
15230
  }
15222
15231
  hitTest(x, y) {
15223
15232
  EventsTicker.pauseUpdate = true;
15224
- const invertedPath = this.hitTestRecursive(this.rootTarget, this.rootTarget.eventMode, tempHitLocation.set(x, y), this.hitTestFn, this.hitPruneFn);
15233
+ const useMove = this._isPointerMoveEvent && this.enableGlobalMoveEvents;
15234
+ const fn = useMove ? "hitTestMoveRecursive" : "hitTestRecursive";
15235
+ const invertedPath = this[fn](this.rootTarget, this.rootTarget.eventMode, tempHitLocation.set(x, y), this.hitTestFn, this.hitPruneFn);
15225
15236
  return invertedPath && invertedPath[0];
15226
15237
  }
15227
15238
  propagate(e, type) {
@@ -15273,10 +15284,9 @@ ${this.fragmentSrc}`;
15273
15284
  propagationPath.reverse();
15274
15285
  return propagationPath;
15275
15286
  }
15276
- hitTestRecursive(currentTarget, eventMode, location, testFn, pruneFn) {
15277
- if (pruneFn(currentTarget, location)) {
15287
+ hitTestMoveRecursive(currentTarget, eventMode, location, testFn, pruneFn, ignore = false) {
15288
+ if (this._interactivePrune(currentTarget))
15278
15289
  return null;
15279
- }
15280
15290
  if (currentTarget.eventMode === "dynamic" || eventMode === "dynamic") {
15281
15291
  EventsTicker.pauseUpdate = false;
15282
15292
  }
@@ -15284,34 +15294,58 @@ ${this.fragmentSrc}`;
15284
15294
  const children = currentTarget.children;
15285
15295
  for (let i = children.length - 1; i >= 0; i--) {
15286
15296
  const child = children[i];
15287
- const nestedHit = this.hitTestRecursive(child, this._isInteractive(eventMode) ? eventMode : child.eventMode, location, testFn, pruneFn);
15297
+ const nestedHit = this.hitTestMoveRecursive(child, this._isInteractive(eventMode) ? eventMode : child.eventMode, location, testFn, pruneFn, pruneFn(currentTarget, location));
15288
15298
  if (nestedHit) {
15289
15299
  if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) {
15290
15300
  continue;
15291
15301
  }
15292
15302
  const isInteractive = currentTarget.isInteractive();
15293
15303
  if (nestedHit.length > 0 || isInteractive) {
15294
- if (this._collectInteractiveElements && isInteractive) {
15304
+ if (isInteractive)
15295
15305
  this._allInteractiveElements.push(currentTarget);
15296
- }
15297
15306
  nestedHit.push(currentTarget);
15298
15307
  }
15299
- if (this._collectInteractiveElements && this._hitElements.length === 0) {
15308
+ if (this._hitElements.length === 0)
15300
15309
  this._hitElements = nestedHit;
15301
- }
15302
- if (!this._collectInteractiveElements)
15303
- return nestedHit;
15304
15310
  }
15305
15311
  }
15306
15312
  }
15307
15313
  const isInteractiveMode = this._isInteractive(eventMode);
15308
15314
  const isInteractiveTarget = currentTarget.isInteractive();
15309
- if (this._collectInteractiveElements) {
15310
- if (isInteractiveMode && isInteractiveTarget)
15311
- this._allInteractiveElements.push(currentTarget);
15312
- if (this._hitElements.length > 0)
15313
- return null;
15315
+ if (isInteractiveTarget && isInteractiveTarget)
15316
+ this._allInteractiveElements.push(currentTarget);
15317
+ if (ignore || this._hitElements.length > 0)
15318
+ return null;
15319
+ if (isInteractiveMode && (!pruneFn(currentTarget, location) && testFn(currentTarget, location))) {
15320
+ return isInteractiveTarget ? [currentTarget] : [];
15321
+ }
15322
+ return null;
15323
+ }
15324
+ hitTestRecursive(currentTarget, eventMode, location, testFn, pruneFn) {
15325
+ if (this._interactivePrune(currentTarget) || pruneFn(currentTarget, location)) {
15326
+ return null;
15327
+ }
15328
+ if (currentTarget.eventMode === "dynamic" || eventMode === "dynamic") {
15329
+ EventsTicker.pauseUpdate = false;
15330
+ }
15331
+ if (currentTarget.interactiveChildren && currentTarget.children) {
15332
+ const children = currentTarget.children;
15333
+ for (let i = children.length - 1; i >= 0; i--) {
15334
+ const child = children[i];
15335
+ const nestedHit = this.hitTestRecursive(child, this._isInteractive(eventMode) ? eventMode : child.eventMode, location, testFn, pruneFn);
15336
+ if (nestedHit) {
15337
+ if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) {
15338
+ continue;
15339
+ }
15340
+ const isInteractive = currentTarget.isInteractive();
15341
+ if (nestedHit.length > 0 || isInteractive)
15342
+ nestedHit.push(currentTarget);
15343
+ return nestedHit;
15344
+ }
15345
+ }
15314
15346
  }
15347
+ const isInteractiveMode = this._isInteractive(eventMode);
15348
+ const isInteractiveTarget = currentTarget.isInteractive();
15315
15349
  if (isInteractiveMode && testFn(currentTarget, location)) {
15316
15350
  return isInteractiveTarget ? [currentTarget] : [];
15317
15351
  }
@@ -15320,7 +15354,7 @@ ${this.fragmentSrc}`;
15320
15354
  _isInteractive(int) {
15321
15355
  return int === "static" || int === "dynamic";
15322
15356
  }
15323
- hitPruneFn(displayObject, location) {
15357
+ _interactivePrune(displayObject) {
15324
15358
  if (!displayObject || displayObject.isMask || !displayObject.visible || !displayObject.renderable) {
15325
15359
  return true;
15326
15360
  }
@@ -15333,8 +15367,9 @@ ${this.fragmentSrc}`;
15333
15367
  if (displayObject.isMask) {
15334
15368
  return true;
15335
15369
  }
15336
- if (this._collectInteractiveElements)
15337
- return false;
15370
+ return false;
15371
+ }
15372
+ hitPruneFn(displayObject, location) {
15338
15373
  if (displayObject.hitArea) {
15339
15374
  displayObject.worldTransform.applyInverse(location, tempLocalMapping);
15340
15375
  if (!displayObject.hitArea.contains(tempLocalMapping.x, tempLocalMapping.y)) {
@@ -15395,9 +15430,9 @@ ${this.fragmentSrc}`;
15395
15430
  }
15396
15431
  this._allInteractiveElements.length = 0;
15397
15432
  this._hitElements.length = 0;
15398
- this._collectInteractiveElements = true;
15433
+ this._isPointerMoveEvent = true;
15399
15434
  const e = this.createPointerEvent(from);
15400
- this._collectInteractiveElements = false;
15435
+ this._isPointerMoveEvent = false;
15401
15436
  const isMouse = e.pointerType === "mouse" || e.pointerType === "pen";
15402
15437
  const trackingData = this.trackingData(from.pointerId);
15403
15438
  const outTarget = this.findMountedTarget(trackingData.overTargets);
@@ -20439,7 +20474,7 @@ ${e}`);
20439
20474
  const uniforms = shader.uniforms;
20440
20475
  const drawCalls = geometry.drawCalls;
20441
20476
  uniforms.translationMatrix = this.transform.worldTransform;
20442
- Color.shared.setValue(this._tintColor).multiply([worldAlpha, worldAlpha, worldAlpha]).setAlpha(worldAlpha).toArray(uniforms.tint);
20477
+ Color.shared.setValue(this._tintColor).premultiply(worldAlpha).toArray(uniforms.tint);
20443
20478
  renderer.shader.bind(shader);
20444
20479
  renderer.geometry.bind(geometry, shader);
20445
20480
  renderer.state.set(this.state);