Three.js revision 48 – tutorial now updated

Three.js is still in alpha and it’s constantly evolving. That’s a good thing because it’s always striving to be better, but it can cause your older code to break.

I’ve just updated our introduction to three.js tutorial so I thought it’d be worth outlining the main recent changes to the API.

THREE.Camera – is now deprecated, replace it with THREE.PerspectiveCamera – it has the same arguments. Note that cameras now need to be added to the scene and they no longer have a target by default. If you want a camera to have a target object use camera.lookAt(object.position); every frame. If you want the camera to look at the origin you can use camera.lookAt(scene.position);

scene.addObject (and scene.addLight) – has now been replaced with the simpler scene.add(object); The same goes for adding one object3D inside another – just use object.add(childObject); Also removeObject, removeLight etc, are now just remove.

These are the biggest changes so start with those if you want to update your code. Let me know if there are other important changes that catch you out.

Three.js full change log on github
Updated Intro to Three.js tutorial