Back to Aframe

A Image

docs/primitives/a-image.md

1.7.11.6 KB
Original Source

The image primitive shows an image on a flat plane.

Example

html
<a-scene>
  <a-assets>
    
  </a-assets>

  <!-- Using the asset management system. -->
  <a-image src="#my-image"></a-image>

  <!-- Defining the URL inline. Not recommended but more comfortable for web developers. -->
  <a-image src="another-image.png"></a-image>
</a-scene>

Attributes

AttributeComponent MappingDefault Value
colormaterial.color#FFF
heightgeometry.height1
metalnessmaterial.metalness0
opacitymaterial.opacity1
repeatmaterial.repeatNone
roughnessmaterial.roughness0.5
segments-heightgeometry.segmentsHeight1
segments-widthgeometry.segmentsWidth1
shadermaterial.shaderflat
sidematerial.sidefront
srcmaterial.srcNone
transparentmaterial.transparenttrue
widthgeometry.width1

Fine-Tuning

Ensuring that the image is not distorted by stretching requires us to appropriately set the width and height preserving the original aspect ratio of the image. This properties are set in meters, don't confuse with pixels.

For example, a 2:1 image:

html
<a-image src="#logo" width="3" height="1.5"></a-image>