我正在註冊由其他基元組成的框架中的基元。但我想要獨立地縮放和定位這些內部原語。但是由於位置本身就是一個組成部分,所以這些內部基元沒有位置,因此我無法移動它們。如何設置元素的組成部分的值,這些元素是我在aframe中註冊的基元的一部分?
如何設置原始組件的值,這是我想要註冊的基元的一部分?
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爲運行上面的代碼片段。
我想在默認的「components」bmfont-text中將默認位置定義爲任意的xy和z。但我不能,因爲這個'原始'本身沒有位置組件。我怎樣才能做到這一點?
您可以包含迄今爲止嘗試過的示例代碼嗎?有不同的方法來設置bmfont,並且我不知道還有哪些其他原語(可能是指組件?)。你可以在任何元素上放置位置,即使它是一個不會影響位置的基元。 –
是的,我想知道這是與模板相關,還是與組件+基元相關。 – ngokevin