@galacean/effects-core 2.0.0-alpha.30 → 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 +265 -120
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -121
- package/dist/index.mjs.map +1 -1
- package/dist/material/material.d.ts +3 -1
- package/dist/plugins/sprite/sprite-item.d.ts +1 -0
- 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
|
|
@@ -8412,7 +8494,8 @@ var seed$9 = 1;
|
|
|
8412
8494
|
texture = Texture.create(engine, {
|
|
8413
8495
|
sourceType: exports.TextureSourceType.image,
|
|
8414
8496
|
image: image,
|
|
8415
|
-
id: generateGUID()
|
|
8497
|
+
id: generateGUID(),
|
|
8498
|
+
flipY: true
|
|
8416
8499
|
});
|
|
8417
8500
|
texture.initialize();
|
|
8418
8501
|
return [
|
|
@@ -8990,6 +9073,9 @@ exports.MaterialRenderType = void 0;
|
|
|
8990
9073
|
* 初始化 GPU 资源
|
|
8991
9074
|
* @override
|
|
8992
9075
|
*/ _proto.initialize = function initialize() {
|
|
9076
|
+
// OVERRIDE
|
|
9077
|
+
};
|
|
9078
|
+
_proto.createShaderVariant = function createShaderVariant() {
|
|
8993
9079
|
// OVERRIDE
|
|
8994
9080
|
};
|
|
8995
9081
|
_proto.use = function use(render, globalUniforms) {
|
|
@@ -12700,6 +12786,7 @@ var GlobalUniforms = function GlobalUniforms() {
|
|
|
12700
12786
|
this.floats = {};
|
|
12701
12787
|
this.ints = {};
|
|
12702
12788
|
// vector3s: Record<string, vec3> = {};
|
|
12789
|
+
this.vector4s = {};
|
|
12703
12790
|
this.matrices = {};
|
|
12704
12791
|
//...
|
|
12705
12792
|
this.samplers = [] // 存放的sampler名称。
|
|
@@ -12936,6 +13023,9 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
12936
13023
|
_proto.setGlobalInt = function setGlobalInt(name, value) {
|
|
12937
13024
|
// OVERRIDE
|
|
12938
13025
|
};
|
|
13026
|
+
_proto.setGlobalVector4 = function setGlobalVector4(name, value) {
|
|
13027
|
+
// OVERRIDE
|
|
13028
|
+
};
|
|
12939
13029
|
_proto.setGlobalMatrix = function setGlobalMatrix(name, value) {
|
|
12940
13030
|
// OVERRIDE
|
|
12941
13031
|
};
|
|
@@ -13888,6 +13978,8 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
13888
13978
|
function SpriteComponent(engine, props) {
|
|
13889
13979
|
var _this;
|
|
13890
13980
|
_this = RendererComponent.call(this, engine) || this;
|
|
13981
|
+
_this.cachePrefix = "-";
|
|
13982
|
+
_this.frameAnimationLoop = false;
|
|
13891
13983
|
_this.frameAnimationTime = 0;
|
|
13892
13984
|
_this.color = [
|
|
13893
13985
|
1,
|
|
@@ -13911,6 +14003,39 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
13911
14003
|
}
|
|
13912
14004
|
}
|
|
13913
14005
|
};
|
|
14006
|
+
_this.name = "MSprite" + seed$3++;
|
|
14007
|
+
_this.renderer = {
|
|
14008
|
+
renderMode: RenderMode.BILLBOARD,
|
|
14009
|
+
blending: BlendingMode.ALPHA,
|
|
14010
|
+
texture: _this.engine.emptyTexture,
|
|
14011
|
+
occlusion: false,
|
|
14012
|
+
transparentOcclusion: false,
|
|
14013
|
+
side: SideMode.DOUBLE,
|
|
14014
|
+
mask: 0,
|
|
14015
|
+
maskMode: MaskMode.NONE,
|
|
14016
|
+
order: 0
|
|
14017
|
+
};
|
|
14018
|
+
_this.emptyTexture = _this.engine.emptyTexture;
|
|
14019
|
+
_this.splits = singleSplits;
|
|
14020
|
+
_this.renderInfo = getImageItemRenderInfo(_assert_this_initialized(_this));
|
|
14021
|
+
var geometry = _this.createGeometry(glContext.TRIANGLES);
|
|
14022
|
+
var material = _this.createMaterial(_this.renderInfo, 2);
|
|
14023
|
+
_this.worldMatrix = Matrix4.fromIdentity();
|
|
14024
|
+
_this.material = material;
|
|
14025
|
+
_this.geometry = geometry;
|
|
14026
|
+
_this.material.setVector4("_Color", new Vector4().setFromArray([
|
|
14027
|
+
1,
|
|
14028
|
+
1,
|
|
14029
|
+
1,
|
|
14030
|
+
1
|
|
14031
|
+
]));
|
|
14032
|
+
_this.material.setVector4("_TexOffset", new Vector4().setFromArray([
|
|
14033
|
+
0,
|
|
14034
|
+
0,
|
|
14035
|
+
1,
|
|
14036
|
+
1
|
|
14037
|
+
]));
|
|
14038
|
+
_this.setItem();
|
|
13914
14039
|
if (props) {
|
|
13915
14040
|
_this.fromData(props);
|
|
13916
14041
|
}
|
|
@@ -13964,9 +14089,13 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
13964
14089
|
this.frameAnimationTime += dt / 1000;
|
|
13965
14090
|
var time = this.frameAnimationTime;
|
|
13966
14091
|
var duration = this.item.duration;
|
|
14092
|
+
if (time > duration && this.frameAnimationLoop) {
|
|
14093
|
+
time = time % duration;
|
|
14094
|
+
}
|
|
13967
14095
|
var life = Math.min(Math.max(time / duration, 0.0), 1.0);
|
|
13968
14096
|
var ta = this.textureSheetAnimation;
|
|
13969
14097
|
if (ta) {
|
|
14098
|
+
var _this_material_getVector4;
|
|
13970
14099
|
var total = ta.total || ta.row * ta.col;
|
|
13971
14100
|
var texRectX = 0;
|
|
13972
14101
|
var texRectY = 0;
|
|
@@ -14012,7 +14141,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
14012
14141
|
dy
|
|
14013
14142
|
];
|
|
14014
14143
|
}
|
|
14015
|
-
this.material.getVector4("_TexOffset").setFromArray([
|
|
14144
|
+
(_this_material_getVector4 = this.material.getVector4("_TexOffset")) == null ? void 0 : _this_material_getVector4.setFromArray([
|
|
14016
14145
|
texRectX + texOffset[0],
|
|
14017
14146
|
texRectH + texRectY - texOffset[1],
|
|
14018
14147
|
dx,
|
|
@@ -14025,12 +14154,9 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
14025
14154
|
this.item.composition.destroyTextures(this.getTextures());
|
|
14026
14155
|
}
|
|
14027
14156
|
};
|
|
14028
|
-
_proto.getItemInitData = function getItemInitData(
|
|
14029
|
-
|
|
14030
|
-
|
|
14031
|
-
geoData = item.geoData = this.getItemGeometryData(item, idx);
|
|
14032
|
-
}
|
|
14033
|
-
var index = geoData.index;
|
|
14157
|
+
_proto.getItemInitData = function getItemInitData() {
|
|
14158
|
+
this.geoData = this.getItemGeometryData();
|
|
14159
|
+
var _this_geoData = this.geoData, index = _this_geoData.index, atlasOffset = _this_geoData.atlasOffset;
|
|
14034
14160
|
var idxCount = index.length;
|
|
14035
14161
|
// @ts-expect-error
|
|
14036
14162
|
var indexData = this.wireframe ? new Uint8Array([
|
|
@@ -14045,11 +14171,11 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
14045
14171
|
]) : new index.constructor(idxCount);
|
|
14046
14172
|
if (!this.wireframe) {
|
|
14047
14173
|
for(var i = 0; i < idxCount; i++){
|
|
14048
|
-
indexData[i] =
|
|
14174
|
+
indexData[i] = 0 + index[i];
|
|
14049
14175
|
}
|
|
14050
14176
|
}
|
|
14051
14177
|
return {
|
|
14052
|
-
atlasOffset:
|
|
14178
|
+
atlasOffset: atlasOffset,
|
|
14053
14179
|
index: indexData
|
|
14054
14180
|
};
|
|
14055
14181
|
};
|
|
@@ -14060,8 +14186,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
14060
14186
|
addItem(textures, texture);
|
|
14061
14187
|
}
|
|
14062
14188
|
texture = this.renderer.texture;
|
|
14063
|
-
var
|
|
14064
|
-
var data = this.getItemInitData(this, 0, 0, textureIndex);
|
|
14189
|
+
var data = this.getItemInitData();
|
|
14065
14190
|
var renderer = this.renderer;
|
|
14066
14191
|
var texParams = this.material.getVector4("_TexParams");
|
|
14067
14192
|
texParams.x = renderer.occlusion ? +renderer.transparentOcclusion : 1;
|
|
@@ -14152,6 +14277,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
14152
14277
|
setBlendMode(material, states.blendMode);
|
|
14153
14278
|
setMaskMode(material, states.maskMode);
|
|
14154
14279
|
setSideMode(material, states.side);
|
|
14280
|
+
material.shader.shaderData.properties = 'uSampler0("uSampler0",2D) = "white" {}';
|
|
14155
14281
|
if (!material.hasUniform("_Color")) {
|
|
14156
14282
|
material.setVector4("_Color", new Vector4(0, 0, 0, 1));
|
|
14157
14283
|
}
|
|
@@ -14163,8 +14289,8 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
14163
14289
|
}
|
|
14164
14290
|
return material;
|
|
14165
14291
|
};
|
|
14166
|
-
_proto.getItemGeometryData = function getItemGeometryData(
|
|
14167
|
-
var splits =
|
|
14292
|
+
_proto.getItemGeometryData = function getItemGeometryData() {
|
|
14293
|
+
var _this = this, splits = _this.splits, renderer = _this.renderer, textureSheetAnimation = _this.textureSheetAnimation;
|
|
14168
14294
|
var sx = 1, sy = 1;
|
|
14169
14295
|
if (renderer.shape) {
|
|
14170
14296
|
var _renderer_shape = renderer.shape, _renderer_shape_index = _renderer_shape.index, index = _renderer_shape_index === void 0 ? [] : _renderer_shape_index, _renderer_shape_aPoint = _renderer_shape.aPoint, aPoint = _renderer_shape_aPoint === void 0 ? [] : _renderer_shape_aPoint;
|
|
@@ -14319,7 +14445,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
14319
14445
|
this.worldMatrix = Matrix4.fromIdentity();
|
|
14320
14446
|
this.material = material;
|
|
14321
14447
|
this.geometry = geometry;
|
|
14322
|
-
this.name = "MSprite" + seed$3++;
|
|
14323
14448
|
var startColor = options.startColor || [
|
|
14324
14449
|
1,
|
|
14325
14450
|
1,
|
|
@@ -18436,11 +18561,6 @@ var CalculateLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
18436
18561
|
return CalculateLoader;
|
|
18437
18562
|
}(AbstractPlugin);
|
|
18438
18563
|
|
|
18439
|
-
function _assert_this_initialized(self) {
|
|
18440
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
18441
|
-
return self;
|
|
18442
|
-
}
|
|
18443
|
-
|
|
18444
18564
|
var AnimationStream = /*#__PURE__*/ function() {
|
|
18445
18565
|
function AnimationStream(playable) {
|
|
18446
18566
|
this.curveValues = {};
|
|
@@ -19235,6 +19355,9 @@ function compareTracks(a, b) {
|
|
|
19235
19355
|
_this.startTime = 0;
|
|
19236
19356
|
_this.items = [] // 场景的所有元素
|
|
19237
19357
|
;
|
|
19358
|
+
/**
|
|
19359
|
+
* 合成是否冻结标志位
|
|
19360
|
+
*/ _this.fezzed = false;
|
|
19238
19361
|
_this.reusable = false;
|
|
19239
19362
|
_this.sceneBindings = [];
|
|
19240
19363
|
_this.graph = new PlayableGraph();
|
|
@@ -19271,10 +19394,6 @@ function compareTracks(a, b) {
|
|
|
19271
19394
|
};
|
|
19272
19395
|
_proto.update = function update(dt) {
|
|
19273
19396
|
var time = this.time;
|
|
19274
|
-
// 主合成 rootItem 没有绑定轨道,增加结束行为判断。
|
|
19275
|
-
if (this.item.isEnded(this.time) && !this.item.parent) {
|
|
19276
|
-
this.item.ended = true;
|
|
19277
|
-
}
|
|
19278
19397
|
this.timelinePlayable.setTime(time);
|
|
19279
19398
|
this.graph.evaluate(dt);
|
|
19280
19399
|
};
|
|
@@ -19407,6 +19526,8 @@ function compareTracks(a, b) {
|
|
|
19407
19526
|
hitPositions: hitPositions,
|
|
19408
19527
|
behavior: hitParams.behavior
|
|
19409
19528
|
};
|
|
19529
|
+
// 触发单个元素的点击事件
|
|
19530
|
+
item.emit("click", region);
|
|
19410
19531
|
regions.push(region);
|
|
19411
19532
|
if (stop(region)) {
|
|
19412
19533
|
return {
|
|
@@ -20642,8 +20763,6 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
20642
20763
|
this.parentId = parentId;
|
|
20643
20764
|
this.duration = duration;
|
|
20644
20765
|
this.endBehavior = endBehavior;
|
|
20645
|
-
//@ts-expect-error
|
|
20646
|
-
this.oldId = data.oldId;
|
|
20647
20766
|
if (!data.content) {
|
|
20648
20767
|
data.content = {
|
|
20649
20768
|
options: {}
|
|
@@ -24652,89 +24771,93 @@ var listOrder = 0;
|
|
|
24652
24771
|
* 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
|
|
24653
24772
|
* 合成中包含了相关的 Item 元素,支持对 Item 元素的创建、更新和销毁。
|
|
24654
24773
|
* 也负责 Item 相关的动画播放控制,和持有渲染帧数据。
|
|
24655
|
-
*/ var Composition = /*#__PURE__*/ function() {
|
|
24774
|
+
*/ var Composition = /*#__PURE__*/ function(EventEmitter) {
|
|
24775
|
+
_inherits(Composition, EventEmitter);
|
|
24656
24776
|
function Composition(props, scene) {
|
|
24657
|
-
var _this
|
|
24777
|
+
var _this;
|
|
24778
|
+
_this = EventEmitter.call(this) || this;
|
|
24658
24779
|
/**
|
|
24659
24780
|
* 动画播放速度
|
|
24660
|
-
*/
|
|
24781
|
+
*/ _this.speed = 1;
|
|
24661
24782
|
/**
|
|
24662
24783
|
* 用于保存与当前合成相关的插件数据
|
|
24663
|
-
*/
|
|
24784
|
+
*/ _this.loaderData = {};
|
|
24664
24785
|
/**
|
|
24665
24786
|
* 预合成数组
|
|
24666
|
-
*/
|
|
24787
|
+
*/ _this.refContent = [];
|
|
24667
24788
|
/**
|
|
24668
24789
|
* 预合成的合成属性,在 content 中会被其元素属性覆盖
|
|
24669
|
-
*/
|
|
24790
|
+
*/ _this.refCompositionProps = new Map();
|
|
24670
24791
|
// TODO: 待优化
|
|
24671
|
-
|
|
24792
|
+
_this.assigned = false;
|
|
24672
24793
|
/**
|
|
24673
24794
|
* 销毁状态位
|
|
24674
|
-
*/
|
|
24675
|
-
|
|
24795
|
+
*/ _this.destroyed = false;
|
|
24796
|
+
_this.postLoaders = [];
|
|
24676
24797
|
/**
|
|
24677
24798
|
* 合成暂停/播放 标识
|
|
24678
|
-
*/
|
|
24679
|
-
|
|
24680
|
-
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,
|
|
24681
|
-
|
|
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);
|
|
24682
24803
|
scene.jsonScene.imgUsage = undefined;
|
|
24683
24804
|
if (reusable) {
|
|
24684
|
-
|
|
24805
|
+
_this.keepResource = true;
|
|
24685
24806
|
scene.textures = undefined;
|
|
24686
24807
|
scene.consumed = true;
|
|
24687
24808
|
}
|
|
24688
|
-
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;
|
|
24689
24810
|
assertExist(sourceContent);
|
|
24690
|
-
|
|
24691
|
-
|
|
24692
|
-
|
|
24693
|
-
|
|
24694
|
-
|
|
24695
|
-
|
|
24696
|
-
|
|
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;
|
|
24697
24819
|
var imageUsage = !reusable && imgUsage;
|
|
24698
|
-
|
|
24699
|
-
|
|
24700
|
-
|
|
24701
|
-
|
|
24702
|
-
|
|
24703
|
-
|
|
24704
|
-
|
|
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;
|
|
24705
24827
|
var _scene_startTime, _scene_timeInfos_asyncCompile;
|
|
24706
|
-
|
|
24828
|
+
_this.statistic = {
|
|
24707
24829
|
loadTime: totalTime != null ? totalTime : 0,
|
|
24708
24830
|
loadStart: (_scene_startTime = scene.startTime) != null ? _scene_startTime : 0,
|
|
24709
24831
|
firstFrameTime: 0,
|
|
24710
24832
|
precompileTime: (_scene_timeInfos_asyncCompile = scene.timeInfos["asyncCompile"]) != null ? _scene_timeInfos_asyncCompile : scene.timeInfos["syncCompile"]
|
|
24711
24833
|
};
|
|
24712
|
-
|
|
24713
|
-
|
|
24714
|
-
|
|
24715
|
-
|
|
24716
|
-
|
|
24717
|
-
|
|
24718
|
-
|
|
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, {
|
|
24719
24841
|
aspect: width / height
|
|
24720
24842
|
}));
|
|
24721
|
-
|
|
24722
|
-
|
|
24723
|
-
|
|
24724
|
-
|
|
24725
|
-
|
|
24726
|
-
|
|
24727
|
-
|
|
24728
|
-
|
|
24729
|
-
|
|
24730
|
-
|
|
24731
|
-
this.buildItemTree(this.rootItem);
|
|
24732
|
-
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() {
|
|
24733
24853
|
window.setTimeout(function() {
|
|
24734
|
-
_this.
|
|
24854
|
+
_this.emit("end", {
|
|
24855
|
+
composition: _assert_this_initialized(_this)
|
|
24856
|
+
});
|
|
24735
24857
|
}, 0);
|
|
24736
24858
|
};
|
|
24737
|
-
|
|
24859
|
+
_this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
|
|
24860
|
+
return _this;
|
|
24738
24861
|
}
|
|
24739
24862
|
var _proto = Composition.prototype;
|
|
24740
24863
|
/**
|
|
@@ -24785,7 +24908,7 @@ var listOrder = 0;
|
|
|
24785
24908
|
if (this.rootItem.ended && this.reusable) {
|
|
24786
24909
|
this.restart();
|
|
24787
24910
|
}
|
|
24788
|
-
if (
|
|
24911
|
+
if (this.rootComposition.started) {
|
|
24789
24912
|
this.gotoAndPlay(this.time - this.startTime);
|
|
24790
24913
|
} else {
|
|
24791
24914
|
this.gotoAndPlay(0);
|
|
@@ -24808,18 +24931,14 @@ var listOrder = 0;
|
|
|
24808
24931
|
* 跳转合成到指定时间播放
|
|
24809
24932
|
* @param time - 相对 startTime 的时间
|
|
24810
24933
|
*/ _proto.gotoAndPlay = function gotoAndPlay(time) {
|
|
24934
|
+
this.setTime(time);
|
|
24811
24935
|
this.resume();
|
|
24812
|
-
if (!this.rootComposition.started) {
|
|
24813
|
-
this.rootComposition.start();
|
|
24814
|
-
this.rootComposition.started = true;
|
|
24815
|
-
}
|
|
24816
|
-
this.forwardTime(time + this.startTime);
|
|
24817
24936
|
};
|
|
24818
24937
|
/**
|
|
24819
24938
|
* 跳转合成到指定时间并暂停
|
|
24820
24939
|
* @param time - 相对 startTime 的时间
|
|
24821
24940
|
*/ _proto.gotoAndStop = function gotoAndStop(time) {
|
|
24822
|
-
this.
|
|
24941
|
+
this.setTime(time);
|
|
24823
24942
|
this.pause();
|
|
24824
24943
|
};
|
|
24825
24944
|
/**
|
|
@@ -24846,7 +24965,7 @@ var listOrder = 0;
|
|
|
24846
24965
|
this.rootComposition.start();
|
|
24847
24966
|
this.rootComposition.started = true;
|
|
24848
24967
|
}
|
|
24849
|
-
this.forwardTime(time + this.startTime
|
|
24968
|
+
this.forwardTime(time + this.startTime);
|
|
24850
24969
|
if (pause) {
|
|
24851
24970
|
this.pause();
|
|
24852
24971
|
}
|
|
@@ -24859,17 +24978,16 @@ var listOrder = 0;
|
|
|
24859
24978
|
* 前进合成到指定时间
|
|
24860
24979
|
* @param time - 相对0时刻的时间
|
|
24861
24980
|
* @param skipRender - 是否跳过渲染
|
|
24862
|
-
*/ _proto.forwardTime = function forwardTime(time
|
|
24863
|
-
if (skipRender === void 0) skipRender = false;
|
|
24981
|
+
*/ _proto.forwardTime = function forwardTime(time) {
|
|
24864
24982
|
var deltaTime = time * 1000 - this.rootComposition.time * 1000;
|
|
24865
24983
|
var reverse = deltaTime < 0;
|
|
24866
24984
|
var step = 15;
|
|
24867
24985
|
var t = Math.abs(deltaTime);
|
|
24868
24986
|
var ss = reverse ? -step : step;
|
|
24869
24987
|
for(t; t > step; t -= step){
|
|
24870
|
-
this.update(ss
|
|
24988
|
+
this.update(ss);
|
|
24871
24989
|
}
|
|
24872
|
-
this.update(reverse ? -t : t
|
|
24990
|
+
this.update(reverse ? -t : t);
|
|
24873
24991
|
};
|
|
24874
24992
|
/**
|
|
24875
24993
|
* 重置状态函数
|
|
@@ -24910,8 +25028,9 @@ var listOrder = 0;
|
|
|
24910
25028
|
* 是否合成需要重新播放
|
|
24911
25029
|
* @returns 重新播放合成标志位
|
|
24912
25030
|
*/ _proto.shouldRestart = function shouldRestart() {
|
|
24913
|
-
var _this_rootItem = this.rootItem,
|
|
24914
|
-
|
|
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;
|
|
24915
25034
|
};
|
|
24916
25035
|
/**
|
|
24917
25036
|
* 是否合成需要销毁
|
|
@@ -24920,44 +25039,45 @@ var listOrder = 0;
|
|
|
24920
25039
|
if (this.reusable) {
|
|
24921
25040
|
return false;
|
|
24922
25041
|
}
|
|
24923
|
-
var
|
|
25042
|
+
var endBehavior = this.rootItem.endBehavior;
|
|
25043
|
+
if (this.rootItem.isEnded(this.time)) {
|
|
25044
|
+
this.rootItem.ended = true;
|
|
25045
|
+
}
|
|
24924
25046
|
// TODO: 合成结束行为
|
|
24925
|
-
return ended &&
|
|
25047
|
+
return this.rootItem.ended && endBehavior === EndBehavior.destroy;
|
|
24926
25048
|
};
|
|
24927
25049
|
/**
|
|
24928
25050
|
* 合成更新,针对所有 item 的更新
|
|
24929
25051
|
* @param deltaTime - 更新的时间步长
|
|
24930
25052
|
* @param skipRender - 是否需要渲染
|
|
24931
|
-
*/ _proto.update = function update(deltaTime
|
|
24932
|
-
if (skipRender === void 0) skipRender = false;
|
|
25053
|
+
*/ _proto.update = function update(deltaTime) {
|
|
24933
25054
|
if (!this.assigned || this.paused) {
|
|
24934
25055
|
return;
|
|
24935
25056
|
}
|
|
25057
|
+
var time = this.getUpdateTime(deltaTime * this.speed);
|
|
25058
|
+
this.globalTime += time;
|
|
25059
|
+
this.updateRootComposition();
|
|
24936
25060
|
if (this.shouldRestart()) {
|
|
25061
|
+
this.emit("end", {
|
|
25062
|
+
composition: this
|
|
25063
|
+
});
|
|
24937
25064
|
this.restart();
|
|
24938
25065
|
// restart then tick to avoid flicker
|
|
24939
25066
|
}
|
|
24940
|
-
var time = this.getUpdateTime(deltaTime * this.speed);
|
|
24941
|
-
this.globalTime += time;
|
|
24942
|
-
if (this.rootComposition.isActiveAndEnabled) {
|
|
24943
|
-
var localTime = this.toLocalTime(this.globalTime / 1000);
|
|
24944
|
-
this.rootComposition.time = localTime;
|
|
24945
|
-
}
|
|
24946
25067
|
this.updateVideo();
|
|
24947
25068
|
// 更新 model-tree-plugin
|
|
24948
25069
|
this.updatePluginLoaders(deltaTime);
|
|
24949
25070
|
this.callStart(this.rootItem);
|
|
24950
25071
|
this.callUpdate(this.rootItem, time);
|
|
24951
25072
|
this.callLateUpdate(this.rootItem, time);
|
|
24952
|
-
// this.extraCamera?.getComponent(TimelineComponent)?.update(deltaTime);
|
|
24953
25073
|
this.updateCamera();
|
|
24954
25074
|
if (this.shouldDispose()) {
|
|
24955
|
-
this.
|
|
25075
|
+
this.emit("end", {
|
|
25076
|
+
composition: this
|
|
25077
|
+
});
|
|
24956
25078
|
this.dispose();
|
|
24957
25079
|
} else {
|
|
24958
|
-
|
|
24959
|
-
this.prepareRender();
|
|
24960
|
-
}
|
|
25080
|
+
this.prepareRender();
|
|
24961
25081
|
}
|
|
24962
25082
|
};
|
|
24963
25083
|
_proto.toLocalTime = function toLocalTime(time) {
|
|
@@ -24968,13 +25088,20 @@ var listOrder = 0;
|
|
|
24968
25088
|
localTime = localTime % duration;
|
|
24969
25089
|
} else if (this.rootItem.endBehavior === EndBehavior.freeze) {
|
|
24970
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
|
+
}
|
|
24971
25099
|
}
|
|
24972
25100
|
}
|
|
24973
25101
|
return localTime;
|
|
24974
25102
|
};
|
|
24975
25103
|
_proto.getUpdateTime = function getUpdateTime(t) {
|
|
24976
25104
|
var startTimeInMs = this.startTime * 1000;
|
|
24977
|
-
// const content = this.rootItem;
|
|
24978
25105
|
var now = this.rootComposition.time * 1000;
|
|
24979
25106
|
if (t < 0 && now + t < startTimeInMs) {
|
|
24980
25107
|
return startTimeInMs - now;
|
|
@@ -25122,6 +25249,14 @@ var listOrder = 0;
|
|
|
25122
25249
|
});
|
|
25123
25250
|
};
|
|
25124
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
|
+
/**
|
|
25125
25260
|
* 通过名称获取元素
|
|
25126
25261
|
* @param name - 元素名称
|
|
25127
25262
|
* @returns 元素对象
|
|
@@ -25170,12 +25305,17 @@ var listOrder = 0;
|
|
|
25170
25305
|
* @param type - 交互类型
|
|
25171
25306
|
*/ _proto.addInteractiveItem = function addInteractiveItem(item, type) {
|
|
25172
25307
|
if (type === InteractType.MESSAGE) {
|
|
25173
|
-
this.
|
|
25308
|
+
this.handleItemMessage({
|
|
25174
25309
|
name: item.name,
|
|
25175
25310
|
phrase: MESSAGE_ITEM_PHRASE_BEGIN,
|
|
25176
25311
|
id: item.id,
|
|
25177
25312
|
compositionId: this.id
|
|
25178
25313
|
});
|
|
25314
|
+
item.emit("message", {
|
|
25315
|
+
name: item.name,
|
|
25316
|
+
phrase: MESSAGE_ITEM_PHRASE_BEGIN,
|
|
25317
|
+
id: item.id
|
|
25318
|
+
});
|
|
25179
25319
|
return item.id;
|
|
25180
25320
|
}
|
|
25181
25321
|
};
|
|
@@ -25184,14 +25324,19 @@ var listOrder = 0;
|
|
|
25184
25324
|
* @param item - 交互元素
|
|
25185
25325
|
* @param type - 交互类型
|
|
25186
25326
|
*/ _proto.removeInteractiveItem = function removeInteractiveItem(item, type) {
|
|
25187
|
-
// MESSAGE ITEM的结束行为
|
|
25327
|
+
// MESSAGE ITEM 的结束行为
|
|
25188
25328
|
if (type === InteractType.MESSAGE) {
|
|
25189
|
-
this.
|
|
25329
|
+
this.handleItemMessage({
|
|
25190
25330
|
name: item.name,
|
|
25191
25331
|
phrase: MESSAGE_ITEM_PHRASE_END,
|
|
25192
25332
|
id: item.id,
|
|
25193
25333
|
compositionId: this.id
|
|
25194
25334
|
});
|
|
25335
|
+
item.emit("message", {
|
|
25336
|
+
name: item.name,
|
|
25337
|
+
phrase: MESSAGE_ITEM_PHRASE_END,
|
|
25338
|
+
id: item.id
|
|
25339
|
+
});
|
|
25195
25340
|
}
|
|
25196
25341
|
};
|
|
25197
25342
|
/**
|
|
@@ -25287,7 +25432,6 @@ var listOrder = 0;
|
|
|
25287
25432
|
this.update = function() {
|
|
25288
25433
|
logger.error("Update disposed composition: " + _this.name + ".");
|
|
25289
25434
|
};
|
|
25290
|
-
this.onPlayerPause = noop;
|
|
25291
25435
|
this.dispose = noop;
|
|
25292
25436
|
if (textures && this.keepResource) {
|
|
25293
25437
|
textures.forEach(function(tex) {
|
|
@@ -25485,7 +25629,7 @@ var listOrder = 0;
|
|
|
25485
25629
|
}
|
|
25486
25630
|
]);
|
|
25487
25631
|
return Composition;
|
|
25488
|
-
}();
|
|
25632
|
+
}(EventEmitter);
|
|
25489
25633
|
|
|
25490
25634
|
var SIZEOF_SHORT = 2;
|
|
25491
25635
|
var SIZEOF_INT = 4;
|
|
@@ -27449,7 +27593,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
|
|
|
27449
27593
|
registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
|
|
27450
27594
|
registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
|
|
27451
27595
|
registerPlugin("interact", InteractLoader, exports.VFXItem, true);
|
|
27452
|
-
var version = "2.0.0-alpha.
|
|
27596
|
+
var version = "2.0.0-alpha.32";
|
|
27453
27597
|
logger.info("Core version: " + version + ".");
|
|
27454
27598
|
|
|
27455
27599
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -27483,6 +27627,7 @@ exports.EVENT_TYPE_TOUCH_START = EVENT_TYPE_TOUCH_START;
|
|
|
27483
27627
|
exports.EffectsObject = EffectsObject;
|
|
27484
27628
|
exports.EffectsPackage = EffectsPackage;
|
|
27485
27629
|
exports.Engine = Engine;
|
|
27630
|
+
exports.EventEmitter = EventEmitter;
|
|
27486
27631
|
exports.EventSystem = EventSystem;
|
|
27487
27632
|
exports.Float16ArrayWrapper = Float16ArrayWrapper;
|
|
27488
27633
|
exports.Framebuffer = Framebuffer;
|