opengeometry 2.0.3 → 2.0.5
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.
- package/README.md +33 -5
- package/index.d.ts +18 -13
- package/index.js +130 -61
- package/index.js.map +1 -1
- package/opengeometry/pkg/opengeometry.d.ts +218 -213
- package/opengeometry/pkg/opengeometry.js +38 -17
- package/opengeometry/pkg/opengeometry_bg.wasm +0 -0
- package/opengeometry/pkg/opengeometry_bg.wasm.d.ts +214 -213
- package/opengeometry_bg.wasm +0 -0
- package/opengeometry_bg.wasm.d.ts +214 -213
- package/package.json +18 -8
- package/src/operations/boolean.d.ts +13 -0
- package/src/shapes/boolean-subtract.d.ts +5 -1
- package/src/shapes/cuboid.d.ts +3 -3
- package/src/shapes/cylinder.d.ts +3 -3
- package/src/shapes/opening.d.ts +6 -3
- package/src/shapes/polygon.d.ts +6 -3
- package/src/shapes/solid.d.ts +8 -3
- package/src/shapes/sphere.d.ts +3 -3
- package/src/shapes/sweep.d.ts +3 -3
- package/src/shapes/wedge.d.ts +3 -3
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
</p>
|
|
20
20
|
|
|
21
21
|
<p align="center">
|
|
22
|
-
<a href="https://opengeometry.io">Website</a> · <a href="https://docs.opengeometry.io">Documentation</a> · <a href="https://
|
|
22
|
+
<a href="https://opengeometry.io">Website</a> · <a href="https://docs.opengeometry.io">Documentation</a> · <a href="https://demo.opengeometry.io">Live Demos</a> · <a href="https://opengeometry.io/blog">Blog</a> · <a href="https://www.npmjs.com/package/opengeometry">npm</a>
|
|
23
23
|
</p>
|
|
24
24
|
|
|
25
25
|
---
|
|
@@ -32,14 +32,39 @@
|
|
|
32
32
|
|
|
33
33
|
OpenGeometry is an **open-source CAD kernel** purpose-built for the browser. The geometry engine is written in **Rust**, compiled to **WebAssembly**, and ships with a **Three.js integration layer** — so you can build real CAD tools that run entirely on the web.
|
|
34
34
|
|
|
35
|
-
Whether you're building a parametric modeler, a
|
|
35
|
+
OpenGeometry is best suited for **browser-based CAD, AEC/BIM, configurators, and geometry-heavy web tools**. Whether you're building a parametric modeler, a wall/opening workflow, a BIM viewer, or a custom Three.js modeling tool, OpenGeometry gives you kernel-backed primitives and operations without leaving JavaScript.
|
|
36
|
+
|
|
37
|
+
OpenPlans is an application/toolkit built on top of OpenGeometry for AEC workflows. In this repository, OpenGeometry is the engine.
|
|
38
|
+
|
|
39
|
+
## When to use OpenGeometry
|
|
40
|
+
|
|
41
|
+
Use OpenGeometry when you need:
|
|
42
|
+
|
|
43
|
+
- browser-based parametric modeling with Rust + WebAssembly performance
|
|
44
|
+
- wall/opening subtraction and other solid boolean workflows
|
|
45
|
+
- polygon extrusion into solids for CAD or AEC modeling
|
|
46
|
+
- IFC, STEP, STL, and PDF-style export/projection in web apps
|
|
47
|
+
- a Three.js-friendly CAD kernel instead of ad hoc mesh math
|
|
48
|
+
|
|
49
|
+
## AI and Coding Agent Entrypoints
|
|
50
|
+
|
|
51
|
+
If you are using ChatGPT, Claude, Gemini, Copilot, or other coding agents on this repository, start here:
|
|
52
|
+
|
|
53
|
+
- [llms.txt](./llms.txt)
|
|
54
|
+
- [llms-full.txt](./llms-full.txt)
|
|
55
|
+
- [llm.txt](./llm.txt)
|
|
56
|
+
- [AGENTS.md](./AGENTS.md)
|
|
57
|
+
- [Quickstart](https://docs.opengeometry.io/quickstart)
|
|
58
|
+
- [Three.js integration](https://docs.opengeometry.io/integration/threejs)
|
|
59
|
+
- [Boolean operations](https://docs.opengeometry.io/api/operations/boolean-operations)
|
|
60
|
+
- [Extrude](https://docs.opengeometry.io/api/operations/extrude)
|
|
36
61
|
|
|
37
62
|
### What you can do today
|
|
38
63
|
|
|
39
64
|
| Category | Capabilities |
|
|
40
65
|
| --- | --- |
|
|
41
66
|
| **Primitives** | Lines, arcs, curves, polylines, rectangles |
|
|
42
|
-
| **Shapes** | Polygons,
|
|
67
|
+
| **Shapes** | Polygons, solids, cuboids, cylinders, spheres, wedges, sweeps, openings |
|
|
43
68
|
| **Operations** | Triangulation, extrusion, sweep, offset, boolean operations |
|
|
44
69
|
| **Exports** | STL, STEP, IFC, PDF projection |
|
|
45
70
|
| **Integration** | Three.js scene management, WebAssembly-powered performance |
|
|
@@ -48,7 +73,7 @@ Whether you're building a parametric modeler, a BIM viewer, a 3D configurator, o
|
|
|
48
73
|
|
|
49
74
|
See OpenGeometry in action — interactive, browser-based demos showcasing the kernel's capabilities:
|
|
50
75
|
|
|
51
|
-
**[
|
|
76
|
+
**[demo.opengeometry.io](https://demo.opengeometry.io)**
|
|
52
77
|
|
|
53
78
|
Demos include primitives rendering, shape generation, sweep operations, boolean operations, file exports, and more. All running client-side via WebAssembly.
|
|
54
79
|
|
|
@@ -70,6 +95,7 @@ await OpenGeometry.create({
|
|
|
70
95
|
).href,
|
|
71
96
|
});
|
|
72
97
|
|
|
98
|
+
// Initialize once before constructing Vector3 or any wrapper.
|
|
73
99
|
const cuboid = new Cuboid({
|
|
74
100
|
center: new Vector3(0, 0, 0),
|
|
75
101
|
width: 2,
|
|
@@ -140,7 +166,7 @@ npm test
|
|
|
140
166
|
- Contributors interested in the **Rust → WASM geometry pipeline**
|
|
141
167
|
- Anyone exploring **open-source CAD kernel internals**
|
|
142
168
|
|
|
143
|
-
If you just want a quick look, start with the [hosted demos](https://
|
|
169
|
+
If you just want a quick look, start with the [hosted demos](https://demo.opengeometry.io) or the [quickstart repo](https://github.com/OpenGeometry-io/quickstart-js).
|
|
144
170
|
|
|
145
171
|
## Community
|
|
146
172
|
|
|
@@ -159,6 +185,8 @@ OpenGeometry is open source under the [MPL-2.0 license](./LICENSE.md). Contribut
|
|
|
159
185
|
## AI Agent Docs Policy
|
|
160
186
|
|
|
161
187
|
- Repository-level AI agent instructions are in [AGENTS.md](./AGENTS.md).
|
|
188
|
+
- LLM-friendly repo entrypoints are [llms.txt](./llms.txt), [llms-full.txt](./llms-full.txt), and
|
|
189
|
+
[llm.txt](./llm.txt).
|
|
162
190
|
- All AI-generated documentation must live under [`AI-DOCs/`](./AI-DOCs/).
|
|
163
191
|
- AI-generated docs should not be added under app/code folders unless explicitly requested.
|
|
164
192
|
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenGeometry
|
|
3
|
-
* @module @opengeometry/kernel-three
|
|
2
|
+
* Public OpenGeometry JavaScript entrypoint.
|
|
4
3
|
*/
|
|
5
4
|
import { OGSceneManager, Vector3 } from "./opengeometry/pkg/opengeometry.js";
|
|
6
5
|
import { SpotLabel } from "./src/markup/spotMarker.js";
|
|
@@ -47,30 +46,36 @@ export declare class OpenGeometry {
|
|
|
47
46
|
set enableDebug(value: boolean);
|
|
48
47
|
constructor();
|
|
49
48
|
/**
|
|
50
|
-
* Asynchronously
|
|
49
|
+
* Asynchronously initializes the OpenGeometry wasm runtime and returns a
|
|
50
|
+
* cached singleton instance on subsequent calls.
|
|
51
51
|
*
|
|
52
|
-
*
|
|
53
|
-
* rendering context and the WebAssembly module. It ensures all required
|
|
54
|
-
* options are provided and prepares the instance for 3D geometry operations.
|
|
52
|
+
* Call this before constructing `Vector3` or any kernel-backed wrapper.
|
|
55
53
|
*
|
|
56
54
|
* @param options - Configuration object for initializing OpenGeometry.
|
|
57
55
|
* @returns A promise that resolves to a fully initialized OpenGeometry instance.
|
|
58
|
-
* @throws If any of the required options (`container`, `scene`, or `camera`) are missing.
|
|
59
56
|
*
|
|
60
57
|
* @example
|
|
61
58
|
* ```ts
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* scene: threeScene,
|
|
65
|
-
* camera: threeCamera,
|
|
66
|
-
* wasmURL: '/assets/opengeometry.wasm'
|
|
59
|
+
* await OpenGeometry.create({
|
|
60
|
+
* wasmURL: "/opengeometry_bg.wasm",
|
|
67
61
|
* });
|
|
68
62
|
* ```
|
|
69
63
|
*/
|
|
70
64
|
static create(options: OpenGeometryOptions): Promise<OpenGeometry>;
|
|
71
65
|
private setup;
|
|
72
66
|
}
|
|
73
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Scene manager that stores serialized BRep snapshots in wasm for projection,
|
|
69
|
+
* export, and other scene-level workflows.
|
|
70
|
+
*/
|
|
71
|
+
export { OGSceneManager };
|
|
72
|
+
/**
|
|
73
|
+
* Shared wasm-backed vector type used throughout the public API.
|
|
74
|
+
*
|
|
75
|
+
* Initialize `OpenGeometry.create(...)` before constructing `Vector3`.
|
|
76
|
+
*/
|
|
77
|
+
export { Vector3 };
|
|
78
|
+
export { SpotLabel };
|
|
74
79
|
/**
|
|
75
80
|
* Primitive wrappers (line/polyline/arc/rectangle/curve).
|
|
76
81
|
*/
|
package/index.js
CHANGED
|
@@ -138,11 +138,6 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
138
138
|
WASM_VECTOR_LEN = offset;
|
|
139
139
|
return ptr;
|
|
140
140
|
}
|
|
141
|
-
function _assertClass(instance, klass) {
|
|
142
|
-
if (!(instance instanceof klass)) {
|
|
143
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
141
|
function takeFromExternrefTable0(idx) {
|
|
147
142
|
const value = wasm.__wbindgen_export_2.get(idx);
|
|
148
143
|
wasm.__externref_table_dealloc(idx);
|
|
@@ -159,6 +154,11 @@ function getArrayF64FromWasm0(ptr, len) {
|
|
|
159
154
|
ptr = ptr >>> 0;
|
|
160
155
|
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
161
156
|
}
|
|
157
|
+
function _assertClass(instance, klass) {
|
|
158
|
+
if (!(instance instanceof klass)) {
|
|
159
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
162
|
let cachedDataViewMemory0 = null;
|
|
163
163
|
function getDataViewMemory0() {
|
|
164
164
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
@@ -175,6 +175,16 @@ function passArrayJsValueToWasm0(array, malloc) {
|
|
|
175
175
|
WASM_VECTOR_LEN = array.length;
|
|
176
176
|
return ptr;
|
|
177
177
|
}
|
|
178
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
179
|
+
ptr = ptr >>> 0;
|
|
180
|
+
const mem = getDataViewMemory0();
|
|
181
|
+
const result = [];
|
|
182
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
183
|
+
result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
|
|
184
|
+
}
|
|
185
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
178
188
|
function isLikeNone(x) {
|
|
179
189
|
return x === undefined || x === null;
|
|
180
190
|
}
|
|
@@ -241,6 +251,27 @@ function booleanSubtraction$1(lhs_brep_serialized, rhs_brep_serialized, options_
|
|
|
241
251
|
return OGBooleanResult.__wrap(ret[0]);
|
|
242
252
|
}
|
|
243
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Wasm entry point for array-backed repeated subtraction.
|
|
256
|
+
* @param {string} lhs_brep_serialized
|
|
257
|
+
* @param {string} cutters_brep_serialized
|
|
258
|
+
* @param {string | null} [options_json]
|
|
259
|
+
* @returns {OGBooleanResult}
|
|
260
|
+
*/
|
|
261
|
+
function booleanSubtractionMany(lhs_brep_serialized, cutters_brep_serialized, options_json) {
|
|
262
|
+
const ptr0 = passStringToWasm0(lhs_brep_serialized, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
263
|
+
const len0 = WASM_VECTOR_LEN;
|
|
264
|
+
const ptr1 = passStringToWasm0(cutters_brep_serialized, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
265
|
+
const len1 = WASM_VECTOR_LEN;
|
|
266
|
+
var ptr2 = isLikeNone(options_json) ? 0 : passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
267
|
+
var len2 = WASM_VECTOR_LEN;
|
|
268
|
+
const ret = wasm.booleanSubtractionMany(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
269
|
+
if (ret[2]) {
|
|
270
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
271
|
+
}
|
|
272
|
+
return OGBooleanResult.__wrap(ret[0]);
|
|
273
|
+
}
|
|
274
|
+
|
|
244
275
|
/**
|
|
245
276
|
* @param {string} local_brep_serialized
|
|
246
277
|
* @param {number} height
|
|
@@ -267,16 +298,6 @@ function extrudeBrepFace$1(local_brep_serialized, height) {
|
|
|
267
298
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
268
299
|
}
|
|
269
300
|
}
|
|
270
|
-
function getArrayJsValueFromWasm0(ptr, len) {
|
|
271
|
-
ptr = ptr >>> 0;
|
|
272
|
-
const mem = getDataViewMemory0();
|
|
273
|
-
const result = [];
|
|
274
|
-
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
275
|
-
result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
|
|
276
|
-
}
|
|
277
|
-
wasm.__externref_drop_slice(ptr, len);
|
|
278
|
-
return result;
|
|
279
|
-
}
|
|
280
301
|
const Matrix3Finalization = typeof FinalizationRegistry === 'undefined' ? {
|
|
281
302
|
register: () => {},
|
|
282
303
|
unregister: () => {}
|
|
@@ -5688,6 +5709,7 @@ var OGKernel = /*#__PURE__*/Object.freeze({
|
|
|
5688
5709
|
Vector3: Vector3,
|
|
5689
5710
|
booleanIntersection: booleanIntersection$1,
|
|
5690
5711
|
booleanSubtraction: booleanSubtraction$1,
|
|
5712
|
+
booleanSubtractionMany: booleanSubtractionMany,
|
|
5691
5713
|
booleanUnion: booleanUnion$1,
|
|
5692
5714
|
default: __wbg_init,
|
|
5693
5715
|
extrudeBrepFace: extrudeBrepFace$1,
|
|
@@ -7546,6 +7568,9 @@ class BooleanResult extends THREE.Mesh {
|
|
|
7546
7568
|
_BooleanResult_outlineMesh = new WeakMap();
|
|
7547
7569
|
/**
|
|
7548
7570
|
* Computes a kernel-backed boolean union and returns a renderable result mesh.
|
|
7571
|
+
*
|
|
7572
|
+
* Accepts wrapper objects directly, including `Solid`, `Cuboid`, `Opening`,
|
|
7573
|
+
* and other shapes that expose BRep accessors.
|
|
7549
7574
|
*/
|
|
7550
7575
|
function booleanUnion(lhs, rhs, options) {
|
|
7551
7576
|
return executeBoolean("booleanUnion", lhs, rhs, options);
|
|
@@ -7558,16 +7583,34 @@ function booleanIntersection(lhs, rhs, options) {
|
|
|
7558
7583
|
}
|
|
7559
7584
|
/**
|
|
7560
7585
|
* Computes a kernel-backed boolean subtraction and returns a renderable result mesh.
|
|
7586
|
+
*
|
|
7587
|
+
* Use this when you want a standalone helper rather than a shape-level
|
|
7588
|
+
* convenience method like `opening.subtractFrom(host)`.
|
|
7561
7589
|
*/
|
|
7562
7590
|
function booleanSubtraction(lhs, rhs, options) {
|
|
7563
7591
|
return executeBoolean("booleanSubtraction", lhs, rhs, options);
|
|
7564
7592
|
}
|
|
7593
|
+
/**
|
|
7594
|
+
* Computes a kernel-backed repeated subtraction using a left-to-right cutter array.
|
|
7595
|
+
*
|
|
7596
|
+
* This is used by the shape-level `.subtract([...])` helpers so the heavy
|
|
7597
|
+
* boolean orchestration stays in the Rust/WASM layer instead of JavaScript.
|
|
7598
|
+
*/
|
|
7599
|
+
function executeBooleanSubtractionMany(lhs, cutters, options) {
|
|
7600
|
+
const booleanExport = booleanSubtractionMany;
|
|
7601
|
+
if (typeof booleanExport !== "function") {
|
|
7602
|
+
throw new Error("booleanSubtractionMany is not available in the loaded wasm package. Rebuild opengeometry wasm bindings.");
|
|
7603
|
+
}
|
|
7604
|
+
const kernelFunction = booleanExport;
|
|
7605
|
+
const kernelOptions = serializeKernelOptions(options === null || options === void 0 ? void 0 : options.kernel);
|
|
7606
|
+
const kernelResult = kernelFunction(resolveOperandSerialized(lhs), JSON.stringify(cutters.map(resolveOperandPayload)), kernelOptions);
|
|
7607
|
+
return createBooleanResult(kernelResult, options);
|
|
7608
|
+
}
|
|
7565
7609
|
/**
|
|
7566
7610
|
* Normalizes mixed wrapper/raw operands, invokes the wasm boolean export, and
|
|
7567
7611
|
* returns the renderable result wrapper.
|
|
7568
7612
|
*/
|
|
7569
7613
|
function executeBoolean(exportName, lhs, rhs, options) {
|
|
7570
|
-
var _a;
|
|
7571
7614
|
const booleanExport = OGKernel[exportName];
|
|
7572
7615
|
if (typeof booleanExport !== "function") {
|
|
7573
7616
|
throw new Error(`${exportName} is not available in the loaded wasm package. Rebuild opengeometry wasm bindings.`);
|
|
@@ -7575,11 +7618,7 @@ function executeBoolean(exportName, lhs, rhs, options) {
|
|
|
7575
7618
|
const kernelFunction = booleanExport;
|
|
7576
7619
|
const kernelOptions = serializeKernelOptions(options === null || options === void 0 ? void 0 : options.kernel);
|
|
7577
7620
|
const kernelResult = kernelFunction(resolveOperandSerialized(lhs), resolveOperandSerialized(rhs), kernelOptions);
|
|
7578
|
-
|
|
7579
|
-
if ((_a = options === null || options === void 0 ? void 0 : options.outline) !== null && _a !== void 0 ? _a : true) {
|
|
7580
|
-
result.outline = true;
|
|
7581
|
-
}
|
|
7582
|
-
return result;
|
|
7621
|
+
return createBooleanResult(kernelResult, options);
|
|
7583
7622
|
}
|
|
7584
7623
|
/**
|
|
7585
7624
|
* Accepts wrapper objects, raw BRep data, or serialized JSON and normalizes
|
|
@@ -7600,6 +7639,19 @@ function resolveOperandSerialized(operand) {
|
|
|
7600
7639
|
}
|
|
7601
7640
|
return serializeBrepLike(operand);
|
|
7602
7641
|
}
|
|
7642
|
+
/**
|
|
7643
|
+
* Parses a boolean operand into a raw BRep payload so array-backed boolean
|
|
7644
|
+
* calls can serialize a JSON array of BReps instead of a JSON array of strings.
|
|
7645
|
+
*/
|
|
7646
|
+
function resolveOperandPayload(operand) {
|
|
7647
|
+
const serialized = resolveOperandSerialized(operand);
|
|
7648
|
+
try {
|
|
7649
|
+
return JSON.parse(serialized);
|
|
7650
|
+
}
|
|
7651
|
+
catch (_a) {
|
|
7652
|
+
throw new Error("Boolean operands must resolve to valid serialized BRep JSON before array subtraction.");
|
|
7653
|
+
}
|
|
7654
|
+
}
|
|
7603
7655
|
/**
|
|
7604
7656
|
* Accepts either a parsed BRep object or an already serialized JSON payload
|
|
7605
7657
|
* and always returns the canonical serialized form expected by the wasm API.
|
|
@@ -7622,6 +7674,14 @@ function serializeKernelOptions(options) {
|
|
|
7622
7674
|
merge_coplanar_faces: options.mergeCoplanarFaces,
|
|
7623
7675
|
});
|
|
7624
7676
|
}
|
|
7677
|
+
function createBooleanResult(kernelResult, options) {
|
|
7678
|
+
var _a;
|
|
7679
|
+
const result = new BooleanResult(kernelResult, options);
|
|
7680
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.outline) !== null && _a !== void 0 ? _a : true) {
|
|
7681
|
+
result.outline = true;
|
|
7682
|
+
}
|
|
7683
|
+
return result;
|
|
7684
|
+
}
|
|
7625
7685
|
/**
|
|
7626
7686
|
* Builds a display-quality outline buffer from the rendered mesh and falls back
|
|
7627
7687
|
* to the kernel-provided edges when the client-side extraction is empty.
|
|
@@ -7642,8 +7702,11 @@ function getRenderableOutlinePositions(geometry, fallbackSerialized) {
|
|
|
7642
7702
|
/**
|
|
7643
7703
|
* Executes a kernel-backed subtraction for a shape wrapper against another boolean operand.
|
|
7644
7704
|
*/
|
|
7645
|
-
function subtractShapeOperand(host,
|
|
7646
|
-
|
|
7705
|
+
function subtractShapeOperand(host, operands, options) {
|
|
7706
|
+
if (!Array.isArray(operands)) {
|
|
7707
|
+
throw new Error("shape.subtract(...) now requires an operand array. Pass shape.subtract([operand], options) even for a single cutter.");
|
|
7708
|
+
}
|
|
7709
|
+
return executeBooleanSubtractionMany(host, operands, options);
|
|
7647
7710
|
}
|
|
7648
7711
|
|
|
7649
7712
|
var _Solid_outlineMesh;
|
|
@@ -7693,6 +7756,8 @@ class Solid extends THREE.Mesh {
|
|
|
7693
7756
|
}
|
|
7694
7757
|
/**
|
|
7695
7758
|
* Extrudes a face-like BRep source and wraps the result as a renderable solid.
|
|
7759
|
+
*
|
|
7760
|
+
* Prefer `polygon.extrude(height)` when the source is already a `Polygon`.
|
|
7696
7761
|
*/
|
|
7697
7762
|
static extrude(source, height, options) {
|
|
7698
7763
|
return new Solid(Object.assign(Object.assign({}, options), { brep: extrudeBrepFace(source, height) }));
|
|
@@ -7779,10 +7844,13 @@ class Solid extends THREE.Mesh {
|
|
|
7779
7844
|
return JSON.parse(brepSerialized);
|
|
7780
7845
|
}
|
|
7781
7846
|
/**
|
|
7782
|
-
* Subtracts
|
|
7847
|
+
* Subtracts one or more boolean operands from this solid.
|
|
7848
|
+
*
|
|
7849
|
+
* This is the main shape-level boolean workflow after operations like
|
|
7850
|
+
* `polygon.extrude(height)` or `Solid.extrude(...)`.
|
|
7783
7851
|
*/
|
|
7784
|
-
subtract(
|
|
7785
|
-
return subtractShapeOperand(this,
|
|
7852
|
+
subtract(operands, options) {
|
|
7853
|
+
return subtractShapeOperand(this, operands, options);
|
|
7786
7854
|
}
|
|
7787
7855
|
/**
|
|
7788
7856
|
* Rebuilds the visible mesh and outline from the current freeform geometry.
|
|
@@ -8141,6 +8209,9 @@ class Polygon extends THREE.Mesh {
|
|
|
8141
8209
|
}
|
|
8142
8210
|
/**
|
|
8143
8211
|
* Builds a kernel-backed `Solid` by extruding this polygon face by `height`.
|
|
8212
|
+
*
|
|
8213
|
+
* This is the recommended public path when a browser CAD or AEC workflow
|
|
8214
|
+
* starts from a planar profile and needs a boolean-ready solid.
|
|
8144
8215
|
*/
|
|
8145
8216
|
extrude(height) {
|
|
8146
8217
|
const config = this.getConfig();
|
|
@@ -8169,10 +8240,10 @@ class Polygon extends THREE.Mesh {
|
|
|
8169
8240
|
return brepData;
|
|
8170
8241
|
}
|
|
8171
8242
|
/**
|
|
8172
|
-
* Subtracts
|
|
8243
|
+
* Subtracts one or more boolean operands from this polygon.
|
|
8173
8244
|
*/
|
|
8174
|
-
subtract(
|
|
8175
|
-
return subtractShapeOperand(this,
|
|
8245
|
+
subtract(operands, options) {
|
|
8246
|
+
return subtractShapeOperand(this, operands, options);
|
|
8176
8247
|
}
|
|
8177
8248
|
set outlineColor(color) {
|
|
8178
8249
|
this._outlineColor = color;
|
|
@@ -8464,10 +8535,10 @@ class Cylinder extends THREE.Mesh {
|
|
|
8464
8535
|
return JSON.parse(brepData);
|
|
8465
8536
|
}
|
|
8466
8537
|
/**
|
|
8467
|
-
* Subtracts
|
|
8538
|
+
* Subtracts one or more boolean operands, such as Opening volumes, from this cylinder.
|
|
8468
8539
|
*/
|
|
8469
|
-
subtract(
|
|
8470
|
-
return subtractShapeOperand(this,
|
|
8540
|
+
subtract(operands, options) {
|
|
8541
|
+
return subtractShapeOperand(this, operands, options);
|
|
8471
8542
|
}
|
|
8472
8543
|
set outline(enable) {
|
|
8473
8544
|
this._outlineEnabled = enable;
|
|
@@ -8675,10 +8746,10 @@ class Cuboid extends THREE.Mesh {
|
|
|
8675
8746
|
return JSON.parse(brepData);
|
|
8676
8747
|
}
|
|
8677
8748
|
/**
|
|
8678
|
-
* Subtracts
|
|
8749
|
+
* Subtracts one or more boolean operands, such as Opening volumes, from this cuboid.
|
|
8679
8750
|
*/
|
|
8680
|
-
subtract(
|
|
8681
|
-
return subtractShapeOperand(this,
|
|
8751
|
+
subtract(operands, options) {
|
|
8752
|
+
return subtractShapeOperand(this, operands, options);
|
|
8682
8753
|
}
|
|
8683
8754
|
set outline(enable) {
|
|
8684
8755
|
this._outlineEnabled = enable;
|
|
@@ -9000,16 +9071,19 @@ class Opening extends THREE.Mesh {
|
|
|
9000
9071
|
return JSON.parse(brepData);
|
|
9001
9072
|
}
|
|
9002
9073
|
/**
|
|
9003
|
-
* Subtracts
|
|
9074
|
+
* Subtracts one or more boolean operands from this opening volume.
|
|
9004
9075
|
*/
|
|
9005
|
-
subtract(
|
|
9006
|
-
return subtractShapeOperand(this,
|
|
9076
|
+
subtract(operands, options) {
|
|
9077
|
+
return subtractShapeOperand(this, operands, options);
|
|
9007
9078
|
}
|
|
9008
9079
|
/**
|
|
9009
9080
|
* Uses this opening volume to cut a host shape.
|
|
9081
|
+
*
|
|
9082
|
+
* Prefer this helper for wall, slab, and other host-cutting workflows in
|
|
9083
|
+
* browser-based AEC/BIM tools.
|
|
9010
9084
|
*/
|
|
9011
9085
|
subtractFrom(host, options) {
|
|
9012
|
-
return
|
|
9086
|
+
return booleanSubtraction(host, this, options);
|
|
9013
9087
|
}
|
|
9014
9088
|
set outline(enable) {
|
|
9015
9089
|
this._outlineEnabled = enable;
|
|
@@ -9283,10 +9357,10 @@ class Sphere extends THREE.Mesh {
|
|
|
9283
9357
|
return JSON.parse(brepData);
|
|
9284
9358
|
}
|
|
9285
9359
|
/**
|
|
9286
|
-
* Subtracts
|
|
9360
|
+
* Subtracts one or more boolean operands, such as Opening volumes, from this sphere.
|
|
9287
9361
|
*/
|
|
9288
|
-
subtract(
|
|
9289
|
-
return subtractShapeOperand(this,
|
|
9362
|
+
subtract(operands, options) {
|
|
9363
|
+
return subtractShapeOperand(this, operands, options);
|
|
9290
9364
|
}
|
|
9291
9365
|
set outline(enable) {
|
|
9292
9366
|
this._outlineEnabled = enable;
|
|
@@ -9551,10 +9625,10 @@ class Wedge extends THREE.Mesh {
|
|
|
9551
9625
|
return JSON.parse(brepData);
|
|
9552
9626
|
}
|
|
9553
9627
|
/**
|
|
9554
|
-
* Subtracts
|
|
9628
|
+
* Subtracts one or more boolean operands, such as Opening volumes, from this wedge.
|
|
9555
9629
|
*/
|
|
9556
|
-
subtract(
|
|
9557
|
-
return subtractShapeOperand(this,
|
|
9630
|
+
subtract(operands, options) {
|
|
9631
|
+
return subtractShapeOperand(this, operands, options);
|
|
9558
9632
|
}
|
|
9559
9633
|
set outline(enable) {
|
|
9560
9634
|
this._outlineEnabled = enable;
|
|
@@ -9850,10 +9924,10 @@ class Sweep extends THREE.Mesh {
|
|
|
9850
9924
|
return JSON.parse(brepData);
|
|
9851
9925
|
}
|
|
9852
9926
|
/**
|
|
9853
|
-
* Subtracts
|
|
9927
|
+
* Subtracts one or more boolean operands, such as Opening volumes, from this sweep.
|
|
9854
9928
|
*/
|
|
9855
|
-
subtract(
|
|
9856
|
-
return subtractShapeOperand(this,
|
|
9929
|
+
subtract(operands, options) {
|
|
9930
|
+
return subtractShapeOperand(this, operands, options);
|
|
9857
9931
|
}
|
|
9858
9932
|
set outline(enable) {
|
|
9859
9933
|
this._outlineEnabled = enable;
|
|
@@ -10149,7 +10223,7 @@ function createOffsetExample(scene) {
|
|
|
10149
10223
|
],
|
|
10150
10224
|
color: 0x0f172a,
|
|
10151
10225
|
});
|
|
10152
|
-
const polylineOffset = basePolyline.getOffset(0.45,
|
|
10226
|
+
const polylineOffset = basePolyline.getOffset(0.45, 35.0, true);
|
|
10153
10227
|
const polylineOffsetPrimitive = new Polyline({
|
|
10154
10228
|
points: polylineOffset.points,
|
|
10155
10229
|
color: 0xdc2626,
|
|
@@ -10235,7 +10309,7 @@ function createWallFromOffsetsExample(scene) {
|
|
|
10235
10309
|
});
|
|
10236
10310
|
const wallThickness = 0.45;
|
|
10237
10311
|
const half = wallThickness * 0.5;
|
|
10238
|
-
const acuteThreshold =
|
|
10312
|
+
const acuteThreshold = 35.0;
|
|
10239
10313
|
const bevel = true;
|
|
10240
10314
|
const leftOffset = centerline.getOffset(half, acuteThreshold, bevel);
|
|
10241
10315
|
const rightOffset = centerline.getOffset(-0.225, acuteThreshold, bevel);
|
|
@@ -10591,23 +10665,18 @@ class OpenGeometry {
|
|
|
10591
10665
|
this._enableDebug = false;
|
|
10592
10666
|
}
|
|
10593
10667
|
/**
|
|
10594
|
-
* Asynchronously
|
|
10668
|
+
* Asynchronously initializes the OpenGeometry wasm runtime and returns a
|
|
10669
|
+
* cached singleton instance on subsequent calls.
|
|
10595
10670
|
*
|
|
10596
|
-
*
|
|
10597
|
-
* rendering context and the WebAssembly module. It ensures all required
|
|
10598
|
-
* options are provided and prepares the instance for 3D geometry operations.
|
|
10671
|
+
* Call this before constructing `Vector3` or any kernel-backed wrapper.
|
|
10599
10672
|
*
|
|
10600
10673
|
* @param options - Configuration object for initializing OpenGeometry.
|
|
10601
10674
|
* @returns A promise that resolves to a fully initialized OpenGeometry instance.
|
|
10602
|
-
* @throws If any of the required options (`container`, `scene`, or `camera`) are missing.
|
|
10603
10675
|
*
|
|
10604
10676
|
* @example
|
|
10605
10677
|
* ```ts
|
|
10606
|
-
*
|
|
10607
|
-
*
|
|
10608
|
-
* scene: threeScene,
|
|
10609
|
-
* camera: threeCamera,
|
|
10610
|
-
* wasmURL: '/assets/opengeometry.wasm'
|
|
10678
|
+
* await OpenGeometry.create({
|
|
10679
|
+
* wasmURL: "/opengeometry_bg.wasm",
|
|
10611
10680
|
* });
|
|
10612
10681
|
* ```
|
|
10613
10682
|
*/
|
|
@@ -10634,5 +10703,5 @@ class OpenGeometry {
|
|
|
10634
10703
|
OpenGeometry.version = OPEN_GEOMETRY_THREE_VERSION;
|
|
10635
10704
|
OpenGeometry.instance = null;
|
|
10636
10705
|
|
|
10637
|
-
export { Arc, BooleanResult, Cuboid, Curve, Cylinder, FreeformEditor, FreeformGeometry, Line, OGSceneManager, OpenGeometry, Opening, Polygon, Polyline, Rectangle, Solid, Sphere, SpotLabel, Sweep, Vector3, Wedge, booleanIntersection, booleanSubtraction, booleanUnion, clonePlacement, createBooleanExample, createEditorModesExample, createFreeformEditor, createFreeformGeometry, createOffsetExample, createParametricEditCapabilities, createPrimitivesExample, createShapesExample, createSweepExample, createWallFromOffsetsExample, extrudeBrepFace, toObjectTransformation$1 as toObjectTransformation };
|
|
10706
|
+
export { Arc, BooleanResult, Cuboid, Curve, Cylinder, FreeformEditor, FreeformGeometry, Line, OGSceneManager, OpenGeometry, Opening, Polygon, Polyline, Rectangle, Solid, Sphere, SpotLabel, Sweep, Vector3, Wedge, booleanIntersection, booleanSubtraction, booleanUnion, clonePlacement, createBooleanExample, createEditorModesExample, createFreeformEditor, createFreeformGeometry, createOffsetExample, createParametricEditCapabilities, createPrimitivesExample, createShapesExample, createSweepExample, createWallFromOffsetsExample, executeBooleanSubtractionMany, extrudeBrepFace, toObjectTransformation$1 as toObjectTransformation };
|
|
10638
10707
|
//# sourceMappingURL=index.js.map
|