onMount method
Called when the owning node enters a live scene graph.
Implementation
@override
void onMount() {
final world = findAncestorWorld(node);
if (world == null) {
throw StateError(
'RigidBody mounted with no PhysicsWorld on an ancestor node',
);
}
_world = world;
final handle = world.simulation.createBody(
target: NodePoseTarget(node),
type: _type,
additionalMass: _mass,
);
_handle = handle;
final s = world.simulation;
if (_linearVelocity.length2 > 0) {
s.setBodyLinearVelocity(handle, _linearVelocity);
}
if (_angularVelocity.length2 > 0) {
s.setBodyAngularVelocity(handle, _angularVelocity);
}
if (_linearDamping != 0) s.setBodyLinearDamping(handle, _linearDamping);
if (_angularDamping != 0) s.setBodyAngularDamping(handle, _angularDamping);
if (!_useGravity) s.setBodyGravityScale(handle, 0);
if (_ccdEnabled) s.setBodyCcdEnabled(handle, true);
if (_linearAxisLocks != Vector3(1, 1, 1) ||
_angularAxisLocks != Vector3(1, 1, 1)) {
_pushAxisLocks();
}
}