Body constructor
Body({
- int collisionFilterGroup = 1,
- int collisionFilterMask = -1,
- bool collisionResponse = true,
- Vec3? position,
- Vec3? velocity,
- double mass = 0,
- Material? material,
- double linearDamping = 0.01,
- BodyTypes? type,
- bool allowSleep = true,
- double sleepSpeedLimit = 0.1,
- num sleepTimeLimit = 1,
- Quaternion? quaternion,
- Vec3? angularVelocity,
- bool fixedRotation = false,
- double angularDamping = 0.01,
- Vec3? linearFactor,
- Vec3? angularFactor,
- Shape? shape,
- bool isTrigger = false,
Implementation
Body({
this.collisionFilterGroup = 1,
this.collisionFilterMask = -1,
this.collisionResponse = true,
Vec3? position,
Vec3? velocity,
this.mass = 0,
this.material,
this.linearDamping = 0.01,
BodyTypes? type,
this.allowSleep = true,
this.sleepSpeedLimit = 0.1,
this.sleepTimeLimit = 1,
Quaternion? quaternion,
Vec3? angularVelocity,
this.fixedRotation = false,
this.angularDamping = 0.01,
Vec3? linearFactor,
Vec3? angularFactor,
Shape? shape,
this.isTrigger = false,
}):super() {
id = Body.idCounter++;
if (position != null) {
this.position.copy(position);
previousPosition.copy(position);
interpolatedPosition.copy(position);
initPosition.copy(position);
}
if (velocity != null) {
this.velocity.copy(velocity);
}
invMass = mass > 0 ? 1.0 / mass : 0;
this.type = mass <= 0.0 ? BodyTypes.static : BodyTypes.dynamic;
// if (type == BodyTypes.static) {
// this.type = type!;
// }
this.type = type ?? this.type;
if (quaternion != null) {
this.quaternion.copy(quaternion);
previousQuaternion.copy(quaternion);
interpolatedQuaternion.copy(quaternion);
initQuaternion.copy(quaternion);
}
if (angularVelocity != null) {
this.angularVelocity.copy(angularVelocity);
}
if (linearFactor != null) {
this.linearFactor.copy(linearFactor);
}
if (angularFactor != null) {
this.angularFactor.copy(angularFactor);
}
if (shape != null) {
addShape(shape);
}
updateMassProperties();
}