Client
This guide explains how to use the voraus 3D Visu Python and Rust client to interact with the server. The clients can add 3D objects using standard web requests (HTTP protocol) to the server’s REST API, while live updates are handled using WebSockets.
Installation
If not already done, install the voraus 3D Visu client as explained in the Server section.
Adding objects to the Server
It is assumed that the server is running. First import the client with
from voraus_3d_visu import Visu
use voraus_3d_visu::obj::text_panel::TextPanelOptions;
use voraus_3d_visu::{Result, Visu};
then create an instance of the Visu:
visu = Visu("http://localhost:8077/")
let mut visu = Visu::new("http://localhost:8077/", true, false, false, None)?;
Each client instance can be configured on how to interact with the server on its initialization.
By default, each client requests the deletion of all objects (except models) and all materials
associated with this client. To change this behavior, set the parameters clear to False.
If one likes to delete everything regardless of the client origin, set the parameter clear_all to True.
Additionally, if the client is part of a multi-client setup, one can use the identifier parameter to distinguish
between the objects and materials added by different clients.
Adding different 3D objects to the scene, e.g., a text panel, can be done as follows:
text_panel = visu.add_text_panel(text="Hello World!")
let text_panel = visu.add_text_panel("Hello World!", TextPanelOptions::default())?;
Currently, we support the following 3D objects:
Models based on GLB, glTF, or OBJ files created with any 3D modeling tool
Geometric primitives: Box, Sphere and Cylinder
Text panels
Axes helpers (coordinate system arrows)
Lines
Point clouds based on pld or ply files
Each object can be added using its respective method, more information can be found in the voraus_3d_visu (Python) and voraus_3d_visu (Rust) documentation.
Some objects, e.g., geometric primitives can accept an explicit material on initialization. These materials can also be added using their respective methods.
Updating object properties
Once an object is added to the server, its properties can be updated with instructions, for this a WebSocket connection needs to be established:
with visu.connection():
let mut connection = visu.connection()?;
and then the desired properties can be updated, e.g., scaling the text panel:
visu.update(text_panel.scale.xyz(2, 2, 2))
connection.update(vec![text_panel.scale().xyz(2.0, 2.0, 2.0)])?;
Note
Multiple properties can be updated at once by passing multiple instructions into the update method.
Next Step
Check out the Object Instructions to get an overview of the different properties to update.