opengeometry 2.0.13 → 2.0.14

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 (37) hide show
  1. package/analytic-worker.js +90 -0
  2. package/index.d.ts +16 -1
  3. package/index.js +3065 -3675
  4. package/index.js.map +1 -1
  5. package/opengeometry/pkg/opengeometry.d.ts +261 -236
  6. package/opengeometry/pkg/opengeometry.js +754 -538
  7. package/opengeometry/pkg/opengeometry_bg.wasm +0 -0
  8. package/opengeometry/pkg/opengeometry_bg.wasm.d.ts +211 -190
  9. package/opengeometry_bg.wasm +0 -0
  10. package/opengeometry_bg.wasm.d.ts +211 -190
  11. package/package.json +2 -1
  12. package/src/examples/booleans.d.ts +3 -2
  13. package/src/examples/editor-modes.d.ts +4 -8
  14. package/src/examples/shapes.d.ts +1 -1
  15. package/src/examples/wall-from-offsets.d.ts +7 -14
  16. package/src/export/analytic-ifc.d.ts +61 -0
  17. package/src/freeform/geometry.d.ts +2 -0
  18. package/src/freeform/index.d.ts +1 -1
  19. package/src/operations/analytic-errors.d.ts +8 -0
  20. package/src/operations/boolean.d.ts +9 -141
  21. package/src/operations/index.d.ts +2 -1
  22. package/src/operations/loft.d.ts +13 -0
  23. package/src/primitives/analytic-curve.d.ts +42 -0
  24. package/src/primitives/arc.d.ts +26 -55
  25. package/src/primitives/elliptical_arc.d.ts +29 -57
  26. package/src/rendering/analytic-lod.d.ts +32 -0
  27. package/src/rendering/analytic-tessellation.d.ts +32 -0
  28. package/src/shapes/analytic-pattern.d.ts +36 -0
  29. package/src/shapes/analytic-solid.d.ts +288 -0
  30. package/src/shapes/cuboid.d.ts +40 -54
  31. package/src/shapes/cylinder.d.ts +26 -70
  32. package/src/shapes/opening.d.ts +19 -82
  33. package/src/shapes/polygon.d.ts +4 -5
  34. package/src/shapes/solid.d.ts +0 -8
  35. package/src/shapes/sphere.d.ts +18 -73
  36. package/src/shapes/sweep.d.ts +0 -5
  37. package/src/shapes/wedge.d.ts +0 -5
@@ -0,0 +1,90 @@
1
+ let runtime;
2
+ let initialization;
3
+ let totalBytes = 0;
4
+ const models = new Map();
5
+ const jobs = new Map();
6
+ let scheduled = false;
7
+
8
+ function respond(request, result, transfer = []) {
9
+ self.postMessage({ request, result }, transfer);
10
+ }
11
+ function reject(request, error) {
12
+ self.postMessage({ request, error: error instanceof Error ? error.message : error });
13
+ }
14
+ function drain() {
15
+ scheduled = false;
16
+ const entry = jobs.entries().next();
17
+ if (entry.done) return;
18
+ const [handle, job] = entry.value;
19
+ jobs.delete(handle);
20
+ let mesh;
21
+ try {
22
+ const model = models.get(handle);
23
+ if (!model) throw new Error("Unknown analytic worker model handle");
24
+ mesh = model.brep.tessellate(job.deflection);
25
+ const result = {
26
+ positions: mesh.positions(), normals: mesh.normals(), indices: mesh.indices(),
27
+ triangleFaceIds: mesh.triangle_face_ids(), outlinePositions: mesh.outline_positions(),
28
+ outlineEdgeIds: mesh.outline_edge_ids(), revision: mesh.revision(), achievedDeflection: mesh.achieved_deflection(),
29
+ };
30
+ const transfer = [result.positions, result.normals, result.indices, result.triangleFaceIds,
31
+ result.outlinePositions, result.outlineEdgeIds].map((array) => array.buffer);
32
+ respond(job.request, result, transfer);
33
+ } catch (error) { reject(job.request, error); }
34
+ finally { mesh?.free(); }
35
+ schedule();
36
+ }
37
+ function schedule() {
38
+ if (scheduled || !jobs.size) return;
39
+ scheduled = true;
40
+ setTimeout(drain, 0);
41
+ }
42
+ function invalidate(handle) {
43
+ const job = jobs.get(handle);
44
+ if (job) {
45
+ reject(job.request, "Superseded tessellation request");
46
+ jobs.delete(handle);
47
+ }
48
+ }
49
+ async function receive(message) {
50
+ const { request, kind, handle } = message;
51
+ try {
52
+ if (kind === "init") {
53
+ if (initialization) throw new Error("Analytic worker already initialized");
54
+ initialization = (async () => {
55
+ runtime = await import(/* @vite-ignore */ message.kernelURL);
56
+ await runtime.default({ module_or_path: message.wasmURL });
57
+ })();
58
+ await initialization;
59
+ respond(request, true);
60
+ return;
61
+ }
62
+ if (!initialization) throw new Error("Analytic worker has not been initialized");
63
+ await initialization;
64
+ if (typeof handle !== "string" || !handle || handle.length > 1024) throw new Error("Invalid analytic worker handle");
65
+ if (kind === "model") {
66
+ const bytes = typeof message.serialized === "string" ? new TextEncoder().encode(message.serialized).length : Infinity;
67
+ const previous = models.get(handle);
68
+ if (bytes > 64 * 1024 * 1024 || totalBytes - (previous?.bytes ?? 0) + bytes > 128 * 1024 * 1024
69
+ || (!previous && models.size >= 64)) throw new Error("Analytic worker model resource limit exceeded");
70
+ const brep = new runtime.OGAnalyticBrep(message.serialized);
71
+ invalidate(handle);
72
+ previous?.brep.free();
73
+ models.set(handle, { brep, bytes });
74
+ totalBytes += bytes - (previous?.bytes ?? 0);
75
+ respond(request, { revision: brep.get_revision() });
76
+ } else if (kind === "remove") {
77
+ invalidate(handle);
78
+ const previous = models.get(handle);
79
+ if (previous) { previous.brep.free(); totalBytes -= previous.bytes; models.delete(handle); }
80
+ respond(request, true);
81
+ } else if (kind === "tessellate") {
82
+ if (!models.has(handle)) throw new Error("Unknown analytic worker model handle");
83
+ if (!Number.isFinite(message.deflection) || message.deflection <= 0) throw new Error("Invalid tessellation deflection");
84
+ invalidate(handle);
85
+ jobs.set(handle, message);
86
+ schedule();
87
+ } else throw new Error("Unknown analytic worker operation");
88
+ } catch (error) { reject(request, error); }
89
+ }
90
+ self.onmessage = (event) => { void receive(event.data); };
package/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Public OpenGeometry JavaScript entrypoint.
3
3
  */
4
- import { OGSceneManager, Vector3 } from "./opengeometry/pkg/opengeometry.js";
4
+ import { OGAnalyticBrep, OGAnalyticTessellation, OGSceneManager, WorkPlane, analyzeProfile, extrudeBrepFaceDirectional, validateAnalyticBrep, tessellate_brep, Vector3 } from "./opengeometry/pkg/opengeometry.js";
5
5
  import { SpotLabel } from "./src/markup/spotMarker.js";
6
6
  import { OpenGeometryOptions } from "./src/base-types.js";
7
7
  export type OUTLINE_TYPE = "front" | "side" | "top";
@@ -69,6 +69,13 @@ export declare class OpenGeometry {
69
69
  * export, and other scene-level workflows.
70
70
  */
71
71
  export { OGSceneManager };
72
+ export { OGAnalyticBrep, OGAnalyticTessellation };
73
+ export { WorkPlane, analyzeProfile, extrudeBrepFaceDirectional, validateAnalyticBrep };
74
+ export { tessellate_brep };
75
+ export { AnalyticSolid } from "./src/shapes/analytic-solid.js";
76
+ export { AnalyticPattern, circularPattern, linearPattern, rectangularPattern } from "./src/shapes/analytic-pattern.js";
77
+ export type { AnalyticPatternHit, AnalyticPatternInstance } from "./src/shapes/analytic-pattern.js";
78
+ export type { AnalyticBooleanOp, AnalyticBooleanReport, AnalyticBrepOptions, AnalyticFrame, AnalyticAccuracy, AnalyticCircularWallOpening, AnalyticPolygonLoftAlignment, AnalyticProjectionCamera, AnalyticProjectionHlr, AnalyticPrimitiveOptions, AnalyticTessellationStats, AnalyticTessellationOptions, AnalyticStepExport, AnalyticStlExport, } from "./src/shapes/analytic-solid.js";
72
79
  /**
73
80
  * Shared wasm-backed vector type used throughout the public API.
74
81
  *
@@ -100,3 +107,11 @@ export * from "./src/editor/index.js";
100
107
  * Kernel-backed modeling operations (incl. analytic polyline offset → regions).
101
108
  */
102
109
  export * from "./src/operations/index.js";
110
+ export { AnalyticCurve } from "./src/primitives/analytic-curve.js";
111
+ export type { AnalyticCurveOptions, AnalyticCurveStats } from "./src/primitives/analytic-curve.js";
112
+ export { AnalyticTessellationWorker } from "./src/rendering/analytic-tessellation.js";
113
+ export type { AnalyticWorkerOptions, AnalyticTessellationData } from "./src/rendering/analytic-tessellation.js";
114
+ export { AnalyticLodController, deflectionBucket, worldUnitsPerPixel, uniformScale } from "./src/rendering/analytic-lod.js";
115
+ export type { AnalyticLodOptions } from "./src/rendering/analytic-lod.js";
116
+ export { analyticIfcText } from "./src/export/analytic-ifc.js";
117
+ export type { AnalyticExchangeBodyV2, IfcPreparedValue } from "./src/export/analytic-ifc.js";