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: expose expoGL object props #3001

Closed
wants to merge 1 commit into from

Conversation

jeremybarbet
Copy link

Hi hi,

I wanted to take a snapshot of my 3D scene in react-native, but the recommended method for the web does not work with expo-gl.

I added a new object expoGL (that could be extended for additional props from the GLView) and passed it a ref props.

Here is a demo of the use case

import { Canvas } from '@react-three/fiber/native';

const Demo = () => {
  const ref = React.useRef<GLView | null>(null)

  const snapshot = React.useCallback(async () => {
    const res = await ref.current?.takeSnapshotAsync()

    if (res?.localUri) {
      // Do something with the image, e.g. upload to R2
    }
  }, [])

  // Call snapshot() to take a snapshot of the canvas

  return <Canvas expoGL={{ ref }} {...} />
}

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 8, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 58d8649:

Sandbox Source
example Configuration
LGL Raytracer PR

@CodyJasonBennett
Copy link
Member

I'd prefer to keep this an implementation detail if possible. We can, however, merge the HTML Canvas shim and the actual GLView reference without much trouble. For your purposes though, GLView has a static takeSnapshotAsync method which accepts the current GL context.

@CodyJasonBennett
Copy link
Member

Closing as stale. Happy to reopen and resolve conflicts if still current, I believe we can already address use-cases where you'd want the underlying expo-gl handle.

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.

2 participants