@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.mjs
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
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -4563,15 +4563,97 @@ function getDirectStore(target) {
|
|
|
4563
4563
|
return decoratorInitialStore.get(classKey);
|
|
4564
4564
|
}
|
|
4565
4565
|
|
|
4566
|
+
function _assert_this_initialized(self) {
|
|
4567
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4568
|
+
return self;
|
|
4569
|
+
}
|
|
4570
|
+
|
|
4571
|
+
var EventEmitter = function EventEmitter() {
|
|
4572
|
+
var _this = this;
|
|
4573
|
+
var _this1 = this;
|
|
4574
|
+
this.listeners = {};
|
|
4575
|
+
/**
|
|
4576
|
+
* 移除事件监听器
|
|
4577
|
+
* @param eventName - 事件名称
|
|
4578
|
+
* @param listener - 事件监听器
|
|
4579
|
+
* @returns
|
|
4580
|
+
*/ this.off = function(eventName, listener) {
|
|
4581
|
+
if (!_this.listeners[eventName]) {
|
|
4582
|
+
return;
|
|
4583
|
+
}
|
|
4584
|
+
_this.listeners[eventName] = _this.listeners[eventName].filter(function(param) {
|
|
4585
|
+
var l = param.listener;
|
|
4586
|
+
return l !== listener;
|
|
4587
|
+
});
|
|
4588
|
+
};
|
|
4589
|
+
/**
|
|
4590
|
+
* 监听事件
|
|
4591
|
+
* @param eventName - 事件名称
|
|
4592
|
+
* @param listener - 事件监听器
|
|
4593
|
+
* @param options - 事件监听器选项
|
|
4594
|
+
* @returns
|
|
4595
|
+
*/ this.on = function(eventName, listener, options) {
|
|
4596
|
+
_this.listeners[eventName] = _this.listeners[eventName] || [];
|
|
4597
|
+
_this.listeners[eventName].push({
|
|
4598
|
+
listener: listener,
|
|
4599
|
+
options: options
|
|
4600
|
+
});
|
|
4601
|
+
return function() {
|
|
4602
|
+
return _this.off(eventName, listener);
|
|
4603
|
+
};
|
|
4604
|
+
};
|
|
4605
|
+
/**
|
|
4606
|
+
* 一次性监听事件
|
|
4607
|
+
* @param eventName - 事件名称
|
|
4608
|
+
* @param listener - 事件监听器
|
|
4609
|
+
*/ this.once = function(eventName, listener) {
|
|
4610
|
+
_this.on(eventName, listener, {
|
|
4611
|
+
once: true
|
|
4612
|
+
});
|
|
4613
|
+
};
|
|
4614
|
+
/**
|
|
4615
|
+
* 触发事件
|
|
4616
|
+
* @param eventName - 事件名称
|
|
4617
|
+
* @param args - 事件参数
|
|
4618
|
+
*/ this.emit = function(eventName) {
|
|
4619
|
+
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
4620
|
+
args[_key - 1] = arguments[_key];
|
|
4621
|
+
}
|
|
4622
|
+
var _this_listeners_eventName;
|
|
4623
|
+
(_this_listeners_eventName = _this1.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.forEach(function(param) {
|
|
4624
|
+
var listener = param.listener, options = param.options;
|
|
4625
|
+
listener.apply(void 0, [].concat(args));
|
|
4626
|
+
if (options == null ? void 0 : options.once) {
|
|
4627
|
+
_this1.off(eventName, listener);
|
|
4628
|
+
}
|
|
4629
|
+
});
|
|
4630
|
+
};
|
|
4631
|
+
/**
|
|
4632
|
+
* 获取事件名称对应的所有监听器
|
|
4633
|
+
* @param eventName - 事件名称
|
|
4634
|
+
* @returns - 返回事件名称对应的所有监听器
|
|
4635
|
+
*/ this.getListeners = function(eventName) {
|
|
4636
|
+
var _this_listeners_eventName;
|
|
4637
|
+
return ((_this_listeners_eventName = _this.listeners[eventName]) == null ? void 0 : _this_listeners_eventName.map(function(param) {
|
|
4638
|
+
var listener = param.listener;
|
|
4639
|
+
return listener;
|
|
4640
|
+
})) || [];
|
|
4641
|
+
};
|
|
4642
|
+
};
|
|
4643
|
+
|
|
4566
4644
|
/**
|
|
4567
4645
|
* @since 2.0.0
|
|
4568
4646
|
* @internal
|
|
4569
|
-
*/ var EffectsObject = /*#__PURE__*/ function() {
|
|
4647
|
+
*/ var EffectsObject = /*#__PURE__*/ function(EventEmitter) {
|
|
4648
|
+
_inherits(EffectsObject, EventEmitter);
|
|
4570
4649
|
function EffectsObject(engine) {
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4650
|
+
var _this;
|
|
4651
|
+
_this = EventEmitter.call(this) || this;
|
|
4652
|
+
_this.engine = engine;
|
|
4653
|
+
_this.guid = generateGUID();
|
|
4654
|
+
_this.taggedProperties = {};
|
|
4655
|
+
_this.engine.addInstance(_assert_this_initialized(_this));
|
|
4656
|
+
return _this;
|
|
4575
4657
|
}
|
|
4576
4658
|
var _proto = EffectsObject.prototype;
|
|
4577
4659
|
_proto.getInstanceId = function getInstanceId() {
|
|
@@ -4597,7 +4679,7 @@ function getDirectStore(target) {
|
|
|
4597
4679
|
return _instanceof1(obj, EffectsObject) && "guid" in obj;
|
|
4598
4680
|
};
|
|
4599
4681
|
return EffectsObject;
|
|
4600
|
-
}();
|
|
4682
|
+
}(EventEmitter);
|
|
4601
4683
|
|
|
4602
4684
|
/**
|
|
4603
4685
|
* @since 2.0.0
|
|
@@ -8987,6 +9069,9 @@ var MaterialRenderType;
|
|
|
8987
9069
|
* 初始化 GPU 资源
|
|
8988
9070
|
* @override
|
|
8989
9071
|
*/ _proto.initialize = function initialize() {
|
|
9072
|
+
// OVERRIDE
|
|
9073
|
+
};
|
|
9074
|
+
_proto.createShaderVariant = function createShaderVariant() {
|
|
8990
9075
|
// OVERRIDE
|
|
8991
9076
|
};
|
|
8992
9077
|
_proto.use = function use(render, globalUniforms) {
|
|
@@ -12697,6 +12782,7 @@ var GlobalUniforms = function GlobalUniforms() {
|
|
|
12697
12782
|
this.floats = {};
|
|
12698
12783
|
this.ints = {};
|
|
12699
12784
|
// vector3s: Record<string, vec3> = {};
|
|
12785
|
+
this.vector4s = {};
|
|
12700
12786
|
this.matrices = {};
|
|
12701
12787
|
//...
|
|
12702
12788
|
this.samplers = [] // 存放的sampler名称。
|
|
@@ -12933,6 +13019,9 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
12933
13019
|
_proto.setGlobalInt = function setGlobalInt(name, value) {
|
|
12934
13020
|
// OVERRIDE
|
|
12935
13021
|
};
|
|
13022
|
+
_proto.setGlobalVector4 = function setGlobalVector4(name, value) {
|
|
13023
|
+
// OVERRIDE
|
|
13024
|
+
};
|
|
12936
13025
|
_proto.setGlobalMatrix = function setGlobalMatrix(name, value) {
|
|
12937
13026
|
// OVERRIDE
|
|
12938
13027
|
};
|
|
@@ -13478,11 +13567,6 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
13478
13567
|
return SpriteLoader;
|
|
13479
13568
|
}(AbstractPlugin);
|
|
13480
13569
|
|
|
13481
|
-
function _assert_this_initialized(self) {
|
|
13482
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
13483
|
-
return self;
|
|
13484
|
-
}
|
|
13485
|
-
|
|
13486
13570
|
/**
|
|
13487
13571
|
* 动画图,负责更新所有的动画节点
|
|
13488
13572
|
* @since 2.0.0
|
|
@@ -19267,6 +19351,9 @@ function compareTracks(a, b) {
|
|
|
19267
19351
|
_this.startTime = 0;
|
|
19268
19352
|
_this.items = [] // 场景的所有元素
|
|
19269
19353
|
;
|
|
19354
|
+
/**
|
|
19355
|
+
* 合成是否冻结标志位
|
|
19356
|
+
*/ _this.fezzed = false;
|
|
19270
19357
|
_this.reusable = false;
|
|
19271
19358
|
_this.sceneBindings = [];
|
|
19272
19359
|
_this.graph = new PlayableGraph();
|
|
@@ -19303,10 +19390,6 @@ function compareTracks(a, b) {
|
|
|
19303
19390
|
};
|
|
19304
19391
|
_proto.update = function update(dt) {
|
|
19305
19392
|
var time = this.time;
|
|
19306
|
-
// 主合成 rootItem 没有绑定轨道,增加结束行为判断。
|
|
19307
|
-
if (this.item.isEnded(this.time) && !this.item.parent) {
|
|
19308
|
-
this.item.ended = true;
|
|
19309
|
-
}
|
|
19310
19393
|
this.timelinePlayable.setTime(time);
|
|
19311
19394
|
this.graph.evaluate(dt);
|
|
19312
19395
|
};
|
|
@@ -19439,6 +19522,8 @@ function compareTracks(a, b) {
|
|
|
19439
19522
|
hitPositions: hitPositions,
|
|
19440
19523
|
behavior: hitParams.behavior
|
|
19441
19524
|
};
|
|
19525
|
+
// 触发单个元素的点击事件
|
|
19526
|
+
item.emit("click", region);
|
|
19442
19527
|
regions.push(region);
|
|
19443
19528
|
if (stop(region)) {
|
|
19444
19529
|
return {
|
|
@@ -20674,8 +20759,6 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
20674
20759
|
this.parentId = parentId;
|
|
20675
20760
|
this.duration = duration;
|
|
20676
20761
|
this.endBehavior = endBehavior;
|
|
20677
|
-
//@ts-expect-error
|
|
20678
|
-
this.oldId = data.oldId;
|
|
20679
20762
|
if (!data.content) {
|
|
20680
20763
|
data.content = {
|
|
20681
20764
|
options: {}
|
|
@@ -24684,89 +24767,93 @@ var listOrder = 0;
|
|
|
24684
24767
|
* 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
|
|
24685
24768
|
* 合成中包含了相关的 Item 元素,支持对 Item 元素的创建、更新和销毁。
|
|
24686
24769
|
* 也负责 Item 相关的动画播放控制,和持有渲染帧数据。
|
|
24687
|
-
*/ var Composition = /*#__PURE__*/ function() {
|
|
24770
|
+
*/ var Composition = /*#__PURE__*/ function(EventEmitter) {
|
|
24771
|
+
_inherits(Composition, EventEmitter);
|
|
24688
24772
|
function Composition(props, scene) {
|
|
24689
|
-
var _this
|
|
24773
|
+
var _this;
|
|
24774
|
+
_this = EventEmitter.call(this) || this;
|
|
24690
24775
|
/**
|
|
24691
24776
|
* 动画播放速度
|
|
24692
|
-
*/
|
|
24777
|
+
*/ _this.speed = 1;
|
|
24693
24778
|
/**
|
|
24694
24779
|
* 用于保存与当前合成相关的插件数据
|
|
24695
|
-
*/
|
|
24780
|
+
*/ _this.loaderData = {};
|
|
24696
24781
|
/**
|
|
24697
24782
|
* 预合成数组
|
|
24698
|
-
*/
|
|
24783
|
+
*/ _this.refContent = [];
|
|
24699
24784
|
/**
|
|
24700
24785
|
* 预合成的合成属性,在 content 中会被其元素属性覆盖
|
|
24701
|
-
*/
|
|
24786
|
+
*/ _this.refCompositionProps = new Map();
|
|
24702
24787
|
// TODO: 待优化
|
|
24703
|
-
|
|
24788
|
+
_this.assigned = false;
|
|
24704
24789
|
/**
|
|
24705
24790
|
* 销毁状态位
|
|
24706
|
-
*/
|
|
24707
|
-
|
|
24791
|
+
*/ _this.destroyed = false;
|
|
24792
|
+
_this.postLoaders = [];
|
|
24708
24793
|
/**
|
|
24709
24794
|
* 合成暂停/播放 标识
|
|
24710
|
-
*/
|
|
24711
|
-
|
|
24712
|
-
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,
|
|
24713
|
-
|
|
24795
|
+
*/ _this.paused = false;
|
|
24796
|
+
_this.lastVideoUpdateTime = 0;
|
|
24797
|
+
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;
|
|
24798
|
+
_this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
|
|
24714
24799
|
scene.jsonScene.imgUsage = undefined;
|
|
24715
24800
|
if (reusable) {
|
|
24716
|
-
|
|
24801
|
+
_this.keepResource = true;
|
|
24717
24802
|
scene.textures = undefined;
|
|
24718
24803
|
scene.consumed = true;
|
|
24719
24804
|
}
|
|
24720
|
-
var _this_compositionSourceManager =
|
|
24805
|
+
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;
|
|
24721
24806
|
assertExist(sourceContent);
|
|
24722
|
-
|
|
24723
|
-
|
|
24724
|
-
|
|
24725
|
-
|
|
24726
|
-
|
|
24727
|
-
|
|
24728
|
-
|
|
24807
|
+
_this.renderer = renderer;
|
|
24808
|
+
_this.refCompositionProps = refCompositionProps;
|
|
24809
|
+
_this.rootItem = new VFXItem(_this.getEngine(), sourceContent);
|
|
24810
|
+
_this.rootItem.name = "rootItem";
|
|
24811
|
+
_this.rootItem.composition = _assert_this_initialized(_this);
|
|
24812
|
+
_this.rootComposition = _this.rootItem.addComponent(CompositionComponent);
|
|
24813
|
+
_this.rootComposition.startTime = sourceContent.startTime;
|
|
24814
|
+
_this.rootComposition.data = sourceContent;
|
|
24729
24815
|
var imageUsage = !reusable && imgUsage;
|
|
24730
|
-
|
|
24731
|
-
|
|
24732
|
-
|
|
24733
|
-
|
|
24734
|
-
|
|
24735
|
-
|
|
24736
|
-
|
|
24816
|
+
_this.width = width;
|
|
24817
|
+
_this.height = height;
|
|
24818
|
+
_this.renderOrder = baseRenderOrder;
|
|
24819
|
+
_this.id = sourceContent.id;
|
|
24820
|
+
_this.renderer = renderer;
|
|
24821
|
+
_this.texInfo = imageUsage != null ? imageUsage : {};
|
|
24822
|
+
_this.event = event;
|
|
24737
24823
|
var _scene_startTime, _scene_timeInfos_asyncCompile;
|
|
24738
|
-
|
|
24824
|
+
_this.statistic = {
|
|
24739
24825
|
loadTime: totalTime != null ? totalTime : 0,
|
|
24740
24826
|
loadStart: (_scene_startTime = scene.startTime) != null ? _scene_startTime : 0,
|
|
24741
24827
|
firstFrameTime: 0,
|
|
24742
24828
|
precompileTime: (_scene_timeInfos_asyncCompile = scene.timeInfos["asyncCompile"]) != null ? _scene_timeInfos_asyncCompile : scene.timeInfos["syncCompile"]
|
|
24743
24829
|
};
|
|
24744
|
-
|
|
24745
|
-
|
|
24746
|
-
|
|
24747
|
-
|
|
24748
|
-
|
|
24749
|
-
|
|
24750
|
-
|
|
24830
|
+
_this.reusable = reusable;
|
|
24831
|
+
_this.speed = speed;
|
|
24832
|
+
_this.autoRefTex = !_this.keepResource && imageUsage && _this.rootItem.endBehavior !== EndBehavior.restart;
|
|
24833
|
+
_this.name = sourceContent.name;
|
|
24834
|
+
_this.pluginSystem = pluginSystem;
|
|
24835
|
+
_this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
24836
|
+
_this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
|
|
24751
24837
|
aspect: width / height
|
|
24752
24838
|
}));
|
|
24753
|
-
|
|
24754
|
-
|
|
24755
|
-
|
|
24756
|
-
|
|
24757
|
-
|
|
24758
|
-
|
|
24759
|
-
|
|
24760
|
-
|
|
24761
|
-
|
|
24762
|
-
|
|
24763
|
-
this.buildItemTree(this.rootItem);
|
|
24764
|
-
this.rootItem.onEnd = function() {
|
|
24839
|
+
_this.url = scene.url;
|
|
24840
|
+
_this.assigned = true;
|
|
24841
|
+
_this.globalTime = 0;
|
|
24842
|
+
_this.interactive = true;
|
|
24843
|
+
_this.handleItemMessage = handleItemMessage;
|
|
24844
|
+
_this.createRenderFrame();
|
|
24845
|
+
_this.rendererOptions = null;
|
|
24846
|
+
_this.rootComposition.createContent();
|
|
24847
|
+
_this.buildItemTree(_this.rootItem);
|
|
24848
|
+
_this.rootItem.onEnd = function() {
|
|
24765
24849
|
window.setTimeout(function() {
|
|
24766
|
-
_this.
|
|
24850
|
+
_this.emit("end", {
|
|
24851
|
+
composition: _assert_this_initialized(_this)
|
|
24852
|
+
});
|
|
24767
24853
|
}, 0);
|
|
24768
24854
|
};
|
|
24769
|
-
|
|
24855
|
+
_this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
|
|
24856
|
+
return _this;
|
|
24770
24857
|
}
|
|
24771
24858
|
var _proto = Composition.prototype;
|
|
24772
24859
|
/**
|
|
@@ -24817,7 +24904,7 @@ var listOrder = 0;
|
|
|
24817
24904
|
if (this.rootItem.ended && this.reusable) {
|
|
24818
24905
|
this.restart();
|
|
24819
24906
|
}
|
|
24820
|
-
if (
|
|
24907
|
+
if (this.rootComposition.started) {
|
|
24821
24908
|
this.gotoAndPlay(this.time - this.startTime);
|
|
24822
24909
|
} else {
|
|
24823
24910
|
this.gotoAndPlay(0);
|
|
@@ -24840,18 +24927,14 @@ var listOrder = 0;
|
|
|
24840
24927
|
* 跳转合成到指定时间播放
|
|
24841
24928
|
* @param time - 相对 startTime 的时间
|
|
24842
24929
|
*/ _proto.gotoAndPlay = function gotoAndPlay(time) {
|
|
24930
|
+
this.setTime(time);
|
|
24843
24931
|
this.resume();
|
|
24844
|
-
if (!this.rootComposition.started) {
|
|
24845
|
-
this.rootComposition.start();
|
|
24846
|
-
this.rootComposition.started = true;
|
|
24847
|
-
}
|
|
24848
|
-
this.forwardTime(time + this.startTime);
|
|
24849
24932
|
};
|
|
24850
24933
|
/**
|
|
24851
24934
|
* 跳转合成到指定时间并暂停
|
|
24852
24935
|
* @param time - 相对 startTime 的时间
|
|
24853
24936
|
*/ _proto.gotoAndStop = function gotoAndStop(time) {
|
|
24854
|
-
this.
|
|
24937
|
+
this.setTime(time);
|
|
24855
24938
|
this.pause();
|
|
24856
24939
|
};
|
|
24857
24940
|
/**
|
|
@@ -24878,7 +24961,7 @@ var listOrder = 0;
|
|
|
24878
24961
|
this.rootComposition.start();
|
|
24879
24962
|
this.rootComposition.started = true;
|
|
24880
24963
|
}
|
|
24881
|
-
this.forwardTime(time + this.startTime
|
|
24964
|
+
this.forwardTime(time + this.startTime);
|
|
24882
24965
|
if (pause) {
|
|
24883
24966
|
this.pause();
|
|
24884
24967
|
}
|
|
@@ -24891,17 +24974,16 @@ var listOrder = 0;
|
|
|
24891
24974
|
* 前进合成到指定时间
|
|
24892
24975
|
* @param time - 相对0时刻的时间
|
|
24893
24976
|
* @param skipRender - 是否跳过渲染
|
|
24894
|
-
*/ _proto.forwardTime = function forwardTime(time
|
|
24895
|
-
if (skipRender === void 0) skipRender = false;
|
|
24977
|
+
*/ _proto.forwardTime = function forwardTime(time) {
|
|
24896
24978
|
var deltaTime = time * 1000 - this.rootComposition.time * 1000;
|
|
24897
24979
|
var reverse = deltaTime < 0;
|
|
24898
24980
|
var step = 15;
|
|
24899
24981
|
var t = Math.abs(deltaTime);
|
|
24900
24982
|
var ss = reverse ? -step : step;
|
|
24901
24983
|
for(t; t > step; t -= step){
|
|
24902
|
-
this.update(ss
|
|
24984
|
+
this.update(ss);
|
|
24903
24985
|
}
|
|
24904
|
-
this.update(reverse ? -t : t
|
|
24986
|
+
this.update(reverse ? -t : t);
|
|
24905
24987
|
};
|
|
24906
24988
|
/**
|
|
24907
24989
|
* 重置状态函数
|
|
@@ -24942,8 +25024,9 @@ var listOrder = 0;
|
|
|
24942
25024
|
* 是否合成需要重新播放
|
|
24943
25025
|
* @returns 重新播放合成标志位
|
|
24944
25026
|
*/ _proto.shouldRestart = function shouldRestart() {
|
|
24945
|
-
var _this_rootItem = this.rootItem,
|
|
24946
|
-
|
|
25027
|
+
var _this_rootItem = this.rootItem, duration = _this_rootItem.duration, endBehavior = _this_rootItem.endBehavior;
|
|
25028
|
+
var time = this.rootComposition.time;
|
|
25029
|
+
return endBehavior === EndBehavior.restart && duration - time < 0.02;
|
|
24947
25030
|
};
|
|
24948
25031
|
/**
|
|
24949
25032
|
* 是否合成需要销毁
|
|
@@ -24952,44 +25035,45 @@ var listOrder = 0;
|
|
|
24952
25035
|
if (this.reusable) {
|
|
24953
25036
|
return false;
|
|
24954
25037
|
}
|
|
24955
|
-
var
|
|
25038
|
+
var endBehavior = this.rootItem.endBehavior;
|
|
25039
|
+
if (this.rootItem.isEnded(this.time)) {
|
|
25040
|
+
this.rootItem.ended = true;
|
|
25041
|
+
}
|
|
24956
25042
|
// TODO: 合成结束行为
|
|
24957
|
-
return ended &&
|
|
25043
|
+
return this.rootItem.ended && endBehavior === EndBehavior.destroy;
|
|
24958
25044
|
};
|
|
24959
25045
|
/**
|
|
24960
25046
|
* 合成更新,针对所有 item 的更新
|
|
24961
25047
|
* @param deltaTime - 更新的时间步长
|
|
24962
25048
|
* @param skipRender - 是否需要渲染
|
|
24963
|
-
*/ _proto.update = function update(deltaTime
|
|
24964
|
-
if (skipRender === void 0) skipRender = false;
|
|
25049
|
+
*/ _proto.update = function update(deltaTime) {
|
|
24965
25050
|
if (!this.assigned || this.paused) {
|
|
24966
25051
|
return;
|
|
24967
25052
|
}
|
|
25053
|
+
var time = this.getUpdateTime(deltaTime * this.speed);
|
|
25054
|
+
this.globalTime += time;
|
|
25055
|
+
this.updateRootComposition();
|
|
24968
25056
|
if (this.shouldRestart()) {
|
|
25057
|
+
this.emit("end", {
|
|
25058
|
+
composition: this
|
|
25059
|
+
});
|
|
24969
25060
|
this.restart();
|
|
24970
25061
|
// restart then tick to avoid flicker
|
|
24971
25062
|
}
|
|
24972
|
-
var time = this.getUpdateTime(deltaTime * this.speed);
|
|
24973
|
-
this.globalTime += time;
|
|
24974
|
-
if (this.rootComposition.isActiveAndEnabled) {
|
|
24975
|
-
var localTime = this.toLocalTime(this.globalTime / 1000);
|
|
24976
|
-
this.rootComposition.time = localTime;
|
|
24977
|
-
}
|
|
24978
25063
|
this.updateVideo();
|
|
24979
25064
|
// 更新 model-tree-plugin
|
|
24980
25065
|
this.updatePluginLoaders(deltaTime);
|
|
24981
25066
|
this.callStart(this.rootItem);
|
|
24982
25067
|
this.callUpdate(this.rootItem, time);
|
|
24983
25068
|
this.callLateUpdate(this.rootItem, time);
|
|
24984
|
-
// this.extraCamera?.getComponent(TimelineComponent)?.update(deltaTime);
|
|
24985
25069
|
this.updateCamera();
|
|
24986
25070
|
if (this.shouldDispose()) {
|
|
24987
|
-
this.
|
|
25071
|
+
this.emit("end", {
|
|
25072
|
+
composition: this
|
|
25073
|
+
});
|
|
24988
25074
|
this.dispose();
|
|
24989
25075
|
} else {
|
|
24990
|
-
|
|
24991
|
-
this.prepareRender();
|
|
24992
|
-
}
|
|
25076
|
+
this.prepareRender();
|
|
24993
25077
|
}
|
|
24994
25078
|
};
|
|
24995
25079
|
_proto.toLocalTime = function toLocalTime(time) {
|
|
@@ -25000,13 +25084,20 @@ var listOrder = 0;
|
|
|
25000
25084
|
localTime = localTime % duration;
|
|
25001
25085
|
} else if (this.rootItem.endBehavior === EndBehavior.freeze) {
|
|
25002
25086
|
localTime = Math.min(duration, localTime);
|
|
25087
|
+
if (localTime === duration) {
|
|
25088
|
+
if (!this.rootComposition.fezzed) {
|
|
25089
|
+
this.rootComposition.fezzed = true;
|
|
25090
|
+
this.emit("end", {
|
|
25091
|
+
composition: this
|
|
25092
|
+
});
|
|
25093
|
+
}
|
|
25094
|
+
}
|
|
25003
25095
|
}
|
|
25004
25096
|
}
|
|
25005
25097
|
return localTime;
|
|
25006
25098
|
};
|
|
25007
25099
|
_proto.getUpdateTime = function getUpdateTime(t) {
|
|
25008
25100
|
var startTimeInMs = this.startTime * 1000;
|
|
25009
|
-
// const content = this.rootItem;
|
|
25010
25101
|
var now = this.rootComposition.time * 1000;
|
|
25011
25102
|
if (t < 0 && now + t < startTimeInMs) {
|
|
25012
25103
|
return startTimeInMs - now;
|
|
@@ -25154,6 +25245,14 @@ var listOrder = 0;
|
|
|
25154
25245
|
});
|
|
25155
25246
|
};
|
|
25156
25247
|
/**
|
|
25248
|
+
* 更新主合成组件
|
|
25249
|
+
*/ _proto.updateRootComposition = function updateRootComposition() {
|
|
25250
|
+
if (this.rootComposition.isActiveAndEnabled) {
|
|
25251
|
+
var localTime = this.toLocalTime(this.globalTime / 1000);
|
|
25252
|
+
this.rootComposition.time = localTime;
|
|
25253
|
+
}
|
|
25254
|
+
};
|
|
25255
|
+
/**
|
|
25157
25256
|
* 通过名称获取元素
|
|
25158
25257
|
* @param name - 元素名称
|
|
25159
25258
|
* @returns 元素对象
|
|
@@ -25202,12 +25301,17 @@ var listOrder = 0;
|
|
|
25202
25301
|
* @param type - 交互类型
|
|
25203
25302
|
*/ _proto.addInteractiveItem = function addInteractiveItem(item, type) {
|
|
25204
25303
|
if (type === InteractType.MESSAGE) {
|
|
25205
|
-
this.
|
|
25304
|
+
this.handleItemMessage({
|
|
25206
25305
|
name: item.name,
|
|
25207
25306
|
phrase: MESSAGE_ITEM_PHRASE_BEGIN,
|
|
25208
25307
|
id: item.id,
|
|
25209
25308
|
compositionId: this.id
|
|
25210
25309
|
});
|
|
25310
|
+
item.emit("message", {
|
|
25311
|
+
name: item.name,
|
|
25312
|
+
phrase: MESSAGE_ITEM_PHRASE_BEGIN,
|
|
25313
|
+
id: item.id
|
|
25314
|
+
});
|
|
25211
25315
|
return item.id;
|
|
25212
25316
|
}
|
|
25213
25317
|
};
|
|
@@ -25216,14 +25320,19 @@ var listOrder = 0;
|
|
|
25216
25320
|
* @param item - 交互元素
|
|
25217
25321
|
* @param type - 交互类型
|
|
25218
25322
|
*/ _proto.removeInteractiveItem = function removeInteractiveItem(item, type) {
|
|
25219
|
-
// MESSAGE ITEM的结束行为
|
|
25323
|
+
// MESSAGE ITEM 的结束行为
|
|
25220
25324
|
if (type === InteractType.MESSAGE) {
|
|
25221
|
-
this.
|
|
25325
|
+
this.handleItemMessage({
|
|
25222
25326
|
name: item.name,
|
|
25223
25327
|
phrase: MESSAGE_ITEM_PHRASE_END,
|
|
25224
25328
|
id: item.id,
|
|
25225
25329
|
compositionId: this.id
|
|
25226
25330
|
});
|
|
25331
|
+
item.emit("message", {
|
|
25332
|
+
name: item.name,
|
|
25333
|
+
phrase: MESSAGE_ITEM_PHRASE_END,
|
|
25334
|
+
id: item.id
|
|
25335
|
+
});
|
|
25227
25336
|
}
|
|
25228
25337
|
};
|
|
25229
25338
|
/**
|
|
@@ -25319,7 +25428,6 @@ var listOrder = 0;
|
|
|
25319
25428
|
this.update = function() {
|
|
25320
25429
|
logger.error("Update disposed composition: " + _this.name + ".");
|
|
25321
25430
|
};
|
|
25322
|
-
this.onPlayerPause = noop;
|
|
25323
25431
|
this.dispose = noop;
|
|
25324
25432
|
if (textures && this.keepResource) {
|
|
25325
25433
|
textures.forEach(function(tex) {
|
|
@@ -25517,7 +25625,7 @@ var listOrder = 0;
|
|
|
25517
25625
|
}
|
|
25518
25626
|
]);
|
|
25519
25627
|
return Composition;
|
|
25520
|
-
}();
|
|
25628
|
+
}(EventEmitter);
|
|
25521
25629
|
|
|
25522
25630
|
var SIZEOF_SHORT = 2;
|
|
25523
25631
|
var SIZEOF_INT = 4;
|
|
@@ -27481,8 +27589,8 @@ registerPlugin("sprite", SpriteLoader, VFXItem, true);
|
|
|
27481
27589
|
registerPlugin("particle", ParticleLoader, VFXItem, true);
|
|
27482
27590
|
registerPlugin("cal", CalculateLoader, VFXItem, true);
|
|
27483
27591
|
registerPlugin("interact", InteractLoader, VFXItem, true);
|
|
27484
|
-
var version = "2.0.0-alpha.
|
|
27592
|
+
var version = "2.0.0-alpha.32";
|
|
27485
27593
|
logger.info("Core version: " + version + ".");
|
|
27486
27594
|
|
|
27487
|
-
export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, 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, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, 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, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, version, vertexFormatType2GLType };
|
|
27595
|
+
export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, 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, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, 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, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, version, vertexFormatType2GLType };
|
|
27488
27596
|
//# sourceMappingURL=index.mjs.map
|