@galacean/effects-core 2.1.5-alpha.0 → 2.2.0-alpha.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 (34) hide show
  1. package/dist/asset-manager.d.ts +5 -0
  2. package/dist/config.d.ts +1 -0
  3. package/dist/downloader.d.ts +16 -4
  4. package/dist/index.js +562 -527
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +559 -528
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/math/value-getters/value-getter.d.ts +4 -0
  9. package/dist/plugins/cal/animation-stream.d.ts +1 -2
  10. package/dist/plugins/cal/playable-graph.d.ts +1 -30
  11. package/dist/plugins/text/text-layout.d.ts +1 -1
  12. package/dist/plugins/timeline/playables/activation-mixer-playable.d.ts +3 -3
  13. package/dist/plugins/timeline/playables/color-property-mixer-playable.d.ts +3 -3
  14. package/dist/plugins/timeline/playables/float-property-mixer-playable.d.ts +3 -3
  15. package/dist/plugins/timeline/playables/index.d.ts +6 -2
  16. package/dist/plugins/timeline/playables/particle-mixer-playable.d.ts +5 -0
  17. package/dist/plugins/timeline/playables/sprite-color-mixer-playable.d.ts +5 -0
  18. package/dist/plugins/timeline/playables/sub-composition-mixer-playable.d.ts +3 -3
  19. package/dist/plugins/timeline/playables/track-mixer-playable.d.ts +12 -0
  20. package/dist/plugins/timeline/playables/transform-mixer-playable.d.ts +5 -0
  21. package/dist/plugins/timeline/playables/vector4-property-mixer-playable.d.ts +3 -3
  22. package/dist/plugins/timeline/track.d.ts +7 -6
  23. package/dist/plugins/timeline/tracks/activation-track.d.ts +3 -2
  24. package/dist/plugins/timeline/tracks/color-property-track.d.ts +3 -2
  25. package/dist/plugins/timeline/tracks/float-property-track.d.ts +3 -2
  26. package/dist/plugins/timeline/tracks/index.d.ts +1 -0
  27. package/dist/plugins/timeline/tracks/particle-track.d.ts +6 -0
  28. package/dist/plugins/timeline/tracks/property-track.d.ts +1 -1
  29. package/dist/plugins/timeline/tracks/sprite-color-track.d.ts +3 -0
  30. package/dist/plugins/timeline/tracks/sub-composition-track.d.ts +3 -2
  31. package/dist/plugins/timeline/tracks/transform-track.d.ts +3 -0
  32. package/dist/plugins/timeline/tracks/vector4-property-track.d.ts +3 -2
  33. package/dist/scene.d.ts +13 -1
  34. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.1.5-alpha.0
6
+ * Version: v2.2.0-alpha.0
7
7
  */
8
8
 
9
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -59,12 +59,8 @@ function __generator(thisArg, body) {
59
59
  },
60
60
  trys: [],
61
61
  ops: []
62
- }, f, y, t, g;
63
- return g = {
64
- next: verb(0),
65
- "throw": verb(1),
66
- "return": verb(2)
67
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
62
+ }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
63
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
68
64
  return this;
69
65
  }), g;
70
66
  function verb(n) {
@@ -5721,6 +5717,22 @@ var TextureSourceType;
5721
5717
  TextureSourceType[TextureSourceType["mipmaps"] = 7] = "mipmaps";
5722
5718
  })(TextureSourceType || (TextureSourceType = {}));
5723
5719
 
