Skip to content

@mk7s/holochart-render ​

Experimental

@mk7s/holochart-render — the three.js layer: the render root, viewports, GPU primitives, text, picking and marker symbols. @mk7s/holochart exposes it as the render namespace.

The package is experimental until the plugin API is declared stable (plan E22): its exports may change in any minor release (docs/release/versioning.md). The exceptions are tagged @public: the fonts and symbols registries, which the full bundle also exports by name.

Namespaces ​

NamespaceDescription
ExtrusionLazy-
LinesMarkers3DLazy-
MeshLazy-
PatternCode-

Classes ​

ClassDescription
ArcPrimitiveInstanced, anti-aliased annular sectors (pie / donut / gauge wedges) in a single draw call. Style-only updates (fill, borderColor, borderWidth) re-upload only that attribute; shape updates (radii, angles, pad, corners) re-upload the shape + bounds; center updates the centers.
EmitterMinimal typed event emitter used by the render loop and render root.
FillPrimitiveBatched polygon fills: one merged indexed geometry, one draw call for any number of polygons.
GpuPickerGPU ID picker for one 3D view (see the module docs for the design). Create one per viewport; Picker does this automatically for 3D viewports.
HeatmapPrimitiveOne z grid, one draw call. See the module header for the texture layout and shading rules.
ImagePrimitiveA single fitted image. ready resolves (never rejects) once the current source has loaded or failed; nothing is drawn until then, or after a failure.
LazyFillPrimitiveA FillPrimitive whose code loads on first use: the same data, updates and transform, and the same drawing once loaded. Until then it keeps the latest data, transform and viewport size and draws nothing; ready resolves once the fill is drawn (at once when the code has already loaded). A failed load resolves ready too (the fill stays undrawn) and is retried by the next update.
LazyMeshPrimitiveA MeshPrimitive whose code loads on first use: the same data, updates, transform, light rig and picking once loaded. Until then it keeps the latest of each and draws nothing (its object is a hidden placeholder the mesh draws into later, so callers can hold it and set its renderOrder at any time). A failed load resolves ready (the mesh stays undrawn) and is retried by the next update.
LinePrimitiveThick anti-aliased polylines with joins, caps, dashes, per-vertex color and per-segment width, drawn in a single instanced draw call.
MarkerMatrixThe shared columns and style of a scatter plot matrix. Create cells with createCell; add each to its viewport. Disposing the matrix disposes its remaining cells.
MarkerMatrixCellOne cell of a MarkerMatrix: an instanced draw of two shared columns.
MarkerSet-
MeshPickMaterialPick material for one generic mesh: writes base + element and mirrors the source material's side, depth test/write, wireframe, and opaque/transparent bucket (so three.js orders the pick pass like the visible frame). occluder: true makes a depth-only material for non-pickable objects that must still hide pickables behind them.
PickerRoutes picks to the CPU (2D) or GPU (3D) implementation per viewport. One per render root; see createPicker.
PickHitListReusable output of gatherPickHits: parallel arrays of pick ids and CSS distances, sorted by distance (ties by id). Only the first count entries are valid.
PickIdLayoutContiguous id-range layout, rebuilt for every pick: each pickable draw gets size ids starting right after the previous one (instanced markers need one per instance, meshes one per vertex / triangle / instance, or one for the whole object). Rebuilding per pick keeps the id space compact with no bookkeeping when counts change, and costs O(pickables). Ranges are stored in reused arrays, so the steady state does not allocate.
PointIndexStatic 2D spatial index over a point cloud, backed by a packed Hilbert R-tree (flatbush). Used for CPU picking of 2D traces (ADR-010): hover (nearest), box select (withinRect), lasso (withinPolygon) and brush-radius queries.
PointPicker2DCPU picker for one 2D view: registered point sources, each with a lazily (re)built index. Coordinates are the view's world space (2D: CSS px, bottom-left origin).
RasterPrimitiveOne pixel grid, one draw call. See the module header.
RectPrimitiveInstanced, anti-aliased rectangles with borders and rounded corners in a single draw call. Style-only updates (fill, borderColor, borderWidth/cornerRadius) re-upload only the affected instance attribute; coordinate updates re-upload the positions.
RenderLoop-
RenderRoot-
TextPrimitiveBatched label set. Create with createTextPrimitive; add object to a scene.
ViewportA scissored region of the canvas with its own scene and camera. Create via the render root.

Interfaces ​

