@bitbybit-dev/manifold 0.19.0-alpha.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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +63 -0
  3. package/babel.config.cjs +14 -0
  4. package/babel.config.d.cts +5 -0
  5. package/index.d.ts +1 -0
  6. package/index.js +4 -0
  7. package/lib/api/inputs/base-inputs.d.ts +38 -0
  8. package/lib/api/inputs/base-inputs.js +1 -0
  9. package/lib/api/inputs/index.d.ts +2 -0
  10. package/lib/api/inputs/index.js +2 -0
  11. package/lib/api/inputs/inputs.d.ts +2 -0
  12. package/lib/api/inputs/inputs.js +2 -0
  13. package/lib/api/inputs/manifold-inputs.d.ts +1131 -0
  14. package/lib/api/inputs/manifold-inputs.js +1270 -0
  15. package/lib/api/manifold-service.d.ts +14 -0
  16. package/lib/api/manifold-service.js +28 -0
  17. package/lib/api/services/cross-section/cross-section-booleans.d.ts +15 -0
  18. package/lib/api/services/cross-section/cross-section-booleans.js +44 -0
  19. package/lib/api/services/cross-section/cross-section-evaluate.d.ts +11 -0
  20. package/lib/api/services/cross-section/cross-section-evaluate.js +21 -0
  21. package/lib/api/services/cross-section/cross-section-operations.d.ts +13 -0
  22. package/lib/api/services/cross-section/cross-section-operations.js +34 -0
  23. package/lib/api/services/cross-section/cross-section-shapes.d.ts +10 -0
  24. package/lib/api/services/cross-section/cross-section-shapes.js +24 -0
  25. package/lib/api/services/cross-section/cross-section-transforms.d.ts +13 -0
  26. package/lib/api/services/cross-section/cross-section-transforms.js +26 -0
  27. package/lib/api/services/cross-section/cross-section.d.ts +20 -0
  28. package/lib/api/services/cross-section/cross-section.js +35 -0
  29. package/lib/api/services/index.d.ts +0 -0
  30. package/lib/api/services/index.js +0 -0
  31. package/lib/api/services/manifold/manifold-booleans.d.ts +18 -0
  32. package/lib/api/services/manifold/manifold-booleans.js +53 -0
  33. package/lib/api/services/manifold/manifold-evaluate.d.ts +19 -0
  34. package/lib/api/services/manifold/manifold-evaluate.js +45 -0
  35. package/lib/api/services/manifold/manifold-operations.d.ts +22 -0
  36. package/lib/api/services/manifold/manifold-operations.js +59 -0
  37. package/lib/api/services/manifold/manifold-shapes.d.ts +11 -0
  38. package/lib/api/services/manifold/manifold-shapes.js +29 -0
  39. package/lib/api/services/manifold/manifold-transforms.d.ts +16 -0
  40. package/lib/api/services/manifold/manifold-transforms.js +48 -0
  41. package/lib/api/services/manifold/manifold.d.ts +18 -0
  42. package/lib/api/services/manifold/manifold.js +27 -0
  43. package/lib/api/services/mesh/mesh-evaluate.d.ts +15 -0
  44. package/lib/api/services/mesh/mesh-evaluate.js +37 -0
  45. package/lib/api/services/mesh/mesh-operations.d.ts +7 -0
  46. package/lib/api/services/mesh/mesh-operations.js +8 -0
  47. package/lib/api/services/mesh/mesh.d.ts +9 -0
  48. package/lib/api/services/mesh/mesh.js +9 -0
  49. package/lib/index.d.ts +2 -0
  50. package/lib/index.js +2 -0
  51. package/package.json +94 -0
