이제 Android XR SDK를 개발자 프리뷰로 사용할 수 있습니다. 의견을 기다립니다!
지원 페이지를 방문하여 문의하세요.
앱에 하위 공간 추가
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
하위 공간은 앱 내의 3D 공간 파티션으로, 여기에서 3D 모델을 배치하고 3D 레이아웃을 빌드하고 2D 콘텐츠에 깊이를 더할 수 있습니다. 하위 공간은 공간화가 사용 설정된 경우에만 렌더링됩니다. Home Space 또는 XR이 아닌 기기에서는 해당 하위 공간 내의 모든 코드가 무시됩니다.
3D 모델을 배치하는 데 Volume
및 SpatialPanel
와 같은 하위 공간 컴포저블을 사용할 수 있습니다. Orbiter
또는 SpatialDialog
와 같은 일부 XR 구성요소는 2D UI 계층 구조의 어디서나 사용할 수 있는 표준 2D 컴포저블이지만 SubspaceComposable
는 앱의 하위 공간에서 호출해야 합니다. 이렇게 하려면 ApplicationSubspace
컴포저블 또는 Subspace
컴포저블을 사용합니다.
이름에서 알 수 있듯이 ApplicationSubspace
컴포저블에는 앱의 모든 공간화된 콘텐츠가 포함되어야 합니다. Subspace
컴포저블은 앱의 기존 UI 계층 구조에서 3D 공간의 파티션을 더 깊이 중첩하는 데 적합합니다.
다른 컴포저블과 마찬가지로 2D UI 계층 구조에서 직접 Subspace
를 호출할 수 있습니다. 그러나 계층 구조에서 Subspace
를 호출하는 위치의 의미를 이해하는 것이 중요합니다.
하위 공간 계층 구조 정보
최상위 하위 공간은 앱에서 호출하는 가장 바깥쪽 하위 공간입니다. 최상위 하위 공간에는 ApplicationSubspace
컴포저블을 사용하세요. 하지만 앱에서 하위 공간 컴포저블만 사용하는 경우 가장 바깥쪽 Subspace
컴포저블이 최상위 하위 공간이 됩니다. 기본적으로 이 최상위 하위 공간은 앱을 보는 데 권장되는 공간으로 제한되며 일반적으로 앱의 공간 레이아웃과 SpatialPanel
를 배치하는 위치입니다. 최상위 하위 공간의 경계를 변경해야 하는 경우 ApplicationSubspace
에 다른 VolumeConstraints
를 전달합니다.
그러나 최상위 하위 스페이스에 포함된 패널의 2D UI 계층 구조 내에 다른 하위 스페이스를 중첩하면 중첩된 하위 스페이스가 다르게 동작합니다.
중첩된 하위 공간은 최상위 Subspace
와 두 가지 주요 차이점이 있습니다.
- 호출된 2D 레이아웃에 참여합니다. 즉, 하위 공간의 높이와 너비는 2D 상위 레이아웃의 높이와 너비에 의해 제한됩니다.
- 호출된 위치에서 항목의 하위 요소로 작동합니다. 즉,
SpatialPanel
내에 중첩된 Subspace
컴포저블을 호출하면 해당 하위 공간은 호출된 SpatialPanel
의 하위 요소입니다.
중첩된 하위 공간의 이러한 동작은 다음과 같은 기능을 사용 설정합니다.
- 상위 항목과 함께 하위 항목 이동
- 오프셋
SubspaceModifier
을 사용하여 하위 요소의 위치 오프셋
- 2D UI 위에 마우스를 가져가면 표시되고 2D 레이아웃에서 적절한 공간의 높이와 너비와 일치하는 3D 객체 표시
앱에 하위 공간 추가
다음 코드 예는 앱에 최상위 및 중첩된 하위 공간을 추가하는 방법을 보여줍니다.
setContent {
// This is a top-level subspace
ApplicationSubspace {
SpatialPanel {
MyComposable()
}
}
}
@Composable
private fun MyComposable() {
Row {
PrimaryPane()
SecondaryPane()
}
}
@Composable
private fun PrimaryPane() {
// This is a nested subspace, because PrimaryPane is in a SpatialPanel
// and that SpatialPanel is in a top-level Subspace
Subspace {
ObjectInAVolume(true)
}
}
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-23(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-23(UTC)"],[],[],null,["# Add a subspace to your app\n\nA subspace is a partition of 3D space within your app where you can place 3D\nmodels, build 3D layouts, and add depth to otherwise 2D content. A subspace is\nrendered only when spatialization is enabled. In Home Space or on non-XR\ndevices, any code within that subspace is ignored.\n\nYou can use subspace composables such as [`Volume`](/reference/kotlin/androidx/xr/compose/subspace/package-summary#Volume(androidx.xr.compose.subspace.layout.SubspaceModifier,kotlin.Function1)) and [`SpatialPanel`](/reference/kotlin/androidx/xr/compose/subspace/package-summary#SpatialPanel(androidx.xr.compose.subspace.layout.SubspaceModifier,androidx.xr.compose.subspace.layout.SpatialShape,kotlin.Function0))\nfor placing 3D models. Some XR components such as [`Orbiter`](/reference/kotlin/androidx/xr/compose/spatial/package-summary#Orbiter(androidx.xr.compose.spatial.ContentEdge.Horizontal,androidx.compose.ui.unit.Dp,androidx.xr.compose.spatial.OrbiterOffsetType,androidx.compose.ui.Alignment.Horizontal,androidx.xr.compose.subspace.layout.SpatialShape,androidx.compose.ui.unit.Dp,kotlin.Boolean,kotlin.Function0)) or\n[`SpatialDialog`](/reference/kotlin/androidx/xr/compose/spatial/package-summary#SpatialDialog(kotlin.Function0,androidx.xr.compose.spatial.SpatialDialogProperties,kotlin.Function0)) are standard 2D composables that can be used anywhere in\nyour 2D UI hierarchy, but [`SubspaceComposable`](/reference/kotlin/androidx/xr/compose/subspace/SubspaceComposable)s must be invoked in your\napp's subspace. To do this, use either the `ApplicationSubspace` composable or\nthe [`Subspace`](/reference/kotlin/androidx/xr/compose/spatial/package-summary#Subspace(kotlin.Function1)) composable.\n\nAs the name suggests, the [`ApplicationSubspace`](/reference/kotlin/androidx/xr/compose/spatial/package-summary#ApplicationSubspace(androidx.xr.compose.unit.VolumeConstraints,androidx.xr.compose.spatial.ConstraintsBehavior,kotlin.Function1)) composable should contain\nall of your app's spatialized content. The [`Subspace`](/reference/kotlin/androidx/xr/compose/spatial/package-summary#Subspace(kotlin.Function1)) composable is ideal\nfor nesting a partition of 3D space deeper in your app's existing UI hierarchy.\n\nAs with any other composable, you can call [`Subspace`](/reference/kotlin/androidx/xr/compose/spatial/package-summary#Subspace(kotlin.Function1)) directly in your 2D\nUI hierarchy. However, it's important to be aware of the implications of where\nin the hierarchy you invoke [`Subspace`](/reference/kotlin/androidx/xr/compose/spatial/package-summary#Subspace(kotlin.Function1)).\n\nAbout subspace hierarchies\n--------------------------\n\nThe top-level subspace is the outermost subspace invoked by your app. Use the\n[`ApplicationSubspace`](/reference/kotlin/androidx/xr/compose/spatial/package-summary#ApplicationSubspace(androidx.xr.compose.unit.VolumeConstraints,androidx.xr.compose.spatial.ConstraintsBehavior,kotlin.Function1)) composable for your top-level subspace, but, if you\nonly use the Subspace composable in your app, the outermost `Subspace`\ncomposable will be your top-level subspace. By default, this top-level subspace\nis bounded by the recommended space for viewing an app, and it's typically where\nyou place your app's spatial layout and [`SpatialPanel`](/reference/kotlin/androidx/xr/compose/subspace/package-summary#SpatialPanel(androidx.xr.compose.subspace.layout.SubspaceModifier,androidx.xr.compose.subspace.layout.SpatialShape,kotlin.Function0)). If you need to\nchange the bounds of the top-level subspace, pass different\n[`VolumeConstraints`](/reference/kotlin/androidx/xr/compose/unit/VolumeConstraints) to your [`ApplicationSubspace`](/reference/kotlin/androidx/xr/compose/spatial/package-summary#ApplicationSubspace(androidx.xr.compose.unit.VolumeConstraints,androidx.xr.compose.spatial.ConstraintsBehavior,kotlin.Function1)).\n\nHowever, if you nest another subspace inside of a 2D UI hierarchy in a panel\nthat's contained in the top-level subspace, that nested subspace behaves\ndifferently.\n\nNested subspaces have two key differences from top-level [`Subspace`](/reference/kotlin/androidx/xr/compose/spatial/package-summary#Subspace(kotlin.Function1)):\n\n- They participate in the 2D layout in which they are invoked. This means that the height and width of the subspace will be constrained by the height and width of its 2D parent layout.\n- They behave as children of the entity they're invoked in. This means that, if you call a [`Subspace`](/reference/kotlin/androidx/xr/compose/spatial/package-summary#Subspace(kotlin.Function1)) composable nested inside of a [`SpatialPanel`](/reference/kotlin/androidx/xr/compose/subspace/package-summary#SpatialPanel(androidx.xr.compose.subspace.layout.SubspaceModifier,androidx.xr.compose.subspace.layout.SpatialShape,kotlin.Function0)), that subspace is a child of the [`SpatialPanel`](/reference/kotlin/androidx/xr/compose/subspace/package-summary#SpatialPanel(androidx.xr.compose.subspace.layout.SubspaceModifier,androidx.xr.compose.subspace.layout.SpatialShape,kotlin.Function0)) it's called in.\n\nThese behaviors of nested subspace enable capabilities such as:\n\n- Moving the child with the parent entity\n- Offsetting the location of the child using the offset [`SubspaceModifier`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier)\n- Presenting a 3D object that hovers above your 2D UI and matches the height and width of the appropriate space in the 2D layout\n\nAdd a subspace to your app\n--------------------------\n\nThe following code example shows how to add top-level and nested subspaces to\nyour app:\n\n\n```kotlin\nsetContent {\n // This is a top-level subspace\n ApplicationSubspace {\n SpatialPanel {\n MyComposable()\n }\n }\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/xr/src/main/java/com/example/xr/compose/Subspace.kt#L34-L41\n```\n\n\u003cbr /\u003e\n\n\n```kotlin\n@Composable\nprivate fun MyComposable() {\n Row {\n PrimaryPane()\n SecondaryPane()\n }\n}\n\n@Composable\nprivate fun PrimaryPane() {\n // This is a nested subspace, because PrimaryPane is in a SpatialPanel\n // and that SpatialPanel is in a top-level Subspace\n Subspace {\n ObjectInAVolume(true)\n }\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/xr/src/main/java/com/example/xr/compose/Subspace.kt#L47-L62\n```\n\n\u003cbr /\u003e"]]