@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.js +251 -108
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +251 -109
- package/dist/index.mjs.map +1 -1
- package/dist/three-composition.d.ts +1 -22
- package/dist/three-display-object.d.ts +4 -2
- package/package.json +2 -2
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.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.32
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -4589,15 +4589,97 @@ function getDirectStore(target) {
|
|
|
4589
4589
|
return decoratorInitialStore.get(classKey);
|
|
4590
4590
|
}
|
|
4591
4591
|
|
|
4592
|
+
function _assert_this_initialized(self) {
|
|
4593
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4594
|
+
return self;
|
|
4595
|
+
}
|
|
4596
|
+
|
|
4597
|
+
var EventEmitter = function EventEmitter() {
|
|
4598
|
+
var _this = this;
|
|
4599
|
+
var _this1 = this;
|
|
4600
|
+
this.listeners = {};
|
|
4601
|
+
/**
|
|
4602
|
+
* 移除事件监听器
|
|
4603
|
+
* @param eventName - 事件名称
|
|
4604
|
+
* @param listener - 事件监听器
|
|
4605
|
+
* @returns
|
|
4606
|
+
*/ this.off = function(eventName, listener) {
|
|
4607
|
+
if (!_this.listeners[eventName]) {
|
|
4608
|
+
return;
|
|
4609
|
+
}
|
|
4610
|
+
_this.listeners[eventName] = _this.listeners[eventName].filter(function(param) {
|
|
4611
|
+
var l = param.listener;
|
|
4612
|
+
return l !== listener;
|
|
4613
|
+
});
|
|
4614
|
+
};
|
|
4615
|
+
/**
|
|
4616
|
+
* 监听事件
|
|
4617
|
+
* @param eventName - 事件名称
|
|
4618
|
+
* @param listener - 事件监听器
|
|
4619
|
+
* @param options - 事件监听器选项
|
|
4620
|
+
* @returns
|
|
4621
|
+
*/ this.on = function(eventName, listener, options) {
|
|
4622
|
+
_this.listeners[eventName] = _this.listeners[eventName] || [];
|
|
4623
|
+
_this.listeners[eventName].push({
|
|
4624
|
+
listener: listener,
|
|
4625
|
+
options: options
|
|
4626
|
+
});
|
|
4627
|
+
return function() {
|
|
4628
|
+
return _this.off(eventName, listener);
|
|
4629
|
+
};
|
|
4630
|
+
};
|
|
4631
|
+
/**
|
|
4632
|
+
* 一次性监听事件
|
|
4633
|
+
* @param eventName - 事件名称
|
|
4634
|
+
* @param listener - 事件监听器
|
|
4635
|
+
*/ this.once = function(eventName, listener) {
|
|
4636
|
+
_this.on(eventName, listener, {
|
|
4637
|
+
once: true
|
|
4638
|
+
});
|
|
4639
|
+
};
|
|
4640
|
+
/**
|
|
4641
|
+
* 触发事件
|
|
4642
|
+
* @param eventName - 事件名称
|
|
4643
|
+
* @param args - 事件参数
|
|
4644
|
+
*/ this.emit = function(eventName) {
|
|
4645
|
+
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
4646
|
+
args[_key - 1] = arguments[_key];
|
|
4647
|
+
}
|
|
4648
|
+
var _this_listeners_eventName;
|
|
4649
|
+
(_this_listeners_eventName = _this1.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.forEach(function(param) {
|
|
4650
|
+
var listener = param.listener, options = param.options;
|
|
4651
|
+
listener.apply(void 0, [].concat(args));
|
|
4652
|
+
if (options == null ? void 0 : options.once) {
|
|
4653
|
+
_this1.off(eventName, listener);
|
|
4654
|
+
}
|
|
4655
|
+
});
|
|
4656
|
+
};
|
|
4657
|
+
/**
|
|
4658
|
+
* 获取事件名称对应的所有监听器
|
|
4659
|
+
* @param eventName - 事件名称
|
|
4660
|
+
* @returns - 返回事件名称对应的所有监听器
|
|
4661
|
+
*/ this.getListeners = function(eventName) {
|
|
4662
|
+
var _this_listeners_eventName;
|
|
4663
|
+
return ((_this_listeners_eventName = _this.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.map(function(param) {
|
|
4664
|
+
var listener = param.listener;
|
|
4665
|
+
return listener;
|
|
4666
|
+
})) || [];
|
|
4667
|
+
};
|
|
4668
|
+
};
|
|
4669
|
+
|
|
4592
4670
|
/**
|
|
4593
4671
|
* @since 2.0.0
|
|
4594
4672
|
* @internal
|
|
4595
|
-
*/ var EffectsObject = /*#__PURE__*/ function() {
|
|
4673
|
+
*/ var EffectsObject = /*#__PURE__*/ function(EventEmitter) {
|
|
4674
|
+
_inherits(EffectsObject, EventEmitter);
|
|
4596
4675
|
function EffectsObject(engine) {
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4676
|
+
var _this;
|
|
4677
|
+
_this = EventEmitter.call(this) || this;
|
|
4678
|
+
_this.engine = engine;
|
|
4679
|
+
_this.guid = generateGUID();
|
|
4680
|
+
_this.taggedProperties = {};
|
|
4681
|
+
_this.engine.addInstance(_assert_this_initialized(_this));
|
|
4682
|
+
return _this;
|
|
4601
4683
|
}
|
|
4602
4684
|
var _proto = EffectsObject.prototype;
|
|
4603
4685
|
_proto.getInstanceId = function getInstanceId() {
|
|
@@ -4623,7 +4705,7 @@ function getDirectStore(target) {
|
|
|
4623
4705
|
return _instanceof1(obj, EffectsObject) && "guid" in obj;
|
|
4624
4706
|
};
|
|
4625
4707
|
return EffectsObject;
|
|
4626
|
-
}();
|
|
4708
|
+
}(EventEmitter);
|
|
4627
4709
|
|
|
4628
4710
|
/**
|
|
4629
4711
|
* @since 2.0.0
|
|
@@ -9013,6 +9095,9 @@ exports.MaterialRenderType = void 0;
|
|
|
9013
9095
|
* 初始化 GPU 资源
|
|
9014
9096
|
* @override
|
|
9015
9097
|
*/ _proto.initialize = function initialize() {
|
|
9098
|
+
// OVERRIDE
|
|
9099
|
+
};
|
|
9100
|
+
_proto.createShaderVariant = function createShaderVariant() {
|
|
9016
9101
|
// OVERRIDE
|
|
9017
9102
|
};
|
|
9018
9103
|
_proto.use = function use(render, globalUniforms) {
|
|
@@ -12723,6 +12808,7 @@ var GlobalUniforms = function GlobalUniforms() {
|
|
|
12723
12808
|
this.floats = {};
|
|
12724
12809
|
this.ints = {};
|
|
12725
12810
|
// vector3s: Record<string, vec3> = {};
|
|
12811
|
+
this.vector4s = {};
|
|
12726
12812
|
this.matrices = {};
|
|
12727
12813
|
//...
|
|
12728
12814
|
this.samplers = [] // 存放的sampler名称。
|
|
@@ -12959,6 +13045,9 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
12959
13045
|
_proto.setGlobalInt = function setGlobalInt(name, value) {
|
|
12960
13046
|
// OVERRIDE
|
|
12961
13047
|
};
|
|
13048
|
+
_proto.setGlobalVector4 = function setGlobalVector4(name, value) {
|
|
13049
|
+
// OVERRIDE
|
|
13050
|
+
};
|
|
12962
13051
|
_proto.setGlobalMatrix = function setGlobalMatrix(name, value) {
|
|
12963
13052
|
// OVERRIDE
|
|
12964
13053
|
};
|
|
@@ -13504,11 +13593,6 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
13504
13593
|
return SpriteLoader;
|
|
13505
13594
|
}(AbstractPlugin);
|
|
13506
13595
|
|
|
13507
|
-
function _assert_this_initialized(self) {
|
|
13508
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
13509
|
-
return self;
|
|
13510
|
-
}
|
|
13511
|
-
|
|
13512
13596
|
/**
|
|
13513
13597
|
* 动画图,负责更新所有的动画节点
|
|
13514
13598
|
* @since 2.0.0
|
|
@@ -19293,6 +19377,9 @@ function compareTracks(a, b) {
|
|
|
19293
19377
|
_this.startTime = 0;
|
|
19294
19378
|
_this.items = [] // 场景的所有元素
|
|
19295
19379
|
;
|
|
19380
|
+
/**
|
|
19381
|
+
* 合成是否冻结标志位
|
|
19382
|
+
*/ _this.fezzed = false;
|
|
19296
19383
|
_this.reusable = false;
|
|
19297
19384
|
_this.sceneBindings = [];
|
|
19298
19385
|
_this.graph = new PlayableGraph();
|
|
@@ -19329,10 +19416,6 @@ function compareTracks(a, b) {
|
|
|
19329
19416
|
};
|
|
19330
19417
|
_proto.update = function update(dt) {
|
|
19331
19418
|
var time = this.time;
|
|
19332
|
-
// 主合成 rootItem 没有绑定轨道,增加结束行为判断。
|
|
19333
|
-
if (this.item.isEnded(this.time) && !this.item.parent) {
|
|
19334
|
-
this.item.ended = true;
|
|
19335
|
-
}
|
|
19336
19419
|
this.timelinePlayable.setTime(time);
|
|
19337
19420
|
this.graph.evaluate(dt);
|
|
19338
19421
|
};
|
|
@@ -19465,6 +19548,8 @@ function compareTracks(a, b) {
|
|
|
19465
19548
|
hitPositions: hitPositions,
|
|
19466
19549
|
behavior: hitParams.behavior
|
|
19467
19550
|
};
|
|
19551
|
+
// 触发单个元素的点击事件
|
|
19552
|
+
item.emit("click", region);
|
|
19468
19553
|
regions.push(region);
|
|
19469
19554
|
if (stop(region)) {
|
|
19470
19555
|
return {
|
|
@@ -20700,8 +20785,6 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
20700
20785
|
this.parentId = parentId;
|
|
20701
20786
|
this.duration = duration;
|
|
20702
20787
|
this.endBehavior = endBehavior;
|
|
20703
|
-
//@ts-expect-error
|
|
20704
|
-
this.oldId = data.oldId;
|
|
20705
20788
|
if (!data.content) {
|
|
20706
20789
|
data.content = {
|
|
20707
20790
|
options: {}
|
|
@@ -24710,89 +24793,93 @@ var listOrder = 0;
|
|
|
24710
24793
|
* 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
|
|
24711
24794
|
* 合成中包含了相关的 Item 元素,支持对 Item 元素的创建、更新和销毁。
|
|
24712
24795
|
* 也负责 Item 相关的动画播放控制,和持有渲染帧数据。
|
|
24713
|
-
*/ var Composition = /*#__PURE__*/ function() {
|
|
24796
|
+
*/ var Composition = /*#__PURE__*/ function(EventEmitter) {
|
|
24797
|
+
_inherits(Composition, EventEmitter);
|
|
24714
24798
|
function Composition(props, scene) {
|
|
24715
|
-
var _this
|
|
24799
|
+
var _this;
|
|
24800
|
+
_this = EventEmitter.call(this) || this;
|
|
24716
24801
|
/**
|
|
24717
24802
|
* 动画播放速度
|
|
24718
|
-
*/
|
|
24803
|
+
*/ _this.speed = 1;
|
|
24719
24804
|
/**
|
|
24720
24805
|
* 用于保存与当前合成相关的插件数据
|
|
24721
|
-
*/
|
|
24806
|
+
*/ _this.loaderData = {};
|
|
24722
24807
|
/**
|
|
24723
24808
|
* 预合成数组
|
|
24724
|
-
*/
|
|
24809
|
+
*/ _this.refContent = [];
|
|
24725
24810
|
/**
|
|
24726
24811
|
* 预合成的合成属性,在 content 中会被其元素属性覆盖
|
|
24727
|
-
*/
|
|
24812
|
+
*/ _this.refCompositionProps = new Map();
|
|
24728
24813
|
// TODO: 待优化
|
|
24729
|
-
|
|
24814
|
+
_this.assigned = false;
|
|
24730
24815
|
/**
|
|
24731
24816
|
* 销毁状态位
|
|
24732
|
-
*/
|
|
24733
|
-
|
|
24817
|
+
*/ _this.destroyed = false;
|
|
24818
|
+
_this.postLoaders = [];
|
|
24734
24819
|
/**
|
|
24735
24820
|
* 合成暂停/播放 标识
|
|
24736
|
-
*/
|
|
24737
|
-
|
|
24738
|
-
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,
|
|
24739
|
-
|
|
24821
|
+
*/ _this.paused = false;
|
|
24822
|
+
_this.lastVideoUpdateTime = 0;
|
|
24823
|
+
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;
|
|
24824
|
+
_this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
|
|
24740
24825
|
scene.jsonScene.imgUsage = undefined;
|
|
24741
24826
|
if (reusable) {
|
|
24742
|
-
|
|
24827
|
+
_this.keepResource = true;
|
|
24743
24828
|
scene.textures = undefined;
|
|
24744
24829
|
scene.consumed = true;
|
|
24745
24830
|
}
|
|
24746
|
-
var _this_compositionSourceManager =
|
|
24831
|
+
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;
|
|
24747
24832
|
assertExist(sourceContent);
|
|
24748
|
-
|
|
24749
|
-
|
|
24750
|
-
|
|
24751
|
-
|
|
24752
|
-
|
|
24753
|
-
|
|
24754
|
-
|
|
24833
|
+
_this.renderer = renderer;
|
|
24834
|
+
_this.refCompositionProps = refCompositionProps;
|
|
24835
|
+
_this.rootItem = new exports.VFXItem(_this.getEngine(), sourceContent);
|
|
24836
|
+
_this.rootItem.name = "rootItem";
|
|
24837
|
+
_this.rootItem.composition = _assert_this_initialized(_this);
|
|
24838
|
+
_this.rootComposition = _this.rootItem.addComponent(CompositionComponent);
|
|
24839
|
+
_this.rootComposition.startTime = sourceContent.startTime;
|
|
24840
|
+
_this.rootComposition.data = sourceContent;
|
|
24755
24841
|
var imageUsage = !reusable && imgUsage;
|
|
24756
|
-
|
|
24757
|
-
|
|
24758
|
-
|
|
24759
|
-
|
|
24760
|
-
|
|
24761
|
-
|
|
24762
|
-
|
|
24842
|
+
_this.width = width;
|
|
24843
|
+
_this.height = height;
|
|
24844
|
+
_this.renderOrder = baseRenderOrder;
|
|
24845
|
+
_this.id = sourceContent.id;
|
|
24846
|
+
_this.renderer = renderer;
|
|
24847
|
+
_this.texInfo = imageUsage != null ? imageUsage : {};
|
|
24848
|
+
_this.event = event;
|
|
24763
24849
|
var _scene_startTime, _scene_timeInfos_asyncCompile;
|
|
24764
|
-
|
|
24850
|
+
_this.statistic = {
|
|
24765
24851
|
loadTime: totalTime != null ? totalTime : 0,
|
|
24766
24852
|
loadStart: (_scene_startTime = scene.startTime) != null ? _scene_startTime : 0,
|
|
24767
24853
|
firstFrameTime: 0,
|
|
24768
24854
|
precompileTime: (_scene_timeInfos_asyncCompile = scene.timeInfos["asyncCompile"]) != null ? _scene_timeInfos_asyncCompile : scene.timeInfos["syncCompile"]
|
|
24769
24855
|
};
|
|
24770
|
-
|
|
24771
|
-
|
|
24772
|
-
|
|
24773
|
-
|
|
24774
|
-
|
|
24775
|
-
|
|
24776
|
-
|
|
24856
|
+
_this.reusable = reusable;
|
|
24857
|
+
_this.speed = speed;
|
|
24858
|
+
_this.autoRefTex = !_this.keepResource && imageUsage && _this.rootItem.endBehavior !== EndBehavior.restart;
|
|
24859
|
+
_this.name = sourceContent.name;
|
|
24860
|
+
_this.pluginSystem = pluginSystem;
|
|
24861
|
+
_this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
24862
|
+
_this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
|
|
24777
24863
|
aspect: width / height
|
|
24778
24864
|
}));
|
|
24779
|
-
|
|
24780
|
-
|
|
24781
|
-
|
|
24782
|
-
|
|
24783
|
-
|
|
24784
|
-
|
|
24785
|
-
|
|
24786
|
-
|
|
24787
|
-
|
|
24788
|
-
|
|
24789
|
-
this.buildItemTree(this.rootItem);
|
|
24790
|
-
this.rootItem.onEnd = function() {
|
|
24865
|
+
_this.url = scene.url;
|
|
24866
|
+
_this.assigned = true;
|
|
24867
|
+
_this.globalTime = 0;
|
|
24868
|
+
_this.interactive = true;
|
|
24869
|
+
_this.handleItemMessage = handleItemMessage;
|
|
24870
|
+
_this.createRenderFrame();
|
|
24871
|
+
_this.rendererOptions = null;
|
|
24872
|
+
_this.rootComposition.createContent();
|
|
24873
|
+
_this.buildItemTree(_this.rootItem);
|
|
24874
|
+
_this.rootItem.onEnd = function() {
|
|
24791
24875
|
window.setTimeout(function() {
|
|
24792
|
-
_this.
|
|
24876
|
+
_this.emit("end", {
|
|
24877
|
+
composition: _assert_this_initialized(_this)
|
|
24878
|
+
});
|
|
24793
24879
|
}, 0);
|
|
24794
24880
|
};
|
|
24795
|
-
|
|
24881
|
+
_this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
|
|
24882
|
+
return _this;
|
|
24796
24883
|
}
|
|
24797
24884
|
var _proto = Composition.prototype;
|
|
24798
24885
|
/**
|
|
@@ -24843,7 +24930,7 @@ var listOrder = 0;
|
|
|
24843
24930
|
if (this.rootItem.ended && this.reusable) {
|
|
24844
24931
|
this.restart();
|
|
24845
24932
|
}
|
|
24846
|
-
if (
|
|
24933
|
+
if (this.rootComposition.started) {
|
|
24847
24934
|
this.gotoAndPlay(this.time - this.startTime);
|
|
24848
24935
|
} else {
|
|
24849
24936
|
this.gotoAndPlay(0);
|
|
@@ -24866,18 +24953,14 @@ var listOrder = 0;
|
|
|
24866
24953
|
* 跳转合成到指定时间播放
|
|
24867
24954
|
* @param time - 相对 startTime 的时间
|
|
24868
24955
|
*/ _proto.gotoAndPlay = function gotoAndPlay(time) {
|
|
24956
|
+
this.setTime(time);
|
|
24869
24957
|
this.resume();
|
|
24870
|
-
if (!this.rootComposition.started) {
|
|
24871
|
-
this.rootComposition.start();
|
|
24872
|
-
this.rootComposition.started = true;
|
|
24873
|
-
}
|
|
24874
|
-
this.forwardTime(time + this.startTime);
|
|
24875
24958
|
};
|
|
24876
24959
|
/**
|
|
24877
24960
|
* 跳转合成到指定时间并暂停
|
|
24878
24961
|
* @param time - 相对 startTime 的时间
|
|
24879
24962
|
*/ _proto.gotoAndStop = function gotoAndStop(time) {
|
|
24880
|
-
this.
|
|
24963
|
+
this.setTime(time);
|
|
24881
24964
|
this.pause();
|
|
24882
24965
|
};
|
|
24883
24966
|
/**
|
|
@@ -24904,7 +24987,7 @@ var listOrder = 0;
|
|
|
24904
24987
|
this.rootComposition.start();
|
|
24905
24988
|
this.rootComposition.started = true;
|
|
24906
24989
|
}
|
|
24907
|
-
this.forwardTime(time + this.startTime
|
|
24990
|
+
this.forwardTime(time + this.startTime);
|
|
24908
24991
|
if (pause) {
|
|
24909
24992
|
this.pause();
|
|
24910
24993
|
}
|
|
@@ -24917,17 +25000,16 @@ var listOrder = 0;
|
|
|
24917
25000
|
* 前进合成到指定时间
|
|
24918
25001
|
* @param time - 相对0时刻的时间
|
|
24919
25002
|
* @param skipRender - 是否跳过渲染
|
|
24920
|
-
*/ _proto.forwardTime = function forwardTime(time
|
|
24921
|
-
if (skipRender === void 0) skipRender = false;
|
|
25003
|
+
*/ _proto.forwardTime = function forwardTime(time) {
|
|
24922
25004
|
var deltaTime = time * 1000 - this.rootComposition.time * 1000;
|
|
24923
25005
|
var reverse = deltaTime < 0;
|
|
24924
25006
|
var step = 15;
|
|
24925
25007
|
var t = Math.abs(deltaTime);
|
|
24926
25008
|
var ss = reverse ? -step : step;
|
|
24927
25009
|
for(t; t > step; t -= step){
|
|
24928
|
-
this.update(ss
|
|
25010
|
+
this.update(ss);
|
|
24929
25011
|
}
|
|
24930
|
-
this.update(reverse ? -t : t
|
|
25012
|
+
this.update(reverse ? -t : t);
|
|
24931
25013
|
};
|
|
24932
25014
|
/**
|
|
24933
25015
|
* 重置状态函数
|
|
@@ -24968,8 +25050,9 @@ var listOrder = 0;
|
|
|
24968
25050
|
* 是否合成需要重新播放
|
|
24969
25051
|
* @returns 重新播放合成标志位
|
|
24970
25052
|
*/ _proto.shouldRestart = function shouldRestart() {
|
|
24971
|
-
var _this_rootItem = this.rootItem,
|
|
24972
|
-
|
|
25053
|
+
var _this_rootItem = this.rootItem, duration = _this_rootItem.duration, endBehavior = _this_rootItem.endBehavior;
|
|
25054
|
+
var time = this.rootComposition.time;
|
|
25055
|
+
return endBehavior === EndBehavior.restart && duration - time < 0.02;
|
|
24973
25056
|
};
|
|
24974
25057
|
/**
|
|
24975
25058
|
* 是否合成需要销毁
|
|
@@ -24978,44 +25061,45 @@ var listOrder = 0;
|
|
|
24978
25061
|
if (this.reusable) {
|
|
24979
25062
|
return false;
|
|
24980
25063
|
}
|
|
24981
|
-
var
|
|
25064
|
+
var endBehavior = this.rootItem.endBehavior;
|
|
25065
|
+
if (this.rootItem.isEnded(this.time)) {
|
|
25066
|
+
this.rootItem.ended = true;
|
|
25067
|
+
}
|
|
24982
25068
|
// TODO: 合成结束行为
|
|
24983
|
-
return ended &&
|
|
25069
|
+
return this.rootItem.ended && endBehavior === EndBehavior.destroy;
|
|
24984
25070
|
};
|
|
24985
25071
|
/**
|
|
24986
25072
|
* 合成更新,针对所有 item 的更新
|
|
24987
25073
|
* @param deltaTime - 更新的时间步长
|
|
24988
25074
|
* @param skipRender - 是否需要渲染
|
|
24989
|
-
*/ _proto.update = function update(deltaTime
|
|
24990
|
-
if (skipRender === void 0) skipRender = false;
|
|
25075
|
+
*/ _proto.update = function update(deltaTime) {
|
|
24991
25076
|
if (!this.assigned || this.paused) {
|
|
24992
25077
|
return;
|
|
24993
25078
|
}
|
|
25079
|
+
var time = this.getUpdateTime(deltaTime * this.speed);
|
|
25080
|
+
this.globalTime += time;
|
|
25081
|
+
this.updateRootComposition();
|
|
24994
25082
|
if (this.shouldRestart()) {
|
|
25083
|
+
this.emit("end", {
|
|
25084
|
+
composition: this
|
|
25085
|
+
});
|
|
24995
25086
|
this.restart();
|
|
24996
25087
|
// restart then tick to avoid flicker
|
|
24997
25088
|
}
|
|
24998
|
-
var time = this.getUpdateTime(deltaTime * this.speed);
|
|
24999
|
-
this.globalTime += time;
|
|
25000
|
-
if (this.rootComposition.isActiveAndEnabled) {
|
|
25001
|
-
var localTime = this.toLocalTime(this.globalTime / 1000);
|
|
25002
|
-
this.rootComposition.time = localTime;
|
|
25003
|
-
}
|
|
25004
25089
|
this.updateVideo();
|
|
25005
25090
|
// 更新 model-tree-plugin
|
|
25006
25091
|
this.updatePluginLoaders(deltaTime);
|
|
25007
25092
|
this.callStart(this.rootItem);
|
|
25008
25093
|
this.callUpdate(this.rootItem, time);
|
|
25009
25094
|
this.callLateUpdate(this.rootItem, time);
|
|
25010
|
-
// this.extraCamera?.getComponent(TimelineComponent)?.update(deltaTime);
|
|
25011
25095
|
this.updateCamera();
|
|
25012
25096
|
if (this.shouldDispose()) {
|
|
25013
|
-
this.
|
|
25097
|
+
this.emit("end", {
|
|
25098
|
+
composition: this
|
|
25099
|
+
});
|
|
25014
25100
|
this.dispose();
|
|
25015
25101
|
} else {
|
|
25016
|
-
|
|
25017
|
-
this.prepareRender();
|
|
25018
|
-
}
|
|
25102
|
+
this.prepareRender();
|
|
25019
25103
|
}
|
|
25020
25104
|
};
|
|
25021
25105
|
_proto.toLocalTime = function toLocalTime(time) {
|
|
@@ -25026,13 +25110,20 @@ var listOrder = 0;
|
|
|
25026
25110
|
localTime = localTime % duration;
|
|
25027
25111
|
} else if (this.rootItem.endBehavior === EndBehavior.freeze) {
|
|
25028
25112
|
localTime = Math.min(duration, localTime);
|
|
25113
|
+
if (localTime === duration) {
|
|
25114
|
+
if (!this.rootComposition.fezzed) {
|
|
25115
|
+
this.rootComposition.fezzed = true;
|
|
25116
|
+
this.emit("end", {
|
|
25117
|
+
composition: this
|
|
25118
|
+
});
|
|
25119
|
+
}
|
|
25120
|
+
}
|
|
25029
25121
|
}
|
|
25030
25122
|
}
|
|
25031
25123
|
return localTime;
|
|
25032
25124
|
};
|
|
25033
25125
|
_proto.getUpdateTime = function getUpdateTime(t) {
|
|
25034
25126
|
var startTimeInMs = this.startTime * 1000;
|
|
25035
|
-
// const content = this.rootItem;
|
|
25036
25127
|
var now = this.rootComposition.time * 1000;
|
|
25037
25128
|
if (t < 0 && now + t < startTimeInMs) {
|
|
25038
25129
|
return startTimeInMs - now;
|
|
@@ -25180,6 +25271,14 @@ var listOrder = 0;
|
|
|
25180
25271
|
});
|
|
25181
25272
|
};
|
|
25182
25273
|
/**
|
|
25274
|
+
* 更新主合成组件
|
|
25275
|
+
*/ _proto.updateRootComposition = function updateRootComposition() {
|
|
25276
|
+
if (this.rootComposition.isActiveAndEnabled) {
|
|
25277
|
+
var localTime = this.toLocalTime(this.globalTime / 1000);
|
|
25278
|
+
this.rootComposition.time = localTime;
|
|
25279
|
+
}
|
|
25280
|
+
};
|
|
25281
|
+
/**
|
|
25183
25282
|
* 通过名称获取元素
|
|
25184
25283
|
* @param name - 元素名称
|
|
25185
25284
|
* @returns 元素对象
|
|
@@ -25228,12 +25327,17 @@ var listOrder = 0;
|
|
|
25228
25327
|
* @param type - 交互类型
|
|
25229
25328
|
*/ _proto.addInteractiveItem = function addInteractiveItem(item, type) {
|
|
25230
25329
|
if (type === InteractType.MESSAGE) {
|
|
25231
|
-
this.
|
|
25330
|
+
this.handleItemMessage({
|
|
25232
25331
|
name: item.name,
|
|
25233
25332
|
phrase: MESSAGE_ITEM_PHRASE_BEGIN,
|
|
25234
25333
|
id: item.id,
|
|
25235
25334
|
compositionId: this.id
|
|
25236
25335
|
});
|
|
25336
|
+
item.emit("message", {
|
|
25337
|
+
name: item.name,
|
|
25338
|
+
phrase: MESSAGE_ITEM_PHRASE_BEGIN,
|
|
25339
|
+
id: item.id
|
|
25340
|
+
});
|
|
25237
25341
|
return item.id;
|
|
25238
25342
|
}
|
|
25239
25343
|
};
|
|
@@ -25242,14 +25346,19 @@ var listOrder = 0;
|
|
|
25242
25346
|
* @param item - 交互元素
|
|
25243
25347
|
* @param type - 交互类型
|
|
25244
25348
|
*/ _proto.removeInteractiveItem = function removeInteractiveItem(item, type) {
|
|
25245
|
-
// MESSAGE ITEM的结束行为
|
|
25349
|
+
// MESSAGE ITEM 的结束行为
|
|
25246
25350
|
if (type === InteractType.MESSAGE) {
|
|
25247
|
-
this.
|
|
25351
|
+
this.handleItemMessage({
|
|
25248
25352
|
name: item.name,
|
|
25249
25353
|
phrase: MESSAGE_ITEM_PHRASE_END,
|
|
25250
25354
|
id: item.id,
|
|
25251
25355
|
compositionId: this.id
|
|
25252
25356
|
});
|
|
25357
|
+
item.emit("message", {
|
|
25358
|
+
name: item.name,
|
|
25359
|
+
phrase: MESSAGE_ITEM_PHRASE_END,
|
|
25360
|
+
id: item.id
|
|
25361
|
+
});
|
|
25253
25362
|
}
|
|
25254
25363
|
};
|
|
25255
25364
|
/**
|
|
@@ -25345,7 +25454,6 @@ var listOrder = 0;
|
|
|
25345
25454
|
this.update = function() {
|
|
25346
25455
|
logger.error("Update disposed composition: " + _this.name + ".");
|
|
25347
25456
|
};
|
|
25348
|
-
this.onPlayerPause = noop;
|
|
25349
25457
|
this.dispose = noop;
|
|
25350
25458
|
if (textures && this.keepResource) {
|
|
25351
25459
|
textures.forEach(function(tex) {
|
|
@@ -25543,7 +25651,7 @@ var listOrder = 0;
|
|
|
25543
25651
|
}
|
|
25544
25652
|
]);
|
|
25545
25653
|
return Composition;
|
|
25546
|
-
}();
|
|
25654
|
+
}(EventEmitter);
|
|
25547
25655
|
|
|
25548
25656
|
var SIZEOF_SHORT = 2;
|
|
25549
25657
|
var SIZEOF_INT = 4;
|
|
@@ -27507,7 +27615,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
|
|
|
27507
27615
|
registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
|
|
27508
27616
|
registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
|
|
27509
27617
|
registerPlugin("interact", InteractLoader, exports.VFXItem, true);
|
|
27510
|
-
var version$1 = "2.0.0-alpha.
|
|
27618
|
+
var version$1 = "2.0.0-alpha.32";
|
|
27511
27619
|
logger.info("Core version: " + version$1 + ".");
|
|
27512
27620
|
|
|
27513
27621
|
var _obj;
|
|
@@ -27581,6 +27689,13 @@ var _obj3;
|
|
|
27581
27689
|
*/ _this.uniforms = {};
|
|
27582
27690
|
var shader = props == null ? void 0 : props.shader;
|
|
27583
27691
|
var level = engine.gpuCapability.level;
|
|
27692
|
+
_this.shader = new exports.Shader(engine);
|
|
27693
|
+
_this.shader.shaderData = _extends({}, shader, {
|
|
27694
|
+
id: generateGUID(),
|
|
27695
|
+
dataType: DataType.Shader,
|
|
27696
|
+
vertex: (shader == null ? void 0 : shader.vertex) || "",
|
|
27697
|
+
fragment: (shader == null ? void 0 : shader.fragment) || ""
|
|
27698
|
+
});
|
|
27584
27699
|
for(var i = 0; i < exports.maxSpriteMeshItemCount; i++){
|
|
27585
27700
|
_this.uniforms["uSampler" + i] = new THREE__namespace.Uniform(null);
|
|
27586
27701
|
}
|
|
@@ -28761,6 +28876,8 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
28761
28876
|
var _this;
|
|
28762
28877
|
_this = Renderer.call(this) || this;
|
|
28763
28878
|
_this.engine = new ThreeEngine(gl);
|
|
28879
|
+
_this.engine.renderer = _assert_this_initialized(_this);
|
|
28880
|
+
_this.env = "";
|
|
28764
28881
|
_this.renderingData = {
|
|
28765
28882
|
//@ts-expect-error
|
|
28766
28883
|
currentFrame: {}
|
|
@@ -28788,8 +28905,8 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
28788
28905
|
var _this;
|
|
28789
28906
|
_this = _THREE_Group.call(this) || this;
|
|
28790
28907
|
_this.compositions = [];
|
|
28791
|
-
_this.baseCompositionIndex = 0;
|
|
28792
28908
|
_this.env = "";
|
|
28909
|
+
_this.baseCompositionIndex = 0;
|
|
28793
28910
|
var width = options.width, height = options.height, camera = options.camera;
|
|
28794
28911
|
_this.renderer = new ThreeRenderer(context);
|
|
28795
28912
|
_this.width = width;
|
|
@@ -28858,6 +28975,19 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
28858
28975
|
});
|
|
28859
28976
|
})();
|
|
28860
28977
|
};
|
|
28978
|
+
_proto.pause = function pause() {
|
|
28979
|
+
this.dispatchEvent({
|
|
28980
|
+
type: "pause"
|
|
28981
|
+
});
|
|
28982
|
+
this.compositions.forEach(function(composition) {
|
|
28983
|
+
composition.pause();
|
|
28984
|
+
});
|
|
28985
|
+
};
|
|
28986
|
+
_proto.resume = function resume() {
|
|
28987
|
+
this.compositions.forEach(function(composition) {
|
|
28988
|
+
composition.resume();
|
|
28989
|
+
});
|
|
28990
|
+
};
|
|
28861
28991
|
_proto.createComposition = function createComposition(url, options) {
|
|
28862
28992
|
if (options === void 0) options = {};
|
|
28863
28993
|
var _this = this;
|
|
@@ -28914,8 +29044,20 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
28914
29044
|
composition = new ThreeComposition(_extends({}, opts, {
|
|
28915
29045
|
width: _this.width,
|
|
28916
29046
|
height: _this.height,
|
|
28917
|
-
renderer: _this.renderer
|
|
29047
|
+
renderer: _this.renderer,
|
|
29048
|
+
handleItemMessage: function(message) {
|
|
29049
|
+
_this.dispatchEvent({
|
|
29050
|
+
type: "message",
|
|
29051
|
+
message: message
|
|
29052
|
+
});
|
|
29053
|
+
}
|
|
28918
29054
|
}), scene);
|
|
29055
|
+
composition.on("end", function() {
|
|
29056
|
+
_this.dispatchEvent({
|
|
29057
|
+
type: "end",
|
|
29058
|
+
composition: composition
|
|
29059
|
+
});
|
|
29060
|
+
});
|
|
28919
29061
|
_this.renderer.engine.setOptions({
|
|
28920
29062
|
threeCamera: _this.camera,
|
|
28921
29063
|
threeGroup: _this,
|
|
@@ -29140,7 +29282,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
29140
29282
|
*/ Mesh.create = function(engine, props) {
|
|
29141
29283
|
return new ThreeMesh(engine, props);
|
|
29142
29284
|
};
|
|
29143
|
-
var version = "2.0.0-alpha.
|
|
29285
|
+
var version = "2.0.0-alpha.32";
|
|
29144
29286
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
29145
29287
|
|
|
29146
29288
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -29178,6 +29320,7 @@ exports.EVENT_TYPE_TOUCH_START = EVENT_TYPE_TOUCH_START;
|
|
|
29178
29320
|
exports.EffectsObject = EffectsObject;
|
|
29179
29321
|
exports.EffectsPackage = EffectsPackage;
|
|
29180
29322
|
exports.Engine = Engine;
|
|
29323
|
+
exports.EventEmitter = EventEmitter;
|
|
29181
29324
|
exports.EventSystem = EventSystem;
|
|
29182
29325
|
exports.Float16ArrayWrapper = Float16ArrayWrapper;
|
|
29183
29326
|
exports.Framebuffer = Framebuffer;
|