@galacean/engine-physics-lite 1.4.0-alpha.0 → 1.4.0-alpha.2
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 +184 -51
- 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 +184 -51
- package/dist/main.js.map +1 -1
- package/dist/module.js +185 -52
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/LiteDynamicCollider.d.ts +40 -0
- package/types/LitePhysics.d.ts +2 -2
- package/types/LitePhysicsScene.d.ts +2 -11
- 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/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Utils,
|
|
1
|
+
import { Utils, Vector3, Quaternion, Vector4, Ray, MathUtil, Matrix, Logger, BoundingBox, BoundingSphere, DisorderedArray, CollisionUtil } from '@galacean/engine';
|
|
2
2
|
|
|
3
3
|
function _set_prototype_of(o, p) {
|
|
4
4
|
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
@@ -90,6 +90,7 @@ function _instanceof(left, right) {
|
|
|
90
90
|
/** @internal */ this._worldScale = new Vector3(1, 1, 1);
|
|
91
91
|
/** @internal */ this._transform = new LiteTransform();
|
|
92
92
|
/** @internal */ this._invModelMatrix = new Matrix();
|
|
93
|
+
this._rotation = new Vector3();
|
|
93
94
|
this._transform.owner = this;
|
|
94
95
|
this._inverseWorldMatFlag = this._transform.registerWorldChangeFlag();
|
|
95
96
|
}
|
|
@@ -97,7 +98,8 @@ function _instanceof(left, right) {
|
|
|
97
98
|
/**
|
|
98
99
|
* {@inheritDoc IColliderShape.setRotation }
|
|
99
100
|
*/ _proto.setRotation = function setRotation(rotation) {
|
|
100
|
-
|
|
101
|
+
var rotationInRadians = this._rotation.set(MathUtil.degreeToRadian(rotation.x), MathUtil.degreeToRadian(rotation.y), MathUtil.degreeToRadian(rotation.z));
|
|
102
|
+
Quaternion.rotationEuler(rotationInRadians.x, rotationInRadians.y, rotationInRadians.z, this._transform.rotationQuaternion);
|
|
101
103
|
};
|
|
102
104
|
/**
|
|
103
105
|
* {@inheritDoc IColliderShape.setPosition }
|
|
@@ -172,8 +174,12 @@ function _instanceof(left, right) {
|
|
|
172
174
|
};
|
|
173
175
|
return LiteColliderShape;
|
|
174
176
|
}();
|
|
175
|
-
LiteColliderShape.
|
|
177
|
+
LiteColliderShape._tempPos = new Vector3();
|
|
178
|
+
LiteColliderShape._tempRot = new Quaternion();
|
|
179
|
+
LiteColliderShape._tempScale = new Vector3();
|
|
176
180
|
LiteColliderShape._tempPoint = new Vector3();
|
|
181
|
+
LiteColliderShape._tempVector4 = new Vector4();
|
|
182
|
+
LiteColliderShape._ray = new Ray();
|
|
177
183
|
|
|
178
184
|
/**
|
|
179
185
|
* Used to implement transformation related functions.
|
|
@@ -482,11 +488,13 @@ LiteTransform._tempMat42 = new Matrix();
|
|
|
482
488
|
*/ _proto.addShape = function addShape(shape) {
|
|
483
489
|
var oldCollider = shape._collider;
|
|
484
490
|
if (oldCollider !== this) {
|
|
491
|
+
var _this__scene;
|
|
485
492
|
if (oldCollider) {
|
|
486
493
|
oldCollider.removeShape(shape);
|
|
487
494
|
}
|
|
488
495
|
this._shapes.push(shape);
|
|
489
496
|
shape._collider = this;
|
|
497
|
+
(_this__scene = this._scene) == null ? void 0 : _this__scene._addColliderShape(shape);
|
|
490
498
|
}
|
|
491
499
|
};
|
|
492
500
|
/**
|
|
@@ -494,8 +502,10 @@ LiteTransform._tempMat42 = new Matrix();
|
|
|
494
502
|
*/ _proto.removeShape = function removeShape(shape) {
|
|
495
503
|
var index = this._shapes.indexOf(shape);
|
|
496
504
|
if (index !== -1) {
|
|
505
|
+
var _this__scene;
|
|
497
506
|
this._shapes.splice(index, 1);
|
|
498
507
|
shape._collider = null;
|
|
508
|
+
(_this__scene = this._scene) == null ? void 0 : _this__scene._removeColliderShape(shape);
|
|
499
509
|
}
|
|
500
510
|
};
|
|
501
511
|
/**
|
|
@@ -541,6 +551,23 @@ LiteTransform._tempMat42 = new Matrix();
|
|
|
541
551
|
}
|
|
542
552
|
var _proto = LiteDynamicCollider.prototype;
|
|
543
553
|
/**
|
|
554
|
+
* {@inheritDoc IDynamicCollider.getInertiaTensor }
|
|
555
|
+
*/ _proto.getInertiaTensor = function getInertiaTensor(out) {
|
|
556
|
+
Logger.error("Physics-lite don't support getInertiaTensor. Use Physics-PhysX instead!");
|
|
557
|
+
return out;
|
|
558
|
+
};
|
|
559
|
+
/**
|
|
560
|
+
* {@inheritDoc IDynamicCollider.getCenterOfMass }
|
|
561
|
+
*/ _proto.getCenterOfMass = function getCenterOfMass(out) {
|
|
562
|
+
Logger.error("Physics-lite don't support getCenterOfMass. Use Physics-PhysX instead!");
|
|
563
|
+
return out;
|
|
564
|
+
};
|
|
565
|
+
/**
|
|
566
|
+
* {@inheritDoc IDynamicCollider.setMassAndUpdateInertia }
|
|
567
|
+
*/ _proto.setMassAndUpdateInertia = function setMassAndUpdateInertia(mass) {
|
|
568
|
+
Logger.error("Physics-lite don't support setMassAndUpdateInertia. Use Physics-PhysX instead!");
|
|
569
|
+
};
|
|
570
|
+
/**
|
|
544
571
|
* {@inheritDoc IDynamicCollider.addForce }
|
|
545
572
|
*/ _proto.addForce = function addForce(force) {
|
|
546
573
|
throw "Physics-lite don't support addForce. Use Physics-PhysX instead!";
|
|
@@ -561,74 +588,111 @@ LiteTransform._tempMat42 = new Matrix();
|
|
|
561
588
|
throw "Physics-lite don't support putToSleep. Use Physics-PhysX instead!";
|
|
562
589
|
};
|
|
563
590
|
/**
|
|
591
|
+
* {@inheritDoc IDynamicCollider.isSleeping }
|
|
592
|
+
*/ _proto.isSleeping = function isSleeping() {
|
|
593
|
+
throw "Physics-lite don't support isSleeping. Use Physics-PhysX instead!";
|
|
594
|
+
};
|
|
595
|
+
/**
|
|
596
|
+
* {@inheritDoc IDynamicCollider.getAngularDamping }
|
|
597
|
+
*/ _proto.getAngularDamping = function getAngularDamping() {
|
|
598
|
+
throw "Physics-lite don't support getAngularDamping. Use Physics-PhysX instead!";
|
|
599
|
+
};
|
|
600
|
+
/**
|
|
564
601
|
* {@inheritDoc IDynamicCollider.setAngularDamping }
|
|
565
602
|
*/ _proto.setAngularDamping = function setAngularDamping(value) {
|
|
566
|
-
|
|
603
|
+
Logger.error("Physics-lite don't support setAngularDamping. Use Physics-PhysX instead!");
|
|
604
|
+
};
|
|
605
|
+
/**
|
|
606
|
+
* {@inheritDoc IDynamicCollider.getAngularVelocity }
|
|
607
|
+
*/ _proto.getAngularVelocity = function getAngularVelocity(out) {
|
|
608
|
+
Logger.error("Physics-lite don't support getAngularVelocity. Use Physics-PhysX instead!");
|
|
609
|
+
return out;
|
|
567
610
|
};
|
|
568
611
|
/**
|
|
569
612
|
* {@inheritDoc IDynamicCollider.setAngularVelocity }
|
|
570
613
|
*/ _proto.setAngularVelocity = function setAngularVelocity(value) {
|
|
571
|
-
|
|
614
|
+
Logger.error("Physics-lite don't support setAngularVelocity. Use Physics-PhysX instead!");
|
|
572
615
|
};
|
|
573
616
|
/**
|
|
574
617
|
* {@inheritDoc IDynamicCollider.setCenterOfMass }
|
|
575
618
|
*/ _proto.setCenterOfMass = function setCenterOfMass(value) {
|
|
576
|
-
|
|
619
|
+
Logger.error("Physics-lite don't support setCenterOfMass. Use Physics-PhysX instead!");
|
|
577
620
|
};
|
|
578
621
|
/**
|
|
579
622
|
* {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
|
|
580
623
|
*/ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
|
|
581
|
-
|
|
624
|
+
Logger.error("Physics-lite don't support setCollisionDetectionMode. Use Physics-PhysX instead!");
|
|
582
625
|
};
|
|
583
626
|
/**
|
|
584
627
|
* {@inheritDoc IDynamicCollider.setConstraints }
|
|
585
628
|
*/ _proto.setConstraints = function setConstraints(flags) {
|
|
586
|
-
|
|
629
|
+
Logger.error("Physics-lite don't support setConstraints. Use Physics-PhysX instead!");
|
|
587
630
|
};
|
|
588
631
|
/**
|
|
589
632
|
* {@inheritDoc IDynamicCollider.setInertiaTensor }
|
|
590
633
|
*/ _proto.setInertiaTensor = function setInertiaTensor(value) {
|
|
591
|
-
|
|
634
|
+
Logger.error("Physics-lite don't support setInertiaTensor. Use Physics-PhysX instead!");
|
|
635
|
+
};
|
|
636
|
+
/**
|
|
637
|
+
* {@inheritDoc IDynamicCollider.setUseGravity }
|
|
638
|
+
*/ _proto.setUseGravity = function setUseGravity(value) {
|
|
639
|
+
throw "Physics-lite don't support setUseGravity. Use Physics-PhysX instead!";
|
|
592
640
|
};
|
|
593
641
|
/**
|
|
594
642
|
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
595
643
|
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
596
|
-
|
|
644
|
+
Logger.error("Physics-lite don't support setIsKinematic. Use Physics-PhysX instead!");
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* {@inheritDoc IDynamicCollider.setLinearDamping }
|
|
648
|
+
*/ _proto.getLinearDamping = function getLinearDamping() {
|
|
649
|
+
throw "Physics-lite don't support getLinearDamping. Use Physics-PhysX instead!";
|
|
597
650
|
};
|
|
598
651
|
/**
|
|
599
652
|
* {@inheritDoc IDynamicCollider.setLinearDamping }
|
|
600
653
|
*/ _proto.setLinearDamping = function setLinearDamping(value) {
|
|
601
|
-
|
|
654
|
+
Logger.error("Physics-lite don't support setLinearDamping. Use Physics-PhysX instead!");
|
|
655
|
+
};
|
|
656
|
+
/**
|
|
657
|
+
* {@inheritDoc IDynamicCollider.getLinearVelocity }
|
|
658
|
+
*/ _proto.getLinearVelocity = function getLinearVelocity(out) {
|
|
659
|
+
Logger.error("Physics-lite don't support getLinearVelocity. Use Physics-PhysX instead!");
|
|
660
|
+
return out;
|
|
602
661
|
};
|
|
603
662
|
/**
|
|
604
663
|
* {@inheritDoc IDynamicCollider.setLinearVelocity }
|
|
605
664
|
*/ _proto.setLinearVelocity = function setLinearVelocity(value) {
|
|
606
|
-
|
|
665
|
+
Logger.error("Physics-lite don't support setLinearVelocity. Use Physics-PhysX instead!");
|
|
607
666
|
};
|
|
608
667
|
/**
|
|
609
668
|
* {@inheritDoc IDynamicCollider.setMass }
|
|
610
669
|
*/ _proto.setMass = function setMass(value) {
|
|
611
|
-
|
|
670
|
+
Logger.error("Physics-lite don't support setMass. Use Physics-PhysX instead!");
|
|
612
671
|
};
|
|
613
672
|
/**
|
|
614
673
|
* {@inheritDoc IDynamicCollider.setMaxAngularVelocity }
|
|
615
674
|
*/ _proto.setMaxAngularVelocity = function setMaxAngularVelocity(value) {
|
|
616
|
-
|
|
675
|
+
Logger.error("Physics-lite don't support setMaxAngularVelocity. Use Physics-PhysX instead!");
|
|
676
|
+
};
|
|
677
|
+
/**
|
|
678
|
+
* {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
|
|
679
|
+
*/ _proto.getMaxDepenetrationVelocity = function getMaxDepenetrationVelocity() {
|
|
680
|
+
throw "Physics-lite don't support getMaxDepenetrationVelocity. Use Physics-PhysX instead!";
|
|
617
681
|
};
|
|
618
682
|
/**
|
|
619
683
|
* {@inheritDoc IDynamicCollider.setMaxDepenetrationVelocity }
|
|
620
684
|
*/ _proto.setMaxDepenetrationVelocity = function setMaxDepenetrationVelocity(value) {
|
|
621
|
-
|
|
685
|
+
Logger.error("Physics-lite don't support setMaxDepenetrationVelocity. Use Physics-PhysX instead!");
|
|
622
686
|
};
|
|
623
687
|
/**
|
|
624
688
|
* {@inheritDoc IDynamicCollider.setSleepThreshold }
|
|
625
689
|
*/ _proto.setSleepThreshold = function setSleepThreshold(value) {
|
|
626
|
-
|
|
690
|
+
Logger.error("Physics-lite don't support setSleepThreshold. Use Physics-PhysX instead!");
|
|
627
691
|
};
|
|
628
692
|
/**
|
|
629
693
|
* {@inheritDoc IDynamicCollider.setSolverIterations }
|
|
630
694
|
*/ _proto.setSolverIterations = function setSolverIterations(value) {
|
|
631
|
-
|
|
695
|
+
Logger.error("Physics-lite don't support setSolverIterations. Use Physics-PhysX instead!");
|
|
632
696
|
};
|
|
633
697
|
/**
|
|
634
698
|
* {@inheritDoc IDynamicCollider.wakeUp }
|
|
@@ -686,11 +750,11 @@ LiteTransform._tempMat42 = new Matrix();
|
|
|
686
750
|
|
|
687
751
|
/**
|
|
688
752
|
* Box collider shape in Lite.
|
|
689
|
-
*/ var LiteBoxColliderShape = /*#__PURE__*/ function(
|
|
690
|
-
_inherits(LiteBoxColliderShape,
|
|
753
|
+
*/ var LiteBoxColliderShape = /*#__PURE__*/ function(LiteColliderShape1) {
|
|
754
|
+
_inherits(LiteBoxColliderShape, LiteColliderShape1);
|
|
691
755
|
function LiteBoxColliderShape(uniqueID, size, material) {
|
|
692
756
|
var _this;
|
|
693
|
-
_this =
|
|
757
|
+
_this = LiteColliderShape1.call(this) || this, _this._halfSize = new Vector3(), _this._sizeScale = new Vector3(1, 1, 1), /** @internal */ _this._boxMin = new Vector3(-0.5, -0.5, -0.5), /** @internal */ _this._boxMax = new Vector3(0.5, 0.5, 0.5);
|
|
694
758
|
_this._id = uniqueID;
|
|
695
759
|
_this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
|
|
696
760
|
_this._setBondingBox();
|
|
@@ -700,13 +764,13 @@ LiteTransform._tempMat42 = new Matrix();
|
|
|
700
764
|
/**
|
|
701
765
|
* {@inheritDoc IColliderShape.setPosition }
|
|
702
766
|
*/ _proto.setPosition = function setPosition(position) {
|
|
703
|
-
|
|
767
|
+
LiteColliderShape1.prototype.setPosition.call(this, position);
|
|
704
768
|
this._setBondingBox();
|
|
705
769
|
};
|
|
706
770
|
/**
|
|
707
771
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
708
772
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
709
|
-
|
|
773
|
+
LiteColliderShape1.prototype.setWorldScale.call(this, scale);
|
|
710
774
|
this._sizeScale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
|
|
711
775
|
this._setBondingBox();
|
|
712
776
|
};
|
|
@@ -717,6 +781,44 @@ LiteTransform._tempMat42 = new Matrix();
|
|
|
717
781
|
this._setBondingBox();
|
|
718
782
|
};
|
|
719
783
|
/**
|
|
784
|
+
* {@inheritDoc IColliderShape.pointDistance }
|
|
785
|
+
*/ _proto.pointDistance = function pointDistance(point) {
|
|
786
|
+
var position = LiteColliderShape._tempPos;
|
|
787
|
+
var rotation = LiteColliderShape._tempRot;
|
|
788
|
+
this._transform.worldMatrix.decompose(position, rotation, LiteColliderShape._tempScale);
|
|
789
|
+
var _this__transform = this._transform, shapePosition = _this__transform.position;
|
|
790
|
+
var m = LiteBoxColliderShape._tempMatrix;
|
|
791
|
+
var invM = LiteBoxColliderShape._tempInvMatrix;
|
|
792
|
+
var p = LiteColliderShape._tempPoint;
|
|
793
|
+
var scale = this._sizeScale;
|
|
794
|
+
var boundingBox = LiteBoxColliderShape._tempBox;
|
|
795
|
+
var _this = this, _boxMin = _this._boxMin, _boxMax = _this._boxMax;
|
|
796
|
+
p.copyFrom(_boxMin);
|
|
797
|
+
p.subtract(shapePosition);
|
|
798
|
+
p.divide(scale);
|
|
799
|
+
boundingBox.min.copyFrom(p);
|
|
800
|
+
p.copyFrom(_boxMax);
|
|
801
|
+
p.subtract(shapePosition);
|
|
802
|
+
p.divide(scale);
|
|
803
|
+
boundingBox.max.copyFrom(p);
|
|
804
|
+
Matrix.affineTransformation(scale, rotation, position, m);
|
|
805
|
+
Matrix.invert(m, invM);
|
|
806
|
+
Vector3.transformCoordinate(point, invM, p);
|
|
807
|
+
var min = boundingBox.min;
|
|
808
|
+
var max = boundingBox.max;
|
|
809
|
+
p.x = Math.max(min.x, Math.min(p.x, max.x));
|
|
810
|
+
p.y = Math.max(min.y, Math.min(p.y, max.y));
|
|
811
|
+
p.z = Math.max(min.z, Math.min(p.z, max.z));
|
|
812
|
+
Vector3.transformCoordinate(p, m, p);
|
|
813
|
+
var res = LiteColliderShape._tempVector4;
|
|
814
|
+
if (Vector3.equals(p, point)) {
|
|
815
|
+
res.set(point.x, point.y, point.z, 0);
|
|
816
|
+
} else {
|
|
817
|
+
res.set(p.x, p.y, p.z, Vector3.distanceSquared(p, point));
|
|
818
|
+
}
|
|
819
|
+
return res;
|
|
820
|
+
};
|
|
821
|
+
/**
|
|
720
822
|
* @internal
|
|
721
823
|
*/ _proto._raycast = function _raycast(ray, hit) {
|
|
722
824
|
var localRay = this._getLocalRay(ray);
|
|
@@ -743,14 +845,16 @@ LiteTransform._tempMat42 = new Matrix();
|
|
|
743
845
|
return LiteBoxColliderShape;
|
|
744
846
|
}(LiteColliderShape);
|
|
745
847
|
LiteBoxColliderShape._tempBox = new BoundingBox();
|
|
848
|
+
LiteBoxColliderShape._tempMatrix = new Matrix();
|
|
849
|
+
LiteBoxColliderShape._tempInvMatrix = new Matrix();
|
|
746
850
|
|
|
747
851
|
/**
|
|
748
852
|
* Sphere collider shape in Lite.
|
|
749
|
-
*/ var LiteSphereColliderShape = /*#__PURE__*/ function(
|
|
750
|
-
_inherits(LiteSphereColliderShape,
|
|
853
|
+
*/ var LiteSphereColliderShape = /*#__PURE__*/ function(LiteColliderShape1) {
|
|
854
|
+
_inherits(LiteSphereColliderShape, LiteColliderShape1);
|
|
751
855
|
function LiteSphereColliderShape(uniqueID, radius, material) {
|
|
752
856
|
var _this;
|
|
753
|
-
_this =
|
|
857
|
+
_this = LiteColliderShape1.call(this) || this, _this._radius = 1, _this._maxScale = 1;
|
|
754
858
|
_this._radius = radius;
|
|
755
859
|
_this._id = uniqueID;
|
|
756
860
|
return _this;
|
|
@@ -764,10 +868,31 @@ LiteBoxColliderShape._tempBox = new BoundingBox();
|
|
|
764
868
|
/**
|
|
765
869
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
766
870
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
767
|
-
|
|
871
|
+
LiteColliderShape1.prototype.setWorldScale.call(this, scale);
|
|
768
872
|
this._maxScale = Math.max(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
|
|
769
873
|
};
|
|
770
874
|
/**
|
|
875
|
+
* {@inheritDoc IColliderShape.pointDistance }
|
|
876
|
+
*/ _proto.pointDistance = function pointDistance(point) {
|
|
877
|
+
var position = LiteColliderShape._tempPos;
|
|
878
|
+
var worldRadius = this.worldRadius;
|
|
879
|
+
this._transform.worldMatrix.decompose(position, LiteColliderShape._tempRot, LiteColliderShape._tempScale);
|
|
880
|
+
var p = LiteColliderShape._tempPoint;
|
|
881
|
+
Vector3.subtract(point, position, p);
|
|
882
|
+
var distanceFromCenter = p.lengthSquared();
|
|
883
|
+
var direction = p.normalize();
|
|
884
|
+
Vector3.scale(direction, worldRadius, p);
|
|
885
|
+
p.add(position);
|
|
886
|
+
var res = LiteColliderShape._tempVector4;
|
|
887
|
+
var distanceSquared = Vector3.distanceSquared(p, point);
|
|
888
|
+
if (distanceFromCenter <= worldRadius * worldRadius) {
|
|
889
|
+
res.set(point.x, point.y, point.z, 0);
|
|
890
|
+
} else {
|
|
891
|
+
res.set(p.x, p.y, p.z, distanceSquared);
|
|
892
|
+
}
|
|
893
|
+
return res;
|
|
894
|
+
};
|
|
895
|
+
/**
|
|
771
896
|
* @internal
|
|
772
897
|
*/ _proto._raycast = function _raycast(ray, hit) {
|
|
773
898
|
var boundingSphere = LiteSphereColliderShape._tempSphere;
|
|
@@ -818,41 +943,26 @@ LiteSphereColliderShape._tempSphere = new BoundingSphere();
|
|
|
818
943
|
console.log("Physics-lite don't support gravity. Use Physics-PhysX instead!");
|
|
819
944
|
};
|
|
820
945
|
/**
|
|
821
|
-
* {@inheritDoc IPhysicsManager.addColliderShape }
|
|
822
|
-
*/ _proto.addColliderShape = function addColliderShape(colliderShape) {
|
|
823
|
-
this._eventMap[colliderShape._id] = {};
|
|
824
|
-
};
|
|
825
|
-
/**
|
|
826
|
-
* {@inheritDoc IPhysicsManager.removeColliderShape }
|
|
827
|
-
*/ _proto.removeColliderShape = function removeColliderShape(colliderShape) {
|
|
828
|
-
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents, eventMap = _this._eventMap;
|
|
829
|
-
var id = colliderShape._id;
|
|
830
|
-
currentEvents.forEach(function(event, i) {
|
|
831
|
-
if (event.index1 == id) {
|
|
832
|
-
currentEvents.deleteByIndex(i);
|
|
833
|
-
eventPool.push(event);
|
|
834
|
-
} else if (event.index2 == id) {
|
|
835
|
-
currentEvents.deleteByIndex(i);
|
|
836
|
-
eventPool.push(event);
|
|
837
|
-
// If the shape is big index, should clear from the small index shape subMap
|
|
838
|
-
eventMap[event.index1][id] = undefined;
|
|
839
|
-
}
|
|
840
|
-
});
|
|
841
|
-
delete eventMap[id];
|
|
842
|
-
};
|
|
843
|
-
/**
|
|
844
946
|
* {@inheritDoc IPhysicsManager.addCollider }
|
|
845
947
|
*/ _proto.addCollider = function addCollider(actor) {
|
|
948
|
+
actor._scene = this;
|
|
846
949
|
var colliders = actor._isStaticCollider ? this._staticColliders : this._dynamicColliders;
|
|
847
950
|
colliders.push(actor);
|
|
951
|
+
var shapes = actor._shapes;
|
|
952
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
953
|
+
this._addColliderShape(shapes[i]);
|
|
954
|
+
}
|
|
848
955
|
};
|
|
849
956
|
/**
|
|
850
957
|
* {@inheritDoc IPhysicsManager.removeCollider }
|
|
851
958
|
*/ _proto.removeCollider = function removeCollider(collider) {
|
|
959
|
+
collider._scene = null;
|
|
852
960
|
var colliders = collider._isStaticCollider ? this._staticColliders : this._dynamicColliders;
|
|
853
961
|
var index = colliders.indexOf(collider);
|
|
854
|
-
|
|
855
|
-
|
|
962
|
+
index > -1 && colliders.splice(index, 1);
|
|
963
|
+
var shapes = collider._shapes;
|
|
964
|
+
for(var i = 0, n = shapes.length; i < n; i++){
|
|
965
|
+
this._removeColliderShape(shapes[i]);
|
|
856
966
|
}
|
|
857
967
|
};
|
|
858
968
|
/**
|
|
@@ -900,6 +1010,29 @@ LiteSphereColliderShape._tempSphere = new BoundingSphere();
|
|
|
900
1010
|
*/ _proto.removeCharacterController = function removeCharacterController(characterController) {
|
|
901
1011
|
throw "Physics-lite don't support removeCharacterController. Use Physics-PhysX instead!";
|
|
902
1012
|
};
|
|
1013
|
+
/**
|
|
1014
|
+
* @internal
|
|
1015
|
+
*/ _proto._addColliderShape = function _addColliderShape(colliderShape) {
|
|
1016
|
+
this._eventMap[colliderShape._id] = {};
|
|
1017
|
+
};
|
|
1018
|
+
/**
|
|
1019
|
+
* @internal
|
|
1020
|
+
*/ _proto._removeColliderShape = function _removeColliderShape(colliderShape) {
|
|
1021
|
+
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents, eventMap = _this._eventMap;
|
|
1022
|
+
var id = colliderShape._id;
|
|
1023
|
+
currentEvents.forEach(function(event, i) {
|
|
1024
|
+
if (event.index1 == id) {
|
|
1025
|
+
currentEvents.deleteByIndex(i);
|
|
1026
|
+
eventPool.push(event);
|
|
1027
|
+
} else if (event.index2 == id) {
|
|
1028
|
+
currentEvents.deleteByIndex(i);
|
|
1029
|
+
eventPool.push(event);
|
|
1030
|
+
// If the shape is big index, should clear from the small index shape subMap
|
|
1031
|
+
eventMap[event.index1][id] = undefined;
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
delete eventMap[id];
|
|
1035
|
+
};
|
|
903
1036
|
_proto._getTrigger = function _getTrigger(index1, index2) {
|
|
904
1037
|
var event;
|
|
905
1038
|
if (this._eventPool.length) {
|
|
@@ -1161,7 +1294,7 @@ var LitePhysics = /*#__PURE__*/ function() {
|
|
|
1161
1294
|
}();
|
|
1162
1295
|
|
|
1163
1296
|
//@ts-ignore
|
|
1164
|
-
var version = "1.4.0-alpha.
|
|
1297
|
+
var version = "1.4.0-alpha.2";
|
|
1165
1298
|
console.log("Galacean PhysicsLite version: " + version);
|
|
1166
1299
|
|
|
1167
1300
|
export { LitePhysics, version };
|