TypeError: this.mesh.geometry.area is not a function

TypeError: this.mesh.geometry.area is not a function

我最近使用 Leapmotion JavaScript 和 Three.js,我开始使用 leap 小部件 (http://blog.leapmotion.com/leapjs-widgets-new-library-3d-web-design/here!) 库向我的程序添加一些很酷的按钮。

几个小时后,我从其中一个库中得到了这个类型错误。是我的东西吗?我就是想不通...

TypeError: this.mesh.geometry.area is not a function

这里指的是这段代码:

  this.mass = this.mesh.geometry.area() * this.density;

这个库看起来运行不正常。

正如本期的回答:https://github.com/leapmotion/leapjs-widgets/issues/4

#area is a custom method added by this project to particular THREE.js geometries.

This error occurs when you try and turn a non-supported geometry in to a button. Supported geometries are PlaneGeometry and CircleGeometry.

I have some code sitting around from MozVR which will scale a box to make it look like it is being pushed by a plane. Here: https://github.com/leapmotion/HIRO/blob/master/js/vrhud.js#L290-L319 Note that scale must be used, because that's the only way to resize an initialized THREE.js geometry.

编辑:这似乎是一个相当普遍的问题。也许在未来的版本中,我们会使错误更明确。