Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Implement M19 basic modeling UI with body translation workflow

Yuechen Li2b5f32d6f6e0
diff --git a/Aetheris.Server.Tests/KernelApiIntegrationTests.cs b/Aetheris.Server.Tests/KernelApiIntegrationTests.cs
index 3fae823d..72df205e 100644
--- a/Aetheris.Server.Tests/KernelApiIntegrationTests.cs
+++ b/Aetheris.Server.Tests/KernelApiIntegrationTests.cs
@@ -84,6 +84,49 @@ public sealed class KernelApiIntegrationTests : IClassFixture<WebApplicationFact
Assert.Empty(pick.Diagnostics);
}
+
+ [Fact]
+ public async Task BodyTranslation_UpdatesTessellationAndPickCoordinates()
+ {
+ var document = await CreateDocumentAsync("/api/v1/documents");
+ var box = await CreateBoxAsync("/api/v1/documents", document.Data!.DocumentId, 2, 2, 2);
+
+ var transformResponse = await _client.PostAsJsonAsync(
+ $"/api/v1/documents/{document.Data.DocumentId}/bodies/{box.Data!.BodyId}/transform",
+ new TranslateBodyRequestDto(new Vector3Dto(3, 0, 0)));
+ transformResponse.EnsureSuccessStatusCode();
+
+ var transformed = await transformResponse.Content.ReadFromJsonAsync<ApiResponseDto<BodyTransformedResponseDto>>();
+ Assert.NotNull(transformed);
+ Assert.True(transformed!.Success);
+ Assert.Equal(3d, transformed.Data!.AppliedTranslation.X);
+
+ var tessellationResponse = await _client.PostAsJsonAsync(
+ $"/api/v1/documents/{document.Data.DocumentId}/bodies/{box.Data.BodyId}/tessellate",
+ new TessellateRequestDto(null));
+ tessellationResponse.EnsureSuccessStatusCode();
+
+ var tessellation = await tessellationResponse.Content.ReadFromJsonAsync<ApiResponseDto<TessellationResponseDto>>();
+ Assert.NotNull(tessellation);
+ Assert.True(tessellation!.Success);
+ Assert.Contains(tessellation.Data!.FacePatches.SelectMany(static p => p.Positions), p => p.X > 3.9);
+
+ var pickResponse = await _client.PostAsJsonAsync(
+ $"/api/v1/documents/{document.Data.DocumentId}/bodies/{box.Data.BodyId}/pick",
+ new PickRequestDto(
+ new Point3Dto(3, 0, 5),
+ new Vector3Dto(0, 0, -1),
+ TessellationOptions: null,
+ PickOptions: new PickOptionsDto(NearestOnly: true, IncludeBackfaces: null, EdgeTolerance: null, SortTieTolerance: null, MaxDistance: null)));
+ pickResponse.EnsureSuccessStatusCode();
+
+ var pick = await pickResponse.Content.ReadFromJsonAsync<ApiResponseDto<PickResponseDto>>();
+ Assert.NotNull(pick);
+ Assert.True(pick!.Success);
+ Assert.Single(pick.Data!.Hits);
+ Assert.InRange(pick.Data.Hits[0].Point.X, 2d, 4d);
+ }
+
[Fact]
public async Task UnsupportedBoolean_OnV1_ReturnsUnprocessableEntityWithDiagnosticEnvelope()
{
diff --git a/Aetheris.Server/Api/ApiMappings.cs b/Aetheris.Server/Api/ApiMappings.cs
index b5194803..238d9818 100644
--- a/Aetheris.Server/Api/ApiMappings.cs
+++ b/Aetheris.Server/Api/ApiMappings.cs
@@ -52,22 +52,28 @@ public static class ApiMappings
public static Vector3Dto ToVectorDto(Vector3D vector) => new(vector.X, vector.Y, vector.Z);
public static TessellationResponseDto ToTessellationResponse(DisplayTessellationResult result)
+ => ToTessellationResponse(result, Transform3D.Identity);
+
+ public static TessellationResponseDto ToTessellationResponse(DisplayTessellationResult result, Transform3D transform)
=> new(
result.FacePatches.Select(p => new FacePatchDto(
p.FaceId.Value,
- p.Positions.Select(ToPointDto).ToArray(),
- p.Normals.Select(ToVectorDto).ToArray(),
+ p.Positions.Select(position => ToPointDto(transform.Apply(position))).ToArray(),
+ p.Normals.Select(normal => ToVectorDto(transform.Apply(normal))).ToArray(),
p.TriangleIndices.ToArray())).ToArray(),
result.EdgePolylines.Select(e => new EdgePolylineDto(
e.EdgeId.Value,
- e.Points.Select(ToPointDto).ToArray(),
+ e.Points.Select(point => ToPointDto(transform.Apply(point))).ToArray(),
e.IsClosed)).ToArray());
public static PickResponseDto ToPickResponse(IReadOnlyList<PickHit> hits)
+ => ToPickResponse(hits, Transform3D.Identity);
+
+ public static PickResponseDto ToPickResponse(IReadOnlyList<PickHit> hits, Transform3D transform)
=> new(hits.Select(h => new PickHitDto(
h.T,
- ToPointDto(h.Point),
- h.Normal is null ? null : ToVectorDto(h.Normal.Value.ToVector()),
+ ToPointDto(transform.Apply(h.Point)),
+ h.Normal is null ? null : ToVectorDto(transform.Apply(h.Normal.Value.ToVector())),
h.EntityKind.ToString(),
h.FaceId?.Value,
h.EdgeId?.Value,
diff --git a/Aetheris.Server/Api/KernelEndpoints.cs b/Aetheris.Server/Api/KernelEndpoints.cs
index a6c7d645..8a5c2cd3 100644
--- a/Aetheris.Server/Api/KernelEndpoints.cs
+++ b/Aetheris.Server/Api/KernelEndpoints.cs
@@ -170,8 +170,19 @@ public static class KernelEndpoints
return ApiMappings.Ok(CreateBodyResponse(document, kernel.Value));
}));
+ documents.MapPost("/{documentId:guid}/bodies/{bodyId:guid}/transform", (Guid documentId, Guid bodyId, TranslateBodyRequestDto request, KernelDocumentStore store) =>
+ WithDocument(store, documentId, document =>
+ {
+ if (!document.ApplyBodyTranslation(bodyId, new Vector3D(request.Translation.X, request.Translation.Y, request.Translation.Z), out _))
+ {
+ return ApiMappings.NotFound($"Body '{bodyId}' was not found.", "documents.body");
+ }
+
+ return ApiMappings.Ok(new BodyTransformedResponseDto(documentId, bodyId, request.Translation));
+ }));
+
documents.MapPost("/{documentId:guid}/bodies/{bodyId:guid}/tessellate", (Guid documentId, Guid bodyId, TessellateRequestDto? request, KernelDocumentStore store) =>
- WithDocumentBody(store, documentId, bodyId, body =>
+ WithDocumentBody(store, documentId, bodyId, (document, body) =>
{
var options = ApiMappings.BuildTessellationOptions(request?.Options);
var kernel = BrepDisplayTessellator.Tessellate(body, options);
@@ -180,11 +191,16 @@ public static class KernelEndpoints
return ApiMappings.KernelFailure(kernel.Diagnostics);
}
+ if (document.TryGetBodyTransform(bodyId, out var transform))
+ {
+ return ApiMappings.Ok(ApiMappings.ToTessellationResponse(kernel.Value, transform));
+ }
+
return ApiMappings.Ok(ApiMappings.ToTessellationResponse(kernel.Value));
}));
documents.MapPost("/{documentId:guid}/bodies/{bodyId:guid}/pick", (Guid documentId, Guid bodyId, PickRequestDto request, KernelDocumentStore store) =>
- WithDocumentBody(store, documentId, bodyId, body =>
+ WithDocumentBody(store, documentId, bodyId, (document, body) =>
{
if (!Direction3D.TryCreate(new Vector3D(request.Direction.X, request.Direction.Y, request.Direction.Z), out var direction))
{
@@ -192,6 +208,11 @@ public static class KernelEndpoints
}
var ray = new Ray3D(new Point3D(request.Origin.X, request.Origin.Y, request.Origin.Z), direction);
+ if (document.TryGetBodyTransform(bodyId, out var transform) && transform.TryInverse(out var inverse))
+ {
+ ray = new Ray3D(inverse.Apply(ray.Origin), inverse.Apply(ray.Direction));
+ }
+
var kernel = BrepPicker.Pick(
body,
ray,
@@ -203,6 +224,11 @@ public static class KernelEndpoints
return ApiMappings.KernelFailure(kernel.Diagnostics);
}
+ if (document.TryGetBodyTransform(bodyId, out transform))
+ {
+ return ApiMappings.Ok(ApiMappings.ToPickResponse(kernel.Value, transform));
+ }
+
return ApiMappings.Ok(ApiMappings.ToPickResponse(kernel.Value));
}));
}
@@ -217,7 +243,7 @@ public static class KernelEndpoints
return operation(document);
}
- private static IResult WithDocumentBody(KernelDocumentStore store, Guid documentId, Guid bodyId, Func<BrepBody, IResult> operation)
+ private static IResult WithDocumentBody(KernelDocumentStore store, Guid documentId, Guid bodyId, Func<DocumentSession, BrepBody, IResult> operation)
=> WithDocument(store, documentId, document =>
{
if (!document.TryGetBody(bodyId, out var body))
@@ -225,7 +251,7 @@ public static class KernelEndpoints
return ApiMappings.NotFound($"Body '{bodyId}' was not found.", "documents.body");
}
- return operation(body);
+ return operation(document, body);
});
private static BodyCreatedResponseDto CreateBodyResponse(DocumentSession document, BrepBody body)
diff --git a/Aetheris.Server/Contracts/ApiContracts.cs b/Aetheris.Server/Contracts/ApiContracts.cs
index 7539bed6..590af2ca 100644
--- a/Aetheris.Server/Contracts/ApiContracts.cs
+++ b/Aetheris.Server/Contracts/ApiContracts.cs
@@ -24,6 +24,10 @@ public sealed record CylinderCreateRequestDto(double Radius, double Height);
public sealed record SphereCreateRequestDto(double Radius);
+public sealed record TranslateBodyRequestDto(Vector3Dto Translation);
+
+public sealed record BodyTransformedResponseDto(Guid DocumentId, Guid BodyId, Vector3Dto AppliedTranslation);
+
public sealed record ExtrudeRequestDto(
IReadOnlyList<ProfilePoint2Dto> Profile,
Point3Dto Origin,
diff --git a/Aetheris.Server/Documents/DocumentSession.cs b/Aetheris.Server/Documents/DocumentSession.cs
index 5c13380d..e0436e39 100644
--- a/Aetheris.Server/Documents/DocumentSession.cs
+++ b/Aetheris.Server/Documents/DocumentSession.cs
@@ -1,10 +1,12 @@
using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Math;
namespace Aetheris.Server.Documents;
public sealed class DocumentSession
{
private readonly Dictionary<Guid, BrepBody> _bodies = new();
+ private readonly Dictionary<Guid, Transform3D> _bodyTransforms = new();
private readonly object _sync = new();
public DocumentSession(Guid id, string? name = null)
@@ -31,6 +33,7 @@ public sealed class DocumentSession
lock (_sync)
{
_bodies[bodyId] = body;
+ _bodyTransforms[bodyId] = Transform3D.Identity;
}
return bodyId;
@@ -57,4 +60,36 @@ public sealed class DocumentSession
return true;
}
}
+
+ public bool TryGetBodyTransform(Guid bodyId, out Transform3D transform)
+ {
+ lock (_sync)
+ {
+ if (_bodyTransforms.TryGetValue(bodyId, out transform))
+ {
+ return true;
+ }
+
+ transform = Transform3D.Identity;
+ return false;
+ }
+ }
+
+ public bool ApplyBodyTranslation(Guid bodyId, Vector3D translation, out Transform3D updatedTransform)
+ {
+ lock (_sync)
+ {
+ if (!_bodies.ContainsKey(bodyId))
+ {
+ updatedTransform = Transform3D.Identity;
+ return false;
+ }
+
+ var current = _bodyTransforms.GetValueOrDefault(bodyId, Transform3D.Identity);
+ var delta = Transform3D.CreateTranslation(translation);
+ updatedTransform = delta * current;
+ _bodyTransforms[bodyId] = updatedTransform;
+ return true;
+ }
+ }
}
diff --git a/aetheris.client/src/App.css b/aetheris.client/src/App.css
index 2443ec39..8e27331b 100644
--- a/aetheris.client/src/App.css
+++ b/aetheris.client/src/App.css
@@ -32,7 +32,7 @@
.main-grid {
flex: 1;
display: grid;
- grid-template-columns: minmax(0, 1fr) 320px;
+ grid-template-columns: minmax(0, 1fr) 360px;
}
.viewport-shell {
@@ -51,12 +51,40 @@
margin-top: 0;
}
+.debug-panel section {
+ margin-bottom: 1rem;
+ padding-bottom: 0.75rem;
+ border-bottom: 1px solid #1e293b;
+}
+
.debug-panel ul {
margin: 0;
padding-left: 1rem;
word-break: break-word;
}
+.form-grid {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: 0.4rem;
+ margin-bottom: 0.5rem;
+}
+
+.form-grid label {
+ display: flex;
+ flex-direction: column;
+ gap: 0.25rem;
+ font-size: 0.8rem;
+}
+
+input {
+ border-radius: 4px;
+ border: 1px solid #334155;
+ padding: 0.3rem 0.4rem;
+ color: #e2e8f0;
+ background: #020617;
+}
+
button {
border-radius: 6px;
border: 1px solid #334155;
@@ -65,6 +93,11 @@ button {
background: #1e293b;
}
+button.active-row {
+ border-color: #38bdf8;
+ background: #0c4a6e;
+}
+
button:disabled {
opacity: 0.5;
cursor: not-allowed;
diff --git a/aetheris.client/src/App.tsx b/aetheris.client/src/App.tsx
index 5e599d88..a1aead0f 100644
--- a/aetheris.client/src/App.tsx
+++ b/aetheris.client/src/App.tsx
@@ -7,6 +7,7 @@ import {
getDocumentSummary,
pickBody,
tessellateBody,
+ translateBody,
type DiagnosticDto,
type PickHitDto,
type TessellationResponseDto,
@@ -28,6 +29,12 @@ function App() {
const [pickMessage, setPickMessage] = useState<string>('Click in the viewport to run nearest-hit pick.');
const [pickDiagnostics, setPickDiagnostics] = useState<DiagnosticDto[]>([]);
const [pickHits, setPickHits] = useState<PickHitDto[]>([]);
+ const [boxWidth, setBoxWidth] = useState('1.75');
+ const [boxHeight, setBoxHeight] = useState('1.25');
+ const [boxDepth, setBoxDepth] = useState('1.1');
+ const [tx, setTx] = useState('0');
+ const [ty, setTy] = useState('0');
+ const [tz, setTz] = useState('0');
const runAction = useCallback(async (actionName: string, action: () => Promise<void>) => {
setStatus('loading');
@@ -48,9 +55,28 @@ function App() {
}
}, []);
+ const refreshSummaryAndActiveTessellation = useCallback(async (targetBodyId?: string) => {
+ if (!documentId) {
+ return;
+ }
+
+ const summary = await getDocumentSummary(documentId);
+ const selected = targetBodyId ?? (summary.bodyIds.includes(activeBodyId ?? '') ? activeBodyId : summary.bodyIds[0] ?? null);
+
+ setBodyIds(summary.bodyIds);
+ setActiveBodyId(selected ?? null);
+
+ if (selected) {
+ const tessellated = await tessellateBody(documentId, selected);
+ setTessellation(tessellated);
+ } else {
+ setTessellation(null);
+ }
+ }, [activeBodyId, documentId]);
+
const handleCreateDocument = useCallback(async () => {
await runAction('Create document', async () => {
- const created = await createDocument('Viewer Shell M18');
+ const created = await createDocument('Basic Modeling UI M19');
setDocumentId(created.documentId);
setBodyIds([]);
setActiveBodyId(null);
@@ -67,21 +93,67 @@ function App() {
return;
}
- await runAction('Create box + tessellate', async () => {
- const created = await createBox(documentId, 1.75, 1.25, 1.1);
- const summary = await getDocumentSummary(documentId);
- const tessellated = await tessellateBody(documentId, created.bodyId);
+ const width = Number(boxWidth);
+ const height = Number(boxHeight);
+ const depth = Number(boxDepth);
- setBodyIds(summary.bodyIds);
- setActiveBodyId(created.bodyId);
- setTessellation(tessellated);
+ if (width <= 0 || height <= 0 || depth <= 0 || Number.isNaN(width) || Number.isNaN(height) || Number.isNaN(depth)) {
+ setStatus('error');
+ setStatusMessage('Box dimensions must be positive numbers.');
+ return;
+ }
+
+ await runAction('Create box', async () => {
+ const created = await createBox(documentId, width, height, depth);
+ await refreshSummaryAndActiveTessellation(created.bodyId);
setPickStatus('idle');
setPickMessage('Click in the viewport to run nearest-hit pick.');
setPickDiagnostics([]);
setPickHits([]);
});
+ }, [boxDepth, boxHeight, boxWidth, documentId, refreshSummaryAndActiveTessellation, runAction]);
+
+ const handleSelectBody = useCallback(async (nextBodyId: string) => {
+ if (!documentId) {
+ return;
+ }
+
+ await runAction('Select active body', async () => {
+ const tessellated = await tessellateBody(documentId, nextBodyId);
+ setActiveBodyId(nextBodyId);
+ setTessellation(tessellated);
+ setPickStatus('idle');
+ setPickMessage('Active body changed. Click in viewport to pick nearest hit.');
+ setPickDiagnostics([]);
+ setPickHits([]);
+ });
}, [documentId, runAction]);
+ const handleApplyTranslation = useCallback(async () => {
+ if (!documentId || !activeBodyId) {
+ return;
+ }
+
+ const x = Number(tx);
+ const y = Number(ty);
+ const z = Number(tz);
+
+ if ([x, y, z].some((value) => Number.isNaN(value))) {
+ setStatus('error');
+ setStatusMessage('Translation values must be valid numbers.');
+ return;
+ }
+
+ await runAction('Apply translation', async () => {
+ await translateBody(documentId, activeBodyId, { x, y, z });
+ await refreshSummaryAndActiveTessellation(activeBodyId);
+ setPickStatus('idle');
+ setPickMessage('Body translated. Click in viewport to refresh nearest hit.');
+ setPickDiagnostics([]);
+ setPickHits([]);
+ });
+ }, [activeBodyId, documentId, refreshSummaryAndActiveTessellation, runAction, tx, ty, tz]);
+
const handleRefreshTessellation = useCallback(async () => {
if (!documentId || !activeBodyId) {
return;
@@ -120,7 +192,7 @@ function App() {
setPickHits(pickResponse.hits);
setPickMessage(pickResponse.hits.length === 0
? 'No hit for current click ray.'
- : `Picked ${pickResponse.hits[0].entityKind} (nearest hit).`);
+ : `Picked ${pickResponse.hits[0].entityKind} (nearest hit on active body).`);
} catch (error) {
const apiError = error instanceof ApiError
? error
@@ -140,14 +212,11 @@ function App() {
return (
<div className="app-shell">
<header className="toolbar">
- <h1>Aetheris Viewer Shell (M18.5)</h1>
+ <h1>Aetheris Basic Modeling UI (M19)</h1>
<div className="toolbar-actions">
- <button type="button" onClick={() => void handleCreateDocument()}>
+ <button type="button" onClick={() => void handleCreateDocument()} disabled={status === 'loading'}>
Create Document
</button>
- <button type="button" onClick={() => void handleCreateBox()} disabled={!documentId || status === 'loading'}>
- Create Box
- </button>
<button type="button" onClick={() => void handleRefreshTessellation()} disabled={!activeBodyId || status === 'loading'}>
Refresh Tessellation
</button>
@@ -162,20 +231,55 @@ function App() {
onPickRay={(origin, direction) => void handlePickRay(origin, direction)}
/>
<aside className="debug-panel">
+ <h2>Modeling Controls</h2>
+ <section>
+ <h3>Create Box</h3>
+ <div className="form-grid">
+ <label>Width <input type="number" value={boxWidth} onChange={(event) => setBoxWidth(event.target.value)} /></label>
+ <label>Height <input type="number" value={boxHeight} onChange={(event) => setBoxHeight(event.target.value)} /></label>
+ <label>Depth <input type="number" value={boxDepth} onChange={(event) => setBoxDepth(event.target.value)} /></label>
+ </div>
+ <button type="button" onClick={() => void handleCreateBox()} disabled={!documentId || status === 'loading'}>Create Box</button>
+ </section>
+
+ <section>
+ <h3>Body List</h3>
+ {bodyIds.length === 0 ? <p>No bodies in document.</p> : (
+ <ul>
+ {bodyIds.map((bodyId) => (
+ <li key={bodyId}>
+ <button
+ type="button"
+ className={bodyId === activeBodyId ? 'active-row' : ''}
+ onClick={() => void handleSelectBody(bodyId)}
+ disabled={status === 'loading'}>
+ {bodyId}
+ </button>
+ </li>
+ ))}
+ </ul>
+ )}
+ </section>
+
+ <section>
+ <h3>Translate Active Body</h3>
+ <div className="form-grid">
+ <label>X <input type="number" value={tx} onChange={(event) => setTx(event.target.value)} /></label>
+ <label>Y <input type="number" value={ty} onChange={(event) => setTy(event.target.value)} /></label>
+ <label>Z <input type="number" value={tz} onChange={(event) => setTz(event.target.value)} /></label>
+ </div>
+ <button type="button" onClick={() => void handleApplyTranslation()} disabled={!activeBodyId || status === 'loading'}>Apply Translation</button>
+ </section>
+
<h2>Debug / Status</h2>
<p><strong>Request status:</strong> {status}</p>
<p><strong>Message:</strong> {statusMessage}</p>
<p><strong>Document ID:</strong> {documentId ?? 'None'}</p>
<p><strong>Active body ID:</strong> {activeBodyId ?? 'None'}</p>
<p><strong>Body count:</strong> {bodyIds.length}</p>
- <ul>
- {bodyIds.map((bodyId) => <li key={bodyId}>{bodyId}</li>)}
- </ul>
<p><strong>Face patches:</strong> {tessellation?.facePatches.length ?? 0}</p>
<p><strong>Edge polylines:</strong> {tessellation?.edgePolylines.length ?? 0}</p>
- <h3>Pick Behavior (M18.5)</h3>
- <p>Single left click in viewport sends world-space camera ray to backend.</p>
- <p>Pick mode: nearest-only. Backface handling: backend default (not overridden).</p>
+ <h3>Pick Diagnostics (active body only)</h3>
<p><strong>Pick status:</strong> {pickStatus}</p>
<p><strong>Pick message:</strong> {pickMessage}</p>
<p><strong>Pick hits:</strong> {pickHits.length}</p>
@@ -186,12 +290,6 @@ function App() {
<li><strong>Edge ID:</strong> {nearestHit.edgeId ?? 'n/a'}</li>
<li><strong>t:</strong> {nearestHit.t.toFixed(5)}</li>
<li><strong>Point:</strong> ({nearestHit.point.x.toFixed(5)}, {nearestHit.point.y.toFixed(5)}, {nearestHit.point.z.toFixed(5)})</li>
- <li>
- <strong>Normal:</strong>{' '}
- {nearestHit.normal
- ? `(${nearestHit.normal.x.toFixed(5)}, ${nearestHit.normal.y.toFixed(5)}, ${nearestHit.normal.z.toFixed(5)})`
- : 'n/a'}
- </li>
</ul>
) : <p>No nearest hit to display.</p>}
<h3>Pick Diagnostics</h3>
diff --git a/aetheris.client/src/__tests__/aetherisApi.test.ts b/aetheris.client/src/__tests__/aetherisApi.test.ts
index a13b212b..f2eb82bb 100644
--- a/aetheris.client/src/__tests__/aetherisApi.test.ts
+++ b/aetheris.client/src/__tests__/aetherisApi.test.ts
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
-import { ApiError, parseEnvelope, pickBody } from '../api/aetherisApi';
+import { ApiError, parseEnvelope, pickBody, translateBody } from '../api/aetherisApi';
describe('parseEnvelope', () => {
it('returns data when envelope success is true', async () => {
@@ -72,3 +72,27 @@ describe('pickBody', () => {
expect(response.hits[0].faceId).toBe(2);
});
});
+
+describe('translateBody', () => {
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ });
+
+ it('posts translation payload with v1 envelope handling', async () => {
+ const fetchMock = vi.fn().mockResolvedValue(new Response(JSON.stringify({
+ success: true,
+ data: {
+ documentId: 'doc-1',
+ bodyId: 'body-1',
+ appliedTranslation: { x: 1, y: 2, z: 3 },
+ },
+ diagnostics: [],
+ }), { status: 200 }));
+ vi.stubGlobal('fetch', fetchMock);
+
+ const response = await translateBody('doc-1', 'body-1', { x: 1, y: 2, z: 3 });
+
+ expect(fetchMock).toHaveBeenCalledWith('/api/v1/documents/doc-1/bodies/body-1/transform', expect.objectContaining({ method: 'POST' }));
+ expect(response.appliedTranslation.z).toBe(3);
+ });
+});
diff --git a/aetheris.client/src/api/aetherisApi.ts b/aetheris.client/src/api/aetherisApi.ts
index 32d69971..599550f6 100644
--- a/aetheris.client/src/api/aetherisApi.ts
+++ b/aetheris.client/src/api/aetherisApi.ts
@@ -32,6 +32,12 @@ export interface BodyCreatedResponseDto {
vertexCount: number;
}
+export interface BodyTransformedResponseDto {
+ documentId: string;
+ bodyId: string;
+ appliedTranslation: Vector3Dto;
+}
+
export interface Point3Dto {
x: number;
y: number;
@@ -167,4 +173,11 @@ export async function pickBody(documentId: string, bodyId: string, pickRequest:
});
}
+export async function translateBody(documentId: string, bodyId: string, translation: Vector3Dto): Promise<BodyTransformedResponseDto> {
+ return request<BodyTransformedResponseDto>(`/api/v1/documents/${documentId}/bodies/${bodyId}/transform`, {
+ method: 'POST',
+ body: JSON.stringify({ translation }),
+ });
+}
+
export { parseEnvelope };
diff --git a/docs/milestones.md b/docs/milestones.md
index 1c916ce0..73da9e19 100644
--- a/docs/milestones.md
+++ b/docs/milestones.md
@@ -171,3 +171,11 @@
- [x] Surface pick status, hit details (kind, IDs, t, point, normal), and diagnostics/no-hit feedback in the debug panel.
- [x] Add minimal debug highlighting for nearest picked face/edge using tessellation topology IDs.
- [x] Defer full selection UX/tooling architecture (multi-select, inspectors, manipulators, hover/tool systems) to M19+.
+
+## M19 — Basic Modeling UI v1 (Primitive + Transform)
+
+- [x] Extend the React frontend with explicit modeling controls: box primitive creation form, body list, active body selection, and numeric translation inputs.
+- [x] Keep backend as source of truth by refreshing document summary + tessellation after create/transform operations and surfacing deterministic status/diagnostics.
+- [x] Add minimal backend transform route (`POST /api/v1/documents/{documentId}/bodies/{bodyId}/transform`) with typed DTOs and M17 envelope semantics.
+- [x] Apply document-level body transforms to tessellation and picking responses so viewport updates and hit data stay in world space after translation.
+- [x] Preserve M18/M18.5 debug visibility (active body, body count, pick status/hits/diagnostics, tessellation counts) while deferring booleans UI, gizmos, undo/redo, feature tree, and persistence to later milestones.