brianzinn / react-babylonjs

React for Babylon 3D engine
https://brianzinn.github.io/react-babylonjs/
812 stars 102 forks source link

useBeforeCameraRender and useAfterCameraRender hook #252

Closed saidmoya12 closed 1 month ago

saidmoya12 commented 1 year ago

implement of useBeforeCameraRender and useAfterCameraRender to work with multiple cameras like VR eyes

This is an easy alternative to get active shader for camera

useBeforeCameraRender is used in textureDome (PhotoDome) to check current eye of camera https://github.com/BabylonJS/Babylon.js/blob/fdbf393d1d7699dc7cc69cec1dca0819ebd2622a/packages/dev/core/src/Helpers/textureDome.ts

brianzinn commented 1 year ago

thanks @saidmoya12 this is great! if you don't mind could you change the import to fully qualified (with .js) I think

import { Camera } from "@babylonjs/core/Cameras/camera"

would become:

import { Camera } from "@babylonjs/core/Cameras/camera.js"
//                                                     ^^

That's needed for compat with bundlers. I don't mind making that change just let me know and then I'll merge 😄

brianzinn commented 1 year ago

also, let me know if it's ok to at mention you in main readme as a contributor. thx

brianzinn commented 1 year ago

@saidmoya12 Do you have an example codepen or code sample for using it - would be cool to have a working page up for the hook in the docs.

saidmoya12 commented 1 year ago

Sounds great, but you can give me some example to install from my fork while isn't merge?

Thanks!

brianzinn commented 1 year ago

@saidmoya12 what about a codesandbox with current NPM version? I can add the sample to the new doc - it would be great to have an example of how to use the hooks. You could also just post some snippets of how you found those hooks useful here. If you wanted to do a codesandbox this may be a useful starting point: https://codesandbox.io/s/floral-water-els13w

brianzinn commented 1 year ago

you can also npm link current version if you want to make a separate CRA example. the other option is to use the 'static' folder to make an example in the Gatsby site (I have no docs to run it yet), but the storybook site is currently broken - otherwise normally you can test out new features directly in the repo.

saidmoya12 commented 1 year ago

Thanks, I will working with it soon!

brianzinn commented 1 month ago

hi @saidmoya12 - sorry i didn't merge this earlier. i think i was waiting on a sample from you and then... ⏲️ anyway. Better late then never! Thank-you for your contribution.

saidmoya12 commented 1 month ago

hi @saidmoya12 - sorry i didn't merge this earlier. i think i was waiting on a sample from you and then... ⏲️ anyway. Better late then never! Thank-you for your contribution.