Sketchfab Forum

Viewer API - force refresh


(Num T) #1

Hello!

I've been experimenting with the viewer API and have hit a bit of a snag with hiding and showing objects. Currently I'm hiding an object by instanceID and then showing it after a delay (just to test this). The issue is that the viewer doesn't update with this change until the view is rotated (I believe this is probably the result of a performance / battery life optimisation). Is there someway to tell the viewer "hey I've changed something - time to force a refresh"?

Cheers

Jon Westlake


#2

Hi Jon,

The hide() and show() function should already force a redraw, even if the camera is not moving. It looks like there is a bug.


#3

As a workaround, you can add 'continuousRender', but it might hurt performance if it's a heavy model.

client.init( urlid, {
    success: success,
    error: error,
    continuousRender: 1
});

(Klaasnienhuis) #4

I've come across this exact same issue, but then with changing colors. I used a method to nudge the camera a little bit.

function NudgeView (api) {
    // Update the camera position by slightly nudging it. This forces the model to update after a 
    // color change. Note that the camera is not actually moved.
        api.getCameraLookAt( function( err, theCamera ){
        api.setCameraLookAt(
            theCamera.position,
            theCamera.target,
            0.0
        );    
    } );
}

You can see I actually don't move the camera at all. I'm using the existing camera and target position.


#5

@stephomi it looks like something is going wrong with the redraw request?