server
Viser server setup utilities.
compute_grid_size(pos: np.ndarray | None, padding: float = 1.2, default_size: float = 10.0) -> float
¶
Compute grid size based on trajectory extent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos
|
ndarray | None
|
Position array of shape (N, 3), or None if position is not available |
required |
padding
|
float
|
Padding factor (1.2 = 20% padding) |
1.2
|
default_size
|
float
|
Grid size when pos is None |
10.0
|
Returns:
| Type | Description |
|---|---|
float
|
Grid size (width and height) |
Source code in openscvx/plotting/viser/server.py
compute_velocity_colors(vel: np.ndarray | None, cmap_name: str = 'viridis', fallback_length: int | None = None, cmap: Colormap | None = None) -> np.ndarray
¶
Compute RGB colors based on velocity magnitude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vel
|
ndarray | None
|
Velocity array of shape (N, 3), or None if velocity is not available |
required |
cmap_name
|
str
|
Matplotlib colormap name |
'viridis'
|
fallback_length
|
int | None
|
When vel is None, number of points for default color array. Required when vel is None. |
None
|
cmap
|
Colormap | None
|
Preloaded colormap to use instead of looking up |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of RGB colors with shape (N, 3), values in [0, 255] |
Source code in openscvx/plotting/viser/server.py
create_server(pos: np.ndarray | None, dark_mode: bool = True, show_grid: bool = True, port: int | None = None, *, show_origin: bool = True) -> viser.ViserServer
¶
Create a viser server with basic scene setup.
Prefer this over a bare viser.ViserServer(): it is the only thing that
attaches the OpenSCvx titlebar (logo and documentation links), so a scene
built without it silently ships unbranded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos
|
ndarray | None
|
Position array for computing grid size, or None to use default grid size |
required |
dark_mode
|
bool
|
Whether to use dark theme |
True
|
show_grid
|
bool
|
Whether to show the grid (default True) |
True
|
port
|
int | None
|
Preferred HTTP port. Defaults to 8080. If that port is already bound on localhost, the next free port is used. |
None
|
show_origin
|
bool
|
Whether to draw the origin triad. The frame is half a metre across, so switch it off for scenes whose whole extent is on that order (a scale-model track, a tabletop workspace) where it would dominate rather than orient. |
True
|
Returns:
| Type | Description |
|---|---|
ViserServer
|
ViserServer instance with the titlebar, and optionally a grid and origin frame |
Source code in openscvx/plotting/viser/server.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |