import * as BABYLON from "@babylonjs/core"; 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 { Vector } from "@bitbybit-dev/base"; import type { JSCADWorkerManager, JSCADText } from "@bitbybit-dev/jscad-worker"; import type { ManifoldWorkerManager } from "@bitbybit-dev/manifold-worker"; import type { OCCTWorkerManager } from "@bitbybit-dev/occt-worker"; 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 designStates; private readonly jscadBackFaces; private readonly pointsLooks; private readonly designMeshes; private readonly recipeDrawer; private readonly unlitMaterialCache; 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; private generateEntityId; private colourMetallic; private colourRoughness; protected getMaterialKey(hex: string, alpha: number, zOffset: number, unlit?: boolean): string; /** * `options` with `edgeWidth` scaled to the size of all `meshes` together, when `edgeWidthBySize` * asks for it, and that flag then off, so sizing them again changes nothing. Otherwise the options * come back as they are. * @param options - Drawing options that may ask for edges sized to what they draw * @param meshes - Every mesh the options will draw * @returns New options with the edge width for that size */ withEdgeWidthSized & Pick>(options: T, meshes: readonly DrawableShapeMesh[]): T; private drawnSize; private getOrCreateMaterial; private getOrCreateUnlitMaterial; private createBackFaceMesh; createOrUpdateSurfacesMesh(meshDataConverted: readonly MeshPart[], mesh: BABYLON.Mesh | undefined, updatable: boolean, material: BABYLON.PBRMetallicRoughnessMaterial, addToScene: boolean, hidden: boolean): BABYLON.Mesh; edgesRendering(mesh: BABYLON.LinesMesh, size: number, opacity: number, colours: string | string[]): void; drawLines(inputs: Inputs.Line.DrawLinesDto): BABYLON.LinesMesh; drawPolylineClose(inputs: Inputs.Polyline.DrawPolylineDto & { arrowSize?: number | undefined; arrowAngle?: number | undefined; }): BABYLON.GreasedLineMesh; drawCurve(inputs: Inputs.Verb.DrawCurveDto): BABYLON.GreasedLineMesh; drawSurface(inputs: Inputs.Verb.DrawSurfaceDto): BABYLON.Mesh; drawSurfaces(inputs: Inputs.Verb.DrawSurfacesDto): BABYLON.Mesh; drawSurfacesMultiColour(inputs: Inputs.Verb.DrawSurfacesColoursDto & { colorMapStrategy?: Inputs.Base.colorMapStrategyEnum | undefined; }): BABYLON.Mesh; drawCurves(inputs: Inputs.Verb.DrawCurvesDto): BABYLON.GreasedLineMesh; drawPolyline(mesh: BABYLON.GreasedLineMesh | undefined, pointsToDraw: number[][], updatable: boolean, size: number, opacity: number, colours: string | string[], arrowSize?: number, arrowAngle?: number): BABYLON.GreasedLineMesh; drawPolylinesWithColours(inputs: Inputs.Polyline.DrawPolylinesDto & { colorMapStrategy?: Inputs.Base.colorMapStrategyEnum | undefined; arrowSize?: number | undefined; arrowAngle?: number | undefined; }): BABYLON.GreasedLineMesh | undefined; drawPolylines(mesh: BABYLON.GreasedLineMesh | undefined, polylinePoints: number[][][], updatable: boolean, size: number, opacity: number, colours: string | string[], tolerance?: number, segmentize?: boolean, colorMapStrategy?: Inputs.Base.colorMapStrategyEnum, arrowSize?: number, arrowAngle?: number): BABYLON.GreasedLineMesh | undefined; private canRestyleGreasedPolylines; private restyleGreasedPolylines; private hasMultipleGreasedColors; private expandedGreasedColors; createGreasedPolylines(updatable: boolean, lines: number[][], width: number, colors: BABYLON.Color3[], visibility: number): BABYLON.GreasedLineMesh; private segmentizePolylinePoints; private isSegmentedPolyline; private arePointsEqual; localAxes(size: number, scene: BABYLON.Scene, colorXHex: string, colorYHex: string, colorZHex: string): BABYLON.Mesh; drawPoint(inputs: Inputs.Point.DrawPointDto): BABYLON.Mesh; drawPoints(inputs: Inputs.Point.DrawPointsDto & { colorMapStrategy?: Inputs.Base.colorMapStrategyEnum | undefined; }): BABYLON.Mesh; updatePointsInstances(mesh: BABYLON.Mesh, positions: Inputs.Base.Point3[]): void; private createPointsInLook; private drawnInLook; private createPointSpheresMesh; drawSolidOrPolygonMesh(inputs: Inputs.JSCAD.DrawSolidMeshDto): Promise; private makeMesh; drawSolidOrPolygonMeshes(inputs: Inputs.JSCAD.DrawSolidMeshesDto): Promise; drawPath(inputs: Inputs.JSCAD.DrawPathDto): Promise; drawManifoldsOrCrossSections(inputs: Inputs.Manifold.DrawManifoldsOrCrossSectionsDto): Promise; drawManifoldOrCrossSection(inputs: Inputs.Manifold.DrawManifoldOrCrossSectionDto): Promise; drawManifoldMesh(mesh: Inputs.Manifold.DecomposedManifoldMeshDto, options: Inputs.Draw.DrawManifoldOrCrossSectionOptions): BABYLON.Mesh | undefined; drawManifoldMeshes(meshes: Inputs.Manifold.DecomposedManifoldMeshDto[], options: Inputs.Draw.DrawManifoldOrCrossSectionOptions): BABYLON.Mesh; drawRecipeMeshes(meshes: Inputs.Manifold.RecipeMeshesDto, options: Inputs.Draw.DrawRecipeMeshesOptions): BABYLON.Mesh; 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, a sub-mesh and a * material each, its back faces when asked, and its edges once, each in its color. * @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 mesh 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 mesh holding one mesh 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, * into one mesh with a sub-mesh per look and one line for its edges, and every placement is a * thin instance of both. Given the mesh an earlier build drew, it redraws in place: when the same * parts sit at the same paths, it only moves them, and otherwise it keeps what it drew for every * part whose shape and appearance are unchanged under the same options, places it again, and * meshes and draws only the rest. * @param build - The build to draw * @param drawOptions - The drawing options; the face color is the color of faces no look colors * @param previous - The mesh an earlier build drew, to redraw in place * @returns The mesh holding the build: `previous` when given, else a new mesh added to the scene */ drawDesignBuild(build: Models.OCCT.DesignBuildResult | Models.OCCT.DesignSection, drawOptions: Inputs.Draw.DrawOcctShapeOptions, previous?: BABYLON.Mesh): 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 lookedShapeMesh; private partEdges; private lookedMesh; private lookMaterial; private newDesignRoot; private fillDesign; private poseDesign; private clearDesign; handleDecomposedMesh(inputs: Omit, "shape">, decomposedMesh: DrawableShapeMesh, options: Partial): Promise; handleDecomposedMeshIndividually(inputs: Omit, "shape">, decomposedMesh: DrawableShapeMesh, options: Partial): Promise; private getOrCreateAnalysisMaterial; private manifoldMeshContainer; private handleDecomposedManifold; private createLineSystemMesh; private createMesh; private parseFaces; private getSafeWorkerOptions; private getMeshingOptions; }