@galacean/effects-core 2.1.5 → 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 +559 -517
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +556 -518
  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
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) {
@@ -17007,14 +17101,10 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17007
17101
  var playableOutput2 = _step2.value;
17008
17102
  this.processFrameWithRoot(playableOutput2);
17009
17103
  }
17010
- // 更新节点时间
17011
- for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playables), _step3; !(_step3 = _iterator3()).done;){
17012
- var playable = _step3.value;
17013
- this.updatePlayableTime(playable, dt / 1000);
17014
- }
17015
- };
17016
- _proto.connect = function connect(source, sourceOutputPort, destination, destinationInputPort) {
17017
- destination.connectInput(destinationInputPort, source, sourceOutputPort);
17104
+ // 更新节点时间
17105
+ // for (const playable of this.playables) {
17106
+ // this.updatePlayableTime(playable, dt / 1000);
17107
+ // }
17018
17108
  };
17019
17109
  _proto.addOutput = function addOutput(output) {
17020
17110
  this.playableOutputs.push(output);
@@ -17023,12 +17113,12 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17023
17113
  this.playables.push(playable);
17024
17114
  };
17025
17115
  _proto.processFrameWithRoot = function processFrameWithRoot(output) {
17026
- output.sourcePlayable.processFrameRecursive(output.context, output.getSourceOutputPort());
17116
+ output.sourcePlayable.processFrame(output.context);
17027
17117
  output.processFrame();
17028
17118
  };
17029
17119
  _proto.prepareFrameWithRoot = function prepareFrameWithRoot(output) {
17030
- output.sourcePlayable.prepareFrameRecursive(output.context, output.getSourceOutputPort());
17031
17120
  output.prepareFrame();
17121
+ output.sourcePlayable.prepareFrame(output.context);
17032
17122
  };
