Skip to content

Commit ebfae45

Browse files
committed
Add a camera rig to set the user height. look-controls is no longer responsible of implicitly setting the user height. It is up to the content creator to build a camera rig that sets the user height as
appropriate. The examples have been updated to reflect this change (fix #3315, #3118, #3051, #2487)
1 parent dffb77c commit ebfae45

File tree

22 files changed

+50
-171
lines changed

22 files changed

+50
-171
lines changed

docs/components/camera.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ to move and rotate the camera.
1616
A camera situated at the average height of human eye level (1.6 meters).
1717

1818
```html
19-
<a-entity camera="userHeight: 1.6" look-controls></a-entity>
19+
<a-entity position="0 1.6 0">
20+
<a-entity camera look-controls></a-entity>
21+
</a-entity>
2022
```
2123

2224
## Properties
@@ -36,22 +38,14 @@ A camera situated at the average height of human eye level (1.6 meters).
3638
If a camera is not specified, A-Frame will inject a default camera:
3739

3840
```html
39-
<a-entity camera="active: true; userHeight: 1.6" look-controls wasd-controls position="0 0 0" data-aframe-default-camera></a-entity>
41+
<a-entity camera="active: true" look-controls wasd-controls position="0 0 0" data-aframe-default-camera></a-entity>
4042
```
4143

4244
If a camera is specified (e.g., our own `<a-camera>` or `<a-entity camera>`),
4345
then the default camera will not be added.
4446

4547
## VR Behavior
4648

47-
When not in VR mode, `userHeight` translates the camera up to approximate
48-
average height of human eye level. The injected camera has this set to 1.6
49-
(meters). When entering VR, this height offset is *removed* such that we used
50-
absolute position returned from the VR headset. The offset is convenient for
51-
experiences that work both in and out of VR, as well as making experiences look
52-
decent from a desktop screen as opposed to clipping the ground if the headset
53-
was resting on the ground.
54-
5549
When exiting VR, the camera will restore its rotation to its rotation *before*
5650
it entered VR. This is so when we exit VR, the rotation of the camera is back
5751
to normal for a desktop screen.

docs/components/look-controls.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ component](camera.md).
3030
| hmdEnabled | Whether to use VR headset pose in VR mode. | true |
3131
| reverseMouseDrag | Whether to reverse mouse drag. | false |
3232
| touchEnabled | Whether to use touch controls in magic window mode. | true |
33-
| userHeight | Height offset to add to the camera when *not* in VR mode so the camera is not on ground level. The default camera that A-Frame injects or the `<a-camera>` primitive sets this to 1.6 meters. But note the default camera component alone (`<a-entity camera>`) defaults this to 0. | 0 |
3433

3534
## Customizing look-controls
3635

@@ -49,8 +48,7 @@ be left maintaining a wide array of flags.
4948

5049
The component lives within a Browserify/Webpack context so you'll need to
5150
replace the `require` statements with A-Frame globals (e.g.,
52-
`AFRAME.registerComponent`, `window.THREE`,
53-
`AFRAME.constants.DEFAULT_CAMERA_HEIGHT`), and get rid of the `module.exports`.
51+
`AFRAME.registerComponent`, `window.THREE`), and get rid of the `module.exports`.
5452

5553
## Caveats
5654

docs/primitives/a-camera.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ source_code: src/extras/primitives/primitives/a-camera.js
99
The camera primitive determines what the user sees. We can change the viewport
1010
by modifying the camera entity's position and rotation.
1111

12-
[userheight]: ../components/camera.md#vr-behavior
13-
14-
Note that by default, the camera origin will be at `0 1.6 0` in desktop mode
15-
and `0 0 0` in VR mode. Read about the [`camera.userHeight` property][userheight].
16-
1712
## Example
1813

