glodrei
Version:
useful add-ons for react-three-fiber
30 lines (27 loc) • 644 B
JSX
import React, { useRef } from 'react'
import ReactDOM from 'react-dom'
import { Canvas, useFrame } from '@react-three/fiber'
import './styles.css'
function Thing() {
const ref = useRef(null)
useFrame(() => {
ref.current.rotation.x = ref.current.rotation.y += 0.01
})
return (
<mesh
ref={ref}
onClick={(e) => console.log('click')}
onPointerOver={(e) => console.log('hover')}
onPointerOut={(e) => console.log('unhover')}
>
<boxGeometry args={[1, 1, 1]} />
<meshNormalMaterial />
</mesh>
)
}
ReactDOM.render(
<Canvas>
<Thing />
</Canvas>,
document.getElementById('root')
)