All files / api bitbybit-base.ts

100% Statements 32/32
100% Branches 4/4
100% Functions 2/2
100% Lines 32/32

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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