opengeometry 2.0.2 → 2.0.3

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 (39) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +12 -0
  3. package/index.js +683 -283
  4. package/index.js.map +1 -1
  5. package/opengeometry/pkg/opengeometry.d.ts +207 -197
  6. package/opengeometry/pkg/opengeometry.js +76 -14
  7. package/opengeometry/pkg/opengeometry_bg.wasm +0 -0
  8. package/opengeometry/pkg/opengeometry_bg.wasm.d.ts +202 -197
  9. package/opengeometry_bg.wasm +0 -0
  10. package/opengeometry_bg.wasm.d.ts +202 -197
  11. package/package.json +1 -1
  12. package/src/base-types.d.ts +7 -1
  13. package/src/editor/freeform.d.ts +63 -0
  14. package/src/editor/index.d.ts +3 -0
  15. package/src/editor/parametric.d.ts +10 -0
  16. package/src/editor/types.d.ts +72 -0
  17. package/src/freeform/geometry.d.ts +59 -0
  18. package/src/freeform/index.d.ts +3 -0
  19. package/src/freeform/types.d.ts +12 -0
  20. package/src/operations/boolean.d.ts +15 -0
  21. package/src/operations/extrude.d.ts +9 -0
  22. package/src/operations/index.d.ts +1 -0
  23. package/src/primitives/arc.d.ts +15 -0
  24. package/src/primitives/curve.d.ts +18 -0
  25. package/src/primitives/line.d.ts +15 -0
  26. package/src/primitives/polyline.d.ts +18 -0
  27. package/src/primitives/rectangle.d.ts +18 -0
  28. package/src/shapes/boolean-subtract.d.ts +9 -0
  29. package/src/shapes/cuboid.d.ts +15 -0
  30. package/src/shapes/cylinder.d.ts +15 -0
  31. package/src/shapes/extrusion.d.ts +64 -0
  32. package/src/shapes/index.d.ts +1 -0
  33. package/src/shapes/opening.d.ts +15 -0
  34. package/src/shapes/outline-utils.d.ts +21 -0
  35. package/src/shapes/polygon.d.ts +30 -3
  36. package/src/shapes/solid.d.ts +111 -0
  37. package/src/shapes/sphere.d.ts +15 -0
  38. package/src/shapes/sweep.d.ts +15 -0
  39. package/src/shapes/wedge.d.ts +15 -0
@@ -0,0 +1,64 @@
1
+ import { Vector3 } from "../../opengeometry/pkg/opengeometry.js";
2
+ import * as THREE from "three";
3
+ import type { ShapeSubtractOperand, ShapeSubtractOptions, ShapeSubtractResult } from "./boolean-subtract.js";
4
+ export interface IExtrusionOptions {
5
+ ogid?: string;
6
+ vertices: Vector3[];
7
+ holes?: Vector3[][];
8
+ height: number;
9
+ color: number;
10
+ fatOutlines?: boolean;
11
+ outlineWidth?: number;
12
+ translation?: Vector3;
13
+ rotation?: Vector3;
14
+ scale?: Vector3;
15
+ }
16
+ export interface ExtrusionPlacementOptions {
17
+ translation?: Vector3;
18
+ rotation?: Vector3;
19
+ scale?: Vector3;
20
+ }
21
+ export type ExtrusionConfigUpdate = Partial<Omit<IExtrusionOptions, "translation" | "rotation" | "scale">>;
22
+ export type ExtrusionPlacementUpdate = ExtrusionPlacementOptions;
23
+ export declare class Extrusion extends THREE.Mesh {
24
+ #private;
25
+ ogid: string;
26
+ options: IExtrusionOptions;
27
+ private extrusion;
28
+ private _outlineEnabled;
29
+ private _fatOutlines;
30
+ private _outlineWidth;
31
+ private _outlineColor;
32
+ set color(color: number);
33
+ constructor(options?: IExtrusionOptions);
34
+ validateOptions(): void;
35
+ setConfig(options: ExtrusionConfigUpdate): void;
36
+ getConfig(): IExtrusionOptions;
37
+ getAnchor(): Vector3;
38
+ setAnchor(anchor: Vector3): void;
39
+ resetAnchor(): void;
40
+ setPlacement(placement: ExtrusionPlacementUpdate): void;
41
+ setTransform(translation: Vector3, rotation: Vector3, scale: Vector3): void;
42
+ setTranslation(translation: Vector3): void;
43
+ setRotation(rotation: Vector3): void;
44
+ setScale(scale: Vector3): void;
45
+ getPlacement(): import("../editor.js").ParametricPlacement;
46
+ getEditCapabilities(): import("../editor.js").ParametricEditCapabilities;
47
+ canConvertToFreeform(): boolean;
48
+ toFreeform(id?: string): import("../freeform.js").FreeformGeometry;
49
+ cleanGeometry(): void;
50
+ generateGeometry(): void;
51
+ getBrepData(): any;
52
+ subtract(operand: ShapeSubtractOperand, options?: ShapeSubtractOptions): ShapeSubtractResult;
53
+ set outlineColor(color: number);
54
+ get outlineColor(): number;
55
+ set outline(enable: boolean);
56
+ get outline(): boolean;
57
+ set fatOutlines(value: boolean);
58
+ get fatOutlines(): boolean;
59
+ set outlineWidth(value: number);
60
+ get outlineWidth(): number;
61
+ clearOutlineMesh(): void;
62
+ discardGeometry(): void;
63
+ private writePositionsToGeometry;
64
+ }
@@ -2,6 +2,7 @@
2
2
  * High-level 3D shape wrappers backed by the OpenGeometry kernel.
