API reference
API reference
Select your platform
No SDKs available
No versions available

com.meta.spatial.toolkit

Package-level declarations

Types

NameSummary
class Animated(startTime: Long = -1L, pausedTime: Float = 0.0f, playbackState: PlaybackState = PlaybackState.PLAYING, playbackType: PlaybackType = PlaybackType.LOOP, track: Int = 0) : ComponentBase
Plays animation for a glTF asset. Also configures different settings for animation.
open class AppSystemActivity : VrActivity, AppSystemCommon
AppSystemActivity serves as the base class for all Spatial activities. It contains all Android activity lifecycle callbacks: onCreate, onStop, onDestroy and others. It also provides scene lifecycle callbacks: onSceneReady and onSceneTick. This class also provides hooks to override system features through registerSystemFeatures and to register panels through registerPanels.
interface AppSystemCommon
class Audio(audio: String = "", volume: Float = 1.0f) : ComponentBase
Audio component that can be attached to an entity. This component will play audio spatially from the entity.
class AudioSystem : SystemBase
This System is responsible for playing audio and managing audio assets.
class AvatarAttachment(type: String = "") : ComponentBase
Defines what part of an Avatar the entity is meant to represent. (head, body, controller, etc.)
class AvatarBody(head: Entity = Entity.nullEntity(), leftHand: Entity = Entity.nullEntity(), rightHand: Entity = Entity.nullEntity(), root: Entity = Entity.nullEntity(), isPlayerControlled: Boolean = false) : ComponentBase
AvatarBody is a component that represents the body of an avatar. It contains references to the head, left hand, right hand, and root of the avatar. It also contains a boolean flag to indicate whether the avatar is player controlled.
class AvatarSystem : SystemBase
This system handles the visibility of the controllers and hands.
enum BodyJoint : Enum<BodyJoint>
Describes each joint found in TrackedBody
class Box(min: Vector3 = Vector3(0.0f, 0.0f, 0.0f), max: Vector3 = Vector3(0.0f, 0.0f, 0.0f)) : ComponentBase
Defines the dimensions of a box shape by the relative offset of two opposite corners. A box of max=Vector3(1,1,1) and min=Vector3(-1,-1,-1) will result in a 2x2x2 box. This is to be used with the mesh://boxMesh URI.
enum ClickState : Enum<ClickState>
ClickState is an enum that represents the state of a click.
class Color3
class Color4
class Controller(buttonState: Int = 0, changedButtons: Int = 0, isActive: Boolean = false, type: ControllerType = ControllerType.CONTROLLER, directTouchEnabled: Boolean = false, directTouchButtonState: Int = 0, laserEnabled: Boolean = true) : ComponentBase
Represents Controller Data and properties that can be used to facilitate input.
class CreatorVisibility(state: CreatorVisibilityState = CreatorVisibilityState.CREATOR_ONLY_VISIBLE) : ComponentBase
Use this Component to hide an Entity from every user except for the creator of the Entity or hide the entity from only the creator. This MUST be used with dynamically created Entities, Entities created using scene.xml do not have a "creator" and so will not be hidden.
enum CreatorVisibilityState : Enum<CreatorVisibilityState>
CreatorVisibilityState is an enum that represents the state of the CreatorVisibility Component.
class DeleteEntitiesSystem : SystemBase
This system is responsible for deleting entities that have been marked for deletion. It is responsible for deleting the scene object associated with the entity if it exists.
class Dome(radius: Float = 950.0f) : ComponentBase
Defines the dimensions of a dome shape by a radius. This can be used for skyboxes.
sealed class FlatColorMaterials
class Followable(target: Entity = Entity.nullEntity(), offset: Pose = Pose(Vector3(0.0f, 0.0f, 3.0f), Quaternion(0.0f, 0.0f, 1.0f, 0.0f)), minAngle: Float = -90f, maxAngle: Float = 90.0f, type: FollowableType = FollowableType.FACE, tolerance: Float = 0.2f, speed: Float = 1.0f, active: Boolean = true) : ComponentBase
Followable is a component that enables an entity to stay in front of another entity. Followable will track the orientation of the parent and move itself to stay in front.
class FollowableSystem : SystemBase
FollowableSystem is a System that updates the position of FollowableEntity’s based on the the position of the FollowableEntity’s target Entity.
enum GLTFTransformType : Enum<GLTFTransformType>
An enumeration representing the different types of transformations that can be applied to a node in a GLTF file.
class GLXF(uriInternal: String = "") : ComponentBase
This Component is used to represent a GLXF file from a URI. The URI can be a local file or a remote file.
data class GLXFAsset(val uri: <Error class: unknown class>, val index: Int, val name: String? = null, val scene: String? = null, val assetNodes: List<String>? = null, val transform: GLTFTransformType = GLTFTransformType.UNDEFINED)
A data class representing an asset in a GLXF file.
class GLXFAttributeTypeReference(val type: String, val innerTypes: List<String>? = null)
class GLXFEntityDeletionSystem(val glXFManager: GLXFManager) : SystemBase
This system is responsible for deleting GLXF entities.
class GLXFInfo(val glxfManager: GLXFManager, val version: String, val experience: Boolean, assets: MutableList<GLXFAsset>, var nodes: MutableList<GLXFNode>, val rootEntity: Entity, val uri: <Error class: unknown class>, context: <Error class: unknown class>, nodeMap: NodeMap = mutableMapOf<Entity, GLXFNode>(), nodesByName: MutableMap<String, GLXFNode> = mutableMapOf<String, GLXFNode>(), val keyName: String? = null, entityIdToEntityMap: MutableMap<String, Entity>, overrideCreateEntity: (<Error class: unknown class>?) -> Entity)
GLXFInfo is a class that represents a GLXF file. Refer to https://github.com/KhronosGroup/glTF-External-Reference/blob/main/specification/2.0/README.md for detailed specification.
typealias GLXFInfoMap = MutableMap<String, GLXFInfo>
class GLXFInternalNode(val entity: Entity, transform: GLXFNodeTransform, var name: String? = null, asset: GLXFAsset = GLXFAsset.nullGLXFAsset(), children: MutableList<GLXFNode> = mutableListOf<GLXFNode>(), childrenIndices: MutableSet<Int> = mutableSetOf<Int>(), isRoot: Boolean = true) : GLXFNode
A subclass of GLXFNode that represents a node in a GLXF file that has children.
class GLXFLeafNode(val entity: Entity, transform: GLXFNodeTransform, var name: String? = null, asset: GLXFAsset) : GLXFNode
A subclass of GLXFNode that represents a leaf node in a GLXF file.
class GLXFManager(val context: <Error class: unknown class>)
GLXFManager is a class that manages GLXF files.
open class GLXFNode(val entity: Entity, transform: GLXFNodeTransform, var name: String? = null, asset: GLXFAsset = GLXFAsset.nullGLXFAsset())
An open class representing a node in a GLXF file.
data class GLXFNodeTransform(val pose: Pose? = null, val scale: Vector3? = null, val matrix: Matrix44? = null)
A union of three types of transforms: pose, scale, and matrix.
enum GLXFReloadType : Enum<GLXFReloadType>
GLXFReloadType is an enum that specifies how GLXFs should be reloaded.
class GLXFRoot(rootEntity: Entity = Entity.nullEntity()) : ComponentBase
GLXFRoot is a Component that represents the root of a GLXF scene.
class Grabbable(enabled: Boolean = true, type: GrabbableType = GrabbableType.FACE, isGrabbed: Boolean = false, minHeight: Float = -Float.MAX_VALUE, maxHeight: Float = Float.MAX_VALUE) : ComponentBase
Grabbable is a component that allows an object to be grabbed by a controller. It requires the Mesh Component to be present.
class GrabbableSystem : SystemBase
GrabbableSystem is a System that allows for grabbing of objects in the scene. It is responsible for detecting when an object is grabbed and then updating the object’s position and rotation to match the grabber’s position and rotation. It also handles the release of the object when the grabber releases it.
enum GrabbableType : Enum<GrabbableType>
GrabbableType is an enum that defines the type of behavior an object has when grabbed.
class Hittable(hittable: MeshCollision = MeshCollision.LineTest) : ComponentBase
Defines whether an object is hittable or not.
class LazyViewModel<VM : SpatialViewModel>(args: Map<String, Any?>, owner: SpatialViewModelOwner, producer: (Map<String, Any?>) -> VM, viewModelClass: KClass<VM>)
class Material(repeatU: Float = 1.0f, repeatV: Float = 1.0f, offsetU: Float = 0.0f, offsetV: Float = 0.0f, baseColor: Color4 = Color4(0.5f, 0.5f, 0.5f, 1.0f), metallicInternal: Float = 0.0f, roughnessInternal: Float = 0.3f, unlit: Boolean = false, alphaMode: Int = com.meta.spatial.runtime.AlphaMode.OPAQUE.ordinal, shader: String = "", baseTextureAndroidResourceId: Int = 0) : ComponentBase
Material is a component that describes the material properties of an object. Details can be find Filament Materials Guide: https://google.github.io/filament/Materials.html
class Mesh(meshInternal: String = "", hittable: MeshCollision = MeshCollision.LineTest, defaultShaderOverride: String = "", defaultSceneOverride: Int = 0) : ComponentBase
Mesh component, used to specify a mesh to be rendered. This component is used to specify the mesh uri, hittable, default shader override, and default scene override.
enum MeshCollision : Enum<MeshCollision>
Mesh collision test type, used to determine how a mesh is hit tested.
class MeshCreationSystem(val meshManager: MeshManager) : SystemBase
MeshCreationSystem is responsible for creating the mesh for an entity when the Mesh component is added.
class MeshManager(val scene: Scene, val meshCreators: HashMap<String, (ent: Entity) -> SceneMesh>, val sceneObjectSystem: SceneObjectSystem)
class MeshMaterialOverrides(size: Int = 0) : ComponentBase
MeshMaterialOverrides is a component that allows you to override the material of a mesh.
class MeshMaterialOverridesSystem : SystemBase
MeshMaterialOverridesSystem is responsible for updating the material overrides of a mesh.
sealed class MetalMaterials
sealed class MineralMaterials
class Named(name: String = "n/a") : ComponentBase
A named component. This is a simple component that can be used to name the Entity.
class NetworkingTickSystem(val spatial: SpatialInterface) : SystemBase
NetworkingTickSystem is a system that runs every tick to update the networking state of the app
typealias NodeMap = MutableMap<Entity, GLXFNode>
sealed class OrganicMaterials
class Panel(panelRegistrationId: Int = 0, hittable: MeshCollision = MeshCollision.LineTest) : ComponentBase
Panel is a component that can be attached to a scene object to indicate that it is a panel. @param panelRegistrationId The id of the panel. This is used to identify the @PanelRegistration when creating the panel. @param hittable hit test type for the panel, @see MeshCollision
class PanelClickState(clickStateInternal: Int = 0) : ComponentBase
PanelClickState is a component that is used to track the state of a panel click. It is used in @see PanelClickSystem, and passes the state to the @see Panel component.
class PanelClickSystem : SystemBase
PanelClickSystem is responsible for handling the click events on the panels. It listens to the click events from the user and triggers the corresponding actions on the panels.
class PanelCreationSystem(val panelCreator: HashMap<Int, (ent: Entity) -> PanelSceneObject>) : SystemBase
PanelCreationSystem is responsible for creating and destroying panels.
class PanelCreator(val registrationId: Int, panelCreator: (entity: Entity) -> PanelSceneObject) : PanelRegistration
PanelCreator is a class that allows you to specify the panel creator function for a panel. The panel creator function is any customized function that takes an entity as input and returns the @see PanelSceneObject.
class PanelDimensions(dimensions: Vector2 = Vector2(0.75f, 1.0f)) : ComponentBase
PanelDimensions is a component that holds the dimensions of a panel. This is used to override the height and width of a panel when creating the panel. Without it, the panel’s height and width will be the values from @see PanelRegistration.
class PanelDimensionsSystem : SystemBase
PanelDimensionsSystem is responsible for updating the PanelDimensionsOverrides for each panel. The PanelDimensionsOverrides are used to determine the size of the panel.
open class PanelRegistration(val registrationId: Int, val init: PanelRegistration.(entity: Entity) -> Unit = {})
PanelRegistration is a class that allows you to register a panel with the Spatial Toolkit. To use panels in your app, you will need to:
object PerfLogger
class Plane(width: Float = 1.0f, depth: Float = 1.0f) : ComponentBase
Defines the dimensions of a horizontal plane.
enum PlaybackState : Enum<PlaybackState>
Playback state of the animation. This is used to determine whether the animation is playing or paused.
enum PlaybackType : Enum<PlaybackType>
Playback type of the animation. This is used to determine how the animation is played.
class PlayerBodyAttachmentSystem : SystemBase
This PlayerBodyAttachmentSystem is responsible for setting the local player’s avatar body components based on the local player’s attachments.
class ProcessListenersSystem(val spatial: SpatialInterface) : SystemBase
This System processes listeners in the DataModel
class Quad(min: Vector2 = Vector2(0.0f, 0.0f), max: Vector2 = Vector2(0.0f, 0.0f)) : ComponentBase
A Quad is a 2D shape that can be used to represent a 2D surface in 3D space. It is defined by its minimum and maximum coordinates.
class ResetDataModelSystem(val spatial: SpatialInterface) : SystemBase
This System resets the data model. This is used to reset the data model when the app is closed.
class RoundedBox(min: Vector3 = Vector3(0.0f, 0.0f, 0.0f), max: Vector3 = Vector3(1.0f, 1.0f, 1.0f), radius: Vector3 = Vector3(0.1f, 0.1f, 0.1f)) : ComponentBase
Defines the dimensions of a box shape with rounded edges by the relative offset of two opposite corners and a Vector3 of radii to modify the roundedness of the edges
class RunMainThreadWorkItemsSystem(val spatial: SpatialInterface) : SystemBase
This System runs the main thread work items.
class Scale(scale: Vector3 = Vector3(1.0f, 1.0f, 1.0f)) : ComponentBase
Sets the scale for any Mesh attached to this entity uniformly in each direction.
class ScaleSystem : SystemBase
This System scales an entity based on the Scale component.
class SceneObjectSystem : SystemBase
System to manage SceneObjects and their lifecycles.
class ScenePlane(name: String = "", type: String = "", offset: Vector3 = Vector3(0.0f, 0.0f, 0.0f), extents: Vector3 = Vector3(0.0f, 0.0f, 0.0f)) : ComponentBase
A ScenePlane is a 2D plane in the scene. It has a name, type, offset, and extents.
class SceneUpdateTickTimeSystem(val spatial: SpatialInterface) : SystemBase
System that updates the scene every tick.
class SceneVolume(name: String = "", type: String = "", offset: Vector3 = Vector3(0.0f, 0.0f, 0.0f), extents: Vector3 = Vector3(0.0f, 0.0f, 0.0f)) : ComponentBase
A SceneVolume is a 3D volume that can be used to represent a physical object in the scene.
object SpatialActivityManager
This object is used to manage the current activity. It is used to get the weak reference to the current activity and execute code on the current activity.
abstract class SpatialViewModel(closeables: ConcurrentHashMap<String, Closeable> = ConcurrentHashMap()) : Closeable
class Sphere(radius: Float = 0.0f) : ComponentBase
The component that defines the dimensions of a sphere by the radius. To be used with the mesh://sphereMesh URI.
class SupportsLocomotion : ComponentBase
This component is used to indicate that an entity supports locomotion. When added to an entity with a mesh, it allows for default locomotion on the mesh
class TickAnimationSystem(val spatial: SpatialInterface) : SystemBase
This System animates the scene object.
class TickControllerSystem(val spatial: SpatialInterface) : SystemBase
This System handles the behavior of controllers.
class TickDataModelSystem(val spatial: SpatialInterface) : SystemBase
This System runs the DataModel
class TickTransformSystem(val spatial: SpatialInterface) : SystemBase
This System calculates and sets the transforms of the entites.
class ToolkitFeature(val glXFManager: GLXFManager, spatial: SpatialInterface, systemManager: SystemManager, ctx: <Error class: unknown class>) : SpatialFeature
class Transform(transform: Pose = Pose()) : ComponentBase
A component that represents a transform. The transform is the Pose, aka. a combination of a position and an orientation. The Pose identifies the position and orientation of the entity.
class TransformParent(entity: Entity = Entity.nullEntity()) : ComponentBase
This is a component that is used to store the parent of a transform. This is used to keep track of the parent of a transform when it is moved. The entity’s transform will be updated to match the parent’s transform when the parent is moved.
class Visible(isVisible: Boolean = true) : ComponentBase
Gives the ability to change mesh between being visible and invisible.
class VisibleSystem : SystemBase
This System shows/hides entites with the Visible component.

