我正在尝试按下面的THREE.Mesh
进行子类化(THREE.Mesh继承自THREE.Object3D)。
Planet = function(geometry, material) {
THREE.Mesh.call(this);
this.geometry = geometry;
this.material = material;
};
Planet.prototype = Object.create(THREE.Mesh.prototype);
当我传入SphereGeometry
时似乎工作正常,但boundRadius
属性未设置,就像我只使用{{}一样1}}。场景绘制正确。
然而,当我传入THREE.Mesh
时,渲染循环变得非常不开心。
CubeGeometry
我模仿了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)
将Three.js
与THREE.Object3D
子类化的方式。我必须遗漏一些东西。
答案 0 :(得分:2)
未调用半径,因为未设置几何体。
Planet = function(geometry, material) {
THREE.Mesh.call(this,geometry,material);
};
Planet.prototype = Object.create(THREE.Mesh.prototype);