fluidcad 0.0.25 → 0.0.27
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/lib/dist/common/scene-object.d.ts +4 -14
- package/lib/dist/common/scene-object.js +10 -127
- package/lib/dist/common/shape-factory.d.ts +1 -1
- package/lib/dist/common/shapes.d.ts +0 -1
- package/lib/dist/common/shapes.js +0 -1
- package/lib/dist/common/transformable-primitive.d.ts +16 -0
- package/lib/dist/common/transformable-primitive.js +116 -0
- package/lib/dist/core/chamfer.d.ts +5 -5
- package/lib/dist/core/color.d.ts +3 -3
- package/lib/dist/core/extrude.d.ts +12 -13
- package/lib/dist/core/extrude.js +19 -1
- package/lib/dist/core/fillet.d.ts +6 -6
- package/lib/dist/core/index.d.ts +1 -1
- package/lib/dist/core/interfaces.d.ts +32 -24
- package/lib/dist/core/load.d.ts +2 -2
- package/lib/dist/core/mirror.d.ts +7 -7
- package/lib/dist/core/mirror.js +42 -57
- package/lib/dist/core/part.d.ts +2 -1
- package/lib/dist/core/part.js +4 -1
- package/lib/dist/core/plane.d.ts +5 -7
- package/lib/dist/core/remove.d.ts +2 -2
- package/lib/dist/core/rotate.d.ts +5 -5
- package/lib/dist/core/sketch.d.ts +4 -3
- package/lib/dist/core/sketch.js +4 -1
- package/lib/dist/core/subtract.d.ts +2 -2
- package/lib/dist/core/translate.d.ts +9 -9
- package/lib/dist/features/2d/slot.d.ts +3 -0
- package/lib/dist/features/2d/slot.js +28 -7
- package/lib/dist/features/cylinder.d.ts +2 -2
- package/lib/dist/features/cylinder.js +2 -2
- package/lib/dist/features/extrude-base.d.ts +7 -1
- package/lib/dist/features/extrude-base.js +36 -3
- package/lib/dist/features/extrude-to-face.d.ts +1 -1
- package/lib/dist/features/extrude-to-face.js +29 -17
- package/lib/dist/features/extrude-two-distances.d.ts +1 -1
- package/lib/dist/features/extrude-two-distances.js +23 -12
- package/lib/dist/features/extrude.d.ts +1 -1
- package/lib/dist/features/extrude.js +47 -15
- package/lib/dist/features/mirror-shape.d.ts +1 -3
- package/lib/dist/features/mirror-shape.js +2 -1
- package/lib/dist/features/plane-from-object.d.ts +1 -1
- package/lib/dist/features/plane-from-object.js +11 -6
- package/lib/dist/features/plane-mid.d.ts +1 -1
- package/lib/dist/features/plane.d.ts +1 -1
- package/lib/dist/features/revolve.js +4 -2
- package/lib/dist/features/rotate.js +1 -0
- package/lib/dist/features/select.d.ts +1 -1
- package/lib/dist/features/select.js +1 -1
- package/lib/dist/features/simple-extruder.js +5 -0
- package/lib/dist/features/sphere.d.ts +2 -2
- package/lib/dist/features/sphere.js +2 -2
- package/lib/dist/features/translate.js +3 -1
- package/lib/dist/filters/face/face-filter.d.ts +12 -0
- package/lib/dist/filters/face/face-filter.js +21 -0
- package/lib/dist/filters/face/torus-filter.d.ts +19 -0
- package/lib/dist/filters/face/torus-filter.js +38 -0
- package/lib/dist/helpers/scene-helpers.d.ts +3 -1
- package/lib/dist/helpers/scene-helpers.js +6 -3
- package/lib/dist/index.d.ts +1 -0
- package/lib/dist/math/index.d.ts +1 -1
- package/lib/dist/math/plane.d.ts +1 -2
- package/lib/dist/math/plane.js +20 -19
- package/lib/dist/oc/boolean-ops.d.ts +5 -3
- package/lib/dist/oc/boolean-ops.js +15 -2
- package/lib/dist/oc/face-ops.d.ts +0 -1
- package/lib/dist/oc/face-ops.js +0 -13
- package/lib/dist/oc/face-query.d.ts +2 -0
- package/lib/dist/oc/face-query.js +30 -0
- package/lib/dist/oc/fillet-ops.js +84 -66
- package/lib/dist/oc/mesh.d.ts +25 -2
- package/lib/dist/oc/mesh.js +112 -35
- package/lib/dist/oc/shape-ops.d.ts +1 -21
- package/lib/dist/oc/shape-ops.js +0 -103
- package/lib/dist/rendering/mesh-transform.js +17 -1
- package/lib/dist/rendering/render-solid.js +19 -6
- package/lib/dist/rendering/render-wire.js +2 -0
- package/lib/dist/rendering/render.d.ts +12 -2
- package/lib/dist/rendering/render.js +195 -220
- package/lib/dist/scene-manager.d.ts +2 -0
- package/lib/dist/scene-manager.js +4 -3
- package/lib/dist/tests/features/cut-two-distances.test.js +1 -1
- package/lib/dist/tests/features/cut.test.js +1 -1
- package/lib/dist/tests/features/extrude.test.js +71 -0
- package/lib/dist/tests/features/fillet2d.test.js +16 -1
- package/lib/dist/tests/features/primitive-chain.test.js +45 -0
- package/lib/dist/tests/features/select.test.js +50 -0
- package/lib/dist/tests/setup.js +3 -2
- package/lib/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/ui/dist/assets/{index-D2eOzshJ.js → index-55iqIwnj.js} +37 -37
- package/ui/dist/index.html +1 -1
- package/lib/dist/common/solid-face.d.ts +0 -9
- package/lib/dist/common/solid-face.js +0 -22
- package/lib/dist/tests/features/scene-object-chain.test.js +0 -64
- /package/lib/dist/tests/features/{scene-object-chain.test.d.ts → primitive-chain.test.d.ts} +0 -0
|
@@ -3,9 +3,6 @@ import { Matrix4 } from "../math/matrix4.js";
|
|
|
3
3
|
import { ISceneObject } from "../core/interfaces.js";
|
|
4
4
|
import { FusionScope, OperationMode } from "../features/extrude-options.js";
|
|
5
5
|
import { ShapeType } from "./shape-type.js";
|
|
6
|
-
import type { AxisLike } from "../math/axis.js";
|
|
7
|
-
import type { PlaneLike } from "../math/plane.js";
|
|
8
|
-
import type { PointLike } from "../math/point.js";
|
|
9
6
|
export type SourceLocation = {
|
|
10
7
|
filePath: string;
|
|
11
8
|
line: number;
|
|
@@ -61,15 +58,7 @@ export declare abstract class SceneObject implements Comparable<SceneObject>, Se
|
|
|
61
58
|
abstract getType(): string;
|
|
62
59
|
abstract build(context?: BuildSceneObjectContext): void;
|
|
63
60
|
getAppliedTransform(): Matrix4 | null;
|
|
64
|
-
|
|
65
|
-
translate(x: number): this;
|
|
66
|
-
translate(x: number, y: number): this;
|
|
67
|
-
translate(x: number, y: number, z: number): this;
|
|
68
|
-
translate(p: PointLike): this;
|
|
69
|
-
rotate(angle: number): this;
|
|
70
|
-
rotate(axis: AxisLike, angle: number): this;
|
|
71
|
-
mirror(plane: PlaneLike): this;
|
|
72
|
-
mirror(axis: AxisLike): this;
|
|
61
|
+
protected composeAppliedTransform(matrix: Matrix4): void;
|
|
73
62
|
compareTo(other: SceneObject): boolean;
|
|
74
63
|
getDependencies(): SceneObject[];
|
|
75
64
|
createCopy(remap: Map<SceneObject, SceneObject>): SceneObject;
|
|
@@ -118,9 +107,10 @@ export declare abstract class SceneObject implements Comparable<SceneObject>, Se
|
|
|
118
107
|
getOperationMode(): OperationMode;
|
|
119
108
|
isSymmetric(): boolean;
|
|
120
109
|
resolveFusionScope(sceneObjects: SceneObject[]): SceneObject[];
|
|
121
|
-
add(
|
|
110
|
+
add(): this;
|
|
122
111
|
new(): this;
|
|
123
|
-
remove(
|
|
112
|
+
remove(): this;
|
|
113
|
+
scope(...objects: ISceneObject[]): this;
|
|
124
114
|
symmetric(): this;
|
|
125
115
|
/**
|
|
126
116
|
* Called after all objects have been built. Override to perform
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { randomUUID } from "crypto";
|
|
2
|
-
import { Matrix4 } from "../math/matrix4.js";
|
|
3
|
-
import { Point } from "../math/point.js";
|
|
4
|
-
import { Vector3d } from "../math/vector3d.js";
|
|
5
|
-
import { rad } from "../helpers/math-helpers.js";
|
|
6
2
|
export class SceneObject {
|
|
7
3
|
state;
|
|
8
4
|
children = [];
|
|
@@ -97,55 +93,10 @@ export class SceneObject {
|
|
|
97
93
|
getAppliedTransform() {
|
|
98
94
|
return this._appliedTransform;
|
|
99
95
|
}
|
|
100
|
-
|
|
96
|
+
composeAppliedTransform(matrix) {
|
|
101
97
|
this._appliedTransform = this._appliedTransform
|
|
102
98
|
? matrix.multiply(this._appliedTransform)
|
|
103
99
|
: matrix;
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
translate(a, b, c) {
|
|
107
|
-
let x, y, z;
|
|
108
|
-
if (typeof a === 'number') {
|
|
109
|
-
x = a;
|
|
110
|
-
y = b ?? 0;
|
|
111
|
-
z = c ?? 0;
|
|
112
|
-
}
|
|
113
|
-
else if (Array.isArray(a)) {
|
|
114
|
-
x = a[0] ?? 0;
|
|
115
|
-
y = a[1] ?? 0;
|
|
116
|
-
z = a[2] ?? 0;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
x = a.x;
|
|
120
|
-
y = a.y;
|
|
121
|
-
z = a.z;
|
|
122
|
-
}
|
|
123
|
-
return this.transform(Matrix4.fromTranslation(x, y, z));
|
|
124
|
-
}
|
|
125
|
-
rotate(a, b) {
|
|
126
|
-
let origin;
|
|
127
|
-
let direction;
|
|
128
|
-
let angleDeg;
|
|
129
|
-
if (typeof a === 'number') {
|
|
130
|
-
origin = new Point(0, 0, 0);
|
|
131
|
-
direction = Vector3d.unitZ();
|
|
132
|
-
angleDeg = a;
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
const resolved = resolveAxisLike(a);
|
|
136
|
-
origin = resolved.origin;
|
|
137
|
-
direction = resolved.direction;
|
|
138
|
-
angleDeg = b;
|
|
139
|
-
}
|
|
140
|
-
return this.transform(Matrix4.fromRotationAroundAxis(origin, direction, rad(angleDeg)));
|
|
141
|
-
}
|
|
142
|
-
mirror(arg) {
|
|
143
|
-
if (isAxisLikeArg(arg)) {
|
|
144
|
-
const axis = resolveAxisLike(arg);
|
|
145
|
-
return this.transform(Matrix4.mirrorAxis(axis.origin, axis.direction));
|
|
146
|
-
}
|
|
147
|
-
const plane = resolvePlaneLike(arg);
|
|
148
|
-
return this.transform(Matrix4.mirrorPlane(plane.normal, plane.origin));
|
|
149
100
|
}
|
|
150
101
|
compareTo(other) {
|
|
151
102
|
const match = this._guide === other._guide && this._reusable === other._reusable;
|
|
@@ -419,17 +370,9 @@ export class SceneObject {
|
|
|
419
370
|
}
|
|
420
371
|
return sceneObjects;
|
|
421
372
|
}
|
|
422
|
-
add(
|
|
373
|
+
add() {
|
|
423
374
|
this._operationMode = 'add';
|
|
424
|
-
|
|
425
|
-
this._fusionScope = 'all';
|
|
426
|
-
}
|
|
427
|
-
else if (objects.length === 1) {
|
|
428
|
-
this._fusionScope = objects[0];
|
|
429
|
-
}
|
|
430
|
-
else {
|
|
431
|
-
this._fusionScope = objects;
|
|
432
|
-
}
|
|
375
|
+
this._fusionScope = 'all';
|
|
433
376
|
return this;
|
|
434
377
|
}
|
|
435
378
|
new() {
|
|
@@ -437,15 +380,16 @@ export class SceneObject {
|
|
|
437
380
|
this._fusionScope = 'none';
|
|
438
381
|
return this;
|
|
439
382
|
}
|
|
440
|
-
remove(
|
|
383
|
+
remove() {
|
|
441
384
|
this._operationMode = 'remove';
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
385
|
+
this._fusionScope = 'all';
|
|
386
|
+
return this;
|
|
387
|
+
}
|
|
388
|
+
scope(...objects) {
|
|
389
|
+
if (objects.length === 1) {
|
|
446
390
|
this._fusionScope = objects[0];
|
|
447
391
|
}
|
|
448
|
-
else {
|
|
392
|
+
else if (objects.length > 1) {
|
|
449
393
|
this._fusionScope = objects;
|
|
450
394
|
}
|
|
451
395
|
return this;
|
|
@@ -463,64 +407,3 @@ export class SceneObject {
|
|
|
463
407
|
return `${this.getOrder()}-${this.getUniqueType()}-${suffix}`;
|
|
464
408
|
}
|
|
465
409
|
}
|
|
466
|
-
function isAxisLikeArg(arg) {
|
|
467
|
-
if (arg === 'x' || arg === 'y' || arg === 'z') {
|
|
468
|
-
return true;
|
|
469
|
-
}
|
|
470
|
-
if (arg && typeof arg === 'object') {
|
|
471
|
-
if (typeof arg.getAxis === 'function') {
|
|
472
|
-
return true;
|
|
473
|
-
}
|
|
474
|
-
if (arg.origin && arg.direction) {
|
|
475
|
-
return true;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
return false;
|
|
479
|
-
}
|
|
480
|
-
function resolveAxisLike(arg) {
|
|
481
|
-
if (arg === 'x') {
|
|
482
|
-
return { origin: new Point(0, 0, 0), direction: Vector3d.unitX() };
|
|
483
|
-
}
|
|
484
|
-
if (arg === 'y') {
|
|
485
|
-
return { origin: new Point(0, 0, 0), direction: Vector3d.unitY() };
|
|
486
|
-
}
|
|
487
|
-
if (arg === 'z') {
|
|
488
|
-
return { origin: new Point(0, 0, 0), direction: Vector3d.unitZ() };
|
|
489
|
-
}
|
|
490
|
-
const a = arg;
|
|
491
|
-
if (typeof a.getAxis === 'function') {
|
|
492
|
-
const axis = a.getAxis();
|
|
493
|
-
return { origin: axis.origin, direction: axis.direction };
|
|
494
|
-
}
|
|
495
|
-
return { origin: a.origin, direction: a.direction };
|
|
496
|
-
}
|
|
497
|
-
function resolvePlaneLike(arg) {
|
|
498
|
-
if (typeof arg === 'string') {
|
|
499
|
-
switch (arg) {
|
|
500
|
-
case 'xy':
|
|
501
|
-
case 'top':
|
|
502
|
-
return { origin: new Point(0, 0, 0), normal: Vector3d.unitZ() };
|
|
503
|
-
case '-xy':
|
|
504
|
-
case 'bottom':
|
|
505
|
-
return { origin: new Point(0, 0, 0), normal: Vector3d.unitZ().multiply(-1) };
|
|
506
|
-
case 'xz':
|
|
507
|
-
case 'front':
|
|
508
|
-
return { origin: new Point(0, 0, 0), normal: Vector3d.unitY().multiply(-1) };
|
|
509
|
-
case '-xz':
|
|
510
|
-
case 'back':
|
|
511
|
-
return { origin: new Point(0, 0, 0), normal: Vector3d.unitY() };
|
|
512
|
-
case 'yz':
|
|
513
|
-
case 'right':
|
|
514
|
-
return { origin: new Point(0, 0, 0), normal: Vector3d.unitX() };
|
|
515
|
-
case '-yz':
|
|
516
|
-
case 'left':
|
|
517
|
-
return { origin: new Point(0, 0, 0), normal: Vector3d.unitX().multiply(-1) };
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
const p = arg;
|
|
521
|
-
if (typeof p.getPlane === 'function') {
|
|
522
|
-
const plane = p.getPlane();
|
|
523
|
-
return { origin: plane.origin, normal: plane.normal };
|
|
524
|
-
}
|
|
525
|
-
return { origin: p.origin, normal: p.normal };
|
|
526
|
-
}
|
|
@@ -4,5 +4,5 @@ import { Wire } from "./wire.js";
|
|
|
4
4
|
import { Face } from "./face.js";
|
|
5
5
|
import { Edge } from "./edge.js";
|
|
6
6
|
export declare class ShapeFactory {
|
|
7
|
-
static fromShape(shape: TopoDS_Shape): Wire | Edge |
|
|
7
|
+
static fromShape(shape: TopoDS_Shape): Wire | Edge | Face | Solid;
|
|
8
8
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SceneObject } from "./scene-object.js";
|
|
2
|
+
import { Matrix4 } from "../math/matrix4.js";
|
|
3
|
+
import type { AxisLike } from "../math/axis.js";
|
|
4
|
+
import type { PlaneLike } from "../math/plane.js";
|
|
5
|
+
import type { PointLike } from "../math/point.js";
|
|
6
|
+
export declare abstract class TransformablePrimitive extends SceneObject {
|
|
7
|
+
transform(matrix: Matrix4): this;
|
|
8
|
+
translate(x: number): this;
|
|
9
|
+
translate(x: number, y: number): this;
|
|
10
|
+
translate(x: number, y: number, z: number): this;
|
|
11
|
+
translate(p: PointLike): this;
|
|
12
|
+
rotate(angle: number): this;
|
|
13
|
+
rotate(axis: AxisLike, angle: number): this;
|
|
14
|
+
mirror(plane: PlaneLike): this;
|
|
15
|
+
mirror(axis: AxisLike): this;
|
|
16
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { SceneObject } from "./scene-object.js";
|
|
2
|
+
import { Matrix4 } from "../math/matrix4.js";
|
|
3
|
+
import { Point } from "../math/point.js";
|
|
4
|
+
import { Vector3d } from "../math/vector3d.js";
|
|
5
|
+
import { rad } from "../helpers/math-helpers.js";
|
|
6
|
+
export class TransformablePrimitive extends SceneObject {
|
|
7
|
+
transform(matrix) {
|
|
8
|
+
this.composeAppliedTransform(matrix);
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
11
|
+
translate(a, b, c) {
|
|
12
|
+
let x, y, z;
|
|
13
|
+
if (typeof a === 'number') {
|
|
14
|
+
x = a;
|
|
15
|
+
y = b ?? 0;
|
|
16
|
+
z = c ?? 0;
|
|
17
|
+
}
|
|
18
|
+
else if (Array.isArray(a)) {
|
|
19
|
+
x = a[0] ?? 0;
|
|
20
|
+
y = a[1] ?? 0;
|
|
21
|
+
z = a[2] ?? 0;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
x = a.x;
|
|
25
|
+
y = a.y;
|
|
26
|
+
z = a.z;
|
|
27
|
+
}
|
|
28
|
+
return this.transform(Matrix4.fromTranslation(x, y, z));
|
|
29
|
+
}
|
|
30
|
+
rotate(a, b) {
|
|
31
|
+
let origin;
|
|
32
|
+
let direction;
|
|
33
|
+
let angleDeg;
|
|
34
|
+
if (typeof a === 'number') {
|
|
35
|
+
origin = new Point(0, 0, 0);
|
|
36
|
+
direction = Vector3d.unitZ();
|
|
37
|
+
angleDeg = a;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const resolved = resolveAxisLike(a);
|
|
41
|
+
origin = resolved.origin;
|
|
42
|
+
direction = resolved.direction;
|
|
43
|
+
angleDeg = b;
|
|
44
|
+
}
|
|
45
|
+
return this.transform(Matrix4.fromRotationAroundAxis(origin, direction, rad(angleDeg)));
|
|
46
|
+
}
|
|
47
|
+
mirror(arg) {
|
|
48
|
+
if (isAxisLikeArg(arg)) {
|
|
49
|
+
const axis = resolveAxisLike(arg);
|
|
50
|
+
return this.transform(Matrix4.mirrorAxis(axis.origin, axis.direction));
|
|
51
|
+
}
|
|
52
|
+
const plane = resolvePlaneLike(arg);
|
|
53
|
+
return this.transform(Matrix4.mirrorPlane(plane.normal, plane.origin));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function isAxisLikeArg(arg) {
|
|
57
|
+
if (arg === 'x' || arg === 'y' || arg === 'z') {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
if (arg && typeof arg === 'object') {
|
|
61
|
+
if (typeof arg.getAxis === 'function') {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
if (arg.origin && arg.direction) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
function resolveAxisLike(arg) {
|
|
71
|
+
if (arg === 'x') {
|
|
72
|
+
return { origin: new Point(0, 0, 0), direction: Vector3d.unitX() };
|
|
73
|
+
}
|
|
74
|
+
if (arg === 'y') {
|
|
75
|
+
return { origin: new Point(0, 0, 0), direction: Vector3d.unitY() };
|
|
76
|
+
}
|
|
77
|
+
if (arg === 'z') {
|
|
78
|
+
return { origin: new Point(0, 0, 0), direction: Vector3d.unitZ() };
|
|
79
|
+
}
|
|
80
|
+
const a = arg;
|
|
81
|
+
if (typeof a.getAxis === 'function') {
|
|
82
|
+
const axis = a.getAxis();
|
|
83
|
+
return { origin: axis.origin, direction: axis.direction };
|
|
84
|
+
}
|
|
85
|
+
return { origin: a.origin, direction: a.direction };
|
|
86
|
+
}
|
|
87
|
+
function resolvePlaneLike(arg) {
|
|
88
|
+
if (typeof arg === 'string') {
|
|
89
|
+
switch (arg) {
|
|
90
|
+
case 'xy':
|
|
91
|
+
case 'top':
|
|
92
|
+
return { origin: new Point(0, 0, 0), normal: Vector3d.unitZ() };
|
|
93
|
+
case '-xy':
|
|
94
|
+
case 'bottom':
|
|
95
|
+
return { origin: new Point(0, 0, 0), normal: Vector3d.unitZ().multiply(-1) };
|
|
96
|
+
case 'xz':
|
|
97
|
+
case 'front':
|
|
98
|
+
return { origin: new Point(0, 0, 0), normal: Vector3d.unitY().multiply(-1) };
|
|
99
|
+
case '-xz':
|
|
100
|
+
case 'back':
|
|
101
|
+
return { origin: new Point(0, 0, 0), normal: Vector3d.unitY() };
|
|
102
|
+
case 'yz':
|
|
103
|
+
case 'right':
|
|
104
|
+
return { origin: new Point(0, 0, 0), normal: Vector3d.unitX() };
|
|
105
|
+
case '-yz':
|
|
106
|
+
case 'left':
|
|
107
|
+
return { origin: new Point(0, 0, 0), normal: Vector3d.unitX().multiply(-1) };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const p = arg;
|
|
111
|
+
if (typeof p.getPlane === 'function') {
|
|
112
|
+
const plane = p.getPlane();
|
|
113
|
+
return { origin: plane.origin, normal: plane.normal };
|
|
114
|
+
}
|
|
115
|
+
return { origin: p.origin, normal: p.normal };
|
|
116
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { ISceneObject
|
|
1
|
+
import { ISceneObject } from "./interfaces.js";
|
|
2
2
|
interface ChamferFunction {
|
|
3
3
|
/**
|
|
4
4
|
* Chamfers selected edges with the given distance.
|
|
5
5
|
* @param distance - The chamfer distance (defaults to 1)
|
|
6
6
|
*/
|
|
7
|
-
(distance?: number):
|
|
7
|
+
(distance?: number): ISceneObject;
|
|
8
8
|
/**
|
|
9
9
|
* Chamfers the given edge selections with the given distance.
|
|
10
10
|
* @param distance - The chamfer distance
|
|
11
11
|
* @param sceneObjects - The edge selections to chamfer
|
|
12
12
|
*/
|
|
13
|
-
(distance: number, ...sceneObjects: ISceneObject[]):
|
|
13
|
+
(distance: number, ...sceneObjects: ISceneObject[]): ISceneObject;
|
|
14
14
|
/**
|
|
15
15
|
* Chamfers selected edges with two distances or a distance and angle.
|
|
16
16
|
* @param distance - The first chamfer distance
|
|
17
17
|
* @param distance2 - The second distance, or angle if `isAngle` is true
|
|
18
18
|
* @param isAngle - Whether `distance2` is an angle
|
|
19
19
|
*/
|
|
20
|
-
(distance: number, distance2: number, isAngle?: boolean):
|
|
20
|
+
(distance: number, distance2: number, isAngle?: boolean): ISceneObject;
|
|
21
21
|
/**
|
|
22
22
|
* Chamfers the given edge selections with two distances or a distance and angle.
|
|
23
23
|
* @param distance - The first chamfer distance
|
|
@@ -25,7 +25,7 @@ interface ChamferFunction {
|
|
|
25
25
|
* @param isAngle - Whether `distance2` is an angle
|
|
26
26
|
* @param sceneObjects - The edge selections to chamfer
|
|
27
27
|
*/
|
|
28
|
-
(distance: number, distance2: number, isAngle: boolean, ...sceneObjects: ISceneObject[]):
|
|
28
|
+
(distance: number, distance2: number, isAngle: boolean, ...sceneObjects: ISceneObject[]): ISceneObject;
|
|
29
29
|
}
|
|
30
30
|
declare const _default: ChamferFunction;
|
|
31
31
|
export default _default;
|
package/lib/dist/core/color.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { ISceneObject
|
|
1
|
+
import { ISceneObject } from "./interfaces.js";
|
|
2
2
|
interface ColorFunction {
|
|
3
3
|
/**
|
|
4
4
|
* Applies a color to the last selection.
|
|
5
5
|
* @param color - The color value (CSS color string)
|
|
6
6
|
*/
|
|
7
|
-
(color: string):
|
|
7
|
+
(color: string): ISceneObject;
|
|
8
8
|
/**
|
|
9
9
|
* Applies a color to the given selection.
|
|
10
10
|
* @param color - The color value (CSS color string)
|
|
11
11
|
* @param selection - The face or edge selection to color
|
|
12
12
|
*/
|
|
13
|
-
(color: string, selection: ISceneObject):
|
|
13
|
+
(color: string, selection: ISceneObject): ISceneObject;
|
|
14
14
|
}
|
|
15
15
|
declare const _default: ColorFunction;
|
|
16
16
|
export default _default;
|
|
@@ -2,45 +2,44 @@ import { IExtrude, ISceneObject } from "./interfaces.js";
|
|
|
2
2
|
interface ExtrudeFunction {
|
|
3
3
|
/**
|
|
4
4
|
* Extrudes the last sketch with a default distance.
|
|
5
|
-
* @param target - The sketch to extrude
|
|
5
|
+
* @param target - The sketch or face-bearing scene object to extrude
|
|
6
6
|
*/
|
|
7
7
|
(target?: ISceneObject): IExtrude;
|
|
8
8
|
/**
|
|
9
|
-
* Extrudes
|
|
9
|
+
* Extrudes by a given distance.
|
|
10
10
|
* @param distance - The extrusion distance
|
|
11
|
-
* @param target - The sketch to extrude
|
|
11
|
+
* @param target - The sketch or face-bearing scene object to extrude
|
|
12
12
|
*/
|
|
13
13
|
(distance: number, target?: ISceneObject): IExtrude;
|
|
14
14
|
/**
|
|
15
|
-
* Extrudes
|
|
15
|
+
* Extrudes between two distances.
|
|
16
16
|
* @param distance1 - The first extrusion distance
|
|
17
17
|
* @param distance2 - The second extrusion distance
|
|
18
|
-
* @param target - The sketch to extrude
|
|
19
18
|
*/
|
|
20
19
|
(distance1: number, distance2: number): IExtrude;
|
|
21
20
|
/**
|
|
22
|
-
* Extrudes
|
|
21
|
+
* Extrudes between two distances.
|
|
23
22
|
* @param distance1 - The first extrusion distance
|
|
24
23
|
* @param distance2 - The second extrusion distance
|
|
25
|
-
* @param target - The sketch to extrude
|
|
24
|
+
* @param target - The sketch or face-bearing scene object to extrude
|
|
26
25
|
*/
|
|
27
26
|
(distance1: number, distance2: number, target: ISceneObject): IExtrude;
|
|
28
27
|
/**
|
|
29
|
-
* Extrudes
|
|
28
|
+
* Extrudes up to a specific face.
|
|
30
29
|
* @param face - A face selection to extrude up to
|
|
31
|
-
* @param target - The sketch to extrude
|
|
30
|
+
* @param target - The sketch or face-bearing scene object to extrude
|
|
32
31
|
*/
|
|
33
32
|
(face: ISceneObject, target?: ISceneObject): IExtrude;
|
|
34
33
|
/**
|
|
35
|
-
* Extrudes
|
|
34
|
+
* Extrudes up to the first intersecting face.
|
|
36
35
|
* @param face - The literal `'first-face'`
|
|
37
|
-
* @param target - The sketch to extrude
|
|
36
|
+
* @param target - The sketch or face-bearing scene object to extrude
|
|
38
37
|
*/
|
|
39
38
|
(face: 'first-face', target?: ISceneObject): IExtrude;
|
|
40
39
|
/**
|
|
41
|
-
* Extrudes
|
|
40
|
+
* Extrudes up to the last intersecting face.
|
|
42
41
|
* @param face - The literal `'last-face'`
|
|
43
|
-
* @param target - The sketch to extrude
|
|
42
|
+
* @param target - The sketch or face-bearing scene object to extrude
|
|
44
43
|
*/
|
|
45
44
|
(face: 'last-face', target?: ISceneObject): IExtrude;
|
|
46
45
|
}
|
package/lib/dist/core/extrude.js
CHANGED
|
@@ -3,9 +3,22 @@ import { registerBuilder } from "../index.js";
|
|
|
3
3
|
import { Extrude } from "../features/extrude.js";
|
|
4
4
|
import { ExtrudeTwoDistances } from "../features/extrude-two-distances.js";
|
|
5
5
|
import { ExtrudeToFace } from "../features/extrude-to-face.js";
|
|
6
|
+
import { SelectSceneObject } from "../features/select.js";
|
|
6
7
|
function isExtrudable(obj) {
|
|
7
8
|
return obj instanceof SceneObject && obj.isExtrudable();
|
|
8
9
|
}
|
|
10
|
+
function isFaceSource(obj) {
|
|
11
|
+
if (!(obj instanceof SceneObject)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (isExtrudable(obj)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (obj instanceof SelectSceneObject) {
|
|
18
|
+
return obj.shapeType() === 'face';
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
9
22
|
function build(context) {
|
|
10
23
|
function doExtrude(params, extrudable) {
|
|
11
24
|
const defaultDistance = 25;
|
|
@@ -41,8 +54,13 @@ function build(context) {
|
|
|
41
54
|
return function extrude() {
|
|
42
55
|
const args = [...arguments];
|
|
43
56
|
let extrudable;
|
|
44
|
-
|
|
57
|
+
const last = args.length > 0 ? args[args.length - 1] : undefined;
|
|
58
|
+
if (last !== undefined && isExtrudable(last)) {
|
|
59
|
+
extrudable = args.pop();
|
|
60
|
+
}
|
|
61
|
+
else if (last !== undefined && args.length >= 2 && isFaceSource(last)) {
|
|
45
62
|
extrudable = args.pop();
|
|
63
|
+
context.addSceneObject(extrudable);
|
|
46
64
|
}
|
|
47
65
|
else {
|
|
48
66
|
extrudable = context.getLastExtrudable() || undefined;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { IGeometry, ISceneObject
|
|
1
|
+
import { IGeometry, ISceneObject } from "./interfaces.js";
|
|
2
2
|
interface FilletFunction {
|
|
3
3
|
/**
|
|
4
4
|
* Fillets selected edges with the given radius.
|
|
5
5
|
* @param radius - The fillet radius (defaults to 1)
|
|
6
6
|
*/
|
|
7
|
-
(radius?: number):
|
|
7
|
+
(radius?: number): ISceneObject;
|
|
8
8
|
/**
|
|
9
9
|
* Fillets the given edge selections with the given radius.
|
|
10
10
|
* @param radius - The fillet radius
|
|
11
11
|
* @param sceneObjects - The edge selections to fillet
|
|
12
12
|
*/
|
|
13
|
-
(radius: number, ...sceneObjects: ISceneObject[]):
|
|
13
|
+
(radius: number, ...sceneObjects: ISceneObject[]): ISceneObject;
|
|
14
14
|
/**
|
|
15
15
|
* [2D] Fillets corners between the given geometries.
|
|
16
16
|
* @param objects - The geometries whose corners to fillet
|
|
17
17
|
*/
|
|
18
|
-
(objects: IGeometry[]):
|
|
18
|
+
(objects: IGeometry[]): ISceneObject;
|
|
19
19
|
/**
|
|
20
20
|
* [2D] Fillets corners between the given geometries with a radius.
|
|
21
21
|
* @param objects - The geometries whose corners to fillet
|
|
22
22
|
* @param radius - The fillet radius
|
|
23
23
|
*/
|
|
24
|
-
(objects: IGeometry[], radius: number):
|
|
24
|
+
(objects: IGeometry[], radius: number): ISceneObject;
|
|
25
25
|
/**
|
|
26
26
|
* [2D] Fillets corners at the given radius and geometries.
|
|
27
27
|
* @param radius - The fillet radius
|
|
28
28
|
* @param objects - The geometries whose corners to fillet
|
|
29
29
|
*/
|
|
30
|
-
(radius: number, ...objects: IGeometry[]):
|
|
30
|
+
(radius: number, ...objects: IGeometry[]): ISceneObject;
|
|
31
31
|
}
|
|
32
32
|
declare const _default: FilletFunction;
|
|
33
33
|
export default _default;
|
package/lib/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { ISceneObject, ITransformable,
|
|
1
|
+
export type { ISceneObject, ITransformable, IBooleanOperation, IPlane, IAxis, ISelect, IGeometry, IExtrudableGeometry, IRect, ISlot, IPolygon, ITwoObjectsTangentLine, ITangentArcTwoObjects, IExtrude, ICut, ICommon, ISweep, ILoft, IRevolve, IDraft } from "./interfaces.js";
|
|
2
2
|
export { default as axis } from "./axis.js";
|
|
3
3
|
export { default as local } from "./local.js";
|
|
4
4
|
export { default as plane } from "./plane.js";
|