|
1 | 1 | import { Canvas, useThree } from '@react-three/fiber'
|
2 |
| -import { createXRStore, useHover, XR, XRLayer } from '@react-three/xr' |
| 2 | +import { createXRStore, useHover, XR, XRLayer, XROrigin } from '@react-three/xr' |
3 | 3 | import { Text } from '@react-three/drei'
|
4 | 4 | import { useEffect, useMemo, useRef } from 'react'
|
5 | 5 | import { Mesh, SRGBColorSpace, VideoTexture } from 'three'
|
@@ -27,29 +27,30 @@ export function App() {
|
27 | 27 | <Canvas
|
28 | 28 | events={() => ({ enabled: false, priority: 0 })}
|
29 | 29 | style={{ width: '100%', flexGrow: 1 }}
|
30 |
| - camera={{ position: [0, 1.5, 0], rotation: [0, 0, 0] }} |
| 30 | + camera={{ position: [0, 0, 0], rotation: [0, 0, 0] }} |
31 | 31 | >
|
32 | 32 | <SwitchToXRPointerEvents />
|
33 | 33 | <XR store={store}>
|
34 |
| - <Text scale={0.03} color="black" position={[-0.6, 1.78, -0.5]}> |
| 34 | + <Text scale={0.03} color="black" position={[-0.6, 0.28, -0.5]}> |
35 | 35 | 32x32 XRLayer with DPR=32
|
36 | 36 | </Text>
|
37 |
| - <XRLayer dpr={32} pixelWidth={32} pixelHeight={32} position={[-0.6, 1.5, -0.5]} scale={0.5} shape="quad"> |
| 37 | + <XROrigin position={[0, -1.5, 0]} /> |
| 38 | + <XRLayer dpr={32} pixelWidth={32} pixelHeight={32} position={[-0.6, 0, -0.5]} scale={0.5} shape="quad"> |
38 | 39 | <mesh>
|
39 | 40 | <boxGeometry />
|
40 | 41 | <meshBasicMaterial color="red" toneMapped={false} />
|
41 | 42 | </mesh>
|
42 | 43 | </XRLayer>
|
43 | 44 |
|
44 |
| - <Text scale={0.03} color="black" position={[0, 1.78, -0.5]}> |
| 45 | + <Text scale={0.03} color="black" position={[0, 0.28, -0.5]}> |
45 | 46 | With XRLayer
|
46 | 47 | </Text>
|
47 |
| - <XRLayer position={[0, 1.5, -0.5]} onClick={() => video.play()} scale={0.5} shape="quad" src={video} /> |
| 48 | + <XRLayer position={[0, 0, -0.5]} onClick={() => video.play()} scale={0.5} shape="quad" src={video} /> |
48 | 49 |
|
49 |
| - <Text scale={0.03} color="black" position={[0.6, 1.78, -0.5]}> |
| 50 | + <Text scale={0.03} color="black" position={[0.6, 0.28, -0.5]}> |
50 | 51 | Without XRLayer
|
51 | 52 | </Text>
|
52 |
| - <mesh position={[0.6, 1.5, -0.5]} scale={0.5}> |
| 53 | + <mesh position={[0.6, 0, -0.5]} scale={0.5}> |
53 | 54 | <planeGeometry />
|
54 | 55 | <meshBasicMaterial map={videoTexture} toneMapped={false} />
|
55 | 56 | </mesh>
|
|
0 commit comments