|
| 1 | +<p align="center"> |
| 2 | + <img src="./docs/getting-started/logo.svg" width="100" /> |
| 3 | +</p> |
| 4 | + |
| 5 | +<h1 align="center">xr</h1> |
| 6 | +<h3 align="center">Turn any R3F app into an interactive immersive experience.</h3> |
| 7 | +<br/> |
| 8 | + |
| 9 | + |
| 10 | +<p align="center"> |
| 11 | + <a href="https://npmjs.com/package/@react-three/xr" target="_blank"> |
| 12 | + <img src="https://img.shields.io/npm/v/@react-three/xr?style=flat&colorA=000000&colorB=000000" alt="NPM" /> |
| 13 | + </a> |
| 14 | + <a href="https://npmjs.com/package/@react-three/xr" target="_blank"> |
| 15 | + <img src="https://img.shields.io/npm/dt/@react-three/xr.svg?style=flat&colorA=000000&colorB=000000" alt="NPM" /> |
| 16 | + </a> |
| 17 | + <a href="https://twitter.com/pmndrs" target="_blank"> |
| 18 | + <img src="https://img.shields.io/twitter/follow/pmndrs?label=%40pmndrs&style=flat&colorA=000000&colorB=000000&logo=twitter&logoColor=000000" alt="Twitter" /> |
| 19 | + </a> |
| 20 | + <a href="https://discord.gg/ZZjjNvJ" target="_blank"> |
| 21 | + <img src="https://img.shields.io/discord/740090768164651008?style=flat&colorA=000000&colorB=000000&label=discord&logo=discord&logoColor=000000" alt="Discord" /> |
| 22 | + </a> |
| 23 | +</p> |
| 24 | + |
| 25 | +```bash |
| 26 | +npm install three @react-three/fiber @react-three/xr@latest |
| 27 | +``` |
| 28 | + |
| 29 | +## What does it look like? |
| 30 | + |
| 31 | +| A simple scene with a mesh that toggles its material color between `"red"` and `"blue"` when clicked through touching or pointing. |  | |
| 32 | +|-|-| |
| 33 | + |
| 34 | +```tsx |
| 35 | +import { Canvas } from '@react-three/fiber' |
| 36 | +import { XR, createXRStore } from '@react-three/xr' |
| 37 | +import { useState } from 'react' |
| 38 | + |
| 39 | +const store = createXRStore() |
| 40 | + |
| 41 | +export function App() { |
| 42 | + const [red, setRed] = useState(false) |
| 43 | + return <> |
| 44 | + <button onClick={() => store.enterAR()}>Enter AR</button> |
| 45 | + <Canvas> |
| 46 | + <XR store={store}> |
| 47 | + <mesh pointerEventsType={{ deny: 'grab' }} onClick={() => setRed(!red)} position={[0, 1, -1]}> |
| 48 | + <boxGeometry /> |
| 49 | + <meshBasicMaterial color={red ? 'red' : 'blue'} /> |
| 50 | + </mesh> |
| 51 | + </XR> |
| 52 | + </Canvas> |
| 53 | + </> |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +### How to enable XR for your @react-three/fiber app? |
| 58 | + |
| 59 | +1. `const store = createXRStore()` create a xr store |
| 60 | +2. `store.enterAR()` call enter AR when clicking on a button |
| 61 | +3. `<XR>...</XR>` wrap your content with the XR component |
| 62 | + |
| 63 | +... or read this guide for [converting a react-three/fiber app to XR](https://docs.pmnd.rs/xr/getting-started/convert-to-xr). |
| 64 | + |
| 65 | +## Tutorials |
| 66 | + |
| 67 | +- 👌 [Interactions](https://docs.pmnd.rs/xr/tutorials/interactions) |
| 68 | +- 🔧 [Options](https://docs.pmnd.rs/xr/tutorials/options) |
| 69 | +- 🧊 [Object Detection](https://docs.pmnd.rs/xr/tutorials/object-detection) |
| 70 | +- ✴ [Origin](https://docs.pmnd.rs/xr/tutorials/origin) |
| 71 | +- 🪄 [Teleport](https://docs.pmnd.rs/xr/tutorials/teleport) |
| 72 | +- 🕹️ [Gamepad](https://docs.pmnd.rs/xr/tutorials/gamepad) |
| 73 | +- 🎮 [Custom Controller/Hands/...](https://docs.pmnd.rs/xr/tutorials/custom-inputs) |
| 74 | +- ⛨ [Guards](https://docs.pmnd.rs/xr/tutorials/guards) |
| 75 | + |
| 76 | +## Roadmap |
| 77 | + |
| 78 | +- 🤳 XR Gestures |
| 79 | +- ⚓️ Anchors |
| 80 | +- 📺 Layers |
| 81 | +- 📱 Dom Overlays |
| 82 | +- 🕺 Tracked Body |
| 83 | +- 🎯 Hit Test |
| 84 | +- ↕ react-three/controls |
| 85 | + |
| 86 | +## Migration guides |
| 87 | + |
| 88 | +- from [@react-three/xr v5](https://docs.pmnd.rs/xr/migration/from-react-three-xr-5) |
| 89 | +- from [natuerlich](https://docs.pmnd.rs/xr/migration/from-natuerlich) |
| 90 | + |
| 91 | +## Sponsors |
| 92 | + |
| 93 | +This project is supported by a few companies and individuals building cutting-edge 3D Web & XR experiences. Check them out! |
| 94 | + |
| 95 | + |
0 commit comments