diff --git a/tests/unit/viewport-simulation-membership.test.ts b/tests/unit/viewport-simulation-membership.test.ts index 8624443b..1617f4be 100644 --- a/tests/unit/viewport-simulation-membership.test.ts +++ b/tests/unit/viewport-simulation-membership.test.ts @@ -1,8 +1,10 @@ import { describe, expect, it } from "vitest"; +import { Object3D } from "three"; import { createDefaultProjectTimeSettings } from "../../src/document/project-time-settings"; import { createDefaultWorldSettings } from "../../src/document/world-settings"; import { + collectTerrainBrushRaycastObjectsForTerrain, createViewportSimulationMembershipSignatures, resolveViewportWorldState } from "../../src/viewport-three/viewport-host"; @@ -102,6 +104,41 @@ describe("createViewportSimulationMembershipSignatures", () => { }); }); +describe("collectTerrainBrushRaycastObjectsForTerrain", () => { + it("limits terrain brush raycasts to the active terrain pick meshes", () => { + const targetPickMesh = new Object3D(); + const targetChunkPickMesh = new Object3D(); + const otherTerrainPickMesh = new Object3D(); + + const raycastObjects = collectTerrainBrushRaycastObjectsForTerrain( + new Map([ + [ + "terrain-target", + { + pickMeshes: [targetPickMesh, targetChunkPickMesh] + } + ], + [ + "terrain-other", + { + pickMeshes: [otherTerrainPickMesh] + } + ] + ]), + "terrain-target" + ); + + expect(raycastObjects).toEqual([targetPickMesh, targetChunkPickMesh]); + expect(raycastObjects).not.toContain(otherTerrainPickMesh); + }); + + it("returns no terrain brush raycast objects when the terrain has no render mesh", () => { + expect( + collectTerrainBrushRaycastObjectsForTerrain(new Map(), "terrain-missing") + ).toEqual([]); + }); +}); + describe("resolveViewportWorldState", () => { it("applies document project time when the runtime scene is unavailable", () => { const world = createDefaultWorldSettings();