@awayjs/scene 0.13.249 → 0.13.251

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.
@@ -2359,30 +2359,41 @@ var DisplayObject = /** @class */ (function (_super) {
2359
2359
  configurable: true
2360
2360
  });
2361
2361
  DisplayObject.prototype._mergeMasks = function (timeline, script) {
2362
- if (!timeline && !script) {
2363
- return null;
2364
- }
2362
+ if (!timeline && !script)
2363
+ return;
2365
2364
  // we can not have mask array, create it
2366
- if (!timeline && script) {
2367
- script.maskMode = true;
2365
+ if (!timeline && script)
2368
2366
  return [script];
2369
- }
2370
2367
  // and make sure that we not have same script mask in it
2371
- if (script && !timeline.includes(script)) {
2368
+ if (script && !timeline.includes(script))
2372
2369
  timeline.push(script);
2373
- }
2374
- // and make sure that mask mode enabled
2375
- for (var i = timeline.length - 1; i >= 0; i--) {
2376
- var m = timeline[i];
2377
- if (!m) {
2378
- console.warn('[DisplayObject] Timeline mask has null value, skipping it');
2379
- timeline.splice(i, 1);
2380
- }
2381
- else {
2382
- m.maskMode = true;
2370
+ return timeline;
2371
+ };
2372
+ DisplayObject.prototype._setMasks = function (masks) {
2373
+ var oldMasks = this._masks ? this._masks : [];
2374
+ if (masks) {
2375
+ // and make sure that mask mode enabled if not already
2376
+ for (var i = masks.length - 1; i >= 0; i--) {
2377
+ var mask = masks[i];
2378
+ if (!mask) {
2379
+ console.warn('[DisplayObject] Timeline mask has null value, skipping it');
2380
+ masks.splice(i, 1);
2381
+ }
2382
+ else {
2383
+ var index = oldMasks.indexOf(mask);
2384
+ if (index != -1) {
2385
+ oldMasks.splice(index, 1);
2386
+ }
2387
+ else {
2388
+ mask.maskMode = true;
2389
+ }
2390
+ }
2383
2391
  }
2384
2392
  }
2385
- return timeline;
2393
+ //set mask mode to false for old masks
2394
+ for (var i = oldMasks.length - 1; i >= 0; i--)
2395
+ oldMasks[i].maskMode = false;
2396
+ this._masks = masks;
2386
2397
  };
2387
2398
  Object.defineProperty(DisplayObject.prototype, "scriptMask", {
2388
2399
  get: function () {
@@ -2400,10 +2411,13 @@ var DisplayObject = /** @class */ (function (_super) {
2400
2411
  var index = this._masks.indexOf(this._scriptMask);
2401
2412
  if (index !== -1) {
2402
2413
  this._masks.splice(index, 1);
2414
+ this._scriptMask.maskMode = false;
2403
2415
  }
2404
2416
  }
2405
2417
  this._scriptMask = mask;
2406
2418
  this._masks = this._mergeMasks(this._masks, mask);
2419
+ if (mask)
2420
+ mask.maskMode = true;
2407
2421
  this._invalidateHierarchicalProperty(_awayjs_view.HierarchicalProperty.MASKS);
2408
2422
  },
2409
2423
  enumerable: true,
@@ -2415,7 +2429,7 @@ var DisplayObject = /** @class */ (function (_super) {
2415
2429
  * @param masks Masks from timeline
2416
2430
  */
2417
2431
  DisplayObject.prototype.updateTimelineMask = function (masks) {
2418
- this._masks = this._mergeMasks(masks, this._scriptMask);
2432
+ this._setMasks(this._mergeMasks(masks, this._scriptMask));
2419
2433
  this._invalidateHierarchicalProperty(_awayjs_view.HierarchicalProperty.MASKS);
2420
2434
  };
2421
2435
  Object.defineProperty(DisplayObject.prototype, "masks", {
@@ -2429,7 +2443,6 @@ var DisplayObject = /** @class */ (function (_super) {
2429
2443
  set: function (value) {
2430
2444
  if (this._masks == value)
2431
2445
  return;
2432
- this._masks = value;
2433
2446
  // this is edge case, if we set masks direct,
2434
2447
  // this means that we should reset _scriptMask when it not present in input mask
2435
2448
  if (!value || !value.length) {
@@ -2438,14 +2451,13 @@ var DisplayObject = /** @class */ (function (_super) {
2438
2451
  else {
2439
2452
  var len = value.length;
2440
2453
  var hasScriptMask = false;
2441
- for (var i = 0; i < len; i++) {
2442
- value[i].maskMode = true;
2454
+ for (var i = 0; i < len; i++)
2443
2455
  hasScriptMask = hasScriptMask || (value[i] === this._scriptMask);
2444
- }
2445
- if (this._scriptMask && !hasScriptMask) {
2456
+ //if we had a script mask set but it wasn't present in the new masks value, remove it
2457
+ if (this._scriptMask && !hasScriptMask)
2446
2458
  this._scriptMask = null;
2447
- }
2448
2459
  }
2460
+ this._setMasks(value);
2449
2461
  this._invalidateHierarchicalProperty(_awayjs_view.HierarchicalProperty.MASKS);
2450
2462
  },
2451
2463
  enumerable: true,
@@ -4096,7 +4108,7 @@ var Timeline = /** @class */ (function () {
4096
4108
  child.maskMode = true;
4097
4109
  };
4098
4110
  Timeline.remove_masks = function (_timeline, child, _target_mc, _i) {
4099
- child.masks = null;
4111
+ child.updateTimelineMask(null);
4100
4112
  };
4101
4113
  Timeline.update_filters = function (timeline, child, _target_mc, i) {
4102
4114
  var startFilter = timeline.properties_stream_int[i++];
@@ -11354,18 +11366,17 @@ var TextField = /** @class */ (function (_super) {
11354
11366
  this.maskChild.graphics.endFill();
11355
11367
  this.addChild(this.maskChild);
11356
11368
  this.addChild(this.textChild);
11357
- this.maskChild.maskMode = true;
11358
- //this.textChild.masks = [this.maskChild];
11369
+ this.maskChild.visible = false;
11359
11370
  this._graphics.clear();
11360
11371
  this.targetGraphics = this.textChild.graphics;
11361
11372
  return;
11362
11373
  }
11363
11374
  // only use masking if needed:
11364
11375
  if (this._textWidth > this._width || this._textHeight > this._height) {
11365
- this.textChild.masks = [this.maskChild];
11376
+ this.textChild.scriptMask = this.maskChild;
11366
11377
  }
11367
11378
  else {
11368
- this.textChild.masks = null;
11379
+ this.textChild.scriptMask = null;
11369
11380
  }
11370
11381
  return;
11371
11382
  };
@@ -14878,8 +14889,8 @@ var SceneImage2D = /** @class */ (function (_super) {
14878
14889
  if (!useBlend && this._lastUsedFill !== null) {
14879
14890
  // bitmap was filled plain, go clear TMP to this color too
14880
14891
  renderer.disableClear = false;
14881
- renderer.view.backgroundColor = this._lastUsedFill;
14882
- renderer.view.backgroundAlpha = (this._lastUsedFill >>> 24 & 0xff) / 0xff;
14892
+ renderer.view.backgroundColor = this._lastUsedFill & 0xffffff;
14893
+ renderer.view.backgroundAlpha = this._transparent ? (this._lastUsedFill >>> 24 & 0xff) / 0xff : 1;
14883
14894
  }
14884
14895
  else {
14885
14896
  // we clear TMP and render to it, prepare to composing
@@ -18173,7 +18184,7 @@ var Scene = /** @class */ (function () {
18173
18184
  _awayjs_graphics.MaterialManager.materialClass = _awayjs_materials.MethodMaterial;
18174
18185
  _awayjs_graphics.MaterialManager.textureClass = _awayjs_renderer.ImageTexture2D;
18175
18186
 
18176
- console.debug('AwayJS - Scene - 0.13.249');
18187
+ console.debug('AwayJS - Scene - 0.13.251');
18177
18188
 
18178
18189
  exports.Timeline = Timeline;
18179
18190
  exports.ControllerBase = ControllerBase;