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

Material

Material

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. This component is only used to assign properties to procedural meshes such as those created with the Mesh component. Meta Spatial SDK provides some basic preset materials with FlatColorMaterials.
Example of procedural mesh box with material:
Entity.create(
  listOf(
      Mesh(Uri.parse("mesh://box")),
      Material().apply {
        baseColor = Color4(red = 0.2f, green = 0.8f, blue = 0.4f, alpha = 1.0f)
      },
      Box(Vector3(0.25f)),
      Transform(Pose(Vector3(0.0f, 0.0f, 0.0f))),
  ))
Details about the properties can be found in the Filament Materials Guide: https://google.github.io/filament/Materials.html

Constructors

NameSummary
Material
constructor(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)

Types

NameSummary
Companion
object Companion : ComponentCompanion

Properties

NameSummary
alphaMode
var alphaMode: Int

alpha mode of the material
baseColor
var baseColor: Color4

: base color of the material
baseTextureAndroidResourceId
var baseTextureAndroidResourceId: Int

base texture of the material
cachable
open override var cachable: <Error class: unknown class>
entID
var entID: Long
isDirty
var isDirty: Boolean
metallic
var metallic: Float

: metallic of the material
metallicInternal
var metallicInternal: Float

metallic of the material
offsetU
var offsetU: Float

offset u of the material
offsetV
var offsetV: Float

offset v of the material
recycled
var recycled: Boolean
repeatU
var repeatU: Float

repeat u of the material
repeatV
var repeatV: Float

repeat v of the material
roughness
var roughness: Float

: roughness of the material
roughnessInternal
var roughnessInternal: Float

roughness of the material
shader
var shader: String

shader of the material
timeStamp
var timeStamp: Long
unlit
var unlit: Boolean

whether the material is unlit

Functions

NameSummary
companion
open override fun companion(): ComponentCompanion

Gets the companion object for this component.
generateSceneMaterial
fun generateSceneMaterial(entity: Entity, ctx: <Error class: unknown class>): SceneMaterial
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
alphaModeData
val alphaModeData: IntAttributeData
alphaModeId
val alphaModeId: <Error class: unknown class>
attributeKeys_
val attributeKeys_: IntArray
attributeTypeCounts_
val attributeTypeCounts_: IntArray
attributeTypes_
val attributeTypes_: IntArray
attrMetaData_
val attrMetaData_: Map<Int, <Error class: unknown class><RegisteredAttributeType, String>>
baseColorData
val baseColorData: Color4AttributeData
baseColorId
val baseColorId: <Error class: unknown class>
baseTextureAndroidResourceIdData
val baseTextureAndroidResourceIdData: IntAttributeData
baseTextureAndroidResourceIdId
val baseTextureAndroidResourceIdId: <Error class: unknown class>
createDefaultInstance
open override val createDefaultInstance: () -> Material
enumClassesMap_
val enumClassesMap_: Map<Int, Class<out Enum<*>>>
id
open override val id: <Error class: unknown class>
keyStringToKeyIntMap_
val keyStringToKeyIntMap_: Map<String, Int>
metallicInternalData
val metallicInternalData: FloatAttributeData
metallicInternalId
val metallicInternalId: <Error class: unknown class>
offsetUData
val offsetUData: FloatAttributeData
offsetUId
val offsetUId: <Error class: unknown class>
offsetVData
val offsetVData: FloatAttributeData
offsetVId
val offsetVId: <Error class: unknown class>
repeatUData
val repeatUData: FloatAttributeData
repeatUId
val repeatUId: <Error class: unknown class>
repeatVData
val repeatVData: FloatAttributeData
repeatVId
val repeatVId: <Error class: unknown class>
roughnessInternalData
val roughnessInternalData: FloatAttributeData
roughnessInternalId
val roughnessInternalId: <Error class: unknown class>
sceneTextureCache
val sceneTextureCache: <Error class: unknown class><Int, SceneTexture>
shaderData
val shaderData: StringAttributeData
shaderId
val shaderId: <Error class: unknown class>
unlitData
val unlitData: BooleanAttributeData
unlitId
val unlitId: <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 override 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