onSceneReady()
function. The system calls onSceneReady()
when the spatial scene is ready to be populated. To add a cube, you’ll modify the onSceneReady()
function.StarterSampleActivity.kt
file, which has a file path of /Meta-Spatial-SDK-Samples/StarterSample/app/src/main/java/com/meta/spatial/samples/startersample
. This file is the starting point for your app. import com.meta.spatial.core.Quaternion
import com.meta.spatial.toolkit.Box
import com.meta.spatial.toolkit.Color4
onSceneReady()
function, add this code. It passes components to the Entity.create()
method to create a red cube at the world origin and add it to your scene in a single call. Entity.create(
listOf(
Mesh(Uri.parse("mesh://box")),
Box(Vector3(-0.25f, -0.25f, -0.25f), Vector3(0.25f, 0.25f, 0.25f)),
Material().apply {
baseColor = Color4(red = 1.0f, green = 0.1f, blue = 0.1f, alpha = 1.0f)
},
Transform(
Pose(
Vector3(0.0f, 0.0f, 0.0f),
Quaternion(0.0f, 0.0f, 0.0f))),
))
green = 0.1f
to green = 1.0f
to adjust the color.Grabbable
component from the Spatial SDK toolkit
package. import com.meta.spatial.toolkit.Grabbable
Grabbable()
as an argument at the end of listOf()
. Entity.create(
listOf(
Mesh(Uri.parse("mesh://box")),
Box(Vector3(-0.25f, -0.25f, -0.25f), Vector3(0.25f, 0.25f, 0.25f)),
Material().apply {
baseColor = Color4(red = 1.0f, green = 0.1f, blue = 0.1f, alpha = 1.0f)
},
Transform(
Pose(
Vector3(0.0f, 0.0f, 0.0f),
Quaternion(0.0f, 0.0f, 0.0f))),
Grabbable(),
))