From 492f7aacabb3b05cc9cd5d123369850dc19b0390 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 15 Apr 2026 15:12:32 +0200 Subject: [PATCH] Add test for framing multiple selected model instances around their combined authored bounds --- tests/unit/viewport-focus.test.ts | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/unit/viewport-focus.test.ts b/tests/unit/viewport-focus.test.ts index c9e07d41..eedf2b19 100644 --- a/tests/unit/viewport-focus.test.ts +++ b/tests/unit/viewport-focus.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from "vitest"; +import { createModelInstance } from "../../src/assets/model-instances"; import { createBoxBrush } from "../../src/document/brushes"; import { createScenePath } from "../../src/document/paths"; import { createEmptySceneDocument } from "../../src/document/scene-document"; @@ -324,6 +325,58 @@ describe("resolveViewportFocusTarget", () => { }); }); + it("frames multiple selected model instances around their combined authored bounds", () => { + const modelInstanceA = createModelInstance({ + id: "model-focus-a", + assetId: "asset-model-focus", + position: { + x: 0, + y: 0, + z: 0 + }, + scale: { + x: 2, + y: 2, + z: 2 + } + }); + const modelInstanceB = createModelInstance({ + id: "model-focus-b", + assetId: "asset-model-focus", + position: { + x: 6, + y: 0, + z: 0 + }, + scale: { + x: 2, + y: 2, + z: 2 + } + }); + const document = { + ...createEmptySceneDocument(), + modelInstances: { + [modelInstanceA.id]: modelInstanceA, + [modelInstanceB.id]: modelInstanceB + } + }; + + expect( + resolveViewportFocusTarget(document, { + kind: "modelInstances", + ids: [modelInstanceA.id, modelInstanceB.id] + }) + ).toEqual({ + center: { + x: 3, + y: 0, + z: 0 + }, + radius: Math.hypot(8, 2, 2) * 0.5 + }); + }); + it("frames the authored scene when nothing is selected and returns null when the scene is empty", () => { const brush = createBoxBrush({ id: "brush-room"