@galacean/effects-threejs 2.1.5 → 2.2.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.js 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
6
+ * Version: v2.2.0
7
7
  */
8
8
 
9
9
  'use strict';
@@ -85,12 +85,8 @@ function __generator(thisArg, body) {
85
85
  },
86
86
  trys: [],
87
87
  ops: []
88
- }, f, y, t, g;
89
- return g = {
90
- next: verb(0),
91
- "throw": verb(1),
92
- "return": verb(2)
93
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
88
+ }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
89
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
94
90
  return this;
95
91
  }), g;
96
92
  function verb(n) {
@@ -12778,8 +12774,8 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
12778
12774
  return data;
12779
12775
  };
12780
12776
  _proto.getMaxTime = function getMaxTime() {
12781
- var keyTimeData = Object.keys(this.curveMap);
12782
- return Number(keyTimeData[keyTimeData.length - 1].split("&")[1]);
12777
+ var keyTimeData = this.keyTimeData;
12778
+ return this.curveMap[keyTimeData[keyTimeData.length - 1]].timeEnd;
12783
12779
  };
12784
12780
  return BezierCurve;
12785
12781
  }(ValueGetter);
@@ -12857,19 +12853,22 @@ var BezierCurvePath = /*#__PURE__*/ function(ValueGetter) {
12857
12853
  timeInterval: timeInterval,
12858
12854
  valueInterval: valueInterval,
12859
12855
  easingCurve: easingCurve,
12860
- pathCurve: pathCurve
12856
+ pathCurve: pathCurve,
12857
+ timeStart: Number(s.x),
12858
+ timeEnd: Number(e.x)
12861
12859
  };
12862
12860
  }
12861
+ this.keyTimeData = Object.keys(this.curveSegments);
12863
12862
  };
