Draws any entity into the scene, as drawAnyAsync does, without giving the drawn object
back; for the last step of a script that only needs the result to appear.
The entity to draw and the optional drawing options
Draws any entity the library produces into the scene and gives back the drawn object: kernel shapes from OCCT, JSCAD and Manifold, points, lines, polylines, frames, curves, meshes, tags and nodes.
The options are matched to the entity, with defaults when none are given; pass the previous result back in the update slot to redraw in place.
What drawing the entity produces: a scene object for geometry, the tag or tags for a tag, an axis triad for a node; undefined for an empty list
const box = await bitbybit.occt.shapes.solid.createBox({ width: 10, length: 10, height: 10, center: [0, 0, 0] });
const options = bitbybit.draw.optionsOcctShapeSimple({ precision: 0.01, drawFaces: true, faceColour: "#ff0000", drawEdges: true, edgeColour: "#ffffff", edgeWidth: 2, drawTwoSided: true, backFaceColour: "#0000ff", backFaceOpacity: 1 });
const drawn = await bitbybit.draw.drawAnyAsync({ entity: box, options });
Draws an entity that needs no kernel work, as drawAny does, without giving the drawn object
back; points, lines, polylines, frames and tags qualify, kernel shapes do not.
The entity to draw and the optional drawing options
Draws an entity that needs no kernel work into the scene right away and gives back the drawn object: points, lines, polylines, frames, tags and nodes.
Kernel shapes from OCCT, JSCAD and Manifold must go through drawAnyAsync, which waits for
the kernel to mesh them.
What drawing the entity produces: a scene object for geometry, the tag or tags for a tag, an axis triad for a node; undefined for an empty list
const options = bitbybit.draw.optionsSimple({ colours: "#00ff00", size: 0.5, opacity: 1, updatable: false, hidden: false, drawTwoSided: true, backFaceColour: "#0000ff", backFaceOpacity: 1, colorMapStrategy: Bit.Inputs.Base.colorMapStrategyEnum.lastColorRemainder, arrowSize: 0, arrowAngle: 15 });
const drawn = bitbybit.draw.drawAny({ entity: [[0, 0, 0], [5, 5, 5], [10, 0, 0]], options });
Draws a grid on the ground plane, as drawGridMesh does, without giving the mesh back.
The size, line spacing, colors and opacity of the grid
Draws a grid on the ground plane, the XZ plane through the origin, to give a sense of scale and orientation; every tenth line is drawn thicker by default.
The size, line spacing, colors and opacity of the grid
The grid mesh
Creates an image texture from a URL for the texture slots of createPBRMaterial, with
tiling, offset, rotation and filtering that mean the same in every renderer.
The image URL and the tiling, offset, rotation, flip and sampling options
The engine's texture
Creates a physically based material from settings that mean the same in every renderer: base
color, metallic and roughness, opacity, emissive glow, the texture slots and the alpha and
side options; put it in the faceMaterial of the drawing options.
The name, colors, metallic and roughness values, opacity, textures and rendering options
The engine's material
const material = bitbybit.draw.createPBRMaterial({ name: "steel", baseColor: "#c0c0c0", metallic: 1, roughness: 0.4, alpha: 1, emissiveColor: "#000000", emissiveIntensity: 1, zOffset: 0, zOffsetUnits: 0, alphaMode: Bit.Inputs.Draw.alphaModeEnum.opaque, alphaCutoff: 0.5, doubleSided: false, wireframe: false, unlit: false });
const options = bitbybit.draw.optionsOcctShapeMaterial({ precision: 0.01, faceMaterial: material, drawEdges: true, edgeColour: "#ffffff", edgeWidth: 2 });
Builds drawing options for points, lines, polylines, curves, surfaces and JSCAD meshes: colors, size, opacity, two-sided rendering and arrow heads on lines, with defaults for what is left out.
The options to start from
The drawing options
const options = bitbybit.draw.optionsSimple({ colours: "#ff0000", size: 2, opacity: 1, updatable: false, hidden: false, drawTwoSided: true, backFaceColour: "#0000ff", backFaceOpacity: 1, colorMapStrategy: Bit.Inputs.Base.colorMapStrategyEnum.lastColorRemainder, arrowSize: 0, arrowAngle: 15 });
Builds drawing options for frames: how long the axes are and their colors, whether the small grid in the frame's plane is drawn and in which color, the line width and whether the frame can be redrawn in place, with defaults for what is left out.
The options to start from
The drawing options
Builds the full drawing options for OCCT shapes: meshing precision, face, edge and vertex colors and sizes, index labels, arrows on edges, two-sided rendering, iso curves, a surface analysis coloring the faces and the triangulation cache, with defaults for what is left out.
The options to start from
The drawing options
const options = bitbybit.draw.optionsOcctShape({ faceOpacity: 1, edgeOpacity: 1, edgeColour: "#ffffff", faceColour: "#ff0000", edgeWidth: 2, drawEdges: true, drawFaces: true, drawVertices: false, vertexColour: "#ff00ff", vertexSize: 0.03, precision: 0.01, drawEdgeIndexes: false, edgeIndexHeight: 0.06, edgeIndexColour: "#ff00ff", drawFaceIndexes: false, faceIndexHeight: 0.06, faceIndexColour: "#0000ff", drawTwoSided: true, backFaceColour: "#0000ff", backFaceOpacity: 1, edgeArrowSize: 0, edgeArrowAngle: 15, keepMeshData: false, allowQualityDecrease: true, forceFaceDeflection: false, drawIsoCurves: true, isoCurvesU: 5, isoCurvesV: 5, isoCurvesColour: "#808080", surfaceAnalysis: Bit.Inputs.OCCT.surfaceAnalysisEnum.gaussian, draftDirection: [0, 1, 0] });
Builds the most used drawing options for OCCT shapes, precision, face and edge colors and two-sided rendering, with defaults for what is left out.
The options to start from
The drawing options
Builds drawing options for OCCT shapes whose faces use a full engine material, as
createPBRMaterial makes one, plus the precision and edge style.
The options to start from
The drawing options
const material = bitbybit.draw.createPBRMaterial({ name: "steel", baseColor: "#c0c0c0", metallic: 1, roughness: 0.4, alpha: 1, emissiveColor: "#000000", emissiveIntensity: 1, zOffset: 0, zOffsetUnits: 0, alphaMode: Bit.Inputs.Draw.alphaModeEnum.opaque, alphaCutoff: 0.5, doubleSided: false, wireframe: false, unlit: false });
const options = bitbybit.draw.optionsOcctShapeMaterial({ precision: 0.01, faceMaterial: material, drawEdges: true, edgeColour: "#ffffff", edgeWidth: 2 });
Builds drawing options for Manifold solids and cross-sections: face color or a full engine material, the line style of cross-sections, normals and the two-sided rendering.
The options to start from
The drawing options
const options = bitbybit.draw.optionsManifoldShapeMaterial({ faceOpacity: 1, faceColour: "#ff0000", faceMaterial: material, crossSectionColour: "#ff00ff", crossSectionWidth: 2, crossSectionOpacity: 1, computeNormals: false, drawTwoSided: true, backFaceColour: "#0000ff", backFaceOpacity: 1 });
const drawn = await bitbybit.draw.drawAnyAsync({ entity: solid, options });
Builds drawing options for transform nodes, which are drawn as a triad of colored axis lines of a given length.
The options to start from
The drawing options
Drawing anything into the scene: kernel shapes, points, lines, polylines, frames, curves, meshes and tags all go through
drawAnyAsync, which picks the right renderer for the entity and returns the drawn object. Theoptionsmethods build the drawing options with defaults for each kind of entity,createPBRMaterialandcreateTexturemake materials for the face slots, and a drawn object can be redrawn in place by passing it back.