@galacean/engine 2.0.0-alpha.15 → 2.0.0-alpha.16

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.
@@ -5318,74 +5318,69 @@ function _instanceof1$2(left, right) {
5318
5318
  return cloneModes;
5319
5319
  };
5320
5320
  CloneManager.cloneProperty = function cloneProperty(source, target, k, cloneMode, srcRoot, targetRoot, deepInstanceMap) {
5321
- if (cloneMode === CloneMode.Ignore) {
5321
+ var sourceProperty = source[k];
5322
+ // Remappable references (Entity/Component) are always remapped, regardless of clone decorator
5323
+ if (_instanceof1$2(sourceProperty, Object) && sourceProperty._remap) {
5324
+ target[k] = sourceProperty._remap(srcRoot, targetRoot);
5322
5325
  return;
5323
5326
  }
5324
- var sourceProperty = source[k];
5325
- if (_instanceof1$2(sourceProperty, Object)) {
5326
- if (cloneMode === undefined || cloneMode === CloneMode.Assignment) {
5327
- target[k] = sourceProperty;
5328
- return;
5329
- }
5330
- var type = sourceProperty.constructor;
5331
- switch(type){
5332
- case Uint8Array:
5333
- case Uint16Array:
5334
- case Uint32Array:
5335
- case Int8Array:
5336
- case Int16Array:
5337
- case Int32Array:
5338
- case Float32Array:
5339
- case Float64Array:
5340
- var targetPropertyT = target[k];
5341
- if (targetPropertyT == null || targetPropertyT.length !== sourceProperty.length) {
5342
- target[k] = sourceProperty.slice();
5343
- } else {
5344
- targetPropertyT.set(sourceProperty);
5345
- }
5346
- break;
5347
- case Array:
5348
- var targetPropertyA = target[k];
5349
- var length = sourceProperty.length;
5350
- if (targetPropertyA == null) {
5351
- target[k] = targetPropertyA = new Array(length);
5352
- } else {
5353
- targetPropertyA.length = length;
5354
- }
5355
- for(var i = 0; i < length; i++){
5356
- CloneManager.cloneProperty(sourceProperty, targetPropertyA, i, cloneMode, srcRoot, targetRoot, deepInstanceMap);
5357
- }
5358
- break;
5359
- default:
5360
- var targetProperty = target[k];
5361
- // If the target property is undefined, create new instance and keep reference sharing like the source
5327
+ if (cloneMode === CloneMode.Ignore) return;
5328
+ // Primitives, undecorated, or @assignmentClone: direct assign
5329
+ if (!_instanceof1$2(sourceProperty, Object) || cloneMode === undefined || cloneMode === CloneMode.Assignment) {
5330
+ target[k] = sourceProperty;
5331
+ return;
5332
+ }
5333
+ // @shallowClone / @deepClone: deep copy complex objects
5334
+ var type = sourceProperty.constructor;
5335
+ switch(type){
5336
+ case Uint8Array:
5337
+ case Uint16Array:
5338
+ case Uint32Array:
5339
+ case Int8Array:
5340
+ case Int16Array:
5341
+ case Int32Array:
5342
+ case Float32Array:
5343
+ case Float64Array:
5344
+ var targetPropertyT = target[k];
5345
+ if (targetPropertyT == null || targetPropertyT.length !== sourceProperty.length) {
5346
+ target[k] = sourceProperty.slice();
5347
+ } else {
5348
+ targetPropertyT.set(sourceProperty);
5349
+ }
5350
+ break;
5351
+ case Array:
5352
+ var targetPropertyA = target[k];
5353
+ var length = sourceProperty.length;
5354
+ if (targetPropertyA == null) {
5355
+ target[k] = targetPropertyA = new Array(length);
5356
+ } else {
5357
+ targetPropertyA.length = length;
5358
+ }
5359
+ for(var i = 0; i < length; i++){
5360
+ CloneManager.cloneProperty(sourceProperty, targetPropertyA, i, cloneMode, srcRoot, targetRoot, deepInstanceMap);
5361
+ }
5362
+ break;
5363
+ default:
5364
+ var targetProperty = target[k];
5365
+ // If the target property is undefined, create new instance and keep reference sharing like the source
5366
+ if (!targetProperty) {
5367
+ targetProperty = deepInstanceMap.get(sourceProperty);
5362
5368
  if (!targetProperty) {
5363
- targetProperty = deepInstanceMap.get(sourceProperty);
5364
- if (!targetProperty) {
5365
- targetProperty = new sourceProperty.constructor();
5366
- deepInstanceMap.set(sourceProperty, targetProperty);
5367
- }
5368
- target[k] = targetProperty;
5369
+ targetProperty = new sourceProperty.constructor();
5370
+ deepInstanceMap.set(sourceProperty, targetProperty);
5369
5371
  }
5370
- if (sourceProperty.copyFrom) {
5371
- // Custom clone
5372
- targetProperty.copyFrom(sourceProperty);
5373
- } else {
5374
- // Universal clone
5375
- var cloneModes = CloneManager.getCloneMode(sourceProperty.constructor);
5376
- for(var _$k in sourceProperty){
5377
- CloneManager.cloneProperty(sourceProperty, targetProperty, _$k, cloneModes[_$k], srcRoot, targetRoot, deepInstanceMap);
5378
- }
5379
- // Custom incremental clone
5380
- if (sourceProperty._cloneTo) {
5381
- sourceProperty._cloneTo(targetProperty, srcRoot, targetRoot);
5382
- }
5372
+ target[k] = targetProperty;
5373
+ }
5374
+ if (sourceProperty.copyFrom) {
5375
+ targetProperty.copyFrom(sourceProperty);
5376
+ } else {
5377
+ var cloneModes = CloneManager.getCloneMode(sourceProperty.constructor);
5378
+ for(var _$k in sourceProperty){
5379
+ CloneManager.cloneProperty(sourceProperty, targetProperty, _$k, cloneModes[_$k], srcRoot, targetRoot, deepInstanceMap);
5383
5380
  }
5384
- break;
5385
- }
5386
- } else {
5387
- // null, undefined, primitive type, function
5388
- target[k] = sourceProperty;
5381
+ sourceProperty._cloneTo == null ? void 0 : sourceProperty._cloneTo.call(sourceProperty, targetProperty, srcRoot, targetRoot);
5382
+ }
5383
+ break;
5389
5384
  }
5390
5385
  };
5391
5386
  CloneManager.deepCloneObject = function deepCloneObject(source, target, deepInstanceMap) {
@@ -12332,6 +12327,44 @@ Sky._projectionMatrix = new Matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, Sky._epsilon -
12332
12327
  return Background;
12333
12328
  }();
12334
12329
  /** @internal */ Background._premultiplySolidColor = new Color();
12330
+ /**
12331
+ * @internal
12332
+ * Utility functions for remapping Entity/Component references during cloning.
12333
+ */ var CloneUtils = /*#__PURE__*/ function() {
12334
+ function CloneUtils() {}
12335
+ CloneUtils.remapEntity = function remapEntity(srcRoot, targetRoot, entity) {
12336
+ var path = CloneUtils._tempRemapPath;
12337
+ if (!CloneUtils._getEntityHierarchyPath(srcRoot, entity, path)) return entity;
12338
+ return CloneUtils._getEntityByHierarchyPath(targetRoot, path);
12339
+ };
12340
+ CloneUtils.remapComponent = function remapComponent(srcRoot, targetRoot, component) {
12341
+ var path = CloneUtils._tempRemapPath;
12342
+ var srcEntity = component.entity;
12343
+ if (!CloneUtils._getEntityHierarchyPath(srcRoot, srcEntity, path)) return component;
12344
+ return CloneUtils._getEntityByHierarchyPath(targetRoot, path)._components[srcEntity._components.indexOf(component)];
12345
+ };
12346
+ CloneUtils._getEntityHierarchyPath = function _getEntityHierarchyPath(rootEntity, searchEntity, inversePath) {
12347
+ inversePath.length = 0;
12348
+ while(searchEntity !== rootEntity){
12349
+ var parent = searchEntity.parent;
12350
+ if (!parent) {
12351
+ return false;
12352
+ }
12353
+ inversePath.push(searchEntity.siblingIndex);
12354
+ searchEntity = parent;
12355
+ }
12356
+ return true;
12357
+ };
12358
+ CloneUtils._getEntityByHierarchyPath = function _getEntityByHierarchyPath(rootEntity, inversePath) {
12359
+ var entity = rootEntity;
12360
+ for(var i = inversePath.length - 1; i >= 0; i--){
12361
+ entity = entity.children[inversePath[i]];
12362
+ }
12363
+ return entity;
12364
+ };
12365
+ return CloneUtils;
12366
+ }();
12367
+ CloneUtils._tempRemapPath = [];
12335
12368
  var ActiveChangeFlag = /*#__PURE__*/ function(ActiveChangeFlag) {
12336
12369
  ActiveChangeFlag[ActiveChangeFlag["None"] = 0] = "None";
12337
12370
  ActiveChangeFlag[ActiveChangeFlag["Scene"] = 1] = "Scene";
@@ -12406,6 +12439,11 @@ var ActiveChangeFlag = /*#__PURE__*/ function(ActiveChangeFlag) {
12406
12439
  }
12407
12440
  }
12408
12441
  };
12442
+ /**
12443
+ * @internal
12444
+ */ _proto._remap = function _remap(srcRoot, targetRoot) {
12445
+ return CloneUtils.remapComponent(srcRoot, targetRoot, this);
12446
+ };
12409
12447
  _proto._addResourceReferCount = function _addResourceReferCount(resource, count) {
12410
12448
  this._entity._isTemplate || resource._addReferCount(count);
12411
12449
  };
@@ -12479,9 +12517,6 @@ var ActiveChangeFlag = /*#__PURE__*/ function(ActiveChangeFlag) {
12479
12517
  ]);
12480
12518
  return Component;
12481
12519
  }(EngineObject);
