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
impl SceneObject
Sourcepub fn content_size(&self) -> Option<(f32, f32)>
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.
Sourcepub fn bbox(&self, fallback: (f32, f32)) -> Rect
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.
Sourcepub fn evaluate_property_at(
&self,
t: TimeStamp,
prop: &AnimatedProperty,
) -> Option<KeyframeValue>
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.
Sourcepub fn effective_transform_at(&self, t: TimeStamp) -> Transform
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 baseposition. Animations are offsets from the base, matching the documentedOperation::SetTransformsemantics (“animations on the same object continue to add to this base”).Scale(Vec2) — multiplied with basescale. Matches the convention used by After Effects / Lottie scale tracks.Rotation(Scalar, radians) — added to baserotation.Skew(Vec2, radians) — added to baseskew.Anchor(Vec2, normalised 0..=1) — replaces baseanchor. 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.
Sourcepub fn effective_opacity_at(&self, t: TimeStamp) -> f32
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.
Sourcepub fn sample_at(&self, t: TimeStamp) -> Sample
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
impl Clone for SceneObject
Source§fn clone(&self) -> SceneObject
fn clone(&self) -> SceneObject
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more