客场 3D 脸部链接
我最近在玩 Away3D 库,在 Away3D 中查找面部中心时遇到问题。为什么Away3DLite有face.center功能而Away3D没有?以及替代解决方案是什么?
I'm recently playing with Away3D Library and have a problem in finding Face center in Away3D. Why Away3DLite has a face.center feature while Away3D doesn't have it ? and what is the alternative solution for this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你想找到一个面的中心,它只是构成该面的所有顶点的平均位置:
上面是一个非常简单的计算平均值的函数,尽管是在 3D 向量而不是简单的标量上。该平均值是面部所有顶点的中心。
如果您需要经常这样做,请通过阻止它分配向量(通过传入应写入返回值的向量)来优化该方法,并为顶点列表长度创建一个临时变量,而不是通过两个变量取消引用它像 min(
f
和vertices
)这样的对象引用,这不必要地繁重。If you want to find the center of a face, it's simply the average position of all the vertices making up that face:
The above is a very simple function to calculate an average, although on a 3D vector instead of a simple scalar number. That average is the center of all the vertices in the face.
If you need to do this a lot, optimize the method by preventing it from allocating a vector (by passing in a vector to which the return values should be written) and create a temporary variable for the vertex list length instead of dereferencing it through two object references like min (
f
andvertices
), which is unnecessarily heavy.