Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could we skip off-screen scenes rendering? #18

Open
Peque opened this issue Aug 5, 2020 · 0 comments
Open

Could we skip off-screen scenes rendering? #18

Peque opened this issue Aug 5, 2020 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed

Comments

@Peque
Copy link
Collaborator

Peque commented Aug 5, 2020

We used to have this check in the loop:

    scenes.forEach( function ( scene ) {

        var rect = scene.userData.view.getBoundingClientRect();
        // check if it's offscreen. If so skip it
        if ( rect.bottom < 0 || rect.top > renderer.domElement.clientHeight ||
             rect.right < 0 || rect.left > renderer.domElement.clientWidth ) {

            return; // it's off screen

        }

        // set the viewport
        var width = rect.right - rect.left;
        var height = rect.bottom - rect.top;
        var left = rect.left;
        var bottom = renderer.domElement.clientHeight - rect.bottom;

        renderer.setViewport( left, bottom, width, height );
        renderer.setScissor( left, bottom, width, height );

        var camera = scene.userData.camera
        camera.aspect = width / height;
        camera.updateProjectionMatrix();

        renderer.render( scene, scene.userData.camera );

    } );

However, it resulted in scenes "sticking" when scrolling up/down.

How to reproduce: go to one scene and scroll fast up or down. The scene, or part of it, may get stuck to the view, as long as another scene does not appear with the scroll (i.e.: try to scroll away from any scenes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant