@galacean/effects-core 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/comp-vfx-item.d.ts +4 -0
- package/dist/composition.d.ts +16 -30
- package/dist/effects-object.d.ts +3 -1
- package/dist/events/event-emitter.d.ts +46 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/types.d.ts +37 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +214 -105
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +214 -106
- package/dist/index.mjs.map +1 -1
- package/dist/material/material.d.ts +3 -1
- package/dist/render/render-frame.d.ts +1 -0
- package/dist/render/renderer.d.ts +2 -1
- package/dist/vfx-item.d.ts +0 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.32
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -4567,15 +4567,97 @@ function getDirectStore(target) {
|
|
|
4567
4567
|
return decoratorInitialStore.get(classKey);
|
|
4568
4568
|
}
|
|
4569
4569
|
|
|
4570
|
+
function _assert_this_initialized(self) {
|
|
4571
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4572
|
+
return self;
|
|
4573
|
+
}
|
|
4574
|
+
|
|
4575
|
+
var EventEmitter = function EventEmitter() {
|
|
4576
|
+
var _this = this;
|
|
4577
|
+
var _this1 = this;
|
|
4578
|
+
this.listeners = {};
|
|
4579
|
+
/**
|
|
4580
|
+
* 移除事件监听器
|
|
4581
|
+
* @param eventName - 事件名称
|
|
4582
|
+
* @param listener - 事件监听器
|
|
4583
|
+
* @returns
|
|
4584
|
+
*/ this.off = function(eventName, listener) {
|
|
4585
|
+
if (!_this.listeners[eventName]) {
|
|
4586
|
+
return;
|
|
4587
|
+
}
|
|
4588
|
+
_this.listeners[eventName] = _this.listeners[eventName].filter(function(param) {
|
|
4589
|
+
var l = param.listener;
|
|
4590
|
+
return l !== listener;
|
|
4591
|
+
});
|
|
4592
|
+
};
|
|
4593
|
+
/**
|
|
4594
|
+
* 监听事件
|
|
4595
|
+
* @param eventName - 事件名称
|
|
4596
|
+
* @param listener - 事件监听器
|
|
4597
|
+
* @param options - 事件监听器选项
|
|
4598
|
+
* @returns
|
|
4599
|
+
*/ this.on = function(eventName, listener, options) {
|
|
4600
|
+
_this.listeners[eventName] = _this.listeners[eventName] || [];
|
|
4601
|
+
_this.listeners[eventName].push({
|
|
4602
|
+
listener: listener,
|
|
4603
|
+
options: options
|
|
4604
|
+
});
|
|
4605
|
+
return function() {
|
|
4606
|
+
return _this.off(eventName, listener);
|
|
4607
|
+
};
|
|
4608
|
+
};
|
|
4609
|
+
/**
|
|
4610
|
+
* 一次性监听事件
|
|
4611
|
+
* @param eventName - 事件名称
|
|
4612
|
+
* @param listener - 事件监听器
|
|
4613
|
+
*/ this.once = function(eventName, listener) {
|
|
4614
|
+
_this.on(eventName, listener, {
|
|
4615
|
+
once: true
|
|
4616
|
+
});
|
|
4617
|
+
};
|
|
4618
|
+
/**
|
|
4619
|
+
* 触发事件
|
|
4620
|
+
* @param eventName - 事件名称
|
|
4621
|
+
* @param args - 事件参数
|
|
4622
|
+
*/ this.emit = function(eventName) {
|
|
4623
|
+
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
4624
|
+
args[_key - 1] = arguments[_key];
|
|
4625
|
+
}
|
|
4626
|
+
var _this_listeners_eventName;
|
|
4627
|
+
(_this_listeners_eventName = _this1.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.forEach(function(param) {
|
|
4628
|
+
var listener = param.listener, options = param.options;
|
|
4629
|
+
listener.apply(void 0, [].concat(args));
|
|
4630
|
+
if (options == null ? void 0 : options.once) {
|
|
4631
|
+
_this1.off(eventName, listener);
|
|
4632
|
+
}
|
|
4633
|
+
});
|
|
4634
|
+
};
|
|
4635
|
+
/**
|
|
4636
|
+
* 获取事件名称对应的所有监听器
|
|
4637
|
+
* @param eventName - 事件名称
|
|
4638
|
+
* @returns - 返回事件名称对应的所有监听器
|
|
4639
|
+
*/ this.getListeners = function(eventName) {
|
|
4640
|
+
var _this_listeners_eventName;
|
|
4641
|
+
return ((_this_listeners_eventName = _this.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.map(function(param) {
|
|
4642
|
+
var listener = param.listener;
|
|
4643
|
+
return listener;
|
|
4644
|
+
})) || [];
|
|
4645
|
+
};
|
|
4646
|
+
};
|
|
4647
|
+
|
|
4570
4648
|
/**
|
|
4571
4649
|
* @since 2.0.0
|
|
4572
4650
|
* @internal
|
|
4573
|
-
*/ var EffectsObject = /*#__PURE__*/ function() {
|
|
4651
|
+
*/ var EffectsObject = /*#__PURE__*/ function(EventEmitter) {
|
|
4652
|
+
_inherits(EffectsObject, EventEmitter);
|
|
4574
4653
|
function EffectsObject(engine) {
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4654
|
+
var _this;
|
|
4655
|
+
_this = EventEmitter.call(this) || this;
|
|
4656
|
+
_this.engine = engine;
|
|
4657
|
+
_this.guid = generateGUID();
|
|
4658
|
+
_this.taggedProperties = {};
|
|
4659
|
+
_this.engine.addInstance(_assert_this_initialized(_this));
|
|
4660
|
+
return _this;
|
|
4579
4661
|
}
|
|
4580
4662
|
var _proto = EffectsObject.prototype;
|
|
4581
4663
|
_proto.getInstanceId = function getInstanceId() {
|
|
@@ -4601,7 +4683,7 @@ function getDirectStore(target) {
|
|
|
4601
4683
|
return _instanceof1(obj, EffectsObject) && "guid" in obj;
|
|
4602
4684
|
};
|
|
4603
4685
|
return EffectsObject;
|
|
4604
|
-
}();
|
|
4686
|
+
}(EventEmitter);
|
|
4605
4687
|
|
|
4606
4688
|
/**
|
|
4607
4689
|
* @since 2.0.0
|
|
@@ -8991,6 +9073,9 @@ exports.MaterialRenderType = void 0;
|
|
|
8991
9073
|
* 初始化 GPU 资源
|
|
8992
9074
|
* @override
|
|
8993
9075
|
*/ _proto.initialize = function initialize() {
|
|
9076
|
+
// OVERRIDE
|
|
9077
|
+
};
|
|
9078
|
+
_proto.createShaderVariant = function createShaderVariant() {
|
|
8994
9079
|
// OVERRIDE
|
|
8995
9080
|
};
|
|
8996
9081
|
_proto.use = function use(render, globalUniforms) {
|
|
@@ -12701,6 +12786,7 @@ var GlobalUniforms = function GlobalUniforms() {
|
|
|
12701
12786
|
this.floats = {};
|
|
12702
12787
|
this.ints = {};
|
|
12703
12788
|
// vector3s: Record<string, vec3> = {};
|
|
12789
|
+
this.vector4s = {};
|
|
12704
12790
|
this.matrices = {};
|
|
12705
12791
|
//...
|
|
12706
12792
|
this.samplers = [] // 存放的sampler名称。
|
|
@@ -12937,6 +13023,9 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
12937
13023
|
_proto.setGlobalInt = function setGlobalInt(name, value) {
|
|
12938
13024
|
// OVERRIDE
|
|
12939
13025
|
};
|
|
13026
|
+
_proto.setGlobalVector4 = function setGlobalVector4(name, value) {
|
|
13027
|
+
// OVERRIDE
|
|
13028
|
+
};
|
|
12940
13029
|
_proto.setGlobalMatrix = function setGlobalMatrix(name, value) {
|
|
12941
13030
|
// OVERRIDE
|
|
12942
13031
|
};
|
|
@@ -13482,11 +13571,6 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
13482
13571
|
return SpriteLoader;
|
|
13483
13572
|
}(AbstractPlugin);
|
|
13484
13573
|
|
|
13485
|
-
function _assert_this_initialized(self) {
|
|
13486
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
13487
|
-
return self;
|
|
13488
|
-
}
|
|
13489
|
-
|
|
13490
13574
|
/**
|
|
13491
13575
|
* 动画图,负责更新所有的动画节点
|
|
13492
13576
|
* @since 2.0.0
|
|
@@ -19271,6 +19355,9 @@ function compareTracks(a, b) {
|
|
|
19271
19355
|
_this.startTime = 0;
|
|
19272
19356
|
_this.items = [] // 场景的所有元素
|
|
19273
19357
|
;
|
|
19358
|
+
/**
|
|
19359
|
+
* 合成是否冻结标志位
|
|
19360
|
+
*/ _this.fezzed = false;
|
|
19274
19361
|
_this.reusable = false;
|
|
19275
19362
|
_this.sceneBindings = [];
|
|
19276
19363
|
_this.graph = new PlayableGraph();
|
|
@@ -19307,10 +19394,6 @@ function compareTracks(a, b) {
|
|
|
19307
19394
|
};
|
|
19308
19395
|
_proto.update = function update(dt) {
|
|
19309
19396
|
var time = this.time;
|
|
19310
|
-
// 主合成 rootItem 没有绑定轨道,增加结束行为判断。
|
|
19311
|
-
if (this.item.isEnded(this.time) && !this.item.parent) {
|
|
19312
|
-
this.item.ended = true;
|
|
19313
|
-
}
|
|
19314
19397
|
this.timelinePlayable.setTime(time);
|
|
19315
19398
|
this.graph.evaluate(dt);
|
|
19316
19399
|
};
|
|
@@ -19443,6 +19526,8 @@ function compareTracks(a, b) {
|
|
|
19443
19526
|
hitPositions: hitPositions,
|
|
19444
19527
|
behavior: hitParams.behavior
|
|
19445
19528
|
};
|
|
19529
|
+
// 触发单个元素的点击事件
|
|
19530
|
+
item.emit("click", region);
|
|
19446
19531
|
regions.push(region);
|
|
19447
19532
|
if (stop(region)) {
|
|
19448
19533
|
return {
|
|
@@ -20678,8 +20763,6 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
20678
20763
|
this.parentId = parentId;
|
|
20679
20764
|
this.duration = duration;
|
|
20680
20765
|
this.endBehavior = endBehavior;
|
|
20681
|
-
//@ts-expect-error
|
|
20682
|
-
this.oldId = data.oldId;
|
|
20683
20766
|
if (!data.content) {
|
|
20684
20767
|
data.content = {
|
|
20685
20768
|
options: {}
|
|
@@ -24688,89 +24771,93 @@ var listOrder = 0;
|
|
|
24688
24771
|
* 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
|
|
24689
24772
|
* 合成中包含了相关的 Item 元素,支持对 Item 元素的创建、更新和销毁。
|
|
24690
24773
|
* 也负责 Item 相关的动画播放控制,和持有渲染帧数据。
|
|
24691
|
-
*/ var Composition = /*#__PURE__*/ function() {
|
|
24774
|
+
*/ var Composition = /*#__PURE__*/ function(EventEmitter) {
|
|
24775
|
+
_inherits(Composition, EventEmitter);
|
|
24692
24776
|
function Composition(props, scene) {
|
|
24693
|
-
var _this
|
|
24777
|
+
var _this;
|
|
24778
|
+
_this = EventEmitter.call(this) || this;
|
|
24694
24779
|
/**
|
|
24695
24780
|
* 动画播放速度
|
|
24696
|
-
*/
|
|
24781
|
+
*/ _this.speed = 1;
|
|
24697
24782
|
/**
|
|
24698
24783
|
* 用于保存与当前合成相关的插件数据
|
|
24699
|
-
*/
|
|
24784
|
+
*/ _this.loaderData = {};
|
|
24700
24785
|
/**
|
|
24701
24786
|
* 预合成数组
|
|
24702
|
-
*/
|
|
24787
|
+
*/ _this.refContent = [];
|
|
24703
24788
|
/**
|
|
24704
24789
|
* 预合成的合成属性,在 content 中会被其元素属性覆盖
|
|
24705
|
-
*/
|
|
24790
|
+
*/ _this.refCompositionProps = new Map();
|
|
24706
24791
|
// TODO: 待优化
|
|
24707
|
-
|
|
24792
|
+
_this.assigned = false;
|
|
24708
24793
|
/**
|
|
24709
24794
|
* 销毁状态位
|
|
24710
|
-
*/
|
|
24711
|
-
|
|
24795
|
+
*/ _this.destroyed = false;
|
|
24796
|
+
_this.postLoaders = [];
|
|
24712
24797
|
/**
|
|
24713
24798
|
* 合成暂停/播放 标识
|
|
24714
|
-
*/
|
|
24715
|
-
|
|
24716
|
-
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,
|
|
24717
|
-
|
|
24799
|
+
*/ _this.paused = false;
|
|
24800
|
+
_this.lastVideoUpdateTime = 0;
|
|
24801
|
+
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;
|
|
24802
|
+
_this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
|
|
24718
24803
|
scene.jsonScene.imgUsage = undefined;
|
|
24719
24804
|
if (reusable) {
|
|
24720
|
-
|
|
24805
|
+
_this.keepResource = true;
|
|
24721
24806
|
scene.textures = undefined;
|
|
24722
24807
|
scene.consumed = true;
|
|
24723
24808
|
}
|
|
24724
|
-
var _this_compositionSourceManager =
|
|
24809
|
+
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;
|
|
24725
24810
|
assertExist(sourceContent);
|
|
24726
|
-
|
|
24727
|
-
|
|
24728
|
-
|
|
24729
|
-
|
|
24730
|
-
|
|
24731
|
-
|
|
24732
|
-
|
|
24811
|
+
_this.renderer = renderer;
|
|
24812
|
+
_this.refCompositionProps = refCompositionProps;
|
|
24813
|
+
_this.rootItem = new exports.VFXItem(_this.getEngine(), sourceContent);
|
|
24814
|
+
_this.rootItem.name = "rootItem";
|
|
24815
|
+
_this.rootItem.composition = _assert_this_initialized(_this);
|
|
24816
|
+
_this.rootComposition = _this.rootItem.addComponent(CompositionComponent);
|
|
24817
|
+
_this.rootComposition.startTime = sourceContent.startTime;
|
|
24818
|
+
_this.rootComposition.data = sourceContent;
|
|
24733
24819
|
var imageUsage = !reusable && imgUsage;
|
|
24734
|
-
|
|
24735
|
-
|
|
24736
|
-
|
|
24737
|
-
|
|
24738
|
-
|
|
24739
|
-
|
|
24740
|
-
|
|
24820
|
+
_this.width = width;
|
|
24821
|
+
_this.height = height;
|
|
24822
|
+
_this.renderOrder = baseRenderOrder;
|
|
24823
|
+
_this.id = sourceContent.id;
|
|
24824
|
+
_this.renderer = renderer;
|
|
24825
|
+
_this.texInfo = imageUsage != null ? imageUsage : {};
|
|
24826
|
+
_this.event = event;
|
|
24741
24827
|
var _scene_startTime, _scene_timeInfos_asyncCompile;
|
|
24742
|
-
|
|
24828
|
+
_this.statistic = {
|
|
24743
24829
|
loadTime: totalTime != null ? totalTime : 0,
|
|
24744
24830
|
loadStart: (_scene_startTime = scene.startTime) != null ? _scene_startTime : 0,
|
|
24745
24831
|
firstFrameTime: 0,
|
|
24746
24832
|
precompileTime: (_scene_timeInfos_asyncCompile = scene.timeInfos["asyncCompile"]) != null ? _scene_timeInfos_asyncCompile : scene.timeInfos["syncCompile"]
|
|
24747
24833
|
};
|
|
24748
|
-
|
|
24749
|
-
|
|
24750
|
-
|
|
24751
|
-
|
|
24752
|
-
|
|
24753
|
-
|
|
24754
|
-
|
|
24834
|
+
_this.reusable = reusable;
|
|
24835
|
+
_this.speed = speed;
|
|
24836
|
+
_this.autoRefTex = !_this.keepResource && imageUsage && _this.rootItem.endBehavior !== EndBehavior.restart;
|
|
24837
|
+
_this.name = sourceContent.name;
|
|
24838
|
+
_this.pluginSystem = pluginSystem;
|
|
24839
|
+
_this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
24840
|
+
_this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
|
|
24755
24841
|
aspect: width / height
|
|
24756
24842
|
}));
|
|
24757
|
-
|
|
24758
|
-
|
|
24759
|
-
|
|
24760
|
-
|
|
24761
|
-
|
|
24762
|
-
|
|
24763
|
-
|
|
24764
|
-
|
|
24765
|
-
|
|
24766
|
-
|
|
24767
|
-
this.buildItemTree(this.rootItem);
|
|
24768
|
-
this.rootItem.onEnd = function() {
|
|
24843
|
+
_this.url = scene.url;
|
|
24844
|
+
_this.assigned = true;
|
|
24845
|
+
_this.globalTime = 0;
|
|
24846
|
+
_this.interactive = true;
|
|
24847
|
+
_this.handleItemMessage = handleItemMessage;
|
|
24848
|
+
_this.createRenderFrame();
|
|
24849
|
+
_this.rendererOptions = null;
|
|
24850
|
+
_this.rootComposition.createContent();
|
|
24851
|
+
_this.buildItemTree(_this.rootItem);
|
|
24852
|
+
_this.rootItem.onEnd = function() {
|
|
24769
24853
|
window.setTimeout(function() {
|
|
24770
|
-
_this.
|
|
24854
|
+
_this.emit("end", {
|
|
24855
|
+
composition: _assert_this_initialized(_this)
|
|
24856
|
+
});
|
|
24771
24857
|
}, 0);
|
|
24772
24858
|
};
|
|
24773
|
-
|
|
24859
|
+
_this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
|
|
24860
|
+
return _this;
|
|
24774
24861
|
}
|
|
24775
24862
|
var _proto = Composition.prototype;
|
|
24776
24863
|
/**
|
|
@@ -24821,7 +24908,7 @@ var listOrder = 0;
|
|
|
24821
24908
|
if (this.rootItem.ended && this.reusable) {
|
|
24822
24909
|
this.restart();
|
|
24823
24910
|
}
|
|
24824
|
-
if (
|
|
24911
|
+
if (this.rootComposition.started) {
|
|
24825
24912
|
this.gotoAndPlay(this.time - this.startTime);
|
|
24826
24913
|
} else {
|
|
24827
24914
|
this.gotoAndPlay(0);
|
|
@@ -24844,18 +24931,14 @@ var listOrder = 0;
|
|
|
24844
24931
|
* 跳转合成到指定时间播放
|
|
24845
24932
|
* @param time - 相对 startTime 的时间
|
|
24846
24933
|
*/ _proto.gotoAndPlay = function gotoAndPlay(time) {
|
|
24934
|
+
this.setTime(time);
|
|
24847
24935
|
this.resume();
|
|
24848
|
-
if (!this.rootComposition.started) {
|
|
24849
|
-
this.rootComposition.start();
|
|
24850
|
-
this.rootComposition.started = true;
|
|
24851
|
-
}
|
|
24852
|
-
this.forwardTime(time + this.startTime);
|
|
24853
24936
|
};
|
|
24854
24937
|
/**
|
|
24855
24938
|
* 跳转合成到指定时间并暂停
|
|
24856
24939
|
* @param time - 相对 startTime 的时间
|
|
24857
24940
|
*/ _proto.gotoAndStop = function gotoAndStop(time) {
|
|
24858
|
-
this.
|
|
24941
|
+
this.setTime(time);
|
|
24859
24942
|
this.pause();
|
|
24860
24943
|
};
|
|
24861
24944
|
/**
|
|
@@ -24882,7 +24965,7 @@ var listOrder = 0;
|
|
|
24882
24965
|
this.rootComposition.start();
|
|
24883
24966
|
this.rootComposition.started = true;
|
|
24884
24967
|
}
|
|
24885
|
-
this.forwardTime(time + this.startTime
|
|
24968
|
+
this.forwardTime(time + this.startTime);
|
|
24886
24969
|
if (pause) {
|
|
24887
24970
|
this.pause();
|
|
24888
24971
|
}
|
|
@@ -24895,17 +24978,16 @@ var listOrder = 0;
|
|
|
24895
24978
|
* 前进合成到指定时间
|
|
24896
24979
|
* @param time - 相对0时刻的时间
|
|
24897
24980
|
* @param skipRender - 是否跳过渲染
|
|
24898
|
-
*/ _proto.forwardTime = function forwardTime(time
|
|
24899
|
-
if (skipRender === void 0) skipRender = false;
|
|
24981
|
+
*/ _proto.forwardTime = function forwardTime(time) {
|
|
24900
24982
|
var deltaTime = time * 1000 - this.rootComposition.time * 1000;
|
|
24901
24983
|
var reverse = deltaTime < 0;
|
|
24902
24984
|
var step = 15;
|
|
24903
24985
|
var t = Math.abs(deltaTime);
|
|
24904
24986
|
var ss = reverse ? -step : step;
|
|
24905
24987
|
for(t; t > step; t -= step){
|
|
24906
|
-
this.update(ss
|
|
24988
|
+
this.update(ss);
|
|
24907
24989
|
}
|
|
24908
|
-
this.update(reverse ? -t : t
|
|
24990
|
+
this.update(reverse ? -t : t);
|
|
24909
24991
|
};
|
|
24910
24992
|
/**
|
|
24911
24993
|
* 重置状态函数
|
|
@@ -24946,8 +25028,9 @@ var listOrder = 0;
|
|
|
24946
25028
|
* 是否合成需要重新播放
|
|
24947
25029
|
* @returns 重新播放合成标志位
|
|
24948
25030
|
*/ _proto.shouldRestart = function shouldRestart() {
|
|
24949
|
-
var _this_rootItem = this.rootItem,
|
|
24950
|
-
|
|
25031
|
+
var _this_rootItem = this.rootItem, duration = _this_rootItem.duration, endBehavior = _this_rootItem.endBehavior;
|
|
25032
|
+
var time = this.rootComposition.time;
|
|
25033
|
+
return endBehavior === EndBehavior.restart && duration - time < 0.02;
|
|
24951
25034
|
};
|
|
24952
25035
|
/**
|
|
24953
25036
|
* 是否合成需要销毁
|
|
@@ -24956,44 +25039,45 @@ var listOrder = 0;
|
|
|
24956
25039
|
if (this.reusable) {
|
|
24957
25040
|
return false;
|
|
24958
25041
|
}
|
|
24959
|
-
var
|
|
25042
|
+
var endBehavior = this.rootItem.endBehavior;
|
|
25043
|
+
if (this.rootItem.isEnded(this.time)) {
|
|
25044
|
+
this.rootItem.ended = true;
|
|
25045
|
+
}
|
|
24960
25046
|
// TODO: 合成结束行为
|
|
24961
|
-
return ended &&
|
|
25047
|
+
return this.rootItem.ended && endBehavior === EndBehavior.destroy;
|
|
24962
25048
|
};
|
|
24963
25049
|
/**
|
|
24964
25050
|
* 合成更新,针对所有 item 的更新
|
|
24965
25051
|
* @param deltaTime - 更新的时间步长
|
|
24966
25052
|
* @param skipRender - 是否需要渲染
|
|
24967
|
-
*/ _proto.update = function update(deltaTime
|
|
24968
|
-
if (skipRender === void 0) skipRender = false;
|
|
25053
|
+
*/ _proto.update = function update(deltaTime) {
|
|
24969
25054
|
if (!this.assigned || this.paused) {
|
|
24970
25055
|
return;
|
|
24971
25056
|
}
|
|
25057
|
+
var time = this.getUpdateTime(deltaTime * this.speed);
|
|
25058
|
+
this.globalTime += time;
|
|
25059
|
+
this.updateRootComposition();
|
|
24972
25060
|
if (this.shouldRestart()) {
|
|
25061
|
+
this.emit("end", {
|
|
25062
|
+
composition: this
|
|
25063
|
+
});
|
|
24973
25064
|
this.restart();
|
|
24974
25065
|
// restart then tick to avoid flicker
|
|
24975
25066
|
}
|
|
24976
|
-
var time = this.getUpdateTime(deltaTime * this.speed);
|
|
24977
|
-
this.globalTime += time;
|
|
24978
|
-
if (this.rootComposition.isActiveAndEnabled) {
|
|
24979
|
-
var localTime = this.toLocalTime(this.globalTime / 1000);
|
|
24980
|
-
this.rootComposition.time = localTime;
|
|
24981
|
-
}
|
|
24982
25067
|
this.updateVideo();
|
|
24983
25068
|
// 更新 model-tree-plugin
|
|
24984
25069
|
this.updatePluginLoaders(deltaTime);
|
|
24985
25070
|
this.callStart(this.rootItem);
|
|
24986
25071
|
this.callUpdate(this.rootItem, time);
|
|
24987
25072
|
this.callLateUpdate(this.rootItem, time);
|
|
24988
|
-
// this.extraCamera?.getComponent(TimelineComponent)?.update(deltaTime);
|
|
24989
25073
|
this.updateCamera();
|
|
24990
25074
|
if (this.shouldDispose()) {
|
|
24991
|
-
this.
|
|
25075
|
+
this.emit("end", {
|
|
25076
|
+
composition: this
|
|
25077
|
+
});
|
|
24992
25078
|
this.dispose();
|
|
24993
25079
|
} else {
|
|
24994
|
-
|
|
24995
|
-
this.prepareRender();
|
|
24996
|
-
}
|
|
25080
|
+
this.prepareRender();
|
|
24997
25081
|
}
|
|
24998
25082
|
};
|
|
24999
25083
|
_proto.toLocalTime = function toLocalTime(time) {
|
|
@@ -25004,13 +25088,20 @@ var listOrder = 0;
|
|
|
25004
25088
|
localTime = localTime % duration;
|
|
25005
25089
|
} else if (this.rootItem.endBehavior === EndBehavior.freeze) {
|
|
25006
25090
|
localTime = Math.min(duration, localTime);
|
|
25091
|
+
if (localTime === duration) {
|
|
25092
|
+
if (!this.rootComposition.fezzed) {
|
|
25093
|
+
this.rootComposition.fezzed = true;
|
|
25094
|
+
this.emit("end", {
|
|
25095
|
+
composition: this
|
|
25096
|
+
});
|
|
25097
|
+
}
|
|
25098
|
+
}
|
|
25007
25099
|
}
|
|
25008
25100
|
}
|
|
25009
25101
|
return localTime;
|
|
25010
25102
|
};
|
|
25011
25103
|
_proto.getUpdateTime = function getUpdateTime(t) {
|
|
25012
25104
|
var startTimeInMs = this.startTime * 1000;
|
|
25013
|
-
// const content = this.rootItem;
|
|
25014
25105
|
var now = this.rootComposition.time * 1000;
|
|
25015
25106
|
if (t < 0 && now + t < startTimeInMs) {
|
|
25016
25107
|
return startTimeInMs - now;
|
|
@@ -25158,6 +25249,14 @@ var listOrder = 0;
|
|
|
25158
25249
|
});
|
|
25159
25250
|
};
|
|
25160
25251
|
/**
|
|
25252
|
+
* 更新主合成组件
|
|
25253
|
+
*/ _proto.updateRootComposition = function updateRootComposition() {
|
|
25254
|
+
if (this.rootComposition.isActiveAndEnabled) {
|
|
25255
|
+
var localTime = this.toLocalTime(this.globalTime / 1000);
|
|
25256
|
+
this.rootComposition.time = localTime;
|
|
25257
|
+
}
|
|
25258
|
+
};
|
|
25259
|
+
/**
|
|
25161
25260
|
* 通过名称获取元素
|
|
25162
25261
|
* @param name - 元素名称
|
|
25163
25262
|
* @returns 元素对象
|
|
@@ -25206,12 +25305,17 @@ var listOrder = 0;
|
|
|
25206
25305
|
* @param type - 交互类型
|
|
25207
25306
|
*/ _proto.addInteractiveItem = function addInteractiveItem(item, type) {
|
|
25208
25307
|
if (type === InteractType.MESSAGE) {
|
|
25209
|
-
this.
|
|
25308
|
+
this.handleItemMessage({
|
|
25210
25309
|
name: item.name,
|
|
25211
25310
|
phrase: MESSAGE_ITEM_PHRASE_BEGIN,
|
|
25212
25311
|
id: item.id,
|
|
25213
25312
|
compositionId: this.id
|
|
25214
25313
|
});
|
|
25314
|
+
item.emit("message", {
|
|
25315
|
+
name: item.name,
|
|
25316
|
+
phrase: MESSAGE_ITEM_PHRASE_BEGIN,
|
|
25317
|
+
id: item.id
|
|
25318
|
+
});
|
|
25215
25319
|
return item.id;
|
|
25216
25320
|
}
|
|
25217
25321
|
};
|
|
@@ -25220,14 +25324,19 @@ var listOrder = 0;
|
|
|
25220
25324
|
* @param item - 交互元素
|
|
25221
25325
|
* @param type - 交互类型
|
|
25222
25326
|
*/ _proto.removeInteractiveItem = function removeInteractiveItem(item, type) {
|
|
25223
|
-
// MESSAGE ITEM的结束行为
|
|
25327
|
+
// MESSAGE ITEM 的结束行为
|
|
25224
25328
|
if (type === InteractType.MESSAGE) {
|
|
25225
|
-
this.
|
|
25329
|
+
this.handleItemMessage({
|
|
25226
25330
|
name: item.name,
|
|
25227
25331
|
phrase: MESSAGE_ITEM_PHRASE_END,
|
|
25228
25332
|
id: item.id,
|
|
25229
25333
|
compositionId: this.id
|
|
25230
25334
|
});
|
|
25335
|
+
item.emit("message", {
|
|
25336
|
+
name: item.name,
|
|
25337
|
+
phrase: MESSAGE_ITEM_PHRASE_END,
|
|
25338
|
+
id: item.id
|
|
25339
|
+
});
|
|
25231
25340
|
}
|
|
25232
25341
|
};
|
|
25233
25342
|
/**
|
|
@@ -25323,7 +25432,6 @@ var listOrder = 0;
|
|
|
25323
25432
|
this.update = function() {
|
|
25324
25433
|
logger.error("Update disposed composition: " + _this.name + ".");
|
|
25325
25434
|
};
|
|
25326
|
-
this.onPlayerPause = noop;
|
|
25327
25435
|
this.dispose = noop;
|
|
25328
25436
|
if (textures && this.keepResource) {
|
|
25329
25437
|
textures.forEach(function(tex) {
|
|
@@ -25521,7 +25629,7 @@ var listOrder = 0;
|
|
|
25521
25629
|
}
|
|
25522
25630
|
]);
|
|
25523
25631
|
return Composition;
|
|
25524
|
-
}();
|
|
25632
|
+
}(EventEmitter);
|
|
25525
25633
|
|
|
25526
25634
|
var SIZEOF_SHORT = 2;
|
|
25527
25635
|
var SIZEOF_INT = 4;
|
|
@@ -27485,7 +27593,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
|
|
|
27485
27593
|
registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
|
|
27486
27594
|
registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
|
|
27487
27595
|
registerPlugin("interact", InteractLoader, exports.VFXItem, true);
|
|
27488
|
-
var version = "2.0.0-alpha.
|
|
27596
|
+
var version = "2.0.0-alpha.32";
|
|
27489
27597
|
logger.info("Core version: " + version + ".");
|
|
27490
27598
|
|
|
27491
27599
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -27519,6 +27627,7 @@ exports.EVENT_TYPE_TOUCH_START = EVENT_TYPE_TOUCH_START;
|
|
|
27519
27627
|
exports.EffectsObject = EffectsObject;
|
|
27520
27628
|
exports.EffectsPackage = EffectsPackage;
|
|
27521
27629
|
exports.Engine = Engine;
|
|
27630
|
+
exports.EventEmitter = EventEmitter;
|
|
27522
27631
|
exports.EventSystem = EventSystem;
|
|
27523
27632
|
exports.Float16ArrayWrapper = Float16ArrayWrapper;
|
|
27524
27633
|
exports.Framebuffer = Framebuffer;
|