Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
91 changes: 51 additions & 40 deletions OpenGeometry/.atlas-analysis.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
"projectDescription": "A high-performance CAD kernel for the web, providing 2D/3D geometric primitives and CAD operations via WebAssembly.",
"theme": "almond",
"primaryColor": "#4460FF",
"lightColor": null,
"darkColor": null,
"lightColor": "#4460FF",
"darkColor": "#4460FF",
"navigation": {
"tabs": [
{
"tab": "Documentation",
"groups": [
{
"group": "Get Started",
"group": "Introduction",
"pages": [
"introduction",
"what-is-opengeometry",
"installation",
"quickstart"
]
Expand All @@ -23,15 +23,11 @@
"group": "Core Concepts",
"pages": [
"concepts/architecture",
"concepts/brep",
"concepts/scene-graph"
]
},
{
"group": "Integration",
"pages": [
"integration/threejs",
"integration/examples"
"concepts/primitives-and-shapes",
"concepts/operations",
"concepts/booleans",
"concepts/exports",
"concepts/brep"
]
}
]
Expand All @@ -57,7 +53,8 @@
"api/shapes/cuboid",
"api/shapes/sphere",
"api/shapes/wedge",
"api/shapes/sweep"
"api/shapes/sweep",
"api/shapes/opening"
]
},
{
Expand All @@ -66,15 +63,32 @@
"api/operations/extrude",
"api/operations/offset",
"api/operations/sweep",
"api/operations/triangulate"
"api/operations/triangulate",
"api/operations/boolean-operations"
]
},
{
"group": "Scene & Export",
"group": "Export (Experimental)",
"pages": [
"api/export/stl",
"api/export/ifc",
"api/export/pdf",
"api/export/step",
"api/export/projection"
]
},
{
"group": "Scene",
"pages": [
"api/scene/scene-management",
"api/export/projection",
"api/export/pdf"
"api/scene/spot-label"
]
},
{
"group": "Core",
"pages": [
"api/core/opengeometry",
"api/core/vector3"
]
}
]
Expand All @@ -84,29 +98,26 @@
"keyFeatures": [
"WebAssembly-powered geometric kernel written in Rust",
"2D primitives: lines, arcs, rectangles, polylines, curves",
"3D shapes: polygons, cylinders, cuboids, spheres, wedges",
"CAD operations: extrusion, offset, sweep, triangulation",
"3D shapes: polygons, cylinders, cuboids, spheres, wedges, sweep, openings",
"CAD operations: extrusion, offset, sweep, triangulate, boolean operations",
"BREP (Boundary Representation) data structure",
"Scene graph management for complex models",
"Export to PDF with projection support",
"Three.js integration layer"
"Scene management via OGSceneManager",
"3D-to-2D projection with hidden line removal",
"Export to STL, STEP, IFC, PDF",
"Three.js integration layer with CSS2D markup support"
],
"publicApiSurface": [
"OGLine",
"OGArc",
"OGRectangle",
"OGPolyline",
"OGCurve",
"OGPolygon",
"OGCylinder",
"OGCuboid",
"OGSphere",
"OGWedge",
"OGScene",
"Brep",
"extrude_polygon_by_buffer_geometry",
"offset_polygon",
"sweep_operation",
"triangulate_polygon"
]
"OpenGeometry",
"OpenGeometryOptions",
"Vector3",
"OGSceneManager",
"SpotLabel",
"OUTLINE_TYPE",
"OGStlExportResult",
"OGStepExportResult",
"OGIfcExportResult"
],
"extractedAt": "2026-04-26T00:10:00.661Z",
"sourceRef": "HEAD",
"entryFile": "main/opengeometry-three/index.ts"
}
126 changes: 126 additions & 0 deletions OpenGeometry/api/core/opengeometry.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
title: OpenGeometry
description: The runtime entrypoint that initializes the WebAssembly module and provides the singleton instance
icon: rocket
---

## Overview

`OpenGeometry` is the top-level class you initialize before using any kernel-backed API. It loads and caches the WebAssembly binary, exposes version information, and provides an optional debug mode.

**Use cases:**
- Bootstrap the wasm runtime once at application startup.
- Gate geometry construction behind `await OpenGeometry.create(...)` to guarantee the wasm module is ready.
- Enable debug rendering to inspect face normals and geometry orientation during development.

## Initialization

`OpenGeometry` is a singleton — call `create` once and reuse the returned instance.

```ts
import { OpenGeometry } from "opengeometry";

const og = await OpenGeometry.create({
wasmURL: "/opengeometry_bg.wasm",
});
```

## `OpenGeometry.create` (static)

Asynchronously initializes the wasm runtime. Subsequent calls return the cached singleton without re-initializing.

```ts
static async create(options: OpenGeometryOptions): Promise<OpenGeometry>
```

Call this before constructing `Vector3` or any kernel-backed wrapper.

### Parameters

<ParamField path="options" type="OpenGeometryOptions">
Configuration object for the runtime. All fields are optional.
</ParamField>

<ParamField path="options.wasmURL" type="string">
URL to the `opengeometry_bg.wasm` binary. When omitted, the module resolves the wasm file from a default relative path.
</ParamField>

<ParamField path="options.debugMeshes" type="boolean" default="false">
Enable debug mesh overlays for visualizing internal geometry structures.
</ParamField>

## Properties

<ResponseField name="version" type="string">
The current version of the `opengeometry` package. Static read-only property — access as `OpenGeometry.version`.
</ResponseField>

<ResponseField name="instance" type="OpenGeometry | null">
The cached singleton set after the first successful `create` call. `null` before initialization. Static property.
</ResponseField>

