ntcharts3d

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 33 Imported by: 1

README

ntcharts3d - Nimble Terminal 3D Charts

Build Status Deploy to GitHub Pages Status Latest Release GoDoc Code Of Conduct

3D charts for Bubble Tea terminals and go-booba browser applications.

Live Demo (source)
gallery demo

import "github.com/NimbleMarkets/ntcharts3d"

One ntcharts3d.Model combines named scatter, surface, bar, line, vector-field, or custom series with a shared camera. Charts support orbit, pan, zoom, picking, color legends, hover highlights, fixed axis and color ranges, plot proportions, and in-chart axis labels with optional back-plane grids. Rendering uses go-gpuimage v0.1.0, with software and wireframe fallbacks. ntcharts handles terminal images and glyph output.

Install v0.2.2 with:

go get github.com/NimbleMarkets/ntcharts3d@v0.2.2

See the changelog, API guide, gallery instructions, transport diagnostic, and demo site.

Run locally

go test -race ./...
cd examples/gallery
go run .
# Shared memory requires a compatible local terminal:
go run . -medium shm

The gallery has scatter, surface, bar, textured map, and vector-field tabs. Run go -C examples/gallery run . -tab 4 -rotate=false from the root to try the map: t swaps imagery, f toggles flat/terrain, and l toggles lighting. Press v to switch legend modes, g to switch Kitty/glyph output, o to switch projection, and b for grid lines. Use PNG over SSH. Run with -tab 5 -rotate=false for swirling arrows and streamlines: n normalizes lengths, s toggles streamlines, and w changes stroke widths. See the gallery instructions for browser builds and all controls.

Development tasks

Install Task, then run tasks from the repository root. task builds the library and native examples into bin/.

Command Purpose
task list List all tasks
task ci Check formatting, modules, race tests, vet, and native/WASM builds
task test-gpu Run hardware GPU tests without the race detector
task gallery -- -render-mode software Run the gallery with flags
task transport -- -medium shm Run the transport diagnostic with flags
task go-tidy Update module files in all three modules
task build-web Compile both WASM examples and generate browser assets
task serve-gallery / task serve-transport Serve generated browser examples
task build-wasm-site / task serve-wasm-site Build and serve the Go/TinyGo demo page
task clean Remove compiled outputs, keeping browser assets

Builds and CI check module files without updating them. task build-web generates the browser assets bundled with go-booba v0.9.1, including Kitty shared-memory support. No local terminal asset overlay is needed.

GitHub Actions runs task ci on Linux and macOS for pushes and pull requests. Hardware GPU tests run separately with task test-gpu. WASM compilation does not verify browser rendering. A separate Pages workflow builds the gallery with Go and TinyGo and deploys from main. See the demo site instructions. The Pages gallery uses Kitty shared memory with the bundled terminal assets.

Dependencies

The library and both examples require Go 1.26.8 and pin NTCharts v2.8.0, which includes the Kitty transport APIs. No local NTCharts checkout is needed.

The gallery's ntcharts3d => ../.. replacement uses this repository directly. Both examples use go-booba v0.9.1 and its Bubble Tea WASM fork at c397c32a5074. The bundled ghostty-web assets support browser shared memory.

As of 2026-10-12, the latest go-booba release, v0.9.1, does not include the ghostty-web graphics pin introduced by 5b8e62a. The examples use v0.9.1; when a release includes that pin, update both modules and regenerate their browser assets with task web-assets.

Ownership

  • ntcharts3d: chart geometry, interactions, legends, and rendering.
  • go-gpuimage: GPU execution, textures, and readback.
  • ntcharts: terminal image transport and canvas.
  • go-booba and the browser terminal: WASM hosting and Kitty image display.

Extracted from ntcharts wgpu-shared-memory at 2ed8872. MIT license; existing copyright notices are preserved.

Documentation

Overview

Package ntcharts3d provides Z-up 3D charts for Bubble Tea. A Model combines named scatter, surface, bar, or custom series with one camera. Axes provide shared names, numeric ticks, categories, and optional fixed ranges. Charts support plot proportions, back-plane grids, and hover highlights.

A Palette supplies colors; a color domain maps values to those colors. A ColorLegend displays the mapping. RenderMode selects WebGPU, software, or wireframe rendering. ntcharts handles terminal image and glyph output.

Index

Constants

