greggman / twgl.js

A Tiny WebGL helper Library
http://twgljs.org
MIT License
2.61k stars 258 forks source link

Fix 'instanceof' bug #210

Closed EliasWatson closed 1 year ago

EliasWatson commented 1 year ago

Resolves https://github.com/greggman/twgl.js/issues/125

I ran into the instanceof error when trying to use twgl with react-new-window. However, the bug occurs with any multi-realm project, it's not specific to that library. This behavior of instanceof is described in its MDN docs.

I have successfully tested this with my project.

greggman commented 1 year ago

Thanks for the PR. Can you rebase on top of current master branch?

EliasWatson commented 1 year ago

Thanks for the PR. Can you rebase on top of current master branch?

No problem. I'm used to GitLab, so I'm not sure if I did it correctly.

greggman commented 1 year ago

So, I'm not sure what to do here as there's a big perf difference. For most uses of isXXX they are not in critical paths but one use case is, setting uniform samplers

https://github.com/greggman/twgl.js/blob/master/src/programs.js#L282

The speed difference in Chrome is 20x and that function can easily by called 1000s of times per frame

https://jsbenchit.org/?src=0e299fd0022fef1c2821aaeb9e0aaf86