From fe3a2657d760f449b4b0eb0b50770d0f7c7edeaf Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 12 May 2026 22:48:43 +0200 Subject: [PATCH] auto-git: [change] tests/domain/scene-paths.test.ts --- tests/domain/scene-paths.test.ts | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/domain/scene-paths.test.ts b/tests/domain/scene-paths.test.ts index 39aec67e..ff4b74fe 100644 --- a/tests/domain/scene-paths.test.ts +++ b/tests/domain/scene-paths.test.ts @@ -179,6 +179,61 @@ describe("scene paths", () => { expect(smoothedTangent.z).toBeGreaterThan(0); }); + it("resolves Catmull-Rom spline paths into sampled arc-length segments", () => { + const path = createScenePath({ + id: "path-spline-corner", + curveMode: "catmullRom", + sampledResolution: 8, + points: [ + { + id: "point-a", + position: { + x: 0, + y: 0, + z: 0 + } + }, + { + id: "point-b", + position: { + x: 0, + y: 0, + z: 3 + } + }, + { + id: "point-c", + position: { + x: 4, + y: 0, + z: 3 + } + } + ] + }); + const resolvedPath = resolveScenePath(path); + const midpoint = sampleScenePathPosition(path, 0.5); + const nearest = resolveNearestPointOnResolvedScenePath(resolvedPath, { + x: 0.5, + y: 0, + z: 3.5 + }); + + expect(resolvedPath.curveMode).toBe("catmullRom"); + expect(resolvedPath.sampledResolution).toBe(8); + expect(resolvedPath.segments).toHaveLength(16); + expect(resolvedPath.totalLength).toBeGreaterThan(0); + expect(midpoint).not.toEqual({ + x: 0.5, + y: 0, + z: 3 + }); + expect(nearest.segmentIndex).not.toBeNull(); + expect(nearest.progress).toBeGreaterThan(0); + expect(nearest.progress).toBeLessThan(1); + expect(nearest.distanceAlongPath).toBeGreaterThan(0); + }); + it("projects world points onto the nearest resolved path segment and returns progress", () => { const path = createScenePath({ id: "path-nearest-point",