plnkr / feedback

Feedback on Plunker
19 stars 11 forks source link

My example with sprite animation in pure WebGL 1.0 doesn't work on Plunker #598

Closed 8Observer8 closed 1 year ago

8Observer8 commented 1 year ago

My example doesn't show animation and doesn't print any errors to the console: https://plnkr.co/edit/RuOBTnWsiwk3uMln?preview

Exactly the same example works on PlayCode: https://playcode.io/1524054

Using only PlayCode is not a solution. I need both for a reservation.

Source on GitHub with instruction to build with Rollup: https://github.com/8Observer8/run-animation-texture-packer-webgl-js

run-animation-texture-packer-webgl-js

ggoodman commented 1 year ago

That's quite strange. I'm unfortunately not familiar enough with webgl to tell you what's going on but here are some observations:

  1. The issue seems to reliably reproduce when the preview pane is initially shown (either on initial load or after toggling it).
  2. The issue does not reproduce when the preview is refreshed.

That sort of thing makes me think that there is a race condition somewhere in the code that is making an assumption about load ordering that doesn't always hold true.

8Observer8 commented 1 year ago

I remembered a similar problem you helped me solve a year ago with window.onresize: Three.js doesn’t start rendering automatically on Plunker

I added this window.onresize handler and the problem was solved: https://plnkr.co/edit/RuOBTnWsiwk3uMln?preview

    window.onresize = () => {
        const w = gl.canvas.clientWidth;
        const h = gl.canvas.clientHeight;
        gl.canvas.width = w;
        gl.canvas.height = h;
        gl.viewport(0, 0, w, h);
        mat4.lookAt(viewMatrix, [0, 0, 50], [0, 0, 0], [0, 1, 0]);
        mat4.mul(projViewMatrix, projMatrix, viewMatrix);
    };
    window.onresize(null);