Skill Library

advanced Code Development

AR Spatial Mapper

Build AR applications with spatial understanding, mesh reconstruction, and persistent world anchoring.

When to Use This Skill

  • AR navigation apps
  • Furniture placement
  • Multiplayer AR games
  • Industrial AR guides

How to use this skill

1. Copy the AI Core Logic from the Instructions tab below.

2. Paste it into your AI's System Instructions or as your first message.

3. Provide your raw data or requirements as requested by the AI.

#ar#spatial#mapping#ios#android

System Directives

## ARKit Implementation ```swift import ARKit import RealityKit class SpatialMappingViewController: UIViewController, ARSessionDelegate { @IBOutlet var arView: ARView! override func viewDidLoad() { super.viewDidLoad() // Configure AR session for spatial mapping let configuration = ARWorldTrackingConfiguration() configuration.sceneReconstruction = .mesh configuration.planeDetection = [.horizontal, .vertical] arView.session.delegate = self arView.session.run(configuration) } func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) { for anchor in anchors { if let meshAnchor = anchor as? ARMeshAnchor { updateMeshGeometry(meshAnchor) } } } func updateMeshGeometry(_ anchor: ARMeshAnchor) { let meshGeometry = anchor.geometry // Convert to ModelEntity var descriptor = MeshDescriptor() descriptor.positions = MeshBuffers.Positions( meshGeometry.vertices ) descriptor.faces = MeshDescriptor.Primitives( .triangles(meshGeometry.faces) ) let mesh = try! Mesh.generate(from: [descriptor]) let material = SimpleMaterial( color: .gray.withAlphaComponent(0.3), roughness: 0.5 ) let model = ModelEntity(mesh: mesh, materials: [material]) model.transform = Transform(matrix: anchor.transform) arView.scene.addAnchor(model) } } ``` ### Persistent Anchors ```swift func saveWorldMap() { arView.session.getCurrentWorldMap { worldMap, error in guard let map = worldMap else { print("Error: \(error!.localizedDescription)") return } // Serialize and save do { let data = try NSKeyedArchiver.archivedData( withRootObject: map, requiringSecureCoding: true ) UserDefaults.standard.set(data, forKey: "worldMap") } catch { print("Can't save map") } } } func loadWorldMap() { guard let data = UserDefaults.standard.data(forKey: "worldMap"), let worldMap = try? NSKeyedUnarchiver.unarchivedObject( ofClass: ARWorldMap.self, from: data ) else { return } let configuration = ARWorldTrackingConfiguration() configuration.initialWorldMap = worldMap arView.session.run(configuration) } ``` ## ARCore Implementation ```kotlin class SpatialMappingActivity : AppCompatActivity() { private lateinit var arFragment: ArFragment private val sceneNodes = mutableMapOf<Anchor, TransformableNode>() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) arFragment = supportFragmentManager .findFragmentById(R.id.arFragment) as ArFragment arFragment.setOnTapArPlaneListener { hitResult, _, _ -> placeObject(hitResult) } setupPlaneDetection() } private fun placeObject(hitResult: HitResult) { val anchor = hitResult.createAnchor() val anchorNode = AnchorNode(anchor).apply { setParent(arFragment.arSceneView.scene) } // Load 3D model ModelRenderable.builder() .setSource(this, Uri.parse("model.glb")) .build() .thenAccept { model -> val node = TransformableNode(arFragment.transformationSystem) node.renderable = model node.setParent(anchorNode) node.select() sceneNodes[anchor] = node } } } ``` ## Occlusion and Physics ``` SPATIAL FEATURES: ├── Mesh reconstruction ├── Plane detection ├── Image tracking ├── Object detection └── Scene understanding OPTIMIZATION: ├── Level of Detail (LOD) ├── Frustum culling ├── Occlusion culling └── Shadow optimization ```

Procedural Integration

This skill is formatted as a set of persistent system instructions. When integrated, it provides the AI model with specialized workflows and knowledge constraints for Code Development.

Skill Actions


Model Compatibility
🎭 Claude Sonnet🧠 GPT-4
Code Execution: Required
MCP Tools: Optional
Footprint ~1,105 tokens