@galacean/engine-physics-lite 1.4.0-alpha.1 → 1.4.0-alpha.3
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 +103 -31
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +103 -31
- package/dist/main.js.map +1 -1
- package/dist/module.js +104 -32
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/LiteDynamicCollider.d.ts +4 -0
- package/types/LitePhysics.d.ts +2 -2
- package/types/LitePhysicsScene.d.ts +2 -2
- package/types/shape/LiteBoxColliderShape.d.ts +7 -1
- package/types/shape/LiteColliderShape.d.ts +11 -2
- package/types/shape/LiteSphereColliderShape.d.ts +5 -1
package/dist/main.js
CHANGED
|
@@ -94,6 +94,7 @@ function _instanceof(left, right) {
|
|
|
94
94
|
/** @internal */ this._worldScale = new engine.Vector3(1, 1, 1);
|
|
95
95
|
/** @internal */ this._transform = new LiteTransform();
|
|
96
96
|
/** @internal */ this._invModelMatrix = new engine.Matrix();
|
|
97
|
+
this._rotation = new engine.Vector3();
|
|
97
98
|
this._transform.owner = this;
|
|
98
99
|
this._inverseWorldMatFlag = this._transform.registerWorldChangeFlag();
|
|
99
100
|
}
|
|
@@ -101,7 +102,8 @@ function _instanceof(left, right) {
|
|
|
101
102
|
/**
|
|
102
103
|
* {@inheritDoc IColliderShape.setRotation }
|
|
103
104
|
*/ _proto.setRotation = function setRotation(rotation) {
|
|
104
|
-
|
|
105
|
+
var rotationInRadians = this._rotation.set(engine.MathUtil.degreeToRadian(rotation.x), engine.MathUtil.degreeToRadian(rotation.y), engine.MathUtil.degreeToRadian(rotation.z));
|
|
106
|
+
engine.Quaternion.rotationEuler(rotationInRadians.x, rotationInRadians.y, rotationInRadians.z, this._transform.rotationQuaternion);
|
|
105
107
|
};
|
|
106
108
|
/**
|
|
107
109
|
* {@inheritDoc IColliderShape.setPosition }
|
|
@@ -176,8 +178,12 @@ function _instanceof(left, right) {
|
|
|
176
178
|
};
|
|
177
179
|
return LiteColliderShape;
|
|
178
180
|
}();
|
|
179
|
-
LiteColliderShape.
|
|
181
|
+
LiteColliderShape._tempPos = new engine.Vector3();
|
|
182
|
+
LiteColliderShape._tempRot = new engine.Quaternion();
|
|
183
|
+
LiteColliderShape._tempScale = new engine.Vector3();
|
|
180
184
|
LiteColliderShape._tempPoint = new engine.Vector3();
|
|
185
|
+
LiteColliderShape._tempVector4 = new engine.Vector4();
|
|
186
|
+
LiteColliderShape._ray = new engine.Ray();
|
|
181
187
|
|
|
182
188
|
/**
|
|
183
189
|
* Used to implement transformation related functions.
|
|
@@ -551,19 +557,19 @@ LiteTransform._tempMat42 = new engine.Matrix();
|
|
|
551
557
|
/**
|
|
552
558
|
* {@inheritDoc IDynamicCollider.getInertiaTensor }
|
|
553
559
|
*/ _proto.getInertiaTensor = function getInertiaTensor(out) {
|
|
554
|
-
|
|
560
|
+
engine.Logger.error("Physics-lite don't support getInertiaTensor. Use Physics-PhysX instead!");
|
|
555
561
|
return out;
|
|
556
562
|
};
|
|
557
563
|
/**
|
|
558
564
|
* {@inheritDoc IDynamicCollider.getCenterOfMass }
|
|
559
565
|
*/ _proto.getCenterOfMass = function getCenterOfMass(out) {
|
|
560
|
-
|
|
566
|
+
engine.Logger.error("Physics-lite don't support getCenterOfMass. Use Physics-PhysX instead!");
|
|
561
567
|
return out;
|
|
562
568
|
};
|
|
563
569
|
/**
|
|
564
570
|
* {@inheritDoc IDynamicCollider.setMassAndUpdateInertia }
|
|
565
571
|
*/ _proto.setMassAndUpdateInertia = function setMassAndUpdateInertia(mass) {
|
|
566
|
-
|
|
572
|
+
engine.Logger.error("Physics-lite don't support setMassAndUpdateInertia. Use Physics-PhysX instead!");
|
|
567
573
|
};
|
|
568
574
|
/**
|
|
569
575
|
* {@inheritDoc IDynamicCollider.addForce }
|
|
@@ -598,43 +604,48 @@ LiteTransform._tempMat42 = new engine.Matrix();
|
|
|
598
604
|
/**
|
|
599
605
|
* {@inheritDoc IDynamicCollider.setAngularDamping }
|
|
600
606
|
*/ _proto.setAngularDamping = function setAngularDamping(value) {
|
|
601
|
-
|
|
607
|
+
engine.Logger.error("Physics-lite don't support setAngularDamping. Use Physics-PhysX instead!");
|
|
602
608
|
};
|
|
603
609
|
/**
|
|
604
610
|
* {@inheritDoc IDynamicCollider.getAngularVelocity }
|
|
605
611
|
*/ _proto.getAngularVelocity = function getAngularVelocity(out) {
|
|
606
|
-
|
|
612
|
+
engine.Logger.error("Physics-lite don't support getAngularVelocity. Use Physics-PhysX instead!");
|
|
607
613
|
return out;
|
|
608
614
|
};
|
|
609
615
|
/**
|
|
610
616
|
* {@inheritDoc IDynamicCollider.setAngularVelocity }
|
|
611
617
|
*/ _proto.setAngularVelocity = function setAngularVelocity(value) {
|
|
612
|
-
|
|
618
|
+
engine.Logger.error("Physics-lite don't support setAngularVelocity. Use Physics-PhysX instead!");
|
|
613
619
|
};
|
|
614
620
|
/**
|
|
615
621
|
* {@inheritDoc IDynamicCollider.setCenterOfMass }
|
|
616
622
|
*/ _proto.setCenterOfMass = function setCenterOfMass(value) {
|
|
617
|
-
|
|
623
|
+
engine.Logger.error("Physics-lite don't support setCenterOfMass. Use Physics-PhysX instead!");
|
|
618
624
|
};
|
|
619
625
|
/**
|
|
620
626
|
* {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
|
|
621
627
|
*/ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
|
|
622
|
-
|
|
628
|
+
engine.Logger.error("Physics-lite don't support setCollisionDetectionMode. Use Physics-PhysX instead!");
|
|
623
629
|
};
|
|
624
630
|
/**
|
|
625
631
|
* {@inheritDoc IDynamicCollider.setConstraints }
|
|
626
632
|
*/ _proto.setConstraints = function setConstraints(flags) {
|
|
627
|
-
|
|
633
|
+
engine.Logger.error("Physics-lite don't support setConstraints. Use Physics-PhysX instead!");
|
|
628
634
|
};
|
|
629
635
|
/**
|
|
630
636
|
* {@inheritDoc IDynamicCollider.setInertiaTensor }
|
|
631
637
|
*/ _proto.setInertiaTensor = function setInertiaTensor(value) {
|
|
632
|
-
|
|
638
|
+
engine.Logger.error("Physics-lite don't support setInertiaTensor. Use Physics-PhysX instead!");
|
|
639
|
+
};
|
|
640
|
+
/**
|
|
641
|
+
* {@inheritDoc IDynamicCollider.setUseGravity }
|
|
642
|
+
*/ _proto.setUseGravity = function setUseGravity(value) {
|
|
643
|
+
throw "Physics-lite don't support setUseGravity. Use Physics-PhysX instead!";
|
|
633
644
|
};
|
|
634
645
|
/**
|
|
635
646
|
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
636
647
|
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
637
|
-
|
|
648
|
+
engine.Logger.error("Physics-lite don't support setIsKinematic. Use Physics-PhysX instead!");
|
|
638
649
|
};
|
|
639
650
|
/**
|
|
640
651
|
* {@inheritDoc IDynamicCollider.setLinearDamping }
|
|
@@ -644,28 +655,28 @@ LiteTransform._tempMat42 = new engine.Matrix();
|
|
|
644
655
|
/**
|
|
645
656
|
* {@inheritDoc IDynamicCollider.setLinearDamping }
|
|
646
657
|
*/ _proto.setLinearDamping = function setLinearDamping(value) {
|
|
647
|
-
|
|
658
|
+
engine.Logger.error("Physics-lite don't support setLinearDamping. Use Physics-PhysX instead!");
|
|
648
659
|
};
|
|
649
660
|
/**
|
|
650
661
|
* {@inheritDoc IDynamicCollider.getLinearVelocity }
|
|
651
662
|
*/ _proto.getLinearVelocity = function getLinearVelocity(out) {
|
|
652
|
-
|
|
663
|
+
engine.Logger.error("Physics-lite don't support getLinearVelocity. Use Physics-PhysX instead!");
|
|
653
664
|
return out;
|
|
654
665
|
};
|
|
655
666
|
/**
|
|
656
667
|
* {@inheritDoc IDynamicCollider.setLinearVelocity }
|
|
657
668
|
*/ _proto.setLinearVelocity = function setLinearVelocity(value) {
|
|
658
|
-
|
|
669
|
+
engine.Logger.error("Physics-lite don't support setLinearVelocity. Use Physics-PhysX instead!");
|
|
659
670
|
};
|
|
660
671
|
/**
|
|
661
672
|
* {@inheritDoc IDynamicCollider.setMass }
|
|
662
673
|
*/ _proto.setMass = function setMass(value) {
|
|
663
|
-
|
|
674
|
+
engine.Logger.error("Physics-lite don't support setMass. Use Physics-PhysX instead!");
|
|
664
675
|
};
|
|
665
676
|
/**
|
|
666
677
|
* {@inheritDoc IDynamicCollider.setMaxAngularVelocity }
|
|
667
678
|
*/ _proto.setMaxAngularVelocity = function setMaxAngularVelocity(value) {
|
|
668
|
-
|
|
679
|
+
engine.Logger.error("Physics-lite don't support setMaxAngularVelocity. Use Physics-PhysX instead!");
|
|
669
680
|
};
|
|
670
681
|
/**
|
|
671
682
|
* {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
|
|
@@ -675,17 +686,17 @@ LiteTransform._tempMat42 = new engine.Matrix();
|
|
|
675
686
|
/**
|
|
676
687
|
* {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
|
|
677
688
|
*/ _proto.setMaxDepenetrationVelocity = function setMaxDepenetrationVelocity(value) {
|
|
678
|
-
|
|
689
|
+
engine.Logger.error("Physics-lite don't support setMaxDepenetrationVelocity. Use Physics-PhysX instead!");
|
|
679
690
|
};
|
|
680
691
|
/**
|
|
681
692
|
* {@inheritDoc IDynamicCollider.setSleepThreshold }
|
|
682
693
|
*/ _proto.setSleepThreshold = function setSleepThreshold(value) {
|
|
683
|
-
|
|
694
|
+
engine.Logger.error("Physics-lite don't support setSleepThreshold. Use Physics-PhysX instead!");
|
|
684
695
|
};
|
|
685
696
|
/**
|
|
686
697
|
* {@inheritDoc IDynamicCollider.setSolverIterations }
|
|
687
698
|
*/ _proto.setSolverIterations = function setSolverIterations(value) {
|
|
688
|
-
|
|
699
|
+
engine.Logger.error("Physics-lite don't support setSolverIterations. Use Physics-PhysX instead!");
|
|
689
700
|
};
|
|
690
701
|
/**
|
|
691
702
|
* {@inheritDoc IDynamicCollider.wakeUp }
|
|
@@ -743,11 +754,11 @@ LiteTransform._tempMat42 = new engine.Matrix();
|
|
|
743
754
|
|
|
744
755
|
/**
|
|
745
756
|
* Box collider shape in Lite.
|
|
746
|
-
*/ var LiteBoxColliderShape = /*#__PURE__*/ function(
|
|
747
|
-
_inherits(LiteBoxColliderShape,
|
|
757
|
+
*/ var LiteBoxColliderShape = /*#__PURE__*/ function(LiteColliderShape1) {
|
|
758
|
+
_inherits(LiteBoxColliderShape, LiteColliderShape1);
|
|
748
759
|
function LiteBoxColliderShape(uniqueID, size, material) {
|
|
749
760
|
var _this;
|
|
750
|
-
_this =
|
|
761
|
+
_this = LiteColliderShape1.call(this) || this, _this._halfSize = new engine.Vector3(), _this._sizeScale = new engine.Vector3(1, 1, 1), /** @internal */ _this._boxMin = new engine.Vector3(-0.5, -0.5, -0.5), /** @internal */ _this._boxMax = new engine.Vector3(0.5, 0.5, 0.5);
|
|
751
762
|
_this._id = uniqueID;
|
|
752
763
|
_this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
|
|
753
764
|
_this._setBondingBox();
|
|
@@ -757,13 +768,13 @@ LiteTransform._tempMat42 = new engine.Matrix();
|
|
|
757
768
|
/**
|
|
758
769
|
* {@inheritDoc IColliderShape.setPosition }
|
|
759
770
|
*/ _proto.setPosition = function setPosition(position) {
|
|
760
|
-
|
|
771
|
+
LiteColliderShape1.prototype.setPosition.call(this, position);
|
|
761
772
|
this._setBondingBox();
|
|
762
773
|
};
|
|
763
774
|
/**
|
|
764
775
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
765
776
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
766
|
-
|
|
777
|
+
LiteColliderShape1.prototype.setWorldScale.call(this, scale);
|
|
767
778
|
this._sizeScale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
|
|
768
779
|
this._setBondingBox();
|
|
769
780
|
};
|
|
@@ -774,6 +785,44 @@ LiteTransform._tempMat42 = new engine.Matrix();
|
|
|
774
785
|
this._setBondingBox();
|
|
775
786
|
};
|
|
776
787
|
/**
|
|
788
|
+
* {@inheritDoc IColliderShape.pointDistance }
|
|
789
|
+
*/ _proto.pointDistance = function pointDistance(point) {
|
|
790
|
+
var position = LiteColliderShape._tempPos;
|
|
791
|
+
var rotation = LiteColliderShape._tempRot;
|
|
792
|
+
this._transform.worldMatrix.decompose(position, rotation, LiteColliderShape._tempScale);
|
|
793
|
+
var _this__transform = this._transform, shapePosition = _this__transform.position;
|
|
794
|
+
var m = LiteBoxColliderShape._tempMatrix;
|
|
795
|
+
var invM = LiteBoxColliderShape._tempInvMatrix;
|
|
796
|
+
var p = LiteColliderShape._tempPoint;
|
|
797
|
+
var scale = this._sizeScale;
|
|
798
|
+
var boundingBox = LiteBoxColliderShape._tempBox;
|
|
799
|
+
var _this = this, _boxMin = _this._boxMin, _boxMax = _this._boxMax;
|
|
800
|
+
p.copyFrom(_boxMin);
|
|
801
|
+
p.subtract(shapePosition);
|
|
802
|
+
p.divide(scale);
|
|
803
|
+
boundingBox.min.copyFrom(p);
|
|
804
|
+
p.copyFrom(_boxMax);
|
|
805
|
+
p.subtract(shapePosition);
|
|
806
|
+
p.divide(scale);
|
|
807
|
+
boundingBox.max.copyFrom(p);
|
|
808
|
+
engine.Matrix.affineTransformation(scale, rotation, position, m);
|
|
809
|
+
engine.Matrix.invert(m, invM);
|
|
810
|
+
engine.Vector3.transformCoordinate(point, invM, p);
|
|
811
|
+
var min = boundingBox.min;
|
|
812
|
+
var max = boundingBox.max;
|
|
813
|
+
p.x = Math.max(min.x, Math.min(p.x, max.x));
|
|
814
|
+
p.y = Math.max(min.y, Math.min(p.y, max.y));
|
|
815
|
+
p.z = Math.max(min.z, Math.min(p.z, max.z));
|
|
816
|
+
engine.Vector3.transformCoordinate(p, m, p);
|
|
817
|
+
var res = LiteColliderShape._tempVector4;
|
|
818
|
+
if (engine.Vector3.equals(p, point)) {
|
|
819
|
+
res.set(point.x, point.y, point.z, 0);
|
|
820
|
+
} else {
|
|
821
|
+
res.set(p.x, p.y, p.z, engine.Vector3.distanceSquared(p, point));
|
|
822
|
+
}
|
|
823
|
+
return res;
|
|
824
|
+
};
|
|
825
|
+
/**
|
|
777
826
|
* @internal
|
|
778
827
|
*/ _proto._raycast = function _raycast(ray, hit) {
|
|
779
828
|
var localRay = this._getLocalRay(ray);
|
|
@@ -800,14 +849,16 @@ LiteTransform._tempMat42 = new engine.Matrix();
|
|
|
800
849
|
return LiteBoxColliderShape;
|
|
801
850
|
}(LiteColliderShape);
|
|
802
851
|
LiteBoxColliderShape._tempBox = new engine.BoundingBox();
|
|
852
|
+
LiteBoxColliderShape._tempMatrix = new engine.Matrix();
|
|
853
|
+
LiteBoxColliderShape._tempInvMatrix = new engine.Matrix();
|
|
803
854
|
|
|
804
855
|
/**
|
|
805
856
|
* Sphere collider shape in Lite.
|
|
806
|
-
*/ var LiteSphereColliderShape = /*#__PURE__*/ function(
|
|
807
|
-
_inherits(LiteSphereColliderShape,
|
|
857
|
+
*/ var LiteSphereColliderShape = /*#__PURE__*/ function(LiteColliderShape1) {
|
|
858
|
+
_inherits(LiteSphereColliderShape, LiteColliderShape1);
|
|
808
859
|
function LiteSphereColliderShape(uniqueID, radius, material) {
|
|
809
860
|
var _this;
|
|
810
|
-
_this =
|
|
861
|
+
_this = LiteColliderShape1.call(this) || this, _this._radius = 1, _this._maxScale = 1;
|
|
811
862
|
_this._radius = radius;
|
|
812
863
|
_this._id = uniqueID;
|
|
813
864
|
return _this;
|
|
@@ -821,10 +872,31 @@ LiteBoxColliderShape._tempBox = new engine.BoundingBox();
|
|
|
821
872
|
/**
|
|
822
873
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
823
874
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
824
|
-
|
|
875
|
+
LiteColliderShape1.prototype.setWorldScale.call(this, scale);
|
|
825
876
|
this._maxScale = Math.max(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
|
|
826
877
|
};
|
|
827
878
|
/**
|
|
879
|
+
* {@inheritDoc IColliderShape.pointDistance }
|
|
880
|
+
*/ _proto.pointDistance = function pointDistance(point) {
|
|
881
|
+
var position = LiteColliderShape._tempPos;
|
|
882
|
+
var worldRadius = this.worldRadius;
|
|
883
|
+
this._transform.worldMatrix.decompose(position, LiteColliderShape._tempRot, LiteColliderShape._tempScale);
|
|
884
|
+
var p = LiteColliderShape._tempPoint;
|
|
885
|
+
engine.Vector3.subtract(point, position, p);
|
|
886
|
+
var distanceFromCenter = p.lengthSquared();
|
|
887
|
+
var direction = p.normalize();
|
|
888
|
+
engine.Vector3.scale(direction, worldRadius, p);
|
|
889
|
+
p.add(position);
|
|
890
|
+
var res = LiteColliderShape._tempVector4;
|
|
891
|
+
var distanceSquared = engine.Vector3.distanceSquared(p, point);
|
|
892
|
+
if (distanceFromCenter <= worldRadius * worldRadius) {
|
|
893
|
+
res.set(point.x, point.y, point.z, 0);
|
|
894
|
+
} else {
|
|
895
|
+
res.set(p.x, p.y, p.z, distanceSquared);
|
|
896
|
+
}
|
|
897
|
+
return res;
|
|
898
|
+
};
|
|
899
|
+
/**
|
|
828
900
|
* @internal
|
|
829
901
|
*/ _proto._raycast = function _raycast(ray, hit) {
|
|
830
902
|
var boundingSphere = LiteSphereColliderShape._tempSphere;
|
|
@@ -1226,7 +1298,7 @@ var LitePhysics = /*#__PURE__*/ function() {
|
|
|
1226
1298
|
}();
|
|
1227
1299
|
|
|
1228
1300
|
//@ts-ignore
|
|
1229
|
-
var version = "1.4.0-alpha.
|
|
1301
|
+
var version = "1.4.0-alpha.3";
|
|
1230
1302
|
console.log("Galacean PhysicsLite version: " + version);
|
|
1231
1303
|
|
|
1232
1304
|
exports.LitePhysics = LitePhysics;
|