12864
12863
  _proto.getValue = function getValue(time) {
12865
12864
  var t = numberToFix(time, 5);
12866
12865
  var perc = 0, point = new Vector3();
12867
- var keyTimeData = Object.keys(this.curveSegments);
12866
+ var keyTimeData = this.keyTimeData;
12868
12867
  if (!keyTimeData.length) {
12869
12868
  return point;
12870
12869
  }
12871
- var keyTimeStart = Number(keyTimeData[0].split("&")[0]);
12872
- var keyTimeEnd = Number(keyTimeData[keyTimeData.length - 1].split("&")[1]);
12870
+ var keyTimeStart = this.curveSegments[keyTimeData[0]].timeStart;
12871
+ var keyTimeEnd = this.curveSegments[keyTimeData[keyTimeData.length - 1]].timeEnd;
12873
12872
  if (t <= keyTimeStart) {
12874
12873
  var pathCurve = this.curveSegments[keyTimeData[0]].pathCurve;
12875
12874
  point = pathCurve.getPointInPercent(0);
@@ -12881,7 +12880,8 @@ var BezierCurvePath = /*#__PURE__*/ function(ValueGetter) {
12881
12880
  return point;
12882
12881
  }
12883
12882
  for(var i = 0; i < keyTimeData.length; i++){
12884
- var _keyTimeData_i_split = keyTimeData[i].split("&"), xMin = _keyTimeData_i_split[0], xMax = _keyTimeData_i_split[1];
12883
+ var xMin = this.curveSegments[keyTimeData[i]].timeStart;
12884
+ var xMax = this.curveSegments[keyTimeData[i]].timeEnd;
12885
12885
  if (t >= Number(xMin) && t < Number(xMax)) {
12886
12886
  var bezierPath = this.curveSegments[keyTimeData[i]].pathCurve;
12887
12887
  perc = this.getPercValue(keyTimeData[i], t);
@@ -12900,8 +12900,8 @@ var BezierCurvePath = /*#__PURE__*/ function(ValueGetter) {
12900
12900
  return clamp$1(value, 0, 1);
12901
12901
  };
12902
12902
  _proto.getMaxTime = function getMaxTime() {
12903
- var keyTimeData = Object.keys(this.curveSegments);
12904
- return Number(keyTimeData[keyTimeData.length - 1].split("&")[1]);
12903
+ var keyTimeData = this.keyTimeData;
12904
+ return this.curveSegments[keyTimeData[keyTimeData.length - 1]].timeEnd;
12905
12905
  };
12906
12906
  return BezierCurvePath;
12907
12907
  }(ValueGetter);
@@ -13054,15 +13054,18 @@ function createKeyFrameMeta() {
13054
13054
  }
13055
13055
 
13056
13056
  function _is_native_reflect_construct() {
13057
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
13058
- if (Reflect.construct.sham) return false;
13059
- if (typeof Proxy === "function") return true;
13057
+ // Since Reflect.construct can't be properly polyfilled, some
13058
+ // implementations (e.g. core-js@2) don't set the correct internal slots.
13059
+ // Those polyfills don't allow us to subclass built-ins, so we need to
13060
+ // use our fallback implementation.
13060
13061
  try {
13061
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
13062
- return true;
13063
- } catch (e) {
13064
- return false;
13065
- }
13062
+ // If the internal slots aren't set, this throws an error similar to
13063
+ // TypeError: this is not a Boolean object.
13064
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
13065
+ } catch (_) {}
13066
+ return (_is_native_reflect_construct = function _is_native_reflect_construct() {
13067
+ return !!result;
13068
+ })();
13066
13069
  }
13067
13070
 
13068
13071
  function _construct(Parent, args, Class) {
@@ -15926,6 +15929,7 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15926
15929
  if (this.animated) {
15927
15930
  this.buildPath(this.data);
15928
15931
  this.buildGeometryFromPath(this.path.shapePath);
15932
+ this.animated = false;
15929
15933
  }
15930
15934
  };
15931
15935
  _proto.buildGeometryFromPath = function buildGeometryFromPath(shapePath) {
@@ -17033,14 +17037,10 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17033
17037
  var playableOutput2 = _step2.value;
17034
17038
  this.processFrameWithRoot(playableOutput2);
17035
17039
  }
17036
- // 更新节点时间
17037
- for(var _iterator3 = _create_for_of_iterator_helper_loose(this.playables), _step3; !(_step3 = _iterator3()).done;){
17038
- var playable = _step3.value;
17039
- this.updatePlayableTime(playable, dt / 1000);
17040
- }
17041
- };
17042
- _proto.connect = function connect(source, sourceOutputPort, destination, destinationInputPort) {
17043
- destination.connectInput(destinationInputPort, source, sourceOutputPort);
17040
+ // 更新节点时间
17041
+ // for (const playable of this.playables) {
17042
+ // this.updatePlayableTime(playable, dt / 1000);
17043
+ // }
17044
17044
  };
17045
17045
  _proto.addOutput = function addOutput(output) {
17046
17046
  this.playableOutputs.push(output);
@@ -17049,12 +17049,12 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17049
17049
  this.playables.push(playable);
17050
17050
  };
17051
17051
  _proto.processFrameWithRoot = function processFrameWithRoot(output) {
17052
- output.sourcePlayable.processFrameRecursive(output.context, output.getSourceOutputPort());
17052
+ output.sourcePlayable.processFrame(output.context);
17053
17053
  output.processFrame();
17054
17054
  };
17055
17055
  _proto.prepareFrameWithRoot = function prepareFrameWithRoot(output) {
17056
- output.sourcePlayable.prepareFrameRecursive(output.context, output.getSourceOutputPort());
17057
17056
  output.prepareFrame();
17057
+ output.sourcePlayable.prepareFrame(output.context);
17058
17058
  };
17059
17059
  _proto.updatePlayableTime = function updatePlayableTime(playable, deltaTime) {
17060
17060
  if (playable.getPlayState() !== 0) {
@@ -17069,24 +17069,15 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17069
17069
  * @since 2.0.0
17070
17070
  */ var Playable = /*#__PURE__*/ function() {
17071
17071
  function Playable(graph, inputCount) {
17072
- if (inputCount === void 0) inputCount = 0;
17073
17072
  this.onPlayablePlayFlag = true;
17074
17073
  this.onPlayablePauseFlag = false;
17075
17074
  this.duration = 0;
17076
17075
  this.destroyed = false;
17077
- this.inputs = [];
17078
- this.inputOuputPorts = [];
17079
- this.inputWeight = [];
17080
- this.outputs = [];
17081
17076
  this.playState = 0;
17082
- this.traversalMode = 0;
17083
17077
  /**
17084
17078
  * 当前本地播放的时间
17085
17079
  */ this.time = 0;
17086
17080
  graph.addPlayable(this);
17087
- this.inputs = new Array(inputCount);
17088
- this.inputOuputPorts = new Array(inputCount);
17089
- this.inputWeight = new Array(inputCount);
17090
17081
  }
17091
17082
  var _proto = Playable.prototype;
17092
17083
  _proto.play = function play() {
@@ -17109,56 +17100,6 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17109
17100
  break;
17110
17101
  }
17111
17102
  };
17112
- _proto.connectInput = function connectInput(inputPort, sourcePlayable, sourceOutputPort, weight) {
17113
- if (weight === void 0) weight = 1.0;
17114
- this.setInput(sourcePlayable, inputPort);
17115
- this.setInputWeight(inputPort, weight);
17116
- sourcePlayable.setOutput(this, sourceOutputPort);
17117
- if (this.inputOuputPorts.length < inputPort + 1) {
17118
- this.inputOuputPorts.length = inputPort + 1;
17119
- }
17120
- this.inputOuputPorts[inputPort] = sourceOutputPort;
17121
- };
17122
- _proto.addInput = function addInput(sourcePlayable, sourceOutputPort, weight) {
17123
- if (weight === void 0) weight = 1.0;
17124
- this.connectInput(this.getInputCount(), sourcePlayable, sourceOutputPort, weight);
17125
- };
17126
- _proto.getInputCount = function getInputCount() {
17127
- return this.inputs.length;
17128
- };
17129
- _proto.getInputs = function getInputs() {
17130
- return this.inputs;
17131
- };
17132
- _proto.getInput = function getInput(index) {
17133
- return this.inputs[index];
17134
- };
17135
- _proto.getOutputCount = function getOutputCount() {
17136
- return this.outputs.length;
17137
- };
17138
- _proto.getOutputs = function getOutputs() {
17139
- return this.outputs;
17140
- };
17141
- _proto.getOutput = function getOutput(index) {
17142
- return this.outputs[index];
17143
- };
17144
- _proto.getInputWeight = function getInputWeight(inputIndex) {
17145
- return this.inputWeight[inputIndex];
17146
- };
17147
- _proto.setInputWeight = function setInputWeight(playableOrIndex, weight) {
17148
- if (_instanceof1(playableOrIndex, Playable)) {
17149
- for(var i = 0; i < this.inputs.length; i++){
17150
- if (this.inputs[i] === playableOrIndex) {
17151
- this.inputWeight[i] = weight;
17152
- return;
17153
- }
17154
- }
17155
- } else {
17156
- if (this.inputWeight.length < playableOrIndex + 1) {
17157
- this.inputWeight.length = playableOrIndex + 1;
17158
- }
17159
- this.inputWeight[playableOrIndex] = weight;
17160
- }
17161
- };
17162
17103
  _proto.setTime = function setTime(time) {
17163
17104
  this.time = time;
17164
17105
  };
@@ -17174,18 +17115,14 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17174
17115
  _proto.getPlayState = function getPlayState() {
17175
17116
  return this.playState;
17176
17117
  };
17177
- _proto.setTraversalMode = function setTraversalMode(mode) {
17178
- this.traversalMode = mode;
17179
- };
17180
- _proto.getTraversalMode = function getTraversalMode() {
17181
- return this.traversalMode;
17182
- };
17183
17118
  // onGraphStart () {
17184
17119
  // }
17185
17120
  // onGraphStop () {
17186
17121
  // }
17187
- _proto.onPlayablePlay = function onPlayablePlay(context) {};
17188
- _proto.onPlayablePause = function onPlayablePause(context) {};
17122
+ // onPlayablePlay (context: FrameContext) {
17123
+ // }
17124
+ // onPlayablePause (context: FrameContext) {
17125
+ // }
17189
17126
  _proto.prepareFrame = function prepareFrame(context) {};
17190
17127
  _proto.processFrame = function processFrame(context) {};
17191
17128
  _proto.onPlayableDestroy = function onPlayableDestroy() {};
@@ -17197,76 +17134,6 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17197
17134
  // TODO 将节点从动画图中移除
17198
17135
  this.destroyed = true;
17199
17136
  };
17200
- /**
17201
- * @internal
17202
- */ _proto.prepareFrameRecursive = function prepareFrameRecursive(context, passthroughPort) {
17203
- if (this.destroyed || this.playState !== 0) {
17204
- return;
17205
- }
17206
- if (this.onPlayablePlayFlag) {
17207
- this.onPlayablePlay(context);
17208
- this.onPlayablePlayFlag = false;
17209
- }
17210
- if (this.onPlayablePauseFlag) {
17211
- this.onPlayablePause(context);
17212
- this.onPlayablePauseFlag = false;
17213
- }
17214
- if (passthroughPort === 0) {
17215
- this.prepareFrame(context);
17216
- }
17217
- // 前序遍历,用于设置节点的初始状态,weight etc.
17218
- switch(this.getTraversalMode()){
17219
- case 0:
17220
- for(var i = 0; i < this.getInputCount(); i++){
17221
- var input = this.getInput(i);
17222
- input.prepareFrameRecursive(context, this.inputOuputPorts[i]);
17223
- }
17224
- break;
17225
- case 1:
17226
- {
17227
- var input1 = this.getInput(passthroughPort);
17228
- input1.prepareFrameRecursive(context, this.inputOuputPorts[passthroughPort]);
17229
- break;
17230
- }
17231
- }
17232
- };
17233
- /**
17234
- * @internal
17235
- */ _proto.processFrameRecursive = function processFrameRecursive(context, passthroughPort) {
17236
- if (this.destroyed || this.playState !== 0) {
17237
- return;
17238
- }
17239
- // 后序遍历,保证 playable 拿到的 input 节点的估计数据是最新的
17240
- switch(this.getTraversalMode()){
17241
- case 0:
17242
- {
17243
- for(var i = 0; i < this.getInputCount(); i++){
17244
- var input = this.getInput(i);
17245
- input.processFrameRecursive(context, this.inputOuputPorts[i]);
17246
- }
17247
- break;
17248
- }
17249
- case 1:
17250
- {
17251
- var input1 = this.getInput(passthroughPort);
17252
- input1.processFrameRecursive(context, this.inputOuputPorts[passthroughPort]);
17253
- break;
17254
- }
17255
- }
17256
- this.processFrame(context);
17257
- };
17258
- _proto.setOutput = function setOutput(outputPlayable, outputPort) {
17259
- if (this.outputs.length < outputPort + 1) {
17260
- this.outputs.length = outputPort + 1;
17261
- }
17262
- this.outputs[outputPort] = outputPlayable;
17263
- };
17264
- _proto.setInput = function setInput(inputPlayable, inputPort) {
17265
- if (this.inputs.length < inputPort + 1) {
17266
- this.inputs.length = inputPort + 1;
17267
- }
17268
- this.inputs[inputPort] = inputPlayable;
17269
- };
17270
17137
  return Playable;
17271
17138
  }();
17272
17139
  /**
@@ -17274,20 +17141,14 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
17274
17141
  * @since 2.0.0
17275
17142
  */ var PlayableOutput = /*#__PURE__*/ function() {
17276
17143
  function PlayableOutput() {
17277
- this.sourceOutputPort = 0;
17278
17144
  this.context = {
17279
17145
  deltaTime: 0,
17280
17146
  output: this
17281
17147
  };
17282
17148
  }
17283
17149
  var _proto = PlayableOutput.prototype;
17284
- _proto.setSourcePlayable = function setSourcePlayable(playable, port) {
17285
- if (port === void 0) port = 0;
17150
+ _proto.setSourcePlayable = function setSourcePlayable(playable) {
17286
17151
  this.sourcePlayable = playable;
17287
- this.sourceOutputPort = port;
17288
- };
17289
- _proto.getSourceOutputPort = function getSourceOutputPort() {
17290
- return this.sourceOutputPort;
17291
17152
  };
17292
17153
  _proto.setUserData = function setUserData(value) {
17293
17154
  this.userData = value;
@@ -17313,11 +17174,6 @@ var PlayState;
17313
17174
  PlayState[PlayState["Playing"] = 0] = "Playing";
17314
17175
  PlayState[PlayState["Paused"] = 1] = "Paused";
17315
17176
  })(PlayState || (PlayState = {}));
17316
- var PlayableTraversalMode;
17317
- (function(PlayableTraversalMode) {
17318
- PlayableTraversalMode[PlayableTraversalMode["Mix"] = 0] = "Mix";
17319
- PlayableTraversalMode[PlayableTraversalMode["Passthrough"] = 1] = "Passthrough";
17320
- })(PlayableTraversalMode || (PlayableTraversalMode = {}));
17321
17177
 
17322
17178
  var tempQuat$1 = new Quaternion();
17323
17179
  var seed$4 = 1;
@@ -17970,7 +17826,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
17970
17826
  };
17971
17827
  /**
17972
17828
  * 添加组件
17973
- * @param classConstructor - 要添加的组件类型
17829
+ * @param classConstructor - 要添加的组件
17974
17830
  */ _proto.addComponent = function addComponent(classConstructor) {
17975
17831
  var newComponent = new classConstructor(this.engine);
17976
17832
  this.components.push(newComponent);
@@ -18213,7 +18069,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
18213
18069
  };
18214
18070
  _proto.fromData = function fromData(data) {
18215
18071
  EffectsObject.prototype.fromData.call(this, data);
18216
- var id = data.id, name = data.name, delay = data.delay, parentId = data.parentId, endBehavior = data.endBehavior, transform = data.transform, _data_listIndex = data.listIndex, listIndex = _data_listIndex === void 0 ? 0 : _data_listIndex, _data_duration = data.duration, duration = _data_duration === void 0 ? 0 : _data_duration;
18072
+ var id = data.id, name = data.name, delay = data.delay, parentId = data.parentId, endBehavior = data.endBehavior, transform = data.transform, _data_duration = data.duration, duration = _data_duration === void 0 ? 0 : _data_duration;
18217
18073
  this.props = data;
18218
18074
  //@ts-expect-error
18219
18075
  this.type = data.type;
@@ -18275,8 +18131,6 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
18275
18131
  this.rendererComponents.push(component.renderer);
18276
18132
  }
18277
18133
  }
18278
- // renderOrder 在 component 初始化后设置。确保能拿到 rendererComponent。
18279
- this.renderOrder = listIndex;
18280
18134
  };
18281
18135
  _proto.toData = function toData() {
18282
18136
  var _this_parent;
@@ -22822,12 +22676,6 @@ var AnimationStream = /*#__PURE__*/ function() {
22822
22676
  _proto.findCurveValue = function findCurveValue(componentType, propertyName) {
22823
22677
  return this.curveValues[componentType + propertyName];
22824
22678
  };
22825
- _proto.getInputStream = function getInputStream(index) {
22826
- var inputPlayable = this.playable.getInput(index);
22827
- if (_instanceof1(inputPlayable, AnimationPlayable)) {
22828
- return inputPlayable.animationStream;
22829
- }
22830
- };
22831
22679
  return AnimationStream;
22832
22680
  }();
22833
22681
 
@@ -23162,214 +23010,65 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
23162
23010
  return AnimationClipPlayable;
23163
23011
  }(Playable);
23164
23012
 
23165
- /**
23166
- * @since 2.0.0
23167
- */ var TimelineClip = /*#__PURE__*/ function() {
23168
- function TimelineClip() {
23169
- this.start = 0;
23170
- this.duration = 0;
23171
- }
23172
- var _proto = TimelineClip.prototype;
23173
- _proto.toLocalTime = function toLocalTime(time) {
23174
- var localTime = time - this.start;
23175
- var duration = this.duration;
23176
- if (localTime - duration > 0) {
23177
- if (this.endBehavior === EndBehavior.restart) {
23178
- localTime = localTime % duration;
23179
- } else if (this.endBehavior === EndBehavior.freeze) {
23180
- localTime = Math.min(duration, localTime);
23181
- }
23182
- }
23183
- return localTime;
23184
- };
23185
- return TimelineClip;
23186
- }();
23187
- exports.TrackAsset = /*#__PURE__*/ function(PlayableAsset) {
23188
- _inherits(TrackAsset, PlayableAsset);
23189
- function TrackAsset() {
23013
+ var TrackMixerPlayable = /*#__PURE__*/ function(Playable1) {
23014
+ _inherits(TrackMixerPlayable, Playable1);
23015
+ function TrackMixerPlayable() {
23190
23016
  var _this;
23191
- _this = PlayableAsset.apply(this, arguments) || this;
23192
- _this.trackType = 0;
23193
- _this.clipSeed = 0;
23194
- _this.clips = [];
23195
- _this.children = [];
23017
+ _this = Playable1.apply(this, arguments) || this;
23018
+ _this.clipPlayables = [];
23019
+ _this.clipWeights = [];
23196
23020
  return _this;
23197
23021
  }
23198
- var _proto = TrackAsset.prototype;
23199
- /**
23200
- * 重写该方法以获取自定义对象绑定
23201
- */ _proto.updateAnimatedObject = function updateAnimatedObject() {
23202
- if (this.parent) {
23203
- this.boundObject = this.parent.boundObject;
23204
- }
23205
- };
23206
- /**
23207
- * 重写该方法以创建自定义混合器
23208
- */ _proto.createTrackMixer = function createTrackMixer(graph) {
23209
- return new Playable(graph);
23210
- };
23211
- _proto.createOutput = function createOutput() {
23212
- var output = new PlayableOutput();
23213
- return output;
23214
- };
23215
- _proto.createPlayableGraph = function createPlayableGraph(graph, runtimeClips) {
23216
- var mixerPlayable = this.createMixerPlayableGraph(graph, runtimeClips);
23217
- return mixerPlayable;
23218
- };
23219
- _proto.createMixerPlayableGraph = function createMixerPlayableGraph(graph, runtimeClips) {
23220
- var clips = [];
23221
- for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
23222
- var clip = _step.value;
23223
- clips.push(clip);
23224
- }
23225
- var mixerPlayable = this.compileClips(graph, clips, runtimeClips);
23226
- return mixerPlayable;
23227
- };
23228
- _proto.compileClips = function compileClips(graph, timelineClips, runtimeClips) {
23229
- var mixer = this.createTrackMixer(graph);
23230
- for(var _iterator = _create_for_of_iterator_helper_loose(timelineClips), _step; !(_step = _iterator()).done;){
23231
- var timelineClip = _step.value;
23232
- var clipPlayable = this.createClipPlayable(graph, timelineClip);
23233
- clipPlayable.setDuration(timelineClip.duration);
23234
- var clip = new RuntimeClip(timelineClip, clipPlayable, mixer, this);
23235
- runtimeClips.push(clip);
23236
- mixer.addInput(clipPlayable, 0);
23237
- mixer.setInputWeight(clipPlayable, 0.0);
23022
+ var _proto = TrackMixerPlayable.prototype;
23023
+ _proto.processFrame = function processFrame(context) {
23024
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.clipPlayables), _step; !(_step = _iterator()).done;){
23025
+ var clipPlayable = _step.value;
23026
+ clipPlayable.processFrame(context);
23238
23027
  }
23239
- return mixer;
23240
- };
23241
- _proto.createPlayable = function createPlayable(graph) {
23242
- return new Playable(graph);
23243
- };
23244
- _proto.getChildTracks = function getChildTracks() {
23245
- return this.children;
23246
- };
23247
- _proto.addChild = function addChild(child) {
23248
- this.children.push(child);
23249
- child.parent = this;
23250
- };
23251
- _proto.createClip = function createClip(classConstructor, name) {
23252
- var newClip = new TimelineClip();
23253
- newClip.asset = new classConstructor(this.engine);
23254
- newClip.name = name ? name : "TimelineClip" + newClip.id;
23255
- this.addClip(newClip);
23256
- return newClip;
23028
+ this.evaluate(context);
23257
23029
  };
23258
- _proto.getClips = function getClips() {
23259
- return this.clips;
23260
- };
23261
- _proto.findClip = function findClip(name) {
23262
- for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
23263
- var clip = _step.value;
23264
- if (clip.name === name) {
23265
- return clip;
23030
+ _proto.setClipWeight = function setClipWeight(playableOrIndex, weight) {
23031
+ if (_instanceof1(playableOrIndex, Playable)) {
23032
+ for(var i = 0; i < this.clipPlayables.length; i++){
23033
+ if (this.clipPlayables[i] === playableOrIndex) {
23034
+ this.clipWeights[i] = weight;
23035
+ return;
23036
+ }
23037
+ }
23038
+ } else {
23039
+ if (this.clipWeights.length < playableOrIndex + 1) {
23040
+ this.clipWeights.length = playableOrIndex + 1;
23266
23041
  }
23042
+ this.clipWeights[playableOrIndex] = weight;
23267
23043
  }
23268
23044
  };
23269
- _proto.addClip = function addClip(clip) {
23270
- clip.id = (this.clipSeed++).toString();
23271
- this.clips.push(clip);
23045
+ _proto.getClipWeight = function getClipWeight(inputIndex) {
23046
+ return this.clipWeights[inputIndex];
23272
23047
  };
23273
- _proto.createClipPlayable = function createClipPlayable(graph, clip) {
23274
- return clip.asset.createPlayable(graph);
23048
+ _proto.getClipPlayable = function getClipPlayable(index) {
23049
+ return this.clipPlayables[index];
23275
23050
  };
23276
- _proto.fromData = function fromData(data) {
23277
- PlayableAsset.prototype.fromData.call(this, data);
23278
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
23279
- var child = _step.value;
23280
- child.parent = this;
23281
- }
23051
+ _proto.evaluate = function evaluate(context) {
23052
+ // Override
23282
23053
  };
23283
- return TrackAsset;
23284
- }(PlayableAsset);
23285
- __decorate([
23286
- serialize(TimelineClip)
23287
- ], exports.TrackAsset.prototype, "clips", void 0);
23288
- __decorate([
23289
- serialize()
23290
- ], exports.TrackAsset.prototype, "children", void 0);
23291
- exports.TrackAsset = __decorate([
23292
- effectsClass(DataType.TrackAsset)
23293
- ], exports.TrackAsset);
23294
- exports.TrackType = void 0;
23295
- (function(TrackType) {
23296
- TrackType[TrackType["MasterTrack"] = 0] = "MasterTrack";
23297
- TrackType[TrackType["ObjectTrack"] = 1] = "ObjectTrack";
23298
- })(exports.TrackType || (exports.TrackType = {}));
23299
- var RuntimeClip = /*#__PURE__*/ function() {
23300
- function RuntimeClip(clip, clipPlayable, parentMixer, track) {
23301
- this.clip = clip;
23302
- this.playable = clipPlayable;
23303
- this.parentMixer = parentMixer;
23304
- this.track = track;
23305
- if (_instanceof1(this.track.boundObject, exports.VFXItem)) {
23306
- this.particleSystem = this.track.boundObject.getComponent(exports.ParticleSystem);
23307
- }
23308
- }
23309
- var _proto = RuntimeClip.prototype;
23310
- _proto.evaluateAt = function evaluateAt(localTime) {
23311
- var clip = this.clip;
23312
- var weight = 1.0;
23313
- var ended = false;
23314
- var started = false;
23315
- var boundObject = this.track.boundObject;
23316
- if (localTime >= clip.start + clip.duration && clip.endBehavior === EndBehavior.destroy) {
23317
- if (_instanceof1(boundObject, exports.VFXItem) && exports.VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
23318
- weight = 1.0;
23319
- } else {
23320
- weight = 0.0;
23321
- ended = true;
23322
- }
23323
- } else if (localTime - this.clip.start >= 0) {
23324
- weight = 1.0;
23325
- started = true;
23326
- } else if (localTime < clip.start) {
23327
- weight = 0.0;
23328
- }
23329
- if (started && this.playable.getPlayState() !== PlayState.Playing) {
23330
- this.playable.play();
23331
- }
23332
- this.parentMixer.setInputWeight(this.playable, weight);
23333
- var clipTime = parseFloat(clip.toLocalTime(localTime).toFixed(3));
23334
- this.playable.setTime(clipTime);
23335
- // 判断动画是否结束
23336
- if (ended) {
23337
- if (this.playable.getPlayState() === PlayState.Playing) {
23338
- this.playable.pause();
23339
- }
23340
- }
23341
- };
23342
- _create_class(RuntimeClip, [
23343
- {
23344
- key: "enable",
23345
- set: function set(value) {
23346
- if (value) {
23347
- this.playable.play();
23348
- } else {
23349
- this.parentMixer.setInputWeight(this.playable, 0);
23350
- this.playable.pause();
23351
- }
23352
- }
23353
- }
23354
- ]);
23355
- return RuntimeClip;
23356
- }();
23054
+ return TrackMixerPlayable;
23055
+ }(Playable);
23357
23056
 
23358
- var ActivationMixerPlayable = /*#__PURE__*/ function(Playable) {
23359
- _inherits(ActivationMixerPlayable, Playable);
23057
+ var ActivationMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23058
+ _inherits(ActivationMixerPlayable, TrackMixerPlayable);
23360
23059
  function ActivationMixerPlayable() {
23361
- return Playable.apply(this, arguments);
23060
+ return TrackMixerPlayable.apply(this, arguments);
23362
23061
  }
23363
23062
  var _proto = ActivationMixerPlayable.prototype;
23364
- _proto.processFrame = function processFrame(context) {
23063
+ _proto.evaluate = function evaluate(context) {
23365
23064
  var boundObject = context.output.getUserData();
23366
23065
  if (!_instanceof1(boundObject, exports.VFXItem)) {
23367
23066
  return;
23368
23067
  }
23369
23068
  var boundItem = boundObject;
23370
23069
  var hasInput = false;
23371
- for(var i = 0; i < this.getInputCount(); i++){
23372
- if (this.getInputWeight(i) > 0) {
23070
+ for(var i = 0; i < this.clipPlayables.length; i++){
23071
+ if (this.getClipWeight(i) > 0) {
23373
23072
  hasInput = true;
23374
23073
  break;
23375
23074
  }
@@ -23383,22 +23082,7 @@ var ActivationMixerPlayable = /*#__PURE__*/ function(Playable) {
23383
23082
  }
23384
23083
  };
23385
23084
  return ActivationMixerPlayable;
23386
- }(Playable);
23387
-
23388
- exports.ActivationTrack = /*#__PURE__*/ function(TrackAsset) {
23389
- _inherits(ActivationTrack, TrackAsset);
23390
- function ActivationTrack() {
23391
- return TrackAsset.apply(this, arguments);
23392
- }
23393
- var _proto = ActivationTrack.prototype;
23394
- _proto.createTrackMixer = function createTrackMixer(graph) {
23395
- return new ActivationMixerPlayable(graph);
23396
- };
23397
- return ActivationTrack;
23398
- }(exports.TrackAsset);
23399
- exports.ActivationTrack = __decorate([
23400
- effectsClass(DataType.ActivationTrack)
23401
- ], exports.ActivationTrack);
23085
+ }(TrackMixerPlayable);
23402
23086
 
23403
23087
  var PropertyClipPlayable = /*#__PURE__*/ function(Playable) {
23404
23088
  _inherits(PropertyClipPlayable, Playable);
@@ -23412,16 +23096,61 @@ var PropertyClipPlayable = /*#__PURE__*/ function(Playable) {
23412
23096
  return PropertyClipPlayable;
23413
23097
  }(Playable);
23414
23098
 
23415
- var FloatPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
23416
- _inherits(FloatPropertyMixerPlayable, Playable);
23099
+ var ColorPropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23100
+ _inherits(ColorPropertyMixerPlayable, TrackMixerPlayable);
23101
+ function ColorPropertyMixerPlayable() {
23102
+ var _this;
23103
+ _this = TrackMixerPlayable.apply(this, arguments) || this;
23104
+ _this.propertyName = "";
23105
+ return _this;
23106
+ }
23107
+ var _proto = ColorPropertyMixerPlayable.prototype;
23108
+ _proto.evaluate = function evaluate(context) {
23109
+ var boundObject = context.output.getUserData();
23110
+ if (!boundObject) {
23111
+ return;
23112
+ }
23113
+ var hasInput = false;
23114
+ var value = boundObject[this.propertyName];
23115
+ if (!_instanceof1(value, Color)) {
23116
+ return;
23117
+ }
23118
+ value.setZero();
23119
+ // evaluate the curve
23120
+ for(var i = 0; i < this.clipPlayables.length; i++){
23121
+ var weight = this.getClipWeight(i);
23122
+ if (weight > 0) {
23123
+ var propertyClipPlayable = this.getClipPlayable(i);
23124
+ if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
23125
+ console.error("ColorPropertyMixerPlayable received incompatible input");
23126
+ continue;
23127
+ }
23128
+ var curveValue = propertyClipPlayable.value;
23129
+ value.r += curveValue.r * weight;
23130
+ value.g += curveValue.g * weight;
23131
+ value.b += curveValue.b * weight;
23132
+ value.a += curveValue.a * weight;
23133
+ hasInput = true;
23134
+ }
23135
+ }
23136
+ // set value
23137
+ if (hasInput) {
23138
+ boundObject[this.propertyName] = value;
23139
+ }
23140
+ };
23141
+ return ColorPropertyMixerPlayable;
23142
+ }(TrackMixerPlayable);
23143
+
23144
+ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23145
+ _inherits(FloatPropertyMixerPlayable, TrackMixerPlayable);
23417
23146
  function FloatPropertyMixerPlayable() {
23418
23147
  var _this;
23419
- _this = Playable.apply(this, arguments) || this;
23148
+ _this = TrackMixerPlayable.apply(this, arguments) || this;
23420
23149
  _this.propertyName = "";
23421
23150
  return _this;
23422
23151
  }
23423
23152
  var _proto = FloatPropertyMixerPlayable.prototype;
23424
- _proto.processFrame = function processFrame(context) {
23153
+ _proto.evaluate = function evaluate(context) {
23425
23154
  var boundObject = context.output.getUserData();
23426
23155
  if (!boundObject) {
23427
23156
  return;
@@ -23429,10 +23158,10 @@ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
23429
23158
  var hasInput = false;
23430
23159
  var value = 0;
23431
23160
  // evaluate the curve
23432
- for(var i = 0; i < this.getInputCount(); i++){
23433
- var weight = this.getInputWeight(i);
23161
+ for(var i = 0; i < this.clipPlayables.length; i++){
23162
+ var weight = this.getClipWeight(i);
23434
23163
  if (weight > 0) {
23435
- var propertyClipPlayable = this.getInput(i);
23164
+ var propertyClipPlayable = this.getClipPlayable(i);
23436
23165
  if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
23437
23166
  console.error("FloatPropertyTrack added non-FloatPropertyPlayableAsset");
23438
23167
  continue;
@@ -23448,7 +23177,27 @@ var FloatPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
23448
23177
  }
23449
23178
  };
23450
23179
  return FloatPropertyMixerPlayable;
23451
- }(Playable);
23180
+ }(TrackMixerPlayable);
23181
+
23182
+ var ParticleMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23183
+ _inherits(ParticleMixerPlayable, TrackMixerPlayable);
23184
+ function ParticleMixerPlayable() {
23185
+ return TrackMixerPlayable.apply(this, arguments);
23186
+ }
23187
+ var _proto = ParticleMixerPlayable.prototype;
23188
+ _proto.evaluate = function evaluate(context) {};
23189
+ return ParticleMixerPlayable;
23190
+ }(TrackMixerPlayable);
23191
+
23192
+ var SpriteColorMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23193
+ _inherits(SpriteColorMixerPlayable, TrackMixerPlayable);
23194
+ function SpriteColorMixerPlayable() {
23195
+ return TrackMixerPlayable.apply(this, arguments);
23196
+ }
23197
+ var _proto = SpriteColorMixerPlayable.prototype;
23198
+ _proto.evaluate = function evaluate(context) {};
23199
+ return SpriteColorMixerPlayable;
23200
+ }(TrackMixerPlayable);
23452
23201
 
23453
23202
  var SerializationHelper = /*#__PURE__*/ function() {
23454
23203
  function SerializationHelper() {}
@@ -23940,7 +23689,8 @@ var SerializationHelper = /*#__PURE__*/ function() {
23940
23689
  this.timelinePlayable.setTime(time);
23941
23690
  // The properties of the object may change dynamically,
23942
23691
  // so reset the track binding to avoid invalidation of the previously obtained binding object.
23943
- this.resolveBindings();
23692
+ // this.resolveBindings();
23693
+ this.timelinePlayable.evaluate();
23944
23694
  this.graph.evaluate(dt);
23945
23695
  };
23946
23696
  _proto.createContent = function createContent() {
@@ -24073,6 +23823,20 @@ var SerializationHelper = /*#__PURE__*/ function() {
24073
23823
  }
24074
23824
  return regions;
24075
23825
  };
23826
+ /**
23827
+ * 设置当前合成子元素的渲染顺序
23828
+ * @internal
23829
+ */ _proto.setChildrenRenderOrder = function setChildrenRenderOrder(startOrder) {
23830
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.items), _step; !(_step = _iterator()).done;){
23831
+ var item = _step.value;
23832
+ item.renderOrder = startOrder++;
23833
+ var subCompositionComponent = item.getComponent(CompositionComponent);
23834
+ if (subCompositionComponent) {
23835
+ startOrder = subCompositionComponent.setChildrenRenderOrder(startOrder);
23836
+ }
23837
+ }
23838
+ return startOrder;
23839
+ };
24076
23840
  _proto.fromData = function fromData(data) {
24077
23841
  Behaviour.prototype.fromData.call(this, data);
24078
23842
  this.items = data.items;
@@ -24119,21 +23883,21 @@ var SubCompositionClipPlayable = /*#__PURE__*/ function(Playable) {
24119
23883
  return SubCompositionClipPlayable;
24120
23884
  }(Playable);
24121
23885
 
24122
- var SubCompositionMixerPlayable = /*#__PURE__*/ function(Playable) {
24123
- _inherits(SubCompositionMixerPlayable, Playable);
23886
+ var SubCompositionMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23887
+ _inherits(SubCompositionMixerPlayable, TrackMixerPlayable);
24124
23888
  function SubCompositionMixerPlayable() {
24125
- return Playable.apply(this, arguments);
23889
+ return TrackMixerPlayable.apply(this, arguments);
24126
23890
  }
24127
23891
  var _proto = SubCompositionMixerPlayable.prototype;
24128
- _proto.processFrame = function processFrame(context) {
23892
+ _proto.evaluate = function evaluate(context) {
24129
23893
  var boundObject = context.output.getUserData();
24130
23894
  if (!_instanceof1(boundObject, CompositionComponent)) {
24131
23895
  return;
24132
23896
  }
24133
23897
  var compositionComponent = boundObject;
24134
23898
  var hasInput = false;
24135
- for(var i = 0; i < this.getInputCount(); i++){
24136
- if (this.getInputWeight(i) > 0) {
23899
+ for(var i = 0; i < this.clipPlayables.length; i++){
23900
+ if (this.getClipWeight(i) > 0) {
24137
23901
  hasInput = true;
24138
23902
  break;
24139
23903
  }
@@ -24145,18 +23909,28 @@ var SubCompositionMixerPlayable = /*#__PURE__*/ function(Playable) {
24145
23909
  }
24146
23910
  };
24147
23911
  return SubCompositionMixerPlayable;
24148
- }(Playable);
23912
+ }(TrackMixerPlayable);
23913
+
23914
+ var TransformMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23915
+ _inherits(TransformMixerPlayable, TrackMixerPlayable);
23916
+ function TransformMixerPlayable() {
23917
+ return TrackMixerPlayable.apply(this, arguments);
23918
+ }
23919
+ var _proto = TransformMixerPlayable.prototype;
23920
+ _proto.evaluate = function evaluate(context) {};
23921
+ return TransformMixerPlayable;
23922
+ }(TrackMixerPlayable);
24149
23923
 
24150
- var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24151
- _inherits(Vector4PropertyMixerPlayable, Playable);
23924
+ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
23925
+ _inherits(Vector4PropertyMixerPlayable, TrackMixerPlayable);
24152
23926
  function Vector4PropertyMixerPlayable() {
24153
23927
  var _this;
24154
- _this = Playable.apply(this, arguments) || this;
23928
+ _this = TrackMixerPlayable.apply(this, arguments) || this;
24155
23929
  _this.propertyName = "";
24156
23930
  return _this;
24157
23931
  }
24158
23932
  var _proto = Vector4PropertyMixerPlayable.prototype;
24159
- _proto.processFrame = function processFrame(context) {
23933
+ _proto.evaluate = function evaluate(context) {
24160
23934
  var boundObject = context.output.getUserData();
24161
23935
  if (!boundObject) {
24162
23936
  return;
@@ -24168,10 +23942,10 @@ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24168
23942
  }
24169
23943
  value.setZero();
24170
23944
  // evaluate the curve
24171
- for(var i = 0; i < this.getInputCount(); i++){
24172
- var weight = this.getInputWeight(i);
23945
+ for(var i = 0; i < this.clipPlayables.length; i++){
23946
+ var weight = this.getClipWeight(i);
24173
23947
  if (weight > 0) {
24174
- var propertyClipPlayable = this.getInput(i);
23948
+ var propertyClipPlayable = this.getClipPlayable(i);
24175
23949
  if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
24176
23950
  console.error("Vector4PropertyTrack added non-Vector4PropertyPlayableAsset");
24177
23951
  continue;
@@ -24190,52 +23964,215 @@ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24190
23964
  }
24191
23965
  };
24192
23966
  return Vector4PropertyMixerPlayable;
24193
- }(Playable);
23967
+ }(TrackMixerPlayable);
24194
23968
 
24195
- var ColorPropertyMixerPlayable = /*#__PURE__*/ function(Playable) {
24196
- _inherits(ColorPropertyMixerPlayable, Playable);
24197
- function ColorPropertyMixerPlayable() {
23969
+ /**
23970
+ * @since 2.0.0
23971
+ */ var TimelineClip = /*#__PURE__*/ function() {
23972
+ function TimelineClip() {
23973
+ this.start = 0;
23974
+ this.duration = 0;
23975
+ }
23976
+ var _proto = TimelineClip.prototype;
23977
+ _proto.toLocalTime = function toLocalTime(time) {
23978
+ var localTime = time - this.start;
23979
+ var duration = this.duration;
23980
+ if (localTime - duration > 0) {
23981
+ if (this.endBehavior === EndBehavior.restart) {
23982
+ localTime = localTime % duration;
23983
+ } else if (this.endBehavior === EndBehavior.freeze) {
23984
+ localTime = Math.min(duration, localTime);
23985
+ }
23986
+ }
23987
+ return localTime;
23988
+ };
23989
+ return TimelineClip;
23990
+ }();
23991
+ exports.TrackAsset = /*#__PURE__*/ function(PlayableAsset) {
23992
+ _inherits(TrackAsset, PlayableAsset);
23993
+ function TrackAsset() {
24198
23994
  var _this;
24199
- _this = Playable.apply(this, arguments) || this;
24200
- _this.propertyName = "";
23995
+ _this = PlayableAsset.apply(this, arguments) || this;
23996
+ _this.trackType = 0;
23997
+ _this.clipSeed = 0;
23998
+ _this.clips = [];
23999
+ _this.children = [];
24201
24000
  return _this;
24202
24001
  }
24203
- var _proto = ColorPropertyMixerPlayable.prototype;
24204
- _proto.processFrame = function processFrame(context) {
24205
- var boundObject = context.output.getUserData();
24206
- if (!boundObject) {
24207
- return;
24002
+ var _proto = TrackAsset.prototype;
24003
+ /**
24004
+ * 重写该方法以获取自定义对象绑定
24005
+ */ _proto.updateAnimatedObject = function updateAnimatedObject() {
24006
+ if (this.parent) {
24007
+ this.boundObject = this.parent.boundObject;
24208
24008
  }
24209
- var hasInput = false;
24210
- var value = boundObject[this.propertyName];
24211
- if (!_instanceof1(value, Color)) {
24212
- return;
24009
+ };
24010
+ /**
24011
+ * 重写该方法以创建自定义混合器
24012
+ */ _proto.createTrackMixer = function createTrackMixer(graph) {
24013
+ return new TrackMixerPlayable(graph);
24014
+ };
24015
+ _proto.createOutput = function createOutput() {
24016
+ var output = new PlayableOutput();
24017
+ return output;
24018
+ };
24019
+ _proto.createPlayableGraph = function createPlayableGraph(graph, runtimeClips) {
24020
+ var mixerPlayable = this.createMixerPlayableGraph(graph, runtimeClips);
24021
+ return mixerPlayable;
24022
+ };
24023
+ _proto.createMixerPlayableGraph = function createMixerPlayableGraph(graph, runtimeClips) {
24024
+ var clips = [];
24025
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
24026
+ var clip = _step.value;
24027
+ clips.push(clip);
24213
24028
  }
24214
- value.setZero();
24215
- // evaluate the curve
24216
- for(var i = 0; i < this.getInputCount(); i++){
24217
- var weight = this.getInputWeight(i);
24218
- if (weight > 0) {
24219
- var propertyClipPlayable = this.getInput(i);
24220
- if (!_instanceof1(propertyClipPlayable, PropertyClipPlayable)) {
24221
- console.error("ColorPropertyMixerPlayable received incompatible input");
24222
- continue;
24223
- }
24224
- var curveValue = propertyClipPlayable.value;
24225
- value.r += curveValue.r * weight;
24226
- value.g += curveValue.g * weight;
24227
- value.b += curveValue.b * weight;
24228
- value.a += curveValue.a * weight;
24229
- hasInput = true;
24029
+ var mixerPlayable = this.compileClips(graph, clips, runtimeClips);
24030
+ return mixerPlayable;
24031
+ };
24032
+ _proto.compileClips = function compileClips(graph, timelineClips, runtimeClips) {
24033
+ var mixer = this.createTrackMixer(graph);
24034
+ for(var _iterator = _create_for_of_iterator_helper_loose(timelineClips), _step; !(_step = _iterator()).done;){
24035
+ var timelineClip = _step.value;
24036
+ var clipPlayable = this.createClipPlayable(graph, timelineClip);
24037
+ clipPlayable.setDuration(timelineClip.duration);
24038
+ var clip = new RuntimeClip(timelineClip, clipPlayable, mixer, this);
24039
+ runtimeClips.push(clip);
24040
+ mixer.clipPlayables.push(clipPlayable);
24041
+ mixer.setClipWeight(clipPlayable, 0.0);
24042
+ }
24043
+ return mixer;
24044
+ };
24045
+ _proto.createPlayable = function createPlayable(graph) {
24046
+ return new Playable(graph);
24047
+ };
24048
+ _proto.getChildTracks = function getChildTracks() {
24049
+ return this.children;
24050
+ };
24051
+ _proto.addChild = function addChild(child) {
24052
+ this.children.push(child);
24053
+ child.parent = this;
24054
+ };
24055
+ _proto.createClip = function createClip(classConstructor, name) {
24056
+ var newClip = new TimelineClip();
24057
+ newClip.asset = new classConstructor(this.engine);
24058
+ newClip.name = name ? name : "TimelineClip" + newClip.id;
24059
+ this.addClip(newClip);
24060
+ return newClip;
24061
+ };
24062
+ _proto.getClips = function getClips() {
24063
+ return this.clips;
24064
+ };
24065
+ _proto.findClip = function findClip(name) {
24066
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.clips), _step; !(_step = _iterator()).done;){
24067
+ var clip = _step.value;
24068
+ if (clip.name === name) {
24069
+ return clip;
24230
24070
  }
24231
24071
  }
24232
- // set value
24233
- if (hasInput) {
24234
- boundObject[this.propertyName] = value;
24072
+ };
24073
+ _proto.addClip = function addClip(clip) {
24074
+ clip.id = (this.clipSeed++).toString();
24075
+ this.clips.push(clip);
24076
+ };
24077
+ _proto.createClipPlayable = function createClipPlayable(graph, clip) {
24078
+ return clip.asset.createPlayable(graph);
24079
+ };
24080
+ _proto.fromData = function fromData(data) {
24081
+ PlayableAsset.prototype.fromData.call(this, data);
24082
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
24083
+ var child = _step.value;
24084
+ child.parent = this;
24235
24085
  }
24236
24086
  };
24237
- return ColorPropertyMixerPlayable;
24238
- }(Playable);
24087
+ return TrackAsset;
24088
+ }(PlayableAsset);
24089
+ __decorate([
24090
+ serialize(TimelineClip)
24091
+ ], exports.TrackAsset.prototype, "clips", void 0);
24092
+ __decorate([
24093
+ serialize()
24094
+ ], exports.TrackAsset.prototype, "children", void 0);
24095
+ exports.TrackAsset = __decorate([
24096
+ effectsClass(DataType.TrackAsset)
24097
+ ], exports.TrackAsset);
24098
+ exports.TrackType = void 0;
24099
+ (function(TrackType) {
24100
+ TrackType[TrackType["MasterTrack"] = 0] = "MasterTrack";
24101
+ TrackType[TrackType["ObjectTrack"] = 1] = "ObjectTrack";
24102
+ })(exports.TrackType || (exports.TrackType = {}));
24103
+ var RuntimeClip = /*#__PURE__*/ function() {
24104
+ function RuntimeClip(clip, clipPlayable, parentMixer, track) {
24105
+ this.clip = clip;
24106
+ this.playable = clipPlayable;
24107
+ this.parentMixer = parentMixer;
24108
+ this.track = track;
24109
+ if (_instanceof1(this.track.boundObject, exports.VFXItem)) {
24110
+ this.particleSystem = this.track.boundObject.getComponent(exports.ParticleSystem);
24111
+ }
24112
+ }
24113
+ var _proto = RuntimeClip.prototype;
24114
+ _proto.evaluateAt = function evaluateAt(localTime) {
24115
+ var clip = this.clip;
24116
+ var weight = 1.0;
24117
+ var ended = false;
24118
+ var started = false;
24119
+ var boundObject = this.track.boundObject;
24120
+ if (localTime >= clip.start + clip.duration && clip.endBehavior === EndBehavior.destroy) {
24121
+ if (_instanceof1(boundObject, exports.VFXItem) && exports.VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
24122
+ weight = 1.0;
24123
+ } else {
24124
+ weight = 0.0;
24125
+ ended = true;
24126
+ }
24127
+ } else if (localTime - this.clip.start >= 0) {
24128
+ weight = 1.0;
24129
+ started = true;
24130
+ } else if (localTime < clip.start) {
24131
+ weight = 0.0;
24132
+ }
24133
+ if (started && this.playable.getPlayState() !== PlayState.Playing) {
24134
+ this.playable.play();
24135
+ }
24136
+ this.parentMixer.setClipWeight(this.playable, weight);
24137
+ var clipTime = parseFloat(clip.toLocalTime(localTime).toFixed(3));
24138
+ this.playable.setTime(clipTime);
24139
+ // 判断动画是否结束
24140
+ if (ended) {
24141
+ if (this.playable.getPlayState() === PlayState.Playing) {
24142
+ this.playable.pause();
24143
+ }
24144
+ }
24145
+ };
24146
+ _create_class(RuntimeClip, [
24147
+ {
24148
+ key: "enable",
24149
+ set: function set(value) {
24150
+ if (value) {
24151
+ this.playable.play();
24152
+ } else {
24153
+ this.parentMixer.setClipWeight(this.playable, 0);
24154
+ this.playable.pause();
24155
+ }
24156
+ }
24157
+ }
24158
+ ]);
24159
+ return RuntimeClip;
24160
+ }();
24161
+
24162
+ exports.ActivationTrack = /*#__PURE__*/ function(TrackAsset) {
24163
+ _inherits(ActivationTrack, TrackAsset);
24164
+ function ActivationTrack() {
24165
+ return TrackAsset.apply(this, arguments);
24166
+ }
24167
+ var _proto = ActivationTrack.prototype;
24168
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24169
+ return new ActivationMixerPlayable(graph);
24170
+ };
24171
+ return ActivationTrack;
24172
+ }(exports.TrackAsset);
24173
+ exports.ActivationTrack = __decorate([
24174
+ effectsClass(DataType.ActivationTrack)
24175
+ ], exports.ActivationTrack);
24239
24176
 
24240
24177
  var PropertyTrack = /*#__PURE__*/ function(TrackAsset) {
24241
24178
  _inherits(PropertyTrack, TrackAsset);
@@ -24308,6 +24245,10 @@ exports.SpriteColorTrack = /*#__PURE__*/ function(TrackAsset) {
24308
24245
  function SpriteColorTrack() {
24309
24246
  return TrackAsset.apply(this, arguments);
24310
24247
  }
24248
+ var _proto = SpriteColorTrack.prototype;
24249
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24250
+ return new SpriteColorMixerPlayable(graph);
24251
+ };
24311
24252
  return SpriteColorTrack;
24312
24253
  }(exports.TrackAsset);
24313
24254
  exports.SpriteColorTrack = __decorate([
@@ -24340,6 +24281,10 @@ exports.TransformTrack = /*#__PURE__*/ function(TrackAsset) {
24340
24281
  function TransformTrack() {
24341
24282
  return TrackAsset.apply(this, arguments);
24342
24283
  }
24284
+ var _proto = TransformTrack.prototype;
24285
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24286
+ return new TransformMixerPlayable(graph);
24287
+ };
24343
24288
  return TransformTrack;
24344
24289
  }(exports.TrackAsset);
24345
24290
  exports.TransformTrack = __decorate([
@@ -24368,6 +24313,18 @@ exports.MaterialTrack = __decorate([
24368
24313
  effectsClass("MaterialTrack")
24369
24314
  ], exports.MaterialTrack);
24370
24315
 
24316
+ var ParticleTrack = /*#__PURE__*/ function(TrackAsset) {
24317
+ _inherits(ParticleTrack, TrackAsset);
24318
+ function ParticleTrack() {
24319
+ return TrackAsset.apply(this, arguments);
24320
+ }
24321
+ var _proto = ParticleTrack.prototype;
24322
+ _proto.createTrackMixer = function createTrackMixer(graph) {
24323
+ return new ParticleMixerPlayable(graph);
24324
+ };
24325
+ return ParticleTrack;
24326
+ }(exports.TrackAsset);
24327
+
24371
24328
  exports.Vector4PropertyTrack = /*#__PURE__*/ function(PropertyTrack) {
24372
24329
  _inherits(Vector4PropertyTrack, PropertyTrack);
24373
24330
  function Vector4PropertyTrack() {
@@ -24496,7 +24453,6 @@ exports.TimelineAsset = /*#__PURE__*/ function(PlayableAsset) {
24496
24453
  var _proto = TimelineAsset.prototype;
24497
24454
  _proto.createPlayable = function createPlayable(graph) {
24498
24455
  var timelinePlayable = new TimelinePlayable(graph);
24499
- timelinePlayable.setTraversalMode(PlayableTraversalMode.Passthrough);
24500
24456
  for(var _iterator = _create_for_of_iterator_helper_loose(this.tracks), _step; !(_step = _iterator()).done;){
24501
24457
  var track = _step.value;
24502
24458
  if (_instanceof1(track, exports.ObjectBindingTrack)) {
@@ -24577,9 +24533,7 @@ var TimelinePlayable = /*#__PURE__*/ function(Playable) {
24577
24533
  return _this;
24578
24534
  }
24579
24535
  var _proto = TimelinePlayable.prototype;
24580
- _proto.prepareFrame = function prepareFrame(context) {
24581
- this.evaluate();
24582
- };
24536
+ _proto.prepareFrame = function prepareFrame(context) {};
24583
24537
  _proto.evaluate = function evaluate() {
24584
24538
  var time = this.getTime();
24585
24539
  // TODO search active clips
@@ -24596,11 +24550,10 @@ var TimelinePlayable = /*#__PURE__*/ function(Playable) {
24596
24550
  var track = _step.value;
24597
24551
  // create track mixer and track output
24598
24552
  var trackMixPlayable = track.createPlayableGraph(graph, this.clips);
24599
- this.addInput(trackMixPlayable, 0);
24600
24553
  var trackOutput = track.createOutput();
24601
24554
  trackOutput.setUserData(track.boundObject);
24602
24555
  graph.addOutput(trackOutput);
24603
- trackOutput.setSourcePlayable(this, this.getInputCount() - 1);
24556
+ trackOutput.setSourcePlayable(trackMixPlayable);
24604
24557
  // create track instance
24605
24558
  var trackInstance = new TrackInstance(track, trackMixPlayable, trackOutput);
24606
24559
  trackInstanceMap[track.getInstanceId()] = trackInstance;
@@ -24661,10 +24614,10 @@ exports.Vector4PropertyPlayableAsset = __decorate([
24661
24614
  effectsClass("Vector4PropertyPlayableAsset")
24662
24615
  ], exports.Vector4PropertyPlayableAsset);
24663
24616
 
24664
- exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
24665
- _inherits(ObjectBindingTrack, TrackAsset1);
24617
+ exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset) {
24618
+ _inherits(ObjectBindingTrack, TrackAsset);
24666
24619
  function ObjectBindingTrack() {
24667
- return TrackAsset1.apply(this, arguments);
24620
+ return TrackAsset.apply(this, arguments);
24668
24621
  }
24669
24622
  var _proto = ObjectBindingTrack.prototype;
24670
24623
  _proto.updateAnimatedObject = function updateAnimatedObject() {};
@@ -24675,7 +24628,7 @@ exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
24675
24628
  var boundItem = this.boundObject;
24676
24629
  // 添加粒子动画 clip // TODO 待移除
24677
24630
  if (boundItem.getComponent(exports.ParticleSystem)) {
24678
- var particleTrack = timelineAsset.createTrack(exports.TrackAsset, this, "ParticleTrack");
24631
+ var particleTrack = timelineAsset.createTrack(ParticleTrack, this, "ParticleTrack");
24679
24632
  particleTrack.boundObject = this.boundObject;
24680
24633
  var particleClip = particleTrack.createClip(ParticleBehaviourPlayableAsset);
24681
24634
  particleClip.start = boundItem.start;
@@ -24698,14 +24651,14 @@ var TextLayout = /*#__PURE__*/ function() {
24698
24651
  function TextLayout(options) {
24699
24652
  this.width = 0;
24700
24653
  this.height = 0;
24701
- var _options_textHeight = options.textHeight, textHeight = _options_textHeight === void 0 ? 100 : _options_textHeight, _options_textWidth = options.textWidth, textWidth = _options_textWidth === void 0 ? 100 : _options_textWidth, _options_textOverflow = options.textOverflow, textOverflow = _options_textOverflow === void 0 ? TextOverflow.display : _options_textOverflow, _options_textBaseline = options.textBaseline, textBaseline = _options_textBaseline === void 0 ? TextBaseline.top : _options_textBaseline, _options_textAlign = options.textAlign, textAlign = _options_textAlign === void 0 ? TextAlignment.left : _options_textAlign, _options_text = options.text, text = _options_text === void 0 ? " " : _options_text, _options_letterSpace = options.letterSpace, letterSpace = _options_letterSpace === void 0 ? 0 : _options_letterSpace, _options_autoWidth = options.autoWidth, autoWidth = _options_autoWidth === void 0 ? false : _options_autoWidth, fontSize = options.fontSize, _options_lineHeight = options.lineHeight, lineHeight = _options_lineHeight === void 0 ? fontSize : _options_lineHeight;
24654
+ var _options_textHeight = options.textHeight, textHeight = _options_textHeight === void 0 ? 100 : _options_textHeight, _options_textWidth = options.textWidth, textWidth = _options_textWidth === void 0 ? 100 : _options_textWidth, _options_textOverflow = options.textOverflow, textOverflow = _options_textOverflow === void 0 ? TextOverflow.clip : _options_textOverflow, _options_textBaseline = options.textBaseline, textBaseline = _options_textBaseline === void 0 ? TextBaseline.top : _options_textBaseline, _options_textAlign = options.textAlign, textAlign = _options_textAlign === void 0 ? TextAlignment.left : _options_textAlign, _options_text = options.text, text = _options_text === void 0 ? " " : _options_text, _options_letterSpace = options.letterSpace, letterSpace = _options_letterSpace === void 0 ? 0 : _options_letterSpace, _options_autoWidth = options.autoWidth, autoWidth = _options_autoWidth === void 0 ? false : _options_autoWidth, fontSize = options.fontSize, _options_lineHeight = options.lineHeight, lineHeight = _options_lineHeight === void 0 ? fontSize : _options_lineHeight;
24702
24655
  var tempWidth = fontSize + letterSpace;
24703
24656
  this.autoWidth = autoWidth;
24704
24657
  this.maxTextWidth = text.length * tempWidth;
24705
24658
  this.width = textWidth;
24706
24659
  this.height = textHeight;
24707
24660
  this.letterSpace = letterSpace;
24708
- this.overFlow = textOverflow;
24661
+ this.overflow = textOverflow;
24709
24662
  this.textBaseline = textBaseline;
24710
24663
  this.textAlign = textAlign;
24711
24664
  this.lineHeight = lineHeight;
@@ -27695,11 +27648,11 @@ var seed$1 = 1;
27695
27648
  if (compressedTexture === void 0) compressedTexture = 0;
27696
27649
  var _this = this;
27697
27650
  return _async_to_generator(function() {
27698
- var _this_options, useCompressedTexture, variables, baseUrl, jobs, loadedImages;
27651
+ var _this_options, useCompressedTexture, variables, disableWebP, disableAVIF, baseUrl, jobs, loadedImages;
27699
27652
  return __generator(this, function(_state) {
27700
27653
  switch(_state.label){
27701
27654
  case 0:
27702
- _this_options = _this.options, useCompressedTexture = _this_options.useCompressedTexture, variables = _this_options.variables;
27655
+ _this_options = _this.options, useCompressedTexture = _this_options.useCompressedTexture, variables = _this_options.variables, disableWebP = _this_options.disableWebP, disableAVIF = _this_options.disableAVIF;
27703
27656
  baseUrl = _this.baseUrl;
27704
27657
  jobs = images.map(/*#__PURE__*/ _async_to_generator(function(img, idx) {
27705
27658
  var png, webp, avif, imageURL, webpURL, avifURL, id, template, background, url, isVideo, loadFn, resultImage, e, compressed, src, bufferURL, _ref, url1, image, _tmp;
@@ -27710,9 +27663,9 @@ var seed$1 = 1;
27710
27663
  // eslint-disable-next-line compat/compat
27711
27664
  imageURL = new URL(png, baseUrl).href;
27712
27665
  // eslint-disable-next-line compat/compat
27713
- webpURL = webp && new URL(webp, baseUrl).href;
27666
+ webpURL = !disableWebP && webp ? new URL(webp, baseUrl).href : undefined;
27714
27667
  // eslint-disable-next-line compat/compat
27715
- avifURL = avif && new URL(avif, baseUrl).href;
27668
+ avifURL = !disableAVIF && avif ? new URL(avif, baseUrl).href : undefined;
27716
27669
  id = img.id;
27717
27670
  if (!("template" in img)) return [
27718
27671
  3,
@@ -28401,7 +28354,6 @@ var tmpScale = new Vector3(1, 1, 1);
28401
28354
  return Camera;
28402
28355
  }();
28403
28356
 
28404
- var listOrder = 0;
28405
28357
  /**
28406
28358
  * 合成资源管理
28407
28359
  */ var CompositionSourceManager = /*#__PURE__*/ function() {
@@ -28434,7 +28386,6 @@ var listOrder = 0;
28434
28386
  this.pluginSystem = pluginSystem;
28435
28387
  this.totalTime = totalTime != null ? totalTime : 0;
28436
28388
  this.textures = cachedTextures;
28437
- listOrder = 0;
28438
28389
  this.sourceContent = this.getContent(this.composition);
28439
28390
  }
28440
28391
  var _proto = CompositionSourceManager.prototype;
@@ -28465,7 +28416,6 @@ var listOrder = 0;
28465
28416
  var sourceItemData = this.engine.jsonSceneData[itemDataPath.id];
28466
28417
  var itemProps = sourceItemData;
28467
28418
  if (passRenderLevel(sourceItemData.renderLevel, this.renderLevel)) {
28468
- itemProps.listIndex = listOrder++;
28469
28419
  if (itemProps.type === ItemType.sprite || itemProps.type === ItemType.particle || itemProps.type === ItemType.spine || //@ts-expect-error
28470
28420
  itemProps.type === ItemType.shape) {
28471
28421
  for(var _iterator2 = _create_for_of_iterator_helper_loose(itemProps.components), _step2; !(_step2 = _iterator2()).done;){
@@ -28768,6 +28718,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
28768
28718
  SerializationHelper.deserialize(sourceContent, _this.rootComposition);
28769
28719
  _this.rootComposition.createContent();
28770
28720
  _this.buildItemTree(_this.rootItem);
28721
+ _this.rootComposition.setChildrenRenderOrder(0);
28771
28722
  _this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
28772
28723
  return _this;
28773
28724
  }
@@ -31407,7 +31358,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
31407
31358
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
31408
31359
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
31409
31360
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
31410
- var version$1 = "2.1.5";
31361
+ var version$1 = "2.2.0";
31411
31362
  logger.info("Core version: " + version$1 + ".");
31412
31363
 
31413
31364
  var _obj;
@@ -31464,6 +31415,7 @@ var _obj3;
31464
31415
  /**
31465
31416
  * 储存 uniform 变量名及对应的 THREE uniform 对象
31466
31417
  */ _this.uniforms = {};
31418
+ _this.macrosDirty = true;
31467
31419
  var shader = props == null ? void 0 : props.shader;
31468
31420
  var level = engine.gpuCapability.level;
31469
31421
  _this.shader = new exports.Shader(engine);
@@ -31703,15 +31655,20 @@ var _obj3;
31703
31655
  var uniform = new THREE__namespace.Uniform(value);
31704
31656
  this.uniforms[name] = this.material.uniforms[name] = uniform;
31705
31657
  };
31706
- // 下列三个方法暂时不需要实现
31707
- _proto.enableMacro = function enableMacro(keyword) {
31708
- throw new Error("Method not implemented.");
31658
+ _proto.enableMacro = function enableMacro(keyword, value) {
31659
+ if (!this.isMacroEnabled(keyword) || this.enabledMacros[keyword] !== value) {
31660
+ this.enabledMacros[keyword] = value != null ? value : true;
31661
+ this.macrosDirty = true;
31662
+ }
31709
31663
  };
31710
31664
  _proto.disableMacro = function disableMacro(keyword) {
31711
- throw new Error("Method not implemented.");
31665
+ if (this.isMacroEnabled(keyword)) {
31666
+ delete this.enabledMacros[keyword];
31667
+ this.macrosDirty = true;
31668
+ }
31712
31669
  };
31713
31670
  _proto.isMacroEnabled = function isMacroEnabled(keyword) {
31714
- throw new Error("Method not implemented.");
31671
+ return this.enabledMacros[keyword] !== undefined;
31715
31672
  };
31716
31673
  _proto.clone = function clone(props) {
31717
31674
  //FIXME: 暂时不实现
@@ -33034,7 +32991,7 @@ setMaxSpriteMeshItemCount(8);
33034
32991
  */ Mesh.create = function(engine, props) {
33035
32992
  return new ThreeMesh(engine, props);
33036
32993
  };
33037
- var version = "2.1.5";
32994
+ var version = "2.2.0";
33038
32995
  logger.info("THREEJS plugin version: " + version + ".");
33039
32996
 
33040
32997
  exports.AbstractPlugin = AbstractPlugin;
@@ -33101,6 +33058,7 @@ exports.ParticleBehaviourPlayableAsset = ParticleBehaviourPlayableAsset;
33101
33058
  exports.ParticleLoader = ParticleLoader;
33102
33059
  exports.ParticleMesh = ParticleMesh;
33103
33060
  exports.ParticleSystemRenderer = ParticleSystemRenderer;
33061
+ exports.ParticleTrack = ParticleTrack;
33104
33062
  exports.PassTextureCache = PassTextureCache;
33105
33063
  exports.PathSegments = PathSegments;
33106
33064
  exports.PluginSystem = PluginSystem;