Skip to content

Commit 0d52c3c

Browse files
Merge pull request #53 from bitbybit-dev/develop
Improved splitting to exclude empty manifolds, included package.json with test commands, improved readme
2 parents 7245d05 + d3ff159 commit 0d52c3c

10 files changed

Lines changed: 175 additions & 46 deletions

File tree

package.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "bitbybit",
3+
"version": "0.19.0",
4+
"description": "Monorepo for browser CAD which holds bitbybit.dev npm packages",
5+
"main": "index.js",
6+
"scripts": {
7+
"test-base": "cd packages/dev/base && npm run test-c",
8+
"test-occt": "cd packages/dev/occt && npm run test-c",
9+
"test-core": "cd packages/dev/core && npm run test-c",
10+
"test-jscad": "cd packages/dev/jscad && npm run test-c",
11+
"test-manifold": "cd packages/dev/manifold && npm run test-c",
12+
"test": "npm run test-occt && npm run test-base && npm run test-core && npm run test-jscad && npm run test-manifold"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/bitbybit-dev/bitbybit.git"
17+
},
18+
"keywords": [
19+
"CAD",
20+
"3D",
21+
"Geometry",
22+
"OCCT",
23+
"JSCAD",
24+
"Manifold",
25+
"ThreeJS",
26+
"BabylonJS",
27+
"Automotive",
28+
"AEC"
29+
],
30+
"author": "Bit By Bit Developers",
31+
"license": "MIT",
32+
"bugs": {
33+
"url": "https://github.com/bitbybit-dev/bitbybit/issues"
34+
},
35+
"homepage": "https://bitbybit.dev",
36+
"devDependencies": {
37+
"typescript": "^4.3.5"
38+
}
39+
}

packages/dev/base/README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22

33
<img src="https://app.bitbybit.dev/assets/git-cover.png" alt="Picture showing bitbybit.dev platform">
44

5-
This genericc package contains base algorithms for our CAD platform. It has various helper functions for math, text, lists, vectors, matrix operations. It also contains some base types used accross bitbybit.dev platform on higher levels. This layer should be kept as lightweight as possible and ideally not contain any third-party dependencies as they just add to the weight and complexity.
5+
This package contains base algorithms for our CAD platform. It has various helper functions for math, text, lists, vectors, matrix operations. It also contains some base types used accross bitbybit.dev platform on higher levels. This layer should be kept as lightweight as possible and ideally not contain any third-party dependencies as they just add to the weight and complexity.
66

77
This package is already used or will be used in these packages:
88

9-
@bitbybit-dev/occt
10-
@bitbybit-dev/occt-worker
11-
@bitbybit-dev/jscad
12-
@bitbybit-dev/jscad-worker
13-
@bitbybit-dev/manifold
14-
@bitbybit-dev/manifold-worker
15-
@bitbybit-dev/core
16-
@bitbybit-dev/babylonjs
17-
@bitbybit-dev/threejs
9+
10+
[@bitbybit-dev/babylonjs](https://www.npmjs.com/package/@bitbybit-dev/babylonjs)
11+
[@bitbybit-dev/threejs](https://www.npmjs.com/package/@bitbybit-dev/threejs)
12+
[@bitbybit-dev/core](https://www.npmjs.com/package/@bitbybit-dev/core)
13+
[@bitbybit-dev/jscad](https://www.npmjs.com/package/@bitbybit-dev/jscad)
14+
[@bitbybit-dev/jscad-worker](https://www.npmjs.com/package/@bitbybit-dev/jscad-worker)
15+
[@bitbybit-dev/manifold](https://www.npmjs.com/package/@bitbybit-dev/manifold)
16+
[@bitbybit-dev/manifold-worker](https://www.npmjs.com/package/@bitbybit-dev/manifold-worker)
17+
[@bitbybit-dev/occt](https://www.npmjs.com/package/@bitbybit-dev/occt)
18+
[@bitbybit-dev/occt-worker](https://www.npmjs.com/package/@bitbybit-dev/occt-worker)
19+
[@bitbybit-dev/base](https://www.npmjs.com/package/@bitbybit-dev/base)
1820

1921
This package should work in Node and browser based applications and should provide generic layer which could be helpful to all higher-level CAD algorithms and kernels. Algorithms of this base layer are also exposed on our bitbybit.dev Rete, Blockly & Monaco editors.
2022

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Jscad } from "./jscad-service";
2+
3+
describe("Jscad unit tests", () => {
4+
let jscad: Jscad;
5+
beforeAll(async () => {
6+
const s = await import("../../jscad-generated");
7+
jscad = new Jscad(s.default());
8+
});
9+
10+
it("should create jscad instance", () => {
11+
expect(jscad).toBeDefined();
12+
});
13+
14+
it("should create booleans service", () => {
15+
expect(jscad.booleans).toBeDefined();
16+
});
17+
});

packages/dev/manifold-worker/README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,35 @@
22

33
<img src="https://app.bitbybit.dev/assets/git-cover.png" alt="Picture showing bitbybit.dev platform">
44

5-
This project exposes 3D algorithms based on manifold-3d 3D CAD kernel via webworker. Manifold project is developed by Emmett Lalish, you can find it on https://github.com/elalish/manifold. Bit By Bit Developers platform integrates this kernel into it's platform via this library. Currently we try to expose Manifold library 1:1 in terms of functionality through our structured API, but as time goes we will have more unique algorithms in this package, which will be tuned specifically to our users.
5+
This project exposes 3D algorithms based on manifold-3d 3D CAD kernel via webworker. Manifold project is developed by Emmett Lalish and Chun Kit LAM, you can find it on https://github.com/elalish/manifold. Bit By Bit Developers platform integrates this kernel into it's platform via this library. Currently we try to expose Manifold library 1:1 in terms of functionality through our structured API, but as time goes we will have more unique algorithms in this package, which will be tuned specifically to our users.
66

77
This package should be used in browser based applications. If you want to use our manifold library in Node apps, consider checking @bitbybit-dev/manifold npm package, which this library wraps through webworker.
88

99
Visit https://bitbybit.dev to use our full cloud platform.
1010

1111
## Github
12-
https://github.com/bitbybit-dev/bitbybit/tree/master/packages/dev/manifold
12+
https://github.com/bitbybit-dev/bitbybit/tree/master/packages/dev/manifold-worker
1313
## NPM
14-
https://www.npmjs.com/package/@bitbybit-dev/manifold
14+
https://www.npmjs.com/package/@bitbybit-dev/manifold-worker
1515

16-
## THREEJS Example Applications
17-
Vase
18-
https://app-store.bitbybit.dev/vase
19-
Github Source Code - https://github.com/bitbybit-dev/app-examples/tree/main/react/threejs/vase
16+
## THREEJS Example Applications Using Manifold
17+
[Manifold Sliced Mesh](https://app-store.bitbybit.dev/manifold-sliced-mesh/)
18+
[Github Source Code](https://github.com/bitbybit-dev/app-examples/blob/main/webpack/threejs/src/code/manifold-sliced-mesh.ts)
19+
20+
## Other THREEJS Applications
21+
[Vase](https://app-store.bitbybit.dev/vase)
22+
[Github source code](https://github.com/bitbybit-dev/app-examples/tree/main/react/threejs/vase)
2023

2124
## Other Example Applications
22-
Laptop Holder
23-
https://app-store.bitbybit.dev/laptop-holder
24-
Github Source Code Angular - https://github.com/bitbybit-dev/app-examples/tree/main/angular/laptop-holder
25-
Github Source Code React - https://github.com/bitbybit-dev/app-examples/tree/main/react/laptop-holder
25+
[Laptop Holder](https://app-store.bitbybit.dev/laptop-holder)
26+
[Github Source Code Angular](https://github.com/bitbybit-dev/app-examples/tree/main/angular/laptop-holder)
27+
[Github Source Code React](https://github.com/bitbybit-dev/app-examples/tree/main/react/laptop-holder)
2628

27-
Cup Configurator
28-
https://app-store.bitbybit.dev/cup
29-
Github Source Code - https://github.com/bitbybit-dev/app-examples/tree/main/react/cup
29+
[Cup Configurator](https://app-store.bitbybit.dev/cup)
30+
[Github Source Code](https://github.com/bitbybit-dev/app-examples/tree/main/react/cup)
3031

3132
## Closed Source Example Applications
32-
https://app-store.bitbybit.dev/terrace-furniture
33+
[Terrace Furniture](https://app-store.bitbybit.dev/terrace-furniture)
3334

3435
## Build package
3536
npm run build-p

packages/dev/manifold/README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<img src="https://app.bitbybit.dev/assets/git-cover.png" alt="Picture showing bitbybit.dev platform">
44

5-
This project exposes 3D algorithms based on manifold-3d 3D CAD kernel, developed by Emmett Lalish, which you can find on https://github.com/elalish/manifold. Bit By Bit Developers platform integrates this kernel into it's platform via this library. Currently we try to expose Manifold library 1:1 in terms of functionality through our structured API, but as time goes we will have more unique algorithms in this package, which will be tuned specifically to our users.
5+
This project exposes 3D algorithms based on manifold-3d 3D CAD kernel, developed by Emmett Lalish and Chun Kit LAM, which you can find on https://github.com/elalish/manifold. Bit By Bit Developers platform integrates this kernel into it's platform via this library. Currently we try to expose Manifold library 1:1 in terms of functionality through our structured API, but as time goes we will have more unique algorithms in this package, which will be tuned specifically to our users.
66

77
This package should work in Node and browser based applications. If you want to use this package in your browser based applications we highly suggest to use @bitbybit-dev/manifold-webworker npm package, which wraps this lib into promisified non-blocking API.
88

@@ -13,23 +13,24 @@ https://github.com/bitbybit-dev/bitbybit/tree/master/packages/dev/manifold
1313
## NPM
1414
https://www.npmjs.com/package/@bitbybit-dev/manifold
1515

16-
## THREEJS Example Applications
17-
Vase
18-
https://app-store.bitbybit.dev/vase
19-
Github Source Code - https://github.com/bitbybit-dev/app-examples/tree/main/react/threejs/vase
16+
## THREEJS Example Applications Using Manifold
17+
[Manifold Sliced Mesh](https://app-store.bitbybit.dev/manifold-sliced-mesh/)
18+
[Github Source Code](https://github.com/bitbybit-dev/app-examples/blob/main/webpack/threejs/src/code/manifold-sliced-mesh.ts)
19+
20+
## Other THREEJS Applications
21+
[Vase](https://app-store.bitbybit.dev/vase)
22+
[Github source code](https://github.com/bitbybit-dev/app-examples/tree/main/react/threejs/vase)
2023

2124
## Other Example Applications
22-
Laptop Holder
23-
https://app-store.bitbybit.dev/laptop-holder
24-
Github Source Code Angular - https://github.com/bitbybit-dev/app-examples/tree/main/angular/laptop-holder
25-
Github Source Code React - https://github.com/bitbybit-dev/app-examples/tree/main/react/laptop-holder
25+
[Laptop Holder](https://app-store.bitbybit.dev/laptop-holder)
26+
[Github Source Code Angular](https://github.com/bitbybit-dev/app-examples/tree/main/angular/laptop-holder)
27+
[Github Source Code React](https://github.com/bitbybit-dev/app-examples/tree/main/react/laptop-holder)
2628

27-
Cup Configurator
28-
https://app-store.bitbybit.dev/cup
29-
Github Source Code - https://github.com/bitbybit-dev/app-examples/tree/main/react/cup
29+
[Cup Configurator](https://app-store.bitbybit.dev/cup)
30+
[Github Source Code](https://github.com/bitbybit-dev/app-examples/tree/main/react/cup)
3031

3132
## Closed Source Example Applications
32-
https://app-store.bitbybit.dev/terrace-furniture
33+
[Terrace Furniture](https://app-store.bitbybit.dev/terrace-furniture)
3334

3435
## Build package
3536
npm run build-p
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
module.exports = {
22
presets: [
33
[
4-
'@babel/preset-env',
4+
"@babel/preset-env",
55
{
66
targets: {
7-
node: 'current',
7+
node: "current",
88
},
99
},
1010
],
11-
'@babel/preset-typescript'
11+
"@babel/preset-typescript"
12+
],
13+
plugins: [
14+
"babel-plugin-transform-import-meta"
1215
],
1316
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// import Module from "manifold-3d";
2+
import { ManifoldService } from "./manifold-service";
3+
4+
// TODO - if possible, configure to run manifold against actual Module (could be useful to find degradations in expectations), otherwise let's just use mocks
5+
describe("Manifold unit tests", () => {
6+
let manifold: ManifoldService;
7+
beforeAll(async () => {
8+
// const wasm = await Module();
9+
// wasm.setup();
10+
manifold = new ManifoldService({} as any);
11+
});
12+
13+
it("should create manifold instance", () => {
14+
expect(manifold).toBeDefined();
15+
});
16+
17+
});

packages/dev/manifold/lib/api/services/manifold/manifold-booleans.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,27 @@ export class ManifoldBooleans {
2222

2323
const clone = inputs.manifold.asOriginal();
2424
const remainders = [clone];
25+
const junk = [];
2526

26-
// original should not be deleted
2727
inputs.originOffsets.forEach((s, i) => {
28-
const halfs = remainders[i].splitByPlane(inputs.normal, s);
29-
pieces.push(halfs[1]);
30-
remainders.push(halfs[0]);
28+
if (remainders[i]) {
29+
const halfs = remainders[i].splitByPlane(inputs.normal, s);
30+
if (!halfs[1].isEmpty() && !halfs[0].isEmpty()) {
31+
pieces.push(halfs[1]);
32+
remainders.push(halfs[0]);
33+
} else if (halfs[1].isEmpty() && !halfs[0].isEmpty()) {
34+
remainders.push(halfs[0]);
35+
junk.push(halfs[1]);
36+
} else if (!halfs[1].isEmpty() && halfs[0].isEmpty()) {
37+
pieces.push(halfs[1]);
38+
junk.push(halfs[0]);
39+
} else if (halfs[0].isEmpty() && halfs[1].isEmpty()) {
40+
junk.push(...halfs);
41+
}
42+
}
3143
});
32-
// release remainders
3344
remainders.forEach(r => r.delete());
45+
junk.forEach(j => j.delete());
3446
return pieces;
3547
}
3648

packages/dev/manifold/package-lock.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dev/manifold/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"@babel/core": "7.16.0",
7575
"@babel/preset-env": "7.16.0",
7676
"@babel/preset-typescript": "7.16.0",
77+
"babel-plugin-transform-import-meta": "2.2.1",
7778
"jest-html-reporters": "3.0.11"
7879
},
7980
"jest": {

0 commit comments

Comments
 (0)