@bitbybit-dev/create-app 1.4.0 → 1.5.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +1 -0
  2. package/dist/index.js +31 -21
  3. package/dist/index.js.map +1 -1
  4. package/dist/scaffold.d.ts.map +1 -1
  5. package/dist/scaffold.js +16 -8
  6. package/dist/scaffold.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/index.test.ts +290 -10
  9. package/src/index.ts +42 -25
  10. package/src/scaffold.ts +23 -8
  11. package/templates/apps/drone-assembly/package.json +3 -3
  12. package/templates/apps/drone-assembly/scripts/smoke.ts +3 -3
  13. package/templates/apps/drone-assembly/src/parts.ts +3 -3
  14. package/templates/apps/ifc-house/AGENTS.section.md +19 -0
  15. package/templates/apps/ifc-house/README.md +36 -0
  16. package/templates/apps/ifc-house/eslint.config.js +47 -0
  17. package/templates/apps/ifc-house/index.html +22 -0
  18. package/templates/apps/ifc-house/package.json +36 -0
  19. package/templates/apps/ifc-house/public/favicon.ico +0 -0
  20. package/templates/apps/ifc-house/public/logo.png +0 -0
  21. package/templates/apps/ifc-house/scripts/smoke.ts +118 -0
  22. package/templates/apps/ifc-house/src/export/step-export.ts +29 -0
  23. package/templates/apps/ifc-house/src/house/build-house.ts +194 -0
  24. package/templates/apps/ifc-house/src/house/details.ts +393 -0
  25. package/templates/apps/ifc-house/src/house/house-plan.ts +400 -0
  26. package/templates/apps/ifc-house/src/house/house-types.ts +192 -0
  27. package/templates/apps/ifc-house/src/main.ts +138 -0
  28. package/templates/apps/ifc-house/src/scene/draw-house.ts +92 -0
  29. package/templates/apps/ifc-house/src/scene/scene-types.ts +30 -0
  30. package/templates/apps/ifc-house/src/scene/stage.ts +64 -0
  31. package/templates/apps/ifc-house/src/style.css +347 -0
  32. package/templates/apps/ifc-house/src/ui/panel.ts +144 -0
  33. package/templates/apps/ifc-house/src/ui/room-labels.ts +75 -0
  34. package/templates/apps/ifc-house/src/ui/ui-types.ts +14 -0
  35. package/templates/apps/ifc-house/src/vite-env.d.ts +1 -0
  36. package/templates/apps/ifc-house/src/workers/ifc.worker.ts +7 -0
  37. package/templates/apps/ifc-house/src/workers/manifold.worker.ts +16 -0
  38. package/templates/apps/ifc-house/src/workers/occt.worker.ts +17 -0
  39. package/templates/apps/ifc-house/tsconfig.json +29 -0
  40. package/templates/apps/laser-cut-box/package.json +2 -2
  41. package/templates/apps/laser-cut-box/scripts/smoke.ts +2 -1
  42. package/templates/apps/laser-cut-box/src/panels.ts +2 -0
  43. package/templates/apps/product-configurator/package.json +2 -2
  44. package/templates/apps/product-configurator/scripts/smoke.ts +4 -3
  45. package/templates/apps/sheet-metal-unfold/backend/package.json +1 -1
  46. package/templates/apps/sheet-metal-unfold/frontend/package.json +2 -2
  47. package/templates/apps/sheet-metal-unfold/frontend/scripts/smoke.ts +4 -3
  48. package/templates/apps/step-to-gltf-cli/package.json +2 -2
  49. package/templates/apps/step-to-gltf-cli/src/convert.ts +7 -2
  50. package/templates/cloud/backends/hono-rest/package.json +1 -1
  51. package/templates/cloud/backends/hono-sdk/package.json +2 -2
  52. package/templates/cloud/backends/nodejs-rest/package.json +1 -1
  53. package/templates/cloud/backends/nodejs-sdk/package.json +2 -2
  54. package/templates/cloud/frontend/package.json +1 -1
  55. package/templates/vite/babylonjs/typescript/AGENTS.section.md +1 -1
  56. package/templates/vite/babylonjs/typescript/package.json +2 -2
  57. package/templates/vite/babylonjs/typescript/scripts/smoke.ts +4 -3
  58. package/templates/vite/playcanvas/typescript/AGENTS.section.md +1 -1
  59. package/templates/vite/playcanvas/typescript/package.json +2 -2
  60. package/templates/vite/playcanvas/typescript/scripts/smoke.ts +4 -3
  61. package/templates/vite/threejs/typescript/AGENTS.section.md +1 -1
  62. package/templates/vite/threejs/typescript/package.json +2 -2
  63. package/templates/vite/threejs/typescript/scripts/smoke.ts +4 -3