View Source
const (
	MaxMeshTriangles = (128 << 20) / 48 / 3
	MaxMeshIndices   = 3 * MaxMeshTriangles
)

MaxMeshIndices is the most indices a series' mesh may have, three to a triangle. The GPU renderer keeps a 48-byte record for each index, vertices shared or not, in a storage buffer; 128 MiB is the largest binding that WebGPU promises, and so the largest mesh that can be drawn wherever WebGPU can. MaxMeshTriangles is the same limit, counted in faces.

View Source
const MaxLineSegments = 512 * 512
View Source
const MaxPickPoints = 200_000
View Source
const MaxPoints = 500_000
View Source
const MaxVectors = 100_000

Variables

This section is empty.

Functions

This section is empty.

Types

type Arrow

type Arrow struct {
	Start, End      math3d.Vec3
	Width, HeadSize float32
	Color           color.RGBA
	Datum           int
}

Arrow is an unlit, screen-facing shaft and triangular head between two world positions. Width is in render pixels (zero defaults to 1). HeadSize is the head length in pixels, 0..64; zero draws only the shaft. Short projections shrink the head to at most 45% of the projected length. End-on arrows appear as a square of Width pixels. Datum identifies the original vector for picking.

type Axes

type Axes struct{ X, Y, Z Axis }

Axes configures the X, Y, and Z axes shared by all series.

type Axis

type Axis struct {
	Range      *Range // Optional fixed numeric bounds. Geometry outside them is clipped.
	Name       string
	Categories []string // Names at coordinates 0, 1, ...; at most 512 entries.
	TickCount  int      // Target numeric tick count, 2–64; zero uses five.
	// Format formats numeric tick values. It runs synchronously when a frame is
	// prepared and may run again after camera or size changes. Nil uses numbers.
	Format                                  func(float64) string
	Hidden, HideName, HideTicks, HideLabels bool
}

Axis configures one shared coordinate axis. The zero value shows a numeric axis with automatic ticks. An empty Name uses X, Y, or Z.

type AxisFrame

type AxisFrame struct {
	Name                                    string
	Ticks                                   []AxisTick
	Hidden, HideName, HideTicks, HideLabels bool
}

AxisFrame is a resolved axis for rendering. Tick labels are already formatted. Renderers must not mutate its ticks. Axes in Frame are ordered X, Y, Z.

type AxisTick

type AxisTick struct {
	Value float32
	Label string
}

AxisTick pairs a data coordinate with its display label.

type Bars

type Bars struct {
	NX, NY             int
	Values, ColorValue []float32
}

Bars holds a category grid stored by row. Values are signed heights from zero; Axis.Categories names the columns and rows. SetBars copies all slices.

type Box

type Box struct {
	Min, Size math3d.Vec3
	Color     color.RGBA
	Datum     int
}

type Camera

type Camera struct {
	Alpha, Beta, Distance float64
	Target                math3d.Vec3
	Projection            Projection
	AutoRotate            bool
	ResumeAfter           float64 // idle seconds before rotation resumes after input
}

Camera uses degrees for Alpha (elevation) and Beta (azimuth). Distance and Target use normalized units: geometry is centered at the origin and its longest extent spans two units.

func DefaultCamera

func DefaultCamera() Camera

DefaultCamera returns a Camera initialized with some typical default values.

func (Camera) Matrix

func (c Camera) Matrix(aspect float32) math3d.Mat4

func (Camera) RayFromCell

func (c Camera) RayFromCell(x, y, cols, rows, cellW, cellH int) math3d.Ray

RayFromCell returns a ray through a cell center, accounting for cell dimensions.

type ColorDomainSeries

type ColorDomainSeries interface {
	GeometryWithColorDomain(Palette, float32, float32) (Geometry, error)
}

ColorDomainSeries lets a custom Series map values against a shared color domain.

type ColorLegend

type ColorLegend struct {
	Label   string
	Min     float32
	Max     float32
	Palette Palette
}

ColorLegend describes a palette and its numeric range for rendering.

type ColorLegendMode

type ColorLegendMode uint8

ColorLegendMode selects a legend in the image or as terminal text beside it.

const (
	ColorLegendImage ColorLegendMode = iota
	ColorLegendText
)

type Emphasis

type Emphasis struct {
	Hidden    bool
	ShowLabel bool
	Color     color.Color // Nil uses orange.
}

Emphasis controls the foreground highlight for the hovered datum. The zero value draws a point ring or bar outline without a label.

