Keyboard selection: label every target, type the label. More...
| Import Statement: | import Clayground.Lab |
Press f (LabKeys routes it here) and every target the lab names grows a short label - one or two characters, home-row first, so the common case is a single keystroke on a strong finger. Typing the label selects the target exactly as a click would, and the camera does not move; framing stays a separate, deliberate act. Off-screen targets appear as a grouped badge strip at the bottom edge, and choosing one of those does fly to it - the one sanctioned exception, because selecting what you cannot see helps nobody.
A hint label is sized for reading, not for the object's pixel footprint, which is why the same mechanism also retires the tiny-hit-region class of bug: a switch lever a few pixels wide costs the same two keystrokes as a board-filling part.
The mechanism is the kernel's; the vocabulary is the lab's: targets returns what can be jumped to, with a display name and a group per entry. Place the item as a sibling of the View3D, filling the same area, and hand it to LabKeys via its jump property - the keymap starts it, routes keys while it is up, and documents it in the help.
While labels are up the keyboard is this component's (a text-entry context, like the pin prompt - not a mode): letters refine, the matching label selects, anything else puts the labels away.
See also LabKeys, SelectionFrame3D, and WorldLabel.
active : bool |
Labels are up and the keyboard is this component's.
camera : var |
The camera the View3D renders with (projection dependency).
maxBadges : int |
Off-screen entries shown before the strip says "+N".
rig : var |
An OrbitCamera3D; only focusOn is used, and only for off-screen targets (select-and-fly).
targets : var |
() => [{id, pos, name, group}] - what can be jumped to.
pos is a world-space vector3d (label anchor and fly-to point), name the display label beside the letter, group the badge-strip grouping for off-screen entries (a net, a road - the part type when a kit has nothing better). The list is asked for fresh on every begin, so it always reflects the scene.
view : var |
The View3D to project through.
var, not View3D, for the same reason as WorldLabel: the kernel should not need a 3D dependency to draw a paper chip.
selected(var target) |
A label was typed to the end; target is the lab's own entry.
Selection is the lab's act - the component neither knows nor sets what "selected" means in the scene.
Note: The corresponding handler is onSelected.
bool begin() |
Puts the labels up; a second call puts them away.
Returns false - after showing a short "nothing to jump to" notice - when the lab has no targets, so a caller never has to distinguish the two.
void cancel() |
Puts the labels away without selecting.
bool handleKey(var event) |
Every key while active; LabKeys routes them here.