如何在three.js中获取顶点的绝对位置? [英] How to get the absolute position of a vertex in three.js?

查看:397
本文介绍了如何在three.js中获取顶点的绝对位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知 var point = object.geometry.vertices [i]; 将返回 x的相对位置 y z 对象几何内的点。

As far as I know var point = object.geometry.vertices[i]; will return with the relative position for the x, y and z of the point inside the geometry of the object.

如果物体被移动,旋转或缩放,如何获得绝对位置?

How to get the absolute position, if the object was moved, rotated or scaled?

推荐答案

首先确保对象的矩阵已更新。

First make sure the object's matrices have been updated.

object.updateMatrixWorld();

渲染循环通常会为你调用。

The render loop usually calls this for you.

然后,执行此操作:

var vector = object.geometry.vertices[i].clone();

vector.applyMatrix4( object.matrixWorld );

该向量现在将包含世界坐标中的位置。

The vector will now contain the position in world coordinates.

您可能想阅读一些CG参考书。

You might want to read some CG reference books.


  1. 用于图形和游戏开发的3D数学入门/ Fletcher Dunn和Ian Parberry

  1. 3D math primer for graphics and game development / by Fletcher Dunn and Ian Parberry

游戏和互动应用的基本数学:程序员指南
James M. Van Verth和Lars M. Bishop

Essential Mathematics for Games and Interactive Applications: A Programmer’s Guide James M. Van Verth and Lars M. Bishop

three.js r69

three.js r69

这篇关于如何在three.js中获取顶点的绝对位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