I wanted to do the same thing, but since I needed it to show DoF, the common workarounds didn’t cut it for me.
My solution is a rectangular shape 3D layer which uses length and lookAt to connect the dots – no pun intended ???? It’s basically nice cos / sin math packed into readily available commands.
Rectangle path / Size:
distance = length(thisComp.layer("Layer1").transform.position, thisComp.layer("Layer2"). transform.position);
[20,distance]
I used a slider on that same layer to control the width (x) value instead of a fixed value:
[effect("Stroke")("Slider")[0],distance]
Rectangle path / Position:
posDiff = content("Rectangle 1").content("Rectangle Path 1").size[1]/2;
[0,posDiff]
Transform / Position:
thisComp.layer("Layer1").transform.position
Transform / Orientation:
lookAt(thisComp.layer("Layer1").transform.position, thisComp.layer("Layer2").transform.position)
Then in my example, the circles are auto-oriented towards camera to look like spheres.
The problem I’m having, is that the rectangle should auto orient towards camera in width only. Because right now, depending on the viewing angle, the lines look different in size/width because of the 3D distortion of the flat layer. Basically, I believe, that I would only need to auto-orient the Y-rotation for it to work, but Dan’s script doesn’t work for me here, which is probably because of the script in the orientation parameter….
