evanw / lightgl.js

A lightweight WebGL library
MIT License
1.52k stars 146 forks source link

Mouse down not working in Chrome 24.0.1312.57 #11

Open kylepaulsen opened 11 years ago

kylepaulsen commented 11 years ago

This could be a bug with chrome... I'm not sure because it's really weird. I think chrome 24.0.1312.57 is garbage collecting your canvas reference or something. In your first person camera example, try putting a setTimeout wrapper with 1 second of delay around your gl settings block like this:

setTimeout(function(){
  gl.fullscreen();
  gl.animate();
  gl.enable(gl.CULL_FACE);
  gl.enable(gl.POLYGON_OFFSET_FILL);
  gl.polygonOffset(1, 1);
  gl.clearColor(0.8, 0.8, 0.8, 1);
  gl.enable(gl.DEPTH_TEST);
}, 1000);

The mouse look no longer works. I'm not trying to use a setTimeout but I think my code is slow. I did some investigating and noticed that when I leaked the canvas element var to the window or to the GL object at around here: https://github.com/evanw/lightgl.js/blob/master/src/main.js#L213 everything worked just fine again. That's why I think it's some sort of garbage collecting issue.

I love the library by the way. I just thought I'd let you know of this strange situation.