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