تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يشبه SubspaceModifierمعدِّل Compose للعناصر القابلة للإنشاء
في Subspace. تتيح لك SubspaceModifier معالجة العناصر القابلة للإنشاء في مساحة ثلاثية الأبعاد، ما يساعدك في تحديد موضع عقد التنسيق ثلاثي الأبعاد وتدويرها وإضافة سلوكيات إليها.
تؤدي المعدِّلات fillMaxSize وfillMaxWidth وfillMaxHeight وfillMaxDepth إلى أن يملأ المحتوى حدود العنصر الأصل (جزئيًا).
يساعد استخدام معدِّلات التعبئة في تصميم محتوى تطبيقك بشكل مستقل عن خصائص شاشة جهاز XR.
ينقل المعدِّل offset العنصر القابل للإنشاء في المساحة الثلاثية الأبعاد على طول المحاور x وy وz. يجب تحديد هذه الوحدات في dp، وللتحويل من الأمتار إلى وحدات مستقلة الكثافة، استخدِم Meter.toDp().
rotate
يدير المعدِّل rotate العنصر القابل للإنشاء المحدّد في المساحة. يمكنك تحديد اتجاه الدوران ومقدار الدوران بطرق مختلفة:
باستخدام الميل والانحراف والدوران، التي تحدّد الدوران حول المحاور x وy وz على التوالي،
باستخدام axisAngle، وهو Vector3 يمثّل محور الدوران، ومقدار الدرجات التي يجب الدوران حولها،
استخدام Quaternion يمثّل التدوير
تغيير مظهر العناصر القابلة للإنشاء
alpha
يضبط المعدِّل alpha مستوى التعتيم للعنصر وعناصره الثانوية، حيث يمثّل 0f الشفافية الكاملة ويمثّل 1.0f التعتيم الكامل.
scale
يؤدي المعدِّل scale إلى تغيير حجم محتوى العنصر القابل للإنشاء على المحاور الأفقية والعمودية والعمق.
إضافة سلوكيات إلى العناصر القابلة للإنشاء
resizable
عند تفعيل المعدِّل resizable، ستظهر عناصر تحكّم في واجهة المستخدم قابلة للسحب تتيح للمستخدم تغيير حجم العنصر. يشبه ذلك استخدام
ResizableComponent على Entity.
movable
عند تفعيل المعدِّل movable، ستتم إضافة عناصر تحكُّم في واجهة المستخدم إلى المكوّن، ما يتيح للمستخدم نقل العنصر في المساحة الثلاثية الأبعاد. يشبه ذلك استخدام MovableComponent على Entity.
يمكن لعقدة التنسيق movable أن تحدّد اختياريًا أنواع الطائرات التي يجب أن ترتبط بها عند نقلها. على سبيل المثال، لإنشاء SpatialPanel يتم محاذاته مع الجداول، اتّبِع الخطوات التالية:
SpatialPanel(modifier.movable(anchorPlaneSemantics=setOf(PlaneSemantic.TABLE))){// This panel snaps to available planes that are detected as a TABLE.}
يتطلّب المحاذاة مع المستويات منح android.permission.SCENE_UNDERSTANDING_COARSEإذن التشغيل لتطبيقك.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-31 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-07-31 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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."]]