קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
SubspaceModifier דומה למַעְדִּר Compose לרכיבים שניתנים ליצירה ב-Subspace. בעזרת SubspaceModifier אפשר לבצע פעולות על רכיבים מורכבים במרחב תלת-ממדי, כמו מיקום, סיבוב והוספת התנהגויות לצמתים של פריסה תלת-ממדית.
בעזרת המשתנים המשתנים fillMaxSize, fillMaxWidth, fillMaxHeight ו-fillMaxDepth, התוכן ממלא (חלקית) את גבולות ההורה שלו.
שימוש במודיפיקציות מילוי עוזר לכם לתכנן את הפריסה של האפליקציה כך שהתוכן יהיה עצמאי ממאפייני התצוגה של מכשיר ה-XR.
המשתנה offset מעביר את הרכיב המודולרי במרחב תלת-ממדי לאורך הצירים x, y ו-z. צריך לציין את היחידות האלה ב-dp. כדי להמיר מטרים ל-dp, משתמשים ב-Meter.toDp().
rotate
המשתנה rotate מסובב את הרכיב הנתון במרחב. אפשר לציין את הכיוון ואת מידת הסיבוב בדרכים שונות:
באמצעות שימוש ב-pitch, yaw ו-roll, שמציינים את הסיבוב סביב הצירים x, y ו-z, בהתאמה.
באמצעות axisAngle, שהוא Vector3 שמייצג את ציר הסיבוב, ואת מספר המעלות שצריך לסובב אותו,
באמצעות Quaternion שמייצג את הסיבוב.
שינוי המראה של רכיבים מורכבים
alpha
המאפיין alpha מגדיר את האטימות של הרכיב ושל רכיבי הצאצאים שלו, כאשר הערך 0f מייצג שקיפות מלאה והערך 1.0f מייצג אטימות מלאה.
scale
המשתנה המשנה scale משנה את הגודל של התוכן של ה-composable לאורך הצירים האופקי, האנכי והעומק.
הוספת התנהגויות לרכיבים
resizable
כשהמשתנה המשנה resizable מופעל, יוצגו אמצעי בקרה של ממשק המשתמש שניתן לגרור, שמאפשרים למשתמש לשנות את גודל הרכיב. התהליך הזה דומה לשימוש ב-ResizableComponent ב-Entity.
movable
כשמפעילים את המשתנה movable, יתווספו לרכיב אמצעי בקרה בממשק המשתמש שמאפשרים למשתמש להזיז את הרכיב במרחב תלת-ממדי. התהליך הזה דומה לשימוש ב-MovableComponent ב-Entity.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-09-03 (שעון 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-09-03 (שעון UTC)."],[],[],null,["# Subspace modifiers\n\nA [`SubspaceModifier`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier) is similar to a [Compose modifier](/develop/ui/compose/modifiers) for composables\nin a [`Subspace`](/develop/xr/jetpack-xr-sdk/add-subspace). A `SubspaceModifier` lets you manipulate composables in 3D\nspace, helping you position, rotate, and add behaviors to 3D layout nodes.\n\nLayout\n------\n\nBy default, a `Subspace` is [bounded by the recommended space for viewing an\napp](/develop/xr/jetpack-xr-sdk/add-subspace#subspace-hierarchies). These bounds are used when measuring the layout of your subspace\ncomponents, similar to [bounds in 2D Compose layouts](/develop/ui/compose/layouts/constraints-modifiers).\n\n### Fill bounds\n\nThe modifiers [`fillMaxSize`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).fillMaxSize(kotlin.Float)), [`fillMaxWidth`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).fillMaxWidth(kotlin.Float)), [`fillMaxHeight`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).fillMaxHeight(kotlin.Float)), and\n[`fillMaxDepth`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).fillMaxDepth(kotlin.Float)) make content (partially) fill the bounds of its parent.\nUsing fill modifiers helps your app layout content that's independent of the XR\ndevice's display characteristics.\n\n### Set the size and required size\n\nThe modifiers [`size`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).size(androidx.compose.ui.unit.Dp)), [`width`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).width(androidx.compose.ui.unit.Dp)), [`height`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).height(androidx.compose.ui.unit.Dp)), and [`depth`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).depth(androidx.compose.ui.unit.Dp))\ndeclare the preferred size of the content. To declare the exact size of the\ncontent, use [`requiredSize`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).requiredSize(androidx.compose.ui.unit.Dp)), [`requiredWidth`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).requiredWidth(androidx.compose.ui.unit.Dp)),\n[`requiredHeight`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).requiredHeight(androidx.compose.ui.unit.Dp)), and [`requiredDepth`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).requiredDepth(androidx.compose.ui.unit.Dp)). These units must be specified\nin `dp`; to convert from meters to dp, use [`Meter.toDp()`](/reference/kotlin/androidx/xr/compose/unit/Meter#toDp()).\n\nPosition composables\n--------------------\n\n### `offset`\n\nThe [`offset`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).offset(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)) modifier moves the composable in 3D space along the `x`, `y`,\nand `z` axes. These units must be specified in `dp`; to convert from meters to\ndp, use [`Meter.toDp()`](/reference/kotlin/androidx/xr/compose/unit/Meter#toDp()).\n\n### `rotate`\n\nThe [`rotate`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).rotate(androidx.xr.runtime.math.Quaternion)) modifier rotates the given composable in space. You can\nspecify the direction and the amount of rotation in different ways:\n\n- Using pitch, yaw, and roll, which specify the rotation around the `x`, `y`, and `z` axes respectively,\n- Using an `axisAngle`, which is a `Vector3` representing the axis of rotation, and the amount of degrees it should be rotated around,\n- Using a `Quaternion` that represents the rotation.\n\nChange the appearance of composables\n------------------------------------\n\n### `alpha`\n\nThe [`alpha`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).alpha(kotlin.Float)) modifier sets the opacity of the element and its children,\nwhere `0f` represents fully transparent and `1.0f` represents completely opaque.\n| **Preview:** Currently, the `alpha` modifier only works on `SpatialPanel`.\n\n### `scale`\n\nThe [`scale`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).scale(kotlin.Float)) modifier scales the contents of the composible along the\nhorizontal, vertical, and depth axes.\n\nAdd behaviors to composables\n----------------------------\n\n### `resizable`\n\nWhen the [`resizable`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).resizable(kotlin.Boolean,androidx.xr.compose.unit.DpVolumeSize,androidx.xr.compose.unit.DpVolumeSize,kotlin.Boolean,kotlin.Function1)) modifier is enabled, draggable UI controls will be\nshown that allow the user to resize the element. This is similar to using\n[`ResizableComponent`](/reference/kotlin/androidx/xr/scenecore/ResizableComponent) on an `Entity`.\n\n\nYour browser doesn't support HTML video. Here is a\n[link to the video](/static/develop/xr/jetpack-xr-sdk/videos/resizablecomponent.mp4) instead.\n| **Preview:** Currently, the `resizable` modifier only works on `SpatialPanel`.\n\n### `movable`\n\nWhen the [`movable`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).movable(kotlin.Boolean,kotlin.Boolean,kotlin.Boolean,kotlin.Function1,kotlin.Function1,kotlin.Function1)) modifier is enabled, UI controls will be added to the\ncomponent which allow the user to move the element in 3D space. This is similar\nto using [`MovableComponent`](/reference/kotlin/androidx/xr/scenecore/MovableComponent) on an `Entity`.\n\n\nYour browser doesn't support HTML video. Here is a\n[link to the video](/static/develop/xr/jetpack-xr-sdk/videos/movablecomponent.mp4) instead.\n\nA `movable` layout node can optionally specify types of planes it should anchor\nto when it is moved. For example, to create a `SpatialPanel` that snaps to\ntables: \n\n SpatialPanel(\n modifier.movable(anchorPlaneSemantics = setOf(PlaneSemantic.TABLE))\n ) {\n // This panel snaps to available planes that are detected as a TABLE.\n }\n\nSnapping to planes requires the `android.permission.SCENE_UNDERSTANDING_COARSE`\n[runtime permission](/training/permissions/requesting) to be granted to your app.\n| **Preview:** Currently, the `movable` modifier only works on `SpatialPanel`.\n\nTesting and accessibility\n-------------------------\n\n### `semantics`\n\nThe [`semantics`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).semantics(kotlin.Function1)) modifier adds semantics to the layout node, for use in\ntesting and accessibility. See [Semantics in Jetpack Compose](/develop/ui/compose/accessibility/semantics) and\n[`SemanticsModifier`](/reference/kotlin/androidx/compose/ui/semantics/SemanticsModifier).\n\n### `testTag`\n\nThe [`testTag`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).testTag(kotlin.String)) modifier is a shorthand for\n[`SemanticsPropertyReceiver.testTag`](/reference/kotlin/androidx/compose/ui/semantics/SemanticsPropertyReceiver#(androidx.compose.ui.semantics.SemanticsPropertyReceiver).testTag()), which allows test frameworks to find\nthe element in tests."]]