@bitbybit-dev/create-app 1.3.2 → 1.4.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 (190) hide show
  1. package/README.md +47 -124
  2. package/dist/index.js +253 -21
  3. package/dist/index.js.map +1 -1
  4. package/dist/scaffold.d.ts +30 -0
  5. package/dist/scaffold.d.ts.map +1 -0
  6. package/dist/scaffold.js +107 -0
  7. package/dist/scaffold.js.map +1 -0
  8. package/package.json +4 -3
  9. package/src/index.test.ts +309 -8
  10. package/src/index.ts +285 -24
  11. package/src/scaffold.test.ts +177 -0
  12. package/src/scaffold.ts +99 -0
  13. package/templates/_agent/AGENTS.md +39 -0
  14. package/templates/_agent/CLAUDE.md +1 -0
  15. package/templates/_agent/_dot-cursor/mcp.json +5 -0
  16. package/templates/_agent/_dot-gitignore +7 -0
  17. package/templates/_agent/_dot-mcp.json +5 -0
  18. package/templates/_agent/_dot-vscode/mcp.json +5 -0
  19. package/templates/apps/drone-assembly/AGENTS.section.md +20 -0
  20. package/templates/apps/drone-assembly/README.md +35 -0
  21. package/templates/apps/drone-assembly/eslint.config.js +47 -0
  22. package/templates/apps/drone-assembly/index.html +17 -0
  23. package/templates/apps/drone-assembly/package.json +31 -0
  24. package/templates/apps/drone-assembly/public/favicon.ico +0 -0
  25. package/templates/apps/drone-assembly/public/logo.png +0 -0
  26. package/templates/apps/drone-assembly/scripts/smoke.ts +172 -0
  27. package/templates/apps/drone-assembly/src/assembly.ts +99 -0
  28. package/templates/apps/drone-assembly/src/exports.ts +10 -0
  29. package/templates/apps/drone-assembly/src/kernel.ts +14 -0
  30. package/templates/apps/drone-assembly/src/main.ts +298 -0
  31. package/templates/apps/drone-assembly/src/materials.ts +58 -0
  32. package/templates/apps/drone-assembly/src/model.ts +280 -0
  33. package/templates/apps/drone-assembly/src/parts.ts +343 -0
  34. package/templates/apps/drone-assembly/src/style.css +219 -0
  35. package/templates/apps/drone-assembly/src/ui.ts +180 -0
  36. package/templates/apps/drone-assembly/src/vite-env.d.ts +1 -0
  37. package/templates/apps/drone-assembly/tsconfig.json +29 -0
  38. package/templates/apps/laser-cut-box/AGENTS.section.md +17 -0
  39. package/templates/apps/laser-cut-box/README.md +34 -0
  40. package/templates/apps/laser-cut-box/eslint.config.js +47 -0
  41. package/templates/apps/laser-cut-box/index.html +17 -0
  42. package/templates/apps/laser-cut-box/package.json +30 -0
  43. package/templates/apps/laser-cut-box/public/favicon.ico +0 -0
  44. package/templates/apps/laser-cut-box/public/logo.png +0 -0
  45. package/templates/apps/laser-cut-box/scripts/smoke.ts +106 -0
  46. package/templates/apps/laser-cut-box/src/exports.ts +28 -0
  47. package/templates/apps/laser-cut-box/src/main.ts +176 -0
  48. package/templates/apps/laser-cut-box/src/model.ts +92 -0
  49. package/templates/apps/laser-cut-box/src/panels.ts +229 -0
  50. package/templates/apps/laser-cut-box/src/style.css +223 -0
  51. package/templates/apps/laser-cut-box/src/ui.ts +136 -0
  52. package/templates/apps/laser-cut-box/src/vite-env.d.ts +1 -0
  53. package/templates/apps/laser-cut-box/tsconfig.json +29 -0
  54. package/templates/apps/product-configurator/AGENTS.section.md +19 -0
  55. package/templates/apps/product-configurator/README.md +33 -0
  56. package/templates/apps/product-configurator/eslint.config.js +47 -0
  57. package/templates/apps/product-configurator/index.html +17 -0
  58. package/templates/apps/product-configurator/package.json +30 -0
  59. package/templates/apps/product-configurator/public/favicon.ico +0 -0
  60. package/templates/apps/product-configurator/public/logo.png +0 -0
  61. package/templates/apps/product-configurator/scripts/smoke.ts +69 -0
  62. package/templates/apps/product-configurator/src/catalog.ts +56 -0
  63. package/templates/apps/product-configurator/src/exports.ts +19 -0
  64. package/templates/apps/product-configurator/src/main.ts +134 -0
  65. package/templates/apps/product-configurator/src/model.ts +153 -0
  66. package/templates/apps/product-configurator/src/style.css +177 -0
  67. package/templates/apps/product-configurator/src/ui.ts +150 -0
  68. package/templates/apps/product-configurator/src/vite-env.d.ts +1 -0
  69. package/templates/apps/product-configurator/tsconfig.json +29 -0
  70. package/templates/apps/sheet-metal-unfold/AGENTS.section.md +26 -0
  71. package/templates/apps/sheet-metal-unfold/README.md +41 -0
  72. package/templates/apps/sheet-metal-unfold/backend/_dot-env.example +5 -0
  73. package/templates/apps/sheet-metal-unfold/backend/eslint.config.js +47 -0
  74. package/templates/apps/sheet-metal-unfold/backend/package.json +28 -0
  75. package/templates/apps/sheet-metal-unfold/backend/scripts/smoke.ts +52 -0
  76. package/templates/apps/sheet-metal-unfold/backend/src/app.ts +65 -0
  77. package/templates/apps/sheet-metal-unfold/backend/src/cloud.ts +42 -0
  78. package/templates/apps/sheet-metal-unfold/backend/src/index.ts +13 -0
  79. package/templates/apps/sheet-metal-unfold/backend/tsconfig.build.json +9 -0
  80. package/templates/apps/sheet-metal-unfold/backend/tsconfig.json +27 -0
  81. package/templates/apps/sheet-metal-unfold/frontend/eslint.config.js +47 -0
  82. package/templates/apps/sheet-metal-unfold/frontend/index.html +17 -0
  83. package/templates/apps/sheet-metal-unfold/frontend/package.json +30 -0
  84. package/templates/apps/sheet-metal-unfold/frontend/public/favicon.ico +0 -0
  85. package/templates/apps/sheet-metal-unfold/frontend/public/logo.png +0 -0
  86. package/templates/apps/sheet-metal-unfold/frontend/scripts/smoke.ts +84 -0
  87. package/templates/apps/sheet-metal-unfold/frontend/src/cloud-access.ts +37 -0
  88. package/templates/apps/sheet-metal-unfold/frontend/src/exports.ts +10 -0
  89. package/templates/apps/sheet-metal-unfold/frontend/src/flat.ts +71 -0
  90. package/templates/apps/sheet-metal-unfold/frontend/src/main.ts +193 -0
  91. package/templates/apps/sheet-metal-unfold/frontend/src/model.ts +166 -0
  92. package/templates/apps/sheet-metal-unfold/frontend/src/style.css +291 -0
  93. package/templates/apps/sheet-metal-unfold/frontend/src/ui.ts +150 -0
  94. package/templates/apps/sheet-metal-unfold/frontend/src/vite-env.d.ts +1 -0
  95. package/templates/apps/sheet-metal-unfold/frontend/tsconfig.json +29 -0
  96. package/templates/apps/sheet-metal-unfold/frontend/vite.config.ts +9 -0
  97. package/templates/apps/sheet-metal-unfold/package.json +18 -0
  98. package/templates/apps/step-to-gltf-cli/AGENTS.section.md +20 -0
  99. package/templates/apps/step-to-gltf-cli/README.md +34 -0
  100. package/templates/apps/step-to-gltf-cli/eslint.config.js +47 -0
  101. package/templates/apps/step-to-gltf-cli/package.json +26 -0
  102. package/templates/apps/step-to-gltf-cli/samples/bracket.step +2545 -0
  103. package/templates/apps/step-to-gltf-cli/scripts/smoke.ts +49 -0
  104. package/templates/apps/step-to-gltf-cli/src/cli.ts +106 -0
  105. package/templates/apps/step-to-gltf-cli/src/cloud.ts +34 -0
  106. package/templates/apps/step-to-gltf-cli/src/convert.ts +65 -0
  107. package/templates/apps/step-to-gltf-cli/src/kernel.ts +14 -0
  108. package/templates/apps/step-to-gltf-cli/tsconfig.json +27 -0
  109. package/templates/cloud/AGENTS.section.md +22 -0
  110. package/templates/cloud/backends/dotnet-rest/BitbybitClient.cs +22 -50
  111. package/templates/cloud/backends/dotnet-rest/Program.cs +1 -11
  112. package/templates/cloud/backends/dotnet-rest/dotnet-rest.csproj +4 -1
  113. package/templates/cloud/backends/hono-rest/eslint.config.js +47 -0
  114. package/templates/cloud/backends/hono-rest/package.json +11 -4
  115. package/templates/cloud/backends/hono-rest/src/bitbybit-client.ts +34 -45
  116. package/templates/cloud/backends/hono-rest/src/index.ts +1 -11
  117. package/templates/cloud/backends/hono-rest/tsconfig.json +19 -8
  118. package/templates/cloud/backends/hono-sdk/eslint.config.js +47 -0
  119. package/templates/cloud/backends/hono-sdk/package.json +12 -5
  120. package/templates/cloud/backends/hono-sdk/src/bitbybit-client.ts +6 -37
  121. package/templates/cloud/backends/hono-sdk/src/index.ts +1 -12
  122. package/templates/cloud/backends/hono-sdk/tsconfig.json +19 -8
  123. package/templates/cloud/backends/nodejs-rest/eslint.config.js +47 -0
  124. package/templates/cloud/backends/nodejs-rest/package.json +12 -5
  125. package/templates/cloud/backends/nodejs-rest/src/bitbybit-client.ts +6 -35
  126. package/templates/cloud/backends/nodejs-rest/src/index.ts +6 -16
  127. package/templates/cloud/backends/nodejs-rest/tsconfig.build.json +9 -0
  128. package/templates/cloud/backends/nodejs-rest/tsconfig.json +17 -7
  129. package/templates/cloud/backends/nodejs-sdk/eslint.config.js +47 -0
  130. package/templates/cloud/backends/nodejs-sdk/package.json +14 -7
  131. package/templates/cloud/backends/nodejs-sdk/src/bitbybit-client.ts +8 -33
  132. package/templates/cloud/backends/nodejs-sdk/src/index.ts +5 -16
  133. package/templates/cloud/backends/nodejs-sdk/tsconfig.build.json +9 -0
  134. package/templates/cloud/backends/nodejs-sdk/tsconfig.json +19 -9
  135. package/templates/cloud/frontend/eslint.config.js +50 -0
  136. package/templates/cloud/frontend/index.html +3 -1
  137. package/templates/cloud/frontend/package.json +13 -4
  138. package/templates/cloud/frontend/public/favicon.ico +0 -0
  139. package/templates/cloud/frontend/public/logo.png +0 -0
  140. package/templates/cloud/frontend/src/App.tsx +11 -9
  141. package/templates/cloud/frontend/src/api.ts +31 -0
  142. package/templates/cloud/frontend/src/components/ApiKeyWarning.tsx +28 -25
  143. package/templates/cloud/frontend/src/components/Header.tsx +4 -2
  144. package/templates/cloud/frontend/src/components/Tabs.tsx +4 -3
  145. package/templates/cloud/frontend/src/components/Viewer.tsx +57 -77
  146. package/templates/cloud/frontend/src/main.tsx +6 -1
  147. package/templates/cloud/frontend/src/panels/ModelsPanel.tsx +65 -73
  148. package/templates/cloud/frontend/src/panels/PipelinesPanel.tsx +82 -83
  149. package/templates/cloud/frontend/src/vite-env.d.ts +1 -0
  150. package/templates/cloud/frontend/tsconfig.json +19 -7
  151. package/templates/vite/babylonjs/typescript/AGENTS.section.md +13 -0
  152. package/templates/vite/babylonjs/typescript/eslint.config.js +47 -0
  153. package/templates/vite/babylonjs/typescript/index.html +4 -2
  154. package/templates/vite/babylonjs/typescript/package.json +14 -4
  155. package/templates/vite/babylonjs/typescript/public/favicon.ico +0 -0
  156. package/templates/vite/babylonjs/typescript/public/logo.png +0 -0
  157. package/templates/vite/babylonjs/typescript/scripts/smoke.ts +41 -0
  158. package/templates/vite/babylonjs/typescript/src/main.ts +8 -17
  159. package/templates/vite/babylonjs/typescript/src/model.ts +24 -0
  160. package/templates/vite/babylonjs/typescript/tsconfig.json +16 -12
  161. package/templates/vite/playcanvas/typescript/AGENTS.section.md +13 -0
  162. package/templates/vite/playcanvas/typescript/eslint.config.js +47 -0
  163. package/templates/vite/playcanvas/typescript/index.html +4 -2
  164. package/templates/vite/playcanvas/typescript/package.json +14 -4
  165. package/templates/vite/playcanvas/typescript/public/favicon.ico +0 -0
  166. package/templates/vite/playcanvas/typescript/public/logo.png +0 -0
  167. package/templates/vite/playcanvas/typescript/scripts/smoke.ts +41 -0
  168. package/templates/vite/playcanvas/typescript/src/main.ts +11 -22
  169. package/templates/vite/playcanvas/typescript/src/model.ts +24 -0
  170. package/templates/vite/playcanvas/typescript/tsconfig.json +16 -12
  171. package/templates/vite/threejs/typescript/AGENTS.section.md +13 -0
  172. package/templates/vite/threejs/typescript/eslint.config.js +47 -0
  173. package/templates/vite/threejs/typescript/index.html +4 -2
  174. package/templates/vite/threejs/typescript/package.json +16 -6
  175. package/templates/vite/threejs/typescript/public/favicon.ico +0 -0
  176. package/templates/vite/threejs/typescript/public/logo.png +0 -0
  177. package/templates/vite/threejs/typescript/scripts/smoke.ts +41 -0
  178. package/templates/vite/threejs/typescript/src/main.ts +11 -22
  179. package/templates/vite/threejs/typescript/src/model.ts +24 -0
  180. package/templates/vite/threejs/typescript/tsconfig.json +16 -12
  181. package/templates/vite/babylonjs/typescript/public/vite.svg +0 -1
  182. package/templates/vite/playcanvas/typescript/public/vite.svg +0 -1
  183. package/templates/vite/threejs/typescript/public/vite.svg +0 -1
  184. /package/templates/cloud/backends/dotnet-rest/{_gitignore → _dot-gitignore} +0 -0
  185. /package/templates/cloud/backends/hono-rest/{_gitignore → _dot-gitignore} +0 -0
  186. /package/templates/cloud/backends/hono-sdk/{_gitignore → _dot-gitignore} +0 -0
  187. /package/templates/cloud/backends/nodejs-rest/{.env.example → _dot-env.example} +0 -0
  188. /package/templates/cloud/backends/nodejs-rest/{_gitignore → _dot-gitignore} +0 -0
  189. /package/templates/cloud/backends/nodejs-sdk/{.env.example → _dot-env.example} +0 -0
  190. /package/templates/cloud/backends/nodejs-sdk/{_gitignore → _dot-gitignore} +0 -0
