sceneview-android
sceneview-android copied to clipboard
How to use with Geospatial API
Hey there! Thank you for this useful library which saves a lot of time when working with ARCore :)
I'm trying to create an android app that shows AR markers by specific location (LatLng). I'd like to create something like in this video (from README AR Geospatial API), but with simple ViewNode
instead of ArModelNode
.
I also can't place AR model at a specific location with a sample code from README. The model spawns just in front of the current camera position.
Here is my code:
val earth = binding.sceneView.arSession?.earth ?: return@launchWhenResumed
if (earth.trackingState == TrackingState.TRACKING) {
val cameraGeospatialPose = earth.cameraGeospatialPose
val earthAnchor = earth.createAnchor(49.844141, 24.024532, cameraGeospatialPose.altitude, 0f, 0f, 0f, 1f)
val arModelNode = ArModelNode(
context = this@MainActivity,
lifecycle = lifecycle,
modelFileLocation = "https://sceneview.github.io/assets/models/Gumball.glb"
)
arModelNode.anchor = earthAnchor
binding.sceneView.addChild(arModelNode)
}
I would be grateful for your help!
I also attached a file with the desired result

Hi.
The code you posted looks fine to me. Did you figure out the problem? Does setting editableTransforms
on arModelNode
to EditableTransform.ALL
help?
It looks like EditableTransform
doesn't exist in io.github.sceneview:arsceneview:0.8.0
I guess the editableTransforms
is not important. I think it's a problem with 0.8.0. You can downgrade to 0.7.0 for now until the problems are fixed.
I have the same problem. It seems that the position
of the arModelNode
is not updated, after assigning the anchor, when isSmoothPoseEnable
is true
@SeyedAlirezaFatemi You are right, downgrading to 0.7.0
helped me to fix it.
I also added implementation 'com.google.ar:core:1.32.0'
to enable Geospatial API. More here: #109
Thank you for your help and hope that it will be fixed in the next version :)
@lincollincol
Does earth.trackingState
become TrackingState.TRACKING
?
Always different.
binding.arSceneView.apply {
geospatialEnabled = true
onArSessionFailed = { _: Exception ->
}
onArSessionCreated = { arSession ->
val earth = arSession.earth
if (earth != null && earth.trackingState == TrackingState.TRACKING) {
val altitude = earth.cameraGeospatialPose.altitude - 1
val rotation = Rotation(0f, 0f, 0f)
val latitude = earth.cameraGeospatialPose.latitude + 0.0004
val longitude = earth.cameraGeospatialPose.longitude + 0.0004
earthAnchor = earth.createAnchor(latitude, longitude, altitude, rotation.toFloatArray())
val arModelNode = ArModelNode(
context = this@GeoSpatialActivity,
lifecycle = lifecycle,
modelFileLocation = "https://sceneview.github.io/assets/models/Gumball.glb"
)
arModelNode.anchor = earthAnchor
binding.arSceneView.addChild(arModelNode)
}
}
}
I solved ↑.
In onArSessionCreated
, the trackingState was still PAUSED. When a button is clicked, it is TRACKING.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.