SVG + DOM overlay that paints one or more 3D distance
measurements on a View's canvas. Each
measurement shows the diagonal length plus the X/Y/Z axis
decomposition between the two anchors.
Mirrors the shape of V2's DistanceMeasurementsPlugin, but
rendered with SVG + DOM (no second renderer or off-screen canvas).
One DistanceMeasurementTool per
View owns the overlay and a keyed
collection of DistanceMeasurements;
an optional MouseDistanceMeasurementsControl turns canvas
clicks into measurements with two-click creation.
Per-View singleton —
openFor is idempotent;
re-calling for the same View brings the existing tool back to the
foreground.
SVG + DOM overlay — no second renderer or off-screen canvas;
the overlay shares the View canvas's stacking context so
letterboxing and CSS transforms apply uniformly.
Diagonal + axis decomposition — each measurement renders the
diagonal length wire (orange by default) and the red/green/blue
axis wires with per-wire numeric labels. Toggle wires, axes, and
labels independently via
DistanceMeasurementParams.
Snap-aware picking — the tool routes mouse clicks through a
caller-supplied PickStrategy.
Supply a RoutingPickStrategy
for snap-to-vertex / snap-to-edge; omit picker to get a default
BVH-only picker built from the View's Scene.
Lazy mouse control — tool.mouseControl lazily constructs the
MouseDistanceMeasurementsControl on first access, so a
tool used purely programmatically never pays its setup cost.
Coarse change event —
onMeasurementsChanged
fires after every create / destroy / clear; listeners that need
the current contents re-read the
measurements map.
tool.mouseControl is lazy — first access constructs the helper.
activate() starts listening for clicks on the View canvas;
Esc cancels an in-progress measurement; deactivate() stops
listening.
tool.mouseControl.activate();
// ...later, when the user picks a different tool: tool.mouseControl.deactivate();
5) Snap-aware picking
Pass a RoutingPickStrategy as
picker to get snap-to-vertex and snap-to-edge in mouse-driven
creation. Omit picker for a BVH-only fallback.
onMeasurementsChanged is coarse — it fires once per
create / destroy / clear without the changed id. Listeners that
need the current state re-read
measurements.
Distance Measurements
SVG + DOM overlay that paints one or more 3D distance measurements on a View's canvas. Each measurement shows the diagonal length plus the X/Y/Z axis decomposition between the two anchors.
Mirrors the shape of V2's
DistanceMeasurementsPlugin, but rendered with SVG + DOM (no second renderer or off-screen canvas). One DistanceMeasurementTool per View owns the overlay and a keyed collection of DistanceMeasurements; an optional MouseDistanceMeasurementsControl turns canvas clicks into measurements with two-click creation.Shape
Features
pickerto get a default BVH-only picker built from the View's Scene.tool.mouseControllazily constructs the MouseDistanceMeasurementsControl on first access, so a tool used purely programmatically never pays its setup cost.Installation
Quick Start
1) Import the entry points
2) Open the tool on a View
openForis the canonical entry — idempotent, View-keyed, and shows the existing tool again if it was hidden.3) Create a measurement programmatically
Pass two world-space anchors. The tool computes length and the X/Y/Z decomposition; both update every frame as the camera moves.
4) Wire up mouse-driven creation
tool.mouseControlis lazy — first access constructs the helper.activate()starts listening for clicks on the View canvas;Esccancels an in-progress measurement;deactivate()stops listening.5) Snap-aware picking
Pass a RoutingPickStrategy as
pickerto get snap-to-vertex and snap-to-edge in mouse-driven creation. Omitpickerfor a BVH-only fallback.6) React to changes
onMeasurementsChangedis coarse — it fires once per create / destroy / clear without the changed id. Listeners that need the current state re-read measurements.7) Show, hide, toggle
Visibility on the tool hides the entire overlay; per-measurement visibility flags hide individual measurements while the overlay stays mounted.
8) Tearing down
destroytears down the overlay, every child measurement, and the camera-update subscription. Idempotent.