type EmphasisFrame

type EmphasisFrame struct {
	Position math3d.Vec3
	Radius   float32 // Point radius in pixels, before the ring's padding.
	Box      *Box
	Label    string
	Color    color.RGBA
}

EmphasisFrame describes a resolved hover highlight. Box is nil for a point ring.

type Frame

type Frame struct {
	Width, Height   int
	Matrix          math3d.Mat4
	Revision        uint64
	TextureRevision uint64
	Bounds          math3d.AABB  // Plot bounds after fixed axis ranges.
	Axes            [3]AxisFrame // X, Y, Z; separate from cached series geometry.
	Geometry        []Geometry   // Clipped geometry; mesh normals account for plot proportions.
	GridLines       []Vertex     // Dynamic pairs of back-plane grid endpoints.
	Emphasis        *EmphasisFrame
	ColorLegends    []ColorLegend
	Background      color.RGBA
	Light           Light
	// contains filtered or unexported fields
}

Frame is a read-only snapshot. Mesh data changes only when Revision changes; materials may also change when TextureRevision changes.

type Geometry

type Geometry struct {
	UV            []UV      // One per vertex when textured.
	Material      *Material // Applies to indexed triangles only.
	Points        []Point
	Vertices      []Vertex
	Indices       []uint32
	Boxes         []Box
	Lines         []Vertex
	LineWidth     float32 // Render pixels for Lines; zero defaults to 1.
	Arrows        []Arrow
	Labels        []string
	Bounds        math3d.AABB
	ColorMin      float32
	ColorMax      float32
	HasColorRange bool
}

Geometry contains points, indexed triangles, boxes, line pairs, and arrow instances. Custom Series must not mutate geometry after returning it to the model.

type Grid

type Grid struct {
	Show  bool
	Color color.Color // Nil uses a muted gray.
}

Grid adds tick-aligned lines on the three faces behind the data. It is off by default.

type Light

type Light struct {
	Direction math3d.Vec3
	Ambient   float32
}

type Lines

type Lines struct {
	Start, End []math3d.Vec3
	Width      float32
	Color      []uint32
	ColorValue []float32
	Labels     []string
}

Lines contains independent Start/End pairs. Width is in render pixels (1..32); zero defaults to 1. Segments have butt caps and no joins. Repeat adjacent endpoints to form a polyline. Optional columns have one entry per segment. Color uses 0xRRGGBBAA (alpha ignored). Without Color, the palette maps ColorValue, or each segment's midpoint Z when ColorValue is absent.

type Material

type Material struct {
	Texture *Texture
	Unlit   bool
}

Material controls triangle appearance. Texture replaces vertex colors. Unlit preserves colors without applying the scene light.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is a Bubble Tea chart containing named series in a shared 3D space.

func New

func New(width, height int, opts ...Option) *Model

func (*Model) Axes

func (m *Model) Axes() Axes

Axes returns the current configuration with copies of its category slices.

func (*Model) Background added in v0.2.1

func (m *Model) Background() color.RGBA

Background returns the color behind the scene.

func (*Model) Bounds

func (m *Model) Bounds() math3d.AABB

Bounds returns the combined data bounds of the current series.

func (*Model) Camera

func (m *Model) Camera() Camera

func (*Model) Clear

func (m *Model) Clear() tea.Cmd

func (*Model) Close

func (m *Model) Close() error

Close releases GPU resources and pending shared-memory images. Call it after the Bubble Tea program exits. The GPU renderer waits for any active render.

func (*Model) ColorDomain

func (m *Model) ColorDomain() *Range

ColorDomain returns a copy of the fixed domain, or nil for automatic domains.

func (*Model) ColorLegendMode

func (m *Model) ColorLegendMode() ColorLegendMode

func (*Model) Emphasis

func (m *Model) Emphasis() Emphasis

Emphasis returns the current hover highlight settings.

func (*Model) Err

func (m *Model) Err() error

func (*Model) Grid

func (m *Model) Grid() Grid

Grid returns the current back-plane grid settings.

func (*Model) ID

func (m *Model) ID() uint64

func (*Model) Init

func (m *Model) Init() tea.Cmd

func (*Model) Pick

func (m *Model) Pick(x, y int) *PickMsg

Pick finds a datum at cell coordinates relative to the plot, or returns nil. Points use projected radii with a minimum tolerance based on cell size. Above MaxPickPoints total points, line segments, and arrows, only bars and surface vertices are tested. Lines and arrows use their projected strokes. Bars use ray/box intersections; surfaces use nearby grid vertices.

