DarkString
DarkString
Back to Pico Dev
06
PICO SPATIAL SDK · 0.10.7Device required

Spatial Mesh

Turn environment anchors into visible, collidable game space

The sample maps mesh-anchor add/update/remove events to wireframe entities and static colliders, then interacts with them through pooled projectiles.

Capability
Mesh tracking, anchor updates, and collision
Environment
UI on emulator; scanning requires headset
Result
Shooter UI verified; real mesh remains device-only
RUN EVIDENCE

Emulator capture

Spatial Mesh shooting UI in the PICO emulator
Captured from the local PICO Emulator 0.10 run; no mockup is used as test evidence.
01

Run boundary

The emulator opens the game layer with fire and score controls, but has no real room scan. The projectile proves rendering and the interaction entry point—not anchor accuracy or real-wall collision quality.

02

Core code: anchor state machine

After MeshTrackingManager.start, the app handles ADDED, UPDATED, and REMOVED. Mesh loading runs on IO while entity updates stay on Main; pendingTransforms handles updates arriving before the first load finishes.

Core code · kotlinMeshScanManager.kt
when (anchorUpdate.event) {
  ADDED -> handleAdded(uuid, transform)
  UPDATED -> handleUpdated(uuid, transform)
  REMOVED -> handleRemoved(uuid)
}
val mesh = withContext(Dispatchers.IO) {
  MeshResource.loadFromMeshAnchor(uuid)
}

The UUID-to-Entity map is the primary index for the scan lifecycle.

03

Core code: static mesh and projectile pool

Environment meshes use createStaticMesh and collide only with GROUP_AMMO. Thirty-two projectiles are preallocated and fully reset on free to avoid runtime allocation spikes.

Core code · kotlinAmmoManager.kt
private const val MAX = 32
private val freeIndices = IntArray(MAX) { it }

fun allocate(): Int = freeIndices[--freeCount]
fun free(index: Int) {
  ammo.enabled = false
  ammo.components.set(PhysicsVelocityComponent())
  freeIndices[freeCount++] = index
}

A pooled entity needs a complete reset contract or old physics state will leak into its next use.