Built-in components
Updated: Sep 17, 2025
Spatial SDK provides a comprehensive set of built-in components in com.meta.spatial.toolkit that handle the most common needs when building spatial applications. Instead of writing complex 3D rendering code from scratch, you can simply attach these pre-made components to your entities. For example, adding a Mesh component gives your object a 3D shape, while a Transform component positions it in space, and a Material component controls its appearance.
This document covers all the essential built-in components you’ll use to create interactive 3D experiences, from basic visual elements to user interactions and spatial audio. Each component is designed to work seamlessly with others, allowing you to combine them like LEGO blocks to build sophisticated spatial applications.
Spatial SDK’s built-in components fall into four categories:
- Core visual: Make objects appear (
Mesh, Visible, Transform) - Appearance: Control how objects look (
Material, Scale) - Interaction: Respond to user input (
Panel, Audio) - Geometry: Customize built-in shapes (
Box, Sphere, Quad, Plane)
Every visible object needs these three components:
Defines the shape of your object - sphere, cube, or custom 3D model.
Use case: Loading 3D models, creating basic shapes, or defining skyboxes.
Key attributes:
mesh: Uri - Path to 3D model or built-in mesh (mesh://sphere,
mesh://box, mesh://plane, mesh://quad)hittable: MeshCollision - Enables touch/ray interactions
// Basic sphere
Entity.create(
Mesh(Uri.parse("mesh://sphere")),
Transform(Pose()),
Visible(true)
)
Places your object in 3D space with position and rotation.
Use case: Positioning objects, animating movement, managing spatial relationships.
Key attributes:
transform: Pose - Contains position (Vector3) and rotation (Quaternion)- Coordinate system: X=left/right, Y=up/down, Z=forward/back
// Position object 2 meters forward, 1 meter up
Transform(Pose(Vector3(0f, 1f, -2f)))
Controls whether an entity appears in the scene.
Use case: Show/hide UI, progressive disclosure, inventory systems, conditional rendering.
Key attributes:
isVisible: Boolean - Whether the entity renders
// Toggle visibility based on game state
entity.setComponent(Visible(gameStarted))
Controls colors, textures, and lighting behavior of objects.
Use case: Styling objects, applying textures, creating different surface types (metal, plastic, glass).
Key attributes:
baseColor: Color4 - RGBA colormetallic: Float - Metallic appearance (0.0-1.0)roughness: Float - Surface roughness (0.0=mirror, 1.0=rough)unlit: Boolean - Ignore scene lightingbaseTextureAndroidResourceId - Apply textures from resources
// Shiny red metal
Material().apply {
baseColor = Color4(1f, 0f, 0f, 1f)
metallic = 0.8f
roughness = 0.2f
}
Changes object size without modifying the original 3D model.
Use case: Resizing objects, creating size variations, adjusting UI panel dimensions.
Key attributes:
scale: Vector3 - Scale factors for X, Y, Z axes
// Make object 50% smaller
Scale(Vector3(0.5f, 0.5f, 0.5f))
Panel - 2D UI in 3D space
Displays Android UI layouts as surfaces in your 3D world.
Use case: Menus, HUDs, information displays, interactive controls.
Key attributes:
panelRegistrationId: Int - Links to your registered Android UIhittable: MeshCollision - Enables touch/ray interactions
// Register panel first
LayoutXMLPanelRegistration(
R.id.game_ui,
layoutIdCreator = { R.layout.game_ui },
settingsCreator = {
UIPanelSettings(
shape = QuadShapeOptions(width = 2.0f, height = 1.5f),
)
}
)
// Create panel entity
Entity.create(
Panel(panelRegistrationId = R.id.game_ui),
Transform(Pose()),
Visible(true)
)
Plays positioned audio in 3D space.
Use case: Sound effects, ambient audio, interaction feedback, spatial audio experiences.
Key methods:
SceneAudioAsset.loadLocalFile() - Load audio from assetsscene.playSound(asset, volume) - Play at user positionscene.playSound(asset, position, volume) - Play at specific 3D location
// Play button press sound
val sound = SceneAudioAsset.loadLocalFile("sounds/button.wav")
scene.playSound(sound, 1.0f)
These components customize built-in procedural mesh dimensions:
Box - Custom cube dimensions
Use case: Creating custom-sized boxes without external 3D models.
Box(min = Vector3(-1f, -0.5f, -2f), max = Vector3(1f, 0.5f, 2f))
Use case: Precise sphere sizing for physics objects or decorative elements.
Use case: Billboards, signs, or UI backgrounds.
Quad(min = Vector2(-2f, -1f), max = Vector2(2f, 1f))
Plane - Custom horizontal surface
Use case: Ground planes, platforms, or large flat surfaces.
Plane(width = 20.0f, depth = 20.0f)
Learn more about components an systems in ECS: