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

position

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

The position component places entities at certain spots in 3D space. Position takes a coordinate value as three space-delimited numbers.

All entities inherently have the position component.

Example

            
              <
                a-entity
                position=
                "0 1 -1">
              </
                a-entity>
          

Value

A-Frame uses a right-handed coordinate system where the negative Z axis extends into the screen. The table below assumes looking down the negative Z axis from the origin.

AxisDescriptionDefault Value
xNegative X axis extends left. Positive X Axis extends right.0
yNegative Y axis extends down. Positive Y Axis extends up.0
zNegative Z axis extends in. Positive Z Axis extends out.0

Relative Positioning

World-space positions of child entities inherit from parent entities. Consider this scene:

            
              <
                a-entity
                id=
                "parent"
                position=
                "1 2 3">
            
              <
                a-entity
                id=
                "child-1">
              </
                a-entity>
            
              <
                a-entity
                id=
                "child-2"
                position=
                "2 3 4">
              </
                a-entity>
            
              </
                a-entity>
          

The world-space position of #child1would be 1 2 3as inherited by the entity. In the local parent’s space, #child1‘s position would be 0 0 0.

The world-space position of #child2would be 3 5 7, by combining the position with the parent entity. In the parent’s local space, #child2‘s position would be 2 3 4.