@galacean/effects-core 2.4.0-beta.0 → 2.4.0-beta.1
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/asset-loader.d.ts +1 -2
- package/dist/binary-asset.d.ts +0 -2
- package/dist/comp-vfx-item.d.ts +2 -2
- package/dist/components/component.d.ts +1 -0
- package/dist/components/post-process-volume.d.ts +2 -2
- package/dist/components/renderer-component.d.ts +0 -5
- package/dist/composition.d.ts +2 -8
- package/dist/effects-object.d.ts +1 -1
- package/dist/engine.d.ts +5 -3
- package/dist/fallback/migration.d.ts +1 -0
- package/dist/index.js +710 -1004
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +706 -998
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/camera/camera-controller-node.d.ts +2 -2
- package/dist/plugins/particle/trail-mesh.d.ts +1 -1
- package/dist/serialization-helper.d.ts +0 -4
- package/dist/vfx-item.d.ts +10 -4
- package/package.json +2 -2
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.4.0-beta.
|
|
6
|
+
* Version: v2.4.0-beta.1
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -2004,7 +2004,7 @@ function getDirectStore(target) {
|
|
|
2004
2004
|
function EffectsObject(engine) {
|
|
2005
2005
|
this.engine = engine;
|
|
2006
2006
|
this.guid = generateGUID();
|
|
2007
|
-
this.
|
|
2007
|
+
this.defination = {};
|
|
2008
2008
|
this.engine.addInstance(this);
|
|
2009
2009
|
}
|
|
2010
2010
|
var _proto = EffectsObject.prototype;
|
|
@@ -2029,11 +2029,7 @@ function getDirectStore(target) {
|
|
|
2029
2029
|
* 反序列化函数
|
|
2030
2030
|
*
|
|
2031
2031
|
* @param data - 对象的序列化的数据
|
|
2032
|
-
*/ _proto.fromData = function fromData(data) {
|
|
2033
|
-
if (data.id) {
|
|
2034
|
-
this.setInstanceId(data.id);
|
|
2035
|
-
}
|
|
2036
|
-
};
|
|
2032
|
+
*/ _proto.fromData = function fromData(data) {};
|
|
2037
2033
|
/**
|
|
2038
2034
|
*
|
|
2039
2035
|
*/ _proto.dispose = function dispose() {};
|
|
@@ -2129,9 +2125,6 @@ function getDirectStore(target) {
|
|
|
2129
2125
|
};
|
|
2130
2126
|
_proto.fromData = function fromData(data) {
|
|
2131
2127
|
EffectsObject.prototype.fromData.call(this, data);
|
|
2132
|
-
if (data.item) {
|
|
2133
|
-
this.item = data.item;
|
|
2134
|
-
}
|
|
2135
2128
|
};
|
|
2136
2129
|
_proto.dispose = function dispose() {
|
|
2137
2130
|
if (this.isEnableCalled) {
|
|
@@ -2196,11 +2189,15 @@ function getDirectStore(target) {
|
|
|
2196
2189
|
]);
|
|
2197
2190
|
return Component;
|
|
2198
2191
|
}(EffectsObject);
|
|
2192
|
+
__decorate([
|
|
2193
|
+
serialize()
|
|
2194
|
+
], Component.prototype, "item", void 0);
|
|
2199
2195
|
__decorate([
|
|
2200
2196
|
serialize()
|
|
2201
2197
|
], Component.prototype, "_enabled", void 0);
|
|
2202
2198
|
/**
|
|
2203
2199
|
* @since 2.0.0
|
|
2200
|
+
* @deprecated 2.4.0 Please use Component instead
|
|
2204
2201
|
*/ var Behaviour = /*#__PURE__*/ function(Component) {
|
|
2205
2202
|
_inherits(Behaviour, Component);
|
|
2206
2203
|
function Behaviour() {
|
|
@@ -2230,10 +2227,6 @@ __decorate([
|
|
|
2230
2227
|
}
|
|
2231
2228
|
var _proto = RendererComponent.prototype;
|
|
2232
2229
|
_proto.render = function render(renderer) {};
|
|
2233
|
-
_proto.setVFXItem = function setVFXItem(item) {
|
|
2234
|
-
Component.prototype.setVFXItem.call(this, item);
|
|
2235
|
-
this.item.rendererComponents.push(this);
|
|
2236
|
-
};
|
|
2237
2230
|
_proto.onEnable = function onEnable() {
|
|
2238
2231
|
var _this_item_composition;
|
|
2239
2232
|
(_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.renderFrame.addMeshToDefaultRenderPass(this);
|
|
@@ -2242,18 +2235,6 @@ __decorate([
|
|
|
2242
2235
|
var _this_item_composition;
|
|
2243
2236
|
(_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.renderFrame.removeMeshFromDefaultRenderPass(this);
|
|
2244
2237
|
};
|
|
2245
|
-
_proto.fromData = function fromData(data) {
|
|
2246
|
-
Component.prototype.fromData.call(this, data);
|
|
2247
|
-
};
|
|
2248
|
-
_proto.toData = function toData() {
|
|
2249
|
-
Component.prototype.toData.call(this);
|
|
2250
|
-
};
|
|
2251
|
-
_proto.dispose = function dispose() {
|
|
2252
|
-
if (this.item) {
|
|
2253
|
-
removeItem(this.item.rendererComponents, this);
|
|
2254
|
-
}
|
|
2255
|
-
Component.prototype.dispose.call(this);
|
|
2256
|
-
};
|
|
2257
2238
|
_create_class(RendererComponent, [
|
|
2258
2239
|
{
|
|
2259
2240
|
key: "priority",
|
|
@@ -3876,11 +3857,11 @@ exports.EffectComponent = __decorate([
|
|
|
3876
3857
|
effectsClass(DataType.EffectComponent)
|
|
3877
3858
|
], exports.EffectComponent);
|
|
3878
3859
|
|
|
3879
|
-
exports.PostProcessVolume = /*#__PURE__*/ function(
|
|
3880
|
-
_inherits(PostProcessVolume,
|
|
3860
|
+
exports.PostProcessVolume = /*#__PURE__*/ function(Component) {
|
|
3861
|
+
_inherits(PostProcessVolume, Component);
|
|
3881
3862
|
function PostProcessVolume(engine) {
|
|
3882
3863
|
var _this;
|
|
3883
|
-
_this =
|
|
3864
|
+
_this = Component.call(this, engine) || this;
|
|
3884
3865
|
_this.bloom = {
|
|
3885
3866
|
threshold: 0,
|
|
3886
3867
|
intensity: 0,
|
|
@@ -3911,7 +3892,7 @@ exports.PostProcessVolume = /*#__PURE__*/ function(Behaviour) {
|
|
|
3911
3892
|
}
|
|
3912
3893
|
};
|
|
3913
3894
|
return PostProcessVolume;
|
|
3914
|
-
}(
|
|
3895
|
+
}(Component);
|
|
3915
3896
|
__decorate([
|
|
3916
3897
|
serialize()
|
|
3917
3898
|
], exports.PostProcessVolume.prototype, "bloom", void 0);
|
|
@@ -12748,6 +12729,10 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12748
12729
|
RendererComponent.prototype.fromData.call(this, data);
|
|
12749
12730
|
var _data_renderer;
|
|
12750
12731
|
var renderer = (_data_renderer = data.renderer) != null ? _data_renderer : {};
|
|
12732
|
+
var maskProps = data.mask;
|
|
12733
|
+
if (maskProps && maskProps.ref) {
|
|
12734
|
+
maskProps.ref = this.engine.findObject(maskProps.ref);
|
|
12735
|
+
}
|
|
12751
12736
|
var maskMode = this.maskManager.getMaskMode(data);
|
|
12752
12737
|
// TODO 新蒙板上线后移除
|
|
12753
12738
|
//-------------------------------------------------------------------------
|
|
@@ -12755,15 +12740,15 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12755
12740
|
//@ts-expect-error
|
|
12756
12741
|
var split = data.splits && !data.textureSheetAnimation ? data.splits[0] : undefined;
|
|
12757
12742
|
var shapeGeometry = undefined;
|
|
12758
|
-
if (shapeData !== undefined && !("aPoint" in shapeData && "index" in shapeData)) {
|
|
12743
|
+
if (shapeData !== undefined && shapeData !== null && !("aPoint" in shapeData && "index" in shapeData)) {
|
|
12759
12744
|
shapeGeometry = getGeometryByShape(shapeData, split);
|
|
12760
12745
|
}
|
|
12761
|
-
var _renderer_renderMode, _renderer_blending,
|
|
12746
|
+
var _renderer_renderMode, _renderer_blending, _renderer_side;
|
|
12762
12747
|
//-------------------------------------------------------------------------
|
|
12763
12748
|
this.renderer = {
|
|
12764
12749
|
renderMode: (_renderer_renderMode = renderer.renderMode) != null ? _renderer_renderMode : RenderMode.MESH,
|
|
12765
12750
|
blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
|
|
12766
|
-
texture:
|
|
12751
|
+
texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.emptyTexture,
|
|
12767
12752
|
occlusion: !!renderer.occlusion,
|
|
12768
12753
|
transparentOcclusion: !!renderer.transparentOcclusion || maskMode === exports.MaskMode.MASK,
|
|
12769
12754
|
side: (_renderer_side = renderer.side) != null ? _renderer_side : SideMode.DOUBLE,
|
|
@@ -12980,14 +12965,14 @@ exports.ShapeComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
12980
12965
|
var control2 = easingIns[pointIndex.easingIn];
|
|
12981
12966
|
this.graphicsPath.bezierCurveTo(control1.x + lastPoint.x, control1.y + lastPoint.y, control2.x + point.x, control2.y + point.y, point.x, point.y, 1);
|
|
12982
12967
|
}
|
|
12983
|
-
var pointIndex1 = indices[0];
|
|
12984
|
-
var lastPointIndex1 = indices[indices.length - 1];
|
|
12985
|
-
var point1 = points[pointIndex1.point];
|
|
12986
|
-
var lastPoint1 = points[lastPointIndex1.point];
|
|
12987
|
-
var control11 = easingOuts[lastPointIndex1.easingOut];
|
|
12988
|
-
var control21 = easingIns[pointIndex1.easingIn];
|
|
12989
|
-
this.graphicsPath.bezierCurveTo(control11.x + lastPoint1.x, control11.y + lastPoint1.y, control21.x + point1.x, control21.y + point1.y, point1.x, point1.y, 1);
|
|
12990
12968
|
if (shape.close) {
|
|
12969
|
+
var pointIndex1 = indices[0];
|
|
12970
|
+
var lastPointIndex1 = indices[indices.length - 1];
|
|
12971
|
+
var point1 = points[pointIndex1.point];
|
|
12972
|
+
var lastPoint1 = points[lastPointIndex1.point];
|
|
12973
|
+
var control11 = easingOuts[lastPointIndex1.easingOut];
|
|
12974
|
+
var control21 = easingIns[pointIndex1.easingIn];
|
|
12975
|
+
this.graphicsPath.bezierCurveTo(control11.x + lastPoint1.x, control11.y + lastPoint1.y, control21.x + point1.x, control21.y + point1.y, point1.x, point1.y, 1);
|
|
12991
12976
|
this.graphicsPath.closePath();
|
|
12992
12977
|
}
|
|
12993
12978
|
}
|
|
@@ -13117,6 +13102,10 @@ exports.ShapeComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
13117
13102
|
break;
|
|
13118
13103
|
}
|
|
13119
13104
|
}
|
|
13105
|
+
var maskProps = data.mask;
|
|
13106
|
+
if (maskProps && maskProps.ref) {
|
|
13107
|
+
maskProps.ref = this.engine.findObject(maskProps.ref);
|
|
13108
|
+
}
|
|
13120
13109
|
var maskMode = this.maskManager.getMaskMode(data);
|
|
13121
13110
|
var maskRef = this.maskManager.getRefValue();
|
|
13122
13111
|
this.material.stencilRef = maskRef !== undefined ? [
|
|
@@ -13266,11 +13255,11 @@ exports.Fake3DAnimationMode = void 0;
|
|
|
13266
13255
|
Fake3DAnimationMode[Fake3DAnimationMode["Linear"] = 1] = "Linear";
|
|
13267
13256
|
})(exports.Fake3DAnimationMode || (exports.Fake3DAnimationMode = {}));
|
|
13268
13257
|
|
|
13269
|
-
exports.CameraController = /*#__PURE__*/ function(
|
|
13270
|
-
_inherits(CameraController,
|
|
13258
|
+
exports.CameraController = /*#__PURE__*/ function(Component) {
|
|
13259
|
+
_inherits(CameraController, Component);
|
|
13271
13260
|
function CameraController(engine, props) {
|
|
13272
13261
|
var _this;
|
|
13273
|
-
_this =
|
|
13262
|
+
_this = Component.call(this, engine) || this;
|
|
13274
13263
|
if (props) {
|
|
13275
13264
|
_this.fromData(props);
|
|
13276
13265
|
}
|
|
@@ -13291,11 +13280,11 @@ exports.CameraController = /*#__PURE__*/ function(Behaviour) {
|
|
|
13291
13280
|
}
|
|
13292
13281
|
};
|
|
13293
13282
|
_proto.fromData = function fromData(data) {
|
|
13294
|
-
|
|
13283
|
+
Component.prototype.fromData.call(this, data);
|
|
13295
13284
|
this.options = data.options;
|
|
13296
13285
|
};
|
|
13297
13286
|
return CameraController;
|
|
13298
|
-
}(
|
|
13287
|
+
}(Component);
|
|
13299
13288
|
exports.CameraController = __decorate([
|
|
13300
13289
|
effectsClass(DataType.CameraController)
|
|
13301
13290
|
], exports.CameraController);
|
|
@@ -19443,7 +19432,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
19443
19432
|
mask: maskProps.maskRef,
|
|
19444
19433
|
maskMode: maskProps.maskMode,
|
|
19445
19434
|
forceTarget: forceTarget,
|
|
19446
|
-
diffuse: renderer.texture,
|
|
19435
|
+
diffuse: renderer.texture ? this.engine.findObject(renderer.texture) : undefined,
|
|
19447
19436
|
sizeOverLifetime: sizeOverLifetimeGetter,
|
|
19448
19437
|
anchor: anchor
|
|
19449
19438
|
};
|
|
@@ -19530,7 +19519,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
19530
19519
|
maxTrailCount: options.maxCount,
|
|
19531
19520
|
pointCountPerTrail: Math.round(trails.maxPointPerTrail) || 32,
|
|
19532
19521
|
blending: trails.blending,
|
|
19533
|
-
texture: trails.texture,
|
|
19522
|
+
texture: trails.texture ? this.engine.findObject(trails.texture) : undefined,
|
|
19534
19523
|
opacityOverLifetime: createValueGetter(trails.opacityOverLifetime || 1),
|
|
19535
19524
|
widthOverTrail: createValueGetter(trails.widthOverTrail || 1),
|
|
19536
19525
|
// order: vfxItem.listIndex + (trails.orderOffset || 0),
|
|
@@ -19569,8 +19558,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
19569
19558
|
var maskRef = 0;
|
|
19570
19559
|
if (data.mask) {
|
|
19571
19560
|
var _data_mask = data.mask, mode = _data_mask.mode, ref = _data_mask.ref;
|
|
19561
|
+
var refComponent = this.engine.findObject(ref);
|
|
19572
19562
|
maskMode = mode;
|
|
19573
|
-
maskRef =
|
|
19563
|
+
maskRef = refComponent.maskManager.getRefValue();
|
|
19574
19564
|
}
|
|
19575
19565
|
return {
|
|
19576
19566
|
maskMode: maskMode,
|
|
@@ -19858,7 +19848,7 @@ var SubCompositionClipPlayable = /*#__PURE__*/ function(Playable) {
|
|
|
19858
19848
|
var _proto = SubCompositionClipPlayable.prototype;
|
|
19859
19849
|
_proto.processFrame = function processFrame(context) {
|
|
19860
19850
|
var boundObject = context.output.getUserData();
|
|
19861
|
-
if (_instanceof1(boundObject, CompositionComponent)) {
|
|
19851
|
+
if (_instanceof1(boundObject, exports.CompositionComponent)) {
|
|
19862
19852
|
boundObject.time = this.getTime();
|
|
19863
19853
|
}
|
|
19864
19854
|
};
|
|
@@ -19873,7 +19863,7 @@ var SubCompositionMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
|
|
|
19873
19863
|
var _proto = SubCompositionMixerPlayable.prototype;
|
|
19874
19864
|
_proto.evaluate = function evaluate(context) {
|
|
19875
19865
|
var boundObject = context.output.getUserData();
|
|
19876
|
-
if (!_instanceof1(boundObject, CompositionComponent)) {
|
|
19866
|
+
if (!_instanceof1(boundObject, exports.CompositionComponent)) {
|
|
19877
19867
|
return;
|
|
19878
19868
|
}
|
|
19879
19869
|
var compositionComponent = boundObject;
|
|
@@ -20241,7 +20231,7 @@ exports.SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
|
|
|
20241
20231
|
if (!this.parent || !_instanceof1(this.parent.boundObject, exports.VFXItem)) {
|
|
20242
20232
|
throw new Error("SubCompositionTrack needs to be set under the VFXItem track.");
|
|
20243
20233
|
}
|
|
20244
|
-
this.boundObject = this.parent.boundObject.getComponent(CompositionComponent);
|
|
20234
|
+
this.boundObject = this.parent.boundObject.getComponent(exports.CompositionComponent);
|
|
20245
20235
|
};
|
|
20246
20236
|
_proto.createTrackMixer = function createTrackMixer(graph) {
|
|
20247
20237
|
return new SubCompositionMixerPlayable(graph);
|
|
@@ -20658,13 +20648,11 @@ exports.Vector2PropertyPlayableAsset = __decorate([
|
|
|
20658
20648
|
effectsClass(DataType.Vector2PropertyPlayableAsset)
|
|
20659
20649
|
], exports.Vector2PropertyPlayableAsset);
|
|
20660
20650
|
|
|
20661
|
-
|
|
20662
|
-
|
|
20663
|
-
*/ var CompositionComponent = /*#__PURE__*/ function(Behaviour) {
|
|
20664
|
-
_inherits(CompositionComponent, Behaviour);
|
|
20651
|
+
exports.CompositionComponent = /*#__PURE__*/ function(Component) {
|
|
20652
|
+
_inherits(CompositionComponent, Component);
|
|
20665
20653
|
function CompositionComponent() {
|
|
20666
20654
|
var _this;
|
|
20667
|
-
_this =
|
|
20655
|
+
_this = Component.apply(this, arguments) || this;
|
|
20668
20656
|
_this.time = 0;
|
|
20669
20657
|
_this.startTime = 0;
|
|
20670
20658
|
_this.items = [] // 场景的所有元素
|
|
@@ -20840,13 +20828,10 @@ exports.Vector2PropertyPlayableAsset = __decorate([
|
|
|
20840
20828
|
return startOrder;
|
|
20841
20829
|
};
|
|
20842
20830
|
_proto.fromData = function fromData(data) {
|
|
20843
|
-
|
|
20831
|
+
Component.prototype.fromData.call(this, data);
|
|
20844
20832
|
var compositionData = data;
|
|
20845
|
-
this.items = compositionData.items;
|
|
20846
20833
|
var _compositionData_startTime;
|
|
20847
20834
|
this.startTime = (_compositionData_startTime = compositionData.startTime) != null ? _compositionData_startTime : 0;
|
|
20848
|
-
this.sceneBindings = compositionData.sceneBindings;
|
|
20849
|
-
this.timelineAsset = compositionData.timelineAsset;
|
|
20850
20835
|
};
|
|
20851
20836
|
_proto.resolveBindings = function resolveBindings() {
|
|
20852
20837
|
for(var _iterator = _create_for_of_iterator_helper_loose(this.sceneBindings), _step; !(_step = _iterator()).done;){
|
|
@@ -20869,7 +20854,19 @@ exports.Vector2PropertyPlayableAsset = __decorate([
|
|
|
20869
20854
|
}
|
|
20870
20855
|
};
|
|
20871
20856
|
return CompositionComponent;
|
|
20872
|
-
}(
|
|
20857
|
+
}(Component);
|
|
20858
|
+
__decorate([
|
|
20859
|
+
serialize()
|
|
20860
|
+
], exports.CompositionComponent.prototype, "items", void 0);
|
|
20861
|
+
__decorate([
|
|
20862
|
+
serialize()
|
|
20863
|
+
], exports.CompositionComponent.prototype, "sceneBindings", void 0);
|
|
20864
|
+
__decorate([
|
|
20865
|
+
serialize()
|
|
20866
|
+
], exports.CompositionComponent.prototype, "timelineAsset", void 0);
|
|
20867
|
+
exports.CompositionComponent = __decorate([
|
|
20868
|
+
effectsClass("CompositionComponent")
|
|
20869
|
+
], exports.CompositionComponent);
|
|
20873
20870
|
|
|
20874
20871
|
/**
|
|
20875
20872
|
*
|
|
@@ -21061,636 +21058,166 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
21061
21058
|
// }
|
|
21062
21059
|
(TickData);
|
|
21063
21060
|
|
|
21064
|
-
|
|
21065
|
-
|
|
21066
|
-
|
|
21067
|
-
|
|
21068
|
-
|
|
21061
|
+
/**
|
|
21062
|
+
* 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
|
|
21063
|
+
* 合成中包含了相关的 Item 元素,支持对 Item 元素的创建、更新和销毁。
|
|
21064
|
+
* 也负责 Item 相关的动画播放控制,和持有渲染帧数据。
|
|
21065
|
+
*/ var Composition = /*#__PURE__*/ function(EventEmitter) {
|
|
21066
|
+
_inherits(Composition, EventEmitter);
|
|
21067
|
+
function Composition(props, scene) {
|
|
21068
|
+
var _this;
|
|
21069
|
+
var _scene_jsonScene_renderSettings;
|
|
21070
|
+
_this = EventEmitter.call(this) || this;
|
|
21071
|
+
/**
|
|
21072
|
+
*
|
|
21073
|
+
*/ _this.sceneTicking = new SceneTicking();
|
|
21074
|
+
/**
|
|
21075
|
+
* 动画播放速度
|
|
21076
|
+
*/ _this.speed = 1;
|
|
21077
|
+
/**
|
|
21078
|
+
* 合成是否结束
|
|
21079
|
+
*/ _this.isEnded = false;
|
|
21080
|
+
/**
|
|
21081
|
+
* 用于保存与当前合成相关的插件数据
|
|
21082
|
+
*/ _this.loaderData = {};
|
|
21083
|
+
/**
|
|
21084
|
+
* 预合成数组
|
|
21085
|
+
*/ _this.refContent = [];
|
|
21086
|
+
/**
|
|
21087
|
+
* 是否开启后处理
|
|
21088
|
+
*/ _this.postProcessingEnabled = false;
|
|
21089
|
+
// TODO: 待优化
|
|
21090
|
+
_this.assigned = false;
|
|
21091
|
+
/**
|
|
21092
|
+
* 销毁状态位
|
|
21093
|
+
*/ _this.destroyed = false;
|
|
21094
|
+
_this.postLoaders = [];
|
|
21095
|
+
/**
|
|
21096
|
+
* 合成暂停/播放 标识
|
|
21097
|
+
*/ _this.paused = false;
|
|
21098
|
+
_this.lastVideoUpdateTime = 0;
|
|
21099
|
+
_this.isEndCalled = false;
|
|
21100
|
+
_this._textures = [];
|
|
21101
|
+
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;
|
|
21102
|
+
_this.renderer = renderer;
|
|
21103
|
+
_this._textures = scene.textureOptions;
|
|
21104
|
+
var _scene_jsonScene_renderSettings_postProcessingEnabled;
|
|
21105
|
+
_this.postProcessingEnabled = (_scene_jsonScene_renderSettings_postProcessingEnabled = (_scene_jsonScene_renderSettings = scene.jsonScene.renderSettings) == null ? void 0 : _scene_jsonScene_renderSettings.postProcessingEnabled) != null ? _scene_jsonScene_renderSettings_postProcessingEnabled : false;
|
|
21106
|
+
_this.getEngine().renderLevel = scene.renderLevel;
|
|
21107
|
+
if (reusable) {
|
|
21108
|
+
_this.keepResource = true;
|
|
21109
|
+
scene.textures = undefined;
|
|
21110
|
+
scene.consumed = true;
|
|
21069
21111
|
}
|
|
21070
|
-
|
|
21071
|
-
|
|
21072
|
-
|
|
21073
|
-
|
|
21074
|
-
|
|
21075
|
-
var key = _step.value;
|
|
21076
|
-
// TODO 待移除,序列化属性通过 effectsObject 对象直接获取
|
|
21077
|
-
var value = effectsObject.taggedProperties[key];
|
|
21078
|
-
if (value === undefined) {
|
|
21079
|
-
value = effectsObject[key];
|
|
21080
|
-
}
|
|
21081
|
-
if (EffectsObject.is(value)) {
|
|
21082
|
-
SerializationHelper.collectSerializableObject(value, res);
|
|
21083
|
-
} else if (isArray(value)) {
|
|
21084
|
-
for(var _iterator1 = _create_for_of_iterator_helper_loose(value), _step1; !(_step1 = _iterator1()).done;){
|
|
21085
|
-
var arrayValue = _step1.value;
|
|
21086
|
-
if (EffectsObject.is(arrayValue)) {
|
|
21087
|
-
SerializationHelper.collectSerializableObject(arrayValue, res);
|
|
21088
|
-
}
|
|
21089
|
-
}
|
|
21090
|
-
} else if (isObject(value)) {
|
|
21091
|
-
// 非 EffectsObject 对象只递归一层
|
|
21092
|
-
for(var _iterator2 = _create_for_of_iterator_helper_loose(Object.keys(value)), _step2; !(_step2 = _iterator2()).done;){
|
|
21093
|
-
var objectKey = _step2.value;
|
|
21094
|
-
var objectValue = value[objectKey];
|
|
21095
|
-
if (EffectsObject.is(objectValue)) {
|
|
21096
|
-
SerializationHelper.collectSerializableObject(objectValue, res);
|
|
21097
|
-
}
|
|
21098
|
-
}
|
|
21099
|
-
}
|
|
21112
|
+
var sourceContent = scene.jsonScene.compositions[0];
|
|
21113
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(scene.jsonScene.compositions), _step; !(_step = _iterator()).done;){
|
|
21114
|
+
var composition = _step.value;
|
|
21115
|
+
if (composition.id === scene.jsonScene.compositionId) {
|
|
21116
|
+
sourceContent = composition;
|
|
21100
21117
|
}
|
|
21101
21118
|
}
|
|
21119
|
+
assertExist(sourceContent);
|
|
21120
|
+
// Instantiate composition rootItem
|
|
21121
|
+
_this.rootItem = new exports.VFXItem(_this.getEngine());
|
|
21122
|
+
_this.rootItem.name = "rootItem";
|
|
21123
|
+
_this.rootItem.duration = sourceContent.duration;
|
|
21124
|
+
_this.rootItem.endBehavior = sourceContent.endBehavior;
|
|
21125
|
+
_this.rootItem.composition = _assert_this_initialized(_this);
|
|
21126
|
+
// Create rootItem components
|
|
21127
|
+
//@ts-expect-error TODO update spec.
|
|
21128
|
+
var componentPaths = sourceContent.components;
|
|
21129
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(componentPaths), _step1; !(_step1 = _iterator1()).done;){
|
|
21130
|
+
var componentPath = _step1.value;
|
|
21131
|
+
var component = _this.getEngine().findObject(componentPath);
|
|
21132
|
+
_this.rootItem.components.push(component);
|
|
21133
|
+
component.item = _this.rootItem;
|
|
21134
|
+
}
|
|
21135
|
+
_this.rootComposition = _this.rootItem.getComponent(exports.CompositionComponent);
|
|
21136
|
+
_this.width = width;
|
|
21137
|
+
_this.height = height;
|
|
21138
|
+
_this.renderOrder = baseRenderOrder;
|
|
21139
|
+
_this.id = sourceContent.id;
|
|
21140
|
+
_this.renderer = renderer;
|
|
21141
|
+
_this.event = event;
|
|
21142
|
+
var _scene_startTime, _scene_totalTime;
|
|
21143
|
+
_this.statistic = {
|
|
21144
|
+
loadStart: (_scene_startTime = scene.startTime) != null ? _scene_startTime : 0,
|
|
21145
|
+
loadTime: (_scene_totalTime = scene.totalTime) != null ? _scene_totalTime : 0,
|
|
21146
|
+
compileTime: 0,
|
|
21147
|
+
firstFrameTime: 0
|
|
21148
|
+
};
|
|
21149
|
+
_this.reusable = reusable;
|
|
21150
|
+
_this.speed = speed;
|
|
21151
|
+
_this.name = sourceContent.name;
|
|
21152
|
+
_this.pluginSystem = scene.pluginSystem;
|
|
21153
|
+
_this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
21154
|
+
_this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
|
|
21155
|
+
aspect: width / height
|
|
21156
|
+
}));
|
|
21157
|
+
_this.url = scene.url;
|
|
21158
|
+
_this.assigned = true;
|
|
21159
|
+
_this.interactive = true;
|
|
21160
|
+
_this.handleItemMessage = handleItemMessage;
|
|
21161
|
+
_this.createRenderFrame();
|
|
21162
|
+
_this.rendererOptions = null;
|
|
21163
|
+
Composition.buildItemTree(_this.rootItem);
|
|
21164
|
+
_this.rootComposition.setChildrenRenderOrder(0);
|
|
21165
|
+
_this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
|
|
21166
|
+
return _this;
|
|
21167
|
+
}
|
|
21168
|
+
var _proto = Composition.prototype;
|
|
21169
|
+
/**
|
|
21170
|
+
* 获取合成的时长
|
|
21171
|
+
*/ _proto.getDuration = function getDuration() {
|
|
21172
|
+
return this.rootItem.duration;
|
|
21102
21173
|
};
|
|
21103
|
-
|
|
21104
|
-
|
|
21105
|
-
|
|
21106
|
-
|
|
21107
|
-
|
|
21108
|
-
var serializedDatas = _extends({}, engine.jsonSceneData);
|
|
21109
|
-
// 递归收集所有需要序列化的对象
|
|
21110
|
-
SerializationHelper.collectSerializableObject(effectsObject, serializableMap);
|
|
21111
|
-
// 依次序列化
|
|
21112
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializableMap)), _step; !(_step = _iterator()).done;){
|
|
21113
|
-
var guid = _step.value;
|
|
21114
|
-
var serializeObject = serializableMap[guid];
|
|
21115
|
-
if (!serializedDatas[serializeObject.getInstanceId()]) {
|
|
21116
|
-
serializedDatas[serializeObject.getInstanceId()] = {};
|
|
21117
|
-
}
|
|
21118
|
-
SerializationHelper.serialize(serializeObject, serializedDatas[serializeObject.getInstanceId()]);
|
|
21119
|
-
}
|
|
21120
|
-
return serializedDatas;
|
|
21174
|
+
/**
|
|
21175
|
+
* 重新开始合成
|
|
21176
|
+
*/ _proto.restart = function restart() {
|
|
21177
|
+
this.reset();
|
|
21178
|
+
this.forwardTime(this.startTime);
|
|
21121
21179
|
};
|
|
21122
|
-
|
|
21123
|
-
|
|
21124
|
-
|
|
21125
|
-
|
|
21126
|
-
|
|
21127
|
-
|
|
21128
|
-
|
|
21129
|
-
|
|
21130
|
-
|
|
21131
|
-
|
|
21132
|
-
|
|
21133
|
-
|
|
21134
|
-
|
|
21135
|
-
|
|
21136
|
-
|
|
21137
|
-
|
|
21138
|
-
|
|
21139
|
-
|
|
21140
|
-
|
|
21141
|
-
|
|
21142
|
-
|
|
21143
|
-
|
|
21144
|
-
|
|
21145
|
-
|
|
21146
|
-
|
|
21147
|
-
|
|
21148
|
-
|
|
21149
|
-
|
|
21150
|
-
|
|
21151
|
-
|
|
21180
|
+
/**
|
|
21181
|
+
* 设置当前合成的渲染顺序
|
|
21182
|
+
* @param index - 序号,大的后绘制
|
|
21183
|
+
*/ _proto.setIndex = function setIndex(index) {
|
|
21184
|
+
this.renderOrder = index;
|
|
21185
|
+
};
|
|
21186
|
+
/**
|
|
21187
|
+
* 获取当前合成的渲染顺序
|
|
21188
|
+
* @returns
|
|
21189
|
+
*/ _proto.getIndex = function getIndex() {
|
|
21190
|
+
return this.renderOrder;
|
|
21191
|
+
};
|
|
21192
|
+
/**
|
|
21193
|
+
* 设置合成的动画速度
|
|
21194
|
+
* @param speed - 速度
|
|
21195
|
+
*/ _proto.setSpeed = function setSpeed(speed) {
|
|
21196
|
+
this.speed = speed;
|
|
21197
|
+
};
|
|
21198
|
+
/**
|
|
21199
|
+
* 设置合成的可见性
|
|
21200
|
+
* @since 2.0.0
|
|
21201
|
+
* @param visible - 是否可见
|
|
21202
|
+
*/ _proto.setVisible = function setVisible(visible) {
|
|
21203
|
+
this.rootItem.setVisible(visible);
|
|
21204
|
+
};
|
|
21205
|
+
/**
|
|
21206
|
+
* 获取合成的动画速度
|
|
21207
|
+
* @returns
|
|
21208
|
+
*/ _proto.getSpeed = function getSpeed() {
|
|
21209
|
+
return this.speed;
|
|
21210
|
+
};
|
|
21211
|
+
/**
|
|
21212
|
+
*
|
|
21213
|
+
*/ _proto.play = function play() {
|
|
21214
|
+
if (this.isEnded && this.reusable) {
|
|
21215
|
+
this.restart();
|
|
21152
21216
|
}
|
|
21153
|
-
|
|
21154
|
-
|
|
21155
|
-
|
|
21156
|
-
|
|
21157
|
-
if (typeof value1 === "number" || typeof value1 === "string" || typeof value1 === "boolean" || SerializationHelper.checkTypedArray(value1)) {
|
|
21158
|
-
// TODO json 数据避免传 typedArray
|
|
21159
|
-
serializedData[key1] = value1;
|
|
21160
|
-
} else if (isArray(value1)) {
|
|
21161
|
-
if (!serializedData[key1]) {
|
|
21162
|
-
serializedData[key1] = [];
|
|
21163
|
-
}
|
|
21164
|
-
SerializationHelper.serializeArrayProperty(value1, serializedData[key1], 0);
|
|
21165
|
-
} else if (EffectsObject.is(value1)) {
|
|
21166
|
-
// TODO 处理 EffectsObject 递归序列化
|
|
21167
|
-
serializedData[key1] = {
|
|
21168
|
-
id: value1.getInstanceId()
|
|
21169
|
-
};
|
|
21170
|
-
} else if (isObject(value1)) {
|
|
21171
|
-
if (!serializedData[key1]) {
|
|
21172
|
-
serializedData[key1] = {};
|
|
21173
|
-
}
|
|
21174
|
-
SerializationHelper.serializeObjectProperty(value1, serializedData[key1], 0);
|
|
21175
|
-
}
|
|
21176
|
-
}
|
|
21177
|
-
return serializedData;
|
|
21178
|
-
};
|
|
21179
|
-
SerializationHelper.deserialize = function deserialize(serializedData, effectsObject) {
|
|
21180
|
-
var taggedProperties = effectsObject.taggedProperties;
|
|
21181
|
-
var serializedProperties = getMergedStore(effectsObject);
|
|
21182
|
-
var engine = effectsObject.engine;
|
|
21183
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedData)), _step; !(_step = _iterator()).done;){
|
|
21184
|
-
var key = _step.value;
|
|
21185
|
-
if (serializedProperties && serializedProperties[key]) {
|
|
21186
|
-
continue;
|
|
21187
|
-
}
|
|
21188
|
-
var value = serializedData[key];
|
|
21189
|
-
taggedProperties[key] = SerializationHelper.deserializeProperty(value, engine, 0);
|
|
21190
|
-
}
|
|
21191
|
-
if (serializedProperties) {
|
|
21192
|
-
for(var _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step1; !(_step1 = _iterator1()).done;){
|
|
21193
|
-
var key1 = _step1.value;
|
|
21194
|
-
var value1 = serializedData[key1];
|
|
21195
|
-
if (value1 === undefined) {
|
|
21196
|
-
continue;
|
|
21197
|
-
}
|
|
21198
|
-
var propertyType = serializedProperties[key1].type;
|
|
21199
|
-
// FIXME: taggedProperties 为 readonly,这里存在强制赋值
|
|
21200
|
-
// @ts-expect-error
|
|
21201
|
-
effectsObject[key1] = SerializationHelper.deserializeProperty(value1, engine, 0, propertyType);
|
|
21202
|
-
}
|
|
21203
|
-
}
|
|
21204
|
-
effectsObject.fromData(taggedProperties);
|
|
21205
|
-
};
|
|
21206
|
-
SerializationHelper.deserializeAsync = function deserializeAsync(serializedData, effectsObject) {
|
|
21207
|
-
return _async_to_generator(function() {
|
|
21208
|
-
var taggedProperties, serializedProperties, engine, _iterator, _step, key, value, _iterator1, _step1, key1, value1, propertyType;
|
|
21209
|
-
return __generator(this, function(_state) {
|
|
21210
|
-
switch(_state.label){
|
|
21211
|
-
case 0:
|
|
21212
|
-
taggedProperties = effectsObject.taggedProperties;
|
|
21213
|
-
serializedProperties = getMergedStore(effectsObject);
|
|
21214
|
-
engine = effectsObject.engine;
|
|
21215
|
-
_iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedData));
|
|
21216
|
-
_state.label = 1;
|
|
21217
|
-
case 1:
|
|
21218
|
-
if (!!(_step = _iterator()).done) return [
|
|
21219
|
-
3,
|
|
21220
|
-
4
|
|
21221
|
-
];
|
|
21222
|
-
key = _step.value;
|
|
21223
|
-
if (serializedProperties && serializedProperties[key]) {
|
|
21224
|
-
return [
|
|
21225
|
-
3,
|
|
21226
|
-
3
|
|
21227
|
-
];
|
|
21228
|
-
}
|
|
21229
|
-
value = serializedData[key];
|
|
21230
|
-
return [
|
|
21231
|
-
4,
|
|
21232
|
-
SerializationHelper.deserializePropertyAsync(value, engine, 0)
|
|
21233
|
-
];
|
|
21234
|
-
case 2:
|
|
21235
|
-
taggedProperties[key] = _state.sent();
|
|
21236
|
-
_state.label = 3;
|
|
21237
|
-
case 3:
|
|
21238
|
-
return [
|
|
21239
|
-
3,
|
|
21240
|
-
1
|
|
21241
|
-
];
|
|
21242
|
-
case 4:
|
|
21243
|
-
if (!serializedProperties) return [
|
|
21244
|
-
3,
|
|
21245
|
-
8
|
|
21246
|
-
];
|
|
21247
|
-
_iterator1 = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties));
|
|
21248
|
-
_state.label = 5;
|
|
21249
|
-
case 5:
|
|
21250
|
-
if (!!(_step1 = _iterator1()).done) return [
|
|
21251
|
-
3,
|
|
21252
|
-
8
|
|
21253
|
-
];
|
|
21254
|
-
key1 = _step1.value;
|
|
21255
|
-
value1 = serializedData[key1];
|
|
21256
|
-
if (value1 === undefined) {
|
|
21257
|
-
return [
|
|
21258
|
-
3,
|
|
21259
|
-
7
|
|
21260
|
-
];
|
|
21261
|
-
}
|
|
21262
|
-
propertyType = serializedProperties[key1].type;
|
|
21263
|
-
return [
|
|
21264
|
-
4,
|
|
21265
|
-
SerializationHelper.deserializePropertyAsync(value1, engine, 0, propertyType)
|
|
21266
|
-
];
|
|
21267
|
-
case 6:
|
|
21268
|
-
// FIXME: taggedProperties 为 readonly,这里存在强制赋值
|
|
21269
|
-
// @ts-expect-error
|
|
21270
|
-
effectsObject[key1] = _state.sent();
|
|
21271
|
-
_state.label = 7;
|
|
21272
|
-
case 7:
|
|
21273
|
-
return [
|
|
21274
|
-
3,
|
|
21275
|
-
5
|
|
21276
|
-
];
|
|
21277
|
-
case 8:
|
|
21278
|
-
effectsObject.fromData(taggedProperties);
|
|
21279
|
-
return [
|
|
21280
|
-
2
|
|
21281
|
-
];
|
|
21282
|
-
}
|
|
21283
|
-
});
|
|
21284
|
-
})();
|
|
21285
|
-
};
|
|
21286
|
-
SerializationHelper.checkTypedArray = function checkTypedArray(obj) {
|
|
21287
|
-
return _instanceof1(obj, Int8Array) || _instanceof1(obj, Uint8Array) || _instanceof1(obj, Uint8ClampedArray) || _instanceof1(obj, Int16Array) || _instanceof1(obj, Uint16Array) || _instanceof1(obj, Int32Array) || _instanceof1(obj, Uint32Array) || _instanceof1(obj, Float32Array) || _instanceof1(obj, Float64Array) || _instanceof1(obj, ArrayBuffer);
|
|
21288
|
-
};
|
|
21289
|
-
// check value is { id: 7e69662e964e4892ae8933f24562395b }
|
|
21290
|
-
SerializationHelper.checkDataPath = function checkDataPath(value) {
|
|
21291
|
-
return !!(isObject(value) && Object.keys(value).length === 1 && "id" in value && isString(value.id) && value.id.length === 32);
|
|
21292
|
-
};
|
|
21293
|
-
// TODO 测试函数,2.0 上线后移除
|
|
21294
|
-
SerializationHelper.checkGLTFNode = function checkGLTFNode(value) {
|
|
21295
|
-
return isObject(value) && value.nodeIndex !== undefined && value.isJoint !== undefined;
|
|
21296
|
-
};
|
|
21297
|
-
SerializationHelper.checkImageSource = function checkImageSource(value) {
|
|
21298
|
-
return isCanvas(value) || _instanceof1(value, HTMLImageElement);
|
|
21299
|
-
};
|
|
21300
|
-
SerializationHelper.deserializeProperty = function deserializeProperty(property, engine, level, type) {
|
|
21301
|
-
if (level > 14) {
|
|
21302
|
-
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
21303
|
-
return;
|
|
21304
|
-
}
|
|
21305
|
-
// 加载并链接 DataPath 字段表示的 EffectsObject 引用。Class 对象 copy [key, value] 会丢失对象信息,因此只递归数组对象和普通 js Object 结构对象。
|
|
21306
|
-
if (isArray(property)) {
|
|
21307
|
-
var res = [];
|
|
21308
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(property), _step; !(_step = _iterator()).done;){
|
|
21309
|
-
var value = _step.value;
|
|
21310
|
-
res.push(SerializationHelper.deserializeProperty(value, engine, level + 1, type));
|
|
21311
|
-
}
|
|
21312
|
-
return res;
|
|
21313
|
-
// TODO json 数据避免传 typedArray
|
|
21314
|
-
} else if (SerializationHelper.checkDataPath(property)) {
|
|
21315
|
-
return engine.assetLoader.loadGUID(property.id);
|
|
21316
|
-
} else if (isObject(property) && property.constructor === Object) {
|
|
21317
|
-
var res1;
|
|
21318
|
-
if (type) {
|
|
21319
|
-
res1 = new type();
|
|
21320
|
-
} else {
|
|
21321
|
-
res1 = {};
|
|
21322
|
-
}
|
|
21323
|
-
for(var _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(property)), _step1; !(_step1 = _iterator1()).done;){
|
|
21324
|
-
var key = _step1.value;
|
|
21325
|
-
res1[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
|
|
21326
|
-
}
|
|
21327
|
-
return res1;
|
|
21328
|
-
} else {
|
|
21329
|
-
return property;
|
|
21330
|
-
}
|
|
21331
|
-
};
|
|
21332
|
-
SerializationHelper.deserializePropertyAsync = function deserializePropertyAsync(property, engine, level, type) {
|
|
21333
|
-
return _async_to_generator(function() {
|
|
21334
|
-
var res, _iterator, _step, value, _, res1, res2, _iterator1, _step1, key;
|
|
21335
|
-
return __generator(this, function(_state) {
|
|
21336
|
-
switch(_state.label){
|
|
21337
|
-
case 0:
|
|
21338
|
-
if (level > 14) {
|
|
21339
|
-
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
21340
|
-
return [
|
|
21341
|
-
2
|
|
21342
|
-
];
|
|
21343
|
-
}
|
|
21344
|
-
if (!isArray(property)) return [
|
|
21345
|
-
3,
|
|
21346
|
-
5
|
|
21347
|
-
];
|
|
21348
|
-
res = [];
|
|
21349
|
-
_iterator = _create_for_of_iterator_helper_loose(property);
|
|
21350
|
-
_state.label = 1;
|
|
21351
|
-
case 1:
|
|
21352
|
-
if (!!(_step = _iterator()).done) return [
|
|
21353
|
-
3,
|
|
21354
|
-
4
|
|
21355
|
-
];
|
|
21356
|
-
value = _step.value;
|
|
21357
|
-
_ = res.push;
|
|
21358
|
-
return [
|
|
21359
|
-
4,
|
|
21360
|
-
SerializationHelper.deserializePropertyAsync(value, engine, level + 1, type)
|
|
21361
|
-
];
|
|
21362
|
-
case 2:
|
|
21363
|
-
_.apply(res, [
|
|
21364
|
-
_state.sent()
|
|
21365
|
-
]);
|
|
21366
|
-
_state.label = 3;
|
|
21367
|
-
case 3:
|
|
21368
|
-
return [
|
|
21369
|
-
3,
|
|
21370
|
-
1
|
|
21371
|
-
];
|
|
21372
|
-
case 4:
|
|
21373
|
-
return [
|
|
21374
|
-
2,
|
|
21375
|
-
res
|
|
21376
|
-
];
|
|
21377
|
-
case 5:
|
|
21378
|
-
if (!SerializationHelper.checkDataPath(property)) return [
|
|
21379
|
-
3,
|
|
21380
|
-
7
|
|
21381
|
-
];
|
|
21382
|
-
return [
|
|
21383
|
-
4,
|
|
21384
|
-
engine.assetLoader.loadGUIDAsync(property.id)
|
|
21385
|
-
];
|
|
21386
|
-
case 6:
|
|
21387
|
-
res1 = _state.sent();
|
|
21388
|
-
return [
|
|
21389
|
-
2,
|
|
21390
|
-
res1
|
|
21391
|
-
];
|
|
21392
|
-
case 7:
|
|
21393
|
-
if (!(isObject(property) && property.constructor === Object)) return [
|
|
21394
|
-
3,
|
|
21395
|
-
12
|
|
21396
|
-
];
|
|
21397
|
-
if (type) {
|
|
21398
|
-
res2 = new type();
|
|
21399
|
-
} else {
|
|
21400
|
-
res2 = {};
|
|
21401
|
-
}
|
|
21402
|
-
_iterator1 = _create_for_of_iterator_helper_loose(Object.keys(property));
|
|
21403
|
-
_state.label = 8;
|
|
21404
|
-
case 8:
|
|
21405
|
-
if (!!(_step1 = _iterator1()).done) return [
|
|
21406
|
-
3,
|
|
21407
|
-
11
|
|
21408
|
-
];
|
|
21409
|
-
key = _step1.value;
|
|
21410
|
-
return [
|
|
21411
|
-
4,
|
|
21412
|
-
SerializationHelper.deserializePropertyAsync(property[key], engine, level + 1)
|
|
21413
|
-
];
|
|
21414
|
-
case 9:
|
|
21415
|
-
res2[key] = _state.sent();
|
|
21416
|
-
_state.label = 10;
|
|
21417
|
-
case 10:
|
|
21418
|
-
return [
|
|
21419
|
-
3,
|
|
21420
|
-
8
|
|
21421
|
-
];
|
|
21422
|
-
case 11:
|
|
21423
|
-
return [
|
|
21424
|
-
2,
|
|
21425
|
-
res2
|
|
21426
|
-
];
|
|
21427
|
-
case 12:
|
|
21428
|
-
return [
|
|
21429
|
-
2,
|
|
21430
|
-
property
|
|
21431
|
-
];
|
|
21432
|
-
case 13:
|
|
21433
|
-
return [
|
|
21434
|
-
2
|
|
21435
|
-
];
|
|
21436
|
-
}
|
|
21437
|
-
});
|
|
21438
|
-
})();
|
|
21439
|
-
};
|
|
21440
|
-
SerializationHelper.serializeObjectProperty = function serializeObjectProperty(objectProperty, serializedData, level) {
|
|
21441
|
-
if (level > 14) {
|
|
21442
|
-
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
21443
|
-
return;
|
|
21444
|
-
}
|
|
21445
|
-
if (!serializedData) {
|
|
21446
|
-
serializedData = {};
|
|
21447
|
-
}
|
|
21448
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(objectProperty)), _step; !(_step = _iterator()).done;){
|
|
21449
|
-
var key = _step.value;
|
|
21450
|
-
var value = objectProperty[key];
|
|
21451
|
-
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean" || SerializationHelper.checkTypedArray(objectProperty)) {
|
|
21452
|
-
// TODO json 数据避免传 typedArray
|
|
21453
|
-
serializedData[key] = value;
|
|
21454
|
-
} else if (isArray(value)) {
|
|
21455
|
-
if (!serializedData[key]) {
|
|
21456
|
-
serializedData[key] = [];
|
|
21457
|
-
}
|
|
21458
|
-
SerializationHelper.serializeArrayProperty(value, serializedData[key], level + 1);
|
|
21459
|
-
} else if (EffectsObject.is(value)) {
|
|
21460
|
-
// TODO 处理 EffectsObject 递归序列化
|
|
21461
|
-
serializedData[key] = {
|
|
21462
|
-
id: value.getInstanceId()
|
|
21463
|
-
};
|
|
21464
|
-
} else if (isObject(value)) {
|
|
21465
|
-
if (!serializedData[key]) {
|
|
21466
|
-
serializedData[key] = {};
|
|
21467
|
-
}
|
|
21468
|
-
SerializationHelper.serializeObjectProperty(value, serializedData[key], level + 1);
|
|
21469
|
-
}
|
|
21470
|
-
}
|
|
21471
|
-
};
|
|
21472
|
-
SerializationHelper.serializeArrayProperty = function serializeArrayProperty(arrayProperty, serializedData, level) {
|
|
21473
|
-
if (level > 14) {
|
|
21474
|
-
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
21475
|
-
return;
|
|
21476
|
-
}
|
|
21477
|
-
if (!serializedData) {
|
|
21478
|
-
serializedData = [];
|
|
21479
|
-
}
|
|
21480
|
-
for(var i = 0; i < arrayProperty.length; i++){
|
|
21481
|
-
var value = arrayProperty[i];
|
|
21482
|
-
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean" || SerializationHelper.checkTypedArray(arrayProperty)) {
|
|
21483
|
-
// TODO json 数据避免传 typedArray
|
|
21484
|
-
serializedData[i] = value;
|
|
21485
|
-
} else if (isArray(value)) {
|
|
21486
|
-
if (!serializedData[i]) {
|
|
21487
|
-
serializedData[i] = [];
|
|
21488
|
-
}
|
|
21489
|
-
SerializationHelper.serializeArrayProperty(value, serializedData[i], level + 1);
|
|
21490
|
-
} else if (EffectsObject.is(value)) {
|
|
21491
|
-
// TODO 处理 EffectsObject 递归序列化
|
|
21492
|
-
serializedData[i] = {
|
|
21493
|
-
id: value.getInstanceId()
|
|
21494
|
-
};
|
|
21495
|
-
} else if (isObject(value)) {
|
|
21496
|
-
if (!serializedData[i]) {
|
|
21497
|
-
serializedData[i] = {};
|
|
21498
|
-
}
|
|
21499
|
-
SerializationHelper.serializeObjectProperty(value, serializedData[i], level + 1);
|
|
21500
|
-
}
|
|
21501
|
-
}
|
|
21502
|
-
};
|
|
21503
|
-
return SerializationHelper;
|
|
21504
|
-
}();
|
|
21505
|
-
|
|
21506
|
-
var _obj$1;
|
|
21507
|
-
/**
|
|
21508
|
-
* 机型和渲染等级对应表
|
|
21509
|
-
*
|
|
21510
|
-
* 机型:B-低端机、A-中端机、S-高端机
|
|
21511
|
-
* 渲染等级:B-低、A-中、S-高、A+-中高、B+-全部
|
|
21512
|
-
*
|
|
21513
|
-
* - S(高端机):高、全部、中高
|
|
21514
|
-
* - A(中端机):中、全部、中高
|
|
21515
|
-
* - B(低端机):低、全部
|
|
21516
|
-
* - undefined(全部机型)
|
|
21517
|
-
*/ var renderLevelPassSet = (_obj$1 = {}, _obj$1[RenderLevel.S] = [
|
|
21518
|
-
RenderLevel.S,
|
|
21519
|
-
RenderLevel.BPlus,
|
|
21520
|
-
RenderLevel.APlus
|
|
21521
|
-
], _obj$1[RenderLevel.A] = [
|
|
21522
|
-
RenderLevel.A,
|
|
21523
|
-
RenderLevel.BPlus,
|
|
21524
|
-
RenderLevel.APlus
|
|
21525
|
-
], _obj$1[RenderLevel.B] = [
|
|
21526
|
-
RenderLevel.B,
|
|
21527
|
-
RenderLevel.BPlus
|
|
21528
|
-
], _obj$1);
|
|
21529
|
-
function passRenderLevel(l, renderLevel) {
|
|
21530
|
-
if (!l || !renderLevel) {
|
|
21531
|
-
return true;
|
|
21532
|
-
}
|
|
21533
|
-
var arr = renderLevelPassSet[renderLevel];
|
|
21534
|
-
if (arr) {
|
|
21535
|
-
return arr.includes(l);
|
|
21536
|
-
}
|
|
21537
|
-
return false;
|
|
21538
|
-
}
|
|
21539
|
-
|
|
21540
|
-
/**
|
|
21541
|
-
* 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
|
|
21542
|
-
* 合成中包含了相关的 Item 元素,支持对 Item 元素的创建、更新和销毁。
|
|
21543
|
-
* 也负责 Item 相关的动画播放控制,和持有渲染帧数据。
|
|
21544
|
-
*/ var Composition = /*#__PURE__*/ function(EventEmitter) {
|
|
21545
|
-
_inherits(Composition, EventEmitter);
|
|
21546
|
-
function Composition(props, scene) {
|
|
21547
|
-
var _this;
|
|
21548
|
-
var _scene_jsonScene_renderSettings;
|
|
21549
|
-
_this = EventEmitter.call(this) || this;
|
|
21550
|
-
/**
|
|
21551
|
-
*
|
|
21552
|
-
*/ _this.sceneTicking = new SceneTicking();
|
|
21553
|
-
/**
|
|
21554
|
-
* 动画播放速度
|
|
21555
|
-
*/ _this.speed = 1;
|
|
21556
|
-
/**
|
|
21557
|
-
* 合成是否结束
|
|
21558
|
-
*/ _this.isEnded = false;
|
|
21559
|
-
/**
|
|
21560
|
-
* 用于保存与当前合成相关的插件数据
|
|
21561
|
-
*/ _this.loaderData = {};
|
|
21562
|
-
/**
|
|
21563
|
-
* 预合成数组
|
|
21564
|
-
*/ _this.refContent = [];
|
|
21565
|
-
/**
|
|
21566
|
-
* 是否开启后处理
|
|
21567
|
-
*/ _this.postProcessingEnabled = false;
|
|
21568
|
-
// TODO: 待优化
|
|
21569
|
-
_this.assigned = false;
|
|
21570
|
-
/**
|
|
21571
|
-
* 销毁状态位
|
|
21572
|
-
*/ _this.destroyed = false;
|
|
21573
|
-
_this.postLoaders = [];
|
|
21574
|
-
/**
|
|
21575
|
-
* 合成暂停/播放 标识
|
|
21576
|
-
*/ _this.paused = false;
|
|
21577
|
-
_this.lastVideoUpdateTime = 0;
|
|
21578
|
-
_this.isEndCalled = false;
|
|
21579
|
-
_this._textures = [];
|
|
21580
|
-
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;
|
|
21581
|
-
_this.renderer = renderer;
|
|
21582
|
-
_this._textures = scene.textureOptions;
|
|
21583
|
-
var _scene_jsonScene_renderSettings_postProcessingEnabled;
|
|
21584
|
-
_this.postProcessingEnabled = (_scene_jsonScene_renderSettings_postProcessingEnabled = (_scene_jsonScene_renderSettings = scene.jsonScene.renderSettings) == null ? void 0 : _scene_jsonScene_renderSettings.postProcessingEnabled) != null ? _scene_jsonScene_renderSettings_postProcessingEnabled : false;
|
|
21585
|
-
_this.getEngine().renderLevel = scene.renderLevel;
|
|
21586
|
-
if (reusable) {
|
|
21587
|
-
_this.keepResource = true;
|
|
21588
|
-
scene.textures = undefined;
|
|
21589
|
-
scene.consumed = true;
|
|
21590
|
-
}
|
|
21591
|
-
var sourceContent = scene.jsonScene.compositions[0];
|
|
21592
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(scene.jsonScene.compositions), _step; !(_step = _iterator()).done;){
|
|
21593
|
-
var composition = _step.value;
|
|
21594
|
-
if (composition.id === scene.jsonScene.compositionId) {
|
|
21595
|
-
sourceContent = composition;
|
|
21596
|
-
}
|
|
21597
|
-
}
|
|
21598
|
-
assertExist(sourceContent);
|
|
21599
|
-
// Instantiate composition rootItem
|
|
21600
|
-
_this.rootItem = new exports.VFXItem(_this.getEngine());
|
|
21601
|
-
_this.rootItem.name = "rootItem";
|
|
21602
|
-
_this.rootItem.duration = sourceContent.duration;
|
|
21603
|
-
_this.rootItem.endBehavior = sourceContent.endBehavior;
|
|
21604
|
-
_this.rootItem.composition = _assert_this_initialized(_this);
|
|
21605
|
-
// Create rootCompositionComponent
|
|
21606
|
-
_this.rootComposition = _this.rootItem.addComponent(CompositionComponent);
|
|
21607
|
-
filterItemsByRenderLevel(sourceContent, _this.getEngine(), scene.renderLevel);
|
|
21608
|
-
SerializationHelper.deserialize(sourceContent, _this.rootComposition);
|
|
21609
|
-
_this.width = width;
|
|
21610
|
-
_this.height = height;
|
|
21611
|
-
_this.renderOrder = baseRenderOrder;
|
|
21612
|
-
_this.id = sourceContent.id;
|
|
21613
|
-
_this.renderer = renderer;
|
|
21614
|
-
_this.event = event;
|
|
21615
|
-
var _scene_startTime, _scene_totalTime;
|
|
21616
|
-
_this.statistic = {
|
|
21617
|
-
loadStart: (_scene_startTime = scene.startTime) != null ? _scene_startTime : 0,
|
|
21618
|
-
loadTime: (_scene_totalTime = scene.totalTime) != null ? _scene_totalTime : 0,
|
|
21619
|
-
compileTime: 0,
|
|
21620
|
-
firstFrameTime: 0
|
|
21621
|
-
};
|
|
21622
|
-
_this.reusable = reusable;
|
|
21623
|
-
_this.speed = speed;
|
|
21624
|
-
_this.name = sourceContent.name;
|
|
21625
|
-
_this.pluginSystem = scene.pluginSystem;
|
|
21626
|
-
_this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
21627
|
-
_this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
|
|
21628
|
-
aspect: width / height
|
|
21629
|
-
}));
|
|
21630
|
-
_this.url = scene.url;
|
|
21631
|
-
_this.assigned = true;
|
|
21632
|
-
_this.interactive = true;
|
|
21633
|
-
_this.handleItemMessage = handleItemMessage;
|
|
21634
|
-
_this.createRenderFrame();
|
|
21635
|
-
_this.rendererOptions = null;
|
|
21636
|
-
_this.buildItemTree(_this.rootItem);
|
|
21637
|
-
_this.rootComposition.setChildrenRenderOrder(0);
|
|
21638
|
-
_this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
|
|
21639
|
-
return _this;
|
|
21640
|
-
}
|
|
21641
|
-
var _proto = Composition.prototype;
|
|
21642
|
-
/**
|
|
21643
|
-
* 获取合成的时长
|
|
21644
|
-
*/ _proto.getDuration = function getDuration() {
|
|
21645
|
-
return this.rootItem.duration;
|
|
21646
|
-
};
|
|
21647
|
-
/**
|
|
21648
|
-
* 重新开始合成
|
|
21649
|
-
*/ _proto.restart = function restart() {
|
|
21650
|
-
this.reset();
|
|
21651
|
-
this.forwardTime(this.startTime);
|
|
21652
|
-
};
|
|
21653
|
-
/**
|
|
21654
|
-
* 设置当前合成的渲染顺序
|
|
21655
|
-
* @param index - 序号,大的后绘制
|
|
21656
|
-
*/ _proto.setIndex = function setIndex(index) {
|
|
21657
|
-
this.renderOrder = index;
|
|
21658
|
-
};
|
|
21659
|
-
/**
|
|
21660
|
-
* 获取当前合成的渲染顺序
|
|
21661
|
-
* @returns
|
|
21662
|
-
*/ _proto.getIndex = function getIndex() {
|
|
21663
|
-
return this.renderOrder;
|
|
21664
|
-
};
|
|
21665
|
-
/**
|
|
21666
|
-
* 设置合成的动画速度
|
|
21667
|
-
* @param speed - 速度
|
|
21668
|
-
*/ _proto.setSpeed = function setSpeed(speed) {
|
|
21669
|
-
this.speed = speed;
|
|
21670
|
-
};
|
|
21671
|
-
/**
|
|
21672
|
-
* 设置合成的可见性
|
|
21673
|
-
* @since 2.0.0
|
|
21674
|
-
* @param visible - 是否可见
|
|
21675
|
-
*/ _proto.setVisible = function setVisible(visible) {
|
|
21676
|
-
this.rootItem.setVisible(visible);
|
|
21677
|
-
};
|
|
21678
|
-
/**
|
|
21679
|
-
* 获取合成的动画速度
|
|
21680
|
-
* @returns
|
|
21681
|
-
*/ _proto.getSpeed = function getSpeed() {
|
|
21682
|
-
return this.speed;
|
|
21683
|
-
};
|
|
21684
|
-
/**
|
|
21685
|
-
*
|
|
21686
|
-
*/ _proto.play = function play() {
|
|
21687
|
-
if (this.isEnded && this.reusable) {
|
|
21688
|
-
this.restart();
|
|
21689
|
-
}
|
|
21690
|
-
if (this.rootComposition.isStartCalled) {
|
|
21691
|
-
this.gotoAndPlay(this.time - this.startTime);
|
|
21692
|
-
} else {
|
|
21693
|
-
this.gotoAndPlay(0);
|
|
21217
|
+
if (this.rootComposition.isStartCalled) {
|
|
21218
|
+
this.gotoAndPlay(this.time - this.startTime);
|
|
21219
|
+
} else {
|
|
21220
|
+
this.gotoAndPlay(0);
|
|
21694
21221
|
}
|
|
21695
21222
|
};
|
|
21696
21223
|
/**
|
|
@@ -21851,38 +21378,6 @@ function passRenderLevel(l, renderLevel) {
|
|
|
21851
21378
|
}
|
|
21852
21379
|
};
|
|
21853
21380
|
/**
|
|
21854
|
-
* 构建父子树,同时保存到 itemCacheMap 中便于查找
|
|
21855
|
-
*/ _proto.buildItemTree = function buildItemTree(compVFXItem) {
|
|
21856
|
-
if (!compVFXItem.composition) {
|
|
21857
|
-
return;
|
|
21858
|
-
}
|
|
21859
|
-
var itemMap = new Map();
|
|
21860
|
-
var contentItems = compVFXItem.getComponent(CompositionComponent).items;
|
|
21861
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(contentItems), _step; !(_step = _iterator()).done;){
|
|
21862
|
-
var item = _step.value;
|
|
21863
|
-
itemMap.set(item.id, item);
|
|
21864
|
-
}
|
|
21865
|
-
for(var _iterator1 = _create_for_of_iterator_helper_loose(contentItems), _step1; !(_step1 = _iterator1()).done;){
|
|
21866
|
-
var item1 = _step1.value;
|
|
21867
|
-
if (item1.parentId === undefined) {
|
|
21868
|
-
item1.setParent(compVFXItem);
|
|
21869
|
-
} else {
|
|
21870
|
-
var parent = itemMap.get(item1.parentId);
|
|
21871
|
-
if (parent) {
|
|
21872
|
-
item1.setParent(parent);
|
|
21873
|
-
} else {
|
|
21874
|
-
throw new Error("The element references a non-existent element, please check the data.");
|
|
21875
|
-
}
|
|
21876
|
-
}
|
|
21877
|
-
}
|
|
21878
|
-
for(var _iterator2 = _create_for_of_iterator_helper_loose(contentItems), _step2; !(_step2 = _iterator2()).done;){
|
|
21879
|
-
var item2 = _step2.value;
|
|
21880
|
-
if (exports.VFXItem.isComposition(item2)) {
|
|
21881
|
-
this.buildItemTree(item2);
|
|
21882
|
-
}
|
|
21883
|
-
}
|
|
21884
|
-
};
|
|
21885
|
-
/**
|
|
21886
21381
|
* 更新视频数据到纹理
|
|
21887
21382
|
* @override
|
|
21888
21383
|
*/ _proto.updateVideo = function updateVideo() {
|
|
@@ -21993,7 +21488,7 @@ function passRenderLevel(l, renderLevel) {
|
|
|
21993
21488
|
var ray = this.getHitTestRay(x, y);
|
|
21994
21489
|
this.refContent.forEach(function(ref) {
|
|
21995
21490
|
var _ref_getComponent;
|
|
21996
|
-
(_ref_getComponent = ref.getComponent(CompositionComponent)) == null ? void 0 : _ref_getComponent.hitTest(ray, x, y, regions, force, options);
|
|
21491
|
+
(_ref_getComponent = ref.getComponent(exports.CompositionComponent)) == null ? void 0 : _ref_getComponent.hitTest(ray, x, y, regions, force, options);
|
|
21997
21492
|
});
|
|
21998
21493
|
return regions;
|
|
21999
21494
|
};
|
|
@@ -22046,7 +21541,7 @@ function passRenderLevel(l, renderLevel) {
|
|
|
22046
21541
|
// 预合成元素销毁时销毁其中的item
|
|
22047
21542
|
if (item.type == ItemType.composition) {
|
|
22048
21543
|
if (item.endBehavior !== EndBehavior.freeze) {
|
|
22049
|
-
var contentItems = item.getComponent(CompositionComponent).items;
|
|
21544
|
+
var contentItems = item.getComponent(exports.CompositionComponent).items;
|
|
22050
21545
|
contentItems.forEach(function(it) {
|
|
22051
21546
|
return _this.pluginSystem.plugins.forEach(function(loader) {
|
|
22052
21547
|
return loader.onCompositionItemRemoved(_this, it);
|
|
@@ -22238,8 +21733,32 @@ function passRenderLevel(l, renderLevel) {
|
|
|
22238
21733
|
2
|
|
22239
21734
|
];
|
|
22240
21735
|
}
|
|
22241
|
-
});
|
|
22242
|
-
})();
|
|
21736
|
+
});
|
|
21737
|
+
})();
|
|
21738
|
+
};
|
|
21739
|
+
/**
|
|
21740
|
+
* @internal
|
|
21741
|
+
* 构建父子树,同时保存到 itemCacheMap 中便于查找
|
|
21742
|
+
*/ Composition.buildItemTree = function buildItemTree(compVFXItem) {
|
|
21743
|
+
var itemMap = new Map();
|
|
21744
|
+
var contentItems = compVFXItem.getComponent(exports.CompositionComponent).items;
|
|
21745
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(contentItems), _step; !(_step = _iterator()).done;){
|
|
21746
|
+
var item = _step.value;
|
|
21747
|
+
itemMap.set(item.id, item);
|
|
21748
|
+
}
|
|
21749
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(contentItems), _step1; !(_step1 = _iterator1()).done;){
|
|
21750
|
+
var item1 = _step1.value;
|
|
21751
|
+
if (item1.parentId === undefined) {
|
|
21752
|
+
item1.setParent(compVFXItem);
|
|
21753
|
+
} else {
|
|
21754
|
+
var parent = itemMap.get(item1.parentId);
|
|
21755
|
+
if (parent) {
|
|
21756
|
+
item1.setParent(parent);
|
|
21757
|
+
} else {
|
|
21758
|
+
throw new Error("The element references a non-existent element, please check the data.");
|
|
21759
|
+
}
|
|
21760
|
+
}
|
|
21761
|
+
}
|
|
22243
21762
|
};
|
|
22244
21763
|
_create_class(Composition, [
|
|
22245
21764
|
{
|
|
@@ -22302,25 +21821,6 @@ function passRenderLevel(l, renderLevel) {
|
|
|
22302
21821
|
]);
|
|
22303
21822
|
return Composition;
|
|
22304
21823
|
}(EventEmitter);
|
|
22305
|
-
function filterItemsByRenderLevel(composition, engine, renderLevel) {
|
|
22306
|
-
var items = [];
|
|
22307
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(composition.items), _step; !(_step = _iterator()).done;){
|
|
22308
|
-
var itemDataPath = _step.value;
|
|
22309
|
-
var itemProps = engine.findEffectsObjectData(itemDataPath.id);
|
|
22310
|
-
if (passRenderLevel(itemProps.renderLevel, renderLevel)) {
|
|
22311
|
-
items.push(itemDataPath);
|
|
22312
|
-
} else {
|
|
22313
|
-
// 非预合成元素未达到渲染等级的转化为空节点。
|
|
22314
|
-
// 预合成元素有根据 item type 的子元素加载判断,没法保留空节点,这边先整体过滤掉。
|
|
22315
|
-
if (itemProps.type !== ItemType.composition) {
|
|
22316
|
-
itemProps.components = [];
|
|
22317
|
-
items.push(itemDataPath);
|
|
22318
|
-
}
|
|
22319
|
-
}
|
|
22320
|
-
}
|
|
22321
|
-
composition.items = items;
|
|
22322
|
-
return composition;
|
|
22323
|
-
}
|
|
22324
21824
|
|
|
22325
21825
|
exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
22326
21826
|
_inherits(VFXItem, EffectsObject);
|
|
@@ -22333,7 +21833,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22333
21833
|
*/ _this.transform = new Transform();
|
|
22334
21834
|
/**
|
|
22335
21835
|
* 元素动画的当前时间
|
|
22336
|
-
*/ _this.time =
|
|
21836
|
+
*/ _this.time = -1;
|
|
22337
21837
|
/**
|
|
22338
21838
|
* 元素动画的持续时间
|
|
22339
21839
|
*/ _this.duration = 0;
|
|
@@ -22344,9 +21844,8 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22344
21844
|
* 元素动画结束时行为(如何处理元素)
|
|
22345
21845
|
*/ _this.endBehavior = EndBehavior.forward;
|
|
22346
21846
|
_this.type = ItemType.base;
|
|
22347
|
-
_this.isDuringPlay = false;
|
|
22348
21847
|
_this.components = [];
|
|
22349
|
-
_this.
|
|
21848
|
+
_this.isDuringPlay = false;
|
|
22350
21849
|
/**
|
|
22351
21850
|
* 元素是否激活
|
|
22352
21851
|
*/ _this.active = true;
|
|
@@ -22614,6 +22113,25 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22614
22113
|
return undefined;
|
|
22615
22114
|
};
|
|
22616
22115
|
/**
|
|
22116
|
+
* 复制 VFXItem,返回一个新的 VFXItem
|
|
22117
|
+
* @since 2.4.0
|
|
22118
|
+
* @returns 复制的新 VFXItem
|
|
22119
|
+
*/ _proto.duplicate = function duplicate() {
|
|
22120
|
+
var previousObjectIDMap = new Map();
|
|
22121
|
+
this.gatherPreviousObjectID(previousObjectIDMap);
|
|
22122
|
+
// 重新设置当前元素和组件的 ID 以及子元素和子元素组件的 ID,避免实例化新的对象时产生碰撞
|
|
22123
|
+
this.resetGUID();
|
|
22124
|
+
var newItem = this.engine.findObject({
|
|
22125
|
+
id: this.defination.id
|
|
22126
|
+
});
|
|
22127
|
+
newItem.resetGUID();
|
|
22128
|
+
this.resetGUID(previousObjectIDMap);
|
|
22129
|
+
if (this.composition) {
|
|
22130
|
+
newItem.setParent(this.composition.rootItem);
|
|
22131
|
+
}
|
|
22132
|
+
return newItem;
|
|
22133
|
+
};
|
|
22134
|
+
/**
|
|
22617
22135
|
* @internal
|
|
22618
22136
|
*/ _proto.beginPlay = function beginPlay() {
|
|
22619
22137
|
this.isDuringPlay = true;
|
|
@@ -22708,19 +22226,18 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22708
22226
|
if (duration < 0) {
|
|
22709
22227
|
throw new Error("Item duration can't be less than 0, see " + HELP_LINK["Item duration can't be less than 0"] + ".");
|
|
22710
22228
|
}
|
|
22711
|
-
|
|
22712
|
-
|
|
22713
|
-
var
|
|
22714
|
-
|
|
22715
|
-
|
|
22716
|
-
this.
|
|
22717
|
-
|
|
22718
|
-
|
|
22719
|
-
|
|
22720
|
-
|
|
22721
|
-
|
|
22229
|
+
if (data.components) {
|
|
22230
|
+
this.components.length = 0;
|
|
22231
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(data.components), _step; !(_step = _iterator()).done;){
|
|
22232
|
+
var componentPath = _step.value;
|
|
22233
|
+
var component = this.engine.findObject(componentPath);
|
|
22234
|
+
this.components.push(component);
|
|
22235
|
+
// TODO ParticleSystemRenderer 现在是动态生成的,后面需要在 json 中单独表示为一个组件
|
|
22236
|
+
if (_instanceof1(component, exports.ParticleSystem)) {
|
|
22237
|
+
if (!this.components.includes(component.renderer)) {
|
|
22238
|
+
this.components.push(component.renderer);
|
|
22239
|
+
}
|
|
22722
22240
|
}
|
|
22723
|
-
this.rendererComponents.push(component.renderer);
|
|
22724
22241
|
}
|
|
22725
22242
|
}
|
|
22726
22243
|
if (VFXItem.isComposition(this)) {
|
|
@@ -22729,24 +22246,24 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22729
22246
|
};
|
|
22730
22247
|
_proto.toData = function toData() {
|
|
22731
22248
|
var _this_parent;
|
|
22732
|
-
this.
|
|
22733
|
-
this.
|
|
22734
|
-
this.
|
|
22249
|
+
this.defination.id = this.guid;
|
|
22250
|
+
this.defination.transform = this.transform.toData();
|
|
22251
|
+
this.defination.dataType = DataType.VFXItemData;
|
|
22735
22252
|
if (((_this_parent = this.parent) == null ? void 0 : _this_parent.name) !== "rootItem") {
|
|
22736
22253
|
var _this_parent1;
|
|
22737
|
-
this.
|
|
22254
|
+
this.defination.parentId = (_this_parent1 = this.parent) == null ? void 0 : _this_parent1.guid;
|
|
22738
22255
|
}
|
|
22739
22256
|
// TODO 统一 sprite 等其他组件的序列化逻辑
|
|
22740
|
-
if (!this.
|
|
22741
|
-
this.
|
|
22257
|
+
if (!this.defination.components) {
|
|
22258
|
+
this.defination.components = [];
|
|
22742
22259
|
for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
|
|
22743
22260
|
var component = _step.value;
|
|
22744
22261
|
if (_instanceof1(component, exports.EffectComponent)) {
|
|
22745
|
-
this.
|
|
22262
|
+
this.defination.components.push(component);
|
|
22746
22263
|
}
|
|
22747
22264
|
}
|
|
22748
22265
|
}
|
|
22749
|
-
this.
|
|
22266
|
+
this.defination.content = {};
|
|
22750
22267
|
};
|
|
22751
22268
|
_proto.translateByPixel = function translateByPixel(x, y) {
|
|
22752
22269
|
if (this.composition) {
|
|
@@ -22803,17 +22320,52 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22803
22320
|
if (!props) {
|
|
22804
22321
|
throw new Error("Referenced precomposition with Id: " + refId + " does not exist.");
|
|
22805
22322
|
}
|
|
22806
|
-
|
|
22807
|
-
|
|
22808
|
-
|
|
22809
|
-
|
|
22810
|
-
var
|
|
22811
|
-
|
|
22812
|
-
|
|
22813
|
-
|
|
22814
|
-
|
|
22323
|
+
//@ts-expect-error TODO update spec.
|
|
22324
|
+
var componentPaths = props.components;
|
|
22325
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(componentPaths), _step; !(_step = _iterator()).done;){
|
|
22326
|
+
var componentPath = _step.value;
|
|
22327
|
+
var component = this.engine.findObject(componentPath);
|
|
22328
|
+
component.item = this;
|
|
22329
|
+
this.components.push(component);
|
|
22330
|
+
component.setInstanceId(generateGUID());
|
|
22331
|
+
if (_instanceof1(component, exports.CompositionComponent)) {
|
|
22332
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(component.items), _step1; !(_step1 = _iterator1()).done;){
|
|
22333
|
+
var vfxItem = _step1.value;
|
|
22334
|
+
vfxItem.setInstanceId(generateGUID());
|
|
22335
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(vfxItem.components), _step2; !(_step2 = _iterator2()).done;){
|
|
22336
|
+
var component1 = _step2.value;
|
|
22337
|
+
component1.setInstanceId(generateGUID());
|
|
22338
|
+
}
|
|
22339
|
+
}
|
|
22815
22340
|
}
|
|
22816
22341
|
}
|
|
22342
|
+
Composition.buildItemTree(this);
|
|
22343
|
+
};
|
|
22344
|
+
_proto.resetGUID = function resetGUID(previousObjectIDMap) {
|
|
22345
|
+
var _previousObjectIDMap_get;
|
|
22346
|
+
var itemGUID = (_previousObjectIDMap_get = previousObjectIDMap == null ? void 0 : previousObjectIDMap.get(this)) != null ? _previousObjectIDMap_get : generateGUID();
|
|
22347
|
+
this.setInstanceId(itemGUID);
|
|
22348
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
|
|
22349
|
+
var component = _step.value;
|
|
22350
|
+
var _previousObjectIDMap_get1;
|
|
22351
|
+
var componentGUID = (_previousObjectIDMap_get1 = previousObjectIDMap == null ? void 0 : previousObjectIDMap.get(component)) != null ? _previousObjectIDMap_get1 : generateGUID();
|
|
22352
|
+
component.setInstanceId(componentGUID);
|
|
22353
|
+
}
|
|
22354
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(this.children), _step1; !(_step1 = _iterator1()).done;){
|
|
22355
|
+
var child = _step1.value;
|
|
22356
|
+
child.resetGUID(previousObjectIDMap);
|
|
22357
|
+
}
|
|
22358
|
+
};
|
|
22359
|
+
_proto.gatherPreviousObjectID = function gatherPreviousObjectID(previousObjectIDMap) {
|
|
22360
|
+
previousObjectIDMap.set(this, this.getInstanceId());
|
|
22361
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
|
|
22362
|
+
var component = _step.value;
|
|
22363
|
+
previousObjectIDMap.set(component, component.getInstanceId());
|
|
22364
|
+
}
|
|
22365
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(this.children), _step1; !(_step1 = _iterator1()).done;){
|
|
22366
|
+
var child = _step1.value;
|
|
22367
|
+
child.gatherPreviousObjectID(previousObjectIDMap);
|
|
22368
|
+
}
|
|
22817
22369
|
};
|
|
22818
22370
|
/**
|
|
22819
22371
|
*
|
|
@@ -22920,9 +22472,11 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22920
22472
|
set: function set(value) {
|
|
22921
22473
|
if (this.listIndex !== value) {
|
|
22922
22474
|
this.listIndex = value;
|
|
22923
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.
|
|
22924
|
-
var
|
|
22925
|
-
|
|
22475
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
|
|
22476
|
+
var component = _step.value;
|
|
22477
|
+
if (_instanceof1(component, RendererComponent)) {
|
|
22478
|
+
component.priority = value;
|
|
22479
|
+
}
|
|
22926
22480
|
}
|
|
22927
22481
|
}
|
|
22928
22482
|
}
|
|
@@ -22946,9 +22500,6 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22946
22500
|
]);
|
|
22947
22501
|
return VFXItem;
|
|
22948
22502
|
}(EffectsObject);
|
|
22949
|
-
__decorate([
|
|
22950
|
-
serialize()
|
|
22951
|
-
], exports.VFXItem.prototype, "components", void 0);
|
|
22952
22503
|
exports.VFXItem = __decorate([
|
|
22953
22504
|
effectsClass(DataType.VFXItemData)
|
|
22954
22505
|
], exports.VFXItem);
|
|
@@ -26963,66 +26514,255 @@ var TextComponentBase = /*#__PURE__*/ function() {
|
|
|
26963
26514
|
if (fontStyle !== FontStyle.normal) {
|
|
26964
26515
|
fontDesc = fontStyle + " " + fontDesc;
|
|
26965
26516
|
}
|
|
26966
|
-
return fontDesc;
|
|
26517
|
+
return fontDesc;
|
|
26518
|
+
};
|
|
26519
|
+
_proto.setupOutline = function setupOutline() {
|
|
26520
|
+
var context = this.context;
|
|
26521
|
+
var _this_textStyle = this.textStyle, outlineColor = _this_textStyle.outlineColor, outlineWidth = _this_textStyle.outlineWidth;
|
|
26522
|
+
var r = outlineColor[0], g = outlineColor[1], b = outlineColor[2], a = outlineColor[3];
|
|
26523
|
+
if (context) {
|
|
26524
|
+
context.strokeStyle = "rgba(" + r * 255 + ", " + g * 255 + ", " + b * 255 + ", " + a + ")";
|
|
26525
|
+
context.lineWidth = outlineWidth * 2;
|
|
26526
|
+
}
|
|
26527
|
+
};
|
|
26528
|
+
_proto.setupShadow = function setupShadow() {
|
|
26529
|
+
var context = this.context;
|
|
26530
|
+
var _this_textStyle = this.textStyle, outlineColor = _this_textStyle.outlineColor, shadowBlur = _this_textStyle.shadowBlur, shadowOffsetX = _this_textStyle.shadowOffsetX, shadowOffsetY = _this_textStyle.shadowOffsetY;
|
|
26531
|
+
var r = outlineColor[0], g = outlineColor[1], b = outlineColor[2], a = outlineColor[3];
|
|
26532
|
+
if (context) {
|
|
26533
|
+
context.shadowColor = "rgba(" + r * 255 + ", " + g * 255 + ", " + b * 255 + ", " + a + ")";
|
|
26534
|
+
context.shadowBlur = shadowBlur;
|
|
26535
|
+
context.shadowOffsetX = shadowOffsetX;
|
|
26536
|
+
context.shadowOffsetY = -shadowOffsetY;
|
|
26537
|
+
}
|
|
26538
|
+
};
|
|
26539
|
+
return TextComponentBase;
|
|
26540
|
+
}();
|
|
26541
|
+
applyMixins(exports.TextComponent, [
|
|
26542
|
+
TextComponentBase
|
|
26543
|
+
]);
|
|
26544
|
+
|
|
26545
|
+
// TODO: 注册必须用
|
|
26546
|
+
var TextLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
26547
|
+
_inherits(TextLoader, AbstractPlugin);
|
|
26548
|
+
function TextLoader() {
|
|
26549
|
+
return AbstractPlugin.apply(this, arguments);
|
|
26550
|
+
}
|
|
26551
|
+
return TextLoader;
|
|
26552
|
+
}(AbstractPlugin);
|
|
26553
|
+
|
|
26554
|
+
var Asset = /*#__PURE__*/ function(EffectsObject) {
|
|
26555
|
+
_inherits(Asset, EffectsObject);
|
|
26556
|
+
function Asset() {
|
|
26557
|
+
return EffectsObject.apply(this, arguments);
|
|
26558
|
+
}
|
|
26559
|
+
return Asset;
|
|
26560
|
+
}(EffectsObject);
|
|
26561
|
+
|
|
26562
|
+
exports.BinaryAsset = /*#__PURE__*/ function(EffectsObject) {
|
|
26563
|
+
_inherits(BinaryAsset, EffectsObject);
|
|
26564
|
+
function BinaryAsset() {
|
|
26565
|
+
return EffectsObject.apply(this, arguments);
|
|
26566
|
+
}
|
|
26567
|
+
return BinaryAsset;
|
|
26568
|
+
}(EffectsObject);
|
|
26569
|
+
__decorate([
|
|
26570
|
+
serialize()
|
|
26571
|
+
], exports.BinaryAsset.prototype, "buffer", void 0);
|
|
26572
|
+
exports.BinaryAsset = __decorate([
|
|
26573
|
+
effectsClass(DataType.BinaryAsset)
|
|
26574
|
+
], exports.BinaryAsset);
|
|
26575
|
+
|
|
26576
|
+
var SerializationHelper = /*#__PURE__*/ function() {
|
|
26577
|
+
function SerializationHelper() {}
|
|
26578
|
+
SerializationHelper.serialize = function serialize(effectsObject, serializedData) {
|
|
26579
|
+
effectsObject.toData();
|
|
26580
|
+
if (!serializedData) {
|
|
26581
|
+
serializedData = {};
|
|
26582
|
+
}
|
|
26583
|
+
var serializedProperties = getMergedStore(effectsObject);
|
|
26584
|
+
if (serializedProperties) {
|
|
26585
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step; !(_step = _iterator()).done;){
|
|
26586
|
+
var key = _step.value;
|
|
26587
|
+
var value = effectsObject[key];
|
|
26588
|
+
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean" || SerializationHelper.checkTypedArray(value)) {
|
|
26589
|
+
// TODO json 数据避免传 typedArray
|
|
26590
|
+
serializedData[key] = value;
|
|
26591
|
+
} else if (isArray(value)) {
|
|
26592
|
+
if (!serializedData[key]) {
|
|
26593
|
+
serializedData[key] = [];
|
|
26594
|
+
}
|
|
26595
|
+
SerializationHelper.serializeArrayProperty(value, serializedData[key], 0);
|
|
26596
|
+
} else if (EffectsObject.is(value)) {
|
|
26597
|
+
// TODO 处理 EffectsObject 递归序列化
|
|
26598
|
+
serializedData[key] = {
|
|
26599
|
+
id: value.getInstanceId()
|
|
26600
|
+
};
|
|
26601
|
+
} else if (isObject(value)) {
|
|
26602
|
+
if (!serializedData[key]) {
|
|
26603
|
+
serializedData[key] = {};
|
|
26604
|
+
}
|
|
26605
|
+
SerializationHelper.serializeObjectProperty(value, serializedData[key], 0);
|
|
26606
|
+
}
|
|
26607
|
+
}
|
|
26608
|
+
}
|
|
26609
|
+
// TODO 待移除 tagggedProperties 为没有装饰器的临时方案
|
|
26610
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(effectsObject.defination)), _step1; !(_step1 = _iterator1()).done;){
|
|
26611
|
+
var key1 = _step1.value;
|
|
26612
|
+
var value1 = effectsObject.defination[key1];
|
|
26613
|
+
if (typeof value1 === "number" || typeof value1 === "string" || typeof value1 === "boolean" || SerializationHelper.checkTypedArray(value1)) {
|
|
26614
|
+
// TODO json 数据避免传 typedArray
|
|
26615
|
+
serializedData[key1] = value1;
|
|
26616
|
+
} else if (isArray(value1)) {
|
|
26617
|
+
if (!serializedData[key1]) {
|
|
26618
|
+
serializedData[key1] = [];
|
|
26619
|
+
}
|
|
26620
|
+
SerializationHelper.serializeArrayProperty(value1, serializedData[key1], 0);
|
|
26621
|
+
} else if (EffectsObject.is(value1)) {
|
|
26622
|
+
// TODO 处理 EffectsObject 递归序列化
|
|
26623
|
+
serializedData[key1] = {
|
|
26624
|
+
id: value1.getInstanceId()
|
|
26625
|
+
};
|
|
26626
|
+
} else if (isObject(value1)) {
|
|
26627
|
+
if (!serializedData[key1]) {
|
|
26628
|
+
serializedData[key1] = {};
|
|
26629
|
+
}
|
|
26630
|
+
SerializationHelper.serializeObjectProperty(value1, serializedData[key1], 0);
|
|
26631
|
+
}
|
|
26632
|
+
}
|
|
26633
|
+
return serializedData;
|
|
26634
|
+
};
|
|
26635
|
+
SerializationHelper.deserialize = function deserialize(serializedData, effectsObject) {
|
|
26636
|
+
effectsObject.defination = serializedData;
|
|
26637
|
+
var serializedProperties = getMergedStore(effectsObject);
|
|
26638
|
+
var engine = effectsObject.engine;
|
|
26639
|
+
if (serializedProperties) {
|
|
26640
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step; !(_step = _iterator()).done;){
|
|
26641
|
+
var key = _step.value;
|
|
26642
|
+
var value = serializedData[key];
|
|
26643
|
+
if (value === undefined) {
|
|
26644
|
+
continue;
|
|
26645
|
+
}
|
|
26646
|
+
var propertyType = serializedProperties[key].type;
|
|
26647
|
+
// FIXME: taggedProperties 为 readonly,这里存在强制赋值
|
|
26648
|
+
effectsObject[key] = SerializationHelper.deserializeProperty(value, engine, 0, propertyType);
|
|
26649
|
+
}
|
|
26650
|
+
}
|
|
26651
|
+
effectsObject.fromData(effectsObject.defination);
|
|
26652
|
+
};
|
|
26653
|
+
SerializationHelper.checkTypedArray = function checkTypedArray(obj) {
|
|
26654
|
+
return _instanceof1(obj, Int8Array) || _instanceof1(obj, Uint8Array) || _instanceof1(obj, Uint8ClampedArray) || _instanceof1(obj, Int16Array) || _instanceof1(obj, Uint16Array) || _instanceof1(obj, Int32Array) || _instanceof1(obj, Uint32Array) || _instanceof1(obj, Float32Array) || _instanceof1(obj, Float64Array) || _instanceof1(obj, ArrayBuffer);
|
|
26655
|
+
};
|
|
26656
|
+
// check value is { id: 7e69662e964e4892ae8933f24562395b }
|
|
26657
|
+
SerializationHelper.checkDataPath = function checkDataPath(value) {
|
|
26658
|
+
return !!(isObject(value) && Object.keys(value).length === 1 && "id" in value && isString(value.id) && value.id.length === 32);
|
|
26659
|
+
};
|
|
26660
|
+
// TODO 测试函数,2.0 上线后移除
|
|
26661
|
+
SerializationHelper.checkGLTFNode = function checkGLTFNode(value) {
|
|
26662
|
+
return isObject(value) && value.nodeIndex !== undefined && value.isJoint !== undefined;
|
|
26663
|
+
};
|
|
26664
|
+
SerializationHelper.checkImageSource = function checkImageSource(value) {
|
|
26665
|
+
return isCanvas(value) || _instanceof1(value, HTMLImageElement);
|
|
26666
|
+
};
|
|
26667
|
+
SerializationHelper.deserializeProperty = function deserializeProperty(property, engine, level, type, overrideDataPath) {
|
|
26668
|
+
if (overrideDataPath === void 0) overrideDataPath = true;
|
|
26669
|
+
if (level > 14) {
|
|
26670
|
+
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
26671
|
+
return;
|
|
26672
|
+
}
|
|
26673
|
+
// 加载并链接 DataPath 字段表示的 EffectsObject 引用。Class 对象 copy [key, value] 会丢失对象信息,因此只递归数组对象和普通 js Object 结构对象。
|
|
26674
|
+
if (isArray(property)) {
|
|
26675
|
+
var res = [];
|
|
26676
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(property), _step; !(_step = _iterator()).done;){
|
|
26677
|
+
var value = _step.value;
|
|
26678
|
+
res.push(SerializationHelper.deserializeProperty(value, engine, level + 1, type, overrideDataPath));
|
|
26679
|
+
}
|
|
26680
|
+
return res;
|
|
26681
|
+
// TODO json 数据避免传 typedArray
|
|
26682
|
+
} else if (SerializationHelper.checkDataPath(property)) {
|
|
26683
|
+
var referenceObject = engine.findObject(property);
|
|
26684
|
+
return overrideDataPath ? referenceObject : property;
|
|
26685
|
+
} else if (isObject(property) && property.constructor === Object) {
|
|
26686
|
+
var res1;
|
|
26687
|
+
if (type) {
|
|
26688
|
+
res1 = new type();
|
|
26689
|
+
} else {
|
|
26690
|
+
res1 = {};
|
|
26691
|
+
}
|
|
26692
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(property)), _step1; !(_step1 = _iterator1()).done;){
|
|
26693
|
+
var key = _step1.value;
|
|
26694
|
+
res1[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1, undefined, overrideDataPath);
|
|
26695
|
+
}
|
|
26696
|
+
return res1;
|
|
26697
|
+
} else {
|
|
26698
|
+
return property;
|
|
26699
|
+
}
|
|
26700
|
+
};
|
|
26701
|
+
SerializationHelper.serializeObjectProperty = function serializeObjectProperty(objectProperty, serializedData, level) {
|
|
26702
|
+
if (level > 14) {
|
|
26703
|
+
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
26704
|
+
return;
|
|
26705
|
+
}
|
|
26706
|
+
if (!serializedData) {
|
|
26707
|
+
serializedData = {};
|
|
26708
|
+
}
|
|
26709
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(objectProperty)), _step; !(_step = _iterator()).done;){
|
|
26710
|
+
var key = _step.value;
|
|
26711
|
+
var value = objectProperty[key];
|
|
26712
|
+
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean" || SerializationHelper.checkTypedArray(objectProperty)) {
|
|
26713
|
+
// TODO json 数据避免传 typedArray
|
|
26714
|
+
serializedData[key] = value;
|
|
26715
|
+
} else if (isArray(value)) {
|
|
26716
|
+
if (!serializedData[key]) {
|
|
26717
|
+
serializedData[key] = [];
|
|
26718
|
+
}
|
|
26719
|
+
SerializationHelper.serializeArrayProperty(value, serializedData[key], level + 1);
|
|
26720
|
+
} else if (EffectsObject.is(value)) {
|
|
26721
|
+
// TODO 处理 EffectsObject 递归序列化
|
|
26722
|
+
serializedData[key] = {
|
|
26723
|
+
id: value.getInstanceId()
|
|
26724
|
+
};
|
|
26725
|
+
} else if (isObject(value)) {
|
|
26726
|
+
if (!serializedData[key]) {
|
|
26727
|
+
serializedData[key] = {};
|
|
26728
|
+
}
|
|
26729
|
+
SerializationHelper.serializeObjectProperty(value, serializedData[key], level + 1);
|
|
26730
|
+
}
|
|
26731
|
+
}
|
|
26967
26732
|
};
|
|
26968
|
-
|
|
26969
|
-
|
|
26970
|
-
|
|
26971
|
-
|
|
26972
|
-
if (context) {
|
|
26973
|
-
context.strokeStyle = "rgba(" + r * 255 + ", " + g * 255 + ", " + b * 255 + ", " + a + ")";
|
|
26974
|
-
context.lineWidth = outlineWidth * 2;
|
|
26733
|
+
SerializationHelper.serializeArrayProperty = function serializeArrayProperty(arrayProperty, serializedData, level) {
|
|
26734
|
+
if (level > 14) {
|
|
26735
|
+
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
26736
|
+
return;
|
|
26975
26737
|
}
|
|
26976
|
-
|
|
26977
|
-
|
|
26978
|
-
|
|
26979
|
-
var
|
|
26980
|
-
|
|
26981
|
-
|
|
26982
|
-
|
|
26983
|
-
|
|
26984
|
-
|
|
26985
|
-
|
|
26738
|
+
if (!serializedData) {
|
|
26739
|
+
serializedData = [];
|
|
26740
|
+
}
|
|
26741
|
+
for(var i = 0; i < arrayProperty.length; i++){
|
|
26742
|
+
var value = arrayProperty[i];
|
|
26743
|
+
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean" || SerializationHelper.checkTypedArray(arrayProperty)) {
|
|
26744
|
+
// TODO json 数据避免传 typedArray
|
|
26745
|
+
serializedData[i] = value;
|
|
26746
|
+
} else if (isArray(value)) {
|
|
26747
|
+
if (!serializedData[i]) {
|
|
26748
|
+
serializedData[i] = [];
|
|
26749
|
+
}
|
|
26750
|
+
SerializationHelper.serializeArrayProperty(value, serializedData[i], level + 1);
|
|
26751
|
+
} else if (EffectsObject.is(value)) {
|
|
26752
|
+
// TODO 处理 EffectsObject 递归序列化
|
|
26753
|
+
serializedData[i] = {
|
|
26754
|
+
id: value.getInstanceId()
|
|
26755
|
+
};
|
|
26756
|
+
} else if (isObject(value)) {
|
|
26757
|
+
if (!serializedData[i]) {
|
|
26758
|
+
serializedData[i] = {};
|
|
26759
|
+
}
|
|
26760
|
+
SerializationHelper.serializeObjectProperty(value, serializedData[i], level + 1);
|
|
26761
|
+
}
|
|
26986
26762
|
}
|
|
26987
26763
|
};
|
|
26988
|
-
return
|
|
26764
|
+
return SerializationHelper;
|
|
26989
26765
|
}();
|
|
26990
|
-
applyMixins(exports.TextComponent, [
|
|
26991
|
-
TextComponentBase
|
|
26992
|
-
]);
|
|
26993
|
-
|
|
26994
|
-
// TODO: 注册必须用
|
|
26995
|
-
var TextLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
26996
|
-
_inherits(TextLoader, AbstractPlugin);
|
|
26997
|
-
function TextLoader() {
|
|
26998
|
-
return AbstractPlugin.apply(this, arguments);
|
|
26999
|
-
}
|
|
27000
|
-
return TextLoader;
|
|
27001
|
-
}(AbstractPlugin);
|
|
27002
|
-
|
|
27003
|
-
var Asset = /*#__PURE__*/ function(EffectsObject) {
|
|
27004
|
-
_inherits(Asset, EffectsObject);
|
|
27005
|
-
function Asset() {
|
|
27006
|
-
return EffectsObject.apply(this, arguments);
|
|
27007
|
-
}
|
|
27008
|
-
return Asset;
|
|
27009
|
-
}(EffectsObject);
|
|
27010
|
-
|
|
27011
|
-
exports.BinaryAsset = /*#__PURE__*/ function(EffectsObject) {
|
|
27012
|
-
_inherits(BinaryAsset, EffectsObject);
|
|
27013
|
-
function BinaryAsset() {
|
|
27014
|
-
return EffectsObject.apply(this, arguments);
|
|
27015
|
-
}
|
|
27016
|
-
var _proto = BinaryAsset.prototype;
|
|
27017
|
-
_proto.fromData = function fromData(data) {};
|
|
27018
|
-
return BinaryAsset;
|
|
27019
|
-
}(EffectsObject);
|
|
27020
|
-
__decorate([
|
|
27021
|
-
serialize()
|
|
27022
|
-
], exports.BinaryAsset.prototype, "buffer", void 0);
|
|
27023
|
-
exports.BinaryAsset = __decorate([
|
|
27024
|
-
effectsClass(DataType.BinaryAsset)
|
|
27025
|
-
], exports.BinaryAsset);
|
|
27026
26766
|
|
|
27027
26767
|
/**
|
|
27028
26768
|
* @since 2.0.0
|
|
@@ -27031,9 +26771,10 @@ exports.BinaryAsset = __decorate([
|
|
|
27031
26771
|
this.engine = engine;
|
|
27032
26772
|
}
|
|
27033
26773
|
var _proto = AssetLoader.prototype;
|
|
27034
|
-
_proto.loadGUID = function loadGUID(
|
|
27035
|
-
|
|
27036
|
-
|
|
26774
|
+
_proto.loadGUID = function loadGUID(dataPath) {
|
|
26775
|
+
var guid = dataPath.id;
|
|
26776
|
+
if (!dataPath) {
|
|
26777
|
+
return null;
|
|
27037
26778
|
}
|
|
27038
26779
|
var effectsObjectData = this.findData(guid);
|
|
27039
26780
|
var effectsObject;
|
|
@@ -27068,92 +26809,6 @@ exports.BinaryAsset = __decorate([
|
|
|
27068
26809
|
SerializationHelper.deserialize(effectsObjectData, effectsObject);
|
|
27069
26810
|
return effectsObject;
|
|
27070
26811
|
};
|
|
27071
|
-
// 加载本地文件资产
|
|
27072
|
-
_proto.loadGUIDAsync = function loadGUIDAsync(guid) {
|
|
27073
|
-
var _this = this;
|
|
27074
|
-
return _async_to_generator(function() {
|
|
27075
|
-
var effectsObjectData, effectsObject, classConstructor;
|
|
27076
|
-
return __generator(this, function(_state) {
|
|
27077
|
-
switch(_state.label){
|
|
27078
|
-
case 0:
|
|
27079
|
-
if (_this.engine.objectInstance[guid]) {
|
|
27080
|
-
return [
|
|
27081
|
-
2,
|
|
27082
|
-
_this.engine.objectInstance[guid]
|
|
27083
|
-
];
|
|
27084
|
-
}
|
|
27085
|
-
effectsObjectData = _this.findData(guid);
|
|
27086
|
-
if (!!effectsObjectData) return [
|
|
27087
|
-
3,
|
|
27088
|
-
2
|
|
27089
|
-
];
|
|
27090
|
-
if (!_this.engine.database) {
|
|
27091
|
-
console.error("Object data with uuid: " + guid + " not found.");
|
|
27092
|
-
return [
|
|
27093
|
-
2,
|
|
27094
|
-
undefined
|
|
27095
|
-
];
|
|
27096
|
-
}
|
|
27097
|
-
return [
|
|
27098
|
-
4,
|
|
27099
|
-
_this.engine.database.loadGUID(guid)
|
|
27100
|
-
];
|
|
27101
|
-
case 1:
|
|
27102
|
-
effectsObject = _state.sent();
|
|
27103
|
-
if (!effectsObject) {
|
|
27104
|
-
console.error("Disk data with uuid: " + guid + " not found.");
|
|
27105
|
-
return [
|
|
27106
|
-
2,
|
|
27107
|
-
undefined
|
|
27108
|
-
];
|
|
27109
|
-
}
|
|
27110
|
-
_this.engine.addInstance(effectsObject);
|
|
27111
|
-
return [
|
|
27112
|
-
2,
|
|
27113
|
-
effectsObject
|
|
27114
|
-
];
|
|
27115
|
-
case 2:
|
|
27116
|
-
switch(effectsObjectData.dataType){
|
|
27117
|
-
case DataType.Material:
|
|
27118
|
-
effectsObject = Material.create(_this.engine);
|
|
27119
|
-
break;
|
|
27120
|
-
case DataType.Geometry:
|
|
27121
|
-
effectsObject = Geometry.create(_this.engine);
|
|
27122
|
-
break;
|
|
27123
|
-
case DataType.Texture:
|
|
27124
|
-
effectsObject = Texture.create(_this.engine);
|
|
27125
|
-
break;
|
|
27126
|
-
default:
|
|
27127
|
-
{
|
|
27128
|
-
classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
|
|
27129
|
-
if (classConstructor) {
|
|
27130
|
-
effectsObject = new classConstructor(_this.engine);
|
|
27131
|
-
}
|
|
27132
|
-
}
|
|
27133
|
-
}
|
|
27134
|
-
if (!effectsObject) {
|
|
27135
|
-
console.error("Constructor for DataType: " + effectsObjectData.dataType + " not found.");
|
|
27136
|
-
return [
|
|
27137
|
-
2,
|
|
27138
|
-
undefined
|
|
27139
|
-
];
|
|
27140
|
-
}
|
|
27141
|
-
effectsObject.setInstanceId(effectsObjectData.id);
|
|
27142
|
-
_this.engine.addInstance(effectsObject);
|
|
27143
|
-
return [
|
|
27144
|
-
4,
|
|
27145
|
-
SerializationHelper.deserializeAsync(effectsObjectData, effectsObject)
|
|
27146
|
-
];
|
|
27147
|
-
case 3:
|
|
27148
|
-
_state.sent();
|
|
27149
|
-
return [
|
|
27150
|
-
2,
|
|
27151
|
-
effectsObject
|
|
27152
|
-
];
|
|
27153
|
-
}
|
|
27154
|
-
});
|
|
27155
|
-
})();
|
|
27156
|
-
};
|
|
27157
26812
|
_proto.findData = function findData(uuid) {
|
|
27158
26813
|
return this.engine.jsonSceneData[uuid];
|
|
27159
26814
|
};
|
|
@@ -27503,35 +27158,35 @@ function rotationZYXFromQuat(out, quat) {
|
|
|
27503
27158
|
];
|
|
27504
27159
|
}
|
|
27505
27160
|
}
|
|
27506
|
-
var _obj;
|
|
27507
|
-
var particleOriginTranslateMap = (_obj = {}, _obj[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
|
|
27161
|
+
var _obj$1;
|
|
27162
|
+
var particleOriginTranslateMap = (_obj$1 = {}, _obj$1[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
|
|
27508
27163
|
0,
|
|
27509
27164
|
0
|
|
27510
|
-
], _obj[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
|
|
27165
|
+
], _obj$1[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
|
|
27511
27166
|
0,
|
|
27512
27167
|
-0.5
|
|
27513
|
-
], _obj[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
|
|
27168
|
+
], _obj$1[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
|
|
27514
27169
|
0,
|
|
27515
27170
|
0.5
|
|
27516
|
-
], _obj[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
|
|
27171
|
+
], _obj$1[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
|
|
27517
27172
|
-0.5,
|
|
27518
27173
|
0.5
|
|
27519
|
-
], _obj[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
|
|
27174
|
+
], _obj$1[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
|
|
27520
27175
|
-0.5,
|
|
27521
27176
|
0
|
|
27522
|
-
], _obj[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
|
|
27177
|
+
], _obj$1[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
|
|
27523
27178
|
-0.5,
|
|
27524
27179
|
-0.5
|
|
27525
|
-
], _obj[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
|
|
27180
|
+
], _obj$1[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
|
|
27526
27181
|
0.5,
|
|
27527
27182
|
0
|
|
27528
|
-
], _obj[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
|
|
27183
|
+
], _obj$1[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
|
|
27529
27184
|
0.5,
|
|
27530
27185
|
-0.5
|
|
27531
|
-
], _obj[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
|
|
27186
|
+
], _obj$1[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
|
|
27532
27187
|
0.5,
|
|
27533
27188
|
0.5
|
|
27534
|
-
], _obj);
|
|
27189
|
+
], _obj$1);
|
|
27535
27190
|
function getBezierCurveFromHermite(m0, m1, p0, p3) {
|
|
27536
27191
|
var xStart = p0[0];
|
|
27537
27192
|
var yStart = p0[1];
|
|
@@ -27770,28 +27425,6 @@ var refCompositions = new Map();
|
|
|
27770
27425
|
}
|
|
27771
27426
|
}
|
|
27772
27427
|
}
|
|
27773
|
-
// Composition id 转 guid
|
|
27774
|
-
var compositionId = json.compositionId;
|
|
27775
|
-
var compositionIdToGUIDMap = {};
|
|
27776
|
-
for(var _iterator3 = _create_for_of_iterator_helper_loose(json.compositions), _step3; !(_step3 = _iterator3()).done;){
|
|
27777
|
-
var composition = _step3.value;
|
|
27778
|
-
var guid = generateGUID();
|
|
27779
|
-
compositionIdToGUIDMap[composition.id] = guid;
|
|
27780
|
-
if (composition.id === compositionId) {
|
|
27781
|
-
json.compositionId = guid;
|
|
27782
|
-
}
|
|
27783
|
-
composition.id = guid;
|
|
27784
|
-
}
|
|
27785
|
-
// 预合成元素 refId 同步改为生成的合成 guid
|
|
27786
|
-
for(var _iterator4 = _create_for_of_iterator_helper_loose(json.items), _step4; !(_step4 = _iterator4()).done;){
|
|
27787
|
-
var item = _step4.value;
|
|
27788
|
-
if (item.content) {
|
|
27789
|
-
var compositionOptions = item.content.options;
|
|
27790
|
-
if (compositionOptions && compositionOptions.refId !== undefined) {
|
|
27791
|
-
compositionOptions.refId = compositionIdToGUIDMap[compositionOptions.refId];
|
|
27792
|
-
}
|
|
27793
|
-
}
|
|
27794
|
-
}
|
|
27795
27428
|
return json;
|
|
27796
27429
|
}
|
|
27797
27430
|
function version32Migration(json) {
|
|
@@ -27818,21 +27451,68 @@ function version32Migration(json) {
|
|
|
27818
27451
|
itemMap.set(item.id, item);
|
|
27819
27452
|
}
|
|
27820
27453
|
processContent(mainComp);
|
|
27454
|
+
return json;
|
|
27455
|
+
}
|
|
27456
|
+
function version33Migration(json) {
|
|
27821
27457
|
// 老 shape 数据兼容
|
|
27822
|
-
for(var
|
|
27823
|
-
var
|
|
27824
|
-
if (
|
|
27825
|
-
var spriteComponent = componentMap.get(
|
|
27458
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(json.items), _step; !(_step = _iterator()).done;){
|
|
27459
|
+
var item = _step.value;
|
|
27460
|
+
if (item.type === ItemType.sprite) {
|
|
27461
|
+
var spriteComponent = componentMap.get(item.components[0].id);
|
|
27826
27462
|
if (spriteComponent) {
|
|
27827
27463
|
var shape = spriteComponent.renderer.shape;
|
|
27828
27464
|
var shapeData = void 0;
|
|
27829
27465
|
if (Number.isInteger(shape)) {
|
|
27830
27466
|
shapeData = json.shapes[shape];
|
|
27467
|
+
} else {
|
|
27468
|
+
shapeData = shape;
|
|
27831
27469
|
}
|
|
27832
27470
|
spriteComponent.renderer.shape = shapeData;
|
|
27833
27471
|
}
|
|
27834
27472
|
}
|
|
27835
27473
|
}
|
|
27474
|
+
// Composition id 转 guid, Composition 分离 CompositionComponent
|
|
27475
|
+
var compositionId = json.compositionId;
|
|
27476
|
+
var compositionIdToGUIDMap = {};
|
|
27477
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(json.compositions), _step1; !(_step1 = _iterator1()).done;){
|
|
27478
|
+
var composition = _step1.value;
|
|
27479
|
+
var guid = generateGUID();
|
|
27480
|
+
compositionIdToGUIDMap[composition.id] = guid;
|
|
27481
|
+
if (composition.id === compositionId) {
|
|
27482
|
+
json.compositionId = guid;
|
|
27483
|
+
}
|
|
27484
|
+
composition.id = guid;
|
|
27485
|
+
var compositionComponent = {
|
|
27486
|
+
id: generateGUID(),
|
|
27487
|
+
dataType: "CompositionComponent",
|
|
27488
|
+
items: composition.items,
|
|
27489
|
+
timelineAsset: composition.timelineAsset,
|
|
27490
|
+
sceneBindings: composition.sceneBindings,
|
|
27491
|
+
startTime: composition.startTime
|
|
27492
|
+
};
|
|
27493
|
+
//@ts-expect-error
|
|
27494
|
+
composition.timelineAsset = undefined;
|
|
27495
|
+
//@ts-expect-error
|
|
27496
|
+
composition.sceneBindings = undefined;
|
|
27497
|
+
composition.startTime = undefined;
|
|
27498
|
+
//@ts-expect-error
|
|
27499
|
+
composition.components = [
|
|
27500
|
+
{
|
|
27501
|
+
id: compositionComponent.id
|
|
27502
|
+
}
|
|
27503
|
+
];
|
|
27504
|
+
json.components.push(compositionComponent);
|
|
27505
|
+
}
|
|
27506
|
+
// 预合成元素 refId 同步改为生成的合成 guid
|
|
27507
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(json.items), _step2; !(_step2 = _iterator2()).done;){
|
|
27508
|
+
var item1 = _step2.value;
|
|
27509
|
+
if (item1.content) {
|
|
27510
|
+
var compositionOptions = item1.content.options;
|
|
27511
|
+
if (compositionOptions && compositionOptions.refId !== undefined) {
|
|
27512
|
+
compositionOptions.refId = compositionIdToGUIDMap[compositionOptions.refId];
|
|
27513
|
+
}
|
|
27514
|
+
}
|
|
27515
|
+
}
|
|
27836
27516
|
return json;
|
|
27837
27517
|
}
|
|
27838
27518
|
function processContent(composition) {
|
|
@@ -28706,7 +28386,7 @@ function getStandardJSON(json) {
|
|
|
28706
28386
|
if (v0.test(json.version)) {
|
|
28707
28387
|
var _exec;
|
|
28708
28388
|
reverseParticle = ((_exec = /^(\d+)/.exec(json.version)) == null ? void 0 : _exec[0]) === "0";
|
|
28709
|
-
return version32Migration(version31Migration(version30Migration(version21Migration(getStandardJSONFromV0(json)))));
|
|
28389
|
+
return version33Migration(version32Migration(version31Migration(version30Migration(version21Migration(getStandardJSONFromV0(json))))));
|
|
28710
28390
|
}
|
|
28711
28391
|
reverseParticle = false;
|
|
28712
28392
|
var vs = standardVersion.exec(json.version) || [];
|
|
@@ -28731,6 +28411,9 @@ function getStandardJSON(json) {
|
|
|
28731
28411
|
if (minorVersion < 3) {
|
|
28732
28412
|
json = version32Migration(json);
|
|
28733
28413
|
}
|
|
28414
|
+
if (minorVersion < 4) {
|
|
28415
|
+
json = version33Migration(json);
|
|
28416
|
+
}
|
|
28734
28417
|
}
|
|
28735
28418
|
return json;
|
|
28736
28419
|
}
|
|
@@ -29014,6 +28697,40 @@ function getStandardItem(item, opt) {
|
|
|
29014
28697
|
}
|
|
29015
28698
|
}
|
|
29016
28699
|
|
|
28700
|
+
var _obj;
|
|
28701
|
+
/**
|
|
28702
|
+
* 机型和渲染等级对应表
|
|
28703
|
+
*
|
|
28704
|
+
* 机型:B-低端机、A-中端机、S-高端机
|
|
28705
|
+
* 渲染等级:B-低、A-中、S-高、A+-中高、B+-全部
|
|
28706
|
+
*
|
|
28707
|
+
* - S(高端机):高、全部、中高
|
|
28708
|
+
* - A(中端机):中、全部、中高
|
|
28709
|
+
* - B(低端机):低、全部
|
|
28710
|
+
* - undefined(全部机型)
|
|
28711
|
+
*/ var renderLevelPassSet = (_obj = {}, _obj[RenderLevel.S] = [
|
|
28712
|
+
RenderLevel.S,
|
|
28713
|
+
RenderLevel.BPlus,
|
|
28714
|
+
RenderLevel.APlus
|
|
28715
|
+
], _obj[RenderLevel.A] = [
|
|
28716
|
+
RenderLevel.A,
|
|
28717
|
+
RenderLevel.BPlus,
|
|
28718
|
+
RenderLevel.APlus
|
|
28719
|
+
], _obj[RenderLevel.B] = [
|
|
28720
|
+
RenderLevel.B,
|
|
28721
|
+
RenderLevel.BPlus
|
|
28722
|
+
], _obj);
|
|
28723
|
+
function passRenderLevel(l, renderLevel) {
|
|
28724
|
+
if (!l || !renderLevel) {
|
|
28725
|
+
return true;
|
|
28726
|
+
}
|
|
28727
|
+
var arr = renderLevelPassSet[renderLevel];
|
|
28728
|
+
if (arr) {
|
|
28729
|
+
return arr.includes(l);
|
|
28730
|
+
}
|
|
28731
|
+
return false;
|
|
28732
|
+
}
|
|
28733
|
+
|
|
29017
28734
|
exports.Scene = void 0;
|
|
29018
28735
|
(function(Scene) {
|
|
29019
28736
|
function isJSONObject(scene) {
|
|
@@ -29913,7 +29630,9 @@ function createTextureOptionsBySource(image, sourceFrom, id) {
|
|
|
29913
29630
|
if (_instanceof1(textureOptions, Texture)) {
|
|
29914
29631
|
this.engine.addInstance(textureOptions);
|
|
29915
29632
|
} else {
|
|
29916
|
-
textureOptions = this.engine.
|
|
29633
|
+
textureOptions = this.engine.findObject({
|
|
29634
|
+
id: scene.textureOptions[i].id
|
|
29635
|
+
});
|
|
29917
29636
|
scene.textureOptions[i] = textureOptions;
|
|
29918
29637
|
}
|
|
29919
29638
|
textureOptions.initialize();
|
|
@@ -31560,8 +31279,18 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
|
|
|
31560
31279
|
_proto.addInstance = function addInstance(effectsObject) {
|
|
31561
31280
|
this.objectInstance[effectsObject.getInstanceId()] = effectsObject;
|
|
31562
31281
|
};
|
|
31563
|
-
|
|
31564
|
-
|
|
31282
|
+
/**
|
|
31283
|
+
* @ignore
|
|
31284
|
+
*/ _proto.findObject = function findObject(guid) {
|
|
31285
|
+
// 编辑器可能传 Class 对象,这边判断处理一下直接返回原对象。
|
|
31286
|
+
if (!(isObject(guid) && guid.constructor === Object)) {
|
|
31287
|
+
return guid;
|
|
31288
|
+
}
|
|
31289
|
+
if (this.objectInstance[guid.id]) {
|
|
31290
|
+
return this.objectInstance[guid.id];
|
|
31291
|
+
}
|
|
31292
|
+
var result = this.assetLoader.loadGUID(guid);
|
|
31293
|
+
return result;
|
|
31565
31294
|
};
|
|
31566
31295
|
_proto.removeInstance = function removeInstance(id) {
|
|
31567
31296
|
delete this.objectInstance[id];
|
|
@@ -31575,6 +31304,10 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
|
|
|
31575
31304
|
}
|
|
31576
31305
|
for(var _iterator1 = _create_for_of_iterator_helper_loose(items), _step1; !(_step1 = _iterator1()).done;){
|
|
31577
31306
|
var vfxItemData = _step1.value;
|
|
31307
|
+
if (!passRenderLevel(vfxItemData.renderLevel, scene.renderLevel)) {
|
|
31308
|
+
vfxItemData.components = [];
|
|
31309
|
+
vfxItemData.type = ItemType.null;
|
|
31310
|
+
}
|
|
31578
31311
|
this.addEffectsObjectData(vfxItemData);
|
|
31579
31312
|
}
|
|
31580
31313
|
for(var _iterator2 = _create_for_of_iterator_helper_loose(materials), _step2; !(_step2 = _iterator2()).done;){
|
|
@@ -31629,45 +31362,20 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
|
|
|
31629
31362
|
return _async_to_generator(function() {
|
|
31630
31363
|
var jsonScene, _iterator, _step, itemData, itemType;
|
|
31631
31364
|
return __generator(this, function(_state) {
|
|
31632
|
-
|
|
31633
|
-
|
|
31634
|
-
|
|
31635
|
-
|
|
31636
|
-
|
|
31637
|
-
|
|
31638
|
-
|
|
31639
|
-
|
|
31640
|
-
|
|
31641
|
-
|
|
31642
|
-
itemData = _step.value;
|
|
31643
|
-
itemType = itemData.type;
|
|
31644
|
-
if (!(itemType === "ECS" || itemType === "camera" || itemType === ItemType.sprite || itemType === ItemType.particle || itemType === ItemType.mesh || itemType === ItemType.skybox || itemType === ItemType.light || itemType === ItemType.tree || itemType === ItemType.interact || itemType === ItemType.camera)) {
|
|
31645
|
-
return [
|
|
31646
|
-
3,
|
|
31647
|
-
3
|
|
31648
|
-
];
|
|
31649
|
-
}
|
|
31650
|
-
if (!_this.database) return [
|
|
31651
|
-
3,
|
|
31652
|
-
3
|
|
31653
|
-
];
|
|
31654
|
-
return [
|
|
31655
|
-
4,
|
|
31656
|
-
_this.assetLoader.loadGUIDAsync(itemData.id)
|
|
31657
|
-
];
|
|
31658
|
-
case 2:
|
|
31659
|
-
_state.sent();
|
|
31660
|
-
_state.label = 3;
|
|
31661
|
-
case 3:
|
|
31662
|
-
return [
|
|
31663
|
-
3,
|
|
31664
|
-
1
|
|
31665
|
-
];
|
|
31666
|
-
case 4:
|
|
31667
|
-
return [
|
|
31668
|
-
2
|
|
31669
|
-
];
|
|
31365
|
+
jsonScene = scene.jsonScene;
|
|
31366
|
+
for(_iterator = _create_for_of_iterator_helper_loose(jsonScene.items); !(_step = _iterator()).done;){
|
|
31367
|
+
itemData = _step.value;
|
|
31368
|
+
itemType = itemData.type;
|
|
31369
|
+
if (!(itemType === "ECS" || itemType === "camera" || itemType === ItemType.sprite || itemType === ItemType.particle || itemType === ItemType.mesh || itemType === ItemType.skybox || itemType === ItemType.light || itemType === ItemType.tree || itemType === ItemType.interact || itemType === ItemType.camera)) {
|
|
31370
|
+
continue;
|
|
31371
|
+
}
|
|
31372
|
+
if (_this.database) {
|
|
31373
|
+
_this.assetLoader.loadGUID(itemData);
|
|
31374
|
+
}
|
|
31670
31375
|
}
|
|
31376
|
+
return [
|
|
31377
|
+
2
|
|
31378
|
+
];
|
|
31671
31379
|
});
|
|
31672
31380
|
})();
|
|
31673
31381
|
};
|
|
@@ -31915,7 +31623,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
|
|
|
31915
31623
|
registerPlugin("particle", ParticleLoader, exports.VFXItem);
|
|
31916
31624
|
registerPlugin("cal", CalculateLoader, exports.VFXItem);
|
|
31917
31625
|
registerPlugin("interact", InteractLoader, exports.VFXItem);
|
|
31918
|
-
var version = "2.4.0-beta.
|
|
31626
|
+
var version = "2.4.0-beta.1";
|
|
31919
31627
|
logger.info("Core version: " + version + ".");
|
|
31920
31628
|
|
|
31921
31629
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -31940,7 +31648,6 @@ exports.CameraVFXItemLoader = CameraVFXItemLoader;
|
|
|
31940
31648
|
exports.ColorCurve = ColorCurve;
|
|
31941
31649
|
exports.Component = Component;
|
|
31942
31650
|
exports.Composition = Composition;
|
|
31943
|
-
exports.CompositionComponent = CompositionComponent;
|
|
31944
31651
|
exports.DEFAULT_FONTS = DEFAULT_FONTS;
|
|
31945
31652
|
exports.DEFAULT_FPS = DEFAULT_FPS;
|
|
31946
31653
|
exports.Database = Database;
|
|
@@ -32064,7 +31771,6 @@ exports.effectsClassStore = effectsClassStore;
|
|
|
32064
31771
|
exports.enlargeBuffer = enlargeBuffer;
|
|
32065
31772
|
exports.ensureFixedNumber = ensureFixedNumber;
|
|
32066
31773
|
exports.ensureVec3 = ensureVec3;
|
|
32067
|
-
exports.filterItemsByRenderLevel = filterItemsByRenderLevel;
|
|
32068
31774
|
exports.findPreviousRenderPass = findPreviousRenderPass;
|
|
32069
31775
|
exports.gaussianDownFrag = gaussianDown_frag;
|
|
32070
31776
|
exports.gaussianDownHFrag = gaussianDownHFrag;
|