XR / Spatial Computing

Getting Started With Spatial Mesh and Scene Understanding: Letting Virtual Objects Know About the Real Room

Spatial anchors keep a virtual object pinned in place. Scene meshing goes further, giving your app an actual 3D model of the room so real furniture can occlude virtual content and virtual objects can rest on real surfaces.

If a virtual object you’ve placed in AR floats visibly in front of a real couch it’s supposed to be sitting behind, the illusion breaks instantly — and that’s exactly the problem scene meshing and occlusion exist to fix. Where a spatial anchor just keeps a virtual object pinned to a real-world location, scene meshing gives your app an actual, continuously updated 3D model of the room, so it knows what’s real and where, well enough to hide a virtual object behind real furniture convincingly.

ARKit and LiDAR: the mesh comes from the hardware

On iOS and visionOS devices with a LiDAR scanner, ARKit builds its scene mesh directly from depth data the sensor captures in real time. Starting it requires a scene-reconstruction provider in your ARKit session, and your app’s Info.plist needs the NSWorldSensingUsageDescription key, since reconstructing the room is sensitive enough to require explicit permission disclosure. The resulting mesh isn’t just raw geometry — ARKit classifies parts of it into floors, tables, seats, windows, and ceilings, which means your app can reason about what kind of surface it’s placing something on, not just that there’s a surface there. On visionOS specifically, this mesh-level scene understanding is what’s available; full camera-frame-based people occlusion isn’t currently exposed on that platform.

Unity AR Foundation: three mesh modes, picked for you

If you’re building in Unity rather than native Swift, AR Foundation wraps ARKit’s (and ARCore’s) scene meshing behind a cross-platform API, with sample scenes for three distinct modes: a plain Classification mesh for identifying surface types, a Normal mesh exposing surface-orientation data useful for physics and lighting, and an Occlusion mesh specifically for hiding virtual geometry behind real-world shapes. The Occlusion sample is the most directly useful starting point if hiding-behind-furniture is your actual goal rather than full scene classification.

ARCore’s path: depth images, not a persistent mesh

Google’s ARCore Depth API takes a different approach on Android: rather than building and maintaining a persistent 3D mesh of the room, it gives your app a per-frame depth image, where each pixel encodes the distance from the camera to whatever it’s looking at in that instant. Google’s own codelab walks through visualizing that depth data and using it to occlude placed virtual objects frame-by-frame — a lighter-weight approach than full meshing, well suited to devices without a dedicated depth sensor, though it reconstructs occlusion fresh each frame rather than maintaining one consistent model of the room over time.

Which approach to reach for

If you’re targeting a LiDAR-equipped iPhone, iPad, or Vision Pro and want the room classified into meaningful surface types, ARKit’s native scene reconstruction is the most capable starting point. If you’re building cross-platform in Unity, AR Foundation’s Occlusion sample scene is the fastest path to the specific “hide behind real furniture” effect most AR demos actually want. And if you’re targeting a broader range of Android devices without guaranteed depth-sensor hardware, ARCore’s Depth API gets you working occlusion without requiring the persistent-mesh infrastructure the other two approaches depend on.