func (*Model) PictureMode

func (m *Model) PictureMode() picture.PictureMode

func (*Model) PlotAspect

func (m *Model) PlotAspect() math3d.Vec3

PlotAspect returns the configured relative plot lengths.

func (*Model) PlotBounds

func (m *Model) PlotBounds() math3d.AABB

PlotBounds returns data bounds with fixed axis ranges applied. Bounds returns the data bounds.

func (*Model) RenderMode

func (m *Model) RenderMode() RenderMode

RenderMode returns the active rendering mode, including automatic fallback.

func (*Model) RequestedRenderMode

func (m *Model) RequestedRenderMode() RenderMode

RequestedRenderMode returns the last selected mode, defaulting to WebGPU. Fallback does not change it.

func (*Model) SetAxes

func (m *Model) SetAxes(a Axes) tea.Cmd

SetAxes replaces the shared axes and copies category slices. Invalid settings leave the previous axes intact and set Err. Return the command from Update.

func (*Model) SetBackground added in v0.2.1

func (m *Model) SetBackground(c color.Color) tea.Cmd

SetBackground changes the color behind the scene and redraws it. It is WithBackground for a chart already made; the color is always opaque.

func (*Model) SetBars

func (m *Model) SetBars(name string, d Bars) tea.Cmd

func (*Model) SetCamera

func (m *Model) SetCamera(c Camera) tea.Cmd

func (*Model) SetColorDomain

func (m *Model) SetColorDomain(r *Range) tea.Cmd

SetColorDomain fixes the palette domain and clamps values to its endpoints. Nil restores automatic domains, respecting SetSharedColorDomain. Custom mapped series must implement ColorDomainSeries. The range is copied.

func (*Model) SetColorLegend

func (m *Model) SetColorLegend(title string) tea.Cmd

SetColorLegend sets the legend title. An empty title uses series names, or "value" for a shared domain. SetColorLegendVisible controls visibility.

func (*Model) SetColorLegendMode

func (m *Model) SetColorLegendMode(mode ColorLegendMode) tea.Cmd

SetColorLegendMode switches between image and terminal-text legends.

func (*Model) SetColorLegendVisible

func (m *Model) SetColorLegendVisible(visible bool) tea.Cmd

func (*Model) SetEmphasis

func (m *Model) SetEmphasis(e Emphasis) tea.Cmd

SetEmphasis replaces the hover highlight settings.

func (*Model) SetGrid

func (m *Model) SetGrid(g Grid) tea.Cmd

SetGrid replaces the back-plane grid settings.

func (*Model) SetLight

func (m *Model) SetLight(l Light) tea.Cmd

func (*Model) SetLines

func (m *Model) SetLines(name string, d Lines) tea.Cmd

SetLines copies all slices. Invalid input leaves the existing series intact.

func (*Model) SetPalette

func (m *Model) SetPalette(cs []color.Color) tea.Cmd

SetPalette copies color stops and recompiles series using the new palette. Empty palettes are ignored; invalid colors leave the existing data intact. Execute the returned command when calling this after Init.

func (*Model) SetPlotAspect

func (m *Model) SetPlotAspect(v math3d.Vec3) tea.Cmd

SetPlotAspect sets relative plot lengths, for example (1, 1, .5). All components must be positive and finite, or all zero to preserve data proportions.

func (*Model) SetRenderMode

func (m *Model) SetRenderMode(l RenderMode) tea.Cmd

SetRenderMode selects both the requested and active mode. Selecting WebGPU after fallback retries GPU initialization. Invalid modes are ignored.

func (*Model) SetScatter

func (m *Model) SetScatter(name string, d Scatter) tea.Cmd

func (*Model) SetSeries

func (m *Model) SetSeries(s Series) tea.Cmd

SetSeries compiles geometry synchronously. Call it before Init or from Update. A matching name replaces the existing series in place; a new name appends it. Providers must not mutate returned geometry. Err reports validation errors.

func (*Model) SetSeriesTexture

func (m *Model) SetSeriesTexture(name string, texture *Texture) tea.Cmd

SetSeriesTexture replaces the image of an already textured series without resampling or rebuilding its mesh. Invalid input leaves the series intact. Execute the returned command after Init. Err reports errors.

func (*Model) SetSharedColorDomain

