https://github.com/pmndrs/react-three-scissor
✂ Multiple scenes, one canvas! WebGL Scissoring implementation for React Three Fiber.
https://github.com/pmndrs/react-three-scissor
Last synced: 4 months ago
JSON representation
✂ Multiple scenes, one canvas! WebGL Scissoring implementation for React Three Fiber.
- Host: GitHub
- URL: https://github.com/pmndrs/react-three-scissor
- Owner: pmndrs
- License: mit
- Archived: true
- Created: 2022-01-23T09:36:18.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-19T11:38:53.000Z (about 3 years ago)
- Last Synced: 2024-10-29T23:49:56.275Z (7 months ago)
- Language: TypeScript
- Homepage:
- Size: 2.62 MB
- Stars: 79
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
react-three-scissor
Multiple scenes, one canvas! WebGL Scissoring implementation for React Three Fiber.
Depricated! Use
<View />
fromreact-three-drei
Show depricated readme
`scissor` lets you render an infinite number of individual scenes (limited by your processing capability of course) on one single WebGL context and canvas.
It is as easy as:
```jsx
// Add Scissored components to the canvas
// Define sissor windows.
// ... Any number of windows
```## Why this?
Havigng multiple WebGL contests within one webpage is generally a bad idea because (from [ThreeJS manual](https://threejs.org/manual/?q=mul#en/multiple-scenes)):
- **The browser limits how many WebGL contexts you can have.** Typically that limit is around 8 of them. After which, the oldest ones lose context.
- **WebGL resources can not be shared across contexts.** That means expensive operation like loading models and compiling shaders would have to be repeated.Instead, we create the illusion of multiple canvases by having one large one and drawing on very speciifc parts of it. This process is called Scissoring.
## Getting Started
### ⚡️ Jump Start
```shell
# Install the entire library
npm install @react-three/scissor
``````jsx
import { Box } from '@react-three/drei'
import { Scissor, ScissorWindow } from '@react-three/scissor'export default function App() {
return (
<>
{/* Any R3F Components */}
>
)
}
```It's as simple as that to create scroll-in animations.
### 💅 Styling Windows
### CSS
`ScissorWindow` can be styled, positioned and scaled with any CSS property.
```jsx
{/* Any R3F Components */}
```
Or,
```css
.window {
width: 420px;
height: 420px;
border: 2px solid black;position: absolute;
top: 0;
...;
}
```### Styled components
It can also be wrapped in `styled-component` definitions like so:
```js
const StyledScissorWindow = styled(ScissorWindow)`
width: 420px;
height: 420px;
border: 2px solid black;position: absolute;
top: 0;
...
`
```## Roadmap
Major TODOs
- [ ] Controls support
- [ ] `` support
- [ ] Other Drei helpers support
- [ ] Per-window camera