Demonstrate how to use dense SpatialMap.

  • Demonstrate how to render dense SpatialMap mesh

  • Demonstrate how to use dense SpatialMap to do collision and occlusion

How to Use

Mark 1: Display system status and operation hint.
Mark 2: Whether render the mesh transparently.
Mark 3: Whether render the mesh.

A ball will be shot when clicking the screen. You can shoot the ball onto the mesh if one is build.

How It Works

Build dense spatial map

Dense spatial map can be build when a DenseSpatialMapBuilderFrameFilter is running in the session.

Render mesh on/off

DenseSpatialMapBuilderFrameFilter.RenderMesh can be used to control mesh render.

public void RenderMesh(bool show)
    dense.RenderMesh = show;

Render transparent mesh

DenseSpatialMapBuilderFrameFilter.MeshColor can be used to control mesh color, including the alpha value.

public void TransparentMesh(bool trans)
    dense.MeshColor = trans ? Color.clear : meshColor;

Shoot ball

Shoot balls from camera, they will be driven by Unity physics system.

Ray ray = Camera.main.ScreenPointToRay(Input.touches[0].position);
var launchPoint = Camera.main.transform;
var ball = Instantiate(Ball, launchPoint.position, launchPoint.rotation);
var rigid = ball.GetComponent<Rigidbody>();
rigid.velocity =;
rigid.AddForce(ray.direction * 15f + Vector3.up * 5f);