@galacean/engine-core 0.0.0-experimental-2.0-migrate.2 → 0.0.0-experimental-2.0-migrate.4
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 +47 -16
- package/dist/main.js.map +1 -1
- package/dist/module.js +47 -16
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/Entity.d.ts +2 -1
- package/types/asset/LoadItem.d.ts +8 -0
package/dist/main.js
CHANGED
|
@@ -5317,10 +5317,12 @@ __decorate([
|
|
|
5317
5317
|
};
|
|
5318
5318
|
/**
|
|
5319
5319
|
* @internal
|
|
5320
|
-
*/ ComponentsDependencies._removeCheck = function _removeCheck(entity, type) {
|
|
5320
|
+
*/ ComponentsDependencies._removeCheck = function _removeCheck(entity, type, replace) {
|
|
5321
5321
|
var components = entity._components;
|
|
5322
5322
|
var n = components.length;
|
|
5323
5323
|
while(type !== Component){
|
|
5324
|
+
// The replacement still satisfies this type and all of its base types.
|
|
5325
|
+
if (replace && (replace === type || _instanceof(replace.prototype, type))) return;
|
|
5324
5326
|
var count = 0;
|
|
5325
5327
|
for(var i = 0; i < n; i++){
|
|
5326
5328
|
if (_instanceof(components[i], type) && ++count > 1) return;
|
|
@@ -6479,10 +6481,22 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
6479
6481
|
_this = EngineObject.call(this, engine) || this, /** The layer the entity belongs to. */ _this.layer = Layer.Layer0, /** @internal */ _this._isActiveInHierarchy = false, /** @internal */ _this._isActiveInScene = false, /** @internal */ _this._components = [], /** @internal */ _this._scripts = new DisorderedArray(), /** @internal */ _this._scriptsVersion = 0, /** @internal */ _this._children = [], /** @internal */ _this._isRoot = false, /** @internal */ _this._isActive = true, /** @internal */ _this._siblingIndex = -1, /** @internal */ _this._isTemplate = false, /** @internal */ _this._updateFlagManager = new UpdateFlagManager(), _this._parent = null, //--------------------------------------------------------------deprecated----------------------------------------------------------------
|
|
6480
6482
|
_this._invModelMatrix = new engineMath.Matrix();
|
|
6481
6483
|
_this.name = name != null ? name : "Entity";
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
+
var transformType = Transform;
|
|
6485
|
+
var n = components.length;
|
|
6486
|
+
for(var i = n - 1; i >= 0; i--){
|
|
6487
|
+
var componentType = components[i];
|
|
6488
|
+
if (Entity._isTransformType(componentType)) {
|
|
6489
|
+
transformType = componentType;
|
|
6490
|
+
break;
|
|
6491
|
+
}
|
|
6492
|
+
}
|
|
6493
|
+
_this._transform = _this.addComponent(transformType);
|
|
6494
|
+
for(var i1 = 0; i1 < n; i1++){
|
|
6495
|
+
var componentType1 = components[i1];
|
|
6496
|
+
if (!Entity._isTransformType(componentType1)) {
|
|
6497
|
+
_this.addComponent(componentType1);
|
|
6498
|
+
}
|
|
6484
6499
|
}
|
|
6485
|
-
!_this._transform && _this.addComponent(Transform);
|
|
6486
6500
|
_this._inverseWorldMatFlag = _this.registerWorldChangeFlag();
|
|
6487
6501
|
return _this;
|
|
6488
6502
|
}
|
|
@@ -6496,13 +6510,19 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
6496
6510
|
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
6497
6511
|
args[_key - 1] = arguments[_key];
|
|
6498
6512
|
}
|
|
6513
|
+
var needReplaceTransform = Entity._isTransformType(type) && this._transform;
|
|
6514
|
+
if (needReplaceTransform) {
|
|
6515
|
+
ComponentsDependencies._removeCheck(this, this._transform.constructor, type);
|
|
6516
|
+
}
|
|
6499
6517
|
ComponentsDependencies._addCheck(this, type);
|
|
6500
6518
|
var component = _construct(type, [].concat([
|
|
6501
6519
|
this
|
|
6502
6520
|
], args));
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6521
|
+
if (needReplaceTransform) {
|
|
6522
|
+
this._replaceTransform(component);
|
|
6523
|
+
} else {
|
|
6524
|
+
this._components.push(component);
|
|
6525
|
+
}
|
|
6506
6526
|
component._setActive(true, ActiveChangeFlag.All);
|
|
6507
6527
|
return component;
|
|
6508
6528
|
};
|
|
@@ -6710,9 +6730,13 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
6710
6730
|
/**
|
|
6711
6731
|
* @internal
|
|
6712
6732
|
*/ _proto._removeComponent = function _removeComponent(component) {
|
|
6713
|
-
ComponentsDependencies._removeCheck(this, component.constructor);
|
|
6714
6733
|
var components = this._components;
|
|
6715
|
-
components.
|
|
6734
|
+
var index = components.indexOf(component);
|
|
6735
|
+
// A replaced Transform is detached from the component slot immediately but
|
|
6736
|
+
// can still reach here later because object destruction may be deferred.
|
|
6737
|
+
if (index < 0) return;
|
|
6738
|
+
ComponentsDependencies._removeCheck(this, component.constructor);
|
|
6739
|
+
components.splice(index, 1);
|
|
6716
6740
|
};
|
|
6717
6741
|
/**
|
|
6718
6742
|
* @internal
|
|
@@ -6914,15 +6938,18 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
6914
6938
|
}
|
|
6915
6939
|
}
|
|
6916
6940
|
};
|
|
6917
|
-
_proto.
|
|
6941
|
+
_proto._replaceTransform = function _replaceTransform(value) {
|
|
6918
6942
|
var previous = this._transform;
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6943
|
+
value.position.copyFrom(previous.position);
|
|
6944
|
+
value.rotationQuaternion.copyFrom(previous.rotationQuaternion);
|
|
6945
|
+
value.scale.copyFrom(previous.scale);
|
|
6946
|
+
// Keep the unique Transform in the same component slot. Detach the old
|
|
6947
|
+
// instance before destroy because destroy can be deferred during a frame.
|
|
6948
|
+
var components = this._components;
|
|
6949
|
+
var previousIndex = components.indexOf(previous);
|
|
6950
|
+
components[previousIndex] = value;
|
|
6925
6951
|
this._transform = value;
|
|
6952
|
+
previous.destroy();
|
|
6926
6953
|
var children = this._children;
|
|
6927
6954
|
for(var i = 0, n = children.length; i < n; i++){
|
|
6928
6955
|
var _children_i_transform;
|
|
@@ -6938,6 +6965,9 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
6938
6965
|
}
|
|
6939
6966
|
return this._invModelMatrix;
|
|
6940
6967
|
};
|
|
6968
|
+
Entity._isTransformType = function _isTransformType(type) {
|
|
6969
|
+
return type === Transform || _instanceof(type.prototype, Transform);
|
|
6970
|
+
};
|
|
6941
6971
|
/**
|
|
6942
6972
|
* @internal
|
|
6943
6973
|
*/ Entity._findChildByName = function _findChildByName(entity, childIndex, paths, pathIndex) {
|
|
@@ -19953,6 +19983,7 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
19953
19983
|
item.url = !Utils.isAbsoluteUrl(assetBaseURL) && this.baseUrl ? Utils.resolveAbsoluteUrl(this.baseUrl, assetBaseURL) : assetBaseURL;
|
|
19954
19984
|
var _virtualResourceEntry_path;
|
|
19955
19985
|
var remoteAssetBaseURL = (_virtualResourceEntry_path = virtualResourceEntry == null ? void 0 : virtualResourceEntry.path) != null ? _virtualResourceEntry_path : item.url;
|
|
19986
|
+
item.resolvedUrl = remoteAssetBaseURL;
|
|
19956
19987
|
// Check cache
|
|
19957
19988
|
var cacheObject = this._assetUrlPool[remoteAssetBaseURL];
|
|
19958
19989
|
if (cacheObject) {
|