From 53373877c0d87d926192e5941633ef55bba6314c Mon Sep 17 00:00:00 2001 From: mahach666 <79989386+mahach666@users.noreply.github.com> Date: Wed, 18 Nov 2026 19:39:54 +0300 Subject: [PATCH] Snap distance measurements to visible geometry Refs #40 --- CHANGELOG.md | 1 + README.md | 3 +- docs/viewer-performance-baseline.md | 17 +- src/IOViewer/Viewer/dist/viewer.js | 374 +++++++++--------- src/IOViewer/Viewer/playwright.config.js | 3 +- src/IOViewer/Viewer/src/data.js | 70 +++- src/IOViewer/Viewer/src/engine/modelScene.js | 4 + src/IOViewer/Viewer/src/engine/picking.js | 119 +++++- src/IOViewer/Viewer/src/main.js | 44 ++- src/IOViewer/Viewer/src/tools/measure.js | 20 +- src/IOViewer/Viewer/src/tools/measureSnap.js | 182 +++++++++ src/IOViewer/Viewer/styles/viewer.css | 25 ++ src/IOViewer/Viewer/test/e2e/global-setup.js | 11 + .../Viewer/test/e2e/measure-snap.spec.js | 97 +++++ .../Viewer/test/e2e/selection.spec.js | 17 +- src/IOViewer/Viewer/test/e2e/tools.spec.js | 10 +- src/IOViewer/Viewer/test/perf/orbit.perf.js | 38 +- src/IOViewer/Viewer/test/unit/data.test.js | 19 + .../Viewer/test/unit/measureSnap.test.js | 52 +++ 19 files changed, 868 insertions(+), 238 deletions(-) create mode 100644 src/IOViewer/Viewer/src/tools/measureSnap.js create mode 100644 src/IOViewer/Viewer/test/e2e/measure-snap.spec.js create mode 100644 src/IOViewer/Viewer/test/unit/measureSnap.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d93481..1f960bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ API between minor releases. - Filter the model tree by source model, level and category, and optionally isolate the matches in 3D. - Export explicitly placed source models together in one standalone HTML viewer with independent visibility. - Import BCF 2.1 topics and open their cameras, clipping and matched components in the offline viewer. +- Preview distance measurement points and snap to visible vertices, edge midpoints and edges near the pointer. ### Fixed diff --git a/README.md b/README.md index d20d1c1..079609f 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ Built clean-room under the [IOExtend](https://github.com/IOExtend) organization. - context menu: properties, hide, isolate, show all, zoom to object, section box around the object, copy Id; - view cube that follows the camera exactly, with face clicks, 90° arrows and a home button; - section planes (up to six, moved and rotated with an in-scene gizmo) or a section box (keep inside or cut inside, face handles, move by the centre, box around the selection); - - point-to-point distance measurement, display modes (materials, textures, white, wireframe), viewport background color, grid lines and a global opacity slider; + - point-to-point distance measurement previews the point under the cursor and snaps to visible vertices, edge midpoints and edges within eight screen pixels; + - display modes (materials, textures, white, wireframe), viewport background color, grid lines and a global opacity slider; - saved viewpoints with a viewpoint tour, clash results, a 4D schedule player and linked-file visibility, each shown only when the document has that data. - Imports binary glTF 2.0 (`.glb`), Wavefront OBJ (`.obj`), and JSON: viewer JSON, IOScene scene files and IOViewer 0.1/0.2 snapshots. diff --git a/docs/viewer-performance-baseline.md b/docs/viewer-performance-baseline.md index 90f50e6..2f05bdb 100644 --- a/docs/viewer-performance-baseline.md +++ b/docs/viewer-performance-baseline.md @@ -69,7 +69,7 @@ for ($trial = 1; $trial -le 3; $trial++) { Each `ladder-