Expand description
polyscope-rs: A Rust-native 3D visualization library for geometric data.
Polyscope is a viewer and user interface for 3D data such as meshes and point clouds. It allows you to register your data and quickly generate informative visualizations.
§Quick Start
use polyscope_rs::*;
fn main() -> Result<()> {
// Initialize polyscope
init()?;
// Register a point cloud
let points = vec![
Vec3::new(0.0, 0.0, 0.0),
Vec3::new(1.0, 0.0, 0.0),
Vec3::new(0.0, 1.0, 0.0),
];
register_point_cloud("my points", points);
// Show the viewer
show();
Ok(())
}§Architecture
Polyscope uses a paradigm of structures and quantities:
- A structure is a geometric object in the scene (point cloud, mesh, etc.)
- A quantity is data associated with a structure (scalar field, vector field, colors)
§Structures
PointCloud- A set of points in 3D spaceSurfaceMesh- A triangular or polygonal meshCurveNetwork- A network of curves/edgesVolumeMesh- A tetrahedral or hexahedral meshVolumeGrid- A regular grid of values (for implicit surfaces)CameraView- A camera frustum visualization
Structs§
- Appearance
Settings - Appearance settings for UI.
- Camera
- A 3D camera for viewing the scene.
- Camera
Extrinsics - Camera extrinsics parameters (position and orientation).
- Camera
Intrinsics - Camera intrinsics parameters.
- Camera
Parameters - Combined camera parameters (intrinsics + extrinsics).
- Camera
Settings - Camera settings exposed in UI.
- Camera
View - A camera view structure for visualizing camera poses.
- Camera
View Handle - Handle for a registered camera view.
- Color
Map - A color map for mapping scalar values to colors.
- Color
MapRegistry - Registry for managing color maps.
- Context
- The global context containing all polyscope state.
- Curve
Network - A curve network structure (nodes connected by edges).
- Curve
Network Handle - Handle for a registered curve network.
- Gizmo
Config - Configuration for a transformation gizmo.
- Gizmo
Settings - Gizmo settings for UI.
- Group
- A group that can contain structures and other groups.
- Group
Handle - Handle for a group.
- Group
Settings - Settings for a single group in the UI.
- Mat4
- A 4x4 column major matrix.
- Material
- A material definition for rendering.
- Material
Registry - Registry for managing materials.
- Options
- Global configuration options for polyscope.
- Pick
Result - Result of a pick/selection operation.
- Point
Cloud - A point cloud structure.
- Point
Cloud Handle - Handle for a registered point cloud.
- Registry
- Registry for managing all structures in polyscope.
- Render
Context - Render context passed to structures during drawing.
- Render
Engine - The main rendering engine backed by wgpu.
- Scene
Extents - Scene extents information for UI display.
- Screenshot
Options - Options for taking screenshots.
- Screenshot
Request - A pending screenshot request.
- Selection
Info - Current selection info for UI.
- Slice
Plane - A slice plane that can cut through geometry.
- Slice
Plane Handle - Handle for a slice plane.
- Slice
Plane Selection Info - Selection info for slice plane gizmo manipulation.
- Slice
Plane Settings - Settings for a single slice plane in the UI.
- Slice
Plane Uniforms - GPU-compatible slice plane uniforms.
- Surface
Mesh - A surface mesh structure (triangular or polygonal).
- Surface
Mesh Handle - Handle for a registered surface mesh.
- Transform
- A transformation represented as separate components.
- Vec2
- A 2-dimensional vector.
- Vec3
- A 3-dimensional vector.
- Vec4
- A 4-dimensional vector.
- Volume
Grid - A regular 3D grid structure.
- Volume
Grid Handle - Handle for a registered volume grid.
- Volume
Mesh - A volume mesh structure (tetrahedral or hexahedral).
- Volume
Mesh Handle - Handle for a registered volume mesh.
Enums§
- Axis
Direction - Axis direction for up/front vectors.
- Gizmo
Action - Actions that can be triggered from the gizmo UI.
- Gizmo
Axis - Axis for single-axis gizmo operations.
- Gizmo
Mode - The type of transformation gizmo.
- Gizmo
Space - The coordinate space for gizmo operations.
- Groups
Action - Actions that can be triggered from the groups UI.
- Navigation
Style - Camera navigation/interaction style.
- Param
Coords Type - How to interpret UV coordinates.
- Param
VizStyle - Visualization style for parameterization quantities.
- Pick
Element Type - Element type for pick results.
- Polyscope
Error - The main error type for polyscope-rs operations.
- Projection
Mode - Camera projection mode.
- Quantity
Kind - The kind of quantity (for categorization and UI).
- Screenshot
Error - Error type for screenshot operations.
- Slice
Plane Gizmo Action - Actions specific to slice plane gizmo manipulation.
- Slice
Planes Action - Actions that can be triggered from the slice planes UI.
- View
Action - Actions that can be triggered from the view/controls UI.
- Volume
Cell Type - Cell type for volume meshes.
- Volume
Grid VizMode - Visualization mode for volume grid scalar quantities.
Constants§
- MAX_
SLICE_ PLANES - Maximum number of slice planes supported.
Traits§
- HasQuantities
- A structure that can have quantities attached to it.
- Into
Face List - Trait for face data that can be converted to the internal polygon format.
- Pickable
- Trait for objects that support picking/selection.
- Quantity
- Data associated with a structure that can be visualized.
- Structure
- A geometric object that can be visualized in polyscope.
Functions§
- add_
slice_ plane - Adds a new slice plane to cut through geometry.
- add_
slice_ plane_ with_ pose - Adds a slice plane with a specific pose.
- apply_
camera_ settings - Syncs
CameraSettingsfrom UI to the actual Camera. - apply_
gizmo_ settings - Applies gizmo settings from UI.
- apply_
group_ settings - Applies UI settings to a group.
- apply_
selection_ transform - Applies transform from selection info to the selected structure.
- apply_
slice_ plane_ gizmo_ transform - Applies gizmo transform to the selected slice plane.
- apply_
slice_ plane_ settings - Applies UI settings to a slice plane.
- camera_
to_ settings - Creates
CameraSettingsfrom the current Camera state. - clear_
file_ drop_ callback - Clears the file drop callback.
- create_
group - Creates a new group for organizing structures.
- deselect_
slice_ plane_ gizmo - Deselects the current slice plane from gizmo.
- deselect_
structure - Deselects the currently selected structure.
- get_
all_ groups - Returns all group names.
- get_
all_ slice_ planes - Returns all slice plane names.
- get_
camera_ view - Gets a registered camera view by name.
- get_
curve_ network - Gets a registered curve network by name.
- get_
curve_ network_ transform - Gets the transform of a curve network by name.
- get_
gizmo_ mode - Returns the current gizmo mode.
- get_
gizmo_ settings - Gets gizmo settings for UI.
- get_
gizmo_ space - Returns the current gizmo coordinate space.
- get_
group - Gets an existing group by name.
- get_
group_ settings - Gets all groups as UI settings.
- get_
point_ cloud - Gets a registered point cloud by name.
- get_
point_ cloud_ transform - Gets the transform of a point cloud by name.
- get_
scene_ extents - Gets scene extents from the global context.
- get_
selected_ structure - Returns the currently selected structure, if any.
- get_
selected_ transform - Gets the transform of the currently selected structure.
- get_
selection_ info - Gets selection info for UI.
- get_
slice_ plane - Gets an existing slice plane by name.
- get_
slice_ plane_ selection_ info - Gets slice plane selection info for gizmo rendering.
- get_
slice_ plane_ settings - Gets all slice planes as UI settings.
- get_
surface_ mesh - Gets a registered surface mesh by name.
- get_
surface_ mesh_ transform - Gets the transform of a surface mesh by name.
- get_
volume_ grid - Gets a registered volume grid by name.
- get_
volume_ mesh - Gets a registered volume mesh by name.
- get_
volume_ mesh_ transform - Gets the transform of a volume mesh by name.
- handle_
gizmo_ action - Handles a gizmo UI action.
- handle_
group_ action - Handles a group UI action.
- handle_
slice_ plane_ action - Handles a slice plane UI action. Returns the new list of settings after the action.
- has_
selection - Returns whether any structure is currently selected.
- init
- Initializes polyscope with default settings.
- is_
gizmo_ visible - Returns whether the gizmo is visible.
- is_
initialized - Returns whether polyscope has been initialized.
- load_
blendable_ material - Loads a blendable (4-channel, RGB-tintable) matcap material from disk.
- load_
blendable_ material_ ext - Loads a blendable material using a base path and extension.
- load_
static_ material - Loads a static (single-texture, non-RGB-tintable) matcap material from disk.
- register_
camera_ view - Registers a camera view with polyscope using camera parameters.
- register_
camera_ view_ look_ at - Registers a camera view from position, target, and up direction.
- register_
curve_ network - Registers a curve network with explicit edges.
- register_
curve_ network_ line - Registers a curve network as a connected line (0-1-2-3-…).
- register_
curve_ network_ loop - Registers a curve network as a closed loop (0-1-2-…-n-0).
- register_
curve_ network_ segments - Registers a curve network as separate segments (0-1, 2-3, 4-5, …).
- register_
floating_ color_ image - Registers a floating color image (not attached to any structure).
- register_
floating_ scalar_ image - Registers a floating scalar image (not attached to any structure).
- register_
hex_ mesh - Registers a hexahedral mesh with polyscope.
- register_
point_ cloud - Registers a point cloud with polyscope.
- register_
surface_ mesh - Registers a surface mesh with polyscope.
- register_
tet_ mesh - Registers a tetrahedral mesh with polyscope.
- register_
volume_ grid - Registers a volume grid with polyscope.
- register_
volume_ grid_ uniform - Registers a volume grid with uniform dimensions.
- register_
volume_ mesh - Registers a generic volume mesh with polyscope.
- remove_
all_ floating_ quantities - Removes all floating quantities.
- remove_
all_ groups - Removes all groups.
- remove_
all_ slice_ planes - Removes all slice planes.
- remove_
all_ structures - Removes all structures.
- remove_
everything - Removes all structures, groups, slice planes, floating quantities, and clears callbacks.
- remove_
floating_ quantity - Removes a floating quantity by name.
- remove_
group - Removes a group by name.
- remove_
slice_ plane - Removes a slice plane by name.
- remove_
structure - Removes a structure by name.
- render_
to_ file - Renders the current scene to a file.
- render_
to_ image - Renders the current scene to a raw RGBA pixel buffer.
- reset_
selected_ transform - Resets the transform of the currently selected structure to identity.
- screenshot
- Requests a screenshot with an auto-generated filename.
- screenshot_
to_ file - Requests a screenshot to be saved to a specific file.
- screenshot_
to_ file_ with_ options - Requests a screenshot to be saved to a specific file with custom options.
- screenshot_
with_ options - Requests a screenshot with custom options.
- select_
slice_ plane_ for_ gizmo - Selects a slice plane for gizmo manipulation.
- select_
structure - Selects a structure for gizmo manipulation.
- set_
auto_ compute_ extents - Sets auto-compute scene extents option.
- set_
curve_ network_ transform - Sets the transform of a curve network by name.
- set_
file_ drop_ callback - Sets a callback that is invoked when files are dropped onto the polyscope window.
- set_
gizmo_ mode - Sets the gizmo mode (translate, rotate, or scale).
- set_
gizmo_ snap_ rotate - Sets the rotation snap value for the gizmo (in degrees).
- set_
gizmo_ snap_ scale - Sets the scale snap value for the gizmo.
- set_
gizmo_ snap_ translate - Sets the translation snap value for the gizmo.
- set_
gizmo_ space - Sets the gizmo coordinate space (world or local).
- set_
gizmo_ visible - Sets whether the gizmo is visible.
- set_
point_ cloud_ transform - Sets the transform of a point cloud by name.
- set_
selected_ transform - Sets the transform of the currently selected structure.
- set_
surface_ mesh_ transform - Sets the transform of a surface mesh by name.
- set_
volume_ mesh_ transform - Sets the transform of a volume mesh by name.
- show
- Shows the polyscope viewer window.
- shutdown
- Shuts down polyscope and releases all resources.
- with_
camera_ view - Executes a closure with mutable access to a registered camera view.
- with_
camera_ view_ ref - Executes a closure with immutable access to a registered camera view.
- with_
context - Access the global context for reading.
- with_
context_ mut - Access the global context for writing.
- with_
curve_ network - Executes a closure with mutable access to a registered curve network.
- with_
curve_ network_ ref - Executes a closure with immutable access to a registered curve network.
- with_
point_ cloud - Executes a closure with mutable access to a registered point cloud.
- with_
point_ cloud_ ref - Executes a closure with immutable access to a registered point cloud.
- with_
surface_ mesh - Executes a closure with mutable access to a registered surface mesh.
- with_
surface_ mesh_ ref - Executes a closure with immutable access to a registered surface mesh.
- with_
volume_ grid - Executes a closure with mutable access to a registered volume grid.
- with_
volume_ grid_ ref - Executes a closure with immutable access to a registered volume grid.
- with_
volume_ mesh - Executes a closure with mutable access to a registered volume mesh.
- with_
volume_ mesh_ ref - Executes a closure with immutable access to a registered volume mesh.
Type Aliases§
- Result
- A specialized Result type for polyscope-rs operations.