AMP
  • stories

amp-story-360

Introduction

The amp-story-360 component embeds 360 images and videos, explorable by gyroscope or animatable between points.

To begin, import amp-story-360 along with your other stories imports.

<script async custom-element="amp-story-360" src="https://cdn.ampproject.org/v0/amp-story-360-0.1.js"></script>

We also import amp-video since we will use a 360 video.

<script async custom-element="amp-video" src="https://cdn.ampproject.org/v0/amp-video-0.1.js"></script>

Basic usage

The amp-story-360 component accepts 1 descendant, an amp-img or amp-video.

On this page we embed a 360 image using amp-img and set a default PoV (point of view).

Use the -start attributes to define the initial PoV:
- heading-start Horizontal angle in degrees. Centered on 0 (default) with a negative angle looking towards the left, positive angle to the right.
- pitch-start Vertical angle in degrees. Centered on 0 (default) at the horizon, with a negative angle looking downwards, positive angle upwards.
- zoom-start This corresponds to a horizontal field of view of 90 degrees. The default is 1. A higher value indicates a narrower field of view.

Photo credit: NASA / JPL / MSSS / Seán Doran.

<amp-story-page id="360-image-1">
  <amp-story-grid-layer template="fill">
    <amp-story-360 layout="fill"
    heading-start="115"
    pitch-start="10"
    zoom-start="1">
      <amp-img
        src="/static/samples/img/amp-story-360.jpg" width="4300" height="2150" alt="...">
      </amp-img>
    </amp-story-360>
  </amp-story-grid-layer>
</amp-story-page>

Defining the animation

Add the -end and duration attributes to animate between the start and end PoV: - heading-end The heading of a complete animation.
- pitch-end The pitch of a complete animation.
- zoom-end The zoom of a complete animation.
- duration How many seconds (s) or milliseconds (ms) an animation takes to complete.

<amp-story-page id="360-image-2">
  <amp-story-grid-layer template="fill">
    <amp-story-360 layout="fill"
      heading-start="115"
      pitch-start="10"
      zoom-start="1"
      heading-end="50"
      pitch-end="-5"
      zoom-end="1.33"
      duration="3s">
      <amp-img
        src="/static/samples/img/amp-story-360.jpg" width="4300" height="2150" alt="...">
      </amp-img>
    </amp-story-360>
  </amp-story-grid-layer>
</amp-story-page>

Gyroscope controls

Add controls="gyroscope" to set the PoV using the devices gyroscope sensor.

If the gyroscope sensor is not available the component will default to animating.
If the device requires permission for the sensor an activate-360 button will display.

Serving over https is required to access the device's gyroscope.

Currently, the amp-story-360 component does not provide any controls for mouse or keyboard users.

<amp-story-page id="360-image-3">
  <amp-story-grid-layer template="fill">
    <amp-story-360 layout="fill"
      heading-start="115"
      pitch-start="10"
      zoom-start="1"
      heading-end="50"
      pitch-end="-5"
      zoom-end="1.33"
      duration="3s"
      controls="gyroscope">
      <amp-img
        src="/static/samples/img/amp-story-360.jpg" width="4300" height="2150" alt="...">
      </amp-img>
    </amp-story-360>
  </amp-story-grid-layer>
</amp-story-page>

amp-video

We use the same attributes for this component but pass an amp-video child.

Video credit: NASA.

<amp-story-page id="360-video-1">
  <amp-story-grid-layer template="fill">
    <amp-story-360 layout="fill"
      heading-start="30" 
      pitch-start="20" 
      zoom-start="1"
      heading-end="-20" 
      pitch-end="10" 
      zoom-end="1.33"
      duration="3s"
      controls="gyroscope">
      <amp-video poster="img/amp-story-360-video-cover.jpg" autoplay layout="fill" loop>
        <source src="/static/samples/video/amp-story-360.mp4" type="video/mp4" />
      </amp-video>
    </amp-story-360>
  </amp-story-grid-layer>
</amp-story-page>

More Resources

If you want to learn more about 360 content for Web Stories, head over to the documentation.

자세한 설명이 필요하신가요?

이 페이지의 설명만으로 궁금한 점이 모두 해결되지 않는다면 다른 AMP 사용자에게 문의하여 구체적인 활용 사례를 논의해 보세요.

Stack Overflow로 이동
설명이 부족한 기능을 발견하셨나요?

AMP 프로젝트는 여러분의 참여와 기여를 적극 환영합니다! 오픈 소스 커뮤니티를 통해 지속적으로 활동해 주셔도 좋지만 관심 있는 주제에 한 번만 기여하셔도 큰 도움이 됩니다.

GitHub에서 샘플 수정하기