#BlackLivesMatter
AMP
  • websites

amp-3d-gltf

Introduction

The amp-3d-gltf component displays 3D models that are in glTF format. The doc describing this element can be found here

Note: A WebGL capable browser is required to display these models.

Setup

Import the amp-3d-gltf component in the header.

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

Basic Usage

Embed 3d model via the src attribute.

<amp-3d-gltf layout="fixed"
  width="320"
  height="240"
  src="/static/samples/glTF/DamagedHelmet.glb"></amp-3d-gltf>

Customization

You can customize the 3D model using these attributes: src - A required attribute that specifies the URL to the glTF file. alpha - A Boolean attribute that specifies whether free space on canvas is transparent. By default, free space is filled with black. Default value is false. antialiasing - A Boolean attribute that specifies whether to turn on antialiasing. Default value is false. maxPixelRatio - A numeric value that specifies the upper limit for the pixelRatio render option. The default is window.devicePixelRatio. autoRotate - A Boolean attribute that specifies whether to automatically rotate the camera around the model's center. Default value is false. enableZoom - A Boolean attribute that specifies whether to turn on zoom. Default value is true.

<amp-3d-gltf layout="fixed"
  width="320"
  height="240"
  alpha="true"
  antialiasing="true"
  autorotate="true"
  enablezoom="false"
  src="/static/samples/glTF/DamagedHelmet.glb"></amp-3d-gltf>
需要进一步说明?

如果此页面的说明未能涵盖您的所有问题,欢迎与其他 AMP 用户取得联系,讨论您的具体用例。

前往 Stack Overflow
一项无法解释的功能?

AMP 项目强烈鼓励您参与其中并作出贡献!我们希望您能成为我们开源社区的持续参与者,但我们也欢迎您对热衷问题做出单次贡献。

在 GitHub 上编辑实例