draw library

The draw library (github.com/viam-labs/motion-tools/draw) builds the transforms and entities that the 3D scene and Viam Visualization render. This page lists the options you reach for while writing a producer. The library lives in viam-labs and moves faster than the RDK, so treat the project’s generated API docs and pkg.go.dev as the full and current inventory.

Placement and identity

Options for Draw calls and NewDrawConfig, all of type DrawableOption:

OptionWhat it sets
WithParentThe reference frame the pose is expressed in. Defaults to world.
WithPoseThe entity’s pose in the parent frame.
WithCenterAn offset applied at the entity’s own center.
WithIDA string identity; the library derives a stable UUID from it, so re-sends update in place.
WithUUIDAn explicit UUID, when you manage identity yourself.
WithAxesHelperDraws a coordinate triad at the entity’s origin.
WithInvisibleHides the entity by default; the viewer can re-enable it.

Shapes

ConstructorBuilds
NewDrawnGeometryA styled spatialmath.Geometry; its Draw method returns a *commonpb.Transform.
NewShape + WithArrowsArrows, for directions, normals, or vectors.
NewShape + WithLine / NewLineA line, for paths, segments, or connections.
NewShape + WithPointsPoints, for sampled data or markers.
NewShape + WithModelA detailed 3D mesh model.
NewShape + WithNurbs / NewNurbsA smooth NURBS curve or surface.

Style a geometry with WithGeometryColor (one color) or WithGeometryColors (per-point colors) when you call NewDrawnGeometry.

Colors

Build a Color with NewColor plus one option, or use the one-call helpers:

With NewColorHelperInput
WithRGBColorFromRGBr, g, b as 0 to 255
WithRGBAColorFromRGBAr, g, b plus alpha for opacity
WithNameColorFromNameA CSS color name, such as dodgerblue
WithHexColorFromHexA hex string
WithHSVColorFromHSVHue, saturation, value

Metadata

Options for NewDrawing and NewTransform, all of type DrawMetadataOption. Each writes one of the metadata keys the scene reads:

OptionMetadata it writes
WithMetadataColorscolors (and opacities from alpha)
WithMetadataAxesHelpershow_axes_helper
WithMetadataInvisibleinvisible
WithMetadataRelationshipsrelationships, for links such as HoverLink

Snapshots

Options for NewSnapshot, which builds a loadable scene snapshot:

OptionWhat it sets
WithSceneCameraWhere the scene camera starts.
WithGrid, WithGridCellSizeThe reference grid and its cell size.
WithScenePointSize, WithScenePointColorDefault point rendering.
WithRenderArmModelsWhether arms render as colliders, models, or both.

What’s next