Skip to content

Commit

Permalink
update to v0.9.16 bitbybit-core to latest version for laptop react ex…
Browse files Browse the repository at this point in the history
…ample
  • Loading branch information
matas-bitbybit-dev committed Jan 31, 2023
1 parent 20330e0 commit ee77bf8
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 41 deletions.
54 changes: 52 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,52 @@
# app-examples
App examples that use bitbybit-core npm package to build custom CAD websites.
# Bit By Bit Developers App Examples
These app examples are meant to show how bitbybit-core and bitbybit-occt npm packages can be used to create 3D models on the browser and on the server.
bitbybit-core library works only on the browser and is dependant on many great 3D libraries. bitbybit-occt library is much more versatile and can be used both on the nodejs and browser applications.

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

# App Example Frameworks
For browser based applications we provide few examples using bitbybit-core library by using most popular frameworks such as React and Angular. For Node based applications we provide express server app example and a simple node example.

# Github
https://github.com/bitbybit-dev/app-examples

# NPM
CORE
https://www.npmjs.com/package/bitbybit-core
OCCT
https://www.npmjs.com/package/bitbybit-occt

# Example Applications
Laptop Holder
https://app-store.bitbybit.dev/laptop-holder
Github Source Code Angular - https://github.com/bitbybit-dev/app-examples/tree/main/angular/laptop-holder
Github Source Code React - https://github.com/bitbybit-dev/app-examples/tree/main/react/laptop-holder

Cup Configurator
https://app-store.bitbybit.dev/cup
Github Source Code - https://github.com/bitbybit-dev/app-examples/tree/main/react/cup

Other Closed Source Apps We Built
Terrace Furniture
https://app-store.bitbybit.dev/terrace-furniture

# Build package
tsc -p tsconfig.bitbybit.json

# Media Channels
Discord: https://discord.gg/GSe3VMe
Youtube: https://www.youtube.com/channel/UCWM0VODRsLYOjB2IAaFHBSQ
Instagram: https://www.instagram.com/bitbybit.dev
Twitter: https://twitter.com/bitbybit_dev
LinkedIn: https://lnkd.in/gQjEQA2
Facebook: https://www.facebook.com/bitbybitdev
Medium: https://bitbybit-dev.medium.com/

# Principles
Bit By Bit Developers company will keep these core algorithms that you can find in this repository free and opensource for its users. These algorithms are based on other open-source projects, run and are deployed on the browser, thus there is no point of closing them down from public.

# About Bit By Bit Developers platform
Bit By Bit Developers web platform allows creators to program geometry through simple visual programming language or choose monaco typescript editor with full intellisense of bitbybit API. This cloud platform can fulfil many practical, educational and artistic needs of its users. Through familiar programming interface used in tools such as Scratch and Blockly.Games we expose powerful 3D algorithms that make it easier to implement various parametric tasks. Our goal is to make it very simple for users to share their ideas and designs. We want to encourage everyone to engage in the future of this tool.

# Major Dependencies
BabylonJS, Blockly, OpenCascade, JSCAD, Verbnurbs
2 changes: 1 addition & 1 deletion angular/laptop-holder/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion angular/laptop-holder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@angular/platform-browser": "13.3.0",
"@angular/platform-browser-dynamic": "13.3.0",
"@angular/router": "13.3.0",
"bitbybit-core": "0.9.12",
"bitbybit-core": "0.9.16",
"rxjs": "7.5.5",
"tslib": "2.3.1",
"zone.js": "0.11.5"
Expand Down
30 changes: 15 additions & 15 deletions react/cup/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion react/cup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"react-scripts": "5.0.1",
"typescript": "^4.6.2",
"web-vitals": "^2.1.4",
"bitbybit-core": "0.9.15",
"bitbybit-core": "0.9.16",
"file-loader": "6.2.0",
"@mui/icons-material": "5.6.2",
"@mui/material": "5.6.4",
Expand Down
12 changes: 11 additions & 1 deletion react/laptop-holder/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@ module.exports = {
crypto: false,
stream: false
}

