1

I am trying to make a model in which you can select faces ( and they change color/separate from the model). What I am trying to do now is to get a vertice from my selected face and project those coordinates into the screen. I have searched around but most of the questions I've found use deprecated functions. I do realize this question may seem like a duplicate but I haven't found nothing that solves my problem. I am trying to use the project function from THREE.Vector3 but the coordinates I get are always wrong.

This is the relevant part of the code I am using:

var startPoint = mesh.geometry.vertices[selectedPoly.a].clone();
startPoint.project(camera);
startPoint.x = (startPoint.x + 1) / 2 * window.innerWidth;
startPoint.y = ( -startPoint.y - 1)  / 2 * window.innerHeight;

I am just trying to reverse what I do to get a mouse click in 3d space. I am probably doing something wrong. Could you please give me a hand?

XFCC
  • 376
  • 1
  • 2
  • 19
  • check [here](http://stackoverflow.com/questions/34214345/extracting-the-2d-screen-position-of-a-3d-point-with-three-js) or [here](http://stackoverflow.com/questions/27409074/three-js-converting-3d-position-to-2d-screen-position-r69) – 2pha Dec 11 '15 at 12:11
  • I have seen both and it doesn't work. the coordinates I get are way off. – XFCC Dec 11 '15 at 12:48
  • 2
    Try calling `startPoint.applyMatrix4( mesh.matrixWorld );` before calling `project()`. – WestLangley Dec 11 '15 at 16:19
  • That actually worked. If you want to make an answer explaining the reasoning i'd be glad to accept it – XFCC Dec 12 '15 at 21:58

0 Answers0