From 552a1bd0d890f2319d7ed2516b24b86a2c70f7e0 Mon Sep 17 00:00:00 2001 From: Matas Ubarevicius Date: Tue, 31 Jan 2023 10:31:31 +0200 Subject: [PATCH] update angular app to v0.9.16 of bitbybit-core and bitbybit-occt --- .../laptop-holder/custom-webpack.config.js | 10 ++++++ angular/laptop-holder/package-lock.json | 24 ++++++++++---- angular/laptop-holder/src/app/laptop.ts | 33 ++++++++++--------- angular/laptop-holder/src/app/occ.worker.ts | 4 +-- 4 files changed, 48 insertions(+), 23 deletions(-) diff --git a/angular/laptop-holder/custom-webpack.config.js b/angular/laptop-holder/custom-webpack.config.js index b8dd3ff..f769641 100644 --- a/angular/laptop-holder/custom-webpack.config.js +++ b/angular/laptop-holder/custom-webpack.config.js @@ -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, + }, } ] }, diff --git a/angular/laptop-holder/package-lock.json b/angular/laptop-holder/package-lock.json index 867e651..35e8a2a 100644 --- a/angular/laptop-holder/package-lock.json +++ b/angular/laptop-holder/package-lock.json @@ -3604,9 +3604,9 @@ } }, "node_modules/bitbybit-core": { - "version": "0.9.12", - "resolved": "https://registry.npmjs.org/bitbybit-core/-/bitbybit-core-0.9.12.tgz", - "integrity": "sha512-ke60Ra8dH47L4MD+vlt4fBkL2gVjTnRgTcFA9dlZMUaNUFSOoDVEcRkB6KCoHuLfjoXQ7uES4m+/BqAzkAzrlQ==", + "version": "0.9.16", + "resolved": "https://registry.npmjs.org/bitbybit-core/-/bitbybit-core-0.9.16.tgz", + "integrity": "sha512-MMdjXAnhBQNjIdvjqgrp5N2//WR0+pz1dwV51NmT32PNsSqB/lwW9siyew1KH/Gl+kOHVNf5LxQjcPyc3GyTyg==", "dependencies": { "@babylonjs/core": "5.42.2", "@babylonjs/gui": "5.42.2", @@ -3616,10 +3616,16 @@ "@jscad/io-utils": "2.0.13", "@jscad/modeling": "2.7.2", "@jscad/stl-serializer": "2.1.3", + "bitbybit-occt": "0.9.16", "rxjs": "7.5.5", "verb-nurbs-web": "2.1.3" } }, + "node_modules/bitbybit-occt": { + "version": "0.9.16", + "resolved": "https://registry.npmjs.org/bitbybit-occt/-/bitbybit-occt-0.9.16.tgz", + "integrity": "sha512-zr9mbOULiiyt/jFw+u4HwkdfJoUYsd60rninKQ+Zf8uMYKKbqSgEQNNWb/w72Yf9BARyCs8Njef0x0q/22yj4g==" + }, "node_modules/bl": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", @@ -14561,9 +14567,9 @@ } }, "bitbybit-core": { - "version": "0.9.12", - "resolved": "https://registry.npmjs.org/bitbybit-core/-/bitbybit-core-0.9.12.tgz", - "integrity": "sha512-ke60Ra8dH47L4MD+vlt4fBkL2gVjTnRgTcFA9dlZMUaNUFSOoDVEcRkB6KCoHuLfjoXQ7uES4m+/BqAzkAzrlQ==", + "version": "0.9.16", + "resolved": "https://registry.npmjs.org/bitbybit-core/-/bitbybit-core-0.9.16.tgz", + "integrity": "sha512-MMdjXAnhBQNjIdvjqgrp5N2//WR0+pz1dwV51NmT32PNsSqB/lwW9siyew1KH/Gl+kOHVNf5LxQjcPyc3GyTyg==", "requires": { "@babylonjs/core": "5.42.2", "@babylonjs/gui": "5.42.2", @@ -14573,10 +14579,16 @@ "@jscad/io-utils": "2.0.13", "@jscad/modeling": "2.7.2", "@jscad/stl-serializer": "2.1.3", + "bitbybit-occt": "0.9.16", "rxjs": "7.5.5", "verb-nurbs-web": "2.1.3" } }, + "bitbybit-occt": { + "version": "0.9.16", + "resolved": "https://registry.npmjs.org/bitbybit-occt/-/bitbybit-occt-0.9.16.tgz", + "integrity": "sha512-zr9mbOULiiyt/jFw+u4HwkdfJoUYsd60rninKQ+Zf8uMYKKbqSgEQNNWb/w72Yf9BARyCs8Njef0x0q/22yj4g==" + }, "bl": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", diff --git a/angular/laptop-holder/src/app/laptop.ts b/angular/laptop-holder/src/app/laptop.ts index 82a99ed..3f9b159 100644 --- a/angular/laptop-holder/src/app/laptop.ts +++ b/angular/laptop-holder/src/app/laptop.ts @@ -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[] = [ { @@ -34,6 +36,7 @@ export class LaptopLogic { constructor(bitbybit: BitByBitBase) { this.bitbybit = bitbybit; + this.occt = bitbybit.occt as OCCT; } async renderLaptops(laptops) { @@ -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; @@ -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[]) { diff --git a/angular/laptop-holder/src/app/occ.worker.ts b/angular/laptop-holder/src/app/occ.worker.ts index 4081708..07faac4 100644 --- a/angular/laptop-holder/src/app/occ.worker.ts +++ b/angular/laptop-holder/src/app/occ.worker.ts @@ -1,6 +1,6 @@ /// -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) => {