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

SceneObject

SceneObject

open class SceneObject
The SceneObject class combines a SceneMesh with position and rotation to fully represent a 3D Object in the scene. Entitys with meshes have SceneObjects created and managed by the com.meta.spatial.toolkit.Transform, com.meta.spatial.toolkit.Mesh, and com.meta.spatial.toolkit.Panel components.
In addition to position, the SceneObject is also responsible for handling:
  1. 3D object visibility. (Also managed via the com.meta.spatial.toolkit.Visible component and com.meta.spatial.toolkit.VisibleSystem System).
  2. InputListener for handling input events on 3D objects.
  3. Managing GLTF animations.
  4. Updating positions of nodes in a GLTF scenegraph.
SceneObjects associated with an Entity can be accessed via:
systemManager.findSystem<SceneObjectSystem>().getSceneObject(myEntity)?.thenAccept { sceneObject -> sceneObject.addInputListener(myInputListener) }

Constructors

NameSummary
SceneObject
constructor(scene: Scene, mesh: SceneMesh, name: String, entity: Entity? = null)

Constructor for a SceneObject.

constructor(scene: Scene, entity: Entity? = null)

Constructor for a SceneObject.

Types

NameSummary
Companion
object Companion

Properties

NameSummary
entity
val entity: Entity?
handle
var handle: Long
materials
var materials: Array<SceneMaterial>?

Array of SceneMaterials created from this SceneObject’s mesh property. Changes to the materials in this array will be unique to this SceneObject, but these materials will inhererit any changes made in the SceneMesh they come from.
mesh
var mesh: SceneMesh?

Reference to the SceneMesh used by this SceneObject. This property is a reference to the underlying mesh resource. Changes to the SceneMesh or its SceneMaterials will be reflected across all SceneObjects that reference it.

Functions

NameSummary
addInputListener
fun addInputListener(listener: InputListener): Long

Add an input listener to this SceneObject.
destroy
fun destroy()

Destory this SceneObject.
destroyInternal
open fun destroyInternal()

Destroy this SceneObject’s native components.
onClick
open fun onClick(hitInfo: HitInfo, sourceOfInput: Entity)

Handler for clicks on this SceneObject.
onClickDown
fun onClickDown(hitInfo: HitInfo, sourceOfInput: Entity)

Handler for click downs on this SceneObject. Use onClick() to ensure user releases the click on the SceneObject.
onHoverStart
open fun onHoverStart(sourceOfInput: Entity)

Handler for the start of hovers on this SceneObject.
onHoverStop
open fun onHoverStop(sourceOfInput: Entity)

Handler for the termination of hovers on this SceneObject.
onInput
open fun onInput(hitInfo: HitInfo, sourceOfInput: Entity, changed: Int, buttonState: Int, downTime: Long): Boolean

Handler to handle generic input.
onPointerEvent
open fun onPointerEvent(hitInfo: HitInfo, type: Int, sourceOfInput: Entity, scrollInfo: Vector2, semanticType: Int = SemanticType.Unknown.id)

Handler to handle pointer events on this SceneObject.
removeInputListener
fun removeInputListener(id: Long)

Remove an input listener by id.
setIsVisible
fun setIsVisible(isVisible: Boolean)

Set whether this SceneObject is visible.
setLocalNodePose
fun setLocalNodePose(node: Int, pose: Pose)

Sets the local transform of the node (relative to it’s parent) to the input pose
setPosition
fun setPosition(position: Vector3)

fun setPosition(x: Float, y: Float, z: Float)

Set the 3D position of this SceneObject.
setRotation
fun setRotation(pitch: Float, yaw: Float, roll: Float)

Set the rotation of this SceneObject.
setRotationQuat
fun setRotationQuat(quat: Quaternion)

fun setRotationQuat(x: Float, y: Float, z: Float, w: Float)

Set the rotation of this SceneObject.
setScale
open fun setScale(scale: Vector3)

Set the scale of the model. The default value is 1.0f.
setSceneMesh
open fun setSceneMesh(mesh: SceneMesh, name: String)

Set the SceneMesh for this SceneObject.
shouldFrustumCull
fun shouldFrustumCull(cull: Boolean)

Whether this SceneObject can be frustum culled (default is true)
stopInput
open fun stopInput(sourceOfInput: Entity, downTime: Long)

This function calls the stopInput function on all InputListener for this SceneObject. This is called automatically by Scene when handling inputs.
updateAnimationTrackToTime
fun updateAnimationTrackToTime(track: Int, timeInSeconds: Float)

Update the local transforms of the model to match the given animation track at the specified time (matching keyframe time in the glTF).
updateNodeLocalPoseToObjectPose
fun updateNodeLocalPoseToObjectPose(node: Int, pose: Pose)

Sets the local transform of a node (relative to it’s parent) such that the resulting object transform (relative to the model) is placed at the input pose
updateSceneMesh
fun updateSceneMesh(meshModifier: SceneMesh.() -> Unit)

Modify and update this SceneObject’s mesh.

Companion

object Companion
Did you find this page helpful?
Thumbs up icon
Thumbs down icon