-
-
Save philogb/396146 to your computer and use it in GitHub Desktop.
This file contains 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
//I think that the main problem with the code is that | |
//Particle inherits from Object3D, but you couldn't reuse that same code to | |
//make another object inherit from Particle, since the original Particle constructor | |
//is overridden by Object3Ds. So my approach would be: | |
THREE.Particle = function (material) { | |
THREE.Object3D.call(this); | |
this.size = 1; | |
this.material = material; | |
}; | |
THREE.Particle.prototype = new THREE.Object3D(); | |
THREE.Particle.prototype.constructor = THREE.Particle; | |
var particle = new THREE.Particle(); | |
alert(particle instanceof THREE.Object3D); // true | |
alert(particle instanceof THREE.Particle); // true | |
//...And here's a code that tests it completely: | |
var THREE = {}; | |
THREE.Object3D = function(){}; | |
THREE.Object3D.prototype.constructor = THREE.Object3D; | |
THREE.Particle = function (material) { | |
THREE.Object3D.call(this); | |
this.size = 1; | |
this.material = material; | |
}; | |
THREE.Particle.prototype = new THREE.Object3D(); | |
THREE.Particle.prototype.constructor = THREE.Particle; | |
var particle = new THREE.Particle(); | |
alert(particle instanceof THREE.Object3D); // true | |
alert(particle instanceof THREE.Particle); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
True, I didn't tried doing another level. That does the trick! :D