func (m *Model) SetSharedColorDomain(enabled bool) tea.Cmd

SetSharedColorDomain maps series with color ranges against their combined minimum and maximum. Custom series must implement ColorDomainSeries.

func (*Model) SetSize

func (m *Model) SetSize(w, h int) tea.Cmd

func (*Model) SetSurface

func (m *Model) SetSurface(name string, d Surface) tea.Cmd

func (*Model) SetVectorField

func (m *Model) SetVectorField(name string, d VectorField) tea.Cmd

SetVectorField copies all slices and compiles GPU arrow instances. Camera changes do not rebuild or upload them. Return the command from Update.

func (*Model) Snapshot added in v0.2.0

func (m *Model) Snapshot(width, height int) (image.Image, RenderMode, error)

Snapshot draws the chart as it stands into an image of width by height pixels. It needs no terminal: the program need not be running, and the chart's size in cells plays no part. The picture's own shape sets the camera's aspect. Its area may not exceed 4096×2160 pixels.

The chart is drawn in its requested render mode, and the mode returned is the one that drew it. WebGPU falls back to software if the GPU is unavailable or fails, as it does for the terminal, but a snapshot's fallback does not change how the chart is drawn on screen. A software snapshot draws every point, triangle, bar, line, and arrow; frames for the terminal sample large series to stay prompt. Wireframe draws text, and has no image to give.

Snapshot returns when the image is drawn. Like the chart's other methods, it must not be called while another goroutine changes the chart.

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Model) View

func (m *Model) View() tea.View

type Option

type Option func(*Model)

func WithAutoRotate

func WithAutoRotate(on bool) Option

func WithAxes

func WithAxes(a Axes) Option

WithAxes sets the initial axes. Category slices are copied by New.

func WithBackground

func WithBackground(c color.Color) Option

func WithColorDomain

func WithColorDomain(r Range) Option

WithColorDomain sets a fixed domain for all palette-mapped series.

func WithColorLegend

func WithColorLegend(title string) Option

WithColorLegend sets the legend title. An empty title uses series names, or "value" for a shared domain.

func WithColorLegendMode

func WithColorLegendMode(mode ColorLegendMode) Option

func WithEmphasis

func WithEmphasis(e Emphasis) Option

WithEmphasis sets the initial hover highlight settings.

func WithGrid

func WithGrid(g Grid) Option

WithGrid sets the initial back-plane grid settings.

func WithKittyFormat added in v0.2.2

func WithKittyFormat(format picture.KittyFormat) Option

WithKittyFormat chooses the direct transport encoding. Zlib is the default; shared-memory frames use raw pixels regardless of this setting, and use the selected encoding when falling back to direct transport.

func WithKittyID

func WithKittyID(id int) Option

func WithKittyMedium

func WithKittyMedium(medium picture.KittyMedium) Option

func WithMaxPoints

func WithMaxPoints(n int) Option

func WithOrtho

func WithOrtho() Option

func WithPlotAspect

func WithPlotAspect(v math3d.Vec3) Option

WithPlotAspect sets relative X, Y, Z plot lengths. Zero preserves data proportions.

func WithProjection

func WithProjection(p Projection) Option

func WithRenderMode

func WithRenderMode(l RenderMode) Option

WithRenderMode selects the initial requested and active rendering mode. WebGPU is the default; invalid modes are ignored.

func WithRenderer

func WithRenderer(r Renderer) Option

func WithSharedColorDomain

func WithSharedColorDomain(enabled bool) Option

WithSharedColorDomain maps series with color ranges against their combined minimum and maximum. The domain updates when data or palettes change.

func WithZoneManager

func WithZoneManager(z *zone.Manager) Option

WithZoneManager uses a parent's zone manager. The parent must Scan its full View. By default, the chart owns a manager and starts at the terminal origin.

type Palette

type Palette []color.RGBA

Palette is a sequence of color stops, independent of a numeric color domain.

func (Palette) At

func (s Palette) At(t float64) color.RGBA

At interpolates the palette at t, clamped to [0,1]. An empty palette returns transparent black.

type PickMsg

type PickMsg struct {
	ModelID     uint64
	SeriesIndex int
	SeriesName  string
	Datum       int
	Position    math3d.Vec3
	Label       string
}

PickMsg identifies a clicked datum. SeriesIndex is the zero-based series position at the time of the pick. SeriesName comes from the setter or Series.Name.

