import type { Context } from "./context"; import * as Inputs from "./inputs"; import { DrawHelperCore } from "@bitbybit-dev/core"; import type { KeptDesignMesh, DrawableShapeMesh } from "@bitbybit-dev/core"; import type { MeshPart } from "@bitbybit-dev/core"; import type * as Models from "@bitbybit-dev/core/lib/api/models"; import type { JSCADText } from "@bitbybit-dev/jscad-worker"; import type { Vector } from "@bitbybit-dev/base"; import type { JSCADWorkerManager } from "@bitbybit-dev/jscad-worker"; import type { ManifoldWorkerManager } from "@bitbybit-dev/manifold-worker"; import type { OCCTWorkerManager } from "@bitbybit-dev/occt-worker"; import * as THREEJS from "three"; import type * as Resolved from "./resolved-inputs"; export declare class DrawHelper extends DrawHelperCore { private readonly context; private readonly solidText; readonly vector: Vector; private readonly jscadWorkerManager; private readonly manifoldWorkerManager; private readonly occWorkerManager; private readonly materialCache; private readonly unlitMaterialCache; private readonly lineMaterialCache; private readonly designStates; private readonly pointsLooks; private readonly designMeshes; private readonly scratchMatrix; private readonly recipeDrawer; private entityIdCounter; private readonly instanceId; constructor(context: Context, solidText: JSCADText, vector: Vector, jscadWorkerManager: JSCADWorkerManager, manifoldWorkerManager: ManifoldWorkerManager, occWorkerManager: OCCTWorkerManager); /** * Check if DrawHelper has been disposed * @returns True if disposed, false otherwise */ isDisposed(): boolean; /** * Cleanup method to dispose of cached materials and prevent memory leaks * Should be called when the DrawHelper instance is no longer needed */ dispose(): void; drawManifoldsOrCrossSections(inputs: Inputs.Manifold.DrawManifoldsOrCrossSectionsDto): Promise; drawManifoldOrCrossSection(inputs: Inputs.Manifold.DrawManifoldOrCrossSectionDto): Promise; drawManifoldMesh(mesh: Inputs.Manifold.DecomposedManifoldMeshDto, options: Inputs.Draw.DrawManifoldOrCrossSectionOptions): THREEJS.Group | undefined; drawManifoldMeshes(meshes: Inputs.Manifold.DecomposedManifoldMeshDto[], options: Inputs.Draw.DrawManifoldOrCrossSectionOptions): THREEJS.Group; drawRecipeMeshes(meshes: Inputs.Manifold.RecipeMeshesDto, options: Inputs.Draw.DrawRecipeMeshesOptions): THREEJS.Group; setRecipeElementsVisible(resolved: Resolved.Draw.RecipeElementsVisibilityDto): void; setRecipeElementsColour(resolved: Resolved.Draw.RecipeElementsColourDto): void; recipeElementOfPick(inputs: Inputs.Draw.RecipeElementPickDto): string | undefined; private recipeMaterial; drawShape(inputs: Inputs.OCCT.DrawShapeDto): Promise; drawShapes(inputs: Inputs.OCCT.DrawShapesDto): Promise; /** * Draws a kernel shape in its appearance: one mesh whose faces take their looks, its back faces * when asked, and its edges once. * @param entity - The shape with its appearance * @param options - The drawing options; the face color is the color of faces no look colors * @returns The group holding the shape, added to the scene */ drawShapeWithAppearance(entity: Inputs.Draw.ShapeWithAppearance, options: Inputs.Draw.DrawOcctShapeOptions): Promise; /** * Draws kernel shapes in their appearance, all meshed in one call to the worker, each as * `drawShapeWithAppearance` draws one. * @param entities - The shapes with their appearance * @param options - The drawing options; the face color is the color of faces no look colors * @returns A group holding one group per shape, in order, added to the scene */ drawShapesWithAppearance(entities: readonly Inputs.Draw.ShapeWithAppearance[], options: Inputs.Draw.DrawOcctShapeOptions): Promise; /** * Draws what `occt.design.build` or `occt.design.section` returns. Every part is meshed once, in one call to the worker; * every placement is a GPU instance, in one `BatchedMesh` per look; and every edge goes into one * batched line. Given the group an earlier build drew, it redraws in place: when the same parts * sit at the same paths, it only moves them, and otherwise it meshes only the parts it has not. * @param build - The build to draw * @param options - The drawing options; the face color is the color of faces no look colors * @param previous - The group an earlier build drew, to redraw in place * @returns The group holding the build: `previous` when given, else a new group added to the scene */ drawDesignBuild(build: Models.OCCT.DesignBuildResult | Models.OCCT.DesignSection, drawOptions: Inputs.Draw.DrawOcctShapeOptions, previous?: THREEJS.Group): Promise; /** * The meshes this drawer keeps for design parts with the given shape hashes, as it meshed them for * these drawing options, so a caller can store them and hand them back with `keepDesignMeshes`. * They are the drawer's own meshes, not copies, and their numbers are views into buffers the * worker handed over, so store them where a structured clone keeps them, such as IndexedDB or a * message posted without a transfer list. Never transfer their buffers to another thread, which * empties them here too, and never store them as JSON, which turns their typed arrays into plain * records: `keepDesignMeshes` refuses both rather than drawing nothing. * @param shapeHashes - The parts' shape hashes, as a design build gives them * @param drawOptions - The options the parts were drawn with * @returns The meshes it keeps, each with its part's shape hash; a part it has not meshed for these options is left out */ keptDesignMeshes(shapeHashes: readonly string[], drawOptions: Inputs.Draw.DrawOcctShapeOptions): KeptDesignMesh[]; /** * Keeps meshes a caller stored for design parts, so the parts with these shape hashes are drawn with * these options without being meshed again. A mesh that is not one of faces and edges is passed over. * @param meshes - The meshes, each with its part's shape hash * @param drawOptions - The options the meshes were made for * @throws Error when a mesh of faces and edges can no longer be drawn: its buffers were transferred * to another thread, or it was stored as JSON; then none of the meshes is kept */ keepDesignMeshes(meshes: readonly KeptDesignMesh[], drawOptions: Inputs.Draw.DrawOcctShapeOptions): void; private meshingForLooks; private meshingTextOf; private meshShapesForLooks; private isMeshOfFacesAndEdges; private lookedShapeGroup; private partEdgeColour; private lookedMesh; private lookMaterial; private newDesignGroup; private fillDesign; private lookBatch; private edgeBatch; private segmentColors; private poseDesign; private clearDesign; drawSolidOrPolygonMesh(inputs: Inputs.JSCAD.DrawSolidMeshDto): Promise; drawSolidOrPolygonMeshes(inputs: Inputs.JSCAD.DrawSolidMeshesDto): Promise; drawPolylinesWithColours(inputs: Inputs.Polyline.DrawPolylinesDto & { colorMapStrategy?: Inputs.Base.colorMapStrategyEnum | undefined; arrowSize?: number | undefined; arrowAngle?: number | undefined; }): THREEJS.Group; drawPoint(inputs: Inputs.Point.DrawPointDto): THREEJS.Group; drawPolylineClose(inputs: Inputs.Polyline.DrawPolylineDto & { arrowSize?: number | undefined; arrowAngle?: number | undefined; }): THREEJS.Group; drawPolyline(mesh: THREEJS.Group | undefined, pointsToDraw: Inputs.Base.Point3[], updatable: boolean, size: number, opacity: number, colours: string | string[], arrowSize?: number, arrowAngle?: number): THREEJS.Group; drawCurve(inputs: Inputs.Verb.DrawCurveDto): THREEJS.Group; drawPoints(inputs: Inputs.Point.DrawPointsDto & { colorMapStrategy?: Inputs.Base.colorMapStrategyEnum | undefined; }): THREEJS.Group; private drawnPointCount; private freePoints; private createPointsInLook; private drawnInLook; updatePointsInstances(group: THREEJS.Group, positions: Inputs.Base.Point3[]): void; drawCurves(inputs: Inputs.Verb.DrawCurvesDto): THREEJS.Group; drawSurfacesMultiColour(inputs: Inputs.Verb.DrawSurfacesColoursDto & { colorMapStrategy?: Inputs.Base.colorMapStrategyEnum | undefined; }): THREEJS.Group; createOrUpdateSurfacesMesh(meshDataConverted: readonly MeshPart[], group: THREEJS.Group | undefined, updatable: boolean, material: THREEJS.MeshPhysicalMaterial, addToScene: boolean, hidden: boolean): THREEJS.Group; drawSurface(inputs: Inputs.Verb.DrawSurfaceDto): THREEJS.Group; private parseFaces; private makeMesh; private createMesh; private clearFreeingGeometries; handleDecomposedMesh(inputs: Omit, "shape">, decomposedMesh: DrawableShapeMesh, options: Partial): Promise>; handleDecomposedMeshIndividually(inputs: Omit, "shape">, decomposedMesh: DrawableShapeMesh, options: Partial): Promise; private drawPolylines; private computePolylineColors; private computePolylineColorsWithExplicit; private createLineGeometry; private static readonly LINE_WIDTH_PER_SIZE; private static readonly LINE_WIDTH_MIN_PX; private static readonly LINE_WIDTH_PRECISION; private static flattenVertices; private getOrCreateLineMaterial; private manifoldMeshContainer; private handleDecomposedManifold; private getSafeWorkerOptions; private getMeshingOptions; private getOrCreateAnalysisMaterial; private generateEntityId; private getOrCreateMaterial; private getOrCreateUnlitMaterial; private createBackFaceMesh; private createPointSpheresMesh; }