This repository is a collection of code samples and projects that demonstrate the capabilities of Meta Spatial SDK. Meta Spatial SDK is a new way to build immersive apps for Meta Horizon OS. Meta Spatial SDK lets you combine the rich ecosystem of Android development and the unique capabilities of Meta Quest via accessible APIs.
The samples in this repository showcase various features of the SDK, such as spatial anchors, scene understanding, and object recognition. Each sample project includes source code, build scripts, and documentation to help developers understand how to use the SDK to build their own spatially-aware applications.
Whether you're a seasoned developer or just starting out with Meta Quest/Horizon OS, the Meta Spatial SDK Samples are a valuable resource for learning how to leverage the power of spatial computing in your applications.
To try out these sample apps, you will need:
- A Meta Quest device (Quest 2/3/3S/Pro)
- Mac or Windows
- Android Studio Hedgehog or newer
- Meta Spatial Editor
First, ensure that all of the requirements are met.
Then, to build and run a sample:
- Clone this repository to your computer
- Open the specific sample app with Android Studio
- Plug in your Quest device to your computer
- Click the "Run" button in the Android Studio toolbar, the app will now be running on your headset
Notes:
- All samples, except MRUKSample and PremiumMediaSample, require you to install Meta Spatial Editor.
- MediaPlayerSample and PremiumMediaSample contain examples of custom shaders, which requires the NDK to be installed and set up in app/build.gradle.kts (ex.
ndkVersion = "27.0.12077973"
) - Our samples support our custom OVRMetrics integration
We have 11 sample apps, demonstrating various features of Meta Spatial SDK:
- AnimationsSample shows how to play animation clips, create reusable animation drivers, and demonstrates frame-based procedural animation.
- HybridSample shows how to begin with a standard Android-based 2D panel experience and switch between an immersive experience that hosts the same panel.
- CustomComponentsSample shows how to create a custom component that embodies the data shared across various instances of an application.
- PremiumMediaSample shows how to stream DRM-protected content, play 180-degree videos, and cast reflections from panels into the user's spatial setup with MRUK.
- MediaPlayerSample shows how to build an immersive video playback experience.
- MixedRealitySample shows an immersive experience that interacts with the user's physical surroundings.
- MrukSample shows an immersive experience influenced by the user's physical surroundings.
- Object3DSample shows inserting 3D objects into a scene and adjusting their properties in Meta Spatial Editor.
- PhysicsSample shows adding a physics component and adjusting its properties in Meta Spatial Editor.
- PremiumMediaSample shows a media streaming experience integrated into the users spatial environment.
- SpatialVideoSample shows how to play video with spatialized audio.
- StarterSample is a starter project that is part of Getting Started with Meta Spatial SDK.
We also have a starter app CustomComponentsStarter, which only contains the boilerplate code of CustomComponentsSample. You can download this starter app and follow this tutorial to build a LookAt app with Meta Spatial Editor and SDK.
The Showcases folder contains five apps. These are fully-featured applications built with Meta Spatial SDK, and are open-sourced here in this repository.
The documentation for Meta Spatial SDK can be found here.
Find our official release notes here.
-
New Panel Registration APIs
ComposeViewPanelRegistration
: Panel registration for Jetpack Compose-based panels.ViewPanelRegistration
: Panel registration for dynamically created View-based panels.LayoutXMLPanelRegistration
: Panel registration for XML layout view-based panels.IntentPanelRegistration
: Panel registration for Intent-based panels that launch Activities.ActivityPanelRegistration
: Panel registration for Activity-based panels that launch specific Activity classes.VideoSurfacePanelRegistration
: Panel registration for direct-to-surface media rendering.ReadableVideoSurfacePanelRegistration
: Panel registration for when you want both post-processing and a simple surface to render on.- The new APIs are focused on simplifying panel configuration, for more information see our documentation page on panel registration
-
Shader hot reload
- You can now hot reload your custom shader code. More information is available in our documentation.
-
preloadMesh()
support-
This method loads and caches a mesh from the specified URI so that when it's later assigned to an entity via the Mesh component, it will be available immediately. This is useful for performance optimization, especially during app startup when you can front-load your meshes.
-
Example code:
systemManager.findSystem<MeshCreationSystem>() meshCreationSystem.preloadMesh(Uri.parse(meshFile))
-
-
Panel graphics changes
- New
layerBlendType
, replaces theenableTransparent
control for panels. Now supports the ability to set the layer as:OPAQUE
: Alpha/transparency is ignoredMASKED
: This is whatenableTransparent
previously enabled, panels can become transparent but will not blend with the background (the alpha is essentially force to be only 0 or 1)ALPHA_BLEND
: Alpha is blended accurately, resulting in higher quality edges. However, it is slower and can result in blending artifacts when overlapping with semitransparent meshes.
- New
enableLayerFeatheredEdge
option inPanelRenderSettings
, this will allow you to remove sharp black outlines on the edge of panels
- New
-
UISet
- Bordered buttons
- New composables:
BorderedButton
,BorderedIconButton
(com.meta.spatial.uiset.button
). - New defaults and colors:
BorderedButtonDefaults
,BorderedButtonColors
(com.meta.spatial.uiset.button.foundation
). - New button variants:
ButtonVariant.Regular.Bordered
,ButtonVariant.Circled.Bordered
.
- New composables:
- Card components
- New composables:
PrimaryCard
,SecondaryCard
,OutlinedCard
(com.meta.spatial.uiset.card.SpatialCard
). - Foundation:
CardImpl
,CardDefaults
,CardVariant
.
- New composables:
- Bordered buttons
-
Experimental:
Entity.markComponentChanged()
API- Marks a component as "changed" without setting new component data
- This is useful in rare cases where you want the component to be considered "changed" for change detection purposes, even when the actual component data hasn't been modified. This will trigger component change listeners and queries that look for changed components.
- ISDK
-
ISDK is now the default input system.
-
Opt-out of ISDK via a new argument on VRFeature
override fun registerFeatures(): List<SpatialFeature> { return listOf( // Set the inputSystemType to SIMPLE_CONTROLLER to turn off ISDK VRFeature(this, inputSystemType = VrInputSystemType.SIMPLE_CONTROLLER), ) }
- Adds near-field touch limiting & grabbing of objects
- Some updates to your app may be required - interactions no longer support 2 sided panels. ensure panels and buttons are oriented with their normal vector pointing forwards.
-
com.meta.spatial.vr.InputSystem
is no longer enabled by default. (com.meta.spatial.isdk.IsdkSystem
now controls input) -
com.meta.spatial.toolkit.GrabbableSystem
is no longer enabled by default (com.meta.spatial.isdk.IsdkSystem
now controls grabbing & transforms) -
IsdkGrabbableFollowableSystem
fixes behavior when Entity has bothGrabbable
andFollowable
components. -
IsdkDefaultCursorSystem
: made some non-user-servicable fields private -
Support for microgestures, check out
MicrogestureBits
-
- Cast input forwarding
- The debug lines (green lines that would appear during input forwarding) have now been removed.
- Cursor placement for input forwarding is most accurate when the eye is set to "Right Eye" in MQDH Cast
- Spatial gradle plugin
- The
export
step of the Gradle build process is now always executed and cannot be opted-out. If you don’t specify the Spatial Editor asset folder, the export step will not generate a GLXF file.
- The
- UISet
- Buttons foundation (
ButtonImpl
)- Signature extended with
modifier
,colors
,borderColor
,labelTextStyle
,contentAlignment
. - Color resolution updated to use provided
*ButtonColors
per variant; falls back to defaults whencolors
is null. - Border rendering added for bordered variants (1.dp, configurable via
borderColor
). - Content alignment is now configurable (affects container alignment and row arrangement).
- Signature extended with
- Primary and Secondary buttons
PrimaryButton
andSecondaryButton
signatures extended withmodifier
,colors
,labelTextStyle
,contentAlignment
.
- Existing
PrimaryIconButton
,PrimaryCircleButton
,SecondaryIconButton
, andSecondaryCircleButton
functions were updated to supportmodifier
,colors
, and other customization parameters. - Switch (
SpatialSwitch
andSwitchImpl
)SpatialSwitch
signature was updated to acceptcolors
andthumbContent
, and themodifier
parameter was reordered.SwitchImpl
updated to accept and render optionalthumbContent
.SwitchColors
now exposesiconColor(enabled, checked)
for thumb content tinting.
- Dropdown
SpatialDropdown
andSpatialIconDropdown
signatures were extended withmenuModifier
,showChevron
, andshowDividers
parameters.SpatialDropdownItem
data class now includes an optionalsuffix
composable property.- Chevron visibility is now conditional for
DropdownPillVariant.Standard
. DropdownMenu
styling updated to support custommenuModifier
and optional dividers.- Menu item layout was refined to support
suffix
.
- Navigation (
SpatialSideNavItem
and defaults)SpatialSideNavItem
signature extended withcolors
,primaryTextStyle
,secondaryTextStyle
, andselectedBackgroundColor
.- Text styling is now configurable via
primaryTextStyle
/secondaryTextStyle
. - Selected background color can be overridden via
selectedBackgroundColor
. - Removed fixed icon size wrappers to allow flexible icon sizing.
- Theme
SpatialShapes
andSpatialShapeSizes
were extended with anxLarge
size (32.dp).
- Buttons foundation (
- Component XML Schema
- A new schema definition is available at: https://developers.meta.com/horizon/spatial-sdk/0.8.0/ComponentSchema.xsd/
- Removed APIs
com.meta.spatial.toolkit.BodyJoint
andcom.meta.spatial.toolkit.TrackedBody
have been removed as they were not implemented
The samples all include the Spatial SDK Gradle Plugin in their build files. This plugin is used for the Spatial Editor integration and for build-related features like custom shaders.
Meta collects telemetry data from the Spatial SDK Gradle Plugin to help improve MPT Products. You can read the Supplemental Meta Platforms Technologies Privacy Policy to learn more.
The Meta Spatial SDK Samples package is multi-licensed.
The majority of the project is licensed under the MIT License, as found in the LICENSE file.
The Meta Platform Technologies SDK license applies to the Meta Spatial SDK and supporting material, and to the assets used in the Meta Spatial SDK Samples package. The MPT SDK license can be found in the asset folder of each sample.
Specifically, all the supporting materials in each sample's app/src/main/res/raw
and app/src/main/assets
folders including 3D models, videos, sounds, and others, are licensed under the MPT SDK license.