Place a shape or an image on your composition.
Convert it into 3D Layer.
Click T to open its opacity property.
Alt-Click on Stop-Watch icon to enable expressions.
Delete and paste the following expression in this field.
JavaScript
var startFade = effect("Start Fade")("Slider"); // Start fade 500 pixels from camera.
var endFade = effect("End Fade")("Slider"); // End fade 1500 pixels from camera.
try {
// Check whether there's a camera
var C = thisComp.activeCamera.toWorld([0,0,0]);
} catch ( err ) {
// No camera, so assume 50mm
var w = thisComp.width * thisComp.pixelAspect;
var z = (w/2)/Math.tan(degreesToRadians(19.799));
var C = [0,0,-z];
}
var P = toWorld( anchorPoint );
var d = length( C, P );
linear( d, startFade, endFade, 100, 0 );
Now add two Expression Controls:

Both should be Slider Control. You can add Expression Controls from: Effect – Expression Controls

Now create a camera to see the result. You can control Start Fade and End Fade properties from sliders.

Feel free to download project file from the link below:
Download “Fade Opacity of a 3D Layer Based on Distance from Camera” Fade-opacity-of-a-3D-layer-based-on-distance-from-camera.zip – Downloaded 0 times – 6.01 KB