You have two issues to overcome.
The first problem is simple: your imported camera is probably not pointed in the direction that the default AE camera is when it’s created. You need to move your 3D layers in front of the imported camera.
The second problem is a little more complicated. The Lens Flare effect needs to be applied to a 2D solid, but you want it’s position to be based in 3D space. To do this you need to create a 3D null to act as the flare’s center. Then apply the lens flare effect to a composition sized 2D solid. Add this expression to the lens flare’s center:
l = thisComp.layer("Null 1"); //your lens null layer
l.toComp(l.anchorPoint); //transforms the null's 3D position to a 2D position
Make sure that your 3D null is visible by your imported camera or you won’t see the lens flare. Also, this will result in the flare moving in front of the camera if the Null is actually behind the camera. In order to prevent this you need to apply another expression to the flare’s brightness property:
c = thisComp.activeCamera; //active camera
l = thisComp.layer("Null 1"); //3d flare null
cv = c.toWorldVec([0,0,1]); //unit vector pointing down the z-axis of the camera
cp = c.toWorld([0,0,0]); //world position of the camera
p = l.toWorld(l.anchorPoint); //world position of the 3d flare null
v = p - cp; //a vector from the world position of the camera to the world position of the 3d flare null
z = dot(v, cv); //returns only the magnitude of the above vector that lies on the camera's z-axis
if(z > 0) value; //if the 3d null is in front of the camera then use the effect's brightness value
else 0; //otherwise clamp the brightness to 0
The above code will shut off the lens flare effect when the null moves behind the camera. You could alternatively change this code to adjust the brightness of the flare based on the distance from the camera:
maxdist = 5000; //distance from the camera at which the flare becomes invisible
maxbright = 150; //brightness of the flare when it's closest to the camera
c = thisComp.activeCamera;
l = thisComp.layer("Null 1");
cv = c.toWorldVec([0,0,1]);
cp = c.toWorld([0,0,0]);
p = l.toWorld(l.anchorPoint);
v = p - cp;
z = dot(v, cv);
if(z > 0) linear(z, 0, maxdist, maxbright, 0); //interpolate from 0 brightness at the maxdist to maxbright at 0 distance
else 0; //if the null is behind the camera clamp the brightness to 0
This is more than you asked for, but I like to be thorough 🙂 Let me know if you have any questions.
Darby Edelen