How to get the absolute position of a vertex in three.js?

后端 未结 2 615
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 15:37

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

2条回答
  •  孤城傲影
    2020-11-27 16:16

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

    object.updateMatrixWorld();
    

    The render loop usually calls this for you.

    Then, do this:

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

    The vector will now contain the position in world coordinates.

    You might want to read some CG reference books.

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

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

    three.js r69

提交回复
热议问题