Viglino/ol-ext

Swipe with WebGlTile: Left side doesn't update

Closed this issue · 2 comments

I have two WebGlTile layers and it seems the drawing to one side doesn't work always. Moving to the left works, but to the right it doesn't refresh. If I enforce a redraw by slightly changing the size of the windows, it redraws and it looks correct again (click play):

redraw-swipe

It also sometimes happens on first load of data.

I've set className for each layer according to #1047
Seems somewhat similar to #1051

Firefox 128.0, OpenLayers 9.2.4, ol-ext 4.0.19

If I remove the conditional around the if (this._time != e.frameState.time) in https://github.com/Viglino/ol-ext/blob/master/src/control/Swipe.js#L308-L312 it works for me:

So just:

  precomposeLeft(e) {
    var ctx = e.context;
    if (ctx instanceof WebGLRenderingContext) {
      if (e.type === 'prerender') {
        // Clear
        ctx.clearColor(0, 0, 0, 0);
        ctx.clear(ctx.COLOR_BUFFER_BIT);

        // Clip
        ctx.enable(ctx.SCISSOR_TEST);

I'm not sure abot the side-effects though.

The issue is that left and right use the same variable to store the e.frameState.time, i.e. one of them is skipped when the time is the same. Can be fixed by using two variables. See PR #1087