Properties

NameSummary
changed
const val changed: Int = 1
distance
const val distance: Float = 0.0f
downTime
const val downTime: Long = 1000
meshElementId
const val meshElementId: Int = 0
nodeId
const val nodeId: Int = 0
point
val point: Vector3
srcId
const val srcId: Long = 2000
SUPPORTED_GLXF_EXTENSIONS
val SUPPORTED_GLXF_EXTENSIONS: Set<String>
A set of supported GLXF file extensions.
textureCoordinate
val textureCoordinate: Vector2

Functions

NameSummary
addName
fun Entity.addName(name: String): Entity
Box
fun Box(size: Vector3): Box
Creates a box with a given size in each dimension.
fun Box(edgeLength: Float = 1.0f): Box
Creates a cube with a given edge length.
clampYAngle
fun clampYAngle(vector: Vector3, minAngleDegrees: Float, maxAngleDegrees: Float): Vector3
createPanelEntity
fun Entity.Companion.createPanelEntity(panelId: Int, transform: Transform, vararg components: ComponentBase): Entity
fun Entity.Companion.createPanelEntity(entityId: Int, panelId: Int, transform: Transform, vararg components: ComponentBase): Entity
fromBox
fun Entity.Companion.fromBox(length: Float, transform: Transform, material: Material? = null, vararg components: ComponentBase): Entity
fromGLB
fun Entity.Companion.fromGLB(mesh: Mesh, transform: Transform, vararg components: ComponentBase): Entity
fromMeshAndMaterial
fun Entity.Companion.fromMeshAndMaterial(mesh: Mesh, material: Material, transform: Transform, vararg components: ComponentBase): Entity
fromPanelRegistry
fun Entity.Companion.fromPanelRegistry(registry: PanelRegistration, transform: Transform, vararg components: ComponentBase): Entity
fromSphere
fun Entity.Companion.fromSphere(length: Float, transform: Transform, material: Material? = null, vararg components: ComponentBase): Entity
getAbsoluteTransform
fun getAbsoluteTransform(entity: Entity): Pose
getRelativePose
fun getRelativePose(parent: Entity, child: Entity): Pose
fun getRelativePose(parent: Entity, child: Pose): Pose
fun getRelativePose(parent: Pose, child: Pose): Pose
GLXF
fun GLXF(uri: <Error class: unknown class>): GLXF
Mesh
fun Mesh(mesh: <Error class: unknown class>, hittable: MeshCollision = MeshCollision.LineTest, defaultShaderOverride: String = "", defaultSceneOverride: Int = -1): Mesh
MeshMaterialOverrides
fun MeshMaterialOverrides(colors: <Error class: unknown class><Int, Int>): MeshMaterialOverrides
PanelClickState
fun PanelClickState(clickState: ClickState): PanelClickState
reparentChildInWorldCoordinates
fun reparentChildInWorldCoordinates(parent: Entity, child: Entity)
resetFollowable
fun resetFollowable(followable: Entity)
Scale
fun Scale(scaleValue: Float): Scale
TrackedBody
fun TrackedBody(jointPoses: <Error class: unknown class><Int, Pose>): TrackedBody
viewModels
inline fun <VM : SpatialViewModel> SpatialViewModelOwner.viewModels(args: Map<String, Any?> = emptyMap(), owner: SpatialViewModelOwner = this, noinline producer: (Map<String, Any?>) -> VM = { VM::class.constructors.firstOrNull { it.parameters.isEmpty() }?.call() ?: throw IllegalArgumentException( "Primary constructor does not exist or requires one or more parameters. Please " + "make your primary constructor require zero parameters or provide a factory " + "producer") }): <Error class: unknown class><VM>
Did you find this page helpful?
Thumbs up icon
Thumbs down icon