3
3
  */
4
4
  export * from './polygon.js';
5
+ export * from './solid.js';
5
6
  export * from './cylinder.js';
6
7
  export * from './cuboid.js';
7
8
  export * from './opening.js';
@@ -2,6 +2,9 @@ import { Vector3 } from "../../opengeometry/pkg/opengeometry.js";
2
2
  import * as THREE from "three";
3
3
  import { ShapeOutlineMesh } from "./outline-utils.js";
4
4
  import type { ShapeSubtractOperand, ShapeSubtractOptions, ShapeSubtractResult } from "./boolean-subtract.js";
5
+ /**
6
+ * Construction options for an architectural opening volume.
7
+ */
5
8
  export interface IOpeningOptions {
6
9
  ogid?: string;
7
10
  center: Vector3;
@@ -15,13 +18,25 @@ export interface IOpeningOptions {
15
18
  rotation?: Vector3;
16
19
  scale?: Vector3;
17
20
  }
21
+ /**
22
+ * Placement updates accepted by `Opening`.
23
+ */
18
24
  export interface OpeningPlacementOptions {
19
25
  translation?: Vector3;
20
26
  rotation?: Vector3;
21
27
  scale?: Vector3;
22
28
  }
29
+ /**
30
+ * Partial config payload accepted by `Opening.setConfig(...)`.
31
+ */
23
32
  export type OpeningConfigUpdate = Partial<Omit<IOpeningOptions, "translation" | "rotation" | "scale">>;
33
+ /**
34
+ * Alias for `Opening` placement updates.
35
+ */
24
36
  export type OpeningPlacementUpdate = OpeningPlacementOptions;
37
+ /**
38
+ * Opening wrapper used as a subtractive solid in architectural workflows.
39
+ */
25
40
  export declare class Opening extends THREE.Mesh {
26
41
  #private;
27
42
  ogid: string;
@@ -1,14 +1,35 @@
1
1
  import * as THREE from "three";
2
2
  import { LineSegments2 } from "three/examples/jsm/lines/LineSegments2.js";
3
+ /**
4
+ * Outline mesh variants used by shape wrappers.
5
+ */
3
6
  export type ShapeOutlineMesh = THREE.LineSegments | LineSegments2;
7
+ /**
8
+ * Options for building a shape outline mesh.
9
+ */
4
10
  export interface ShapeOutlineMeshOptions {
5
11
  positions: number[];
6
12
  color?: number;
7
13
  fatOutlines?: boolean;
8
14
  outlineWidth?: number;
9
15
  }
16
+ /**
17
+ * Clamps outline width inputs to the supported positive finite range.
18
+ */
10
19
  export declare function sanitizeOutlineWidth(width?: number): number;
20
+ /**
21
+ * Creates either a thin or fat outline mesh from line segment positions.
22
+ */
11
23
  export declare function createShapeOutlineMesh({ positions, color, fatOutlines, outlineWidth, }: ShapeOutlineMeshOptions): ShapeOutlineMesh;
24
+ /**
25
+ * Disposes the geometry and material owned by an outline mesh.
26
+ */
12
27
  export declare function disposeShapeOutlineMesh(mesh: ShapeOutlineMesh | null): void;
28
+ /**
29
+ * Updates the color of an existing outline mesh in place.
30
+ */
13
31
  export declare function setShapeOutlineColor(mesh: ShapeOutlineMesh | null, color: number): void;
32
+ /**
33
+ * Reads the current outline color, falling back when no outline exists.
34
+ */
14
35
  export declare function getShapeOutlineColor(mesh: ShapeOutlineMesh | null, fallback?: number): number;
@@ -1,6 +1,10 @@
1
1
  import * as THREE from "three";
2
2
  import { OGPolygon, Vector3 } from "../../opengeometry/pkg/opengeometry.js";
3
+ import { Solid } from "./solid.js";
3
4
  import type { ShapeSubtractOperand, ShapeSubtractOptions, ShapeSubtractResult } from "./boolean-subtract.js";
5
+ /**
6
+ * Construction options for a planar polygon.
7
+ */
4
8
  export interface IPolygonOptions {
5
9
  ogid?: string;
6
10
  vertices: Vector3[];
@@ -17,8 +21,17 @@ export interface PolygonPlacementOptions {
17
21
  rotation?: Vector3;
18
22
  scale?: Vector3;
19
23
  }
24
+ /**
25
+ * Partial polygon config updates that regenerate the profile when geometry changes.
26
+ */
20
27
  export type PolygonConfigUpdate = Partial<Omit<IPolygonOptions, "translation" | "rotation" | "scale">>;
28
+ /**
29
+ * Placement updates accepted by `Polygon`.
30
+ */
21
31
  export type PolygonPlacementUpdate = PolygonPlacementOptions;
32
+ /**
33
+ * Planar polygon mesh with support for holes, booleans, and extrusion to `Solid`.
34
+ */
22
35
  export declare class Polygon extends THREE.Mesh {
23
36
  #private;
24
37
  ogid: string;
@@ -28,10 +41,8 @@ export declare class Polygon extends THREE.Mesh {
28
41
  private _fatOutlines;
29
42
  private _outlineWidth;
30
43
  private _outlineColor;
31
- transformationMatrix: THREE.Matrix4;
32
44
  set color(color: number);
33
45
  get color(): number;
34
- private _geometryCenterOffset;
35
46
  constructor(options?: IPolygonOptions);
36
47
  validateOptions(): void;
37
48
  setConfig(options: PolygonConfigUpdate): void;
@@ -45,14 +56,29 @@ export declare class Polygon extends THREE.Mesh {
45
56
  setRotation(rotation: Vector3): void;
46
57
  setScale(scale: Vector3): void;
47
58
  getPlacement(): import("../editor.js").ParametricPlacement;
59
+ /**
60
+ * Returns the editing capability payload advertised by parametric wrappers.
61
+ */
48
62
  getEditCapabilities(): import("../editor.js").ParametricEditCapabilities;
63
+ /**
64
+ * Polygon always supports conversion into the freeform editing wrapper.
65
+ */
49
66
  canConvertToFreeform(): boolean;
67
+ /**
68
+ * Returns a freeform wrapper for direct BRep editing of this polygon.
69
+ */
50
70
  toFreeform(id?: string): import("../freeform.js").FreeformGeometry;
51
71
  cleanGeometry(): void;
52
72
  generateGeometry(): void;
53
73
  addVertices(vertices: Vector3[]): void;
54
- saveTransformationToBREP(): void;
55
74
  addHole(holeVertices: Vector3[]): void;
75
+ /**
76
+ * Builds a kernel-backed `Solid` by extruding this polygon face by `height`.
77
+ */
78
+ extrude(height: number): Solid;
79
+ /**
80
+ * Returns the serialized BRep payload for this polygon.
81
+ */
56
82
  getBrepData(): string | null;
57
83
  /**
58
84
  * Subtracts another boolean operand from this polygon.
@@ -70,4 +96,5 @@ export declare class Polygon extends THREE.Mesh {
70
96
  private clearOutlineMesh;
71
97
  dispose(): void;
72
98
  private writePositionsToGeometry;
99
+ private disposeResources;
73
100
  }
@@ -0,0 +1,111 @@
1
+ import { Vector3 } from "../../opengeometry/pkg/opengeometry.js";
2
+ import * as THREE from "three";
3
+ import { type FreeformGeometry } from "../freeform.js";
4
+ import type { FreeformSource } from "../freeform/types.js";
5
+ import type { ShapeSubtractOperand, ShapeSubtractOptions, ShapeSubtractResult } from "./boolean-subtract.js";
6
+ /**
7
+ * Construction options for a generic BRep-backed solid.
8
+ */
9
+ export interface ISolidOptions {
10
+ ogid?: string;
11
+ brep: FreeformSource;
12
+ color: number;
13
+ fatOutlines?: boolean;
14
+ outlineWidth?: number;
15
+ anchor?: Vector3;
16
+ translation?: Vector3;
17
+ rotation?: Vector3;
18
+ scale?: Vector3;
19
+ }
20
+ /**
21
+ * Placement updates accepted by `Solid`.
22
+ */
23
+ export interface SolidPlacementOptions {
24
+ translation?: Vector3;
25
+ rotation?: Vector3;
26
+ scale?: Vector3;
27
+ }
28
+ /**
29
+ * Additional options accepted when creating a `Solid` through face extrusion.
30
+ */
31
+ export interface ExtrudeSolidOptions extends Omit<ISolidOptions, "brep" | "ogid" | "anchor" | "translation" | "rotation" | "scale"> {
32
+ ogid?: string;
33
+ anchor?: Vector3;
34
+ translation?: Vector3;
35
+ rotation?: Vector3;
36
+ scale?: Vector3;
37
+ }
38
+ /**
39
+ * Generic renderable BRep-backed solid used for extrusion outputs and other
40
+ * kernel results that are not dedicated parametric shapes.
41
+ */
42
+ export declare class Solid extends THREE.Mesh {
43
+ #private;
44
+ ogid: string;
45
+ options: ISolidOptions;
46
+ private solid;
47
+ private _outlineEnabled;
48
+ private _fatOutlines;
49
+ private _outlineWidth;
50
+ private _outlineColor;
51
+ set color(color: number);
52
+ get color(): number;
53
+ constructor(options: ISolidOptions);
54
+ /**
55
+ * Extrudes a face-like BRep source and wraps the result as a renderable solid.
56
+ */
57
+ static extrude(source: FreeformSource, height: number, options: ExtrudeSolidOptions): Solid;
58
+ /**
59
+ * Returns the current placement values as cloned vectors.
60
+ */
61
+ getPlacement(): import("../editor.js").ParametricPlacement;
62
+ /**
63
+ * Applies translation, rotation, and scale updates to the wrapped BRep.
64
+ */
65
+ setPlacement(placement: SolidPlacementOptions): void;
66
+ setTransform(translation: Vector3, rotation: Vector3, scale: Vector3): void;
67
+ setTranslation(translation: Vector3): void;
68
+ setRotation(rotation: Vector3): void;
69
+ setScale(scale: Vector3): void;
70
+ getAnchor(): Vector3;
71
+ setAnchor(anchor: Vector3): void;
72
+ /**
73
+ * Solid is always convertible back to the freeform editing wrapper.
74
+ */
75
+ canConvertToFreeform(): boolean;
76
+ /**
77
+ * Returns a freeform wrapper for direct editing of this solid's BRep.
78
+ */
79
+ toFreeform(id?: string): FreeformGeometry;
80
+ /**
81
+ * Returns the world-space serialized BRep payload for this solid.
82
+ */
83
+ getBrepSerialized(): string;
84
+ /**
85
+ * Returns the local-space serialized BRep payload for this solid.
86
+ */
87
+ getLocalBrepSerialized(): string;
88
+ /**
89
+ * Returns the parsed world-space BRep object for this solid.
90
+ */
91
+ getBrepData(): any;
92
+ /**
93
+ * Subtracts another boolean operand from this solid.
94
+ */
95
+ subtract(operand: ShapeSubtractOperand, options?: ShapeSubtractOptions): ShapeSubtractResult;
96
+ /**
97
+ * Rebuilds the visible mesh and outline from the current freeform geometry.
98
+ */
99
+ generateGeometry(): void;
100
+ set outlineColor(color: number);
101
+ get outlineColor(): number;
102
+ set outline(enable: boolean);
103
+ get outline(): boolean;
104
+ set fatOutlines(value: boolean);
105
+ get fatOutlines(): boolean;
106
+ set outlineWidth(value: number);
107
+ get outlineWidth(): number;
108
+ clearOutlineMesh(): void;
109
+ private getPlacementTransform;
110
+ private writePositionsToGeometry;
111
+ }
@@ -3,6 +3,9 @@ import { Vector3 } from "../../opengeometry/pkg/opengeometry.js";
3
3
  import * as THREE from "three";
4
4
  import { ShapeOutlineMesh } from "./outline-utils.js";
5
5
  import type { ShapeSubtractOperand, ShapeSubtractOptions, ShapeSubtractResult } from "./boolean-subtract.js";
6
+ /**
7
+ * Construction options for a sphere shape.
8
+ */
6
9
  export interface ISphereOptions {
7
10
  ogid?: string;
8
11
  center: Vector3;
@@ -16,13 +19,25 @@ export interface ISphereOptions {
16
19
  rotation?: Vector3;
17
20
  scale?: Vector3;
18
21
  }
22
+ /**
23
+ * Placement updates accepted by `Sphere`.
24
+ */
19
25
  export interface SpherePlacementOptions {
20
26
  translation?: Vector3;
21
27
  rotation?: Vector3;
22
28
  scale?: Vector3;
23
29
  }
30
+ /**
31
+ * Partial config payload accepted by `Sphere.setConfig(...)`.
32
+ */
24
33
  export type SphereConfigUpdate = Partial<Omit<ISphereOptions, "translation" | "rotation" | "scale">>;
34
+ /**
35
+ * Alias for `Sphere` placement updates.
36
+ */
25
37
  export type SpherePlacementUpdate = SpherePlacementOptions;
38
+ /**
39
+ * Sphere wrapper backed by the kernel sphere primitive.
40
+ */
26
41
  export declare class Sphere extends THREE.Mesh {
27
42
  #private;
28
43
  ogid: string;
@@ -2,6 +2,9 @@ import * as OGKernel from "../../opengeometry/pkg/opengeometry.js";
2
2
  import { Vector3 } from "../../opengeometry/pkg/opengeometry.js";
3
3
  import * as THREE from "three";
4
4
  import type { ShapeSubtractOperand, ShapeSubtractOptions, ShapeSubtractResult } from "./boolean-subtract.js";
5
+ /**
6
+ * Construction options for a swept solid.
7
+ */
5
8
  export interface ISweepOptions {
6
9
  ogid?: string;
7
10
  path: Vector3[];
@@ -15,13 +18,25 @@ export interface ISweepOptions {
15
18
  rotation?: Vector3;
16
19
  scale?: Vector3;
17
20
  }
21
+ /**
22
+ * Placement updates accepted by `Sweep`.
23
+ */
18
24
  export interface SweepPlacementOptions {
19
25
  translation?: Vector3;
20
26
  rotation?: Vector3;
21
27
  scale?: Vector3;
22
28
  }
29
+ /**
30
+ * Partial config payload accepted by `Sweep.setConfig(...)`.
31
+ */
23
32
  export type SweepConfigUpdate = Partial<Omit<ISweepOptions, "translation" | "rotation" | "scale">>;
33
+ /**
34
+ * Alias for `Sweep` placement updates.
35
+ */
24
36
  export type SweepPlacementUpdate = SweepPlacementOptions;
37
+ /**
38
+ * Sweep wrapper backed by the kernel sweep primitive.
39
+ */
25
40
  export declare class Sweep extends THREE.Mesh {
26
41
  #private;
27
42
  ogid: string;
@@ -2,6 +2,9 @@ import { Vector3 } from "../../opengeometry/pkg/opengeometry.js";
2
2
  import * as THREE from "three";
3
3
  import { ShapeOutlineMesh } from "./outline-utils.js";
4
4
  import type { ShapeSubtractOperand, ShapeSubtractOptions, ShapeSubtractResult } from "./boolean-subtract.js";
5
+ /**
6
+ * Construction options for a wedge/prism shape.
7
+ */
5
8
  export interface IWedgeOptions {
6
9
  ogid?: string;
7
10
  center: Vector3;
@@ -15,13 +18,25 @@ export interface IWedgeOptions {
15
18
  rotation?: Vector3;
16
19
  scale?: Vector3;
17
20
  }
21
+ /**
22
+ * Placement updates accepted by `Wedge`.
23
+ */
18
24
  export interface WedgePlacementOptions {
19
25
  translation?: Vector3;
20
26
  rotation?: Vector3;
21
27
  scale?: Vector3;
22
28
  }
29
+ /**
30
+ * Partial config payload accepted by `Wedge.setConfig(...)`.
31
+ */
23
32
  export type WedgeConfigUpdate = Partial<Omit<IWedgeOptions, "translation" | "rotation" | "scale">>;
33
+ /**
34
+ * Alias for `Wedge` placement updates.
35
+ */
24
36
  export type WedgePlacementUpdate = WedgePlacementOptions;
37
+ /**
38
+ * Wedge wrapper backed by the kernel wedge primitive.
39
+ */
25
40
  export declare class Wedge extends THREE.Mesh {
26
41
  #private;
27
42
  ogid: string;