Dealing with Different ThreeJs Versions, Without the Pain

DEALING WITH DIFFERENT three.js VERSIONS, WITHOUT THE PAIN

Semver? No Way!

The development pace of three.js is fast, and it uses a slightly unusual versioning system. Most software gets released incrementally as V0.5, V0.6, V1.0, V1.1.1 etc. This is known as Semantic Versioning, or semver for short.
Well, three.js is far too hipster for that - instead, we use a revision system, with names like R45, R67, R98 etc. There’s a new revision out once a month or so. You can view a change log of recent releases here.

API Changes

The three.js API (Application Programming Interface) - that is, the commands that we type into our code to make three.js do things - may change in any revision. This means that if you are following a tutorial or book that was written a couple of years ago when R65 was the bee’s knees, you may find that things are not working out as you expect.
In practice, it’s not actually that bad. The majority of the syntax has not changed in years. Also, everything that does change is kept as an alias if possible. Whenever you use one of these aliases, a deprecation warning is logged to the console but your app will still work just fine.


A deprecation warning








For example, here we are being told that the improperly named AxisHelperwas renamed to the correct AxesHelper. The old name will still work, but we’ll get this warning every time we use it.
So if you are following an old tutorial or getting help from a three year old StackOverflow post that has out of date syntax, most things will still work. Just make sure to keep an eye on those console warnings.

Always Use Examples and Plugins that Match Your three.js Version

While the syntax is relatively static, behind the scenes the code may have changed a lot between releases.
You should make sure that any files you use from the /examples folder match the version of three.js you are using, otherwise, you might run into some nasty and hard to pin down bugs.
If in doubt, download the entire latest release of three.js as a zip file and use the files from that.

Watch These Pages for Changes

To keep up to date with changes, follow these pages:

Comments

Popular posts from this blog

How to download a file using command prompt (cmd) Windows?

The future of Artificial Intelligence: 6 ways it will impact everyday life

How to Include ThreeJs in Your Projects