New nodes: Sort, Filter, Reverse, Shift, Shuffle, Number Sequence, List Indices, List Slice, Read Number (#4347)

This commit is contained in:
Keavon Chambers
2026-07-17 01:15:10 -07:00
committed by GitHub
parent d241cdcb2e
commit 048c458789
8 changed files with 560 additions and 21 deletions
+27
View File
@@ -46,6 +46,33 @@ fn read_gradient(ctx: impl Ctx + ExtractVarArgs) -> Item<Gradient> {
var_arg.downcast_ref().cloned().unwrap_or_default()
}
/// Reads the current number from within a **Map** node's loop.
#[node_macro::node(category("Context"))]
fn read_number(ctx: impl Ctx + ExtractVarArgs) -> Item<f64> {
let Ok(var_arg) = ctx.vararg(0) else { return Default::default() };
let var_arg = var_arg as &dyn std::any::Any;
if let Some(item) = var_arg.downcast_ref::<Item<f64>>() {
return item.clone();
}
// Numeric lists carry several possible element types, so probe each and widen to f64, keeping the item's attributes
if let Some(item) = var_arg.downcast_ref::<Item<f32>>() {
let (element, attributes) = item.clone().into_parts();
return Item::from_parts(element as f64, attributes);
}
if let Some(item) = var_arg.downcast_ref::<Item<u32>>() {
let (element, attributes) = item.clone().into_parts();
return Item::from_parts(element as f64, attributes);
}
if let Some(item) = var_arg.downcast_ref::<Item<u64>>() {
let (element, attributes) = item.clone().into_parts();
return Item::from_parts(element as f64, attributes);
}
Default::default()
}
#[node_macro::node(category("Context"), path(core_types::vector))]
async fn read_position(
ctx: impl Ctx + ExtractPosition,