Skip to content

ForceGraph3D zoomToFit Example Request #593

Description

@shahar-caura

Is your feature request related to a problem? Please describe.
I'm trying to zoom in on the graph when it loads - zoomToFit a ForceGraph3D onEngineStop - but it zooms in 10+ seconds after the graph was rendered to the screen.

Describe the solution you'd like
Code example, similar to https://github.com/vasturiano/react-force-graph/blob/master/example/fit-to-canvas/index.html, for focusing on a 3D Graph when it finishes loading.

Describe alternatives you've considered
setTimeout rather than using onEngineStop (unreliable), considering a useEffect on the graphRef.

Additional context
My current (slow to zoom in) solution looks like this:

<ForceGraph3D
        ref={graphRef}
        graphData={processedGraphData}
        warmupTicks={250}
        onEngineStop={() => {
          if (isInitialRender.current && graphRef.current) {
            // Use zoomToFit for adaptive zoom based on graph size
            // 1000ms transition, 50px padding from edges
            graphRef.current.zoomToFit(1000, 50);
            isInitialRender.current = false;
          }
        }}
...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions