okgeometry-api 1.1.13 → 1.1.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/PolyCurve.d.ts +11 -0
- package/dist/PolyCurve.d.ts.map +1 -1
- package/dist/PolyCurve.js +17 -0
- package/dist/PolyCurve.js.map +1 -1
- 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/dist/wasm-bindings.js +1 -1
- package/package.json +1 -1
- package/src/PolyCurve.ts +41 -20
- package/src/wasm-base64.ts +1 -1
- package/src/wasm-bindings.js +1 -1
package/dist/wasm-base64.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm-base64.js","sourceRoot":"","sources":["../src/wasm-base64.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,MAAM,CAAC,MAAM,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"wasm-base64.js","sourceRoot":"","sources":["../src/wasm-base64.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,MAAM,CAAC,MAAM,QAAQ,GAAG,8thyDAA8thyD,CAAC"}
|
package/dist/wasm-bindings.js
CHANGED
|
@@ -1688,7 +1688,7 @@ export function version() {
|
|
|
1688
1688
|
function __wbg_get_imports() {
|
|
1689
1689
|
const import0 = {
|
|
1690
1690
|
__proto__: null,
|
|
1691
|
-
|
|
1691
|
+
__wbg___okgeometry_boolean_should_cancel_b0b784127d530dd2: function () {
|
|
1692
1692
|
const ret = globalThis.__okgeometry_boolean_should_cancel();
|
|
1693
1693
|
return ret;
|
|
1694
1694
|
},
|
package/package.json
CHANGED
package/src/PolyCurve.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { ensureInit } from "./engine.js";
|
|
2
2
|
import { Point } from "./Point.js";
|
|
3
3
|
import { Line } from "./Line.js";
|
|
4
|
-
import { Arc } from "./Arc.js";
|
|
5
|
-
import { Vec3 } from "./Vec3.js";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import type {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
4
|
+
import { Arc } from "./Arc.js";
|
|
5
|
+
import { Vec3 } from "./Vec3.js";
|
|
6
|
+
import { Mesh } from "./Mesh.js";
|
|
7
|
+
import { NurbsCurve } from "./NurbsCurve.js";
|
|
8
|
+
import type { Plane } from "./Plane.js";
|
|
9
|
+
import type { CurveSegment, RotationAxis } from "./types.js";
|
|
10
|
+
import { SegmentTypeCode } from "./types.js";
|
|
11
|
+
import { pointsToCoords } from "./BufferCodec.js";
|
|
12
|
+
import * as wasm from "./wasm-bindings.js";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Composite curve made of sequential Line and Arc segments.
|
|
@@ -108,10 +109,10 @@ export class PolyCurve {
|
|
|
108
109
|
return new PolyCurve(this.segments.map(s => s.translate(offset)));
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
projectOntoPlane(plane: Plane, direction?: Vec3, arcSamples = 32): PolyCurve {
|
|
112
|
-
const proj = (p: Point) => direction ? plane.projectPointAlongDirection(p, direction) : plane.projectPoint(p);
|
|
113
|
-
const segs: CurveSegment[] = [];
|
|
114
|
-
for (const s of this.segments) {
|
|
112
|
+
projectOntoPlane(plane: Plane, direction?: Vec3, arcSamples = 32): PolyCurve {
|
|
113
|
+
const proj = (p: Point) => direction ? plane.projectPointAlongDirection(p, direction) : plane.projectPoint(p);
|
|
114
|
+
const segs: CurveSegment[] = [];
|
|
115
|
+
for (const s of this.segments) {
|
|
115
116
|
if (s instanceof Line) {
|
|
116
117
|
segs.push(new Line(proj(s.start), proj(s.end)));
|
|
117
118
|
} else {
|
|
@@ -121,14 +122,34 @@ export class PolyCurve {
|
|
|
121
122
|
segs.push(new Line(proj(pts[i]), proj(pts[i + 1])));
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
|
-
}
|
|
125
|
-
return new PolyCurve(segs);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
|
|
125
|
+
}
|
|
126
|
+
return new PolyCurve(segs);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Extrude this polycurve along a direction vector.
|
|
131
|
+
* Curved segments are sampled to a polyline first, so `segments` controls
|
|
132
|
+
* the tessellation density used for arc segments before extrusion.
|
|
133
|
+
* @param direction - Extrusion direction and magnitude
|
|
134
|
+
* @param segments - Number of samples per arc segment (default 32)
|
|
135
|
+
* @param caps - Whether to cap closed profiles (default false)
|
|
136
|
+
* @returns Mesh representing the extruded surface
|
|
137
|
+
*/
|
|
138
|
+
extrude(direction: Vec3, segments = 32, caps = false): Mesh {
|
|
139
|
+
ensureInit();
|
|
140
|
+
const arcSamples = Number.isFinite(segments) ? Math.max(2, Math.floor(segments)) : 32;
|
|
141
|
+
const buf = wasm.extrude_polyline(
|
|
142
|
+
pointsToCoords(this.sample(arcSamples)),
|
|
143
|
+
direction.x, direction.y, direction.z,
|
|
144
|
+
arcSamples, caps,
|
|
145
|
+
);
|
|
146
|
+
return Mesh.fromBuffer(buf);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Fillet corners of this PolyCurve with arcs of the given radius.
|
|
151
|
+
* Extracts the vertex points, calls WASM fillet_corners, returns a new PolyCurve.
|
|
152
|
+
*/
|
|
132
153
|
fillet(radius: number, normal?: Vec3): PolyCurve {
|
|
133
154
|
ensureInit();
|
|
134
155
|
if (this.segments.length < 2) {
|