@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/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
@@ -21316,7 +21313,16 @@ __decorate([
21316
21313
  */ _proto._onLateUpdate = function _onLateUpdate() {
21317
21314
  var transform = this.entity.transform;
21318
21315
  var worldPosition = transform.worldPosition, worldRotationQuaternion = transform.worldRotationQuaternion;
21319
- this._nativeCollider.getWorldTransform(worldPosition, worldRotationQuaternion);
21316
+ var outPosition = DynamicCollider._tempVector3;
21317
+ var outRotation = DynamicCollider._tempQuat;
21318
+ this._nativeCollider.getWorldTransform(outPosition, outRotation);
21319
+ // To resolve the issue where onValueChanged is triggered even though the values are equal
21320
+ if (!engineMath.Vector3.equals(outPosition, worldPosition)) {
21321
+ worldPosition.copyFrom(outPosition);
21322
+ }
21323
+ if (!engineMath.Quaternion.equals(outRotation, worldRotationQuaternion)) {
21324
+ worldRotationQuaternion.copyFrom(outRotation);
21325
+ }
21320
21326
  this._updateFlag.flag = false;
21321
21327
  };
21322
21328
  /**
@@ -21352,6 +21358,7 @@ __decorate([
21352
21358
  this._nativeCollider.setMaxDepenetrationVelocity(this._maxDepenetrationVelocity);
21353
21359
  this._nativeCollider.setSleepThreshold(this._sleepThreshold);
21354
21360
  this._nativeCollider.setSolverIterations(this._solverIterations);
21361
+ this._nativeCollider.setUseGravity(this._useGravity);
21355
21362
  this._nativeCollider.setIsKinematic(this._isKinematic);
21356
21363
  this._nativeCollider.setConstraints(this._constraints);
21357
21364
  this._nativeCollider.setCollisionDetectionMode(this._collisionDetectionMode);
@@ -21651,6 +21658,8 @@ __decorate([
21651
21658
  ]);
21652
21659
  return DynamicCollider;
21653
21660
  }(exports.Collider);
21661
+ DynamicCollider._tempVector3 = new engineMath.Vector3();
21662
+ DynamicCollider._tempQuat = new engineMath.Quaternion();
21654
21663
  __decorate([
21655
21664
  ignoreClone
21656
21665
  ], DynamicCollider.prototype, "_linearVelocity", void 0);
@@ -21865,6 +21874,7 @@ exports.Joint = /*#__PURE__*/ function(Component) {
21865
21874
  */ _proto._onEnableInScene = function _onEnableInScene() {
21866
21875
  this._createJoint();
21867
21876
  this._syncNative();
21877
+ this._updateRotation();
21868
21878
  };
21869
21879
  /**
21870
21880
  * @internal
@@ -21893,20 +21903,19 @@ exports.Joint = /*#__PURE__*/ function(Component) {
21893
21903
  _proto._calculateConnectedAnchor = function _calculateConnectedAnchor() {
21894
21904
  var colliderInfo = this._colliderInfo;
21895
21905
  var connectedColliderInfo = this._connectedColliderInfo;
21896
- var _this_entity_transform = this.entity.transform, selfPos = _this_entity_transform.worldPosition;
21897
- var selfActualAnchor = colliderInfo.actualAnchor;
21898
21906
  var connectedAnchor = connectedColliderInfo.anchor;
21899
21907
  var connectedActualAnchor = connectedColliderInfo.actualAnchor;
21900
21908
  var connectedCollider = connectedColliderInfo.collider;
21901
21909
  // @ts-ignore
21902
21910
  connectedAnchor._onValueChanged = null;
21903
21911
  if (connectedCollider) {
21904
- var _connectedCollider_entity_transform = connectedCollider.entity.transform, connectedPos = _connectedCollider_entity_transform.worldPosition, connectedWorldScale = _connectedCollider_entity_transform.lossyWorldScale;
21905
- engineMath.Vector3.subtract(selfPos, connectedPos, Joint._tempVector3);
21906
- engineMath.Vector3.add(Joint._tempVector3, selfActualAnchor, connectedActualAnchor);
21907
- engineMath.Vector3.divide(connectedActualAnchor, connectedWorldScale, connectedAnchor);
21912
+ var tempVector3 = Joint._tempVector3;
21913
+ var tempMatrix = Joint._tempMatrix;
21914
+ engineMath.Vector3.transformCoordinate(colliderInfo.anchor, this.entity.transform.worldMatrix, tempVector3);
21915
+ engineMath.Matrix.invert(connectedCollider.entity.transform.worldMatrix, tempMatrix);
21916
+ engineMath.Vector3.transformCoordinate(tempVector3, tempMatrix, connectedAnchor);
21908
21917
  } else {
21909
- engineMath.Vector3.add(selfPos, selfActualAnchor, connectedActualAnchor);
21918
+ engineMath.Vector3.transformCoordinate(colliderInfo.anchor, this.entity.transform.worldMatrix, connectedActualAnchor);
21910
21919
  connectedAnchor.copyFrom(connectedActualAnchor);
21911
21920
  }
21912
21921
  // @ts-ignore
@@ -21930,6 +21939,17 @@ exports.Joint = /*#__PURE__*/ function(Component) {
21930
21939
  this._updateActualAnchor(2);
21931
21940
  }
21932
21941
  };
21942
+ _proto._updateRotation = function _updateRotation() {
21943
+ var _this__nativeJoint;
21944
+ var quat = Joint._tempQuat;
21945
+ var connectedColliderInfo = this._connectedColliderInfo;
21946
+ var connectedCollider = connectedColliderInfo.collider;
21947
+ if (connectedCollider) {
21948
+ engineMath.Quaternion.invert(connectedCollider.entity.transform.worldRotationQuaternion, quat);
21949
+ }
21950
+ engineMath.Quaternion.multiply(quat, this.entity.transform.worldRotationQuaternion, quat);
21951
+ (_this__nativeJoint = this._nativeJoint) == null ? void 0 : _this__nativeJoint.setRotation(quat);
21952
+ };
21933
21953
  _proto._updateActualAnchor = function _updateActualAnchor(flag) {
21934
21954
  if (flag & 1) {
21935
21955
  var _this__nativeJoint;
@@ -21967,6 +21987,7 @@ exports.Joint = /*#__PURE__*/ function(Component) {
21967
21987
  value == null ? void 0 : value.entity._updateFlagManager.addListener(this._onConnectedTransformChanged);
21968
21988
  this._connectedColliderInfo.collider = value;
21969
21989
  (_this__nativeJoint = this._nativeJoint) == null ? void 0 : _this__nativeJoint.setConnectedCollider(value == null ? void 0 : value._nativeCollider);
21990
+ this._updateRotation();
21970
21991
  if (this._automaticConnectedAnchor) {
21971
21992
  this._calculateConnectedAnchor();
21972
21993
  } else {
@@ -22113,6 +22134,8 @@ exports.Joint = /*#__PURE__*/ function(Component) {
22113
22134
  return Joint;
22114
22135
  }(Component);
22115
22136
  exports.Joint._tempVector3 = new engineMath.Vector3();
22137
+ exports.Joint._tempQuat = new engineMath.Quaternion();
22138
+ exports.Joint._tempMatrix = new engineMath.Matrix();
22116
22139
  __decorate([
22117
22140
  deepClone
22118
22141
  ], exports.Joint.prototype, "_colliderInfo", void 0);
@@ -27021,12 +27044,20 @@ PostProcessManager._tempVector3 = new engineMath.Vector3();
27021
27044
  * @returns Entity
27022
27045
  */ _proto.findEntityByPath = function findEntityByPath(path) {
27023
27046
  var splits = path.split("/").filter(Boolean);
27047
+ if (!splits.length) {
27048
+ return null;
27049
+ }
27050
+ var searchRootName = splits.shift();
27024
27051
  for(var i = 0, n = this.rootEntitiesCount; i < n; i++){
27025
27052
  var findEntity = this.getRootEntity(i);
27026
- if (findEntity.name != splits[0]) continue;
27027
- for(var j = 1, m = splits.length; j < m; ++j){
27028
- findEntity = Entity._findChildByName(findEntity, splits[j]);
27029
- 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
+ }
27030
27061
  }
27031
27062
  return findEntity;
27032
27063
  }