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 Authored for PhysicsJoint
impl Authored for PhysicsJoint
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<PhysicsJoint, CnResult>
fn from_baked(bytes: &[u8]) -> Result<PhysicsJoint, 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.Source§fn slot(s: &ComponentStorage) -> &Column<PhysicsJoint>
fn slot(s: &ComponentStorage) -> &Column<PhysicsJoint>
Source§fn slot_mut(s: &mut ComponentStorage) -> &mut Column<PhysicsJoint>
fn slot_mut(s: &mut ComponentStorage) -> &mut Column<PhysicsJoint>
Source§impl Debug for PhysicsJoint
impl Debug for PhysicsJoint
Source§impl Default for PhysicsJoint
impl Default for PhysicsJoint
Source§fn default() -> PhysicsJoint
fn default() -> PhysicsJoint
Source§impl<'de> Deserialize<'de> for PhysicsJointwhere
PhysicsJoint: Default,
impl<'de> Deserialize<'de> for PhysicsJointwhere
PhysicsJoint: Default,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PhysicsJoint, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PhysicsJoint, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl RuntimeComponent for PhysicsJoint
Source§impl Serialize for PhysicsJoint
impl Serialize for PhysicsJoint
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for PhysicsJoint
impl RefUnwindSafe for PhysicsJoint
impl Send for PhysicsJoint
impl Sync for PhysicsJoint
impl Unpin for PhysicsJoint
impl UnsafeUnpin for PhysicsJoint
impl UnwindSafe for PhysicsJoint
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more