9c0b7070d1
- Dragging the arrow of a selected face or shape orbited the view instead (since the last push: a pause meant for double taps also caught a drag). Fixed - Tablets and up: Items runs the full height like History; with Items open the top bar centres in the room beside it (it overlapped Items on a tablet); the view cube sits below the top bar (it was beside Items / More) - Working… sits below the hint line (they overlapped) - Items: each kind (Bodies, Sketches, Planes & axes, Images) folds away under its heading - Every value box is also a scroll wheel: a click opens the numpad / types, a press and drag left or right turns the value down or up - Every drag has a value box by the pointer that stays after letting go (Move/Rotate, Move Face/Edge, Scale, Scale Face; Freeform while dragging): tap it to type - Typing during a drag goes into the value box on screen: no second blue "Enter ↵ apply · Esc cancel" box - Cards tighter with a mouse; on tablets and desktops Cancel is only in the card (not also in the tool column) - Right-click steps back: what's half done or picked, then the drawing tool, then out of the sketch; in other tools it backs out, in Freeform it lets go of the picks, then finishes - Move/Rotate Edge and Move/Rotate Face have their own icons; a straight edge picked shows its Move/Rotate gimbal (it was the fillet dot; Fillet / Chamfer are in the list) - Move/Rotate Face: move it every way and turn it about its normal too — on a body of flat faces, the faces round it follow (it only pushed and tilted) - Subtract / Intersect open a tool: "Select a body to remove from, then a body to subtract from it", a + on the body changed and − on the ones it's changed with, Keep modified body / Keep subtracted bodies (bodies picked first are filled in) - Section View: the cut is a solid cap (a stencil marks the inside; the inside of the far wall used to show through, edges and all), outlined with a thick line - Freeform: press on empty space and drag a box to pick the cage points inside; picked edges thick, points bigger, faces filled; Symmetry (across X / Y / Z through the middle, or across a tapped cage edge): points moved move their mirror images, points on the plane stay on it - Freeform scale stress test (tests/freeformscale.test.ts, 634 checks: 5 cages × all / half / a face / a point × 12 factors from 0.01 to 100 and lopsided; whole bodies uniform and per axis, copies too): all clean, and the right size - Speed: a body's size is worked out once (every join measured it again for a tolerance); Delete Face reads the result's faces once per try — deleting a hole in the jet's casing 8.5 → 5.6 s, the jet's whole build 41 → 38 s Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
3.3 KiB
TypeScript
51 lines
3.3 KiB
TypeScript
// Run: npx tsx tests/facesketchkeep.test.ts
|
||
// A face slid within its own plane / turned about its normal (the faces round
|
||
// it follow, on a body of flat faces), and Subtract / Intersect keeping the
|
||
// body changed or the bodies it was changed with.
|
||
import opencascade from "replicad-opencascadejs";
|
||
import { measureVolume, setOC } from "replicad";
|
||
import { debugBodies, regenerate, shapeValid } from "../src/kernel/engine";
|
||
|
||
setOC(await (opencascade as unknown as () => Promise<any>)());
|
||
let failed = 0;
|
||
const check = (name: string, ok: boolean, info = "") => {
|
||
if (!ok) failed++;
|
||
console.log(ok ? "ok " : "FAIL", name, info);
|
||
};
|
||
const XY = { origin: [0, 0, 0], normal: [0, 0, 1], xDir: [1, 0, 0] };
|
||
const block = (id: string, cx: number, w = 40, h = 20, d = 30) => [
|
||
{ id: `s${id}`, name: id, type: "sketch", plane: XY, entities: [{ id: `r${id}`, kind: "rect", center: [cx, 0], w, h, rotation: 0 }] },
|
||
{ id, name: id, type: "extrude", source: { kind: "profile", sketch: `s${id}`, regions: [{ c: [cx, 0], a: w * h }] }, distance: d, mode: "new" },
|
||
];
|
||
const top = { body: "b", center: [0, 0, 30], normal: [0, 0, 1], area: 800 };
|
||
const V = (id: string) => Math.abs(measureVolume(debugBodies().get(id)!));
|
||
const bb = (id: string) => (debugBodies().get(id) as any).boundingBox.bounds.map((p: number[]) => p.map((x) => +x.toFixed(2)));
|
||
|
||
{
|
||
const r: any = await regenerate([...block("b", 0), { id: "m", name: "m", type: "moveFace", face: top, translate: [6, 0, 0] }] as any);
|
||
const b = bb("b");
|
||
check("a face slid sideways: the body leans (sheared, same volume)", !r.errors.length && Math.abs(V("b") - 24000) < 1 && b[1][0] === 26 && b[0][0] === -20 && shapeValid(debugBodies().get("b") as any), `${JSON.stringify(b)} ${V("b").toFixed(1)}`);
|
||
}
|
||
{
|
||
const r: any = await regenerate([...block("b", 0), { id: "m", name: "m", type: "moveFace", face: top, translate: [0, 0, 0], rotate: { origin: [0, 0, 30], axis: [0, 0, 1], angle: 15 } }] as any);
|
||
const b = bb("b");
|
||
check("a face turned about its normal: the body twists (the top's corners turned)", !r.errors.length && b[1][1] > 10.5 && shapeValid(debugBodies().get("b") as any), JSON.stringify(b));
|
||
}
|
||
{
|
||
const r: any = await regenerate([...block("b", 0), { id: "m", name: "m", type: "moveFace", face: top, translate: [3, 4, 5] }] as any);
|
||
check("a face moved every way at once: pushed and slid", !r.errors.length && bb("b")[1][2] === 35 && bb("b")[1][0] === 23, JSON.stringify(bb("b")));
|
||
}
|
||
for (const op of ["subtract", "intersect"] as const) {
|
||
for (const [kt, kT] of [[false, false], [true, false], [false, true], [true, true]]) {
|
||
const r: any = await regenerate([...block("A", 0), ...block("B", 25), { id: "op", name: "op", type: "boolean", op, target: "A", tools: ["B"], keepTools: kt || undefined, keepTarget: kT || undefined }] as any);
|
||
const ids = r.bodies.map((b: any) => b.id).sort();
|
||
const want = ["A", ...(kt ? ["B"] : []), ...(kT ? ["op"] : [])].sort();
|
||
const result = kT ? "op" : "A";
|
||
const vr = V(result);
|
||
// A and B overlap 15 × 20 × 30 = 9000.
|
||
const expect = op === "subtract" ? 24000 - 9000 : 9000;
|
||
check(`${op}, keep tools ${kt}, keep target ${kT}: the right bodies, the right result`, !r.errors.length && JSON.stringify(ids) === JSON.stringify(want) && Math.abs(vr - expect) < 1 && (!kT || Math.abs(V("A") - 24000) < 1), `${ids} ${vr.toFixed(0)}`);
|
||
}
|
||
}
|
||
process.exit(failed ? 1 : 0);
|