fixes UseGravity property in rigidbody component (#4165)

This commit is contained in:
jiaxin.lai
2019-04-08 18:14:45 +08:00
committed by Weiliang Wang
parent c694545e12
commit abc2d65da1
2 changed files with 4 additions and 11 deletions
@@ -21,7 +21,7 @@ export class ColliderComponentBase extends PhysicsBasedComponent {
set isTrigger (value) {
this._triggered = value;
if (this._body) {
let type = this._triggered ? ERigidBodyType.DYNAMIC : ERigidBodyType.STATIC;
const type = this._triggered ? ERigidBodyType.DYNAMIC : ERigidBodyType.STATIC;
this._body.setType(type);
this._body.setIsTrigger(value);
}
+3 -10
View File
@@ -453,22 +453,15 @@ export class CannonRigidBody implements RigidBodyBase {
}
private _onWorldBeforeStep () {
// this._useGravity = false;
if (!this._useGravity) {
const gravity = this._cannonBody.world.gravity;
vec3.scaleAndAdd(this._cannonBody.force, this._cannonBody.force, gravity, this._cannonBody.mass * -1);
}
}
private _onWorldPostStep (event: CANNON.IEvent) {
}
private _onSelfPreStep () {
// this._useGravity = false;
// if (!this._useGravity) {
// const gravity = this._cannonBody.world.gravity;
// vec3.scaleAndAdd(this._cannonBody.force, this._cannonBody.force, gravity, this._cannonBody.mass * -1);
// }
if (!this._useGravity) {
this._cannonBody.force.y -= this._cannonBody.mass * this._cannonBody.world.gravity.y;
}
}
private _onSelfPostStep () {