@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.js 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
  'use strict';
@@ -63,12 +63,8 @@ function __generator(thisArg, body) {
63
63
  },
64
64
  trys: [],
65
65
  ops: []
66
- }, f, y, t, g;
67
- return g = {
68
- next: verb(0),
69
- "throw": verb(1),
70
- "return": verb(2)
71
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
66
+ }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
67
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
72
68
  return this;
73
69
  }), g;
74
70
  function verb(n) {
@@ -5725,6 +5721,22 @@ exports.TextureSourceType = void 0;
5725
5721
  TextureSourceType[TextureSourceType["mipmaps"] = 7] = "mipmaps";
5726
5722
  })(exports.TextureSourceType || (exports.TextureSourceType = {}));
5727
5723
 
5724
+ var RUNTIME_ENV = "runtime_env";
5725
+ var RENDER_PREFER_LOOKUP_TEXTURE = "lookup_texture";
5726
+ // 文本元素使用 offscreen canvas 绘制
5727
+ var TEMPLATE_USE_OFFSCREEN_CANVAS = "offscreen_canvas";
5728
+ // 后处理配置相关
5729
+ var POST_PROCESS_SETTINGS = "post_process_settings";
5730
+ // 加载图片时是否使用 ImageBitmap
5731
+ var LOAD_PREFER_IMAGE_BITMAP = "load_image_bitmap";
5732
+ var config = {};
5733
+ function getConfig(name) {
5734
+ return config[name];
5735
+ }
5736
+ function setConfig(name, value) {
5737
+ return config[name] = value;
5738
+ }
5739
+
5728
5740
  /**
5729
5741
  * 负责下载各种资源,并提供了一些异步加载和缓存管理的功能
5730
5742
  */ var Downloader = /*#__PURE__*/ function() {
@@ -5813,11 +5825,11 @@ var avifFailed = false;
5813
5825
  * 异步加载一个 WebP 图片文件,如果不支持 WebP,则加载 PNG 图片文件
5814
5826
  * @param png - PNG 图片文件的 URL
5815
5827
  * @param webp - WebP 图片文件的 URL
5816
- */ function loadWebPOptional(png, webp) {
5828
+ */ function loadWebPOptional(png, webp, options) {
5817
5829
  return _loadWebPOptional.apply(this, arguments);
5818
5830
  }
5819
5831
  function _loadWebPOptional() {
5820
- _loadWebPOptional = _async_to_generator(function(png, webp) {
5832
+ _loadWebPOptional = _async_to_generator(function(png, webp, options) {
5821
5833
  var image, image1, image2;
5822
5834
  return __generator(this, function(_state) {
5823
5835
  switch(_state.label){
@@ -5828,7 +5840,7 @@ function _loadWebPOptional() {
5828
5840
  ];
5829
5841
  return [
5830
5842
  4,
5831
- loadImage(png)
5843
+ loadImageBitmap(png, options)
5832
5844
  ];
5833
5845
  case 1:
5834
5846
  image = _state.sent();
@@ -5848,7 +5860,7 @@ function _loadWebPOptional() {
5848
5860
  ]);
5849
5861
  return [
5850
5862
  4,
5851
- loadImage(webp)
5863
+ loadImageBitmap(webp, options)
5852
5864
  ];
5853
5865
  case 3:
5854
5866
  image1 = _state.sent();
@@ -5864,7 +5876,7 @@ function _loadWebPOptional() {
5864
5876
  webPFailed = true;
5865
5877
  return [
5866
5878
  4,
5867
- loadImage(png)
5879
+ loadImageBitmap(png, options)
5868
5880
  ];
5869
5881
  case 5:
5870
5882
  image2 = _state.sent();
@@ -5888,11 +5900,11 @@ function _loadWebPOptional() {
5888
5900
  * 异步加载一个 AVIF 图片文件,如果不支持 AVIF,则加载 PNG 图片文件
5889
5901
  * @param png - PNG 图片文件的 URL
5890
5902
  * @param avif - AVIF 图片文件的 URL
5891
- */ function loadAVIFOptional(png, avif) {
5903
+ */ function loadAVIFOptional(png, avif, options) {
5892
5904
  return _loadAVIFOptional.apply(this, arguments);
5893
5905
  }
5894
5906
  function _loadAVIFOptional() {
5895
- _loadAVIFOptional = _async_to_generator(function(png, avif) {
5907
+ _loadAVIFOptional = _async_to_generator(function(png, avif, options) {
5896
5908
  var image, image1, image2;
5897
5909
  return __generator(this, function(_state) {
5898
5910
  switch(_state.label){
@@ -5903,7 +5915,7 @@ function _loadAVIFOptional() {
5903
5915
  ];
5904
5916
  return [
5905
5917
  4,
5906
- loadImage(png)
5918
+ loadImageBitmap(png, options)
5907
5919
  ];
5908
5920
  case 1:
5909
5921
  image = _state.sent();
@@ -5923,7 +5935,7 @@ function _loadAVIFOptional() {
5923
5935
  ]);
5924
5936
  return [
5925
5937
  4,
5926
- loadImage(avif)
5938
+ loadImageBitmap(avif, options)
5927
5939
  ];
5928
5940
  case 3:
5929
5941
  image1 = _state.sent();
@@ -5939,7 +5951,7 @@ function _loadAVIFOptional() {
5939
5951
  avifFailed = true;
5940
5952
  return [
5941
5953
  4,
5942
- loadImage(png)
5954
+ loadImageBitmap(png, options)
5943
5955
  ];
5944
5956
  case 5:
5945
5957
  image2 = _state.sent();
@@ -6154,6 +6166,80 @@ function _loadMedia() {
6154
6166
  });
6155
6167
  return _loadMedia.apply(this, arguments);
6156
6168
  }
6169
+ var imageBitMapAvailable = typeof createImageBitmap === "function";
6170
+ /**
6171
+ * 异步加载一个图片文件,如果支持 ImageBitmap 则返回 ImageBitmap 对象
6172
+ * @param source
6173
+ * @param options
6174
+ * @returns
6175
+ */ function loadImageBitmap(source, options) {
6176
+ return _loadImageBitmap.apply(this, arguments);
6177
+ }
6178
+ function _loadImageBitmap() {
6179
+ _loadImageBitmap = _async_to_generator(function(source, options) {
6180
+ var blob;
6181
+ return __generator(this, function(_state) {
6182
+ switch(_state.label){
6183
+ case 0:
6184
+ if (!(imageBitMapAvailable && getConfig(LOAD_PREFER_IMAGE_BITMAP))) return [
6185
+ 3,
6186
+ 4
6187
+ ];
6188
+ if (!(typeof source === "string")) return [
6189
+ 3,
6190
+ 2
6191
+ ];
6192
+ return [
6193
+ 4,
6194
+ loadBlob(source)
6195
+ ];
6196
+ case 1:
6197
+ blob = _state.sent();
6198
+ return [
6199
+ 3,
6200
+ 3
6201
+ ];
6202
+ case 2:
6203
+ if (_instanceof1(source, Blob)) {
6204
+ blob = source;
6205
+ } else {
6206
+ return [
6207
+ 2,
6208
+ loadImage(source)
6209
+ ];
6210
+ }
6211
+ _state.label = 3;
6212
+ case 3:
6213
+ return [
6214
+ 2,
6215
+ createImageBitmap(blob, options)
6216
+ ];
6217
+ case 4:
6218
+ return [
6219
+ 2,
6220
+ loadImage(source)
6221
+ ];
6222
+ case 5:
6223
+ return [
6224
+ 2
6225
+ ];
6226
+ }
6227
+ });
6228
+ });
6229
+ return _loadImageBitmap.apply(this, arguments);
6230
+ }
6231
+ /**
6232
+ * 关闭 ImageBitMap,释放内存
6233
+ * @param imgs
6234
+ */ function closeImageBitMap(imgs) {
6235
+ if (imageBitMapAvailable) {
6236
+ if (_instanceof1(imgs, ImageBitmap)) {
6237
+ imgs.close();
6238
+ } else if (_instanceof1(imgs, Array)) {
6239
+ imgs.forEach(closeImageBitMap);
6240
+ }
6241
+ }
6242
+ }
6157
6243
 
6158
6244
  function deserializeMipmapTexture(textureOptions, bins, assets) {
6159
6245
  return _deserializeMipmapTexture.apply(this, arguments);
@@ -12756,8 +12842,8 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
12756
12842
  return data;
12757
12843
  };
12758
12844
  _proto.getMaxTime = function getMaxTime() {
12759
- var keyTimeData = Object.keys(this.curveMap);
12760
- return Number(keyTimeData[keyTimeData.length - 1].split("&")[1]);
12845
+ var keyTimeData = this.keyTimeData;
12846
+ return this.curveMap[keyTimeData[keyTimeData.length - 1]].timeEnd;
12761
12847
  };
12762
12848
  return BezierCurve;
12763
12849
  }(ValueGetter);
@@ -12835,19 +12921,22 @@ var BezierCurvePath = /*#__PURE__*/ function(ValueGetter) {
12835
12921
  timeInterval: timeInterval,
12836
12922
  valueInterval: valueInterval,
12837
12923
  easingCurve: easingCurve,
12838
- pathCurve: pathCurve
12924
+ pathCurve: pathCurve,
12925
+ timeStart: Number(s.x),
12926
+ timeEnd: Number(e.x)
12839
12927
  };
12840
12928
  }
12929
+ this.keyTimeData = Object.keys(this.curveSegments);
12841
12930
  };
12842
12931
  _proto.getValue = function getValue(time) {
12843
12932
  var t = numberToFix(time, 5);
12844
12933
  var perc = 0, point = new Vector3();
12845
- var keyTimeData = Object.keys(this.curveSegments);
12934
+ var keyTimeData = this.keyTimeData;
12846
12935
  if (!keyTimeData.length) {
12847
12936
  return point;
12848
12937
  }
12849
- var keyTimeStart = Number(keyTimeData[0].split("&")[0]);
12850
- var keyTimeEnd = Number(keyTimeData[keyTimeData.length - 1].split("&")[1]);
12938
+ var keyTimeStart = this.curveSegments[keyTimeData[0]].timeStart;
12939
+ var keyTimeEnd = this.curveSegments[keyTimeData[keyTimeData.length - 1]].timeEnd;
12851
12940
  if (t <= keyTimeStart) {
12852
12941
  var pathCurve = this.curveSegments[keyTimeData[0]].pathCurve;
12853
12942
  point = pathCurve.getPointInPercent(0);
@@ -12859,7 +12948,8 @@ var BezierCurvePath = /*#__PURE__*/ function(ValueGetter) {
12859
12948
  return point;
12860
12949
  }
12861
12950
  for(var i = 0; i < keyTimeData.length; i++){
12862
- var _keyTimeData_i_split = keyTimeData[i].split("&"), xMin = _keyTimeData_i_split[0], xMax = _keyTimeData_i_split[1];
12951
+ var xMin = this.curveSegments[keyTimeData[i]].timeStart;
12952
+ var xMax = this.curveSegments[keyTimeData[i]].timeEnd;
12863
12953
  if (t >= Number(xMin) && t < Number(xMax)) {
12864
12954
  var bezierPath = this.curveSegments[keyTimeData[i]].pathCurve;
12865
12955
  perc = this.getPercValue(keyTimeData[i], t);
@@ -12878,8 +12968,8 @@ var BezierCurvePath = /*#__PURE__*/ function(ValueGetter) {
12878
12968
  return clamp$1(value, 0, 1);
12879
12969
  };
12880
12970
  _proto.getMaxTime = function getMaxTime() {
12881
- var keyTimeData = Object.keys(this.curveSegments);
12882
- return Number(keyTimeData[keyTimeData.length - 1].split("&")[1]);
12971
+ var keyTimeData = this.keyTimeData;
12972
+ return this.curveSegments[keyTimeData[keyTimeData.length - 1]].timeEnd;
12883
12973
  };
12884
12974
  return BezierCurvePath;
12885
12975
  }(ValueGetter);
@@ -13032,15 +13122,18 @@ function createKeyFrameMeta() {
13032
13122
  }
13033
13123
 
13034
13124
  function _is_native_reflect_construct() {
13035
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
13036
- if (Reflect.construct.sham) return false;
13037
- if (typeof Proxy === "function") return true;
13125
+ // Since Reflect.construct can't be properly polyfilled, some
13126
+ // implementations (e.g. core-js@2) don't set the correct internal slots.
13127
+ // Those polyfills don't allow us to subclass built-ins, so we need to
13128
+ // use our fallback implementation.
13038
13129
  try {
13039
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
13040
- return true;
13041
- } catch (e) {
13042
- return false;
13043
- }
13130
+ // If the internal slots aren't set, this throws an error similar to
13131
+ // TypeError: this is not a Boolean object.
13132
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
13133
+ } catch (_) {}
13134
+ return (_is_native_reflect_construct = function _is_native_reflect_construct() {
13135
+ return !!result;
13136
+ })();
13044
13137
  }
13045
13138
 
13046
13139
  function _construct(Parent, args, Class) {
@@ -15904,6 +15997,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15904
15997
  if (this.animated) {
15905
15998
  this.buildPath(this.data);
15906
15999
  this.buildGeometryFromPath(this.path.shapePath);
16000
+ this.animated = false;
15907
16001
  }
15908
16002
  };
15909
16003
  _proto.buildGeometryFromPath = function buildGeometryFromPath(shapePath) {
@@ -16582,17 +16676,10 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
16582
16676
  ];
16583
16677
  };
16584
16678
  _proto.onStart = function onStart() {
16585
- var _this = this;
16586
- var _this_item_composition;
16587
16679
  var options = this.item.props.content.options;
16588
16680
  var env = this.item.engine.renderer.env;
16589
16681
  var composition = this.item.composition;
16590
16682
  var _this_interactData_options = this.interactData.options, type = _this_interactData_options.type, showPreview = _this_interactData_options.showPreview;
16591
- (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.on("goto", function() {
16592
- if (_this.item.time > 0) {
16593
- _this.duringPlay = true;
16594
- }
16595
- });
16596
16683
  if (type === InteractType.CLICK) {
16597
16684
  this.clickable = true;
16598
16685
  if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
@@ -16633,12 +16720,12 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
16633
16720
  };
16634
16721
  _proto.onUpdate = function onUpdate(dt) {
16635
16722
  var _this_previewContent;
16723
+ this.duringPlay = true;
16636
16724
  // trigger messageBegin when item enter
16637
- if (this.item.time > 0 && !this.duringPlay) {
16725
+ if (this.item.time > 0 && this.item.time - dt / 1000 <= 0) {
16638
16726
  var _this_item_composition;
16639
16727
  var options = this.item.props.content.options;
16640
16728
  (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.addInteractiveItem(this.item, options.type);
16641
- this.duringPlay = true;
16642
16729
  }
16643
16730
  (_this_previewContent = this.previewContent) == null ? void 0 : _this_previewContent.updateMesh();
16644
16731
  if (!this.dragEvent || !this.bouncingArg) {
@@ -17018,14 +17105,10 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17018
17105
  var playableOutput2 = _step2.value;
17019
17106
  this.processFrameWithRoot(playableOutput2);
17020
17107
  }
17021
- // 更新节点时间
17022
- for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playables), _step3; !(_step3 = _iterator3()).done;){
17023
- var playable = _step3.value;
17024
- this.updatePlayableTime(playable, dt / 1000);
17025
- }
17026
- };
17027
- _proto.connect = function connect(source, sourceOutputPort, destination, destinationInputPort) {
17028
- destination.connectInput(destinationInputPort, source, sourceOutputPort);
17108
+ // 更新节点时间
17109
+ // for (const playable of this.playables) {
17110
+ // this.updatePlayableTime(playable, dt / 1000);
17111
+ // }
17029
17112
  };
17030
17113
  _proto.addOutput = function addOutput(output) {
17031
17114
  this.playableOutputs.push(output);
@@ -17034,12 +17117,12 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17034
17117
  this.playables.push(playable);
17035
17118
  };
17036
17119
  _proto.processFrameWithRoot = function processFrameWithRoot(output) {
17037
- output.sourcePlayable.processFrameRecursive(output.context, output.getSourceOutputPort());
17120
+ output.sourcePlayable.processFrame(output.context);
17038
17121
  output.processFrame();
17039
17122
  };
17040
17123
  _proto.prepareFrameWithRoot = function prepareFrameWithRoot(output) {
17041
- output.sourcePlayable.prepareFrameRecursive(output.context, output.getSourceOutputPort());
17042
17124
  output.prepareFrame();
17125
+ output.sourcePlayable.prepareFrame(output.context);
17043
17126
  };
17044
17127
  _proto.updatePlayableTime = function updatePlayableTime(playable, deltaTime) {
17045
17128
  if (playable.getPlayState() !== 0) {
@@ -17054,24 +17137,15 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17054
17137
  * @since 2.0.0
17055
17138
  */ var Playable = /*#__PURE__*/ function() {
17056
17139
  function Playable(graph, inputCount) {
17057
- if (inputCount === void 0) inputCount = 0;
17058
17140
  this.onPlayablePlayFlag = true;
17059
17141
  this.onPlayablePauseFlag = false;
17060
17142
  this.duration = 0;
17061
17143
  this.destroyed = false;
17062
- this.inputs = [];
17063
- this.inputOuputPorts = [];
17064
- this.inputWeight = [];
17065
- this.outputs = [];
17066
17144
  this.playState = 0;
17067
- this.traversalMode = 0;
17068
17145
  /**
17069
17146
  * 当前本地播放的时间
17070
17147
  */ this.time = 0;
17071
17148
  graph.addPlayable(this);
17072
- this.inputs = new Array(inputCount);
17073
- this.inputOuputPorts = new Array(inputCount);
17074
- this.inputWeight = new Array(inputCount);
17075
17149
  }
17076
17150
  var _proto = Playable.prototype;
17077
17151
  _proto.play = function play() {
@@ -17094,56 +17168,6 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17094
17168
  break;
17095
17169
  }
17096
17170
  };
17097
- _proto.connectInput = function connectInput(inputPort, sourcePlayable, sourceOutputPort, weight) {
17098
- if (weight === void 0) weight = 1.0;
17099
- this.setInput(sourcePlayable, inputPort);
17100
- this.setInputWeight(inputPort, weight);
17101
- sourcePlayable.setOutput(this, sourceOutputPort);
17102
- if (this.inputOuputPorts.length < inputPort + 1) {
17103
- this.inputOuputPorts.length = inputPort + 1;
17104
- }
17105
- this.inputOuputPorts[inputPort] = sourceOutputPort;
17106
- };
17107
- _proto.addInput = function addInput(sourcePlayable, sourceOutputPort, weight) {
17108
- if (weight === void 0) weight = 1.0;
17109
- this.connectInput(this.getInputCount(), sourcePlayable, sourceOutputPort, weight);
17110
- };
17111
- _proto.getInputCount = function getInputCount() {
17112
- return this.inputs.length;
17113
- };
17114
- _proto.getInputs = function getInputs() {
17115
- return this.inputs;
17116
- };
17117
- _proto.getInput = function getInput(index) {
17118
- return this.inputs[index];
17119
- };
17120
- _proto.getOutputCount = function getOutputCount() {
17121
- return this.outputs.length;
17122
- };
17123
- _proto.getOutputs = function getOutputs() {
17124
- return this.outputs;
17125
- };
17126
- _proto.getOutput = function getOutput(index) {
17127
- return this.outputs[index];
17128
- };
17129
- _proto.getInputWeight = function getInputWeight(inputIndex) {
17130
- return this.inputWeight[inputIndex];
17131
- };
17132
- _proto.setInputWeight = function setInputWeight(playableOrIndex, weight) {
17133
- if (_instanceof1(playableOrIndex, Playable)) {
17134
- for(var i = 0; i < this.inputs.length; i++){
17135
- if (this.inputs[i] === playableOrIndex) {
17136
- this.inputWeight[i] = weight;
17137
- return;
17138
- }
17139
- }
17140
- } else {
17141
- if (this.inputWeight.length < playableOrIndex + 1) {
17142
- this.inputWeight.length = playableOrIndex + 1;
17143
- }
17144
- this.inputWeight[playableOrIndex] = weight;
17145
- }
17146
- };
17147
17171
  _proto.setTime = function setTime(time) {
17148
17172
  this.time = time;
17149
17173
  };
@@ -17159,18 +17183,14 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17159
17183
  _proto.getPlayState = function getPlayState() {
17160
17184
  return this.playState;
17161
17185
  };
17162
- _proto.setTraversalMode = function setTraversalMode(mode) {
17163
- this.traversalMode = mode;
17164
- };
17165
- _proto.getTraversalMode = function getTraversalMode() {
17166
- return this.traversalMode;
17167
- };
17168
17186
  // onGraphStart () {
17169
17187
  // }
17170
17188
  // onGraphStop () {
17171
17189
  // }
17172
- _proto.onPlayablePlay = function onPlayablePlay(context) {};
17173
- _proto.onPlayablePause = function onPlayablePause(context) {};
17190
+ // onPlayablePlay (context: FrameContext) {
17191
+ // }
17192
+ // onPlayablePause (context: FrameContext) {
17193
+ // }
17174
17194
  _proto.prepareFrame = function prepareFrame(context) {};
17175
17195
  _proto.processFrame = function processFrame(context) {};
17176
17196
  _proto.onPlayableDestroy = function onPlayableDestroy() {};
@@ -17182,76 +17202,6 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17182
17202
  // TODO 将节点从动画图中移除
17183
17203
  this.destroyed = true;
17184
17204
  };
17185
- /**
17186
- * @internal
17187
- */ _proto.prepareFrameRecursive = function prepareFrameRecursive(context, passthroughPort) {
17188
- if (this.destroyed || this.playState !== 0) {
17189
- return;
17190
- }
17191
- if (this.onPlayablePlayFlag) {
17192
- this.onPlayablePlay(context);
17193
- this.onPlayablePlayFlag = false;
17194
- }
17195
- if (this.onPlayablePauseFlag) {
17196
- this.onPlayablePause(context);
17197
- this.onPlayablePauseFlag = false;
17198
- }
17199
- if (passthroughPort === 0) {
17200
- this.prepareFrame(context);
17201
- }
17202
- // 前序遍历,用于设置节点的初始状态,weight etc.
17203
- switch(this.getTraversalMode()){
17204
- case 0:
17205
- for(var i = 0; i < this.getInputCount(); i++){
17206
- var input = this.getInput(i);
17207
- input.prepareFrameRecursive(context, this.inputOuputPorts[i]);
17208
- }
17209
- break;
17210
- case 1:
17211
- {
17212
- var input1 = this.getInput(passthroughPort);
17213
- input1.prepareFrameRecursive(context, this.inputOuputPorts[passthroughPort]);
17214
- break;
17215
- }
17216
- }
17217
- };
17218
- /**
17219
- * @internal
17220
- */ _proto.processFrameRecursive = function processFrameRecursive(context, passthroughPort) {
17221
- if (this.destroyed || this.playState !== 0) {
17222
- return;
17223
- }
17224
- // 后序遍历,保证 playable 拿到的 input 节点的估计数据是最新的
17225
- switch(this.getTraversalMode()){
17226
- case 0:
17227
- {
17228
- for(var i = 0; i < this.getInputCount(); i++){
17229
- var input = this.getInput(i);
17230
- input.processFrameRecursive(context, this.inputOuputPorts[i]);
17231
- }
17232
- break;
17233
- }
17234
- case 1:
17235
- {
17236
- var input1 = this.getInput(passthroughPort);
17237
- input1.processFrameRecursive(context, this.inputOuputPorts[passthroughPort]);
17238
- break;
17239
- }
17240
- }
17241
- this.processFrame(context);
17242
- };
17243
- _proto.setOutput = function setOutput(outputPlayable, outputPort) {
17244
- if (this.outputs.length < outputPort + 1) {
17245
- this.outputs.length = outputPort + 1;
17246
- }
17247
- this.outputs[outputPort] = outputPlayable;
17248
- };
17249
- _proto.setInput = function setInput(inputPlayable, inputPort) {
17250
- if (this.inputs.length < inputPort + 1) {
17251
- this.inputs.length = inputPort + 1;
17252
- }
17253
- this.inputs[inputPort] = inputPlayable;
17254
- };
17255
17205
  return Playable;
17256
17206
  }();
17257
17207
  /**
@@ -17259,20 +17209,14 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17259
17209
  * @since 2.0.0
17260
17210
  */ var PlayableOutput = /*#__PURE__*/ function() {
17261
17211
  function PlayableOutput() {
17262
- this.sourceOutputPort = 0;
17263
17212
  this.context = {
17264
17213
  deltaTime: 0,
17265
17214
  output: this
17266
17215
  };
17267
17216
  }
17268
17217
  var _proto = PlayableOutput.prototype;
17269
- _proto.setSourcePlayable = function setSourcePlayable(playable, port) {
17270
- if (port === void 0) port = 0;
17218
+ _proto.setSourcePlayable = function setSourcePlayable(playable) {
17271
17219
  this.sourcePlayable = playable;
17272
- this.sourceOutputPort = port;
17273
- };
17274
- _proto.getSourceOutputPort = function getSourceOutputPort() {
17275
- return this.sourceOutputPort;
17276
17220
  };
17277
17221
  _proto.setUserData = function setUserData(value) {
17278
17222
  this.userData = value;
@@ -17298,11 +17242,6 @@ var PlayState;
17298
17242
  PlayState[PlayState["Playing"] = 0] = "Playing";
17299
17243
  PlayState[PlayState["Paused"] = 1] = "Paused";
17300
17244
  })(PlayState || (PlayState = {}));
17301
- var PlayableTraversalMode;
17302
- (function(PlayableTraversalMode) {
17303
- PlayableTraversalMode[PlayableTraversalMode["Mix"] = 0] = "Mix";
17304
- PlayableTraversalMode[PlayableTraversalMode["Passthrough"] = 1] = "Passthrough";
17305
- })(PlayableTraversalMode || (PlayableTraversalMode = {}));
17306
17245
 
17307
17246
  var tempQuat$1 = new Quaternion();
17308
17247
  var seed$3 = 1;
@@ -18869,20 +18808,6 @@ exports.SpriteComponent = __decorate([
18869
18808
  effectsClass(DataType.SpriteComponent)
18870
18809
  ], exports.SpriteComponent);
18871
18810
 
18872
- var RUNTIME_ENV = "runtime_env";
18873
- var RENDER_PREFER_LOOKUP_TEXTURE = "lookup_texture";
18874
- // 文本元素使用 offscreen canvas 绘制
18875
- var TEMPLATE_USE_OFFSCREEN_CANVAS = "offscreen_canvas";
18876
- // 后处理配置相关
18877
- var POST_PROCESS_SETTINGS = "post_process_settings";
18878
- var config = {};
18879
- function getConfig(name) {
18880
- return config[name];
18881
- }
18882
- function setConfig(name, value) {
18883
- return config[name] = value;
18884
- }
18885
-
18886
18811
  var Cone = /*#__PURE__*/ function() {
18887
18812
  function Cone(props) {
18888
18813
  var _this = this;
@@ -22807,12 +22732,6 @@ var AnimationStream = /*#__PURE__*/ function() {
22807
22732
  _proto.findCurveValue = function findCurveValue(componentType, propertyName) {
22808
22733
  return this.curveValues[componentType + propertyName];
22809
22734
  };
22810
- _proto.getInputStream = function getInputStream(index) {
22811
- var inputPlayable = this.playable.getInput(index);
22812
- if (_instanceof1(inputPlayable, AnimationPlayable)) {
22813
- return inputPlayable.animationStream;
22814
- }
22815
- };
22816
22735
  return AnimationStream;
22817
22736
  }();
22818
22737
 
@@ -23147,266 +23066,147 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
23147
23066
  return AnimationClipPlayable;
23148
23067
  }(Playable);
23149
23068
 
23150
- /**
23151
- * @since 2.0.0
23152
- */ var TimelineClip = /*#__PURE__*/ function() {
23153
- function TimelineClip() {
23154
- this.start = 0;
23155
- this.duration = 0;
23156
- }
23157
- var _proto = TimelineClip.prototype;
23158
- _proto.toLocalTime = function toLocalTime(time) {
23159
- var localTime = time - this.start;
23160
- var duration = this.duration;
23161
- if (localTime - duration > 0) {
23162
- if (this.endBehavior === EndBehavior.restart) {
23163
- localTime = localTime % duration;
23164
- } else if (this.endBehavior === EndBehavior.freeze) {
23165
- localTime = Math.min(duration, localTime);
23166
- }
23167
- }
23168
- return localTime;
23169
- };
23170
- return TimelineClip;
23171
- }();
23172
- exports.TrackAsset = /*#__PURE__*/ function(PlayableAsset) {
23173
- _inherits(TrackAsset, PlayableAsset);
23174
- function TrackAsset() {
23069
+ var TrackMixerPlayable = /*#__PURE__*/ function(Playable1) {
23070
+ _inherits(TrackMixerPlayable, Playable1);
23071
+ function TrackMixerPlayable() {
23175
23072
  var _this;
23176
- _this = PlayableAsset.apply(this, arguments) || this;
23177
- _this.trackType = 0;
23178
- _this.clipSeed = 0;
23179
- _this.clips = [];
23180
- _this.children = [];
23073
+ _this = Playable1.apply(this, arguments) || this;
23074
+ _this.clipPlayables = [];
23075
+ _this.clipWeights = [];
23181
23076
  return _this;
23182
23077
  }
23183
- var _proto = TrackAsset.prototype;
23184
- /**
23185
- * 重写该方法以获取自定义对象绑定
23186
- */ _proto.updateAnimatedObject = function updateAnimatedObject() {
23187
- if (this.parent) {
23188
- this.boundObject = this.parent.boundObject;
23078
+ var _proto = TrackMixerPlayable.prototype;
23079
+ _proto.processFrame = function processFrame(context) {
23080
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.clipPlayables), _step; !(_step = _iterator()).done;){
23081
+ var clipPlayable = _step.value;
23082
+ clipPlayable.processFrame(context);
23189
23083
  }
23084
+ this.evaluate(context);
23190
23085
  };
23191
- /**
23192
- * 重写该方法以创建自定义混合器
23193
- */ _proto.createTrackMixer = function createTrackMixer(graph) {
23194
- return new Playable(graph);
23086
+ _proto.setClipWeight = function setClipWeight(playableOrIndex, weight) {
23087
+ if (_instanceof1(playableOrIndex, Playable)) {
23088
+ for(var i = 0; i < this.clipPlayables.length; i++){
23089
+ if (this.clipPlayables[i] === playableOrIndex) {
23090
+ this.clipWeights[i] = weight;
23091
+ return;
23092
+ }
23093
+ }
23094
+ } else {
23095
+ if (this.clipWeights.length < playableOrIndex + 1) {
23096
+ this.clipWeights.length = playableOrIndex + 1;
23097
+ }
23098
+ this.clipWeights[playableOrIndex] = weight;
23099
+ }
23195
23100
  };
23196
- _proto.createOutput = function createOutput() {
23197
- var output = new PlayableOutput();
23198
- return output;
23101
+ _proto.getClipWeight = function getClipWeight(inputIndex) {
23102
+ return this.clipWeights[inputIndex];
23199
23103
  };
23200
- _proto.createPlayableGraph = function createPlayableGraph(graph, runtimeClips) {
23201
- var mixerPlayable = this.createMixerPlayableGraph(graph, runtimeClips);
23202
- return mixerPlayable;
23104
+ _proto.getClipPlayable = function getClipPlayable(index) {
23105
+ return this.clipPlayables[index];
23203
23106
  };
23204
- _proto.createMixerPlayableGraph = function createMixerPlayableGraph(graph, runtimeClips) {
23205
- var clips = [];
23206
- for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
23207
- var clip = _step.value;
23208
- clips.push(clip);
23209
- }
23210
- var mixerPlayable = this.compileClips(graph, clips, runtimeClips);
23211
- return mixerPlayable;
23107
+ _proto.evaluate = function evaluate(context) {
23108
+ // Override
23212
23109
  };
23213
- _proto.compileClips = function compileClips(graph, timelineClips, runtimeClips) {
23214
- var mixer = this.createTrackMixer(graph);
23215
- for(var _iterator = _create_for_of_iterator_helper_loose(timelineClips), _step; !(_step = _iterator()).done;){
23216
- var timelineClip = _step.value;
23217
- var clipPlayable = this.createClipPlayable(graph, timelineClip);
23218
- clipPlayable.setDuration(timelineClip.duration);
23219
- var clip = new RuntimeClip(timelineClip, clipPlayable, mixer, this);
23220
- runtimeClips.push(clip);
23221
- mixer.addInput(clipPlayable, 0);
23222
- mixer.setInputWeight(clipPlayable, 0.0);
23110
+ return TrackMixerPlayable;
23111
+ }(Playable);
23112
+
23113
+ var ActivationMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23114
+ _inherits(ActivationMixerPlayable, TrackMixerPlayable);
23115
+ function ActivationMixerPlayable() {
23116
+ return TrackMixerPlayable.apply(this, arguments);
23117
+ }
23118
+ var _proto = ActivationMixerPlayable.prototype;
23119
+ _proto.evaluate = function evaluate(context) {
23120
+ var boundObject = context.output.getUserData();
23121
+ if (!_instanceof1(boundObject, exports.VFXItem)) {
23122
+ return;
23123
+ }
23124
+ var boundItem = boundObject;
23125
+ var hasInput = false;
23126
+ for(var i = 0; i < this.clipPlayables.length; i++){
23127
+ if (this.getClipWeight(i) > 0) {
23128
+ hasInput = true;
23129
+ break;
23130
+ }
23131
+ }
23132
+ if (hasInput) {
23133
+ boundItem.transform.setValid(true);
23134
+ boundItem.setActive(true);
23135
+ } else {
23136
+ boundItem.transform.setValid(false);
23137
+ boundItem.setActive(false);
23223
23138
  }
23224
- return mixer;
23225
- };
23226
- _proto.createPlayable = function createPlayable(graph) {
23227
- return new Playable(graph);
23228
23139
  };
23229
- _proto.getChildTracks = function getChildTracks() {
23230
- return this.children;
23231
- };
23232
- _proto.addChild = function addChild(child) {
23233
- this.children.push(child);
23234
- child.parent = this;
23235
- };
23236
- _proto.createClip = function createClip(classConstructor, name) {
23237
- var newClip = new TimelineClip();
23238
- newClip.asset = new classConstructor(this.engine);
23239
- newClip.name = name ? name : "TimelineClip" + newClip.id;
23240
- this.addClip(newClip);
23241
- return newClip;
23242
- };
23243
- _proto.getClips = function getClips() {
23244
- return this.clips;
23245
- };
23246
- _proto.findClip = function findClip(name) {
23247
- for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
23248
- var clip = _step.value;
23249
- if (clip.name === name) {
23250
- return clip;
23251
- }
23252
- }
23253
- };
23254
- _proto.addClip = function addClip(clip) {
23255
- clip.id = (this.clipSeed++).toString();
23256
- this.clips.push(clip);
23257
- };
23258
- _proto.createClipPlayable = function createClipPlayable(graph, clip) {
23259
- return clip.asset.createPlayable(graph);
23260
- };
23261
- _proto.fromData = function fromData(data) {
23262
- PlayableAsset.prototype.fromData.call(this, data);
23263
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
23264
- var child = _step.value;
23265
- child.parent = this;
23266
- }
23267
- };
23268
- return TrackAsset;
23269
- }(PlayableAsset);
23270
- __decorate([
23271
- serialize(TimelineClip)
23272
- ], exports.TrackAsset.prototype, "clips", void 0);
23273
- __decorate([
23274
- serialize()
23275
- ], exports.TrackAsset.prototype, "children", void 0);
23276
- exports.TrackAsset = __decorate([
23277
- effectsClass(DataType.TrackAsset)
23278
- ], exports.TrackAsset);
23279
- exports.TrackType = void 0;
23280
- (function(TrackType) {
23281
- TrackType[TrackType["MasterTrack"] = 0] = "MasterTrack";
23282
- TrackType[TrackType["ObjectTrack"] = 1] = "ObjectTrack";
23283
- })(exports.TrackType || (exports.TrackType = {}));
23284
- var RuntimeClip = /*#__PURE__*/ function() {
23285
- function RuntimeClip(clip, clipPlayable, parentMixer, track) {
23286
- this.clip = clip;
23287
- this.playable = clipPlayable;
23288
- this.parentMixer = parentMixer;
23289
- this.track = track;
23290
- if (_instanceof1(this.track.boundObject, exports.VFXItem)) {
23291
- this.particleSystem = this.track.boundObject.getComponent(exports.ParticleSystem);
23292
- }
23293
- }
23294
- var _proto = RuntimeClip.prototype;
23295
- _proto.evaluateAt = function evaluateAt(localTime) {
23296
- var clip = this.clip;
23297
- var weight = 1.0;
23298
- var ended = false;
23299
- var started = false;
23300
- var boundObject = this.track.boundObject;
23301
- if (localTime >= clip.start + clip.duration && clip.endBehavior === EndBehavior.destroy) {
23302
- if (_instanceof1(boundObject, exports.VFXItem) && exports.VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
23303
- weight = 1.0;
23304
- } else {
23305
- weight = 0.0;
23306
- ended = true;
23307
- }
23308
- } else if (localTime - this.clip.start >= 0) {
23309
- weight = 1.0;
23310
- started = true;
23311
- } else if (localTime < clip.start) {
23312
- weight = 0.0;
23313
- }
23314
- if (started && this.playable.getPlayState() !== PlayState.Playing) {
23315
- this.playable.play();
23316
- }
23317
- this.parentMixer.setInputWeight(this.playable, weight);
23318
- var clipTime = clip.toLocalTime(localTime);
23319
- this.playable.setTime(clipTime);
23320
- // 判断动画是否结束
23321
- if (ended) {
23322
- if (this.playable.getPlayState() === PlayState.Playing) {
23323
- this.playable.pause();
23324
- }
23325
- }
23326
- };
23327
- _create_class(RuntimeClip, [
23328
- {
23329
- key: "enable",
23330
- set: function set(value) {
23331
- if (value) {
23332
- this.playable.play();
23333
- } else {
23334
- this.parentMixer.setInputWeight(this.playable, 0);
23335
- this.playable.pause();
23336
- }
23337
- }
23338
- }
23339
- ]);
23340
- return RuntimeClip;
23341
- }();
23140
+ return ActivationMixerPlayable;
23141
+ }(TrackMixerPlayable);
23342
23142
 
23343
- var ActivationMixerPlayable = /*#__PURE__*/ function(Playable) {
23344
- _inherits(ActivationMixerPlayable, Playable);
23345
- function ActivationMixerPlayable() {
23143
+ var PropertyClipPlayable = /*#__PURE__*/ function(Playable) {
23144
+ _inherits(PropertyClipPlayable, Playable);
23145
+ function PropertyClipPlayable() {
23346
23146
  return Playable.apply(this, arguments);
23347
23147
  }
23348
- var _proto = ActivationMixerPlayable.prototype;
23148
+ var _proto = PropertyClipPlayable.prototype;
23349
23149
  _proto.processFrame = function processFrame(context) {
23150
+ this.value = this.curve.getValue(this.time / this.getDuration());
23151
+ };
23152
+ return PropertyClipPlayable;
23153
+ }(Playable);
23154
+
23155
+ var ColorPropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23156
+ _inherits(ColorPropertyMixerPlayable, TrackMixerPlayable);
23157
+ function ColorPropertyMixerPlayable() {
23158
+ var _this;
23159
+ _this = TrackMixerPlayable.apply(this, arguments) || this;
23160
+ _this.propertyName = "";
23161
+ return _this;
23162
+ }
23163
+ var _proto = ColorPropertyMixerPlayable.prototype;
23164
+ _proto.evaluate = function evaluate(context) {
23350
23165
  var boundObject = context.output.getUserData();
23351
- if (!_instanceof1(boundObject, exports.VFXItem)) {
23166
+ if (!boundObject) {
23352
23167
  return;
23353
23168
  }
23354
- var boundItem = boundObject;
23355
23169
  var hasInput = false;
23356
- for(var i = 0; i < this.getInputCount(); i++){
23357
- if (this.getInputWeight(i) > 0) {
23170
+ var value = boundObject[this.propertyName];
23171
+ if (!_instanceof1(value, Color)) {
23172
+ return;
23173
+ }
23174
+ value.setZero();
23175
+ // evaluate the curve
23176
+ for(var i = 0; i < this.clipPlayables.length; i++){
23177
+ var weight = this.getClipWeight(i);
23178
+ if (weight > 0) {
23179
+ var propertyClipPlayable = this.getClipPlayable(i);
23180
+ if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
23181
+ console.error("ColorPropertyMixerPlayable received incompatible input");
23182
+ continue;
23183
+ }
23184
+ var curveValue = propertyClipPlayable.value;
23185
+ value.r += curveValue.r * weight;
23186
+ value.g += curveValue.g * weight;
23187
+ value.b += curveValue.b * weight;
23188
+ value.a += curveValue.a * weight;
23358
23189
  hasInput = true;
23359
- break;
23360
23190
  }
23361
23191
  }
23192
+ // set value
23362
23193
  if (hasInput) {
23363
- boundItem.transform.setValid(true);
23364
- boundItem.setActive(true);
23365
- } else {
23366
- boundItem.transform.setValid(false);
23367
- boundItem.setActive(false);
23194
+ boundObject[this.propertyName] = value;
23368
23195
  }
23369
23196
  };
23370
- return ActivationMixerPlayable;
23371
- }(Playable);
23372
-
23373
- exports.ActivationTrack = /*#__PURE__*/ function(TrackAsset) {
23374
- _inherits(ActivationTrack, TrackAsset);
23375
- function ActivationTrack() {
23376
- return TrackAsset.apply(this, arguments);
23377
- }
23378
- var _proto = ActivationTrack.prototype;
23379
- _proto.createTrackMixer = function createTrackMixer(graph) {
23380
- return new ActivationMixerPlayable(graph);
23381
- };
23382
- return ActivationTrack;
23383
- }(exports.TrackAsset);
23384
- exports.ActivationTrack = __decorate([
23385
- effectsClass(DataType.ActivationTrack)
23386
- ], exports.ActivationTrack);
23387
-
23388
- var PropertyClipPlayable = /*#__PURE__*/ function(Playable) {
23389
- _inherits(PropertyClipPlayable, Playable);
23390
- function PropertyClipPlayable() {
23391
- return Playable.apply(this, arguments);
23392
- }
23393
- var _proto = PropertyClipPlayable.prototype;
23394
- _proto.processFrame = function processFrame(context) {
23395
- this.value = this.curve.getValue(this.time / this.getDuration());
23396
- };
23397
- return PropertyClipPlayable;
23398
- }(Playable);
23197
+ return ColorPropertyMixerPlayable;
23198
+ }(TrackMixerPlayable);
23399
23199
 
23400
- var FloatPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
23401
- _inherits(FloatPropertyMixerPlayable, Playable);
23200
+ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23201
+ _inherits(FloatPropertyMixerPlayable, TrackMixerPlayable);
23402
23202
  function FloatPropertyMixerPlayable() {
23403
23203
  var _this;
23404
- _this = Playable.apply(this, arguments) || this;
23204
+ _this = TrackMixerPlayable.apply(this, arguments) || this;
23405
23205
  _this.propertyName = "";
23406
23206
  return _this;
23407
23207
  }
23408
23208
  var _proto = FloatPropertyMixerPlayable.prototype;
23409
- _proto.processFrame = function processFrame(context) {
23209
+ _proto.evaluate = function evaluate(context) {
23410
23210
  var boundObject = context.output.getUserData();
23411
23211
  if (!boundObject) {
23412
23212
  return;
@@ -23414,10 +23214,10 @@ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
23414
23214
  var hasInput = false;
23415
23215
  var value = 0;
23416
23216
  // evaluate the curve
23417
- for(var i = 0; i < this.getInputCount(); i++){
23418
- var weight = this.getInputWeight(i);
23217
+ for(var i = 0; i < this.clipPlayables.length; i++){
23218
+ var weight = this.getClipWeight(i);
23419
23219
  if (weight > 0) {
23420
- var propertyClipPlayable = this.getInput(i);
23220
+ var propertyClipPlayable = this.getClipPlayable(i);
23421
23221
  if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
23422
23222
  console.error("FloatPropertyTrack added non-FloatPropertyPlayableAsset");
23423
23223
  continue;
@@ -23433,7 +23233,27 @@ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
23433
23233
  }
23434
23234
  };
23435
23235
  return FloatPropertyMixerPlayable;
23436
- }(Playable);
23236
+ }(TrackMixerPlayable);
23237
+
23238
+ var ParticleMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23239
+ _inherits(ParticleMixerPlayable, TrackMixerPlayable);
23240
+ function ParticleMixerPlayable() {
23241
+ return TrackMixerPlayable.apply(this, arguments);
23242
+ }
23243
+ var _proto = ParticleMixerPlayable.prototype;
23244
+ _proto.evaluate = function evaluate(context) {};
23245
+ return ParticleMixerPlayable;
23246
+ }(TrackMixerPlayable);
23247
+
23248
+ var SpriteColorMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23249
+ _inherits(SpriteColorMixerPlayable, TrackMixerPlayable);
23250
+ function SpriteColorMixerPlayable() {
23251
+ return TrackMixerPlayable.apply(this, arguments);
23252
+ }
23253
+ var _proto = SpriteColorMixerPlayable.prototype;
23254
+ _proto.evaluate = function evaluate(context) {};
23255
+ return SpriteColorMixerPlayable;
23256
+ }(TrackMixerPlayable);
23437
23257
 
23438
23258
  var SerializationHelper = /*#__PURE__*/ function() {
23439
23259
  function SerializationHelper() {}
@@ -23925,7 +23745,8 @@ var SerializationHelper = /*#__PURE__*/ function() {
23925
23745
  this.timelinePlayable.setTime(time);
23926
23746
  // The properties of the object may change dynamically,
23927
23747
  // so reset the track binding to avoid invalidation of the previously obtained binding object.
23928
- this.resolveBindings();
23748
+ // this.resolveBindings();
23749
+ this.timelinePlayable.evaluate();
23929
23750
  this.graph.evaluate(dt);
23930
23751
  };
23931
23752
  _proto.createContent = function createContent() {
@@ -24104,21 +23925,21 @@ var SubCompositionClipPlayable = /*#__PURE__*/ function(Playable) {
24104
23925
  return SubCompositionClipPlayable;
24105
23926
  }(Playable);
24106
23927
 
24107
- var SubCompositionMixerPlayable = /*#__PURE__*/ function(Playable) {
24108
- _inherits(SubCompositionMixerPlayable, Playable);
23928
+ var SubCompositionMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23929
+ _inherits(SubCompositionMixerPlayable, TrackMixerPlayable);
24109
23930
  function SubCompositionMixerPlayable() {
24110
- return Playable.apply(this, arguments);
23931
+ return TrackMixerPlayable.apply(this, arguments);
24111
23932
  }
24112
23933
  var _proto = SubCompositionMixerPlayable.prototype;
24113
- _proto.processFrame = function processFrame(context) {
23934
+ _proto.evaluate = function evaluate(context) {
24114
23935
  var boundObject = context.output.getUserData();
24115
23936
  if (!_instanceof1(boundObject, CompositionComponent)) {
24116
23937
  return;
24117
23938
  }
24118
23939
  var compositionComponent = boundObject;
24119
23940
  var hasInput = false;
24120
- for(var i = 0; i < this.getInputCount(); i++){
24121
- if (this.getInputWeight(i) > 0) {
23941
+ for(var i = 0; i < this.clipPlayables.length; i++){
23942
+ if (this.getClipWeight(i) > 0) {
24122
23943
  hasInput = true;
24123
23944
  break;
24124
23945
  }
@@ -24130,18 +23951,28 @@ var SubCompositionMixerPlayable = /*#__PURE__*/ function(Playable) {
24130
23951
  }
24131
23952
  };
24132
23953
  return SubCompositionMixerPlayable;
24133
- }(Playable);
23954
+ }(TrackMixerPlayable);
23955
+
23956
+ var TransformMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23957
+ _inherits(TransformMixerPlayable, TrackMixerPlayable);
23958
+ function TransformMixerPlayable() {
23959
+ return TrackMixerPlayable.apply(this, arguments);
23960
+ }
23961
+ var _proto = TransformMixerPlayable.prototype;
23962
+ _proto.evaluate = function evaluate(context) {};
23963
+ return TransformMixerPlayable;
23964
+ }(TrackMixerPlayable);
24134
23965
 
24135
- var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24136
- _inherits(Vector4PropertyMixerPlayable, Playable);
23966
+ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23967
+ _inherits(Vector4PropertyMixerPlayable, TrackMixerPlayable);
24137
23968
  function Vector4PropertyMixerPlayable() {
24138
23969
  var _this;
24139
- _this = Playable.apply(this, arguments) || this;
23970
+ _this = TrackMixerPlayable.apply(this, arguments) || this;
24140
23971
  _this.propertyName = "";
24141
23972
  return _this;
24142
23973
  }
24143
23974
  var _proto = Vector4PropertyMixerPlayable.prototype;
24144
- _proto.processFrame = function processFrame(context) {
23975
+ _proto.evaluate = function evaluate(context) {
24145
23976
  var boundObject = context.output.getUserData();
24146
23977
  if (!boundObject) {
24147
23978
  return;
@@ -24153,10 +23984,10 @@ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24153
23984
  }
24154
23985
  value.setZero();
24155
23986
  // evaluate the curve
24156
- for(var i = 0; i < this.getInputCount(); i++){
24157
- var weight = this.getInputWeight(i);
23987
+ for(var i = 0; i < this.clipPlayables.length; i++){
23988
+ var weight = this.getClipWeight(i);
24158
23989
  if (weight > 0) {
24159
- var propertyClipPlayable = this.getInput(i);
23990
+ var propertyClipPlayable = this.getClipPlayable(i);
24160
23991
  if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
24161
23992
  console.error("Vector4PropertyTrack added non-Vector4PropertyPlayableAsset");
24162
23993
  continue;
@@ -24175,52 +24006,215 @@ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24175
24006
  }
24176
24007
  };
24177
24008
  return Vector4PropertyMixerPlayable;
24178
- }(Playable);
24009
+ }(TrackMixerPlayable);
24179
24010
 
24180
- var ColorPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24181
- _inherits(ColorPropertyMixerPlayable, Playable);
24182
- function ColorPropertyMixerPlayable() {
24011
+ /**
24012
+ * @since 2.0.0
24013
+ */ var TimelineClip = /*#__PURE__*/ function() {
24014
+ function TimelineClip() {
24015
+ this.start = 0;
24016
+ this.duration = 0;
24017
+ }
24018
+ var _proto = TimelineClip.prototype;
24019
+ _proto.toLocalTime = function toLocalTime(time) {
24020
+ var localTime = time - this.start;
24021
+ var duration = this.duration;
24022
+ if (localTime - duration > 0) {
24023
+ if (this.endBehavior === EndBehavior.restart) {
24024
+ localTime = localTime % duration;
24025
+ } else if (this.endBehavior === EndBehavior.freeze) {
24026
+ localTime = Math.min(duration, localTime);
24027
+ }
24028
+ }
24029
+ return localTime;
24030
+ };
24031
+ return TimelineClip;
24032
+ }();
24033
+ exports.TrackAsset = /*#__PURE__*/ function(PlayableAsset) {
24034
+ _inherits(TrackAsset, PlayableAsset);
24035
+ function TrackAsset() {
24183
24036
  var _this;
24184
- _this = Playable.apply(this, arguments) || this;
24185
- _this.propertyName = "";
24037
+ _this = PlayableAsset.apply(this, arguments) || this;
24038
+ _this.trackType = 0;
24039
+ _this.clipSeed = 0;
24040
+ _this.clips = [];
24041
+ _this.children = [];
24186
24042
  return _this;
24187
24043
  }
24188
- var _proto = ColorPropertyMixerPlayable.prototype;
24189
- _proto.processFrame = function processFrame(context) {
24190
- var boundObject = context.output.getUserData();
24191
- if (!boundObject) {
24192
- return;
24044
+ var _proto = TrackAsset.prototype;
24045
+ /**
24046
+ * 重写该方法以获取自定义对象绑定
24047
+ */ _proto.updateAnimatedObject = function updateAnimatedObject() {
24048
+ if (this.parent) {
24049
+ this.boundObject = this.parent.boundObject;
24193
24050
  }
24194
- var hasInput = false;
24195
- var value = boundObject[this.propertyName];
24196
- if (!_instanceof1(value, Color)) {
24197
- return;
24051
+ };
24052
+ /**
24053
+ * 重写该方法以创建自定义混合器
24054
+ */ _proto.createTrackMixer = function createTrackMixer(graph) {
24055
+ return new TrackMixerPlayable(graph);
24056
+ };
24057
+ _proto.createOutput = function createOutput() {
24058
+ var output = new PlayableOutput();
24059
+ return output;
24060
+ };
24061
+ _proto.createPlayableGraph = function createPlayableGraph(graph, runtimeClips) {
24062
+ var mixerPlayable = this.createMixerPlayableGraph(graph, runtimeClips);
24063
+ return mixerPlayable;
24064
+ };
24065
+ _proto.createMixerPlayableGraph = function createMixerPlayableGraph(graph, runtimeClips) {
24066
+ var clips = [];
24067
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
24068
+ var clip = _step.value;
24069
+ clips.push(clip);
24198
24070
  }
24199
- value.setZero();
24200
- // evaluate the curve
24201
- for(var i = 0; i < this.getInputCount(); i++){
24202
- var weight = this.getInputWeight(i);
24203
- if (weight > 0) {
24204
- var propertyClipPlayable = this.getInput(i);
24205
- if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
24206
- console.error("ColorPropertyMixerPlayable received incompatible input");
24207
- continue;
24208
- }
24209
- var curveValue = propertyClipPlayable.value;
24210
- value.r += curveValue.r * weight;
24211
- value.g += curveValue.g * weight;
24212
- value.b += curveValue.b * weight;
24213
- value.a += curveValue.a * weight;
24214
- hasInput = true;
24071
+ var mixerPlayable = this.compileClips(graph, clips, runtimeClips);
24072
+ return mixerPlayable;
24073
+ };
24074
+ _proto.compileClips = function compileClips(graph, timelineClips, runtimeClips) {
24075
+ var mixer = this.createTrackMixer(graph);
24076
+ for(var _iterator = _create_for_of_iterator_helper_loose(timelineClips), _step; !(_step = _iterator()).done;){
24077
+ var timelineClip = _step.value;
24078
+ var clipPlayable = this.createClipPlayable(graph, timelineClip);
24079
+ clipPlayable.setDuration(timelineClip.duration);
24080
+ var clip = new RuntimeClip(timelineClip, clipPlayable, mixer, this);
24081
+ runtimeClips.push(clip);
24082
+ mixer.clipPlayables.push(clipPlayable);
24083
+ mixer.setClipWeight(clipPlayable, 0.0);
24084
+ }
24085
+ return mixer;
24086
+ };
24087
+ _proto.createPlayable = function createPlayable(graph) {
24088
+ return new Playable(graph);
24089
+ };
24090
+ _proto.getChildTracks = function getChildTracks() {
24091
+ return this.children;
24092
+ };
24093
+ _proto.addChild = function addChild(child) {
24094
+ this.children.push(child);
24095
+ child.parent = this;
24096
+ };
24097
+ _proto.createClip = function createClip(classConstructor, name) {
24098
+ var newClip = new TimelineClip();
24099
+ newClip.asset = new classConstructor(this.engine);
24100
+ newClip.name = name ? name : "TimelineClip" + newClip.id;
24101
+ this.addClip(newClip);
24102
+ return newClip;
24103
+ };
24104
+ _proto.getClips = function getClips() {
24105
+ return this.clips;
24106
+ };
24107
+ _proto.findClip = function findClip(name) {
24108
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
24109
+ var clip = _step.value;
24110
+ if (clip.name === name) {
24111
+ return clip;
24215
24112
  }
24216
24113
  }
24217
- // set value
24218
- if (hasInput) {
24219
- boundObject[this.propertyName] = value;
24114
+ };
24115
+ _proto.addClip = function addClip(clip) {
24116
+ clip.id = (this.clipSeed++).toString();
24117
+ this.clips.push(clip);
24118
+ };
24119
+ _proto.createClipPlayable = function createClipPlayable(graph, clip) {
24120
+ return clip.asset.createPlayable(graph);
24121
+ };
24122
+ _proto.fromData = function fromData(data) {
24123
+ PlayableAsset.prototype.fromData.call(this, data);
24124
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
24125
+ var child = _step.value;
24126
+ child.parent = this;
24220
24127
  }
24221
24128
  };
24222
- return ColorPropertyMixerPlayable;
24223
- }(Playable);
24129
+ return TrackAsset;
24130
+ }(PlayableAsset);
24131
+ __decorate([
24132
+ serialize(TimelineClip)
24133
+ ], exports.TrackAsset.prototype, "clips", void 0);
24134
+ __decorate([
24135
+ serialize()
24136
+ ], exports.TrackAsset.prototype, "children", void 0);
24137
+ exports.TrackAsset = __decorate([
24138
+ effectsClass(DataType.TrackAsset)
24139
+ ], exports.TrackAsset);
24140
+ exports.TrackType = void 0;
24141
+ (function(TrackType) {
24142
+ TrackType[TrackType["MasterTrack"] = 0] = "MasterTrack";
24143
+ TrackType[TrackType["ObjectTrack"] = 1] = "ObjectTrack";
24144
+ })(exports.TrackType || (exports.TrackType = {}));
24145
+ var RuntimeClip = /*#__PURE__*/ function() {
24146
+ function RuntimeClip(clip, clipPlayable, parentMixer, track) {
24147
+ this.clip = clip;
24148
+ this.playable = clipPlayable;
24149
+ this.parentMixer = parentMixer;
24150
+ this.track = track;
24151
+ if (_instanceof1(this.track.boundObject, exports.VFXItem)) {
24152
+ this.particleSystem = this.track.boundObject.getComponent(exports.ParticleSystem);
24153
+ }
24154
+ }
24155
+ var _proto = RuntimeClip.prototype;
24156
+ _proto.evaluateAt = function evaluateAt(localTime) {
24157
+ var clip = this.clip;
24158
+ var weight = 1.0;
24159
+ var ended = false;
24160
+ var started = false;
24161
+ var boundObject = this.track.boundObject;
24162
+ if (localTime >= clip.start + clip.duration && clip.endBehavior === EndBehavior.destroy) {
24163
+ if (_instanceof1(boundObject, exports.VFXItem) && exports.VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
24164
+ weight = 1.0;
24165
+ } else {
24166
+ weight = 0.0;
24167
+ ended = true;
24168
+ }
24169
+ } else if (localTime - this.clip.start >= 0) {
24170
+ weight = 1.0;
24171
+ started = true;
24172
+ } else if (localTime < clip.start) {
24173
+ weight = 0.0;
24174
+ }
24175
+ if (started && this.playable.getPlayState() !== PlayState.Playing) {
24176
+ this.playable.play();
24177
+ }
24178
+ this.parentMixer.setClipWeight(this.playable, weight);
24179
+ var clipTime = parseFloat(clip.toLocalTime(localTime).toFixed(3));
24180
+ this.playable.setTime(clipTime);
24181
+ // 判断动画是否结束
24182
+ if (ended) {
24183
+ if (this.playable.getPlayState() === PlayState.Playing) {
24184
+ this.playable.pause();
24185
+ }
24186
+ }
24187
+ };
24188
+ _create_class(RuntimeClip, [
24189
+ {
24190
+ key: "enable",
24191
+ set: function set(value) {
24192
+ if (value) {
24193
+ this.playable.play();
24194
+ } else {
24195
+ this.parentMixer.setClipWeight(this.playable, 0);
24196
+ this.playable.pause();
24197
+ }
24198
+ }
24199
+ }
24200
+ ]);
24201
+ return RuntimeClip;
24202
+ }();
24203
+
24204
+ exports.ActivationTrack = /*#__PURE__*/ function(TrackAsset) {
24205
+ _inherits(ActivationTrack, TrackAsset);
24206
+ function ActivationTrack() {
24207
+ return TrackAsset.apply(this, arguments);
24208
+ }
24209
+ var _proto = ActivationTrack.prototype;
24210
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24211
+ return new ActivationMixerPlayable(graph);
24212
+ };
24213
+ return ActivationTrack;
24214
+ }(exports.TrackAsset);
24215
+ exports.ActivationTrack = __decorate([
24216
+ effectsClass(DataType.ActivationTrack)
24217
+ ], exports.ActivationTrack);
24224
24218
 
24225
24219
  var PropertyTrack = /*#__PURE__*/ function(TrackAsset) {
24226
24220
  _inherits(PropertyTrack, TrackAsset);
@@ -24293,6 +24287,10 @@ exports.SpriteColorTrack = /*#__PURE__*/ function(TrackAsset) {
24293
24287
  function SpriteColorTrack() {
24294
24288
  return TrackAsset.apply(this, arguments);
24295
24289
  }
24290
+ var _proto = SpriteColorTrack.prototype;
24291
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24292
+ return new SpriteColorMixerPlayable(graph);
24293
+ };
24296
24294
  return SpriteColorTrack;
24297
24295
  }(exports.TrackAsset);
24298
24296
  exports.SpriteColorTrack = __decorate([
@@ -24325,6 +24323,10 @@ exports.TransformTrack = /*#__PURE__*/ function(TrackAsset) {
24325
24323
  function TransformTrack() {
24326
24324
  return TrackAsset.apply(this, arguments);
24327
24325
  }
24326
+ var _proto = TransformTrack.prototype;
24327
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24328
+ return new TransformMixerPlayable(graph);
24329
+ };
24328
24330
  return TransformTrack;
24329
24331
  }(exports.TrackAsset);
24330
24332
  exports.TransformTrack = __decorate([
@@ -24353,6 +24355,18 @@ exports.MaterialTrack = __decorate([
24353
24355
  effectsClass("MaterialTrack")
24354
24356
  ], exports.MaterialTrack);
24355
24357
 
24358
+ var ParticleTrack = /*#__PURE__*/ function(TrackAsset) {
24359
+ _inherits(ParticleTrack, TrackAsset);
24360
+ function ParticleTrack() {
24361
+ return TrackAsset.apply(this, arguments);
24362
+ }
24363
+ var _proto = ParticleTrack.prototype;
24364
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24365
+ return new ParticleMixerPlayable(graph);
24366
+ };
24367
+ return ParticleTrack;
24368
+ }(exports.TrackAsset);
24369
+
24356
24370
  exports.Vector4PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
24357
24371
  _inherits(Vector4PropertyTrack, PropertyTrack);
24358
24372
  function Vector4PropertyTrack() {
@@ -24481,7 +24495,6 @@ exports.TimelineAsset = /*#__PURE__*/ function(PlayableAsset) {
24481
24495
  var _proto = TimelineAsset.prototype;
24482
24496
  _proto.createPlayable = function createPlayable(graph) {
24483
24497
  var timelinePlayable = new TimelinePlayable(graph);
24484
- timelinePlayable.setTraversalMode(PlayableTraversalMode.Passthrough);
24485
24498
  for(var _iterator = _create_for_of_iterator_helper_loose(this.tracks), _step; !(_step = _iterator()).done;){
24486
24499
  var track = _step.value;
24487
24500
  if (_instanceof1(track, exports.ObjectBindingTrack)) {
@@ -24562,9 +24575,7 @@ var TimelinePlayable = /*#__PURE__*/ function(Playable) {
24562
24575
  return _this;
24563
24576
  }
24564
24577
  var _proto = TimelinePlayable.prototype;
24565
- _proto.prepareFrame = function prepareFrame(context) {
24566
- this.evaluate();
24567
- };
24578
+ _proto.prepareFrame = function prepareFrame(context) {};
24568
24579
  _proto.evaluate = function evaluate() {
24569
24580
  var time = this.getTime();
24570
24581
  // TODO search active clips
@@ -24581,11 +24592,10 @@ var TimelinePlayable = /*#__PURE__*/ function(Playable) {
24581
24592
  var track = _step.value;
24582
24593
  // create track mixer and track output
24583
24594
  var trackMixPlayable = track.createPlayableGraph(graph, this.clips);
24584
- this.addInput(trackMixPlayable, 0);
24585
24595
  var trackOutput = track.createOutput();
24586
24596
  trackOutput.setUserData(track.boundObject);
24587
24597
  graph.addOutput(trackOutput);
24588
- trackOutput.setSourcePlayable(this, this.getInputCount() - 1);
24598
+ trackOutput.setSourcePlayable(trackMixPlayable);
24589
24599
  // create track instance
24590
24600
  var trackInstance = new TrackInstance(track, trackMixPlayable, trackOutput);
24591
24601
  trackInstanceMap[track.getInstanceId()] = trackInstance;
@@ -24646,10 +24656,10 @@ exports.Vector4PropertyPlayableAsset = __decorate([
24646
24656
  effectsClass("Vector4PropertyPlayableAsset")
24647
24657
  ], exports.Vector4PropertyPlayableAsset);
24648
24658
 
24649
- exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
24650
- _inherits(ObjectBindingTrack, TrackAsset1);
24659
+ exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset) {
24660
+ _inherits(ObjectBindingTrack, TrackAsset);
24651
24661
  function ObjectBindingTrack() {
24652
- return TrackAsset1.apply(this, arguments);
24662
+ return TrackAsset.apply(this, arguments);
24653
24663
  }
24654
24664
  var _proto = ObjectBindingTrack.prototype;
24655
24665
  _proto.updateAnimatedObject = function updateAnimatedObject() {};
@@ -24660,7 +24670,7 @@ exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
24660
24670
  var boundItem = this.boundObject;
24661
24671
  // 添加粒子动画 clip // TODO 待移除
24662
24672
  if (boundItem.getComponent(exports.ParticleSystem)) {
24663
- var particleTrack = timelineAsset.createTrack(exports.TrackAsset, this, "ParticleTrack");
24673
+ var particleTrack = timelineAsset.createTrack(ParticleTrack, this, "ParticleTrack");
24664
24674
  particleTrack.boundObject = this.boundObject;
24665
24675
  var particleClip = particleTrack.createClip(ParticleBehaviourPlayableAsset);
24666
24676
  particleClip.start = boundItem.start;
@@ -24690,7 +24700,7 @@ var TextLayout = /*#__PURE__*/ function() {
24690
24700
  this.width = textWidth;
24691
24701
  this.height = textHeight;
24692
24702
  this.letterSpace = letterSpace;
24693
- this.overFlow = textOverflow;
24703
+ this.overflow = textOverflow;
24694
24704
  this.textBaseline = textBaseline;
24695
24705
  this.textAlign = textAlign;
24696
24706
  this.lineHeight = lineHeight;
@@ -27305,6 +27315,7 @@ var seed = 1;
27305
27315
  this.downloader = downloader;
27306
27316
  this.assets = {};
27307
27317
  this.sourceFrom = {};
27318
+ this.imageBitmapOptions = {};
27308
27319
  this.id = seed++;
27309
27320
  this.timers = [];
27310
27321
  this.updateOptions(options);
@@ -27562,12 +27573,12 @@ var seed = 1;
27562
27573
  _proto.processJSON = function processJSON(json) {
27563
27574
  var _this = this;
27564
27575
  return _async_to_generator(function() {
27565
- var jsonScene, _jsonScene_plugins, plugins, pluginSystem;
27576
+ var jsonScene, _jsonScene_plugins, plugins, textures, pluginSystem;
27566
27577
  return __generator(this, function(_state) {
27567
27578
  switch(_state.label){
27568
27579
  case 0:
27569
27580
  jsonScene = getStandardJSON(json);
27570
- _jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins;
27581
+ _jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins, textures = jsonScene.textures;
27571
27582
  pluginSystem = new PluginSystem(plugins);
27572
27583
  return [
27573
27584
  4,
@@ -27575,6 +27586,7 @@ var seed = 1;
27575
27586
  ];
27576
27587
  case 1:
27577
27588
  _state.sent();
27589
+ _this.assignImageBitmapOptions(textures);
27578
27590
  return [
27579
27591
  2,
27580
27592
  {
@@ -27680,11 +27692,11 @@ var seed = 1;
27680
27692
  if (compressedTexture === void 0) compressedTexture = 0;
27681
27693
  var _this = this;
27682
27694
  return _async_to_generator(function() {
27683
- var _this_options, useCompressedTexture, variables, baseUrl, jobs, loadedImages;
27695
+ var _this_options, useCompressedTexture, variables, disableWebP, disableAVIF, baseUrl, jobs, loadedImages;
27684
27696
  return __generator(this, function(_state) {
27685
27697
  switch(_state.label){
27686
27698
  case 0:
27687
- _this_options = _this.options, useCompressedTexture = _this_options.useCompressedTexture, variables = _this_options.variables;
27699
+ _this_options = _this.options, useCompressedTexture = _this_options.useCompressedTexture, variables = _this_options.variables, disableWebP = _this_options.disableWebP, disableAVIF = _this_options.disableAVIF;
27688
27700
  baseUrl = _this.baseUrl;
27689
27701
  jobs = images.map(/*#__PURE__*/ _async_to_generator(function(img, idx) {
27690
27702
  var png, webp, avif, imageURL, webpURL, avifURL, id, template, background, url, isVideo, loadFn, resultImage, e, compressed, src, bufferURL, _ref, url1, image, _tmp;
@@ -27695,9 +27707,9 @@ var seed = 1;
27695
27707
  // eslint-disable-next-line compat/compat
27696
27708
  imageURL = new URL(png, baseUrl).href;
27697
27709
  // eslint-disable-next-line compat/compat
27698
- webpURL = webp && new URL(webp, baseUrl).href;
27710
+ webpURL = !disableWebP && webp ? new URL(webp, baseUrl).href : undefined;
27699
27711
  // eslint-disable-next-line compat/compat
27700
- avifURL = avif && new URL(avif, baseUrl).href;
27712
+ avifURL = !disableAVIF && avif ? new URL(avif, baseUrl).href : undefined;
27701
27713
  id = img.id;
27702
27714
  if (!("template" in img)) return [
27703
27715
  3,
@@ -27806,7 +27818,7 @@ var seed = 1;
27806
27818
  ];
27807
27819
  return [
27808
27820
  4,
27809
- loadAVIFOptional(imageURL, avifURL)
27821
+ loadAVIFOptional(imageURL, avifURL, _this.imageBitmapOptions[id])
27810
27822
  ];
27811
27823
  case 10:
27812
27824
  _tmp = _state.sent();
@@ -27817,7 +27829,7 @@ var seed = 1;
27817
27829
  case 11:
27818
27830
  return [
27819
27831
  4,
27820
- loadWebPOptional(imageURL, webpURL)
27832
+ loadWebPOptional(imageURL, webpURL, _this.imageBitmapOptions[id])
27821
27833
  ];
27822
27834
  case 12:
27823
27835
  _tmp = _state.sent();
@@ -28029,6 +28041,21 @@ var seed = 1;
28029
28041
  this.assets[images[i].id] = loadedImages[i];
28030
28042
  }
28031
28043
  };
28044
+ _proto.assignImageBitmapOptions = function assignImageBitmapOptions(textures) {
28045
+ var _this = this;
28046
+ if (textures === void 0) textures = [];
28047
+ textures.forEach(function(texture) {
28048
+ if (!(_instanceof1(texture, Texture) || "mipmaps" in texture)) {
28049
+ var source = texture.source;
28050
+ if (isObject(source)) {
28051
+ _this.imageBitmapOptions[source.id] = {
28052
+ imageOrientation: texture.flipY ? "flipY" : "none",
28053
+ premultiplyAlpha: texture.premultiplyAlpha ? "premultiply" : "none"
28054
+ };
28055
+ }
28056
+ }
28057
+ });
28058
+ };
28032
28059
  _proto.removeTimer = function removeTimer(id) {
28033
28060
  var index = this.timers.indexOf(id);
28034
28061
  if (index !== -1) {
@@ -28038,11 +28065,15 @@ var seed = 1;
28038
28065
  /**
28039
28066
  * 销毁方法
28040
28067
  */ _proto.dispose = function dispose() {
28068
+ var _this = this;
28041
28069
  if (this.timers.length) {
28042
28070
  this.timers.map(function(id) {
28043
28071
  return window.clearTimeout(id);
28044
28072
  });
28045
28073
  }
28074
+ closeImageBitMap(Object.keys(this.assets).map(function(key) {
28075
+ return _this.assets[key];
28076
+ }));
28046
28077
  this.assets = {};
28047
28078
  this.sourceFrom = {};
28048
28079
  this.timers = [];
@@ -28059,7 +28090,7 @@ function createTextureOptionsBySource(image, sourceFrom, id) {
28059
28090
  };
28060
28091
  if (_instanceof1(image, Texture)) {
28061
28092
  return _extends({}, image.source, options);
28062
- } else if (_instanceof1(image, HTMLImageElement) || isCanvas(image)) {
28093
+ } else if (_instanceof1(image, HTMLImageElement) || _instanceof1(image, ImageBitmap) || isCanvas(image)) {
28063
28094
  return _extends({
28064
28095
  image: image,
28065
28096
  sourceType: exports.TextureSourceType.image,
@@ -28915,7 +28946,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
28915
28946
  if (!this.assigned || this.paused) {
28916
28947
  return;
28917
28948
  }
28918
- var dt = this.getUpdateTime(deltaTime * this.speed);
28949
+ var dt = parseFloat(this.getUpdateTime(deltaTime * this.speed).toFixed(0));
28919
28950
  this.updateRootComposition(dt / 1000);
28920
28951
  this.updateVideo();
28921
28952
  // 更新 model-tree-plugin
@@ -31392,7 +31423,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
31392
31423
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
31393
31424
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
31394
31425
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
31395
- var version = "2.1.5-alpha.0";
31426
+ var version = "2.2.0-alpha.0";
31396
31427
  logger.info("Core version: " + version + ".");
31397
31428
 
31398
31429
  exports.AbstractPlugin = AbstractPlugin;
@@ -31442,6 +31473,7 @@ exports.HELP_LINK = HELP_LINK;
31442
31473
  exports.InteractLoader = InteractLoader;
31443
31474
  exports.InteractMesh = InteractMesh;
31444
31475
  exports.KTXTexture = KTXTexture;
31476
+ exports.LOAD_PREFER_IMAGE_BITMAP = LOAD_PREFER_IMAGE_BITMAP;
31445
31477
  exports.LineSegments = LineSegments;
31446
31478
  exports.LinearValue = LinearValue;
31447
31479
  exports.Material = Material;
@@ -31455,6 +31487,7 @@ exports.ParticleBehaviourPlayableAsset = ParticleBehaviourPlayableAsset;
31455
31487
  exports.ParticleLoader = ParticleLoader;
31456
31488
  exports.ParticleMesh = ParticleMesh;
31457
31489
  exports.ParticleSystemRenderer = ParticleSystemRenderer;
31490
+ exports.ParticleTrack = ParticleTrack;
31458
31491
  exports.PassTextureCache = PassTextureCache;
31459
31492
  exports.PathSegments = PathSegments;
31460
31493
  exports.PluginSystem = PluginSystem;
@@ -31511,6 +31544,7 @@ exports.base64ToFile = base64ToFile;
31511
31544
  exports.blend = blend;
31512
31545
  exports.calculateTranslation = calculateTranslation;
31513
31546
  exports.canvasPool = canvasPool;
31547
+ exports.closeImageBitMap = closeImageBitMap;
31514
31548
  exports.colorGradingFrag = colorGradingFrag;
31515
31549
  exports.colorStopsFromGradient = colorStopsFromGradient;
31516
31550
  exports.colorToArr = colorToArr$1;
@@ -31589,6 +31623,7 @@ exports.loadAVIFOptional = loadAVIFOptional;
31589
31623
  exports.loadBinary = loadBinary;
31590
31624
  exports.loadBlob = loadBlob;
31591
31625
  exports.loadImage = loadImage;
31626
+ exports.loadImageBitmap = loadImageBitmap;
31592
31627
  exports.loadMedia = loadMedia;
31593
31628
  exports.loadVideo = loadVideo;
31594
31629
  exports.loadWebPOptional = loadWebPOptional;