Skip to content

Commit 04ef396

Browse files
committed
add basic geo support
1 parent a0f08b7 commit 04ef396

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

arsceneview/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ dependencies {
4848
api project(":sceneview")
4949

5050
// ARCore
51-
def arcore_version = '1.30.0'
51+
def arcore_version = '1.32.0'
5252
api "com.google.ar:core:$arcore_version"
5353
}
5454

arsceneview/src/main/java/io/github/sceneview/ar/ArSceneView.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ open class ArSceneView @JvmOverloads constructor(
152152
arSession?.cloudAnchorEnabled = value
153153
}
154154

155+
private var _geospatialEnabled = false
156+
var geospatialEnabled: Boolean
157+
get() = arSession?.geospatialEnabled ?: _geospatialEnabled
158+
set(value) {
159+
_geospatialEnabled = value
160+
arSession?.geospatialEnabled = value
161+
}
162+
155163
private var _sessionLightEstimationMode = Config.LightEstimationMode.ENVIRONMENTAL_HDR
156164

157165
/**
@@ -319,6 +327,7 @@ open class ArSceneView @JvmOverloads constructor(
319327
config.instantPlacementEnabled = _instantPlacementEnabled
320328
config.cloudAnchorEnabled = _cloudAnchorEnabled
321329
config.lightEstimationMode = _sessionLightEstimationMode
330+
config.geospatialEnabled = _geospatialEnabled
322331
}
323332

324333
// Feature config, therefore facing direction, can only be configured once per session.

arsceneview/src/main/java/io/github/sceneview/ar/arcore/ArSession.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,17 @@ class ArSession(
217217
}
218218
}
219219

220+
var geospatialEnabled: Boolean
221+
get() = config.geospatialEnabled
222+
set(value) {
223+
if (geospatialEnabled != value) {
224+
configure {
225+
it.geospatialEnabled = value
226+
}
227+
}
228+
}
229+
230+
220231
/**
221232
* ### The behavior of the lighting estimation subsystem
222233
*
@@ -329,4 +340,14 @@ var Config.cloudAnchorEnabled
329340
} else {
330341
Config.CloudAnchorMode.DISABLED
331342
}
343+
}
344+
345+
var Config.geospatialEnabled
346+
get() = geospatialMode != Config.GeospatialMode.DISABLED
347+
set(value) {
348+
geospatialMode = if (value) {
349+
Config.GeospatialMode.ENABLED
350+
} else {
351+
Config.GeospatialMode.DISABLED
352+
}
332353
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package io.github.sceneview.ar.arcore
2+
3+
import com.google.ar.core.Earth
4+
import dev.romainguy.kotlin.math.Quaternion
5+
import io.github.sceneview.math.Rotation
6+
import io.github.sceneview.math.toQuaternion
7+
8+
fun Earth.createAnchor(
9+
latitude: Double,
10+
longitude: Double,
11+
altitude: Double,
12+
quaternion: Quaternion
13+
) = createAnchor(
14+
latitude,
15+
longitude,
16+
altitude,
17+
quaternion.x,
18+
quaternion.y,
19+
quaternion.z,
20+
quaternion.w
21+
)
22+
23+
fun Earth.createAnchor(
24+
latitude: Double,
25+
longitude: Double,
26+
altitude: Double,
27+
rotation: Rotation
28+
) = createAnchor(
29+
latitude,
30+
longitude,
31+
altitude,
32+
rotation.toQuaternion()
33+
)

0 commit comments

Comments
 (0)