1914
```html
@@ -31,7 +26,6 @@ and `0 0 0` in VR mode. Read about the [`camera.userHeight` property][userheight
3126
| fov | camera.fov | 80 |
3227
| look-controls-enabled | look-controls.enabled | true |
3328
| near | camera.near | 0.5 |
34-
| user-height | camera.userHeight | 1.6 |
3529
| reverse-mouse-drag | look-controls.reverseMouseDrag | false |
3630
| wasd-controls-enabled | wasd-controls.enabled | true |
3731

examples/animation/aframe-logo/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
<a-animation attribute="position" from="0 5 0" to="0 0 0" dur="4000"
1818
easing="ease-out"></a-animation>
1919
<a-entity position="0 880 1290" rotation="-34 0 0">
20-
<a-camera id="camera" near="1000" far="4000" fov="2.2" user-height="0"
21-
wasd-controls-enabled="false" look-controls-enabled="false"></a-camera>
20+
<a-camera id="camera" near="1000" far="4000" fov="2.2" wasd-controls-enabled="false" look-controls-enabled="false"></a-camera>
2221
</a-entity>
2322
</a-entity>
2423

examples/animation/generic-logo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</a-assets>
1515

1616
<a-entity>
17-
<a-camera fov="80" near="0.1" wasd-controls-enabled="false" user-height="0"></a-camera>
17+
<a-camera fov="80" near="0.1" wasd-controls-enabled="false"></a-camera>
1818
</a-entity>
1919

2020
<!-- A generic logo made of animated elements -->

examples/animation/pivots/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</a-assets>
1919

2020
<a-entity position="0 0 8">
21-
<a-camera user-height="0"></a-camera>
21+
<a-camera></a-camera>
2222
</a-entity>
2323

2424
<!-- 1 -->

examples/showcase/anime-UI/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</a-assets>
3232

3333
<a-entity position="1.75 0 1.2" rotation="0 28 0">
34-
<a-camera near="0.1" user-height="0"></a-camera>
34+
<a-camera near="0.1"></a-camera>
3535
</a-entity>
3636

3737
<a-entity position="0 0 -3">

examples/showcase/link-traversal/js/components/ground.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ AFRAME.registerComponent('ground', {
1515
value.geometry.computeFaceNormals();
1616
value.geometry.computeVertexNormals();
1717
value.receiveShadow = true;
18-
value.material.shading = THREE.FlatShading;
18+
value.material.flatShading = THREE.FlatShading;
1919
}
2020
});
2121
self.el.setObject3D('ground', obj);

examples/showcase/tracked-controls/components/ground.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ AFRAME.registerComponent('ground', {
1414
objectLoader.load(MODEL_URL, function (obj) {
1515
obj.children.forEach(function (value) {
1616
value.receiveShadow = true;
17-
value.material.shading = THREE.FlatShading;
17+
value.material.flatShading = THREE.FlatShading;
1818
});
1919
object3D.add(obj);
2020
});

examples/showcase/tracked-controls/index.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
material="color: #EF2D5E;"></a-mixin>
2828
</a-assets>
2929

30-
<!-- Hands -->
31-
<a-entity hand-controls="left" aabb-collider="objects: .cube;" grab></a-entity>
32-
<a-entity hand-controls="right" aabb-collider="objects: .cube;" grab></a-entity>
33-
3430
<!-- A-Frame cubes -->
3531
<a-entity position="0 0 -0.5">
3632
<a-entity class="cube" mixin="cube" position="0.30 1.65 0"></a-entity>
@@ -62,8 +58,11 @@
6258
<a-entity light="type: point; color: #f4f4f4; intensity: 0.6; distance: 0" position="-8 10 -18"></a-entity>
6359
<a-entity light="type: ambient; color: #f4f4f4; intensity: 0.4;" position="-8 10 -18"></a-entity>
6460
</a-entity>
65-
<a-camera></a-camera>
66-
61+
<a-entity position="0 1.6 0">
62+
<!-- Hands -->
63+
<a-entity hand-controls="left" aabb-collider="objects: .cube;" grab></a-entity>
64+
<a-entity hand-controls="right" aabb-collider="objects: .cube;" grab></a-entity>
65+
</a-entity>
6766
</a-scene>
6867
</body>
6968
</html>

0 commit comments

Comments
 (0)