Simple Godot 4.7+ project for 3-axis CNC raster and waterline (constant-Z) toolpaths over a mesh.
raster_pass_planner.gd— 2D raster as a line mesh (one LINE_STRIP surface per pass)raster_project_to_mesh.gd—compute_line_mesh(passes, mesh, tool)projects by tool-shape vs mesh collision (ball-nose drop-cutter on triangles — not Physics raycasts) → 3D line meshtoolpath_animation.gd— projected points →Animationraster_baker.gd— UI glue + save assets
Waterline uses waterline_toolpath.gd to intersect the mesh with horizontal
planes, join the segments into closed contours, apply planar tool-radius
compensation, and sample each loop. Passes are ordered top-down and retract to
safe height between contours. Godot's vertical axis is Y; the UI uses the
conventional CNC name Z stepdown.
Assets:
animations/raster_passes_2d.tres— yellow 2D passes (Raster2DPreview)animations/raster_toolpath_lines.tres— cyan projected 3D path (ToolpathPreview)animations/raster_toolpath_curve.tres— editorPath3Dpreviewanimations/raster_toolpath.tres— Animationanimations/waterline_contours.tres— compensated constant-height contoursanimations/waterline_toolpath_lines.tres— contours with safe retractsanimations/waterline_toolpath_curve.tres— editorPath3Dpreviewanimations/waterline_toolpath.tres— Animation
All generated resources use stable res://animations/... paths and are
overwritten on each bake. In the editor, ToolpathCurve is the placeholder
Path3D, and AnimationPlayer is the animation placeholder. Select
EditorAssetReload and set Preview Strategy to raster or waterline;
its @tool script detects rewritten Curve3D/Animation files and reloads those
two placeholders automatically. Select ToolpathCurve to see the Path3D
editor gizmo. No game rerun or scene reopen is required.
Units: metres in-scene; Bake UI in mm. Play: MMB orbit, Shift+MMB pan, wheel zoom.
git clone https://github.com/DynamicDevices/godot-cnc-toolpath.git
cd godot-cnc-toolpath
git pull- Open in Godot 4.7+ →
scenes/main.tscn - Press Play → choose Raster or Waterline → Bake
Headless smoke proof for either strategy:
godot --headless --path . -s res://tools/bake_once.gd -- --strategy=waterlineThe smoke bake also asserts the stable Curve3D/Animation paths and placeholder
wiring, and prints an ASSET_PROOF line.
MIT — see LICENSE.