@@ -0,0 +1,48 @@
1
+ export class ManifoldTransforms {
2
+ constructor(wasm) {
3
+ this.manifold = wasm;
4
+ }
5
+ scale3D(inputs) {
6
+ return inputs.manifold.scale(inputs.vector);
7
+ }
8
+ scale(inputs) {
9
+ return inputs.manifold.scale(inputs.vector);
10
+ }
11
+ mirror(inputs) {
12
+ return inputs.manifold.mirror(inputs.normal);
13
+ }
14
+ translate(inputs) {
15
+ return inputs.manifold.translate(inputs.vector);
16
+ }
17
+ translateByVectors(inputs) {
18
+ return inputs.vectors.map(vector => {
19
+ return inputs.manifold.translate(vector);
20
+ });
21
+ }
22
+ rotate(inputs) {
23
+ return inputs.manifold.rotate(inputs.vector);
24
+ }
25
+ rotateXYZ(inputs) {
26
+ return inputs.manifold.rotate(inputs.x, inputs.y, inputs.z);
27
+ }
28
+ translateXYZ(inputs) {
29
+ return inputs.manifold.translate(inputs.x, inputs.y, inputs.z);
30
+ }
31
+ transform(inputs) {
32
+ return inputs.manifold.transform(inputs.transform);
33
+ }
34
+ transforms(inputs) {
35
+ let currentShape = inputs.manifold;
36
+ //potentially leaks in betweens...
37
+ const transformedShapes = [];
38
+ inputs.transforms.forEach(transform => {
39
+ currentShape = currentShape.transform(transform);
40
+ transformedShapes.push(currentShape);
41
+ });
42
+ const res = transformedShapes.pop();
43
+ transformedShapes.forEach(shape => {
44
+ shape.delete();
45
+ });
46
+ return res;
47
+ }
48
+ }
@@ -0,0 +1,18 @@
1
+ import * as Manifold3D from "manifold-3d";
2
+ import { ManifoldShapes } from "./manifold-shapes";
3
+ import { ManifoldBooleans } from "./manifold-booleans";
4
+ import { ManifoldOperations } from "./manifold-operations";
5
+ import { ManifoldTransforms } from "./manifold-transforms";
6
+ import { ManifoldEvaluate } from "./manifold-evaluate";
7
+ import * as Inputs from "../../inputs";
8
+ export declare class Manifold {
9
+ plugins: any;
10
+ shapes: ManifoldShapes;
11
+ booleans: ManifoldBooleans;
12
+ operations: ManifoldOperations;
13
+ transforms: ManifoldTransforms;
14
+ evaluate: ManifoldEvaluate;
15
+ constructor(wasm: Manifold3D.ManifoldToplevel);
16
+ manifoldToMesh(inputs: Inputs.Manifold.ManifoldToMeshDto<Manifold3D.Manifold>): Manifold3D.Mesh;
17
+ manifoldsToMeshes(inputs: Inputs.Manifold.ManifoldsToMeshesDto<Manifold3D.Manifold>): (Manifold3D.Mesh)[];
18
+ }
@@ -0,0 +1,27 @@
1
+ import { ManifoldShapes } from "./manifold-shapes";
2
+ import { ManifoldBooleans } from "./manifold-booleans";
3
+ import { ManifoldOperations } from "./manifold-operations";
4
+ import { ManifoldTransforms } from "./manifold-transforms";
5
+ import { ManifoldEvaluate } from "./manifold-evaluate";
6
+ // Worker make an instance of this class itself
7
+ export class Manifold {
8
+ constructor(wasm) {
9
+ this.shapes = new ManifoldShapes(wasm);
10
+ this.booleans = new ManifoldBooleans(wasm);
11
+ this.operations = new ManifoldOperations(wasm);
12
+ this.transforms = new ManifoldTransforms(wasm);
13
+ this.evaluate = new ManifoldEvaluate(wasm);
14
+ }
15
+ manifoldToMesh(inputs) {
16
+ return inputs.manifold.getMesh(inputs.normalIdx);
17
+ }
18
+ manifoldsToMeshes(inputs) {
19
+ return inputs.manifolds.map((manifold, index) => {
20
+ const normalIdx = inputs.normalIdx ? inputs.normalIdx[index] : undefined;
21
+ return this.manifoldToMesh({
22
+ manifold,
23
+ normalIdx
24
+ });
25
+ });
26
+ }
27
+ }
@@ -0,0 +1,15 @@
1
+ import * as Inputs from "../../inputs";
2
+ import * as Manifold3D from "manifold-3d";
3
+ export declare class MeshEvaluate {
4
+ private manifold;
5
+ constructor(wasm: Manifold3D.ManifoldToplevel);
6
+ position(inputs: Inputs.Manifold.MeshVertexIndexDto<Manifold3D.Mesh>): Inputs.Base.Point3;
7
+ tangent(inputs: Inputs.Manifold.MeshHalfEdgeIndexDto<Manifold3D.Mesh>): number[];
8
+ verts(inputs: Inputs.Manifold.MeshTriangleIndexDto<Manifold3D.Mesh>): number[];
9
+ extras(inputs: Inputs.Manifold.MeshVertexIndexDto<Manifold3D.Mesh>): number[];
10
+ transform(inputs: Inputs.Manifold.MeshTriangleRunIndexDto<Manifold3D.Mesh>): number[];
11
+ numProp(inputs: Inputs.Manifold.MeshDto<Manifold3D.Mesh>): number;
12
+ numVert(inputs: Inputs.Manifold.MeshDto<Manifold3D.Mesh>): number;
13
+ numTri(inputs: Inputs.Manifold.MeshDto<Manifold3D.Mesh>): number;
14
+ numRun(inputs: Inputs.Manifold.MeshDto<Manifold3D.Mesh>): number;
15
+ }
@@ -0,0 +1,37 @@
1
+ export class MeshEvaluate {
2
+ constructor(wasm) {
3
+ this.manifold = wasm;
4
+ }
5
+ position(inputs) {
6
+ const res = inputs.mesh.position(inputs.vertexIndex);
7
+ return [res[0], res[1], res[2]];
8
+ }
9
+ tangent(inputs) {
10
+ const res = inputs.mesh.tangent(inputs.halfEdgeIndex);
11
+ return [res[0], res[1], res[2], res[4]];
12
+ }
13
+ verts(inputs) {
14
+ const res = inputs.mesh.verts(inputs.triangleIndex);
15
+ return [res[0], res[1], res[2]];
16
+ }
17
+ extras(inputs) {
18
+ const res = inputs.mesh.extras(inputs.vertexIndex);
19
+ return [...res];
20
+ }
21
+ transform(inputs) {
22
+ const res = inputs.mesh.transform(inputs.triangleRunIndex);
23
+ return [...res];
24
+ }
25
+ numProp(inputs) {
26
+ return inputs.mesh.numProp;
27
+ }
28
+ numVert(inputs) {
29
+ return inputs.mesh.numVert;
30
+ }
31
+ numTri(inputs) {
32
+ return inputs.mesh.numTri;
33
+ }
34
+ numRun(inputs) {
35
+ return inputs.mesh.numRun;
36
+ }
37
+ }
@@ -0,0 +1,7 @@
1
+ import * as Inputs from "../../inputs";
2
+ import * as Manifold3D from "manifold-3d";
3
+ export declare class MeshOperations {
4
+ private manifold;
5
+ constructor(wasm: Manifold3D.ManifoldToplevel);
6
+ merge(inputs: Inputs.Manifold.MeshDto<Manifold3D.Mesh>): boolean;
7
+ }
@@ -0,0 +1,8 @@
1
+ export class MeshOperations {
2
+ constructor(wasm) {
3
+ this.manifold = wasm;
4
+ }
5
+ merge(inputs) {
6
+ return inputs.mesh.merge();
7
+ }
8
+ }
@@ -0,0 +1,9 @@
1
+ import * as Manifold3D from "manifold-3d";
2
+ import { MeshEvaluate } from "./mesh-evaluate";
3
+ import { MeshOperations } from "./mesh-operations";
4
+ export declare class Mesh {
5
+ plugins: any;
6
+ operations: MeshOperations;
7
+ evaluate: MeshEvaluate;
8
+ constructor(wasm: Manifold3D.ManifoldToplevel);
9
+ }
@@ -0,0 +1,9 @@
1
+ import { MeshEvaluate } from "./mesh-evaluate";
2
+ import { MeshOperations } from "./mesh-operations";
3
+ // Worker make an instance of this class itself
4
+ export class Mesh {
5
+ constructor(wasm) {
6
+ this.operations = new MeshOperations(wasm);
7
+ this.evaluate = new MeshEvaluate(wasm);
8
+ }
9
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./api/inputs";
2
+ export * from "./api/manifold-service";
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./api/inputs";
2
+ export * from "./api/manifold-service";
package/package.json ADDED
@@ -0,0 +1,94 @@
1
+ {
2
+ "name": "@bitbybit-dev/manifold",
3
+ "version": "0.19.0-alpha.0",
4
+ "description": "Bit By Bit Developers Manifold based CAD Library to Program Geometry",
5
+ "main": "index.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/bitbybit-dev/bitbybit"
9
+ },
10
+ "keywords": [
11
+ "Bit By Bit Developers",
12
+ "bitbybit",
13
+ "bitbybit.dev",
14
+ "Geometry",
15
+ "CAD",
16
+ "3D",
17
+ "JSCAD",
18
+ "OCCT",
19
+ "OpenCascade",
20
+ "Creative coding",
21
+ "CSG",
22
+ "Mesh",
23
+ "Meshing",
24
+ "Manifold",
25
+ "Manifold-3D",
26
+ "WebGL",
27
+ "WebGPU",
28
+ "Parametric",
29
+ "Modeling",
30
+ "Browser CAD",
31
+ "3D algorithms",
32
+ "3D modeling",
33
+ "3D printing",
34
+ "3D printing algorithms",
35
+ "3D software",
36
+ "OpenCascade Technology",
37
+ "AEC",
38
+ "Automotive",
39
+ "Engineering",
40
+ "CAE",
41
+ "CAM"
42
+ ],
43
+ "directories": {
44
+ "lib": "lib"
45
+ },
46
+ "scripts": {
47
+ "build": "tsc -p tsconfig.bitbybit.json",
48
+ "build-p": "npm run build && npm run copy-package && npm run copy-readme && npm run delete-coverage",
49
+ "copy-package": "cp -R ./package.json ./dist",
50
+ "copy-readme": "cp -R ./README.md ./dist && cp -R ./LICENSE ./dist",
51
+ "delete-coverage": "rm -R ./dist/coverage",
52
+ "test": "set NODE_OPTIONS=--experimental-specifier-resolution=node && jest --watchAll=true",
53
+ "test-c": "set NODE_OPTIONS=--experimental-specifier-resolution=node && jest --coverage --watchAll=false",
54
+ "test-c-l": "set NODE_OPTIONS=--experimental-specifier-resolution=node && jest --coverage --watchAll=true"
55
+ },
56
+ "author": "Bit by bit developers",
57
+ "license": "MIT",
58
+ "types": "./index.d.ts",
59
+ "type": "module",
60
+ "dependencies": {
61
+ "manifold-3d": "3.0.0"
62
+ },
63
+ "devDependencies": {
64
+ "sass": "1.57.1",
65
+ "@testing-library/jest-dom": "5.14.1",
66
+ "mvdir": "1.0.21",
67
+ "jest": "29.4.1",
68
+ "ts-node": "10.9.1",
69
+ "ts-jest": "29.0.0",
70
+ "typescript": "4.8.2",
71
+ "@types/jest": "29.0.0",
72
+ "@types/three": "0.169.0",
73
+ "babel-jest": "29.0.0",
74
+ "@babel/core": "7.16.0",
75
+ "@babel/preset-env": "7.16.0",
76
+ "@babel/preset-typescript": "7.16.0",
77
+ "jest-html-reporters": "3.0.11"
78
+ },
79
+ "jest": {
80
+ "preset": "ts-jest",
81
+ "transform": {
82
+ "\\.[jt]sx?$": "babel-jest"
83
+ },
84
+ "extensionsToTreatAsEsm": [
85
+ ".ts"
86
+ ],
87
+ "transformIgnorePatterns": [
88
+ "node_modules/(?!@bitbybit-dev)/"
89
+ ],
90
+ "collectCoverageFrom": [
91
+ "lib/api/**/*"
92
+ ]
93
+ }
94
+ }