# SpaceEntity

Artifact: [androidx.xr.scenecore:scenecore](https://developer.android.com/jetpack/androidx/releases/xr-scenecore) [View Source](https://cs.android.com/search?q=file:androidx/xr/scenecore/SpaceEntity.kt+class:androidx.xr.scenecore.SpaceEntity) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

*** ** * ** ***


```
abstract class SpaceEntity : Entity
```

<br />

|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) ||||
| ↳ | [androidx.xr.scenecore.BaseScenePose](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose) |||
|   | ↳ | [androidx.xr.scenecore.Entity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity) ||
|   |   | ↳ | [androidx.xr.scenecore.SpaceEntity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity) |

Known direct subclasses [ActivitySpace](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace), [AnchorSpace](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/AnchorSpace)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace` | ActivitySpace is a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity` used to track the system-managed pose and boundary of the volume associated with a spatialized Activity. |
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/AnchorSpace` | An AnchorSpace is a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity` tracks a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` relative to some position or surface in the "Real World." Children of this `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity` will remain positioned relative to that location in the real world. |

*** ** * ** ***

A SpaceEntity is a special Entity subtype whose position is independent of other SpaceEntity. It is parentless and its position and scale are controlled by the system. Calling `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity#setPose(androidx.xr.runtime.math.Pose,androidx.xr.scenecore.Space)`, `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity#setScale(kotlin.Float,androidx.xr.scenecore.Space)`, or setting the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#parent()` property on a SpaceEntity will result in an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html`.

Examples of SpaceEntity are `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace` and `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/AnchorSpace`.

## Summary

| ### Public functions |
|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity#getPose(androidx.xr.scenecore.Space)(relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)` Returns the pose of the `SpaceEntity` relative to the specified coordinate space. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity#getScale(androidx.xr.scenecore.Space)(relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)` Returns the scale of the `SpaceEntity` relative to the specified coordinate space. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity#setPose(androidx.xr.runtime.math.Pose,androidx.xr.scenecore.Space)(pose: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose, relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)` Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` if called. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity#setScale(kotlin.Float,androidx.xr.scenecore.Space)(scale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)` Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` if called. |

| ### Public properties |
|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity?` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity#parent()` Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` if called. |

### Inherited functions

From [androidx.xr.scenecore.BaseScenePose](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose) `open suspend https://developer.android.com/reference/kotlin/androidx/xr/scenecore/HitTestResult?` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#hitTest(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)(origin: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, direction: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3)`

Perform a hit test from the specified origin in the specified direction into the Scene.
`open suspend https://developer.android.com/reference/kotlin/androidx/xr/scenecore/HitTestResult?` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#hitTest(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3,kotlin.Int)(origin: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, direction: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, hitTestFilter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Creates a hit test from the specified origin in the specified direction into the scene.
`open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#transformDirectionTo(androidx.xr.runtime.math.Vector3,androidx.xr.scenecore.ScenePose)(direction: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, destination: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose)`

Transforms a direction from this ScenePose's local space to the destination ScenePose's local space.
`open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#transformPoseTo(androidx.xr.runtime.math.Pose,androidx.xr.scenecore.ScenePose)(pose: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose, destination: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose)`

Returns a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` relative to this ScenePose, transformed into a Pose relative to the destination.
`open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#transformPositionTo(androidx.xr.runtime.math.Vector3,androidx.xr.scenecore.ScenePose)(position: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, destination: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose)`

Transforms a position from this ScenePose's local space to the destination ScenePose's local space.
`open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#transformVectorTo(androidx.xr.runtime.math.Vector3,androidx.xr.scenecore.ScenePose)(vector: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, destination: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose)`

Transforms a vector from this ScenePose's local space to the destination ScenePose's local space.
From [androidx.xr.scenecore.Entity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#addChild(androidx.xr.scenecore.Entity)(child: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity)`

Sets an Entity to be a child of this Entity in the scene graph.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#addComponent(androidx.xr.scenecore.Component)(component: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Component)`

Adds a Component to this Entity.
`@https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getAlpha(androidx.xr.scenecore.Space)(relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)`

Returns the alpha transparency set for this Entity, relative to given Space.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Component>` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getComponents()()`

Retrieves all components attached to this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T>` `<T : https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Component> https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getComponentsOfType(java.lang.Class)(type: https://developer.android.com/reference/java/lang/Class.html<T>)`

Retrieves all Components of the given type `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getComponentsOfType(java.lang.Class)` and its subtypes attached to this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#isEnabled(kotlin.Boolean)(includeParents: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Returns the enabled status of this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#removeAllComponents()()`

Remove all components from this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#removeComponent(androidx.xr.scenecore.Component)(component: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Component)`

Removes the given Component from this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#setAlpha(kotlin.Float)(alpha: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`

Sets the alpha transparency of the Entity relative to the parent Space.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#setEnabled(kotlin.Boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Sets the local enabled state of this Entity.

### Inherited properties

From [androidx.xr.scenecore.BaseScenePose](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose) `open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#poseInActivitySpace()`

The current `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` relative to the activity space root.
From [androidx.xr.scenecore.Entity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity>` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#children()`

Provides the list of all children of this entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#contentDescription()`

Alternate text for this Entity to be consumed by Accessibility systems.

## Public functions

### getPose

```
open fun getPose(relativeTo: Space = Space.PARENT): Pose
```

Returns the pose of the `SpaceEntity` relative to the specified coordinate space.

| Parameters |
|---|---|
| `relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space = Space.PARENT` | The coordinate space to get the pose relative to. Defaults to `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space#PARENT()`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` | The current pose of the `SpaceEntity`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if called with Space.PARENT since SpaceEntity has no parents. |

### getScale

```
open fun getScale(relativeTo: Space = Space.PARENT): Float
```

Returns the scale of the `SpaceEntity` relative to the specified coordinate space.

| Parameters |
|---|---|
| `relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space = Space.PARENT` | The coordinate space to get the scale relative to. Defaults to `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space#PARENT()`. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The current scale of the `SpaceEntity`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if called with Space.PARENT since SpaceEntity has no parents. |

### setPose

```
open fun setPose(pose: Pose, relativeTo: Space = Space.PARENT): Unit
```

Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` if called.

**Note:** The pose of the `SpaceEntity` is managed by the system. Applications should not call this method, as any changes may be overwritten by the system.

| Parameters |
|---|---|
| `pose: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` | The new pose to set. |
| `relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space = Space.PARENT` | The space in which the pose is defined. Defaults to `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space#PARENT()`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` | if called. |

### setScale

```
open fun setScale(scale: Float, relativeTo: Space = Space.PARENT): Unit
```

Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` if called.

**Note:** The scale of an `SpaceEntity` is managed by the system. Applications should not call this method, as any changes may be overwritten by the system.

| Parameters |
|---|---|
| `scale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The new scale to set. |
| `relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space = Space.PARENT` | The space in which the scale is defined. Defaults to `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space#PARENT()`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` | if called. |

## Public properties

### parent

```
open var parent: Entity?
```

Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` if called.

**Note:** The `SpaceEntity` has no parent; retrieving the parent will return null.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` | when setting |