Skip to content

Commit

Permalink
update angular app to v0.9.16 of bitbybit-core and bitbybit-occt
Browse files Browse the repository at this point in the history
  • Loading branch information
matas-bitbybit-dev committed Jan 31, 2023
1 parent ee77bf8 commit 552a1bd
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 23 deletions.
10 changes: 10 additions & 0 deletions angular/laptop-holder/custom-webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ module.exports = {
test: /\.wasm$/,
type: "javascript/auto",
loader: "file-loader",
},
{
test: /\.m?js/,
type: "javascript/auto",
},
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
}
]
},
Expand Down
24 changes: 18 additions & 6 deletions angular/laptop-holder/package-lock.json

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

33 changes: 18 additions & 15 deletions angular/laptop-holder/src/app/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 { OCCT } from "bitbybit-core/lib/api/bitbybit/occt/occt";
import * as Inputs from "bitbybit-core/lib/api/inputs";
export class LaptopLogic {

private bitbybit: BitByBitBase;
private occt: 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 All @@ -49,45 +52,45 @@ export class LaptopLogic {
totalDistance += this.distanceBetweenLaptops + laptop.length / 2 + previousLaptopLength / 2;
previousLaptopLength = laptop.length;
laptop.center[2] = totalDistance;
const laptopBaseModel = await this.bitbybit.occt.shapes.solid.createBox({
const laptopBaseModel = await this.occt.shapes.solid.createBox({
width: laptop.width,
length: laptop.length,
height: laptop.height,
center: laptop.center
});
const laptopFillet = await this.bitbybit.occt.fillets.filletEdges({ shape: laptopBaseModel, radius: 0.2 });
const laptopFillet = await this.occt.fillets.filletEdges({ shape: laptopBaseModel, radius: 0.2 });
laptopFillets.push(laptopFillet);

const laptopVisModel = await this.bitbybit.occt.shapes.solid.createBox({
const laptopVisModel = await this.occt.shapes.solid.createBox({
width: laptop.width,
length: laptop.length - 0.01,
height: laptop.height,
center: laptop.center
});
const laptopVisFillet = await this.bitbybit.occt.fillets.filletEdges({ shape: laptopVisModel, radius: 0.2 });
const laptopVisFillet = await this.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 @@ -124,11 +127,11 @@ export class LaptopLogic {
}

downloadStep() {
this.bitbybit.occt.io.saveShapeSTEP({ shape: this.laptopStand, filename: 'laptop-stand.step', adjustYtoZ: false });
this.occt.io.saveShapeSTEP({ shape: this.laptopStand, filename: 'laptop-stand.step', adjustYtoZ: false });
}

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 angular/laptop-holder/src/app/occ.worker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference lib="webworker" />
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 552a1bd

Please sign in to comment.