2

我正在尝试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);

当我传入 a 时,它似乎工作正常SphereGeometry,只是没有像我只使用 a那样设置boundRadius属性。场景绘制正确。 THREE.Mesh

但是,当我传入 aCubeGeometry时,渲染循环变得非常不开心。

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.Object3DTHREE.Mesh

4

1 回答 1

2

未调用半径,因为未设置几何。

Planet = function(geometry, material) {
  THREE.Mesh.call(this,geometry,material);
};

Planet.prototype = Object.create(THREE.Mesh.prototype);
于 2013-01-25T14:39:38.810 回答