17033
17123
  _proto.updatePlayableTime = function updatePlayableTime(playable, deltaTime) {
17034
17124
  if (playable.getPlayState() !== 0) {
@@ -17043,24 +17133,15 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17043
17133
  * @since 2.0.0
17044
17134
  */ var Playable = /*#__PURE__*/ function() {
17045
17135
  function Playable(graph, inputCount) {
17046
- if (inputCount === void 0) inputCount = 0;
17047
17136
  this.onPlayablePlayFlag = true;
17048
17137
  this.onPlayablePauseFlag = false;
17049
17138
  this.duration = 0;
17050
17139
  this.destroyed = false;
17051
- this.inputs = [];
17052
- this.inputOuputPorts = [];
17053
- this.inputWeight = [];
17054
- this.outputs = [];
17055
17140
  this.playState = 0;
17056
- this.traversalMode = 0;
17057
17141
  /**
17058
17142
  * 当前本地播放的时间
17059
17143
  */ this.time = 0;
17060
17144
  graph.addPlayable(this);
17061
- this.inputs = new Array(inputCount);
17062
- this.inputOuputPorts = new Array(inputCount);
17063
- this.inputWeight = new Array(inputCount);
17064
17145
  }
17065
17146
  var _proto = Playable.prototype;
17066
17147
  _proto.play = function play() {
@@ -17083,56 +17164,6 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17083
17164
  break;
17084
17165
  }
17085
17166
  };
17086
- _proto.connectInput = function connectInput(inputPort, sourcePlayable, sourceOutputPort, weight) {
17087
- if (weight === void 0) weight = 1.0;
17088
- this.setInput(sourcePlayable, inputPort);
17089
- this.setInputWeight(inputPort, weight);
17090
- sourcePlayable.setOutput(this, sourceOutputPort);
17091
- if (this.inputOuputPorts.length < inputPort + 1) {
17092
- this.inputOuputPorts.length = inputPort + 1;
17093
- }
17094
- this.inputOuputPorts[inputPort] = sourceOutputPort;
17095
- };
17096
- _proto.addInput = function addInput(sourcePlayable, sourceOutputPort, weight) {
17097
- if (weight === void 0) weight = 1.0;
17098
- this.connectInput(this.getInputCount(), sourcePlayable, sourceOutputPort, weight);
17099
- };
17100
- _proto.getInputCount = function getInputCount() {
17101
- return this.inputs.length;
17102
- };
17103
- _proto.getInputs = function getInputs() {
17104
- return this.inputs;
17105
- };
17106
- _proto.getInput = function getInput(index) {
17107
- return this.inputs[index];
17108
- };
17109
- _proto.getOutputCount = function getOutputCount() {
17110
- return this.outputs.length;
17111
- };
17112
- _proto.getOutputs = function getOutputs() {
17113
- return this.outputs;
17114
- };
17115
- _proto.getOutput = function getOutput(index) {
17116
- return this.outputs[index];
17117
- };
17118
- _proto.getInputWeight = function getInputWeight(inputIndex) {
17119
- return this.inputWeight[inputIndex];
17120
- };
17121
- _proto.setInputWeight = function setInputWeight(playableOrIndex, weight) {
17122
- if (_instanceof1(playableOrIndex, Playable)) {
17123
- for(var i = 0; i < this.inputs.length; i++){
17124
- if (this.inputs[i] === playableOrIndex) {
17125
- this.inputWeight[i] = weight;
17126
- return;
17127
- }
17128
- }
17129
- } else {
17130
- if (this.inputWeight.length < playableOrIndex + 1) {
17131
- this.inputWeight.length = playableOrIndex + 1;
17132
- }
17133
- this.inputWeight[playableOrIndex] = weight;
17134
- }
17135
- };
17136
17167
  _proto.setTime = function setTime(time) {
17137
17168
  this.time = time;
17138
17169
  };
@@ -17148,18 +17179,14 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17148
17179
  _proto.getPlayState = function getPlayState() {
17149
17180
  return this.playState;
17150
17181
  };
17151
- _proto.setTraversalMode = function setTraversalMode(mode) {
17152
- this.traversalMode = mode;
17153
- };
17154
- _proto.getTraversalMode = function getTraversalMode() {
17155
- return this.traversalMode;
17156
- };
17157
17182
  // onGraphStart () {
17158
17183
  // }
17159
17184
  // onGraphStop () {
17160
17185
  // }
17161
- _proto.onPlayablePlay = function onPlayablePlay(context) {};
17162
- _proto.onPlayablePause = function onPlayablePause(context) {};
17186
+ // onPlayablePlay (context: FrameContext) {
17187
+ // }
17188
+ // onPlayablePause (context: FrameContext) {
17189
+ // }
17163
17190
  _proto.prepareFrame = function prepareFrame(context) {};
17164
17191
  _proto.processFrame = function processFrame(context) {};
17165
17192
  _proto.onPlayableDestroy = function onPlayableDestroy() {};
@@ -17171,76 +17198,6 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17171
17198
  // TODO 将节点从动画图中移除
17172
17199
  this.destroyed = true;
17173
17200
  };
17174
- /**
17175
- * @internal
17176
- */ _proto.prepareFrameRecursive = function prepareFrameRecursive(context, passthroughPort) {
17177
- if (this.destroyed || this.playState !== 0) {
17178
- return;
17179
- }
17180
- if (this.onPlayablePlayFlag) {
17181
- this.onPlayablePlay(context);
17182
- this.onPlayablePlayFlag = false;
17183
- }
17184
- if (this.onPlayablePauseFlag) {
17185
- this.onPlayablePause(context);
17186
- this.onPlayablePauseFlag = false;
17187
- }
17188
- if (passthroughPort === 0) {
17189
- this.prepareFrame(context);
17190
- }
17191
- // 前序遍历,用于设置节点的初始状态,weight etc.
17192
- switch(this.getTraversalMode()){
17193
- case 0:
17194
- for(var i = 0; i < this.getInputCount(); i++){
17195
- var input = this.getInput(i);
17196
- input.prepareFrameRecursive(context, this.inputOuputPorts[i]);
17197
- }
17198
- break;
17199
- case 1:
17200
- {
17201
- var input1 = this.getInput(passthroughPort);
17202
- input1.prepareFrameRecursive(context, this.inputOuputPorts[passthroughPort]);
17203
- break;
17204
- }
17205
- }
17206
- };
17207
- /**
17208
- * @internal
17209
- */ _proto.processFrameRecursive = function processFrameRecursive(context, passthroughPort) {
17210
- if (this.destroyed || this.playState !== 0) {
17211
- return;
17212
- }
17213
- // 后序遍历,保证 playable 拿到的 input 节点的估计数据是最新的
17214
- switch(this.getTraversalMode()){
17215
- case 0:
17216
- {
17217
- for(var i = 0; i < this.getInputCount(); i++){
17218
- var input = this.getInput(i);
17219
- input.processFrameRecursive(context, this.inputOuputPorts[i]);
17220
- }
17221
- break;
17222
- }
17223
- case 1:
17224
- {
17225
- var input1 = this.getInput(passthroughPort);
17226
- input1.processFrameRecursive(context, this.inputOuputPorts[passthroughPort]);
17227
- break;
17228
- }
17229
- }
17230
- this.processFrame(context);
17231
- };
17232
- _proto.setOutput = function setOutput(outputPlayable, outputPort) {
17233
- if (this.outputs.length < outputPort + 1) {
17234
- this.outputs.length = outputPort + 1;
17235
- }
17236
- this.outputs[outputPort] = outputPlayable;
17237
- };
17238
- _proto.setInput = function setInput(inputPlayable, inputPort) {
17239
- if (this.inputs.length < inputPort + 1) {
17240
- this.inputs.length = inputPort + 1;
17241
- }
17242
- this.inputs[inputPort] = inputPlayable;
17243
- };
17244
17201
  return Playable;
17245
17202
  }();
17246
17203
  /**
@@ -17248,20 +17205,14 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17248
17205
  * @since 2.0.0
17249
17206
  */ var PlayableOutput = /*#__PURE__*/ function() {
17250
17207
  function PlayableOutput() {
17251
- this.sourceOutputPort = 0;
17252
17208
  this.context = {
17253
17209
  deltaTime: 0,
17254
17210
  output: this
17255
17211
  };
17256
17212
  }
17257
17213
  var _proto = PlayableOutput.prototype;
17258
- _proto.setSourcePlayable = function setSourcePlayable(playable, port) {
17259
- if (port === void 0) port = 0;
17214
+ _proto.setSourcePlayable = function setSourcePlayable(playable) {
17260
17215
  this.sourcePlayable = playable;
17261
- this.sourceOutputPort = port;
17262
- };
17263
- _proto.getSourceOutputPort = function getSourceOutputPort() {
17264
- return this.sourceOutputPort;
17265
17216
  };
17266
17217
  _proto.setUserData = function setUserData(value) {
17267
17218
  this.userData = value;
@@ -17287,11 +17238,6 @@ var PlayState;
17287
17238
  PlayState[PlayState["Playing"] = 0] = "Playing";
17288
17239
  PlayState[PlayState["Paused"] = 1] = "Paused";
17289
17240
  })(PlayState || (PlayState = {}));
17290
- var PlayableTraversalMode;
17291
- (function(PlayableTraversalMode) {
17292
- PlayableTraversalMode[PlayableTraversalMode["Mix"] = 0] = "Mix";
17293
- PlayableTraversalMode[PlayableTraversalMode["Passthrough"] = 1] = "Passthrough";
17294
- })(PlayableTraversalMode || (PlayableTraversalMode = {}));
17295
17241
 
17296
17242
  var tempQuat$1 = new Quaternion();
17297
17243
  var seed$3 = 1;
@@ -18858,20 +18804,6 @@ SpriteComponent = __decorate([
18858
18804
  effectsClass(DataType.SpriteComponent)
18859
18805
  ], SpriteComponent);
18860
18806
 
18861
- var RUNTIME_ENV = "runtime_env";
18862
- var RENDER_PREFER_LOOKUP_TEXTURE = "lookup_texture";
18863
- // 文本元素使用 offscreen canvas 绘制
18864
- var TEMPLATE_USE_OFFSCREEN_CANVAS = "offscreen_canvas";
18865
- // 后处理配置相关
18866
- var POST_PROCESS_SETTINGS = "post_process_settings";
18867
- var config = {};
18868
- function getConfig(name) {
18869
- return config[name];
18870
- }
18871
- function setConfig(name, value) {
18872
- return config[name] = value;
18873
- }
18874
-
18875
18807
  var Cone = /*#__PURE__*/ function() {
18876
18808
  function Cone(props) {
18877
18809
  var _this = this;
@@ -22796,12 +22728,6 @@ var AnimationStream = /*#__PURE__*/ function() {
22796
22728
  _proto.findCurveValue = function findCurveValue(componentType, propertyName) {
22797
22729
  return this.curveValues[componentType + propertyName];
22798
22730
  };
22799
- _proto.getInputStream = function getInputStream(index) {
22800
- var inputPlayable = this.playable.getInput(index);
22801
- if (_instanceof1(inputPlayable, AnimationPlayable)) {
22802
- return inputPlayable.animationStream;
22803
- }
22804
- };
22805
22731
  return AnimationStream;
22806
22732
  }();
22807
22733
 
@@ -23136,266 +23062,147 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
23136
23062
  return AnimationClipPlayable;
23137
23063
  }(Playable);
23138
23064
 
23139
- /**
23140
- * @since 2.0.0
23141
- */ var TimelineClip = /*#__PURE__*/ function() {
23142
- function TimelineClip() {
23143
- this.start = 0;
23144
- this.duration = 0;
23145
- }
23146
- var _proto = TimelineClip.prototype;
23147
- _proto.toLocalTime = function toLocalTime(time) {
23148
- var localTime = time - this.start;
23149
- var duration = this.duration;
23150
- if (localTime - duration > 0) {
23151
- if (this.endBehavior === EndBehavior.restart) {
23152
- localTime = localTime % duration;
23153
- } else if (this.endBehavior === EndBehavior.freeze) {
23154
- localTime = Math.min(duration, localTime);
23155
- }
23156
- }
23157
- return localTime;
23158
- };
23159
- return TimelineClip;
23160
- }();
23161
- var TrackAsset = /*#__PURE__*/ function(PlayableAsset) {
23162
- _inherits(TrackAsset, PlayableAsset);
23163
- function TrackAsset() {
23065
+ var TrackMixerPlayable = /*#__PURE__*/ function(Playable1) {
23066
+ _inherits(TrackMixerPlayable, Playable1);
23067
+ function TrackMixerPlayable() {
23164
23068
  var _this;
23165
- _this = PlayableAsset.apply(this, arguments) || this;
23166
- _this.trackType = 0;
23167
- _this.clipSeed = 0;
23168
- _this.clips = [];
23169
- _this.children = [];
23069
+ _this = Playable1.apply(this, arguments) || this;
23070
+ _this.clipPlayables = [];
23071
+ _this.clipWeights = [];
23170
23072
  return _this;
23171
23073
  }
23172
- var _proto = TrackAsset.prototype;
23173
- /**
23174
- * 重写该方法以获取自定义对象绑定
23175
- */ _proto.updateAnimatedObject = function updateAnimatedObject() {
23176
- if (this.parent) {
23177
- 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);
23178
23079
  }
23080
+ this.evaluate(context);
23179
23081
  };
23180
- /**
23181
- * 重写该方法以创建自定义混合器
23182
- */ _proto.createTrackMixer = function createTrackMixer(graph) {
23183
- 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
+ }
23184
23096
  };
23185
- _proto.createOutput = function createOutput() {
23186
- var output = new PlayableOutput();
23187
- return output;
23097
+ _proto.getClipWeight = function getClipWeight(inputIndex) {
23098
+ return this.clipWeights[inputIndex];
23188
23099
  };
23189
- _proto.createPlayableGraph = function createPlayableGraph(graph, runtimeClips) {
23190
- var mixerPlayable = this.createMixerPlayableGraph(graph, runtimeClips);
23191
- return mixerPlayable;
23100
+ _proto.getClipPlayable = function getClipPlayable(index) {
23101
+ return this.clipPlayables[index];
23192
23102
  };
23193
- _proto.createMixerPlayableGraph = function createMixerPlayableGraph(graph, runtimeClips) {
23194
- var clips = [];
23195
- for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
23196
- var clip = _step.value;
23197
- clips.push(clip);
23198
- }
23199
- var mixerPlayable = this.compileClips(graph, clips, runtimeClips);
23200
- return mixerPlayable;
23103
+ _proto.evaluate = function evaluate(context) {
23104
+ // Override
23201
23105
  };
23202
- _proto.compileClips = function compileClips(graph, timelineClips, runtimeClips) {
23203
- var mixer = this.createTrackMixer(graph);
23204
- for(var _iterator = _create_for_of_iterator_helper_loose(timelineClips), _step; !(_step = _iterator()).done;){
23205
- var timelineClip = _step.value;
23206
- var clipPlayable = this.createClipPlayable(graph, timelineClip);
23207
- clipPlayable.setDuration(timelineClip.duration);
23208
- var clip = new RuntimeClip(timelineClip, clipPlayable, mixer, this);
23209
- runtimeClips.push(clip);
23210
- mixer.addInput(clipPlayable, 0);
23211
- 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);
23212
23134
  }
23213
- return mixer;
23214
- };
23215
- _proto.createPlayable = function createPlayable(graph) {
23216
- return new Playable(graph);
23217
- };
23218
- _proto.getChildTracks = function getChildTracks() {
23219
- return this.children;
23220
23135
  };
23221
- _proto.addChild = function addChild(child) {
23222
- this.children.push(child);
23223
- child.parent = this;
23224
- };
23225
- _proto.createClip = function createClip(classConstructor, name) {
23226
- var newClip = new TimelineClip();
23227
- newClip.asset = new classConstructor(this.engine);
23228
- newClip.name = name ? name : "TimelineClip" + newClip.id;
23229
- this.addClip(newClip);
23230
- return newClip;
23231
- };
23232
- _proto.getClips = function getClips() {
23233
- return this.clips;
23234
- };
23235
- _proto.findClip = function findClip(name) {
23236
- for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
23237
- var clip = _step.value;
23238
- if (clip.name === name) {
23239
- return clip;
23240
- }
23241
- }
23242
- };
23243
- _proto.addClip = function addClip(clip) {
23244
- clip.id = (this.clipSeed++).toString();
23245
- this.clips.push(clip);
23246
- };
23247
- _proto.createClipPlayable = function createClipPlayable(graph, clip) {
23248
- return clip.asset.createPlayable(graph);
23249
- };
23250
- _proto.fromData = function fromData(data) {
23251
- PlayableAsset.prototype.fromData.call(this, data);
23252
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
23253
- var child = _step.value;
23254
- child.parent = this;
23255
- }
23256
- };
23257
- return TrackAsset;
23258
- }(PlayableAsset);
23259
- __decorate([
23260
- serialize(TimelineClip)
23261
- ], TrackAsset.prototype, "clips", void 0);
23262
- __decorate([
23263
- serialize()
23264
- ], TrackAsset.prototype, "children", void 0);
23265
- TrackAsset = __decorate([
23266
- effectsClass(DataType.TrackAsset)
23267
- ], TrackAsset);
23268
- var TrackType;
23269
- (function(TrackType) {
23270
- TrackType[TrackType["MasterTrack"] = 0] = "MasterTrack";
23271
- TrackType[TrackType["ObjectTrack"] = 1] = "ObjectTrack";
23272
- })(TrackType || (TrackType = {}));
23273
- var RuntimeClip = /*#__PURE__*/ function() {
23274
- function RuntimeClip(clip, clipPlayable, parentMixer, track) {
23275
- this.clip = clip;
23276
- this.playable = clipPlayable;
23277
- this.parentMixer = parentMixer;
23278
- this.track = track;
23279
- if (_instanceof1(this.track.boundObject, VFXItem)) {
23280
- this.particleSystem = this.track.boundObject.getComponent(ParticleSystem);
23281
- }
23282
- }
23283
- var _proto = RuntimeClip.prototype;
23284
- _proto.evaluateAt = function evaluateAt(localTime) {
23285
- var clip = this.clip;
23286
- var weight = 1.0;
23287
- var ended = false;
23288
- var started = false;
23289
- var boundObject = this.track.boundObject;
23290
- if (localTime >= clip.start + clip.duration && clip.endBehavior === EndBehavior.destroy) {
23291
- if (_instanceof1(boundObject, VFXItem) && VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
23292
- weight = 1.0;
23293
- } else {
23294
- weight = 0.0;
23295
- ended = true;
23296
- }
23297
- } else if (localTime - this.clip.start >= 0) {
23298
- weight = 1.0;
23299
- started = true;
23300
- } else if (localTime < clip.start) {
23301
- weight = 0.0;
23302
- }
23303
- if (started && this.playable.getPlayState() !== PlayState.Playing) {
23304
- this.playable.play();
23305
- }
23306
- this.parentMixer.setInputWeight(this.playable, weight);
23307
- var clipTime = parseFloat(clip.toLocalTime(localTime).toFixed(3));
23308
- this.playable.setTime(clipTime);
23309
- // 判断动画是否结束
23310
- if (ended) {
23311
- if (this.playable.getPlayState() === PlayState.Playing) {
23312
- this.playable.pause();
23313
- }
23314
- }
23315
- };
23316
- _create_class(RuntimeClip, [
23317
- {
23318
- key: "enable",
23319
- set: function set(value) {
23320
- if (value) {
23321
- this.playable.play();
23322
- } else {
23323
- this.parentMixer.setInputWeight(this.playable, 0);
23324
- this.playable.pause();
23325
- }
23326
- }
23327
- }
23328
- ]);
23329
- return RuntimeClip;
23330
- }();
23136
+ return ActivationMixerPlayable;
23137
+ }(TrackMixerPlayable);
23331
23138
 
23332
- var ActivationMixerPlayable = /*#__PURE__*/ function(Playable) {
23333
- _inherits(ActivationMixerPlayable, Playable);
23334
- function ActivationMixerPlayable() {
23139
+ var PropertyClipPlayable = /*#__PURE__*/ function(Playable) {
23140
+ _inherits(PropertyClipPlayable, Playable);
23141
+ function PropertyClipPlayable() {
23335
23142
  return Playable.apply(this, arguments);
23336
23143
  }
23337
- var _proto = ActivationMixerPlayable.prototype;
23144
+ var _proto = PropertyClipPlayable.prototype;
23338
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) {
23339
23161
  var boundObject = context.output.getUserData();
23340
- if (!_instanceof1(boundObject, VFXItem)) {
23162
+ if (!boundObject) {
23341
23163
  return;
23342
23164
  }
23343
- var boundItem = boundObject;
23344
23165
  var hasInput = false;
23345
- for(var i = 0; i < this.getInputCount(); i++){
23346
- 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;
23347
23185
  hasInput = true;
23348
- break;
23349
23186
  }
23350
23187
  }
23188
+ // set value
23351
23189
  if (hasInput) {
23352
- boundItem.transform.setValid(true);
23353
- boundItem.setActive(true);
23354
- } else {
23355
- boundItem.transform.setValid(false);
23356
- boundItem.setActive(false);
23190
+ boundObject[this.propertyName] = value;
23357
23191
  }
23358
23192
  };
23359
- return ActivationMixerPlayable;
23360
- }(Playable);
23361
-
23362
- var ActivationTrack = /*#__PURE__*/ function(TrackAsset) {
23363
- _inherits(ActivationTrack, TrackAsset);
23364
- function ActivationTrack() {
23365
- return TrackAsset.apply(this, arguments);
23366
- }
23367
- var _proto = ActivationTrack.prototype;
23368
- _proto.createTrackMixer = function createTrackMixer(graph) {
23369
- return new ActivationMixerPlayable(graph);
23370
- };
23371
- return ActivationTrack;
23372
- }(TrackAsset);
23373
- ActivationTrack = __decorate([
23374
- effectsClass(DataType.ActivationTrack)
23375
- ], ActivationTrack);
23376
-
23377
- var PropertyClipPlayable = /*#__PURE__*/ function(Playable) {
23378
- _inherits(PropertyClipPlayable, Playable);
23379
- function PropertyClipPlayable() {
23380
- return Playable.apply(this, arguments);
23381
- }
23382
- var _proto = PropertyClipPlayable.prototype;
23383
- _proto.processFrame = function processFrame(context) {
23384
- this.value = this.curve.getValue(this.time / this.getDuration());
23385
- };
23386
- return PropertyClipPlayable;
23387
- }(Playable);
23193
+ return ColorPropertyMixerPlayable;
23194
+ }(TrackMixerPlayable);
23388
23195
 
23389
- var FloatPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
23390
- _inherits(FloatPropertyMixerPlayable, Playable);
23196
+ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23197
+ _inherits(FloatPropertyMixerPlayable, TrackMixerPlayable);
23391
23198
  function FloatPropertyMixerPlayable() {
23392
23199
  var _this;
23393
- _this = Playable.apply(this, arguments) || this;
23200
+ _this = TrackMixerPlayable.apply(this, arguments) || this;
23394
23201
  _this.propertyName = "";
23395
23202
  return _this;
23396
23203
  }
23397
23204
  var _proto = FloatPropertyMixerPlayable.prototype;
23398
- _proto.processFrame = function processFrame(context) {
23205
+ _proto.evaluate = function evaluate(context) {
23399
23206
  var boundObject = context.output.getUserData();
23400
23207
  if (!boundObject) {
23401
23208
  return;
@@ -23403,10 +23210,10 @@ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
23403
23210
  var hasInput = false;
23404
23211
  var value = 0;
23405
23212
  // evaluate the curve
23406
- for(var i = 0; i < this.getInputCount(); i++){
23407
- var weight = this.getInputWeight(i);
23213
+ for(var i = 0; i < this.clipPlayables.length; i++){
23214
+ var weight = this.getClipWeight(i);
23408
23215
  if (weight > 0) {
23409
- var propertyClipPlayable = this.getInput(i);
23216
+ var propertyClipPlayable = this.getClipPlayable(i);
23410
23217
  if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
23411
23218
  console.error("FloatPropertyTrack added non-FloatPropertyPlayableAsset");
23412
23219
  continue;
@@ -23422,7 +23229,27 @@ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
23422
23229
  }
23423
23230
  };
23424
23231
  return FloatPropertyMixerPlayable;
23425
- }(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);
23426
23253
 
23427
23254
  var SerializationHelper = /*#__PURE__*/ function() {
23428
23255
  function SerializationHelper() {}
@@ -23914,7 +23741,8 @@ var SerializationHelper = /*#__PURE__*/ function() {
23914
23741
  this.timelinePlayable.setTime(time);
23915
23742
  // The properties of the object may change dynamically,
23916
23743
  // so reset the track binding to avoid invalidation of the previously obtained binding object.
23917
- this.resolveBindings();
23744
+ // this.resolveBindings();
23745
+ this.timelinePlayable.evaluate();
23918
23746
  this.graph.evaluate(dt);
23919
23747
  };
23920
23748
  _proto.createContent = function createContent() {
@@ -24093,21 +23921,21 @@ var SubCompositionClipPlayable = /*#__PURE__*/ function(Playable) {
24093
23921
  return SubCompositionClipPlayable;
24094
23922
  }(Playable);
24095
23923
 
24096
- var SubCompositionMixerPlayable = /*#__PURE__*/ function(Playable) {
24097
- _inherits(SubCompositionMixerPlayable, Playable);
23924
+ var SubCompositionMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23925
+ _inherits(SubCompositionMixerPlayable, TrackMixerPlayable);
24098
23926
  function SubCompositionMixerPlayable() {
24099
- return Playable.apply(this, arguments);
23927
+ return TrackMixerPlayable.apply(this, arguments);
24100
23928
  }
24101
23929
  var _proto = SubCompositionMixerPlayable.prototype;
24102
- _proto.processFrame = function processFrame(context) {
23930
+ _proto.evaluate = function evaluate(context) {
24103
23931
  var boundObject = context.output.getUserData();
24104
23932
  if (!_instanceof1(boundObject, CompositionComponent)) {
24105
23933
  return;
24106
23934
  }
24107
23935
  var compositionComponent = boundObject;
24108
23936
  var hasInput = false;
24109
- for(var i = 0; i < this.getInputCount(); i++){
24110
- if (this.getInputWeight(i) > 0) {
23937
+ for(var i = 0; i < this.clipPlayables.length; i++){
23938
+ if (this.getClipWeight(i) > 0) {
24111
23939
  hasInput = true;
24112
23940
  break;
24113
23941
  }
@@ -24119,18 +23947,28 @@ var SubCompositionMixerPlayable = /*#__PURE__*/ function(Playable) {
24119
23947
  }
24120
23948
  };
24121
23949
  return SubCompositionMixerPlayable;
24122
- }(Playable);
23950
+ }(TrackMixerPlayable);
24123
23951
 
24124
- var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24125
- _inherits(Vector4PropertyMixerPlayable, Playable);
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);
23961
+
23962
+ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23963
+ _inherits(Vector4PropertyMixerPlayable, TrackMixerPlayable);
24126
23964
  function Vector4PropertyMixerPlayable() {
24127
23965
  var _this;
24128
- _this = Playable.apply(this, arguments) || this;
23966
+ _this = TrackMixerPlayable.apply(this, arguments) || this;
24129
23967
  _this.propertyName = "";
24130
23968
  return _this;
24131
23969
  }
24132
23970
  var _proto = Vector4PropertyMixerPlayable.prototype;
24133
- _proto.processFrame = function processFrame(context) {
23971
+ _proto.evaluate = function evaluate(context) {
24134
23972
  var boundObject = context.output.getUserData();
24135
23973
  if (!boundObject) {
24136
23974
  return;
@@ -24142,10 +23980,10 @@ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24142
23980
  }
24143
23981
  value.setZero();
24144
23982
  // evaluate the curve
24145
- for(var i = 0; i < this.getInputCount(); i++){
24146
- var weight = this.getInputWeight(i);
23983
+ for(var i = 0; i < this.clipPlayables.length; i++){
23984
+ var weight = this.getClipWeight(i);
24147
23985
  if (weight > 0) {
24148
- var propertyClipPlayable = this.getInput(i);
23986
+ var propertyClipPlayable = this.getClipPlayable(i);
24149
23987
  if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
24150
23988
  console.error("Vector4PropertyTrack added non-Vector4PropertyPlayableAsset");
24151
23989
  continue;
@@ -24164,52 +24002,215 @@ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24164
24002
  }
24165
24003
  };
24166
24004
  return Vector4PropertyMixerPlayable;
24167
- }(Playable);
24005
+ }(TrackMixerPlayable);
24168
24006
 
24169
- var ColorPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24170
- _inherits(ColorPropertyMixerPlayable, Playable);
24171
- 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() {
24172
24032
  var _this;
24173
- _this = Playable.apply(this, arguments) || this;
24174
- _this.propertyName = "";
24033
+ _this = PlayableAsset.apply(this, arguments) || this;
24034
+ _this.trackType = 0;
24035
+ _this.clipSeed = 0;
24036
+ _this.clips = [];
24037
+ _this.children = [];
24175
24038
  return _this;
24176
24039
  }
24177
- var _proto = ColorPropertyMixerPlayable.prototype;
24178
- _proto.processFrame = function processFrame(context) {
24179
- var boundObject = context.output.getUserData();
24180
- if (!boundObject) {
24181
- return;
24040
+ var _proto = TrackAsset.prototype;
24041
+ /**
24042
+ * 重写该方法以获取自定义对象绑定
24043
+ */ _proto.updateAnimatedObject = function updateAnimatedObject() {
24044
+ if (this.parent) {
24045
+ this.boundObject = this.parent.boundObject;
24182
24046
  }
24183
- var hasInput = false;
24184
- var value = boundObject[this.propertyName];
24185
- if (!_instanceof1(value, Color)) {
24186
- 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);
24187
24066
  }
24188
- value.setZero();
24189
- // evaluate the curve
24190
- for(var i = 0; i < this.getInputCount(); i++){
24191
- var weight = this.getInputWeight(i);
24192
- if (weight > 0) {
24193
- var propertyClipPlayable = this.getInput(i);
24194
- if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
24195
- console.error("ColorPropertyMixerPlayable received incompatible input");
24196
- continue;
24197
- }
24198
- var curveValue = propertyClipPlayable.value;
24199
- value.r += curveValue.r * weight;
24200
- value.g += curveValue.g * weight;
24201
- value.b += curveValue.b * weight;
24202
- value.a += curveValue.a * weight;
24203
- 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;
24204
24108
  }
24205
24109
  }
24206
- // set value
24207
- if (hasInput) {
24208
- 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;
24209
24123
  }
24210
24124
  };
24211
- return ColorPropertyMixerPlayable;
24212
- }(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);
24213
24214
 
24214
24215
  var PropertyTrack = /*#__PURE__*/ function(TrackAsset) {
24215
24216
  _inherits(PropertyTrack, TrackAsset);
@@ -24282,6 +24283,10 @@ var SpriteColorTrack = /*#__PURE__*/ function(TrackAsset) {
24282
24283
  function SpriteColorTrack() {
24283
24284
  return TrackAsset.apply(this, arguments);
24284
24285
  }
24286
+ var _proto = SpriteColorTrack.prototype;
24287
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24288
+ return new SpriteColorMixerPlayable(graph);
24289
+ };
24285
24290
  return SpriteColorTrack;
24286
24291
  }(TrackAsset);
24287
24292
  SpriteColorTrack = __decorate([
@@ -24314,6 +24319,10 @@ var TransformTrack = /*#__PURE__*/ function(TrackAsset) {
24314
24319
  function TransformTrack() {
24315
24320
  return TrackAsset.apply(this, arguments);
24316
24321
  }
24322
+ var _proto = TransformTrack.prototype;
24323
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24324
+ return new TransformMixerPlayable(graph);
24325
+ };
24317
24326
  return TransformTrack;
24318
24327
  }(TrackAsset);
24319
24328
  TransformTrack = __decorate([
@@ -24342,6 +24351,18 @@ MaterialTrack = __decorate([
24342
24351
  effectsClass("MaterialTrack")
24343
24352
  ], MaterialTrack);
24344
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
+
24345
24366
  var Vector4PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
24346
24367
  _inherits(Vector4PropertyTrack, PropertyTrack);
24347
24368
  function Vector4PropertyTrack() {
@@ -24470,7 +24491,6 @@ var TimelineAsset = /*#__PURE__*/ function(PlayableAsset) {
24470
24491
  var _proto = TimelineAsset.prototype;
24471
24492
  _proto.createPlayable = function createPlayable(graph) {
24472
24493
  var timelinePlayable = new TimelinePlayable(graph);
24473
- timelinePlayable.setTraversalMode(PlayableTraversalMode.Passthrough);
24474
24494
  for(var _iterator = _create_for_of_iterator_helper_loose(this.tracks), _step; !(_step = _iterator()).done;){
24475
24495
  var track = _step.value;
24476
24496
  if (_instanceof1(track, ObjectBindingTrack)) {
@@ -24551,9 +24571,7 @@ var TimelinePlayable = /*#__PURE__*/ function(Playable) {
24551
24571
  return _this;
24552
24572
  }
24553
24573
  var _proto = TimelinePlayable.prototype;
24554
- _proto.prepareFrame = function prepareFrame(context) {
24555
- this.evaluate();
24556
- };
24574
+ _proto.prepareFrame = function prepareFrame(context) {};
24557
24575
  _proto.evaluate = function evaluate() {
24558
24576
  var time = this.getTime();
24559
24577
  // TODO search active clips
@@ -24570,11 +24588,10 @@ var TimelinePlayable = /*#__PURE__*/ function(Playable) {
24570
24588
  var track = _step.value;
24571
24589
  // create track mixer and track output
24572
24590
  var trackMixPlayable = track.createPlayableGraph(graph, this.clips);
24573
- this.addInput(trackMixPlayable, 0);
24574
24591
  var trackOutput = track.createOutput();
24575
24592
  trackOutput.setUserData(track.boundObject);
24576
24593
  graph.addOutput(trackOutput);
24577
- trackOutput.setSourcePlayable(this, this.getInputCount() - 1);
24594
+ trackOutput.setSourcePlayable(trackMixPlayable);
24578
24595
  // create track instance
24579
24596
  var trackInstance = new TrackInstance(track, trackMixPlayable, trackOutput);
24580
24597
  trackInstanceMap[track.getInstanceId()] = trackInstance;
@@ -24635,10 +24652,10 @@ Vector4PropertyPlayableAsset = __decorate([
24635
24652
  effectsClass("Vector4PropertyPlayableAsset")
24636
24653
  ], Vector4PropertyPlayableAsset);
24637
24654
 
24638
- var ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
24639
- _inherits(ObjectBindingTrack, TrackAsset1);
24655
+ var ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset) {
24656
+ _inherits(ObjectBindingTrack, TrackAsset);
24640
24657
  function ObjectBindingTrack() {
24641
- return TrackAsset1.apply(this, arguments);
24658
+ return TrackAsset.apply(this, arguments);
24642
24659
  }
24643
24660
  var _proto = ObjectBindingTrack.prototype;
24644
24661
  _proto.updateAnimatedObject = function updateAnimatedObject() {};
@@ -24649,7 +24666,7 @@ var ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
24649
24666
  var boundItem = this.boundObject;
24650
24667
  // 添加粒子动画 clip // TODO 待移除
24651
24668
  if (boundItem.getComponent(ParticleSystem)) {
24652
- var particleTrack = timelineAsset.createTrack(TrackAsset, this, "ParticleTrack");
24669
+ var particleTrack = timelineAsset.createTrack(ParticleTrack, this, "ParticleTrack");
24653
24670
  particleTrack.boundObject = this.boundObject;
24654
24671
  var particleClip = particleTrack.createClip(ParticleBehaviourPlayableAsset);
24655
24672
  particleClip.start = boundItem.start;
@@ -24679,7 +24696,7 @@ var TextLayout = /*#__PURE__*/ function() {
24679
24696
  this.width = textWidth;
24680
24697
  this.height = textHeight;
24681
24698
  this.letterSpace = letterSpace;
24682
- this.overFlow = textOverflow;
24699
+ this.overflow = textOverflow;
24683
24700
  this.textBaseline = textBaseline;
24684
24701
  this.textAlign = textAlign;
24685
24702
  this.lineHeight = lineHeight;
@@ -27294,6 +27311,7 @@ var seed = 1;
27294
27311
  this.downloader = downloader;
27295
27312
  this.assets = {};
27296
27313
  this.sourceFrom = {};
27314
+ this.imageBitmapOptions = {};
27297
27315
  this.id = seed++;
27298
27316
  this.timers = [];
27299
27317
  this.updateOptions(options);
@@ -27551,12 +27569,12 @@ var seed = 1;
27551
27569
  _proto.processJSON = function processJSON(json) {
27552
27570
  var _this = this;
27553
27571
  return _async_to_generator(function() {
27554
- var jsonScene, _jsonScene_plugins, plugins, pluginSystem;
27572
+ var jsonScene, _jsonScene_plugins, plugins, textures, pluginSystem;
27555
27573
  return __generator(this, function(_state) {
27556
27574
  switch(_state.label){
27557
27575
  case 0:
27558
27576
  jsonScene = getStandardJSON(json);
27559
- _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;
27560
27578
  pluginSystem = new PluginSystem(plugins);
27561
27579
  return [
27562
27580
  4,
@@ -27564,6 +27582,7 @@ var seed = 1;
27564
27582
  ];
27565
27583
  case 1:
27566
27584
  _state.sent();
27585
+ _this.assignImageBitmapOptions(textures);
27567
27586
  return [
27568
27587
  2,
27569
27588
  {
@@ -27669,11 +27688,11 @@ var seed = 1;
27669
27688
  if (compressedTexture === void 0) compressedTexture = 0;
27670
27689
  var _this = this;
27671
27690
  return _async_to_generator(function() {
27672
- var _this_options, useCompressedTexture, variables, baseUrl, jobs, loadedImages;
27691
+ var _this_options, useCompressedTexture, variables, disableWebP, disableAVIF, baseUrl, jobs, loadedImages;
27673
27692
  return __generator(this, function(_state) {
27674
27693
  switch(_state.label){
27675
27694
  case 0:
27676
- _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;
27677
27696
  baseUrl = _this.baseUrl;
27678
27697
  jobs = images.map(/*#__PURE__*/ _async_to_generator(function(img, idx) {
27679
27698
  var png, webp, avif, imageURL, webpURL, avifURL, id, template, background, url, isVideo, loadFn, resultImage, e, compressed, src, bufferURL, _ref, url1, image, _tmp;
@@ -27684,9 +27703,9 @@ var seed = 1;
27684
27703
  // eslint-disable-next-line compat/compat
27685
27704
  imageURL = new URL(png, baseUrl).href;
27686
27705
  // eslint-disable-next-line compat/compat
27687
- webpURL = webp && new URL(webp, baseUrl).href;
27706
+ webpURL = !disableWebP && webp ? new URL(webp, baseUrl).href : undefined;
27688
27707
  // eslint-disable-next-line compat/compat
27689
- avifURL = avif && new URL(avif, baseUrl).href;
27708
+ avifURL = !disableAVIF && avif ? new URL(avif, baseUrl).href : undefined;
27690
27709
  id = img.id;
27691
27710
  if (!("template" in img)) return [
27692
27711
  3,
@@ -27795,7 +27814,7 @@ var seed = 1;
27795
27814
  ];
27796
27815
  return [
27797
27816
  4,
27798
- loadAVIFOptional(imageURL, avifURL)
27817
+ loadAVIFOptional(imageURL, avifURL, _this.imageBitmapOptions[id])
27799
27818
  ];
27800
27819
  case 10:
27801
27820
  _tmp = _state.sent();
@@ -27806,7 +27825,7 @@ var seed = 1;
27806
27825
  case 11:
27807
27826
  return [
27808
27827
  4,
27809
- loadWebPOptional(imageURL, webpURL)
27828
+ loadWebPOptional(imageURL, webpURL, _this.imageBitmapOptions[id])
27810
27829
  ];
27811
27830
  case 12:
27812
27831
  _tmp = _state.sent();
@@ -28018,6 +28037,21 @@ var seed = 1;
28018
28037
  this.assets[images[i].id] = loadedImages[i];
28019
28038
  }
28020
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
+ };
28021
28055
  _proto.removeTimer = function removeTimer(id) {
28022
28056
  var index = this.timers.indexOf(id);
28023
28057
  if (index !== -1) {
@@ -28027,11 +28061,15 @@ var seed = 1;
28027
28061
  /**
28028
28062
  * 销毁方法
28029
28063
  */ _proto.dispose = function dispose() {
28064
+ var _this = this;
28030
28065
  if (this.timers.length) {
28031
28066
  this.timers.map(function(id) {
28032
28067
  return window.clearTimeout(id);
28033
28068
  });
28034
28069
  }
28070
+ closeImageBitMap(Object.keys(this.assets).map(function(key) {
28071
+ return _this.assets[key];
28072
+ }));
28035
28073
  this.assets = {};
28036
28074
  this.sourceFrom = {};
28037
28075
  this.timers = [];
@@ -28048,7 +28086,7 @@ function createTextureOptionsBySource(image, sourceFrom, id) {
28048
28086
  };
28049
28087
  if (_instanceof1(image, Texture)) {
28050
28088
  return _extends({}, image.source, options);
28051
- } else if (_instanceof1(image, HTMLImageElement) || isCanvas(image)) {
28089
+ } else if (_instanceof1(image, HTMLImageElement) || _instanceof1(image, ImageBitmap) || isCanvas(image)) {
28052
28090
  return _extends({
28053
28091
  image: image,
28054
28092
  sourceType: TextureSourceType.image,
@@ -31381,8 +31419,8 @@ registerPlugin("sprite", SpriteLoader, VFXItem, true);
31381
31419
  registerPlugin("particle", ParticleLoader, VFXItem, true);
31382
31420
  registerPlugin("cal", CalculateLoader, VFXItem, true);
31383
31421
  registerPlugin("interact", InteractLoader, VFXItem, true);
31384
- var version = "2.1.5";
31422
+ var version = "2.2.0-alpha.0";
31385
31423
  logger.info("Core version: " + version + ".");
31386
31424
 
31387
- 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 };
31388
31426
  //# sourceMappingURL=index.mjs.map