@galacean/engine-core 1.4.4 → 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
@@ -21312,7 +21309,16 @@ __decorate([
21312
21309
  */ _proto._onLateUpdate = function _onLateUpdate() {
21313
21310
  var transform = this.entity.transform;
21314
21311
  var worldPosition = transform.worldPosition, worldRotationQuaternion = transform.worldRotationQuaternion;
21315
- this._nativeCollider.getWorldTransform(worldPosition, worldRotationQuaternion);
21312
+ var outPosition = DynamicCollider._tempVector3;
21313
+ var outRotation = DynamicCollider._tempQuat;
21314
+ this._nativeCollider.getWorldTransform(outPosition, outRotation);
21315
+ // To resolve the issue where onValueChanged is triggered even though the values are equal
21316
+ if (!Vector3.equals(outPosition, worldPosition)) {
21317
+ worldPosition.copyFrom(outPosition);
21318
+ }
21319
+ if (!Quaternion.equals(outRotation, worldRotationQuaternion)) {
21320
+ worldRotationQuaternion.copyFrom(outRotation);
21321
+ }
21316
21322
  this._updateFlag.flag = false;
21317
21323
  };
21318
21324
  /**
@@ -21348,6 +21354,7 @@ __decorate([
21348
21354
  this._nativeCollider.setMaxDepenetrationVelocity(this._maxDepenetrationVelocity);
21349
21355
  this._nativeCollider.setSleepThreshold(this._sleepThreshold);
21350
21356
  this._nativeCollider.setSolverIterations(this._solverIterations);
21357
+ this._nativeCollider.setUseGravity(this._useGravity);
21351
21358
  this._nativeCollider.setIsKinematic(this._isKinematic);
21352
21359
  this._nativeCollider.setConstraints(this._constraints);
21353
21360
  this._nativeCollider.setCollisionDetectionMode(this._collisionDetectionMode);
@@ -21647,6 +21654,8 @@ __decorate([
21647
21654
  ]);
21648
21655
  return DynamicCollider;
21649
21656
  }(Collider);
21657
+ DynamicCollider._tempVector3 = new Vector3();
21658
+ DynamicCollider._tempQuat = new Quaternion();
21650
21659
  __decorate([
21651
21660
  ignoreClone
21652
21661
  ], DynamicCollider.prototype, "_linearVelocity", void 0);
@@ -21861,6 +21870,7 @@ var Joint = /*#__PURE__*/ function(Component) {
21861
21870
  */ _proto._onEnableInScene = function _onEnableInScene() {
21862
21871
  this._createJoint();
21863
21872
  this._syncNative();
21873
+ this._updateRotation();
21864
21874
  };
21865
21875
  /**
21866
21876
  * @internal
@@ -21889,20 +21899,19 @@ var Joint = /*#__PURE__*/ function(Component) {
21889
21899
  _proto._calculateConnectedAnchor = function _calculateConnectedAnchor() {
21890
21900
  var colliderInfo = this._colliderInfo;
21891
21901
  var connectedColliderInfo = this._connectedColliderInfo;
21892
- var _this_entity_transform = this.entity.transform, selfPos = _this_entity_transform.worldPosition;
21893
- var selfActualAnchor = colliderInfo.actualAnchor;
21894
21902
  var connectedAnchor = connectedColliderInfo.anchor;
21895
21903
  var connectedActualAnchor = connectedColliderInfo.actualAnchor;
21896
21904
  var connectedCollider = connectedColliderInfo.collider;
21897
21905
  // @ts-ignore
21898
21906
  connectedAnchor._onValueChanged = null;
21899
21907
  if (connectedCollider) {
21900
- var _connectedCollider_entity_transform = connectedCollider.entity.transform, connectedPos = _connectedCollider_entity_transform.worldPosition, connectedWorldScale = _connectedCollider_entity_transform.lossyWorldScale;
21901
- Vector3.subtract(selfPos, connectedPos, Joint._tempVector3);
21902
- Vector3.add(Joint._tempVector3, selfActualAnchor, connectedActualAnchor);
21903
- Vector3.divide(connectedActualAnchor, connectedWorldScale, connectedAnchor);
21908
+ var tempVector3 = Joint._tempVector3;
21909
+ var tempMatrix = Joint._tempMatrix;
21910
+ Vector3.transformCoordinate(colliderInfo.anchor, this.entity.transform.worldMatrix, tempVector3);
21911
+ Matrix.invert(connectedCollider.entity.transform.worldMatrix, tempMatrix);
21912
+ Vector3.transformCoordinate(tempVector3, tempMatrix, connectedAnchor);
21904
21913
  } else {
21905
- Vector3.add(selfPos, selfActualAnchor, connectedActualAnchor);
21914
+ Vector3.transformCoordinate(colliderInfo.anchor, this.entity.transform.worldMatrix, connectedActualAnchor);
21906
21915
  connectedAnchor.copyFrom(connectedActualAnchor);
21907
21916
  }
21908
21917
  // @ts-ignore
@@ -21926,6 +21935,17 @@ var Joint = /*#__PURE__*/ function(Component) {
21926
21935
  this._updateActualAnchor(2);
21927
21936
  }
21928
21937
  };
21938
+ _proto._updateRotation = function _updateRotation() {
21939
+ var _this__nativeJoint;
21940
+ var quat = Joint._tempQuat;
21941
+ var connectedColliderInfo = this._connectedColliderInfo;
21942
+ var connectedCollider = connectedColliderInfo.collider;
21943
+ if (connectedCollider) {
21944
+ Quaternion.invert(connectedCollider.entity.transform.worldRotationQuaternion, quat);
21945
+ }
21946
+ Quaternion.multiply(quat, this.entity.transform.worldRotationQuaternion, quat);
21947
+ (_this__nativeJoint = this._nativeJoint) == null ? void 0 : _this__nativeJoint.setRotation(quat);
21948
+ };
21929
21949
  _proto._updateActualAnchor = function _updateActualAnchor(flag) {
21930
21950
  if (flag & 1) {
21931
21951
  var _this__nativeJoint;
@@ -21963,6 +21983,7 @@ var Joint = /*#__PURE__*/ function(Component) {
21963
21983
  value == null ? void 0 : value.entity._updateFlagManager.addListener(this._onConnectedTransformChanged);
21964
21984
  this._connectedColliderInfo.collider = value;
21965
21985
  (_this__nativeJoint = this._nativeJoint) == null ? void 0 : _this__nativeJoint.setConnectedCollider(value == null ? void 0 : value._nativeCollider);
21986
+ this._updateRotation();
21966
21987
  if (this._automaticConnectedAnchor) {
21967
21988
  this._calculateConnectedAnchor();
21968
21989
  } else {
@@ -22109,6 +22130,8 @@ var Joint = /*#__PURE__*/ function(Component) {
22109
22130
  return Joint;
22110
22131
  }(Component);
22111
22132
  Joint._tempVector3 = new Vector3();
22133
+ Joint._tempQuat = new Quaternion();
22134
+ Joint._tempMatrix = new Matrix();
22112
22135
  __decorate([
22113
22136
  deepClone
22114
22137
  ], Joint.prototype, "_colliderInfo", void 0);
@@ -27017,12 +27040,20 @@ PostProcessManager._tempVector3 = new Vector3();
27017
27040
  * @returns Entity
27018
27041
  */ _proto.findEntityByPath = function findEntityByPath(path) {
27019
27042
  var splits = path.split("/").filter(Boolean);
27043
+ if (!splits.length) {
27044
+ return null;
27045
+ }
27046
+ var searchRootName = splits.shift();
27020
27047
  for(var i = 0, n = this.rootEntitiesCount; i < n; i++){
27021
27048
  var findEntity = this.getRootEntity(i);
27022
- if (findEntity.name != splits[0]) continue;
27023
- for(var j = 1, m = splits.length; j < m; ++j){
27024
- findEntity = Entity._findChildByName(findEntity, splits[j]);
27025
- 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
+ }
27026
27057
  }
27027
27058
  return findEntity;
27028
27059
  }