Viewer Background Color


(Avinash Srivastava) #1

Hi,I am initializing Viewer using below method and trying to set model background color to specific hexadecimal color but seems it is not working. I am pasting my code here in forum for reference. Please let me know how i can change the background color.

init3DViewer(modelId){

    var iframe = document.getElementById('3dViewer');
    var version = '1.0.0';
    var viewerModelId = modelId;
    var client = new Sketchfab( version, iframe );      
    
    client.init( viewerModelId, {
        success: function onSuccess( api ){
            api.start();
            api.addEventListener( 'viewerready', function() {
                //API is ready to use
                console.log( 'Viewer is ready' );
            } );
        },
        error: function onError() {
            console.log( 'Viewer error' );
        },
        autostart: 1,
        autospin:0,
        preload:1,
        ui_stop:0,
        transparent:0,
        ui_controls:0,
        ui_general_control:0,
        ui_help:0,
        //navigation:'fps',
        ui_infos:0,
        background :{"color": "#ffffff"}
    } );
}

#2

We don't support that in the Viewer API, but it's an interesting idea.


(Aleahy) #3

Hi, If you can cope with the aliasing artefacts on the edge of your model you could use a transparent background on initialization and then set the iframe background with CSS.

See this thread...

Cheers, Andrew