---
title: Fade walls near the camera
summary: Mark walls, roofs and coverings as soft occluders so they fade out and become click-through as the camera comes close, and zooming into a building reveals the interior without hiding anything by hand.
order: 42
since: 3.0
languages: [javascript]
terms: [object-state-manager, bvl, qid]
see-also: [how-to/viewer3d/hide-and-isolate, how-to/viewer3d/section-planes, reference/bvl, how-to/viewer3d/xray-set]
---

# Fade walls near the camera

Looking inside a building otherwise means hiding walls or cutting with a section plane. The proximity fade does it for you: the objects you mark as *soft occluders* dither out when the camera gets near them, and while they are faded the mouse picks through them. Move away and they are back.

## Live demo

```demo
name: proximity-fade
title: Fade the envelope near the camera
models: ac11
height: 520
notes: |
  The fade is on when the demo starts. Zoom towards the building and push the camera through a wall; the walls, roof and windows in front of you fade and the rooms behind them show. The two sliders set where the fade starts and where it is complete, in model units; **Automatic distances** derives them from the size of the occluders.
```

## Before you start

You have a viewer with a model loaded ([[page:how-to/viewer3d/embed-the-viewer]]). The soft-occluder set is an object state held by the [[term:object-state-manager|ObjectStateManager]], next to visible, selected and coloured, so every viewer connected to it fades the same objects.

## Steps

1. **Choose the occluders.** Put the envelope types in the soft-occluder set and set the distances:

   ```example
   name: proximity-fade-api
   code: javascript/viewer3d/proximityfade.js
   notes: Puts the envelope types in the soft-occluder set and changes the distances. Distances are in model units, usually millimetres.
   ```

   `setSoftOccluderSet` takes a BQL condition or a set of [[term:qid|Qids]]; `addToSoftOccluderSet` and `removeFromSoftOccluderSet` edit the set. The envelope a camera has to get through is the useful set: the BIM.works app uses walls, windows and doors, the demo above adds curtain walls, roofs, coverings and plates. Leave slabs out: fading the floor under the camera looks broken.

2. **Tune the ramp.** `viewer.setProximityFadeConfig({fadeNear, fadeFar, minRampRatio, smoothingTauMs})` sets where the fade starts and where it is complete; `"auto"` for a distance derives it from the median height of the occluders.

3. **Or switch it on from a visualisation.** [[term:bvl|BVL]] has the `SOFT_OCCLUDER` and `NO_SOFT_OCCLUDER` verbs, so a visualisation action can switch the fade on for a type set ([[page:reference/bvl]]).

The viewer setting `proximityFade: {enabled: false}` disables the feature entirely.

## How it behaves

The fade is computed in the vertex shader from the camera position and the object's bounds, so it costs nothing per frame on the CPU, and it applies to picking as well, which is what makes a faded wall click-through.

## In the app

The Proximity group of the viewer's view options (the camera button in the toolbar) switches the fade on and off. **Default** fades walls, windows and doors; **Custom** takes a BQL condition of your own, as after `WHERE` in a query, and starts from the default's `type IN (IFCWALL, IFCWINDOW, IFCDOOR)`. There is no key binding.

## Limits

An object without a bounding volume, or with a pick id outside the range the shader supports, is skipped with a warning in the console. The fade is one ramp for the whole set: there is no per-object distance.

## Check

Zoom into the building through a wall: the wall fades as the camera reaches it, and a click lands on what is behind it.
