From 49746c607927b319f049efe40e03881f61037109 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Thu, 7 May 2026 23:43:17 +0200 Subject: [PATCH] feat(branch): phyllotactic spiral and upward angle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Default rotation to the golden angle (137.5°) so successive branches spiral naturally around the stem. Add an `angle` input (-90..90°) that tilts branches between horizontal and along-stem before rotating around the stem axis. Co-Authored-By: Claude Opus 4.7 --- nodes/max/plantarium/branch/src/input.json | 8 ++++++++ nodes/max/plantarium/branch/src/lib.rs | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/nodes/max/plantarium/branch/src/input.json b/nodes/max/plantarium/branch/src/input.json index 5136079..c116beb 100644 --- a/nodes/max/plantarium/branch/src/input.json +++ b/nodes/max/plantarium/branch/src/input.json @@ -83,6 +83,14 @@ "min": 0, "max": 360, "step": 0.01, + "value": 137.5 + }, + "angle": { + "type": "float", + "description": "Upward tilt of branches. 0 = horizontal, positive = upward, negative = drooping.", + "min": -90, + "max": 90, + "step": 1, "value": 0 } } diff --git a/nodes/max/plantarium/branch/src/lib.rs b/nodes/max/plantarium/branch/src/lib.rs index 6f9b60d..7a4a7d5 100644 --- a/nodes/max/plantarium/branch/src/lib.rs +++ b/nodes/max/plantarium/branch/src/lib.rs @@ -78,7 +78,9 @@ pub fn execute(input: &[i32]) -> Vec { continue; } - let branch_direction = rotate_vector_by_angle(orthogonal, direction, rotation_angle); + let up_angle = evaluate_float(args[10]) * PI / 180.0; + let tilted = (orthogonal * up_angle.cos() + direction * up_angle.sin()).normalize(); + let branch_direction = rotate_vector_by_angle(tilted, direction, rotation_angle); log!( "BRANCH depth: {}, branch_origin: {:?}, direction_at: {:?}, branch_direction: {:?}",