Prototypes as the new class declaration

Allen Wirfs-Brock allen at wirfs-brock.com
Mon Jun 20 05:28:16 PDT 2011


On Jun 20, 2011, at 12:12 PM, Axel Rauschmayer wrote:

> I was referring to “such things could still be wired up manually”. Where would the manual wiring occur?

SkinnedMesh = Object.create(THREE.Mesh);
const ctor = constructor(geometry, materials) {
   super.constructor(geometry, materials);

   this.identityMatrix = new THREE.Matrix4();
   this.bones = [];
   this.boneMatrices = [];
   ...
 }, 
ctor.prototype=SkinnedMesh;
SkinnedMesh.constructor=ctor;

However, in another thread today I mentioned that to allow super to be used in functions outside of object literals we probably a new reflection function that binds super.  In that case the last line above would probably be replaed with something like:
Object.defineMethod(SkinnedMesh,"constructor",ctor);

Allen


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110620/dd1c5fdf/attachment.html>


More information about the es-discuss mailing list