Closed sunjiang0018 closed 3 weeks ago
Hello! Thanks for the contribution. Is there a reason you need a replacement function like this rather than postprocessing the model once it has been loaded? Something like so:
const loader = new URDFLoader();
loader.loadAsync( url ).then( robot => {
robot.traverse( c => {
if ( c.material ) {
const mat = c.material;
c.material = new MeshStandardMaterial( {
color: mat.color,
opacity: mat.opacity,
depthWrite: mat.depthWrite,
transparent: mat.transparent,
} );
}
} );
} );
edit: heh - closed right as a commented 😅
#
Hello! Thanks for the contribution. Is there a reason you need a replacement function like this rather than postprocessing the model once it has been loaded? Something like so:
const loader = new URDFLoader(); loader.loadAsync( url ).then( robot => { robot.traverse( c => { if ( c.material ) { const mat = c.material; c.material = new MeshStandardMaterial( { color: mat.color, opacity: mat.opacity, depthWrite: mat.depthWrite, transparent: mat.transparent, } ); } } ); } );
edit: heh - closed right as a commented 😅
oh, just saw😅. it seems to solve my problem, although it feels a bit inelegant. Thanks anyway
it feels a bit inelegant. Thanks anyway
If there are simple solutions that don't require internal modifications to that class I think it's best. It's easy to wrap this into a custom loader wrapper, as well.
If there's more demand for this or some functionality that's not possible then I'm happy to discuss and reconsider. Thanks again for the contribution!
Currently
URDFLoader
can only loadMeshPhongMaterial
, and cannot load other materials (MeshStandardMaterial
, etc.). AdddefaultMeshLoader
method to load more materials