@galacean/engine-loader 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.
- package/dist/main.js +26 -8
- package/dist/main.js.map +1 -1
- package/dist/module.js +26 -8
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +1 -0
- package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +4 -3
package/dist/main.js
CHANGED
|
@@ -850,11 +850,14 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
850
850
|
return resource;
|
|
851
851
|
});
|
|
852
852
|
} else if (ReflectionParser._isComponentRef(value)) {
|
|
853
|
-
var
|
|
854
|
-
return Promise.resolve(
|
|
853
|
+
var entity = this._resolveEntityByPath(value.entityPath);
|
|
854
|
+
if (!entity) return Promise.resolve(null);
|
|
855
|
+
var type = engineCore.Loader.getClass(value.componentType);
|
|
856
|
+
if (!type) return Promise.resolve(null);
|
|
857
|
+
var _entity_getComponents_value_componentIndex;
|
|
858
|
+
return Promise.resolve((_entity_getComponents_value_componentIndex = entity.getComponents(type, [])[value.componentIndex]) != null ? _entity_getComponents_value_componentIndex : null);
|
|
855
859
|
} else if (ReflectionParser._isEntityRef(value)) {
|
|
856
|
-
|
|
857
|
-
return Promise.resolve(this._context.entityMap.get(value.entityId));
|
|
860
|
+
return Promise.resolve(this._resolveEntityByPath(value.entityPath));
|
|
858
861
|
} else if (ReflectionParser._isSignalRef(value)) {
|
|
859
862
|
return this.parseSignal(value);
|
|
860
863
|
} else if (originValue) {
|
|
@@ -912,6 +915,16 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
912
915
|
return Promise.resolve(entity);
|
|
913
916
|
}
|
|
914
917
|
};
|
|
918
|
+
_proto._resolveEntityByPath = function _resolveEntityByPath(entityPath) {
|
|
919
|
+
var _this__context = this._context, rootIds = _this__context.rootIds, entityMap = _this__context.entityMap;
|
|
920
|
+
if (!entityPath.length || entityPath[0] >= rootIds.length) return null;
|
|
921
|
+
var entity = entityMap.get(rootIds[entityPath[0]]);
|
|
922
|
+
for(var i = 1; i < entityPath.length; i++){
|
|
923
|
+
if (!entity || entityPath[i] >= entity.children.length) return null;
|
|
924
|
+
entity = entity.children[entityPath[i]];
|
|
925
|
+
}
|
|
926
|
+
return entity;
|
|
927
|
+
};
|
|
915
928
|
ReflectionParser._isClass = function _isClass(value) {
|
|
916
929
|
return value["class"] !== undefined;
|
|
917
930
|
};
|
|
@@ -922,10 +935,10 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
922
935
|
return value["url"] !== undefined;
|
|
923
936
|
};
|
|
924
937
|
ReflectionParser._isEntityRef = function _isEntityRef(value) {
|
|
925
|
-
return value["
|
|
938
|
+
return Array.isArray(value["entityPath"]) && value["componentType"] === undefined;
|
|
926
939
|
};
|
|
927
940
|
ReflectionParser._isComponentRef = function _isComponentRef(value) {
|
|
928
|
-
return value["
|
|
941
|
+
return Array.isArray(value["entityPath"]) && value["componentType"] !== undefined;
|
|
929
942
|
};
|
|
930
943
|
ReflectionParser._isSignalRef = function _isSignalRef(value) {
|
|
931
944
|
return value["listeners"] !== undefined;
|
|
@@ -1162,6 +1175,13 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
|
1162
1175
|
for(var i = 0, l = entities.length; i < l; i++){
|
|
1163
1176
|
entityMap.set(entitiesConfig[i].id, entities[i]);
|
|
1164
1177
|
}
|
|
1178
|
+
// Build rootIds in serialization order (not async completion order)
|
|
1179
|
+
var rootIds = _this.context.rootIds;
|
|
1180
|
+
for(var i1 = 0, l1 = entitiesConfig.length; i1 < l1; i1++){
|
|
1181
|
+
if (!entitiesConfig[i1].parent && !entitiesConfig[i1].strippedId) {
|
|
1182
|
+
rootIds.push(entitiesConfig[i1].id);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1165
1185
|
return entities;
|
|
1166
1186
|
});
|
|
1167
1187
|
};
|
|
@@ -1287,7 +1307,6 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
|
1287
1307
|
_proto._parseEntity = function _parseEntity(entityConfig, engine) {
|
|
1288
1308
|
var transform = entityConfig.transform;
|
|
1289
1309
|
var entity = new engineCore.Entity(engine, entityConfig.name, transform ? engineCore.Loader.getClass(transform.class) : engineCore.Transform);
|
|
1290
|
-
if (!entityConfig.parent) this.context.rootIds.push(entityConfig.id);
|
|
1291
1310
|
this._addEntityPlugin(entityConfig.id, entity);
|
|
1292
1311
|
return Promise.resolve(entity);
|
|
1293
1312
|
};
|
|
@@ -1300,7 +1319,6 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
|
1300
1319
|
}).then(function(prefabResource) {
|
|
1301
1320
|
var entity = _instanceof(prefabResource, PrefabResource) ? prefabResource.instantiate() : prefabResource.instantiateSceneRoot();
|
|
1302
1321
|
var instanceContext = new ParserContext(engine, ParserType.Prefab, null);
|
|
1303
|
-
if (!entityConfig.parent) _this.context.rootIds.push(entityConfig.id);
|
|
1304
1322
|
_this._generateInstanceContext(entity, instanceContext, "");
|
|
1305
1323
|
_this._prefabContextMap.set(entity, instanceContext);
|
|
1306
1324
|
var cbArray = _this._prefabPromiseMap.get(entityConfig.id);
|