@galacean/effects-threejs 2.0.0-alpha.31 → 2.0.0-alpha.32

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.0.0-alpha.31
6
+ * Version: v2.0.0-alpha.32
7
7
  */
8
8
 
9
9
  import * as THREE from 'three';
@@ -4565,15 +4565,97 @@ function getDirectStore(target) {
4565
4565
  return decoratorInitialStore.get(classKey);
4566
4566
  }
4567
4567
 
4568
+ function _assert_this_initialized(self) {
4569
+ if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4570
+ return self;
4571
+ }
4572
+
4573
+ var EventEmitter = function EventEmitter() {
4574
+ var _this = this;
4575
+ var _this1 = this;
4576
+ this.listeners = {};
4577
+ /**
4578
+ * 移除事件监听器
4579
+ * @param eventName - 事件名称
4580
+ * @param listener - 事件监听器
4581
+ * @returns
4582
+ */ this.off = function(eventName, listener) {
4583
+ if (!_this.listeners[eventName]) {
4584
+ return;
4585
+ }
4586
+ _this.listeners[eventName] = _this.listeners[eventName].filter(function(param) {
4587
+ var l = param.listener;
4588
+ return l !== listener;
4589
+ });
4590
+ };
4591
+ /**
4592
+ * 监听事件
4593
+ * @param eventName - 事件名称
4594
+ * @param listener - 事件监听器
4595
+ * @param options - 事件监听器选项
4596
+ * @returns
4597
+ */ this.on = function(eventName, listener, options) {
4598
+ _this.listeners[eventName] = _this.listeners[eventName] || [];
4599
+ _this.listeners[eventName].push({
4600
+ listener: listener,
4601
+ options: options
4602
+ });
4603
+ return function() {
4604
+ return _this.off(eventName, listener);
4605
+ };
4606
+ };
4607
+ /**
4608
+ * 一次性监听事件
4609
+ * @param eventName - 事件名称
4610
+ * @param listener - 事件监听器
4611
+ */ this.once = function(eventName, listener) {
4612
+ _this.on(eventName, listener, {
4613
+ once: true
4614
+ });
4615
+ };
4616
+ /**
4617
+ * 触发事件
4618
+ * @param eventName - 事件名称
4619
+ * @param args - 事件参数
4620
+ */ this.emit = function(eventName) {
4621
+ for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
4622
+ args[_key - 1] = arguments[_key];
4623
+ }
4624
+ var _this_listeners_eventName;
4625
+ (_this_listeners_eventName = _this1.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.forEach(function(param) {
4626
+ var listener = param.listener, options = param.options;
4627
+ listener.apply(void 0, [].concat(args));
4628
+ if (options == null ? void 0 : options.once) {
4629
+ _this1.off(eventName, listener);
4630
+ }
4631
+ });
4632
+ };
4633
+ /**
4634
+ * 获取事件名称对应的所有监听器
4635
+ * @param eventName - 事件名称
4636
+ * @returns - 返回事件名称对应的所有监听器
4637
+ */ this.getListeners = function(eventName) {
4638
+ var _this_listeners_eventName;
4639
+ return ((_this_listeners_eventName = _this.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.map(function(param) {
4640
+ var listener = param.listener;
4641
+ return listener;
4642
+ })) || [];
4643
+ };
4644
+ };
4645
+
4568
4646
  /**
4569
4647
  * @since 2.0.0
4570
4648
  * @internal
4571
- */ var EffectsObject = /*#__PURE__*/ function() {
4649
+ */ var EffectsObject = /*#__PURE__*/ function(EventEmitter) {
4650
+ _inherits(EffectsObject, EventEmitter);
4572
4651
  function EffectsObject(engine) {
4573
- this.engine = engine;
4574
- this.guid = generateGUID();
4575
- this.taggedProperties = {};
4576
- this.engine.addInstance(this);
4652
+ var _this;
4653
+ _this = EventEmitter.call(this) || this;
4654
+ _this.engine = engine;
4655
+ _this.guid = generateGUID();
4656
+ _this.taggedProperties = {};
4657
+ _this.engine.addInstance(_assert_this_initialized(_this));
4658
+ return _this;
4577
4659
  }
4578
4660
  var _proto = EffectsObject.prototype;
4579
4661
  _proto.getInstanceId = function getInstanceId() {
@@ -4599,7 +4681,7 @@ function getDirectStore(target) {
4599
4681
  return _instanceof1(obj, EffectsObject) && "guid" in obj;
4600
4682
  };
4601
4683
  return EffectsObject;
4602
- }();
4684
+ }(EventEmitter);
4603
4685
 
4604
4686
  /**
4605
4687
  * @since 2.0.0
@@ -8989,6 +9071,9 @@ var MaterialRenderType;
8989
9071
  * 初始化 GPU 资源
8990
9072
  * @override
8991
9073
  */ _proto.initialize = function initialize() {
9074
+ // OVERRIDE
9075
+ };
9076
+ _proto.createShaderVariant = function createShaderVariant() {
8992
9077
  // OVERRIDE
8993
9078
  };
8994
9079
  _proto.use = function use(render, globalUniforms) {
@@ -12699,6 +12784,7 @@ var GlobalUniforms = function GlobalUniforms() {
12699
12784
  this.floats = {};
12700
12785
  this.ints = {};
12701
12786
  // vector3s: Record<string, vec3> = {};
12787
+ this.vector4s = {};
12702
12788
  this.matrices = {};
12703
12789
  //...
12704
12790
  this.samplers = [] // 存放的sampler名称。
@@ -12935,6 +13021,9 @@ var Renderer = /*#__PURE__*/ function() {
12935
13021
  _proto.setGlobalInt = function setGlobalInt(name, value) {
12936
13022
  // OVERRIDE
12937
13023
  };
13024
+ _proto.setGlobalVector4 = function setGlobalVector4(name, value) {
13025
+ // OVERRIDE
13026
+ };
12938
13027
  _proto.setGlobalMatrix = function setGlobalMatrix(name, value) {
12939
13028
  // OVERRIDE
12940
13029
  };
@@ -13480,11 +13569,6 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
13480
13569
  return SpriteLoader;
13481
13570
  }(AbstractPlugin);
13482
13571
 
13483
- function _assert_this_initialized(self) {
13484
- if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
13485
- return self;
13486
- }
13487
-
13488
13572
  /**
13489
13573
  * 动画图,负责更新所有的动画节点
13490
13574
  * @since 2.0.0
@@ -19269,6 +19353,9 @@ function compareTracks(a, b) {
19269
19353
  _this.startTime = 0;
19270
19354
  _this.items = [] // 场景的所有元素
19271
19355
  ;
19356
+ /**
19357
+ * 合成是否冻结标志位
19358
+ */ _this.fezzed = false;
19272
19359
  _this.reusable = false;
19273
19360
  _this.sceneBindings = [];
19274
19361
  _this.graph = new PlayableGraph();
@@ -19305,10 +19392,6 @@ function compareTracks(a, b) {
19305
19392
  };
19306
19393
  _proto.update = function update(dt) {
19307
19394
  var time = this.time;
19308
- // 主合成 rootItem 没有绑定轨道,增加结束行为判断。
19309
- if (this.item.isEnded(this.time) && !this.item.parent) {
19310
- this.item.ended = true;
19311
- }
19312
19395
  this.timelinePlayable.setTime(time);
19313
19396
  this.graph.evaluate(dt);
19314
19397
  };
@@ -19441,6 +19524,8 @@ function compareTracks(a, b) {
19441
19524
  hitPositions: hitPositions,
19442
19525
  behavior: hitParams.behavior
19443
19526
  };
19527
+ // 触发单个元素的点击事件
19528
+ item.emit("click", region);
19444
19529
  regions.push(region);
19445
19530
  if (stop(region)) {
19446
19531
  return {
@@ -20676,8 +20761,6 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
20676
20761
  this.parentId = parentId;
20677
20762
  this.duration = duration;
20678
20763
  this.endBehavior = endBehavior;
20679
- //@ts-expect-error
20680
- this.oldId = data.oldId;
20681
20764
  if (!data.content) {
20682
20765
  data.content = {
20683
20766
  options: {}
@@ -24686,89 +24769,93 @@ var listOrder = 0;
24686
24769
  * 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
24687
24770
  * 合成中包含了相关的 Item 元素,支持对 Item 元素的创建、更新和销毁。
24688
24771
  * 也负责 Item 相关的动画播放控制,和持有渲染帧数据。
24689
- */ var Composition = /*#__PURE__*/ function() {
24772
+ */ var Composition = /*#__PURE__*/ function(EventEmitter) {
24773
+ _inherits(Composition, EventEmitter);
24690
24774
  function Composition(props, scene) {
24691
- var _this = this;
24775
+ var _this;
24776
+ _this = EventEmitter.call(this) || this;
24692
24777
  /**
24693
24778
  * 动画播放速度
24694
- */ this.speed = 1;
24779
+ */ _this.speed = 1;
24695
24780
  /**
24696
24781
  * 用于保存与当前合成相关的插件数据
24697
- */ this.loaderData = {};
24782
+ */ _this.loaderData = {};
24698
24783
  /**
24699
24784
  * 预合成数组
24700
- */ this.refContent = [];
24785
+ */ _this.refContent = [];
24701
24786
  /**
24702
24787
  * 预合成的合成属性,在 content 中会被其元素属性覆盖
24703
- */ this.refCompositionProps = new Map();
24788
+ */ _this.refCompositionProps = new Map();
24704
24789
  // TODO: 待优化
24705
- this.assigned = false;
24790
+ _this.assigned = false;
24706
24791
  /**
24707
24792
  * 销毁状态位
24708
- */ this.destroyed = false;
24709
- this.postLoaders = [];
24793
+ */ _this.destroyed = false;
24794
+ _this.postLoaders = [];
24710
24795
  /**
24711
24796
  * 合成暂停/播放 标识
24712
- */ this.paused = false;
24713
- this.lastVideoUpdateTime = 0;
24714
- var _props_reusable = props.reusable, reusable = _props_reusable === void 0 ? false : _props_reusable, _props_speed = props.speed, speed = _props_speed === void 0 ? 1 : _props_speed, _props_baseRenderOrder = props.baseRenderOrder, baseRenderOrder = _props_baseRenderOrder === void 0 ? 0 : _props_baseRenderOrder, renderer = props.renderer, onPlayerPause = props.onPlayerPause, onMessageItem = props.onMessageItem, onEnd = props.onEnd, event = props.event, width = props.width, height = props.height;
24715
- this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
24797
+ */ _this.paused = false;
24798
+ _this.lastVideoUpdateTime = 0;
24799
+ var _props_reusable = props.reusable, reusable = _props_reusable === void 0 ? false : _props_reusable, _props_speed = props.speed, speed = _props_speed === void 0 ? 1 : _props_speed, _props_baseRenderOrder = props.baseRenderOrder, baseRenderOrder = _props_baseRenderOrder === void 0 ? 0 : _props_baseRenderOrder, renderer = props.renderer, event = props.event, width = props.width, height = props.height, handleItemMessage = props.handleItemMessage;
24800
+ _this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
24716
24801
  scene.jsonScene.imgUsage = undefined;
24717
24802
  if (reusable) {
24718
- this.keepResource = true;
24803
+ _this.keepResource = true;
24719
24804
  scene.textures = undefined;
24720
24805
  scene.consumed = true;
24721
24806
  }
24722
- var _this_compositionSourceManager = this.compositionSourceManager, sourceContent = _this_compositionSourceManager.sourceContent, pluginSystem = _this_compositionSourceManager.pluginSystem, imgUsage = _this_compositionSourceManager.imgUsage, totalTime = _this_compositionSourceManager.totalTime, refCompositionProps = _this_compositionSourceManager.refCompositionProps;
24807
+ var _this_compositionSourceManager = _this.compositionSourceManager, sourceContent = _this_compositionSourceManager.sourceContent, pluginSystem = _this_compositionSourceManager.pluginSystem, imgUsage = _this_compositionSourceManager.imgUsage, totalTime = _this_compositionSourceManager.totalTime, refCompositionProps = _this_compositionSourceManager.refCompositionProps;
24723
24808
  assertExist(sourceContent);
24724
- this.renderer = renderer;
24725
- this.refCompositionProps = refCompositionProps;
24726
- this.rootItem = new VFXItem(this.getEngine(), sourceContent);
24727
- this.rootItem.name = "rootItem";
24728
- this.rootItem.composition = this;
24729
- this.rootComposition = this.rootItem.addComponent(CompositionComponent);
24730
- this.rootComposition.data = sourceContent;
24809
+ _this.renderer = renderer;
24810
+ _this.refCompositionProps = refCompositionProps;
24811
+ _this.rootItem = new VFXItem(_this.getEngine(), sourceContent);
24812
+ _this.rootItem.name = "rootItem";
24813
+ _this.rootItem.composition = _assert_this_initialized(_this);
24814
+ _this.rootComposition = _this.rootItem.addComponent(CompositionComponent);
24815
+ _this.rootComposition.startTime = sourceContent.startTime;
24816
+ _this.rootComposition.data = sourceContent;
24731
24817
  var imageUsage = !reusable && imgUsage;
24732
- this.width = width;
24733
- this.height = height;
24734
- this.renderOrder = baseRenderOrder;
24735
- this.id = sourceContent.id;
24736
- this.renderer = renderer;
24737
- this.texInfo = imageUsage != null ? imageUsage : {};
24738
- this.event = event;
24818
+ _this.width = width;
24819
+ _this.height = height;
24820
+ _this.renderOrder = baseRenderOrder;
24821
+ _this.id = sourceContent.id;
24822
+ _this.renderer = renderer;
24823
+ _this.texInfo = imageUsage != null ? imageUsage : {};
24824
+ _this.event = event;
24739
24825
  var _scene_startTime, _scene_timeInfos_asyncCompile;
24740
- this.statistic = {
24826
+ _this.statistic = {
24741
24827
  loadTime: totalTime != null ? totalTime : 0,
24742
24828
  loadStart: (_scene_startTime = scene.startTime) != null ? _scene_startTime : 0,
24743
24829
  firstFrameTime: 0,
24744
24830
  precompileTime: (_scene_timeInfos_asyncCompile = scene.timeInfos["asyncCompile"]) != null ? _scene_timeInfos_asyncCompile : scene.timeInfos["syncCompile"]
24745
24831
  };
24746
- this.reusable = reusable;
24747
- this.speed = speed;
24748
- this.autoRefTex = !this.keepResource && imageUsage && this.rootItem.endBehavior !== EndBehavior.restart;
24749
- this.name = sourceContent.name;
24750
- this.pluginSystem = pluginSystem;
24751
- this.pluginSystem.initializeComposition(this, scene);
24752
- this.camera = new Camera(this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
24832
+ _this.reusable = reusable;
24833
+ _this.speed = speed;
24834
+ _this.autoRefTex = !_this.keepResource && imageUsage && _this.rootItem.endBehavior !== EndBehavior.restart;
24835
+ _this.name = sourceContent.name;
24836
+ _this.pluginSystem = pluginSystem;
24837
+ _this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
24838
+ _this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
24753
24839
  aspect: width / height
24754
24840
  }));
24755
- this.url = scene.url;
24756
- this.assigned = true;
24757
- this.globalTime = 0;
24758
- this.interactive = true;
24759
- this.onPlayerPause = onPlayerPause;
24760
- this.onMessageItem = onMessageItem;
24761
- this.onEnd = onEnd;
24762
- this.createRenderFrame();
24763
- this.rendererOptions = null;
24764
- this.rootComposition.createContent();
24765
- this.buildItemTree(this.rootItem);
24766
- this.rootItem.onEnd = function() {
24841
+ _this.url = scene.url;
24842
+ _this.assigned = true;
24843
+ _this.globalTime = 0;
24844
+ _this.interactive = true;
24845
+ _this.handleItemMessage = handleItemMessage;
24846
+ _this.createRenderFrame();
24847
+ _this.rendererOptions = null;
24848
+ _this.rootComposition.createContent();
24849
+ _this.buildItemTree(_this.rootItem);
24850
+ _this.rootItem.onEnd = function() {
24767
24851
  window.setTimeout(function() {
24768
- _this.onEnd == null ? void 0 : _this.onEnd.call(_this, _this);
24852
+ _this.emit("end", {
24853
+ composition: _assert_this_initialized(_this)
24854
+ });
24769
24855
  }, 0);
24770
24856
  };
24771
- this.pluginSystem.resetComposition(this, this.renderFrame);
24857
+ _this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
24858
+ return _this;
24772
24859
  }
24773
24860
  var _proto = Composition.prototype;
24774
24861
  /**
@@ -24819,7 +24906,7 @@ var listOrder = 0;
24819
24906
  if (this.rootItem.ended && this.reusable) {
24820
24907
  this.restart();
24821
24908
  }
24822
- if (!this.rootComposition.started) {
24909
+ if (this.rootComposition.started) {
24823
24910
  this.gotoAndPlay(this.time - this.startTime);
24824
24911
  } else {
24825
24912
  this.gotoAndPlay(0);
@@ -24842,18 +24929,14 @@ var listOrder = 0;
24842
24929
  * 跳转合成到指定时间播放
24843
24930
  * @param time - 相对 startTime 的时间
24844
24931
  */ _proto.gotoAndPlay = function gotoAndPlay(time) {
24932
+ this.setTime(time);
24845
24933
  this.resume();
24846
- if (!this.rootComposition.started) {
24847
- this.rootComposition.start();
24848
- this.rootComposition.started = true;
24849
- }
24850
- this.forwardTime(time + this.startTime);
24851
24934
  };
24852
24935
  /**
24853
24936
  * 跳转合成到指定时间并暂停
24854
24937
  * @param time - 相对 startTime 的时间
24855
24938
  */ _proto.gotoAndStop = function gotoAndStop(time) {
24856
- this.gotoAndPlay(time);
24939
+ this.setTime(time);
24857
24940
  this.pause();
24858
24941
  };
24859
24942
  /**
@@ -24880,7 +24963,7 @@ var listOrder = 0;
24880
24963
  this.rootComposition.start();
24881
24964
  this.rootComposition.started = true;
24882
24965
  }
24883
- this.forwardTime(time + this.startTime, true);
24966
+ this.forwardTime(time + this.startTime);
24884
24967
  if (pause) {
24885
24968
  this.pause();
24886
24969
  }
@@ -24893,17 +24976,16 @@ var listOrder = 0;
24893
24976
  * 前进合成到指定时间
24894
24977
  * @param time - 相对0时刻的时间
24895
24978
  * @param skipRender - 是否跳过渲染
24896
- */ _proto.forwardTime = function forwardTime(time, skipRender) {
24897
- if (skipRender === void 0) skipRender = false;
24979
+ */ _proto.forwardTime = function forwardTime(time) {
24898
24980
  var deltaTime = time * 1000 - this.rootComposition.time * 1000;
24899
24981
  var reverse = deltaTime < 0;
24900
24982
  var step = 15;
24901
24983
  var t = Math.abs(deltaTime);
24902
24984
  var ss = reverse ? -step : step;
24903
24985
  for(t; t > step; t -= step){
24904
- this.update(ss, skipRender);
24986
+ this.update(ss);
24905
24987
  }
24906
- this.update(reverse ? -t : t, skipRender);
24988
+ this.update(reverse ? -t : t);
24907
24989
  };
24908
24990
  /**
24909
24991
  * 重置状态函数
@@ -24944,8 +25026,9 @@ var listOrder = 0;
24944
25026
  * 是否合成需要重新播放
24945
25027
  * @returns 重新播放合成标志位
24946
25028
  */ _proto.shouldRestart = function shouldRestart() {
24947
- var _this_rootItem = this.rootItem, ended = _this_rootItem.ended, endBehavior = _this_rootItem.endBehavior;
24948
- return ended && endBehavior === EndBehavior.restart;
25029
+ var _this_rootItem = this.rootItem, duration = _this_rootItem.duration, endBehavior = _this_rootItem.endBehavior;
25030
+ var time = this.rootComposition.time;
25031
+ return endBehavior === EndBehavior.restart && duration - time < 0.02;
24949
25032
  };
24950
25033
  /**
24951
25034
  * 是否合成需要销毁
@@ -24954,44 +25037,45 @@ var listOrder = 0;
24954
25037
  if (this.reusable) {
24955
25038
  return false;
24956
25039
  }
24957
- var _this_rootItem = this.rootItem, ended = _this_rootItem.ended, endBehavior = _this_rootItem.endBehavior;
25040
+ var endBehavior = this.rootItem.endBehavior;
25041
+ if (this.rootItem.isEnded(this.time)) {
25042
+ this.rootItem.ended = true;
25043
+ }
24958
25044
  // TODO: 合成结束行为
24959
- return ended && (!endBehavior || endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY);
25045
+ return this.rootItem.ended && endBehavior === EndBehavior.destroy;
24960
25046
  };
24961
25047
  /**
24962
25048
  * 合成更新,针对所有 item 的更新
24963
25049
  * @param deltaTime - 更新的时间步长
24964
25050
  * @param skipRender - 是否需要渲染
24965
- */ _proto.update = function update(deltaTime, skipRender) {
24966
- if (skipRender === void 0) skipRender = false;
25051
+ */ _proto.update = function update(deltaTime) {
24967
25052
  if (!this.assigned || this.paused) {
24968
25053
  return;
24969
25054
  }
25055
+ var time = this.getUpdateTime(deltaTime * this.speed);
25056
+ this.globalTime += time;
25057
+ this.updateRootComposition();
24970
25058
  if (this.shouldRestart()) {
25059
+ this.emit("end", {
25060
+ composition: this
25061
+ });
24971
25062
  this.restart();
24972
25063
  // restart then tick to avoid flicker
24973
25064
  }
24974
- var time = this.getUpdateTime(deltaTime * this.speed);
24975
- this.globalTime += time;
24976
- if (this.rootComposition.isActiveAndEnabled) {
24977
- var localTime = this.toLocalTime(this.globalTime / 1000);
24978
- this.rootComposition.time = localTime;
24979
- }
24980
25065
  this.updateVideo();
24981
25066
  // 更新 model-tree-plugin
24982
25067
  this.updatePluginLoaders(deltaTime);
24983
25068
  this.callStart(this.rootItem);
24984
25069
  this.callUpdate(this.rootItem, time);
24985
25070
  this.callLateUpdate(this.rootItem, time);
24986
- // this.extraCamera?.getComponent(TimelineComponent)?.update(deltaTime);
24987
25071
  this.updateCamera();
24988
25072
  if (this.shouldDispose()) {
24989
- this.onEnd == null ? void 0 : this.onEnd.call(this, this);
25073
+ this.emit("end", {
25074
+ composition: this
25075
+ });
24990
25076
  this.dispose();
24991
25077
  } else {
24992
- if (!skipRender) {
24993
- this.prepareRender();
24994
- }
25078
+ this.prepareRender();
24995
25079
  }
24996
25080
  };
24997
25081
  _proto.toLocalTime = function toLocalTime(time) {
@@ -25002,13 +25086,20 @@ var listOrder = 0;
25002
25086
  localTime = localTime % duration;
25003
25087
  } else if (this.rootItem.endBehavior === EndBehavior.freeze) {
25004
25088
  localTime = Math.min(duration, localTime);
25089
+ if (localTime === duration) {
25090
+ if (!this.rootComposition.fezzed) {
25091
+ this.rootComposition.fezzed = true;
25092
+ this.emit("end", {
25093
+ composition: this
25094
+ });
25095
+ }
25096
+ }
25005
25097
  }
25006
25098
  }
25007
25099
  return localTime;
25008
25100
  };
25009
25101
  _proto.getUpdateTime = function getUpdateTime(t) {
25010
25102
  var startTimeInMs = this.startTime * 1000;
25011
- // const content = this.rootItem;
25012
25103
  var now = this.rootComposition.time * 1000;
25013
25104
  if (t < 0 && now + t < startTimeInMs) {
25014
25105
  return startTimeInMs - now;
@@ -25156,6 +25247,14 @@ var listOrder = 0;
25156
25247
  });
25157
25248
  };
25158
25249
  /**
25250
+ * 更新主合成组件
25251
+ */ _proto.updateRootComposition = function updateRootComposition() {
25252
+ if (this.rootComposition.isActiveAndEnabled) {
25253
+ var localTime = this.toLocalTime(this.globalTime / 1000);
25254
+ this.rootComposition.time = localTime;
25255
+ }
25256
+ };
25257
+ /**
25159
25258
  * 通过名称获取元素
25160
25259
  * @param name - 元素名称
25161
25260
  * @returns 元素对象
@@ -25204,12 +25303,17 @@ var listOrder = 0;
25204
25303
  * @param type - 交互类型
25205
25304
  */ _proto.addInteractiveItem = function addInteractiveItem(item, type) {
25206
25305
  if (type === InteractType.MESSAGE) {
25207
- this.onMessageItem == null ? void 0 : this.onMessageItem.call(this, {
25306
+ this.handleItemMessage({
25208
25307
  name: item.name,
25209
25308
  phrase: MESSAGE_ITEM_PHRASE_BEGIN,
25210
25309
  id: item.id,
25211
25310
  compositionId: this.id
25212
25311
  });
25312
+ item.emit("message", {
25313
+ name: item.name,
25314
+ phrase: MESSAGE_ITEM_PHRASE_BEGIN,
25315
+ id: item.id
25316
+ });
25213
25317
  return item.id;
25214
25318
  }
25215
25319
  };
@@ -25218,14 +25322,19 @@ var listOrder = 0;
25218
25322
  * @param item - 交互元素
25219
25323
  * @param type - 交互类型
25220
25324
  */ _proto.removeInteractiveItem = function removeInteractiveItem(item, type) {
25221
- // MESSAGE ITEM的结束行为
25325
+ // MESSAGE ITEM 的结束行为
25222
25326
  if (type === InteractType.MESSAGE) {
25223
- this.onMessageItem == null ? void 0 : this.onMessageItem.call(this, {
25327
+ this.handleItemMessage({
25224
25328
  name: item.name,
25225
25329
  phrase: MESSAGE_ITEM_PHRASE_END,
25226
25330
  id: item.id,
25227
25331
  compositionId: this.id
25228
25332
  });
25333
+ item.emit("message", {
25334
+ name: item.name,
25335
+ phrase: MESSAGE_ITEM_PHRASE_END,
25336
+ id: item.id
25337
+ });
25229
25338
  }
25230
25339
  };
25231
25340
  /**
@@ -25321,7 +25430,6 @@ var listOrder = 0;
25321
25430
  this.update = function() {
25322
25431
  logger.error("Update disposed composition: " + _this.name + ".");
25323
25432
  };
25324
- this.onPlayerPause = noop;
25325
25433
  this.dispose = noop;
25326
25434
  if (textures && this.keepResource) {
25327
25435
  textures.forEach(function(tex) {
@@ -25519,7 +25627,7 @@ var listOrder = 0;
25519
25627
  }
25520
25628
  ]);
25521
25629
  return Composition;
25522
- }();
25630
+ }(EventEmitter);
25523
25631
 
25524
25632
  var SIZEOF_SHORT = 2;
25525
25633
  var SIZEOF_INT = 4;
@@ -27483,7 +27591,7 @@ registerPlugin("sprite", SpriteLoader, VFXItem, true);
27483
27591
  registerPlugin("particle", ParticleLoader, VFXItem, true);
27484
27592
  registerPlugin("cal", CalculateLoader, VFXItem, true);
27485
27593
  registerPlugin("interact", InteractLoader, VFXItem, true);
27486
- var version$1 = "2.0.0-alpha.31";
27594
+ var version$1 = "2.0.0-alpha.32";
27487
27595
  logger.info("Core version: " + version$1 + ".");
27488
27596
 
27489
27597
  var _obj;
@@ -27557,6 +27665,13 @@ var _obj3;
27557
27665
  */ _this.uniforms = {};
27558
27666
  var shader = props == null ? void 0 : props.shader;
27559
27667
  var level = engine.gpuCapability.level;
27668
+ _this.shader = new Shader(engine);
27669
+ _this.shader.shaderData = _extends({}, shader, {
27670
+ id: generateGUID(),
27671
+ dataType: DataType.Shader,
27672
+ vertex: (shader == null ? void 0 : shader.vertex) || "",
27673
+ fragment: (shader == null ? void 0 : shader.fragment) || ""
27674
+ });
27560
27675
  for(var i = 0; i < maxSpriteMeshItemCount; i++){
27561
27676
  _this.uniforms["uSampler" + i] = new THREE.Uniform(null);
27562
27677
  }
@@ -28737,6 +28852,8 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
28737
28852
  var _this;
28738
28853
  _this = Renderer.call(this) || this;
28739
28854
  _this.engine = new ThreeEngine(gl);
28855
+ _this.engine.renderer = _assert_this_initialized(_this);
28856
+ _this.env = "";
28740
28857
  _this.renderingData = {
28741
28858
  //@ts-expect-error
28742
28859
  currentFrame: {}
@@ -28764,8 +28881,8 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
28764
28881
  var _this;
28765
28882
  _this = _THREE_Group.call(this) || this;
28766
28883
  _this.compositions = [];
28767
- _this.baseCompositionIndex = 0;
28768
28884
  _this.env = "";
28885
+ _this.baseCompositionIndex = 0;
28769
28886
  var width = options.width, height = options.height, camera = options.camera;
28770
28887
  _this.renderer = new ThreeRenderer(context);
28771
28888
  _this.width = width;
@@ -28834,6 +28951,19 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
28834
28951
  });
28835
28952
  })();
28836
28953
  };
28954
+ _proto.pause = function pause() {
28955
+ this.dispatchEvent({
28956
+ type: "pause"
28957
+ });
28958
+ this.compositions.forEach(function(composition) {
28959
+ composition.pause();
28960
+ });
28961
+ };
28962
+ _proto.resume = function resume() {
28963
+ this.compositions.forEach(function(composition) {
28964
+ composition.resume();
28965
+ });
28966
+ };
28837
28967
  _proto.createComposition = function createComposition(url, options) {
28838
28968
  if (options === void 0) options = {};
28839
28969
  var _this = this;
@@ -28890,8 +29020,20 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
28890
29020
  composition = new ThreeComposition(_extends({}, opts, {
28891
29021
  width: _this.width,
28892
29022
  height: _this.height,
28893
- renderer: _this.renderer
29023
+ renderer: _this.renderer,
29024
+ handleItemMessage: function(message) {
29025
+ _this.dispatchEvent({
29026
+ type: "message",
29027
+ message: message
29028
+ });
29029
+ }
28894
29030
  }), scene);
29031
+ composition.on("end", function() {
29032
+ _this.dispatchEvent({
29033
+ type: "end",
29034
+ composition: composition
29035
+ });
29036
+ });
28895
29037
  _this.renderer.engine.setOptions({
28896
29038
  threeCamera: _this.camera,
28897
29039
  threeGroup: _this,
@@ -29116,8 +29258,8 @@ setMaxSpriteMeshItemCount(8);
29116
29258
  */ Mesh.create = function(engine, props) {
29117
29259
  return new ThreeMesh(engine, props);
29118
29260
  };
29119
- var version = "2.0.0-alpha.31";
29261
+ var version = "2.0.0-alpha.32";
29120
29262
  logger.info("THREEJS plugin version: " + version + ".");
29121
29263
 
29122
- export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, 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, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, 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, EventSystem, FilterMode, Float16ArrayWrapper, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, 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, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderType, ShaderVariant, SpriteColorPlayable, 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, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, createCopyShader, createGLContext, createKeyFrameMeta, createShaderWithMacros, createShape, createValueGetter, decimalEqual, defaultGlobalVolume, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, 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, isSceneJSON, isSceneURL, isSceneWithOptions, 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, pluginLoaderMap, pointOnLine, 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, vecAssign, vecFill, vecMulCombine, vecNormalize, version, vertexFormatType2GLType };
29264
+ export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, 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, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, 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, FilterMode, Float16ArrayWrapper, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, 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, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderType, ShaderVariant, SpriteColorPlayable, 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, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, createCopyShader, createGLContext, createKeyFrameMeta, createShaderWithMacros, createShape, createValueGetter, decimalEqual, defaultGlobalVolume, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, 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, isSceneJSON, isSceneURL, isSceneWithOptions, 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, pluginLoaderMap, pointOnLine, 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, vecAssign, vecFill, vecMulCombine, vecNormalize, version, vertexFormatType2GLType };
29123
29265
  //# sourceMappingURL=index.mjs.map