Skip to content

Commit a9d7d9c

Browse files
authored
Merge branch 'android:main' into tb/projected-snippets
2 parents a55ef05 + 2757264 commit a9d7d9c

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/wear/ @android/devrel-wear
66
/wearcompanion/ @android/devrel-wear
77
/xr/ @android/devrel-xr
8+
/compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/ @android/devrel-adaptive-apps

compose/snippets/src/main/java/com/example/compose/snippets/lists/LazyListSnippets.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ private fun ListsSnippetsContentSpacing3(photos: List<Photo>) {
203203

204204
private object ListsSnippetsStickyHeaders1 {
205205
// [START android_compose_layouts_lazy_column_sticky_header]
206-
@OptIn(ExperimentalFoundationApi::class)
207206
@Composable
208207
fun ListWithHeader(items: List<Item>) {
209208
LazyColumn {
@@ -224,7 +223,6 @@ private object ListsSnippetsStickyHeaders2 {
224223
// This ideally would be done in the ViewModel
225224
val grouped = contacts.groupBy { it.firstName[0] }
226225

227-
@OptIn(ExperimentalFoundationApi::class)
228226
@Composable
229227
fun ContactsList(grouped: Map<Char, List<Contact>>) {
230228
LazyColumn {
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.xr.scenecore
18+
19+
import androidx.xr.runtime.Session
20+
import androidx.xr.runtime.math.Vector4
21+
import androidx.xr.scenecore.AlphaMode
22+
import androidx.xr.scenecore.GltfModelEntity
23+
import androidx.xr.scenecore.KhronosPbrMaterial
24+
import androidx.xr.scenecore.Texture
25+
import kotlin.io.path.Path
26+
27+
private class MaterialOverride(val xrSession: Session) {
28+
private suspend fun createMaterial() {
29+
// [START androidxr_scenecore_material_override_createMaterial]
30+
val pbrMaterial = KhronosPbrMaterial.create(
31+
session = xrSession,
32+
alphaMode = AlphaMode.OPAQUE
33+
)
34+
// [END androidxr_scenecore_material_override_createMaterial]
35+
}
36+
37+
private fun setBaseColor(pbrMaterial: KhronosPbrMaterial) {
38+
// [START androidxr_scenecore_material_override_setBaseColor]
39+
pbrMaterial.setBaseColorFactor(
40+
Vector4(
41+
x = 0.5f,
42+
y = 0.0f,
43+
z = 0.5f,
44+
w = 0.0f
45+
)
46+
)
47+
// [END androidxr_scenecore_material_override_setBaseColor]
48+
}
49+
50+
private suspend fun createTexture() {
51+
// [START androidxr_scenecore_material_override_createTexture]
52+
val texture = Texture.create(
53+
session = xrSession,
54+
path = Path("textures/texture_file.png")
55+
)
56+
// [END androidxr_scenecore_material_override_createTexture]
57+
}
58+
59+
private fun setOcclusionTexture(pbrMaterial: KhronosPbrMaterial, texture: Texture) {
60+
// [START androidxr_scenecore_material_override_setOcclusionTexture]
61+
pbrMaterial.setOcclusionTexture(
62+
texture = texture,
63+
strength = 1.0f
64+
)
65+
// [END androidxr_scenecore_material_override_setOcclusionTexture]
66+
}
67+
68+
private fun setMaterialOverride(gltfModelEntity: GltfModelEntity, pbrMaterial: KhronosPbrMaterial) {
69+
// [START androidxr_scenecore_material_override_setMaterialOverride]
70+
gltfModelEntity.setMaterialOverride(
71+
material = pbrMaterial,
72+
nodeName = "Node Name"
73+
)
74+
// [END androidxr_scenecore_material_override_setMaterialOverride]
75+
}
76+
77+
private fun clearMaterialOverride(gltfModelEntity: GltfModelEntity) {
78+
// [START androidxr_scenecore_material_override_clearMaterialOverride]
79+
gltfModelEntity.clearMaterialOverride(
80+
nodeName = "Node Name"
81+
)
82+
// [END androidxr_scenecore_material_override_clearMaterialOverride]
83+
}
84+
}

0 commit comments

Comments
 (0)