Aframe 基线未对齐文本
Aframe baseline not aligning for text
为什么这个文本出现在方框的中间?我认为 baseline: top
会将其与包含实体的顶部对齐。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
</head>
<body>
<a-scene background="color: #FAFAFA">
<a-entity
position="0 2 -3"
geometry="primitive: plane; width: 3; height: 3;"
material="shader: flat; color: red;"
>
<a-entity
position="0 0 0.01"
text="color: black; baseline: top; value: test;"
></a-entity>
</a-entity>
</a-scene>
</body>
</html>
基线基本上告诉文本组件 Y 位置是指文本本身的底部、中心还是顶部(即“测试”一词),而不是父实体。您仍然需要更改文本位置以将其移动到顶部(在您的情况下,将 Y 位置设置为 1.5,即平面高度的一半)。通过设置 baseline: top
,您可以确保 multi-line 文本向下流动到平面上而不是向上溢出。
您可以看到 this example from the text component documentation and its corresponding code 中说明的不同属性。
为什么这个文本出现在方框的中间?我认为 baseline: top
会将其与包含实体的顶部对齐。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
</head>
<body>
<a-scene background="color: #FAFAFA">
<a-entity
position="0 2 -3"
geometry="primitive: plane; width: 3; height: 3;"
material="shader: flat; color: red;"
>
<a-entity
position="0 0 0.01"
text="color: black; baseline: top; value: test;"
></a-entity>
</a-entity>
</a-scene>
</body>
</html>
基线基本上告诉文本组件 Y 位置是指文本本身的底部、中心还是顶部(即“测试”一词),而不是父实体。您仍然需要更改文本位置以将其移动到顶部(在您的情况下,将 Y 位置设置为 1.5,即平面高度的一半)。通过设置 baseline: top
,您可以确保 multi-line 文本向下流动到平面上而不是向上溢出。
您可以看到 this example from the text component documentation and its corresponding code 中说明的不同属性。