@galacean/engine-physics-lite 1.0.0-beta.8 → 1.0.1
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/browser.js +38 -21
- package/dist/browser.min.js +1 -1
- package/dist/main.js +38 -21
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +121 -37768
- package/dist/module.js +38 -21
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/LitePhysicsScene.d.ts +79 -0
- package/types/shape/LiteBoxColliderShape.d.ts +0 -1
- package/types/shape/LiteColliderShape.d.ts +3 -2
package/dist/module.js
CHANGED
|
@@ -86,6 +86,8 @@ function _instanceof(left, right) {
|
|
|
86
86
|
* Abstract class for collider shapes.
|
|
87
87
|
*/ var LiteColliderShape = /*#__PURE__*/ function() {
|
|
88
88
|
function LiteColliderShape() {
|
|
89
|
+
/** @internal */ this._position = new Vector3();
|
|
90
|
+
/** @internal */ this._worldScale = new Vector3(1, 1, 1);
|
|
89
91
|
/** @internal */ this._transform = new LiteTransform();
|
|
90
92
|
/** @internal */ this._invModelMatrix = new Matrix();
|
|
91
93
|
this._transform.owner = this;
|
|
@@ -100,7 +102,18 @@ function _instanceof(left, right) {
|
|
|
100
102
|
/**
|
|
101
103
|
* {@inheritDoc IColliderShape.setPosition }
|
|
102
104
|
*/ _proto.setPosition = function setPosition(position) {
|
|
103
|
-
|
|
105
|
+
if (position !== this._position) {
|
|
106
|
+
this._position.copyFrom(position);
|
|
107
|
+
}
|
|
108
|
+
this._setLocalPose();
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* {@inheritDoc IColliderShape.setWorldScale }
|
|
112
|
+
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
113
|
+
if (scale !== this._worldScale) {
|
|
114
|
+
this._worldScale.copyFrom(scale);
|
|
115
|
+
}
|
|
116
|
+
this._setLocalPose();
|
|
104
117
|
};
|
|
105
118
|
/**
|
|
106
119
|
* {@inheritDoc IColliderShape.setContactOffset }
|
|
@@ -154,6 +167,11 @@ function _instanceof(left, right) {
|
|
|
154
167
|
}
|
|
155
168
|
return this._invModelMatrix;
|
|
156
169
|
};
|
|
170
|
+
_proto._setLocalPose = function _setLocalPose() {
|
|
171
|
+
var shapePosition = LiteColliderShape._tempPoint;
|
|
172
|
+
Vector3.multiply(this._position, this._worldScale, shapePosition);
|
|
173
|
+
this._transform.position = shapePosition;
|
|
174
|
+
};
|
|
157
175
|
return LiteColliderShape;
|
|
158
176
|
}();
|
|
159
177
|
(function() {
|
|
@@ -713,7 +731,6 @@ var /**
|
|
|
713
731
|
var _this;
|
|
714
732
|
_this = LiteColliderShape.call(this) || this;
|
|
715
733
|
_this._halfSize = new Vector3();
|
|
716
|
-
_this._scale = new Vector3(1, 1, 1);
|
|
717
734
|
/** @internal */ _this._boxMin = new Vector3(-0.5, -0.5, -0.5);
|
|
718
735
|
/** @internal */ _this._boxMax = new Vector3(0.5, 0.5, 0.5);
|
|
719
736
|
_this._id = uniqueID;
|
|
@@ -731,8 +748,8 @@ var /**
|
|
|
731
748
|
/**
|
|
732
749
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
733
750
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
734
|
-
|
|
735
|
-
this.
|
|
751
|
+
LiteColliderShape.prototype.setWorldScale.call(this, scale);
|
|
752
|
+
this._setBondingBox();
|
|
736
753
|
};
|
|
737
754
|
/**
|
|
738
755
|
* {@inheritDoc IBoxColliderShape.setSize }
|
|
@@ -745,8 +762,8 @@ var /**
|
|
|
745
762
|
*/ _proto._raycast = function _raycast(ray, hit) {
|
|
746
763
|
var localRay = this._getLocalRay(ray);
|
|
747
764
|
var boundingBox = LiteBoxColliderShape._tempBox;
|
|
748
|
-
boundingBox.min.set(-this._halfSize.x * this.
|
|
749
|
-
boundingBox.max.set(this._halfSize.x * this.
|
|
765
|
+
boundingBox.min.set(-this._halfSize.x * this._worldScale.x, -this._halfSize.y * this._worldScale.y, -this._halfSize.z * this._worldScale.z);
|
|
766
|
+
boundingBox.max.set(this._halfSize.x * this._worldScale.x, this._halfSize.y * this._worldScale.y, this._halfSize.z * this._worldScale.z);
|
|
750
767
|
var rayDistance = localRay.intersectBox(boundingBox);
|
|
751
768
|
if (rayDistance !== -1) {
|
|
752
769
|
this._updateHitResult(localRay, rayDistance, hit, ray.origin);
|
|
@@ -756,10 +773,11 @@ var /**
|
|
|
756
773
|
}
|
|
757
774
|
};
|
|
758
775
|
_proto._setBondingBox = function _setBondingBox() {
|
|
759
|
-
var
|
|
776
|
+
var position = this._transform.position;
|
|
777
|
+
var scale = this._worldScale;
|
|
760
778
|
var halfSize = this._halfSize;
|
|
761
|
-
|
|
762
|
-
|
|
779
|
+
this._boxMin.set(-halfSize.x * scale.x + position.x, -halfSize.y * scale.y + position.y, -halfSize.z * scale.z + position.z);
|
|
780
|
+
this._boxMax.set(halfSize.x * scale.x + position.x, halfSize.y * scale.y + position.y, halfSize.z * scale.z + position.z);
|
|
763
781
|
};
|
|
764
782
|
return LiteBoxColliderShape;
|
|
765
783
|
}(LiteColliderShape);
|
|
@@ -789,7 +807,8 @@ var /**
|
|
|
789
807
|
/**
|
|
790
808
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
791
809
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
792
|
-
|
|
810
|
+
LiteColliderShape.prototype.setWorldScale.call(this, scale);
|
|
811
|
+
this._maxScale = Math.max(scale.x, scale.y, scale.z);
|
|
793
812
|
};
|
|
794
813
|
/**
|
|
795
814
|
* @internal
|
|
@@ -895,19 +914,17 @@ var /**
|
|
|
895
914
|
var curHit = LitePhysicsManager._currentHit;
|
|
896
915
|
for(var i = 0, len = colliders.length; i < len; i++){
|
|
897
916
|
var collider = colliders[i];
|
|
898
|
-
if (collider._raycast(ray, onRaycast, curHit)) {
|
|
917
|
+
if (collider._raycast(ray, onRaycast, curHit) && curHit.distance < distance) {
|
|
899
918
|
isHit = true;
|
|
900
|
-
if (
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
return true;
|
|
908
|
-
}
|
|
909
|
-
distance = curHit.distance;
|
|
919
|
+
if (hitResult) {
|
|
920
|
+
hitResult.normal.copyFrom(curHit.normal);
|
|
921
|
+
hitResult.point.copyFrom(curHit.point);
|
|
922
|
+
hitResult.distance = curHit.distance;
|
|
923
|
+
hitResult.shapeID = curHit.shapeID;
|
|
924
|
+
} else {
|
|
925
|
+
return true;
|
|
910
926
|
}
|
|
927
|
+
distance = curHit.distance;
|
|
911
928
|
}
|
|
912
929
|
}
|
|
913
930
|
if (!isHit && hitResult) {
|