okgeometry-api 1.26.1 → 1.27.0
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.js +1 -1
- package/dist/Arc.js.map +1 -1
- package/dist/Brep.js +1 -1
- package/dist/Brep.js.map +1 -1
- package/dist/Circle.js +1 -1
- package/dist/Circle.js.map +1 -1
- package/dist/Line.js +1 -1
- package/dist/Line.js.map +1 -1
- package/dist/Mesh.d.ts +41 -0
- package/dist/Mesh.d.ts.map +1 -1
- package/dist/Mesh.js +235 -21
- package/dist/Mesh.js.map +1 -1
- package/dist/MeshSurface.js +1 -1
- package/dist/MeshSurface.js.map +1 -1
- package/dist/NurbsCurve.js +1 -1
- package/dist/NurbsCurve.js.map +1 -1
- package/dist/NurbsSurface.js +1 -1
- package/dist/NurbsSurface.js.map +1 -1
- package/dist/PolyCurve.js +1 -1
- package/dist/PolyCurve.js.map +1 -1
- package/dist/Polyline.js +1 -1
- package/dist/Polyline.js.map +1 -1
- package/dist/Ray.js +1 -1
- package/dist/Ray.js.map +1 -1
- package/dist/SculptSession.js +1 -1
- package/dist/SculptSession.js.map +1 -1
- package/dist/engine-threaded.d.ts +2 -0
- package/dist/engine-threaded.d.ts.map +1 -0
- package/dist/engine-threaded.js +33 -0
- package/dist/engine-threaded.js.map +1 -0
- package/dist/engine.d.ts +21 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +42 -0
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mesh-boolean.pool.d.ts +23 -1
- package/dist/mesh-boolean.pool.d.ts.map +1 -1
- package/dist/mesh-boolean.pool.js +97 -12
- package/dist/mesh-boolean.pool.js.map +1 -1
- package/dist/mesh-boolean.protocol.d.ts +21 -1
- package/dist/mesh-boolean.protocol.d.ts.map +1 -1
- package/dist/mesh-boolean.protocol.js.map +1 -1
- package/dist/mesh-boolean.worker.d.ts.map +1 -1
- package/dist/mesh-boolean.worker.js +94 -1
- package/dist/mesh-boolean.worker.js.map +1 -1
- package/dist/wasm-active.d.ts +20 -0
- package/dist/wasm-active.d.ts.map +1 -0
- package/dist/wasm-active.js +26 -0
- package/dist/wasm-active.js.map +1 -0
- package/dist/wasm-base64-threaded.d.ts +2 -0
- package/dist/wasm-base64-threaded.d.ts.map +1 -0
- package/dist/wasm-base64-threaded.js +3 -0
- package/dist/wasm-base64-threaded.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/dist/wasm-bindings-threaded.d.ts +2664 -0
- package/dist/wasm-bindings-threaded.d.ts.map +1 -0
- package/dist/wasm-bindings-threaded.js +5008 -0
- package/dist/wasm-bindings-threaded.js.map +1 -0
- package/dist/wasm-bindings.d.ts +130 -0
- package/dist/wasm-bindings.d.ts.map +1 -1
- package/dist/wasm-bindings.js +208 -0
- package/dist/wasm-bindings.js.map +1 -1
- package/dist/workerHelpers-threaded.d.ts +2 -0
- package/dist/workerHelpers-threaded.d.ts.map +1 -0
- package/dist/workerHelpers-threaded.js +100 -0
- package/dist/workerHelpers-threaded.js.map +1 -0
- package/package.json +8 -3
- package/src/Arc.ts +117 -117
- package/src/Brep.ts +1 -1
- package/src/Circle.ts +166 -166
- package/src/Line.ts +171 -171
- package/src/Mesh.ts +300 -45
- package/src/MeshSurface.ts +1 -1
- package/src/NurbsCurve.ts +655 -655
- package/src/NurbsSurface.ts +721 -721
- package/src/PolyCurve.ts +203 -203
- package/src/Polyline.ts +316 -316
- package/src/Ray.ts +90 -90
- package/src/SculptSession.ts +377 -377
- package/src/engine-threaded.ts +39 -0
- package/src/engine.ts +46 -0
- package/src/index.ts +1 -1
- package/src/mesh-boolean.pool.ts +208 -86
- package/src/mesh-boolean.protocol.ts +44 -1
- package/src/mesh-boolean.worker.ts +170 -56
- package/src/wasm-active.ts +31 -0
- package/src/wasm-base64-threaded.ts +2 -0
- package/src/wasm-base64.ts +1 -1
- package/src/wasm-bindings-threaded.d.ts +1989 -0
- package/src/wasm-bindings-threaded.js +5235 -0
- package/src/wasm-bindings.d.ts +104 -0
- package/src/wasm-bindings.js +225 -0
- package/src/workerHelpers-threaded.js +107 -0
package/src/Ray.ts
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
import { ensureInit } from "./engine.js";
|
|
2
|
-
import { Point } from "./Point.js";
|
|
3
|
-
import { Vec3 } from "./Vec3.js";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 3D ray defined by origin and direction.
|
|
8
|
-
* Parametric form: point(t) = origin + t * direction
|
|
9
|
-
*/
|
|
10
|
-
export class Ray {
|
|
11
|
-
constructor(
|
|
12
|
-
public readonly origin: Point,
|
|
13
|
-
public readonly direction: Vec3
|
|
14
|
-
) {}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Create a ray from origin and direction, normalizing the direction.
|
|
18
|
-
* Returns null if direction is zero-length.
|
|
19
|
-
*/
|
|
20
|
-
static fromOriginDirection(origin: Point, direction: Vec3): Ray | null {
|
|
21
|
-
const normalized = direction.normalize();
|
|
22
|
-
if (normalized.length() < 1e-10) return null;
|
|
23
|
-
return new Ray(origin, normalized);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Get point along the ray at parameter t.
|
|
28
|
-
* Returns origin + t * direction
|
|
29
|
-
*/
|
|
30
|
-
pointAt(t: number): Point {
|
|
31
|
-
ensureInit();
|
|
32
|
-
const r = wasm.ray_point_at(
|
|
33
|
-
this.origin.x, this.origin.y, this.origin.z,
|
|
34
|
-
this.direction.x, this.direction.y, this.direction.z,
|
|
35
|
-
t
|
|
36
|
-
);
|
|
37
|
-
return new Point(r[0], r[1], r[2]);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Find the parameter t for the closest point on the ray to a given point.
|
|
42
|
-
* The closest point is at: origin + t * direction
|
|
43
|
-
* Note: t can be negative if the closest point is "behind" the ray origin,
|
|
44
|
-
* but closestPoint() clamps t >= 0.
|
|
45
|
-
*/
|
|
46
|
-
closestPointParameter(point: Point): number {
|
|
47
|
-
ensureInit();
|
|
48
|
-
return wasm.ray_closest_point_parameter(
|
|
49
|
-
this.origin.x, this.origin.y, this.origin.z,
|
|
50
|
-
this.direction.x, this.direction.y, this.direction.z,
|
|
51
|
-
point.x, point.y, point.z
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Find the closest point on the ray to a given point.
|
|
57
|
-
* The result is clamped to the ray (t >= 0), so if the closest
|
|
58
|
-
* point would be "behind" the origin, returns the origin.
|
|
59
|
-
*/
|
|
60
|
-
closestPoint(point: Point): Point {
|
|
61
|
-
ensureInit();
|
|
62
|
-
const r = wasm.ray_closest_point(
|
|
63
|
-
this.origin.x, this.origin.y, this.origin.z,
|
|
64
|
-
this.direction.x, this.direction.y, this.direction.z,
|
|
65
|
-
point.x, point.y, point.z
|
|
66
|
-
);
|
|
67
|
-
return new Point(r[0], r[1], r[2]);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Compute the distance from this ray to a point.
|
|
72
|
-
* This is the perpendicular distance from the ray to the point,
|
|
73
|
-
* clamped so that the closest point is on the ray (t >= 0).
|
|
74
|
-
*/
|
|
75
|
-
distanceToPoint(point: Point): number {
|
|
76
|
-
ensureInit();
|
|
77
|
-
return wasm.ray_distance_to_point(
|
|
78
|
-
this.origin.x, this.origin.y, this.origin.z,
|
|
79
|
-
this.direction.x, this.direction.y, this.direction.z,
|
|
80
|
-
point.x, point.y, point.z
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Translate the ray by an offset vector.
|
|
86
|
-
*/
|
|
87
|
-
translate(offset: Vec3): Ray {
|
|
88
|
-
return new Ray(this.origin.add(offset), this.direction);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
import { ensureInit } from "./engine.js";
|
|
2
|
+
import { Point } from "./Point.js";
|
|
3
|
+
import { Vec3 } from "./Vec3.js";
|
|
4
|
+
import { wasm } from "./wasm-active.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 3D ray defined by origin and direction.
|
|
8
|
+
* Parametric form: point(t) = origin + t * direction
|
|
9
|
+
*/
|
|
10
|
+
export class Ray {
|
|
11
|
+
constructor(
|
|
12
|
+
public readonly origin: Point,
|
|
13
|
+
public readonly direction: Vec3
|
|
14
|
+
) {}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Create a ray from origin and direction, normalizing the direction.
|
|
18
|
+
* Returns null if direction is zero-length.
|
|
19
|
+
*/
|
|
20
|
+
static fromOriginDirection(origin: Point, direction: Vec3): Ray | null {
|
|
21
|
+
const normalized = direction.normalize();
|
|
22
|
+
if (normalized.length() < 1e-10) return null;
|
|
23
|
+
return new Ray(origin, normalized);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get point along the ray at parameter t.
|
|
28
|
+
* Returns origin + t * direction
|
|
29
|
+
*/
|
|
30
|
+
pointAt(t: number): Point {
|
|
31
|
+
ensureInit();
|
|
32
|
+
const r = wasm.ray_point_at(
|
|
33
|
+
this.origin.x, this.origin.y, this.origin.z,
|
|
34
|
+
this.direction.x, this.direction.y, this.direction.z,
|
|
35
|
+
t
|
|
36
|
+
);
|
|
37
|
+
return new Point(r[0], r[1], r[2]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Find the parameter t for the closest point on the ray to a given point.
|
|
42
|
+
* The closest point is at: origin + t * direction
|
|
43
|
+
* Note: t can be negative if the closest point is "behind" the ray origin,
|
|
44
|
+
* but closestPoint() clamps t >= 0.
|
|
45
|
+
*/
|
|
46
|
+
closestPointParameter(point: Point): number {
|
|
47
|
+
ensureInit();
|
|
48
|
+
return wasm.ray_closest_point_parameter(
|
|
49
|
+
this.origin.x, this.origin.y, this.origin.z,
|
|
50
|
+
this.direction.x, this.direction.y, this.direction.z,
|
|
51
|
+
point.x, point.y, point.z
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Find the closest point on the ray to a given point.
|
|
57
|
+
* The result is clamped to the ray (t >= 0), so if the closest
|
|
58
|
+
* point would be "behind" the origin, returns the origin.
|
|
59
|
+
*/
|
|
60
|
+
closestPoint(point: Point): Point {
|
|
61
|
+
ensureInit();
|
|
62
|
+
const r = wasm.ray_closest_point(
|
|
63
|
+
this.origin.x, this.origin.y, this.origin.z,
|
|
64
|
+
this.direction.x, this.direction.y, this.direction.z,
|
|
65
|
+
point.x, point.y, point.z
|
|
66
|
+
);
|
|
67
|
+
return new Point(r[0], r[1], r[2]);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Compute the distance from this ray to a point.
|
|
72
|
+
* This is the perpendicular distance from the ray to the point,
|
|
73
|
+
* clamped so that the closest point is on the ray (t >= 0).
|
|
74
|
+
*/
|
|
75
|
+
distanceToPoint(point: Point): number {
|
|
76
|
+
ensureInit();
|
|
77
|
+
return wasm.ray_distance_to_point(
|
|
78
|
+
this.origin.x, this.origin.y, this.origin.z,
|
|
79
|
+
this.direction.x, this.direction.y, this.direction.z,
|
|
80
|
+
point.x, point.y, point.z
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Translate the ray by an offset vector.
|
|
86
|
+
*/
|
|
87
|
+
translate(offset: Vec3): Ray {
|
|
88
|
+
return new Ray(this.origin.add(offset), this.direction);
|
|
89
|
+
}
|
|
90
|
+
}
|