Hi!

I’m working on some image tracking with QR codes for an AR BabylonReactNative project. I’ve got the scanner part and am getting both the data from the QR code and the 4 cornerpoints in screenspace.

I thought I could get position and rotation from those but I don’t seem to be able to do that.

I’ve tried

`const position: Vector3 = Vector3.Unproject( new Vector3(corner.x, corner.y, 1), engine.getRenderWidth(), engine.getRenderHeight(), Matrix.Identity(), scene?.getViewMatrix()!, scene?.getProjectionMatrix()!, );`

with the separate corner points but that gives me numbers that are in the thousands.

I’ve had a little more success with

`var pickResult = scene?.pick( Number(corner.x), Number(corner.y), ); const distance: number = 0.3; if (pickResult != null && pickResult.ray) { position.x = pickResult.ray.origin.x + pickResult.ray.direction.x * distance; position.y = pickResult.ray.origin.y + pickResult.ray.direction.y * distance; position.z = pickResult.ray.origin.z + pickResult.ray.direction.z * distance;`

Which is better, the coordinates make more sense, but it’s still just the individual points. I also have to hold the camera at a set distance for this to work…

Googling doesn’t really give me any answers, but I may be using the wrong search terms. Could anyone help me figure out how I get the position and rotation from the 4 cornerpoints I have?

Thanks!