Skip to main content

SceneObject

Struct SceneObject 

Source
pub struct SceneObject {
    pub id: ObjectId,
    pub kind: ObjectKind,
    pub transform: Transform,
    pub lifetime: Lifetime,
    pub animations: Vec<Animation>,
    pub z_order: i32,
    pub opacity: f32,
    pub blend_mode: BlendMode,
    pub effects: Vec<Effect>,
    pub clip: Option<ClipRect>,
}
Expand description

One renderable element on a scene.

Fields§

§id: ObjectId§kind: ObjectKind§transform: Transform§lifetime: Lifetime§animations: Vec<Animation>§z_order: i32§opacity: f32§blend_mode: BlendMode§effects: Vec<Effect>§clip: Option<ClipRect>

Implementations§

Source§

impl SceneObject

Source

pub fn content_size(&self) -> Option<(f32, f32)>

Object-local content extent — sugar over ObjectKind::content_size for the object’s own kind. See that method for which kinds report a size and which return None.

Source

pub fn bbox(&self, fallback: (f32, f32)) -> Rect

Axis-aligned bounding box of this object in canvas space.

The intrinsic content extent is taken from SceneObject::content_size when available; otherwise fallback is used — pass the canvas size (or a per-object hint from the renderer) for kinds whose content size isn’t known to the scene layer (raster images, video, text runs). The chosen extent is then run through Transform::bbox and finally intersected with SceneObject::clip if the object carries one.

Clipping is conservative: the returned rectangle is the intersection of the transformed content AABB with the clip rect, expressed in canvas coordinates. The clip’s coordinates are interpreted as already living in canvas space (matching the ClipRect doc-comment). When the intersection is empty the returned rect has zero width / height — the caller can detect culling by checking rect.width == 0.0 || rect.height == 0.0.

Source

pub fn evaluate_property_at( &self, t: TimeStamp, prop: &AnimatedProperty, ) -> Option<KeyframeValue>

Find the first animation track on this object whose AnimatedProperty matches prop and sample it at scene time t. Returns the raw KeyframeValue the track emits — no merging with the object’s base Transform / opacity is performed here.

Returns None when the object carries no track for prop or when the matching track has no keyframes. Tracks are searched in insertion order; if two tracks animate the same property (currently allowed by Operation::Animate) only the first is consulted — the second is effectively shadowed until a CancelAnimation removes the leader.

Source

pub fn effective_transform_at(&self, t: TimeStamp) -> Transform

Compose the object’s base Transform with any Position / Scale / Rotation / Skew / Anchor animation tracks evaluated at scene time t.

Composition rule (per property):

  • Position (Vec2) — added to base position. Animations are offsets from the base, matching the documented Operation::SetTransform semantics (“animations on the same object continue to add to this base”).
  • Scale (Vec2) — multiplied with base scale. Matches the convention used by After Effects / Lottie scale tracks.
  • Rotation (Scalar, radians) — added to base rotation.
  • Skew (Vec2, radians) — added to base skew.
  • Anchor (Vec2, normalised 0..=1) — replaces base anchor. Anchors are pivot points, not deltas, so addition would be meaningless; the animated value is used verbatim.

Variant mismatches between the base field type and the track’s [KeyframeValue] (e.g. an Animation on Position carrying a Scalar) are silently ignored — the base value passes through. Animation tracks targeting non-transform properties (Opacity, Volume, EffectParam, Custom) are likewise ignored by this method.

Source

pub fn effective_opacity_at(&self, t: TimeStamp) -> f32

Compose the object’s base opacity with any Opacity animation track evaluated at scene time t.

The animated value multiplies the base — a base of 0.5 and an animated Scalar(0.5) yields 0.25. The result is clamped to 0.0..=1.0 so the caller can hand it straight to a compositor’s alpha channel without re-clamping.

Variant mismatches (a non-Scalar keyframe on an Opacity track) are ignored — the base value passes through clamped.

Source

pub fn sample_at(&self, t: TimeStamp) -> Sample

Evaluate every animation track on this object at scene time t and return a Sample carrying the resolved transform + opacity. The object’s kind, z_order, blend_mode, clip and id are forwarded verbatim from self.

This is the single-call entry point a renderer uses per object per frame: it hides the per-property dispatch and produces a pre-merged state that can be fed straight to the compositor.

Trait Implementations§

Source§

impl Clone for SceneObject

Source§

fn clone(&self) -> SceneObject

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SceneObject

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SceneObject

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.