@galacean/engine-core 1.4.5 → 1.4.6

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 CHANGED
@@ -17502,21 +17502,14 @@ var ComponentCloner = /*#__PURE__*/ function() {
17502
17502
  };
17503
17503
  /**
17504
17504
  * Find the entity by path.
17505
- * @param path - The path fo the entity eg: /entity
17505
+ * @param path - The path of the entity eg: /entity
17506
17506
  * @returns The component which be found
17507
17507
  */ _proto.findByPath = function findByPath(path) {
17508
- var splits = path.split("/");
17509
- var entity = this;
17510
- for(var i = 0, length = splits.length; i < length; ++i){
17511
- var split = splits[i];
17512
- if (split) {
17513
- entity = Entity._findChildByName(entity, split);
17514
- if (!entity) {
17515
- return null;
17516
- }
17517
- }
17508
+ var splits = path.split("/").filter(Boolean);
17509
+ if (!splits.length) {
17510
+ return this;
17518
17511
  }
17519
- return entity;
17512
+ return Entity._findChildByName(this, 0, splits, 0);
17520
17513
  };
17521
17514
  /**
17522
17515
  * Create child entity.
@@ -17848,15 +17841,19 @@ var ComponentCloner = /*#__PURE__*/ function() {
17848
17841
  };
17849
17842
  /**
17850
17843
  * @internal
17851
- */ Entity._findChildByName = function _findChildByName(root, name) {
17852
- var children = root._children;
17853
- for(var i = children.length - 1; i >= 0; i--){
17854
- var child = children[i];
17855
- if (child.name === name) {
17856
- return child;
17844
+ */ Entity._findChildByName = function _findChildByName(entity, childIndex, paths, pathIndex) {
17845
+ var searchPath = paths[pathIndex];
17846
+ var isEndPath = pathIndex === paths.length - 1;
17847
+ var children = entity._children;
17848
+ for(var n = children.length; childIndex < n; childIndex++){
17849
+ var child = children[childIndex];
17850
+ if (child.name === searchPath) {
17851
+ // Search success if end path, or downward search
17852
+ return isEndPath ? child : Entity._findChildByName(child, 0, paths, pathIndex + 1);
17857
17853
  }
17858
17854
  }
17859
- return null;
17855
+ // Search failed if first path, or upward search
17856
+ return pathIndex === 0 ? null : Entity._findChildByName(entity.parent, entity.siblingIndex + 1, paths, pathIndex - 1);
17860
17857
  };
17861
17858
  /**
17862
17859
  * @internal
@@ -21361,6 +21358,7 @@ __decorate([
21361
21358
  this._nativeCollider.setMaxDepenetrationVelocity(this._maxDepenetrationVelocity);
21362
21359
  this._nativeCollider.setSleepThreshold(this._sleepThreshold);
21363
21360
  this._nativeCollider.setSolverIterations(this._solverIterations);
21361
+ this._nativeCollider.setUseGravity(this._useGravity);
21364
21362
  this._nativeCollider.setIsKinematic(this._isKinematic);
21365
21363
  this._nativeCollider.setConstraints(this._constraints);
21366
21364
  this._nativeCollider.setCollisionDetectionMode(this._collisionDetectionMode);
@@ -27046,12 +27044,20 @@ PostProcessManager._tempVector3 = new engineMath.Vector3();
27046
27044
  * @returns Entity
27047
27045
  */ _proto.findEntityByPath = function findEntityByPath(path) {
27048
27046
  var splits = path.split("/").filter(Boolean);
27047
+ if (!splits.length) {
27048
+ return null;
27049
+ }
27050
+ var searchRootName = splits.shift();
27049
27051
  for(var i = 0, n = this.rootEntitiesCount; i < n; i++){
27050
27052
  var findEntity = this.getRootEntity(i);
27051
- if (findEntity.name != splits[0]) continue;
27052
- for(var j = 1, m = splits.length; j < m; ++j){
27053
- findEntity = Entity._findChildByName(findEntity, splits[j]);
27054
- if (!findEntity) break;
27053
+ if (findEntity.name !== searchRootName) {
27054
+ continue;
27055
+ }
27056
+ if (splits.length) {
27057
+ findEntity = Entity._findChildByName(findEntity, 0, splits, 0);
27058
+ if (!findEntity) {
27059
+ continue;
27060
+ }
27055
27061
  }
27056
27062
  return findEntity;
27057
27063
  }