My goal is to create a subclass of THREE.Mesh
as shown below (THREE.Mesh inherits from THREE.Object3D).
Planet = function(geometry, material) {
THREE.Mesh.call(this);
this.geometry = geometry;
this.material = material;
};
Planet.prototype = Object.create(THREE.Mesh.prototype);
Everything seems to be working well when I provide a SphereGeometry
, except for the fact that the boundRadius
property is not set as it would have been if I had used just a regular THREE.Mesh
. However, the scene still renders correctly.
On the other hand, when I provide a CubeGeometry
, there are problems in the render loop.
Uncaught TypeError: Cannot read property 'radius' of null three.min.js:105
THREE.Frustum.intersectsObject three.min.js:105
render three.min.js:414
starsgl.Application.render Application.js:60
starsgl.Application.animate Application.js:55
starsgl.Application Application.js:50
(anonymous function)
I followed the similar approach that Three.js
uses to subclass THREE.Object3D
with THREE.Mesh
. However, it seems like I might be overlooking something.