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:
- Extraction flattens depth-first and composes matrices per node,
acc = acc * node_transform, so the resultingCoreItemsequence preserves 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::core_item::transformed::{Transformed, TransformedExt};
use ranim_core::core_item::vitem::VItem as CoreVItem;
use ranim_core::glam::{DAffine3, Vec4, dvec3};
use ranim_core::traits::ShiftTransform;
use ranim_core::Extract;
use ranim_items::hierarchy::Node;
let stroke = CoreVItem {
points: vec![Vec4::new(1.0, 0.0, 0.0, 0.0)],
..Default::default()
};
// A tree is placed by wrapping it — root posing is O(1) and never
// bakes points.
let mut tree = Transformed::new(
Node::<CoreVItem>::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 extracted = tree.extract();
assert_eq!(extracted.len(), 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 byAlignablefirst. - transparent_
clones 🔒 - Grow
sourcetolenentries by cloning entries and marking every clone transparent — the absence rule ofAlignable::align_withfor child lists that have nothing of their own to repeat.