5720
+ var RUNTIME_ENV = "runtime_env";
5721
+ var RENDER_PREFER_LOOKUP_TEXTURE = "lookup_texture";
5722
+ // 文本元素使用 offscreen canvas 绘制
5723
+ var TEMPLATE_USE_OFFSCREEN_CANVAS = "offscreen_canvas";
5724
+ // 后处理配置相关
5725
+ var POST_PROCESS_SETTINGS = "post_process_settings";
5726
+ // 加载图片时是否使用 ImageBitmap
5727
+ var LOAD_PREFER_IMAGE_BITMAP = "load_image_bitmap";
5728
+ var config = {};
5729
+ function getConfig(name) {
5730
+ return config[name];
5731
+ }
5732
+ function setConfig(name, value) {
5733
+ return config[name] = value;
5734
+ }
5735
+
5724
5736
  /**
5725
5737
  * 负责下载各种资源,并提供了一些异步加载和缓存管理的功能
5726
5738
  */ var Downloader = /*#__PURE__*/ function() {
@@ -5809,11 +5821,11 @@ var avifFailed = false;
5809
5821
  * 异步加载一个 WebP 图片文件,如果不支持 WebP,则加载 PNG 图片文件
5810
5822
  * @param png - PNG 图片文件的 URL
5811
5823
  * @param webp - WebP 图片文件的 URL
5812
- */ function loadWebPOptional(png, webp) {
5824
+ */ function loadWebPOptional(png, webp, options) {
5813
5825
  return _loadWebPOptional.apply(this, arguments);
5814
5826
  }
5815
5827
  function _loadWebPOptional() {
5816
- _loadWebPOptional = _async_to_generator(function(png, webp) {
5828
+ _loadWebPOptional = _async_to_generator(function(png, webp, options) {
5817
5829
  var image, image1, image2;
5818
5830
  return __generator(this, function(_state) {
5819
5831
  switch(_state.label){
@@ -5824,7 +5836,7 @@ function _loadWebPOptional() {
5824
5836
  ];
5825
5837
  return [
5826
5838
  4,
5827
- loadImage(png)
5839
+ loadImageBitmap(png, options)
5828
5840
  ];
5829
5841
  case 1:
5830
5842
  image = _state.sent();
@@ -5844,7 +5856,7 @@ function _loadWebPOptional() {
5844
5856
  ]);
5845
5857
  return [
5846
5858
  4,
5847
- loadImage(webp)
5859
+ loadImageBitmap(webp, options)
5848
5860
  ];
5849
5861
  case 3:
5850
5862
  image1 = _state.sent();
@@ -5860,7 +5872,7 @@ function _loadWebPOptional() {
5860
5872
  webPFailed = true;
5861
5873
  return [
5862
5874
  4,
5863
- loadImage(png)
5875
+ loadImageBitmap(png, options)
5864
5876
  ];
5865
5877
  case 5:
5866
5878
  image2 = _state.sent();
@@ -5884,11 +5896,11 @@ function _loadWebPOptional() {
5884
5896
  * 异步加载一个 AVIF 图片文件,如果不支持 AVIF,则加载 PNG 图片文件
5885
5897
  * @param png - PNG 图片文件的 URL
5886
5898
  * @param avif - AVIF 图片文件的 URL
5887
- */ function loadAVIFOptional(png, avif) {
5899
+ */ function loadAVIFOptional(png, avif, options) {
5888
5900
  return _loadAVIFOptional.apply(this, arguments);
5889
5901
  }
5890
5902
  function _loadAVIFOptional() {
5891
- _loadAVIFOptional = _async_to_generator(function(png, avif) {
5903
+ _loadAVIFOptional = _async_to_generator(function(png, avif, options) {
5892
5904
  var image, image1, image2;
5893
5905
  return __generator(this, function(_state) {
5894
5906
  switch(_state.label){
@@ -5899,7 +5911,7 @@ function _loadAVIFOptional() {
5899
5911
  ];
5900
5912
  return [
5901
5913
  4,
5902
- loadImage(png)
5914
+ loadImageBitmap(png, options)
5903
5915
  ];
5904
5916
  case 1:
5905
5917
  image = _state.sent();
@@ -5919,7 +5931,7 @@ function _loadAVIFOptional() {
5919
5931
  ]);
5920
5932
  return [
5921
5933
  4,
5922
- loadImage(avif)
5934
+ loadImageBitmap(avif, options)
5923
5935
  ];
5924
5936
  case 3:
5925
5937
  image1 = _state.sent();
@@ -5935,7 +5947,7 @@ function _loadAVIFOptional() {
5935
5947
  avifFailed = true;
5936
5948
  return [
5937
5949
  4,
5938
- loadImage(png)
5950
+ loadImageBitmap(png, options)
5939
5951
  ];
5940
5952
  case 5:
5941
5953
  image2 = _state.sent();
@@ -6150,6 +6162,80 @@ function _loadMedia() {
6150
6162
  });
6151
6163
  return _loadMedia.apply(this, arguments);
6152
6164
  }
6165
+ var imageBitMapAvailable = typeof createImageBitmap === "function";
6166
+ /**
6167
+ * 异步加载一个图片文件,如果支持 ImageBitmap 则返回 ImageBitmap 对象
6168
+ * @param source
6169
+ * @param options
6170
+ * @returns
6171
+ */ function loadImageBitmap(source, options) {
6172
+ return _loadImageBitmap.apply(this, arguments);
6173
+ }
6174
+ function _loadImageBitmap() {
6175
+ _loadImageBitmap = _async_to_generator(function(source, options) {
6176
+ var blob;
6177
+ return __generator(this, function(_state) {
6178
+ switch(_state.label){
6179
+ case 0:
6180
+ if (!(imageBitMapAvailable && getConfig(LOAD_PREFER_IMAGE_BITMAP))) return [
6181
+ 3,
6182
+ 4
6183
+ ];
6184
+ if (!(typeof source === "string")) return [
6185
+ 3,
6186
+ 2
6187
+ ];
6188
+ return [
6189
+ 4,
6190
+ loadBlob(source)
6191
+ ];
6192
+ case 1:
6193
+ blob = _state.sent();
6194
+ return [
6195
+ 3,
6196
+ 3
6197
+ ];
6198
+ case 2:
6199
+ if (_instanceof1(source, Blob)) {
6200
+ blob = source;
6201
+ } else {
6202
+ return [
6203
+ 2,
6204
+ loadImage(source)
6205
+ ];
6206
+ }
6207
+ _state.label = 3;
6208
+ case 3:
6209
+ return [
6210
+ 2,
6211
+ createImageBitmap(blob, options)
6212
+ ];
6213
+ case 4:
6214
+ return [
6215
+ 2,
6216
+ loadImage(source)
6217
+ ];
6218
+ case 5:
6219
+ return [
6220
+ 2
6221
+ ];
6222
+ }
6223
+ });
6224
+ });
6225
+ return _loadImageBitmap.apply(this, arguments);
6226
+ }
6227
+ /**
6228
+ * 关闭 ImageBitMap,释放内存
6229
+ * @param imgs
6230
+ */ function closeImageBitMap(imgs) {
6231
+ if (imageBitMapAvailable) {
6232
+ if (_instanceof1(imgs, ImageBitmap)) {
6233
+ imgs.close();
6234
+ } else if (_instanceof1(imgs, Array)) {
6235
+ imgs.forEach(closeImageBitMap);
6236
+ }
6237
+ }
6238
+ }
6153
6239
 
6154
6240
  function deserializeMipmapTexture(textureOptions, bins, assets) {
6155
6241
  return _deserializeMipmapTexture.apply(this, arguments);
@@ -12752,8 +12838,8 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
12752
12838
  return data;
12753
12839
  };
12754
12840
  _proto.getMaxTime = function getMaxTime() {
12755
- var keyTimeData = Object.keys(this.curveMap);
12756
- return Number(keyTimeData[keyTimeData.length - 1].split("&")[1]);
12841
+ var keyTimeData = this.keyTimeData;
12842
+ return this.curveMap[keyTimeData[keyTimeData.length - 1]].timeEnd;
12757
12843
  };
12758
12844
  return BezierCurve;
12759
12845
  }(ValueGetter);
@@ -12831,19 +12917,22 @@ var BezierCurvePath = /*#__PURE__*/ function(ValueGetter) {
12831
12917
  timeInterval: timeInterval,
12832
12918
  valueInterval: valueInterval,
12833
12919
  easingCurve: easingCurve,
12834
- pathCurve: pathCurve
12920
+ pathCurve: pathCurve,
12921
+ timeStart: Number(s.x),
12922
+ timeEnd: Number(e.x)
12835
12923
  };
12836
12924
  }
12925
+ this.keyTimeData = Object.keys(this.curveSegments);
12837
12926
  };
12838
12927
  _proto.getValue = function getValue(time) {
12839
12928
  var t = numberToFix(time, 5);
12840
12929
  var perc = 0, point = new Vector3();
12841
- var keyTimeData = Object.keys(this.curveSegments);
12930
+ var keyTimeData = this.keyTimeData;
12842
12931
  if (!keyTimeData.length) {
12843
12932
  return point;
12844
12933
  }
12845
- var keyTimeStart = Number(keyTimeData[0].split("&")[0]);
12846
- var keyTimeEnd = Number(keyTimeData[keyTimeData.length - 1].split("&")[1]);
12934
+ var keyTimeStart = this.curveSegments[keyTimeData[0]].timeStart;
12935
+ var keyTimeEnd = this.curveSegments[keyTimeData[keyTimeData.length - 1]].timeEnd;
12847
12936
  if (t <= keyTimeStart) {
12848
12937
  var pathCurve = this.curveSegments[keyTimeData[0]].pathCurve;
12849
12938
  point = pathCurve.getPointInPercent(0);
@@ -12855,7 +12944,8 @@ var BezierCurvePath = /*#__PURE__*/ function(ValueGetter) {
12855
12944
  return point;
12856
12945
  }
12857
12946
  for(var i = 0; i < keyTimeData.length; i++){
12858
- var _keyTimeData_i_split = keyTimeData[i].split("&"), xMin = _keyTimeData_i_split[0], xMax = _keyTimeData_i_split[1];
12947
+ var xMin = this.curveSegments[keyTimeData[i]].timeStart;
12948
+ var xMax = this.curveSegments[keyTimeData[i]].timeEnd;
12859
12949
  if (t >= Number(xMin) && t < Number(xMax)) {
12860
12950
  var bezierPath = this.curveSegments[keyTimeData[i]].pathCurve;
12861
12951
  perc = this.getPercValue(keyTimeData[i], t);
@@ -12874,8 +12964,8 @@ var BezierCurvePath = /*#__PURE__*/ function(ValueGetter) {
12874
12964
  return clamp$1(value, 0, 1);
12875
12965
  };
12876
12966
  _proto.getMaxTime = function getMaxTime() {
12877
- var keyTimeData = Object.keys(this.curveSegments);
12878
- return Number(keyTimeData[keyTimeData.length - 1].split("&")[1]);
12967
+ var keyTimeData = this.keyTimeData;
12968
+ return this.curveSegments[keyTimeData[keyTimeData.length - 1]].timeEnd;
12879
12969
  };
12880
12970
  return BezierCurvePath;
12881
12971
  }(ValueGetter);
@@ -13028,15 +13118,18 @@ function createKeyFrameMeta() {
13028
13118
  }
13029
13119
 
13030
13120
  function _is_native_reflect_construct() {
13031
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
13032
- if (Reflect.construct.sham) return false;
13033
- if (typeof Proxy === "function") return true;
13121
+ // Since Reflect.construct can't be properly polyfilled, some
13122
+ // implementations (e.g. core-js@2) don't set the correct internal slots.
13123
+ // Those polyfills don't allow us to subclass built-ins, so we need to
13124
+ // use our fallback implementation.
13034
13125
  try {
13035
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
13036
- return true;
13037
- } catch (e) {
13038
- return false;
13039
- }
13126
+ // If the internal slots aren't set, this throws an error similar to
13127
+ // TypeError: this is not a Boolean object.
13128
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
13129
+ } catch (_) {}
13130
+ return (_is_native_reflect_construct = function _is_native_reflect_construct() {
13131
+ return !!result;
13132
+ })();
13040
13133
  }
13041
13134
 
13042
13135
  function _construct(Parent, args, Class) {
@@ -15900,6 +15993,7 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15900
15993
  if (this.animated) {
15901
15994
  this.buildPath(this.data);
15902
15995
  this.buildGeometryFromPath(this.path.shapePath);
15996
+ this.animated = false;
15903
15997
  }
15904
15998
  };
15905
15999
  _proto.buildGeometryFromPath = function buildGeometryFromPath(shapePath) {
@@ -16578,17 +16672,10 @@ var InteractComponent = /*#__PURE__*/ function(RendererComponent) {
16578
16672
  ];
16579
16673
  };
16580
16674
  _proto.onStart = function onStart() {
16581
- var _this = this;
16582
- var _this_item_composition;
16583
16675
  var options = this.item.props.content.options;
16584
16676
  var env = this.item.engine.renderer.env;
16585
16677
  var composition = this.item.composition;
16586
16678
  var _this_interactData_options = this.interactData.options, type = _this_interactData_options.type, showPreview = _this_interactData_options.showPreview;
16587
- (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.on("goto", function() {
16588
- if (_this.item.time > 0) {
16589
- _this.duringPlay = true;
16590
- }
16591
- });
16592
16679
  if (type === InteractType.CLICK) {
16593
16680
  this.clickable = true;
16594
16681
  if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
@@ -16629,12 +16716,12 @@ var InteractComponent = /*#__PURE__*/ function(RendererComponent) {
16629
16716
  };
16630
16717
  _proto.onUpdate = function onUpdate(dt) {
16631
16718
  var _this_previewContent;
16719
+ this.duringPlay = true;
16632
16720
  // trigger messageBegin when item enter
16633
- if (this.item.time > 0 && !this.duringPlay) {
16721
+ if (this.item.time > 0 && this.item.time - dt / 1000 <= 0) {
16634
16722
  var _this_item_composition;
16635
16723
  var options = this.item.props.content.options;
16636
16724
  (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.addInteractiveItem(this.item, options.type);
16637
- this.duringPlay = true;
16638
16725
  }
16639
16726
  (_this_previewContent = this.previewContent) == null ? void 0 : _this_previewContent.updateMesh();
16640
16727
  if (!this.dragEvent || !this.bouncingArg) {
@@ -17014,14 +17101,10 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17014
17101
  var playableOutput2 = _step2.value;
17015
17102
  this.processFrameWithRoot(playableOutput2);
17016
17103
  }
17017
- // 更新节点时间
17018
- for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playables), _step3; !(_step3 = _iterator3()).done;){
17019
- var playable = _step3.value;
17020
- this.updatePlayableTime(playable, dt / 1000);
17021
- }
17022
- };
17023
- _proto.connect = function connect(source, sourceOutputPort, destination, destinationInputPort) {
17024
- destination.connectInput(destinationInputPort, source, sourceOutputPort);
17104
+ // 更新节点时间
17105
+ // for (const playable of this.playables) {
17106
+ // this.updatePlayableTime(playable, dt / 1000);
17107
+ // }
17025
17108
  };
17026
17109
  _proto.addOutput = function addOutput(output) {
17027
17110
  this.playableOutputs.push(output);
@@ -17030,12 +17113,12 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17030
17113
  this.playables.push(playable);
17031
17114
  };
17032
17115
  _proto.processFrameWithRoot = function processFrameWithRoot(output) {
17033
- output.sourcePlayable.processFrameRecursive(output.context, output.getSourceOutputPort());
17116
+ output.sourcePlayable.processFrame(output.context);
17034
17117
  output.processFrame();
17035
17118
  };
17036
17119
  _proto.prepareFrameWithRoot = function prepareFrameWithRoot(output) {
17037
- output.sourcePlayable.prepareFrameRecursive(output.context, output.getSourceOutputPort());
17038
17120
  output.prepareFrame();
17121
+ output.sourcePlayable.prepareFrame(output.context);
17039
17122
  };
17040
17123
  _proto.updatePlayableTime = function updatePlayableTime(playable, deltaTime) {
17041
17124
  if (playable.getPlayState() !== 0) {
@@ -17050,24 +17133,15 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17050
17133
  * @since 2.0.0
17051
17134
  */ var Playable = /*#__PURE__*/ function() {
17052
17135
  function Playable(graph, inputCount) {
17053
- if (inputCount === void 0) inputCount = 0;
17054
17136
  this.onPlayablePlayFlag = true;
17055
17137
  this.onPlayablePauseFlag = false;
17056
17138
  this.duration = 0;
17057
17139
  this.destroyed = false;
17058
- this.inputs = [];
17059
- this.inputOuputPorts = [];
17060
- this.inputWeight = [];
17061
- this.outputs = [];
17062
17140
  this.playState = 0;
17063
- this.traversalMode = 0;
17064
17141
  /**
17065
17142
  * 当前本地播放的时间
17066
17143
  */ this.time = 0;
17067
17144
  graph.addPlayable(this);
17068
- this.inputs = new Array(inputCount);
17069
- this.inputOuputPorts = new Array(inputCount);
17070
- this.inputWeight = new Array(inputCount);
17071
17145
  }
17072
17146
  var _proto = Playable.prototype;
17073
17147
  _proto.play = function play() {
@@ -17090,56 +17164,6 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17090
17164
  break;
17091
17165
  }
17092
17166
  };
17093
- _proto.connectInput = function connectInput(inputPort, sourcePlayable, sourceOutputPort, weight) {
17094
- if (weight === void 0) weight = 1.0;
17095
- this.setInput(sourcePlayable, inputPort);
17096
- this.setInputWeight(inputPort, weight);
17097
- sourcePlayable.setOutput(this, sourceOutputPort);
17098
- if (this.inputOuputPorts.length < inputPort + 1) {
17099
- this.inputOuputPorts.length = inputPort + 1;
17100
- }
17101
- this.inputOuputPorts[inputPort] = sourceOutputPort;
17102
- };
17103
- _proto.addInput = function addInput(sourcePlayable, sourceOutputPort, weight) {
17104
- if (weight === void 0) weight = 1.0;
17105
- this.connectInput(this.getInputCount(), sourcePlayable, sourceOutputPort, weight);
17106
- };
17107
- _proto.getInputCount = function getInputCount() {
17108
- return this.inputs.length;
17109
- };
17110
- _proto.getInputs = function getInputs() {
17111
- return this.inputs;
17112
- };
17113
- _proto.getInput = function getInput(index) {
17114
- return this.inputs[index];
17115
- };
17116
- _proto.getOutputCount = function getOutputCount() {
17117
- return this.outputs.length;
17118
- };
17119
- _proto.getOutputs = function getOutputs() {
17120
- return this.outputs;
17121
- };
17122
- _proto.getOutput = function getOutput(index) {
17123
- return this.outputs[index];
17124
- };
17125
- _proto.getInputWeight = function getInputWeight(inputIndex) {
17126
- return this.inputWeight[inputIndex];
17127
- };
17128
- _proto.setInputWeight = function setInputWeight(playableOrIndex, weight) {
17129
- if (_instanceof1(playableOrIndex, Playable)) {
17130
- for(var i = 0; i < this.inputs.length; i++){
17131
- if (this.inputs[i] === playableOrIndex) {
17132
- this.inputWeight[i] = weight;
17133
- return;
17134
- }
17135
- }
17136
- } else {
17137
- if (this.inputWeight.length < playableOrIndex + 1) {
17138
- this.inputWeight.length = playableOrIndex + 1;
17139
- }
17140
- this.inputWeight[playableOrIndex] = weight;
17141
- }
17142
- };
17143
17167
  _proto.setTime = function setTime(time) {
17144
17168
  this.time = time;
17145
17169
  };
@@ -17155,18 +17179,14 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17155
17179
  _proto.getPlayState = function getPlayState() {
17156
17180
  return this.playState;
17157
17181
  };
17158
- _proto.setTraversalMode = function setTraversalMode(mode) {
17159
- this.traversalMode = mode;
17160
- };
17161
- _proto.getTraversalMode = function getTraversalMode() {
17162
- return this.traversalMode;
17163
- };
17164
17182
  // onGraphStart () {
17165
17183
  // }
17166
17184
  // onGraphStop () {
17167
17185
  // }
17168
- _proto.onPlayablePlay = function onPlayablePlay(context) {};
17169
- _proto.onPlayablePause = function onPlayablePause(context) {};
17186
+ // onPlayablePlay (context: FrameContext) {
17187
+ // }
17188
+ // onPlayablePause (context: FrameContext) {
17189
+ // }
17170
17190
  _proto.prepareFrame = function prepareFrame(context) {};
17171
17191
  _proto.processFrame = function processFrame(context) {};
17172
17192
  _proto.onPlayableDestroy = function onPlayableDestroy() {};
@@ -17178,76 +17198,6 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17178
17198
  // TODO 将节点从动画图中移除
17179
17199
  this.destroyed = true;
17180
17200
  };
17181
- /**
17182
- * @internal
17183
- */ _proto.prepareFrameRecursive = function prepareFrameRecursive(context, passthroughPort) {
17184
- if (this.destroyed || this.playState !== 0) {
17185
- return;
17186
- }
17187
- if (this.onPlayablePlayFlag) {
17188
- this.onPlayablePlay(context);
17189
- this.onPlayablePlayFlag = false;
17190
- }
17191
- if (this.onPlayablePauseFlag) {
17192
- this.onPlayablePause(context);
17193
- this.onPlayablePauseFlag = false;
17194
- }
17195
- if (passthroughPort === 0) {
17196
- this.prepareFrame(context);
17197
- }
17198
- // 前序遍历,用于设置节点的初始状态,weight etc.
17199
- switch(this.getTraversalMode()){
17200
- case 0:
17201
- for(var i = 0; i < this.getInputCount(); i++){
17202
- var input = this.getInput(i);
17203
- input.prepareFrameRecursive(context, this.inputOuputPorts[i]);
17204
- }
17205
- break;
17206
- case 1:
17207
- {
17208
- var input1 = this.getInput(passthroughPort);
17209
- input1.prepareFrameRecursive(context, this.inputOuputPorts[passthroughPort]);
17210
- break;
17211
- }
17212
- }
17213
- };
17214
- /**
17215
- * @internal
17216
- */ _proto.processFrameRecursive = function processFrameRecursive(context, passthroughPort) {
17217
- if (this.destroyed || this.playState !== 0) {
17218
- return;
17219
- }
17220
- // 后序遍历,保证 playable 拿到的 input 节点的估计数据是最新的
17221
- switch(this.getTraversalMode()){
17222
- case 0:
17223
- {
17224
- for(var i = 0; i < this.getInputCount(); i++){
17225
- var input = this.getInput(i);
17226
- input.processFrameRecursive(context, this.inputOuputPorts[i]);
17227
- }
17228
- break;
17229
- }
17230
- case 1:
17231
- {
17232
- var input1 = this.getInput(passthroughPort);
17233
- input1.processFrameRecursive(context, this.inputOuputPorts[passthroughPort]);
17234
- break;
17235
- }
17236
- }
17237
- this.processFrame(context);
17238
- };
17239
- _proto.setOutput = function setOutput(outputPlayable, outputPort) {
17240
- if (this.outputs.length < outputPort + 1) {
17241
- this.outputs.length = outputPort + 1;
17242
- }
17243
- this.outputs[outputPort] = outputPlayable;
17244
- };
17245
- _proto.setInput = function setInput(inputPlayable, inputPort) {
17246
- if (this.inputs.length < inputPort + 1) {
17247
- this.inputs.length = inputPort + 1;
17248
- }
17249
- this.inputs[inputPort] = inputPlayable;
17250
- };
17251
17201
  return Playable;
17252
17202
  }();
17253
17203
  /**
@@ -17255,20 +17205,14 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17255
17205
  * @since 2.0.0
17256
17206
  */ var PlayableOutput = /*#__PURE__*/ function() {
17257
17207
  function PlayableOutput() {
17258
- this.sourceOutputPort = 0;
17259
17208
  this.context = {
17260
17209
  deltaTime: 0,
17261
17210
  output: this
17262
17211
  };
17263
17212
  }
17264
17213
  var _proto = PlayableOutput.prototype;
17265
- _proto.setSourcePlayable = function setSourcePlayable(playable, port) {
17266
- if (port === void 0) port = 0;
17214
+ _proto.setSourcePlayable = function setSourcePlayable(playable) {
17267
17215
  this.sourcePlayable = playable;
17268
- this.sourceOutputPort = port;
17269
- };
17270
- _proto.getSourceOutputPort = function getSourceOutputPort() {
17271
- return this.sourceOutputPort;
17272
17216
  };
17273
17217
  _proto.setUserData = function setUserData(value) {
17274
17218
  this.userData = value;
@@ -17294,11 +17238,6 @@ var PlayState;
17294
17238
  PlayState[PlayState["Playing"] = 0] = "Playing";
17295
17239
  PlayState[PlayState["Paused"] = 1] = "Paused";
17296
17240
  })(PlayState || (PlayState = {}));
17297
- var PlayableTraversalMode;
17298
- (function(PlayableTraversalMode) {
17299
- PlayableTraversalMode[PlayableTraversalMode["Mix"] = 0] = "Mix";
17300
- PlayableTraversalMode[PlayableTraversalMode["Passthrough"] = 1] = "Passthrough";
17301
- })(PlayableTraversalMode || (PlayableTraversalMode = {}));
17302
17241
 
17303
17242
  var tempQuat$1 = new Quaternion();
17304
17243
  var seed$3 = 1;
@@ -18865,20 +18804,6 @@ SpriteComponent = __decorate([
18865
18804
  effectsClass(DataType.SpriteComponent)
18866
18805
  ], SpriteComponent);
18867
18806
 
18868
- var RUNTIME_ENV = "runtime_env";
18869
- var RENDER_PREFER_LOOKUP_TEXTURE = "lookup_texture";
18870
- // 文本元素使用 offscreen canvas 绘制
18871
- var TEMPLATE_USE_OFFSCREEN_CANVAS = "offscreen_canvas";
18872
- // 后处理配置相关
18873
- var POST_PROCESS_SETTINGS = "post_process_settings";
18874
- var config = {};
18875
- function getConfig(name) {
18876
- return config[name];
18877
- }
18878
- function setConfig(name, value) {
18879
- return config[name] = value;
18880
- }
18881
-
18882
18807
  var Cone = /*#__PURE__*/ function() {
18883
18808
  function Cone(props) {
18884
18809
  var _this = this;
@@ -22803,12 +22728,6 @@ var AnimationStream = /*#__PURE__*/ function() {
22803
22728
  _proto.findCurveValue = function findCurveValue(componentType, propertyName) {
22804
22729
  return this.curveValues[componentType + propertyName];
22805
22730
  };
22806
- _proto.getInputStream = function getInputStream(index) {
22807
- var inputPlayable = this.playable.getInput(index);
22808
- if (_instanceof1(inputPlayable, AnimationPlayable)) {
22809
- return inputPlayable.animationStream;
22810
- }
22811
- };
22812
22731
  return AnimationStream;
22813
22732
  }();
22814
22733
 
@@ -23143,266 +23062,147 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
23143
23062
  return AnimationClipPlayable;
23144
23063
  }(Playable);
23145
23064
 
23146
- /**
23147
- * @since 2.0.0
23148
- */ var TimelineClip = /*#__PURE__*/ function() {
23149
- function TimelineClip() {
23150
- this.start = 0;
23151
- this.duration = 0;
23152
- }
23153
- var _proto = TimelineClip.prototype;
23154
- _proto.toLocalTime = function toLocalTime(time) {
23155
- var localTime = time - this.start;
23156
- var duration = this.duration;
23157
- if (localTime - duration > 0) {
23158
- if (this.endBehavior === EndBehavior.restart) {
23159
- localTime = localTime % duration;
23160
- } else if (this.endBehavior === EndBehavior.freeze) {
23161
- localTime = Math.min(duration, localTime);
23162
- }
23163
- }
23164
- return localTime;
23165
- };
23166
- return TimelineClip;
23167
- }();
23168
- var TrackAsset = /*#__PURE__*/ function(PlayableAsset) {
23169
- _inherits(TrackAsset, PlayableAsset);
23170
- function TrackAsset() {
23065
+ var TrackMixerPlayable = /*#__PURE__*/ function(Playable1) {
23066
+ _inherits(TrackMixerPlayable, Playable1);
23067
+ function TrackMixerPlayable() {
23171
23068
  var _this;
23172
- _this = PlayableAsset.apply(this, arguments) || this;
23173
- _this.trackType = 0;
23174
- _this.clipSeed = 0;
23175
- _this.clips = [];
23176
- _this.children = [];
23069
+ _this = Playable1.apply(this, arguments) || this;
23070
+ _this.clipPlayables = [];
23071
+ _this.clipWeights = [];
23177
23072
  return _this;
23178
23073
  }
23179
- var _proto = TrackAsset.prototype;
23180
- /**
23181
- * 重写该方法以获取自定义对象绑定
23182
- */ _proto.updateAnimatedObject = function updateAnimatedObject() {
23183
- if (this.parent) {
23184
- this.boundObject = this.parent.boundObject;
23074
+ var _proto = TrackMixerPlayable.prototype;
23075
+ _proto.processFrame = function processFrame(context) {
23076
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.clipPlayables), _step; !(_step = _iterator()).done;){
23077
+ var clipPlayable = _step.value;
23078
+ clipPlayable.processFrame(context);
23185
23079
  }
23080
+ this.evaluate(context);
23186
23081
  };
23187
- /**
23188
- * 重写该方法以创建自定义混合器
23189
- */ _proto.createTrackMixer = function createTrackMixer(graph) {
23190
- return new Playable(graph);
23082
+ _proto.setClipWeight = function setClipWeight(playableOrIndex, weight) {
23083
+ if (_instanceof1(playableOrIndex, Playable)) {
23084
+ for(var i = 0; i < this.clipPlayables.length; i++){
23085
+ if (this.clipPlayables[i] === playableOrIndex) {
23086
+ this.clipWeights[i] = weight;
23087
+ return;
23088
+ }
23089
+ }
23090
+ } else {
23091
+ if (this.clipWeights.length < playableOrIndex + 1) {
23092
+ this.clipWeights.length = playableOrIndex + 1;
23093
+ }
23094
+ this.clipWeights[playableOrIndex] = weight;
23095
+ }
23191
23096
  };
23192
- _proto.createOutput = function createOutput() {
23193
- var output = new PlayableOutput();
23194
- return output;
23097
+ _proto.getClipWeight = function getClipWeight(inputIndex) {
23098
+ return this.clipWeights[inputIndex];
23195
23099
  };
23196
- _proto.createPlayableGraph = function createPlayableGraph(graph, runtimeClips) {
23197
- var mixerPlayable = this.createMixerPlayableGraph(graph, runtimeClips);
23198
- return mixerPlayable;
23100
+ _proto.getClipPlayable = function getClipPlayable(index) {
23101
+ return this.clipPlayables[index];
23199
23102
  };
23200
- _proto.createMixerPlayableGraph = function createMixerPlayableGraph(graph, runtimeClips) {
23201
- var clips = [];
23202
- for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
23203
- var clip = _step.value;
23204
- clips.push(clip);
23205
- }
23206
- var mixerPlayable = this.compileClips(graph, clips, runtimeClips);
23207
- return mixerPlayable;
23103
+ _proto.evaluate = function evaluate(context) {
23104
+ // Override
23208
23105
  };
23209
- _proto.compileClips = function compileClips(graph, timelineClips, runtimeClips) {
23210
- var mixer = this.createTrackMixer(graph);
23211
- for(var _iterator = _create_for_of_iterator_helper_loose(timelineClips), _step; !(_step = _iterator()).done;){
23212
- var timelineClip = _step.value;
23213
- var clipPlayable = this.createClipPlayable(graph, timelineClip);
23214
- clipPlayable.setDuration(timelineClip.duration);
23215
- var clip = new RuntimeClip(timelineClip, clipPlayable, mixer, this);
23216
- runtimeClips.push(clip);
23217
- mixer.addInput(clipPlayable, 0);
23218
- mixer.setInputWeight(clipPlayable, 0.0);
23106
+ return TrackMixerPlayable;
23107
+ }(Playable);
23108
+
23109
+ var ActivationMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23110
+ _inherits(ActivationMixerPlayable, TrackMixerPlayable);
23111
+ function ActivationMixerPlayable() {
23112
+ return TrackMixerPlayable.apply(this, arguments);
23113
+ }
23114
+ var _proto = ActivationMixerPlayable.prototype;
23115
+ _proto.evaluate = function evaluate(context) {
23116
+ var boundObject = context.output.getUserData();
23117
+ if (!_instanceof1(boundObject, VFXItem)) {
23118
+ return;
23119
+ }
23120
+ var boundItem = boundObject;
23121
+ var hasInput = false;
23122
+ for(var i = 0; i < this.clipPlayables.length; i++){
23123
+ if (this.getClipWeight(i) > 0) {
23124
+ hasInput = true;
23125
+ break;
23126
+ }
23127
+ }
23128
+ if (hasInput) {
23129
+ boundItem.transform.setValid(true);
23130
+ boundItem.setActive(true);
23131
+ } else {
23132
+ boundItem.transform.setValid(false);
23133
+ boundItem.setActive(false);
23219
23134
  }
23220
- return mixer;
23221
- };
23222
- _proto.createPlayable = function createPlayable(graph) {
23223
- return new Playable(graph);
23224
23135
  };
23225
- _proto.getChildTracks = function getChildTracks() {
23226
- return this.children;
23227
- };
23228
- _proto.addChild = function addChild(child) {
23229
- this.children.push(child);
23230
- child.parent = this;
23231
- };
23232
- _proto.createClip = function createClip(classConstructor, name) {
23233
- var newClip = new TimelineClip();
23234
- newClip.asset = new classConstructor(this.engine);
23235
- newClip.name = name ? name : "TimelineClip" + newClip.id;
23236
- this.addClip(newClip);
23237
- return newClip;
23238
- };
23239
- _proto.getClips = function getClips() {
23240
- return this.clips;
23241
- };
23242
- _proto.findClip = function findClip(name) {
23243
- for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
23244
- var clip = _step.value;
23245
- if (clip.name === name) {
23246
- return clip;
23247
- }
23248
- }
23249
- };
23250
- _proto.addClip = function addClip(clip) {
23251
- clip.id = (this.clipSeed++).toString();
23252
- this.clips.push(clip);
23253
- };
23254
- _proto.createClipPlayable = function createClipPlayable(graph, clip) {
23255
- return clip.asset.createPlayable(graph);
23256
- };
23257
- _proto.fromData = function fromData(data) {
23258
- PlayableAsset.prototype.fromData.call(this, data);
23259
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
23260
- var child = _step.value;
23261
- child.parent = this;
23262
- }
23263
- };
23264
- return TrackAsset;
23265
- }(PlayableAsset);
23266
- __decorate([
23267
- serialize(TimelineClip)
23268
- ], TrackAsset.prototype, "clips", void 0);
23269
- __decorate([
23270
- serialize()
23271
- ], TrackAsset.prototype, "children", void 0);
23272
- TrackAsset = __decorate([
23273
- effectsClass(DataType.TrackAsset)
23274
- ], TrackAsset);
23275
- var TrackType;
23276
- (function(TrackType) {
23277
- TrackType[TrackType["MasterTrack"] = 0] = "MasterTrack";
23278
- TrackType[TrackType["ObjectTrack"] = 1] = "ObjectTrack";
23279
- })(TrackType || (TrackType = {}));
23280
- var RuntimeClip = /*#__PURE__*/ function() {
23281
- function RuntimeClip(clip, clipPlayable, parentMixer, track) {
23282
- this.clip = clip;
23283
- this.playable = clipPlayable;
23284
- this.parentMixer = parentMixer;
23285
- this.track = track;
23286
- if (_instanceof1(this.track.boundObject, VFXItem)) {
23287
- this.particleSystem = this.track.boundObject.getComponent(ParticleSystem);
23288
- }
23289
- }
23290
- var _proto = RuntimeClip.prototype;
23291
- _proto.evaluateAt = function evaluateAt(localTime) {
23292
- var clip = this.clip;
23293
- var weight = 1.0;
23294
- var ended = false;
23295
- var started = false;
23296
- var boundObject = this.track.boundObject;
23297
- if (localTime >= clip.start + clip.duration && clip.endBehavior === EndBehavior.destroy) {
23298
- if (_instanceof1(boundObject, VFXItem) && VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
23299
- weight = 1.0;
23300
- } else {
23301
- weight = 0.0;
23302
- ended = true;
23303
- }
23304
- } else if (localTime - this.clip.start >= 0) {
23305
- weight = 1.0;
23306
- started = true;
23307
- } else if (localTime < clip.start) {
23308
- weight = 0.0;
23309
- }
23310
- if (started && this.playable.getPlayState() !== PlayState.Playing) {
23311
- this.playable.play();
23312
- }
23313
- this.parentMixer.setInputWeight(this.playable, weight);
23314
- var clipTime = clip.toLocalTime(localTime);
23315
- this.playable.setTime(clipTime);
23316
- // 判断动画是否结束
23317
- if (ended) {
23318
- if (this.playable.getPlayState() === PlayState.Playing) {
23319
- this.playable.pause();
23320
- }
23321
- }
23322
- };
23323
- _create_class(RuntimeClip, [
23324
- {
23325
- key: "enable",
23326
- set: function set(value) {
23327
- if (value) {
23328
- this.playable.play();
23329
- } else {
23330
- this.parentMixer.setInputWeight(this.playable, 0);
23331
- this.playable.pause();
23332
- }
23333
- }
23334
- }
23335
- ]);
23336
- return RuntimeClip;
23337
- }();
23136
+ return ActivationMixerPlayable;
23137
+ }(TrackMixerPlayable);
23338
23138
 
23339
- var ActivationMixerPlayable = /*#__PURE__*/ function(Playable) {
23340
- _inherits(ActivationMixerPlayable, Playable);
23341
- function ActivationMixerPlayable() {
23139
+ var PropertyClipPlayable = /*#__PURE__*/ function(Playable) {
23140
+ _inherits(PropertyClipPlayable, Playable);
23141
+ function PropertyClipPlayable() {
23342
23142
  return Playable.apply(this, arguments);
23343
23143
  }
23344
- var _proto = ActivationMixerPlayable.prototype;
23144
+ var _proto = PropertyClipPlayable.prototype;
23345
23145
  _proto.processFrame = function processFrame(context) {
23146
+ this.value = this.curve.getValue(this.time / this.getDuration());
23147
+ };
23148
+ return PropertyClipPlayable;
23149
+ }(Playable);
23150
+
23151
+ var ColorPropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23152
+ _inherits(ColorPropertyMixerPlayable, TrackMixerPlayable);
23153
+ function ColorPropertyMixerPlayable() {
23154
+ var _this;
23155
+ _this = TrackMixerPlayable.apply(this, arguments) || this;
23156
+ _this.propertyName = "";
23157
+ return _this;
23158
+ }
23159
+ var _proto = ColorPropertyMixerPlayable.prototype;
23160
+ _proto.evaluate = function evaluate(context) {
23346
23161
  var boundObject = context.output.getUserData();
23347
- if (!_instanceof1(boundObject, VFXItem)) {
23162
+ if (!boundObject) {
23348
23163
  return;
23349
23164
  }
23350
- var boundItem = boundObject;
23351
23165
  var hasInput = false;
23352
- for(var i = 0; i < this.getInputCount(); i++){
23353
- if (this.getInputWeight(i) > 0) {
23166
+ var value = boundObject[this.propertyName];
23167
+ if (!_instanceof1(value, Color)) {
23168
+ return;
23169
+ }
23170
+ value.setZero();
23171
+ // evaluate the curve
23172
+ for(var i = 0; i < this.clipPlayables.length; i++){
23173
+ var weight = this.getClipWeight(i);
23174
+ if (weight > 0) {
23175
+ var propertyClipPlayable = this.getClipPlayable(i);
23176
+ if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
23177
+ console.error("ColorPropertyMixerPlayable received incompatible input");
23178
+ continue;
23179
+ }
23180
+ var curveValue = propertyClipPlayable.value;
23181
+ value.r += curveValue.r * weight;
23182
+ value.g += curveValue.g * weight;
23183
+ value.b += curveValue.b * weight;
23184
+ value.a += curveValue.a * weight;
23354
23185
  hasInput = true;
23355
- break;
23356
23186
  }
23357
23187
  }
23188
+ // set value
23358
23189
  if (hasInput) {
23359
- boundItem.transform.setValid(true);
23360
- boundItem.setActive(true);
23361
- } else {
23362
- boundItem.transform.setValid(false);
23363
- boundItem.setActive(false);
23190
+ boundObject[this.propertyName] = value;
23364
23191
  }
23365
23192
  };
23366
- return ActivationMixerPlayable;
23367
- }(Playable);
23368
-
23369
- var ActivationTrack = /*#__PURE__*/ function(TrackAsset) {
23370
- _inherits(ActivationTrack, TrackAsset);
23371
- function ActivationTrack() {
23372
- return TrackAsset.apply(this, arguments);
23373
- }
23374
- var _proto = ActivationTrack.prototype;
23375
- _proto.createTrackMixer = function createTrackMixer(graph) {
23376
- return new ActivationMixerPlayable(graph);
23377
- };
23378
- return ActivationTrack;
23379
- }(TrackAsset);
23380
- ActivationTrack = __decorate([
23381
- effectsClass(DataType.ActivationTrack)
23382
- ], ActivationTrack);
23383
-
23384
- var PropertyClipPlayable = /*#__PURE__*/ function(Playable) {
23385
- _inherits(PropertyClipPlayable, Playable);
23386
- function PropertyClipPlayable() {
23387
- return Playable.apply(this, arguments);
23388
- }
23389
- var _proto = PropertyClipPlayable.prototype;
23390
- _proto.processFrame = function processFrame(context) {
23391
- this.value = this.curve.getValue(this.time / this.getDuration());
23392
- };
23393
- return PropertyClipPlayable;
23394
- }(Playable);
23193
+ return ColorPropertyMixerPlayable;
23194
+ }(TrackMixerPlayable);
23395
23195
 
23396
- var FloatPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
23397
- _inherits(FloatPropertyMixerPlayable, Playable);
23196
+ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23197
+ _inherits(FloatPropertyMixerPlayable, TrackMixerPlayable);
23398
23198
  function FloatPropertyMixerPlayable() {
23399
23199
  var _this;
23400
- _this = Playable.apply(this, arguments) || this;
23200
+ _this = TrackMixerPlayable.apply(this, arguments) || this;
23401
23201
  _this.propertyName = "";
23402
23202
  return _this;
23403
23203
  }
23404
23204
  var _proto = FloatPropertyMixerPlayable.prototype;
23405
- _proto.processFrame = function processFrame(context) {
23205
+ _proto.evaluate = function evaluate(context) {
23406
23206
  var boundObject = context.output.getUserData();
23407
23207
  if (!boundObject) {
23408
23208
  return;
@@ -23410,10 +23210,10 @@ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
23410
23210
  var hasInput = false;
23411
23211
  var value = 0;
23412
23212
  // evaluate the curve
23413
- for(var i = 0; i < this.getInputCount(); i++){
23414
- var weight = this.getInputWeight(i);
23213
+ for(var i = 0; i < this.clipPlayables.length; i++){
23214
+ var weight = this.getClipWeight(i);
23415
23215
  if (weight > 0) {
23416
- var propertyClipPlayable = this.getInput(i);
23216
+ var propertyClipPlayable = this.getClipPlayable(i);
23417
23217
  if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
23418
23218
  console.error("FloatPropertyTrack added non-FloatPropertyPlayableAsset");
23419
23219
  continue;
@@ -23429,7 +23229,27 @@ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
23429
23229
  }
23430
23230
  };
23431
23231
  return FloatPropertyMixerPlayable;
23432
- }(Playable);
23232
+ }(TrackMixerPlayable);
23233
+
23234
+ var ParticleMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23235
+ _inherits(ParticleMixerPlayable, TrackMixerPlayable);
23236
+ function ParticleMixerPlayable() {
23237
+ return TrackMixerPlayable.apply(this, arguments);
23238
+ }
23239
+ var _proto = ParticleMixerPlayable.prototype;
23240
+ _proto.evaluate = function evaluate(context) {};
23241
+ return ParticleMixerPlayable;
23242
+ }(TrackMixerPlayable);
23243
+
23244
+ var SpriteColorMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23245
+ _inherits(SpriteColorMixerPlayable, TrackMixerPlayable);
23246
+ function SpriteColorMixerPlayable() {
23247
+ return TrackMixerPlayable.apply(this, arguments);
23248
+ }
23249
+ var _proto = SpriteColorMixerPlayable.prototype;
23250
+ _proto.evaluate = function evaluate(context) {};
23251
+ return SpriteColorMixerPlayable;
23252
+ }(TrackMixerPlayable);
23433
23253
 
23434
23254
  var SerializationHelper = /*#__PURE__*/ function() {
23435
23255
  function SerializationHelper() {}
@@ -23921,7 +23741,8 @@ var SerializationHelper = /*#__PURE__*/ function() {
23921
23741
  this.timelinePlayable.setTime(time);
23922
23742
  // The properties of the object may change dynamically,
23923
23743
  // so reset the track binding to avoid invalidation of the previously obtained binding object.
23924
- this.resolveBindings();
23744
+ // this.resolveBindings();
23745
+ this.timelinePlayable.evaluate();
23925
23746
  this.graph.evaluate(dt);
23926
23747
  };
23927
23748
  _proto.createContent = function createContent() {
@@ -24100,21 +23921,21 @@ var SubCompositionClipPlayable = /*#__PURE__*/ function(Playable) {
24100
23921
  return SubCompositionClipPlayable;
24101
23922
  }(Playable);
24102
23923
 
24103
- var SubCompositionMixerPlayable = /*#__PURE__*/ function(Playable) {
24104
- _inherits(SubCompositionMixerPlayable, Playable);
23924
+ var SubCompositionMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23925
+ _inherits(SubCompositionMixerPlayable, TrackMixerPlayable);
24105
23926
  function SubCompositionMixerPlayable() {
24106
- return Playable.apply(this, arguments);
23927
+ return TrackMixerPlayable.apply(this, arguments);
24107
23928
  }
24108
23929
  var _proto = SubCompositionMixerPlayable.prototype;
24109
- _proto.processFrame = function processFrame(context) {
23930
+ _proto.evaluate = function evaluate(context) {
24110
23931
  var boundObject = context.output.getUserData();
24111
23932
  if (!_instanceof1(boundObject, CompositionComponent)) {
24112
23933
  return;
24113
23934
  }
24114
23935
  var compositionComponent = boundObject;
24115
23936
  var hasInput = false;
24116
- for(var i = 0; i < this.getInputCount(); i++){
24117
- if (this.getInputWeight(i) > 0) {
23937
+ for(var i = 0; i < this.clipPlayables.length; i++){
23938
+ if (this.getClipWeight(i) > 0) {
24118
23939
  hasInput = true;
24119
23940
  break;
24120
23941
  }
@@ -24126,18 +23947,28 @@ var SubCompositionMixerPlayable = /*#__PURE__*/ function(Playable) {
24126
23947
  }
24127
23948
  };
24128
23949
  return SubCompositionMixerPlayable;
24129
- }(Playable);
23950
+ }(TrackMixerPlayable);
23951
+
23952
+ var TransformMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23953
+ _inherits(TransformMixerPlayable, TrackMixerPlayable);
23954
+ function TransformMixerPlayable() {
23955
+ return TrackMixerPlayable.apply(this, arguments);
23956
+ }
23957
+ var _proto = TransformMixerPlayable.prototype;
23958
+ _proto.evaluate = function evaluate(context) {};
23959
+ return TransformMixerPlayable;
23960
+ }(TrackMixerPlayable);
24130
23961
 
24131
- var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24132
- _inherits(Vector4PropertyMixerPlayable, Playable);
23962
+ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23963
+ _inherits(Vector4PropertyMixerPlayable, TrackMixerPlayable);
24133
23964
  function Vector4PropertyMixerPlayable() {
24134
23965
  var _this;
24135
- _this = Playable.apply(this, arguments) || this;
23966
+ _this = TrackMixerPlayable.apply(this, arguments) || this;
24136
23967
  _this.propertyName = "";
24137
23968
  return _this;
24138
23969
  }
24139
23970
  var _proto = Vector4PropertyMixerPlayable.prototype;
24140
- _proto.processFrame = function processFrame(context) {
23971
+ _proto.evaluate = function evaluate(context) {
24141
23972
  var boundObject = context.output.getUserData();
24142
23973
  if (!boundObject) {
24143
23974
  return;
@@ -24149,10 +23980,10 @@ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24149
23980
  }
24150
23981
  value.setZero();
24151
23982
  // evaluate the curve
24152
- for(var i = 0; i < this.getInputCount(); i++){
24153
- var weight = this.getInputWeight(i);
23983
+ for(var i = 0; i < this.clipPlayables.length; i++){
23984
+ var weight = this.getClipWeight(i);
24154
23985
  if (weight > 0) {
24155
- var propertyClipPlayable = this.getInput(i);
23986
+ var propertyClipPlayable = this.getClipPlayable(i);
24156
23987
  if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
24157
23988
  console.error("Vector4PropertyTrack added non-Vector4PropertyPlayableAsset");
24158
23989
  continue;
@@ -24171,52 +24002,215 @@ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24171
24002
  }
24172
24003
  };
24173
24004
  return Vector4PropertyMixerPlayable;
24174
- }(Playable);
24005
+ }(TrackMixerPlayable);
24175
24006
 
24176
- var ColorPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24177
- _inherits(ColorPropertyMixerPlayable, Playable);
24178
- function ColorPropertyMixerPlayable() {
24007
+ /**
24008
+ * @since 2.0.0
24009
+ */ var TimelineClip = /*#__PURE__*/ function() {
24010
+ function TimelineClip() {
24011
+ this.start = 0;
24012
+ this.duration = 0;
24013
+ }
24014
+ var _proto = TimelineClip.prototype;
24015
+ _proto.toLocalTime = function toLocalTime(time) {
24016
+ var localTime = time - this.start;
24017
+ var duration = this.duration;
24018
+ if (localTime - duration > 0) {
24019
+ if (this.endBehavior === EndBehavior.restart) {
24020
+ localTime = localTime % duration;
24021
+ } else if (this.endBehavior === EndBehavior.freeze) {
24022
+ localTime = Math.min(duration, localTime);
24023
+ }
24024
+ }
24025
+ return localTime;
24026
+ };
24027
+ return TimelineClip;
24028
+ }();
24029
+ var TrackAsset = /*#__PURE__*/ function(PlayableAsset) {
24030
+ _inherits(TrackAsset, PlayableAsset);
24031
+ function TrackAsset() {
24179
24032
  var _this;
24180
- _this = Playable.apply(this, arguments) || this;
24181
- _this.propertyName = "";
24033
+ _this = PlayableAsset.apply(this, arguments) || this;
24034
+ _this.trackType = 0;
24035
+ _this.clipSeed = 0;
24036
+ _this.clips = [];
24037
+ _this.children = [];
24182
24038
  return _this;
24183
24039
  }
24184
- var _proto = ColorPropertyMixerPlayable.prototype;
24185
- _proto.processFrame = function processFrame(context) {
24186
- var boundObject = context.output.getUserData();
24187
- if (!boundObject) {
24188
- return;
24040
+ var _proto = TrackAsset.prototype;
24041
+ /**
24042
+ * 重写该方法以获取自定义对象绑定
24043
+ */ _proto.updateAnimatedObject = function updateAnimatedObject() {
24044
+ if (this.parent) {
24045
+ this.boundObject = this.parent.boundObject;
24189
24046
  }
24190
- var hasInput = false;
24191
- var value = boundObject[this.propertyName];
24192
- if (!_instanceof1(value, Color)) {
24193
- return;
24047
+ };
24048
+ /**
24049
+ * 重写该方法以创建自定义混合器
24050
+ */ _proto.createTrackMixer = function createTrackMixer(graph) {
24051
+ return new TrackMixerPlayable(graph);
24052
+ };
24053
+ _proto.createOutput = function createOutput() {
24054
+ var output = new PlayableOutput();
24055
+ return output;
24056
+ };
24057
+ _proto.createPlayableGraph = function createPlayableGraph(graph, runtimeClips) {
24058
+ var mixerPlayable = this.createMixerPlayableGraph(graph, runtimeClips);
24059
+ return mixerPlayable;
24060
+ };
24061
+ _proto.createMixerPlayableGraph = function createMixerPlayableGraph(graph, runtimeClips) {
24062
+ var clips = [];
24063
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
24064
+ var clip = _step.value;
24065
+ clips.push(clip);
24194
24066
  }
24195
- value.setZero();
24196
- // evaluate the curve
24197
- for(var i = 0; i < this.getInputCount(); i++){
24198
- var weight = this.getInputWeight(i);
24199
- if (weight > 0) {
24200
- var propertyClipPlayable = this.getInput(i);
24201
- if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
24202
- console.error("ColorPropertyMixerPlayable received incompatible input");
24203
- continue;
24204
- }
24205
- var curveValue = propertyClipPlayable.value;
24206
- value.r += curveValue.r * weight;
24207
- value.g += curveValue.g * weight;
24208
- value.b += curveValue.b * weight;
24209
- value.a += curveValue.a * weight;
24210
- hasInput = true;
24067
+ var mixerPlayable = this.compileClips(graph, clips, runtimeClips);
24068
+ return mixerPlayable;
24069
+ };
24070
+ _proto.compileClips = function compileClips(graph, timelineClips, runtimeClips) {
24071
+ var mixer = this.createTrackMixer(graph);
24072
+ for(var _iterator = _create_for_of_iterator_helper_loose(timelineClips), _step; !(_step = _iterator()).done;){
24073
+ var timelineClip = _step.value;
24074
+ var clipPlayable = this.createClipPlayable(graph, timelineClip);
24075
+ clipPlayable.setDuration(timelineClip.duration);
24076
+ var clip = new RuntimeClip(timelineClip, clipPlayable, mixer, this);
24077
+ runtimeClips.push(clip);
24078
+ mixer.clipPlayables.push(clipPlayable);
24079
+ mixer.setClipWeight(clipPlayable, 0.0);
24080
+ }
24081
+ return mixer;
24082
+ };
24083
+ _proto.createPlayable = function createPlayable(graph) {
24084
+ return new Playable(graph);
24085
+ };
24086
+ _proto.getChildTracks = function getChildTracks() {
24087
+ return this.children;
24088
+ };
24089
+ _proto.addChild = function addChild(child) {
24090
+ this.children.push(child);
24091
+ child.parent = this;
24092
+ };
24093
+ _proto.createClip = function createClip(classConstructor, name) {
24094
+ var newClip = new TimelineClip();
24095
+ newClip.asset = new classConstructor(this.engine);
24096
+ newClip.name = name ? name : "TimelineClip" + newClip.id;
24097
+ this.addClip(newClip);
24098
+ return newClip;
24099
+ };
24100
+ _proto.getClips = function getClips() {
24101
+ return this.clips;
24102
+ };
24103
+ _proto.findClip = function findClip(name) {
24104
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
24105
+ var clip = _step.value;
24106
+ if (clip.name === name) {
24107
+ return clip;
24211
24108
  }
24212
24109
  }
24213
- // set value
24214
- if (hasInput) {
24215
- boundObject[this.propertyName] = value;
24110
+ };
24111
+ _proto.addClip = function addClip(clip) {
24112
+ clip.id = (this.clipSeed++).toString();
24113
+ this.clips.push(clip);
24114
+ };
24115
+ _proto.createClipPlayable = function createClipPlayable(graph, clip) {
24116
+ return clip.asset.createPlayable(graph);
24117
+ };
24118
+ _proto.fromData = function fromData(data) {
24119
+ PlayableAsset.prototype.fromData.call(this, data);
24120
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
24121
+ var child = _step.value;
24122
+ child.parent = this;
24216
24123
  }
24217
24124
  };
24218
- return ColorPropertyMixerPlayable;
24219
- }(Playable);
24125
+ return TrackAsset;
24126
+ }(PlayableAsset);
24127
+ __decorate([
24128
+ serialize(TimelineClip)
24129
+ ], TrackAsset.prototype, "clips", void 0);
24130
+ __decorate([
24131
+ serialize()
24132
+ ], TrackAsset.prototype, "children", void 0);
24133
+ TrackAsset = __decorate([
24134
+ effectsClass(DataType.TrackAsset)
24135
+ ], TrackAsset);
24136
+ var TrackType;
24137
+ (function(TrackType) {
24138
+ TrackType[TrackType["MasterTrack"] = 0] = "MasterTrack";
24139
+ TrackType[TrackType["ObjectTrack"] = 1] = "ObjectTrack";
24140
+ })(TrackType || (TrackType = {}));
24141
+ var RuntimeClip = /*#__PURE__*/ function() {
24142
+ function RuntimeClip(clip, clipPlayable, parentMixer, track) {
24143
+ this.clip = clip;
24144
+ this.playable = clipPlayable;
24145
+ this.parentMixer = parentMixer;
24146
+ this.track = track;
24147
+ if (_instanceof1(this.track.boundObject, VFXItem)) {
24148
+ this.particleSystem = this.track.boundObject.getComponent(ParticleSystem);
24149
+ }
24150
+ }
24151
+ var _proto = RuntimeClip.prototype;
24152
+ _proto.evaluateAt = function evaluateAt(localTime) {
24153
+ var clip = this.clip;
24154
+ var weight = 1.0;
24155
+ var ended = false;
24156
+ var started = false;
24157
+ var boundObject = this.track.boundObject;
24158
+ if (localTime >= clip.start + clip.duration && clip.endBehavior === EndBehavior.destroy) {
24159
+ if (_instanceof1(boundObject, VFXItem) && VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
24160
+ weight = 1.0;
24161
+ } else {
24162
+ weight = 0.0;
24163
+ ended = true;
24164
+ }
24165
+ } else if (localTime - this.clip.start >= 0) {
24166
+ weight = 1.0;
24167
+ started = true;
24168
+ } else if (localTime < clip.start) {
24169
+ weight = 0.0;
24170
+ }
24171
+ if (started && this.playable.getPlayState() !== PlayState.Playing) {
24172
+ this.playable.play();
24173
+ }
24174
+ this.parentMixer.setClipWeight(this.playable, weight);
24175
+ var clipTime = parseFloat(clip.toLocalTime(localTime).toFixed(3));
24176
+ this.playable.setTime(clipTime);
24177
+ // 判断动画是否结束
24178
+ if (ended) {
24179
+ if (this.playable.getPlayState() === PlayState.Playing) {
24180
+ this.playable.pause();
24181
+ }
24182
+ }
24183
+ };
24184
+ _create_class(RuntimeClip, [
24185
+ {
24186
+ key: "enable",
24187
+ set: function set(value) {
24188
+ if (value) {
24189
+ this.playable.play();
24190
+ } else {
24191
+ this.parentMixer.setClipWeight(this.playable, 0);
24192
+ this.playable.pause();
24193
+ }
24194
+ }
24195
+ }
24196
+ ]);
24197
+ return RuntimeClip;
24198
+ }();
24199
+
24200
+ var ActivationTrack = /*#__PURE__*/ function(TrackAsset) {
24201
+ _inherits(ActivationTrack, TrackAsset);
24202
+ function ActivationTrack() {
24203
+ return TrackAsset.apply(this, arguments);
24204
+ }
24205
+ var _proto = ActivationTrack.prototype;
24206
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24207
+ return new ActivationMixerPlayable(graph);
24208
+ };
24209
+ return ActivationTrack;
24210
+ }(TrackAsset);
24211
+ ActivationTrack = __decorate([
24212
+ effectsClass(DataType.ActivationTrack)
24213
+ ], ActivationTrack);
24220
24214
 
24221
24215
  var PropertyTrack = /*#__PURE__*/ function(TrackAsset) {
24222
24216
  _inherits(PropertyTrack, TrackAsset);
@@ -24289,6 +24283,10 @@ var SpriteColorTrack = /*#__PURE__*/ function(TrackAsset) {
24289
24283
  function SpriteColorTrack() {
24290
24284
  return TrackAsset.apply(this, arguments);
24291
24285
  }
24286
+ var _proto = SpriteColorTrack.prototype;
24287
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24288
+ return new SpriteColorMixerPlayable(graph);
24289
+ };
24292
24290
  return SpriteColorTrack;
24293
24291
  }(TrackAsset);
24294
24292
  SpriteColorTrack = __decorate([
@@ -24321,6 +24319,10 @@ var TransformTrack = /*#__PURE__*/ function(TrackAsset) {
24321
24319
  function TransformTrack() {
24322
24320
  return TrackAsset.apply(this, arguments);
24323
24321
  }
24322
+ var _proto = TransformTrack.prototype;
24323
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24324
+ return new TransformMixerPlayable(graph);
24325
+ };
24324
24326
  return TransformTrack;
24325
24327
  }(TrackAsset);
24326
24328
  TransformTrack = __decorate([
@@ -24349,6 +24351,18 @@ MaterialTrack = __decorate([
24349
24351
  effectsClass("MaterialTrack")
24350
24352
  ], MaterialTrack);
24351
24353
 
24354
+ var ParticleTrack = /*#__PURE__*/ function(TrackAsset) {
24355
+ _inherits(ParticleTrack, TrackAsset);
24356
+ function ParticleTrack() {
24357
+ return TrackAsset.apply(this, arguments);
24358
+ }
24359
+ var _proto = ParticleTrack.prototype;
24360
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24361
+ return new ParticleMixerPlayable(graph);
24362
+ };
24363
+ return ParticleTrack;
24364
+ }(TrackAsset);
24365
+
24352
24366
  var Vector4PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
24353
24367
  _inherits(Vector4PropertyTrack, PropertyTrack);
24354
24368
  function Vector4PropertyTrack() {
@@ -24477,7 +24491,6 @@ var TimelineAsset = /*#__PURE__*/ function(PlayableAsset) {
24477
24491
  var _proto = TimelineAsset.prototype;
24478
24492
  _proto.createPlayable = function createPlayable(graph) {
24479
24493
  var timelinePlayable = new TimelinePlayable(graph);
24480
- timelinePlayable.setTraversalMode(PlayableTraversalMode.Passthrough);
24481
24494
  for(var _iterator = _create_for_of_iterator_helper_loose(this.tracks), _step; !(_step = _iterator()).done;){
24482
24495
  var track = _step.value;
24483
24496
  if (_instanceof1(track, ObjectBindingTrack)) {
@@ -24558,9 +24571,7 @@ var TimelinePlayable = /*#__PURE__*/ function(Playable) {
24558
24571
  return _this;
24559
24572
  }
24560
24573
  var _proto = TimelinePlayable.prototype;
24561
- _proto.prepareFrame = function prepareFrame(context) {
24562
- this.evaluate();
24563
- };
24574
+ _proto.prepareFrame = function prepareFrame(context) {};
24564
24575
  _proto.evaluate = function evaluate() {
24565
24576
  var time = this.getTime();
24566
24577
  // TODO search active clips
@@ -24577,11 +24588,10 @@ var TimelinePlayable = /*#__PURE__*/ function(Playable) {
24577
24588
  var track = _step.value;
24578
24589
  // create track mixer and track output
24579
24590
  var trackMixPlayable = track.createPlayableGraph(graph, this.clips);
24580
- this.addInput(trackMixPlayable, 0);
24581
24591
  var trackOutput = track.createOutput();
24582
24592
  trackOutput.setUserData(track.boundObject);
24583
24593
  graph.addOutput(trackOutput);
24584
- trackOutput.setSourcePlayable(this, this.getInputCount() - 1);
24594
+ trackOutput.setSourcePlayable(trackMixPlayable);
24585
24595
  // create track instance
24586
24596
  var trackInstance = new TrackInstance(track, trackMixPlayable, trackOutput);
24587
24597
  trackInstanceMap[track.getInstanceId()] = trackInstance;
@@ -24642,10 +24652,10 @@ Vector4PropertyPlayableAsset = __decorate([
24642
24652
  effectsClass("Vector4PropertyPlayableAsset")
24643
24653
  ], Vector4PropertyPlayableAsset);
24644
24654
 
24645
- var ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
24646
- _inherits(ObjectBindingTrack, TrackAsset1);
24655
+ var ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset) {
24656
+ _inherits(ObjectBindingTrack, TrackAsset);
24647
24657
  function ObjectBindingTrack() {
24648
- return TrackAsset1.apply(this, arguments);
24658
+ return TrackAsset.apply(this, arguments);
24649
24659
  }
24650
24660
  var _proto = ObjectBindingTrack.prototype;
24651
24661
  _proto.updateAnimatedObject = function updateAnimatedObject() {};
@@ -24656,7 +24666,7 @@ var ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
24656
24666
  var boundItem = this.boundObject;
24657
24667
  // 添加粒子动画 clip // TODO 待移除
24658
24668
  if (boundItem.getComponent(ParticleSystem)) {
24659
- var particleTrack = timelineAsset.createTrack(TrackAsset, this, "ParticleTrack");
24669
+ var particleTrack = timelineAsset.createTrack(ParticleTrack, this, "ParticleTrack");
24660
24670
  particleTrack.boundObject = this.boundObject;
24661
24671
  var particleClip = particleTrack.createClip(ParticleBehaviourPlayableAsset);
24662
24672
  particleClip.start = boundItem.start;
@@ -24686,7 +24696,7 @@ var TextLayout = /*#__PURE__*/ function() {
24686
24696
  this.width = textWidth;
24687
24697
  this.height = textHeight;
24688
24698
  this.letterSpace = letterSpace;
24689
- this.overFlow = textOverflow;
24699
+ this.overflow = textOverflow;
24690
24700
  this.textBaseline = textBaseline;
24691
24701
  this.textAlign = textAlign;
24692
24702
  this.lineHeight = lineHeight;
@@ -27301,6 +27311,7 @@ var seed = 1;
27301
27311
  this.downloader = downloader;
27302
27312
  this.assets = {};
27303
27313
  this.sourceFrom = {};
27314
+ this.imageBitmapOptions = {};
27304
27315
  this.id = seed++;
27305
27316
  this.timers = [];
27306
27317
  this.updateOptions(options);
@@ -27558,12 +27569,12 @@ var seed = 1;
27558
27569
  _proto.processJSON = function processJSON(json) {
27559
27570
  var _this = this;
27560
27571
  return _async_to_generator(function() {
27561
- var jsonScene, _jsonScene_plugins, plugins, pluginSystem;
27572
+ var jsonScene, _jsonScene_plugins, plugins, textures, pluginSystem;
27562
27573
  return __generator(this, function(_state) {
27563
27574
  switch(_state.label){
27564
27575
  case 0:
27565
27576
  jsonScene = getStandardJSON(json);
27566
- _jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins;
27577
+ _jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins, textures = jsonScene.textures;
27567
27578
  pluginSystem = new PluginSystem(plugins);
27568
27579
  return [
27569
27580
  4,
@@ -27571,6 +27582,7 @@ var seed = 1;
27571
27582
  ];
27572
27583
  case 1:
27573
27584
  _state.sent();
27585
+ _this.assignImageBitmapOptions(textures);
27574
27586
  return [
27575
27587
  2,
27576
27588
  {
@@ -27676,11 +27688,11 @@ var seed = 1;
27676
27688
  if (compressedTexture === void 0) compressedTexture = 0;
27677
27689
  var _this = this;
27678
27690
  return _async_to_generator(function() {
27679
- var _this_options, useCompressedTexture, variables, baseUrl, jobs, loadedImages;
27691
+ var _this_options, useCompressedTexture, variables, disableWebP, disableAVIF, baseUrl, jobs, loadedImages;
27680
27692
  return __generator(this, function(_state) {
27681
27693
  switch(_state.label){
27682
27694
  case 0:
27683
- _this_options = _this.options, useCompressedTexture = _this_options.useCompressedTexture, variables = _this_options.variables;
27695
+ _this_options = _this.options, useCompressedTexture = _this_options.useCompressedTexture, variables = _this_options.variables, disableWebP = _this_options.disableWebP, disableAVIF = _this_options.disableAVIF;
27684
27696
  baseUrl = _this.baseUrl;
27685
27697
  jobs = images.map(/*#__PURE__*/ _async_to_generator(function(img, idx) {
27686
27698
  var png, webp, avif, imageURL, webpURL, avifURL, id, template, background, url, isVideo, loadFn, resultImage, e, compressed, src, bufferURL, _ref, url1, image, _tmp;
@@ -27691,9 +27703,9 @@ var seed = 1;
27691
27703
  // eslint-disable-next-line compat/compat
27692
27704
  imageURL = new URL(png, baseUrl).href;
27693
27705
  // eslint-disable-next-line compat/compat
27694
- webpURL = webp && new URL(webp, baseUrl).href;
27706
+ webpURL = !disableWebP && webp ? new URL(webp, baseUrl).href : undefined;
27695
27707
  // eslint-disable-next-line compat/compat
27696
- avifURL = avif && new URL(avif, baseUrl).href;
27708
+ avifURL = !disableAVIF && avif ? new URL(avif, baseUrl).href : undefined;
27697
27709
  id = img.id;
27698
27710
  if (!("template" in img)) return [
27699
27711
  3,
@@ -27802,7 +27814,7 @@ var seed = 1;
27802
27814
  ];
27803
27815
  return [
27804
27816
  4,
27805
- loadAVIFOptional(imageURL, avifURL)
27817
+ loadAVIFOptional(imageURL, avifURL, _this.imageBitmapOptions[id])
27806
27818
  ];
27807
27819
  case 10:
27808
27820
  _tmp = _state.sent();
@@ -27813,7 +27825,7 @@ var seed = 1;
27813
27825
  case 11:
27814
27826
  return [
27815
27827
  4,
27816
- loadWebPOptional(imageURL, webpURL)
27828
+ loadWebPOptional(imageURL, webpURL, _this.imageBitmapOptions[id])
27817
27829
  ];
27818
27830
  case 12:
27819
27831
  _tmp = _state.sent();
@@ -28025,6 +28037,21 @@ var seed = 1;
28025
28037
  this.assets[images[i].id] = loadedImages[i];
28026
28038
  }
28027
28039
  };
28040
+ _proto.assignImageBitmapOptions = function assignImageBitmapOptions(textures) {
28041
+ var _this = this;
28042
+ if (textures === void 0) textures = [];
28043
+ textures.forEach(function(texture) {
28044
+ if (!(_instanceof1(texture, Texture) || "mipmaps" in texture)) {
28045
+ var source = texture.source;
28046
+ if (isObject(source)) {
28047
+ _this.imageBitmapOptions[source.id] = {
28048
+ imageOrientation: texture.flipY ? "flipY" : "none",
28049
+ premultiplyAlpha: texture.premultiplyAlpha ? "premultiply" : "none"
28050
+ };
28051
+ }
28052
+ }
28053
+ });
28054
+ };
28028
28055
  _proto.removeTimer = function removeTimer(id) {
28029
28056
  var index = this.timers.indexOf(id);
28030
28057
  if (index !== -1) {
@@ -28034,11 +28061,15 @@ var seed = 1;
28034
28061
  /**
28035
28062
  * 销毁方法
28036
28063
  */ _proto.dispose = function dispose() {
28064
+ var _this = this;
28037
28065
  if (this.timers.length) {
28038
28066
  this.timers.map(function(id) {
28039
28067
  return window.clearTimeout(id);
28040
28068
  });
28041
28069
  }
28070
+ closeImageBitMap(Object.keys(this.assets).map(function(key) {
28071
+ return _this.assets[key];
28072
+ }));
28042
28073
  this.assets = {};
28043
28074
  this.sourceFrom = {};
28044
28075
  this.timers = [];
@@ -28055,7 +28086,7 @@ function createTextureOptionsBySource(image, sourceFrom, id) {
28055
28086
  };
28056
28087
  if (_instanceof1(image, Texture)) {
28057
28088
  return _extends({}, image.source, options);
28058
- } else if (_instanceof1(image, HTMLImageElement) || isCanvas(image)) {
28089
+ } else if (_instanceof1(image, HTMLImageElement) || _instanceof1(image, ImageBitmap) || isCanvas(image)) {
28059
28090
  return _extends({
28060
28091
  image: image,
28061
28092
  sourceType: TextureSourceType.image,
@@ -28911,7 +28942,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
28911
28942
  if (!this.assigned || this.paused) {
28912
28943
  return;
28913
28944
  }
28914
- var dt = this.getUpdateTime(deltaTime * this.speed);
28945
+ var dt = parseFloat(this.getUpdateTime(deltaTime * this.speed).toFixed(0));
28915
28946
  this.updateRootComposition(dt / 1000);
28916
28947
  this.updateVideo();
28917
28948
  // 更新 model-tree-plugin
@@ -31388,8 +31419,8 @@ registerPlugin("sprite", SpriteLoader, VFXItem, true);
31388
31419
  registerPlugin("particle", ParticleLoader, VFXItem, true);
31389
31420
  registerPlugin("cal", CalculateLoader, VFXItem, true);
31390
31421
  registerPlugin("interact", InteractLoader, VFXItem, true);
31391
- var version = "2.1.5-alpha.0";
31422
+ var version = "2.2.0-alpha.0";
31392
31423
  logger.info("Core version: " + version + ".");
31393
31424
 
31394
- export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, Asset, AssetLoader, AssetManager, BYTES_TYPE_MAP, BaseRenderComponent, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, ColorCurve, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, DEFAULT_FPS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Engine, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatPropertyPlayableAsset, FloatPropertyTrack, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, MaterialTrack, Mesh, MeshCollider, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, PropertyTrack, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, Vector4Curve, Vector4PropertyPlayableAsset, Vector4PropertyTrack, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, decimalEqual, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
31425
+ export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, Asset, AssetLoader, AssetManager, BYTES_TYPE_MAP, BaseRenderComponent, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, ColorCurve, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, DEFAULT_FPS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Engine, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatPropertyPlayableAsset, FloatPropertyTrack, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LOAD_PREFER_IMAGE_BITMAP, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, MaterialTrack, Mesh, MeshCollider, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, PropertyTrack, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, Vector4Curve, Vector4PropertyPlayableAsset, Vector4PropertyTrack, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, closeImageBitMap, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, decimalEqual, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadImageBitmap, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
31395
31426
  //# sourceMappingURL=index.mjs.map