Created
February 11, 2012 14:10
-
-
Save tomgco/1799570 to your computer and use it in GitHub Desktop.
Inheritance without module pattern and no use of __proto__
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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