Expand description
Hierarchical scene-graph composition for items. Hierarchical scene-graph composition for items.
This module lifts
[Transformed]’s
“canonical local data + external transform” model from a flat wrapper to
a tree. Scene-graph composition lives in the items layer, built on top of
ranim-core’s transform-group algebra
([TransformGroup]): each node
stores canonical local data (like
Transformed::inner
does) plus one transform from its local space into the parent’s space.
The structural rules of the model:
- Render extraction flattens depth-first and composes placements per node,
acc = acc * node_transform, so the resulting render entities preserve painter’s-algorithm draw order (front-to-back document order). - Every node’s pose interpolates independently of its geometry: lerping moves transforms and leaf payloads only and never bakes points into vertices — the basis for future skeletal animation.
§Examples
use ranim_core::transformed::{Transformed, TransformedExt};
use ranim_items::vitem::VItem;
use ranim_core::glam::{DAffine3, dvec3};
use ranim_core::traits::ShiftTransform;
use ranim_core::frame::EvaluatedFrame;
use ranim_items::hierarchy::{Node, PlacedLeaves};
let stroke = VItem::from_vpoints(vec![dvec3(1.0, 0.0, 0.0)]);
// A tree is placed by wrapping it — root posing is O(1) and never
// bakes points.
let mut tree = Transformed::new(
Node::<VItem>::group(vec![
Node::leaf(stroke.clone()).with_id("a"),
Node::leaf(stroke).with_id("b"),
]),
DAffine3::IDENTITY,
);
tree.shift(dvec3(1.0, 0.0, 0.0));
let mut frame = EvaluatedFrame::new();
frame.push((0, 0), tree);
let tree = &frame.items::<Transformed<Node<VItem>, DAffine3>>()[0].value;
assert_eq!(tree.leaves().count(), 2);Structs§
- Leaves
- Iterator over flattened leaf payloads with accumulated world affines,
produced by
Node::leaves. - Leaves
Mut - Iterator over mutable references to leaf payloads, produced by
Node::leaves_mut. Depth-first order; no transforms are composed. - Node
- A node of a scene-graph tree: pure structure — an external id, an optional payload, and a list of placed children.
Traits§
- Placed
Leaves - Leaf iteration for a placed tree: the wrapper’s pose seeds the
accumulation. A bare
Nodeiterates from the identity viaNode::leaves.
Functions§
- expand_
with_ 🔒transparent_ repeats - Expand
nodesin place tolenentries, preserving order; repeated stand-ins become fully transparent viaset_opacity(0.0), matching theVec<T>align blanket in ranim-core. - lerp_
items 🔒 - Structural lerp over payloads.
Nonemust pair withNone: a presence mismatch is filled with transparent clones by [Alignable] first. - transparent_
clones 🔒 - Grow
sourcetolenentries by cloning entries and marking every clone transparent — the absence rule of [Alignable::align_with] for child lists that have nothing of their own to repeat.