dymokomi/luced-3d
Source of release 0.11.8
0.11.8 / src / place_prompt.luc
## Drawing on surfaces in the viewport: a drawing tool collecting corners
## (Edit Mesh's PolyDraw, the `place` gesture) or the Knife's stroke (the
## `knife` gesture, knife_placing.luc). The viewport turns clicks into world
## points (snapped to the edited mesh's points, else on the surface under
## the cursor, else on the ground; luce-3d SurfaceHits) and the workspace
## turns the finished drawing into one recipe step.
from luce_3d.graphics import Vector3
pub class PlacePrompt:
## The drawing tool, and its gesture ("place" or "knife").
pub let name: str
pub let gesture: str
pub var corners: list[Vector3]
## The view ray's direction at each corner as it was clicked (the
## Knife cuts along their mean).
pub var rays: list[Vector3]
## Where the cursor would place the next corner (the rubber band's end).
pub var cursor: Vector3? = none
## The Knife's toggles: Cut through (Z) and the 15° angle snap (C).
pub var through: bool = false
pub var angle: bool = false
pub func init(self, name: str, gesture: str = "place"):
self.name = name
self.gesture = gesture
self.corners = []
self.rays = []
## What the viewport's notice line says while drawing.
pub func hint(self) -> str:
if self.gesture == "knife":
let through = "on" if self.through else "off"
let angle = "on" if self.angle else "off"
return f"Knife: click points on the surface (points snap, Ctrl edge middles, Shift none), C angle snap ({angle}), Z cut through ({through}), Backspace takes the last back, the first point again closes, Enter cuts, Esc cancels"
return f"{self.name}: click to place corners (points snap), Enter or the first corner finishes, Esc cancels"