When visualizing dynamic physical structures—such as time-dependent structural phase transitions in crystallography, changing molecular potentials, or complex network layouts—it is essential to display two layers simultaneously: 1. Nodes/Particles: Moving or changing properties over time. 2. Edges/Topological Framework: Staying connected to those nodes during the animation.
In native plotly, animating both layers concurrently
forces the CPU to re-render the entire geometric matrix every single
frame. This architectural limitation causes the pipeline to lag,
stutter, or freeze entirely, making fluid structural animations
impossible.
sync3d introduces a domain-agnostic separation of
concerns to achieve fluid 60-FPS animations directly on the GPU:
customEdgeIndices) directly
to the widget structure.htmlwidgets::onRender
directly into the browser. It listens to the
plotly_animated event and redraws the geometric wireframes
instantly via ‘WebGL’.This decoupled rendering engine serves critical visual computing needs across multiple scientific domains:
Here is how easily you can implement a synchronized 3D structure
using sync3d. When you run this code in your browser,
notice how the lines track the markers instantly without losing
controller responsiveness:
library(plotly)
library(sync3d)
# 1. Define spatial coordinates (e.g., a simple geometric diamond framework)
nodes_df <- data.frame(
x = c(0, 1, 0, -1, 0, 0),
y = c(0, 0, 1, 0, 0, 0),
z = c(1, 0, 0, 0, -1, 0)
)
# 2. Map the structural connections (from point index to point index)
edge_matrix = matrix(c(1,2, 1,3, 1,4, 1,6), ncol = 2, byrow = TRUE)
# 3. Build the animated marker base
base_plot <- plot_ly(data = nodes_df, x = ~x, y = ~y, z = ~z,
type = 'scatter3d', mode = 'markers')
# 4. Inject the WebGL engine
final_plot <- add_synchronized_3d_edges(base_plot, edge_matrix)Now, the rendering workload is pushed entirely to the graphics card, ensuring a butter-smooth user interface experience.