//this is needed for the bitbybit-occt modules
config.module.rules.push({
test: /\.m?js/,
type: "javascript/auto",
})
config.module.rules.push({
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
})
return config;
},
};
26 changes: 19 additions & 7 deletions react/laptop-holder/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion react/laptop-holder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"react-scripts": "5.0.1",
"typescript": "^4.6.2",
"web-vitals": "^2.1.4",
"bitbybit-core": "0.9.12",
"bitbybit-core": "0.9.16",
"file-loader": "6.2.0",
"@mui/icons-material": "5.6.2",
"@mui/material": "5.6.4",
Expand Down
23 changes: 13 additions & 10 deletions react/laptop-holder/src/laptop.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { BitByBitBase, Base, BabylonScene, Draw } from "bitbybit-core";
import { OCCT } from "bitbybit-core/lib/api/inputs/occ-inputs";
import * as Inputs from "bitbybit-core/lib/api/inputs";
import { OCCT } from "bitbybit-core/lib/api/bitbybit/occt/occt";
export class LaptopLogic {

private bitbybit: BitByBitBase;
private occt;

private laptops: Laptop[] = [
{
Expand Down Expand Up @@ -34,6 +36,7 @@ export class LaptopLogic {

constructor(bitbybit: BitByBitBase) {
this.bitbybit = bitbybit;
this.occt = bitbybit.occt as OCCT;
}

async renderLaptops(laptops) {
Expand Down Expand Up @@ -68,27 +71,27 @@ export class LaptopLogic {
const laptopVisFillet = await this.bitbybit.occt.fillets.filletEdges({ shape: laptopVisModel, radius: 0.2 });
laptopFillets.push(laptopFillet);

const di = new OCCT.DrawShapeDto(laptopVisFillet);
const di = new Inputs.OCCT.DrawShapeDto(laptopVisFillet);
di.faceOpacity = 0.2;
di.edgeWidth = 5;
di.edgeOpacity = 0.6;
di.edgeColour = this.whiteColor;
di.faceColour = this.whiteColor;
const laptopFilletMesh = await this.bitbybit.occt.drawShape(di);
const laptopFilletMesh = await this.occt.drawShape(di);
this.laptopsFilletsMesh.push(laptopFilletMesh);
})

const polygonWire = await this.bitbybit.occt.shapes.wire.createPolygonWire({
const polygonWire = await this.occt.shapes.wire.createPolygonWire({
points: this.controlPoints
});
const extrusion = await this.bitbybit.occt.operations.extrude({
const extrusion = await this.occt.operations.extrude({
shape: polygonWire, direction: [0, 0, totalDistance += this.distanceBetweenLaptops + previousLaptopLength / 2]
});
const laptopStandFillet = await this.bitbybit.occt.fillets.filletEdges({ shape: extrusion, radius: 1 });
const laptopStandThick = await this.bitbybit.occt.operations.makeThickSolidSimple({ shape: laptopStandFillet, offset: -0.5 });
const laptopStandFillet = await this.occt.fillets.filletEdges({ shape: extrusion, radius: 1 });
const laptopStandThick = await this.occt.operations.makeThickSolidSimple({ shape: laptopStandFillet, offset: -0.5 });

this.laptopStand = await this.bitbybit.occt.booleans.difference({ shape: laptopStandThick, shapes: laptopFillets, keepEdges: false });
const li = new OCCT.DrawShapeDto(this.laptopStand);
this.laptopStand = await this.occt.booleans.difference({ shape: laptopStandThick, shapes: laptopFillets, keepEdges: false });
const li = new Inputs.OCCT.DrawShapeDto(this.laptopStand);
li.faceOpacity = 1;
li.faceColour = this.holderColor;
li.edgeColour = this.whiteColor;
Expand Down Expand Up @@ -129,7 +132,7 @@ export class LaptopLogic {
}

downloadStl() {
this.bitbybit.occt.io.saveShapeStl({ shape: this.laptopStand, filename: 'laptop-stand', precision: 0.001, adjustYtoZ: false });
this.occt.io.saveShapeStl({ shape: this.laptopStand, filename: 'laptop-stand', precision: 0.001, adjustYtoZ: false });
}

async render(laptops: Laptop[]) {
Expand Down
4 changes: 2 additions & 2 deletions react/laptop-holder/src/occ.worker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference lib="webworker" />
/*eslint no-restricted-globals: 0*/
import initOpenCascade from 'bitbybit-core/bitbybit-dev-occt';
import { OpenCascadeInstance } from 'bitbybit-core/bitbybit-dev-occt/bitbybit-dev-occt.js';
import initOpenCascade from 'bitbybit-occt/bitbybit-dev-occt';
import { OpenCascadeInstance } from 'bitbybit-occt/bitbybit-dev-occt/bitbybit-dev-occt.js';
import { initializationComplete, onMessageInput } from 'bitbybit-core/lib/workers/occ/occ-worker';

initOpenCascade().then((occ: OpenCascadeInstance) => {
Expand Down

0 comments on commit ee77bf8

Please sign in to comment.