Repository navigation
Description
Describe the bug 📝
ThatOpen snap marker shows on a disabled LengthMeasurement
Minimal reproduction for @thatopen/components-front 3.6.1: setting mode = 'edge' on a disabled LengthMeasurement makes the snap marker of GraphicVertexPicker visible, and it then follows the cursor although the tool is off.
Expected
A disabled measurer never shows the snap marker. Changing its configuration (mode, units, snappings) while it is disabled has no visible effect.
Cause
- The
LengthMeasurement.modesetter callsinitPreview()for'edge'without checkingenabled. buildPreview()callsthis._vertexPicker.get()whenlastPickisnull, before it checksthis.enabled.GraphicVertexPicker.get()never checks_enabledand setsmarker.visible = trueon every hit.- Cursor tracking (
attachCursorTracking) stays attached as long as a world is set, so the marker then keeps following the cursor.
The same pattern can be hit by any other pick that resolves while the measurer is disabled, e.g. a pending scheduleMarkerUpdate() pick (it checks this.enabled only before awaiting) or the unawaited get() in the GraphicVertexPicker.enabled setter.
Suggested fix
- In
GraphicVertexPicker.get(), after theawait, only touch the marker if the picker is enabled:if (!this._enabled) { if (this.marker) this.marker.visible = false; return n; }. - In
LengthMeasurement, only callinitPreview()from themodesetter whenthis.enabledistrue.
Versions
- @thatopen/components 3.6.0
- @thatopen/components-front 3.6.1
- @thatopen/fragments 3.6.1
- three 0.182.0
Reproduction ▶️
https://stackblitz.com/github/berchri/thatopen-snap-marker-repro; https://github.com/berchri/thatopen-snap-marker-repro
Open in StackBlitz
Steps to reproduce 🔢
- Wait for the model to load. The measurer is configured with a world,
mode = 'free', and stays disabled (enabled = false). - Click once into the viewer so it has keyboard focus (on StackBlitz the preview needs focus), hover over the model and press M. M toggles
measurer.modebetween'free'and'edge'; the current mode is shown in the panel. - Move the mouse. The snap marker is visible and follows the cursor although the measurer is disabled. The console logs
BUG: measurer disabled, but snap marker is visibleevery second.
Pressing E toggles measurer.enabled for comparison; enabling and disabling the tool alone behaves correctly.
System Info 💻
OS: Windows 11 10.0.26100
Node: 24.20.0, npm: 11.19.0
Browsers: Chrome 158.0.8127.37, Edge 158.0.4370.45
@thatopen/components 3.6.0, @thatopen/components-front 3.6.1,
@thatopen/fragments 3.6.1, three 0.182.0, web-ifc 0.0.77Used Package Manager 📦
npm
Error Trace/Logs 📃
No response
Validations ✅
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a repository issue and not a framework-specific issue. For example, if it's a THREE.js related bug, it should likely be reported to mrdoob/threejs instead.
- Check that this is a concrete bug. For Q&A join our Community.
- The provided reproduction is a minimal reproducible example of the bug.
Activity
berchri commentedon Nov 27, 2026
Suggested fix in
packages/front/src/measurement/LengthMeasurement/index.ts:set mode(value: LengthMeasurerModes[number]) { this._mode = value; this.cancelCreation(); - if (value === "edge") this.initPreview(); + // onEnabledChange starts the edge preview once the tool is enabled. + if (value === "edge" && this.enabled) this.initPreview(); this.onStateChanged.trigger(["mode"]); }Optionally, as a second guard,
buildPreview()could return early before picking:private async buildPreview() { if (!this.world) { throw new Error("Measurement: world is need!"); } + if (!this.enabled) return;Nothing is lost when the mode is set while disabled:
onEnabledChangealready callsinitPreview()foredgewhen the tool gets enabled.Happy to open a PR with this change if you'd like.