Coping with new version of WebGL.js

I updated my programs with the latest (9/30) version of WebGL.js and the programs wouldn’t work. The “problem” appears to be that the name of the key variable in WebGL.js has been changed from WEBGL to THREE.WEBGL so that the WebGL test in my programs had to be changed to refer to THREE.WEBGL.

Is that correct? Or is there a better way to accommodate this change in WebGL.js or a better way to write my programs which will automatically handle these kind of changes to three.js files?

FYI - I include all of the necessary three.js files with my programs so this kind of problem happens only if I update those three.js files and not the program. But I see that some programs load at least some of the files directly from the three.js website. I wonder if that is the preferred practice and how they would cope with these kinds of changes?

I checked the documents and they refer to the old variable. So I assume they need to be changed eventually?

Thanks.

Correct. All example JavaScript files were moved into the THREE namespace so it’s easier to automatically convert them into modules.

No. If you use examples files from the js directory, it’s necessary to update your code once. However, you should consider to use modules like explained in the following guide:

https://threejs.org/docs/index.html#manual/en/introduction/Import-via-modules

1 Like

Thanks!
So I could have avoided this particular problem by importing the js modules rather than the js files?
Since modules are now the preferred method of using three.js, I will try switching to that method and see what happens.

Basically yes. When working with modules, namespaces like THREE are not required.