Skip to content

Instantly share code, notes, and snippets.

@tomgco
Created February 11, 2012 14:10
Show Gist options
  • Save tomgco/1799570 to your computer and use it in GitHub Desktop.
Save tomgco/1799570 to your computer and use it in GitHub Desktop.
Inheritance without module pattern and no use of __proto__
// define a new type SkinnedMesh and a constructor for it
function SkinnedMesh(geometry, materials) {
// call the superclass constructor
THREE.Mesh.call(this, geometry, materials);
// initialize instance properties
this.identityMatrix = new THREE.Matrix4();
this.bones = [];
this.boneMatrices = [];
...
};
// inherit behavior from Mesh
SkinnedMesh.prototype = Object.create(THREE.Mesh.prototype);
SkinnedMesh.prototype.constructor = SkinnedMesh;
// define an overridden update() method
SkinnedMesh.prototype.update = function(camera) {
...
// call base version of same method
THREE.Mesh.prototype.update.call(this);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment