Working with the excellent Three.js framework and currently looking for a good javascript inheritance pattern, I had a look to what is done in Three.js. I now have a good understanding of what's going on, except for some "class" such as Vector3.
Especially, it's not clear for me, why some methods are directly added to the prototype and some are added using THREE.extend in the same "class", like following :
... THREE.Vector3.prototype = { setX: function ( x ) { this.x = x; return this; }, ... }; //and then later in the same file THREE.extend( THREE.Vector3.prototype, { applyEuler: function () {...}(), ... }
What's the benefit to use extends, whereas it's possible to augment the prototype object ?
Edit
The code sample is part of the same file, see https://github.com/mrdoob/three.js/blob/master/src/math/Vector3.js I'm not asking what are the differences between the two parts, but why extend is used just after defining the prototype. Or in other words (with the previous extract), why not just write :
... THREE.Vector3.prototype = { setX: function ( x ) { this.x = x; return this; }, applyEuler: function () {...}(), ... };