【发布时间】:2019-10-29 04:11:32
【问题描述】:
我正在尝试更改我在搅拌机中创建的对象的颜色。我可以在 html 代码本身中更改对象的颜色,例如“a-box,a-sphere”,但对于 tree.js(gltf 或 .dae - collada)中的对象,我不能。
CodePen(这只是我的真实项目(AR.JS)中未来应用的测试环境)
<html>
<head>
<script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
</head>
<body>
<a-scene>
<a-gltf-model id="test" src="https://raw.githubusercontent.com/KurtRodrigues/KurtRodrigues.github.io/master/Arquivos%20utilizados/Pe%C3%A7a%2Bbancada_V2.gltf" color="#FF0000" position="0 0 -3" rotation="0 0 0" scale="1.5 1.5 1.5" size="20px"> </a-gltf-model>
<a-sky color="#ECECEC"></a-sky>
</a-scene>
</body>
</html>
已经试过了:
HTML 与 color= # ff00000。
CSS by id .test {color: # ff0000}
JS:
var b = document.querySelector ("test");
b.setAttribute ("color", "red");
有什么方法可以直接在代码中更改对象的颜色,或者只是在我制作对象的时候(搅拌机)?
【问题讨论】:
-
你
document.querySelector的参数不对,应该是#test
标签: javascript html css aframe ar.js