我正在框架中注册一个由其他基元组成的基元。但我想独立地缩放和定位这些内部基元。但是由于位置本身是一个组件,这些内部基元没有位置,因此我无法移动它们。
如何在作为我要注册的原语的一部分的原语的组件上设置值?
AFRAME.registerPrimitive('a-svrbutton', {
defaultComponents: {
geometry: {
primitive: 'box',
height: 1.5,
depth: 0.2,
width: 3.5
},
material: {
opacity: 1.0,
transparent: true,
side: 'Double',
color: '#8450ff'
},
position: {
x: 0,
y: 0,
z: -5
},
'bmfont-text': {
text: 'hola',
color: '#ffffff'
},
},
mappings: {
height: 'geometry.height',
width: 'geometry.width',
depth: 'geometry.depth',
color: 'material.color',
opacity: 'material.opacity',
position: 'position'
}
});
<script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script>
<a-scene>
<a-svrbutton id="mybutton" position="0 0 -5"></a-svrbutton>
</a-scene>
确保您的浏览器支持 WebVR 以运行上面的代码片段。
我想将默认“组件”bmfont-text 中的默认位置定义为任意 xy 和 z。但我不能,因为这个“原始”本身没有位置组件。我怎样才能做到这一点?