|
| 1 | +import { OCCT as BaseOCCT, OCCTWorkerManager } from "@bitbybit-dev/occt-worker"; |
| 2 | +import { JSONPath } from "jsonpath-plus"; |
| 3 | +import { Babylon } from "./bitbybit/babylon/babylon"; |
| 4 | +import { |
| 5 | + Line, |
| 6 | + Polyline, |
| 7 | + Verb, |
| 8 | + Tag, |
| 9 | + Time, |
| 10 | + OCCTW, |
| 11 | + Asset, |
| 12 | + JSONBitByBit, |
| 13 | +} from "@bitbybit-dev/core"; |
| 14 | +import { |
| 15 | + Vector, |
| 16 | + Point, |
| 17 | + TextBitByBit, |
| 18 | + Color, |
| 19 | + MathBitByBit, |
| 20 | + GeometryHelper, |
| 21 | + Lists, |
| 22 | + Logic, |
| 23 | + Transforms |
| 24 | +} from "@bitbybit-dev/base"; |
| 25 | +import { |
| 26 | + JSCAD |
| 27 | +} from "@bitbybit-dev/jscad-worker"; |
| 28 | +import { ManifoldBitByBit } from "@bitbybit-dev/manifold-worker"; |
| 29 | +import { Draw } from "./bitbybit/draw"; |
| 30 | +import { Context } from "./context"; |
| 31 | +import { JSCADWorkerManager } from "@bitbybit-dev/jscad-worker"; |
| 32 | +import { ManifoldWorkerManager } from "@bitbybit-dev/manifold-worker"; |
| 33 | +import * as BABYLON from "@babylonjs/core"; |
| 34 | +import * as vrb from "verb-nurbs-web"; |
| 35 | +import { DrawHelper } from "./draw-helper"; |
| 36 | + |
| 37 | +export class BitByBitBase { |
| 38 | + |
| 39 | + public context: Context; |
| 40 | + public jscadWorkerManager: JSCADWorkerManager; |
| 41 | + public manifoldWorkerManager: ManifoldWorkerManager; |
| 42 | + public occtWorkerManager: OCCTWorkerManager; |
| 43 | + |
| 44 | + public math: MathBitByBit; |
| 45 | + public logic: Logic; |
| 46 | + public lists: Lists; |
| 47 | + public json: JSONBitByBit; |
| 48 | + public vector: Vector; |
| 49 | + public babylon: Babylon; |
| 50 | + public point: Point; |
| 51 | + public line: Line; |
| 52 | + public transforms: Transforms; |
| 53 | + public polyline: Polyline; |
| 54 | + public draw: Draw; |
| 55 | + public verb: Verb; |
| 56 | + public jscad: JSCAD; |
| 57 | + public manifold: ManifoldBitByBit; |
| 58 | + public text: TextBitByBit; |
| 59 | + public tag: Tag; |
| 60 | + public time: Time; |
| 61 | + public occt: OCCTW & BaseOCCT; |
| 62 | + public asset: Asset; |
| 63 | + public color: Color; |
| 64 | + |
| 65 | + constructor() { |
| 66 | + this.context = new Context(); |
| 67 | + this.jscadWorkerManager = new JSCADWorkerManager(); |
| 68 | + this.manifoldWorkerManager = new ManifoldWorkerManager(); |
| 69 | + this.occtWorkerManager = new OCCTWorkerManager(); |
| 70 | + this.jscad = new JSCAD(this.jscadWorkerManager); |
| 71 | + this.manifold = new ManifoldBitByBit(this.manifoldWorkerManager); |
| 72 | + |
| 73 | + const geometryHelper = new GeometryHelper(); |
| 74 | + this.math = new MathBitByBit(); |
| 75 | + this.vector = new Vector(this.math, geometryHelper); |
| 76 | + const drawHelper = new DrawHelper(this.context, this.jscad.text, this.vector, this.jscadWorkerManager, this.manifoldWorkerManager, this.occtWorkerManager,); |
| 77 | + this.babylon = new Babylon(this.context, drawHelper, this.color); |
| 78 | + this.tag = new Tag(this.context); |
| 79 | + this.draw = new Draw( |
| 80 | + drawHelper, |
| 81 | + this.babylon.node, |
| 82 | + this.tag, |
| 83 | + this.context); |
| 84 | + |
| 85 | + this.color = new Color(this.math); |
| 86 | + this.line = new Line(this.context, geometryHelper); |
| 87 | + this.transforms = new Transforms(this.vector, this.math); |
| 88 | + this.point = new Point(geometryHelper, this.transforms); |
| 89 | + this.polyline = new Polyline(this.context, geometryHelper); |
| 90 | + this.verb = new Verb(this.context, geometryHelper, this.math); |
| 91 | + this.time = new Time(this.context); |
| 92 | + this.occt = new OCCTW(this.context, this.occtWorkerManager); |
| 93 | + this.asset = new Asset(); |
| 94 | + this.logic = new Logic(); |
| 95 | + this.json = new JSONBitByBit(this.context); |
| 96 | + this.text = new TextBitByBit(); |
| 97 | + this.lists = new Lists(); |
| 98 | + } |
| 99 | + |
| 100 | + init(scene: BABYLON.Scene, occt?: Worker, jscad?: Worker, manifold?: Worker, havokPlugin?: BABYLON.HavokPlugin) { |
| 101 | + this.context.scene = scene; |
| 102 | + if (havokPlugin) { |
| 103 | + this.context.havokPlugin = havokPlugin; |
| 104 | + } |
| 105 | + const verb = { geom: vrb.geom, core: vrb.core }; |
| 106 | + this.context.verb = verb; |
| 107 | + this.context.jsonpath = JSONPath; |
| 108 | + if (occt) { |
| 109 | + this.occtWorkerManager.setOccWorker(occt); |
| 110 | + } |
| 111 | + if (jscad) { |
| 112 | + this.jscadWorkerManager.setJscadWorker(jscad); |
| 113 | + } |
| 114 | + if(manifold){ |
| 115 | + this.manifoldWorkerManager.setManifoldWorker(manifold); |
| 116 | + } |
| 117 | + } |
| 118 | +} |
0 commit comments