I have 2 Points which has x,y,z let's say from and to I am drawing wall between them using ARkit ios
To draw wall I use static height let's say 5 Meters
node.position = SCNVector3(from.x + (to.x - from.x) * 0.5,
from.y + height * 0.5,
from.z + (to.z - from.z) * 0.5)
now I use following code to set angles
// orientation of the wall is fairly simple. we only need to orient it around the y axis,
// and the angle is calculated with 2d math.. now this calculation does not factor in the position of the
// camera, and so if you move the cursor right relative to the starting position the
// wall will be oriented away from the camera (in this app the wall material is set as double sided so you will not notice)
// - obviously if you want to render something on the walls, this issue will need to be resolved.
node.eulerAngles = SCNVector3(0,
-atan2(to.x - node.position.x, from.z - node.position.z) - Float.pi * 0.5,
0)
And I am rendering video into the wall.
Issue is If I draw from point1 to point2 (drag to right) Video is perfectly fine. But I start from point2 to point1 video is flipped because of eulerAngles is different in both case
Angle point1 to point2 --> (0.000000 -1.000000 0.000000 3.735537)
Angle point2 to point1 -- > (0.000000 -1.000000 0.000000 0.478615)
Here is uploaded images of result
https://stackoverflow.com/questions/53282351/arkit-add-2d-video-flipped-by-x
Any help would be appreciated.
I have fixed issue with temporary solution still looking for a better one
Issue is of wall. wall is flipped other side of camera when draw from right to left direction. I have figure it out by setting isDoubleSided = false and by applying a image as diffuse contents which has text and I can see that image is flipped itself.
I have tried many things but this one helps me
Code
Hope it is helpful. If anyone know better solution please answer it.