openglthree.jscolladabump-mapping

Three.js ColladaLoader bumpScale/weighting? Way to adjust bump map intensity


In the current ColladaLoader.js I don't see anything that reads or applies the Collada standard's "weighting" value (0.0-1.0) that indicates bump intensity or "bumpScale" in Three.js Phong material. I noticed that when I export my collada from Blender it picks up the bump materials instantly in three.js (which is amazingly simple - YAY!) but my materials always get an exaggerated bumpScale of default 1.0. It gives the materials an exaggerated bumpiness.

I managed to edit my ColladaLoader a bit and try out my ideal value (0.05) but wonder if I'm missing something or doing this wrong? Anybody else try this? Note that I've not had good luck with json exports so I'm sticking with Collada for now.

Thanks


Solution

  • You can set custom properties in the Collada callback. Use a pattern like this one:

    loader.load( 'collada.dae', function ( collada ) {
    
            var dae = collada.scene;
    
            dae.traverse( function( child ) {
    
                if( child instanceof THREE.Mesh ) {
    
                    child.material.bumpScale = value;
    
                }
    
            } );
    
            scene.add( dae );
    
    } );
    

    three.js r.71