@awayjs/scene 0.13.244 → 0.13.246

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 (41) hide show
  1. package/bundle/awayjs-scene.umd.js +62 -103
  2. package/bundle/awayjs-scene.umd.js.map +1 -1
  3. package/bundle/awayjs-scene.umd.min.js.map +1 -1
  4. package/bundle/awayjs-scene.umd.min.js.map.map +1 -1
  5. package/dist/index.d.ts +0 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/lib/base/Timeline.d.ts +4 -6
  9. package/dist/lib/base/Timeline.d.ts.map +1 -1
  10. package/dist/lib/base/Timeline.js +7 -19
  11. package/dist/lib/display/MovieClip.d.ts +2 -2
  12. package/dist/lib/display/MovieClip.d.ts.map +1 -1
  13. package/dist/lib/display/MovieClip.js +2 -5
  14. package/dist/lib/display/Skybox.d.ts +1 -0
  15. package/dist/lib/display/Skybox.d.ts.map +1 -1
  16. package/dist/lib/display/Skybox.js +1 -0
  17. package/dist/lib/factories/DefaultSceneGraphFactory.d.ts +7 -4
  18. package/dist/lib/factories/DefaultSceneGraphFactory.d.ts.map +1 -1
  19. package/dist/lib/factories/DefaultSceneGraphFactory.js +10 -4
  20. package/dist/lib/factories/ISceneGraphFactory.d.ts +7 -8
  21. package/dist/lib/factories/ISceneGraphFactory.d.ts.map +1 -1
  22. package/dist/lib/managers/DefaultFontManager.d.ts.map +1 -1
  23. package/dist/lib/managers/DefaultFontManager.js +3 -4
  24. package/dist/lib/text/HTMLTextProcessor.js +1 -1
  25. package/dist/lib/text/TextFormat.d.ts +3 -3
  26. package/dist/lib/text/TextFormat.d.ts.map +1 -1
  27. package/dist/lib/text/TextFormat.js +37 -69
  28. package/index.ts +1 -2
  29. package/lib/base/Timeline.ts +9 -21
  30. package/lib/display/MovieClip.ts +4 -4
  31. package/lib/display/Skybox.ts +2 -0
  32. package/lib/factories/DefaultSceneGraphFactory.ts +12 -8
  33. package/lib/factories/ISceneGraphFactory.ts +9 -9
  34. package/lib/managers/DefaultFontManager.ts +3 -6
  35. package/lib/text/HTMLTextProcessor.ts +1 -1
  36. package/lib/text/TextFormat.ts +43 -75
  37. package/package.json +1 -1
  38. package/dist/lib/base/ISymbolDecoder.d.ts +0 -8
  39. package/dist/lib/base/ISymbolDecoder.d.ts.map +0 -1
  40. package/dist/lib/base/ISymbolDecoder.js +0 -0
  41. package/lib/base/ISymbolDecoder.ts +0 -11
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@awayjs/core'), require('@awayjs/view'), require('@awayjs/graphics'), require('@awayjs/stage'), require('@awayjs/renderer'), require('@awayjs/materials'), require('node-html-parser')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@awayjs/core', '@awayjs/view', '@awayjs/graphics', '@awayjs/stage', '@awayjs/renderer', '@awayjs/materials', 'node-html-parser'], factory) :
4
- (factory((global.AwayjsScene = global.AwayjsScene || {}),global.AwayjsCore,global.AwayjsView,global.AwayjsGraphics,global.AwayjsStage,global.AwayjsRenderer,global.AwayjsMaterials,global.nodeHtmlParser));
5
- }(this, (function (exports,_awayjs_core,_awayjs_view,_awayjs_graphics,_awayjs_stage,_awayjs_renderer,_awayjs_materials,nodeHtmlParser) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@awayjs/core'), require('@awayjs/stage'), require('@awayjs/view'), require('@awayjs/graphics'), require('@awayjs/renderer'), require('@awayjs/materials'), require('node-html-parser')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@awayjs/core', '@awayjs/stage', '@awayjs/view', '@awayjs/graphics', '@awayjs/renderer', '@awayjs/materials', 'node-html-parser'], factory) :
4
+ (factory((global.AwayjsScene = global.AwayjsScene || {}),global.AwayjsCore,global.AwayjsStage,global.AwayjsView,global.AwayjsGraphics,global.AwayjsRenderer,global.AwayjsMaterials,global.nodeHtmlParser));
5
+ }(this, (function (exports,_awayjs_core,_awayjs_stage,_awayjs_view,_awayjs_graphics,_awayjs_renderer,_awayjs_materials,nodeHtmlParser) { 'use strict';
6
6
 
7
7
  /*! *****************************************************************************
8
8
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3713,7 +3713,8 @@ function mapBlendIdToString(id) {
3713
3713
  return BLEND_MODES[id] || BLEND_MODES[1];
3714
3714
  }
3715
3715
  var Timeline = /** @class */ (function () {
3716
- function Timeline() {
3716
+ function Timeline(factory) {
3717
+ this.factory = factory;
3717
3718
  this._update_indices = [];
3718
3719
  this._update_frames = [];
3719
3720
  this.isButton = false;
@@ -3731,16 +3732,6 @@ var Timeline = /** @class */ (function () {
3731
3732
  this._framescripts_translated = {};
3732
3733
  this.keyframe_to_frameidx = {};
3733
3734
  }
3734
- Object.defineProperty(Timeline.prototype, "symbolDecoder", {
3735
- get: function () {
3736
- return this._symbolDecoder;
3737
- },
3738
- set: function (value) {
3739
- this._symbolDecoder = value;
3740
- },
3741
- enumerable: true,
3742
- configurable: true
3743
- });
3744
3735
  Timeline.prototype.resetScripts = function () {
3745
3736
  this._framescripts = {};
3746
3737
  this._framescripts_translated = {};
@@ -3749,9 +3740,6 @@ var Timeline = /** @class */ (function () {
3749
3740
  prepares
3750
3741
  */
3751
3742
  Timeline.prototype.init = function () {
3752
- if (!this._symbolDecoder) {
3753
- console.warn('[Timeline] - init - no _symbolDecoder is set');
3754
- }
3755
3743
  if ((this.frame_command_indices == null) || (this.frame_recipe == null) || (this.keyframe_durations == null)) {
3756
3744
  return;
3757
3745
  }
@@ -3829,7 +3817,7 @@ var Timeline = /** @class */ (function () {
3829
3817
  if (checkForTranslation && !this._framescripts_translated[frame_idx]) {
3830
3818
  // todo: cleanup so we can retrieve className of target_mc without hacks
3831
3819
  var name_1 = target_mc.className ? target_mc.className : target_mc.name;
3832
- this._framescripts[frame_idx] = this.symbolDecoder.prepareFrameScriptsForAVM1(this._framescripts[frame_idx], frame_idx, name_1, target_mc.id);
3820
+ this._framescripts[frame_idx] = this.factory.createFrameScripts(this._framescripts[frame_idx], frame_idx, name_1, target_mc.id);
3833
3821
  this._framescripts_translated[frame_idx] = true;
3834
3822
  }
3835
3823
  return this._framescripts[frame_idx];
@@ -3847,7 +3835,7 @@ var Timeline = /** @class */ (function () {
3847
3835
  return this.keyframe_indices[frame_index];
3848
3836
  };
3849
3837
  Timeline.prototype.getChildInstance = function (symbolID, sessionID) {
3850
- return this.symbolDecoder.createChildInstanceForTimeline(this, symbolID, sessionID);
3838
+ return this.factory.createChildInstanceForTimeline(this, symbolID, sessionID);
3851
3839
  };
3852
3840
  Timeline.prototype.extractHitArea = function (target_mc) {
3853
3841
  target_mc.reset(false);
@@ -4032,7 +4020,7 @@ var Timeline = /** @class */ (function () {
4032
4020
  console.warn('[Timeline] - add_childs_continous - could not find child-id in child_stream for idx', idx, this.add_child_stream);
4033
4021
  continue;
4034
4022
  }
4035
- var childAsset = this._symbolDecoder.createChildInstanceForTimeline(this, this.add_child_stream[idx + 2], this.add_child_stream[idx]);
4023
+ var childAsset = this.factory.createChildInstanceForTimeline(this, this.add_child_stream[idx + 2], this.add_child_stream[idx]);
4036
4024
  target_mc.adapter.addTimelineChildAtDepth(childAsset, this.add_child_stream[idx + 1]);
4037
4025
  }
4038
4026
  };
@@ -6870,7 +6858,6 @@ var MouseEvent$1 = /** @class */ (function (_super) {
6870
6858
  var MovieClip = /** @class */ (function (_super) {
6871
6859
  __extends(MovieClip, _super);
6872
6860
  function MovieClip(timeline, spriteMode) {
6873
- if (timeline === void 0) { timeline = null; }
6874
6861
  if (spriteMode === void 0) { spriteMode = false; }
6875
6862
  var _this = _super.call(this) || this;
6876
6863
  _this.symbolID = 0;
@@ -6945,7 +6932,7 @@ var MovieClip = /** @class */ (function (_super) {
6945
6932
  _this._onDragOut = function (_event) {
6946
6933
  _this.currentFrameIndex = 1;
6947
6934
  };
6948
- _this._timeline = timeline || new Timeline();
6935
+ _this._timeline = timeline;
6949
6936
  if (spriteMode) {
6950
6937
  _this.transformToSprite();
6951
6938
  }
@@ -6956,10 +6943,9 @@ var MovieClip = /** @class */ (function (_super) {
6956
6943
  MovieClip._activeSoundsOwners.clear();
6957
6944
  };
6958
6945
  MovieClip.getNewMovieClip = function (timeline) {
6959
- if (timeline === void 0) { timeline = null; }
6960
6946
  if (MovieClip._movieClips.length) {
6961
6947
  var movieClip = MovieClip._movieClips.pop();
6962
- movieClip.timeline = timeline || new Timeline();
6948
+ movieClip.timeline = timeline;
6963
6949
  movieClip.graphics = _awayjs_graphics.Graphics.getGraphics();
6964
6950
  return movieClip;
6965
6951
  }
@@ -7985,6 +7971,7 @@ var Skybox = /** @class */ (function (_super) {
7985
7971
  _this.imageRect = false;
7986
7972
  _this.useColorTransform = false;
7987
7973
  _this.alphaThreshold = 0;
7974
+ _this.alphaBlending = true;
7988
7975
  _this._onTextureInvalidateDelegate = function (event) { return _this.onTextureInvalidate(event); };
7989
7976
  _this._owners = [_this];
7990
7977
  _this.style = new _awayjs_renderer.Style();
@@ -10049,11 +10036,10 @@ var DefaultFontManager = /** @class */ (function () {
10049
10036
  this._registered_fonts_by_className[className] = font;
10050
10037
  };
10051
10038
  DefaultFontManager.getFont = function (fontName, namespace) {
10052
- //console.log('[DefaultFontManager] - getFont', fontName);
10053
10039
  if (namespace === void 0) { namespace = undefined; }
10054
- if (!fontName) {
10055
- return DeviceFontManager.getDeviceFont(fontName);
10056
- }
10040
+ // return null if no fontName supplied
10041
+ if (!fontName)
10042
+ return null;
10057
10043
  // hack for dynamic fonts: first check if reguested font-name is a classname that was registered
10058
10044
  if (this._registered_fonts_by_className[fontName]) {
10059
10045
  return this._registered_fonts_by_className[fontName];
@@ -10129,7 +10115,7 @@ var PUBLIC_FIELDS = [
10129
10115
  'size', 'color',
10130
10116
  'bold', 'italic',
10131
10117
  'underline', 'leading',
10132
- 'letterSpacing', 'font_table'
10118
+ 'letterSpacing'
10133
10119
  ];
10134
10120
  var TextFormat = /** @class */ (function (_super) {
10135
10121
  __extends(TextFormat, _super);
@@ -10187,9 +10173,10 @@ var TextFormat = /** @class */ (function (_super) {
10187
10173
  if (indent === void 0) { indent = null; }
10188
10174
  if (leading === void 0) { leading = null; }
10189
10175
  var _this = _super.call(this) || this;
10176
+ _this.fontLookUpMode = exports.FontLookUpMode.DEFAULT;
10190
10177
  // flag marked that format is changed.
10191
10178
  _this._updateID = 0;
10192
- _this._textFormatDirty = false;
10179
+ _this._fontTableDirty = true;
10193
10180
  /**
10194
10181
  * Specifies custom tab stops as an array of non-negative integers. Each tab
10195
10182
  * stop is specified in pixels. If custom tab stops are not specified
@@ -10197,7 +10184,6 @@ var TextFormat = /** @class */ (function (_super) {
10197
10184
  */
10198
10185
  //todo: not used with in tesselated-font-table yet
10199
10186
  _this.tabStops = [];
10200
- _this.fontLookUpMode = exports.FontLookUpMode.DEFAULT;
10201
10187
  _this._size = size;
10202
10188
  _this._color = color;
10203
10189
  _this._bold = bold;
@@ -10210,15 +10196,11 @@ var TextFormat = /** @class */ (function (_super) {
10210
10196
  _this._rightMargin = rightMargin;
10211
10197
  _this._indent = indent;
10212
10198
  _this._leading = leading;
10213
- _this._letterSpacing = null;
10214
- _this._font_table = null;
10215
10199
  if (typeof font === 'string') {
10216
- _this._setFontFromString(font);
10217
- return _this;
10200
+ _this.font_name = font;
10218
10201
  }
10219
- else if (font) {
10220
- _this._font = font;
10221
- _this._textFormatDirty = true;
10202
+ else {
10203
+ _this.font = font;
10222
10204
  }
10223
10205
  return _this;
10224
10206
  }
@@ -10376,7 +10358,7 @@ var TextFormat = /** @class */ (function (_super) {
10376
10358
  this._updateID++;
10377
10359
  }
10378
10360
  this._bold = value;
10379
- this._textFormatDirty = true;
10361
+ this._fontTableDirty = true;
10380
10362
  },
10381
10363
  enumerable: true,
10382
10364
  configurable: true
@@ -10390,7 +10372,7 @@ var TextFormat = /** @class */ (function (_super) {
10390
10372
  this._updateID++;
10391
10373
  }
10392
10374
  this._italic = value;
10393
- this._textFormatDirty = true;
10375
+ this._fontTableDirty = true;
10394
10376
  },
10395
10377
  enumerable: true,
10396
10378
  configurable: true
@@ -10410,10 +10392,8 @@ var TextFormat = /** @class */ (function (_super) {
10410
10392
  });
10411
10393
  Object.defineProperty(TextFormat.prototype, "font_table", {
10412
10394
  get: function () {
10413
- if (!this._font_table || this._textFormatDirty) {
10414
- this.font; // getter makes sure a font exists !
10395
+ if (!this._font_table || this._fontTableDirty)
10415
10396
  this.update_font_table();
10416
- }
10417
10397
  return this._font_table;
10418
10398
  },
10419
10399
  set: function (value) {
@@ -10421,7 +10401,7 @@ var TextFormat = /** @class */ (function (_super) {
10421
10401
  // font_table is only ever set in parser or when using label-data
10422
10402
  // after using "bold" or "itaic" font_table should never be set directly
10423
10403
  this._font_table = value;
10424
- this._textFormatDirty = false;
10404
+ this._fontTableDirty = false;
10425
10405
  },
10426
10406
  enumerable: true,
10427
10407
  configurable: true
@@ -10431,11 +10411,27 @@ var TextFormat = /** @class */ (function (_super) {
10431
10411
  var _a;
10432
10412
  return (_a = this.font) === null || _a === void 0 ? void 0 : _a.name;
10433
10413
  },
10414
+ set: function (value) {
10415
+ var _a;
10416
+ if (((_a = this.font) === null || _a === void 0 ? void 0 : _a.name) == value)
10417
+ return;
10418
+ if (this.fontLookUpMode == exports.FontLookUpMode.DEFAULT) {
10419
+ this._font = DefaultFontManager.getFont(value);
10420
+ }
10421
+ else if (this.fontLookUpMode == exports.FontLookUpMode.DEVICE) {
10422
+ this._font = DeviceFontManager.getDeviceFont(value);
10423
+ }
10424
+ else if (this.fontLookUpMode == exports.FontLookUpMode.EMBED_CFF) {
10425
+ this._font = DefaultFontManager.getFont_CFF(value);
10426
+ }
10427
+ this._fontTableDirty = true;
10428
+ this._updateID++;
10429
+ },
10434
10430
  enumerable: true,
10435
10431
  configurable: true
10436
10432
  });
10437
10433
  TextFormat.prototype.update_font_table = function () {
10438
- this._textFormatDirty = false;
10434
+ this._fontTableDirty = false;
10439
10435
  var stylename = exports.FontStyleName.STANDART;
10440
10436
  if (this._italic && !this._bold)
10441
10437
  stylename = exports.FontStyleName.ITALIC;
@@ -10444,73 +10440,31 @@ var TextFormat = /** @class */ (function (_super) {
10444
10440
  else if (this._italic && this._bold)
10445
10441
  stylename = exports.FontStyleName.BOLDITALIC;
10446
10442
  if (this._font) {
10447
- var newFontTable = this.font.get_font_table(stylename, TesselatedFontTable.assetType, null, true);
10448
- if (this._font_table && !newFontTable) {
10449
- // if we have a font-table, and we switch to invalid style,
10450
- // we just keep the existing font-table
10443
+ var font_table = this._font.get_font_table(stylename, TesselatedFontTable.assetType, null, true);
10444
+ // if we have a font-table, and we switch to invalid style,
10445
+ // we just keep the existing font-table
10446
+ if (this._font_table && !font_table)
10451
10447
  return;
10452
- }
10453
- this._font_table = newFontTable ? newFontTable : Font.emptyFontTable;
10454
- return;
10448
+ this._font_table = font_table ? font_table : Font.emptyFontTable;
10455
10449
  }
10456
10450
  };
10457
10451
  Object.defineProperty(TextFormat.prototype, "font", {
10458
10452
  get: function () {
10459
- if (this._font) {
10460
- return this._font;
10461
- }
10462
- if (this.fontLookUpMode == exports.FontLookUpMode.DEFAULT) {
10463
- this._font = DefaultFontManager.getFont(null);
10464
- }
10465
- else if (this.fontLookUpMode == exports.FontLookUpMode.DEVICE) {
10466
- this._font = DeviceFontManager.getDeviceFont(null);
10467
- }
10468
- else if (this.fontLookUpMode == exports.FontLookUpMode.EMBED_CFF) {
10469
- this._font = DefaultFontManager.getFont_CFF(null);
10470
- }
10471
- else {
10472
- console.warn('[TextFormat] - unsupported FontLookUpMode', this.fontLookUpMode);
10473
- }
10474
- this._font_table = null;
10475
- this._textFormatDirty = true;
10476
10453
  return this._font;
10477
10454
  },
10478
10455
  set: function (value) {
10479
- this._textFormatDirty = true;
10480
- if (typeof value === 'string') {
10481
- this._setFontFromString(value);
10482
- return;
10483
- }
10484
- if (value !== this._font) {
10485
- this._updateID++;
10486
- }
10487
- if (value) {
10488
- this._font = value;
10456
+ if (this._font == value)
10489
10457
  return;
10490
- }
10491
- this._font = null;
10492
- this._font_table = null;
10458
+ this._font = value;
10459
+ this._fontTableDirty = true;
10460
+ this._updateID++;
10493
10461
  },
10494
10462
  enumerable: true,
10495
10463
  configurable: true
10496
10464
  });
10497
- TextFormat.prototype._setFontFromString = function (font_name) {
10498
- var asset;
10499
- if (this.fontLookUpMode == exports.FontLookUpMode.DEFAULT) {
10500
- asset = DefaultFontManager.getFont(font_name);
10501
- }
10502
- else if (this.fontLookUpMode == exports.FontLookUpMode.DEVICE) {
10503
- asset = DeviceFontManager.getDeviceFont(font_name);
10504
- }
10505
- else if (this.fontLookUpMode == exports.FontLookUpMode.EMBED_CFF) {
10506
- asset = DefaultFontManager.getFont_CFF(font_name);
10507
- }
10508
- this.font = asset;
10509
- this._textFormatDirty = true;
10510
- };
10511
10465
  TextFormat.prototype.clone = function () {
10512
10466
  var clonedFormat = new TextFormat(this._font, this._size, this._color, this._bold, this._italic, this._underline, this.url, this.link_target, this._align, this._leftMargin, this._rightMargin, this._indent, this._leading);
10513
- clonedFormat.font_table = this._font_table;
10467
+ clonedFormat.font_table = this._font_table; //investigate why this needs to be copied
10514
10468
  return clonedFormat;
10515
10469
  };
10516
10470
  TextFormat.prototype.equal = function (format) {
@@ -11093,7 +11047,7 @@ var HTMLTextProcessor = /** @class */ (function () {
11093
11047
  var value = myChild.attributes.face ?
11094
11048
  myChild.attributes.face : myChild.attributes.FACE;
11095
11049
  newProps_values[newProps_values.length] = value;
11096
- newProps_names[newProps_names.length] = 'font';
11050
+ newProps_names[newProps_names.length] = 'font_name';
11097
11051
  }
11098
11052
  }
11099
11053
  // step2: collect the textformat-properties provided by this child.tagName
@@ -14410,12 +14364,14 @@ var ResizeEvent = /** @class */ (function (_super) {
14410
14364
  var DefaultSceneGraphFactory = /** @class */ (function (_super) {
14411
14365
  __extends(DefaultSceneGraphFactory, _super);
14412
14366
  function DefaultSceneGraphFactory() {
14413
- return _super !== null && _super.apply(this, arguments) || this;
14367
+ var _this = _super !== null && _super.apply(this, arguments) || this;
14368
+ _this.awaySymbols = {};
14369
+ return _this;
14414
14370
  }
14415
14371
  DefaultSceneGraphFactory.prototype.createMovieClip = function (timeline, symbol) {
14416
14372
  if (timeline === void 0) { timeline = null; }
14417
14373
  if (symbol === void 0) { symbol = null; }
14418
- return new MovieClip(timeline);
14374
+ return new MovieClip(timeline || new Timeline(this));
14419
14375
  };
14420
14376
  DefaultSceneGraphFactory.prototype.createSprite = function (prefab, graphics, symbol) {
14421
14377
  if (prefab === void 0) { prefab = null; }
@@ -14444,8 +14400,11 @@ var DefaultSceneGraphFactory = /** @class */ (function (_super) {
14444
14400
  DefaultSceneGraphFactory.prototype.createFrameScripts = function (scripts, frameIdx, objName, objID) {
14445
14401
  throw ('[DefaultSceneGraphFactory] - createFrameScripts should be overwritten by AVM');
14446
14402
  };
14403
+ DefaultSceneGraphFactory.prototype.createChildInstanceForTimeline = function (timeline, symbolID, sessionID) {
14404
+ throw ('[DefaultSceneGraphFactory] - createChildInstanceForTimeline should be overwritten by AVM');
14405
+ };
14447
14406
  return DefaultSceneGraphFactory;
14448
- }(_awayjs_stage.DefaultGraphicsFactory));
14407
+ }(_awayjs_stage.DefaultStageFactory));
14449
14408
 
14450
14409
  // empty matrix for transform reset
14451
14410
  var TMP_POINT = new _awayjs_core.Point(0, 0);
@@ -18358,7 +18317,7 @@ var Scene = /** @class */ (function () {
18358
18317
  _awayjs_graphics.MaterialManager.materialClass = _awayjs_materials.MethodMaterial;
18359
18318
  _awayjs_graphics.MaterialManager.textureClass = _awayjs_renderer.ImageTexture2D;
18360
18319
 
18361
- console.debug('AwayJS - Scene - 0.13.244');
18320
+ console.debug('AwayJS - Scene - 0.13.246');
18362
18321
 
18363
18322
  exports.Timeline = Timeline;
18364
18323
  exports.ControllerBase = ControllerBase;