okgeometry-api 0.2.12 → 0.2.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.
- package/dist/Arc.d.ts +52 -2
- package/dist/Arc.d.ts.map +1 -1
- package/dist/Arc.js +50 -1
- package/dist/Arc.js.map +1 -1
- package/dist/BufferCodec.d.ts +118 -0
- package/dist/BufferCodec.d.ts.map +1 -0
- package/dist/BufferCodec.js +171 -0
- package/dist/BufferCodec.js.map +1 -0
- package/dist/Circle.d.ts +66 -12
- package/dist/Circle.d.ts.map +1 -1
- package/dist/Circle.js +64 -8
- package/dist/Circle.js.map +1 -1
- package/dist/Line.d.ts +53 -1
- package/dist/Line.d.ts.map +1 -1
- package/dist/Line.js +51 -0
- package/dist/Line.js.map +1 -1
- package/dist/Mesh.d.ts +167 -20
- package/dist/Mesh.d.ts.map +1 -1
- package/dist/Mesh.js +187 -70
- package/dist/Mesh.js.map +1 -1
- package/dist/NurbsCurve.d.ts +78 -8
- package/dist/NurbsCurve.d.ts.map +1 -1
- package/dist/NurbsCurve.js +76 -7
- package/dist/NurbsCurve.js.map +1 -1
- package/dist/NurbsSurface.d.ts +64 -14
- package/dist/NurbsSurface.d.ts.map +1 -1
- package/dist/NurbsSurface.js +65 -25
- package/dist/NurbsSurface.js.map +1 -1
- package/dist/Point.d.ts +65 -12
- package/dist/Point.d.ts.map +1 -1
- package/dist/Point.js +61 -2
- package/dist/Point.js.map +1 -1
- package/dist/PolyCurve.d.ts +4 -6
- package/dist/PolyCurve.d.ts.map +1 -1
- package/dist/PolyCurve.js +31 -16
- package/dist/PolyCurve.js.map +1 -1
- package/dist/Polygon.d.ts +35 -3
- package/dist/Polygon.d.ts.map +1 -1
- package/dist/Polygon.js +33 -2
- package/dist/Polygon.js.map +1 -1
- package/dist/Polyline.d.ts +67 -2
- package/dist/Polyline.d.ts.map +1 -1
- package/dist/Polyline.js +86 -13
- package/dist/Polyline.js.map +1 -1
- package/dist/Ray.d.ts +45 -0
- package/dist/Ray.d.ts.map +1 -0
- package/dist/Ray.js +68 -0
- package/dist/Ray.js.map +1 -0
- package/dist/Vec3.d.ts +76 -0
- package/dist/Vec3.d.ts.map +1 -1
- package/dist/Vec3.js +76 -0
- package/dist/Vec3.js.map +1 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +3 -2
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +67 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/wasm-base64.d.ts +1 -1
- package/dist/wasm-base64.d.ts.map +1 -1
- package/dist/wasm-base64.js +1 -1
- package/dist/wasm-base64.js.map +1 -1
- package/package.json +1 -1
- package/wasm/okgeometrycore.d.ts +27 -0
- package/wasm/okgeometrycore.js +1 -1
- package/wasm/okgeometrycore_bg.js +81 -0
- package/wasm/okgeometrycore_bg.wasm +0 -0
- package/wasm/okgeometrycore_bg.wasm.d.ts +4 -0
package/dist/Circle.js
CHANGED
|
@@ -4,31 +4,58 @@ import { Vec3 } from "./Vec3.js";
|
|
|
4
4
|
import { Mesh } from "./Mesh.js";
|
|
5
5
|
import { Polygon } from "./Polygon.js";
|
|
6
6
|
import * as wasm from "../wasm/okgeometrycore_bg.js";
|
|
7
|
+
/**
|
|
8
|
+
* Immutable circle defined by center, radius, and normal.
|
|
9
|
+
* Supports evaluation, transformation, extrusion, and projection.
|
|
10
|
+
*/
|
|
7
11
|
export class Circle {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Create a new circle.
|
|
14
|
+
* @param center - Center point
|
|
15
|
+
* @param radius - Circle radius
|
|
16
|
+
* @param normal - Normal vector defining the circle's plane (default Z axis)
|
|
17
|
+
* @param uAxis - Optional reference direction defining where t=0 starts.
|
|
18
|
+
* Critical for sweep operations to maintain consistent profile orientation.
|
|
19
|
+
*/
|
|
20
|
+
constructor(center, radius, normal = Vec3.Z, uAxis) {
|
|
13
21
|
this.center = center;
|
|
14
22
|
this.radius = radius;
|
|
15
23
|
this.normal = normal;
|
|
16
24
|
this.uAxis = uAxis;
|
|
17
25
|
}
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
26
|
+
/**
|
|
27
|
+
* Create a Circle from a Plane, automatically using the plane's xAxis
|
|
28
|
+
* as the circle's uAxis for consistent orientation in sweep operations.
|
|
29
|
+
* @param plane - Plane defining circle's position and orientation
|
|
30
|
+
* @param radius - Circle radius
|
|
31
|
+
* @returns New Circle at plane origin with plane normal
|
|
32
|
+
*/
|
|
20
33
|
static fromPlane(plane, radius) {
|
|
21
34
|
return new Circle(plane.origin, radius, plane.normal, plane.getXAxis());
|
|
22
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Evaluate a point on the circle at normalized parameter t.
|
|
38
|
+
* @param t - Parameter in [0, 1] (0 and 1 are the same point for closed circle)
|
|
39
|
+
* @returns Point on circle at parameter t
|
|
40
|
+
*/
|
|
23
41
|
pointAt(t) {
|
|
24
42
|
ensureInit();
|
|
25
43
|
const r = wasm.circle_point_at(this.center.x, this.center.y, this.center.z, this.normal.x, this.normal.y, this.normal.z, this.radius, t);
|
|
26
44
|
return new Point(r[0], r[1], r[2]);
|
|
27
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the circumference of this circle.
|
|
48
|
+
* @returns 2 * PI * radius
|
|
49
|
+
*/
|
|
28
50
|
length() {
|
|
29
51
|
ensureInit();
|
|
30
52
|
return wasm.circle_length(this.radius);
|
|
31
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Sample the circle into evenly-spaced points.
|
|
56
|
+
* @param n - Number of points to generate
|
|
57
|
+
* @returns Array of n points around the circle
|
|
58
|
+
*/
|
|
32
59
|
sample(n) {
|
|
33
60
|
ensureInit();
|
|
34
61
|
const buf = wasm.create_circle(this.center.x, this.center.y, this.center.z, this.normal.x, this.normal.y, this.normal.z, this.radius, n);
|
|
@@ -38,9 +65,20 @@ export class Circle {
|
|
|
38
65
|
}
|
|
39
66
|
return pts;
|
|
40
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Translate this circle by an offset vector.
|
|
70
|
+
* @param offset - Translation vector
|
|
71
|
+
* @returns New translated circle
|
|
72
|
+
*/
|
|
41
73
|
translate(offset) {
|
|
42
74
|
return new Circle(this.center.add(offset), this.radius, this.normal, this.uAxis);
|
|
43
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Rotate this circle around an axis.
|
|
78
|
+
* @param axis - Rotation axis (Vec3 through origin, or Line for arbitrary axis)
|
|
79
|
+
* @param angle - Rotation angle in radians
|
|
80
|
+
* @returns New rotated circle
|
|
81
|
+
*/
|
|
44
82
|
rotate(axis, angle) {
|
|
45
83
|
const n = this.normal;
|
|
46
84
|
// Normal is a direction — always rotate around origin regardless of axis type
|
|
@@ -54,15 +92,33 @@ export class Circle {
|
|
|
54
92
|
}
|
|
55
93
|
return new Circle(this.center.rotate(axis, angle), this.radius, new Vec3(rn.x, rn.y, rn.z), rotatedUAxis);
|
|
56
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Offset this circle by changing its radius.
|
|
97
|
+
* @param distance - Distance to offset (positive = larger, negative = smaller)
|
|
98
|
+
* @returns New circle with adjusted radius
|
|
99
|
+
*/
|
|
57
100
|
offset(distance) {
|
|
58
101
|
return new Circle(this.center, this.radius + distance, this.normal, this.uAxis);
|
|
59
102
|
}
|
|
60
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* Project onto plane. Returns a Polygon because a tilted circle projects to an ellipse.
|
|
105
|
+
* @param plane - Target plane
|
|
106
|
+
* @param direction - Optional projection direction (default: perpendicular to plane)
|
|
107
|
+
* @param samples - Number of sample points for approximation (default 64)
|
|
108
|
+
* @returns Polygon approximating the projected circle
|
|
109
|
+
*/
|
|
61
110
|
projectOntoPlane(plane, direction, samples = 64) {
|
|
62
111
|
const pts = this.sample(samples);
|
|
63
112
|
const proj = (p) => direction ? plane.projectPointAlongDirection(p, direction) : plane.projectPoint(p);
|
|
64
113
|
return new Polygon(pts.map(proj));
|
|
65
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Extrude this circle along a direction vector to create a cylindrical mesh.
|
|
117
|
+
* @param direction - Extrusion direction and magnitude
|
|
118
|
+
* @param segments - Number of circumferential segments (default 16)
|
|
119
|
+
* @param caps - Whether to cap the ends (default true)
|
|
120
|
+
* @returns Mesh representing the extruded cylinder
|
|
121
|
+
*/
|
|
66
122
|
extrude(direction, segments = 16, caps = true) {
|
|
67
123
|
ensureInit();
|
|
68
124
|
const buf = wasm.extrude_circle(this.center.x, this.center.y, this.center.z, this.normal.x, this.normal.y, this.normal.z, this.radius, direction.x, direction.y, direction.z, segments, caps);
|
package/dist/Circle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Circle.js","sourceRoot":"","sources":["../src/Circle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Circle.js","sourceRoot":"","sources":["../src/Circle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,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,CAAC,CAAQ,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC9G,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,SAAe,EAAE,QAAQ,GAAG,EAAE,EAAE,IAAI,GAAG,IAAI;QACjD,UAAU,EAAE,CAAC;QACb,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,CAC7B,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAC3C,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAC3C,IAAI,CAAC,MAAM,EACX,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EACrC,QAAQ,EAAE,IAAI,CACf,CAAC;QACF,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;CACF"}
|
package/dist/Line.d.ts
CHANGED
|
@@ -2,18 +2,70 @@ import { Point } from "./Point.js";
|
|
|
2
2
|
import { Vec3 } from "./Vec3.js";
|
|
3
3
|
import { Mesh } from "./Mesh.js";
|
|
4
4
|
import type { Plane } from "./Plane.js";
|
|
5
|
+
import type { RotationAxis } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Immutable line segment defined by start and end points.
|
|
8
|
+
* Supports evaluation, transformation, and extrusion operations.
|
|
9
|
+
*/
|
|
5
10
|
export declare class Line {
|
|
6
11
|
readonly start: Point;
|
|
7
12
|
readonly end: Point;
|
|
8
13
|
constructor(start: Point, end: Point);
|
|
14
|
+
/**
|
|
15
|
+
* Evaluate a point on the line at normalized parameter t.
|
|
16
|
+
* @param t - Parameter in [0, 1] (0 = start, 1 = end)
|
|
17
|
+
* @returns Point on line at parameter t
|
|
18
|
+
*/
|
|
9
19
|
pointAt(t: number): Point;
|
|
20
|
+
/**
|
|
21
|
+
* Get the length of this line segment.
|
|
22
|
+
* @returns Euclidean distance from start to end
|
|
23
|
+
*/
|
|
10
24
|
length(): number;
|
|
25
|
+
/**
|
|
26
|
+
* Get the unit direction vector of this line.
|
|
27
|
+
* @returns Normalized vector from start to end
|
|
28
|
+
*/
|
|
11
29
|
tangent(): Vec3;
|
|
30
|
+
/**
|
|
31
|
+
* Sample the line into evenly-spaced points.
|
|
32
|
+
* @param n - Number of points to generate
|
|
33
|
+
* @returns Array of n points along the line
|
|
34
|
+
*/
|
|
12
35
|
sample(n: number): Point[];
|
|
36
|
+
/**
|
|
37
|
+
* Translate this line by an offset vector.
|
|
38
|
+
* @param offset - Translation vector
|
|
39
|
+
* @returns New translated line
|
|
40
|
+
*/
|
|
13
41
|
translate(offset: Vec3): Line;
|
|
14
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Rotate this line around an axis.
|
|
44
|
+
* @param axis - Rotation axis (Vec3 through origin, or Line for arbitrary axis)
|
|
45
|
+
* @param angle - Rotation angle in radians
|
|
46
|
+
* @returns New rotated line
|
|
47
|
+
*/
|
|
48
|
+
rotate(axis: RotationAxis, angle: number): Line;
|
|
49
|
+
/**
|
|
50
|
+
* Offset this line perpendicular to its direction.
|
|
51
|
+
* @param distance - Offset distance (positive = along normal cross direction)
|
|
52
|
+
* @param normal - Reference normal for determining offset direction (default Z axis)
|
|
53
|
+
* @returns New offset line
|
|
54
|
+
*/
|
|
15
55
|
offset(distance: number, normal?: Vec3): Line;
|
|
56
|
+
/**
|
|
57
|
+
* Project this line onto a plane.
|
|
58
|
+
* @param plane - Target plane
|
|
59
|
+
* @param direction - Optional projection direction (default: perpendicular to plane)
|
|
60
|
+
* @returns New projected line
|
|
61
|
+
*/
|
|
16
62
|
projectOntoPlane(plane: Plane, direction?: Vec3): Line;
|
|
63
|
+
/**
|
|
64
|
+
* Extrude this line into a mesh surface.
|
|
65
|
+
* @param direction - Extrusion direction vector
|
|
66
|
+
* @param segments - Number of segments along extrusion (default 1)
|
|
67
|
+
* @returns Mesh representing the extruded surface
|
|
68
|
+
*/
|
|
17
69
|
extrude(direction: Vec3, segments?: number): Mesh;
|
|
18
70
|
}
|
|
19
71
|
//# sourceMappingURL=Line.d.ts.map
|
package/dist/Line.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../src/Line.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../src/Line.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C;;;GAGG;AACH,qBAAa,IAAI;aAEG,KAAK,EAAE,KAAK;aACZ,GAAG,EAAE,KAAK;gBADV,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,KAAK;IAG5B;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK;IAUzB;;;OAGG;IACH,MAAM,IAAI,MAAM;IAQhB;;;OAGG;IACH,OAAO,IAAI,IAAI;IASf;;;;OAIG;IACH,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE;IAc1B;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI;IAI7B;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAI/C;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAE,IAAa,GAAG,IAAI;IASrD;;;;;OAKG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI;IAKtD;;;;;OAKG;IACH,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,SAAI,GAAG,IAAI;CAU7C"}
|
package/dist/Line.js
CHANGED
|
@@ -3,25 +3,47 @@ import { Point } from "./Point.js";
|
|
|
3
3
|
import { Vec3 } from "./Vec3.js";
|
|
4
4
|
import { Mesh } from "./Mesh.js";
|
|
5
5
|
import * as wasm from "../wasm/okgeometrycore_bg.js";
|
|
6
|
+
/**
|
|
7
|
+
* Immutable line segment defined by start and end points.
|
|
8
|
+
* Supports evaluation, transformation, and extrusion operations.
|
|
9
|
+
*/
|
|
6
10
|
export class Line {
|
|
7
11
|
constructor(start, end) {
|
|
8
12
|
this.start = start;
|
|
9
13
|
this.end = end;
|
|
10
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Evaluate a point on the line at normalized parameter t.
|
|
17
|
+
* @param t - Parameter in [0, 1] (0 = start, 1 = end)
|
|
18
|
+
* @returns Point on line at parameter t
|
|
19
|
+
*/
|
|
11
20
|
pointAt(t) {
|
|
12
21
|
ensureInit();
|
|
13
22
|
const r = wasm.line_point_at(this.start.x, this.start.y, this.start.z, this.end.x, this.end.y, this.end.z, t);
|
|
14
23
|
return new Point(r[0], r[1], r[2]);
|
|
15
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the length of this line segment.
|
|
27
|
+
* @returns Euclidean distance from start to end
|
|
28
|
+
*/
|
|
16
29
|
length() {
|
|
17
30
|
ensureInit();
|
|
18
31
|
return wasm.line_length(this.start.x, this.start.y, this.start.z, this.end.x, this.end.y, this.end.z);
|
|
19
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the unit direction vector of this line.
|
|
35
|
+
* @returns Normalized vector from start to end
|
|
36
|
+
*/
|
|
20
37
|
tangent() {
|
|
21
38
|
ensureInit();
|
|
22
39
|
const r = wasm.line_tangent(this.start.x, this.start.y, this.start.z, this.end.x, this.end.y, this.end.z);
|
|
23
40
|
return new Vec3(r[0], r[1], r[2]);
|
|
24
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Sample the line into evenly-spaced points.
|
|
44
|
+
* @param n - Number of points to generate
|
|
45
|
+
* @returns Array of n points along the line
|
|
46
|
+
*/
|
|
25
47
|
sample(n) {
|
|
26
48
|
ensureInit();
|
|
27
49
|
const buf = wasm.create_line(this.start.x, this.start.y, this.start.z, this.end.x, this.end.y, this.end.z, n);
|
|
@@ -31,21 +53,50 @@ export class Line {
|
|
|
31
53
|
}
|
|
32
54
|
return pts;
|
|
33
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Translate this line by an offset vector.
|
|
58
|
+
* @param offset - Translation vector
|
|
59
|
+
* @returns New translated line
|
|
60
|
+
*/
|
|
34
61
|
translate(offset) {
|
|
35
62
|
return new Line(this.start.add(offset), this.end.add(offset));
|
|
36
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Rotate this line around an axis.
|
|
66
|
+
* @param axis - Rotation axis (Vec3 through origin, or Line for arbitrary axis)
|
|
67
|
+
* @param angle - Rotation angle in radians
|
|
68
|
+
* @returns New rotated line
|
|
69
|
+
*/
|
|
37
70
|
rotate(axis, angle) {
|
|
38
71
|
return new Line(this.start.rotate(axis, angle), this.end.rotate(axis, angle));
|
|
39
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Offset this line perpendicular to its direction.
|
|
75
|
+
* @param distance - Offset distance (positive = along normal cross direction)
|
|
76
|
+
* @param normal - Reference normal for determining offset direction (default Z axis)
|
|
77
|
+
* @returns New offset line
|
|
78
|
+
*/
|
|
40
79
|
offset(distance, normal = Vec3.Z) {
|
|
41
80
|
const dir = new Vec3(this.end.x - this.start.x, this.end.y - this.start.y, this.end.z - this.start.z);
|
|
42
81
|
const perp = normal.cross(dir).normalize();
|
|
43
82
|
return new Line(new Point(this.start.x + perp.x * distance, this.start.y + perp.y * distance, this.start.z + perp.z * distance), new Point(this.end.x + perp.x * distance, this.end.y + perp.y * distance, this.end.z + perp.z * distance));
|
|
44
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Project this line onto a plane.
|
|
86
|
+
* @param plane - Target plane
|
|
87
|
+
* @param direction - Optional projection direction (default: perpendicular to plane)
|
|
88
|
+
* @returns New projected line
|
|
89
|
+
*/
|
|
45
90
|
projectOntoPlane(plane, direction) {
|
|
46
91
|
const proj = (p) => direction ? plane.projectPointAlongDirection(p, direction) : plane.projectPoint(p);
|
|
47
92
|
return new Line(proj(this.start), proj(this.end));
|
|
48
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Extrude this line into a mesh surface.
|
|
96
|
+
* @param direction - Extrusion direction vector
|
|
97
|
+
* @param segments - Number of segments along extrusion (default 1)
|
|
98
|
+
* @returns Mesh representing the extruded surface
|
|
99
|
+
*/
|
|
49
100
|
extrude(direction, segments = 1) {
|
|
50
101
|
ensureInit();
|
|
51
102
|
const buf = wasm.extrude_line(this.start.x, this.start.y, this.start.z, this.end.x, this.end.y, this.end.z, direction.x, direction.y, direction.z, segments);
|
package/dist/Line.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Line.js","sourceRoot":"","sources":["../src/Line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,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|
|
4
4
|
import { Polyline } from "./Polyline.js";
|
|
5
|
-
import {
|
|
6
|
-
import { Circle } from "./Circle.js";
|
|
7
|
-
import { Arc } from "./Arc.js";
|
|
8
|
-
import { Polygon } from "./Polygon.js";
|
|
9
|
-
import { NurbsCurve } from "./NurbsCurve.js";
|
|
10
|
-
import { PolyCurve } from "./PolyCurve.js";
|
|
11
|
-
/** Any curve type that sweep/loft can accept */
|
|
12
|
-
export type SweepableCurve = Line | Circle | Arc | Polyline | Polygon | NurbsCurve | PolyCurve;
|
|
5
|
+
import type { SweepableCurve, RotationAxis } from "./types.js";
|
|
13
6
|
/**
|
|
14
|
-
* Buffer-backed mesh
|
|
7
|
+
* Buffer-backed triangle mesh with GPU-ready accessors.
|
|
8
|
+
* All geometry lives in a Float64Array from WASM.
|
|
9
|
+
*
|
|
15
10
|
* Buffer format: [vertexCount, x1,y1,z1, ..., i1,i2,i3, ...]
|
|
16
11
|
*/
|
|
17
12
|
export declare class Mesh {
|
|
@@ -22,25 +17,98 @@ export declare class Mesh {
|
|
|
22
17
|
private _vertices;
|
|
23
18
|
private _faces;
|
|
24
19
|
private constructor();
|
|
25
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Float32 xyz positions for Three.js BufferGeometry.
|
|
22
|
+
* Lazy-computed and cached.
|
|
23
|
+
*/
|
|
26
24
|
get positionBuffer(): Float32Array;
|
|
27
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Uint32 triangle indices for Three.js BufferGeometry.setIndex.
|
|
27
|
+
* Lazy-computed and cached.
|
|
28
|
+
*/
|
|
28
29
|
get indexBuffer(): Uint32Array;
|
|
30
|
+
/** Number of vertices in this mesh */
|
|
29
31
|
get vertexCount(): number;
|
|
32
|
+
/** Number of triangular faces in this mesh */
|
|
30
33
|
get faceCount(): number;
|
|
34
|
+
/**
|
|
35
|
+
* Get all vertices as Point objects.
|
|
36
|
+
* Lazy-computed and cached.
|
|
37
|
+
*/
|
|
31
38
|
get vertices(): Point[];
|
|
39
|
+
/**
|
|
40
|
+
* Get all faces as arrays of vertex indices.
|
|
41
|
+
* Each face is [i0, i1, i2] for the three triangle vertices.
|
|
42
|
+
* Lazy-computed and cached.
|
|
43
|
+
*/
|
|
32
44
|
get faces(): number[][];
|
|
33
45
|
/** Raw WASM buffer (for advanced use / re-passing to WASM) */
|
|
34
46
|
get rawBuffer(): Float64Array;
|
|
47
|
+
/**
|
|
48
|
+
* Create a Mesh from a raw WASM buffer.
|
|
49
|
+
* @param buffer - Float64Array in mesh buffer format
|
|
50
|
+
* @returns New Mesh instance
|
|
51
|
+
*/
|
|
35
52
|
static fromBuffer(buffer: Float64Array): Mesh;
|
|
36
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Create a planar patch mesh from boundary points using fan triangulation.
|
|
55
|
+
* @param pts - Boundary points defining the patch
|
|
56
|
+
* @returns New Mesh with n-2 triangles
|
|
57
|
+
*/
|
|
37
58
|
static patchFromPoints(pts: Point[]): Mesh;
|
|
59
|
+
/**
|
|
60
|
+
* Create an axis-aligned box centered at origin.
|
|
61
|
+
* @param width - Size along X axis
|
|
62
|
+
* @param height - Size along Y axis
|
|
63
|
+
* @param depth - Size along Z axis
|
|
64
|
+
* @returns New Mesh with 8 vertices and 12 triangles
|
|
65
|
+
*/
|
|
38
66
|
static createBox(width: number, height: number, depth: number): Mesh;
|
|
67
|
+
/**
|
|
68
|
+
* Create a UV sphere centered at origin.
|
|
69
|
+
* @param radius - Sphere radius
|
|
70
|
+
* @param segments - Number of longitudinal segments
|
|
71
|
+
* @param rings - Number of latitudinal rings
|
|
72
|
+
* @returns New Mesh representing the sphere
|
|
73
|
+
*/
|
|
39
74
|
static createSphere(radius: number, segments: number, rings: number): Mesh;
|
|
75
|
+
/**
|
|
76
|
+
* Create a cylinder centered at origin with axis along Y.
|
|
77
|
+
* @param radius - Cylinder radius
|
|
78
|
+
* @param height - Total height (extends height/2 above and below origin)
|
|
79
|
+
* @param segments - Number of circumferential segments
|
|
80
|
+
* @returns New Mesh with caps
|
|
81
|
+
*/
|
|
40
82
|
static createCylinder(radius: number, height: number, segments: number): Mesh;
|
|
83
|
+
/**
|
|
84
|
+
* Create a regular prism centered at origin.
|
|
85
|
+
* @param radius - Circumradius of the base polygon
|
|
86
|
+
* @param height - Total height
|
|
87
|
+
* @param sides - Number of sides (3 = triangular prism, 6 = hexagonal, etc.)
|
|
88
|
+
* @returns New Mesh with caps
|
|
89
|
+
*/
|
|
41
90
|
static createPrism(radius: number, height: number, sides: number): Mesh;
|
|
91
|
+
/**
|
|
92
|
+
* Create a cone centered at origin with apex at top.
|
|
93
|
+
* @param radius - Base radius
|
|
94
|
+
* @param height - Height from base to apex
|
|
95
|
+
* @param segments - Number of circumferential segments
|
|
96
|
+
* @returns New Mesh with base cap
|
|
97
|
+
*/
|
|
42
98
|
static createCone(radius: number, height: number, segments: number): Mesh;
|
|
99
|
+
/**
|
|
100
|
+
* Import a mesh from OBJ format string.
|
|
101
|
+
* @param objString - OBJ file content
|
|
102
|
+
* @returns New Mesh parsed from OBJ
|
|
103
|
+
*/
|
|
43
104
|
static fromOBJ(objString: string): Mesh;
|
|
105
|
+
/**
|
|
106
|
+
* Loft through multiple circles to create a surface of revolution.
|
|
107
|
+
* @param circles - Array of circle definitions (center, normal, radius)
|
|
108
|
+
* @param segments - Number of circumferential segments
|
|
109
|
+
* @param caps - Whether to cap the ends (default false)
|
|
110
|
+
* @returns New Mesh representing the lofted surface
|
|
111
|
+
*/
|
|
44
112
|
static loftCircles(circles: Array<{
|
|
45
113
|
center: Point;
|
|
46
114
|
normal?: {
|
|
@@ -50,28 +118,107 @@ export declare class Mesh {
|
|
|
50
118
|
};
|
|
51
119
|
radius: number;
|
|
52
120
|
}>, segments: number, caps?: boolean): Mesh;
|
|
121
|
+
/**
|
|
122
|
+
* Loft through multiple polylines to create a ruled surface.
|
|
123
|
+
* @param polylines - Array of point arrays defining cross-sections
|
|
124
|
+
* @param segments - Interpolation segments between sections
|
|
125
|
+
* @param caps - Whether to cap the ends (default false)
|
|
126
|
+
* @returns New Mesh representing the lofted surface
|
|
127
|
+
*/
|
|
53
128
|
static loftPolylines(polylines: Point[][], segments: number, caps?: boolean): Mesh;
|
|
129
|
+
/**
|
|
130
|
+
* Sweep a profile polyline along a path polyline.
|
|
131
|
+
* @param profilePoints - Profile cross-section points
|
|
132
|
+
* @param pathPoints - Path points to sweep along
|
|
133
|
+
* @param caps - Whether to cap the ends (default false)
|
|
134
|
+
* @returns New Mesh representing the swept surface
|
|
135
|
+
*/
|
|
54
136
|
static sweep(profilePoints: Point[], pathPoints: Point[], caps?: boolean): Mesh;
|
|
55
|
-
/**
|
|
56
|
-
*
|
|
137
|
+
/**
|
|
138
|
+
* Sweep any curve type along any curve type.
|
|
139
|
+
* Passes exact curve data to WASM for native evaluation (no pre-sampling).
|
|
140
|
+
* @param profile - Profile curve (cross-section)
|
|
141
|
+
* @param path - Path curve to sweep along
|
|
142
|
+
* @param segments - Number of samples along path (default 32)
|
|
143
|
+
* @param caps - Whether to cap the ends (default false)
|
|
144
|
+
* @returns New Mesh representing the swept surface
|
|
145
|
+
*/
|
|
57
146
|
static sweepCurves(profile: SweepableCurve, path: SweepableCurve, segments?: number, caps?: boolean): Mesh;
|
|
58
|
-
/** Encode a curve into the WASM format for sweep_curves.
|
|
59
|
-
* type 0: Line, type 1: Circle, type 2: Arc, type 3: Polyline,
|
|
60
|
-
* type 4: NurbsCurve, type 5: PolyCurve */
|
|
147
|
+
/** Encode a curve into the WASM format for sweep_curves. */
|
|
61
148
|
private static encodeCurve;
|
|
149
|
+
/**
|
|
150
|
+
* Translate this mesh by an offset vector.
|
|
151
|
+
* @param offset - Translation vector
|
|
152
|
+
* @returns New translated mesh
|
|
153
|
+
*/
|
|
62
154
|
translate(offset: Vec3): Mesh;
|
|
63
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Rotate this mesh around an axis.
|
|
157
|
+
* @param axis - Rotation axis (Vec3 through origin, or Line for arbitrary axis)
|
|
158
|
+
* @param angleRadians - Rotation angle in radians
|
|
159
|
+
* @returns New rotated mesh
|
|
160
|
+
*/
|
|
161
|
+
rotate(axis: RotationAxis, angleRadians: number): Mesh;
|
|
162
|
+
/**
|
|
163
|
+
* Scale this mesh uniformly.
|
|
164
|
+
* @param factor - Scale factor (1 = no change, 2 = double size)
|
|
165
|
+
* @returns New scaled mesh
|
|
166
|
+
*/
|
|
64
167
|
scale(factor: number): Mesh;
|
|
168
|
+
/**
|
|
169
|
+
* Scale this mesh non-uniformly along each axis.
|
|
170
|
+
* @param sx - Scale factor along X
|
|
171
|
+
* @param sy - Scale factor along Y
|
|
172
|
+
* @param sz - Scale factor along Z
|
|
173
|
+
* @returns New scaled mesh
|
|
174
|
+
*/
|
|
65
175
|
scaleXYZ(sx: number, sy: number, sz: number): Mesh;
|
|
176
|
+
/**
|
|
177
|
+
* Compute boolean union with another mesh.
|
|
178
|
+
* @param other - Mesh to union with
|
|
179
|
+
* @returns New mesh containing volume of both inputs
|
|
180
|
+
*/
|
|
66
181
|
union(other: Mesh): Mesh;
|
|
182
|
+
/**
|
|
183
|
+
* Compute boolean subtraction with another mesh.
|
|
184
|
+
* @param other - Mesh to subtract
|
|
185
|
+
* @returns New mesh with other's volume removed from this
|
|
186
|
+
*/
|
|
67
187
|
subtract(other: Mesh): Mesh;
|
|
188
|
+
/**
|
|
189
|
+
* Compute boolean intersection with another mesh.
|
|
190
|
+
* @param other - Mesh to intersect with
|
|
191
|
+
* @returns New mesh containing only the overlapping volume
|
|
192
|
+
*/
|
|
68
193
|
intersect(other: Mesh): Mesh;
|
|
194
|
+
/**
|
|
195
|
+
* Compute intersection curves with a plane.
|
|
196
|
+
* @param plane - Cutting plane
|
|
197
|
+
* @returns Array of polylines representing intersection curves
|
|
198
|
+
*/
|
|
69
199
|
intersectPlane(plane: Plane): Polyline[];
|
|
200
|
+
/**
|
|
201
|
+
* Compute intersection curves with another mesh.
|
|
202
|
+
* @param other - Mesh to intersect with
|
|
203
|
+
* @returns Array of polylines representing intersection curves
|
|
204
|
+
*/
|
|
70
205
|
intersectMesh(other: Mesh): Polyline[];
|
|
71
|
-
/**
|
|
206
|
+
/**
|
|
207
|
+
* Apply a 4x4 transformation matrix.
|
|
208
|
+
* @param matrix - Row-major flat array of 16 numbers
|
|
209
|
+
* @returns New transformed mesh
|
|
210
|
+
*/
|
|
72
211
|
applyMatrix(matrix: number[]): Mesh;
|
|
73
|
-
/**
|
|
212
|
+
/**
|
|
213
|
+
* Extract boundary (perimeter) edges as polylines.
|
|
214
|
+
* Boundary edges are edges that belong to only one face.
|
|
215
|
+
* @returns Array of polylines representing open boundaries
|
|
216
|
+
*/
|
|
74
217
|
boundaryPolylines(): Polyline[];
|
|
218
|
+
/**
|
|
219
|
+
* Export this mesh to OBJ format.
|
|
220
|
+
* @returns OBJ file content as string
|
|
221
|
+
*/
|
|
75
222
|
toOBJ(): string;
|
|
76
223
|
}
|
|
77
224
|
//# sourceMappingURL=Mesh.d.ts.map
|
package/dist/Mesh.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mesh.d.ts","sourceRoot":"","sources":["../src/Mesh.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"Mesh.d.ts","sourceRoot":"","sources":["../src/Mesh.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOzC,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY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