Skip to content

Commit e3b6cba

Browse files
committed
Merge branch 'main' of https://github.com/pmndrs/xr
2 parents b094251 + c2e2cbb commit e3b6cba

File tree

3 files changed

+87
-25
lines changed

3 files changed

+87
-25
lines changed

.github/workflows/static.yml

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ on:
66
- main
77

88
jobs:
9-
deploy-static-files:
9+
docs:
10+
uses: pmndrs/docs/.github/workflows/build.yml@main
11+
with:
12+
mdx: './docs'
13+
libname: 'xr'
14+
base_path: '/xr/docs'
15+
icon: '🤳'
16+
home_redirect: '/getting-started/introduction'
17+
18+
examples:
1019
runs-on: ubuntu-latest
11-
permissions:
12-
contents: write
1320
steps:
14-
1521
- name: Checkout code
1622
uses: actions/checkout@v3
1723

@@ -46,12 +52,56 @@ jobs:
4652
cp -r ./examples/watch/dist/* ./public/examples/watch
4753
cp -r ./examples/room-with-shadows/dist/* ./public/examples/room-with-shadows
4854
49-
# Deploy to GH Pages
50-
- name: Add no jekyll
51-
run: touch public/.nojekyll
55+
- name: Upload Artifact
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: examples
59+
path: public/examples/
60+
61+
bundle-artifacts:
62+
runs-on: ubuntu-latest
63+
needs:
64+
- docs
65+
- examples
66+
steps:
67+
- name: Download Examples Artifiact
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: examples
71+
path: ./examples
72+
73+
- name: Download Docs Artifiact
74+
uses: actions/download-artifact@v4
75+
with:
76+
name: github-pages
77+
path: ./docs
5278

53-
- name: Deploy
54-
uses: JamesIves/github-pages-deploy-action@v4
79+
- name: Extract Docs
80+
run: tar -xf ./docs/artifact.tar -C ./docs/
81+
82+
- name: Create deploy.tar
83+
run: tar -cf deploy.tar ./*
84+
85+
- name: Upload Artifact
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: deploy
89+
path: ./deploy.tar
90+
91+
deploy:
92+
needs: bundle-artifacts
93+
runs-on: ubuntu-latest
94+
permissions:
95+
pages: write # to deploy to Pages
96+
id-token: write # to verify the deployment originates from an appropriate source
97+
98+
# Deploy to the github-pages environment
99+
environment:
100+
name: github-pages
101+
url: ${{ steps.deployment.outputs.page_url }}
102+
103+
steps:
104+
- id: deployment
105+
uses: actions/deploy-pages@v4
55106
with:
56-
branch: gh-pages
57-
folder: public
107+
artifact_name: deploy

docs/advanced/pitfalls.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,17 @@ If you cannot enter the VR or AR experience while the assets in your scene are l
4141
## XRSpace
4242

4343
If you are placing `<XRSpace>` components outside of the `<XROrigin>` while changing the transformation of the `<XROrigin>` (e.g. by setting `<XROrigin position={[0,1,0]} />`), the elements rendered inside of the `<XRSpace>` will not be transformed with the origin. If the transformations of the origin should be applied to the `<XRSpace>`, make sure to place those components inside the `<XROrigin>`. Not placing `<XRSpace>` components into the `<XROrigin>` can be useful in scenarios where you want to move the `<XROrigin>` independently from the `<XRSpace>`. For instance, building a virtual elevator where your actual room is duplicated into the x-axis so that you can use the elevator to travel between multiple instances of your room.
44+
45+
## OrbitControls
46+
47+
If you have OrbitControls in your scene, make sure to place an `<IfInSessionMode>` guard around them when in XR. Having OrbitControls enabled causes the VR camera to report false values and behave in strange ways.
48+
49+
```tsx
50+
const OrbitControlsWrapper = () => {
51+
return (
52+
<IfInSessionMode deny={['immersive-ar', 'immersive-vr']} >
53+
<OrbitControls />
54+
</IfInSessionMode>
55+
)
56+
}
57+
```

examples/minecraft/src/VRPlayerControl.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,28 @@ export function VRPlayerControl({
2626
}) {
2727
const originRef = useRef<THREE.Group>(null)
2828

29-
const controllerLeft = useXRControllerState('right')
30-
const controllerRight = useXRControllerState('left')
29+
const controllerLeft = useXRControllerState('left')
30+
const controllerRight = useXRControllerState('right')
3131

3232
useFrame((state, delta) => {
33-
if (controllerRight != null) {
34-
const thumbstick = controllerRight.gamepad?.['xr-standard-thumbstick']
35-
if (originRef.current != null && thumbstick?.xAxis != null && thumbstick.xAxis != 0) {
36-
originRef.current.rotateY((thumbstick.xAxis < 0 ? 1 : -1) * TURN_SPEED * delta)
37-
}
33+
const thumbstickRight = controllerRight?.gamepad?.['xr-standard-thumbstick']
34+
if (originRef.current != null && thumbstickRight?.xAxis != null && thumbstickRight.xAxis != 0) {
35+
originRef.current.rotateY((thumbstickRight.xAxis < 0 ? 1 : -1) * TURN_SPEED * delta)
3836
}
3937

40-
if (controllerLeft?.gamepad?.['a-button']?.state === 'pressed') {
38+
if (controllerRight?.gamepad?.['a-button']?.state === 'pressed') {
4139
playerJump?.()
4240
}
4341

44-
const thumbstick = controllerLeft?.gamepad['xr-standard-thumbstick']
45-
if (thumbstick?.xAxis != null && thumbstick.yAxis != null) {
42+
const thumbstickLeft = controllerLeft?.gamepad['xr-standard-thumbstick']
43+
if (thumbstickLeft?.xAxis != null && thumbstickLeft.yAxis != null) {
4644
state.camera.getWorldQuaternion(helpers.quaternion)
4745

4846
playerMove?.({
49-
forward: thumbstick.yAxis < 0,
50-
backward: thumbstick.yAxis > 0,
51-
left: thumbstick.xAxis < -THUMBSTICK_X_WIGGLE,
52-
right: thumbstick.xAxis > THUMBSTICK_X_WIGGLE,
47+
forward: thumbstickLeft.yAxis < 0,
48+
backward: thumbstickLeft.yAxis > 0,
49+
left: thumbstickLeft.xAxis < -THUMBSTICK_X_WIGGLE,
50+
right: thumbstickLeft.xAxis > THUMBSTICK_X_WIGGLE,
5351

5452
// rotation: state.camera.rotation
5553
rotation: helpers.euler.setFromQuaternion(helpers.quaternion),

0 commit comments

Comments
 (0)