2016-11-09 20 views
0
var obj = document.querySelector("#sphere"); 
obj.components.material.data.roughness = 0.3; 
obj.components.material.update(object); 
obj.components.material.flushToDOM(); 
//I don't think object matters for this use, 
// it is only useful for shaders I believe. 

我想“flushToDOM()”,但似乎并没有在所有它仍然停留在初始设置更新实体HTML材料...冲洗材料更新到HTML中AFRAME

<a-sphere id="sphere" position="0 0.25 -4.5" radius="1.25" color="#712ef0" transparent="true" material="color:#712ef0;transparent:true;metalness:0.3;opacity:1" geometry="primitive:sphere;radius:1.25" rotation="0 0 0" scale="1 1 1"> 

回答

2

您应该使用setAttribute('material', 'roughness', 0.3)

但是,可能会出现像着色器和几何图形一样冲洗“子组件”的错误。将检查出这个问题。

+0

这很快,会在一分钟内尝试标记为正确。谢谢。 – msj121

+0

哇,它不会让我接受这么快的答案......但是,这工作完美,哇,我一直在尝试不同的方法相当一段时间。谢谢。将在〜9分钟内标记正确 – msj121