pub struct PhysicsJoint {
pub asset_id: AssetId,
pub kind: String,
pub body_a: Option<AssetId>,
pub body_b: Option<AssetId>,
pub anchor_a: [f32; 3],
pub anchor_b: [f32; 3],
pub axis: [f32; 3],
pub limits_enabled: bool,
pub limits: [f32; 2],
pub motor_target_velocity: f32,
pub motor_max_force: f32,
}Expand description
A physics constraint connecting two Props that own a collider.
The joint pins anchor_a on body_a to anchor_b on body_b and locks
the relative motion of the two bodies according to its kind. Anchors are
in each body’s local frame: [0, 0, 0] is the body’s own pivot.
To anchor a body to “the world” (no second prop), leave body_b empty: a
hidden static anchor is created at anchor_b (interpreted as world space in
that case) and the body joints to it. This is the pendulum / lamp / trapeze
pattern.
axis only applies to revolute and prismatic: it is the single free
axis (rotation or translation) in each body’s local frame. The vector is
normalised on load; a zero axis falls back to [0, 1, 0].
limits_enabled clamps the free axis: angle in degrees for revolute,
distance in world units for prismatic. motor_target_velocity and
motor_max_force drive the free axis when motor_max_force > 0; the
velocity is in degrees/sec for revolute, units/sec for prismatic.
PhysicsJoint {
kind: "revolute".into(),
anchor_a: [0.0, 2.0, 0.0],
anchor_b: [0.0, 5.0, 0.0],
axis: [0.0, 0.0, 1.0],
..Default::default()
};Fields§
§asset_id: AssetIdAsset identity; injected via inject_name. Not part of args.
kind: StringConstraint shape; defaults to “fixed”.
body_a: Option<AssetId>First body: a Prop name. Required.
body_b: Option<AssetId>Second body: a Prop name. Empty means “world anchor”, in which
case anchor_b is interpreted as a world-space position.
anchor_a: [f32; 3]Attach point in body_a’s local frame.
anchor_b: [f32; 3]Attach point in body_b’s local frame (or world space if body_b is
empty).
axis: [f32; 3]Free axis for revolute/prismatic, in each body’s local frame.
limits_enabled: boolWhether the limits clamp is enforced.
limits: [f32; 2][min, max] clamp on the free axis: degrees for revolute, world units
for prismatic. Ignored unless limits_enabled is true.
motor_target_velocity: f32Motor target velocity: degrees/sec for revolute, world units/sec for
prismatic. Ignored unless motor_max_force > 0.
motor_max_force: f32Motor force budget. The motor is inactive when this is 0.
Implementations§
Source§impl PhysicsJoint
impl PhysicsJoint
Sourcepub fn parsed_kind(&self) -> PhysicsJointKind
pub fn parsed_kind(&self) -> PhysicsJointKind
Parse kind; falls back to Fixed for unrecognised values so a typo
degrades safely. Cross-reference validation flags bad kinds explicitly.
Trait Implementations§
Source§impl Clone for PhysicsJoint
impl Clone for PhysicsJoint
Source§fn clone(&self) -> PhysicsJoint
fn clone(&self) -> PhysicsJoint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Component for PhysicsJoint
impl Component for PhysicsJoint
Source§const NAME: &'static str = "PhysicsJoint"
const NAME: &'static str = "PhysicsJoint"
Source§fn inject_name(&mut self, id: AssetId)
fn inject_name(&mut self, id: AssetId)
Source§fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Source§impl ComponentSlot for PhysicsJoint
impl ComponentSlot for PhysicsJoint
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.