Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(modeling): a boolean step cuts real holes and a uv step aims textures, with an atlas for a texture painted for one model

yhhf7cb04100872
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c458597aa..c1f89a743 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,7 +19,7 @@ published separately; it ships inside the editor.
- **Glyphs can be put on the atlas before they are shown.** The first page of a novel is hundreds of new characters, all landing in one frame. `preloadGlyphs(app, label, text, { budgetMs })` makes them ahead of time, a slice a frame, drawn as that `Text` will draw them, and returns `progress`, `done` and `release()`. On a Snapdragon 8 Elite a book's 2992 characters at 28 px took 145 ms over 25 frames with the worst frame at 9.5 ms, after which the first page's frame went from 49 to 11 ms and no page made a new glyph. Preloaded glyphs hold their atlas pages (4 MB each, a few hundred characters at that size) until `release()`.
- **Voxel GI lights what the camera does not see, and bounces light more than once.** The cache now reads the sun's shadow map back into the world, so a surface the sun lights behind or beside the camera still sends light into the view. Each surface also gives off again the bounce light it received, so a corner or a floor in shade gets light that took two or more bounces to reach it. A ray now brings what it meets at full strength however far it went (it used to fade with distance, 40% at 4 m with 12 cm voxels). Each voxel is weighed by how much of it a surface covers, so a bright patch no longer lights like the whole voxel around it. Together these keep the result close to a path tracer's whatever the voxel size. In a sunlit test room the whole frame carries 0.95 of Cycles' light at the default size and 0.74 at 12 cm voxels; before, it was 0.54 at the default and darker the finer the grid. With the lit patch behind the camera, the walls went from no bounce light to 25–57%. A closed room the sun only lights from outside stays dark. Two inspector controls tune it: **Off-screen Sun Albedo** (the colour the shadow map cannot give, assumed) and **Multi-bounce**. A fine grid no longer drops every voxel: a count truncated by the cache's ageing had kept them below the two samples a ray asks for. The WebGL2 fallback does the same in its own passes: each voxel asks the sun's map whether a sunlit surface stands in it, and traces two rays through last frame's grid for the light it is given. In the test room it carries 1.00 of Cycles' light at the default size (it was 0.56) and 0.80 at 12 cm; with the lit patch behind the camera 0.20 (it was 0). Its voxel pass costs about 1.3 ms more at 720p on a desktop.
-**AI agents can build 3D models in the editor from steps.** The `modeling` tool group writes a `.esmodel`, the steps that build a model (boxes, cylinders and floor plans, then extrude, inset, bevel, slice, array, mirror, paint), and bakes the `.esmesh` a scene draws beside it. Changing one number rebuilds it and whatever draws it follows, Undo takes both files back, and `model_views` shows every side with its silhouette, so an agent can check a shape without a scene. Blockouts, buildings and hard-surface props; and with the `organic` step, creatures, plants and rocks, as one skin over parts that melt into each other, carve, mirror and roughen.
+**AI agents can build 3D models in the editor from steps.** The `modeling` tool group writes a `.esmodel`, the steps that build a model (boxes, cylinders and floor plans, then extrude, inset, bevel, slice, array, mirror, paint), and bakes the `.esmesh` a scene draws beside it. Changing one number rebuilds it and whatever draws it follows, Undo takes both files back, and `model_views` shows every side with its silhouette, so an agent can check a shape without a scene. Blockouts, buildings and hard-surface props; and with the `organic` step, creatures, plants and rocks, as one skin over parts that melt into each other, carve, mirror and roughen. A `boolean` step cuts real holes through solids, and a `uv` step or `uvAtlas` lays out how a texture lands.
- **A model of many parts that moves: `CompositeBatch`.** Put it on the root of a ship, a vehicle or a moving platform assembled from many meshes, and while the game runs its parts are drawn in a few draws parented to the root: a mesh repeated four times or more (a deck plank, a rail post) as one instanced set that copies no vertices, every other part merged by draw state into chunks of the root's own space. Moving, turning or scaling the root moves the whole model and merges nothing again. Adding, removing, re-meshing or re-placing a part re-merges only its chunk within half a second (`CompositeBatchingRes.refresh(root)` looks at once), and a part that keeps moving inside the model is let go to draw itself. The root reports what it drew, and so does `get_stats`. On a model of 2,004 parts, the meshes handed to the renderer went from 2,003 to 5 and the CPU frame from 3.3 ms to 1.2–1.4 ms; a model of about a hundred parts costs the same either way. A part under a composite is never also statically batched.
diff --git a/desktop b/desktop
index b4c4e4055..a8c1bb8eb 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit b4c4e4055dce5eb1dbe2532845777c83ba3e6085
+Subproject commit a8c1bb8eb712d441bf8e4b15fe6a3537098383e9
diff --git a/pipeline/package.json b/pipeline/package.json
index 80f630b37..51b1ac3fd 100644
--- a/pipeline/package.json
+++ b/pipeline/package.json
@@ -21,6 +21,7 @@
"ffmpeg-static": "^5.3.0",
"jpeg-js": "0.4.4",
"js-yaml": "4.3.0",
+ "manifold-3d": "3.5.4",
"meshoptimizer": "^1.2.0",
"pngjs": "^7.0.0",
"typescript": "^6.0.3",
diff --git a/pipeline/src/modeling/booleans.ts b/pipeline/src/modeling/booleans.ts
new file mode 100644
index 000000000..00d6da945
--- /dev/null
+++ b/pipeline/src/modeling/booleans.ts
@@ -0,0 +1,159 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file booleans.ts — the `boolean` step: a hole right through a wall, parts welded into one.
+ *
+ * Manifold does the cut, because a hand-written one leaves the cracks and slivers
+ * that this kernel's own report exists to catch. Its wasm loads asynchronously and
+ * a build is synchronous, so a caller prepares it first: see {@link prepareModeling}.
+ */
+import { triangulateFace } from './triangulate';
+import { collectEdges, compact, selectFaces, type Face, type FaceSelector, type PolyMesh, type Vec3 } from './polyMesh';
+
+interface ManifoldMeshData {
+ numProp: number;
+ vertProperties: Float32Array;
+ triVerts: Uint32Array;
+ faceID?: Uint32Array;
+}
+interface ManifoldSolid {
+ add(other: ManifoldSolid): ManifoldSolid;
+ subtract(other: ManifoldSolid): ManifoldSolid;
+ intersect(other: ManifoldSolid): ManifoldSolid;
+ getMesh(): ManifoldMeshData;
+ isEmpty(): boolean;
+ delete(): void;
+}
+interface ManifoldEngine {
+ setup(): void;
+ Mesh: new (data: ManifoldMeshData) => ManifoldMeshData;
+ Manifold: new (mesh: ManifoldMeshData) => ManifoldSolid;
+}
+
+let engine: ManifoldEngine | null = null;
+
+/** Whether any step of a parsed source needs {@link prepareModeling} first. */
+export const needsPreparing = (steps: readonly { op: string }[]): boolean => steps.some((s) => s.op === 'boolean');
+
+/**
+ * Loads what a `boolean` step runs on; once is enough. `wasmUrl` is for a bundled host,
+ * where the module cannot find its own file beside itself.
+ */
+export async function prepareModeling(wasmUrl?: string): Promise<void> {
+ if (engine) return;
+ const { default: Module } = await import('manifold-3d/manifold') as unknown as {
+ default: (options?: { locateFile?: () => string }) => Promise<ManifoldEngine>;
+ };
+ const loaded = await Module(wasmUrl ? { locateFile: () => wasmUrl } : undefined);
+ loaded.setup();
+ engine = loaded;
+}
+
+/** Why these faces are not a solid a boolean could cut, or null. */
+function notSolid(mesh: PolyMesh, faces: readonly number[]): string | null {
+ const only: PolyMesh = { positions: mesh.positions, faces: faces.map((f) => mesh.faces[f]!) };
+ let open = 0, crowded = 0;
+ for (const edge of collectEdges(only).values()) {
+ if (edge.faces.length === 1) open++;
+ else if (edge.faces.length > 2) crowded++;
+ }
+ if (open) return `they have ${open} open edge${open > 1 ? 's' : ''}, so there is no inside to cut`;
+ if (crowded) return `${crowded} edge${crowded > 1 ? 's are' : ' is'} shared by more than two faces; raise an organic skin's resolution or blend, or weld`;
+ return null;
+}
+
+function toSolid(e: ManifoldEngine, mesh: PolyMesh, faces: readonly number[], triangulate: (face: Face) => [number, number, number][]): ManifoldSolid {
+ const remap = new Map<number, number>();
+ const props: number[] = [];
+ const tris: number[] = [];
+ const ids: number[] = [];
+ const index = (v: number): number => {
+ let to = remap.get(v);
+ if (to === undefined) {
+ to = props.length / 3;
+ remap.set(v, to);
+ const p = mesh.positions[v]!;
+ props.push(p[0], p[1], p[2]);
+ }
+ return to;
+ };
+ for (const f of faces) {
+ for (const [a, b, c] of triangulate(mesh.faces[f]!)) {
+ tris.push(index(a), index(b), index(c));
+ ids.push(f);
+ }
+ }
+ const data = new e.Mesh({
+ numProp: 3,
+ vertProperties: new Float32Array(props),
+ triVerts: new Uint32Array(tris),
+ faceID: new Uint32Array(ids),
+ });
+ try {
+ return new e.Manifold(data);
+ } catch (err) {
+ throw new Error(`these faces are not a clean solid (${(err as Error).message}), so they cannot be cut: raise an organic skin's resolution, or weld and check the report's warnings`);
+ }
+}
+
+export type BooleanOperation = 'subtract' | 'union' | 'intersect';
+
+export interface BooleanParams {
+ operation: BooleanOperation;
+ /** The cutter, or what is added: a closed shell, usually by its tag. Consumed unless `keep`. */
+ with: FaceSelector;
+ /** What is cut. Default every face not in `with`. */
+ from?: FaceSelector;
+ keep?: boolean;
+ /** Names the walls of the cut, which otherwise take the cutter's tag. */
+ tag?: string;
+ color?: readonly number[];
+}
+
+/** Applies the operation. Each result face keeps the tag and colour of the face it came from; a cut's walls come from the cutter. */
+export function booleanOp(mesh: PolyMesh, p: BooleanParams): PolyMesh {
+ if (!engine) throw new Error('booleans are not loaded: call prepareModeling() before building this source');
+ if (!['subtract', 'union', 'intersect'].includes(p.operation)) throw new Error(`operation ${JSON.stringify(p.operation)} must be subtract, union or intersect`);
+ const tool = selectFaces(mesh, p.with);
+ if (tool.length === 0) throw new Error(`\`with\` ${JSON.stringify(p.with)} matched no face`);
+ const toolSet = new Set(tool);
+ const target = (p.from === undefined ? mesh.faces.map((_, i) => i) : selectFaces(mesh, p.from)).filter((f) => !toolSet.has(f));
+ if (target.length === 0) throw new Error(`\`from\` ${JSON.stringify(p.from ?? 'everything else')} leaves no face to act on`);
+ for (const [name, faces] of [['with', tool], ['from', target]] as const) {
+ const bad = notSolid(mesh, faces);
+ if (bad) throw new Error(`the faces in \`${name}\` are not a closed solid: ${bad}`);
+ }
+
+ const triangulate = (face: Face): [number, number, number][] => triangulateFace(mesh, face);
+ const a = toSolid(engine, mesh, target, triangulate);
+ const b = toSolid(engine, mesh, tool, triangulate);
+ const result = p.operation === 'subtract' ? a.subtract(b) : p.operation === 'union' ? a.add(b) : a.intersect(b);
+ try {
+ if (result.isEmpty()) throw new Error(`this ${p.operation} leaves nothing: do the two actually overlap?`);
+ const out = result.getMesh();
+ const base = mesh.positions.length;
+ const positions: Vec3[] = [...mesh.positions];
+ for (let i = 0; i < out.vertProperties.length; i += out.numProp) {
+ positions.push([out.vertProperties[i]!, out.vertProperties[i + 1]!, out.vertProperties[i + 2]!]);
+ }
+ const targetSet = new Set(target);
+ const kept = mesh.faces.filter((_, i) => !targetSet.has(i) && (p.keep === true || !toolSet.has(i)));
+ const made: Face[] = [];
+ for (let t = 0; t * 3 < out.triVerts.length; t++) {
+ const source = mesh.faces[out.faceID![t]!];
+ if (!source) throw new Error(`the cut lost track of a face (${out.faceID![t]})`);
+ const fromTool = toolSet.has(out.faceID![t]!);
+ made.push({
+ ...source,
+ v: [out.triVerts[t * 3]! + base, out.triVerts[t * 3 + 1]! + base, out.triVerts[t * 3 + 2]! + base],
+ ...(fromTool && p.tag ? { tag: p.tag } : {}),
+ ...(fromTool && p.color ? { color: [p.color[0]!, p.color[1]!, p.color[2]!, p.color[3] ?? 1] as const } : {}),
+ });
+ }
+ return compact({ positions, faces: [...kept, ...made] });
+ } finally {
+ a.delete();
+ b.delete();
+ result.delete();
+ }
+}
diff --git a/pipeline/src/modeling/index.ts b/pipeline/src/modeling/index.ts
index e130ebdcd..9423a34ac 100644
--- a/pipeline/src/modeling/index.ts
+++ b/pipeline/src/modeling/index.ts
@@ -9,6 +9,7 @@ export {
type ModelEdit, type ModelSource, type ModelStep, type StepReport,
} from './modelSource';
export { organic, ORGANIC_DEFAULT_RESOLUTION, ORGANIC_MAX_RESOLUTION, type OrganicParams, type OrganicPart } from './organic';
+export { needsPreparing, prepareModeling } from './booleans';
export { bakeModel, type BakedModel, type ModelReport } from './modelBake';
export type { FaceSelector } from './polyMesh';
export { DEFAULT_MODEL_VIEWS, MODEL_VIEWS, renderModelSheet, type ModelSheet, type ModelViewName } from './modelViews';
diff --git a/pipeline/src/modeling/modelBake.ts b/pipeline/src/modeling/modelBake.ts
index 119219498..9b71270da 100644
--- a/pipeline/src/modeling/modelBake.ts
+++ b/pipeline/src/modeling/modelBake.ts
@@ -9,10 +9,12 @@
* where the same fault in a lit picture reads as a slightly odd shadow.
*/
import { MeshChannel, MeshChannelType, packChannels, unwrapLightmapUV, type MeshData } from 'esengine';
+import { triangulateFace } from './triangulate';
+import { faceUvs } from './modelUv';
import { buildPolyMesh, validateModelSource, type ModelSource, type StepReport } from './modelSource';
import {
boundsOf, collectEdges, cross, dot, faceArea, faceNormal, length, normalize, sub,
- type Face, type PolyMesh, type Vec3,
+ type PolyMesh, type Vec3,
} from './polyMesh';
const DEFAULT_SMOOTH_ANGLE = 30;
@@ -47,57 +49,6 @@ export interface BakedModel {
triangles: { v: [number, number, number]; face: number }[];
}
-// ---- Triangulation ---------------------------------------------------------------
-
-/** Ear clipping in the face's own plane: n-gons here can be concave (a prism's floor plan). */
-function triangulateFace(mesh: PolyMesh, face: Face): [number, number, number][] {
- const count = face.v.length;
- if (count < 3) return [];
- if (count === 3) return [[face.v[0]!, face.v[1]!, face.v[2]!]];
- const n = faceNormal(mesh, face);
- const ref = Math.abs(n[0]) < 0.9 ? [1, 0, 0] as Vec3 : [0, 1, 0] as Vec3;
- const u = normalize(cross(ref, n));
- const w = cross(n, u);
- const flat = face.v.map((i) => {
- const p = mesh.positions[i]!;
- return [dot(p, u), dot(p, w)] as const;
- });
- const area2 = (a: number, b: number, c: number): number => {
- const [ax, ay] = flat[a]!, [bx, by] = flat[b]!, [cx, cy] = flat[c]!;
- return (bx - ax) * (cy - ay) - (cx - ax) * (by - ay);
- };
- const span = Math.max(...flat.map((q) => Math.hypot(q[0] - flat[0]![0], q[1] - flat[0]![1])), 1e-9);
- const tiny = span * span * 1e-10;
- const out: [number, number, number][] = [];
- const loop = flat.map((_, i) => i);
- let guard = count * count + 8;
- while (loop.length > 3 && guard-- > 0) {
- let clipped = false;
- for (let i = 0; i < loop.length; i++) {
- const a = loop[(i + loop.length - 1) % loop.length]!, b = loop[i]!, c = loop[(i + 1) % loop.length]!;
- if (area2(a, b, c) <= tiny) continue; // reflex, or a vertex lying on a straight run (kept: a neighbour may rely on it)
- let blocked = false;
- for (const q of loop) {
- if (q === a || q === b || q === c) continue;
- if (area2(a, b, q) >= -tiny && area2(b, c, q) >= -tiny && area2(c, a, q) >= -tiny) { blocked = true; break; }
- }
- if (blocked) continue;
- out.push([face.v[a]!, face.v[b]!, face.v[c]!]);
- loop.splice(i, 1);
- clipped = true;
- break;
- }
- if (!clipped) break;
- }
- // What is left is a triangle, or a loop no ear could be cut from: a self-crossing face. Fanned, it still draws something to look at.
- for (let i = 1; i + 1 < loop.length; i++) {
- if (Math.abs(area2(loop[0]!, loop[i]!, loop[i + 1]!)) > tiny) {
- out.push([face.v[loop[0]!]!, face.v[loop[i]!]!, face.v[loop[i + 1]!]!]);
- }
- }
- return out;
-}
-
// ---- Report -----------------------------------------------------------------------
/** Shells as lists of faces: faces sharing a vertex are one. */
@@ -154,14 +105,6 @@ function cornerNormals(mesh: PolyMesh, smoothAngle: number): Vec3[][] {
}));
}
-/** A box projection, face by face: the same scale everywhere, so a tiling texture does not stretch. */
-function projectUv(p: Vec3, n: Vec3, uvScale: number): [number, number] {
- const [ax, ay, az] = [Math.abs(n[0]), Math.abs(n[1]), Math.abs(n[2])];
- if (ay >= ax && ay >= az) return [p[0] / uvScale, (n[1] > 0 ? -p[2] : p[2]) / uvScale];
- if (ax >= az) return [(n[0] > 0 ? -p[2] : p[2]) / uvScale, p[1] / uvScale];
- return [(n[2] > 0 ? p[0] : -p[0]) / uvScale, p[1] / uvScale];
-}
-
function toMeshData(mesh: PolyMesh, triangles: readonly [number, number, number][][], source: ModelSource): MeshData {
const { channels, vertexStride } = packChannels([
{ semantic: MeshChannel.Position, components: 3, type: MeshChannelType.Float32 },
@@ -174,12 +117,14 @@ function toMeshData(mesh: PolyMesh, triangles: readonly [number, number, number]
const seen = new Map<string, number>();
const pos: number[] = [], nrm: number[] = [], uv: number[] = [], col: number[] = [];
const indices: number[] = [];
+ const uvs = new Map<number, Map<number, readonly [number, number]>>();
const vertexOf = (f: number, v: number): number => {
const face = mesh.faces[f]!;
const n = normals[f]![face.v.indexOf(v)]!;
- const flat = faceNormal(mesh, face);
const p = mesh.positions[v]!;
- const [tu, tv] = projectUv(p, flat, uvScale);
+ let corners = uvs.get(f);
+ if (!corners) { corners = faceUvs(mesh, face, uvScale); uvs.set(f, corners); }
+ const [tu, tv] = corners.get(v)!;
const color = (face.color ?? [1, 1, 1, 1]).map((c) => Math.round(c * 255));
const key = `${v}|${n.map((x) => x.toFixed(4))}|${tu.toFixed(5)},${tv.toFixed(5)}|${color}`;
let at = seen.get(key);
@@ -222,6 +167,18 @@ function toMeshData(mesh: PolyMesh, triangles: readonly [number, number, number]
};
}
+/** Gives the base UV the unwrap's: no two triangles share texels, so a texture can be painted for this one model. */
+function copyLightmapUvToBase(mesh: MeshData): void {
+ const from = mesh.channels.find((c) => c.semantic === MeshChannel.TexCoord1)!.offset;
+ const to = mesh.channels.find((c) => c.semantic === MeshChannel.TexCoord0)!.offset;
+ const view = new DataView(mesh.vertices.buffer, mesh.vertices.byteOffset, mesh.vertices.byteLength);
+ for (let i = 0; i < mesh.vertexCount; i++) {
+ const at = i * mesh.vertexStride;
+ view.setFloat32(at + to, view.getFloat32(at + from, true), true);
+ view.setFloat32(at + to + 4, view.getFloat32(at + from + 4, true), true);
+ }
+}
+
/** Validates, builds and bakes @p raw. Throws a ModelBuildError naming the step that failed; writes nothing, so a failure leaves nothing half made. */
export function bakeModel(raw: unknown): BakedModel {
const source = validateModelSource(raw);
@@ -230,6 +187,7 @@ export function bakeModel(raw: unknown): BakedModel {
const triangles = mesh.faces.map((f) => triangulateFace(mesh, f));
const unwrapped = unwrapLightmapUV(toMeshData(mesh, triangles, source)).mesh;
+ if (source.uvAtlas) copyLightmapUvToBase(unwrapped);
const edges = [...collectEdges(mesh).values()];
const openEdges = edges.filter((e) => e.faces.length === 1).length;
diff --git a/pipeline/src/modeling/modelSource.ts b/pipeline/src/modeling/modelSource.ts
index 44a66a043..82839afc4 100644
--- a/pipeline/src/modeling/modelSource.ts
+++ b/pipeline/src/modeling/modelSource.ts
@@ -14,6 +14,8 @@
*/
import * as ops from './modelOps';
import { organic } from './organic';
+import { booleanOp } from './booleans';
+import { uvStep } from './modelUv';
import { compact, type Face, type FaceSelector, type PolyMesh, type Vec3 } from './polyMesh';
export const MODEL_SOURCE_VERSION = 1;
@@ -32,11 +34,13 @@ export interface ModelSource {
smoothAngle?: number;
/** World units one texture repeat covers. Default 1. */
uvScale?: number;
+ /** Lay the base UV out so no two triangles share texels: for a texture painted for this one model, where tiling is not wanted. */
+ uvAtlas?: boolean;
steps: ModelStep[];
}
type Kind = 'number' | 'integer' | 'boolean' | 'string' | 'vec3' | 'number|vec3' | 'number|vec2' | 'number|numbers'
- | 'color' | 'points' | 'faces' | 'edges' | 'axis' | 'pivot' | 'parts' | 'noise';
+ | 'color' | 'points' | 'faces' | 'edges' | 'axis' | 'pivot' | 'parts' | 'noise' | 'operation' | 'uvmode' | 'number|vec2only' | 'vec2';
interface OpSpec {
params: Record<string, Kind>;
@@ -64,6 +68,8 @@ export const MODEL_OPS: Record<string, OpSpec> = {
inset: { params: { faces: 'faces', amount: 'number', tag: 'string' }, required: ['faces', 'amount'], run: ops.inset as OpSpec['run'], says: 'adds a smaller copy inside each face; `tag` names that copy' },
bevel: { params: { edges: 'edges', width: 'number', tag: 'string' }, required: ['edges', 'width'], run: ops.bevel as OpSpec['run'], says: 'chamfers edges flat, mitring where they meet' },
slice: { params: { faces: 'faces', axis: 'axis', at: 'number|numbers' }, required: ['axis', 'at'], run: ops.slice as OpSpec['run'], says: 'cuts faces across planes, making the seams a window sits between' },
+ boolean: { params: { operation: 'operation', with: 'faces', from: 'faces', keep: 'boolean', tag: 'string', color: 'color' }, required: ['operation', 'with'], run: booleanOp as unknown as OpSpec['run'], says: 'cuts or joins closed solids: subtract `with` from `from` makes a real hole' },
+ uv: { params: { faces: 'faces', mode: 'uvmode', axis: 'string', at: 'vec3', scale: 'number|vec2only', repeat: 'number|vec2only', offset: 'vec2', rotate: 'number' }, required: ['mode'], run: uvStep as unknown as OpSpec['run'], says: 'sets how faces take a texture: box, planar, cylinder or sphere' },
delete: { params: { faces: 'faces' }, required: ['faces'], run: ops.deleteFaces as OpSpec['run'], says: 'removes faces, leaving a hole' },
paint: { params: { faces: 'faces', color: 'color' }, required: ['faces', 'color'], run: ops.paint as OpSpec['run'], says: 'sets vertex colour: linear [r, g, b] in 0..1, multiplied into the material' },
tag: { params: { faces: 'faces', tag: 'string' }, required: ['faces', 'tag'], run: ops.tagFaces as OpSpec['run'], says: 'names faces for later steps' },
@@ -181,6 +187,10 @@ const KIND_CHECK: Record<Kind, (v: unknown) => string | null> = {
edges: checkEdges,
axis: (v) => (v === 'x' || v === 'y' || v === 'z' ? null : 'must be x, y or z'),
parts: checkParts,
+ operation: (v) => (v === 'subtract' || v === 'union' || v === 'intersect' ? null : 'must be subtract, union or intersect'),
+ uvmode: (v) => (['box', 'planar', 'cylinder', 'sphere'].includes(v as string) ? null : 'must be box, planar, cylinder or sphere'),
+ 'number|vec2only': (v) => (isNum(v) || isNums(v, 2) ? null : 'must be a number or [u, v]'),
+ vec2: (v) => (isNums(v, 2) ? null : 'must be [u, v]'),
noise: checkNoise,
pivot: (v) => (v === 'center' || v === 'base' || isNums(v, 3) ? null : 'must be "center", "base" or [x, y, z]'),
};
@@ -200,8 +210,8 @@ export function validateModelSource(raw: unknown): ModelSource {
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) throw new ModelBuildError('a model source must be an object with `steps`', null, null, null);
const source = raw as Record<string, unknown>;
for (const key of Object.keys(source)) {
- if (!['version', 'smoothAngle', 'uvScale', 'steps'].includes(key)) {
- throw new ModelBuildError(`unknown field "${key}"; a model source has version, smoothAngle, uvScale, steps`, null, null, null);
+ if (!['version', 'smoothAngle', 'uvScale', 'uvAtlas', 'steps'].includes(key)) {
+ throw new ModelBuildError(`unknown field "${key}"; a model source has version, smoothAngle, uvScale, uvAtlas, steps`, null, null, null);
}
}
if (source.version !== undefined && source.version !== MODEL_SOURCE_VERSION) {
@@ -213,6 +223,9 @@ export function validateModelSource(raw: unknown): ModelSource {
if (source.uvScale !== undefined && !(isNum(source.uvScale) && source.uvScale > 0)) {
throw new ModelBuildError('uvScale must be a positive number', null, null, null);
}
+ if (source.uvAtlas !== undefined && typeof source.uvAtlas !== 'boolean') {
+ throw new ModelBuildError('uvAtlas must be true or false', null, null, null);
+ }
if (!Array.isArray(source.steps)) throw new ModelBuildError('`steps` must be an array', null, null, null);
const ids = new Set<string>();
source.steps.forEach((step: Partial<ModelStep> | null, index: number) => {
@@ -274,7 +287,7 @@ export type ModelEdit =
| { op: 'set'; step: string | number; fields: Record<string, unknown> }
| { op: 'insert'; step: ModelStep; before?: string | number; after?: string | number }
| { op: 'remove'; step: string | number }
- | { op: 'settings'; fields: Pick<ModelSource, 'smoothAngle' | 'uvScale'> };
+ | { op: 'settings'; fields: Pick<ModelSource, 'smoothAngle' | 'uvScale' | 'uvAtlas'> };
function indexOfStep(source: ModelSource, ref: string | number): number {
const i = typeof ref === 'number' ? ref : source.steps.findIndex((s) => s.id === ref);
diff --git a/pipeline/src/modeling/modelUv.ts b/pipeline/src/modeling/modelUv.ts
new file mode 100644
index 000000000..8701a025c
--- /dev/null
+++ b/pipeline/src/modeling/modelUv.ts
@@ -0,0 +1,102 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file modelUv.ts — how each face takes a texture: the `uv` step, and the corner UVs
+ * the bake asks for. A face's corners are worked out together, because a seam
+ * can only be stepped over by looking at the corners next to each other.
+ */
+import {
+ boundsOf, dot, faceNormal, isAxisName, axisVector, selectFaces, sub,
+ type Face, type FaceSelector, type FaceUv, type PolyMesh, type Vec3,
+} from './polyMesh';
+
+const pair = (v: number | readonly number[] | undefined, fallback: readonly [number, number]): readonly [number, number] =>
+ v === undefined ? fallback : typeof v === 'number' ? [v, v] : [v[0]!, v[1]!];
+
+export interface UvParams {
+ faces?: FaceSelector;
+ mode: FaceUv['mode'];
+ axis?: string;
+ at?: Vec3;
+ scale?: number | readonly number[];
+ repeat?: number | readonly number[];
+ offset?: readonly number[];
+ rotate?: number;
+}
+
+export function uvStep(mesh: PolyMesh, p: UvParams): PolyMesh {
+ const selector = p.faces ?? 'all';
+ const hit = selectFaces(mesh, selector);
+ if (hit.length === 0) throw new Error(`\`faces\` ${JSON.stringify(selector)} matched no face`);
+ const axis = p.axis ?? (p.mode === 'planar' ? '+z' : p.mode === 'cylinder' ? 'y' : undefined);
+ if (p.mode === 'planar' && !isAxisName(axis!)) throw new Error(`a planar uv's axis ${JSON.stringify(axis)} must be one like "+z"`);
+ if (p.mode === 'cylinder' && !['x', 'y', 'z'].includes(axis!)) throw new Error(`a cylinder uv's axis ${JSON.stringify(axis)} must be x, y or z`);
+ const scale = pair(p.scale, [1, 1]);
+ if (scale[0] === 0 || scale[1] === 0) throw new Error('scale must not be 0');
+
+ const { min, max } = boundsOf(mesh, new Set(hit.flatMap((f) => mesh.faces[f]!.v)));
+ const k = { x: 0, y: 1, z: 2 }[axis as 'x'] ?? 1;
+ const uv: FaceUv = {
+ mode: p.mode,
+ ...(axis ? { axis } : {}),
+ center: p.at ?? [(min[0] + max[0]) / 2, (min[1] + max[1]) / 2, (min[2] + max[2]) / 2],
+ extent: Math.max(max[k]! - min[k]!, 1e-6),
+ scale,
+ repeat: pair(p.repeat, [1, 1]),
+ offset: pair(p.offset, [0, 0]),
+ rotate: p.rotate ?? 0,
+ };
+ const set = new Set(hit);
+ return { ...mesh, faces: mesh.faces.map((f, i) => (set.has(i) ? { ...f, uv } : f)) };
+}
+
+/** The in-plane axes a texture is laid along when seen from @p n, with up staying up where it can. */
+function planeAxes(n: Vec3): [Vec3, Vec3] {
+ const [ax, ay, az] = [Math.abs(n[0]), Math.abs(n[1]), Math.abs(n[2])];
+ if (ay >= ax && ay >= az) return [[1, 0, 0], n[1] > 0 ? [0, 0, -1] : [0, 0, 1]];
+ if (ax >= az) return [n[0] > 0 ? [0, 0, -1] : [0, 0, 1], [0, 1, 0]];
+ return [n[2] > 0 ? [1, 0, 0] : [-1, 0, 0], [0, 1, 0]];
+}
+
+function finish(uv: FaceUv | undefined, u: number, v: number): [number, number] {
+ if (!uv) return [u, v];
+ const a = (uv.rotate * Math.PI) / 180;
+ const [c, s] = [Math.cos(a), Math.sin(a)];
+ return [c * u - s * v + uv.offset[0], s * u + c * v + uv.offset[1]];
+}
+
+/** The UV at each corner of @p face. */
+export function faceUvs(mesh: PolyMesh, face: Face, uvScale: number): Map<number, readonly [number, number]> {
+ const out = new Map<number, readonly [number, number]>();
+ const uv = face.uv;
+ if (!uv || uv.mode === 'box' || uv.mode === 'planar') {
+ const normal = uv?.mode === 'planar' ? axisVector(uv.axis as never) : faceNormal(mesh, face);
+ const [right, up] = planeAxes(normal);
+ const [su, sv] = uv ? uv.scale : [uvScale, uvScale];
+ const origin: Vec3 = uv ? uv.center : [0, 0, 0];
+ for (const i of face.v) {
+ const p = sub(mesh.positions[i]!, origin);
+ out.set(i, finish(uv, dot(p, right) / su, dot(p, up) / sv));
+ }
+ return out;
+ }
+ // The round modes: an angle jumps by a whole turn across its seam, and a face straddling that must not paint the texture backwards across itself.
+ const raw = face.v.map((i) => {
+ const q = sub(mesh.positions[i]!, uv.center);
+ if (uv.mode === 'sphere') {
+ const len = Math.hypot(q[0], q[1], q[2]) || 1;
+ return [Math.atan2(q[0], q[2]) / (2 * Math.PI) + 0.5, Math.acos(Math.max(-1, Math.min(1, q[1] / len))) / Math.PI] as [number, number];
+ }
+ const k = { x: 0, y: 1, z: 2 }[uv.axis as 'x']!;
+ const [a, b] = [q[(k + 2) % 3]!, q[(k + 1) % 3]!];
+ return [Math.atan2(b, a) / (2 * Math.PI) + 0.5, q[k]! / uv.extent + 0.5] as [number, number];
+ });
+ const first = raw[0]![0];
+ face.v.forEach((i, n) => {
+ let u = raw[n]![0];
+ if (u - first > 0.5) u -= 1;
+ else if (first - u > 0.5) u += 1;
+ out.set(i, finish(uv, u * uv.repeat[0], raw[n]![1] * uv.repeat[1]));
+ });
+ return out;
+}
diff --git a/pipeline/src/modeling/polyMesh.ts b/pipeline/src/modeling/polyMesh.ts
index 9d1561317..e46335524 100644
--- a/pipeline/src/modeling/polyMesh.ts
+++ b/pipeline/src/modeling/polyMesh.ts
@@ -20,6 +20,23 @@ export interface Face {
color?: readonly [number, number, number, number];
/** Part of a continuous skin: shaded smooth with its neighbours whatever the angle, and its edges are not features. */
smooth?: boolean;
+ /** How this face takes its texture, from a `uv` step; absent, a box projection at the source's uvScale. */
+ uv?: FaceUv;
+}
+
+export interface FaceUv {
+ mode: 'box' | 'planar' | 'cylinder' | 'sphere';
+ /** planar: the way it faces. cylinder: the axis it wraps. */
+ axis?: string;
+ center: Vec3;
+ /** What the curved modes stretch over: a cylinder's length along its axis. */
+ extent: number;
+ /** box, planar: world units one repeat covers. */
+ scale: readonly [number, number];
+ /** cylinder, sphere: repeats around and along. */
+ repeat: readonly [number, number];
+ offset: readonly [number, number];
+ rotate: number;
}
export interface PolyMesh {
diff --git a/pipeline/src/modeling/triangulate.ts b/pipeline/src/modeling/triangulate.ts
new file mode 100644
index 000000000..8b5ce3b03
--- /dev/null
+++ b/pipeline/src/modeling/triangulate.ts
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/** @file triangulate.ts — a polygon as triangles, for the bake and for a boolean's input. */
+import { cross, dot, faceNormal, normalize, type Face, type PolyMesh, type Vec3 } from './polyMesh';
+
+/** Ear clipping in the face's own plane: n-gons here can be concave (a prism's floor plan). */
+export function triangulateFace(mesh: PolyMesh, face: Face): [number, number, number][] {
+ const count = face.v.length;
+ if (count < 3) return [];
+ if (count === 3) return [[face.v[0]!, face.v[1]!, face.v[2]!]];
+ if (face.smooth && count === 4) {
+ // A skin's quad bends, and may be a sliver. Split on the shorter diagonal, keeping both halves whatever their size: a dropped one is a crack.
+ const [a, b, c, d] = face.v as [number, number, number, number];
+ const gap = (i: number, j: number): number => {
+ const [p, q] = [mesh.positions[i]!, mesh.positions[j]!];
+ return Math.hypot(p[0] - q[0], p[1] - q[1], p[2] - q[2]);
+ };
+ return gap(a, c) <= gap(b, d) ? [[a, b, c], [a, c, d]] : [[a, b, d], [b, c, d]];
+ }
+ const n = faceNormal(mesh, face);
+ const ref = Math.abs(n[0]) < 0.9 ? [1, 0, 0] as Vec3 : [0, 1, 0] as Vec3;
+ const u = normalize(cross(ref, n));
+ const w = cross(n, u);
+ const flat = face.v.map((i) => {
+ const p = mesh.positions[i]!;
+ return [dot(p, u), dot(p, w)] as const;
+ });
+ const area2 = (a: number, b: number, c: number): number => {
+ const [ax, ay] = flat[a]!, [bx, by] = flat[b]!, [cx, cy] = flat[c]!;
+ return (bx - ax) * (cy - ay) - (cx - ax) * (by - ay);
+ };
+ const span = Math.max(...flat.map((q) => Math.hypot(q[0] - flat[0]![0], q[1] - flat[0]![1])), 1e-9);
+ const tiny = span * span * 1e-10;
+ const out: [number, number, number][] = [];
+ const loop = flat.map((_, i) => i);
+ let guard = count * count + 8;
+ while (loop.length > 3 && guard-- > 0) {
+ let clipped = false;
+ for (let i = 0; i < loop.length; i++) {
+ const a = loop[(i + loop.length - 1) % loop.length]!, b = loop[i]!, c = loop[(i + 1) % loop.length]!;
+ if (area2(a, b, c) <= tiny) continue; // reflex, or a vertex lying on a straight run (kept: a neighbour may rely on it)
+ let blocked = false;
+ for (const q of loop) {
+ if (q === a || q === b || q === c) continue;
+ if (area2(a, b, q) >= -tiny && area2(b, c, q) >= -tiny && area2(c, a, q) >= -tiny) { blocked = true; break; }
+ }
+ if (blocked) continue;
+ out.push([face.v[a]!, face.v[b]!, face.v[c]!]);
+ loop.splice(i, 1);
+ clipped = true;
+ break;
+ }
+ if (!clipped) break;
+ }
+ // What is left is a triangle, or a loop no ear could be cut from: a self-crossing face. Fanned, it still draws something to look at.
+ // All of it, even with no area: the edges are shared with the neighbours whether or not this has any.
+ for (let i = 1; i + 1 < loop.length; i++) out.push([face.v[loop[0]!]!, face.v[loop[i]!]!, face.v[loop[i + 1]!]!]);
+ return out;
+}
diff --git a/pipeline/tests/modeling-boolean-uv.test.ts b/pipeline/tests/modeling-boolean-uv.test.ts
new file mode 100644
index 000000000..c7bfa001f
--- /dev/null
+++ b/pipeline/tests/modeling-boolean-uv.test.ts
@@ -0,0 +1,219 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/** Real holes and how a texture lands: volumes for the first, the numbers on the corners for the second. */
+import { beforeAll, describe, expect, it } from 'vitest';
+import { MeshChannel } from 'esengine';
+import { bakeModel, needsPreparing, prepareModeling, renderModelSheet, validateModelSource, type BakedModel, type ModelStep } from '../src/modeling';
+
+beforeAll(() => prepareModeling());
+
+const model = (...steps: ModelStep[]): BakedModel => bakeModel({ version: 1, steps });
+
+function volume(m: BakedModel): number {
+ let v = 0;
+ for (const { v: [a, b, c] } of m.triangles) {
+ const [p, q, r] = [m.poly.positions[a]!, m.poly.positions[b]!, m.poly.positions[c]!];
+ v += p[0] * (q[1] * r[2] - q[2] * r[1]) + p[1] * (q[2] * r[0] - q[0] * r[2]) + p[2] * (q[0] * r[1] - q[1] * r[0]);
+ }
+ return v / 6;
+}
+
+function sound(m: BakedModel): void {
+ expect(m.report.openEdges).toBe(0);
+ expect(m.report.nonManifoldEdges).toBe(0);
+ expect(m.report.insideOutShells).toBe(0);
+ expect(m.report.warnings).toEqual([]);
+}
+
+const wall: ModelStep = { op: 'box', size: [4, 3, 0.5], tag: 'wall', color: [1, 1, 1] };
+const cutter: ModelStep = { op: 'box', size: [1, 1, 2], tag: 'cutter', color: [1, 0, 0] };
+
+describe('boolean', () => {
+ it('subtract goes all the way through: the volume drops by exactly the hole, and the cutter is gone', () => {
+ const m = model(wall, cutter, { op: 'boolean', operation: 'subtract', with: 'cutter', from: 'wall' });
+ sound(m);
+ expect(volume(m)).toBeCloseTo(6 - 0.5, 4);
+ expect(m.report.shells).toBe(1);
+ expect(m.report.bounds.size).toEqual([4, 3, 0.5]);
+ });
+
+ it('you can see through the hole, in the silhouette', () => {
+ const m = model(wall, cutter, { op: 'boolean', operation: 'subtract', with: 'cutter', from: 'wall' });
+ const s = renderModelSheet(m, ['front'], 128);
+ const px = (x: number, y: number): number => s.rgba[(y * s.width + x) * 4]!;
+ expect(px(64, 129 + 64)).toBeGreaterThan(200); // through the middle
+ expect(px(64 + 30, 129 + 64)).toBeLessThan(60); // wall beside it
+ });
+
+ it('`from` defaults to everything else', () => {
+ const m = model(wall, cutter, { op: 'boolean', operation: 'subtract', with: 'cutter' });
+ expect(volume(m)).toBeCloseTo(5.5, 4);
+ });
+
+ it('union of overlapping solids counts the overlap once, with no wall left inside', () => {
+ const m = model({ op: 'box', size: 2, tag: 'a' }, { op: 'box', size: 2, at: [1, 0, 0], tag: 'b' }, { op: 'boolean', operation: 'union', with: 'b', from: 'a' });
+ sound(m);
+ expect(m.report.shells).toBe(1);
+ expect(volume(m)).toBeCloseTo(12, 4);
+ });
+
+ it('intersect keeps what both hold', () => {
+ const m = model({ op: 'box', size: 2, tag: 'a' }, { op: 'box', size: 2, at: [1, 0, 0], tag: 'b' }, { op: 'boolean', operation: 'intersect', with: 'b', from: 'a' });
+ sound(m);
+ expect(volume(m)).toBeCloseTo(4, 4);
+ });
+
+ it('a cut face keeps what it had: the wall its tag and colour, and the walls of the hole the cutter\'s or those named', () => {
+ const plain = model(wall, cutter, { op: 'boolean', operation: 'subtract', with: 'cutter', from: 'wall' });
+ expect(plain.report.tags.cutter).toBeGreaterThan(0);
+ expect(plain.report.tags.wall).toBeGreaterThan(0);
+ const named = model(wall, cutter, { op: 'boolean', operation: 'subtract', with: 'cutter', from: 'wall', tag: 'reveal', color: [0, 1, 0] });
+ expect(named.report.tags.cutter).toBeUndefined();
+ const reveal = named.poly.faces.filter((f) => f.tag === 'reveal');
+ expect(reveal.length).toBeGreaterThan(0);
+ expect(reveal.every((f) => f.color![1] === 1 && f.color![0] === 0)).toBe(true);
+ expect(named.poly.faces.filter((f) => f.tag === 'wall').every((f) => f.color![0] === 1)).toBe(true);
+ });
+
+ it('leaves other shells alone, and keep leaves the cutter standing', () => {
+ const other: ModelStep = { op: 'box', size: 1, at: [9, 0, 0], tag: 'other' };
+ const m = model(wall, cutter, other, { op: 'boolean', operation: 'subtract', with: 'cutter', from: 'wall' });
+ expect(m.report.tags.other).toBe(6);
+ const kept = model(wall, cutter, { op: 'boolean', operation: 'subtract', with: 'cutter', from: 'wall', keep: true });
+ expect(volume(kept)).toBeCloseTo(5.5 + 2, 4);
+ });
+
+ it('later steps can work on the result', () => {
+ const m = model(wall, cutter, { op: 'boolean', operation: 'subtract', with: 'cutter', from: 'wall', tag: 'reveal' }, { op: 'paint', faces: 'reveal', color: [0, 0, 1] }, { op: 'extrude', faces: { tag: 'wall', facing: '+z' }, distance: 0.1 });
+ sound(m);
+ });
+
+ it('cuts through an organic skin too, and a concave prism', () => {
+ const blob = model({ op: 'organic', resolution: 48, tag: 'blob', parts: [{ shape: 'sphere', radius: 1 }] }, { op: 'box', size: [0.5, 3, 0.5], tag: 'cutter' }, { op: 'boolean', operation: 'subtract', with: 'cutter', from: 'blob' });
+ expect(blob.report.openEdges).toBe(0);
+ expect(volume(blob)).toBeLessThan((4 / 3) * Math.PI - 0.4);
+ const prism = model({ op: 'prism', points: [[0, 0], [2, 0], [2, 1], [1, 1], [1, 2], [0, 2]], height: 1, tag: 'l' }, { op: 'box', size: [0.4, 3, 0.4], at: [0.5, 0, 0.5], tag: 'cutter' }, { op: 'boolean', operation: 'subtract', with: 'cutter', from: 'l' });
+ sound(prism);
+ expect(volume(prism)).toBeCloseTo(3 - 0.16, 3);
+ });
+
+ it('refuses what it cannot cut, saying why', () => {
+ expect(() => model(wall, { op: 'boolean', operation: 'subtract', with: 'nope' })).toThrow(/`with` "nope" matched no face/);
+ expect(() => model(cutter, { op: 'boolean', operation: 'subtract', with: 'cutter' })).toThrow(/leaves no face/);
+ expect(() => model(wall, cutter, { op: 'delete', faces: { tag: 'cutter', facing: '+y' } }, { op: 'boolean', operation: 'subtract', with: 'cutter' })).toThrow(/`with` are not a closed solid.*open edge/);
+ expect(() => model(wall, { op: 'box', size: 1, at: [9, 9, 9], tag: 'cutter' }, { op: 'boolean', operation: 'intersect', with: 'cutter', from: 'wall' })).toThrow(/leaves nothing/);
+ expect(() => validateModelSource({ steps: [{ op: 'boolean', operation: 'carve', with: 'x' }] })).toThrow(/operation must be subtract, union or intersect/);
+ });
+
+ it('says which sources need loading first', () => {
+ expect(needsPreparing([{ op: 'box' }])).toBe(false);
+ expect(needsPreparing([{ op: 'box' }, { op: 'boolean' }])).toBe(true);
+ });
+});
+
+describe('uv', () => {
+ /** Every corner's position and base UV, from the baked vertices. */
+ function corners(m: BakedModel): { p: number[]; n: number[]; uv: number[] }[] {
+ const off = (s: number): number => m.data.channels.find((c) => c.semantic === s)!.offset;
+ const view = new DataView(m.data.vertices.buffer);
+ return Array.from({ length: m.data.vertexCount }, (_, i) => {
+ const at = i * m.data.vertexStride;
+ return {
+ p: [0, 1, 2].map((k) => view.getFloat32(at + off(MeshChannel.Position) + k * 4, true)),
+ n: [0, 1, 2].map((k) => view.getFloat32(at + off(MeshChannel.Normal) + k * 4, true)),
+ uv: [0, 1].map((k) => view.getFloat32(at + off(MeshChannel.TexCoord0) + k * 4, true)),
+ };
+ });
+ }
+ const spread = (values: number[]): number => Math.max(...values) - Math.min(...values);
+
+ it('by default tiles at uvScale world units a repeat, on every side alike', () => {
+ const m = bakeModel({ version: 1, uvScale: 0.5, steps: [{ op: 'box', size: [4, 2, 1] }] });
+ const front = corners(m).filter((c) => c.n[2]! > 0.9);
+ expect(spread(front.map((c) => c.uv[0]!))).toBeCloseTo(8, 4); // 4 units at 0.5 a repeat
+ expect(spread(front.map((c) => c.uv[1]!))).toBeCloseTo(4, 4);
+ });
+
+ it('up on a wall is up in the texture, on all four walls', () => {
+ const m = model({ op: 'box', size: 2 });
+ for (const c of corners(m).filter((x) => Math.abs(x.n[1]!) < 0.1)) expect(c.uv[1]).toBeCloseTo(c.p[1]!, 4);
+ });
+
+ it('reads left to right when you face it: a texture is not mirrored', () => {
+ const m = model({ op: 'box', size: 2 });
+ const facing = (axis: number, sign: number, right: number, rightSign: number): void => {
+ const face = corners(m).filter((c) => c.n[axis]! * sign > 0.9);
+ const a = face.find((c) => c.p[right]! * rightSign > 0)!, b = face.find((c) => c.p[right]! * rightSign < 0)!;
+ expect(a.uv[0]!).toBeGreaterThan(b.uv[0]!);
+ };
+ facing(2, 1, 0, 1); // front: +x is on the right
+ facing(2, -1, 0, -1); // back: -x is
+ facing(0, 1, 2, -1); // right side: -z is
+ facing(0, -1, 2, 1); // left side: +z is
+ });
+
+ it('planar aims faces, and takes scale, offset and rotate', () => {
+ const m = model({ op: 'box', size: 2 }, { op: 'uv', faces: '+z', mode: 'planar', axis: '+z', scale: 2, offset: [0.25, 0.5] });
+ const front = corners(m).filter((c) => c.n[2]! > 0.9);
+ expect(spread(front.map((c) => c.uv[0]!))).toBeCloseTo(1, 4);
+ expect(Math.min(...front.map((c) => c.uv[0]!))).toBeCloseTo(-0.25, 4);
+ const turned = model({ op: 'box', size: 2 }, { op: 'uv', faces: '+z', mode: 'planar', axis: '+z', rotate: 90 });
+ const f = corners(turned).filter((c) => c.n[2]! > 0.9);
+ for (const c of f) expect(c.uv[0]).toBeCloseTo(-c.p[1]!, 4);
+ });
+
+ it('cylinder wraps a pole once around, with no face painted backwards across the seam', () => {
+ const m = model({ op: 'cylinder', radius: 1, height: 4, sides: 16, tag: 'pole' }, { op: 'uv', faces: { tag: 'pole', not: { any: ['+y', '-y'] } }, mode: 'cylinder', axis: 'y', repeat: [2, 3] });
+ const side = corners(m).filter((c) => Math.abs(c.n[1]!) < 0.1);
+ expect(spread(side.map((c) => c.uv[1]!))).toBeCloseTo(3, 3);
+ expect(spread(side.map((c) => c.uv[0]!))).toBeGreaterThan(1.9);
+ // Each triangle spans a sixteenth of the way round, twice over for the repeat: a seam crossed wrongly would span nearly all of it.
+ const view = m.data.indices;
+ const all = corners(m);
+ for (let i = 0; i < view.length; i += 3) {
+ const tri = [all[view[i]!]!, all[view[i + 1]!]!, all[view[i + 2]!]!];
+ if (tri.some((c) => Math.abs(c.n[1]!) > 0.1)) continue;
+ expect(spread(tri.map((c) => c.uv[0]!))).toBeLessThan(0.3);
+ }
+ });
+
+ it('sphere maps pole to pole', () => {
+ const m = model({ op: 'sphere', radius: 1 }, { op: 'uv', mode: 'sphere' });
+ const v = corners(m).map((c) => c.uv[1]!);
+ expect(Math.min(...v)).toBeCloseTo(0, 3);
+ expect(Math.max(...v)).toBeCloseTo(1, 3);
+ });
+
+ it('uvAtlas: no two triangles share texels, and all of them are on the sheet', () => {
+ const m = bakeModel({ version: 1, uvAtlas: true, steps: [{ op: 'box', size: 2 }] });
+ const all = corners(m);
+ for (const c of all) {
+ expect(c.uv[0]).toBeGreaterThanOrEqual(0);
+ expect(c.uv[0]).toBeLessThanOrEqual(1);
+ }
+ // Six faces, six separate rectangles: the UV bounding boxes do not overlap.
+ const byFace = new Map<string, number[][]>();
+ for (const c of all) {
+ const key = c.n.map((x) => Math.round(x)).join();
+ byFace.set(key, [...(byFace.get(key) ?? []), c.uv]);
+ }
+ const boxes = [...byFace.values()].map((uvs) => ({
+ minU: Math.min(...uvs.map((u) => u[0]!)), maxU: Math.max(...uvs.map((u) => u[0]!)),
+ minV: Math.min(...uvs.map((u) => u[1]!)), maxV: Math.max(...uvs.map((u) => u[1]!)),
+ }));
+ expect(boxes.length).toBe(6);
+ for (let i = 0; i < 6; i++) {
+ for (let j = i + 1; j < 6; j++) {
+ const [a, b] = [boxes[i]!, boxes[j]!];
+ const apart = a.maxU <= b.minU || b.maxU <= a.minU || a.maxV <= b.minV || b.maxV <= a.minV;
+ expect(apart, `faces ${i} and ${j} overlap on the sheet`).toBe(true);
+ }
+ }
+ });
+
+ it('refuses an axis that is not one, and a mode that is not one', () => {
+ expect(() => model({ op: 'box', size: 1 }, { op: 'uv', mode: 'planar', axis: 'up' })).toThrow(/planar uv's axis "up"/);
+ expect(() => model({ op: 'box', size: 1 }, { op: 'uv', mode: 'cylinder', axis: '+y' })).toThrow(/cylinder uv's axis/);
+ expect(() => validateModelSource({ steps: [{ op: 'uv', mode: 'wrap' }] })).toThrow(/mode must be box, planar/);
+ });
+});
diff --git a/pipeline/tests/modeling.test.ts b/pipeline/tests/modeling.test.ts
index 2ca4a3c20..0b7f632bd 100644
--- a/pipeline/tests/modeling.test.ts
+++ b/pipeline/tests/modeling.test.ts
@@ -299,7 +299,7 @@ describe('the source format', () => {
});
it('refuses an unknown op, listing them', () => {
- expect(() => validateModelSource({ steps: [{ op: 'boolean' }] })).toThrow(/unknown op "boolean"; there are box/);
+ expect(() => validateModelSource({ steps: [{ op: 'lathe' }] })).toThrow(/unknown op "lathe"; there are box/);
});
it('refuses a missing required field and a wrong type', () => {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 02e867b62..a515b41b1 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -78,6 +78,9 @@ importers:
lucide-react:
specifier: ^1.21.0
version: 1.21.0([email protected])
+ manifold-3d:
+ specifier: 3.5.4
+ version: 3.5.4(@gltf-transform/[email protected])(@gltf-transform/[email protected])(@gltf-transform/[email protected](@types/[email protected]))([email protected])
meshoptimizer:
specifier: ^1.2.0
version: 1.2.0
@@ -189,6 +192,9 @@ importers:
js-yaml:
specifier: 4.3.0
version: 4.3.0
+ manifold-3d:
+ specifier: 3.5.4
+ version: 3.5.4(@gltf-transform/[email protected])(@gltf-transform/[email protected])(@gltf-transform/[email protected](@types/[email protected]))([email protected])
meshoptimizer:
specifier: ^1.2.0
version: 1.2.0
@@ -487,6 +493,9 @@ packages:
'@emnapi/[email protected]':
resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==}
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==}
+
'@emnapi/[email protected]':
resolution: {integrity: sha512-hFPAhMUjJD9BSyCANEISPOogeXC9Zo9ZQl7L6vKnaVsMkCtzznaW/naYypeyl0Gv5rYfWYsZbpixTMpjDJzQeA==}
@@ -805,12 +814,183 @@ packages:
'@fontsource/[email protected]':
resolution: {integrity: sha512-6w8/SG4kqvIMu7xd7wt6x3idn1Qux3p9N62s6G3rfldOUYHpWcc2FKrqf+Vo44jRvqWj2oAtTHrZXEP23oSKwQ==}
+ '@gltf-transform/[email protected]':
+ resolution: {integrity: sha512-OWgBYssKHKoXMIrMb2N20jXqWRnMP9HdtcTFQBEAJtz4P+OOxx5fozl5eAeK7nktIs5uDE/lu4NbkE5VCZaR9g==}
+
+ '@gltf-transform/[email protected]':
+ resolution: {integrity: sha512-3jTe+GWRy4fj1TU790LPsO+rpO/4byUWPTpNkjy6M6h8RvrUivRf12Mptc0770K4ZczibpJDNHXZFkFsFMRDLA==}
+
+ '@gltf-transform/[email protected]':
+ resolution: {integrity: sha512-rfm4nQY2DJ+ip1e15xp7YfQwhRno3kPLcGw4EZiRk1dVwMV3cdFMcF08glYcO/+oLyYkUEs3xXMJYXa0cPgcTg==}
+
resolution: {integrity: sha512-GwtvgtXxnWsucXvbQXkRgqksiH2Qed37H9xHZocE5sA3N8O8O8/8FA3uclQXxXVzc9XBZuEOMK7+r02FmSpHtw==}
engines: {node: '>=18.14.1'}
peerDependencies:
hono: ^4
+ resolution: {integrity: sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==}
+ engines: {node: '>=18'}
+
+ resolution: {integrity: sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==}
+ engines: {node: '>=20.9.0'}
+ cpu: [arm64]
+ os: [darwin]
+
+ resolution: {integrity: sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==}
+ engines: {node: '>=20.9.0'}
+ cpu: [x64]
+ os: [darwin]
+
+ resolution: {integrity: sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==}
+ engines: {node: '>=20.9.0'}
+ os: [freebsd]
+
+ resolution: {integrity: sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==}
+ cpu: [arm64]
+ os: [darwin]
+
+ resolution: {integrity: sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==}
+ cpu: [x64]
+ os: [darwin]
+
+ resolution: {integrity: sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==}
+ cpu: [arm64]
+ os: [linux]
+ libc: [glibc]
+
+ resolution: {integrity: sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==}
+ cpu: [arm]
+ os: [linux]
+ libc: [glibc]
+
+ resolution: {integrity: sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==}
+ cpu: [ppc64]
+ os: [linux]
+ libc: [glibc]
+
+ resolution: {integrity: sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==}
+ cpu: [riscv64]
+ os: [linux]
+ libc: [glibc]
+
+ resolution: {integrity: sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==}
+ cpu: [s390x]
+ os: [linux]
+ libc: [glibc]
+
+ resolution: {integrity: sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==}
+ cpu: [x64]
+ os: [linux]
+ libc: [glibc]
+
+ resolution: {integrity: sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==}
+ cpu: [arm64]
+ os: [linux]
+ libc: [musl]
+
+ resolution: {integrity: sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==}
+ cpu: [x64]
+ os: [linux]
+ libc: [musl]
+
+ resolution: {integrity: sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==}
+ engines: {node: '>=20.9.0'}
+ cpu: [arm64]
+ os: [linux]
+ libc: [glibc]
+
+ resolution: {integrity: sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==}
+ engines: {node: '>=20.9.0'}
+ cpu: [arm]
+ os: [linux]
+ libc: [glibc]
+
+ resolution: {integrity: sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==}
+ engines: {node: '>=20.9.0'}
+ cpu: [ppc64]
+ os: [linux]
+ libc: [glibc]
+
+ resolution: {integrity: sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==}
+ engines: {node: '>=20.9.0'}
+ cpu: [riscv64]
+ os: [linux]
+ libc: [glibc]
+
+ resolution: {integrity: sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==}
+ engines: {node: '>=20.9.0'}
+ cpu: [s390x]
+ os: [linux]
+ libc: [glibc]
+
+ resolution: {integrity: sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==}
+ engines: {node: '>=20.9.0'}
+ cpu: [x64]
+ os: [linux]
+ libc: [glibc]
+
+ resolution: {integrity: sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==}
+ engines: {node: '>=20.9.0'}
+ cpu: [arm64]
+ os: [linux]
+ libc: [musl]
+
+ resolution: {integrity: sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==}
+ engines: {node: '>=20.9.0'}
+ cpu: [x64]
+ os: [linux]
+ libc: [musl]
+
+ resolution: {integrity: sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==}
+ engines: {node: '>=20.9.0'}
+
+ resolution: {integrity: sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==}
+ engines: {node: '>=20.9.0'}
+ cpu: [wasm32]
+
+ resolution: {integrity: sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==}
+ engines: {node: '>=20.9.0'}
+ cpu: [arm64]
+ os: [win32]
+
+ resolution: {integrity: sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==}
+ engines: {node: ^20.9.0}
+ cpu: [ia32]
+ os: [win32]
+
+ resolution: {integrity: sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==}
+ engines: {node: '>=20.9.0'}
+ cpu: [x64]
+ os: [win32]
+
'@isaacs/[email protected]':
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
engines: {node: '>=12'}
@@ -839,6 +1019,9 @@ packages:
'@jridgewell/[email protected]':
resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
+ '@jscadui/[email protected]':
+ resolution: {integrity: sha512-y5vZktqCjyi7wA38zqNlLIdZUIRZoOO9vCjLzwmL4bR0hk7B/Zm1IeffzJPFe1vFc0C1IEv3hm8caDv3doRk9g==}
+
'@malept/[email protected]':
resolution: {integrity: sha512-1DpKU0Z5ThltBwjNySMC14g0CkbyhCaz9FkhxqNsZI6uAPJXFS8cMXlBKo26FJ8ZuW6S9GCMcR9IO5k2X5/9Fg==}
engines: {node: '>= 12.13.0'}
@@ -878,6 +1061,9 @@ packages:
resolution: {integrity: sha512-IYqDGiTXab6FniAgnSdZwgWbomxpy9FtYvLKs7wCUs2a8RkITG+DFGO1DM9cr+E3/RgADRpFjrKVaJ1z6sjtEg==}
engines: {node: '>= 20.19.0'}
+ '@nodable/[email protected]':
+ resolution: {integrity: sha512-LsS/DjHr+uDM647Gru/cA8+J3a3HfhttwCKLyuoyN7yXTFCxKBtSgMQBvrW9yNPa2/zDRUNuGPaH5QUFoa4arQ==}
+
'@oxc-project/[email protected]':
resolution: {integrity: sha512-KzkdCd6Uxqnf6l3HOw1xfatAlUURA0g14cvBYFyJ5SaNOQbOUvBr9PKArcPcrNIeRsBdgcUzOGrhKveVpvOIGA==}
@@ -1348,6 +1534,9 @@ packages:
resolution: {integrity: sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-go+C6vHBUuO9jH6Tj6qEZ63JEGoMSxFdmd+6QAtthGD6xumBfIz3RbNDDs2aoRVLf9naH8lk5jnWy2UHHKgYQQ==}
+
resolution: {integrity: sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==}
@@ -1548,6 +1737,9 @@ packages:
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
engines: {node: '>= 8'}
+ resolution: {integrity: sha512-N6//FLET/tXYNM/F6ABca1oH6fWB+KlTt909Le28WMDBk8oaT4vY17DCrwg2MvmuqUKt3Ni4N5dGJ/EoBgcO6A==}
+
resolution: {integrity: sha512-2VnyWkqsP5v5XbBhL3tD5Syx8iNPBYsoU7kY4S2fz7wg8Rj/nztWKCUzGKaFRTv0Xwf3/H058CR1Kvtd/3lRow==}
engines: {node: '>=14.0.0'}
@@ -1767,6 +1959,10 @@ packages:
resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==}
+ engines: {node: '>=18'}
+
resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
@@ -1814,6 +2010,9 @@ packages:
resolution: {integrity: sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
+
resolution: {integrity: sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==}
engines: {node: '>=6.6.0'}
@@ -1843,6 +2042,9 @@ packages:
resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
+ resolution: {integrity: sha512-WXlK/m+Di8DMMcCjcWr4i+XzcQra9eCdXIJrgh4TUgh0pIS/yJduLxS9JgefsHJ/YVLdgPtXm9r62W92MvanEQ==}
+
resolution: {integrity: sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA==}
engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}
@@ -2094,6 +2296,11 @@ packages:
resolution: {integrity: sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==}
+ resolution: {integrity: sha512-1k03e2/tGz+sLz3/xzoZmUsIqtaGIvJa8k4UqUeqCUry83nHmlxQYZUUES0WBFUYilSQUf7nDUGAciIIklljSg==}
+ engines: {node: '>=18'}
+ hasBin: true
+
resolution: {integrity: sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==}
engines: {node: '>=12'}
@@ -2188,6 +2395,13 @@ packages:
resolution: {integrity: sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==}
+ resolution: {integrity: sha512-pIM/1n3ntFXKYrUZwW7QCK0gAW7XY+wzj1YMIV3tLDvPj/V+zTGJK5e3/4WJfwj0qWw2ElNXiTixda/R+3YSug==}
+
+ resolution: {integrity: sha512-/pXxRBtwxY9w8z7YbgsvIPPcPvFDsTbIkWwTQJhzNJPokj+TbN6ftmcv4j/pEQDvOCNnKGDzuk5Bo2oogIOiFg==}
+ hasBin: true
+
resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==}
engines: {node: '>=12.0.0'}
@@ -2428,6 +2642,9 @@ packages:
resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==}
+ resolution: {integrity: sha512-pZ2xT+LOHckCatGQ3DcG/a+QuEqvoxqkiL7tvE8nn3uuu+f6i1TtpB5/FtWFbxUuVr5PZCx8KskuGatbJDXOWA==}
+
resolution: {integrity: sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA==}
engines: {node: '>= 12'}
@@ -2440,6 +2657,9 @@ packages:
resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==}
+
resolution: {integrity: sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==}
engines: {node: '>= 0.4'}
@@ -2494,6 +2714,9 @@ packages:
resolution: {integrity: sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-ZBllczCCO267vgdFb6Tq3pv+LhHaCiGMdr+ZsuL+OopruAg7S+3ZDs1vD0RPC0uSrkjzbraxaGjtX1YBxjPeFQ==}
+
resolution: {integrity: sha512-GI+WjezhPPcbM+tqE9LnmsY5qqjwHzTvjJ36wxYX5ujNXefSUJ/T17r5bqDV8yLhcgB59KTPNOc9O9cmHTPWsA==}
engines: {node: '>=10'}
@@ -2600,6 +2823,9 @@ packages:
resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==}
+ resolution: {integrity: sha512-mKp3y+FaYgR7mXWAbyyzpa/r1zDWeaunH+INJO4fou3hb45XuNSwar+7llrRyvpMWafxSIi99RNFJ05MHedaJQ==}
+
resolution: {integrity: sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==}
@@ -2750,6 +2976,15 @@ packages:
resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==}
engines: {node: '>=10'}
+ resolution: {integrity: sha512-WWsme5HabwLHVcWPHT9m+s7mdmDVSEvCny+uXH1E7jEc8FbFUgM75C3Dh6NVw57Eeh3Ow7+xHCuXfxDMOemi9A==}
+ hasBin: true
+ peerDependencies:
+ '@gltf-transform/core': ^4.2.0
+ '@gltf-transform/extensions': ^4.2.0
+ '@gltf-transform/functions': ^4.2.0
+ esbuild-wasm: ^0.27.3
+
resolution: {integrity: sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==}
engines: {node: '>=10'}
@@ -2881,6 +3116,18 @@ packages:
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
+ resolution: {integrity: sha512-5kBmmG3Zvyj77qxIAC4QFLKuYdDIBJwCG+DukT6jQHNa1Ft74/hPH1z5mbQXeHBt8yvGPBGVrr3wEOdJPYYZYg==}
+
+ resolution: {integrity: sha512-BppWAFRjMYF7N/r6Ie51q6D4fs0iiGmeXIACKY66fLpnwIui3Wc3CXiD/30mgLbDjPpSLrsqcp3Z62+IcHZsDw==}
+
+ resolution: {integrity: sha512-lTh4tFKziAatVTa9crIsidUyn+lqujVOQpzfdBWvdFu2wo9Uo6z261lVX7SgMyP89xGmj3TMTPbbxl9YDnV4SA==}
+
+ resolution: {integrity: sha512-AsE8w/M2MS+0pD3nP5qbRRtJFeJJJaJ+qXZaZr0XjVGXhy6LIj2TERTlkpdK2AI3WufoOP+pwPk3q2ilAJcZ9g==}
+
resolution: {integrity: sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==}
engines: {node: '>= 0.6'}
@@ -3017,6 +3264,10 @@ packages:
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-enSlaiat05iasnzmgNxRj8reFdj3puY2QpNgP1aPIaVfT6nn9ICuPoFlKHk8EN22HcwewshO+mN2DGbkCEOtqQ==}
+ engines: {node: '>=14.0.0'}
+
resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==}
engines: {node: '>=0.10.0'}
@@ -3158,6 +3409,9 @@ packages:
resolution: {integrity: sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==}
+ resolution: {integrity: sha512-AvPcP7XECNWy4LGmFQ77k7un4lSKM4eS29PTvW4ck95uYeLxXPWJM7hLuBqK91FaHqCcgJvIUCuNJjjxKE7VKQ==}
+
resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==}
engines: {node: '>= 0.10'}
@@ -3379,6 +3633,11 @@ packages:
engines: {node: '>=10'}
hasBin: true
+ resolution: {integrity: sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==}
+ engines: {node: '>=10'}
+ hasBin: true
+
resolution: {integrity: sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==}
engines: {node: '>= 18'}
@@ -3400,6 +3659,15 @@ packages:
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
+ resolution: {integrity: sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==}
+ engines: {node: '>=20.9.0'}
+ peerDependencies:
+ '@types/node': '*'
+ peerDependenciesMeta:
+ '@types/node':
+ optional: true
+
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
engines: {node: '>=8'}
@@ -3518,6 +3786,9 @@ packages:
resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-UM4nTLWzQiDBseVxUGxN0wJzIk0UU89Qi7pKXz9qISo+lhviJikTuikBsK/oFRlpvYHvSdz0TVoLyQ+sEpYwxA==}
+
resolution: {integrity: sha512-O+Q/SJ8s1X2aMLh4213fQ9X/bND9M3dhSsyTRe+O1OXPcewGLiYmAtKCrnP7FDvDBaXB2ZHPkCt3zi4cJXBlCQ==}
engines: {node: '>=18'}
@@ -3696,6 +3967,9 @@ packages:
resolution: {integrity: sha512-YQ3WlbqjYMmNpdvDH64jAgLjxuAR9+649calDWhbshYaeQGO2bR4nI94ORJmwI3J9YhoKQnpyGOK+0zlWS5N5Q==}
engines: {node: '>=22.19.0'}
+ resolution: {integrity: sha512-Gw+zz50YNKPDKXs+9d+aKAjVwpjNwqzvNpLigIruT4HA9lMZNdMqs9x07kKHB/L9WRzqp4+DlTU5s4wG2esdoA==}
+
resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==}
engines: {node: '>= 4.0.0'}
@@ -3932,6 +4206,10 @@ packages:
resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-ghig2TBE/H11aOVgmahA3MhimvkBr6JIYknH/Dhdk10nXwdbIqBJsbfMxpvFPG8bAw77gN29aQWvKpmVoPlvPQ==}
+ engines: {node: '>=16.0.0'}
+
resolution: {integrity: sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==}
engines: {node: '>=8.0'}
@@ -4217,6 +4495,11 @@ snapshots:
tslib: 2.8.1
optional: true
+ '@emnapi/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
'@emnapi/[email protected]':
dependencies:
tslib: 2.8.1
@@ -4387,10 +4670,136 @@ snapshots:
'@fontsource/[email protected]': {}
+ '@gltf-transform/[email protected]':
+ dependencies:
+ property-graph: 4.1.0
+
+ '@gltf-transform/[email protected]':
+ dependencies:
+ '@gltf-transform/core': 4.5.1
+ ktx-parse: 1.1.0
+
+ '@gltf-transform/[email protected](@types/[email protected])':
+ dependencies:
+ '@gltf-transform/core': 4.5.1
+ '@gltf-transform/extensions': 4.5.1
+ ktx-parse: 1.1.0
+ ndarray: 1.1.1
+ ndarray-lanczos: 0.3.0
+ ndarray-pixels: 5.2.0(@types/[email protected])
+ transitivePeerDependencies:
+ - '@types/node'
+
dependencies:
hono: 4.12.26
+ '@img/[email protected]': {}
+
+ optionalDependencies:
+ '@img/sharp-libvips-darwin-arm64': 1.3.4
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-darwin-x64': 1.3.4
+ optional: true
+
+ dependencies:
+ '@img/sharp-wasm32': 0.35.5
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-arm64': 1.3.4
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-arm': 1.3.4
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-ppc64': 1.3.4
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-riscv64': 1.3.4
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-s390x': 1.3.4
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linux-x64': 1.3.4
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linuxmusl-arm64': 1.3.4
+ optional: true
+
+ optionalDependencies:
+ '@img/sharp-libvips-linuxmusl-x64': 1.3.4
+ optional: true
+
+ dependencies:
+ '@emnapi/runtime': 1.11.3
+ optional: true
+
+ dependencies:
+ '@img/sharp-wasm32': 0.35.5
+ optional: true
+
+ optional: true
+
+ optional: true
+
+ optional: true
+
'@isaacs/[email protected]':
dependencies:
string-width: 5.1.2
@@ -4425,6 +4834,8 @@ snapshots:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.5.5
+ '@jscadui/[email protected]': {}
+
'@malept/[email protected]':
dependencies:
cross-spawn: 7.0.6
@@ -4478,6 +4889,8 @@ snapshots:
'@noble/[email protected]': {}
+ '@nodable/[email protected]': {}
+
'@oxc-project/[email protected]': {}
'@oxc-project/[email protected]': {}
@@ -4796,6 +5209,8 @@ snapshots:
'@types/[email protected]': {}
+ '@types/[email protected]': {}
+
'@types/[email protected]': {}
@@ -5039,6 +5454,8 @@ snapshots:
normalize-path: 3.0.0
picomatch: 2.3.1
+
dependencies:
'@electron/asar': 3.4.1
@@ -5315,6 +5732,8 @@ snapshots:
+
@@ -5347,6 +5766,8 @@ snapshots:
+
@@ -5374,6 +5795,10 @@ snapshots:
+ dependencies:
+ uniq: 1.0.1
+
dependencies:
whatwg-mimetype: 5.0.0
@@ -5667,6 +6092,8 @@ snapshots:
optional: true
+
optionalDependencies:
'@esbuild/aix-ppc64': 0.21.5
@@ -5813,6 +6240,20 @@ snapshots:
+ dependencies:
+ path-expression-matcher: 1.6.2
+ xml-naming: 0.3.0
+
+ dependencies:
+ '@nodable/entities': 3.1.0
+ fast-xml-builder: 1.3.1
+ is-unsafe: 2.0.3
+ path-expression-matcher: 1.6.2
+ strnum: 2.5.1
+ xml-naming: 0.3.0
+
optionalDependencies:
picomatch: 4.0.3
@@ -6121,6 +6562,8 @@ snapshots:
+
@@ -6129,6 +6572,8 @@ snapshots:
dependencies:
binary-extensions: 2.3.0
+
dependencies:
hasown: 2.0.2
@@ -6161,6 +6606,8 @@ snapshots:
+
@@ -6276,6 +6723,8 @@ snapshots:
dependencies:
json-buffer: 3.0.1
+
@@ -6404,6 +6853,21 @@ snapshots:
dependencies:
semver: 7.7.4
+ dependencies:
+ '@gltf-transform/core': 4.5.1
+ '@gltf-transform/extensions': 4.5.1
+ '@gltf-transform/functions': 4.5.1(@types/[email protected])
+ '@jridgewell/resolve-uri': 3.1.2
+ '@jridgewell/trace-mapping': 0.3.31
+ '@jscadui/3mf-export': 0.5.0
+ commander: 13.1.0
+ convert-source-map: 2.0.0
+ esbuild-wasm: 0.27.7
+ fast-xml-parser: 5.12.0
+ fflate: 0.8.2
+ magic-string: 0.30.21
+
dependencies:
escape-string-regexp: 4.0.0
@@ -6503,6 +6967,29 @@ snapshots:
+ dependencies:
+ '@types/ndarray': 1.1.0
+ ndarray: 1.1.1
+
+ dependencies:
+ cwise-compiler: 1.1.3
+
+ dependencies:
+ '@types/ndarray': 1.1.0
+ ndarray: 1.1.1
+ ndarray-ops: 1.2.2
+ sharp: 0.35.5(@types/[email protected])
+ transitivePeerDependencies:
+ - '@types/node'
+
+ dependencies:
+ iota-array: 1.0.0
+ is-buffer: 1.1.6
+
@@ -6624,6 +7111,8 @@ snapshots:
+
@@ -6773,6 +7262,8 @@ snapshots:
retry: 0.12.0
signal-exit: 3.0.7
+
dependencies:
forwarded: 0.2.0
@@ -7055,6 +7546,8 @@ snapshots:
+
dependencies:
debug: 4.4.3
@@ -7093,6 +7586,39 @@ snapshots:
+ dependencies:
+ '@img/colour': 1.1.0
+ detect-libc: 2.1.2
+ semver: 7.8.6
+ optionalDependencies:
+ '@img/sharp-darwin-arm64': 0.35.5
+ '@img/sharp-darwin-x64': 0.35.5
+ '@img/sharp-freebsd-wasm32': 0.35.5
+ '@img/sharp-libvips-darwin-arm64': 1.3.4
+ '@img/sharp-libvips-darwin-x64': 1.3.4
+ '@img/sharp-libvips-linux-arm': 1.3.4
+ '@img/sharp-libvips-linux-arm64': 1.3.4
+ '@img/sharp-libvips-linux-ppc64': 1.3.4
+ '@img/sharp-libvips-linux-riscv64': 1.3.4
+ '@img/sharp-libvips-linux-s390x': 1.3.4
+ '@img/sharp-libvips-linux-x64': 1.3.4
+ '@img/sharp-libvips-linuxmusl-arm64': 1.3.4
+ '@img/sharp-libvips-linuxmusl-x64': 1.3.4
+ '@img/sharp-linux-arm': 0.35.5
+ '@img/sharp-linux-arm64': 0.35.5
+ '@img/sharp-linux-ppc64': 0.35.5
+ '@img/sharp-linux-riscv64': 0.35.5
+ '@img/sharp-linux-s390x': 0.35.5
+ '@img/sharp-linux-x64': 0.35.5
+ '@img/sharp-linuxmusl-arm64': 0.35.5
+ '@img/sharp-linuxmusl-x64': 0.35.5
+ '@img/sharp-webcontainers-wasm32': 0.35.5
+ '@img/sharp-win32-arm64': 0.35.5
+ '@img/sharp-win32-ia32': 0.35.5
+ '@img/sharp-win32-x64': 0.35.5
+ '@types/node': 25.9.3
+
dependencies:
shebang-regex: 3.0.0
@@ -7216,6 +7742,10 @@ snapshots:
+ dependencies:
+ anynum: 1.0.1
+
dependencies:
commander: 12.1.0
@@ -7376,6 +7906,8 @@ snapshots:
+
@@ -7641,6 +8173,8 @@ snapshots:
+
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index ee844120b..59aa34e40 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -3866,6 +3866,10 @@ export const NOTED = {
{"note":"A sea seen from above is no longer scored with straight lines."},
"feat(mcp): an agent builds a 3D model in the editor from steps, changes it by one number, and sees every side of it":
{"note":"AI agents can build 3D models in the editor from steps."},
+ "feat(modeling): a boolean step cuts real holes and a uv step aims textures, with an atlas for a texture painted for one model":
+ {"note":"AI agents can build 3D models in the editor from steps."},
+ "feat(mcp): model_write cuts holes and lays out textures":
+ {"note":"AI agents can build 3D models in the editor from steps."},
"feat(modeling): an organic step makes one skin over parts that melt into each other, so an agent can build creatures, plants and rocks":
{"note":"AI agents can build 3D models in the editor from steps."},
"feat(mcp): model_views looks at one part up close and from more sides, and model_write explains how to build a body":