Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
[![npm version](https://badge.fury.io/js/react-xr.svg)](https://badge.fury.io/js/react-xr) ![npm](https://img.shields.io/npm/dt/react-xr.svg)
WebXR + react-three-fiber
React components and hooks for creating VR/AR/XR applications with react-three-fiber
Note: Extremely early in development. Contributors welcome!
npm install react-xr
Enable VR in the Canvas
component, add VR button and add XR
component at the root of your application. This will provide context for XR related state.
import { XR } from 'react-xr'
import { VRButton } from 'three/examples/jsm/webxr/VRButton'
function App() {
return (
<Canvas
vr
colorManagement
onCreated={({ gl }) => {
document.body.appendChild(VRButton.createButton(gl))
}}>
<XR>{/* All the stuff goes here */}</XR>
</Canvas>
)
}
You can access controllers' state (position, orientation, etc.) by using useXR()
hook
const { controllers } = useXR()
To get started with default controller models add DefaultXRControllers
component. It will fetch appropriate input profile models. You can learn more here.
import { XR, DefaultXRControllers } from 'react-xr'
import { VRButton } from 'three/examples/jsm/webxr/VRButton'
function App() {
return (
<Canvas
vr
colorManagement
onCreated={({ gl }) => {
document.body.appendChild(VRButton.createButton(gl))
}}>
<XR>
<DefaultXRControllers />
</XR>
</Canvas>
)
}
Context for all XR related state
import { XR } from 'react-xr'
import { VRButton } from 'three/examples/jsm/webxr/VRButton'
function App() {
return (
<Canvas
vr
colorManagement
onCreated={({ gl }) => {
document.body.appendChild(VRButton.createButton(gl))
}}>
<XR>{/* All the stuff goes here */}</XR>
</Canvas>
)
}
Hook that can only beused by components insde component.
const { controllers } = useXR()
Controllers is an array of XRController
objects
interface XRController {
grip: Group
controller: Group
inputSource?: XRInputSource
// ...
// more in XRController.ts
}
grip
and controller
are ThreeJS groups that have the position and orientation of xr controllers. grip
has an orientation that should be used to render virtual objects such that they appear to be held in the user’s hand and controller
has an orientation of the preferred pointing ray.
inputSource
is the WebXR input source (MDN). Note that it will not be available before controller is connected.
Every controller emits following events: select, selectstart, selectend, squeeze, squeezestart, squeezeend.
To listen to those events use useXREvent
hook:
const onSqueeze = useCallback(() => console.log('Squeezed'), [])
useXREvent('squeeze', onSqueeze)
it supports optional third parameter with options
const onSqueeze = useCallback(() => console.log('Left controller squeeze'), [])
useXREvent('squeeze', onSqueeze, { handedness: 'left' })
react-xr
comes with built-in high level interaction components.
Hover
component will allow you for detecting when ray shot from the controllers is pointing at the given mesh.
<Hover onChange={(value) => console.log(value ? 'hovered' : 'blurred')}>{/* your mesh here */}</Hover>
FAQs
[![npm version](https://badge.fury.io/js/react-xr.svg)](https://badge.fury.io/js/react-xr) ![npm](https://img.shields.io/npm/dt/react-xr.svg)
The npm package react-xr receives a total of 64 weekly downloads. As such, react-xr popularity was classified as not popular.
We found that react-xr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.