---
title: "SceneCoreEntity"
description: "A composable that attaches to a SceneCore entity and allow compose to size, position, reparent, add children, and apply modifiers to the entity."
type: "composable"
lastmod: "2026-07-19T07:47:45.719288Z"
---
## API Reference

### SceneCoreEntity

> Source set: Android

```kotlin
@Composable
@SubspaceComposable
public fun <T : Entity> SceneCoreEntity(
    factory: () -> T,
    modifier: SubspaceModifier = SubspaceModifier,
    update: (T) -> Unit = {},
    sizeAdapter: SceneCoreEntitySizeAdapter<T>? = null,
    content: @Composable @SubspaceComposable () -> Unit = {},
)
```

A composable that attaches to a SceneCore entity and allow compose to size, position, reparent,
add children, and apply modifiers to the entity.

Usage of this API requires the SceneCore dependency to be added. See
https://developer.android.com/jetpack/androidx/releases/xr-scenecore

#### Parameters

| | |
| --- | --- |
| factory | the factory method for creating the SceneCore `Entity`. |
| modifier | the [SubspaceModifier](/jetpack-compose/androidx.xr.compose/compose/interfaces/SubspaceModifier) that will be applied to this node. |
| update | a callback to be invoked on recomposition to apply any state changes to the Entity. This will track snapshot state reads and call `update` when they change. |
| sizeAdapter | an adapter that allows compose to integrate its layout size changes with the rendered entity size. This adapter implementation will likely be different for every entity and some SceneCore entities may not require sizing at all (this may be null). |
| content | the children of this `Entity`. |

## Code Examples
### SceneCoreEntitySample
```kotlin
@Composable
@SubspaceComposable
public fun SceneCoreEntitySample() {
    val session = checkNotNull(LocalSession.current)
    val context = LocalContext.current
    val view = remember(context) { View(context) }
    val density = LocalDensity.current
    val virtualPixelDensity = session.scene.virtualPixelDensity
    // A state variable to dynamically control the size of the panel in DP
    var panelSizeDp by remember { mutableStateOf(400.dp) }
    SceneCoreEntity(
        factory = {
            // Convert the DP size to meters using the virtual pixel density, PanelEntity also has
            // APIs that use pixels directly, but a lot of other SceneCore APIs do not have this.
            val sizeInPx = with(density) { panelSizeDp.toPx() }
            val sizeInMeters = virtualPixelDensity.convertPixelsToMeters(sizeInPx)
            PanelEntity.create(
                session = session,
                view = view,
                dimensions = FloatSize2d(sizeInMeters, sizeInMeters),
                name = "SamplePanel",
            )
        },
        update = { entity ->
            // Update the entity size when state changes
            val sizeInPx = with(density) { panelSizeDp.toPx() }
            val sizeInMeters = virtualPixelDensity.convertPixelsToMeters(sizeInPx)
            entity.size = FloatSize2d(sizeInMeters, sizeInMeters)
        },
    )
}
```
