@bitbybit-dev/manifold 1.7.0 → 1.8.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/lib/api/dto-registry.js +3 -3
- package/lib/api/inputs/manifold-inputs.d.ts +36 -12
- package/lib/api/inputs/manifold-inputs.js +26 -15
- package/lib/api/resolved-inputs/index.d.ts +3 -3
- package/lib/api/services/recipes/recipe-meshes.d.ts +2 -1
- package/lib/api/services/recipes/recipe-meshes.js +9 -7
- package/lib/api/services/recipes/recipe-placing.d.ts +3 -2
- package/lib/api/services/recipes/recipe-placing.js +10 -6
- package/lib/api/services/recipes/recipes.d.ts +4 -4
- package/lib/api/services/recipes/recipes.js +7 -7
- package/package.json +2 -2
package/lib/api/dto-registry.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// GENERATED by scripts/gen-dto-meta.mjs from the ManifoldService surface - do not edit; regenerate with `npm run gen:dto-meta`.
|
|
2
2
|
import { constraintKinds as k } from "@bitbybit-dev/base";
|
|
3
3
|
import * as Inputs from "./inputs";
|
|
4
|
-
const Manifold_BuildRecipeDto = { recipe: k.required(k.opaque), circularSegments: k.between(k.number, { min: 3 }), adjustZtoY: k.boolean, emptyWhenFailed: k.boolean };
|
|
5
|
-
const Manifold_BuildRecipeMeshesDto = { recipe: k.required(k.opaque), circularSegments: k.between(k.number, { min: 3 }), adjustZtoY: k.boolean, emptyWhenFailed: k.boolean, minSharpAngle: k.between(k.number, { min: 0, max: 180 }) };
|
|
4
|
+
const Manifold_BuildRecipeDto = { recipe: k.required(k.opaque), circularSegments: k.between(k.number, { min: 3 }), upAxis: k.oneOf(["keep", "zUpToYUp", "yUpToZUp"]), adjustZtoY: k.boolean, emptyWhenFailed: k.boolean };
|
|
5
|
+
const Manifold_BuildRecipeMeshesDto = { recipe: k.required(k.opaque), circularSegments: k.between(k.number, { min: 3 }), upAxis: k.oneOf(["keep", "zUpToYUp", "yUpToZUp"]), adjustZtoY: k.boolean, emptyWhenFailed: k.boolean, minSharpAngle: k.between(k.number, { min: 0, max: 180 }) };
|
|
6
6
|
const Manifold_CalculateCurvatureDto = { manifold: k.required(k.opaque), gaussianIdx: k.between(k.number, { min: 0 }), meanIdx: k.between(k.number, { min: 0 }) };
|
|
7
7
|
const Manifold_CalculateNormalsDto = { manifold: k.required(k.opaque), normalIdx: k.between(k.number, { min: 0 }), minSharpAngle: k.between(k.number, { min: 0 }) };
|
|
8
8
|
const Manifold_CircleDto = { radius: k.between(k.number, { min: 0 }), circularSegments: k.between(k.number, { min: 0 }) };
|
|
@@ -45,7 +45,7 @@ const Manifold_MirrorCrossSectionDto = { crossSection: k.required(k.opaque), nor
|
|
|
45
45
|
const Manifold_MirrorDto = { manifold: k.required(k.opaque), normal: k.vector3 };
|
|
46
46
|
const Manifold_OffsetDto = { crossSection: k.required(k.opaque), delta: k.number, joinType: k.oneOf(["Square", "Round", "Miter", "Bevel"]), miterLimit: k.between(k.number, { min: 2 }), circularSegments: k.between(k.number, { min: 0 }) };
|
|
47
47
|
const Manifold_RayCastDto = { manifold: k.required(k.opaque), origin: k.point3, endpoint: k.point3 };
|
|
48
|
-
const Manifold_RecipeSurfaceMeshesDto = { recipe: k.required(k.opaque), roots: k.list(k.number), adjustZtoY: k.boolean };
|
|
48
|
+
const Manifold_RecipeSurfaceMeshesDto = { recipe: k.required(k.opaque), roots: k.list(k.number), upAxis: k.oneOf(["keep", "zUpToYUp", "yUpToZUp"]), adjustZtoY: k.boolean };
|
|
49
49
|
const Manifold_RectangleDto = { length: k.between(k.number, { min: 0 }), height: k.between(k.number, { min: 0 }), center: k.boolean };
|
|
50
50
|
const Manifold_RevolveDto = { crossSection: k.required(k.opaque), revolveDegrees: k.between(k.number, { min: 0, exclusiveMin: true }), matchProfile: k.boolean, circularSegments: k.between(k.number, { min: 0 }) };
|
|
51
51
|
const Manifold_RotateCrossSectionDto = { crossSection: k.required(k.opaque), degrees: k.number };
|
|
@@ -1735,7 +1735,7 @@ export declare namespace Manifold {
|
|
|
1735
1735
|
* @beta
|
|
1736
1736
|
*/
|
|
1737
1737
|
class BuildRecipeDto {
|
|
1738
|
-
constructor(recipe?: Base.Recipe, circularSegments?: number, adjustZtoY?: boolean, emptyWhenFailed?: boolean);
|
|
1738
|
+
constructor(recipe?: Base.Recipe, circularSegments?: number, adjustZtoY?: boolean, emptyWhenFailed?: boolean, upAxis?: Base.upAxisConversionEnum);
|
|
1739
1739
|
/**
|
|
1740
1740
|
* The recipe: steps such as polygons, extrusions and cuts, and the roots to build from them, as
|
|
1741
1741
|
* a package that describes geometry as data writes it.
|
|
@@ -1752,9 +1752,17 @@ export declare namespace Manifold {
|
|
|
1752
1752
|
*/
|
|
1753
1753
|
circularSegments?: number | undefined;
|
|
1754
1754
|
/**
|
|
1755
|
-
*
|
|
1756
|
-
*
|
|
1757
|
-
* @default
|
|
1755
|
+
* `zUpToYUp` turns each solid a quarter turn about X so the recipe's Z points along Y, and
|
|
1756
|
+
* `(x, y, z)` becomes `(x, z, -y)`; `keep` leaves them. `yUpToZUp` is refused.
|
|
1757
|
+
* @default keep
|
|
1758
|
+
*/
|
|
1759
|
+
upAxis?: Base.upAxisConversionEnum | undefined;
|
|
1760
|
+
/**
|
|
1761
|
+
* When true, the solids turn as `upAxis` `zUpToYUp` does; false, its old default, decides nothing.
|
|
1762
|
+
* True wins over `upAxis` at its default; beside another chosen turn it is refused.
|
|
1763
|
+
* @deprecated Give `upAxis` instead; this flag goes in the next major version.
|
|
1764
|
+
* @default undefined
|
|
1765
|
+
* @optional true
|
|
1758
1766
|
*/
|
|
1759
1767
|
adjustZtoY?: boolean | undefined;
|
|
1760
1768
|
/**
|
|
@@ -1771,7 +1779,7 @@ export declare namespace Manifold {
|
|
|
1771
1779
|
* @beta
|
|
1772
1780
|
*/
|
|
1773
1781
|
class RecipeSurfaceMeshesDto {
|
|
1774
|
-
constructor(recipe?: Base.Recipe, roots?: number[], adjustZtoY?: boolean);
|
|
1782
|
+
constructor(recipe?: Base.Recipe, roots?: number[], adjustZtoY?: boolean, upAxis?: Base.upAxisConversionEnum);
|
|
1775
1783
|
/**
|
|
1776
1784
|
* The recipe: steps such as polygons, extrusions and triangle meshes, and the roots to build
|
|
1777
1785
|
* from them, as a package that describes geometry as data writes it.
|
|
@@ -1786,9 +1794,17 @@ export declare namespace Manifold {
|
|
|
1786
1794
|
*/
|
|
1787
1795
|
roots?: number[] | undefined;
|
|
1788
1796
|
/**
|
|
1789
|
-
*
|
|
1790
|
-
* `recipes.build` turns its solids
|
|
1791
|
-
* @default
|
|
1797
|
+
* Whether the meshes turn: `zUpToYUp` turns each a quarter turn about X so the recipe's Z points
|
|
1798
|
+
* along Y, as `recipes.build` turns its solids; `keep` leaves them. `yUpToZUp` is refused.
|
|
1799
|
+
* @default keep
|
|
1800
|
+
*/
|
|
1801
|
+
upAxis?: Base.upAxisConversionEnum | undefined;
|
|
1802
|
+
/**
|
|
1803
|
+
* When true, the meshes turn as `upAxis` `zUpToYUp` does; false, its old default, decides nothing.
|
|
1804
|
+
* True wins over `upAxis` at its default; beside another chosen turn it is refused.
|
|
1805
|
+
* @deprecated Give `upAxis` instead; this flag goes in the next major version.
|
|
1806
|
+
* @default undefined
|
|
1807
|
+
* @optional true
|
|
1792
1808
|
*/
|
|
1793
1809
|
adjustZtoY?: boolean | undefined;
|
|
1794
1810
|
}
|
|
@@ -1799,7 +1815,7 @@ export declare namespace Manifold {
|
|
|
1799
1815
|
* @beta
|
|
1800
1816
|
*/
|
|
1801
1817
|
class BuildRecipeMeshesDto {
|
|
1802
|
-
constructor(recipe?: Base.Recipe, circularSegments?: number, adjustZtoY?: boolean, emptyWhenFailed?: boolean, minSharpAngle?: number);
|
|
1818
|
+
constructor(recipe?: Base.Recipe, circularSegments?: number, adjustZtoY?: boolean, emptyWhenFailed?: boolean, minSharpAngle?: number, upAxis?: Base.upAxisConversionEnum);
|
|
1803
1819
|
/**
|
|
1804
1820
|
* The recipe: steps such as polygons, extrusions and cuts, and the roots to draw from them, as
|
|
1805
1821
|
* a package that describes geometry as data writes it.
|
|
@@ -1815,9 +1831,17 @@ export declare namespace Manifold {
|
|
|
1815
1831
|
*/
|
|
1816
1832
|
circularSegments?: number | undefined;
|
|
1817
1833
|
/**
|
|
1818
|
-
*
|
|
1819
|
-
* which is up when drawn
|
|
1820
|
-
* @default
|
|
1834
|
+
* Whether the placements turn: `zUpToYUp` turns each a quarter turn about X so the recipe's Z
|
|
1835
|
+
* points along Y, which is up when drawn; `keep` leaves them. `yUpToZUp` is refused.
|
|
1836
|
+
* @default keep
|
|
1837
|
+
*/
|
|
1838
|
+
upAxis?: Base.upAxisConversionEnum | undefined;
|
|
1839
|
+
/**
|
|
1840
|
+
* When true, the placements turn as `upAxis` `zUpToYUp` does; false, its old default, decides
|
|
1841
|
+
* nothing. True wins over `upAxis` at its default; beside another chosen turn it is refused.
|
|
1842
|
+
* @deprecated Give `upAxis` instead; this flag goes in the next major version.
|
|
1843
|
+
* @default undefined
|
|
1844
|
+
* @optional true
|
|
1821
1845
|
*/
|
|
1822
1846
|
adjustZtoY?: boolean | undefined;
|
|
1823
1847
|
/**
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
+
import { Base } from "./base-inputs";
|
|
1
3
|
// GENERATED by scripts/gen-inputs.mjs from the fragments in ./manifold/ - do not edit; edit a fragment and run `npm run gen:inputs`.
|
|
2
4
|
/**
|
|
3
5
|
* Every parameter object the Manifold kernel accepts. Manifold specialises in fast, reliably
|
|
@@ -1926,7 +1928,7 @@ export var Manifold;
|
|
|
1926
1928
|
* @beta
|
|
1927
1929
|
*/
|
|
1928
1930
|
class BuildRecipeDto {
|
|
1929
|
-
constructor(recipe, circularSegments, adjustZtoY, emptyWhenFailed) {
|
|
1931
|
+
constructor(recipe, circularSegments, adjustZtoY, emptyWhenFailed, upAxis) {
|
|
1930
1932
|
/**
|
|
1931
1933
|
* How many flat sides each circle of the recipe is divided into; more is rounder. The recipe
|
|
1932
1934
|
* leaves this to the kernel, so it is chosen here.
|
|
@@ -1937,11 +1939,11 @@ export var Manifold;
|
|
|
1937
1939
|
*/
|
|
1938
1940
|
this.circularSegments = 32;
|
|
1939
1941
|
/**
|
|
1940
|
-
*
|
|
1941
|
-
*
|
|
1942
|
-
* @default
|
|
1942
|
+
* `zUpToYUp` turns each solid a quarter turn about X so the recipe's Z points along Y, and
|
|
1943
|
+
* `(x, y, z)` becomes `(x, z, -y)`; `keep` leaves them. `yUpToZUp` is refused.
|
|
1944
|
+
* @default keep
|
|
1943
1945
|
*/
|
|
1944
|
-
this.
|
|
1946
|
+
this.upAxis = Base.upAxisConversionEnum.keep;
|
|
1945
1947
|
/**
|
|
1946
1948
|
* When true, a root that cannot be built, such as an open mesh, comes back empty, and an
|
|
1947
1949
|
* opening that cannot is left uncut; when false, both stop the build.
|
|
@@ -1960,6 +1962,9 @@ export var Manifold;
|
|
|
1960
1962
|
if (emptyWhenFailed !== undefined) {
|
|
1961
1963
|
this.emptyWhenFailed = emptyWhenFailed;
|
|
1962
1964
|
}
|
|
1965
|
+
if (upAxis !== undefined) {
|
|
1966
|
+
this.upAxis = upAxis;
|
|
1967
|
+
}
|
|
1963
1968
|
}
|
|
1964
1969
|
}
|
|
1965
1970
|
Manifold.BuildRecipeDto = BuildRecipeDto;
|
|
@@ -1970,13 +1975,13 @@ export var Manifold;
|
|
|
1970
1975
|
* @beta
|
|
1971
1976
|
*/
|
|
1972
1977
|
class RecipeSurfaceMeshesDto {
|
|
1973
|
-
constructor(recipe, roots, adjustZtoY) {
|
|
1978
|
+
constructor(recipe, roots, adjustZtoY, upAxis) {
|
|
1974
1979
|
/**
|
|
1975
|
-
*
|
|
1976
|
-
* `recipes.build` turns its solids
|
|
1977
|
-
* @default
|
|
1980
|
+
* Whether the meshes turn: `zUpToYUp` turns each a quarter turn about X so the recipe's Z points
|
|
1981
|
+
* along Y, as `recipes.build` turns its solids; `keep` leaves them. `yUpToZUp` is refused.
|
|
1982
|
+
* @default keep
|
|
1978
1983
|
*/
|
|
1979
|
-
this.
|
|
1984
|
+
this.upAxis = Base.upAxisConversionEnum.keep;
|
|
1980
1985
|
if (recipe !== undefined) {
|
|
1981
1986
|
this.recipe = recipe;
|
|
1982
1987
|
}
|
|
@@ -1986,6 +1991,9 @@ export var Manifold;
|
|
|
1986
1991
|
if (adjustZtoY !== undefined) {
|
|
1987
1992
|
this.adjustZtoY = adjustZtoY;
|
|
1988
1993
|
}
|
|
1994
|
+
if (upAxis !== undefined) {
|
|
1995
|
+
this.upAxis = upAxis;
|
|
1996
|
+
}
|
|
1989
1997
|
}
|
|
1990
1998
|
}
|
|
1991
1999
|
Manifold.RecipeSurfaceMeshesDto = RecipeSurfaceMeshesDto;
|
|
@@ -1996,7 +2004,7 @@ export var Manifold;
|
|
|
1996
2004
|
* @beta
|
|
1997
2005
|
*/
|
|
1998
2006
|
class BuildRecipeMeshesDto {
|
|
1999
|
-
constructor(recipe, circularSegments, adjustZtoY, emptyWhenFailed, minSharpAngle) {
|
|
2007
|
+
constructor(recipe, circularSegments, adjustZtoY, emptyWhenFailed, minSharpAngle, upAxis) {
|
|
2000
2008
|
/**
|
|
2001
2009
|
* How many flat sides each circle of the recipe is divided into; more is rounder.
|
|
2002
2010
|
* @default 32
|
|
@@ -2006,11 +2014,11 @@ export var Manifold;
|
|
|
2006
2014
|
*/
|
|
2007
2015
|
this.circularSegments = 32;
|
|
2008
2016
|
/**
|
|
2009
|
-
*
|
|
2010
|
-
* which is up when drawn
|
|
2011
|
-
* @default
|
|
2017
|
+
* Whether the placements turn: `zUpToYUp` turns each a quarter turn about X so the recipe's Z
|
|
2018
|
+
* points along Y, which is up when drawn; `keep` leaves them. `yUpToZUp` is refused.
|
|
2019
|
+
* @default keep
|
|
2012
2020
|
*/
|
|
2013
|
-
this.
|
|
2021
|
+
this.upAxis = Base.upAxisConversionEnum.keep;
|
|
2014
2022
|
/**
|
|
2015
2023
|
* When true, a root that cannot be built draws as its surface if it is triangles alone, else
|
|
2016
2024
|
* draws nothing; when false, it stops the build.
|
|
@@ -2040,6 +2048,9 @@ export var Manifold;
|
|
|
2040
2048
|
if (minSharpAngle !== undefined) {
|
|
2041
2049
|
this.minSharpAngle = minSharpAngle;
|
|
2042
2050
|
}
|
|
2051
|
+
if (upAxis !== undefined) {
|
|
2052
|
+
this.upAxis = upAxis;
|
|
2053
|
+
}
|
|
2043
2054
|
}
|
|
2044
2055
|
}
|
|
2045
2056
|
Manifold.BuildRecipeMeshesDto = BuildRecipeMeshesDto;
|
|
@@ -6,8 +6,8 @@ export * from "@bitbybit-dev/base/lib/api/resolved-inputs";
|
|
|
6
6
|
* the way `resolveDto` hands a DTO to the code that reads it.
|
|
7
7
|
*/
|
|
8
8
|
export declare namespace Manifold {
|
|
9
|
-
type BuildRecipeDto = WithDefaults<Inputs.Manifold.BuildRecipeDto, "circularSegments" | "
|
|
10
|
-
type BuildRecipeMeshesDto = WithDefaults<Inputs.Manifold.BuildRecipeMeshesDto, "circularSegments" | "
|
|
9
|
+
type BuildRecipeDto = WithDefaults<Inputs.Manifold.BuildRecipeDto, "circularSegments" | "upAxis" | "emptyWhenFailed">;
|
|
10
|
+
type BuildRecipeMeshesDto = WithDefaults<Inputs.Manifold.BuildRecipeMeshesDto, "circularSegments" | "upAxis" | "emptyWhenFailed" | "minSharpAngle">;
|
|
11
11
|
type CalculateCurvatureDto<T> = WithDefaults<Inputs.Manifold.CalculateCurvatureDto<T>, "gaussianIdx" | "meanIdx">;
|
|
12
12
|
type CalculateNormalsDto<T> = WithDefaults<Inputs.Manifold.CalculateNormalsDto<T>, "normalIdx" | "minSharpAngle">;
|
|
13
13
|
type CircleDto = WithDefaults<Inputs.Manifold.CircleDto, "radius" | "circularSegments">;
|
|
@@ -57,7 +57,7 @@ export declare namespace Manifold {
|
|
|
57
57
|
type RayCastDto<T> = WithDefaults<Inputs.Manifold.RayCastDto<T>, "origin" | "endpoint">;
|
|
58
58
|
type RecipeMeshesDto = Inputs.Manifold.RecipeMeshesDto;
|
|
59
59
|
type RecipeMeshPlacementDto = Inputs.Manifold.RecipeMeshPlacementDto;
|
|
60
|
-
type RecipeSurfaceMeshesDto = WithDefaults<Inputs.Manifold.RecipeSurfaceMeshesDto, "
|
|
60
|
+
type RecipeSurfaceMeshesDto = WithDefaults<Inputs.Manifold.RecipeSurfaceMeshesDto, "upAxis">;
|
|
61
61
|
type RectangleDto = WithDefaults<Inputs.Manifold.RectangleDto, "length" | "height" | "center">;
|
|
62
62
|
type RevolveDto<T> = WithDefaults<Inputs.Manifold.RevolveDto<T>, "revolveDegrees" | "matchProfile" | "circularSegments">;
|
|
63
63
|
type RotateCrossSectionDto<T> = WithDefaults<Inputs.Manifold.RotateCrossSectionDto<T>, "degrees">;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type * as Manifold3D from "manifold-3d";
|
|
2
|
-
import type { Base
|
|
2
|
+
import type { Base } from "@bitbybit-dev/base";
|
|
3
|
+
import { Inputs as BaseInputs } from "@bitbybit-dev/base";
|
|
3
4
|
import { Recipes } from "@bitbybit-dev/base";
|
|
4
5
|
import type * as Inputs from "../../inputs";
|
|
5
6
|
import type * as Resolved from "../../resolved-inputs";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { Inputs as BaseInputs } from "@bitbybit-dev/base";
|
|
1
2
|
import { Recipes } from "@bitbybit-dev/base";
|
|
2
3
|
import { creasedMeshData, positionsOf } from "../mesh-data";
|
|
3
4
|
import { executeRecipeNodes } from "./recipe-executor";
|
|
4
|
-
import { mirrorIntoModel, placedAmongMirrored, turnedZtoY } from "./recipe-placing";
|
|
5
|
+
import { mirrorIntoModel, placedAmongMirrored, turnedFromZUp, turnedZtoY } from "./recipe-placing";
|
|
5
6
|
const IDENTITY = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
6
7
|
const NO_MESH = -1;
|
|
7
|
-
function placedBy(matrix,
|
|
8
|
-
return
|
|
8
|
+
function placedBy(matrix, zUp) {
|
|
9
|
+
return zUp ? turnedZtoY(matrix) : [...matrix];
|
|
9
10
|
}
|
|
10
11
|
function meshOf(solid, minSharpAngle, mirror) {
|
|
11
12
|
if (solid.isEmpty()) {
|
|
@@ -25,7 +26,8 @@ function meshOf(solid, minSharpAngle, mirror) {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
export function recipeMeshes(wasm, recipes, recipe, options, coordinateSystem) {
|
|
28
|
-
const
|
|
29
|
+
const zUp = turnedFromZUp(options.upAxis);
|
|
30
|
+
const mirror = mirrorIntoModel(coordinateSystem, zUp);
|
|
29
31
|
const sources = recipe.roots.map((root) => recipes.sourceOf({ recipe, node: root.node, matrix: root.matrix }));
|
|
30
32
|
const solids = executeRecipeNodes(wasm, recipe, options.circularSegments, options.emptyWhenFailed, [...new Set(sources.map((source) => source.node))]);
|
|
31
33
|
const meshes = [];
|
|
@@ -43,17 +45,17 @@ export function recipeMeshes(wasm, recipes, recipe, options, coordinateSystem) {
|
|
|
43
45
|
}
|
|
44
46
|
const placements = recipe.roots.map((root, index) => {
|
|
45
47
|
var _a;
|
|
46
|
-
return (Object.assign({ mesh: (_a = meshOfNode.get(sources[index].node)) !== null && _a !== void 0 ? _a : NO_MESH, matrix: mirror === undefined ? placedBy(sources[index].matrix,
|
|
48
|
+
return (Object.assign({ mesh: (_a = meshOfNode.get(sources[index].node)) !== null && _a !== void 0 ? _a : NO_MESH, matrix: mirror === undefined ? placedBy(sources[index].matrix, zUp) : placedAmongMirrored(sources[index].matrix, mirror), tag: root.tag }, (root.group === undefined ? {} : { group: root.group })));
|
|
47
49
|
});
|
|
48
50
|
const failed = sources.flatMap((source, index) => solids.get(source.node) === undefined ? [index] : []);
|
|
49
51
|
const surfaces = new Recipes(() => (mirror === undefined || coordinateSystem === undefined ? {} : { coordinateSystem }));
|
|
50
|
-
surfaces.surfaceMeshes({ recipe, roots: failed,
|
|
52
|
+
surfaces.surfaceMeshes({ recipe, roots: failed, upAxis: mirror !== undefined && zUp ? BaseInputs.Base.upAxisConversionEnum.zUpToYUp : BaseInputs.Base.upAxisConversionEnum.keep }).forEach((surface, at) => {
|
|
51
53
|
if (surface === undefined) {
|
|
52
54
|
return;
|
|
53
55
|
}
|
|
54
56
|
const placement = placements[failed[at]];
|
|
55
57
|
placement.mesh = meshes.push(creasedMeshData(surface.positions, surface.indices, options.minSharpAngle)) - 1;
|
|
56
|
-
placement.matrix = mirror === undefined ? placedBy(IDENTITY,
|
|
58
|
+
placement.matrix = mirror === undefined ? placedBy(IDENTITY, zUp) : [...IDENTITY];
|
|
57
59
|
});
|
|
58
60
|
return { meshes, placements };
|
|
59
61
|
}
|
|
@@ -3,7 +3,8 @@ import { Inputs as BaseInputs } from "@bitbybit-dev/base";
|
|
|
3
3
|
import type { Base } from "@bitbybit-dev/base";
|
|
4
4
|
export type RootPlacing = (matrix: Base.TransformMatrix) => Manifold3D.Mat4;
|
|
5
5
|
export declare const asTheRecipeSays: RootPlacing;
|
|
6
|
+
export declare function turnedFromZUp(upAxis: unknown): boolean;
|
|
6
7
|
export declare function turnedZtoY(matrix: Base.TransformMatrix): Manifold3D.Mat4;
|
|
7
|
-
export declare function mirrorIntoModel(coordinateSystem: BaseInputs.Base.coordinateSystemEnum | undefined,
|
|
8
|
-
export declare function rootPlacingOf(coordinateSystem: BaseInputs.Base.coordinateSystemEnum | undefined,
|
|
8
|
+
export declare function mirrorIntoModel(coordinateSystem: BaseInputs.Base.coordinateSystemEnum | undefined, zUp: boolean): Base.TransformMatrix | undefined;
|
|
9
|
+
export declare function rootPlacingOf(coordinateSystem: BaseInputs.Base.coordinateSystemEnum | undefined, zUp: boolean): RootPlacing;
|
|
9
10
|
export declare function placedAmongMirrored(matrix: Base.TransformMatrix, mirror: Base.TransformMatrix): Base.TransformMatrix;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { Inputs as BaseInputs } from "@bitbybit-dev/base";
|
|
1
|
+
import { checkedUpAxis, Inputs as BaseInputs } from "@bitbybit-dev/base";
|
|
2
2
|
import { followedBy } from "@bitbybit-dev/base/lib/api/services/helpers/geometry/matrices";
|
|
3
3
|
import { meshMatrixInModel } from "@bitbybit-dev/base/lib/api/services/helpers/files/mesh-file-axes";
|
|
4
4
|
export const asTheRecipeSays = (matrix) => matrix;
|
|
5
|
+
export function turnedFromZUp(upAxis) {
|
|
6
|
+
const { keep, zUpToYUp } = BaseInputs.Base.upAxisConversionEnum;
|
|
7
|
+
return checkedUpAxis(upAxis, [keep, zUpToYUp]) === zUpToYUp;
|
|
8
|
+
}
|
|
5
9
|
function withoutNegativeZero(matrix) {
|
|
6
10
|
return matrix.map((value) => value + 0);
|
|
7
11
|
}
|
|
@@ -17,15 +21,15 @@ export function turnedZtoY(matrix) {
|
|
|
17
21
|
m, o, negatedWithoutNegativeZero(n), p,
|
|
18
22
|
];
|
|
19
23
|
}
|
|
20
|
-
export function mirrorIntoModel(coordinateSystem,
|
|
21
|
-
return coordinateSystem === BaseInputs.Base.coordinateSystemEnum.leftHanded ? meshMatrixInModel(coordinateSystem,
|
|
24
|
+
export function mirrorIntoModel(coordinateSystem, zUp) {
|
|
25
|
+
return coordinateSystem === BaseInputs.Base.coordinateSystemEnum.leftHanded ? meshMatrixInModel(coordinateSystem, zUp) : undefined;
|
|
22
26
|
}
|
|
23
|
-
export function rootPlacingOf(coordinateSystem,
|
|
24
|
-
const mirror = mirrorIntoModel(coordinateSystem,
|
|
27
|
+
export function rootPlacingOf(coordinateSystem, zUp) {
|
|
28
|
+
const mirror = mirrorIntoModel(coordinateSystem, zUp);
|
|
25
29
|
if (mirror !== undefined) {
|
|
26
30
|
return (matrix) => withoutNegativeZero(followedBy(matrix, mirror));
|
|
27
31
|
}
|
|
28
|
-
return
|
|
32
|
+
return zUp ? turnedZtoY : asTheRecipeSays;
|
|
29
33
|
}
|
|
30
34
|
export function placedAmongMirrored(matrix, mirror) {
|
|
31
35
|
return withoutNegativeZero(followedBy(followedBy(mirror, matrix), mirror));
|
|
@@ -29,7 +29,7 @@ export declare class ManifoldRecipes {
|
|
|
29
29
|
* @example
|
|
30
30
|
* ```typescript
|
|
31
31
|
* const recipe = await bitbybit.ifc.geometry.recipe({ model });
|
|
32
|
-
* const solids = await bitbybit.manifold.recipes.build({ recipe,
|
|
32
|
+
* const solids = await bitbybit.manifold.recipes.build({ recipe, upAxis: Bit.Inputs.Base.upAxisConversionEnum.zUpToYUp, emptyWhenFailed: true });
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
35
|
build(inputs: Inputs.Manifold.BuildRecipeDto): Manifold3D.Manifold[];
|
|
@@ -47,7 +47,7 @@ export declare class ManifoldRecipes {
|
|
|
47
47
|
* @example
|
|
48
48
|
* ```typescript
|
|
49
49
|
* const recipe = await bitbybit.ifc.geometry.recipe({ model });
|
|
50
|
-
* const { meshes, placements } = await bitbybit.manifold.recipes.meshes({ recipe,
|
|
50
|
+
* const { meshes, placements } = await bitbybit.manifold.recipes.meshes({ recipe, upAxis: Bit.Inputs.Base.upAxisConversionEnum.zUpToYUp, emptyWhenFailed: true });
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
53
|
meshes(inputs: Inputs.Manifold.BuildRecipeMeshesDto): Inputs.Manifold.RecipeMeshesDto;
|
|
@@ -64,10 +64,10 @@ export declare class ManifoldRecipes {
|
|
|
64
64
|
* @drawable true
|
|
65
65
|
* @example
|
|
66
66
|
* ```typescript
|
|
67
|
-
* const solids = await bitbybit.manifold.recipes.build({ recipe,
|
|
67
|
+
* const solids = await bitbybit.manifold.recipes.build({ recipe, upAxis: Bit.Inputs.Base.upAxisConversionEnum.zUpToYUp, emptyWhenFailed: true });
|
|
68
68
|
* const meshes = await bitbybit.manifold.manifold.manifoldsToMeshes({ manifolds: solids });
|
|
69
69
|
* const open = meshes.flatMap((mesh, index) => mesh.triVerts.length === 0 ? [index] : []);
|
|
70
|
-
* const surfaces = await bitbybit.manifold.recipes.surfaceMeshes({ recipe, roots: open,
|
|
70
|
+
* const surfaces = await bitbybit.manifold.recipes.surfaceMeshes({ recipe, roots: open, upAxis: Bit.Inputs.Base.upAxisConversionEnum.zUpToYUp });
|
|
71
71
|
* ```
|
|
72
72
|
*/
|
|
73
73
|
surfaceMeshes(inputs: Inputs.Manifold.RecipeSurfaceMeshesDto): Inputs.Manifold.DecomposedManifoldMeshDto[];
|
|
@@ -2,7 +2,7 @@ import { resolveDto } from "@bitbybit-dev/base";
|
|
|
2
2
|
import * as Inputs from "../../inputs/manifold-inputs";
|
|
3
3
|
import { executeRecipe } from "./recipe-executor";
|
|
4
4
|
import { recipeMeshes } from "./recipe-meshes";
|
|
5
|
-
import { rootPlacingOf } from "./recipe-placing";
|
|
5
|
+
import { rootPlacingOf, turnedFromZUp } from "./recipe-placing";
|
|
6
6
|
const MIN_CIRCLE_SIDES = 3;
|
|
7
7
|
const MAX_SHARP_ANGLE = 180;
|
|
8
8
|
const POSITION_PROPERTIES = 3;
|
|
@@ -35,7 +35,7 @@ export class ManifoldRecipes {
|
|
|
35
35
|
* @example
|
|
36
36
|
* ```typescript
|
|
37
37
|
* const recipe = await bitbybit.ifc.geometry.recipe({ model });
|
|
38
|
-
* const solids = await bitbybit.manifold.recipes.build({ recipe,
|
|
38
|
+
* const solids = await bitbybit.manifold.recipes.build({ recipe, upAxis: Bit.Inputs.Base.upAxisConversionEnum.zUpToYUp, emptyWhenFailed: true });
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
41
|
build(inputs) {
|
|
@@ -44,7 +44,7 @@ export class ManifoldRecipes {
|
|
|
44
44
|
if (!Number.isSafeInteger(resolved.circularSegments) || resolved.circularSegments < MIN_CIRCLE_SIDES) {
|
|
45
45
|
throw new RangeError(`A circle needs at least ${MIN_CIRCLE_SIDES} sides, got ${resolved.circularSegments}`);
|
|
46
46
|
}
|
|
47
|
-
return executeRecipe(this.manifold, recipe, resolved.circularSegments, rootPlacingOf(this.settings().coordinateSystem, resolved.
|
|
47
|
+
return executeRecipe(this.manifold, recipe, resolved.circularSegments, rootPlacingOf(this.settings().coordinateSystem, turnedFromZUp(resolved.upAxis)), resolved.emptyWhenFailed);
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Builds a recipe into the meshes its roots draw, each step several roots place meshed once in
|
|
@@ -60,7 +60,7 @@ export class ManifoldRecipes {
|
|
|
60
60
|
* @example
|
|
61
61
|
* ```typescript
|
|
62
62
|
* const recipe = await bitbybit.ifc.geometry.recipe({ model });
|
|
63
|
-
* const { meshes, placements } = await bitbybit.manifold.recipes.meshes({ recipe,
|
|
63
|
+
* const { meshes, placements } = await bitbybit.manifold.recipes.meshes({ recipe, upAxis: Bit.Inputs.Base.upAxisConversionEnum.zUpToYUp, emptyWhenFailed: true });
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
66
|
meshes(inputs) {
|
|
@@ -87,15 +87,15 @@ export class ManifoldRecipes {
|
|
|
87
87
|
* @drawable true
|
|
88
88
|
* @example
|
|
89
89
|
* ```typescript
|
|
90
|
-
* const solids = await bitbybit.manifold.recipes.build({ recipe,
|
|
90
|
+
* const solids = await bitbybit.manifold.recipes.build({ recipe, upAxis: Bit.Inputs.Base.upAxisConversionEnum.zUpToYUp, emptyWhenFailed: true });
|
|
91
91
|
* const meshes = await bitbybit.manifold.manifold.manifoldsToMeshes({ manifolds: solids });
|
|
92
92
|
* const open = meshes.flatMap((mesh, index) => mesh.triVerts.length === 0 ? [index] : []);
|
|
93
|
-
* const surfaces = await bitbybit.manifold.recipes.surfaceMeshes({ recipe, roots: open,
|
|
93
|
+
* const surfaces = await bitbybit.manifold.recipes.surfaceMeshes({ recipe, roots: open, upAxis: Bit.Inputs.Base.upAxisConversionEnum.zUpToYUp });
|
|
94
94
|
* ```
|
|
95
95
|
*/
|
|
96
96
|
surfaceMeshes(inputs) {
|
|
97
97
|
const resolved = resolveDto(Inputs.Manifold.RecipeSurfaceMeshesDto, inputs);
|
|
98
|
-
return this.recipes.surfaceMeshes({ recipe: resolved.recipe, roots: resolved.roots,
|
|
98
|
+
return this.recipes.surfaceMeshes({ recipe: resolved.recipe, roots: resolved.roots, upAxis: resolved.upAxis }).map((mesh) => {
|
|
99
99
|
var _a, _b;
|
|
100
100
|
return ({
|
|
101
101
|
numProp: POSITION_PROPERTIES,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitbybit-dev/manifold",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Bit By Bit Developers Manifold based CAD Library to Program Geometry",
|
|
5
5
|
"homepage": "https://docs.bitbybit.dev/classes/Bit.Manifold",
|
|
6
6
|
"main": "index.js",
|
|
@@ -55,6 +55,6 @@
|
|
|
55
55
|
"type": "module",
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"manifold-3d": "3.5.4",
|
|
58
|
-
"@bitbybit-dev/base": "1.
|
|
58
|
+
"@bitbybit-dev/base": "1.8.0"
|
|
59
59
|
}
|
|
60
60
|
}
|