Getting Started with sync3d: Bypassing 3D Animation Limits — A Minimal Working Example (MWE)

Katharina Maria Brecht (ORCID: 0009-0001-2176-7476)

The Visual Bottleneck in Native 3D Animations

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.

The Dual-Layer Architecture

sync3d introduces a domain-agnostic separation of concerns to achieve fluid 60-FPS animations directly on the GPU:

Target Applications & Fields of Use

This decoupled rendering engine serves critical visual computing needs across multiple scientific domains:

Minimal Working Example (MWE): Static Topology Binding

The following Minimal Working Example (MWE) demonstrates the basic syntax for attaching synchronized WebGL edges to a 3D plotly scatter object using sync3d. When you rotate or zoom the 3D scene in your browser, the injected WebGL edges remain locked to the marker coordinates without degrading controller responsiveness (for a multi-frame time-animated 3D octahedron, see the companion vignette Connecting Discrete Geometry with Continuous Time-Waves):

library(plotly)
library(sync3d)

# 1. Define spatial coordinates (minimal working example geometry)
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. Define edge connectivity (vertex index pairs)
edge_matrix = matrix(c(1,2, 1,3, 1,4, 1,6), ncol = 2, byrow = TRUE)

# 3. Initialize the 3D marker base trace
base_plot <- plot_ly(data = nodes_df, x = ~x, y = ~y, z = ~z, 
                     type = 'scatter3d', mode = 'markers')

# 4. Inject the synchronized WebGL edge layer
final_plot <- add_synchronized_3d_edges(base_plot, edge_matrix)

This delegates edge rendering directly to the WebGL layer, maintaining full interactive responsiveness during multi-frame animations.