@galacean/effects-threejs 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/index.js +514 -808
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +509 -801
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.4.0-beta.
|
|
6
|
+
* Version: v2.4.0-beta.1
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -2026,7 +2026,7 @@ function getDirectStore(target) {
|
|
|
2026
2026
|
function EffectsObject(engine) {
|
|
2027
2027
|
this.engine = engine;
|
|
2028
2028
|
this.guid = generateGUID();
|
|
2029
|
-
this.
|
|
2029
|
+
this.defination = {};
|
|
2030
2030
|
this.engine.addInstance(this);
|
|
2031
2031
|
}
|
|
2032
2032
|
var _proto = EffectsObject.prototype;
|
|
@@ -2051,11 +2051,7 @@ function getDirectStore(target) {
|
|
|
2051
2051
|
* 反序列化函数
|
|
2052
2052
|
*
|
|
2053
2053
|
* @param data - 对象的序列化的数据
|
|
2054
|
-
*/ _proto.fromData = function fromData(data) {
|
|
2055
|
-
if (data.id) {
|
|
2056
|
-
this.setInstanceId(data.id);
|
|
2057
|
-
}
|
|
2058
|
-
};
|
|
2054
|
+
*/ _proto.fromData = function fromData(data) {};
|
|
2059
2055
|
/**
|
|
2060
2056
|
*
|
|
2061
2057
|
*/ _proto.dispose = function dispose() {};
|
|
@@ -2151,9 +2147,6 @@ function getDirectStore(target) {
|
|
|
2151
2147
|
};
|
|
2152
2148
|
_proto.fromData = function fromData(data) {
|
|
2153
2149
|
EffectsObject.prototype.fromData.call(this, data);
|
|
2154
|
-
if (data.item) {
|
|
2155
|
-
this.item = data.item;
|
|
2156
|
-
}
|
|
2157
2150
|
};
|
|
2158
2151
|
_proto.dispose = function dispose() {
|
|
2159
2152
|
if (this.isEnableCalled) {
|
|
@@ -2218,11 +2211,15 @@ function getDirectStore(target) {
|
|
|
2218
2211
|
]);
|
|
2219
2212
|
return Component;
|
|
2220
2213
|
}(EffectsObject);
|
|
2214
|
+
__decorate([
|
|
2215
|
+
serialize()
|
|
2216
|
+
], Component.prototype, "item", void 0);
|
|
2221
2217
|
__decorate([
|
|
2222
2218
|
serialize()
|
|
2223
2219
|
], Component.prototype, "_enabled", void 0);
|
|
2224
2220
|
/**
|
|
2225
2221
|
* @since 2.0.0
|
|
2222
|
+
* @deprecated 2.4.0 Please use Component instead
|
|
2226
2223
|
*/ var Behaviour = /*#__PURE__*/ function(Component) {
|
|
2227
2224
|
_inherits(Behaviour, Component);
|
|
2228
2225
|
function Behaviour() {
|
|
@@ -2252,10 +2249,6 @@ __decorate([
|
|
|
2252
2249
|
}
|
|
2253
2250
|
var _proto = RendererComponent.prototype;
|
|
2254
2251
|
_proto.render = function render(renderer) {};
|
|
2255
|
-
_proto.setVFXItem = function setVFXItem(item) {
|
|
2256
|
-
Component.prototype.setVFXItem.call(this, item);
|
|
2257
|
-
this.item.rendererComponents.push(this);
|
|
2258
|
-
};
|
|
2259
2252
|
_proto.onEnable = function onEnable() {
|
|
2260
2253
|
var _this_item_composition;
|
|
2261
2254
|
(_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.renderFrame.addMeshToDefaultRenderPass(this);
|
|
@@ -2264,18 +2257,6 @@ __decorate([
|
|
|
2264
2257
|
var _this_item_composition;
|
|
2265
2258
|
(_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.renderFrame.removeMeshFromDefaultRenderPass(this);
|
|
2266
2259
|
};
|
|
2267
|
-
_proto.fromData = function fromData(data) {
|
|
2268
|
-
Component.prototype.fromData.call(this, data);
|
|
2269
|
-
};
|
|
2270
|
-
_proto.toData = function toData() {
|
|
2271
|
-
Component.prototype.toData.call(this);
|
|
2272
|
-
};
|
|
2273
|
-
_proto.dispose = function dispose() {
|
|
2274
|
-
if (this.item) {
|
|
2275
|
-
removeItem(this.item.rendererComponents, this);
|
|
2276
|
-
}
|
|
2277
|
-
Component.prototype.dispose.call(this);
|
|
2278
|
-
};
|
|
2279
2260
|
_create_class(RendererComponent, [
|
|
2280
2261
|
{
|
|
2281
2262
|
key: "priority",
|
|
@@ -3898,11 +3879,11 @@ exports.EffectComponent = __decorate([
|
|
|
3898
3879
|
effectsClass(DataType.EffectComponent)
|
|
3899
3880
|
], exports.EffectComponent);
|
|
3900
3881
|
|
|
3901
|
-
exports.PostProcessVolume = /*#__PURE__*/ function(
|
|
3902
|
-
_inherits(PostProcessVolume,
|
|
3882
|
+
exports.PostProcessVolume = /*#__PURE__*/ function(Component) {
|
|
3883
|
+
_inherits(PostProcessVolume, Component);
|
|
3903
3884
|
function PostProcessVolume(engine) {
|
|
3904
3885
|
var _this;
|
|
3905
|
-
_this =
|
|
3886
|
+
_this = Component.call(this, engine) || this;
|
|
3906
3887
|
_this.bloom = {
|
|
3907
3888
|
threshold: 0,
|
|
3908
3889
|
intensity: 0,
|
|
@@ -3933,7 +3914,7 @@ exports.PostProcessVolume = /*#__PURE__*/ function(Behaviour) {
|
|
|
3933
3914
|
}
|
|
3934
3915
|
};
|
|
3935
3916
|
return PostProcessVolume;
|
|
3936
|
-
}(
|
|
3917
|
+
}(Component);
|
|
3937
3918
|
__decorate([
|
|
3938
3919
|
serialize()
|
|
3939
3920
|
], exports.PostProcessVolume.prototype, "bloom", void 0);
|
|
@@ -12770,6 +12751,10 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12770
12751
|
RendererComponent.prototype.fromData.call(this, data);
|
|
12771
12752
|
var _data_renderer;
|
|
12772
12753
|
var renderer = (_data_renderer = data.renderer) != null ? _data_renderer : {};
|
|
12754
|
+
var maskProps = data.mask;
|
|
12755
|
+
if (maskProps && maskProps.ref) {
|
|
12756
|
+
maskProps.ref = this.engine.findObject(maskProps.ref);
|
|
12757
|
+
}
|
|
12773
12758
|
var maskMode = this.maskManager.getMaskMode(data);
|
|
12774
12759
|
// TODO 新蒙板上线后移除
|
|
12775
12760
|
//-------------------------------------------------------------------------
|
|
@@ -12777,15 +12762,15 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12777
12762
|
//@ts-expect-error
|
|
12778
12763
|
var split = data.splits && !data.textureSheetAnimation ? data.splits[0] : undefined;
|
|
12779
12764
|
var shapeGeometry = undefined;
|
|
12780
|
-
if (shapeData !== undefined && !("aPoint" in shapeData && "index" in shapeData)) {
|
|
12765
|
+
if (shapeData !== undefined && shapeData !== null && !("aPoint" in shapeData && "index" in shapeData)) {
|
|
12781
12766
|
shapeGeometry = getGeometryByShape(shapeData, split);
|
|
12782
12767
|
}
|
|
12783
|
-
var _renderer_renderMode, _renderer_blending,
|
|
12768
|
+
var _renderer_renderMode, _renderer_blending, _renderer_side;
|
|
12784
12769
|
//-------------------------------------------------------------------------
|
|
12785
12770
|
this.renderer = {
|
|
12786
12771
|
renderMode: (_renderer_renderMode = renderer.renderMode) != null ? _renderer_renderMode : RenderMode.MESH,
|
|
12787
12772
|
blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
|
|
12788
|
-
texture:
|
|
12773
|
+
texture: renderer.texture ? this.engine.findObject(renderer.texture) : this.engine.emptyTexture,
|
|
12789
12774
|
occlusion: !!renderer.occlusion,
|
|
12790
12775
|
transparentOcclusion: !!renderer.transparentOcclusion || maskMode === exports.MaskMode.MASK,
|
|
12791
12776
|
side: (_renderer_side = renderer.side) != null ? _renderer_side : SideMode.DOUBLE,
|
|
@@ -13002,14 +12987,14 @@ exports.ShapeComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
13002
12987
|
var control2 = easingIns[pointIndex.easingIn];
|
|
13003
12988
|
this.graphicsPath.bezierCurveTo(control1.x + lastPoint.x, control1.y + lastPoint.y, control2.x + point.x, control2.y + point.y, point.x, point.y, 1);
|
|
13004
12989
|
}
|
|
13005
|
-
var pointIndex1 = indices[0];
|
|
13006
|
-
var lastPointIndex1 = indices[indices.length - 1];
|
|
13007
|
-
var point1 = points[pointIndex1.point];
|
|
13008
|
-
var lastPoint1 = points[lastPointIndex1.point];
|
|
13009
|
-
var control11 = easingOuts[lastPointIndex1.easingOut];
|
|
13010
|
-
var control21 = easingIns[pointIndex1.easingIn];
|
|
13011
|
-
this.graphicsPath.bezierCurveTo(control11.x + lastPoint1.x, control11.y + lastPoint1.y, control21.x + point1.x, control21.y + point1.y, point1.x, point1.y, 1);
|
|
13012
12990
|
if (shape.close) {
|
|
12991
|
+
var pointIndex1 = indices[0];
|
|
12992
|
+
var lastPointIndex1 = indices[indices.length - 1];
|
|
12993
|
+
var point1 = points[pointIndex1.point];
|
|
12994
|
+
var lastPoint1 = points[lastPointIndex1.point];
|
|
12995
|
+
var control11 = easingOuts[lastPointIndex1.easingOut];
|
|
12996
|
+
var control21 = easingIns[pointIndex1.easingIn];
|
|
12997
|
+
this.graphicsPath.bezierCurveTo(control11.x + lastPoint1.x, control11.y + lastPoint1.y, control21.x + point1.x, control21.y + point1.y, point1.x, point1.y, 1);
|
|
13013
12998
|
this.graphicsPath.closePath();
|
|
13014
12999
|
}
|
|
13015
13000
|
}
|
|
@@ -13139,6 +13124,10 @@ exports.ShapeComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
13139
13124
|
break;
|
|
13140
13125
|
}
|
|
13141
13126
|
}
|
|
13127
|
+
var maskProps = data.mask;
|
|
13128
|
+
if (maskProps && maskProps.ref) {
|
|
13129
|
+
maskProps.ref = this.engine.findObject(maskProps.ref);
|
|
13130
|
+
}
|
|
13142
13131
|
var maskMode = this.maskManager.getMaskMode(data);
|
|
13143
13132
|
var maskRef = this.maskManager.getRefValue();
|
|
13144
13133
|
this.material.stencilRef = maskRef !== undefined ? [
|
|
@@ -13288,11 +13277,11 @@ exports.Fake3DAnimationMode = void 0;
|
|
|
13288
13277
|
Fake3DAnimationMode[Fake3DAnimationMode["Linear"] = 1] = "Linear";
|
|
13289
13278
|
})(exports.Fake3DAnimationMode || (exports.Fake3DAnimationMode = {}));
|
|
13290
13279
|
|
|
13291
|
-
exports.CameraController = /*#__PURE__*/ function(
|
|
13292
|
-
_inherits(CameraController,
|
|
13280
|
+
exports.CameraController = /*#__PURE__*/ function(Component) {
|
|
13281
|
+
_inherits(CameraController, Component);
|
|
13293
13282
|
function CameraController(engine, props) {
|
|
13294
13283
|
var _this;
|
|
13295
|
-
_this =
|
|
13284
|
+
_this = Component.call(this, engine) || this;
|
|
13296
13285
|
if (props) {
|
|
13297
13286
|
_this.fromData(props);
|
|
13298
13287
|
}
|
|
@@ -13313,11 +13302,11 @@ exports.CameraController = /*#__PURE__*/ function(Behaviour) {
|
|
|
13313
13302
|
}
|
|
13314
13303
|
};
|
|
13315
13304
|
_proto.fromData = function fromData(data) {
|
|
13316
|
-
|
|
13305
|
+
Component.prototype.fromData.call(this, data);
|
|
13317
13306
|
this.options = data.options;
|
|
13318
13307
|
};
|
|
13319
13308
|
return CameraController;
|
|
13320
|
-
}(
|
|
13309
|
+
}(Component);
|
|
13321
13310
|
exports.CameraController = __decorate([
|
|
13322
13311
|
effectsClass(DataType.CameraController)
|
|
13323
13312
|
], exports.CameraController);
|
|
@@ -19465,7 +19454,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
19465
19454
|
mask: maskProps.maskRef,
|
|
19466
19455
|
maskMode: maskProps.maskMode,
|
|
19467
19456
|
forceTarget: forceTarget,
|
|
19468
|
-
diffuse: renderer.texture,
|
|
19457
|
+
diffuse: renderer.texture ? this.engine.findObject(renderer.texture) : undefined,
|
|
19469
19458
|
sizeOverLifetime: sizeOverLifetimeGetter,
|
|
19470
19459
|
anchor: anchor
|
|
19471
19460
|
};
|
|
@@ -19552,7 +19541,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
19552
19541
|
maxTrailCount: options.maxCount,
|
|
19553
19542
|
pointCountPerTrail: Math.round(trails.maxPointPerTrail) || 32,
|
|
19554
19543
|
blending: trails.blending,
|
|
19555
|
-
texture: trails.texture,
|
|
19544
|
+
texture: trails.texture ? this.engine.findObject(trails.texture) : undefined,
|
|
19556
19545
|
opacityOverLifetime: createValueGetter(trails.opacityOverLifetime || 1),
|
|
19557
19546
|
widthOverTrail: createValueGetter(trails.widthOverTrail || 1),
|
|
19558
19547
|
// order: vfxItem.listIndex + (trails.orderOffset || 0),
|
|
@@ -19591,8 +19580,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
19591
19580
|
var maskRef = 0;
|
|
19592
19581
|
if (data.mask) {
|
|
19593
19582
|
var _data_mask = data.mask, mode = _data_mask.mode, ref = _data_mask.ref;
|
|
19583
|
+
var refComponent = this.engine.findObject(ref);
|
|
19594
19584
|
maskMode = mode;
|
|
19595
|
-
maskRef =
|
|
19585
|
+
maskRef = refComponent.maskManager.getRefValue();
|
|
19596
19586
|
}
|
|
19597
19587
|
return {
|
|
19598
19588
|
maskMode: maskMode,
|
|
@@ -19880,7 +19870,7 @@ var SubCompositionClipPlayable = /*#__PURE__*/ function(Playable) {
|
|
|
19880
19870
|
var _proto = SubCompositionClipPlayable.prototype;
|
|
19881
19871
|
_proto.processFrame = function processFrame(context) {
|
|
19882
19872
|
var boundObject = context.output.getUserData();
|
|
19883
|
-
if (_instanceof1(boundObject, CompositionComponent)) {
|
|
19873
|
+
if (_instanceof1(boundObject, exports.CompositionComponent)) {
|
|
19884
19874
|
boundObject.time = this.getTime();
|
|
19885
19875
|
}
|
|
19886
19876
|
};
|
|
@@ -19895,7 +19885,7 @@ var SubCompositionMixerPlayable = /*#__PURE__*/ function(TrackMixerPlayable) {
|
|
|
19895
19885
|
var _proto = SubCompositionMixerPlayable.prototype;
|
|
19896
19886
|
_proto.evaluate = function evaluate(context) {
|
|
19897
19887
|
var boundObject = context.output.getUserData();
|
|
19898
|
-
if (!_instanceof1(boundObject, CompositionComponent)) {
|
|
19888
|
+
if (!_instanceof1(boundObject, exports.CompositionComponent)) {
|
|
19899
19889
|
return;
|
|
19900
19890
|
}
|
|
19901
19891
|
var compositionComponent = boundObject;
|
|
@@ -20263,7 +20253,7 @@ exports.SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
|
|
|
20263
20253
|
if (!this.parent || !_instanceof1(this.parent.boundObject, exports.VFXItem)) {
|
|
20264
20254
|
throw new Error("SubCompositionTrack needs to be set under the VFXItem track.");
|
|
20265
20255
|
}
|
|
20266
|
-
this.boundObject = this.parent.boundObject.getComponent(CompositionComponent);
|
|
20256
|
+
this.boundObject = this.parent.boundObject.getComponent(exports.CompositionComponent);
|
|
20267
20257
|
};
|
|
20268
20258
|
_proto.createTrackMixer = function createTrackMixer(graph) {
|
|
20269
20259
|
return new SubCompositionMixerPlayable(graph);
|
|
@@ -20680,13 +20670,11 @@ exports.Vector2PropertyPlayableAsset = __decorate([
|
|
|
20680
20670
|
effectsClass(DataType.Vector2PropertyPlayableAsset)
|
|
20681
20671
|
], exports.Vector2PropertyPlayableAsset);
|
|
20682
20672
|
|
|
20683
|
-
|
|
20684
|
-
|
|
20685
|
-
*/ var CompositionComponent = /*#__PURE__*/ function(Behaviour) {
|
|
20686
|
-
_inherits(CompositionComponent, Behaviour);
|
|
20673
|
+
exports.CompositionComponent = /*#__PURE__*/ function(Component) {
|
|
20674
|
+
_inherits(CompositionComponent, Component);
|
|
20687
20675
|
function CompositionComponent() {
|
|
20688
20676
|
var _this;
|
|
20689
|
-
_this =
|
|
20677
|
+
_this = Component.apply(this, arguments) || this;
|
|
20690
20678
|
_this.time = 0;
|
|
20691
20679
|
_this.startTime = 0;
|
|
20692
20680
|
_this.items = [] // 场景的所有元素
|
|
@@ -20862,13 +20850,10 @@ exports.Vector2PropertyPlayableAsset = __decorate([
|
|
|
20862
20850
|
return startOrder;
|
|
20863
20851
|
};
|
|
20864
20852
|
_proto.fromData = function fromData(data) {
|
|
20865
|
-
|
|
20853
|
+
Component.prototype.fromData.call(this, data);
|
|
20866
20854
|
var compositionData = data;
|
|
20867
|
-
this.items = compositionData.items;
|
|
20868
20855
|
var _compositionData_startTime;
|
|
20869
20856
|
this.startTime = (_compositionData_startTime = compositionData.startTime) != null ? _compositionData_startTime : 0;
|
|
20870
|
-
this.sceneBindings = compositionData.sceneBindings;
|
|
20871
|
-
this.timelineAsset = compositionData.timelineAsset;
|
|
20872
20857
|
};
|
|
20873
20858
|
_proto.resolveBindings = function resolveBindings() {
|
|
20874
20859
|
for(var _iterator = _create_for_of_iterator_helper_loose(this.sceneBindings), _step; !(_step = _iterator()).done;){
|
|
@@ -20891,7 +20876,19 @@ exports.Vector2PropertyPlayableAsset = __decorate([
|
|
|
20891
20876
|
}
|
|
20892
20877
|
};
|
|
20893
20878
|
return CompositionComponent;
|
|
20894
|
-
}(
|
|
20879
|
+
}(Component);
|
|
20880
|
+
__decorate([
|
|
20881
|
+
serialize()
|
|
20882
|
+
], exports.CompositionComponent.prototype, "items", void 0);
|
|
20883
|
+
__decorate([
|
|
20884
|
+
serialize()
|
|
20885
|
+
], exports.CompositionComponent.prototype, "sceneBindings", void 0);
|
|
20886
|
+
__decorate([
|
|
20887
|
+
serialize()
|
|
20888
|
+
], exports.CompositionComponent.prototype, "timelineAsset", void 0);
|
|
20889
|
+
exports.CompositionComponent = __decorate([
|
|
20890
|
+
effectsClass("CompositionComponent")
|
|
20891
|
+
], exports.CompositionComponent);
|
|
20895
20892
|
|
|
20896
20893
|
/**
|
|
20897
20894
|
*
|
|
@@ -21083,482 +21080,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
21083
21080
|
// }
|
|
21084
21081
|
(TickData);
|
|
21085
21082
|
|
|
21086
|
-
var SerializationHelper = /*#__PURE__*/ function() {
|
|
21087
|
-
function SerializationHelper() {}
|
|
21088
|
-
SerializationHelper.collectSerializableObject = function collectSerializableObject(effectsObject, res) {
|
|
21089
|
-
if (res[effectsObject.getInstanceId()]) {
|
|
21090
|
-
return;
|
|
21091
|
-
}
|
|
21092
|
-
effectsObject.toData();
|
|
21093
|
-
res[effectsObject.getInstanceId()] = effectsObject;
|
|
21094
|
-
var serializedProperties = getMergedStore(effectsObject);
|
|
21095
|
-
if (serializedProperties) {
|
|
21096
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step; !(_step = _iterator()).done;){
|
|
21097
|
-
var key = _step.value;
|
|
21098
|
-
// TODO 待移除,序列化属性通过 effectsObject 对象直接获取
|
|
21099
|
-
var value = effectsObject.taggedProperties[key];
|
|
21100
|
-
if (value === undefined) {
|
|
21101
|
-
value = effectsObject[key];
|
|
21102
|
-
}
|
|
21103
|
-
if (EffectsObject.is(value)) {
|
|
21104
|
-
SerializationHelper.collectSerializableObject(value, res);
|
|
21105
|
-
} else if (isArray(value)) {
|
|
21106
|
-
for(var _iterator1 = _create_for_of_iterator_helper_loose(value), _step1; !(_step1 = _iterator1()).done;){
|
|
21107
|
-
var arrayValue = _step1.value;
|
|
21108
|
-
if (EffectsObject.is(arrayValue)) {
|
|
21109
|
-
SerializationHelper.collectSerializableObject(arrayValue, res);
|
|
21110
|
-
}
|
|
21111
|
-
}
|
|
21112
|
-
} else if (isObject(value)) {
|
|
21113
|
-
// 非 EffectsObject 对象只递归一层
|
|
21114
|
-
for(var _iterator2 = _create_for_of_iterator_helper_loose(Object.keys(value)), _step2; !(_step2 = _iterator2()).done;){
|
|
21115
|
-
var objectKey = _step2.value;
|
|
21116
|
-
var objectValue = value[objectKey];
|
|
21117
|
-
if (EffectsObject.is(objectValue)) {
|
|
21118
|
-
SerializationHelper.collectSerializableObject(objectValue, res);
|
|
21119
|
-
}
|
|
21120
|
-
}
|
|
21121
|
-
}
|
|
21122
|
-
}
|
|
21123
|
-
}
|
|
21124
|
-
};
|
|
21125
|
-
SerializationHelper.serializeEffectObject = function serializeEffectObject(effectsObject) {
|
|
21126
|
-
// 持有所有需要序列化的引擎对象
|
|
21127
|
-
var serializableMap = {};
|
|
21128
|
-
var engine = effectsObject.engine;
|
|
21129
|
-
// 加入内存中已加载的资产数据,避免重复创建资产数据
|
|
21130
|
-
var serializedDatas = _extends({}, engine.jsonSceneData);
|
|
21131
|
-
// 递归收集所有需要序列化的对象
|
|
21132
|
-
SerializationHelper.collectSerializableObject(effectsObject, serializableMap);
|
|
21133
|
-
// 依次序列化
|
|
21134
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializableMap)), _step; !(_step = _iterator()).done;){
|
|
21135
|
-
var guid = _step.value;
|
|
21136
|
-
var serializeObject = serializableMap[guid];
|
|
21137
|
-
if (!serializedDatas[serializeObject.getInstanceId()]) {
|
|
21138
|
-
serializedDatas[serializeObject.getInstanceId()] = {};
|
|
21139
|
-
}
|
|
21140
|
-
SerializationHelper.serialize(serializeObject, serializedDatas[serializeObject.getInstanceId()]);
|
|
21141
|
-
}
|
|
21142
|
-
return serializedDatas;
|
|
21143
|
-
};
|
|
21144
|
-
SerializationHelper.serialize = function serialize(effectsObject, serializedData) {
|
|
21145
|
-
effectsObject.toData();
|
|
21146
|
-
if (!serializedData) {
|
|
21147
|
-
serializedData = {};
|
|
21148
|
-
}
|
|
21149
|
-
var serializedProperties = getMergedStore(effectsObject);
|
|
21150
|
-
if (serializedProperties) {
|
|
21151
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step; !(_step = _iterator()).done;){
|
|
21152
|
-
var key = _step.value;
|
|
21153
|
-
var value = effectsObject[key];
|
|
21154
|
-
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean" || SerializationHelper.checkTypedArray(value)) {
|
|
21155
|
-
// TODO json 数据避免传 typedArray
|
|
21156
|
-
serializedData[key] = value;
|
|
21157
|
-
} else if (isArray(value)) {
|
|
21158
|
-
if (!serializedData[key]) {
|
|
21159
|
-
serializedData[key] = [];
|
|
21160
|
-
}
|
|
21161
|
-
SerializationHelper.serializeArrayProperty(value, serializedData[key], 0);
|
|
21162
|
-
} else if (EffectsObject.is(value)) {
|
|
21163
|
-
// TODO 处理 EffectsObject 递归序列化
|
|
21164
|
-
serializedData[key] = {
|
|
21165
|
-
id: value.getInstanceId()
|
|
21166
|
-
};
|
|
21167
|
-
} else if (isObject(value)) {
|
|
21168
|
-
if (!serializedData[key]) {
|
|
21169
|
-
serializedData[key] = {};
|
|
21170
|
-
}
|
|
21171
|
-
SerializationHelper.serializeObjectProperty(value, serializedData[key], 0);
|
|
21172
|
-
}
|
|
21173
|
-
}
|
|
21174
|
-
}
|
|
21175
|
-
// TODO 待移除 tagggedProperties 为没有装饰器的临时方案
|
|
21176
|
-
for(var _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(effectsObject.taggedProperties)), _step1; !(_step1 = _iterator1()).done;){
|
|
21177
|
-
var key1 = _step1.value;
|
|
21178
|
-
var value1 = effectsObject.taggedProperties[key1];
|
|
21179
|
-
if (typeof value1 === "number" || typeof value1 === "string" || typeof value1 === "boolean" || SerializationHelper.checkTypedArray(value1)) {
|
|
21180
|
-
// TODO json 数据避免传 typedArray
|
|
21181
|
-
serializedData[key1] = value1;
|
|
21182
|
-
} else if (isArray(value1)) {
|
|
21183
|
-
if (!serializedData[key1]) {
|
|
21184
|
-
serializedData[key1] = [];
|
|
21185
|
-
}
|
|
21186
|
-
SerializationHelper.serializeArrayProperty(value1, serializedData[key1], 0);
|
|
21187
|
-
} else if (EffectsObject.is(value1)) {
|
|
21188
|
-
// TODO 处理 EffectsObject 递归序列化
|
|
21189
|
-
serializedData[key1] = {
|
|
21190
|
-
id: value1.getInstanceId()
|
|
21191
|
-
};
|
|
21192
|
-
} else if (isObject(value1)) {
|
|
21193
|
-
if (!serializedData[key1]) {
|
|
21194
|
-
serializedData[key1] = {};
|
|
21195
|
-
}
|
|
21196
|
-
SerializationHelper.serializeObjectProperty(value1, serializedData[key1], 0);
|
|
21197
|
-
}
|
|
21198
|
-
}
|
|
21199
|
-
return serializedData;
|
|
21200
|
-
};
|
|
21201
|
-
SerializationHelper.deserialize = function deserialize(serializedData, effectsObject) {
|
|
21202
|
-
var taggedProperties = effectsObject.taggedProperties;
|
|
21203
|
-
var serializedProperties = getMergedStore(effectsObject);
|
|
21204
|
-
var engine = effectsObject.engine;
|
|
21205
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedData)), _step; !(_step = _iterator()).done;){
|
|
21206
|
-
var key = _step.value;
|
|
21207
|
-
if (serializedProperties && serializedProperties[key]) {
|
|
21208
|
-
continue;
|
|
21209
|
-
}
|
|
21210
|
-
var value = serializedData[key];
|
|
21211
|
-
taggedProperties[key] = SerializationHelper.deserializeProperty(value, engine, 0);
|
|
21212
|
-
}
|
|
21213
|
-
if (serializedProperties) {
|
|
21214
|
-
for(var _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step1; !(_step1 = _iterator1()).done;){
|
|
21215
|
-
var key1 = _step1.value;
|
|
21216
|
-
var value1 = serializedData[key1];
|
|
21217
|
-
if (value1 === undefined) {
|
|
21218
|
-
continue;
|
|
21219
|
-
}
|
|
21220
|
-
var propertyType = serializedProperties[key1].type;
|
|
21221
|
-
// FIXME: taggedProperties 为 readonly,这里存在强制赋值
|
|
21222
|
-
// @ts-expect-error
|
|
21223
|
-
effectsObject[key1] = SerializationHelper.deserializeProperty(value1, engine, 0, propertyType);
|
|
21224
|
-
}
|
|
21225
|
-
}
|
|
21226
|
-
effectsObject.fromData(taggedProperties);
|
|
21227
|
-
};
|
|
21228
|
-
SerializationHelper.deserializeAsync = function deserializeAsync(serializedData, effectsObject) {
|
|
21229
|
-
return _async_to_generator(function() {
|
|
21230
|
-
var taggedProperties, serializedProperties, engine, _iterator, _step, key, value, _iterator1, _step1, key1, value1, propertyType;
|
|
21231
|
-
return __generator(this, function(_state) {
|
|
21232
|
-
switch(_state.label){
|
|
21233
|
-
case 0:
|
|
21234
|
-
taggedProperties = effectsObject.taggedProperties;
|
|
21235
|
-
serializedProperties = getMergedStore(effectsObject);
|
|
21236
|
-
engine = effectsObject.engine;
|
|
21237
|
-
_iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedData));
|
|
21238
|
-
_state.label = 1;
|
|
21239
|
-
case 1:
|
|
21240
|
-
if (!!(_step = _iterator()).done) return [
|
|
21241
|
-
3,
|
|
21242
|
-
4
|
|
21243
|
-
];
|
|
21244
|
-
key = _step.value;
|
|
21245
|
-
if (serializedProperties && serializedProperties[key]) {
|
|
21246
|
-
return [
|
|
21247
|
-
3,
|
|
21248
|
-
3
|
|
21249
|
-
];
|
|
21250
|
-
}
|
|
21251
|
-
value = serializedData[key];
|
|
21252
|
-
return [
|
|
21253
|
-
4,
|
|
21254
|
-
SerializationHelper.deserializePropertyAsync(value, engine, 0)
|
|
21255
|
-
];
|
|
21256
|
-
case 2:
|
|
21257
|
-
taggedProperties[key] = _state.sent();
|
|
21258
|
-
_state.label = 3;
|
|
21259
|
-
case 3:
|
|
21260
|
-
return [
|
|
21261
|
-
3,
|
|
21262
|
-
1
|
|
21263
|
-
];
|
|
21264
|
-
case 4:
|
|
21265
|
-
if (!serializedProperties) return [
|
|
21266
|
-
3,
|
|
21267
|
-
8
|
|
21268
|
-
];
|
|
21269
|
-
_iterator1 = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties));
|
|
21270
|
-
_state.label = 5;
|
|
21271
|
-
case 5:
|
|
21272
|
-
if (!!(_step1 = _iterator1()).done) return [
|
|
21273
|
-
3,
|
|
21274
|
-
8
|
|
21275
|
-
];
|
|
21276
|
-
key1 = _step1.value;
|
|
21277
|
-
value1 = serializedData[key1];
|
|
21278
|
-
if (value1 === undefined) {
|
|
21279
|
-
return [
|
|
21280
|
-
3,
|
|
21281
|
-
7
|
|
21282
|
-
];
|
|
21283
|
-
}
|
|
21284
|
-
propertyType = serializedProperties[key1].type;
|
|
21285
|
-
return [
|
|
21286
|
-
4,
|
|
21287
|
-
SerializationHelper.deserializePropertyAsync(value1, engine, 0, propertyType)
|
|
21288
|
-
];
|
|
21289
|
-
case 6:
|
|
21290
|
-
// FIXME: taggedProperties 为 readonly,这里存在强制赋值
|
|
21291
|
-
// @ts-expect-error
|
|
21292
|
-
effectsObject[key1] = _state.sent();
|
|
21293
|
-
_state.label = 7;
|
|
21294
|
-
case 7:
|
|
21295
|
-
return [
|
|
21296
|
-
3,
|
|
21297
|
-
5
|
|
21298
|
-
];
|
|
21299
|
-
case 8:
|
|
21300
|
-
effectsObject.fromData(taggedProperties);
|
|
21301
|
-
return [
|
|
21302
|
-
2
|
|
21303
|
-
];
|
|
21304
|
-
}
|
|
21305
|
-
});
|
|
21306
|
-
})();
|
|
21307
|
-
};
|
|
21308
|
-
SerializationHelper.checkTypedArray = function checkTypedArray(obj) {
|
|
21309
|
-
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);
|
|
21310
|
-
};
|
|
21311
|
-
// check value is { id: 7e69662e964e4892ae8933f24562395b }
|
|
21312
|
-
SerializationHelper.checkDataPath = function checkDataPath(value) {
|
|
21313
|
-
return !!(isObject(value) && Object.keys(value).length === 1 && "id" in value && isString(value.id) && value.id.length === 32);
|
|
21314
|
-
};
|
|
21315
|
-
// TODO 测试函数,2.0 上线后移除
|
|
21316
|
-
SerializationHelper.checkGLTFNode = function checkGLTFNode(value) {
|
|
21317
|
-
return isObject(value) && value.nodeIndex !== undefined && value.isJoint !== undefined;
|
|
21318
|
-
};
|
|
21319
|
-
SerializationHelper.checkImageSource = function checkImageSource(value) {
|
|
21320
|
-
return isCanvas(value) || _instanceof1(value, HTMLImageElement);
|
|
21321
|
-
};
|
|
21322
|
-
SerializationHelper.deserializeProperty = function deserializeProperty(property, engine, level, type) {
|
|
21323
|
-
if (level > 14) {
|
|
21324
|
-
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
21325
|
-
return;
|
|
21326
|
-
}
|
|
21327
|
-
// 加载并链接 DataPath 字段表示的 EffectsObject 引用。Class 对象 copy [key, value] 会丢失对象信息,因此只递归数组对象和普通 js Object 结构对象。
|
|
21328
|
-
if (isArray(property)) {
|
|
21329
|
-
var res = [];
|
|
21330
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(property), _step; !(_step = _iterator()).done;){
|
|
21331
|
-
var value = _step.value;
|
|
21332
|
-
res.push(SerializationHelper.deserializeProperty(value, engine, level + 1, type));
|
|
21333
|
-
}
|
|
21334
|
-
return res;
|
|
21335
|
-
// TODO json 数据避免传 typedArray
|
|
21336
|
-
} else if (SerializationHelper.checkDataPath(property)) {
|
|
21337
|
-
return engine.assetLoader.loadGUID(property.id);
|
|
21338
|
-
} else if (isObject(property) && property.constructor === Object) {
|
|
21339
|
-
var res1;
|
|
21340
|
-
if (type) {
|
|
21341
|
-
res1 = new type();
|
|
21342
|
-
} else {
|
|
21343
|
-
res1 = {};
|
|
21344
|
-
}
|
|
21345
|
-
for(var _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(property)), _step1; !(_step1 = _iterator1()).done;){
|
|
21346
|
-
var key = _step1.value;
|
|
21347
|
-
res1[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
|
|
21348
|
-
}
|
|
21349
|
-
return res1;
|
|
21350
|
-
} else {
|
|
21351
|
-
return property;
|
|
21352
|
-
}
|
|
21353
|
-
};
|
|
21354
|
-
SerializationHelper.deserializePropertyAsync = function deserializePropertyAsync(property, engine, level, type) {
|
|
21355
|
-
return _async_to_generator(function() {
|
|
21356
|
-
var res, _iterator, _step, value, _, res1, res2, _iterator1, _step1, key;
|
|
21357
|
-
return __generator(this, function(_state) {
|
|
21358
|
-
switch(_state.label){
|
|
21359
|
-
case 0:
|
|
21360
|
-
if (level > 14) {
|
|
21361
|
-
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
21362
|
-
return [
|
|
21363
|
-
2
|
|
21364
|
-
];
|
|
21365
|
-
}
|
|
21366
|
-
if (!isArray(property)) return [
|
|
21367
|
-
3,
|
|
21368
|
-
5
|
|
21369
|
-
];
|
|
21370
|
-
res = [];
|
|
21371
|
-
_iterator = _create_for_of_iterator_helper_loose(property);
|
|
21372
|
-
_state.label = 1;
|
|
21373
|
-
case 1:
|
|
21374
|
-
if (!!(_step = _iterator()).done) return [
|
|
21375
|
-
3,
|
|
21376
|
-
4
|
|
21377
|
-
];
|
|
21378
|
-
value = _step.value;
|
|
21379
|
-
_ = res.push;
|
|
21380
|
-
return [
|
|
21381
|
-
4,
|
|
21382
|
-
SerializationHelper.deserializePropertyAsync(value, engine, level + 1, type)
|
|
21383
|
-
];
|
|
21384
|
-
case 2:
|
|
21385
|
-
_.apply(res, [
|
|
21386
|
-
_state.sent()
|
|
21387
|
-
]);
|
|
21388
|
-
_state.label = 3;
|
|
21389
|
-
case 3:
|
|
21390
|
-
return [
|
|
21391
|
-
3,
|
|
21392
|
-
1
|
|
21393
|
-
];
|
|
21394
|
-
case 4:
|
|
21395
|
-
return [
|
|
21396
|
-
2,
|
|
21397
|
-
res
|
|
21398
|
-
];
|
|
21399
|
-
case 5:
|
|
21400
|
-
if (!SerializationHelper.checkDataPath(property)) return [
|
|
21401
|
-
3,
|
|
21402
|
-
7
|
|
21403
|
-
];
|
|
21404
|
-
return [
|
|
21405
|
-
4,
|
|
21406
|
-
engine.assetLoader.loadGUIDAsync(property.id)
|
|
21407
|
-
];
|
|
21408
|
-
case 6:
|
|
21409
|
-
res1 = _state.sent();
|
|
21410
|
-
return [
|
|
21411
|
-
2,
|
|
21412
|
-
res1
|
|
21413
|
-
];
|
|
21414
|
-
case 7:
|
|
21415
|
-
if (!(isObject(property) && property.constructor === Object)) return [
|
|
21416
|
-
3,
|
|
21417
|
-
12
|
|
21418
|
-
];
|
|
21419
|
-
if (type) {
|
|
21420
|
-
res2 = new type();
|
|
21421
|
-
} else {
|
|
21422
|
-
res2 = {};
|
|
21423
|
-
}
|
|
21424
|
-
_iterator1 = _create_for_of_iterator_helper_loose(Object.keys(property));
|
|
21425
|
-
_state.label = 8;
|
|
21426
|
-
case 8:
|
|
21427
|
-
if (!!(_step1 = _iterator1()).done) return [
|
|
21428
|
-
3,
|
|
21429
|
-
11
|
|
21430
|
-
];
|
|
21431
|
-
key = _step1.value;
|
|
21432
|
-
return [
|
|
21433
|
-
4,
|
|
21434
|
-
SerializationHelper.deserializePropertyAsync(property[key], engine, level + 1)
|
|
21435
|
-
];
|
|
21436
|
-
case 9:
|
|
21437
|
-
res2[key] = _state.sent();
|
|
21438
|
-
_state.label = 10;
|
|
21439
|
-
case 10:
|
|
21440
|
-
return [
|
|
21441
|
-
3,
|
|
21442
|
-
8
|
|
21443
|
-
];
|
|
21444
|
-
case 11:
|
|
21445
|
-
return [
|
|
21446
|
-
2,
|
|
21447
|
-
res2
|
|
21448
|
-
];
|
|
21449
|
-
case 12:
|
|
21450
|
-
return [
|
|
21451
|
-
2,
|
|
21452
|
-
property
|
|
21453
|
-
];
|
|
21454
|
-
case 13:
|
|
21455
|
-
return [
|
|
21456
|
-
2
|
|
21457
|
-
];
|
|
21458
|
-
}
|
|
21459
|
-
});
|
|
21460
|
-
})();
|
|
21461
|
-
};
|
|
21462
|
-
SerializationHelper.serializeObjectProperty = function serializeObjectProperty(objectProperty, serializedData, level) {
|
|
21463
|
-
if (level > 14) {
|
|
21464
|
-
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
21465
|
-
return;
|
|
21466
|
-
}
|
|
21467
|
-
if (!serializedData) {
|
|
21468
|
-
serializedData = {};
|
|
21469
|
-
}
|
|
21470
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(objectProperty)), _step; !(_step = _iterator()).done;){
|
|
21471
|
-
var key = _step.value;
|
|
21472
|
-
var value = objectProperty[key];
|
|
21473
|
-
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean" || SerializationHelper.checkTypedArray(objectProperty)) {
|
|
21474
|
-
// TODO json 数据避免传 typedArray
|
|
21475
|
-
serializedData[key] = value;
|
|
21476
|
-
} else if (isArray(value)) {
|
|
21477
|
-
if (!serializedData[key]) {
|
|
21478
|
-
serializedData[key] = [];
|
|
21479
|
-
}
|
|
21480
|
-
SerializationHelper.serializeArrayProperty(value, serializedData[key], level + 1);
|
|
21481
|
-
} else if (EffectsObject.is(value)) {
|
|
21482
|
-
// TODO 处理 EffectsObject 递归序列化
|
|
21483
|
-
serializedData[key] = {
|
|
21484
|
-
id: value.getInstanceId()
|
|
21485
|
-
};
|
|
21486
|
-
} else if (isObject(value)) {
|
|
21487
|
-
if (!serializedData[key]) {
|
|
21488
|
-
serializedData[key] = {};
|
|
21489
|
-
}
|
|
21490
|
-
SerializationHelper.serializeObjectProperty(value, serializedData[key], level + 1);
|
|
21491
|
-
}
|
|
21492
|
-
}
|
|
21493
|
-
};
|
|
21494
|
-
SerializationHelper.serializeArrayProperty = function serializeArrayProperty(arrayProperty, serializedData, level) {
|
|
21495
|
-
if (level > 14) {
|
|
21496
|
-
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
21497
|
-
return;
|
|
21498
|
-
}
|
|
21499
|
-
if (!serializedData) {
|
|
21500
|
-
serializedData = [];
|
|
21501
|
-
}
|
|
21502
|
-
for(var i = 0; i < arrayProperty.length; i++){
|
|
21503
|
-
var value = arrayProperty[i];
|
|
21504
|
-
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean" || SerializationHelper.checkTypedArray(arrayProperty)) {
|
|
21505
|
-
// TODO json 数据避免传 typedArray
|
|
21506
|
-
serializedData[i] = value;
|
|
21507
|
-
} else if (isArray(value)) {
|
|
21508
|
-
if (!serializedData[i]) {
|
|
21509
|
-
serializedData[i] = [];
|
|
21510
|
-
}
|
|
21511
|
-
SerializationHelper.serializeArrayProperty(value, serializedData[i], level + 1);
|
|
21512
|
-
} else if (EffectsObject.is(value)) {
|
|
21513
|
-
// TODO 处理 EffectsObject 递归序列化
|
|
21514
|
-
serializedData[i] = {
|
|
21515
|
-
id: value.getInstanceId()
|
|
21516
|
-
};
|
|
21517
|
-
} else if (isObject(value)) {
|
|
21518
|
-
if (!serializedData[i]) {
|
|
21519
|
-
serializedData[i] = {};
|
|
21520
|
-
}
|
|
21521
|
-
SerializationHelper.serializeObjectProperty(value, serializedData[i], level + 1);
|
|
21522
|
-
}
|
|
21523
|
-
}
|
|
21524
|
-
};
|
|
21525
|
-
return SerializationHelper;
|
|
21526
|
-
}();
|
|
21527
|
-
|
|
21528
|
-
var _obj$2;
|
|
21529
|
-
/**
|
|
21530
|
-
* 机型和渲染等级对应表
|
|
21531
|
-
*
|
|
21532
|
-
* 机型:B-低端机、A-中端机、S-高端机
|
|
21533
|
-
* 渲染等级:B-低、A-中、S-高、A+-中高、B+-全部
|
|
21534
|
-
*
|
|
21535
|
-
* - S(高端机):高、全部、中高
|
|
21536
|
-
* - A(中端机):中、全部、中高
|
|
21537
|
-
* - B(低端机):低、全部
|
|
21538
|
-
* - undefined(全部机型)
|
|
21539
|
-
*/ var renderLevelPassSet = (_obj$2 = {}, _obj$2[RenderLevel.S] = [
|
|
21540
|
-
RenderLevel.S,
|
|
21541
|
-
RenderLevel.BPlus,
|
|
21542
|
-
RenderLevel.APlus
|
|
21543
|
-
], _obj$2[RenderLevel.A] = [
|
|
21544
|
-
RenderLevel.A,
|
|
21545
|
-
RenderLevel.BPlus,
|
|
21546
|
-
RenderLevel.APlus
|
|
21547
|
-
], _obj$2[RenderLevel.B] = [
|
|
21548
|
-
RenderLevel.B,
|
|
21549
|
-
RenderLevel.BPlus
|
|
21550
|
-
], _obj$2);
|
|
21551
|
-
function passRenderLevel(l, renderLevel) {
|
|
21552
|
-
if (!l || !renderLevel) {
|
|
21553
|
-
return true;
|
|
21554
|
-
}
|
|
21555
|
-
var arr = renderLevelPassSet[renderLevel];
|
|
21556
|
-
if (arr) {
|
|
21557
|
-
return arr.includes(l);
|
|
21558
|
-
}
|
|
21559
|
-
return false;
|
|
21560
|
-
}
|
|
21561
|
-
|
|
21562
21083
|
/**
|
|
21563
21084
|
* 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
|
|
21564
21085
|
* 合成中包含了相关的 Item 元素,支持对 Item 元素的创建、更新和销毁。
|
|
@@ -21624,10 +21145,16 @@ function passRenderLevel(l, renderLevel) {
|
|
|
21624
21145
|
_this.rootItem.duration = sourceContent.duration;
|
|
21625
21146
|
_this.rootItem.endBehavior = sourceContent.endBehavior;
|
|
21626
21147
|
_this.rootItem.composition = _assert_this_initialized(_this);
|
|
21627
|
-
// Create
|
|
21628
|
-
|
|
21629
|
-
|
|
21630
|
-
|
|
21148
|
+
// Create rootItem components
|
|
21149
|
+
//@ts-expect-error TODO update spec.
|
|
21150
|
+
var componentPaths = sourceContent.components;
|
|
21151
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(componentPaths), _step1; !(_step1 = _iterator1()).done;){
|
|
21152
|
+
var componentPath = _step1.value;
|
|
21153
|
+
var component = _this.getEngine().findObject(componentPath);
|
|
21154
|
+
_this.rootItem.components.push(component);
|
|
21155
|
+
component.item = _this.rootItem;
|
|
21156
|
+
}
|
|
21157
|
+
_this.rootComposition = _this.rootItem.getComponent(exports.CompositionComponent);
|
|
21631
21158
|
_this.width = width;
|
|
21632
21159
|
_this.height = height;
|
|
21633
21160
|
_this.renderOrder = baseRenderOrder;
|
|
@@ -21655,7 +21182,7 @@ function passRenderLevel(l, renderLevel) {
|
|
|
21655
21182
|
_this.handleItemMessage = handleItemMessage;
|
|
21656
21183
|
_this.createRenderFrame();
|
|
21657
21184
|
_this.rendererOptions = null;
|
|
21658
|
-
|
|
21185
|
+
Composition.buildItemTree(_this.rootItem);
|
|
21659
21186
|
_this.rootComposition.setChildrenRenderOrder(0);
|
|
21660
21187
|
_this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
|
|
21661
21188
|
return _this;
|
|
@@ -21873,38 +21400,6 @@ function passRenderLevel(l, renderLevel) {
|
|
|
21873
21400
|
}
|
|
21874
21401
|
};
|
|
21875
21402
|
/**
|
|
21876
|
-
* 构建父子树,同时保存到 itemCacheMap 中便于查找
|
|
21877
|
-
*/ _proto.buildItemTree = function buildItemTree(compVFXItem) {
|
|
21878
|
-
if (!compVFXItem.composition) {
|
|
21879
|
-
return;
|
|
21880
|
-
}
|
|
21881
|
-
var itemMap = new Map();
|
|
21882
|
-
var contentItems = compVFXItem.getComponent(CompositionComponent).items;
|
|
21883
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(contentItems), _step; !(_step = _iterator()).done;){
|
|
21884
|
-
var item = _step.value;
|
|
21885
|
-
itemMap.set(item.id, item);
|
|
21886
|
-
}
|
|
21887
|
-
for(var _iterator1 = _create_for_of_iterator_helper_loose(contentItems), _step1; !(_step1 = _iterator1()).done;){
|
|
21888
|
-
var item1 = _step1.value;
|
|
21889
|
-
if (item1.parentId === undefined) {
|
|
21890
|
-
item1.setParent(compVFXItem);
|
|
21891
|
-
} else {
|
|
21892
|
-
var parent = itemMap.get(item1.parentId);
|
|
21893
|
-
if (parent) {
|
|
21894
|
-
item1.setParent(parent);
|
|
21895
|
-
} else {
|
|
21896
|
-
throw new Error("The element references a non-existent element, please check the data.");
|
|
21897
|
-
}
|
|
21898
|
-
}
|
|
21899
|
-
}
|
|
21900
|
-
for(var _iterator2 = _create_for_of_iterator_helper_loose(contentItems), _step2; !(_step2 = _iterator2()).done;){
|
|
21901
|
-
var item2 = _step2.value;
|
|
21902
|
-
if (exports.VFXItem.isComposition(item2)) {
|
|
21903
|
-
this.buildItemTree(item2);
|
|
21904
|
-
}
|
|
21905
|
-
}
|
|
21906
|
-
};
|
|
21907
|
-
/**
|
|
21908
21403
|
* 更新视频数据到纹理
|
|
21909
21404
|
* @override
|
|
21910
21405
|
*/ _proto.updateVideo = function updateVideo() {
|
|
@@ -22015,7 +21510,7 @@ function passRenderLevel(l, renderLevel) {
|
|
|
22015
21510
|
var ray = this.getHitTestRay(x, y);
|
|
22016
21511
|
this.refContent.forEach(function(ref) {
|
|
22017
21512
|
var _ref_getComponent;
|
|
22018
|
-
(_ref_getComponent = ref.getComponent(CompositionComponent)) == null ? void 0 : _ref_getComponent.hitTest(ray, x, y, regions, force, options);
|
|
21513
|
+
(_ref_getComponent = ref.getComponent(exports.CompositionComponent)) == null ? void 0 : _ref_getComponent.hitTest(ray, x, y, regions, force, options);
|
|
22019
21514
|
});
|
|
22020
21515
|
return regions;
|
|
22021
21516
|
};
|
|
@@ -22068,7 +21563,7 @@ function passRenderLevel(l, renderLevel) {
|
|
|
22068
21563
|
// 预合成元素销毁时销毁其中的item
|
|
22069
21564
|
if (item.type == ItemType.composition) {
|
|
22070
21565
|
if (item.endBehavior !== EndBehavior.freeze) {
|
|
22071
|
-
var contentItems = item.getComponent(CompositionComponent).items;
|
|
21566
|
+
var contentItems = item.getComponent(exports.CompositionComponent).items;
|
|
22072
21567
|
contentItems.forEach(function(it) {
|
|
22073
21568
|
return _this.pluginSystem.plugins.forEach(function(loader) {
|
|
22074
21569
|
return loader.onCompositionItemRemoved(_this, it);
|
|
@@ -22263,6 +21758,30 @@ function passRenderLevel(l, renderLevel) {
|
|
|
22263
21758
|
});
|
|
22264
21759
|
})();
|
|
22265
21760
|
};
|
|
21761
|
+
/**
|
|
21762
|
+
* @internal
|
|
21763
|
+
* 构建父子树,同时保存到 itemCacheMap 中便于查找
|
|
21764
|
+
*/ Composition.buildItemTree = function buildItemTree(compVFXItem) {
|
|
21765
|
+
var itemMap = new Map();
|
|
21766
|
+
var contentItems = compVFXItem.getComponent(exports.CompositionComponent).items;
|
|
21767
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(contentItems), _step; !(_step = _iterator()).done;){
|
|
21768
|
+
var item = _step.value;
|
|
21769
|
+
itemMap.set(item.id, item);
|
|
21770
|
+
}
|
|
21771
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(contentItems), _step1; !(_step1 = _iterator1()).done;){
|
|
21772
|
+
var item1 = _step1.value;
|
|
21773
|
+
if (item1.parentId === undefined) {
|
|
21774
|
+
item1.setParent(compVFXItem);
|
|
21775
|
+
} else {
|
|
21776
|
+
var parent = itemMap.get(item1.parentId);
|
|
21777
|
+
if (parent) {
|
|
21778
|
+
item1.setParent(parent);
|
|
21779
|
+
} else {
|
|
21780
|
+
throw new Error("The element references a non-existent element, please check the data.");
|
|
21781
|
+
}
|
|
21782
|
+
}
|
|
21783
|
+
}
|
|
21784
|
+
};
|
|
22266
21785
|
_create_class(Composition, [
|
|
22267
21786
|
{
|
|
22268
21787
|
key: "transform",
|
|
@@ -22324,25 +21843,6 @@ function passRenderLevel(l, renderLevel) {
|
|
|
22324
21843
|
]);
|
|
22325
21844
|
return Composition;
|
|
22326
21845
|
}(EventEmitter);
|
|
22327
|
-
function filterItemsByRenderLevel(composition, engine, renderLevel) {
|
|
22328
|
-
var items = [];
|
|
22329
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(composition.items), _step; !(_step = _iterator()).done;){
|
|
22330
|
-
var itemDataPath = _step.value;
|
|
22331
|
-
var itemProps = engine.findEffectsObjectData(itemDataPath.id);
|
|
22332
|
-
if (passRenderLevel(itemProps.renderLevel, renderLevel)) {
|
|
22333
|
-
items.push(itemDataPath);
|
|
22334
|
-
} else {
|
|
22335
|
-
// 非预合成元素未达到渲染等级的转化为空节点。
|
|
22336
|
-
// 预合成元素有根据 item type 的子元素加载判断,没法保留空节点,这边先整体过滤掉。
|
|
22337
|
-
if (itemProps.type !== ItemType.composition) {
|
|
22338
|
-
itemProps.components = [];
|
|
22339
|
-
items.push(itemDataPath);
|
|
22340
|
-
}
|
|
22341
|
-
}
|
|
22342
|
-
}
|
|
22343
|
-
composition.items = items;
|
|
22344
|
-
return composition;
|
|
22345
|
-
}
|
|
22346
21846
|
|
|
22347
21847
|
exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
22348
21848
|
_inherits(VFXItem, EffectsObject);
|
|
@@ -22355,7 +21855,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22355
21855
|
*/ _this.transform = new Transform();
|
|
22356
21856
|
/**
|
|
22357
21857
|
* 元素动画的当前时间
|
|
22358
|
-
*/ _this.time =
|
|
21858
|
+
*/ _this.time = -1;
|
|
22359
21859
|
/**
|
|
22360
21860
|
* 元素动画的持续时间
|
|
22361
21861
|
*/ _this.duration = 0;
|
|
@@ -22366,9 +21866,8 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22366
21866
|
* 元素动画结束时行为(如何处理元素)
|
|
22367
21867
|
*/ _this.endBehavior = EndBehavior.forward;
|
|
22368
21868
|
_this.type = ItemType.base;
|
|
22369
|
-
_this.isDuringPlay = false;
|
|
22370
21869
|
_this.components = [];
|
|
22371
|
-
_this.
|
|
21870
|
+
_this.isDuringPlay = false;
|
|
22372
21871
|
/**
|
|
22373
21872
|
* 元素是否激活
|
|
22374
21873
|
*/ _this.active = true;
|
|
@@ -22636,6 +22135,25 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22636
22135
|
return undefined;
|
|
22637
22136
|
};
|
|
22638
22137
|
/**
|
|
22138
|
+
* 复制 VFXItem,返回一个新的 VFXItem
|
|
22139
|
+
* @since 2.4.0
|
|
22140
|
+
* @returns 复制的新 VFXItem
|
|
22141
|
+
*/ _proto.duplicate = function duplicate() {
|
|
22142
|
+
var previousObjectIDMap = new Map();
|
|
22143
|
+
this.gatherPreviousObjectID(previousObjectIDMap);
|
|
22144
|
+
// 重新设置当前元素和组件的 ID 以及子元素和子元素组件的 ID,避免实例化新的对象时产生碰撞
|
|
22145
|
+
this.resetGUID();
|
|
22146
|
+
var newItem = this.engine.findObject({
|
|
22147
|
+
id: this.defination.id
|
|
22148
|
+
});
|
|
22149
|
+
newItem.resetGUID();
|
|
22150
|
+
this.resetGUID(previousObjectIDMap);
|
|
22151
|
+
if (this.composition) {
|
|
22152
|
+
newItem.setParent(this.composition.rootItem);
|
|
22153
|
+
}
|
|
22154
|
+
return newItem;
|
|
22155
|
+
};
|
|
22156
|
+
/**
|
|
22639
22157
|
* @internal
|
|
22640
22158
|
*/ _proto.beginPlay = function beginPlay() {
|
|
22641
22159
|
this.isDuringPlay = true;
|
|
@@ -22730,19 +22248,18 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22730
22248
|
if (duration < 0) {
|
|
22731
22249
|
throw new Error("Item duration can't be less than 0, see " + HELP_LINK["Item duration can't be less than 0"] + ".");
|
|
22732
22250
|
}
|
|
22733
|
-
|
|
22734
|
-
|
|
22735
|
-
var
|
|
22736
|
-
|
|
22737
|
-
|
|
22738
|
-
this.
|
|
22739
|
-
|
|
22740
|
-
|
|
22741
|
-
|
|
22742
|
-
|
|
22743
|
-
|
|
22251
|
+
if (data.components) {
|
|
22252
|
+
this.components.length = 0;
|
|
22253
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(data.components), _step; !(_step = _iterator()).done;){
|
|
22254
|
+
var componentPath = _step.value;
|
|
22255
|
+
var component = this.engine.findObject(componentPath);
|
|
22256
|
+
this.components.push(component);
|
|
22257
|
+
// TODO ParticleSystemRenderer 现在是动态生成的,后面需要在 json 中单独表示为一个组件
|
|
22258
|
+
if (_instanceof1(component, exports.ParticleSystem)) {
|
|
22259
|
+
if (!this.components.includes(component.renderer)) {
|
|
22260
|
+
this.components.push(component.renderer);
|
|
22261
|
+
}
|
|
22744
22262
|
}
|
|
22745
|
-
this.rendererComponents.push(component.renderer);
|
|
22746
22263
|
}
|
|
22747
22264
|
}
|
|
22748
22265
|
if (VFXItem.isComposition(this)) {
|
|
@@ -22751,24 +22268,24 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22751
22268
|
};
|
|
22752
22269
|
_proto.toData = function toData() {
|
|
22753
22270
|
var _this_parent;
|
|
22754
|
-
this.
|
|
22755
|
-
this.
|
|
22756
|
-
this.
|
|
22271
|
+
this.defination.id = this.guid;
|
|
22272
|
+
this.defination.transform = this.transform.toData();
|
|
22273
|
+
this.defination.dataType = DataType.VFXItemData;
|
|
22757
22274
|
if (((_this_parent = this.parent) == null ? void 0 : _this_parent.name) !== "rootItem") {
|
|
22758
22275
|
var _this_parent1;
|
|
22759
|
-
this.
|
|
22276
|
+
this.defination.parentId = (_this_parent1 = this.parent) == null ? void 0 : _this_parent1.guid;
|
|
22760
22277
|
}
|
|
22761
22278
|
// TODO 统一 sprite 等其他组件的序列化逻辑
|
|
22762
|
-
if (!this.
|
|
22763
|
-
this.
|
|
22279
|
+
if (!this.defination.components) {
|
|
22280
|
+
this.defination.components = [];
|
|
22764
22281
|
for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
|
|
22765
22282
|
var component = _step.value;
|
|
22766
22283
|
if (_instanceof1(component, exports.EffectComponent)) {
|
|
22767
|
-
this.
|
|
22284
|
+
this.defination.components.push(component);
|
|
22768
22285
|
}
|
|
22769
22286
|
}
|
|
22770
22287
|
}
|
|
22771
|
-
this.
|
|
22288
|
+
this.defination.content = {};
|
|
22772
22289
|
};
|
|
22773
22290
|
_proto.translateByPixel = function translateByPixel(x, y) {
|
|
22774
22291
|
if (this.composition) {
|
|
@@ -22825,17 +22342,52 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22825
22342
|
if (!props) {
|
|
22826
22343
|
throw new Error("Referenced precomposition with Id: " + refId + " does not exist.");
|
|
22827
22344
|
}
|
|
22828
|
-
|
|
22829
|
-
|
|
22830
|
-
|
|
22831
|
-
|
|
22832
|
-
var
|
|
22833
|
-
|
|
22834
|
-
|
|
22835
|
-
|
|
22836
|
-
|
|
22345
|
+
//@ts-expect-error TODO update spec.
|
|
22346
|
+
var componentPaths = props.components;
|
|
22347
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(componentPaths), _step; !(_step = _iterator()).done;){
|
|
22348
|
+
var componentPath = _step.value;
|
|
22349
|
+
var component = this.engine.findObject(componentPath);
|
|
22350
|
+
component.item = this;
|
|
22351
|
+
this.components.push(component);
|
|
22352
|
+
component.setInstanceId(generateGUID());
|
|
22353
|
+
if (_instanceof1(component, exports.CompositionComponent)) {
|
|
22354
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(component.items), _step1; !(_step1 = _iterator1()).done;){
|
|
22355
|
+
var vfxItem = _step1.value;
|
|
22356
|
+
vfxItem.setInstanceId(generateGUID());
|
|
22357
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(vfxItem.components), _step2; !(_step2 = _iterator2()).done;){
|
|
22358
|
+
var component1 = _step2.value;
|
|
22359
|
+
component1.setInstanceId(generateGUID());
|
|
22360
|
+
}
|
|
22361
|
+
}
|
|
22837
22362
|
}
|
|
22838
22363
|
}
|
|
22364
|
+
Composition.buildItemTree(this);
|
|
22365
|
+
};
|
|
22366
|
+
_proto.resetGUID = function resetGUID(previousObjectIDMap) {
|
|
22367
|
+
var _previousObjectIDMap_get;
|
|
22368
|
+
var itemGUID = (_previousObjectIDMap_get = previousObjectIDMap == null ? void 0 : previousObjectIDMap.get(this)) != null ? _previousObjectIDMap_get : generateGUID();
|
|
22369
|
+
this.setInstanceId(itemGUID);
|
|
22370
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
|
|
22371
|
+
var component = _step.value;
|
|
22372
|
+
var _previousObjectIDMap_get1;
|
|
22373
|
+
var componentGUID = (_previousObjectIDMap_get1 = previousObjectIDMap == null ? void 0 : previousObjectIDMap.get(component)) != null ? _previousObjectIDMap_get1 : generateGUID();
|
|
22374
|
+
component.setInstanceId(componentGUID);
|
|
22375
|
+
}
|
|
22376
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(this.children), _step1; !(_step1 = _iterator1()).done;){
|
|
22377
|
+
var child = _step1.value;
|
|
22378
|
+
child.resetGUID(previousObjectIDMap);
|
|
22379
|
+
}
|
|
22380
|
+
};
|
|
22381
|
+
_proto.gatherPreviousObjectID = function gatherPreviousObjectID(previousObjectIDMap) {
|
|
22382
|
+
previousObjectIDMap.set(this, this.getInstanceId());
|
|
22383
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
|
|
22384
|
+
var component = _step.value;
|
|
22385
|
+
previousObjectIDMap.set(component, component.getInstanceId());
|
|
22386
|
+
}
|
|
22387
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(this.children), _step1; !(_step1 = _iterator1()).done;){
|
|
22388
|
+
var child = _step1.value;
|
|
22389
|
+
child.gatherPreviousObjectID(previousObjectIDMap);
|
|
22390
|
+
}
|
|
22839
22391
|
};
|
|
22840
22392
|
/**
|
|
22841
22393
|
*
|
|
@@ -22942,9 +22494,11 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22942
22494
|
set: function set(value) {
|
|
22943
22495
|
if (this.listIndex !== value) {
|
|
22944
22496
|
this.listIndex = value;
|
|
22945
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.
|
|
22946
|
-
var
|
|
22947
|
-
|
|
22497
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
|
|
22498
|
+
var component = _step.value;
|
|
22499
|
+
if (_instanceof1(component, RendererComponent)) {
|
|
22500
|
+
component.priority = value;
|
|
22501
|
+
}
|
|
22948
22502
|
}
|
|
22949
22503
|
}
|
|
22950
22504
|
}
|
|
@@ -22968,9 +22522,6 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
22968
22522
|
]);
|
|
22969
22523
|
return VFXItem;
|
|
22970
22524
|
}(EffectsObject);
|
|
22971
|
-
__decorate([
|
|
22972
|
-
serialize()
|
|
22973
|
-
], exports.VFXItem.prototype, "components", void 0);
|
|
22974
22525
|
exports.VFXItem = __decorate([
|
|
22975
22526
|
effectsClass(DataType.VFXItemData)
|
|
22976
22527
|
], exports.VFXItem);
|
|
@@ -27035,8 +26586,6 @@ exports.BinaryAsset = /*#__PURE__*/ function(EffectsObject) {
|
|
|
27035
26586
|
function BinaryAsset() {
|
|
27036
26587
|
return EffectsObject.apply(this, arguments);
|
|
27037
26588
|
}
|
|
27038
|
-
var _proto = BinaryAsset.prototype;
|
|
27039
|
-
_proto.fromData = function fromData(data) {};
|
|
27040
26589
|
return BinaryAsset;
|
|
27041
26590
|
}(EffectsObject);
|
|
27042
26591
|
__decorate([
|
|
@@ -27046,6 +26595,197 @@ exports.BinaryAsset = __decorate([
|
|
|
27046
26595
|
effectsClass(DataType.BinaryAsset)
|
|
27047
26596
|
], exports.BinaryAsset);
|
|
27048
26597
|
|
|
26598
|
+
var SerializationHelper = /*#__PURE__*/ function() {
|
|
26599
|
+
function SerializationHelper() {}
|
|
26600
|
+
SerializationHelper.serialize = function serialize(effectsObject, serializedData) {
|
|
26601
|
+
effectsObject.toData();
|
|
26602
|
+
if (!serializedData) {
|
|
26603
|
+
serializedData = {};
|
|
26604
|
+
}
|
|
26605
|
+
var serializedProperties = getMergedStore(effectsObject);
|
|
26606
|
+
if (serializedProperties) {
|
|
26607
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step; !(_step = _iterator()).done;){
|
|
26608
|
+
var key = _step.value;
|
|
26609
|
+
var value = effectsObject[key];
|
|
26610
|
+
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean" || SerializationHelper.checkTypedArray(value)) {
|
|
26611
|
+
// TODO json 数据避免传 typedArray
|
|
26612
|
+
serializedData[key] = value;
|
|
26613
|
+
} else if (isArray(value)) {
|
|
26614
|
+
if (!serializedData[key]) {
|
|
26615
|
+
serializedData[key] = [];
|
|
26616
|
+
}
|
|
26617
|
+
SerializationHelper.serializeArrayProperty(value, serializedData[key], 0);
|
|
26618
|
+
} else if (EffectsObject.is(value)) {
|
|
26619
|
+
// TODO 处理 EffectsObject 递归序列化
|
|
26620
|
+
serializedData[key] = {
|
|
26621
|
+
id: value.getInstanceId()
|
|
26622
|
+
};
|
|
26623
|
+
} else if (isObject(value)) {
|
|
26624
|
+
if (!serializedData[key]) {
|
|
26625
|
+
serializedData[key] = {};
|
|
26626
|
+
}
|
|
26627
|
+
SerializationHelper.serializeObjectProperty(value, serializedData[key], 0);
|
|
26628
|
+
}
|
|
26629
|
+
}
|
|
26630
|
+
}
|
|
26631
|
+
// TODO 待移除 tagggedProperties 为没有装饰器的临时方案
|
|
26632
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(effectsObject.defination)), _step1; !(_step1 = _iterator1()).done;){
|
|
26633
|
+
var key1 = _step1.value;
|
|
26634
|
+
var value1 = effectsObject.defination[key1];
|
|
26635
|
+
if (typeof value1 === "number" || typeof value1 === "string" || typeof value1 === "boolean" || SerializationHelper.checkTypedArray(value1)) {
|
|
26636
|
+
// TODO json 数据避免传 typedArray
|
|
26637
|
+
serializedData[key1] = value1;
|
|
26638
|
+
} else if (isArray(value1)) {
|
|
26639
|
+
if (!serializedData[key1]) {
|
|
26640
|
+
serializedData[key1] = [];
|
|
26641
|
+
}
|
|
26642
|
+
SerializationHelper.serializeArrayProperty(value1, serializedData[key1], 0);
|
|
26643
|
+
} else if (EffectsObject.is(value1)) {
|
|
26644
|
+
// TODO 处理 EffectsObject 递归序列化
|
|
26645
|
+
serializedData[key1] = {
|
|
26646
|
+
id: value1.getInstanceId()
|
|
26647
|
+
};
|
|
26648
|
+
} else if (isObject(value1)) {
|
|
26649
|
+
if (!serializedData[key1]) {
|
|
26650
|
+
serializedData[key1] = {};
|
|
26651
|
+
}
|
|
26652
|
+
SerializationHelper.serializeObjectProperty(value1, serializedData[key1], 0);
|
|
26653
|
+
}
|
|
26654
|
+
}
|
|
26655
|
+
return serializedData;
|
|
26656
|
+
};
|
|
26657
|
+
SerializationHelper.deserialize = function deserialize(serializedData, effectsObject) {
|
|
26658
|
+
effectsObject.defination = serializedData;
|
|
26659
|
+
var serializedProperties = getMergedStore(effectsObject);
|
|
26660
|
+
var engine = effectsObject.engine;
|
|
26661
|
+
if (serializedProperties) {
|
|
26662
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(serializedProperties)), _step; !(_step = _iterator()).done;){
|
|
26663
|
+
var key = _step.value;
|
|
26664
|
+
var value = serializedData[key];
|
|
26665
|
+
if (value === undefined) {
|
|
26666
|
+
continue;
|
|
26667
|
+
}
|
|
26668
|
+
var propertyType = serializedProperties[key].type;
|
|
26669
|
+
// FIXME: taggedProperties 为 readonly,这里存在强制赋值
|
|
26670
|
+
effectsObject[key] = SerializationHelper.deserializeProperty(value, engine, 0, propertyType);
|
|
26671
|
+
}
|
|
26672
|
+
}
|
|
26673
|
+
effectsObject.fromData(effectsObject.defination);
|
|
26674
|
+
};
|
|
26675
|
+
SerializationHelper.checkTypedArray = function checkTypedArray(obj) {
|
|
26676
|
+
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);
|
|
26677
|
+
};
|
|
26678
|
+
// check value is { id: 7e69662e964e4892ae8933f24562395b }
|
|
26679
|
+
SerializationHelper.checkDataPath = function checkDataPath(value) {
|
|
26680
|
+
return !!(isObject(value) && Object.keys(value).length === 1 && "id" in value && isString(value.id) && value.id.length === 32);
|
|
26681
|
+
};
|
|
26682
|
+
// TODO 测试函数,2.0 上线后移除
|
|
26683
|
+
SerializationHelper.checkGLTFNode = function checkGLTFNode(value) {
|
|
26684
|
+
return isObject(value) && value.nodeIndex !== undefined && value.isJoint !== undefined;
|
|
26685
|
+
};
|
|
26686
|
+
SerializationHelper.checkImageSource = function checkImageSource(value) {
|
|
26687
|
+
return isCanvas(value) || _instanceof1(value, HTMLImageElement);
|
|
26688
|
+
};
|
|
26689
|
+
SerializationHelper.deserializeProperty = function deserializeProperty(property, engine, level, type, overrideDataPath) {
|
|
26690
|
+
if (overrideDataPath === void 0) overrideDataPath = true;
|
|
26691
|
+
if (level > 14) {
|
|
26692
|
+
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
26693
|
+
return;
|
|
26694
|
+
}
|
|
26695
|
+
// 加载并链接 DataPath 字段表示的 EffectsObject 引用。Class 对象 copy [key, value] 会丢失对象信息,因此只递归数组对象和普通 js Object 结构对象。
|
|
26696
|
+
if (isArray(property)) {
|
|
26697
|
+
var res = [];
|
|
26698
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(property), _step; !(_step = _iterator()).done;){
|
|
26699
|
+
var value = _step.value;
|
|
26700
|
+
res.push(SerializationHelper.deserializeProperty(value, engine, level + 1, type, overrideDataPath));
|
|
26701
|
+
}
|
|
26702
|
+
return res;
|
|
26703
|
+
// TODO json 数据避免传 typedArray
|
|
26704
|
+
} else if (SerializationHelper.checkDataPath(property)) {
|
|
26705
|
+
var referenceObject = engine.findObject(property);
|
|
26706
|
+
return overrideDataPath ? referenceObject : property;
|
|
26707
|
+
} else if (isObject(property) && property.constructor === Object) {
|
|
26708
|
+
var res1;
|
|
26709
|
+
if (type) {
|
|
26710
|
+
res1 = new type();
|
|
26711
|
+
} else {
|
|
26712
|
+
res1 = {};
|
|
26713
|
+
}
|
|
26714
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(Object.keys(property)), _step1; !(_step1 = _iterator1()).done;){
|
|
26715
|
+
var key = _step1.value;
|
|
26716
|
+
res1[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1, undefined, overrideDataPath);
|
|
26717
|
+
}
|
|
26718
|
+
return res1;
|
|
26719
|
+
} else {
|
|
26720
|
+
return property;
|
|
26721
|
+
}
|
|
26722
|
+
};
|
|
26723
|
+
SerializationHelper.serializeObjectProperty = function serializeObjectProperty(objectProperty, serializedData, level) {
|
|
26724
|
+
if (level > 14) {
|
|
26725
|
+
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
26726
|
+
return;
|
|
26727
|
+
}
|
|
26728
|
+
if (!serializedData) {
|
|
26729
|
+
serializedData = {};
|
|
26730
|
+
}
|
|
26731
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(objectProperty)), _step; !(_step = _iterator()).done;){
|
|
26732
|
+
var key = _step.value;
|
|
26733
|
+
var value = objectProperty[key];
|
|
26734
|
+
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean" || SerializationHelper.checkTypedArray(objectProperty)) {
|
|
26735
|
+
// TODO json 数据避免传 typedArray
|
|
26736
|
+
serializedData[key] = value;
|
|
26737
|
+
} else if (isArray(value)) {
|
|
26738
|
+
if (!serializedData[key]) {
|
|
26739
|
+
serializedData[key] = [];
|
|
26740
|
+
}
|
|
26741
|
+
SerializationHelper.serializeArrayProperty(value, serializedData[key], level + 1);
|
|
26742
|
+
} else if (EffectsObject.is(value)) {
|
|
26743
|
+
// TODO 处理 EffectsObject 递归序列化
|
|
26744
|
+
serializedData[key] = {
|
|
26745
|
+
id: value.getInstanceId()
|
|
26746
|
+
};
|
|
26747
|
+
} else if (isObject(value)) {
|
|
26748
|
+
if (!serializedData[key]) {
|
|
26749
|
+
serializedData[key] = {};
|
|
26750
|
+
}
|
|
26751
|
+
SerializationHelper.serializeObjectProperty(value, serializedData[key], level + 1);
|
|
26752
|
+
}
|
|
26753
|
+
}
|
|
26754
|
+
};
|
|
26755
|
+
SerializationHelper.serializeArrayProperty = function serializeArrayProperty(arrayProperty, serializedData, level) {
|
|
26756
|
+
if (level > 14) {
|
|
26757
|
+
console.error("The nested object layers of the serialized data exceed the maximum limit.");
|
|
26758
|
+
return;
|
|
26759
|
+
}
|
|
26760
|
+
if (!serializedData) {
|
|
26761
|
+
serializedData = [];
|
|
26762
|
+
}
|
|
26763
|
+
for(var i = 0; i < arrayProperty.length; i++){
|
|
26764
|
+
var value = arrayProperty[i];
|
|
26765
|
+
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean" || SerializationHelper.checkTypedArray(arrayProperty)) {
|
|
26766
|
+
// TODO json 数据避免传 typedArray
|
|
26767
|
+
serializedData[i] = value;
|
|
26768
|
+
} else if (isArray(value)) {
|
|
26769
|
+
if (!serializedData[i]) {
|
|
26770
|
+
serializedData[i] = [];
|
|
26771
|
+
}
|
|
26772
|
+
SerializationHelper.serializeArrayProperty(value, serializedData[i], level + 1);
|
|
26773
|
+
} else if (EffectsObject.is(value)) {
|
|
26774
|
+
// TODO 处理 EffectsObject 递归序列化
|
|
26775
|
+
serializedData[i] = {
|
|
26776
|
+
id: value.getInstanceId()
|
|
26777
|
+
};
|
|
26778
|
+
} else if (isObject(value)) {
|
|
26779
|
+
if (!serializedData[i]) {
|
|
26780
|
+
serializedData[i] = {};
|
|
26781
|
+
}
|
|
26782
|
+
SerializationHelper.serializeObjectProperty(value, serializedData[i], level + 1);
|
|
26783
|
+
}
|
|
26784
|
+
}
|
|
26785
|
+
};
|
|
26786
|
+
return SerializationHelper;
|
|
26787
|
+
}();
|
|
26788
|
+
|
|
27049
26789
|
/**
|
|
27050
26790
|
* @since 2.0.0
|
|
27051
26791
|
*/ var AssetLoader = /*#__PURE__*/ function() {
|
|
@@ -27053,9 +26793,10 @@ exports.BinaryAsset = __decorate([
|
|
|
27053
26793
|
this.engine = engine;
|
|
27054
26794
|
}
|
|
27055
26795
|
var _proto = AssetLoader.prototype;
|
|
27056
|
-
_proto.loadGUID = function loadGUID(
|
|
27057
|
-
|
|
27058
|
-
|
|
26796
|
+
_proto.loadGUID = function loadGUID(dataPath) {
|
|
26797
|
+
var guid = dataPath.id;
|
|
26798
|
+
if (!dataPath) {
|
|
26799
|
+
return null;
|
|
27059
26800
|
}
|
|
27060
26801
|
var effectsObjectData = this.findData(guid);
|
|
27061
26802
|
var effectsObject;
|
|
@@ -27090,92 +26831,6 @@ exports.BinaryAsset = __decorate([
|
|
|
27090
26831
|
SerializationHelper.deserialize(effectsObjectData, effectsObject);
|
|
27091
26832
|
return effectsObject;
|
|
27092
26833
|
};
|
|
27093
|
-
// 加载本地文件资产
|
|
27094
|
-
_proto.loadGUIDAsync = function loadGUIDAsync(guid) {
|
|
27095
|
-
var _this = this;
|
|
27096
|
-
return _async_to_generator(function() {
|
|
27097
|
-
var effectsObjectData, effectsObject, classConstructor;
|
|
27098
|
-
return __generator(this, function(_state) {
|
|
27099
|
-
switch(_state.label){
|
|
27100
|
-
case 0:
|
|
27101
|
-
if (_this.engine.objectInstance[guid]) {
|
|
27102
|
-
return [
|
|
27103
|
-
2,
|
|
27104
|
-
_this.engine.objectInstance[guid]
|
|
27105
|
-
];
|
|
27106
|
-
}
|
|
27107
|
-
effectsObjectData = _this.findData(guid);
|
|
27108
|
-
if (!!effectsObjectData) return [
|
|
27109
|
-
3,
|
|
27110
|
-
2
|
|
27111
|
-
];
|
|
27112
|
-
if (!_this.engine.database) {
|
|
27113
|
-
console.error("Object data with uuid: " + guid + " not found.");
|
|
27114
|
-
return [
|
|
27115
|
-
2,
|
|
27116
|
-
undefined
|
|
27117
|
-
];
|
|
27118
|
-
}
|
|
27119
|
-
return [
|
|
27120
|
-
4,
|
|
27121
|
-
_this.engine.database.loadGUID(guid)
|
|
27122
|
-
];
|
|
27123
|
-
case 1:
|
|
27124
|
-
effectsObject = _state.sent();
|
|
27125
|
-
if (!effectsObject) {
|
|
27126
|
-
console.error("Disk data with uuid: " + guid + " not found.");
|
|
27127
|
-
return [
|
|
27128
|
-
2,
|
|
27129
|
-
undefined
|
|
27130
|
-
];
|
|
27131
|
-
}
|
|
27132
|
-
_this.engine.addInstance(effectsObject);
|
|
27133
|
-
return [
|
|
27134
|
-
2,
|
|
27135
|
-
effectsObject
|
|
27136
|
-
];
|
|
27137
|
-
case 2:
|
|
27138
|
-
switch(effectsObjectData.dataType){
|
|
27139
|
-
case DataType.Material:
|
|
27140
|
-
effectsObject = Material.create(_this.engine);
|
|
27141
|
-
break;
|
|
27142
|
-
case DataType.Geometry:
|
|
27143
|
-
effectsObject = Geometry.create(_this.engine);
|
|
27144
|
-
break;
|
|
27145
|
-
case DataType.Texture:
|
|
27146
|
-
effectsObject = Texture.create(_this.engine);
|
|
27147
|
-
break;
|
|
27148
|
-
default:
|
|
27149
|
-
{
|
|
27150
|
-
classConstructor = AssetLoader.getClass(effectsObjectData.dataType);
|
|
27151
|
-
if (classConstructor) {
|
|
27152
|
-
effectsObject = new classConstructor(_this.engine);
|
|
27153
|
-
}
|
|
27154
|
-
}
|
|
27155
|
-
}
|
|
27156
|
-
if (!effectsObject) {
|
|
27157
|
-
console.error("Constructor for DataType: " + effectsObjectData.dataType + " not found.");
|
|
27158
|
-
return [
|
|
27159
|
-
2,
|
|
27160
|
-
undefined
|
|
27161
|
-
];
|
|
27162
|
-
}
|
|
27163
|
-
effectsObject.setInstanceId(effectsObjectData.id);
|
|
27164
|
-
_this.engine.addInstance(effectsObject);
|
|
27165
|
-
return [
|
|
27166
|
-
4,
|
|
27167
|
-
SerializationHelper.deserializeAsync(effectsObjectData, effectsObject)
|
|
27168
|
-
];
|
|
27169
|
-
case 3:
|
|
27170
|
-
_state.sent();
|
|
27171
|
-
return [
|
|
27172
|
-
2,
|
|
27173
|
-
effectsObject
|
|
27174
|
-
];
|
|
27175
|
-
}
|
|
27176
|
-
});
|
|
27177
|
-
})();
|
|
27178
|
-
};
|
|
27179
26834
|
_proto.findData = function findData(uuid) {
|
|
27180
26835
|
return this.engine.jsonSceneData[uuid];
|
|
27181
26836
|
};
|
|
@@ -27525,35 +27180,35 @@ function rotationZYXFromQuat(out, quat) {
|
|
|
27525
27180
|
];
|
|
27526
27181
|
}
|
|
27527
27182
|
}
|
|
27528
|
-
var _obj$
|
|
27529
|
-
var particleOriginTranslateMap = (_obj$
|
|
27183
|
+
var _obj$2;
|
|
27184
|
+
var particleOriginTranslateMap = (_obj$2 = {}, _obj$2[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
|
|
27530
27185
|
0,
|
|
27531
27186
|
0
|
|
27532
|
-
], _obj$
|
|
27187
|
+
], _obj$2[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
|
|
27533
27188
|
0,
|
|
27534
27189
|
-0.5
|
|
27535
|
-
], _obj$
|
|
27190
|
+
], _obj$2[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
|
|
27536
27191
|
0,
|
|
27537
27192
|
0.5
|
|
27538
|
-
], _obj$
|
|
27193
|
+
], _obj$2[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
|
|
27539
27194
|
-0.5,
|
|
27540
27195
|
0.5
|
|
27541
|
-
], _obj$
|
|
27196
|
+
], _obj$2[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
|
|
27542
27197
|
-0.5,
|
|
27543
27198
|
0
|
|
27544
|
-
], _obj$
|
|
27199
|
+
], _obj$2[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
|
|
27545
27200
|
-0.5,
|
|
27546
27201
|
-0.5
|
|
27547
|
-
], _obj$
|
|
27202
|
+
], _obj$2[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
|
|
27548
27203
|
0.5,
|
|
27549
27204
|
0
|
|
27550
|
-
], _obj$
|
|
27205
|
+
], _obj$2[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
|
|
27551
27206
|
0.5,
|
|
27552
27207
|
-0.5
|
|
27553
|
-
], _obj$
|
|
27208
|
+
], _obj$2[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
|
|
27554
27209
|
0.5,
|
|
27555
27210
|
0.5
|
|
27556
|
-
], _obj$
|
|
27211
|
+
], _obj$2);
|
|
27557
27212
|
function getBezierCurveFromHermite(m0, m1, p0, p3) {
|
|
27558
27213
|
var xStart = p0[0];
|
|
27559
27214
|
var yStart = p0[1];
|
|
@@ -27792,28 +27447,6 @@ var refCompositions = new Map();
|
|
|
27792
27447
|
}
|
|
27793
27448
|
}
|
|
27794
27449
|
}
|
|
27795
|
-
// Composition id 转 guid
|
|
27796
|
-
var compositionId = json.compositionId;
|
|
27797
|
-
var compositionIdToGUIDMap = {};
|
|
27798
|
-
for(var _iterator3 = _create_for_of_iterator_helper_loose(json.compositions), _step3; !(_step3 = _iterator3()).done;){
|
|
27799
|
-
var composition = _step3.value;
|
|
27800
|
-
var guid = generateGUID();
|
|
27801
|
-
compositionIdToGUIDMap[composition.id] = guid;
|
|
27802
|
-
if (composition.id === compositionId) {
|
|
27803
|
-
json.compositionId = guid;
|
|
27804
|
-
}
|
|
27805
|
-
composition.id = guid;
|
|
27806
|
-
}
|
|
27807
|
-
// 预合成元素 refId 同步改为生成的合成 guid
|
|
27808
|
-
for(var _iterator4 = _create_for_of_iterator_helper_loose(json.items), _step4; !(_step4 = _iterator4()).done;){
|
|
27809
|
-
var item = _step4.value;
|
|
27810
|
-
if (item.content) {
|
|
27811
|
-
var compositionOptions = item.content.options;
|
|
27812
|
-
if (compositionOptions && compositionOptions.refId !== undefined) {
|
|
27813
|
-
compositionOptions.refId = compositionIdToGUIDMap[compositionOptions.refId];
|
|
27814
|
-
}
|
|
27815
|
-
}
|
|
27816
|
-
}
|
|
27817
27450
|
return json;
|
|
27818
27451
|
}
|
|
27819
27452
|
function version32Migration(json) {
|
|
@@ -27840,21 +27473,68 @@ function version32Migration(json) {
|
|
|
27840
27473
|
itemMap.set(item.id, item);
|
|
27841
27474
|
}
|
|
27842
27475
|
processContent(mainComp);
|
|
27476
|
+
return json;
|
|
27477
|
+
}
|
|
27478
|
+
function version33Migration(json) {
|
|
27843
27479
|
// 老 shape 数据兼容
|
|
27844
|
-
for(var
|
|
27845
|
-
var
|
|
27846
|
-
if (
|
|
27847
|
-
var spriteComponent = componentMap.get(
|
|
27480
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(json.items), _step; !(_step = _iterator()).done;){
|
|
27481
|
+
var item = _step.value;
|
|
27482
|
+
if (item.type === ItemType.sprite) {
|
|
27483
|
+
var spriteComponent = componentMap.get(item.components[0].id);
|
|
27848
27484
|
if (spriteComponent) {
|
|
27849
27485
|
var shape = spriteComponent.renderer.shape;
|
|
27850
27486
|
var shapeData = void 0;
|
|
27851
27487
|
if (Number.isInteger(shape)) {
|
|
27852
27488
|
shapeData = json.shapes[shape];
|
|
27489
|
+
} else {
|
|
27490
|
+
shapeData = shape;
|
|
27853
27491
|
}
|
|
27854
27492
|
spriteComponent.renderer.shape = shapeData;
|
|
27855
27493
|
}
|
|
27856
27494
|
}
|
|
27857
27495
|
}
|
|
27496
|
+
// Composition id 转 guid, Composition 分离 CompositionComponent
|
|
27497
|
+
var compositionId = json.compositionId;
|
|
27498
|
+
var compositionIdToGUIDMap = {};
|
|
27499
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose(json.compositions), _step1; !(_step1 = _iterator1()).done;){
|
|
27500
|
+
var composition = _step1.value;
|
|
27501
|
+
var guid = generateGUID();
|
|
27502
|
+
compositionIdToGUIDMap[composition.id] = guid;
|
|
27503
|
+
if (composition.id === compositionId) {
|
|
27504
|
+
json.compositionId = guid;
|
|
27505
|
+
}
|
|
27506
|
+
composition.id = guid;
|
|
27507
|
+
var compositionComponent = {
|
|
27508
|
+
id: generateGUID(),
|
|
27509
|
+
dataType: "CompositionComponent",
|
|
27510
|
+
items: composition.items,
|
|
27511
|
+
timelineAsset: composition.timelineAsset,
|
|
27512
|
+
sceneBindings: composition.sceneBindings,
|
|
27513
|
+
startTime: composition.startTime
|
|
27514
|
+
};
|
|
27515
|
+
//@ts-expect-error
|
|
27516
|
+
composition.timelineAsset = undefined;
|
|
27517
|
+
//@ts-expect-error
|
|
27518
|
+
composition.sceneBindings = undefined;
|
|
27519
|
+
composition.startTime = undefined;
|
|
27520
|
+
//@ts-expect-error
|
|
27521
|
+
composition.components = [
|
|
27522
|
+
{
|
|
27523
|
+
id: compositionComponent.id
|
|
27524
|
+
}
|
|
27525
|
+
];
|
|
27526
|
+
json.components.push(compositionComponent);
|
|
27527
|
+
}
|
|
27528
|
+
// 预合成元素 refId 同步改为生成的合成 guid
|
|
27529
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose(json.items), _step2; !(_step2 = _iterator2()).done;){
|
|
27530
|
+
var item1 = _step2.value;
|
|
27531
|
+
if (item1.content) {
|
|
27532
|
+
var compositionOptions = item1.content.options;
|
|
27533
|
+
if (compositionOptions && compositionOptions.refId !== undefined) {
|
|
27534
|
+
compositionOptions.refId = compositionIdToGUIDMap[compositionOptions.refId];
|
|
27535
|
+
}
|
|
27536
|
+
}
|
|
27537
|
+
}
|
|
27858
27538
|
return json;
|
|
27859
27539
|
}
|
|
27860
27540
|
function processContent(composition) {
|
|
@@ -28728,7 +28408,7 @@ function getStandardJSON(json) {
|
|
|
28728
28408
|
if (v0.test(json.version)) {
|
|
28729
28409
|
var _exec;
|
|
28730
28410
|
reverseParticle = ((_exec = /^(\d+)/.exec(json.version)) == null ? void 0 : _exec[0]) === "0";
|
|
28731
|
-
return version32Migration(version31Migration(version30Migration(version21Migration(getStandardJSONFromV0(json)))));
|
|
28411
|
+
return version33Migration(version32Migration(version31Migration(version30Migration(version21Migration(getStandardJSONFromV0(json))))));
|
|
28732
28412
|
}
|
|
28733
28413
|
reverseParticle = false;
|
|
28734
28414
|
var vs = standardVersion.exec(json.version) || [];
|
|
@@ -28753,6 +28433,9 @@ function getStandardJSON(json) {
|
|
|
28753
28433
|
if (minorVersion < 3) {
|
|
28754
28434
|
json = version32Migration(json);
|
|
28755
28435
|
}
|
|
28436
|
+
if (minorVersion < 4) {
|
|
28437
|
+
json = version33Migration(json);
|
|
28438
|
+
}
|
|
28756
28439
|
}
|
|
28757
28440
|
return json;
|
|
28758
28441
|
}
|
|
@@ -29036,6 +28719,40 @@ function getStandardItem(item, opt) {
|
|
|
29036
28719
|
}
|
|
29037
28720
|
}
|
|
29038
28721
|
|
|
28722
|
+
var _obj$1;
|
|
28723
|
+
/**
|
|
28724
|
+
* 机型和渲染等级对应表
|
|
28725
|
+
*
|
|
28726
|
+
* 机型:B-低端机、A-中端机、S-高端机
|
|
28727
|
+
* 渲染等级:B-低、A-中、S-高、A+-中高、B+-全部
|
|
28728
|
+
*
|
|
28729
|
+
* - S(高端机):高、全部、中高
|
|
28730
|
+
* - A(中端机):中、全部、中高
|
|
28731
|
+
* - B(低端机):低、全部
|
|
28732
|
+
* - undefined(全部机型)
|
|
28733
|
+
*/ var renderLevelPassSet = (_obj$1 = {}, _obj$1[RenderLevel.S] = [
|
|
28734
|
+
RenderLevel.S,
|
|
28735
|
+
RenderLevel.BPlus,
|
|
28736
|
+
RenderLevel.APlus
|
|
28737
|
+
], _obj$1[RenderLevel.A] = [
|
|
28738
|
+
RenderLevel.A,
|
|
28739
|
+
RenderLevel.BPlus,
|
|
28740
|
+
RenderLevel.APlus
|
|
28741
|
+
], _obj$1[RenderLevel.B] = [
|
|
28742
|
+
RenderLevel.B,
|
|
28743
|
+
RenderLevel.BPlus
|
|
28744
|
+
], _obj$1);
|
|
28745
|
+
function passRenderLevel(l, renderLevel) {
|
|
28746
|
+
if (!l || !renderLevel) {
|
|
28747
|
+
return true;
|
|
28748
|
+
}
|
|
28749
|
+
var arr = renderLevelPassSet[renderLevel];
|
|
28750
|
+
if (arr) {
|
|
28751
|
+
return arr.includes(l);
|
|
28752
|
+
}
|
|
28753
|
+
return false;
|
|
28754
|
+
}
|
|
28755
|
+
|
|
29039
28756
|
exports.Scene = void 0;
|
|
29040
28757
|
(function(Scene) {
|
|
29041
28758
|
function isJSONObject(scene) {
|
|
@@ -29935,7 +29652,9 @@ function createTextureOptionsBySource(image, sourceFrom, id) {
|
|
|
29935
29652
|
if (_instanceof1(textureOptions, Texture)) {
|
|
29936
29653
|
this.engine.addInstance(textureOptions);
|
|
29937
29654
|
} else {
|
|
29938
|
-
textureOptions = this.engine.
|
|
29655
|
+
textureOptions = this.engine.findObject({
|
|
29656
|
+
id: scene.textureOptions[i].id
|
|
29657
|
+
});
|
|
29939
29658
|
scene.textureOptions[i] = textureOptions;
|
|
29940
29659
|
}
|
|
29941
29660
|
textureOptions.initialize();
|
|
@@ -31582,8 +31301,18 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
|
|
|
31582
31301
|
_proto.addInstance = function addInstance(effectsObject) {
|
|
31583
31302
|
this.objectInstance[effectsObject.getInstanceId()] = effectsObject;
|
|
31584
31303
|
};
|
|
31585
|
-
|
|
31586
|
-
|
|
31304
|
+
/**
|
|
31305
|
+
* @ignore
|
|
31306
|
+
*/ _proto.findObject = function findObject(guid) {
|
|
31307
|
+
// 编辑器可能传 Class 对象,这边判断处理一下直接返回原对象。
|
|
31308
|
+
if (!(isObject(guid) && guid.constructor === Object)) {
|
|
31309
|
+
return guid;
|
|
31310
|
+
}
|
|
31311
|
+
if (this.objectInstance[guid.id]) {
|
|
31312
|
+
return this.objectInstance[guid.id];
|
|
31313
|
+
}
|
|
31314
|
+
var result = this.assetLoader.loadGUID(guid);
|
|
31315
|
+
return result;
|
|
31587
31316
|
};
|
|
31588
31317
|
_proto.removeInstance = function removeInstance(id) {
|
|
31589
31318
|
delete this.objectInstance[id];
|
|
@@ -31597,6 +31326,10 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
|
|
|
31597
31326
|
}
|
|
31598
31327
|
for(var _iterator1 = _create_for_of_iterator_helper_loose(items), _step1; !(_step1 = _iterator1()).done;){
|
|
31599
31328
|
var vfxItemData = _step1.value;
|
|
31329
|
+
if (!passRenderLevel(vfxItemData.renderLevel, scene.renderLevel)) {
|
|
31330
|
+
vfxItemData.components = [];
|
|
31331
|
+
vfxItemData.type = ItemType.null;
|
|
31332
|
+
}
|
|
31600
31333
|
this.addEffectsObjectData(vfxItemData);
|
|
31601
31334
|
}
|
|
31602
31335
|
for(var _iterator2 = _create_for_of_iterator_helper_loose(materials), _step2; !(_step2 = _iterator2()).done;){
|
|
@@ -31651,45 +31384,20 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
|
|
|
31651
31384
|
return _async_to_generator(function() {
|
|
31652
31385
|
var jsonScene, _iterator, _step, itemData, itemType;
|
|
31653
31386
|
return __generator(this, function(_state) {
|
|
31654
|
-
|
|
31655
|
-
|
|
31656
|
-
|
|
31657
|
-
|
|
31658
|
-
|
|
31659
|
-
|
|
31660
|
-
|
|
31661
|
-
|
|
31662
|
-
|
|
31663
|
-
|
|
31664
|
-
itemData = _step.value;
|
|
31665
|
-
itemType = itemData.type;
|
|
31666
|
-
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)) {
|
|
31667
|
-
return [
|
|
31668
|
-
3,
|
|
31669
|
-
3
|
|
31670
|
-
];
|
|
31671
|
-
}
|
|
31672
|
-
if (!_this.database) return [
|
|
31673
|
-
3,
|
|
31674
|
-
3
|
|
31675
|
-
];
|
|
31676
|
-
return [
|
|
31677
|
-
4,
|
|
31678
|
-
_this.assetLoader.loadGUIDAsync(itemData.id)
|
|
31679
|
-
];
|
|
31680
|
-
case 2:
|
|
31681
|
-
_state.sent();
|
|
31682
|
-
_state.label = 3;
|
|
31683
|
-
case 3:
|
|
31684
|
-
return [
|
|
31685
|
-
3,
|
|
31686
|
-
1
|
|
31687
|
-
];
|
|
31688
|
-
case 4:
|
|
31689
|
-
return [
|
|
31690
|
-
2
|
|
31691
|
-
];
|
|
31387
|
+
jsonScene = scene.jsonScene;
|
|
31388
|
+
for(_iterator = _create_for_of_iterator_helper_loose(jsonScene.items); !(_step = _iterator()).done;){
|
|
31389
|
+
itemData = _step.value;
|
|
31390
|
+
itemType = itemData.type;
|
|
31391
|
+
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)) {
|
|
31392
|
+
continue;
|
|
31393
|
+
}
|
|
31394
|
+
if (_this.database) {
|
|
31395
|
+
_this.assetLoader.loadGUID(itemData);
|
|
31396
|
+
}
|
|
31692
31397
|
}
|
|
31398
|
+
return [
|
|
31399
|
+
2
|
|
31400
|
+
];
|
|
31693
31401
|
});
|
|
31694
31402
|
})();
|
|
31695
31403
|
};
|
|
@@ -31937,7 +31645,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
|
|
|
31937
31645
|
registerPlugin("particle", ParticleLoader, exports.VFXItem);
|
|
31938
31646
|
registerPlugin("cal", CalculateLoader, exports.VFXItem);
|
|
31939
31647
|
registerPlugin("interact", InteractLoader, exports.VFXItem);
|
|
31940
|
-
var version$1 = "2.4.0-beta.
|
|
31648
|
+
var version$1 = "2.4.0-beta.1";
|
|
31941
31649
|
logger.info("Core version: " + version$1 + ".");
|
|
31942
31650
|
|
|
31943
31651
|
var _obj;
|
|
@@ -33101,7 +32809,7 @@ var seed = 1;
|
|
|
33101
32809
|
// 预合成元素
|
|
33102
32810
|
for(var _iterator2 = _create_for_of_iterator_helper_loose(this.refContent), _step2; !(_step2 = _iterator2()).done;){
|
|
33103
32811
|
var refContent = _step2.value;
|
|
33104
|
-
for(var _iterator3 = _create_for_of_iterator_helper_loose(refContent.getComponent(CompositionComponent).items), _step3; !(_step3 = _iterator3()).done;){
|
|
32812
|
+
for(var _iterator3 = _create_for_of_iterator_helper_loose(refContent.getComponent(exports.CompositionComponent).items), _step3; !(_step3 = _iterator3()).done;){
|
|
33105
32813
|
var vfxItem1 = _step3.value;
|
|
33106
32814
|
var rendererComponents1 = vfxItem1.getComponents(RendererComponent);
|
|
33107
32815
|
for(var _iterator4 = _create_for_of_iterator_helper_loose(rendererComponents1), _step4; !(_step4 = _iterator4()).done;){
|
|
@@ -33528,7 +33236,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
33528
33236
|
*/ Mesh.create = function(engine, props) {
|
|
33529
33237
|
return new ThreeMesh(engine, props);
|
|
33530
33238
|
};
|
|
33531
|
-
var version = "2.4.0-beta.
|
|
33239
|
+
var version = "2.4.0-beta.1";
|
|
33532
33240
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
33533
33241
|
|
|
33534
33242
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -33557,7 +33265,6 @@ exports.CameraVFXItemLoader = CameraVFXItemLoader;
|
|
|
33557
33265
|
exports.ColorCurve = ColorCurve;
|
|
33558
33266
|
exports.Component = Component;
|
|
33559
33267
|
exports.Composition = Composition;
|
|
33560
|
-
exports.CompositionComponent = CompositionComponent;
|
|
33561
33268
|
exports.DEFAULT_FONTS = DEFAULT_FONTS;
|
|
33562
33269
|
exports.DEFAULT_FPS = DEFAULT_FPS;
|
|
33563
33270
|
exports.Database = Database;
|
|
@@ -33687,7 +33394,6 @@ exports.effectsClassStore = effectsClassStore;
|
|
|
33687
33394
|
exports.enlargeBuffer = enlargeBuffer;
|
|
33688
33395
|
exports.ensureFixedNumber = ensureFixedNumber;
|
|
33689
33396
|
exports.ensureVec3 = ensureVec3;
|
|
33690
|
-
exports.filterItemsByRenderLevel = filterItemsByRenderLevel;
|
|
33691
33397
|
exports.findPreviousRenderPass = findPreviousRenderPass;
|
|
33692
33398
|
exports.gaussianDownFrag = gaussianDown_frag;
|
|
33693
33399
|
exports.gaussianDownHFrag = gaussianDownHFrag;
|