@galacean/engine-loader 2.0.0-alpha.46 → 2.0.0-alpha.47
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/README.md +3 -1
- package/dist/main.js +35 -32
- package/dist/main.js.map +1 -1
- package/dist/module.js +35 -32
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
A subpackage of `@galacean/engine`.
|
|
1
|
+
A subpackage of `@galacean/engine`.
|
|
2
|
+
|
|
3
|
+
Hierarchy loading creates all ordinary and instance-added components before resolving component properties and calls. References use the template component order plus additions; removals run afterward, so deleting a component does not shift a selector before its reference is resolved. Scene and Prefab loading share this lifecycle.
|
package/dist/main.js
CHANGED
|
@@ -1451,16 +1451,31 @@ function _instanceof(left, right) {
|
|
|
1451
1451
|
var refs = this.data.refs;
|
|
1452
1452
|
for(var i = 0, n = entities.length; i < n; i++){
|
|
1453
1453
|
var entityConfig = entities[i];
|
|
1454
|
-
if (HierarchyParser._isPrefabInstanceEntity(entityConfig)) continue;
|
|
1455
1454
|
var entity = entityInstances[i];
|
|
1455
|
+
if (HierarchyParser._isPrefabInstanceEntity(entityConfig)) {
|
|
1456
|
+
var _entityConfig_instance_overrides;
|
|
1457
|
+
var additions = (_entityConfig_instance_overrides = entityConfig.instance.overrides) == null ? void 0 : _entityConfig_instance_overrides.addedComponents;
|
|
1458
|
+
var _additions_length;
|
|
1459
|
+
for(var j = 0, m = (_additions_length = additions == null ? void 0 : additions.length) != null ? _additions_length : 0; j < m; j++){
|
|
1460
|
+
var added = additions[j];
|
|
1461
|
+
var target = HierarchyParser._resolveEntity(entity, added.target);
|
|
1462
|
+
var config = allComponents[added.component];
|
|
1463
|
+
var instance = HierarchyParser._addComponentFromConfig(target, config, refs);
|
|
1464
|
+
pendingComponents.push({
|
|
1465
|
+
instance: instance,
|
|
1466
|
+
config: config
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
continue;
|
|
1470
|
+
}
|
|
1456
1471
|
var componentIndices = entityConfig.components;
|
|
1457
1472
|
if (!componentIndices) continue;
|
|
1458
|
-
for(var
|
|
1459
|
-
var
|
|
1460
|
-
var
|
|
1473
|
+
for(var j1 = 0, m1 = componentIndices.length; j1 < m1; j1++){
|
|
1474
|
+
var config1 = allComponents[componentIndices[j1]];
|
|
1475
|
+
var instance1 = HierarchyParser._addComponentFromConfig(entity, config1, refs);
|
|
1461
1476
|
pendingComponents.push({
|
|
1462
|
-
instance:
|
|
1463
|
-
config:
|
|
1477
|
+
instance: instance1,
|
|
1478
|
+
config: config1
|
|
1464
1479
|
});
|
|
1465
1480
|
}
|
|
1466
1481
|
}
|
|
@@ -1495,7 +1510,6 @@ function _instanceof(left, right) {
|
|
|
1495
1510
|
return Promise.all(promises);
|
|
1496
1511
|
};
|
|
1497
1512
|
_proto._applyOverrides = function _applyOverrides(rootEntity, overrides, promises) {
|
|
1498
|
-
var refs = this.data.refs;
|
|
1499
1513
|
var reflectionParser = this._reflectionParser;
|
|
1500
1514
|
// entityProps — entity-level property overrides
|
|
1501
1515
|
if (overrides.entityProps) {
|
|
@@ -1513,50 +1527,39 @@ function _instanceof(left, right) {
|
|
|
1513
1527
|
promises.push(reflectionParser.parseMutationBlock(target, override1));
|
|
1514
1528
|
}
|
|
1515
1529
|
}
|
|
1516
|
-
// addedComponents — attach top-level components[index] to a prefab entity and parse props
|
|
1517
|
-
if (overrides.addedComponents) {
|
|
1518
|
-
var allComponents = this.data.components;
|
|
1519
|
-
for(var j2 = 0, m2 = overrides.addedComponents.length; j2 < m2; j2++){
|
|
1520
|
-
var added = overrides.addedComponents[j2];
|
|
1521
|
-
var entity1 = HierarchyParser._resolveEntity(rootEntity, added.target);
|
|
1522
|
-
var config = allComponents[added.component];
|
|
1523
|
-
var component = HierarchyParser._addComponentFromConfig(entity1, config, refs);
|
|
1524
|
-
promises.push(reflectionParser.parseMutationBlock(component, config));
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
1530
|
// addedEntities — attach already-created top-level entityInstances[index] as a child
|
|
1528
1531
|
if (overrides.addedEntities) {
|
|
1529
1532
|
var entityInstances = this.context.entityInstances;
|
|
1530
|
-
for(var
|
|
1531
|
-
var
|
|
1532
|
-
var parent = HierarchyParser._resolveEntity(rootEntity,
|
|
1533
|
-
parent.addChild(entityInstances[
|
|
1533
|
+
for(var j2 = 0, m2 = overrides.addedEntities.length; j2 < m2; j2++){
|
|
1534
|
+
var added = overrides.addedEntities[j2];
|
|
1535
|
+
var parent = HierarchyParser._resolveEntity(rootEntity, added.parent);
|
|
1536
|
+
parent.addChild(entityInstances[added.entity]);
|
|
1534
1537
|
}
|
|
1535
1538
|
}
|
|
1536
1539
|
// removedEntities — pre-resolve all targets then destroy (destroy shifts sibling indices)
|
|
1537
1540
|
if (overrides.removedEntities) {
|
|
1538
1541
|
var removed = overrides.removedEntities;
|
|
1539
1542
|
var targets = new Array(removed.length);
|
|
1540
|
-
for(var
|
|
1541
|
-
targets[
|
|
1543
|
+
for(var j3 = 0, m3 = removed.length; j3 < m3; j3++){
|
|
1544
|
+
targets[j3] = HierarchyParser._resolveEntity(rootEntity, removed[j3]);
|
|
1542
1545
|
}
|
|
1543
|
-
for(var
|
|
1544
|
-
targets[
|
|
1546
|
+
for(var j4 = 0, m4 = targets.length; j4 < m4; j4++){
|
|
1547
|
+
targets[j4].destroy();
|
|
1545
1548
|
}
|
|
1546
1549
|
}
|
|
1547
1550
|
// removedComponents — pre-resolve all targets then destroy (destroy shifts component indices)
|
|
1548
1551
|
if (overrides.removedComponents) {
|
|
1549
1552
|
var targets1 = [];
|
|
1550
|
-
for(var
|
|
1551
|
-
var override2 = overrides.removedComponents[
|
|
1552
|
-
var
|
|
1553
|
+
for(var j5 = 0, m5 = overrides.removedComponents.length; j5 < m5; j5++){
|
|
1554
|
+
var override2 = overrides.removedComponents[j5];
|
|
1555
|
+
var entity1 = HierarchyParser._resolveEntity(rootEntity, override2.path);
|
|
1553
1556
|
var selectors = override2.selectors;
|
|
1554
1557
|
for(var k = 0, p = selectors.length; k < p; k++){
|
|
1555
|
-
targets1.push(HierarchyParser._resolveComponent(
|
|
1558
|
+
targets1.push(HierarchyParser._resolveComponent(entity1, selectors[k]));
|
|
1556
1559
|
}
|
|
1557
1560
|
}
|
|
1558
|
-
for(var
|
|
1559
|
-
targets1[
|
|
1561
|
+
for(var j6 = 0, m6 = targets1.length; j6 < m6; j6++){
|
|
1562
|
+
targets1[j6].destroy();
|
|
1560
1563
|
}
|
|
1561
1564
|
}
|
|
1562
1565
|
};
|