@@ -0,0 +1,343 @@
1
+ import type { Occt, Point3, Shape, Wire } from "./kernel";
2
+
3
+ type Trihedron = Parameters<Occt["operations"]["pipeWireCylindrical"]>[0]["trihedronEnum"];
4
+
5
+ const TRIHEDRON = { constantNormal: "isConstantNormal" as Trihedron, correctedFrenet: "isCorrectedFrenet" as Trihedron };
6
+
7
+ export const FRAME = {
8
+ plate: { length: 150, width: 96, thickness: 3, corner: 26, openingRadius: 6, hex: { width: 56, depth: 20, across: 5, rows: 2, scale: 0.8, at: 60 } },
9
+ gap: 10,
10
+ armRoot: 28,
11
+ arm: { rootWidth: 26, tipWidth: 16, height: 10, padRadius: 15, hexFrom: 62, hexPitch: 24, hexWall: 3.5, hexRound: 1.2 },
12
+ hatch: { length: 50, width: 34, corner: 9, thickness: 1.4 },
13
+ honeycomb: { grow: 1.02, rows: 3, acrossLong: 8, acrossShort: 5, scale: 0.8, round: 0.35 },
14
+ motor: { baseRadius: 13, bellRadius: 14, wall: 1.6, shaftRadius: 2.5, height: 28, boltCircle: 8, slots: 8 },
15
+ propeller: { hubRadius: 8, hubBelow: 5, hubAbove: 7, junctionFillet: 0.6 },
16
+ canopy: { height: 32, forward: 4, hatchForward: 10 },
17
+ standoff: { radius: 3.2, ring: 40 },
18
+ leg: { drop: 46, reach: 26, tube: 4, ring: 52, boss: 5.5, flange: 20, boltOffset: 7.5, entry: 12, bends: [12, 6] as [number, number] },
19
+ damper: { cap: 6.5, capHeight: 4, barrel: 5.5, collar: 6.2, rod: 2.2, length: 30 },
20
+ spring: { radius: 4.2, wire: 0.9, pitch: 2.8, height: 12.5, bottom: 29.8 },
21
+ foot: { height: 10, rings: [[0, 3.2], [-2, 7], [-5, 9.5], [-8, 9], [-10, 7]] as [number, number][] },
22
+ bolt: { headRadius: 2.75, headHeight: 3, shankRadius: 1.5 },
23
+ emblem: { width: 26, thickness: 1, inset: 0.96 },
24
+ gps: { mastRadius: 2.5, mastHeight: 34, puckRadius: 11, puckHeight: 6 },
25
+ antenna: { radius: 1.5, length: 42 },
26
+ } as const;
27
+
28
+ export const PLATE_TOP = FRAME.plate.thickness;
29
+ export const ARM_TOP = PLATE_TOP + FRAME.gap;
30
+ export const TOP_PLATE_TOP = ARM_TOP + FRAME.plate.thickness;
31
+ export const CANOPY_TOP = TOP_PLATE_TOP + FRAME.canopy.height;
32
+ export const MOTOR_TOP = ARM_TOP + FRAME.motor.height;
33
+ export const GROUND_LIFT = FRAME.leg.drop + FRAME.damper.length + FRAME.foot.height;
34
+ export const HATCH_TOP = CANOPY_TOP + FRAME.hatch.thickness;
35
+ export const armRootWidth = (arms: number): number => Math.min(FRAME.arm.rootWidth, Math.round(2 * FRAME.armRoot * Math.sin(Math.PI / arms) * 0.9));
36
+
37
+ async function roundedRect(occt: Occt, width: number, length: number, radius: number, center: Point3, direction: Point3 = [0, 1, 0]): Promise<Wire> {
38
+ const rectangle = await occt.shapes.wire.createRectangleWire({ width, length, center, direction });
39
+ return occt.fillets.fillet2d({ shape: rectangle, radius });
40
+ }
41
+
42
+ async function prism(occt: Occt, outline: Wire, direction: Point3): Promise<Shape> {
43
+ const face = await occt.shapes.face.createFaceFromWire({ shape: outline, planar: true });
44
+ return occt.operations.extrude({ shape: face, direction });
45
+ }
46
+
47
+ function winding(points: number[][]): number {
48
+ let sum = 0;
49
+ for (let i = 0; i < points.length; i++) {
50
+ const [ax = 0, , az = 0] = points[i] ?? [];
51
+ const [bx = 0, , bz = 0] = points[(i + 1) % points.length] ?? [];
52
+ sum += ax * bz - bx * az;
53
+ }
54
+ return sum;
55
+ }
56
+
57
+ export async function faceWithHoles(occt: Occt, outline: Wire, holes: Wire[]): Promise<Shape> {
58
+ if (holes.length === 0) return occt.shapes.face.createFaceFromWire({ shape: outline, planar: true });
59
+ const all = await occt.shapes.compound.makeCompound({ shapes: [outline, ...holes] });
60
+ const runs = await occt.shapes.wire.wiresToPoints({ shape: all, angularDeflection: 0.1, curvatureDeflection: 0.1, minimumOfPoints: 2, uTolerance: 1e-9, minimumLength: 1e-7 });
61
+ const [outlineRun = [], ...holeRuns] = runs;
62
+ const outer = Math.sign(winding(outlineRun));
63
+ const turned: Wire[] = [];
64
+ for (const [i, hole] of holes.entries()) {
65
+ turned.push(Math.sign(winding(holeRuns[i] ?? [])) === outer ? await occt.shapes.wire.reversedWire({ shape: hole }) : hole);
66
+ }
67
+ return occt.shapes.face.createFaceFromWires({ shapes: [outline, ...turned], planar: true });
68
+ }
69
+
70
+ async function revolved(occt: Occt, profile: Point3[]): Promise<Shape> {
71
+ const wire = await occt.shapes.wire.createPolygonWire({ points: profile });
72
+ const face = await occt.shapes.face.createFaceFromWire({ shape: wire, planar: true });
73
+ return occt.operations.revolve({ shape: face, angle: 360, direction: [0, 1, 0], copy: false });
74
+ }
75
+
76
+ export async function plate(occt: Occt): Promise<Shape> {
77
+ const p = FRAME.plate;
78
+ const outline = await roundedRect(occt, p.width, p.length, p.corner, [0, 0, 0]);
79
+ const openings: Wire[] = [];
80
+ for (const angle of [45, 135, 225, 315]) {
81
+ const a = (angle * Math.PI) / 180;
82
+ openings.push(await occt.shapes.wire.createCircleWire({ radius: p.openingRadius, center: [FRAME.leg.ring * Math.cos(a), 0, -FRAME.leg.ring * Math.sin(a)], direction: [0, 1, 0] }));
83
+ }
84
+ const cells = await occt.shapes.wire.hexagonsInGrid({ width: p.hex.width, height: p.hex.depth, nrHexagonsInWidth: p.hex.across, nrHexagonsInHeight: p.hex.rows, flatTop: true, scalePatternWidth: [p.hex.scale], scalePatternHeight: [p.hex.scale] });
85
+ const zones: Wire[] = [];
86
+ for (const z of [p.hex.at, -p.hex.at]) {
87
+ for (const cell of cells) zones.push(await occt.transforms.translate({ shape: cell, translation: [0, 0, z] }));
88
+ }
89
+ const face = await faceWithHoles(occt, outline, [...openings, ...zones]);
90
+ return occt.operations.extrude({ shape: face, direction: [0, p.thickness, 0] });
91
+ }
92
+
93
+ export async function honeycomb(occt: Occt): Promise<Shape> {
94
+ const h = FRAME.honeycomb;
95
+ const shell = await canopy(occt);
96
+ const centre = await occt.operations.boundingBoxCenterOfShape({ shape: shell });
97
+ const grown = await occt.transforms.scale3d({ shape: shell, scale: [h.grow, h.grow, h.grow], center: [centre[0], 0, centre[2]] });
98
+ const faces = await occt.shapes.face.getFaces({ shape: grown });
99
+ const areas = await occt.shapes.face.getFacesAreas({ shapes: faces });
100
+ const largest = Math.max(...areas.slice(0, -2));
101
+ const wires: Wire[] = [];
102
+ for (const [i, face] of faces.entries()) {
103
+ const normal = await occt.shapes.face.normalOnUV({ shape: face, paramU: 0.5, paramV: 0.5 });
104
+ if (Math.abs(normal[1]) > 0.9) continue;
105
+ const across = (areas[i] ?? 0) > largest * 0.7 ? h.acrossLong : h.acrossShort;
106
+ wires.push(...await occt.shapes.face.subdivideToHexagonWires({ shape: face, nrHexagonsU: across, nrHexagonsV: h.rows, flatU: false, scalePatternU: [h.scale], scalePatternV: [h.scale], filletPattern: [h.round], offsetFromBorderU: 0.05, offsetFromBorderV: 0.08 }));
107
+ }
108
+ return occt.shapes.compound.makeCompound({ shapes: wires });
109
+ }
110
+
111
+ export async function canopy(occt: Occt): Promise<Shape> {
112
+ const c = FRAME.canopy;
113
+ const sections: [number, number, number, number, number][] = [
114
+ [0, 140, 90, 26, c.forward],
115
+ [12, 132, 84, 24, c.forward + 2],
116
+ [22, 110, 70, 19, c.forward + 5],
117
+ [29, 76, 48, 13, c.hatchForward],
118
+ [c.height, 52, 36, 10, c.hatchForward],
119
+ ];
120
+ const wires: Wire[] = [];
121
+ for (const [y, length, width, radius, forward] of sections) wires.push(await roundedRect(occt, width, length, radius, [0, y, forward]));
122
+ return occt.operations.loft({ shapes: wires, makeSolid: true });
123
+ }
124
+
125
+ export function armCutouts(armLength: number, rootWidth: number): { x: number; radius: number }[] {
126
+ const a = FRAME.arm;
127
+ const tipX = armLength - a.padRadius + 3;
128
+ const cutouts: { x: number; radius: number }[] = [];
129
+ for (let x = a.hexFrom; x < armLength - a.padRadius - 19; x += a.hexPitch) {
130
+ const width = rootWidth + (a.tipWidth - rootWidth) * ((x - FRAME.armRoot) / (tipX - FRAME.armRoot));
131
+ cutouts.push({ x, radius: Math.max(width / 2 - a.hexWall, 2.5) });
132
+ }
133
+ return cutouts;
134
+ }
135
+
136
+ export async function arm(occt: Occt, armLength: number, rootWidth: number): Promise<Shape> {
137
+ const a = FRAME.arm;
138
+ const tipX = armLength - a.padRadius + 3;
139
+ const plan = await occt.shapes.wire.createPolygonWire({ points: [[FRAME.armRoot, 0, -rootWidth / 2], [tipX, 0, -a.tipWidth / 2], [tipX, 0, a.tipWidth / 2], [FRAME.armRoot, 0, rootWidth / 2]] });
140
+ const outline = await occt.fillets.fillet2d({ shape: plan, radius: 4 });
141
+ const cutouts: Wire[] = [];
142
+ for (const cutout of armCutouts(armLength, rootWidth)) {
143
+ const hexagon = await occt.shapes.wire.createNGonWire({ nrCorners: 6, radius: cutout.radius, center: [cutout.x, 0, 0], direction: [0, 1, 0] });
144
+ cutouts.push(await occt.fillets.fillet2d({ shape: hexagon, radius: a.hexRound }));
145
+ }
146
+ const face = await faceWithHoles(occt, outline, cutouts);
147
+ const slab = await occt.operations.extrude({ shape: face, direction: [0, a.height, 0] });
148
+ const lifted = await occt.transforms.translate({ shape: slab, translation: [0, PLATE_TOP, 0] });
149
+ const pad = await occt.shapes.solid.createCylinder({ radius: a.padRadius, height: a.height, center: [armLength, PLATE_TOP, 0], direction: [0, 1, 0] });
150
+ return occt.booleans.union({ shapes: [lifted, pad], keepEdges: false });
151
+ }
152
+
153
+ export async function motor(occt: Occt): Promise<Shape> {
154
+ const m = FRAME.motor;
155
+ const bellTop = 20;
156
+ const body = await revolved(occt, [
157
+ [0, 0, 0], [m.baseRadius, 0, 0], [m.baseRadius, 3, 0], [8, 3, 0], [8, 6, 0],
158
+ [m.bellRadius, 6, 0], [m.bellRadius, bellTop - 1, 0], [m.bellRadius - 1.2, bellTop, 0], [6, bellTop, 0], [6, bellTop + 2, 0],
159
+ [m.shaftRadius, bellTop + 2, 0], [m.shaftRadius, m.height, 0], [0, m.height, 0],
160
+ ]);
161
+ const cavity = await occt.shapes.solid.createCylinder({ radius: m.bellRadius - m.wall, height: 12, center: [0, 6, 0], direction: [0, 1, 0] });
162
+ const bearingTube = await occt.shapes.solid.createCylinder({ radius: 4, height: 14, center: [0, 5, 0], direction: [0, 1, 0] });
163
+ const ring = await occt.booleans.difference({ shape: cavity, shapes: [bearingTube], keepEdges: false });
164
+ const tools: Shape[] = [ring];
165
+ for (let i = 0; i < m.slots; i++) {
166
+ const slot = await occt.shapes.solid.createBox({ width: 2.2, length: 8, height: 9, center: [0, 13, m.bellRadius - 2] });
167
+ tools.push(await occt.transforms.rotate({ shape: slot, axis: [0, 1, 0], angle: (360 / m.slots) * i }));
168
+ }
169
+ return occt.booleans.difference({ shape: body, shapes: tools, keepEdges: false });
170
+ }
171
+
172
+ export async function stator(occt: Occt): Promise<Shape> {
173
+ return occt.shapes.solid.createCylinder({ radius: FRAME.motor.bellRadius - FRAME.motor.wall - 0.6, height: 11, center: [0, 6.5, 0], direction: [0, 1, 0] });
174
+ }
175
+
176
+ export async function propeller(occt: Occt, diameter: number): Promise<Shape> {
177
+ const p = FRAME.propeller;
178
+ const handed = 1;
179
+ const root = p.hubRadius - 2;
180
+ const span = diameter / 2 - root;
181
+ const stations: [number, number, number, number, number][] = [
182
+ [0, 12, 3.2, 38, 0],
183
+ [0.25, 17, 2.4, 24, 0.6],
184
+ [0.5, 15.5, 1.8, 16, 1.8],
185
+ [0.78, 11, 1.4, 11, 3.6],
186
+ [1, 4.5, 1, 8, 6],
187
+ ];
188
+ const sections: Wire[] = [];
189
+ for (const [t, chord, thickness, twist, sweep] of stations) {
190
+ const r = root + span * t;
191
+ const ellipse = await occt.shapes.wire.createEllipseWire({ center: [r, 0, sweep], direction: [1, 0, 0], radiusMinor: thickness / 2, radiusMajor: chord / 2 });
192
+ sections.push(await occt.transforms.rotateAroundCenter({ shape: ellipse, angle: handed * twist, center: [r, 0, sweep], axis: [1, 0, 0] }));
193
+ }
194
+ const blade = await occt.operations.loft({ shapes: sections, makeSolid: true });
195
+ const other = await occt.transforms.rotate({ shape: blade, axis: [0, 1, 0], angle: 180 });
196
+ const hub = await revolved(occt, [[0, -p.hubBelow, 0], [p.hubRadius, -p.hubBelow, 0], [p.hubRadius, p.hubAbove - 2.5, 0], [p.hubRadius - 1.5, p.hubAbove - 0.8, 0], [4.5, p.hubAbove, 0], [0, p.hubAbove, 0]]);
197
+ const fused = await occt.booleans.union({ shapes: [hub, blade, other], keepEdges: false });
198
+ const edges = await occt.shapes.edge.getEdges({ shape: fused });
199
+ const centers = await occt.shapes.edge.getEdgesCentersOfMass({ shapes: edges });
200
+ const junction = [];
201
+ for (const [i, edge] of edges.entries()) {
202
+ const c = centers[i];
203
+ if (c && Math.abs(Math.hypot(c[0], c[2]) - p.hubRadius) < 0.6 && !await occt.shapes.edge.isEdgeCircular({ shape: edge })) junction.push(edge);
204
+ }
205
+ if (junction.length === 0) return fused;
206
+ try {
207
+ return await occt.fillets.filletEdgesListOneRadius({ shape: fused, edges: junction, radius: p.junctionFillet });
208
+ } catch {
209
+ return fused;
210
+ }
211
+ }
212
+
213
+ export async function mirrored(occt: Occt, shape: Shape): Promise<Shape> {
214
+ return occt.transforms.mirrorAlongNormal({ shape, origin: [0, 0, 0], normal: [0, 0, 1] });
215
+ }
216
+
217
+ export async function bolt(occt: Occt, length: number): Promise<Shape> {
218
+ const b = FRAME.bolt;
219
+ const body = await revolved(occt, [
220
+ [0, -b.headHeight, 0], [b.headRadius - 0.4, -b.headHeight, 0], [b.headRadius, -b.headHeight + 0.4, 0], [b.headRadius, 0, 0],
221
+ [b.shankRadius, 0, 0], [b.shankRadius, length - 0.4, 0], [b.shankRadius - 0.4, length, 0], [0, length, 0],
222
+ ]);
223
+ const socketOutline = await occt.shapes.wire.createNGonWire({ nrCorners: 6, radius: 1.45, center: [0, -b.headHeight - 0.5, 0], direction: [0, 1, 0] });
224
+ const socket = await prism(occt, socketOutline, [0, 2.5, 0]);
225
+ return occt.booleans.difference({ shape: body, shapes: [socket], keepEdges: false });
226
+ }
227
+
228
+ export async function nut(occt: Occt): Promise<Shape> {
229
+ const height = 3.5;
230
+ const hexOutline = await occt.shapes.wire.createNGonWire({ nrCorners: 6, radius: 3.6, center: [0, 0, 0], direction: [0, 1, 0] });
231
+ const hex = await prism(occt, hexOutline, [0, height, 0]);
232
+ const silhouette = await revolved(occt, [[0, 0, 0], [2.9, 0, 0], [3.7, 0.7, 0], [3.7, height - 0.7, 0], [2.9, height, 0], [0, height, 0]]);
233
+ return occt.booleans.intersection({ shapes: [hex, silhouette], keepEdges: false });
234
+ }
235
+
236
+ export async function standoff(occt: Occt): Promise<Shape> {
237
+ return occt.shapes.solid.createCylinder({ radius: FRAME.standoff.radius, height: FRAME.gap, center: [0, 0, 0], direction: [0, 1, 0] });
238
+ }
239
+
240
+ export async function leg(occt: Occt): Promise<Shape> {
241
+ const l = FRAME.leg;
242
+ const path = await occt.shapes.wire.createPolylineWire({ points: [[0, 0, 0], [6, -18, 0], [l.reach, -l.drop + l.entry, 0], [l.reach, -l.drop - FRAME.damper.capHeight / 2, 0]] });
243
+ const rounded = await occt.fillets.fillet3DWire({ shape: path, radiusList: [...l.bends], indexes: [0, 1], direction: [0, 0, 1] });
244
+ const tube = await occt.operations.pipeWireCylindrical({ shape: rounded, radius: l.tube, makeSolid: true, trihedronEnum: TRIHEDRON.constantNormal, forceApproxC1: false });
245
+ const flange = await occt.shapes.solid.createBox({ width: l.flange, length: 12, height: 3, center: [0, -1.5, 0] });
246
+ const boss = await occt.shapes.solid.createCylinder({ radius: l.boss, height: 3 + FRAME.plate.thickness + 0.4, center: [0, -3, 0], direction: [0, 1, 0] });
247
+ return occt.booleans.union({ shapes: [tube, flange, boss], keepEdges: false });
248
+ }
249
+
250
+ export async function damper(occt: Occt): Promise<Shape> {
251
+ const d = FRAME.damper;
252
+ return revolved(occt, [
253
+ [0, 0, 0], [d.cap, 0, 0], [d.cap, -d.capHeight, 0], [d.barrel, -d.capHeight - 0.5, 0], [d.barrel, -14, 0], [d.collar, -14, 0], [d.collar, -16.5, 0],
254
+ [4, -16.5, 0], [4, -18, 0], [d.rod, -18, 0], [d.rod, -d.length, 0], [0, -d.length, 0],
255
+ ]);
256
+ }
257
+
258
+ export async function spring(occt: Occt): Promise<Shape> {
259
+ const s = FRAME.spring;
260
+ const helix = await occt.shapes.wire.createHelixWire({ radius: s.radius, pitch: s.pitch, height: s.height, center: [0, -s.bottom, 0], direction: [0, 1, 0], clockwise: false, tolerance: 1e-4 });
261
+ return occt.operations.pipeWireCylindrical({ shape: helix, radius: s.wire, makeSolid: true, trihedronEnum: TRIHEDRON.correctedFrenet, forceApproxC1: false });
262
+ }
263
+
264
+ export async function foot(occt: Occt): Promise<Shape> {
265
+ const rings: Wire[] = [];
266
+ for (const [y, radius] of FRAME.foot.rings) rings.push(await occt.shapes.wire.createCircleWire({ radius, center: [0, y, 0], direction: [0, 1, 0] }));
267
+ return occt.operations.loft({ shapes: rings, makeSolid: true });
268
+ }
269
+
270
+ export async function led(occt: Occt): Promise<Shape> {
271
+ const dome = await occt.shapes.solid.createSphere({ radius: 3, center: [0, 0, 0] });
272
+ const upper = await occt.shapes.solid.createBox({ width: 8, length: 8, height: 4, center: [0, 2, 0] });
273
+ return occt.booleans.difference({ shape: dome, shapes: [upper], keepEdges: false });
274
+ }
275
+
276
+ export async function gimbal(occt: Occt): Promise<Shape> {
277
+ const outline = await occt.shapes.wire.createPolygonWire({ points: [[-4, 19, -4], [19.5, 19, -4], [19.5, -7, -4], [14.5, -7, -4], [14.5, 15, -4], [-4, 15, -4]] });
278
+ const rounded = await occt.fillets.fillet2d({ shape: outline, radius: 1.5 });
279
+ const bracket = await prism(occt, rounded, [0, 0, 8]);
280
+ const yaw = await occt.shapes.solid.createCylinder({ radius: 9, height: 8, center: [0, 18, 0], direction: [0, 1, 0] });
281
+ const roll = await occt.shapes.solid.createCylinder({ radius: 6, height: 5, center: [14.5, 0, 0], direction: [-1, 0, 0] });
282
+ return occt.booleans.union({ shapes: [yaw, bracket, roll], keepEdges: false });
283
+ }
284
+
285
+ export async function camera(occt: Occt): Promise<Shape> {
286
+ const body = await occt.shapes.solid.createBox({ width: 24, length: 20, height: 18, center: [0, 0, 0] });
287
+ const soft = await occt.fillets.filletEdges({ shape: body, radius: 3 });
288
+ const barrel = await occt.shapes.solid.createCylinder({ radius: 6.5, height: 9, center: [0, 0, 8], direction: [0, 0, 1] });
289
+ return occt.booleans.union({ shapes: [soft, barrel], keepEdges: false });
290
+ }
291
+
292
+ export async function lens(occt: Occt): Promise<Shape> {
293
+ return occt.shapes.solid.createCylinder({ radius: 5.2, height: 1.5, center: [0, 0, 16.5], direction: [0, 0, 1] });
294
+ }
295
+
296
+ export async function battery(occt: Occt): Promise<Shape> {
297
+ const brick = await occt.shapes.solid.createBox({ width: 36, length: 72, height: 26, center: [0, 0, 0] });
298
+ return occt.fillets.filletEdges({ shape: brick, radius: 3 });
299
+ }
300
+
301
+ export async function strap(occt: Occt): Promise<Shape> {
302
+ const outer = await occt.shapes.solid.createBox({ width: 40, length: 10, height: 30, center: [0, 0, 0] });
303
+ const inner = await occt.shapes.solid.createBox({ width: 36.5, length: 12, height: 26.5, center: [0, 0, 0] });
304
+ return occt.booleans.difference({ shape: outer, shapes: [inner], keepEdges: false });
305
+ }
306
+
307
+ export async function gps(occt: Occt): Promise<Shape> {
308
+ const g = FRAME.gps;
309
+ const mast = await occt.shapes.solid.createCylinder({ radius: g.mastRadius, height: g.mastHeight, center: [0, 0, 0], direction: [0, 1, 0] });
310
+ const puck = await occt.shapes.solid.createCylinder({ radius: g.puckRadius, height: g.puckHeight, center: [0, g.mastHeight, 0], direction: [0, 1, 0] });
311
+ const rounded = await occt.fillets.filletEdges({ shape: puck, radius: 1.5 });
312
+ return occt.booleans.union({ shapes: [mast, rounded], keepEdges: false });
313
+ }
314
+
315
+ export async function antenna(occt: Occt): Promise<Shape> {
316
+ const a = FRAME.antenna;
317
+ const rod = await occt.shapes.solid.createCylinder({ radius: a.radius, height: a.length, center: [0, 0, 0], direction: [0, 1, 0] });
318
+ const tip = await occt.shapes.solid.createSphere({ radius: a.radius, center: [0, a.length, 0] });
319
+ return occt.booleans.union({ shapes: [rod, tip], keepEdges: false });
320
+ }
321
+
322
+ export async function logoFaces(occt: Occt, logo: Shape, width: number): Promise<Shape> {
323
+ const mirrored = await occt.transforms.mirrorAlongNormal({ shape: logo, origin: [0, 0, 0], normal: [1, 0, 0] });
324
+ const size = await occt.operations.boundingBoxSizeOfShape({ shape: mirrored });
325
+ const scaled = await occt.transforms.scale({ shape: mirrored, factor: width / Math.max(size[0], size[2]) });
326
+ const box = await occt.operations.boundingBoxOfShape({ shape: scaled });
327
+ return occt.transforms.translate({ shape: scaled, translation: [-box.center[0], -box.min[1], -box.center[2]] });
328
+ }
329
+
330
+ export async function hatch(occt: Occt, logo?: Shape): Promise<Shape> {
331
+ const h = FRAME.hatch;
332
+ const outline = await roundedRect(occt, h.width, h.length, h.corner, [0, 0, 0]);
333
+ const holes = logo ? await occt.shapes.wire.getWires({ shape: await logoFaces(occt, logo, FRAME.emblem.width) }) : [];
334
+ const face = await faceWithHoles(occt, outline, holes);
335
+ return occt.operations.extrude({ shape: face, direction: [0, h.thickness, 0] });
336
+ }
337
+
338
+ export async function emblem(occt: Occt, logo: Shape, width: number, thickness: number): Promise<Shape> {
339
+ const faces = await occt.shapes.face.getFaces({ shape: await logoFaces(occt, logo, width * FRAME.emblem.inset) });
340
+ const solids: Shape[] = [];
341
+ for (const face of faces) solids.push(await occt.operations.extrude({ shape: face, direction: [0, thickness, 0] }));
342
+ return occt.shapes.compound.makeCompound({ shapes: solids });
343
+ }
@@ -0,0 +1,219 @@
1
+ :root {
2
+ --panel: rgba(24, 26, 30, 0.92);
3
+ --line: rgba(255, 255, 255, 0.12);
4
+ --text: #f2f2f2;
5
+ --muted: #a5a8ad;
6
+ --accent: #f0cebb;
7
+ font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
8
+ color: var(--text);
9
+ }
10
+
11
+ body {
12
+ margin: 0;
13
+ overflow: hidden;
14
+ background: #15171a;
15
+ }
16
+
17
+ #three-canvas {
18
+ position: fixed;
19
+ inset: 0;
20
+ width: 100%;
21
+ height: 100%;
22
+ display: block;
23
+ }
24
+
25
+ #panel {
26
+ position: fixed;
27
+ top: 16px;
28
+ left: 16px;
29
+ width: 300px;
30
+ max-height: calc(100vh - 32px);
31
+ overflow-y: auto;
32
+ padding: 18px;
33
+ box-sizing: border-box;
34
+ background: var(--panel);
35
+ border: 1px solid var(--line);
36
+ border-radius: 12px;
37
+ backdrop-filter: blur(12px);
38
+ }
39
+
40
+ .brand {
41
+ display: flex;
42
+ align-items: center;
43
+ gap: 10px;
44
+ margin: 0 0 4px;
45
+ }
46
+
47
+ .brand img {
48
+ width: 28px;
49
+ height: 28px;
50
+ }
51
+
52
+ #panel h1 {
53
+ font-size: 18px;
54
+ margin: 0;
55
+ }
56
+
57
+ #panel .lead {
58
+ color: var(--muted);
59
+ font-size: 13px;
60
+ margin: 0 0 14px;
61
+ }
62
+
63
+ .field {
64
+ display: grid;
65
+ grid-template-columns: 1fr auto;
66
+ gap: 2px 8px;
67
+ align-items: center;
68
+ margin-bottom: 10px;
69
+ font-size: 13px;
70
+ }
71
+
72
+ .field label {
73
+ color: var(--muted);
74
+ }
75
+
76
+ .field output {
77
+ text-align: right;
78
+ font-variant-numeric: tabular-nums;
79
+ }
80
+
81
+ .field input[type="range"] {
82
+ grid-column: 1 / 3;
83
+ width: 100%;
84
+ accent-color: var(--accent);
85
+ }
86
+
87
+ .field select {
88
+ grid-column: 1 / 3;
89
+ padding: 6px;
90
+ background: #101114;
91
+ color: var(--text);
92
+ border: 1px solid var(--line);
93
+ border-radius: 6px;
94
+ }
95
+
96
+ .segments {
97
+ grid-column: 1 / 3;
98
+ display: flex;
99
+ gap: 6px;
100
+ }
101
+
102
+ .segments button, .exports button {
103
+ flex: 1;
104
+ padding: 7px 8px;
105
+ background: transparent;
106
+ color: var(--text);
107
+ border: 1px solid var(--line);
108
+ border-radius: 8px;
109
+ cursor: pointer;
110
+ font-size: 13px;
111
+ }
112
+
113
+ .segments button:hover, .exports button:hover {
114
+ border-color: var(--accent);
115
+ }
116
+
117
+ .segments button.active {
118
+ background: var(--accent);
119
+ color: #1a1c1f;
120
+ border-color: var(--accent);
121
+ }
122
+
123
+ .note {
124
+ min-height: 16px;
125
+ margin: 0 0 8px;
126
+ font-size: 12px;
127
+ color: var(--accent);
128
+ }
129
+
130
+ .field.speed {
131
+ margin-bottom: 8px;
132
+ }
133
+
134
+ .toggles {
135
+ display: flex;
136
+ gap: 14px;
137
+ margin-bottom: 12px;
138
+ font-size: 13px;
139
+ color: var(--muted);
140
+ }
141
+
142
+ .toggles input {
143
+ accent-color: var(--accent);
144
+ }
145
+
146
+ .bom {
147
+ margin: 0 0 14px;
148
+ padding: 12px;
149
+ border: 1px solid var(--line);
150
+ border-radius: 8px;
151
+ font-size: 12px;
152
+ }
153
+
154
+ .bom-title {
155
+ display: flex;
156
+ justify-content: space-between;
157
+ font-weight: 600;
158
+ margin-bottom: 6px;
159
+ }
160
+
161
+ .bom-totals {
162
+ color: var(--muted);
163
+ font-weight: 400;
164
+ }
165
+
166
+ .bom table {
167
+ width: 100%;
168
+ border-collapse: collapse;
169
+ color: var(--muted);
170
+ }
171
+
172
+ .bom td {
173
+ padding: 2px 0;
174
+ }
175
+
176
+ .bom td:last-child {
177
+ text-align: right;
178
+ font-variant-numeric: tabular-nums;
179
+ }
180
+
181
+ .exports {
182
+ display: flex;
183
+ gap: 6px;
184
+ }
185
+
186
+ .status {
187
+ min-height: 18px;
188
+ margin-top: 10px;
189
+ font-size: 12px;
190
+ color: var(--muted);
191
+ }
192
+
193
+ .credit {
194
+ position: fixed;
195
+ right: 16px;
196
+ bottom: 12px;
197
+ display: flex;
198
+ align-items: center;
199
+ gap: 6px;
200
+ color: var(--muted);
201
+ font-size: 12px;
202
+ text-decoration: none;
203
+ }
204
+
205
+ .credit img {
206
+ width: 16px;
207
+ height: 16px;
208
+ }
209
+
210
+ @media (max-width: 640px) {
211
+ #panel {
212
+ top: auto;
213
+ bottom: 0;
214
+ left: 0;
215
+ width: 100%;
216
+ max-height: 55vh;
217
+ border-radius: 12px 12px 0 0;
218
+ }
219
+ }