A project built with React and Three.js to manage and animate 3D scenes using Zustand for state management, and Framer Motion for animation. The project includes components for dynamic and interactive 3D entities, and leverages react-three-fiber
for rendering and @react-three/drei
for helper components.
Ensure you have the following installed on your development environment:
- Node.js (>= 12.x)
- npm (>= 6.x)
Clone the repository and install the dependencies:
git clone https://github.com/markNZed/react-three.git
cd react-three
npm install
To start the development server, run:
npm start
This will start the development server at http://localhost:3000.
To deploy the project to GitHub Pages, use the following command:
npm run deploy
You can then view your deployed site at https://markNZed.github.io/react-three.
- Variants: Variants represent states of an animation component. Framer Motion is used for animating these variants whenever possible. The
animationState
holds the variant and other values needed for animations. - Visibility: The visibility of components does not necessarily require Motion and can be controlled through the
animationState
. - Camera Animation: The camera is animated using
react-spring
instead of Framer Motion.
- Scenes: A Scene consists of
animationComponents
that are instantiated and ananimationSequence
that dictates the order of animations. - Animation Speed: The speed in
AnimationController
can be used to accelerate the animation sequence for faster transitions.
The SceneSelector
component allows you to switch between different scenes. See SceneSelector.js for implementation details.
Define the animation sequence for a scene in an array, specifying delays, component IDs, and animation states. Refer to SceneOne.js and SceneThree.js for examples.
Use the CameraAdjuster
component to handle camera adjustments on window resize. Check out App.js for how it integrates with the canvas.
To work with this project on a remote server (assuming the server has SSH, Docker installed, and a clone of this repo):
- Connect to the server via SSH with VS Code and open the folder with the cloned repo.
- From VS Code command palette:
Dev Containers: Rebuild and Reopen in Container
. - If there are directory permission issues (the directory on the server is owned by a different user than the user in the docker container):
- From the terminal inside VS Code:
sudo chown -R node:node /workspaces/react-three
. - Complete the setup manually:
npm install
andnpm start
.
- From the terminal inside VS Code:
- Configure Git from VS Code terminal:
git config --global user.email "your_email@example.com"
git config --global user.name "your_name"
We use git-crypt for any files iwth .gpg.md
extensions
- Created with CodeSandbox
- View/edit the project on CodeSandbox: (https://codesandbox.io/p/github/markNZed/react-three)
- Configured to run as a GitHub Codespace
- For recording video of an animation, consider using use-capture