InterfaceDescription
ArcDataData accepted by ArcPrimitive. Centers in data space; sizes in CSS px; angles in radians.
ArcShapeResolved per-wedge SDF parameters (see computeArcShape).
ArcShapeInputInputs of computeArcShape (one wedge).
ArrayPointSourceA point source over plain arrays, with a settable transform.
ArrowGeometryThe drawn arrow: a line segment (if any length is left) and head polygons, container px.
ArrowOptionsOptions of arrowGeometry.
ColorscaleTextureHandleA shared LUT texture plus the key to release it with.
CustomSymbolDefinitionA custom marker symbol for symbols.register.
DataTransformAffine map from data space to world space, per axis: world = data * scale + offset.
DefaultFontFaceA face of the built-in default font chosen for a request (defaultFontFace).
DirectionalLightSpecOne directional light of scene.lighting.
DomainCameraA domain trace's tilted camera (see the module comment): world (overlay) px ↔ screen, and the pointer onto the flat trace. Pure (three.js math only).
DomainHostWhat syncDomain reads from a trace's plot context (the runtime's fits).
DomainShapeOne extruded shape, world (overlay) px.
DomainViewThe trace view wrapper: syncDomain updates it again when captured data is missing.
ExtrusionDataData of an ExtrusionPrimitive.
ExtrusionHitA pointer ray's hit on an extruded shape: the ray parameter and the world point (x, y).
ExtrusionHostWhat a trace view hands to syncExtrudedRects (the runtime's plot context fits).
ExtrusionPrimitiveSee the module comment.
FillDataData for FillPrimitive.
FillGeometryInputGeometry-affecting fill inputs (changing any of these re-triangulates).
FillGradientGeometryWhat writeFillGradient needs of a gradient paint.
FillTriangulationResult of triangulateFills.
FontFamilyFacesFont files of one family for registerFontFamily. Every field is optional.
FontMetricsOracleSynchronous, cached text measurement for layout. Every method honors the font's textcase and variant (see the module notes).
FontMetricsOracleOptions-
FontVerticalMetricsVertical font metrics as fractions of the font size.
FrameInfoPer-frame information. The same object is reused for every frame (no per-frame allocation), so listeners must copy fields they want to keep.
FrameSchedulerAbstraction over requestAnimationFrame / cancelAnimationFrame.
GpuCapabilities-
GpuPickableOptionsOptions for GpuPicker.register.
GpuPickerLikeThe subset of GpuPicker the router uses (injectable for tests).
GpuPickRequestA GPU pick query.
GpuPickViewWhat the picker renders through: the view's camera and where on the canvas it draws. A Viewport satisfies this structurally.
HeatmapAxisOne validated heatmap axis in directed space: rel[k] = dir * (edges[k] - origin) ascends from 0 to extent.
HeatmapDataData for HeatmapPrimitive.
HeatmapLerpInterpolation neighbors along one axis: value = z[i0] * (1 - f) + z[i1] * f.
HeatmapTextureImageA packed float texture image: one float per texel, row-major, width × height.
HeatmapUniformsUniforms of the heatmap material (exposed for tests and debugging).
ImageFitResultResult of fitImage: world-px quad [x0, y0, x1, y1] and uv sub-rect [u0, v0, u1, v1].
ImageOptionsOptions for createImagePrimitive.
ImageQuadDataData for ImagePrimitive.
LightingSpecscene.lighting (E8.7). Colors are sRGB 0–1 RGBA (parsed by the caller).
LightRigThe lights of scene.lighting for a 3D scene. Add object to the scene, call attach once with the renderer (shadow maps, environment), and setCamera with the scene's camera (lights in camera or clip space follow it). Set the rig on meshes drawn with Plotly's model (MeshPrimitive.setLightRig) so they use the same lights.
Line3DScreen-space thick 3D polylines in one instanced draw call (see the module docs).
Line3DOptionsConstruction options of Line3D.
LineCursorWhere the sentinel-stream builder stands. buildLineLayout runs it from the start of a stream; streaming edits (LinePrimitive.splice) resume it in the middle of one, which is why the state is explicit.
LineDataData accepted by LinePrimitive.
LineGeometryInputGeometry-affecting line inputs.
LineLayoutResult of buildLineLayout.
LineLayoutOptionsOptions of buildLineLayout.
LinePrimitiveOptionsConstruction options for LinePrimitive.
LineRetainWhich part of new input equals the previous input (see LinePrimitive.splice): input vertices [at, at + (to - from)) of the new x/y are vertices [from, to) of the previous.
LineStreamArraysArrays a LineCursor writes into; omitted to only count.
LoadDefaultFontFacesOptionsOptions of loadDefaultFontFaces.
MarkerDataData accepted by MarkerSet.update. Every field is optional in updates.
MarkerMatrixCellDataColumn indices of a cell (the data of its Primitive.update).
MarkerPositionsLikeWhat markerPointSource needs from a MarkerSet (structural, to avoid a hard link).
Markers3D3D sprite markers: a MarkerSet with 3D blending and optional depth sorting.
Markers3DOptionsConstruction options of Markers3D.
MarkerSetOptions-
MeasuredTextResult of FontMetricsOracle.measureText, all in CSS px.
MeasurementFaceThe face the metrics oracle should measure a font request with (measurementFace).
MeshDataData for MeshPrimitive.
MeshLayoutThe attribute layout the primitive draws: expanded geometry has three vertices per triangle (flat shading, per-cell colors or intensity, triangle picking); otherwise the input vertices are drawn through the index.
MeshLightingPlotly's lighting attributes (surface, mesh3d, isosurface, …).
MeshMaterialSpectrace.material: a type and three.js material parameters (see the module comment).
MeshPrimitiveSee the module comment.
MeshShaderHooksGLSL spliced into the Plotly-model shader ('plotly' / 'flat' materials) at its hooks, e.g. surface contours or a wireframe overlay. Varyings available to fragment hooks: vLocal (RTC position), vViewPos, vNormal, vValue (intensity relative to its origin, with intensity); color is the straight-alpha sRGB color. Vertex hooks also apply to the pick pass (e.g. a displacement); uResolution / uPixelRatio (CSS px) are available to declare.
OutlineA closed counter-clockwise ring of points (see the module comment).
PackedArcsPacked per-instance arrays (see packArcs).
PackedRectsRTC-encoded rect geometry, as uploaded to the iRect / iZ instance attributes.
PatternFillPattern fills of a primitive's items (rects, arcs or fill polygons), resolved per item by the lazily loaded code with Plotly's rules: where fgcolor / bgcolor are unset, fillmode: 'replace' draws the item's color on a transparent background, 'overlay' draws the item's contrast color (white on dark colors, #444 on light ones) at fgopacity 0.5 over the item's color. Items without a shape keep their plain fill.
PickablePrimitiveA primitive with its own pick shader path (e.g. MarkerSet): object is drawn with the material from createPickMaterial, and gets pickCount ids (one per instance).
PickCanvasCanvas geometry a pick window is computed against (CSS px).
PickerHostWhat the picker needs from its render root (a RenderRoot satisfies it).
PickerOptions-
PickIdRangeOne contiguous id range: ids [base, base + size) belong to entry, element = id - base.
PickMaterialHandleA pick-mode material bound to one drawable. It writes encoded pick ids (see PICK_ENCODE_GLSL) and mirrors the drawable's depth state so occlusion matches the visible frame.
PickOptionsOptions for a pick query.
PickRenderStatePer-pick state handed to pick materials before the pick pass renders.
PickResultA single picking hit.
PickWindowA square window of size × size device pixels centred on the pixel under the cursor. Mutable and reused across picks; filled by computePickWindow.
PointIndexOptionsOptions for PointIndex.
PointSource2DA 2D point set the CPU picker can index. Coordinates live in the source's own space and map to the view's world space (2D: CSS px from the viewport rect's bottom-left) through world = v * scale + offset per axis.
PrimitiveA GPU drawing building block. Implementations must: - render all items with a constant number of draw calls (independent of item count), - upload only the buffers affected by an update when possible (plan §E16.3), - release every acquired resource in dispose.
PrimitiveContextContext handed to every primitive at construction.
PrismBuffersGrowing vertex and index buffers (world units), one item id per vertex.
RasterDataData for RasterPrimitive.
RasterPixelsRGBA pixels: 4 bytes per pixel, row-major, row 0 first, straight (not premultiplied) alpha.
RasterUniformsUniforms of the raster material (exposed for tests and debugging).
RectCoverageFill / border coverage of a screen point — see rectCoverage.
RectDataData accepted by RectPrimitive. Coordinates are in data space; sizes in CSS px.
RectScreenGeometryScreen-space (CSS px, y-up) placement of one 2D rect after snapping — see rectScreenGeometry.
RegisteredFontFaceOne registered font file (one face of a family).
RegisterFontOptions-
RenderLoopEvents-
RenderLoopOptions-
RenderRootEvents-
RenderRootOptions-
ResolvedFontFaceA registered face chosen for a font request (see resolveFontFace).
ResourceManagerReference-counted registry for GPU resources shared across primitives and charts (unit quads, colorscale LUT textures, glyph atlases, material variants).
ResourceStat-
RotatedBoxA rotated rectangle: center, half sizes, clockwise angle in degrees.
ScreenPoint2DA point in container px.
SegmentEndPer-end data handed from the vertex to the fragment stage.
SegmentFrameEverything the fragment stage needs for one segment (screen px).
SphereDataData of a SphereSet. Every field is optional in updates.
SphereLightingKey light (view space) and material response.
SphereSetInstanced lit sphere impostors (see the module docs): one draw call, pickCount = number of spheres, pick ids are data indices.
SphereSetOptions-
SymbolDefGeometry of one base symbol.
TextConfigGlobal text-rendering configuration (wraps troika's configureTextBuilder).
TextDataData for TextPrimitive.
TextDecorationLinesDecoration lines of a label (parseLinePosition).
TextFontA font request: CSS family list, size in CSS px, weight, and style, plus Plotly's paint-level font attributes (variant, textcase, lineposition, shadow).
TextLabelOne label. Position is in DATA space (see DataTransform); JS numbers are float64.
TextLinkA clickable link of a run (<a href target> in Plotly text).
TextLinkPointerEventThe parts of a pointer event (the runtime's ComponentPointerEvent) link handling uses.
TextMeasurerLow-level measuring backend: widths and vertical metrics at a font size of 1 px. Results are cached by the oracle, so implementations need not cache.
TextOutlineGlyph outline / halo / shadow (troika's outline pass: one extra draw call when any is set).
TextPrimitiveOptions-
TextRunOne styled run of a rich label. Fields left unset inherit from the label (font fields, color); decoration lines add to the label's font.lineposition.
TextRunBaseBase style a run layout is computed against (the label's resolved style).
TextRunLayoutResult of layoutTextRuns.
TextRunLayoutItemOne positioned run of a TextRunLayout. Coordinates are px, +x right, +y up.
TextRunWrapOptionsOptions of wrapTextRuns.
TextShadowA parsed text shadow (parseTextShadow), lengths in px.
TextStyleStyle shared by all labels (TextData.style) and overridable per label.
TextTransformHow text and size change for a font's textcase and variant (see resolveTextTransform).
ThrottleClockMinimal clock abstraction so createThrottle is testable with fake timers.
TransformUniformsUniforms shared by every primitive's vertex shader (see TRANSFORM_GLSL).
View3DAnglesThe angles of a 2.5D view (layout.view3d).
View3DCameraThe camera of a 2.5D view (world = the viewport's world, CSS px).
View3DProjectorSee the module comment.
ViewLightsLights in view space, as the Plotly shader reads them (see mesh.glsl.ts).
ViewportHostHooks a viewport needs from its render root.
ViewportOptions-
ViewportProjectorA 2.5D view of a 2D viewport (see the module comment): its camera draws instead of the flat one, and it converts container CSS px (top-left origin) between the flat plot plane (z = 0, as the flat view shows it) and the screen.
ViewportRectRectangle in CSS px. Top-left origin unless stated otherwise.
ViewportSizeViewport information a primitive needs for screen-space sizing.
ViewportUniformsUniforms for screen-space sizing (see SCREEN_GLSL).

Type Aliases ​

Type AliasDescription
Blend3DHow a 3D primitive blends: from its data ('auto'), or forced.
ColorInput-
ColorscaleOrdered list of stops (Plotly colorscale after color parsing). At least one stop.
ColorscaleInterpolationColor space in which colorscale stops are interpolated.
ColorscaleStopA colorscale stop: position in [0, 1] and an sRGB 0–1 RGBA color.
DepthCoefficientsdepth = k[0]·x + k[1]·y + k[2]·z + k[3] (view-space z; larger is nearer the camera).
ExtrusionModuleThe lazily loaded 2.5D module (extrusion-lazy.ts).
FillGradientDirectionDirection of a fill gradient (Plotly fillgradient.type).
FillPaintHow the polygons are painted.
FillRuleHow rings combine into a filled region.
FontWeightFacesA URL, or per-style URLs, for one weight in FontFamilyFaces.weights.
HeatmapInputRequired fields of HeatmapData; the rest have defaults.
HeatmapSampleInputFields sampleHeatmap reads.
HeatmapSmoothingPlotly zsmooth: false = nearest cell, 'fast' = index-space, 'best' = data-space bilinear.
ImageFitHow the image fills its box: Plotly sizing 'contain' → 'contain', 'fill' → 'cover', 'stretch' → 'stretch'.
ImageSourceLikeAnything texImage2D accepts, with its pixel size. WebGL ignores the flip / premultiply pixel-store flags for ImageBitmap, so create bitmaps with imageOrientation: 'flipY' and premultiplyAlpha: 'premultiply'.
ImageStatusLoad status of an ImagePrimitive.
LiftedPrimitivePrimitives drawn over extruded shapes (labels, error bars), or layers of them.
LightSpaceWhere a directional light's position is given.
Line3DDataData of a Line3D: the 2D line's fields (x, y, z, starts, connectGaps, color, width, dash, join, cap, miterLimit, opacity; see LineData). z is optional (0).
LineCapCap style at polyline ends (and at dash ends).
LineDashA dash specification: a named style, a Plotly/SVG dash-array string ('5px,10px,2px', '5,10', '2%,1%'), or an explicit list of on/off lengths in CSS px.
LineJoinJoin style between consecutive segments.
LinesMarkers3DModuleThe lazily loaded 3D module (lines-markers-3d.ts).
LineStepWhat writeLinePoint did with an input point: None (dropped: an exact duplicate of the previous point, or a gap skipped by connectGaps), Vertex (written as a valid vertex) or Gap (wrote, or collapsed into, a sentinel).
MarkerMatrixStylePer-point style shared by every cell (everything of MarkerData but positions).
MarkerPatchFields accepted by MarkerSet.patch (arrays indexed from the patch start).
MeshColorSourceWhere a mesh's colors come from, in Plotly's precedence (mesh3d convert.js): intensity (per vertex or per cell), then per-vertex colors, then per-face colors, then one color.
MeshIndexArrayTriangle indices: three per triangle.
MeshInputRequired fields of MeshData; the rest have defaults.
MeshMaterialTypetrace.material.type.
MeshModuleThe lazily loaded mesh module (mesh-lazy.ts).
MeshPickElementHow generic meshes are resolved (WebGL2 has no gl_PrimitiveID, so triangles are derived from gl_VertexID): - object: one id per mesh (default for plain meshes), - instance: gl_InstanceID (default for InstancedMesh), - vertex: the provoking vertex (the LAST vertex of the rasterized triangle in WebGL). Its index is the geometry vertex index for both indexed and non-indexed geometry; for a grid surface it identifies one corner of the cell under the cursor, - triangle: floor(gl_VertexID / 3): exact for non-indexed geometry. Indexed geometry falls back to vertex (an indexed draw's gl_VertexID is the index value, not the draw position).
NamedLineDashNamed Plotly dash styles.
NumericArrayNumeric input accepted for coordinates. Float64Array is preferred (precision, ADR-008).
PatternAttributesPlotly's pattern attributes (marker.pattern, fillpattern) as in a full trace: shape, size and solidity (numbers), fgcolor and bgcolor (CSS colors) may be arrays (per item); fillmode ('replace'
PatternModuleThe lazily loaded half (pattern-code.ts).
PatternShapeA Plotly pattern shape.
PickElementKindWhat a hit refers to: - point: a data point (2D point source or instanced marker), - instance: an instance of a user InstancedMesh, - vertex: a mesh vertex (the provoking vertex of the triangle under the cursor), - triangle: a triangle of a non-indexed mesh, - object: the object as a whole (pointIndex is -1).
PickerAddOptionsOptions for Picker.add.
PickModeHover/pick modes: - closest: the single nearest hit within the radius, - all: every hit within the radius, nearest first, - x / y (2D only): per trace, the point nearest in x (or y) within the radius, sorted by that 1D distance (Plotly's hovermode: 'x'). 3D views treat them as closest: a GPU window cannot express "everything along a screen axis" (ADR-010).
PickRouteWhich implementation answers picks in a viewport.
PickTargetAnything that can be made pickable: - 2D: a PointSource2D, or a marker set (adapted with markerPointSource), - 3D: a pickable primitive (marker set) or any Object3D (its meshes are picked).
RasterInputRequired fields of RasterData; the rest have defaults.
RectBorderAlignWhere a rect's border sits relative to its geometric edge.
ResourceKind-
RGBAColors crossing the render boundary are sRGB 0–1 RGBA floats (i.e. CSS rgb() values / 255, alpha not premultiplied), packed 4 per item (Float32Array of length 4 * count), or a single [r, g, b, a] tuple applied to all items. Custom 2D shaders write these values straight to the sRGB output so chart colors match CSS exactly. Parsing CSS color strings is the job of the core/defaults layer, not the renderer.
ScalarInputA per-item numeric attribute: one value for all items, or one value per item.
ScreenMatrixMaps a float64 world position to CSS-pixel screen coordinates. m is a column-major 4×4 matrix (three.js Matrix4.elements) from world space to pixel clip space, i.e. viewport transform × projection × model-view; the result is divided by w.
SphereSizingHow size is measured (see the module docs).
SymbolInputSymbol per marker set or per item: names ('diamond-open') or Plotly numeric codes.
TextAnchorXHorizontal anchor: which side of the text block sits at the label position (Plotly xanchor).
TextAnchorYVertical anchor (Plotly yanchor): top/middle/bottom of the text block (line boxes), or baseline = the baseline of the first line (like SVG <text y>).
TextFaceA font face without size: what measurements are cached by.
TextFontLinePositionText decoration lines (Plotly font.lineposition): a flaglist of under, over, through joined by + (e.g. 'under+over'), or none.
TextFontRequestA family, weight and style to draw: what picks a font file.
TextFontStyleCSS font style. oblique is treated as italic.
TextFontTextCaseLetter case transform (Plotly font.textcase). word caps is CSS capitalize.
TextFontVariantCapitals variant (Plotly font.variant, CSS font-variant-caps). The SDF renderer approximates the small/petite caps variants (see resolveTextTransform in text-style.ts).
TextFontWeightCSS font weight: a number in 1–1000, or the normal (400) / bold (700) keywords.
TextModefixed: text lies in the world XY plane (2D charts). billboard: text faces the camera (3D).
TextOverflowWhat to do when a label exceeds maxWidth: - wrap: troika wraps at whitespace/hyphens (native, uses the real font file); - ellipsis: each line is truncated with … using the font metrics oracle before typesetting (approximate: the oracle's canvas/fallback metrics may differ slightly from the SDF font); - none: no wrapping, text may overflow.
TextRunLinesA label's runs: one array per line.
TextSizingscreen: font sizes and offsets are CSS px regardless of camera distance or zoom (scaled per frame). world: sizes are world units (in 2D pixel space the two are identical).
Vec3A float64 3-vector (origins and effective transforms are kept in float64 on the CPU).
ViewportKind-
ViewportSourceThe subset of WebGLRenderer that syncViewportUniforms reads (fakeable in tests).

Variables ​

VariableDescription
ARROWHEADSPlotly's arrowheads (annotations/arrow_paths.js) as polygons. 8, which Plotly's list does not define, is a bar across the arrow end.
ASSUMED_GPU_CAPABILITIESWhat holds on every WebGL 2 device at the size holochart was written against: used when the renderer cannot say (a test double) and by primitives constructed without capabilities.
browserFrameSchedulerThe browser's rAF. Resolved lazily so importing this module is safe outside the browser.
BUILTIN_FONT_CSS_FAMILYCSS family under which the built-in default font's faces (TeX Gyre Heros, or the app's configureText({ defaultFontFaces })) are registered as FontFaces once loaded, so the metrics oracle measures with them. Internal: not meant for figures.
CAP_CODE-
COLORSCALE_INTERPOLATIONSThe interpolation spaces, for validation and docs.
COLORSCALE_LUT_SIZENumber of texels in a colorscale LUT.
DEFAULT_FONT_CSS_FAMILYCSS family under which the app's default font (configureText({ defaultFontURL })) is registered as a FontFace, so the canvas metrics oracle can measure with it. Internal: not meant for figures.
DEFAULT_PICK_RADIUSDefault search radius (CSS px), matching Plotly's default hoverdistance.
END_BEVEL-
END_BUTT-
END_MITEREnd modes shared with the shader (vEndA.w / vEndB.w).
END_ROUND-
END_SQUARE-
fontsThe font registry as one namespace (plan E8.3, Holochart.fonts): register a family's faces, registerFace one file, resolve a CSS family list to a registered face, list the registered families, or clear the registry.
HEATMAP_MAX_SEARCH_STEPSBinary-search step bound for non-uniform edges: supports up to 2^24 cells per axis.
HEATMAP_TEXTURE_WIDTHRow width (texels) of the value and edge textures; rows wrap past it. Narrower on a device whose textures are smaller (context.capabilities.maxTextureSize).
IDENTITY_TRANSFORM-
JOIN_CODEShader uniform codes.
LINE_FRAGMENT_SHADER-
LINE_VERTEX_SHADER-
LineStepWhat writeLinePoint did with an input point: None (dropped: an exact duplicate of the previous point, or a gap skipped by connectGaps), Vertex (written as a valid vertex) or Gap (wrote, or collapsed into, a sentinel).
MARKER_DEFAULTSPlotly-like defaults (first colorway color, #444 lines).
MARKER_MATRIX_VERTEXThe marker vertex shader reading aX / aY columns instead of an interleaved aPos.
MARKER_SYMBOLSAll base symbols, indexed by base code.
MAX_DASH_ENTRIESMaximum number of on/off entries the shader supports (after odd-length doubling).
MAX_DEDICATED_CONTEXTSHow many roots get a context of their own under shared: 'auto' before later ones share. Low enough to leave room under the mobile limit of 8 for the shared context, exports and other WebGL content on the page.
MAX_PICK_IDLargest encodable pick id: 32 bits, minus the reserved background value 0.
MAX_PICK_RADIUSLargest supported pick radius (CSS px). Bigger requests are clamped.
MESH_PICK_FRAGMENT-
MESH_PICK_VERTEXGeneric mesh pick vertex shader. Defines select the element id: PICK_VERTEX, PICK_TRIANGLE, PICK_INSTANCE, or none (object-level).
OWN_EPSOffset (px) of the join ownership boundary; mirrors OWN_EPS in line.glsl.ts. Keeps the boundary off pixel centers so rounding differences between the two segments' tangents can't make both discard the same pixel (see the shader comment).
PATTERN_SHAPESPlotly's pattern.shape values; a shape's code is its index (0, '': no pattern).
PETITE_CAPS_SCALESize of approximated petite capitals relative to the font size.
PICK_ENCODE_GLSLvec4 holochartEncodePickId(uint id): the RGBA8 encoding of id + 1 (0 = background), with the same +0.25 byte bias as encodePickId so truncating and rounding float → unorm conversions both return the intended byte.
PIXEL_SCREEN_MATRIXThe screen matrix of the 2D pixel camera (ADR-008): world units are already CSS px.
QUAD_FRINGEHow far the quad of a segment extends past the stroke's sides, in units of the anti-aliasing ramp aa (one device px). Coverage is clamp(0.5 - d / aa, 0, 1) and d is at least the distance to the stroke's sides, so no pixel whose center is further than halfWidth + 0.5 * aa from the segment's axis is drawn; the other half is QUAD_SLACK. Mirrored in line.glsl.ts.
QUAD_SLACKRoom around the centers of the pixels a segment draws, in units of aa: half a device px. The canvas is multisampled, and a pixel at the edge of a quad is only written to the samples the quad covers; with half a pixel of room every sample of every drawn pixel is inside (4× and 8× sample positions lie within 0.47 px of the center). With less, joins show pin holes.
RASTER_FRAGMENT_SHADER-
RASTER_VERTEX_SHADER-
SCREEN_GLSLScreen-space helpers. "Screen" = CSS pixels from the viewport's bottom-left corner. Offsetting in clip space (hcOffsetClip) keeps sizes in px for both the 2D pixel ortho camera and 3D perspective cameras.
SMALL_CAPS_SCALESize of approximated small capitals relative to the font size.
SYMBOL_COUNTNumber of base symbols (55).
SYMBOL_VARIANTSVariant suffixes by variant index (code / 100).
symbolsCustom marker symbols (plan E8.11), exposed by the full bundle as Holochart.symbols.
TEXT_DEFAULT_FONTDefaults applied under TextStyle.font.
TEXT_DEFAULT_LINE_HEIGHTDefault line height as a multiple of the font size (shared with the text primitive).
TEXT_ELLIPSISThe ellipsis appended by FontMetricsOracle.ellipsize.
TRANSFORM_GLSLData → world → clip. Positions are RTC-encoded (local = data - origin), and uOffset already contains offset + origin * scale (computed in float64 on the CPU).
UNIT_QUAD_KEYKey under which createUnitQuadTemplate is shared in the ResourceManager.

Functions ​

FunctionDescription
acquireColorscaleTextureAcquire the shared LUT texture for scale (ref-counted; call release when done).
acquireInstancedGeometryPer-primitive instanced geometry that shares its per-vertex template (e.g. a unit quad) through the ResourceManager.
applyTextCaseApply a Plotly font.textcase: upper / lower (locale-independent toUpperCase / toLowerCase), word caps (the first letter of each word is uppercased, the rest left as is, like CSS capitalize), or normal / unset (unchanged).
applyTransformUniformsWrite transform (relative to origin) into the uniforms.
applyViewportUniforms-
arcBoundsTight bounding box [minX, minY, maxX, maxY] (px, relative to the center, y-up) of the unpadded annular sector — a superset of the padded / rounded wedge. Includes the four corners and every axis extreme of the outer arc that falls inside the span.
arcCountNumber of wedges described by the center arrays (the shorter one).
arcSDFSigned distance (px, negative inside) from a point at (px, py) px relative to the wedge center (y-up) to the wedge. CPU mirror of arcSDF in the fragment shader.
arrayPointSourceCreate a PointSource2D over x/y arrays (identity transform by default).
arrowGeometryThe arrow from tail to head (container px): it starts where it leaves box (plus startstandoff), ends standoff before the head, and is shortened further by each drawn head's back-off, so the heads' tips land exactly on the (stood-off) ends.
buildColorscaleLUTBuild the RGBA8 LUT for a colorscale: texel i holds the color at t = i / (size - 1), interpolated in space (default sRGB).
buildLineLayoutBuild the sentinel-separated vertex stream. Consecutive exact duplicates are dropped (a zero-length segment has no direction, which would break the joins on either side), runs of gaps collapse to one sentinel, and with connectGaps non-finite points are skipped entirely.
clearFontRegistryRemove every registered font (tests, hot reload).
colorAtColor of item i from a ColorInput, written to out (same padding rule as above).
colorscaleKeyResource key for a colorscale. Colors are quantized to 8 bits, as in the LUT.
colorscaleTCPU mirror of the shader mapping value → t ∈ [0, 1] for a resolved domain ([lo, hi] from resolveColorDomain). Returns NaN for non-finite values (drawn with the NaN color).
computeArcShapeResolve one wedge's d3.arc parameters into SDF parameters: swap radii if needed, apply the pad offset h = padRadius · sin(padAngle / 2) and clamp the corner radii (d3 rc, rc0, rc1). Returns null for wedges that draw nothing (non-finite input, zero span or radius, or padding that consumes the whole wedge).
computeDashDistancesCompute per-stream-vertex dash distances: [phase, segmentLength] pairs where phase is the cumulative screen-space length from the polyline (or post-gap) start modulo period, and segmentLength is the screen length of the segment leaving that vertex.
computeEndJoin/cap data at one vertex. dIn is the direction arriving at the vertex, dOut the direction leaving it; both segments sharing the vertex call this with the same arguments.
computeOriginRTC origin for a set of coordinate arrays: the center of each axis' finite range. Non-finite values (NaN gaps, ±Infinity) are ignored; axes with no finite value get origin 0.
computePickWindowFill out for a pick at CSS (x, y) with radius CSS px, in a view that renders into renderArea (CSS, top-left origin) clipped to scissor (or unclipped when null).
computeSegmentFrameVertex-stage mirror: build the frame of segment a → b given optional neighbors (screen px).
configureTextConfigure text rendering globally. Must run before the first label is typeset (troika ignores later calls and warns). Does not load the text engine: before it has loaded, the configuration is kept and applied when it loads.
countLineStreamExact number of stream vertices buildLineLayout writes for input.
createArcPrimitiveCreate an ArcPrimitive.
createCanvasTextMeasurerCanvas 2D measurer, or null when no canvas with a 2D context exists (node, jsdom without the canvas package). Vertical metrics come from fontBoundingBoxAscent/Descent (the font's line metrics) and fall back to Arial-like ratios where unsupported.
createColorscaleTextureCreate a LUT texture (not cached; prefer acquireColorscaleTexture).
createFallbackTextMeasurerDeterministic measurer: Helvetica-like per-character widths, no kerning, bold ≈ 5% wider, italic same as upright. Identical results on every platform, which makes layout unit tests stable.
createFillPrimitiveCreate a FillPrimitive (optionally drawing into mesh, see its constructor).
createFontMetricsOracleCreate an oracle. Most code should use getDefaultFontMetricsOracle.
createGpuPickerCreate a GPU picker for one 3D view (plan E2.13). See GpuPicker.
createHeatmapAxisValidate the first n + 1 edges and build a HeatmapAxis. Returns undefined for fewer than one cell, missing / non-finite edges, or edges that are not strictly monotonic.
createHeatmapPrimitiveCreate a HeatmapPrimitive.
createImagePrimitiveCreate an ImagePrimitive.
createLazyFillPrimitiveCreate a LazyFillPrimitive.
createLazyMeshPrimitiveCreate a LazyMeshPrimitive.
createMarkerMatrixCreate a scatter-plot-matrix marker store (plan E10.9); see MarkerMatrix.
createMarkersCreate a marker set (plan E2.4). Add markers.object to a viewport via viewport.add(markers).
createPickerCreate the unified picker for a render root (plan E2.13).
createPickWindowA zeroed PickWindow to pass to computePickWindow.
createPrimitiveMaterialDefault material for 2D/3D chart primitives: GLSL3 (in/out, declare out highp vec4 fragColor; in the fragment shader), straight (non-premultiplied) alpha blending, depth test on so 3D scenes occlude, depth write off so anti-aliased fringes never punch holes. Colors are written unconverted: inputs are already sRGB (see types.ts).
createRasterPrimitiveCreate a RasterPrimitive.
createRectPrimitiveCreate a RectPrimitive.
createRenderRootCreate a render root inside container (plan E2.1).
createResourceManagerCreate a reference-counted GPU resource registry (plan E2.15).
createTextPrimitiveCreate a TextPrimitive and apply initial data.
createThrottleLeading + trailing throttle: the first request after an idle period runs immediately; requests inside the interval coalesce into one trailing run, so the final state is always computed.
createTransformUniforms-
createUnitQuadTemplateA unit quad template: position.xy in {0,1}², two triangles. Used for instanced rects/arcs.
createViewportUniforms-
cssFontFamilyCanonical CSS family list: names quoted unless they are generic keywords, e.g. 'Open Sans, sans-serif' → '"Open Sans", sans-serif'. An empty list yields sans-serif.
cssFontStringCSS font shorthand for canvas ctx.font, e.g. 'italic 700 12px "Open Sans", sans-serif'. size overrides font.size (the metrics oracle measures at a fixed reference size).
customMarkersReadyResolves once every symbol registered and image requested so far is in the atlases (or failed). The same promise until new work arrives.
dashDependsOnViewportTrue when the dash spec depends on the viewport size (percentage entries).
dashDistanceSigned distance (in pattern units) from along to the nearest "on" interval of the repeating pattern — negative inside a dash. CPU mirror of hcDashDistance in line.glsl.ts.
dashPeriodSum of a resolved pattern (the period of the dash phase).
decodePickIdDecode a pick id from read-back RGBA bytes (0–255). Returns -1 for the background (all zero).
dedicatedContextCountLive roots that own a WebGL context (those created with holochart's default renderer).
defaultFontFaceThe face of the built-in default font that draws a request: undefined when the family is registered or the app set a default font URL. Unregistered families (e.g. 'Helvetica Neue', Helvetica, Arial, sans-serif) are drawn with the built-in font's face closest to the requested weight and style (CSS matching, fontWeightRank): 400/700 × upright/italic.
defaultFontFacesPendingWhether some request could still need a built-in face to load: false once every face has loaded (or failed, unless retryFailed), or while the app's default font URL replaces them. A cheap check that lets callers skip collecting requests for loadDefaultFontFaces.
densifyColorscaleBake an interpolation space into a colorscale: sub-divide every segment between stops (about resolution segments over the whole 0–1 span, at least one per segment) with colors mixed in space, so plain sRGB interpolation between the new stops follows the space's curve (within about 1/255 at the default resolution). Hard steps (equal positions) stay hard. 'rgb' returns the scale unchanged.
effectiveMeshElementThe element mode that actually applies to mesh (triangle ids need non-indexed geometry).
effectiveTransformThe transform actually applied in shaders to RTC-encoded positions: world = local * scale + offset, where offset = transform.offset + origin * transform.scale is computed in float64 so precision is lost only after the (small) subtraction.
ellipsizeFontMetricsOracle.ellipsize on the default oracle.
encodeFillPositionsWrite RTC float32 positions (position - origin, xyz per vertex) for the GPU (plan §E16.4). out is reused when it is large enough.
encodePickIdEncode a pick id as normalized RGBA floats (0–1), e.g. for a custom pick material's color uniform. Output order is R, G, B, A with R the most significant byte of id + 1.
expandColorExpand a ColorInput into 4 * count floats. A tuple is broadcast; a Float32Array shorter than 4 * count is padded by repeating its last complete color (or transparent black when empty), so a partially-streamed color array never reads garbage.
expandScalarExpand a ScalarInput into count floats. A number is broadcast; a short array is padded with its last value (or fallback when empty).
extrudeDomainA domain trace view's hook (pie, treemap, icicle; plan E8.9, E9.12; the full bundle's wrapper calls it): after every update of the trace's own view, with the primitives it has added and, for pies, the item of each slice (items, for per-slice depth). Once the 2.5D and mesh chunks have loaded it is syncDomain (extrusion-domain.ts); before, a trace with depth or tilt starts the load behind a placeholder (see extrudeRects).
extrudeFillsA scatter view's hook for filled areas as slabs (plan E8.9; syncExtrudedFills once loaded, see extrudeRects): call it after every update of the view with the primitives it has added (removed ones are skipped): its fill is extruded, the others are drawn on the slab's front. Waits for the fill's own code too. view keys the view's extrusion primitive.
extrudeHeatmapA heatmap view's hook for cells as columns (plan E8.9; syncHeatmapColumns once loaded, see extrudeRects): call it after every update of the view's heatmap (undefined when it draws none), with lift (the cell labels). view keys the view's extrusion primitive.
extrudeRectsA trace view's hook for extruded rects (plan E8.9, E9.10; bars install it with setBarExtruder): call it after every update of rects with the data just given to them (and host.lift, more primitives to lift: bar-like traces' connectors). Once the 2.5D and mesh chunks have loaded it is syncExtrudedRects, which creates, updates or (for a trace without depth) removes the extrusion primitive of rects — the flat rects are hidden while it draws them — and lifts lift (labels, error bars) onto the front faces. Before, a trace with depth starts the load and adds a placeholder primitive whose ready covers it (so chart.ready and image export wait), then draws with the loaded code.
extrusionModuleLoadedThe 2.5D module if it has loaded, else null (synchronous paths).
fadeTextRunsRuns with the alpha of their own colors multiplied by alpha (runs without one follow the label).
fallbackCharWidthWidth in em of one code point in the fallback table.
fillLineColorsFill per-stream-vertex RGBA colors from per-input-point colors (sentinels get zeros).
fillLineWidthsFill per-stream-vertex widths. The segment from stream vertex v to v + 1 uses the width of v's source point, i.e. input width[i] styles the segment leaving point i.
fillPrimitiveLoadedWhether the fill code has loaded (for tests and diagnostics).
fillProjectionAxesChoose the two axes to triangulate a (possibly 3D) planar polygon in: the axis most aligned with the Newell normal is dropped, so vertical fills in 3D (e.g. an area in the x–z plane) do not collapse. Returns [0, 1] (x, y) for 2D input or degenerate normals.
fitImagePure fit math in world px: the quad to draw and the texture sub-rect (uv 0–1, v up = image top at v=1 with flipY) to sample. Returns undefined for an empty box or zero natural size.
fitsTextureWhether a width × height texture (× depth for a 3D one) fits the device. When it does not, warns once per what and size, naming the limit; the caller then draws nothing.
fontWeightRankRank of a face weight for a requested weight, following the CSS Fonts 4 matching order (lower is better): exact match; for 400–500 then heavier up to 500, lighter, heavier beyond 500; for < 400 lighter first; for > 500 heavier first.
gatherPickHitsCollect the distinct pick ids in a read-back window. pixels holds win.size² RGBA8 pixels, rows bottom-up (as readPixels returns them). A pixel counts when it is not background, lies in the view's visible region, and its centre is within win.radius CSS px of the cursor (the pixel under the cursor always counts). Each id keeps its smallest distance; out ends sorted nearest first. maxHits stops after that many distinct ids in distance order (default: all).
getDefaultFontMetricsOracleThe shared oracle (canvas-backed in browsers, deterministic fallback elsewhere). Its cache is cleared whenever fonts change (registration, CSS font face loaded, document.fonts finished loading).
getDefaultFontURLThe app's default font URL, or undefined when the built-in default font applies.
handleTextLinkPointerPointer handling over a link, for handlePointer of component and trace views: move shows a pointer cursor, a primary click opens the link, and down / up / dblclick are taken so the gesture doesn't zoom, pan or toggle anything. Returns whether the event was handled (false without a link, and for wheel and leave).
hasDecorationLinesWhether any decoration line is set.
heatmapAxisCellCell containing directed coordinate a ∈ [0, extent] (mirror of hmCell): half-open [a_i, a_{i+1}), the last edge inclusive.
heatmapAxisEdgeDirected edge k of an axis (mirror of hmEdge).
heatmapAxisLerpInterpolation neighbors for directed coordinate a in cell (mirror of hmLerp).
heatmapCellIndexCell index of data value v for edges (both directions): −1 outside [first, last], for NaN, or for invalid edges. Cells are half-open in the edges' own direction, [e_i, e_{i+1}), and the last edge belongs to the last cell.
heatmapColorAtStraight-alpha sRGB color at data point (x, y) (without the LUT's 8-bit quantization), or undefined where transparent. Defaults as in createHeatmapPrimitive.
heatmapColorTColorscale position of v (mirror of the shader): clamp((v - zmin) / (zmax - zmin), 0, 1), 0.5 when zmax == zmin, flipped by reverse. NaN for non-finite v.
heatmapTextureSizeTexture size for count texels packed linearly with rows of at most maxWidth.
heatmapZRange[min, max] of the finite values among the first count of z; [0, 1] when none.
inHeatmapGapWhether directed coordinate a in cell falls in the gap strip: within gap / 2 px of either cell edge, with px = data distance × pxPerUnit (
inRotatedBoxWhether a container point lies inside a rotated box (with slop px of tolerance).
intersectRectIntersection of two rects (empty rects have zero width/height, never negative).
isColorscaleInterpolationWhether value names an interpolation space.
isCustomSymbolWhether value names a custom symbol: a registered name (with an optional variant suffix) or a text: glyph. The schema's marker.symbol accepts these besides Plotly's symbols.
isMarkerPositionsLikeWhether value looks like a marker set with CPU-readable positions.
isPointSource2DWhether value looks like a PointSource2D.
isUniformEdgesWhether the first n + 1 edges have equal widths: within 1e-9 relative, plus a few float64 ulps of the largest edge magnitude (so equal-width bins at large offsets, e.g. ms timestamps, qualify).
layoutTextRunsLay out rich lines against a base style: every run's baseline origin relative to the label anchor, plus the block size. Empty lines still take a line advance.
lineCapacityRound capacities up to a power of two (at least 16).
lineCursorA cursor at the start of a new stream.
linesMarkers3DModuleThe 3D line and marker module if it has loaded, else null (synchronous creation paths).
loadDefaultFontFacesLoad the built-in default font faces that draw these requests and have not loaded yet (the regular face for plain text, bold or italic only when requested). Returns a promise that resolves once they have loaded (or failed: text then draws with troika's default font, and the error is logged once), or null when nothing needs loading. Each face is loaded once, and its load includes its CSS FontFace for the metrics oracle, so text measured afterwards uses it.
loadExtrusionModuleLoad the 2.5D code once: concurrent callers share the request; a failed load warns once and is retried by the next call.
loadFillTriangulationThe fill chunk's triangulateFills, for code that triangulates polygons without drawing a fill (GEO8: the globe's sphere meshes, in another package's lazy chunk). triangulateFills is also a synchronous export of the package, but importing that from lazy code makes a bundler keep earcut and the fill-rule code in the app's initial chunk (7 kB gzipped). Through here they stay in the one fill chunk, which is loaded once, as for a fill. Rejects when the chunk cannot be loaded; the next call tries again.
loadLinesMarkers3DLoad the 3D line and marker code once (concurrent callers share the request; a failed load is retried by the next call).
loadMeshModuleLoad the mesh code once (concurrent callers share the request; a failed load is retried).
loadPickercreatePicker, from the picker chunk. Concurrent callers share the request. Rejects when the chunk cannot be loaded; the next call tries again.
lutCoordTexture coordinate for t ∈ [0, 1] so that t = 0 and t = 1 hit the centers of the first and last texels exactly (mirrors the shader).
markerPointSourceAdapt a MarkerSet as a 2D point source. It indexes the RTC positions exactly as drawn (so patch() streaming is covered) and follows setTransform live through the world scale/offset.
measurementFaceThe face to measure a font request with, i.e. the font troika will draw it with (plan E2.18):
measureTextFontMetricsOracle.measureText on the default oracle.
meshModuleLoadedThe mesh module if it has loaded (else null).
meshPickCountNumber of pick ids a mesh needs for element (see effectiveMeshElement).
mixColorsMix two sRGB 0–1 colors at t ∈ [0, 1] in space (alpha linearly). Endpoints are exact: t = 0 gives a and t = 1 gives b in every space.
normalizeFontStyleNormalize a CSS font style (anything but italic/oblique → normal).
normalizeFontWeightNormalize a CSS weight keyword or number to a number in [1, 1000] (invalid → 400).
openTextLinkOpen a link like Plotly's SVG <a>: in target (default _blank), without an opener.
orthoFrustumOrthographic frustum for a 2D viewport whose world origin is the bottom-left of rect (1 unit = 1 CSS px) while GL draws into area (both top-left-origin container rects).
packArcCentersPack RTC centers (relative to the center of their finite bounding box).
packArcsConvenience: pack everything for data (used by tests and tooling).
packArcShapesResolve every wedge's shape (computeArcShape) and bounds (arcBounds) into the iShape / iCorner / iBounds layouts. Wedges with a non-finite center or an empty shape get zero bounds, which the vertex shader culls.
packHeatmapEdgesPack both axes' directed edges into the R32F layout: x edges at texels [0, nx], y edges at [yBase, yBase + ny] with yBase = nx + 1, wrapping rows past maxWidth.
packHeatmapValuesPack values into the R32F layout: texel k = j * nx + i at (k % width, floor(k / width)) holds z[k] - zOrigin, or the largest float32 (3.4028235e38, a hole) for non-finite / missing values and padding texels. out is reused when it has the right length.
packRectsPack rect corners relative to a float64 origin (the center of the finite bounding box of both corners), so float32 deltas stay precise for large coordinates such as ms timestamps.
parseFontFamilyListSplit a CSS font family list into unquoted names, e.g. '"Open Sans", arial' → ['Open Sans', 'arial']. Commas inside quoted names are not supported (none of the common font names contain them).
parseLinePositionParse a Plotly font.lineposition flaglist ('under', 'over+through', 'none', …). Unknown flags are ignored; none, empty, or unset means no lines.
parseShadowColorParse a CSS color to sRGB 0–1 RGBA: #rgb, #rgba, #rrggbb, #rrggbbaa, rgb()/rgba() (comma or space separated, numbers or percentages, / alpha), and a few names (black, white, transparent, gray/grey, …). Returns null for anything else. Kept small on purpose: render cannot depend on d3-color, and shadows rarely use exotic colors.
parseTextShadowParse a CSS text-shadow (the first shadow of a list): two or three lengths (offsetX offsetY [blur], in px, unitless, em, or rem) and an optional color before or after them. A missing color is the text color (currentColor); an unknown one is black.
patternsReadyResolves once every pattern requested so far is drawn (or its code failed to load). The same promise until new work arrives.
pickProjectionNarrow projection onto the pick window: out = T × projection, where T scales and translates clip-space x/y so the window's device pixels fill NDC [-1, 1]². Depth is untouched, so the pick pass depth-tests exactly like the visible frame. Equivalent to camera.setViewOffset(vw, vh, …, size, size) but works for any camera (and camera that already has a view offset) without mutating it. out may alias projection.
pickRouteForADR-010: CPU spatial indexes for 2D viewports, GPU ID picking for 3D viewports.
pointInPolygonEven-odd (crossing number) point-in-polygon test.
preloadFillPrimitiveStart fetching the fill code without drawing anything, e.g. in parallel with loading data, so the first fill appears without the extra round trip. LazyFillPrimitive loads it on its own; charts without fills never load it.
preloadTextEngineStart fetching the SDF text engine without typesetting anything, e.g. in parallel with loading data, so the first labels appear without the extra round trip. Text primitives load it on their own when they first get labels; charts without any text never load it.
preloadTextFontLoad a font and pre-generate glyph SDFs (e.g. digits for tick labels) so the first frame with text does not stall. Resolves the family through the font registry, else the default font (no family: the default font's face for the weight and style). Loads the text engine and the default font face first if needed.
premultiplyPixelsPremultiplied RGBA8 copy of pixels (the texture layout). Missing trailing bytes are transparent. out is reused when it has the right length.
presentedCanvasThe on-page canvas a renderer is drawing for: the root's own canvas under a shared renderer, renderer.domElement otherwise. Use it instead of renderer.domElement for anything that needs the visible element (visibility observers, layout).
quadReachHow far the quad of a segment reaches beyond a vertex along the segment's axis (px): far enough for every pixel the segment draws there, and no further (mirror of the shader's computeEnd return value).
readGpuCapabilitiesAsk the renderer's context for its limits (a lost context answers null: the assumption).
rectCountNumber of rects described by the coordinate arrays (the shortest one).
rectCoverageCPU mirror of the fragment shader: anti-aliased coverage at screen point (px, py) (CSS px) for a rect placed by rectScreenGeometry. The AA ramp is one device pixel centred on the edge.
rectScreenGeometryCPU mirror of the vertex shader for an axis-aligned (2D) projection: given the projected corners (sx0, sy0) and (sx1, sy1) in CSS px, apply border rounding and pixel snapping.
registeredFontFamiliesNames of the registered families (as first registered), in registration order.
registerFontRegister a font file for a family/weight/style. Registering the same family/weight/style again replaces the URL. Returns a function that unregisters the face.
registerFontFamilyRegister several faces of one family at once (plan E8.3: fonts.register('Inter', { regular, bold, italic })). Each face goes through registerFont, so troika resolution and the metrics oracle's CSS FontFace registration both apply. Returns a function that unregisters every face registered by this call (faces replaced by a later registration are left alone).
renderAreaForThe rect GL renders into for a viewport: its own rect for clipped 2D and all 3D viewports, the whole canvas for 2D viewports that may overflow their rect.
renderedTextFaceThe measured face for a request: what troika draws (measurementFace).
reportUserErrorReport an error thrown by user code (an event listener or a callback) without interrupting the chart (S1.7): reportError where available, so the console and error trackers see it as uncaught, else a rethrow on a microtask.
resolveColorDomainResolve the color domain (Plotly semantics): when cmid is set, cmin/cmax are widened so they are equidistant from cmid. A degenerate or non-finite domain falls back to a unit span so the shader never divides by zero.
resolveDashPatternResolve a dash spec to on/off lengths in CSS px. Returns an empty array for a solid line.
resolveDrawnFontURLThe font file troika draws a request with: the registered face's URL, else the built-in default font's face once loaded (loadDefaultFontFaces). While that face has not loaded (or failed to), the closest built-in face that has loaded stands in, so troika never falls back to its CDN font for a whole label (the text primitive waits for the faces it needs, so this only covers empty labels and failed loads). undefined means "troika's default font": the app's defaultFontURL, or no built-in face loaded yet.
resolveFontFaceResolve a CSS family list to a registered face: the first registered family in the list wins, then the best face by style (exact, else the other style) and weight (fontWeightRank). Returns undefined when no family is registered, meaning "use the default font" (see resolveDrawnFontURL).
resolveFontURLResolve a CSS family list to a registered font URL (resolveFontFace). Returns undefined when no family is registered, meaning "use the default font" (resolveDrawnFontURL also resolves the built-in default font).
resolveSymbolResolve a Plotly symbol (name like 'diamond-open-dot', numeric code, or numeric string) to its numeric code. Unknown symbols resolve to 0 (circle), like Plotly's fallback. Registered custom symbols (symbols) and text: glyphs resolve to internal codes of 1000 and up (custom.ts).
resolveTextTransformThe text transform and size scale for a font's textcase and variant, applied in that order (CSS applies text-transform before font-variant-caps).
rotatedBoxCornersThe 4 corners of a rotated box (clockwise from top-left), optionally inset.
rotatedBoxExitWhere a ray from from in direction d (unit) leaves the box: the parameter of the exit point, or 0 when from is outside the box.
rotateScreenPointRotate a screen vector clockwise by deg (screen y points down).
roundedRectSDFExact signed distance from (px, py) to a rounded rect centred at the origin with half extents (hx, hy) and corner radius r (≤ min(hx, hy)); negative inside. Mirror of the GLSL version.
sampleColorscaleSample a colorscale at t ∈ [0, 1] (clamped) with linear interpolation (in space, default sRGB). CPU mirror of the LUT (without 8-bit quantization), for legends, colorbars, and hover labels.
sampleHeatmapThe value the shader colors at data point (x, y) (linear data coordinates), or NaN where the fragment is transparent: outside the edges, on a non-finite cell, in a gap, or for invalid data. transform only matters for gaps (px per data unit); default identity.
sampleHeatmapAxessampleHeatmap with prebuilt axes (for repeated lookups, e.g. hover).
scalarAtValue of item i from a ScalarInput (same padding rule as expandScalar).
scaleTextRunsRuns scaled by k (a label shrunk to fit, or resized by uniformtext): run sizes and baseline shifts are absolute px, so they scale with the label's font.
scissorForThe scissor rect (top-left origin), or null when the viewport is not clipped.
segmentDistanceFragment-stage mirror: signed distance (px, negative inside) from p to this segment's share of the stroke, or undefined when p is owned by a neighbouring segment.
setDefaultFontFacesReplace the files of the built-in default font (TeX Gyre Heros, shipped with Holochart) with the app's own, e.g. the same OTF files self-hosted, so no data: URL or blob: URL is involved. Faces are picked by weight and style like a registered family's (resolveFontFace), and loaded only when text needs them. null restores the shipped files. configureText calls this.
setDefaultFontMetricsOracleReplace the shared oracle (e.g. force the deterministic fallback for reproducible layout); null resets to lazy creation of the default.
setDefaultFontURLRecord the app's default font URL (troika's defaultFontURL, used for every unregistered family) and register it as a CSS FontFace under DEFAULT_FONT_CSS_FAMILY (browsers only), so text is measured with the font that is drawn. configureText calls this; call it directly only when configuring troika yourself. While set, the built-in default font is not used. null forgets it (the built-in default font applies again).
setShadersSet a material's shaders (recompiling only when they changed).
snapRectSpanSnap a screen-space span [a, b] (either order) to the device-pixel grid. A non-empty span never collapses: it keeps at least one device pixel. Mirror of snapSpan in the vertex shader.
snapToDevicePixelSnap a CSS-pixel coordinate to the device-pixel grid (phase 0 = pixel edges, 0.5 = pixel centers). CPU mirror of hcSnap in SCREEN_GLSL, used by tests.
subscribeFontChangesSubscribe to font changes (registrations, CSS font faces finishing loading). Used by the default font metrics oracle to drop measurements taken with a fallback font. Returns an unsubscribe.
symbolNameName for a numeric code (inverse of resolveSymbol).
syncInstancePatternDraw the pattern() of the instanced rect or arc mesh (per-instance attributes for its count() instances and the pattern shaders, once the code is in), or go back to the plain shaders without one. The getters are read when the work runs, so a pattern replaced or removed (or a primitive disposed: pattern() null) while the code loads is never drawn.
syncViewportUniformsMake viewport uniforms match what the renderer is actually drawing into. Primitives call this from onBeforeRender, so it runs for every draw with the GL viewport already set.
textContrastColorThe color with the most contrast to color: white for dark colors, black for light ones.
textFaceKeyCache key for a face (size-independent).
textLinkAtThe link under a point, for pointer handling: dx, dy are the point's offset from the label anchor in screen px (+y down), before the label's offset and rotation (angle, degrees clockwise) are undone here. null when no linked run is there.
textRunFontThe font a run is drawn with: base with the run's overrides; decoration lines are merged.
toDeviceGLRectConvert a CSS rect (top-left origin) to a device-px GL rect (bottom-left origin) the way three.js setViewport/setScissor do: flip against the CSS canvas height, scale by DPR, round.
toGLRectConvert a top-left-origin rect to GL's bottom-left origin (still CSS px).
triangulateFillsTriangulate every polygon and merge the result into one indexed triangle list. origin (optional) is subtracted from coordinates before triangulating, which keeps earcut's cross products well conditioned for large values such as ms timestamps; output positions are absolute either way.
windowPixelDistanceCSS distance from the cursor to the centre of window pixel (i, j) (row from the bottom). The pixel under the cursor is distance 0: whatever is drawn there is under the pointer.
windowPixelVisibleWhether window pixel (i, j) (column from the left, row from the BOTTOM, as read back) lies in the view's visible region.
withPatternsRun work with the pattern code: at once when it has loaded, else once it has (patternsReady covers it). Never rejects: a failed load is reported.
wrapTextFontMetricsOracle.wrapText on the default oracle.
wrapTextRunsWord-wrap rich lines to maxWidth px: Plotly's wrapText (table cells) made run-aware, so rich labels can wrap like plain ones.
writeFillColorsExpand per-polygon colors to per-vertex RGBA (4 floats per vertex) using the triangulation's vertexStarts. This is the whole cost of a color-only update: no re-triangulation.
writeFillGradientPer-vertex gradient coordinates (2 floats per vertex) for the fill shader, from the absolute triangulated positions (xyz per vertex). Linear: (t, 0) with t = (c − start) / (stop − start) along the gradient axis. Radial: the position normalized to the bounding box of all vertices ([0, 1]²); the shader measures t from the box center, so the gradient is an ellipse spanning the box (SVG objectBoundingBox semantics, as Plotly draws it). Both are affine in the position, so per-vertex interpolation is exact and zoom/pan never rewrite them.
writeLinePointFeed input point (px, py, pz) with source serial serial to the builder: a valid vertex, a gap sentinel (non-finite, unless connectGaps), or nothing (exact duplicate of the previous point — a zero-length segment has no direction, which would break the joins on either side).
writeLineSentinelWrite a gap sentinel at the cursor unless the previous vertex already is one.

Released under the MIT License.