React BabylonJS
React BabylonJS is for integration of BabylonJS into a ReactJS and/or Redux project.
I will be expanding and fixing this project. I started as a fun project to integrate the technologies ReactJS, Redux and BabylonJS. Will happily accept any pull requests as there is lots of room for extra functionality, especially with the new declarative model :)
Getting Started
Install the npm module into your project.
How to Install
OR
Usage Styles
'react-babylonjs' tries to remain unopinionated about how you integrate BabylonJS with ReactJS. This module provides a 100% declarative option or you can customise by adding code.
100% Declarative add BabylonJS to your project with zero code!
live demo: default playground declarative
100% declarative with state/props flow. Code to manage props (or state).
You can easily control BabylonJS properties with state or (redux) props. This sample uses state to control the light intensity and direction of rotation.
live demo: with props
100% declarative - Loading 3D models with zero code (optional state/props flow).
You can easily control BabylonJS models as well. This sample loads 3D models and controls them with buttons.
live demo: with model
Setting up a React component in your project using onSceneMount().
This is a more advanced scanario and allows more control. You will need to call engine.runRenderLoop(() => {...}). I will include an example later using the new createCamera() method that makes this even easier (auto attach to canvas) and also creates a typical runRenderLoop() on the engine for you.
Setting up middleware in your project (optional)...
You can optionally apply the 'react-babylonjs' middleware to monitor redux events. Use this if you want to synchronise your BabylonJS Scene with ReactJS.
In your top-level component mount/unmount you need to register and deregister your middleware handlers. The middleware is currently included with babylonjs-react NPM, but I will be splitting to another project. Will post a full-example here then.