<ResponseField name="enableDebug" type="boolean">
Enables or disables debug rendering mode. When `true`:

- Geometry renders with a semi-transparent material.
- Each face is colored randomly for visual distinction.
- Face normals are shown as overlays.

Setting this to `true` also logs `"OpenGeometry Debug Mode Enabled"` to the console. Readable and settable after initialization.
</ResponseField>

## Code examples

### Basic setup

```ts
import { OpenGeometry, Vector3 } from "opengeometry";

await OpenGeometry.create({ wasmURL: "/opengeometry_bg.wasm" });

// Vector3 and all shape wrappers are now safe to use
const origin = new Vector3(0, 0, 0);
```

### Using the cached singleton

```ts
import { OpenGeometry } from "opengeometry";

// First call — loads the wasm binary
const og = await OpenGeometry.create({ wasmURL: "/opengeometry_bg.wasm" });

// Subsequent calls return the same instance immediately
const same = await OpenGeometry.create();
console.log(og === same); // true
```

### Enabling debug mode

```ts
import { OpenGeometry } from "opengeometry";

const og = await OpenGeometry.create({ wasmURL: "/opengeometry_bg.wasm" });

og.enableDebug = true;
// All subsequently rendered shapes show normals and random face colors
```

### Checking the version at runtime

```ts
import { OpenGeometry } from "opengeometry";

console.log(OpenGeometry.version); // e.g. "2.0.3"
```

## See also

<CardGroup cols={2}>
<Card title="Vector3" icon="cube" href="/OpenGeometry/api/core/vector3">
The wasm-backed 3D vector used throughout the API
</Card>
<Card title="Scene management" icon="shapes" href="/OpenGeometry/api/scene/scene-management">
Managing collections of geometry entities with OGSceneManager
</Card>
</CardGroup>
91 changes: 91 additions & 0 deletions OpenGeometry/api/core/vector3.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
title: Vector3
description: The wasm-backed 3D vector used as the coordinate type throughout the OpenGeometry API
icon: cube
---

## Overview

`Vector3` is the shared coordinate type used across all OpenGeometry primitives, shapes, and operations. It is backed by the WebAssembly kernel, so the wasm module must be initialized with `OpenGeometry.create(...)` before you construct any `Vector3` instance.

**Use cases:**
- Supplying start, end, center, or direction coordinates to primitive and shape constructors.
- Passing position arguments to `OGSceneManager` projection and export methods.

<Warning>
Constructing `Vector3` before `await OpenGeometry.create(...)` resolves will throw a wasm initialization error. Always await initialization first.
</Warning>

## Constructor

```ts
new Vector3(x: number, y: number, z: number)
```

### Parameters

<ParamField path="x" type="number" required>
The X component of the vector.
</ParamField>

<ParamField path="y" type="number" required>
The Y component of the vector.
</ParamField>

<ParamField path="z" type="number" required>
The Z component of the vector.
</ParamField>

## Code examples

### Creating vectors after initialization

```ts
import { OpenGeometry, Vector3 } from "opengeometry";

await OpenGeometry.create({ wasmURL: "/opengeometry_bg.wasm" });

const origin = new Vector3(0, 0, 0);
const tip = new Vector3(10, 0, 0);
```

### Using Vector3 with a primitive

```ts
import { OpenGeometry, Vector3, Line } from "opengeometry";

await OpenGeometry.create({ wasmURL: "/opengeometry_bg.wasm" });

const line = new Line({
start: new Vector3(0, 0, 0),
end: new Vector3(5, 5, 0),
color: 0x000000,
});
```

### Using Vector3 with a 3D shape

```ts
import { OpenGeometry, Vector3, Cuboid } from "opengeometry";

await OpenGeometry.create({ wasmURL: "/opengeometry_bg.wasm" });

const box = new Cuboid({
center: new Vector3(0, 0.5, 0),
width: 2,
height: 1,
depth: 1,
color: 0x10b981,
});
```

## See also

<CardGroup cols={2}>
<Card title="OpenGeometry" icon="rocket" href="/OpenGeometry/api/core/opengeometry">
Initialize the runtime before constructing Vector3
</Card>
<Card title="Line" icon="minus" href="/OpenGeometry/api/primitives/line">
A simple line primitive defined by two Vector3 points
</Card>
</CardGroup>
8 changes: 2 additions & 6 deletions OpenGeometry/api/export/ifc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,7 @@ Native-only builds also expose `exportSceneToIfcFile(...)` (not available in bro

## Related

- [Exports](/OpenGeometry/concepts/exports) for an overview of available exporters and runtime constraints
- [Exports](/OpenGeometry/concepts/exports) — Overview of available exporters and runtime constraints
- [STL export](/OpenGeometry/api/export/stl)
- [STEP export](/OpenGeometry/api/export/step) (experimental)
- [Scene Management](/OpenGeometry/api/scene/scene-management) - Organizing geometry entities
## Live demo

There is no dedicated IFC export demo page yet. Start from the demo index:
[OpenGeometry demos](https://demo.opengeometry.io/).
- [Scene management](/OpenGeometry/api/scene/scene-management) — Organizing geometry entities
8 changes: 8 additions & 0 deletions OpenGeometry/api/export/projection.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ an exporter limitation or confusing output, reach out on
[Discord](https://discord.gg/cZY2Vm6E).
</Warning>

## OUTLINE_TYPE

```ts
type OUTLINE_TYPE = "front" | "side" | "top";
```

A convenience string-literal type that names the three standard orthographic views. Use it to label or select the view direction when building multi-view drawings.

## Key Concepts

### Projection Modes
Expand Down
Loading