Add the first field-based nodes: 'Instance on Points', 'Instance Position', 'Instance Index', as well as 'Grid' (#2574)

* Basic fields

* Add 'Extract XY' and 'Split Vector2' nodes

* Add 'Instance Index' node

* Fix test again

* Improve grid generator to support rectangular as well

* Avoid crashing

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
James Lindsay
2025-04-16 11:58:59 +00:00
committed by GitHub
co-authored by Keavon Chambers
parent 184c009f17
commit 435a6daf25
12 changed files with 515 additions and 26 deletions
@@ -34,6 +34,7 @@ impl GridSnapper {
}
lines
}
// Isometric grid has 6 lines around a point, 2 y axis, 2 on the angle a, and 2 on the angle b.
fn get_snap_lines_isometric(&self, document_point: DVec2, snap_data: &mut SnapData, y_axis_spacing: f64, angle_a: f64, angle_b: f64) -> Vec<Line> {
let document = snap_data.document;
@@ -86,9 +87,10 @@ impl GridSnapper {
lines
}
fn get_snap_lines(&self, document_point: DVec2, snap_data: &mut SnapData) -> Vec<Line> {
match snap_data.document.snapping_state.grid.grid_type {
GridType::Rectangle { spacing } => self.get_snap_lines_rectangular(document_point, snap_data, spacing),
GridType::Rectangular { spacing } => self.get_snap_lines_rectangular(document_point, snap_data, spacing),
GridType::Isometric { y_axis_spacing, angle_a, angle_b } => self.get_snap_lines_isometric(document_point, snap_data, y_axis_spacing, angle_a, angle_b),
}
}