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
|
@@ -24,26 +24,28 @@ export interface ISceneObject {
|
|
|
24
24
|
*/
|
|
25
25
|
reusable(): this;
|
|
26
26
|
}
|
|
27
|
-
export interface
|
|
27
|
+
export interface IBooleanOperation extends ISceneObject {
|
|
28
28
|
/**
|
|
29
|
-
* Additive boolean operation — fuses the result with
|
|
30
|
-
*
|
|
31
|
-
* When called with specific objects, fuses only with those objects.
|
|
32
|
-
* @param objects - Optional target objects to fuse with.
|
|
29
|
+
* Additive boolean operation — fuses the result with all intersecting scene objects.
|
|
30
|
+
* Use `.scope()` to target specific objects.
|
|
33
31
|
*/
|
|
34
|
-
add(
|
|
32
|
+
add(): this;
|
|
35
33
|
/**
|
|
36
34
|
* No boolean operation — keeps the result as a standalone shape,
|
|
37
35
|
* separate from all other scene objects.
|
|
38
36
|
*/
|
|
39
37
|
'new'(): this;
|
|
40
38
|
/**
|
|
41
|
-
* Subtractive boolean operation — cuts the result from
|
|
42
|
-
*
|
|
43
|
-
* When called with specific objects, cuts only from those objects.
|
|
44
|
-
* @param objects - Optional target objects to cut from.
|
|
39
|
+
* Subtractive boolean operation — cuts the result from all intersecting scene objects.
|
|
40
|
+
* Use `.scope()` to target specific objects.
|
|
45
41
|
*/
|
|
46
|
-
remove(
|
|
42
|
+
remove(): this;
|
|
43
|
+
/**
|
|
44
|
+
* Narrows the boolean operation scope to specific target objects.
|
|
45
|
+
* Must be chained after `.add()` or `.remove()`.
|
|
46
|
+
* @param objects - The target objects to operate on.
|
|
47
|
+
*/
|
|
48
|
+
scope(...objects: ISceneObject[]): this;
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* Scene objects that can be chained with world-space transformations.
|
|
@@ -98,13 +100,13 @@ export interface ITransformable extends ISceneObject {
|
|
|
98
100
|
*/
|
|
99
101
|
mirror(axis: AxisLike): this;
|
|
100
102
|
}
|
|
101
|
-
export interface IPlane extends
|
|
103
|
+
export interface IPlane extends ISceneObject {
|
|
102
104
|
}
|
|
103
|
-
export interface IAxis extends
|
|
105
|
+
export interface IAxis extends ISceneObject {
|
|
104
106
|
}
|
|
105
107
|
export interface ISelect extends ISceneObject {
|
|
106
108
|
}
|
|
107
|
-
export interface IGeometry extends
|
|
109
|
+
export interface IGeometry extends ISceneObject {
|
|
108
110
|
/**
|
|
109
111
|
* Returns a lazy-evaluated vertex at the start point of this geometry element.
|
|
110
112
|
*/
|
|
@@ -211,6 +213,11 @@ export interface ISlot extends IExtrudableGeometry {
|
|
|
211
213
|
* @param value - `true` to center, `false` (default) to start from the current position.
|
|
212
214
|
*/
|
|
213
215
|
centered(value?: boolean): this;
|
|
216
|
+
/**
|
|
217
|
+
* Sets the rotation angle of the slot's primary axis.
|
|
218
|
+
* @param angle - Rotation in degrees.
|
|
219
|
+
*/
|
|
220
|
+
rotate(angle: number): this;
|
|
214
221
|
}
|
|
215
222
|
export interface IPolygon extends IExtrudableGeometry {
|
|
216
223
|
/**
|
|
@@ -248,7 +255,7 @@ export interface ITangentArcTwoObjects extends IGeometry {
|
|
|
248
255
|
*/
|
|
249
256
|
end(index?: number): LazyVertex;
|
|
250
257
|
}
|
|
251
|
-
export interface ICommon extends
|
|
258
|
+
export interface ICommon extends ISceneObject {
|
|
252
259
|
/**
|
|
253
260
|
* Controls whether the original objects involved in the boolean intersection
|
|
254
261
|
* are retained or removed after the operation.
|
|
@@ -256,7 +263,7 @@ export interface ICommon extends ITransformable {
|
|
|
256
263
|
*/
|
|
257
264
|
keepOriginal(value?: boolean): this;
|
|
258
265
|
}
|
|
259
|
-
export interface IExtrude extends
|
|
266
|
+
export interface IExtrude extends IBooleanOperation {
|
|
260
267
|
/**
|
|
261
268
|
* Enables symmetric mode — extrudes equally in both directions from the sketch plane.
|
|
262
269
|
*/
|
|
@@ -348,16 +355,17 @@ export interface IExtrude extends IFuseable {
|
|
|
348
355
|
*/
|
|
349
356
|
thin(offset1: number, offset2: number): this;
|
|
350
357
|
}
|
|
351
|
-
export interface ICut extends
|
|
358
|
+
export interface ICut extends ISceneObject {
|
|
352
359
|
/**
|
|
353
360
|
* Enables symmetric mode — cuts equally in both directions from the sketch plane.
|
|
354
361
|
*/
|
|
355
362
|
symmetric(): this;
|
|
356
363
|
/**
|
|
357
|
-
* Narrows the cut scope to specific
|
|
364
|
+
* Narrows the cut scope to specific target objects.
|
|
365
|
+
* Must be chained after `.remove()`.
|
|
358
366
|
* @param objects - The target objects to cut from.
|
|
359
367
|
*/
|
|
360
|
-
|
|
368
|
+
scope(...objects: ISceneObject[]): this;
|
|
361
369
|
/**
|
|
362
370
|
* Applies a draft (taper) angle to the cut walls.
|
|
363
371
|
* @param value - A single angle for uniform draft, or a `[start, end]` tuple for asymmetric draft.
|
|
@@ -408,7 +416,7 @@ export interface ICut extends ITransformable {
|
|
|
408
416
|
*/
|
|
409
417
|
thin(offset1: number, offset2: number): this;
|
|
410
418
|
}
|
|
411
|
-
export interface IRevolve extends
|
|
419
|
+
export interface IRevolve extends IBooleanOperation {
|
|
412
420
|
/**
|
|
413
421
|
* Enables symmetric mode — revolves equally in both directions from the sketch plane.
|
|
414
422
|
*/
|
|
@@ -456,7 +464,7 @@ export interface IRevolve extends IFuseable {
|
|
|
456
464
|
*/
|
|
457
465
|
capEdges(...args: (number | EdgeFilterBuilder)[]): ISceneObject;
|
|
458
466
|
}
|
|
459
|
-
export interface ILoft extends
|
|
467
|
+
export interface ILoft extends IBooleanOperation {
|
|
460
468
|
/**
|
|
461
469
|
* Selects faces on the first profile plane of the loft.
|
|
462
470
|
* @param args - Numeric indices or {@link FaceFilterBuilder} instances to filter the selection.
|
|
@@ -525,7 +533,7 @@ export interface ILoft extends IFuseable {
|
|
|
525
533
|
*/
|
|
526
534
|
capEdges(...args: (number | EdgeFilterBuilder)[]): ISceneObject;
|
|
527
535
|
}
|
|
528
|
-
export interface ISweep extends
|
|
536
|
+
export interface ISweep extends IBooleanOperation {
|
|
529
537
|
/**
|
|
530
538
|
* Selects faces at the start (profile plane) of the sweep.
|
|
531
539
|
* @param args - Numeric indices or {@link FaceFilterBuilder} instances to filter the selection.
|
|
@@ -613,9 +621,9 @@ export interface ISweep extends IFuseable {
|
|
|
613
621
|
*/
|
|
614
622
|
capEdges(...args: (number | EdgeFilterBuilder)[]): ISceneObject;
|
|
615
623
|
}
|
|
616
|
-
export interface IDraft extends
|
|
624
|
+
export interface IDraft extends ISceneObject {
|
|
617
625
|
}
|
|
618
|
-
export interface IShell extends
|
|
626
|
+
export interface IShell extends ISceneObject {
|
|
619
627
|
/**
|
|
620
628
|
* Selects the inner wall faces created by the shell operation (from thickness removal).
|
|
621
629
|
* @param args - Numeric indices or {@link FaceFilterBuilder} instances to filter the selection.
|
package/lib/dist/core/load.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ISceneObject } from "./interfaces.js";
|
|
2
2
|
interface LoadFunction {
|
|
3
3
|
/**
|
|
4
4
|
* Loads a 3D model file (STEP, STL, etc.) by filename.
|
|
5
5
|
* @param fileName - The path to the model file
|
|
6
6
|
*/
|
|
7
|
-
(fileName: string):
|
|
7
|
+
(fileName: string): ISceneObject;
|
|
8
8
|
}
|
|
9
9
|
declare const _default: LoadFunction;
|
|
10
10
|
export default _default;
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { PlaneLike } from "../math/plane.js";
|
|
2
2
|
import { AxisLike } from "../math/axis.js";
|
|
3
|
-
import { ISceneObject
|
|
3
|
+
import { ISceneObject } from "./interfaces.js";
|
|
4
4
|
interface MirrorFunction {
|
|
5
5
|
/**
|
|
6
6
|
* [2D] Mirror all sketch geometries across a given line.
|
|
7
7
|
* @param line The line to mirror across
|
|
8
8
|
*/
|
|
9
|
-
(line: ISceneObject):
|
|
9
|
+
(line: ISceneObject): ISceneObject;
|
|
10
10
|
/**
|
|
11
11
|
* [2D] Mirror all sketch geometries across a given axis.
|
|
12
12
|
* @param axis The local axis to mirror across
|
|
13
13
|
*/
|
|
14
|
-
(axis: AxisLike):
|
|
14
|
+
(axis: AxisLike): ISceneObject;
|
|
15
15
|
/**
|
|
16
16
|
* [2D] Mirror given sketch geometries across a given line.
|
|
17
17
|
* @param line The line to mirror across
|
|
18
18
|
* @param geometries The geometries to mirror
|
|
19
19
|
*/
|
|
20
|
-
(line: ISceneObject, ...geometries: ISceneObject[]):
|
|
20
|
+
(line: ISceneObject, ...geometries: ISceneObject[]): ISceneObject;
|
|
21
21
|
/**
|
|
22
22
|
* [2D] Mirror given sketch geometries across a given axis.
|
|
23
23
|
* @param axis The local axis to mirror across
|
|
24
24
|
* @param geometries The geometries to mirror
|
|
25
25
|
*/
|
|
26
|
-
(axis: AxisLike, ...geometries: ISceneObject[]):
|
|
26
|
+
(axis: AxisLike, ...geometries: ISceneObject[]): ISceneObject;
|
|
27
27
|
/**
|
|
28
28
|
* [3D] Mirror all scene shapes across a given plane.
|
|
29
29
|
* @param plane The plane to mirror across
|
|
30
30
|
*/
|
|
31
|
-
(plane: PlaneLike):
|
|
31
|
+
(plane: PlaneLike): ISceneObject;
|
|
32
32
|
/**
|
|
33
33
|
* [3D] Mirror given shapes across a given plane.
|
|
34
34
|
* @param plane The plane to mirror across
|
|
35
35
|
* @param objects The shapes to mirror
|
|
36
36
|
*/
|
|
37
|
-
(plane: PlaneLike, ...objects: ISceneObject[]):
|
|
37
|
+
(plane: PlaneLike, ...objects: ISceneObject[]): ISceneObject;
|
|
38
38
|
}
|
|
39
39
|
declare const _default: MirrorFunction;
|
|
40
40
|
export default _default;
|
package/lib/dist/core/mirror.js
CHANGED
|
@@ -4,84 +4,69 @@ import { SceneObject } from "../common/scene-object.js";
|
|
|
4
4
|
import { MirrorShape } from "../features/mirror-shape.js";
|
|
5
5
|
import { PlaneObjectBase } from "../features/plane-renderable-base.js";
|
|
6
6
|
import { PlaneObject } from "../features/plane.js";
|
|
7
|
-
import { isAxisLike } from "../math/axis.js";
|
|
7
|
+
import { isAxisLike, isStandardAxis } from "../math/axis.js";
|
|
8
8
|
import { MirrorShape2D } from "../features/mirror-shape2d.js";
|
|
9
9
|
import { AxisObjectBase } from "../features/axis-renderable-base.js";
|
|
10
10
|
import { AxisObject } from "../features/axis.js";
|
|
11
11
|
import { AxisFromEdge } from "../features/axis-from-edge.js";
|
|
12
|
+
const axisToPlaneName = { x: "yz", y: "xz", z: "xy" };
|
|
13
|
+
function resolveAxis(arg, context) {
|
|
14
|
+
if (arg instanceof AxisObjectBase) {
|
|
15
|
+
return arg;
|
|
16
|
+
}
|
|
17
|
+
if (arg instanceof SceneObject) {
|
|
18
|
+
const axis = new AxisFromEdge(arg);
|
|
19
|
+
context.addSceneObject(axis);
|
|
20
|
+
return axis;
|
|
21
|
+
}
|
|
22
|
+
const a = normalizeAxis(arg);
|
|
23
|
+
const axis = new AxisObject(a);
|
|
24
|
+
context.addSceneObject(axis);
|
|
25
|
+
return axis;
|
|
26
|
+
}
|
|
27
|
+
function resolvePlane(arg, context) {
|
|
28
|
+
if (arg instanceof PlaneObjectBase) {
|
|
29
|
+
return arg;
|
|
30
|
+
}
|
|
31
|
+
const normalizedPlane = normalizePlane(arg);
|
|
32
|
+
const planeObj = new PlaneObject(normalizedPlane);
|
|
33
|
+
context.addSceneObject(planeObj);
|
|
34
|
+
return planeObj;
|
|
35
|
+
}
|
|
12
36
|
function build(context) {
|
|
13
37
|
return function mirror() {
|
|
38
|
+
const activeSketch = context.getActiveSketch();
|
|
14
39
|
if (arguments.length === 1) {
|
|
15
|
-
if (isAxisLike(arguments[0] || arguments[0] instanceof SceneObject)) {
|
|
16
|
-
|
|
17
|
-
if (arguments[0] instanceof AxisObjectBase) {
|
|
18
|
-
axis = arguments[0];
|
|
19
|
-
}
|
|
20
|
-
else if (arguments[0] instanceof SceneObject) {
|
|
21
|
-
const line = arguments[0];
|
|
22
|
-
axis = new AxisFromEdge(line);
|
|
23
|
-
context.addSceneObject(axis);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
const a = normalizeAxis(arguments[0]);
|
|
27
|
-
axis = new AxisObject(a);
|
|
28
|
-
context.addSceneObject(axis);
|
|
29
|
-
}
|
|
40
|
+
if (activeSketch && (isAxisLike(arguments[0]) || arguments[0] instanceof SceneObject)) {
|
|
41
|
+
const axis = resolveAxis(arguments[0], context);
|
|
30
42
|
const mirror = new MirrorShape2D(axis);
|
|
31
43
|
context.addSceneObject(mirror);
|
|
32
44
|
return mirror;
|
|
33
45
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!(pln instanceof PlaneObjectBase)) {
|
|
38
|
-
const normalizedPlane = normalizePlane(arguments[0]);
|
|
39
|
-
planeObj = new PlaneObject(normalizedPlane);
|
|
40
|
-
context.addSceneObject(planeObj);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
planeObj = pln;
|
|
44
|
-
;
|
|
45
|
-
}
|
|
46
|
-
const mirror = new MirrorShape(planeObj);
|
|
47
|
-
context.addSceneObject(mirror);
|
|
48
|
-
return mirror;
|
|
46
|
+
let planeArg = arguments[0];
|
|
47
|
+
if (isStandardAxis(planeArg)) {
|
|
48
|
+
planeArg = axisToPlaneName[planeArg];
|
|
49
49
|
}
|
|
50
|
+
const planeObj = resolvePlane(planeArg, context);
|
|
51
|
+
const mirror = new MirrorShape(planeObj);
|
|
52
|
+
context.addSceneObject(mirror);
|
|
53
|
+
return mirror;
|
|
50
54
|
}
|
|
51
55
|
if (arguments.length >= 2) {
|
|
52
56
|
const args = Array.from(arguments);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
let axis = null;
|
|
56
|
-
if (args[0] instanceof AxisObjectBase) {
|
|
57
|
-
axis = args[0];
|
|
58
|
-
}
|
|
59
|
-
else if (args[0] instanceof SceneObject) {
|
|
60
|
-
const line = args[0];
|
|
61
|
-
axis = new AxisFromEdge(line);
|
|
62
|
-
context.addSceneObject(axis);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
const a = normalizeAxis(args[0]);
|
|
66
|
-
axis = new AxisObject(a);
|
|
67
|
-
context.addSceneObject(axis);
|
|
68
|
-
}
|
|
57
|
+
if (activeSketch && (isAxisLike(args[0]) || args[0] instanceof SceneObject)) {
|
|
58
|
+
const axis = resolveAxis(args[0], context);
|
|
69
59
|
const targetObjects = args.slice(1);
|
|
70
60
|
const mirror = new MirrorShape2D(axis, targetObjects);
|
|
71
61
|
context.addSceneObject(mirror);
|
|
72
62
|
return mirror;
|
|
73
63
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (!(args[0] instanceof PlaneObjectBase)) {
|
|
78
|
-
const normalizedPlane = normalizePlane(args[0]);
|
|
79
|
-
planeObj = new PlaneObject(normalizedPlane);
|
|
80
|
-
context.addSceneObject(planeObj);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
planeObj = args[0];
|
|
64
|
+
let planeArg = args[0];
|
|
65
|
+
if (isStandardAxis(planeArg)) {
|
|
66
|
+
planeArg = axisToPlaneName[planeArg];
|
|
84
67
|
}
|
|
68
|
+
const planeObj = resolvePlane(planeArg, context);
|
|
69
|
+
const targetObjects = args.slice(1);
|
|
85
70
|
const mirror = new MirrorShape(planeObj, targetObjects);
|
|
86
71
|
context.addSceneObject(mirror);
|
|
87
72
|
return mirror;
|
package/lib/dist/core/part.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ISceneObject } from "./interfaces.js";
|
|
2
|
-
|
|
2
|
+
type Extend<T> = T extends object ? T : {};
|
|
3
|
+
declare function part<T>(name: string, callback: () => T): ISceneObject & Extend<T>;
|
|
3
4
|
export default part;
|
package/lib/dist/core/part.js
CHANGED
|
@@ -12,8 +12,11 @@ function part(name, callback) {
|
|
|
12
12
|
partObj.setSourceLocation(sourceLocation);
|
|
13
13
|
}
|
|
14
14
|
scene.startProgressiveContainer(partObj);
|
|
15
|
-
callback();
|
|
15
|
+
const extensions = callback();
|
|
16
16
|
scene.endProgressiveContainer();
|
|
17
|
+
if (extensions && typeof extensions === 'object') {
|
|
18
|
+
Object.assign(partObj, extensions);
|
|
19
|
+
}
|
|
17
20
|
return partObj;
|
|
18
21
|
}
|
|
19
22
|
export default part;
|
package/lib/dist/core/plane.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { PlaneLike, PlaneTransformOptions } from "../math/plane.js";
|
|
2
2
|
import { IPlane, ISceneObject } from "./interfaces.js";
|
|
3
|
-
export type PlaneRenderableOptions = PlaneTransformOptions
|
|
4
|
-
sticky?: boolean;
|
|
5
|
-
};
|
|
3
|
+
export type PlaneRenderableOptions = PlaneTransformOptions;
|
|
6
4
|
interface PlaneFunction {
|
|
7
5
|
/**
|
|
8
6
|
* Creates a plane from a standard plane or normal vector.
|
|
@@ -12,7 +10,7 @@ interface PlaneFunction {
|
|
|
12
10
|
/**
|
|
13
11
|
* Creates a plane with transform options.
|
|
14
12
|
* @param plane - The standard plane or normal vector
|
|
15
|
-
* @param options - Transform options (offset,
|
|
13
|
+
* @param options - Transform options (offset, rotate, etc.)
|
|
16
14
|
*/
|
|
17
15
|
(plane: PlaneLike, options: PlaneRenderableOptions): IPlane;
|
|
18
16
|
/**
|
|
@@ -29,7 +27,7 @@ interface PlaneFunction {
|
|
|
29
27
|
/**
|
|
30
28
|
* Creates a plane from a face selection with transform options.
|
|
31
29
|
* @param selection - The selected face to create a plane from
|
|
32
|
-
* @param options - Transform options (offset,
|
|
30
|
+
* @param options - Transform options (offset, rotate, etc.)
|
|
33
31
|
*/
|
|
34
32
|
(selection: ISceneObject, options: PlaneRenderableOptions): IPlane;
|
|
35
33
|
/**
|
|
@@ -41,14 +39,14 @@ interface PlaneFunction {
|
|
|
41
39
|
/**
|
|
42
40
|
* Transforms an existing plane with options.
|
|
43
41
|
* @param plane - The existing plane to transform
|
|
44
|
-
* @param options - Transform options (offset,
|
|
42
|
+
* @param options - Transform options (offset, rotate, etc.)
|
|
45
43
|
*/
|
|
46
44
|
(plane: IPlane, options: PlaneRenderableOptions): IPlane;
|
|
47
45
|
/**
|
|
48
46
|
* Creates a plane midway between two standard planes or normal vectors.
|
|
49
47
|
* @param p1 - The first standard plane or normal vector
|
|
50
48
|
* @param p2 - The second standard plane or normal vector
|
|
51
|
-
* @param options - Transform options (offset,
|
|
49
|
+
* @param options - Transform options (offset, rotate, etc.)
|
|
52
50
|
*/
|
|
53
51
|
(p1: PlaneLike, p2: PlaneLike, options?: PlaneRenderableOptions): IPlane;
|
|
54
52
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ISceneObject
|
|
1
|
+
import { ISceneObject } from "./interfaces.js";
|
|
2
2
|
interface RemoveFunction {
|
|
3
3
|
/**
|
|
4
4
|
* Removes the given objects from the scene.
|
|
5
5
|
* @param objects - The objects to remove
|
|
6
6
|
*/
|
|
7
|
-
(...objects: ISceneObject[]):
|
|
7
|
+
(...objects: ISceneObject[]): ISceneObject;
|
|
8
8
|
}
|
|
9
9
|
declare const _default: RemoveFunction;
|
|
10
10
|
export default _default;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { AxisLike } from "../math/axis.js";
|
|
2
|
-
import { ISceneObject
|
|
2
|
+
import { ISceneObject } from "./interfaces.js";
|
|
3
3
|
interface RotateFunction {
|
|
4
4
|
/**
|
|
5
5
|
* [2D] Rotates geometry by an angle inside a sketch.
|
|
6
6
|
* @param angle - The rotation angle in degrees
|
|
7
7
|
* @param targets - The geometries to rotate (defaults to last object)
|
|
8
8
|
*/
|
|
9
|
-
(angle: number, ...targets: ISceneObject[]):
|
|
9
|
+
(angle: number, ...targets: ISceneObject[]): ISceneObject;
|
|
10
10
|
/**
|
|
11
11
|
* [2D] Rotates geometry by an angle inside a sketch, optionally making a copy.
|
|
12
12
|
* @param angle - The rotation angle in degrees
|
|
13
13
|
* @param copy - Whether to copy instead of move
|
|
14
14
|
* @param targets - The geometries to rotate (defaults to last object)
|
|
15
15
|
*/
|
|
16
|
-
(angle: number, copy: boolean, ...targets: ISceneObject[]):
|
|
16
|
+
(angle: number, copy: boolean, ...targets: ISceneObject[]): ISceneObject;
|
|
17
17
|
/**
|
|
18
18
|
* [3D] Rotates objects around an axis by an angle.
|
|
19
19
|
* @param axis - The axis to rotate around
|
|
20
20
|
* @param angle - The rotation angle in degrees
|
|
21
21
|
* @param targets - The objects to rotate (defaults to last object)
|
|
22
22
|
*/
|
|
23
|
-
(axis: AxisLike, angle: number, ...targets: ISceneObject[]):
|
|
23
|
+
(axis: AxisLike, angle: number, ...targets: ISceneObject[]): ISceneObject;
|
|
24
24
|
/**
|
|
25
25
|
* [3D] Rotates objects around an axis by an angle, optionally making a copy.
|
|
26
26
|
* @param axis - The axis to rotate around
|
|
@@ -28,7 +28,7 @@ interface RotateFunction {
|
|
|
28
28
|
* @param copy - Whether to copy instead of move
|
|
29
29
|
* @param targets - The objects to rotate (defaults to last object)
|
|
30
30
|
*/
|
|
31
|
-
(axis: AxisLike, angle: number, copy: boolean, ...targets: ISceneObject[]):
|
|
31
|
+
(axis: AxisLike, angle: number, copy: boolean, ...targets: ISceneObject[]): ISceneObject;
|
|
32
32
|
}
|
|
33
33
|
declare const _default: RotateFunction;
|
|
34
34
|
export default _default;
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { PlaneLike } from "../math/plane.js";
|
|
2
2
|
import { IPlane, ISceneObject } from "./interfaces.js";
|
|
3
|
+
type Extend<T> = T extends object ? T : {};
|
|
3
4
|
interface SketchFunction {
|
|
4
5
|
/**
|
|
5
6
|
* Draws 2D geometry on a standard plane.
|
|
6
7
|
* @param plane - The plane to sketch on
|
|
7
8
|
* @param sketcher - Callback containing sketch operations
|
|
8
9
|
*/
|
|
9
|
-
(plane: PlaneLike, sketcher: () =>
|
|
10
|
+
<T>(plane: PlaneLike, sketcher: () => T): ISceneObject & Extend<T>;
|
|
10
11
|
/**
|
|
11
12
|
* Draws 2D geometry on a face selection.
|
|
12
13
|
* @param face - The face to sketch on
|
|
13
14
|
* @param sketcher - Callback containing sketch operations
|
|
14
15
|
*/
|
|
15
|
-
(face: ISceneObject, sketcher: () =>
|
|
16
|
+
<T>(face: ISceneObject, sketcher: () => T): ISceneObject & Extend<T>;
|
|
16
17
|
/**
|
|
17
18
|
* Draws 2D geometry on an existing Plane object.
|
|
18
19
|
* @param plane - The Plane object to sketch on
|
|
19
20
|
* @param sketcher - Callback containing sketch operations
|
|
20
21
|
*/
|
|
21
|
-
(plane: IPlane, sketcher: () =>
|
|
22
|
+
<T>(plane: IPlane, sketcher: () => T): ISceneObject & Extend<T>;
|
|
22
23
|
}
|
|
23
24
|
declare const _default: SketchFunction;
|
|
24
25
|
export default _default;
|
package/lib/dist/core/sketch.js
CHANGED
|
@@ -26,8 +26,11 @@ function build(context) {
|
|
|
26
26
|
}
|
|
27
27
|
const sketch = new Sketch(planeObj);
|
|
28
28
|
context.startProgressiveContainer(sketch);
|
|
29
|
-
sketcher();
|
|
29
|
+
const extensions = sketcher();
|
|
30
30
|
context.endProgressiveContainer();
|
|
31
|
+
if (extensions && typeof extensions === 'object') {
|
|
32
|
+
Object.assign(sketch, extensions);
|
|
33
|
+
}
|
|
31
34
|
return sketch;
|
|
32
35
|
};
|
|
33
36
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISceneObject
|
|
1
|
+
import { ISceneObject } from "./interfaces.js";
|
|
2
2
|
interface SubtractFunction {
|
|
3
3
|
/**
|
|
4
4
|
* Subtracts the second shape from the first (boolean difference).
|
|
@@ -6,7 +6,7 @@ interface SubtractFunction {
|
|
|
6
6
|
* @param object1 - The base shape
|
|
7
7
|
* @param object2 - The shape to subtract
|
|
8
8
|
*/
|
|
9
|
-
(object1: ISceneObject, object2: ISceneObject):
|
|
9
|
+
(object1: ISceneObject, object2: ISceneObject): ISceneObject;
|
|
10
10
|
}
|
|
11
11
|
declare const _default: SubtractFunction;
|
|
12
12
|
export default _default;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { PointLike } from "../math/point.js";
|
|
2
|
-
import { ISceneObject
|
|
2
|
+
import { ISceneObject } from "./interfaces.js";
|
|
3
3
|
interface TranslateFunction {
|
|
4
4
|
/**
|
|
5
5
|
* Translates objects along the X axis.
|
|
6
6
|
* @param x - The X distance
|
|
7
7
|
* @param targets - The objects to translate (defaults to last object)
|
|
8
8
|
*/
|
|
9
|
-
(x: number, ...targets: ISceneObject[]):
|
|
9
|
+
(x: number, ...targets: ISceneObject[]): ISceneObject;
|
|
10
10
|
/**
|
|
11
11
|
* Translates objects along the X axis, optionally making a copy.
|
|
12
12
|
* @param x - The X distance
|
|
13
13
|
* @param copy - Whether to copy instead of move
|
|
14
14
|
* @param targets - The objects to translate (defaults to last object)
|
|
15
15
|
*/
|
|
16
|
-
(x: number, copy: boolean, ...targets: ISceneObject[]):
|
|
16
|
+
(x: number, copy: boolean, ...targets: ISceneObject[]): ISceneObject;
|
|
17
17
|
/**
|
|
18
18
|
* Translates objects along the X and Y axes.
|
|
19
19
|
* @param x - The X distance
|
|
20
20
|
* @param y - The Y distance
|
|
21
21
|
* @param targets - The objects to translate (defaults to last object)
|
|
22
22
|
*/
|
|
23
|
-
(x: number, y: number, ...targets: ISceneObject[]):
|
|
23
|
+
(x: number, y: number, ...targets: ISceneObject[]): ISceneObject;
|
|
24
24
|
/**
|
|
25
25
|
* Translates objects along the X and Y axes, optionally making a copy.
|
|
26
26
|
* @param x - The X distance
|
|
@@ -28,7 +28,7 @@ interface TranslateFunction {
|
|
|
28
28
|
* @param copy - Whether to copy instead of move
|
|
29
29
|
* @param targets - The objects to translate (defaults to last object)
|
|
30
30
|
*/
|
|
31
|
-
(x: number, y: number, copy: boolean, ...targets: ISceneObject[]):
|
|
31
|
+
(x: number, y: number, copy: boolean, ...targets: ISceneObject[]): ISceneObject;
|
|
32
32
|
/**
|
|
33
33
|
* Translates objects along all three axes.
|
|
34
34
|
* @param x - The X distance
|
|
@@ -36,7 +36,7 @@ interface TranslateFunction {
|
|
|
36
36
|
* @param z - The Z distance
|
|
37
37
|
* @param targets - The objects to translate (defaults to last object)
|
|
38
38
|
*/
|
|
39
|
-
(x: number, y: number, z: number, ...targets: ISceneObject[]):
|
|
39
|
+
(x: number, y: number, z: number, ...targets: ISceneObject[]): ISceneObject;
|
|
40
40
|
/**
|
|
41
41
|
* Translates objects along all three axes, optionally making a copy.
|
|
42
42
|
* @param x - The X distance
|
|
@@ -45,20 +45,20 @@ interface TranslateFunction {
|
|
|
45
45
|
* @param copy - Whether to copy instead of move
|
|
46
46
|
* @param targets - The objects to translate (defaults to last object)
|
|
47
47
|
*/
|
|
48
|
-
(x: number, y: number, z: number, copy: boolean, ...targets: ISceneObject[]):
|
|
48
|
+
(x: number, y: number, z: number, copy: boolean, ...targets: ISceneObject[]): ISceneObject;
|
|
49
49
|
/**
|
|
50
50
|
* Translates objects by a point-like offset.
|
|
51
51
|
* @param distance - The offset as a point
|
|
52
52
|
* @param targets - The objects to translate (defaults to last object)
|
|
53
53
|
*/
|
|
54
|
-
(distance: PointLike, ...targets: ISceneObject[]):
|
|
54
|
+
(distance: PointLike, ...targets: ISceneObject[]): ISceneObject;
|
|
55
55
|
/**
|
|
56
56
|
* Translates objects by a point-like offset, optionally making a copy.
|
|
57
57
|
* @param distance - The offset as a point
|
|
58
58
|
* @param copy - Whether to copy instead of move
|
|
59
59
|
* @param targets - The objects to translate (defaults to last object)
|
|
60
60
|
*/
|
|
61
|
-
(distance: PointLike, copy: boolean, ...targets: ISceneObject[]):
|
|
61
|
+
(distance: PointLike, copy: boolean, ...targets: ISceneObject[]): ISceneObject;
|
|
62
62
|
}
|
|
63
63
|
declare const _default: TranslateFunction;
|
|
64
64
|
export default _default;
|
|
@@ -6,8 +6,10 @@ export declare class Slot extends ExtrudableGeometryBase implements ISlot {
|
|
|
6
6
|
distance: number;
|
|
7
7
|
radius: number;
|
|
8
8
|
private _center;
|
|
9
|
+
private _angle;
|
|
9
10
|
constructor(distance: number, radius: number, targetPlane?: PlaneObjectBase);
|
|
10
11
|
centered(value?: boolean): this;
|
|
12
|
+
rotate(angle: number): this;
|
|
11
13
|
build(): void;
|
|
12
14
|
getType(): string;
|
|
13
15
|
getDependencies(): SceneObject[];
|
|
@@ -17,5 +19,6 @@ export declare class Slot extends ExtrudableGeometryBase implements ISlot {
|
|
|
17
19
|
distance: number;
|
|
18
20
|
radius: number;
|
|
19
21
|
centered: boolean;
|
|
22
|
+
angle: number;
|
|
20
23
|
};
|
|
21
24
|
}
|