type Point

type Point struct {
	Position math3d.Vec3
	Radius   float32
	Color    color.RGBA
	Datum    int
}

type Projection

type Projection uint8
const (
	Orthographic Projection = iota
	Perspective
)

func (Projection) String

func (p Projection) String() string

type Range

type Range struct{ Min, Max float32 }

Range is a fixed numeric interval. Min and Max must be finite, with Min < Max.

type RenderMode

type RenderMode uint8

RenderMode selects WebGPU, software, or wireframe rendering. Kitty/glyph output is a separate setting.

const (
	WebGPU RenderMode = iota
	Software
	Wireframe
)

func (RenderMode) String

func (l RenderMode) String() string

type Renderer

type Renderer interface {
	Render(Frame) (image.Image, error)
	Close() error
}

Renderer draws a Frame into a Go image. Implementations must serialize Render and Close and reuse mesh data while Frame.Revision is unchanged. Texture bindings must also be refreshed when Frame.TextureRevision changes.

type Scatter

type Scatter struct {
	X, Y, Z          []float32
	Color            []uint32
	ColorValue, Size []float32
	Category         []int
	Labels           []string
}

Scatter holds X/Y/Z columns of equal length. SetScatter copies all slices. Optional columns must be empty or match that length. Color uses 0xRRGGBBAA; without it, the palette maps ColorValue (or Z). Size is the point radius in pixels, defaults to 2, and is clamped to [1,32] before rendering.

type Series

type Series interface {
	Name() string
	Geometry(Palette) (Geometry, error)
}

Series supplies a named dataset as geometry. Geometry is compiled when data, palettes, or shared-domain settings change, never on camera movement.

type Surface

type Surface struct {
	Material               *Material
	UV                     []UV // Optional; defaults to north-up XY mapping.
	ColorLegend            bool // Include elevation in palette domains and legends even when textured.
	NX, NY                 int
	Z                      []float32
	Sampler                func(float64, float64) float64
	MinX, MaxX, MinY, MaxY float64
	Wireframe              bool
}

Surface is a regular XY grid stored by row. Sampler overrides Z and runs when geometry is compiled; an update may sample the grid more than once. Equal bounds on either horizontal axis default to [-1,1].

type Texture

type Texture struct {
	// contains filtered or unexported fields
}

Texture owns an immutable snapshot of opaque image pixels. The zero value is invalid. GPU resources are owned by each renderer, not by Texture.

func NewTexture

func NewTexture(src image.Image) (*Texture, error)

NewTexture snapshots src, including images with nonzero bounds. Images must be opaque and at most 8192 pixels per side. Channels are treated as sRGB-encoded values, with filtering and lighting performed directly in that encoded space.

func (*Texture) At

func (t *Texture) At(x, y int) color.Color

At implements image.Image. Pixels outside Bounds are transparent black.

func (*Texture) Bounds

func (t *Texture) Bounds() image.Rectangle

Bounds returns the snapshot dimensions with a zero origin.

func (*Texture) ColorModel

func (t *Texture) ColorModel() color.Model

ColorModel implements image.Image without exposing mutable storage.

type UV

type UV struct{ U, V float32 }

UV is a normalized image coordinate; (0,0) is the top-left corner.

type VectorField

type VectorField struct {
	Origins, Vectors []math3d.Vec3
	Scale            float32
	Normalize        bool
	Width, HeadSize  float32
	Color            []uint32
	ColorValue       []float32
	Labels           []string
}

VectorField pairs Origins with Vectors. The tip is origin + vector * Scale. Scale defaults to 1 and must be positive. Normalize makes every nonzero vector Scale world units long; colors still use the original magnitude. Zero vectors have no arrow. Width defaults to 2 pixels, HeadSize to 8 (range 1..64). Optional Color (0xRRGGBBAA), ColorValue, and Labels have one entry per vector. Without Color, the palette maps ColorValue or the original vector magnitude.

type Vertex

type Vertex struct {
	Position, Normal math3d.Vec3
	Color            color.RGBA
}

Directories

Path Synopsis
cmd
wasm-build command
wasm-build builds the gallery with Go and TinyGo and assembles the Pages site.
wasm-build builds the gallery with Go and TinyGo and assembles the Pages site.
examples
gallery module
Package math3d provides vectors, matrices, rays, and axis-aligned bounds.
Package math3d provides vectors, matrices, rays, and axis-aligned bounds.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL