0
votes

I'm creating a 3D object in Three.js with 6 faces. Each face has a mesh which uses a THREE.PlaneGeometry(width and height both are 256). On the mesh I'm using a JPEG picture which is 256 by 256 for the texture. I'm trying to find a way to find the world coordinate of a pixel coordinate(for example 200,250 is the pixel coordinate) on the Object3D's PlaneGeometry corresponding to where that picture was used as texture. Object hierarchy:- Object3D-->face(object3d) (total 6 faces)-->Each face has a mesh(planegeometry) and uses a jpeg file as texture.

Picture1 pixel coordinate-->Used to create texture for Plane1-->World Coordinate corresponding to that pixel coordinate.

Can someone please help me.

Additional information:- Thanks for the answer. I'm trying to compare 2 results. Method 1:- One yaw/pitch is obtained by clicking on a specific point in the 3d object(e.g, center of a particular car headlight which is the front face) using a mouse and getting the point of intersection with the front face using raycasting.

Method 2:-The other yaw/pitch is obtained by taking the pixel coordinate of the same point(center of a particular car headlight) and calculating the world space coordinate for that pixel point. Pls note that pixel coordinate is taken from the JPEG file that was used as texture to create the PlaneGeometry for the mesh(which is a child of the front face).

Do you think the above comparison approach is supposed to produce the same results, assuming all other parameters are identical between the 2 approaches?

1
And where are you getting stuck?mypetlion
If you explain why you need that world coordinate, we can provide some guidance on the best way to find it.manthrax
By finding the world coordinate I'm trying to calculate the yaw/pitch angles for that point in this specific 3d scene. This is pre-mapped and if I have the world coordinate (x,y,z) I can calculate the yaw/pitch angles using standard formula.Michael Web
to mypetlion's question, I really do not know how to calculate that and right now I don't know how to approach this problem!Michael Web

1 Answers

0
votes

Well assuming your planes are PlaneGeometry(1,1) then the local coordinate X/Y/ZZ for a given pixel is pixelX / 256, pixelY / 256 and the Z is 0.5

so something like:

var localPoint = new THREE.Vector3(px/256,py/256,0.5)
var worldPoint = thePlaneObject.localToWorld(localPoint)