当前位置: 首页 > 文档资料 > A-Frame 中文文档 >

<a-camera>

优质
小牛编辑
120浏览
2023-12-01

The camera primitive determines what the user sees. We can change the viewport by modifying the camera entity’s position and rotation.

Note that by default, the camera origin will be at 0 1.6 0 in desktop mode and 0 0 0 in VR mode. Read about the camera.userHeight property.

Example

<a-scene>  <a-box></a-box>  <a-camera></a-camera></a-scene>

Attributes

AttributeComponent MappingDefault Value
farcamera.far10000
fovcamera.fov80
look-controls-enabledlook-controls.enabledtrue
nearcamera.near0.5
user-heightcamera.userHeight1.6
reverse-mouse-draglook-controls.reverseMouseDragfalse
wasd-controls-enabledwasd-controls.enabledtrue

Manually Positioning the Camera

To position the camera, set the position on a wrapper <a-entity>. Don’t set the position directly on the camera primitive because controls will quickly override the set position:

<a-entity position="0 0 5">  <a-camera></a-camera></a-entity>