Documentation
¶
Overview ¶
Package pointcloud provides point cloud data types and format readers.
Index ¶
- Variables
- func SupportedExtensions() []string
- func WritePLY(w io.Writer, pc *PointCloud) error
- type CubeColors
- type Option
- func WithBackgroundColor(c color.RGBA) Option
- func WithCubeColors(cc CubeColors) Option
- func WithDefaultPointColor(c color.RGBA) Option
- func WithFPS(show bool) Option
- func WithFPSColor(c color.RGBA) Option
- func WithFPSSize(size float32) Option
- func WithFPSStyle(s fyne.TextStyle) Option
- func WithFlythroughButton(show bool) Option
- func WithFlythroughEnabled(on bool) Option
- func WithHomeButton(show bool) Option
- func WithHomeOrientation(q Quat) Option
- func WithInfoLabel(show bool) Option
- func WithInfoLabelColor(c color.RGBA) Option
- func WithInfoLabelSize(size float32) Option
- func WithInfoLabelStyle(s fyne.TextStyle) Option
- func WithInitialZoom(z float64) Option
- func WithMaxZoomOutFraction(f float64) Option
- func WithOrientationCube(show bool) Option
- func WithScaleBar(show bool) Option
- func WithScaleBarColor(c color.RGBA) Option
- func WithScaleUnit(unit string) Option
- func WithScaleUnitScale(s float64) Option
- func WithZoomFitButton(show bool) Option
- type Point3D
- type PointCloud
- type Quat
- type UpAxis
- type Viewer
- func (v *Viewer) CreateRenderer() fyne.WidgetRenderer
- func (v *Viewer) GetUpAxis() UpAxis
- func (v *Viewer) HomeView()
- func (v *Viewer) IsFlythrough() bool
- func (v *Viewer) LODEnabled() bool
- func (v *Viewer) LODTargetSize() int
- func (v *Viewer) MaxZoomOutFraction() float64
- func (v *Viewer) Orientation() Quat
- func (v *Viewer) Pan() (x, y float64)
- func (v *Viewer) SetBackgroundColor(c color.RGBA)
- func (v *Viewer) SetCubeColors(cc CubeColors)
- func (v *Viewer) SetDefaultPointColor(c color.RGBA)
- func (v *Viewer) SetFPSColor(c color.RGBA)
- func (v *Viewer) SetFPSEnabled(on bool)
- func (v *Viewer) SetFPSSize(size float32)
- func (v *Viewer) SetFPSStyle(s fyne.TextStyle)
- func (v *Viewer) SetFlythrough(on bool)
- func (v *Viewer) SetInfoLabelColor(c color.RGBA)
- func (v *Viewer) SetInfoLabelSize(size float32)
- func (v *Viewer) SetInfoLabelStyle(s fyne.TextStyle)
- func (v *Viewer) SetLODEnabled(enabled bool)
- func (v *Viewer) SetLODTargetSize(n int)
- func (v *Viewer) SetMaxZoomOutFraction(f float64)
- func (v *Viewer) SetOnFrameDrawn(fn func(time.Duration))
- func (v *Viewer) SetOrientation(q Quat)
- func (v *Viewer) SetPan(x, y float64)
- func (v *Viewer) SetPoints(pts []Point3D)
- func (v *Viewer) SetPointsPreserveView(pts []Point3D)
- func (v *Viewer) SetScale(normScale float64)
- func (v *Viewer) SetScaleBarColor(c color.RGBA)
- func (v *Viewer) SetScaleUnit(unit string)
- func (v *Viewer) SetScaleUnitScale(multiplier float64)
- func (v *Viewer) SetUpAxis(up UpAxis)
- func (v *Viewer) SetZoom(z float64)
- func (v *Viewer) Zoom() float64
- func (v *Viewer) ZoomToExtents()
Constants ¶
This section is empty.
Variables ¶
var HomeOrientation = QuatFromEulerXY(-0.3, -math.Pi/4)
HomeOrientation is the default home view: side-on, slightly elevated.
Functions ¶
func SupportedExtensions ¶
func SupportedExtensions() []string
SupportedExtensions returns all file extensions the readers handle.
Types ¶
type CubeColors ¶
type CubeColors struct {
Faces [6]color.RGBA // Z+, Z-, X+, X-, Y+, Y-
EdgeColor color.RGBA
LabelColor color.RGBA
AxisColors [3]color.RGBA // X, Y, Z
}
CubeColors configures the colors of the orientation cube.
func DefaultCubeColors ¶
func DefaultCubeColors() CubeColors
DefaultCubeColors returns the default orientation cube colors.
type Option ¶
type Option func(*config)
Option configures a Viewer during construction.
func WithBackgroundColor ¶
WithBackgroundColor sets the canvas background color.
func WithCubeColors ¶
func WithCubeColors(cc CubeColors) Option
WithCubeColors sets the orientation cube colors.
func WithDefaultPointColor ¶
WithDefaultPointColor sets the fallback color for points without RGB data.
func WithFPSColor ¶
WithFPSColor sets the FPS counter text color.
func WithFPSSize ¶
WithFPSSize sets the FPS counter font size. The default is 14.
func WithFPSStyle ¶
WithFPSStyle sets the FPS counter text style.
func WithFlythroughButton ¶
WithFlythroughButton controls whether the flythrough toggle button is displayed.
func WithFlythroughEnabled ¶
WithFlythroughEnabled sets whether flythrough mode is initially active.
func WithHomeButton ¶
WithHomeButton controls whether the home button is displayed.
func WithHomeOrientation ¶
WithHomeOrientation sets the default home view orientation.
func WithInfoLabel ¶
WithInfoLabel controls whether the point info label is displayed.
func WithInfoLabelColor ¶
WithInfoLabelColor sets the info label text color.
func WithInfoLabelSize ¶
WithInfoLabelSize sets the info label font size. The default is 12.
func WithInfoLabelStyle ¶
WithInfoLabelStyle sets the info label text style (font).
func WithInitialZoom ¶
WithInitialZoom sets the starting zoom level.
func WithMaxZoomOutFraction ¶
WithMaxZoomOutFraction sets the minimum visible fraction of the largest canvas dimension that the point cloud must occupy. For example, 0.2 means the user cannot zoom out past the point where the cloud covers less than 20% of the viewport. The default is 0.2.
func WithOrientationCube ¶
WithOrientationCube controls whether the orientation cube is displayed.
func WithScaleBar ¶
WithScaleBar controls whether the scale bar is displayed.
func WithScaleBarColor ¶
WithScaleBarColor sets the scale bar color.
func WithScaleUnit ¶
WithScaleUnit sets the unit label for the scale bar (e.g. "m").
func WithScaleUnitScale ¶
WithScaleUnitScale sets the unit multiplier for the scale bar. For example, if data is in meters and you want to display millimeters, set this to 1000.
func WithZoomFitButton ¶
WithZoomFitButton controls whether the zoom-fit button is displayed.
type PointCloud ¶
type PointCloud struct {
Points []Point3D
MinX, MinY, MinZ float64
MaxX, MaxY, MaxZ float64
// NormScale is the scale factor applied by Normalize (2.0/maxDim).
// Zero if Normalize has not been called.
NormScale float64
// NormCenter is the center point subtracted during Normalize.
NormCenter [3]float64
// contains filtered or unexported fields
}
PointCloud holds a collection of 3D points with bounding box metadata.
func ReadFile ¶
func ReadFile(path string) (*PointCloud, error)
ReadFile detects the format by file extension and reads the point cloud.
func ReadPCD ¶
func ReadPCD(r io.Reader) (*PointCloud, error)
ReadPCD reads a point cloud from a PCD (Point Cloud Library) format file. Supports ASCII and binary formats.
func ReadPLY ¶
func ReadPLY(r io.Reader) (*PointCloud, error)
ReadPLY reads a point cloud from a PLY (Stanford Polygon Format) file. Supports ASCII, binary_little_endian, and binary_big_endian formats.
func ReadPTS ¶
func ReadPTS(r io.Reader) (*PointCloud, error)
ReadPTS reads a point cloud from a PTS (Leica) format file. The first line is the point count. Subsequent lines contain: x y z intensity [r g b] (space-separated).
func ReadXYZ ¶
func ReadXYZ(r io.Reader) (*PointCloud, error)
ReadXYZ reads a point cloud from an XYZ format file. Each line should contain at least 3 whitespace or comma-separated floats (x, y, z). Lines starting with '#' or '//' are treated as comments. Extra columns beyond x, y, z are ignored.
func (*PointCloud) ComputeBounds ¶
func (pc *PointCloud) ComputeBounds()
ComputeBounds calculates the bounding box of the point cloud.
func (*PointCloud) Normalize ¶
func (pc *PointCloud) Normalize()
Normalize centers the point cloud at the origin and scales it so the largest dimension spans [-1, 1].
type Quat ¶
type Quat struct {
X, Y, Z, W float64
}
Quat represents a unit quaternion for 3D rotation.
func QuatFromAxisAngle ¶
QuatFromAxisAngle creates a quaternion from an axis and angle (radians).
func QuatFromEulerXY ¶
QuatFromEulerXY creates a quaternion matching the old Euler convention: rotate by ay around Y, then by ax around X.
func QuatIdentity ¶
func QuatIdentity() Quat
QuatIdentity returns the identity quaternion (no rotation).
func (Quat) Conjugate ¶
Conjugate returns the conjugate of the quaternion, which for unit quaternions is also the inverse rotation.
func (Quat) RotateVec3 ¶
RotateVec3 rotates a 3D vector by the quaternion using the formula q*v*q^-1.
type Viewer ¶
type Viewer struct {
widget.BaseWidget
// OnFlythroughChanged is called when flythrough mode is toggled,
// either via the UI button, the 'G' key, or SetFlythrough.
OnFlythroughChanged func(on bool)
// contains filtered or unexported fields
}
Viewer is a self-contained point cloud viewer widget for Fyne applications.
It provides:
- Interactive 3D rendering with perspective projection
- Arcball rotation via mouse drag
- Panning via Shift+drag
- Zoom via scroll wheel
- An orientation cube for quick view snapping
- Home and zoom-to-fit buttons
func New ¶
New creates a new point cloud viewer widget with default settings. The default up-axis is YUp. Use Viewer.SetUpAxis to change it. Functional options can be provided to configure the viewer at creation time.
func (*Viewer) CreateRenderer ¶
func (v *Viewer) CreateRenderer() fyne.WidgetRenderer
CreateRenderer implements fyne.Widget.
func (*Viewer) HomeView ¶
func (v *Viewer) HomeView()
HomeView resets the orientation, zoom, and pan to the default home view.
func (*Viewer) IsFlythrough ¶
IsFlythrough returns true if flythrough mode is currently active.
func (*Viewer) LODEnabled ¶
LODEnabled returns whether LOD decimation is currently enabled.
func (*Viewer) LODTargetSize ¶
LODTargetSize returns the current LOD target point count.
func (*Viewer) MaxZoomOutFraction ¶
MaxZoomOutFraction returns the current zoom-out fraction limit.
func (*Viewer) Orientation ¶
Orientation returns the current view orientation as a quaternion.
func (*Viewer) SetBackgroundColor ¶
SetBackgroundColor sets the canvas background color. The default is black.
func (*Viewer) SetCubeColors ¶
func (v *Viewer) SetCubeColors(cc CubeColors)
SetCubeColors updates the orientation cube colors at runtime. Has no effect if the cube was hidden via WithOrientationCube(false).
func (*Viewer) SetDefaultPointColor ¶
SetDefaultPointColor sets the fallback color for points without RGB data.
func (*Viewer) SetFPSColor ¶
SetFPSColor sets the FPS counter text color.
func (*Viewer) SetFPSEnabled ¶
SetFPSEnabled shows or hides the FPS counter. The viewer must have been created with WithFPS(true) for this to have any effect.
func (*Viewer) SetFPSSize ¶
SetFPSSize sets the FPS counter font size.
func (*Viewer) SetFPSStyle ¶
SetFPSStyle sets the FPS counter text style.
func (*Viewer) SetFlythrough ¶
SetFlythrough enables or disables flythrough (first-person) camera mode.
func (*Viewer) SetInfoLabelColor ¶
SetInfoLabelColor sets the info label text color at runtime. Has no effect if the info label was hidden via WithInfoLabel(false).
func (*Viewer) SetInfoLabelSize ¶
SetInfoLabelSize sets the info label font size at runtime. Has no effect if the info label was hidden via WithInfoLabel(false).
func (*Viewer) SetInfoLabelStyle ¶
SetInfoLabelStyle sets the info label text style at runtime. Has no effect if the info label was hidden via WithInfoLabel(false).
func (*Viewer) SetLODEnabled ¶
SetLODEnabled enables or disables LOD (level-of-detail) decimation during mouse interaction. When enabled, a decimated point set is rendered while dragging or scrolling for responsive frame rates. The full cloud is restored after a short idle period. LOD is enabled by default.
func (*Viewer) SetLODTargetSize ¶
SetLODTargetSize sets the target number of points in the decimated LOD set. Smaller values give faster interaction at the cost of visual fidelity during drag. The default is 200,000. The LOD arrays are rebuilt immediately.
func (*Viewer) SetMaxZoomOutFraction ¶
SetMaxZoomOutFraction sets the minimum visible fraction of the largest canvas dimension that the point cloud must occupy when zooming out. For example, 0.2 means zoom-out stops when the cloud covers ~20% of the viewport. The default is 0.2.
func (*Viewer) SetOnFrameDrawn ¶
SetOnFrameDrawn registers a callback that is invoked at the end of each frame render with the time the draw call took. Useful for benchmarking. If the FPS display is enabled, both the FPS counter and this callback will be called.
Note: calling this multiple times creates a chain of closures; each new callback wraps the previous one. This is fine for single-call usage.
func (*Viewer) SetOrientation ¶
SetOrientation sets the view orientation to the given quaternion.
func (*Viewer) SetPoints ¶
SetPoints replaces the displayed point cloud and resets the view to fit all points. The points should be normalized (see PointCloud.Normalize).
func (*Viewer) SetPointsPreserveView ¶
SetPointsPreserveView replaces the displayed point cloud without resetting the orientation, zoom, or pan.
func (*Viewer) SetScale ¶
SetScale sets the normalization scale factor for the scale bar. This is typically the NormScale value from a PointCloud after Normalize().
func (*Viewer) SetScaleBarColor ¶
SetScaleBarColor sets the scale bar color at runtime.
func (*Viewer) SetScaleUnit ¶
SetScaleUnit sets the unit label for the scale bar (e.g. "m").
func (*Viewer) SetScaleUnitScale ¶
SetScaleUnitScale sets the unit multiplier for the scale bar.
func (*Viewer) SetUpAxis ¶
SetUpAxis sets the up-axis convention used for rendering. Use YUp for data where Y is up, or ZUp for data where Z is up (typical for LiDAR and surveying data).
func (*Viewer) ZoomToExtents ¶
func (v *Viewer) ZoomToExtents()
ZoomToExtents resets zoom and pan so the full point cloud is visible.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
_examples
|
|
|
seabed
command
Package main generates a synthetic seabed point cloud and displays it.
|
Package main generates a synthetic seabed point cloud and displays it. |
|
streaming
command
Package main demonstrates streaming point cloud data to the viewer widget.
|
Package main demonstrates streaming point cloud data to the viewer widget. |
|
cmd
|
|
|
pcbench
command
pcbench is an end-to-end benchmark for the point cloud viewer.
|
pcbench is an end-to-end benchmark for the point cloud viewer. |
|
pointcloud
command
Package main implements the Point Cloud Viewer application.
|
Package main implements the Point Cloud Viewer application. |
|
xyz-convert
command
Command xyz-convert converts XYZ point cloud files to PLY format.
|
Command xyz-convert converts XYZ point cloud files to PLY format. |
|
internal
|
|
|
raster
Package raster provides 2D raster drawing primitives.
|
Package raster provides 2D raster drawing primitives. |
|
ui
Package ui contains internal UI types
|
Package ui contains internal UI types |


