---
title: "SceneCoreEntitySizeAdapter"
description: "The sizing strategy used by SceneCoreEntity to control and read the size of an entity."
type: "interface"
lastmod: "2026-05-08T01:17:01.416673Z"
---
## API Reference

> Source set: Android

```kotlin
public interface SceneCoreEntitySizeAdapter<T : Entity>
```

The sizing strategy used by [SceneCoreEntity](/jetpack-compose/androidx.xr.compose/compose/composable-functions/SceneCoreEntity) to control and read the size of an entity.

The developer should use [onLayoutSizeChanged](#onlayoutsizechanged) to apply compose layout size changes to the
entity. Compose will not inherently affect the size of the `Entity`.

If the developer uses [onLayoutSizeChanged](#onlayoutsizechanged) to change the size of the entity, but [currentSize](#currentsize)
is not provided, then the intrinsic size of the entity will be ignored and the layout size as
determined solely by compose will be used to size the entity. If the [SceneCoreEntity](/jetpack-compose/androidx.xr.compose/compose/composable-functions/SceneCoreEntity) has no
children or size modifiers then compose doesn't know how to size this node and it will be size 0,
causing it not to render at all. In such a case, please do one of the following: (1) provide
[currentSize](#currentsize) so compose can infer the size from the entity, (2) add a sizing modifier to control
the size of the entity, or (3) remove the adapter from the [SceneCoreEntity](/jetpack-compose/androidx.xr.compose/compose/composable-functions/SceneCoreEntity) as without an
adapter compose will not try to control the size of this entity.

Note that many SceneCore entities accept sizes in meter units instead of pixels. The [Meter](/jetpack-compose/androidx.xr.compose/compose/classes/Meter) type
may be used to convert from pixels to meters.

## Functions

### onLayoutSizeChanged

```kotlin
public fun onLayoutSizeChanged(entity: T, size: IntVolumeSize)
```

A callback that is invoked with the final layout size of the composable in pixels.

### currentSize

```kotlin
public fun currentSize(entity: T): IntVolumeSize?
```

A getter method that returns the current [IntVolumeSize](/jetpack-compose/androidx.xr.compose/compose/classes/IntVolumeSize) in pixels of the entity. This isn't
as critical for compose as [onLayoutSizeChanged](#onlayoutsizechanged); however, this can help to inform compose of
the intrinsic size of the entity.

## Code Examples

### SceneCoreEntitySizeAdapterSample
```kotlin
@Composable
fun SceneCoreEntitySizeAdapterSample() {
    val density = LocalDensity.current
    val panelSizeAdapter =
        object : SceneCoreEntitySizeAdapter<PanelEntity> {
            override fun onLayoutSizeChanged(entity: PanelEntity, size: IntVolumeSize) {
                entity.sizeInPixels =
                    IntSize2d(
                        Meter.fromPixel(size.width.toFloat(), density).toM().toInt(),
                        Meter.fromPixel(size.height.toFloat(), density).toM().toInt(),
                    )
            }
            override fun currentSize(entity: PanelEntity): IntVolumeSize {
                return IntVolumeSize(
                    width = entity.sizeInPixels.width,
                    height = entity.sizeInPixels.height,
                    depth = 0,
                )
            }
        }
}
```