@@ -0,0 +1,144 @@
1
+ import type { Layer, RoomSpec } from "../house/house-types";
2
+ import type { ElementInfo } from "../scene/scene-types";
3
+ import type { PanelFacts, PanelHandlers } from "./ui-types";
4
+
5
+ const TOGGLES: { key: Layer | "labels"; label: string; on: boolean }[] = [
6
+ { key: "roof", label: "Roof and solar", on: true },
7
+ { key: "first", label: "First floor", on: true },
8
+ { key: "ground", label: "Ground floor", on: true },
9
+ { key: "garden", label: "Garden, trees and carport", on: true },
10
+ { key: "labels", label: "Room names", on: false },
11
+ ];
12
+
13
+ function element<K extends keyof HTMLElementTagNameMap>(tag: K, className: string, text?: string): HTMLElementTagNameMap[K] {
14
+ const made = document.createElement(tag);
15
+ made.className = className;
16
+ if (text !== undefined) {
17
+ made.textContent = text;
18
+ }
19
+ return made;
20
+ }
21
+
22
+ export class HousePanel {
23
+ private readonly selection: HTMLElement;
24
+ private readonly switches = new Map<string, HTMLInputElement>();
25
+ private readonly handlers: PanelHandlers;
26
+
27
+ constructor(host: HTMLElement, facts: PanelFacts, rooms: RoomSpec[], areas: Map<string, number>, handlers: PanelHandlers) {
28
+ this.handlers = handlers;
29
+ const panel = element("aside", "panel");
30
+ panel.append(this.header(), this.facts(facts), this.toggles(), this.schedule(rooms, areas));
31
+ this.selection = element("section", "selection");
32
+ this.select(undefined);
33
+ panel.append(this.selection, this.downloads());
34
+ host.appendChild(panel);
35
+ }
36
+
37
+ isOn(key: Layer | "labels"): boolean {
38
+ return this.switches.get(key)?.checked ?? false;
39
+ }
40
+
41
+ turn(key: Layer | "labels", on: boolean): void {
42
+ const input = this.switches.get(key);
43
+ if (input && input.checked !== on) {
44
+ input.checked = on;
45
+ input.dispatchEvent(new Event("change"));
46
+ }
47
+ }
48
+
49
+ select(info: ElementInfo | undefined): void {
50
+ this.selection.replaceChildren();
51
+ if (!info) {
52
+ this.selection.append(element("p", "hint", "Click any part of the house to see what the IFC file says about it."));
53
+ return;
54
+ }
55
+ this.selection.append(element("div", "selection-type", info.type), element("div", "selection-name", info.name || "Unnamed"), element("code", "selection-id", info.globalId));
56
+ }
57
+
58
+ private header(): HTMLElement {
59
+ const header = element("header", "panel-header");
60
+ const logo = element("img", "panel-logo");
61
+ logo.src = "/logo.png";
62
+ logo.alt = "";
63
+ header.append(
64
+ logo,
65
+ element("div", "eyebrow", "IFC4 model, authored in your browser"),
66
+ element("h1", "title", "Family house"),
67
+ element("p", "lede", "Two storeys for a cold climate: insulated rendered masonry below, a timber frame clad in charred larch boards above, cantilevered over the garden terrace, under a warm flat roof with a parapet and solar array. The ground, trees, wall build-ups, U-values, rooms and quantities are all in the open BIM file."),
68
+ );
69
+ return header;
70
+ }
71
+
72
+ private facts(facts: PanelFacts): HTMLElement {
73
+ const list = element("dl", "facts");
74
+ const rows: [string, string][] = [
75
+ [`${facts.netArea.toFixed(0)} m²`, "net floor area"],
76
+ [String(facts.rooms), "rooms"],
77
+ [String(facts.openings), "windows and doors"],
78
+ [`${facts.seconds.toFixed(1)} s`, "to author and build"],
79
+ ];
80
+ for (const [value, label] of rows) {
81
+ const row = element("div", "fact");
82
+ row.append(element("dt", "fact-value", value), element("dd", "fact-label", label));
83
+ list.append(row);
84
+ }
85
+ return list;
86
+ }
87
+
88
+ private toggles(): HTMLElement {
89
+ const section = element("section", "toggles");
90
+ section.append(element("h2", "section-title", "Show"));
91
+ for (const toggle of TOGGLES) {
92
+ const row = element("label", "switch");
93
+ const input = element("input", "switch-input");
94
+ input.type = "checkbox";
95
+ input.checked = toggle.on;
96
+ input.addEventListener("change", () => {
97
+ this.handlers.onToggle(toggle.key, input.checked);
98
+ });
99
+ this.switches.set(toggle.key, input);
100
+ row.append(input, element("span", "switch-track"), element("span", "switch-label", toggle.label));
101
+ section.append(row);
102
+ }
103
+ return section;
104
+ }
105
+
106
+ private schedule(rooms: RoomSpec[], areas: Map<string, number>): HTMLElement {
107
+ const section = element("details", "schedule");
108
+ section.append(element("summary", "section-title", "Room schedule"));
109
+ const table = element("table", "rooms");
110
+ for (const room of rooms) {
111
+ const row = element("tr", "room-row");
112
+ const area = areas.get(room.number);
113
+ row.append(element("td", "room-cell-number", room.number), element("td", "room-cell-name", room.name), element("td", "room-cell-area", area === undefined ? "" : `${area.toFixed(1)} m²`));
114
+ table.append(row);
115
+ }
116
+ section.append(table);
117
+ return section;
118
+ }
119
+
120
+ private downloads(): HTMLElement {
121
+ const section = element("section", "downloads");
122
+ section.append(
123
+ this.downloadButton("Download house.ifc", () => this.handlers.onDownload()),
124
+ this.downloadButton("Download house.step", () => this.handlers.onDownloadStep()),
125
+ );
126
+ return section;
127
+ }
128
+
129
+ private downloadButton(label: string, run: () => Promise<void>): HTMLButtonElement {
130
+ const button = element("button", "download", label);
131
+ button.addEventListener("click", () => {
132
+ button.disabled = true;
133
+ void run().finally(() => {
134
+ button.disabled = false;
135
+ });
136
+ });
137
+ return button;
138
+ }
139
+ }
140
+
141
+ export function showStatus(host: HTMLElement, text: string | undefined): void {
142
+ host.textContent = text ?? "";
143
+ host.classList.toggle("status-hidden", text === undefined);
144
+ }
@@ -0,0 +1,75 @@
1
+ import * as THREE from "three";
2
+ import { FIRST_FLOOR_ELEVATION } from "../house/house-plan";
3
+ import type { RoomSpec, StoreyKey } from "../house/house-types";
4
+ import type { Stage } from "../scene/scene-types";
5
+
6
+ const LABEL_HEIGHT = 0.15;
7
+
8
+ interface Label {
9
+ room: RoomSpec;
10
+ anchor: THREE.Vector3;
11
+ element: HTMLDivElement;
12
+ }
13
+
14
+ function centreOf(room: RoomSpec): THREE.Vector3 {
15
+ const xs = room.outline.map(([x]) => x);
16
+ const ys = room.outline.map(([, y]) => y);
17
+ const x = (Math.min(...xs) + Math.max(...xs)) / 2;
18
+ const y = (Math.min(...ys) + Math.max(...ys)) / 2;
19
+ const base = room.storey === "first" ? FIRST_FLOOR_ELEVATION : 0;
20
+ return new THREE.Vector3(x, base + LABEL_HEIGHT, -y);
21
+ }
22
+
23
+ export class RoomLabels {
24
+ private readonly labels: Label[];
25
+ private storey: StoreyKey | undefined;
26
+ private readonly projected = new THREE.Vector3();
27
+ private readonly stage: Stage;
28
+
29
+ constructor(stage: Stage, rooms: RoomSpec[], areas: Map<string, number>, host: HTMLElement) {
30
+ this.stage = stage;
31
+ this.labels = rooms.map((room) => {
32
+ const element = document.createElement("div");
33
+ element.className = "room-label";
34
+ const area = areas.get(room.number);
35
+ element.append(
36
+ textSpan("room-number", room.number),
37
+ textSpan("room-name", room.name),
38
+ textSpan("room-area", area === undefined ? "" : `${area.toFixed(1)} m²`),
39
+ );
40
+ host.appendChild(element);
41
+ return { room, anchor: centreOf(room), element };
42
+ });
43
+ const follow = (): void => {
44
+ this.place();
45
+ requestAnimationFrame(follow);
46
+ };
47
+ requestAnimationFrame(follow);
48
+ }
49
+
50
+ show(storey: StoreyKey | undefined): void {
51
+ this.storey = storey;
52
+ }
53
+
54
+ private place(): void {
55
+ const { camera, renderer } = this.stage;
56
+ const width = renderer.domElement.clientWidth;
57
+ const height = renderer.domElement.clientHeight;
58
+ for (const label of this.labels) {
59
+ const visible = label.room.storey === this.storey;
60
+ this.projected.copy(label.anchor).project(camera);
61
+ const inFront = this.projected.z < 1;
62
+ label.element.style.display = visible && inFront ? "flex" : "none";
63
+ if (visible && inFront) {
64
+ label.element.style.transform = `translate(-50%, -50%) translate(${(this.projected.x + 1) / 2 * width}px, ${(1 - this.projected.y) / 2 * height}px)`;
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ function textSpan(className: string, text: string): HTMLSpanElement {
71
+ const span = document.createElement("span");
72
+ span.className = className;
73
+ span.textContent = text;
74
+ return span;
75
+ }
@@ -0,0 +1,14 @@
1
+ import type { Layer } from "../house/house-types";
2
+
3
+ export interface PanelFacts {
4
+ netArea: number;
5
+ rooms: number;
6
+ openings: number;
7
+ seconds: number;
8
+ }
9
+
10
+ export interface PanelHandlers {
11
+ onToggle(key: Layer | "labels", on: boolean): void;
12
+ onDownload(): Promise<void>;
13
+ onDownloadStep(): Promise<void>;
14
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,7 @@
1
+ import { initializationComplete, onMessageInput, type DataInput } from "@bitbybit-dev/ifc-worker";
2
+
3
+ initializationComplete();
4
+
5
+ addEventListener("message", ({ data }: MessageEvent<DataInput>) => {
6
+ onMessageInput(data, postMessage);
7
+ });
@@ -0,0 +1,16 @@
1
+ import { initializationComplete, onMessageInput, type DataInput } from "@bitbybit-dev/manifold-worker";
2
+ import Module from "manifold-3d";
3
+
4
+ const MANIFOLD_WASM_URL = "https://git-cdn.bitbybit.dev/v1.5.0-rc.0/wasm/manifold-3.5.3.wasm";
5
+
6
+ async function init(): Promise<void> {
7
+ const wasm = await Module({ locateFile: () => MANIFOLD_WASM_URL });
8
+ wasm.setup();
9
+ initializationComplete(wasm);
10
+ }
11
+
12
+ void init();
13
+
14
+ addEventListener("message", ({ data }: MessageEvent<DataInput>) => {
15
+ onMessageInput(data, postMessage);
16
+ });
@@ -0,0 +1,17 @@
1
+ import initOpenCascade from "@bitbybit-dev/occt/bitbybit-dev-occt/cdn";
2
+ import { initializationComplete, onMessageInput, type DataInput } from "@bitbybit-dev/occt-worker";
3
+
4
+ async function init(): Promise<void> {
5
+ const occ = await initOpenCascade();
6
+ initializationComplete(occ, undefined);
7
+ }
8
+
9
+ init().catch((error: unknown) => {
10
+ setTimeout(() => {
11
+ throw error instanceof Error ? error : new Error(String(error));
12
+ });
13
+ });
14
+
15
+ addEventListener("message", ({ data }: MessageEvent<DataInput>) => {
16
+ onMessageInput(data, postMessage);
17
+ });
@@ -0,0 +1,29 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "types": ["node"],
8
+ "allowImportingTsExtensions": true,
9
+ "moduleDetection": "force",
10
+ "noEmit": true,
11
+ "strict": true,
12
+ "noUncheckedIndexedAccess": true,
13
+ "exactOptionalPropertyTypes": true,
14
+ "noImplicitReturns": true,
15
+ "noImplicitOverride": true,
16
+ "noPropertyAccessFromIndexSignature": true,
17
+ "noFallthroughCasesInSwitch": true,
18
+ "noUnusedLocals": true,
19
+ "noUnusedParameters": true,
20
+ "useUnknownInCatchVariables": true,
21
+ "forceConsistentCasingInFileNames": true,
22
+ "isolatedModules": true,
23
+ "verbatimModuleSyntax": true,
24
+ "erasableSyntaxOnly": true,
25
+ "noUncheckedSideEffectImports": true,
26
+ "skipLibCheck": true
27
+ },
28
+ "include": ["src", "scripts"]
29
+ }
@@ -12,11 +12,11 @@
12
12
  "lint": "eslint . --max-warnings 0"
13
13
  },
14
14
  "dependencies": {
15
- "@bitbybit-dev/threejs": "1.4.0",
15
+ "@bitbybit-dev/threejs": "1.5.0-rc.0",
16
16
  "three": "0.186.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@bitbybit-dev/occt": "1.4.0",
19
+ "@bitbybit-dev/occt": "1.5.0-rc.0",
20
20
  "@eslint/js": "10.0.1",
21
21
  "@types/node": "22.20.1",
22
22
  "@types/three": "0.186.0",
@@ -45,6 +45,7 @@ async function check(name: string, params: BoxParams): Promise<BoxCheck> {
45
45
  const dxfPaths: Record<string, number> = {};
46
46
  for (const part of model.parts) {
47
47
  if (await occt.shapes.shape.getShapeType({ shape: part.face }) !== Inputs.OCCT.shapeTypeEnum.face) problems.push(`${name}: part ${part.id} is not one planar face`);
48
+ if (!(await occt.shapeFix.isValid({ shape: part.assembled }))) problems.push(`${name}: part ${part.id} is not a valid solid`);
48
49
  const paths = await occt.io.shapeToDxfPaths({ shape: part.flat, angularDeflection: 0.1, curvatureDeflection: 0.1, minimumOfPoints: 2, uTolerance: 1e-9, minimumLength: 1e-7 });
49
50
  dxfPaths[part.id] = paths.length;
50
51
  if (paths.length === 0) problems.push(`${name}: part ${part.id} produced no DXF path`);
@@ -55,7 +56,7 @@ async function check(name: string, params: BoxParams): Promise<BoxCheck> {
55
56
  }
56
57
 
57
58
  const assembled = await occt.shapes.compound.makeCompound({ shapes: model.parts.map((part) => part.assembled) });
58
- const bbox = await occt.operations.boundingBoxOfShape({ shape: assembled });
59
+ const bbox = await occt.analysis.measure.tightBoundingBox({ shape: assembled });
59
60
  const expectedMin: [number, number, number] = [-p.length / 2, 0, -p.width / 2];
60
61
  const expectedMax: [number, number, number] = [p.length / 2, p.height, p.width / 2];
61
62
  const slack = p.kerf / 2 + 0.001;
@@ -153,6 +153,7 @@ export function outlineFor(spec: PanelSpec, p: BoxParams): Point2[] {
153
153
  }
154
154
 
155
155
  const same = (a: Point2, b: Point2): boolean => Math.abs(a[0] - b[0]) < 1e-9 && Math.abs(a[1] - b[1]) < 1e-9;
156
+ const collinear = (a: Point2, b: Point2, c: Point2): boolean => Math.abs((b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0])) < 1e-9;
156
157
 
157
158
  function tidy(points: Point2[]): Point2[] {
158
159
  const out = [...points];
@@ -167,6 +168,7 @@ function tidy(points: Point2[]): Point2[] {
167
168
  if (!previous || !here || !next) break;
168
169
  if (same(here, next)) { out.splice(i, 1); changed = true; break; }
169
170
  if (same(previous, next)) { out.splice(i, 2); changed = true; break; }
171
+ if (collinear(previous, here, next)) { out.splice(i, 1); changed = true; break; }
170
172
  }
171
173
  }
172
174
  return out;
@@ -12,11 +12,11 @@
12
12
  "lint": "eslint . --max-warnings 0"
13
13
  },
14
14
  "dependencies": {
15
- "@bitbybit-dev/threejs": "1.4.0",
15
+ "@bitbybit-dev/threejs": "1.5.0-rc.0",
16
16
  "three": "0.186.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@bitbybit-dev/occt": "1.4.0",
19
+ "@bitbybit-dev/occt": "1.5.0-rc.0",
20
20
  "@eslint/js": "10.0.1",
21
21
  "@types/node": "22.20.1",
22
22
  "@types/three": "0.186.0",
@@ -36,7 +36,8 @@ async function check(name: string, params: PlanterParams): Promise<PlanterCheck>
36
36
  const p = clampParams(params);
37
37
  const model = await buildModel(occt, params);
38
38
  const info = await occt.shapes.solid.debugInfo({ shape: model.shape });
39
- const bbox = await occt.operations.boundingBoxOfShape({ shape: model.shape });
39
+ const valid = await occt.shapeFix.isValid({ shape: model.shape });
40
+ const bbox = await occt.analysis.measure.tightBoundingBox({ shape: model.shape });
40
41
  const quote = quoteFor(p, model);
41
42
  const expectedMin: [number, number, number] = [-p.width / 2, 0, -p.depth / 2];
42
43
  const expectedMax: [number, number, number] = [p.width / 2, p.height, p.depth / 2];
@@ -46,13 +47,13 @@ async function check(name: string, params: PlanterParams): Promise<PlanterCheck>
46
47
  const bottom = bottomSize(p);
47
48
  const inside = p.wallThickness + STYLE.lipStep;
48
49
  const leastCavity = (bottom.width - 2 * inside) * (bottom.depth - 2 * inside) * (p.height - p.wallThickness);
49
- if (!info.valid) problems.push(`${name}: the planter is not a valid solid`);
50
+ if (!valid) problems.push(`${name}: the planter is not a valid solid`);
50
51
  if (!(model.volume > 0)) problems.push(`${name}: the planter has no volume`);
51
52
  if (!(model.volume < solidVolume - leastCavity)) problems.push(`${name}: the planter is not hollow (volume ${round(model.volume)} is not below the block's ${solidVolume} less the least cavity ${round(leastCavity)})`);
52
53
  if (!within) problems.push(`${name}: the bounding box ${JSON.stringify([bbox.min, bbox.max])} is not the declared ${JSON.stringify([expectedMin, expectedMax])}`);
53
54
  if (!(Number.isFinite(quote.total) && quote.total > 0)) problems.push(`${name}: the quote is ${quote.total}`);
54
55
  if (drainageHoleCenters(p).length !== p.drainageHoles) problems.push(`${name}: ${drainageHoleCenters(p).length} hole centers for ${p.drainageHoles} holes`);
55
- return { valid: info.valid, faces: info.nbFaces, edges: info.nbEdges, volume: round(model.volume), surfaceArea: round(model.surfaceArea), price: quote.total };
56
+ return { valid, faces: info.nbFaces, edges: info.nbEdges, volume: round(model.volume), surfaceArea: round(model.surfaceArea), price: quote.total };
56
57
  }
57
58
 
58
59
  const summary = {
@@ -12,7 +12,7 @@
12
12
  "lint": "eslint . --max-warnings 0"
13
13
  },
14
14
  "dependencies": {
15
- "@bitbybit-dev/cad-cloud-sdk": "1.4.0",
15
+ "@bitbybit-dev/cad-cloud-sdk": "1.5.0-rc.0",
16
16
  "express": "^5.1.0"
17
17
  },
18
18
  "devDependencies": {
@@ -12,11 +12,11 @@
12
12
  "lint": "eslint . --max-warnings 0"
13
13
  },
14
14
  "dependencies": {
15
- "@bitbybit-dev/threejs": "1.4.0",
15
+ "@bitbybit-dev/threejs": "1.5.0-rc.0",
16
16
  "three": "0.186.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@bitbybit-dev/occt": "1.4.0",
19
+ "@bitbybit-dev/occt": "1.5.0-rc.0",
20
20
  "@eslint/js": "10.0.1",
21
21
  "@types/node": "22.20.1",
22
22
  "@types/three": "0.186.0",
@@ -36,17 +36,18 @@ async function check(name: string, params: PartParams): Promise<PartCheck> {
36
36
  const p = clampParams(params);
37
37
  const model = await buildModel(occt, params);
38
38
  const info = await occt.shapes.solid.debugInfo({ shape: model.shape });
39
- const bbox = await occt.operations.boundingBoxOfShape({ shape: model.shape });
39
+ const valid = await occt.shapeFix.isValid({ shape: model.shape });
40
+ const bbox = await occt.analysis.measure.tightBoundingBox({ shape: model.shape });
40
41
  const expectedVolume = profileArea(p) * p.depth - removedVolume(p);
41
42
  const estimate = flatLengthEstimate(p);
42
43
  const expectedMin: [number, number, number] = [-p.baseWidth / 2, 0, -p.depth / 2];
43
44
  const expectedMax: [number, number, number] = [p.baseWidth / 2, p.flangeHeight, p.depth / 2];
44
45
  const within = spans(bbox.min, expectedMin) && spans(bbox.max, expectedMax);
45
- if (!info.valid) problems.push(`${name}: the part is not a valid solid`);
46
+ if (!valid) problems.push(`${name}: the part is not a valid solid`);
46
47
  if (Math.abs(model.volume - expectedVolume) > expectedVolume * 1e-4) problems.push(`${name}: volume ${round(model.volume)} is not the thickness times the rounded centre line times the depth minus the mounting features (${round(expectedVolume)}); the sheet is not one thickness along its bends or a feature sits in a bend`);
47
48
  if (!within) problems.push(`${name}: the part spans ${JSON.stringify([bbox.min.map(round), bbox.max.map(round)])}, expected ${JSON.stringify([expectedMin, expectedMax])}`);
48
49
  if (!(estimate.total > 0 && estimate.total < estimate.outerLengths)) problems.push(`${name}: the flat length estimate ${round(estimate.total)} is not below the outer lengths ${round(estimate.outerLengths)}`);
49
- return { valid: info.valid, faces: info.nbFaces, volume: round(model.volume), holes: model.mounting.baseHoles.length, slots: model.mounting.flangeSlots.length, bends: estimate.bends, flatEstimate: round(estimate.total) };
50
+ return { valid, faces: info.nbFaces, volume: round(model.volume), holes: model.mounting.baseHoles.length, slots: model.mounting.flangeSlots.length, bends: estimate.bends, flatEstimate: round(estimate.total) };
50
51
  }
51
52
 
52
53
  const report: UnfoldSolidReport[] = [
@@ -11,8 +11,8 @@
11
11
  "lint": "eslint . --max-warnings 0"
12
12
  },
13
13
  "dependencies": {
14
- "@bitbybit-dev/cad-cloud-sdk": "1.4.0",
15
- "@bitbybit-dev/occt": "1.4.0"
14
+ "@bitbybit-dev/cad-cloud-sdk": "1.5.0-rc.0",
15
+ "@bitbybit-dev/occt": "1.5.0-rc.0"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@eslint/js": "10.0.1",
@@ -36,9 +36,9 @@ export function convertFile(occt: OCCTService, file: string, text: string, optio
36
36
  const faces = occt.shapes.face.getFaces({ shape }).length;
37
37
  const edges = occt.shapes.edge.getEdges({ shape }).length;
38
38
  const volume = occt.shapes.solid.getSolidsVolumes({ shapes: solids }).reduce((sum, v) => sum + v, 0);
39
- const bbox = occt.operations.boundingBoxOfShape({ shape });
39
+ const bbox = occt.analysis.measure.tightBoundingBox({ shape });
40
40
  const glb = occt.io.convertStepToGltf({ stepData: text, meshPrecision: options.meshPrecision, meshAngle: 0.5, meshRelative: true, internalVerticesMode: false, controlSurfaceDeflection: false });
41
- const stl = options.stl ? occt.io.saveShapeStl({ shape, fileName: file, precision: options.stlPrecision, adjustYtoZ: true, tryDownload: false, binary: false }) : null;
41
+ const stl = options.stl ? asciiStl(occt.io.saveShapeStl({ shape, fileName: file, precision: options.stlPrecision, adjustYtoZ: true, tryDownload: false, binary: false })) : null;
42
42
  return {
43
43
  glb,
44
44
  stl,
@@ -60,6 +60,11 @@ export function isGlb(bytes: Uint8Array): boolean {
60
60
  return bytes.byteLength > 12 && String.fromCharCode(...bytes.subarray(0, 4)) === GLB_MAGIC;
61
61
  }
62
62
 
63
+ function asciiStl(stl: string | Uint8Array): string {
64
+ if (typeof stl !== "string") throw new Error("the kernel wrote a binary STL where an ASCII one was asked for");
65
+ return stl;
66
+ }
67
+
63
68
  function round(value: number): number {
64
69
  return Math.round(value * 1000) / 1000;
65
70
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitbybit-api-hono-rest-threejs",
3
- "version": "1.4.0",
3
+ "version": "1.5.0-rc.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitbybit-api-hono-sdk-threejs",
3
- "version": "1.4.0",
3
+ "version": "1.5.0-rc.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "hono": "^4.7.0",
15
- "@bitbybit-dev/cad-cloud-sdk": "1.4.0"
15
+ "@bitbybit-dev/cad-cloud-sdk": "1.5.0-rc.0"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@cloudflare/workers-types": "^5.20260903.1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitbybit-api-nodejs-rest-threejs",
3
- "version": "1.4.0",
3
+ "version": "1.5.0-rc.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitbybit-api-nodejs-sdk-threejs",
3
- "version": "1.4.0",
3
+ "version": "1.5.0-rc.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "express": "^5.1.0",
16
16
  "multer": "^2.3.0",
17
- "@bitbybit-dev/cad-cloud-sdk": "1.4.0"
17
+ "@bitbybit-dev/cad-cloud-sdk": "1.5.0-rc.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@eslint/js": "10.0.1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitbybit-example-frontend",
3
- "version": "1.4.0",
3
+ "version": "1.5.0-rc.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -2,7 +2,7 @@
2
2
 
3
3
  - `src/model.ts` is the geometry. `buildModel(occt, params)` builds the OCCT shape from `ModelParams` and returns it. It knows nothing about rendering, and every kernel call is awaited, so the same function runs in the browser (through the OCCT worker, whose calls return promises) and in Node (in-process, whose calls return values). Put new geometry here, and new parameters in `ModelParams` with a default in `defaultParams`.
4
4
  - `src/main.ts` is the wiring: it starts the Babylon.js scene, initialises Bitbybit, calls `buildModel` and draws the result. The Manifold and JSCAD demonstrations live here as well. Keep geometry out of this file.
5
- - `scripts/smoke.ts` loads the OCCT kernel in Node, runs `buildModel` with `defaultParams` and prints one JSON line with the field names `template`, `params`, `valid`, `faces`, `edges`, `volume`, `area` and `bbox`. It exits 1 when the shape is not a valid solid or has no volume. Add an assertion here when a change to the model has a fact worth pinning, such as a face count or a bounding box.
5
+ - `scripts/smoke.ts` loads the OCCT kernel in Node, runs `buildModel` with `defaultParams` and prints one JSON line with the field names `template`, `params`, `valid`, `faces`, `edges`, `volume`, `area` and `bbox`, the box that just holds the exact geometry (`analysis.measure.tightBoundingBox`). It exits 1 when `shapeFix.isValid` finds the shape malformed or it has no volume; `debugInfo`'s own `valid` only says the shape is not empty. Add an assertion here when a change to the model has a fact worth pinning, such as a face count or a bounding box.
6
6
 
7
7
  Commands:
8
8
 
@@ -12,10 +12,10 @@
12
12
  "lint": "eslint . --max-warnings 0"
13
13
  },
14
14
  "dependencies": {
15
- "@bitbybit-dev/babylonjs": "1.4.0"
15
+ "@bitbybit-dev/babylonjs": "1.5.0-rc.0"
16
16
  },
17
17
  "devDependencies": {
18
- "@bitbybit-dev/occt": "1.4.0",
18
+ "@bitbybit-dev/occt": "1.5.0-rc.0",
19
19
  "@eslint/js": "10.0.1",
20
20
  "@types/node": "22.20.1",
21
21
  "eslint": "10.10.0",
@@ -18,13 +18,14 @@ const occt = inProcess(new OCCTService(occ, new OccHelper(new VectorHelperServic
18
18
 
19
19
  const shape = await buildModel(occt, defaultParams);
20
20
  const info = await occt.shapes.solid.debugInfo({ shape });
21
- const bbox = await occt.operations.boundingBoxOfShape({ shape });
21
+ const valid = await occt.shapeFix.isValid({ shape });
22
+ const bbox = await occt.analysis.measure.tightBoundingBox({ shape });
22
23
  const round = (n: number): number => Math.round(n * 1000) / 1000;
23
24
 
24
25
  console.log(JSON.stringify({
25
26
  template: "vite-babylonjs",
26
27
  params: defaultParams,
27
- valid: info.valid,
28
+ valid,
28
29
  faces: info.nbFaces,
29
30
  edges: info.nbEdges,
30
31
  volume: round(info.volume),
@@ -33,7 +34,7 @@ console.log(JSON.stringify({
33
34
  }));
34
35
 
35
36
  const problems: string[] = [];
36
- if (!info.valid) problems.push("the model is not a valid solid");
37
+ if (!valid) problems.push("the model is not a valid solid");
37
38
  if (!(info.volume > 0)) problems.push("the model has no volume");
38
39
  if (problems.length) {
39
40
  console.error(`smoke: ${problems.join("; ")}`);
@@ -2,7 +2,7 @@
2
2
 
3
3
  - `src/model.ts` is the geometry. `buildModel(occt, params)` builds the OCCT shape from `ModelParams` and returns it. It knows nothing about rendering, and every kernel call is awaited, so the same function runs in the browser (through the OCCT worker, whose calls return promises) and in Node (in-process, whose calls return values). Put new geometry here, and new parameters in `ModelParams` with a default in `defaultParams`.
4
4
  - `src/main.ts` is the wiring: it starts the PlayCanvas scene, initialises Bitbybit, calls `buildModel` and draws the result. The Manifold and JSCAD demonstrations live here as well. Keep geometry out of this file.
5
- - `scripts/smoke.ts` loads the OCCT kernel in Node, runs `buildModel` with `defaultParams` and prints one JSON line with the field names `template`, `params`, `valid`, `faces`, `edges`, `volume`, `area` and `bbox`. It exits 1 when the shape is not a valid solid or has no volume. Add an assertion here when a change to the model has a fact worth pinning, such as a face count or a bounding box.
5
+ - `scripts/smoke.ts` loads the OCCT kernel in Node, runs `buildModel` with `defaultParams` and prints one JSON line with the field names `template`, `params`, `valid`, `faces`, `edges`, `volume`, `area` and `bbox`, the box that just holds the exact geometry (`analysis.measure.tightBoundingBox`). It exits 1 when `shapeFix.isValid` finds the shape malformed or it has no volume; `debugInfo`'s own `valid` only says the shape is not empty. Add an assertion here when a change to the model has a fact worth pinning, such as a face count or a bounding box.
6
6
 
7
7
  Commands:
8
8
 
@@ -12,11 +12,11 @@
12
12
  "lint": "eslint . --max-warnings 0"
13
13
  },
14
14
  "dependencies": {
15
- "@bitbybit-dev/playcanvas": "1.4.0",
15
+ "@bitbybit-dev/playcanvas": "1.5.0-rc.0",
16
16
  "playcanvas": "2.22.2"
17
17
  },
18
18
  "devDependencies": {
19
- "@bitbybit-dev/occt": "1.4.0",
19
+ "@bitbybit-dev/occt": "1.5.0-rc.0",
20
20
  "@eslint/js": "10.0.1",
21
21
  "@types/node": "22.20.1",
22
22
  "eslint": "10.10.0",