12482
- __decorate$1([
12483
- ignoreClone
12484
- ], Component.prototype, "_entity", void 0);
12485
12520
  __decorate$1([
12486
12521
  ignoreClone
12487
12522
  ], Component.prototype, "_awoken", void 0);
@@ -12845,7 +12880,7 @@ function dependentComponents(componentOrComponents, dependentMode) {
12845
12880
  };
12846
12881
  /**
12847
12882
  * @internal
12848
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
12883
+ */ _proto._cloneTo = function _cloneTo(target) {
12849
12884
  var position = target._position, rotation = target._rotation, scale = target._scale;
12850
12885
  // @ts-ignore
12851
12886
  position._onValueChanged = rotation._onValueChanged = scale._onValueChanged = null;
@@ -13457,9 +13492,6 @@ __decorate$1([
13457
13492
  __decorate$1([
13458
13493
  ignoreClone
13459
13494
  ], Transform.prototype, "_isParentDirty", void 0);
13460
- __decorate$1([
13461
- ignoreClone
13462
- ], Transform.prototype, "_parentTransformCache", void 0);
13463
13495
  __decorate$1([
13464
13496
  ignoreClone
13465
13497
  ], Transform.prototype, "_dirtyFlag", void 0);
@@ -13918,7 +13950,7 @@ var Camera = /*#__PURE__*/ function(Component) {
13918
13950
  };
13919
13951
  /**
13920
13952
  * @internal
13921
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
13953
+ */ _proto._cloneTo = function _cloneTo(target) {
13922
13954
  var _this__renderTarget;
13923
13955
  (_this__renderTarget = this._renderTarget) == null ? void 0 : _this__renderTarget._addReferCount(1);
13924
13956
  };
@@ -17121,9 +17153,6 @@ __decorate$1([
17121
17153
  return ColliderShape;
17122
17154
  }();
17123
17155
  ColliderShape._idGenerator = 0;
17124
- __decorate$1([
17125
- ignoreClone
17126
- ], ColliderShape.prototype, "_collider", void 0);
17127
17156
  __decorate$1([
17128
17157
  ignoreClone
17129
17158
  ], ColliderShape.prototype, "_nativeShape", void 0);
@@ -21505,7 +21534,7 @@ var Renderer = /*#__PURE__*/ function(Component) {
21505
21534
  };
21506
21535
  /**
21507
21536
  * @internal
21508
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
21537
+ */ _proto._cloneTo = function _cloneTo(target) {
21509
21538
  var materials = this._materials;
21510
21539
  for(var i = 0, n = materials.length; i < n; i++){
21511
21540
  target._setMaterial(i, materials[i]);
@@ -21760,9 +21789,6 @@ __decorate$1([
21760
21789
  __decorate$1([
21761
21790
  ignoreClone
21762
21791
  ], Renderer.prototype, "_bounds", void 0);
21763
- __decorate$1([
21764
- ignoreClone
21765
- ], Renderer.prototype, "_transformEntity", void 0);
21766
21792
  __decorate$1([
21767
21793
  deepClone
21768
21794
  ], Renderer.prototype, "_shaderData", void 0);
@@ -21821,8 +21847,8 @@ var RendererUpdateFlags = /*#__PURE__*/ function(RendererUpdateFlags) {
21821
21847
  };
21822
21848
  /**
21823
21849
  * @internal
21824
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
21825
- Renderer.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
21850
+ */ _proto._cloneTo = function _cloneTo(target) {
21851
+ Renderer.prototype._cloneTo.call(this, target);
21826
21852
  target.sprite = this._sprite;
21827
21853
  };
21828
21854
  /**
@@ -22132,8 +22158,8 @@ __decorate$1([
22132
22158
  };
22133
22159
  /**
22134
22160
  * @internal
22135
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
22136
- Renderer.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
22161
+ */ _proto._cloneTo = function _cloneTo(target) {
22162
+ Renderer.prototype._cloneTo.call(this, target);
22137
22163
  target.sprite = this._sprite;
22138
22164
  target.drawMode = this._drawMode;
22139
22165
  };
@@ -22555,8 +22581,8 @@ __decorate$1([
22555
22581
  };
22556
22582
  /**
22557
22583
  * @internal
22558
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
22559
- Renderer.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
22584
+ */ _proto._cloneTo = function _cloneTo(target) {
22585
+ Renderer.prototype._cloneTo.call(this, target);
22560
22586
  target.font = this._font;
22561
22587
  target._subFont = this._subFont;
22562
22588
  };
@@ -24238,8 +24264,8 @@ var BlendShapeFrameDirty = /*#__PURE__*/ function(BlendShapeFrameDirty) {
24238
24264
  };
24239
24265
  /**
24240
24266
  * @internal
24241
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
24242
- Renderer.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
24267
+ */ _proto._cloneTo = function _cloneTo(target) {
24268
+ Renderer.prototype._cloneTo.call(this, target);
24243
24269
  target.mesh = this._mesh;
24244
24270
  };
24245
24271
  /**
@@ -27094,44 +27120,6 @@ PrimitiveMesh._sphereSeedCells = new Float32Array([
27094
27120
  ]);
27095
27121
  PrimitiveMesh._sphereEdgeIdx = 0;
27096
27122
  PrimitiveMesh._spherePoleIdx = 0;
27097
- /**
27098
- * @internal
27099
- * Utility functions for remapping Entity/Component references during cloning.
27100
- */ var CloneUtils = /*#__PURE__*/ function() {
27101
- function CloneUtils() {}
27102
- CloneUtils.remapEntity = function remapEntity(srcRoot, targetRoot, entity) {
27103
- var paths = CloneUtils._tempRemapPath;
27104
- var success = CloneUtils._getEntityHierarchyPath(srcRoot, entity, paths);
27105
- return success ? CloneUtils._getEntityByHierarchyPath(targetRoot, paths) : entity;
27106
- };
27107
- CloneUtils.remapComponent = function remapComponent(srcRoot, targetRoot, component) {
27108
- var _CloneUtils__getEntityByHierarchyPath;
27109
- var paths = CloneUtils._tempRemapPath;
27110
- var success = CloneUtils._getEntityHierarchyPath(srcRoot, component.entity, paths);
27111
- return success ? (_CloneUtils__getEntityByHierarchyPath = CloneUtils._getEntityByHierarchyPath(targetRoot, paths)) == null ? void 0 : _CloneUtils__getEntityByHierarchyPath.getComponent(component.constructor) : component;
27112
- };
27113
- CloneUtils._getEntityHierarchyPath = function _getEntityHierarchyPath(rootEntity, searchEntity, inversePath) {
27114
- inversePath.length = 0;
27115
- while(searchEntity !== rootEntity){
27116
- var parent = searchEntity.parent;
27117
- if (!parent) {
27118
- return false;
27119
- }
27120
- inversePath.push(searchEntity.siblingIndex);
27121
- searchEntity = parent;
27122
- }
27123
- return true;
27124
- };
27125
- CloneUtils._getEntityByHierarchyPath = function _getEntityByHierarchyPath(rootEntity, inversePath) {
27126
- var entity = rootEntity;
27127
- for(var i = inversePath.length - 1; i >= 0; i--){
27128
- entity = entity.children[inversePath[i]];
27129
- }
27130
- return entity;
27131
- };
27132
- return CloneUtils;
27133
- }();
27134
- CloneUtils._tempRemapPath = [];
27135
27123
  /**
27136
27124
  * Skin used for skinned mesh renderer.
27137
27125
  */ var Skin = /*#__PURE__*/ function(EngineObject) {
@@ -27163,25 +27151,6 @@ CloneUtils._tempRemapPath = [];
27163
27151
  }
27164
27152
  this._updateMark = renderer.engine.time.frameCount;
27165
27153
  };
27166
- /**
27167
- * @internal
27168
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
27169
- // Clone rootBone
27170
- var rootBone = this.rootBone;
27171
- if (rootBone) {
27172
- target.rootBone = CloneUtils.remapEntity(srcRoot, targetRoot, rootBone);
27173
- }
27174
- // Clone bones
27175
- var bones = this.bones;
27176
- if (bones.length > 0) {
27177
- var boneCount = bones.length;
27178
- var destBones = new Array(boneCount);
27179
- for(var i = 0; i < boneCount; i++){
27180
- destBones[i] = CloneUtils.remapEntity(srcRoot, targetRoot, bones[i]);
27181
- }
27182
- target.bones = destBones;
27183
- }
27184
- };
27185
27154
  _create_class$2(Skin, [
27186
27155
  {
27187
27156
  key: "rootBone",
@@ -27245,10 +27214,7 @@ __decorate$1([
27245
27214
  ignoreClone
27246
27215
  ], Skin.prototype, "_updatedManager", void 0);
27247
27216
  __decorate$1([
27248
- ignoreClone
27249
- ], Skin.prototype, "_rootBone", void 0);
27250
- __decorate$1([
27251
- ignoreClone
27217
+ deepClone
27252
27218
  ], Skin.prototype, "_bones", void 0);
27253
27219
  __decorate$1([
27254
27220
  ignoreClone
@@ -27297,8 +27263,8 @@ var SkinUpdateFlag = /*#__PURE__*/ function(SkinUpdateFlag) {
27297
27263
  };
27298
27264
  /**
27299
27265
  * @internal
27300
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
27301
- MeshRenderer.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
27266
+ */ _proto._cloneTo = function _cloneTo(target) {
27267
+ MeshRenderer.prototype._cloneTo.call(this, target);
27302
27268
  if (this.skin) {
27303
27269
  target._applySkin(null, target.skin);
27304
27270
  }
@@ -27834,9 +27800,7 @@ var ComponentCloner = /*#__PURE__*/ function() {
27834
27800
  for(var k in source){
27835
27801
  CloneManager.cloneProperty(source, target, k, cloneModes[k], srcRoot, targetRoot, deepInstanceMap);
27836
27802
  }
27837
- if (source._cloneTo) {
27838
- source._cloneTo(target, srcRoot, targetRoot);
27839
- }
27803
+ source._cloneTo == null ? void 0 : source._cloneTo.call(source, target, srcRoot, targetRoot);
27840
27804
  };
27841
27805
  return ComponentCloner;
27842
27806
  }();
@@ -28020,6 +27984,11 @@ var ComponentCloner = /*#__PURE__*/ function() {
28020
27984
  };
28021
27985
  /**
28022
27986
  * @internal
27987
+ */ _proto._remap = function _remap(srcRoot, targetRoot) {
27988
+ return CloneUtils.remapEntity(srcRoot, targetRoot, this);
27989
+ };
27990
+ /**
27991
+ * @internal
28023
27992
  */ _proto._markAsTemplate = function _markAsTemplate(templateResource) {
28024
27993
  this._isTemplate = true;
28025
27994
  this._templateResource = templateResource;
@@ -35995,7 +35964,7 @@ function _type_of1$1(obj) {
35995
35964
  };
35996
35965
  /**
35997
35966
  * @internal
35998
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
35967
+ */ _proto._cloneTo = function _cloneTo(target) {
35999
35968
  var animatorController = target._animatorController;
36000
35969
  if (animatorController) {
36001
35970
  target._addResourceReferCount(animatorController, 1);
@@ -41104,9 +41073,6 @@ __decorate$1([
41104
41073
  __decorate$1([
41105
41074
  ignoreClone
41106
41075
  ], ParticleGenerator.prototype, "_subPrimitive", void 0);
41107
- __decorate$1([
41108
- ignoreClone
41109
- ], ParticleGenerator.prototype, "_renderer", void 0);
41110
41076
  __decorate$1([
41111
41077
  ignoreClone
41112
41078
  ], ParticleGenerator.prototype, "_isPlaying", void 0);
@@ -41833,7 +41799,7 @@ ConeShape._tempVector31 = new Vector3();
41833
41799
  };
41834
41800
  /**
41835
41801
  * @internal
41836
- */ _proto._cloneTo = function _cloneTo(target, _, __) {
41802
+ */ _proto._cloneTo = function _cloneTo(target) {
41837
41803
  target.mesh = this._mesh;
41838
41804
  };
41839
41805
  _create_class$2(MeshShape, [
@@ -42800,7 +42766,7 @@ AudioManager._needsUserGestureResume = false;
42800
42766
  };
42801
42767
  /**
42802
42768
  * @internal
42803
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
42769
+ */ _proto._cloneTo = function _cloneTo(target) {
42804
42770
  var _target__clip;
42805
42771
  (_target__clip = target._clip) == null ? void 0 : _target__clip._addReferCount(1);
42806
42772
  target._gainNode.gain.setValueAtTime(target._volume, AudioManager.getContext().currentTime);
@@ -46501,11 +46467,14 @@ var ReflectionParser = /*#__PURE__*/ function() {
46501
46467
  return resource;
46502
46468
  });
46503
46469
  } else if (ReflectionParser._isComponentRef(value)) {
46504
- var _this__context_components_get;
46505
- return Promise.resolve((_this__context_components_get = this._context.components.get(value.componentId)) != null ? _this__context_components_get : null);
46470
+ var entity = this._resolveEntityByPath(value.entityPath);
46471
+ if (!entity) return Promise.resolve(null);
46472
+ var type = Loader.getClass(value.componentType);
46473
+ if (!type) return Promise.resolve(null);
46474
+ var _entity_getComponents_value_componentIndex;
46475
+ return Promise.resolve((_entity_getComponents_value_componentIndex = entity.getComponents(type, [])[value.componentIndex]) != null ? _entity_getComponents_value_componentIndex : null);
46506
46476
  } else if (ReflectionParser._isEntityRef(value)) {
46507
- // entity reference
46508
- return Promise.resolve(this._context.entityMap.get(value.entityId));
46477
+ return Promise.resolve(this._resolveEntityByPath(value.entityPath));
46509
46478
  } else if (ReflectionParser._isSignalRef(value)) {
46510
46479
  return this.parseSignal(value);
46511
46480
  } else if (originValue) {
@@ -46563,6 +46532,16 @@ var ReflectionParser = /*#__PURE__*/ function() {
46563
46532
  return Promise.resolve(entity);
46564
46533
  }
46565
46534
  };
46535
+ _proto._resolveEntityByPath = function _resolveEntityByPath(entityPath) {
46536
+ var _this__context = this._context, rootIds = _this__context.rootIds, entityMap = _this__context.entityMap;
46537
+ if (!entityPath.length || entityPath[0] >= rootIds.length) return null;
46538
+ var entity = entityMap.get(rootIds[entityPath[0]]);
46539
+ for(var i = 1; i < entityPath.length; i++){
46540
+ if (!entity || entityPath[i] >= entity.children.length) return null;
46541
+ entity = entity.children[entityPath[i]];
46542
+ }
46543
+ return entity;
46544
+ };
46566
46545
  ReflectionParser._isClass = function _isClass(value) {
46567
46546
  return value["class"] !== undefined;
46568
46547
  };
@@ -46573,10 +46552,10 @@ var ReflectionParser = /*#__PURE__*/ function() {
46573
46552
  return value["url"] !== undefined;
46574
46553
  };
46575
46554
  ReflectionParser._isEntityRef = function _isEntityRef(value) {
46576
- return value["entityId"] !== undefined;
46555
+ return Array.isArray(value["entityPath"]) && value["componentType"] === undefined;
46577
46556
  };
46578
46557
  ReflectionParser._isComponentRef = function _isComponentRef(value) {
46579
- return value["ownerId"] !== undefined && value["componentId"] !== undefined;
46558
+ return Array.isArray(value["entityPath"]) && value["componentType"] !== undefined;
46580
46559
  };
46581
46560
  ReflectionParser._isSignalRef = function _isSignalRef(value) {
46582
46561
  return value["listeners"] !== undefined;
@@ -46802,6 +46781,13 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
46802
46781
  for(var i = 0, l = entities.length; i < l; i++){
46803
46782
  entityMap.set(entitiesConfig[i].id, entities[i]);
46804
46783
  }
46784
+ // Build rootIds in serialization order (not async completion order)
46785
+ var rootIds = _this.context.rootIds;
46786
+ for(var i1 = 0, l1 = entitiesConfig.length; i1 < l1; i1++){
46787
+ if (!entitiesConfig[i1].parent && !entitiesConfig[i1].strippedId) {
46788
+ rootIds.push(entitiesConfig[i1].id);
46789
+ }
46790
+ }
46805
46791
  return entities;
46806
46792
  });
46807
46793
  };
@@ -46927,7 +46913,6 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
46927
46913
  _proto._parseEntity = function _parseEntity(entityConfig, engine) {
46928
46914
  var transform = entityConfig.transform;
46929
46915
  var entity = new Entity(engine, entityConfig.name, transform ? Loader.getClass(transform.class) : Transform);
46930
- if (!entityConfig.parent) this.context.rootIds.push(entityConfig.id);
46931
46916
  this._addEntityPlugin(entityConfig.id, entity);
46932
46917
  return Promise.resolve(entity);
46933
46918
  };
@@ -46940,7 +46925,6 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
46940
46925
  }).then(function(prefabResource) {
46941
46926
  var entity = _instanceof1(prefabResource, PrefabResource) ? prefabResource.instantiate() : prefabResource.instantiateSceneRoot();
46942
46927
  var instanceContext = new ParserContext(engine, ParserType.Prefab, null);
46943
- if (!entityConfig.parent) _this.context.rootIds.push(entityConfig.id);
46944
46928
  _this._generateInstanceContext(entity, instanceContext, "");
46945
46929
  _this._prefabContextMap.set(entity, instanceContext);
46946
46930
  var cbArray = _this._prefabPromiseMap.get(entityConfig.id);
@@ -52920,7 +52904,7 @@ EXT_texture_webp = __decorate([
52920
52904
  ], EXT_texture_webp);
52921
52905
 
52922
52906
  //@ts-ignore
52923
- var version = "2.0.0-alpha.15";
52907
+ var version = "2.0.0-alpha.16";
52924
52908
  console.log("Galacean Engine Version: " + version);
52925
52909
  for(var key in CoreObjects){
52926
52910
  Loader.registerClass(key, CoreObjects[key]);