Skip to content

Commit 552a1bd

Browse files
update angular app to v0.9.16 of bitbybit-core and bitbybit-occt
1 parent ee77bf8 commit 552a1bd

File tree

4 files changed

+48
-23
lines changed

4 files changed

+48
-23
lines changed

angular/laptop-holder/custom-webpack.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ module.exports = {
55
test: /\.wasm$/,
66
type: "javascript/auto",
77
loader: "file-loader",
8+
},
9+
{
10+
test: /\.m?js/,
11+
type: "javascript/auto",
12+
},
13+
{
14+
test: /\.m?js/,
15+
resolve: {
16+
fullySpecified: false,
17+
},
818
}
919
]
1020
},

angular/laptop-holder/package-lock.json

+18-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

angular/laptop-holder/src/app/laptop.ts

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { BitByBitBase, Base, BabylonScene, Draw } from "bitbybit-core";
2-
import { OCCT } from "bitbybit-core/lib/api/inputs/occ-inputs";
2+
import { OCCT } from "bitbybit-core/lib/api/bitbybit/occt/occt";
3+
import * as Inputs from "bitbybit-core/lib/api/inputs";
34
export class LaptopLogic {
45

56
private bitbybit: BitByBitBase;
7+
private occt: OCCT
68

79
private laptops: Laptop[] = [
810
{
@@ -34,6 +36,7 @@ export class LaptopLogic {
3436

3537
constructor(bitbybit: BitByBitBase) {
3638
this.bitbybit = bitbybit;
39+
this.occt = bitbybit.occt as OCCT;
3740
}
3841
async renderLaptops(laptops) {
3942

@@ -49,45 +52,45 @@ export class LaptopLogic {
4952
totalDistance += this.distanceBetweenLaptops + laptop.length / 2 + previousLaptopLength / 2;
5053
previousLaptopLength = laptop.length;
5154
laptop.center[2] = totalDistance;
52-
const laptopBaseModel = await this.bitbybit.occt.shapes.solid.createBox({
55+
const laptopBaseModel = await this.occt.shapes.solid.createBox({
5356
width: laptop.width,
5457
length: laptop.length,
5558
height: laptop.height,
5659
center: laptop.center
5760
});
58-
const laptopFillet = await this.bitbybit.occt.fillets.filletEdges({ shape: laptopBaseModel, radius: 0.2 });
61+
const laptopFillet = await this.occt.fillets.filletEdges({ shape: laptopBaseModel, radius: 0.2 });
5962
laptopFillets.push(laptopFillet);
6063

61-
const laptopVisModel = await this.bitbybit.occt.shapes.solid.createBox({
64+
const laptopVisModel = await this.occt.shapes.solid.createBox({
6265
width: laptop.width,
6366
length: laptop.length - 0.01,
6467
height: laptop.height,
6568
center: laptop.center
6669
});
67-
const laptopVisFillet = await this.bitbybit.occt.fillets.filletEdges({ shape: laptopVisModel, radius: 0.2 });
70+
const laptopVisFillet = await this.occt.fillets.filletEdges({ shape: laptopVisModel, radius: 0.2 });
6871
laptopFillets.push(laptopFillet);
6972

70-
const di = new OCCT.DrawShapeDto(laptopVisFillet);
73+
const di = new Inputs.OCCT.DrawShapeDto(laptopVisFillet);
7174
di.faceOpacity = 0.2;
7275
di.edgeWidth = 5;
7376
di.edgeOpacity = 0.6;
7477
di.edgeColour = this.whiteColor;
7578
di.faceColour = this.whiteColor;
76-
const laptopFilletMesh = await this.bitbybit.occt.drawShape(di);
79+
const laptopFilletMesh = await this.occt.drawShape(di);
7780
this.laptopsFilletsMesh.push(laptopFilletMesh);
7881
})
7982

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

89-
this.laptopStand = await this.bitbybit.occt.booleans.difference({ shape: laptopStandThick, shapes: laptopFillets, keepEdges: false });
90-
const li = new OCCT.DrawShapeDto(this.laptopStand);
92+
this.laptopStand = await this.occt.booleans.difference({ shape: laptopStandThick, shapes: laptopFillets, keepEdges: false });
93+
const li = new Inputs.OCCT.DrawShapeDto(this.laptopStand);
9194
li.faceOpacity = 1;
9295
li.faceColour = this.holderColor;
9396
li.edgeColour = this.whiteColor;
@@ -124,11 +127,11 @@ export class LaptopLogic {
124127
}
125128

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

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

134137
async render(laptops: Laptop[]) {

angular/laptop-holder/src/app/occ.worker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference lib="webworker" />
2-
import initOpenCascade from 'bitbybit-core/bitbybit-dev-occt';
3-
import { OpenCascadeInstance } from 'bitbybit-core/bitbybit-dev-occt/bitbybit-dev-occt.js';
2+
import initOpenCascade from 'bitbybit-occt/bitbybit-dev-occt';
3+
import { OpenCascadeInstance } from 'bitbybit-occt/bitbybit-dev-occt/bitbybit-dev-occt.js';
44
import { initializationComplete, onMessageInput } from 'bitbybit-core/lib/workers/occ/occ-worker';
55

66
initOpenCascade().then((occ: OpenCascadeInstance) => {

0 commit comments

Comments
 (0)