Skip to content

Commit 5fdf7e6

Browse files
committed
Update to snapshot 13740187
1 parent aca6cc3 commit 5fdf7e6

File tree

6 files changed

+149
-76
lines changed

6 files changed

+149
-76
lines changed

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
val snapshotVersion : String? = "13693757"
1+
val snapshotVersion : String? = "13740187"
22

33
pluginManagement {
44
repositories {

xr/src/main/java/com/example/xr/scenecore/Entities.kt

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,10 @@
1616

1717
package com.example.xr.scenecore
1818

19-
import androidx.xr.runtime.Session
20-
import androidx.xr.runtime.math.FloatSize3d
2119
import androidx.xr.runtime.math.Pose
2220
import androidx.xr.runtime.math.Quaternion
2321
import androidx.xr.runtime.math.Vector3
24-
import androidx.xr.scenecore.AnchorPlacement
2522
import androidx.xr.scenecore.Entity
26-
import androidx.xr.scenecore.InputEvent
27-
import androidx.xr.scenecore.InteractableComponent
28-
import androidx.xr.scenecore.MovableComponent
29-
import androidx.xr.scenecore.PlaneOrientation
30-
import androidx.xr.scenecore.PlaneSemanticType
31-
import androidx.xr.scenecore.ResizableComponent
32-
import androidx.xr.scenecore.ResizeListener
33-
import androidx.xr.scenecore.SurfaceEntity
34-
import java.util.concurrent.Executor
35-
import java.util.concurrent.Executors
3623

3724
private fun setPoseExample(entity: Entity) {
3825
// [START androidxr_scenecore_entity_setPoseExample]
@@ -58,65 +45,3 @@ private fun entitySetScale(entity: Entity) {
5845
entity.setScale(2f)
5946
// [END androidxr_scenecore_entity_entitySetScale]
6047
}
61-
62-
@Suppress("RestrictedApi") // b/416066566
63-
private fun moveableComponentExample(session: Session, entity: Entity) {
64-
// [START androidxr_scenecore_moveableComponentExample]
65-
val anchorPlacement = AnchorPlacement.createForPlanes(
66-
planeTypeFilter = setOf(PlaneOrientation.VERTICAL),
67-
planeSemanticFilter = setOf(PlaneSemanticType.FLOOR, PlaneSemanticType.TABLE)
68-
)
69-
70-
val movableComponent = MovableComponent.create(
71-
session = session,
72-
systemMovable = false,
73-
scaleInZ = false,
74-
anchorPlacement = setOf(anchorPlacement)
75-
)
76-
entity.addComponent(movableComponent)
77-
// [END androidxr_scenecore_moveableComponentExample]
78-
}
79-
80-
@Suppress("RestrictedApi") // b/416066566
81-
private fun resizableComponentExample(session: Session, entity: Entity, executor: Executor) {
82-
// [START androidxr_scenecore_resizableComponentExample]
83-
val resizableComponent = ResizableComponent.create(session)
84-
resizableComponent.minimumSize = FloatSize3d(177f, 100f, 1f)
85-
resizableComponent.fixedAspectRatio = 16f / 9f // Specify a 16:9 aspect ratio
86-
87-
resizableComponent.addResizeListener(
88-
executor,
89-
object : ResizeListener {
90-
override fun onResizeEnd(entity: Entity, finalSize: FloatSize3d) {
91-
92-
// update the size in the component
93-
resizableComponent.size = finalSize
94-
95-
// update the Entity to reflect the new size
96-
(entity as SurfaceEntity).canvasShape = SurfaceEntity.CanvasShape.Quad(finalSize.width, finalSize.height)
97-
}
98-
},
99-
)
100-
101-
entity.addComponent(resizableComponent)
102-
// [END androidxr_scenecore_resizableComponentExample]
103-
}
104-
105-
@Suppress("RestrictedApi") // b/416066566
106-
private fun interactableComponentExample(session: Session, entity: Entity) {
107-
// [START androidxr_scenecore_interactableComponentExample]
108-
val executor = Executors.newSingleThreadExecutor()
109-
val interactableComponent = InteractableComponent.create(session, executor) {
110-
// when the user disengages with the entity with their hands
111-
if (it.source == InputEvent.SOURCE_HANDS && it.action == InputEvent.ACTION_UP) {
112-
// increase size with right hand and decrease with left
113-
if (it.pointerType == InputEvent.POINTER_TYPE_RIGHT) {
114-
entity.setScale(1.5f)
115-
} else if (it.pointerType == InputEvent.POINTER_TYPE_LEFT) {
116-
entity.setScale(0.5f)
117-
}
118-
}
119-
}
120-
entity.addComponent(interactableComponent)
121-
// [END androidxr_scenecore_interactableComponentExample]
122-
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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.scenecore.Entity
21+
import androidx.xr.scenecore.InputEvent
22+
import androidx.xr.scenecore.InteractableComponent
23+
import java.util.concurrent.Executors
24+
25+
@Suppress("RestrictedApi") // b/416066566
26+
private fun interactableComponentExample(session: Session, entity: Entity) {
27+
// [START androidxr_scenecore_interactableComponentExample]
28+
val executor = Executors.newSingleThreadExecutor()
29+
val interactableComponent = InteractableComponent.create(session, executor) {
30+
// when the user disengages with the entity with their hands
31+
if (it.source == InputEvent.Source.SOURCE_HANDS && it.action == InputEvent.Action.ACTION_UP) {
32+
// increase size with right hand and decrease with left
33+
if (it.pointerType == InputEvent.Pointer.POINTER_TYPE_RIGHT) {
34+
entity.setScale(1.5f)
35+
} else if (it.pointerType == InputEvent.Pointer.POINTER_TYPE_LEFT) {
36+
entity.setScale(0.5f)
37+
}
38+
}
39+
}
40+
entity.addComponent(interactableComponent)
41+
// [END androidxr_scenecore_interactableComponentExample]
42+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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.scenecore.AnchorPlacement
21+
import androidx.xr.scenecore.Entity
22+
import androidx.xr.scenecore.MovableComponent
23+
import androidx.xr.scenecore.PlaneOrientation
24+
import androidx.xr.scenecore.PlaneSemanticType
25+
26+
@Suppress("RestrictedApi") // b/416066566
27+
private fun createSystemMovable(session: Session, entity: Entity) {
28+
// [START androidxr_scenecore_movableComponent_createSystemMovable]
29+
val movableComponent = MovableComponent.createSystemMovable(session)
30+
entity.addComponent(movableComponent)
31+
// [END androidxr_scenecore_movableComponent_createSystemMovable]
32+
}
33+
34+
@Suppress("RestrictedApi") // b/416066566
35+
private fun movableComponentAnchorExample(session: Session, entity: Entity) {
36+
// [START androidxr_scenecore_movableComponent_anchorable]
37+
val anchorPlacement = AnchorPlacement.createForPlanes(
38+
anchorablePlaneOrientations = setOf(PlaneOrientation.VERTICAL),
39+
anchorablePlaneSemanticTypes = setOf(PlaneSemanticType.FLOOR, PlaneSemanticType.TABLE)
40+
)
41+
42+
val movableComponent = MovableComponent.createAnchorable(
43+
session = session,
44+
anchorPlacement = setOf(anchorPlacement)
45+
)
46+
entity.addComponent(movableComponent)
47+
// [END androidxr_scenecore_movableComponent_anchorable]
48+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.FloatSize3d
21+
import androidx.xr.scenecore.Entity
22+
import androidx.xr.scenecore.ResizableComponent
23+
import androidx.xr.scenecore.ResizeListener
24+
import androidx.xr.scenecore.SurfaceEntity
25+
import java.util.concurrent.Executor
26+
27+
@Suppress("RestrictedApi") // b/416066566
28+
private fun resizableComponentExample(session: Session, entity: Entity, executor: Executor) {
29+
// [START androidxr_scenecore_resizableComponentExample]
30+
val resizableComponent = ResizableComponent.create(session)
31+
resizableComponent.minimumSize = FloatSize3d(177f, 100f, 1f)
32+
resizableComponent.fixedAspectRatio = 16f / 9f // Specify a 16:9 aspect ratio
33+
34+
resizableComponent.addResizeListener(
35+
executor,
36+
object : ResizeListener {
37+
override fun onResizeEnd(entity: Entity, finalSize: FloatSize3d) {
38+
// update the size in the component
39+
resizableComponent.size = finalSize
40+
41+
// update the Entity to reflect the new size
42+
(entity as SurfaceEntity).canvasShape = SurfaceEntity.CanvasShape.Quad(finalSize.width, finalSize.height)
43+
}
44+
},
45+
)
46+
47+
entity.addComponent(resizableComponent)
48+
// [END androidxr_scenecore_resizableComponentExample]
49+
}

xr/src/main/java/com/example/xr/scenecore/SpatialAudio.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import android.content.Context
2020
import android.media.AudioAttributes
2121
import android.media.AudioAttributes.CONTENT_TYPE_SONIFICATION
2222
import android.media.AudioAttributes.USAGE_ASSISTANCE_SONIFICATION
23+
import android.media.MediaCodecList
2324
import android.media.MediaPlayer
2425
import android.media.SoundPool
2526
import androidx.xr.runtime.Session
@@ -152,3 +153,11 @@ private fun playSpatialAudioAtEntityAmbionics(session: Session, appContext: Cont
152153
}
153154
// [END androidxr_scenecore_playSpatialAudioAmbionics]
154155
}
156+
157+
private fun detectSupport() {
158+
// [START androidxr_scenecore_dolby_detect_support]
159+
val codecInfos = MediaCodecList(MediaCodecList.ALL_CODECS).codecInfos
160+
fun supportsEac3SDecoding() = codecInfos.any { !it.isEncoder && it.supportedTypes.any { it == "audio/aec3" } }
161+
fun supportsAc4Decoding() = codecInfos.any { !it.isEncoder && it.supportedTypes.any { it == "audio/ac4" } }
162+
// [END androidxr_scenecore_dolby_detect_support]
163+
}

0 commit comments

Comments
 (0)