X3DOM更新属性

时间:2013-10-04 16:58:09

标签: javascript webgl x3dom

我尝试更新形状的颜色,但它没有改变(尽管F12说,属性已更新)

 <transform scale="10 10 10" onmousedown="$('#matT').attr('diffuseColor', '0 0 1');">               
      <shape def="boxshape11">
           <appearance def="boxApp11">
                 <material id="matT" diffuseColor="1 1 0" specularColor=".5 .5 .5" />
            </appearance>
            <box def="box1" />
       </shape>
  </transform> 

1 个答案:

答案 0 :(得分:1)

使用prop代替attr解决问题

 <transform scale="10 10 10" onmousedown="$('#matT').prop('diffuseColor', '0 0 1');">               
      <shape def="boxshape11">
           <appearance def="boxApp11">
                 <material id="matT" diffuseColor="1 1 0" specularColor=".5 .5 .5" />
            </appearance>
            <box def="box1" />
       </shape>
  </transform>