From a34a5bc55fba1700be1b30232c3e694e6f0f0adb Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 6 Sep 2026 14:31:01 +0300 Subject: [PATCH] fix: drop imported models onto the workplane centre MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every importer places the imported shape at a fixed offset: x: 10, z: -10, The same pair is repeated in stlImport, objImport and svgImport. By the time this object is built, the geometry has already been centred on its own bounding box in X and Z and seated on the plane in Y — so the work of bringing the model to the origin is done, and the last step deliberately undoes part of it. The offset does not scale with anything. On a 35 mm part it is visible; on a 190 mm model it reads as a rounding error rather than a decision. It is also awkward to undo: the shape panel has no X or Y field, so the only numeric way to move a shape is the arrow keys, one snap step per press — and the direction depends on the current camera angle. Zeroing the pair puts the model where the user is already looking. Users arriving from other browser CAD tools expect exactly that. If the offset exists so that an imported model does not land on top of a primitive created at the origin, the offset is still the wrong lever: it is in the way every time and helps in one narrow case. Offsetting the *new primitive* when the spot is taken would fit better. 264 tests pass unchanged. --- apps/web/src/lib/objImport.ts | 4 ++-- apps/web/src/lib/stlImport.ts | 4 ++-- apps/web/src/lib/svgImport.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/web/src/lib/objImport.ts b/apps/web/src/lib/objImport.ts index db6b294..17cb071 100644 --- a/apps/web/src/lib/objImport.ts +++ b/apps/web/src/lib/objImport.ts @@ -158,8 +158,8 @@ function importedObjShapeFromTriangles( name: fileName.replace(/\.[^.]+$/, "") || "Imported OBJ", kind: "mesh", color: "#0098c7", - x: 10, - z: -10, + x: 0, + z: 0, size: Math.max(width, depth), width, depth, diff --git a/apps/web/src/lib/stlImport.ts b/apps/web/src/lib/stlImport.ts index 254fb84..0483b04 100644 --- a/apps/web/src/lib/stlImport.ts +++ b/apps/web/src/lib/stlImport.ts @@ -92,8 +92,8 @@ export function importedShapeFromTriangleSoup( name: fileName.replace(/\.[^.]+$/, "") || `Imported ${sourceFormat.toUpperCase()}`, kind: "mesh", color: "#0098c7", - x: 10, - z: -10, + x: 0, + z: 0, size: Math.max(width, depth), width, depth, diff --git a/apps/web/src/lib/svgImport.ts b/apps/web/src/lib/svgImport.ts index e0b9b4c..c6b7535 100644 --- a/apps/web/src/lib/svgImport.ts +++ b/apps/web/src/lib/svgImport.ts @@ -586,8 +586,8 @@ export function importedShapeFromSvg(fileName: string, source: string): Workplan name: fileName.replace(/\.[^.]+$/, "") || "Imported SVG", kind: "mesh", color: "#0098c7", - x: 10, - z: -10, + x: 0, + z: 0, size: Math.max(analysis.width, analysis.depth), width: analysis.width, depth: analysis.depth,