Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow setting the camera position #47

Merged
merged 1 commit into from
Jan 14, 2024

Conversation

gabotechs
Copy link
Owner

@gabotechs gabotechs commented Jan 14, 2024

As requested by #44.

This would work as follows:

function Component() {
  const cameraRef = useRef<CameraRef>();

  function setCameraPosition() {
    cameraRef.current?.setCameraPosition({
      latitude: Math.PI / 8,
      longitude: -Math.PI / 8,
      distance: 1,
    });
  }
  
  return <StlViewer 
    cameraProps={{ ref: cameraRef }}
  />
}

A more detailed example can be found here https://github.com/gabotechs/react-stl-viewer/blob/master/.storybook/stories/FromUrl.stories.tsx

@gabotechs gabotechs merged commit 669fd08 into master Jan 14, 2024
2 checks passed
@gabotechs gabotechs deleted the allow-setting-camera-position-imperatively branch January 14, 2024 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant