pixi.js 7.2.1 → 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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * pixi.js - v7.2.1
3
- * Compiled Fri, 17 Mar 2023 16:54:13 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
@@ -3348,19 +3348,51 @@ const _Color = class {
3348
3348
  }
3349
3349
  set value(value) {
3350
3350
  if (value instanceof _Color) {
3351
- this._value = value._value;
3351
+ this._value = this.cloneSource(value._value);
3352
3352
  this._int = value._int;
3353
3353
  this._components.set(value._components);
3354
3354
  } else if (value === null) {
3355
3355
  throw new Error("Cannot set PIXI.Color#value to null");
3356
- } else if (this._value !== value) {
3356
+ } else if (this._value === null || !this.isSourceEqual(this._value, value)) {
3357
3357
  this.normalize(value);
3358
- this._value = value;
3358
+ this._value = this.cloneSource(value);
3359
3359
  }
3360
3360
  }
3361
3361
  get value() {
3362
3362
  return this._value;
3363
3363
  }
3364
+ cloneSource(value) {
3365
+ if (typeof value === "string" || typeof value === "number" || value instanceof Number || value === null) {
3366
+ return value;
3367
+ } else if (Array.isArray(value) || ArrayBuffer.isView(value)) {
3368
+ return value.slice(0);
3369
+ } else if (typeof value === "object" && value !== null) {
3370
+ return { ...value };
3371
+ }
3372
+ return value;
3373
+ }
3374
+ isSourceEqual(value1, value2) {
3375
+ const type1 = typeof value1;
3376
+ const type2 = typeof value2;
3377
+ if (type1 !== type2) {
3378
+ return false;
3379
+ } else if (type1 === "number" || type1 === "string" || value1 instanceof Number) {
3380
+ return value1 === value2;
3381
+ } else if (Array.isArray(value1) && Array.isArray(value2) || ArrayBuffer.isView(value1) && ArrayBuffer.isView(value2)) {
3382
+ if (value1.length !== value2.length) {
3383
+ return false;
3384
+ }
3385
+ return value1.every((v, i) => v === value2[i]);
3386
+ } else if (value1 !== null && value2 !== null) {
3387
+ const keys1 = Object.keys(value1);
3388
+ const keys2 = Object.keys(value2);
3389
+ if (keys1.length !== keys2.length) {
3390
+ return false;
3391
+ }
3392
+ return keys1.every((key) => value1[key] === value2[key]);
3393
+ }
3394
+ return value1 === value2;
3395
+ }
3364
3396
  toRgba() {
3365
3397
  const [r, g, b, a] = this._components;
3366
3398
  return { r, g, b, a };
@@ -3442,16 +3474,14 @@ const _Color = class {
3442
3474
  return this.toHex() + "00".substring(0, 2 - alphaString.length) + alphaString;
3443
3475
  }
3444
3476
  setAlpha(alpha) {
3445
- this._components[3] = alpha;
3477
+ this._components[3] = this._clamp(alpha);
3446
3478
  return this;
3447
3479
  }
3448
- round(step) {
3480
+ round(steps) {
3449
3481
  const [r, g, b] = this._components;
3450
- this._components.set([
3451
- Math.min(255, r / step * step),
3452
- Math.min(255, g / step * step),
3453
- Math.min(255, b / step * step)
3454
- ]);
3482
+ this._components[0] = Math.round(r * steps) / steps;
3483
+ this._components[1] = Math.round(g * steps) / steps;
3484
+ this._components[2] = Math.round(b * steps) / steps;
3455
3485
  this.refreshInt();
3456
3486
  this._value = null;
3457
3487
  return this;
@@ -3475,10 +3505,12 @@ const _Color = class {
3475
3505
  (int & 255) / 255,
3476
3506
  1
3477
3507
  ];
3478
- } else if ((Array.isArray(value) || value instanceof Float32Array) && value.length >= 3 && value.length <= 4 && value.every((v) => v <= 1 && v >= 0)) {
3508
+ } else if ((Array.isArray(value) || value instanceof Float32Array) && value.length >= 3 && value.length <= 4) {
3509
+ value = this._clamp(value);
3479
3510
  const [r, g, b, a = 1] = value;
3480
3511
  components = [r, g, b, a];
3481
3512
  } else if ((value instanceof Uint8Array || value instanceof Uint8ClampedArray) && value.length >= 3 && value.length <= 4) {
3513
+ value = this._clamp(value, 0, 255);
3482
3514
  const [r, g, b, a = 255] = value;
3483
3515
  components = [r / 255, g / 255, b / 255, a / 255];
3484
3516
  } else if (typeof value === "string" || typeof value === "object") {
@@ -3502,9 +3534,19 @@ const _Color = class {
3502
3534
  }
3503
3535
  }
3504
3536
  refreshInt() {
3537
+ this._clamp(this._components);
3505
3538
  const [r, g, b] = this._components;
3506
3539
  this._int = (r * 255 << 16) + (g * 255 << 8) + (b * 255 | 0);
3507
3540
  }
3541
+ _clamp(value, min = 0, max = 1) {
3542
+ if (typeof value === "number") {
3543
+ return Math.min(Math.max(value, min), max);
3544
+ }
3545
+ value.forEach((v, i) => {
3546
+ value[i] = Math.min(Math.max(v, min), max);
3547
+ });
3548
+ return value;
3549
+ }
3508
3550
  };
3509
3551
  let Color = _Color;
3510
3552
  Color.shared = new _Color();
@@ -10355,7 +10397,7 @@ class StartupSystem {
10355
10397
  const { renderer } = this;
10356
10398
  renderer.runners.init.emit(renderer.options);
10357
10399
  if (options.hello) {
10358
- console.log(`PixiJS ${"7.2.1"} - ${renderer.rendererLogId} - https://pixijs.com`);
10400
+ console.log(`PixiJS ${"7.2.3"} - ${renderer.rendererLogId} - https://pixijs.com`);
10359
10401
  }
10360
10402
  renderer.resize(renderer.screen.width, renderer.screen.height);
10361
10403
  }
@@ -12541,7 +12583,7 @@ class TransformFeedback {
12541
12583
  }
12542
12584
  }
12543
12585
 
12544
- const VERSION = "7.2.1";
12586
+ const VERSION = "7.2.3";
12545
12587
 
12546
12588
  class Bounds {
12547
12589
  constructor() {
@@ -15133,7 +15175,7 @@ class EventBoundary {
15133
15175
  this.eventPool = /* @__PURE__ */ new Map();
15134
15176
  this._allInteractiveElements = [];
15135
15177
  this._hitElements = [];
15136
- this._collectInteractiveElements = false;
15178
+ this._isPointerMoveEvent = false;
15137
15179
  this.rootTarget = rootTarget;
15138
15180
  this.hitPruneFn = this.hitPruneFn.bind(this);
15139
15181
  this.hitTestFn = this.hitTestFn.bind(this);
@@ -15185,7 +15227,9 @@ class EventBoundary {
15185
15227
  }
15186
15228
  hitTest(x, y) {
15187
15229
  EventsTicker.pauseUpdate = true;
15188
- const invertedPath = this.hitTestRecursive(this.rootTarget, this.rootTarget.eventMode, tempHitLocation.set(x, y), this.hitTestFn, this.hitPruneFn);
15230
+ const useMove = this._isPointerMoveEvent && this.enableGlobalMoveEvents;
15231
+ const fn = useMove ? "hitTestMoveRecursive" : "hitTestRecursive";
15232
+ const invertedPath = this[fn](this.rootTarget, this.rootTarget.eventMode, tempHitLocation.set(x, y), this.hitTestFn, this.hitPruneFn);
15189
15233
  return invertedPath && invertedPath[0];
15190
15234
  }
15191
15235
  propagate(e, type) {
@@ -15237,10 +15281,9 @@ class EventBoundary {
15237
15281
  propagationPath.reverse();
15238
15282
  return propagationPath;
15239
15283
  }
15240
- hitTestRecursive(currentTarget, eventMode, location, testFn, pruneFn) {
15241
- if (pruneFn(currentTarget, location)) {
15284
+ hitTestMoveRecursive(currentTarget, eventMode, location, testFn, pruneFn, ignore = false) {
15285
+ if (this._interactivePrune(currentTarget))
15242
15286
  return null;
15243
- }
15244
15287
  if (currentTarget.eventMode === "dynamic" || eventMode === "dynamic") {
15245
15288
  EventsTicker.pauseUpdate = false;
15246
15289
  }
@@ -15248,34 +15291,58 @@ class EventBoundary {
15248
15291
  const children = currentTarget.children;
15249
15292
  for (let i = children.length - 1; i >= 0; i--) {
15250
15293
  const child = children[i];
15251
- const nestedHit = this.hitTestRecursive(child, this._isInteractive(eventMode) ? eventMode : child.eventMode, location, testFn, pruneFn);
15294
+ const nestedHit = this.hitTestMoveRecursive(child, this._isInteractive(eventMode) ? eventMode : child.eventMode, location, testFn, pruneFn, pruneFn(currentTarget, location));
15252
15295
  if (nestedHit) {
15253
15296
  if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) {
15254
15297
  continue;
15255
15298
  }
15256
15299
  const isInteractive = currentTarget.isInteractive();
15257
15300
  if (nestedHit.length > 0 || isInteractive) {
15258
- if (this._collectInteractiveElements && isInteractive) {
15301
+ if (isInteractive)
15259
15302
  this._allInteractiveElements.push(currentTarget);
15260
- }
15261
15303
  nestedHit.push(currentTarget);
15262
15304
  }
15263
- if (this._collectInteractiveElements && this._hitElements.length === 0) {
15305
+ if (this._hitElements.length === 0)
15264
15306
  this._hitElements = nestedHit;
15265
- }
15266
- if (!this._collectInteractiveElements)
15267
- return nestedHit;
15268
15307
  }
15269
15308
  }
15270
15309
  }
15271
15310
  const isInteractiveMode = this._isInteractive(eventMode);
15272
15311
  const isInteractiveTarget = currentTarget.isInteractive();
15273
- if (this._collectInteractiveElements) {
15274
- if (isInteractiveMode && isInteractiveTarget)
15275
- this._allInteractiveElements.push(currentTarget);
15276
- if (this._hitElements.length > 0)
15277
- return null;
15312
+ if (isInteractiveTarget && isInteractiveTarget)
15313
+ this._allInteractiveElements.push(currentTarget);
15314
+ if (ignore || this._hitElements.length > 0)
15315
+ return null;
15316
+ if (isInteractiveMode && (!pruneFn(currentTarget, location) && testFn(currentTarget, location))) {
15317
+ return isInteractiveTarget ? [currentTarget] : [];
15318
+ }
15319
+ return null;
15320
+ }
15321
+ hitTestRecursive(currentTarget, eventMode, location, testFn, pruneFn) {
15322
+ if (this._interactivePrune(currentTarget) || pruneFn(currentTarget, location)) {
15323
+ return null;
15324
+ }
15325
+ if (currentTarget.eventMode === "dynamic" || eventMode === "dynamic") {
15326
+ EventsTicker.pauseUpdate = false;
15327
+ }
15328
+ if (currentTarget.interactiveChildren && currentTarget.children) {
15329
+ const children = currentTarget.children;
15330
+ for (let i = children.length - 1; i >= 0; i--) {
15331
+ const child = children[i];
15332
+ const nestedHit = this.hitTestRecursive(child, this._isInteractive(eventMode) ? eventMode : child.eventMode, location, testFn, pruneFn);
15333
+ if (nestedHit) {
15334
+ if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) {
15335
+ continue;
15336
+ }
15337
+ const isInteractive = currentTarget.isInteractive();
15338
+ if (nestedHit.length > 0 || isInteractive)
15339
+ nestedHit.push(currentTarget);
15340
+ return nestedHit;
15341
+ }
15342
+ }
15278
15343
  }
15344
+ const isInteractiveMode = this._isInteractive(eventMode);
15345
+ const isInteractiveTarget = currentTarget.isInteractive();
15279
15346
  if (isInteractiveMode && testFn(currentTarget, location)) {
15280
15347
  return isInteractiveTarget ? [currentTarget] : [];
15281
15348
  }
@@ -15284,7 +15351,7 @@ class EventBoundary {
15284
15351
  _isInteractive(int) {
15285
15352
  return int === "static" || int === "dynamic";
15286
15353
  }
15287
- hitPruneFn(displayObject, location) {
15354
+ _interactivePrune(displayObject) {
15288
15355
  if (!displayObject || displayObject.isMask || !displayObject.visible || !displayObject.renderable) {
15289
15356
  return true;
15290
15357
  }
@@ -15297,8 +15364,9 @@ class EventBoundary {
15297
15364
  if (displayObject.isMask) {
15298
15365
  return true;
15299
15366
  }
15300
- if (this._collectInteractiveElements)
15301
- return false;
15367
+ return false;
15368
+ }
15369
+ hitPruneFn(displayObject, location) {
15302
15370
  if (displayObject.hitArea) {
15303
15371
  displayObject.worldTransform.applyInverse(location, tempLocalMapping);
15304
15372
  if (!displayObject.hitArea.contains(tempLocalMapping.x, tempLocalMapping.y)) {
@@ -15359,9 +15427,9 @@ class EventBoundary {
15359
15427
  }
15360
15428
  this._allInteractiveElements.length = 0;
15361
15429
  this._hitElements.length = 0;
15362
- this._collectInteractiveElements = true;
15430
+ this._isPointerMoveEvent = true;
15363
15431
  const e = this.createPointerEvent(from);
15364
- this._collectInteractiveElements = false;
15432
+ this._isPointerMoveEvent = false;
15365
15433
  const isMouse = e.pointerType === "mouse" || e.pointerType === "pen";
15366
15434
  const trackingData = this.trackingData(from.pointerId);
15367
15435
  const outTarget = this.findMountedTarget(trackingData.overTargets);
@@ -20403,7 +20471,7 @@ const _Graphics = class extends Container {
20403
20471
  const uniforms = shader.uniforms;
20404
20472
  const drawCalls = geometry.drawCalls;
20405
20473
  uniforms.translationMatrix = this.transform.worldTransform;
20406
- Color.shared.setValue(this._tintColor).multiply([worldAlpha, worldAlpha, worldAlpha]).setAlpha(worldAlpha).toArray(uniforms.tint);
20474
+ Color.shared.setValue(this._tintColor).premultiply(worldAlpha).toArray(uniforms.tint);
20407
20475
  renderer.shader.bind(shader);
20408
20476
  renderer.geometry.bind(geometry, shader);
20409
20477
  renderer.state.set(this.state);