我正在使用aframe加载.obj和.mtl,一切似乎都很好。但是,我无法更改子节点的材料。有人曾经克服过这个吗?
这是我到目前为止所做的事情
< a - entity id = "model" position = "0 0 0"
< a - entity obj - model = "obj: #tree-obj; mtl: #tree-mtl" position = "-.35
0 .55" rotation = "0 -20 0" scale = "1. 1. 1." > < /a-entity>
< /a-entity>
遍历子项的Java脚本代码
var tex = THREE.ImageUtils.loadTexture( "tex.jpg" );
var cover = new THREE.MeshPhongMaterial( {
name:"set2",
map:tex,
specular: 0x0f8191,
emissive: null,
emissiveIntensity : null,
} )
var el = this.el;
el.object3D.traverse(function( child ) { if (child.material.name == "set2") {
child.material = cover;
child.castShadow = true;
child.receiveShadow = true;
child.material.needsUpdate=true;
}
});
请告诉我我错过的地方。