@galacean/engine-loader 1.2.0-alpha.5 → 1.2.0-alpha.8

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.
@@ -981,6 +981,7 @@ var HierarchyParser = /*#__PURE__*/ function() {
981
981
  }
982
982
  };
983
983
  _proto._applyEntityData = function _applyEntityData(entity, entityConfig) {
984
+ if (entityConfig === void 0) entityConfig = {};
984
985
  var _entityConfig_isActive;
985
986
  entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : entity.isActive;
986
987
  var _entityConfig_name;
@@ -993,12 +994,18 @@ var HierarchyParser = /*#__PURE__*/ function() {
993
994
  };
994
995
  _proto._traverseAddEntityToMap = function _traverseAddEntityToMap(entity, context, path) {
995
996
  var entityMap = context.entityMap, components = context.components;
997
+ var componentsMap = {};
998
+ var componentIndexMap = {};
996
999
  entityMap.set(path, entity);
997
1000
  // @ts-ignore
998
1001
  entity._components.forEach(function(component) {
999
1002
  // @ts-ignore
1000
1003
  var name = miniprogram.Loader.getClassName(component.constructor);
1001
- components.set(path + ":" + name, component);
1004
+ if (!componentsMap[name]) {
1005
+ componentsMap[name] = entity.getComponents(component.constructor, []);
1006
+ componentIndexMap[name] = 0;
1007
+ }
1008
+ components.set(path + ":" + name + "/" + componentIndexMap[name]++, component);
1002
1009
  });
1003
1010
  for(var i = 0; i < entity.children.length; i++){
1004
1011
  var child = entity.children[i];
package/dist/module.js CHANGED
@@ -976,6 +976,7 @@ var HierarchyParser = /*#__PURE__*/ function() {
976
976
  }
977
977
  };
978
978
  _proto._applyEntityData = function _applyEntityData(entity, entityConfig) {
979
+ if (entityConfig === void 0) entityConfig = {};
979
980
  var _entityConfig_isActive;
980
981
  entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : entity.isActive;
981
982
  var _entityConfig_name;
@@ -988,12 +989,18 @@ var HierarchyParser = /*#__PURE__*/ function() {
988
989
  };
989
990
  _proto._traverseAddEntityToMap = function _traverseAddEntityToMap(entity, context, path) {
990
991
  var entityMap = context.entityMap, components = context.components;
992
+ var componentsMap = {};
993
+ var componentIndexMap = {};
991
994
  entityMap.set(path, entity);
992
995
  // @ts-ignore
993
996
  entity._components.forEach(function(component) {
994
997
  // @ts-ignore
995
998
  var name = Loader.getClassName(component.constructor);
996
- components.set(path + ":" + name, component);
999
+ if (!componentsMap[name]) {
1000
+ componentsMap[name] = entity.getComponents(component.constructor, []);
1001
+ componentIndexMap[name] = 0;
1002
+ }
1003
+ components.set(path + ":" + name + "/" + componentIndexMap[name]++, component);
997
1004
  });
998
1005
  for(var i = 0; i < entity.children.length; i++){
999
1006
  var child = entity.children[i];