pmndrs / react-three-fiber

🇨🇭 A React renderer for Three.js
https://docs.pmnd.rs/react-three-fiber
MIT License
27.64k stars 1.6k forks source link

Canvas eventHandler: onWebGLContextLost, onWebGLContextRestored #3206

Closed timohausmann closed 8 months ago

timohausmann commented 8 months ago

Wouldn't it add value to add these events to the Canvas element?

<Canvas
  onWebGLContextLost={() => console.log('onWebGLContextLost')}
  onWebGLContextRestored={() => console.log('onWebGLContextRestored')}
></Canvas>

I'm trying to add these events to my app and I feel like it could be more straight forward. Would be helpful to expose RootState in the events if possible.

CodyJasonBennett commented 8 months ago

We can't tie ourselves to a single backend -- e.g. WebGL or WebGPU. I would keep these in your app, and a good place to subscribe to the WebGL canvas is within the Canvas onCreated callback or another component within.

timohausmann commented 8 months ago

We can't tie ourselves to a single backend -- e.g. WebGL or WebGPU. I would keep these in your app, and a good place to subscribe to the WebGL canvas is within the Canvas onCreated callback or another component within.

Okay, thanks for the explanation.