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