3D engine that AI agents drive
Add edge bevel as a mesh edit and stack node
Nguyen Xuan An552eff79430f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 95504bee..d90618dc 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,7 @@- Add `67js/addons/mesh`, a polygon mesh core for agent modeling: compact `MeshData` with attributes on point, edge, face and corner domains, a half-edge `EditMesh` with typed-array disk and radial cycles, `validateTopology`, conversion from renderer geometry with welding, quads and axis face tags, hard-edge corner normals, n-gon triangulation, render extraction and `lintMesh`- Add semantic face selection and mesh edits (extrude region and individual, inset region and individual, delete, flip normals, translate with proportional falloff, merge by distance, tag) that tag the faces they create- Add the recipe geometry type `mesh` (a base shape plus a replayable edit log) and the `mesh_edit` MCP tool, which appends or replaces edits atomically and reports each edit's result+- Add edge `bevel` as a mesh edit and stack node: rim, angle, region-border or all-edge selection, width, segments, profile and overlap clamping, with sliding corners and smooth triangular patches where three rounded edges meet- Add mesh booleans (union, difference, intersect) through Manifold WebAssembly as the `boolean` edit with an inline primitive cutter, tag transfer and polygon rebuilding; `manifold-3d` is an optional peer dependency, which the MCP runtime serves to its preview page when installed- Add mirror, array and solidify as mesh edits and as a non-destructive modifier stack evaluated after the edits, with every prefix cached, and the `mesh_stack` MCP tool to set the stack or apply its first nodes into the edit log- Report hollow cavities as valid in `lintMesh` instead of as inverted partsdiff --git a/docs/mesh.md b/docs/mesh.mdindex 1ce9692d..8a707f15 100644--- a/docs/mesh.md+++ b/docs/mesh.md@@ -174,7 +174,7 @@ a 32,768-face sphere minus a box about 0.6 s including conversion and lint.### Mirror, array and solidify-These three work as edits and as stack nodes:+These three (and `bevel`, below) work as edits and as stack nodes:| Op | Fields | Creates tags || --- | --- | --- |@@ -194,7 +194,7 @@ These three work as edits and as stack nodes:### Modifier stack-A recipe mesh may carry `stack`, a list of `mirror`, `array` and `solidify` nodes (up to 16) evaluated after the+A recipe mesh may carry `stack`, a list of `mirror`, `array`, `solidify` and `bevel` nodes (up to 16) evaluated after theedits without changing them, as Blender's modifier stack. Every prefix (the edit result, then each node) is cachedby its recipe text in a least-recently-used cache bounded at 64 entries and 64 MiB, so changing a late node reusesthe earlier work. Results list one entry per node with `cached: true` when reused. `meshCacheStats()` reports hits@@ -203,7 +203,28 @@ and misses. `evaluateMeshStack(mesh, stack, { cache, cacheKey })` runs a stack oThe `mesh_stack` tool sets the whole stack in one revision. `apply: n` moves the first `n` nodes into the edit log,as Blender's Apply modifier, which leaves the result unchanged.-Bevel and loop cut are planned next.+### Bevel++`bevel` rounds or chamfers edges, as an edit or as a stack node:++| Field | Meaning |+| --- | --- |+| `edges` | `{ "between": [faceRule, faceRule] }` (the rim between two regions, for example top and side), `{ "angle": 30 }` (edges bending at least this many degrees; the default), `{ "boundaryOf": faceRule }`, or `{ "all": true }` |+| `width` | Distance from the edge into each neighbouring face |+| `segments` | 1 to 16; 1 is a flat chamfer, 3 or more reads as round |+| `profile` | 0 flat, 0.5 round (default), 1 boxy |+| `clampOverlap` | Default true: shrink `width` so neighbouring bevels cannot cross; the result reports `clamped` and the `width` used |++Only edges with two consistently wound faces bevel. A face corner next to one beveled edge slides along its other+edge, shared with the face across that edge, so no T-junctions appear. Each beveled edge becomes a strip of+`segments` quads following a quadratic profile around the original edge (tag `<name>.strip`). Where beveled edges meet+at a vertex, the gap is filled (tag `<name>.corner`): a corner where three rounded edges meet gets a quadratic+triangular patch that matches the three profiles exactly; other corners get a flat polygon (chamfers) or a fan to a+raised centre. The quadratic profile is close to, not exactly, a circular arc, so rounded corners shade slightly+differently from Blender's. Edges between strip segments render smooth when the bend per segment is under the mesh's+`smoothAngle`; with 2 segments on a right angle (45 degrees each), raise `smoothAngle` or use 3 or more segments.++Loop cut is planned next.## MCPdiff --git a/scripts/mcp-server.mjs b/scripts/mcp-server.mjsindex d9769099..b32bb04e 100644--- a/scripts/mcp-server.mjs+++ b/scripts/mcp-server.mjs@@ -145,12 +145,20 @@ const stackNodes = [z.strictObject({ op: z.literal('mirror'), name: editName, axis: z.enum(['x', 'y', 'z']).optional().describe('Mirror across the plane through the local origin perpendicular to this axis. Defaults to x.'), merge: bounded(0, 1000).optional().describe('Vertices this close to the plane are shared by both halves. Defaults to 0.001. Faces lying in the plane are removed, so a closed half becomes a closed whole.') }),z.strictObject({ op: z.literal('array'), name: editName, count: z.number().int().min(1).max(256).optional(), offset: vector3.optional().describe('Constant step between copies.'), relativeOffset: vector3.optional().describe('Step in bounding-box sizes. Defaults to [1, 0, 0] unless offset is given.'), merge: bounded(0, 1000).optional().describe('Weld touching copies and remove the faces between them.') }),z.strictObject({ op: z.literal('solidify'), name: editName, thickness: finite.describe('Wall thickness, positive.'), offset: bounded(-1, 1).optional().describe('-1 grows inward (default), 1 outward, 0 centred.'), evenThickness: z.boolean().optional() }),+ z.strictObject({+ op: z.literal('bevel'), name: editName,+ edges: z.record(z.string(), z.unknown()).optional().describe('Edge rule: {"between":[faceRule,faceRule]} (for example top and side for a rim), {"angle":30} (edges bending at least this many degrees, the default), {"boundaryOf":faceRule}, or {"all":true}.'),+ width: finite.describe('Distance from the edge into each face, positive.'),+ segments: z.number().int().min(1).max(16).optional().describe('1 is a flat chamfer; 3 or more reads as round.'),+ profile: bounded(0, 1).optional().describe('0 flat, 0.5 round (default), 1 boxy.'),+ clampOverlap: z.boolean().optional().describe('Shrink width so neighbouring bevels cannot cross. Defaults to true; the result reports clamped.'),+ }),];const meshStack = z.array(z.discriminatedUnion('op', stackNodes)).max(16);const meshEdits = z.array(z.discriminatedUnion('op', [...meshEdit.options, ...stackNodes])).max(64);const geometry = z.discriminatedUnion('type', [...primitiveGeometries(true),- z.strictObject({ id: identifier, type: z.literal('mesh'), base: z.discriminatedUnion('type', primitiveGeometries(false)).describe('Starting shape, converted to welded quads with axis face tags.'), edits: meshEdits.optional().describe('Replayable edit log, applied in order.'), stack: meshStack.optional().describe('Non-destructive modifier stack (mirror, array, solidify) evaluated after the edits.'), smoothAngle: bounded(0, 180).optional().describe('Edges bending more than this many degrees render hard. Defaults to 30.') }),+ z.strictObject({ id: identifier, type: z.literal('mesh'), base: z.discriminatedUnion('type', primitiveGeometries(false)).describe('Starting shape, converted to welded quads with axis face tags.'), edits: meshEdits.optional().describe('Replayable edit log, applied in order.'), stack: meshStack.optional().describe('Non-destructive modifier stack (mirror, array, solidify, bevel) evaluated after the edits.'), smoothAngle: bounded(0, 180).optional().describe('Edges bending more than this many degrees render hard. Defaults to 30.') }),]);function motionTrack(kind, property, value, tangent) {return z.strictObject({@@ -278,8 +286,8 @@ export function createAgentMcpServer(runtime, { version = packageMetadata.versioregister('scene_create_asset', 'Create the active scene from a catalog GLB and editable asset recipe. Preserves supported maps, skins, morphs and clips. Dispose the existing scene first.', z.strictObject({ recipe: assetRecipe }), { ...edit, destructiveHint: false }, async argumentsValue => jsonResult(await runtime.createAsset(argumentsValue)));register('scene_inspect', 'Read revision, counts and selected nodes. Bounds describe authored geometry rather than shader displacement.', z.strictObject({ ...sessionFields, ids: z.array(identifier).max(4096).optional().describe('Selected node IDs. Omit to inspect scene order.'), kind: z.enum(['meshes', 'hierarchy']).optional().describe('Imported assets only: hierarchy exposes stable source-node IDs and joints.'), offset: z.number().int().min(0).max(4096).optional().describe('Imported assets only: pagination offset.'), limit: z.number().int().min(1).max(4096).optional().describe('Maximum returned node records. Defaults to 64.'), includeBounds: z.boolean().optional().describe('Include world geometry bounds. Defaults to false.') }), readOnly, async argumentsValue => jsonResult(await runtime.inspect(argumentsValue)));register('mesh_inspect', 'Check recipe geometries as polygon meshes: vertex, edge and face counts, triangles/quads/n-gons, connected and closed parts, face tags (top, bottom, side, left, right, front, back), bounds, and lint problems (non-manifold, inconsistent winding, inverted, degenerate, open, loose) with a suggested fix each. Procedural scenes only. Read-only and cached per geometry.', z.strictObject({ ...sessionFields, geometries: z.array(identifier).min(1).max(16).optional().describe('Geometry IDs to check. Omit to check the first 16 geometries.') }), readOnly, async argumentsValue => jsonResult(await runtime.inspectMeshes(argumentsValue)));- register('mesh_edit', 'Append edits to a recipe mesh geometry (or replace its edit log), atomically like scene_apply: extrude, inset, delete, flip, translate with proportional falloff, merge by distance, tag, and booleans (union, difference, intersect) with a primitive cutter. Edits that select no faces or break limits fail without changing the scene. Returns the new revision, render status and the mesh report with per-edit results (faces selected, tags created, size after).', z.strictObject({ ...sessionFields, expectedRevision, geometry: identifier.describe('ID of a geometry with type mesh.'), edits: meshEdits.min(1), replace: z.boolean().optional().describe('Replace the whole edit log instead of appending.') }), edit, async argumentsValue => jsonResult(await runtime.editMesh(argumentsValue)));- register('mesh_stack', 'Set the non-destructive modifier stack of a recipe mesh geometry (mirror, array, solidify), evaluated after its edits with each prefix cached, so changing a late node is cheap. apply: n moves the first n nodes into the edit log, as Blender\'s Apply modifier. Atomic like scene_apply. Returns the revision, render status and mesh report with per-node results.', z.strictObject({ ...sessionFields, expectedRevision, geometry: identifier.describe('ID of a geometry with type mesh.'), stack: meshStack.optional().describe('The whole new stack. Omit to keep the current stack (for example with apply).'), apply: z.number().int().min(0).max(16).optional() }), edit, async argumentsValue => jsonResult(await runtime.setMeshStack(argumentsValue)));+ register('mesh_edit', 'Append edits to a recipe mesh geometry (or replace its edit log), atomically like scene_apply: extrude, inset, delete, flip, translate with proportional falloff, merge by distance, tag, bevel, mirror, array, solidify, and booleans (union, difference, intersect) with a primitive cutter. Edits that select no faces or break limits fail without changing the scene. Returns the new revision, render status and the mesh report with per-edit results (faces selected, tags created, size after).', z.strictObject({ ...sessionFields, expectedRevision, geometry: identifier.describe('ID of a geometry with type mesh.'), edits: meshEdits.min(1), replace: z.boolean().optional().describe('Replace the whole edit log instead of appending.') }), edit, async argumentsValue => jsonResult(await runtime.editMesh(argumentsValue)));+ register('mesh_stack', 'Set the non-destructive modifier stack of a recipe mesh geometry (mirror, array, solidify, bevel), evaluated after its edits with each prefix cached, so changing a late node is cheap. apply: n moves the first n nodes into the edit log, as Blender\'s Apply modifier. Atomic like scene_apply. Returns the revision, render status and mesh report with per-node results.', z.strictObject({ ...sessionFields, expectedRevision, geometry: identifier.describe('ID of a geometry with type mesh.'), stack: meshStack.optional().describe('The whole new stack. Omit to keep the current stack (for example with apply).'), apply: z.number().int().min(0).max(16).optional() }), edit, async argumentsValue => jsonResult(await runtime.setMeshStack(argumentsValue)));register('scene_apply', 'Atomically edit transforms, look, camera or materials. Procedural scenes support membership and set-motion authoring. Imported assets support set-root, set-asset-node, set-motion and absolute set-animation sampling. Successful batches increment revision once.', z.strictObject({ ...sessionFields, expectedRevision, operations: z.array(operation).min(1).max(256).describe('Node/material/camera/root/animation commands use flat fields. Motion, look patches and add commands contain nested records. Backend validates each scene mode before publication.') }), edit, async argumentsValue => jsonResult(await runtime.apply(argumentsValue)));register('scene_look', 'Render the active scene as a bounded PNG. Optional authored motionTime seeks without changing revision; null restores the authored base pose. Omit to retain the last preview pose.', z.strictObject({ ...sessionFields, motionTime: z.number().min(0).max(3600).nullable().optional(), width: z.number().int().min(64).max(1024).default(768).describe('PNG width in pixels.'), height: z.number().int().min(64).max(1024).default(512).describe('PNG height in pixels.') }), readOnly, async argumentsValue => {const { data, mimeType, metadata } = await runtime.look(argumentsValue);diff --git a/src/mesh-bevel.js b/src/mesh-bevel.jsnew file mode 100644index 00000000..434a55de--- /dev/null+++ b/src/mesh-bevel.js@@ -0,0 +1,411 @@+import { editMesh } from './mesh-edit.js';+import { faceNormals } from './mesh-normals.js';+import { selectFaces } from './mesh-select.js';+import { MeshBuilder } from './mesh-stack.js';++// Edge bevel on manifold meshes, a compact take on Blender's bmesh_bevel for the common cases agents need:+// rounding the rim between two tagged regions, or every edge sharper than an angle.+//+// For each face corner touching a beveled edge, the corner moves into its face: away from both edges when both are+// beveled (as an inset corner), or along the other, unbeveled edge when only one is (a slide point shared with the+// face on the other side of that edge, so no T-junctions appear). Each beveled edge becomes a strip of `segments`+// quads following a quadratic profile around the original edge. Where beveled edges meet at a vertex, the gap left+// between the strips is filled with one polygon found by walking around the vertex.++/**+ * Edge selection rules:+ * { "between": [faceRule, faceRule] } edges shared by a face matching the first rule and one matching the second+ * { "angle": 30 } edges whose two faces bend by at least this many degrees+ * { "boundaryOf": faceRule } edges between a matching face and a non-matching one+ * { "all": true } every edge with two faces+ * Returns a Uint8Array over MeshData edges.+ */+export function selectEdges(mesh, rule, table) {+ if (!rule || typeof rule !== 'object' || Array.isArray(rule)) throw new TypeError('Edge rule must be an object.');+ const keys = Object.keys(rule);+ const mask = new Uint8Array(mesh.edgeCount);+ const facesOf = edge => table.faces[edge];+ if (keys.length !== 1) throw new TypeError('Edge rule takes exactly one of between, angle, boundaryOf, all.');+ if (rule.all === true) {+ for (let edge = 0; edge < mesh.edgeCount; edge++) mask[edge] = facesOf(edge).length === 2 ? 1 : 0;+ return mask;+ }+ if (rule.angle !== undefined) {+ if (!Number.isFinite(rule.angle) || rule.angle < 0 || rule.angle > 180) throw new RangeError('Edge rule angle is degrees from 0 to 180.');+ const { normals } = faceNormals(mesh);+ const limit = Math.cos(rule.angle * Math.PI / 180) + 1e-9;+ for (let edge = 0; edge < mesh.edgeCount; edge++) {+ const faces = facesOf(edge);+ if (faces.length !== 2) continue;+ const [first, second] = faces;+ const cosine = normals[first * 3] * normals[second * 3] + normals[first * 3 + 1] * normals[second * 3 + 1] + normals[first * 3 + 2] * normals[second * 3 + 2];+ if (cosine <= limit) mask[edge] = 1;+ }+ return mask;+ }+ if (rule.between !== undefined) {+ if (!Array.isArray(rule.between) || rule.between.length !== 2) throw new TypeError('between needs two face rules.');+ const first = selectFaces(mesh, rule.between[0]);+ const second = selectFaces(mesh, rule.between[1]);+ for (let edge = 0; edge < mesh.edgeCount; edge++) {+ const faces = facesOf(edge);+ if (faces.length !== 2) continue;+ const [left, right] = faces;+ if ((first[left] && second[right]) || (first[right] && second[left])) mask[edge] = 1;+ }+ return mask;+ }+ if (rule.boundaryOf !== undefined) {+ const selected = selectFaces(mesh, rule.boundaryOf);+ for (let edge = 0; edge < mesh.edgeCount; edge++) {+ const faces = facesOf(edge);+ if (faces.length === 2 && selected[faces[0]] !== selected[faces[1]]) mask[edge] = 1;+ }+ return mask;+ }+ throw new TypeError('Edge rule takes exactly one of between, angle, boundaryOf, all.');+}++/** Faces of every MeshData edge. */+export function edgeFaces(mesh) {+ const faces = Array.from({ length: mesh.edgeCount }, () => []);+ for (let face = 0; face < mesh.faceCount; face++) {+ for (let corner = mesh.faceOffsets[face]; corner < mesh.faceOffsets[face + 1]; corner++) faces[mesh.cornerEdges[corner]].push(face);+ }+ return { faces };+}++// Clamped slides stop at 49% of an edge: at exactly half, neighbouring faces collapse to zero area.+const CLAMP_FRACTION = 0.49;++const subtract = (first, second) => [first[0] - second[0], first[1] - second[1], first[2] - second[2]];+const add = (first, second) => [first[0] + second[0], first[1] + second[1], first[2] + second[2]];+const scale = (vector, factor) => [vector[0] * factor, vector[1] * factor, vector[2] * factor];+const dot = (first, second) => first[0] * second[0] + first[1] * second[1] + first[2] * second[2];+const cross = (first, second) => [first[1] * second[2] - first[2] * second[1], first[2] * second[0] - first[0] * second[2], first[0] * second[1] - first[1] * second[0]];+const length = vector => Math.hypot(vector[0], vector[1], vector[2]);+const normalize = vector => {+ const size = length(vector);+ return size === 0 ? [0, 0, 0] : scale(vector, 1 / size);+};++/**+ * Bevel the selected edges. Options: width (distance from the edge into each face), segments (1 is a flat chamfer),+ * profile (0 flat, 0.5 round, 1 boxy), clampOverlap (shrink width so slides stay within half of their edge).+ * Returns { mesh, width, clamped, bevelEdges, stripFaces, cornerFaces, filledCorners }. Strip faces get `<name>.strip`,+ * corner fills `<name>.corner`; the faces around keep their tags.+ */+export function bevelEdges(mesh, edgeRule, { width, segments = 1, profile = 0.5, clampOverlap = true, name = 'bevel' }) {+ const table = edgeFaces(mesh);+ const beveled = selectEdges(mesh, edgeRule, table);+ let bevelCount = 0;+ for (let edge = 0; edge < mesh.edgeCount; edge++) bevelCount += beveled[edge];+ if (!bevelCount) throw new RangeError('The edge rule selects no edges with two faces. Check tags with mesh_inspect, or lower angle.');+ const edit = editMesh(mesh);+ const loops = edit.loops.arrays;+ const positionOf = vertex => edit.vertexPosition(vertex);+ for (let edge = 0; edge < mesh.edgeCount; edge++) {+ if (!beveled[edge]) continue;+ const edgeLoops = edit.edgeLoops(edge);+ if (edgeLoops.length !== 2 || loops.vertex[edgeLoops[0]] === loops.vertex[edgeLoops[1]]) {+ throw new RangeError(`Edge ${edge} needs exactly two consistently wound faces to bevel. Run mesh_inspect and fix non-manifold or flipped faces first.`);+ }+ }+ const { normals: faceNormal } = faceNormals(mesh);+ const normalOf = face => [faceNormal[face * 3], faceNormal[face * 3 + 1], faceNormal[face * 3 + 2]];+ const otherEnd = (edge, vertex) => edit.edgeOtherVertex(edge, vertex);++ // Pass 1: slide distances per (vertex, unbeveled edge), the largest any neighbouring face needs, and the clamp.+ const slideNeeds = new Map();+ let effectiveWidth = width;+ const corners = [];+ for (let face = 0; face < mesh.faceCount; face++) {+ for (const loop of edit.faceLoops(face)) {+ const vertex = loops.vertex[loop];+ const incoming = loops.edge[loops.prev[loop]];+ const outgoing = loops.edge[loop];+ const inBeveled = beveled[incoming] === 1;+ const outBeveled = beveled[outgoing] === 1;+ corners.push({ face, loop, vertex, incoming, outgoing, inBeveled, outBeveled });+ if (inBeveled === outBeveled) continue;+ const bevelEdge = inBeveled ? incoming : outgoing;+ const slideEdge = inBeveled ? outgoing : incoming;+ const origin = positionOf(vertex);+ const along = subtract(positionOf(otherEnd(slideEdge, vertex)), origin);+ const across = normalize(subtract(positionOf(otherEnd(bevelEdge, vertex)), origin));+ const sine = length(cross(normalize(along), across));+ if (sine < 1e-6) throw new RangeError(`Face ${face} has a beveled edge parallel to its neighbour at vertex ${vertex}; bevel cannot slide there.`);+ const key = `${vertex}|${slideEdge}`;+ const need = slideNeeds.get(key) ?? { vertex, slideEdge, sine: Infinity, edgeLength: length(along) };+ need.sine = Math.min(need.sine, sine);+ slideNeeds.set(key, need);+ if (clampOverlap) effectiveWidth = Math.min(effectiveWidth, CLAMP_FRACTION * need.edgeLength * sine);+ }+ }+ if (clampOverlap) {+ // Inset corners: keep both offsets within half of the shorter beveled edge at that corner.+ for (const corner of corners) {+ if (!corner.inBeveled || !corner.outBeveled) continue;+ const origin = positionOf(corner.vertex);+ const first = length(subtract(positionOf(otherEnd(corner.incoming, corner.vertex)), origin));+ const second = length(subtract(positionOf(otherEnd(corner.outgoing, corner.vertex)), origin));+ effectiveWidth = Math.min(effectiveWidth, CLAMP_FRACTION * Math.min(first, second));+ }+ }+ const clamped = effectiveWidth < width;++ // Pass 2: points. Original vertices are added lazily so vertices cut away by the bevel disappear.+ const builder = new MeshBuilder(mesh);+ const originalPoint = new Map();+ const pointPositions = new Map();+ const vertexPoint = vertex => {+ if (!originalPoint.has(vertex)) {+ const position = positionOf(vertex);+ const point = builder.addVertex(...position);+ pointPositions.set(point, position);+ originalPoint.set(vertex, point);+ }+ return originalPoint.get(vertex);+ };+ const addPoint = position => {+ const point = builder.addVertex(...position);+ pointPositions.set(point, position);+ return point;+ };+ const slidePoint = new Map();+ for (const [key, need] of slideNeeds) {+ const origin = positionOf(need.vertex);+ const direction = normalize(subtract(positionOf(otherEnd(need.slideEdge, need.vertex)), origin));+ slidePoint.set(key, addPoint(add(origin, scale(direction, effectiveWidth / need.sine))));+ }+ const pointOnEdge = (vertex, edge) => slidePoint.get(`${vertex}|${edge}`) ?? vertexPoint(vertex);+ const sequenceOfLoop = new Map();+ for (const corner of corners) {+ let sequence;+ if (corner.inBeveled && corner.outBeveled) {+ const origin = positionOf(corner.vertex);+ const normal = normalOf(corner.face);+ const previous = positionOf(otherEnd(corner.incoming, corner.vertex));+ const next = positionOf(otherEnd(corner.outgoing, corner.vertex));+ const inwardIn = normalize(cross(normal, subtract(origin, previous)));+ const inwardOut = normalize(cross(normal, subtract(next, origin)));+ const bisector = normalize(add(inwardIn, inwardOut));+ const cosine = Math.max(0.05, dot(bisector, inwardIn));+ sequence = [addPoint(add(origin, scale(bisector, effectiveWidth / cosine)))];+ } else if (corner.inBeveled) {+ sequence = [slidePoint.get(`${corner.vertex}|${corner.outgoing}`)];+ } else if (corner.outBeveled) {+ sequence = [slidePoint.get(`${corner.vertex}|${corner.incoming}`)];+ } else {+ const start = pointOnEdge(corner.vertex, corner.incoming);+ const end = pointOnEdge(corner.vertex, corner.outgoing);+ sequence = start === end ? [start] : [start, end];+ }+ sequenceOfLoop.set(corner.loop, sequence);+ }+ const positionOfPoint = point => pointPositions.get(point);++ // Profile curves between two corner points around an original vertex, shared by the strip and the corner fill.+ const curves = new Map();+ const curve = (vertex, from, to) => {+ const key = `${vertex}|${Math.min(from, to)}|${Math.max(from, to)}`;+ let points = curves.get(key);+ if (!points) {+ const low = Math.min(from, to);+ const high = Math.max(from, to);+ const start = positionOfPoint(low);+ const end = positionOfPoint(high);+ const middle = scale(add(start, end), 0.5);+ const control = add(middle, scale(subtract(positionOf(vertex), middle), 2 * profile));+ points = [low];+ for (let step = 1; step < segments; step++) {+ const t = step / segments;+ const position = add(add(scale(start, (1 - t) ** 2), scale(control, 2 * t * (1 - t))), scale(end, t * t));+ points.push(addPoint(position));+ }+ points.push(high);+ curves.set(key, points);+ }+ return from === points[0] ? points : [...points].reverse();+ };++ const curveControl = (vertex, from, to) => {+ const middle = scale(add(positionOfPoint(from), positionOfPoint(to)), 0.5);+ return add(middle, scale(subtract(positionOf(vertex), middle), 2 * profile));+ };++ /**+ * Fill a corner where three profile curves meet with a quadratic triangular Bezier patch. Each curve is a+ * quadratic Bezier, so a patch built from the three corner points and the three curve controls reproduces the+ * curves exactly on its border and stays smooth inside. Returns the number of triangles added.+ */+ function fillTriangularCorner(vertex, bridges, reversed) {+ const [first, second, third] = bridges;+ const cornerA = first[0];+ const cornerB = second[0];+ const cornerC = third[0];+ const [positionA, positionB, positionC] = [cornerA, cornerB, cornerC].map(positionOfPoint);+ const controlAB = curveControl(vertex, cornerA, cornerB);+ const controlBC = curveControl(vertex, cornerB, cornerC);+ const controlCA = curveControl(vertex, cornerC, cornerA);+ const grid = new Map();+ const pointAt = (a, b) => {+ const c = segments - a - b;+ const key = `${a},${b}`;+ if (grid.has(key)) return grid.get(key);+ let point;+ if (c === 0) point = first[b];+ else if (a === 0) point = second[c];+ else if (b === 0) point = third[a];+ else {+ const u = a / segments;+ const v = b / segments;+ const w = c / segments;+ let position = scale(positionA, u * u);+ position = add(position, scale(positionB, v * v));+ position = add(position, scale(positionC, w * w));+ position = add(position, scale(controlAB, 2 * u * v));+ position = add(position, scale(controlBC, 2 * v * w));+ position = add(position, scale(controlCA, 2 * w * u));+ point = addPoint(position);+ }+ grid.set(key, point);+ return point;+ };+ let triangles = 0;+ const emit = vertices => {+ builder.addFace(reversed ? [...vertices].reverse() : vertices, { keepTags: false, tags: [`${name}.corner`] });+ triangles++;+ };+ for (let a = 0; a < segments; a++) {+ for (let b = 0; a + b < segments; b++) {+ emit([pointAt(a, b), pointAt(a + 1, b), pointAt(a, b + 1)]);+ if (a + b < segments - 1) emit([pointAt(a + 1, b), pointAt(a + 1, b + 1), pointAt(a, b + 1)]);+ }+ }+ return triangles;+ }++ // Faces: every original face with its corners replaced by their sequences.+ for (let face = 0; face < mesh.faceCount; face++) {+ const vertices = [];+ const sourceCorners = [];+ edit.faceLoops(face).forEach((loop, index) => {+ for (const point of sequenceOfLoop.get(loop)) {+ if (vertices.length && vertices.at(-1) === point) continue;+ vertices.push(point);+ sourceCorners.push(mesh.faceOffsets[face] + index);+ }+ });+ while (vertices.length > 1 && vertices[0] === vertices.at(-1)) {+ vertices.pop();+ sourceCorners.pop();+ }+ if (vertices.length >= 3) builder.addFace(vertices, { sourceFace: face, sourceCorners });+ }+ // Strips along each beveled edge.+ let stripFaces = 0;+ for (let edge = 0; edge < mesh.edgeCount; edge++) {+ if (!beveled[edge]) continue;+ const [first, second] = edit.edgeLoops(edge);+ const start = loops.vertex[first];+ const end = loops.vertex[loops.next[first]];+ // In the first face the edge runs start -> end; its corner points there are the sequence ends next to the edge.+ const firstAtStart = sequenceOfLoop.get(first).at(-1);+ const firstAtEnd = sequenceOfLoop.get(loops.next[first])[0];+ const secondAtEnd = sequenceOfLoop.get(second).at(-1);+ const secondAtStart = sequenceOfLoop.get(loops.next[second])[0];+ const startCurve = curve(start, firstAtStart, secondAtStart);+ const endCurve = curve(end, firstAtEnd, secondAtEnd);+ for (let step = 0; step < segments; step++) {+ // Where both ends of a strip step share a point (a curve that collapses), the quad becomes a triangle.+ const quad = [endCurve[step], startCurve[step], startCurve[step + 1], endCurve[step + 1]]+ .filter((point, index, list) => point !== list[(index + list.length - 1) % list.length]);+ if (quad.length < 3 || new Set(quad).size !== quad.length) continue;+ builder.addFace(quad, { keepTags: false, tags: [`${name}.strip`] });+ stripFaces++;+ }+ }+ // Corner fills: walk around each vertex touching a beveled edge. Each fill must run against the faces it borders,+ // so its winding is read from the directed edges already built.+ const directedEdges = new Set();+ for (let face = 0; face + 1 < builder.faceOffsets.length; face++) {+ const start = builder.faceOffsets[face];+ const end = builder.faceOffsets[face + 1];+ for (let corner = start; corner < end; corner++) {+ directedEdges.add(`${builder.cornerVertices[corner]},${builder.cornerVertices[corner + 1 === end ? start : corner + 1]}`);+ }+ }+ let cornerFaces = 0;+ let filledCorners = 0;+ const touched = new Set();+ for (let edge = 0; edge < mesh.edgeCount; edge++) {+ if (!beveled[edge]) continue;+ for (const vertex of edit.edgeVertices(edge)) touched.add(vertex);+ }+ for (const vertex of touched) {+ const firstSlot = edit.vertices.arrays.edgeSlot[vertex];+ const anyEdge = firstSlot >> 1;+ const startLoop = edit.edgeLoops(anyEdge).map(loop => loops.vertex[loop] === vertex ? loop : loops.next[loop])[0];+ const ring = [];+ const bridges = [];+ let singlePointFaces = true;+ let loop = startLoop;+ let guard = 0;+ let open = false;+ do {+ const sequence = sequenceOfLoop.get(loop);+ if (sequence.length !== 1) singlePointFaces = false;+ for (const point of sequence) ring.push(point);+ const outgoing = loops.edge[loop];+ const across = loops.radialNext[loop];+ if (across === loop) {+ // An open edge at this vertex: the faces do not close around it, so there is no single hole to fill.+ open = true;+ break;+ }+ const nextLoop = loops.next[across];+ if (beveled[outgoing]) {+ const bridge = curve(vertex, sequence.at(-1), sequenceOfLoop.get(nextLoop)[0]);+ bridges.push(bridge);+ for (const point of bridge.slice(1, -1)) ring.push(point);+ }+ loop = nextLoop;+ guard++;+ } while (loop !== startLoop && guard < 1024);+ if (open) continue;+ const polygon = ring.filter((point, index) => point !== ring[(index + ring.length - 1) % ring.length]);+ if (polygon.length < 3 || new Set(polygon).size !== polygon.length) continue;+ let sameDirection = 0;+ let oppositeDirection = 0;+ for (let index = 0; index < polygon.length; index++) {+ const from = polygon[index];+ const to = polygon[(index + 1) % polygon.length];+ if (directedEdges.has(`${from},${to}`)) sameDirection++;+ if (directedEdges.has(`${to},${from}`)) oppositeDirection++;+ }+ if (sameDirection > oppositeDirection) polygon.reverse();+ filledCorners++;+ if (segments > 1 && singlePointFaces && bridges.length === 3 && polygon.length === 3 * segments) {+ cornerFaces += fillTriangularCorner(vertex, bridges, sameDirection > oppositeDirection);+ continue;+ }+ if (segments === 1) {+ // A chamfer corner is flat: one polygon.+ builder.addFace(polygon, { keepTags: false, tags: [`${name}.corner`] });+ cornerFaces++;+ continue;+ }+ // A rounded corner is curved: fan triangles to a centre raised toward the original vertex by the same amount as+ // the apex of each profile curve, so the fill continues the strips instead of cutting a flat facet.+ let centroid = [0, 0, 0];+ for (const point of polygon) centroid = add(centroid, positionOfPoint(point));+ centroid = scale(centroid, 1 / polygon.length);+ const centre = addPoint(add(centroid, scale(subtract(positionOf(vertex), centroid), profile)));+ for (let index = 0; index < polygon.length; index++) {+ builder.addFace([polygon[index], polygon[(index + 1) % polygon.length], centre], { keepTags: false, tags: [`${name}.corner`] });+ cornerFaces++;+ }+ }+ return { mesh: builder.build(), width: effectiveWidth, clamped, bevelEdges: bevelCount, stripFaces, cornerFaces, filledCorners };+}diff --git a/src/mesh-recipe.js b/src/mesh-recipe.jsindex d0ddaebe..fb645eb4 100644--- a/src/mesh-recipe.js+++ b/src/mesh-recipe.js@@ -7,6 +7,7 @@ import {import { meshBoolean, BOOLEAN_OPERATIONS } from './mesh-boolean.js';import { createMeshData } from './mesh-data.js';import { mirrorMesh, arrayMesh, solidifyMesh } from './mesh-stack.js';+import { bevelEdges } from './mesh-bevel.js';// Replayable edit log for agent recipes. Each edit is plain JSON; names follow Blender's bmesh.ops where they match.@@ -28,6 +29,7 @@ export const MESH_EDIT_OPERATIONS = Object.freeze({mirror: { fields: ['name', 'axis', 'merge'], tags: ['mirrored'] },array: { fields: ['name', 'count', 'offset', 'relativeOffset', 'merge'], tags: ['last'] },solidify: { fields: ['name', 'thickness', 'offset', 'evenThickness'], tags: ['inner', 'rim'] },+ bevel: { fields: ['name', 'edges', 'width', 'segments', 'profile', 'clampOverlap'], tags: ['strip', 'corner'] },});function editError(index, message) {@@ -134,6 +136,18 @@ export function normalizeMeshEdits(edits) {if (edit.evenThickness !== undefined && typeof edit.evenThickness !== 'boolean') throw editError(index, 'evenThickness must be boolean');normalized.evenThickness = edit.evenThickness ?? true;break;+ case 'bevel':+ if (edit.edges !== undefined && (!edit.edges || typeof edit.edges !== 'object' || Array.isArray(edit.edges))) {+ throw editError(index, 'edges must be a rule: { "between": [faceRule, faceRule] }, { "angle": degrees }, { "boundaryOf": faceRule } or { "all": true }');+ }+ normalized.edges = edit.edges ?? { angle: 30 };+ normalized.width = finiteNumber(edit.width, index, 'width', { minimum: 0, exclusiveMinimum: true });+ if (!Number.isInteger(edit.segments ?? 1) || (edit.segments ?? 1) < 1 || (edit.segments ?? 1) > 16) throw editError(index, 'segments must be an integer from 1 to 16');+ normalized.segments = edit.segments ?? 1;+ normalized.profile = edit.profile === undefined ? 0.5 : finiteNumber(edit.profile, index, 'profile', { minimum: 0, maximum: 1 });+ if (edit.clampOverlap !== undefined && typeof edit.clampOverlap !== 'boolean') throw editError(index, 'clampOverlap must be boolean');+ normalized.clampOverlap = edit.clampOverlap ?? true;+ break;case 'merge_by_distance':normalized.distance = finiteNumber(edit.distance ?? 1e-4, index, 'distance', { minimum: 0, maximum: 1e3 });break;@@ -199,6 +213,19 @@ function runEdit(current, edit, index, { resolveCutter }) {result.removedFaces = merged.removedFaces;return { mesh: merged.mesh, result };}+ if (edit.op === 'bevel') {+ let outcome;+ try {+ outcome = bevelEdges(current, edit.edges, edit);+ } catch (error) {+ throw new error.constructor(`Mesh edit ${index} (bevel): ${error.message}`);+ }+ result.edges = outcome.bevelEdges;+ result.width = outcome.width;+ if (outcome.clamped) result.clamped = true;+ result.tags = tagSummary(outcome.mesh, edit.name);+ return { mesh: outcome.mesh, result };+ }if (Object.hasOwn(GENERATORS, edit.op)) {const generated = GENERATORS[edit.op](current, edit);result.tags = tagSummary(generated, edit.name);@@ -289,7 +316,7 @@ export function applyMeshEdits(mesh, edits, { maxVertices = 250_000, maxFaces =return { mesh: current, results };}-export const STACK_OPERATIONS = Object.freeze(['mirror', 'array', 'solidify']);+export const STACK_OPERATIONS = Object.freeze(['mirror', 'array', 'solidify', 'bevel']);export const MAX_STACK_NODES = 16;/** Validate a modifier stack: edits restricted to mirror, array and solidify, at most 16. */diff --git a/src/mesh-stack.js b/src/mesh-stack.jsindex e6d901fb..7d64ed92 100644--- a/src/mesh-stack.js+++ b/src/mesh-stack.js@@ -11,7 +11,7 @@ import { mergeByDistance } from './mesh-ops.js';* face, corner attributes from source corners, and edge attributes from the source edge each new corner's edge* came from. Faces built without a source get zeroed attributes.*/-class MeshBuilder {+export class MeshBuilder {constructor(source) {this.source = source;this.positions = [];diff --git a/src/mesh.js b/src/mesh.jsindex 85b0afb7..e89d9117 100644--- a/src/mesh.js+++ b/src/mesh.js@@ -14,6 +14,7 @@ export { selectFaces, countSelected } from './mesh-select.js';export { applyMeshEdits, normalizeMeshEdits, transformMesh, MESH_EDIT_OPERATIONS, MAX_MESH_EDITS } from './mesh-recipe.js';export { evaluateMeshStack, normalizeMeshStack, STACK_OPERATIONS, MAX_STACK_NODES } from './mesh-recipe.js';export { mirrorMesh, arrayMesh, solidifyMesh, removeCoincidentFaces } from './mesh-stack.js';+export { bevelEdges, selectEdges } from './mesh-bevel.js';export { loadMeshBooleans, meshBooleansLoaded, meshBoolean, BOOLEAN_OPERATIONS } from './mesh-boolean.js';export {extrudeFaceRegion, extrudeIndividual, insetRegion, insetIndividual, deleteFaces, flipFaces, translateFaces,diff --git a/tests/mcp-tools.test.js b/tests/mcp-tools.test.jsindex 3adb123a..d7b15316 100644--- a/tests/mcp-tools.test.js+++ b/tests/mcp-tools.test.js@@ -269,7 +269,7 @@ test('mesh_edit builds a mesh from a base and an edit log through the SDK', asynconst replaced = await client.callTool({ name: 'mesh_edit', arguments: { sessionId, expectedRevision: 1, geometry: 'cube', replace: true,edits: [{ op: 'extrude_individual', select: { tag: 'side' }, offset: 0.1 }] } });assert.equal(replaced.structuredContent.mesh.edits.length, 1);- await rejected(client, 'mesh_edit', { sessionId, expectedRevision: 2, geometry: 'cube', edits: [{ op: 'bevel', select: { all: true } }] });+ await rejected(client, 'mesh_edit', { sessionId, expectedRevision: 2, geometry: 'cube', edits: [{ op: 'knife', select: { all: true } }] });await rejected(client, 'mesh_edit', { sessionId, expectedRevision: 2, geometry: 'cube', edits: [] });await rejected(client, 'mesh_edit', { sessionId, expectedRevision: 2, geometry: 'cube', edits: [{ op: 'translate', offset: [0, 1, 0], code: 'run()' }] });});diff --git a/tests/mesh-bevel.test.js b/tests/mesh-bevel.test.jsnew file mode 100644index 00000000..55203e90--- /dev/null+++ b/tests/mesh-bevel.test.js@@ -0,0 +1,146 @@+import assert from 'node:assert/strict';+import test from 'node:test';+import { box, cylinder } from '../src/geometry.js';+import { editMesh, validateTopology, meshFromGeometry, lintMesh, meshBounds, tagCounts, applyMeshEdits } from '../src/mesh.js';+import { bevelEdges, selectEdges, edgeFaces } from '../src/mesh-bevel.js';+import { normalizeMeshEdits } from '../src/mesh-recipe.js';+import { createAgentScene } from '../src/agent-scene.js';++const cube = () => meshFromGeometry(box(0, 1));++function volume(mesh) {+ let total = 0;+ const p = mesh.positions;+ for (let face = 0; face < mesh.faceCount; face++) {+ const start = mesh.faceOffsets[face];+ const a = mesh.cornerVertices[start] * 3;+ for (let corner = start + 1; corner + 1 < mesh.faceOffsets[face + 1]; corner++) {+ const b = mesh.cornerVertices[corner] * 3;+ const c = mesh.cornerVertices[corner + 1] * 3;+ total += (p[a] * (p[b + 1] * p[c + 2] - p[b + 2] * p[c + 1]) + p[a + 1] * (p[b + 2] * p[c] - p[b] * p[c + 2]) + p[a + 2] * (p[b] * p[c + 1] - p[b + 1] * p[c])) / 6;+ }+ }+ return total;+}++function closed(mesh) {+ validateTopology(editMesh(mesh));+ const report = lintMesh(mesh);+ assert.deepEqual(report.problems, []);+ assert.equal(report.parts.closed, 1);+ return report;+}++test('edge rules select rims, sharp edges, region borders and everything', () => {+ const mesh = cube();+ const table = edgeFaces(mesh);+ const count = rule => selectEdges(mesh, rule, table).reduce((sum, value) => sum + value, 0);+ assert.equal(count({ between: [{ tag: 'top' }, { tag: 'side' }] }), 4);+ assert.equal(count({ angle: 30 }), 12);+ assert.equal(count({ angle: 91 }), 0);+ assert.equal(count({ boundaryOf: { tag: 'front' } }), 4);+ assert.equal(count({ all: true }), 12);+ assert.throws(() => selectEdges(mesh, { angle: 30, all: true }, table), /exactly one/);+});++test('chamfering one edge removes exactly the triangular prism', () => {+ const { mesh, bevelEdges: edges, stripFaces } = bevelEdges(cube(), { between: [{ tag: 'front' }, { tag: 'right' }] }, { width: 0.2 });+ closed(mesh);+ assert.equal(edges, 1);+ assert.equal(stripFaces, 1);+ assert.ok(Math.abs(volume(mesh) - (1 - 0.5 * 0.2 * 0.2)) < 1e-6);+});++test('rounded rim keeps the box closed, keeps base tags and tags strips', () => {+ const { mesh, stripFaces, cornerFaces } = bevelEdges(cube(), { between: [{ tag: 'top' }, { tag: 'side' }] }, { width: 0.1, segments: 4, name: 'rim' });+ closed(mesh);+ assert.equal(stripFaces, 16);+ assert.equal(cornerFaces, 0, 'a rim meets the unbeveled vertical edges, so no corner fills are needed');+ const tags = tagCounts(mesh);+ assert.equal(tags['rim.strip'], 16);+ assert.equal(tags.top, 1);+ assert.equal(tags.side, 4);+ const volumeRound = volume(mesh);+ assert.ok(volumeRound > 1 - 4 * 0.5 * 0.01 && volumeRound < 1, 'rounding removes less than a chamfer');+ assert.deepEqual(meshBounds(mesh).max.map(value => Math.round(value * 1e5) / 1e5), [0.5, 0.5, 0.5]);+});++test('beveling every edge fills the corners and clamps widths that would overlap', () => {+ const all = bevelEdges(cube(), { all: true }, { width: 0.1, segments: 3 });+ closed(all.mesh);+ assert.equal(all.filledCorners, 8);+ assert.equal(all.cornerFaces, 72, "each rounded corner fans 9 triangles to its centre");+ const wide = bevelEdges(cube(), { all: true }, { width: 2 });+ closed(wide.mesh);+ assert.equal(wide.clamped, true);+ assert.ok(wide.width < 0.5);+ assert.throws(() => bevelEdges(cube(), { angle: 120 }, { width: 0.1 }), /selects no edges/);+});++test('bevel works on curved caps and on edited meshes', () => {+ const can = bevelEdges(meshFromGeometry(cylinder(24, 0, 1)), { angle: 60 }, { width: 0.05, segments: 3 });+ closed(can.mesh);+ assert.equal(can.bevelEdges, 48);+ const lid = applyMeshEdits(cube(), [+ { op: 'inset_region', select: { tag: 'top' }, thickness: 0.15, name: 'lid' },+ { op: 'extrude_face_region', select: { tag: 'lid.cap' }, offset: 0.2, name: 'raise' },+ { op: 'bevel', edges: { boundaryOf: { tag: 'raise.cap' } }, width: 0.05, segments: 2, name: 'soft' },+ ]);+ closed(lid.mesh);+ assert.equal(lid.results[2].edges, 4);+ assert.equal(lid.results[2].tags['soft.strip'], 8);+});++test('bevel on an open surface keeps the opening as the only problem, and validates its fields', () => {+ const open = applyMeshEdits(cube(), [{ op: 'delete', select: { tag: 'top' } }]).mesh;+ const beveled = bevelEdges(open, { all: true }, { width: 0.1, segments: 2 });+ validateTopology(editMesh(beveled.mesh));+ assert.deepEqual(lintMesh(beveled.mesh).problems.map(problem => problem.kind), ['boundary-edge']);+ assert.equal(beveled.bevelEdges, 8, 'only edges with two faces bevel');+ assert.throws(() => normalizeMeshEdits([{ op: 'bevel', width: 0 }]), /width must be a number above 0/);+ assert.throws(() => normalizeMeshEdits([{ op: 'bevel', width: 0.1, segments: 40 }]), /segments must be an integer from 1 to 16/);+ assert.throws(() => normalizeMeshEdits([{ op: 'bevel', width: 0.1, edges: [] }]), /edges must be a rule/);+ assert.deepEqual(normalizeMeshEdits([{ op: 'bevel', width: 0.1 }])[0].edges, { angle: 30 });+});++test('beveling an already beveled mesh winds its corner fills against their neighbours', () => {+ // Regression: corner fills were oriented by an averaged normal, which flipped them next to rounded rims.+ const rim = bevelEdges(cube(), { between: [{ tag: 'top' }, { tag: 'side' }] }, { width: 0.08, segments: 3 }).mesh;+ const second = bevelEdges(rim, { angle: 80 }, { width: 0.02 });+ closed(second.mesh);+ assert.equal(second.filledCorners, 8);+});++test('random bevels on random boxes stay closed and valid', () => {+ let seed = 5;+ const random = () => {+ seed = (seed * 1103515245 + 12345) & 0x7fffffff;+ return seed / 0x7fffffff;+ };+ const rules = [{ all: true }, { angle: 45 }, { between: [{ tag: 'top' }, { tag: 'side' }] }, { boundaryOf: { tag: 'front' } }, { between: [{ tag: 'left' }, { tag: 'bottom' }] }];+ for (let trial = 0; trial < 25; trial++) {+ const stretched = applyMeshEdits(cube(), [+ { op: 'translate', select: { tag: 'top' }, offset: [0, random() * 2, 0] },+ { op: 'translate', select: { tag: 'right' }, offset: [random() * 2, 0, 0] },+ ]).mesh;+ const rule = rules[Math.floor(random() * rules.length)];+ const { mesh } = bevelEdges(stretched, rule, { width: 0.02 + random() * 0.4, segments: 1 + Math.floor(random() * 4), profile: random() });+ closed(mesh);+ }+});++test('recipe meshes bevel as an edit or as a stack node', () => {+ const scene = createAgentScene({+ format: '67js.scene', schemaVersion: 1,+ geometries: [{ id: 'block', type: 'mesh', base: { type: 'box', bevel: 0 },+ edits: [{ op: 'bevel', edges: { between: [{ tag: 'top' }, { tag: 'side' }] }, width: 0.08, segments: 3 }],+ stack: [{ op: 'bevel', edges: { angle: 80 }, width: 0.02 }] }],+ materials: [{ id: 'grey', color: [0.5, 0.5, 0.5] }],+ nodes: [{ id: 'block', geometry: 'block', material: 'grey' }],+ });+ const [report] = scene.inspectMeshes().meshes;+ assert.equal(report.ok, true, JSON.stringify(report.problems));+ assert.equal(report.edits[0].edges, 4);+ assert.equal(report.stack[0].op, 'bevel');+ assert.ok(report.stack[0].edges > 0);+});diff --git a/tests/mesh-edit.test.js b/tests/mesh-edit.test.jsindex 50edc30d..b1652b36 100644--- a/tests/mesh-edit.test.js+++ b/tests/mesh-edit.test.js@@ -149,7 +149,7 @@ test('translate with connected falloff moves nearby vertices less', () => {});test('edit validation names the op, field and allowed values', () => {- assert.throws(() => normalizeMeshEdits([{ op: 'bevel' }]), /op must be one of extrude_face_region/);+ assert.throws(() => normalizeMeshEdits([{ op: 'knife' }]), /op must be one of extrude_face_region/);assert.throws(() => normalizeMeshEdits([{ op: 'extrude_individual', offset: 1, depth: 2 }]), /does not take depth/);assert.throws(() => normalizeMeshEdits([{ op: 'inset_region', thickness: 0 }]), /thickness must be a number above 0/);assert.throws(() => normalizeMeshEdits([{ op: 'delete' }]), /delete needs select/);