There are several ways to create class-based systems in Javascript. John Resig's βClassβ is great, but it's not the type of inheritance Three.js uses.
Pay attention to the Cube class file :
THREE.Geometry.call( this );
Javascript does not provide an inline model for class inheritance, so if you are not using a library (like John Resig) that bakes inheritance into a cool construct, you must explicitly call the super method.
Your class inherits CubeGeometry if inside your class you call:
THREE.CubeGeometry.call( this );
You probably want to install the CubeGeometry prototype:
THREE.MyCubeGeometry.prototype = new THREE.CubeGeometry(); THREE.MyCubeGeometry.prototype.constructor = THREE.MyCubeGeometry;
Bishopz
source share