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

Mesh

Mesh

class Mesh(mesh: <Error class: unknown class> = Uri.EMPTY, 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.
The Mesh component can point to any glb in the app’s assets folder, on device, or over network. URIs pointing to on-device assets should be of the form "file://replace_with_path". The com.meta.spatial.runtime.NetworkedAssetLoader should be initialized when downloading assets over network.
Entity.create(listOf(Mesh(Uri.parse("environment.glb")), SupportsLocomotion(), Transform())) // From assets folder
Entity.create(listOf(Mesh(Uri.parse("https://github.com/KhronosGroup/glTF-Sample-Models/raw/refs/heads/main/2.0/Duck/glTF-Binary/Duck.glb)), Transform())) // From network
Special URIs are supported for procedural meshes:
Mesh(Uri.parse("mesh://plane")) // creates a flat plane
Mesh(Uri.parse("mesh://sphere")) // creates a sphere
Mesh(Uri.parse("mesh://box")) // creates a cube
Mesh(Uri.parse("mesh://roundedbox")) // creates a rounded cube
Mesh(Uri.parse("mesh://dome")) // creates a half-sphere
Mesh(Uri.parse("mesh://axis")) // creates an axis for debugging
Mesh(Uri.parse("mesh://skybox")) // creates a skybox
Mesh(Uri.parse("mesh://quad")) // creates a quad
The Plane, Sphere, Box, RoundedBox, Dome, and Quad components are provided to customize the dimensions of the procedural meshes. The Material component can be used to customize the material of the procedural meshes.

Constructors

NameSummary
Mesh
constructor(mesh: <Error class: unknown class> = Uri.EMPTY, hittable: MeshCollision = MeshCollision.LineTest, defaultShaderOverride: String = "", defaultSceneOverride: Int = 0)

Types

NameSummary
Companion
object Companion : ComponentCompanion

Properties

NameSummary
cachable
open override var cachable: <Error class: unknown class>
defaultSceneOverride
var defaultSceneOverride: Int

Int of the default scene to be used for the mesh
defaultShaderOverride
var defaultShaderOverride: String

String of the default shader to be used for the mesh
entID
var entID: Long
hittable
var hittable: MeshCollision

The type of behavior the object can be hit using.
isDirty
var isDirty: Boolean
mesh
var mesh: <Error class: unknown class>

Uri of the mesh to be rendered
recycled
var recycled: Boolean
timeStamp
var timeStamp: Long

Functions

NameSummary
companion
open override fun companion(): ComponentCompanion

Gets the companion object for this component.
getComponentDataAttributeType
fun getComponentDataAttributeType(key: Int): AttributePrimitive?

Gets the attribute type for the specified key.



fun getComponentDataAttributeType(keyString: String): AttributePrimitive?

Gets the attribute type for the specified string key.
getComponentDataKey
fun getComponentDataKey(key: String): Int?

Gets the integer key associated with the specified string key.
getComponentDataValue
fun getComponentDataValue(key: Int): Any?

Gets the value for the specified key.



fun getComponentDataValue(keyString: String): Any?

Gets the value for the specified string key.
getEnumClass
fun getEnumClass(key: String): Class<out Enum<*>>?

Gets the enum class associated with the specified string key.
hasComponentData
fun hasComponentData(key: Int): Boolean

Checks if this component has data for the specified key.



fun hasComponentData(keyString: String): Boolean

Checks if this component has data for the specified string key.
read
fun read(e: Entity, cachable: Boolean)

Reads component data from the specified entity.
recycle
fun recycle()

Recycles this component by returning it to its pool.
reset
open fun reset()

Resets the component to its default state.
setComponentDataValue
fun setComponentDataValue(key: Int, value: Any): Boolean

Sets the value for the specified key.



fun setComponentDataValue(keyString: String, value: Any): Boolean

Sets the value for the specified string key.
setPool
fun setPool(pool: ComponentPool<*>, entID: Long)

Sets the component pool and entity ID for this component.
toString
open override fun toString(): String
typeID
open override fun typeID(): Int

Returns the unique type ID of this component.
write
fun write(e: Entity)

Writes this component’s data to the specified entity.

Companion

object Companion : ComponentCompanion

Properties

NameSummary
attributeKeys_
val attributeKeys_: IntArray
attributeTypeCounts_
val attributeTypeCounts_: IntArray
attributeTypes_
val attributeTypes_: IntArray
attrMetaData_
val attrMetaData_: Map<Int, <Error class: unknown class><RegisteredAttributeType, String>>
createDefaultInstance
open override val createDefaultInstance: () -> Mesh
defaultSceneOverrideData
val defaultSceneOverrideData: IntAttributeData
defaultSceneOverrideId
val defaultSceneOverrideId: <Error class: unknown class>
defaultShaderOverrideData
val defaultShaderOverrideData: StringAttributeData
defaultShaderOverrideId
val defaultShaderOverrideId: <Error class: unknown class>
enumClassesMap_
val enumClassesMap_: Map<Int, Class<out Enum<*>>>
hittableData
val hittableData: EnumAttributeData
hittableId
val hittableId: <Error class: unknown class>
id
open override val id: <Error class: unknown class>
keyStringToKeyIntMap_
val keyStringToKeyIntMap_: Map<String, Int>
meshData
val meshData: URIAttributeData
meshId
val meshId: <Error class: unknown class>

Functions

NameSummary
attributeKeys
open override fun attributeKeys(): IntArray
attributeMetaData
open override fun attributeMetaData(): Map<Int, <Error class: unknown class><RegisteredAttributeType, String>>
attributeTypeCountAvailable
open override fun attributeTypeCountAvailable(): Boolean
attributeTypeCounts
open override fun attributeTypeCounts(): IntArray
attributeTypes
open override fun attributeTypes(): IntArray
dependents
open fun dependents(): IntArray
enumClassesMap
open override fun enumClassesMap(): Map<Int, Class<out Enum<*>>>
keyStringToKeyIntMap
open override fun keyStringToKeyIntMap(keyString: String): Int?
Did you find this page helpful?
Thumbs up icon
Thumbs down icon