xml3d / xml3d.js

The WebGL/JS implementation of XML3D
Other
75 stars 25 forks source link

Render tree doesn't update with window resize #189

Open Arsakes opened 8 years ago

Arsakes commented 8 years ago

In case user switches between two render trees from A to B there is a possiblity that A tree won't display corrent image. It happens every time user changes window size when using B render tree - in such case A render tree doesn't get informed about change and when swtiching back to A the image is scaled.

What is the best way to update custom renderTree so it takes into account changes in window size?

csvurt commented 8 years ago

I think right now we don't resize the buffers individually. Internally if the canvas changes size we just rebuild the entire RenderTree from scratch, so that would be the easiest thing to do in your case too.

You'd have to be careful to avoid race conditions because the RenderInterface may not be updated with the new canvas size until the next frame is drawn after a resize. Best bet would be to store a flag like needsResize in both RenderTrees and then recreate A the next time you switch from B to A. B should be recreated automatically by XML3D so long as it was the active tree when the resize happened.