three.js inheritence pattern

vlad0000

New Member
I'm sure this is a very basic javascript question, but I want to know why the three.js code is structured like this:\[code\]THREE.Camera = function(){ THREE.Object3D.call(this); //add more Camera specific properties and methods}THREE.Camera.prototype = new THREE.Object3D();THREE.Camera.prototype.constructor = THREE.Camera;THREE.Camera.prototype.//add more camera specific methods...\[/code\]I want to know why they call the base constructor in the current constructor and also for the prototype?In MDN they show a pattern like this:\[code\]subType = function(){ //new properties for subType}subType.prototype = new baseType();\[/code\]They don't have the call to the base constructor in the subType constructor, so why does THREE.js do this?
 
Top