Reputation: 413
I'm trying to apply a material to a custom 3d mesh in A-frame (based on Three.js) but it doesn't work (ie the model keeps it's original material) Any idea of what could be the problem?
Bellow my scene where "ruban4" is a random Collada model exported from Blender.
<a-scene>
<a-assets>
<a-asset-item id="ruban" src="ruban4.dae">
</a-assets>
<a-collada-model
src="#ruban"
material="shader: flat; color: #93d400;"
position=" 10 10 0">
</a-collada-model>
</a-scene>
Update: Seems to be specific to Collada, works fine with .obj and .mtl
Upvotes: 2
Views: 1669
Reputation: 13233
Giving an alternative to Diego's answer, once the COLLADA model is imported into your scene, you can traverse through its scenegraph and manually modify individual pieces if you want. It's a bit more hacky, but possible.
Poke around:
myColladaEl.getObject3D('mesh');
Upvotes: 2
Reputation: 4585
Collada models should be treated as black boxes. If you want to modify the model or its textures you should do it in your 3d package of choice. Collada models usually contain multiple geometries, animations, textures and mappings (They import a complete sub scene). The aframe material does not apply because it cannot be done in a predictable way. Which texture is going to be replaced? Aframe would need knowledge of the author's intent.
OBJ works because the format describes a simple geometry and apply a material can be done predictably.
Upvotes: 3