sceneview-android
sceneview-android copied to clipboard
3D model moving with camera once we placing using Geospatial API which should not.
Hi, I am using geospatial API for load objects on particular lat long Everything working fine except for two thing,
- Autoanimation not working
- Model moving with the camera once we reach the model and move around it. I want the model should be fixed on position once placed.
Below is my model placing code plz review and update
onSessionUpdated = { session, frames ->
drawNode(session)
}
private fun drawNode(it: Session) {
if (anchorNode == null) {
it.configure(it.config.apply {
geospatialMode = Config.GeospatialMode.ENABLED
})
val earth = it.earth ?: return
if (earth.trackingState == TrackingState.TRACKING) {
val cameraGeospatialPose = earth.cameraGeospatialPose
val earthAnchor = earth.createAnchor(
latTrack, lngTrack,
cameraGeospatialPose.altitude - 1,
0f, 0f, 0f, 1f
)
addAnchorNode(earthAnchor)
}
}
}
private fun addAnchorNode(anchor: Anchor) {
Log.d("MainActivityAr", "addAnchorNode added ")
getString(R.string.msg_node_placed).toToast(this)
bindingView.sceneView.addChildNode(
AnchorNode(bindingView.sceneView.engine, anchor)
.apply {
lifecycleScope.launch {
isLoading = true
bindingView.sceneView.modelLoader.loadModelInstance(
"models/original.glb"
)?.let { modelInstance ->
addChildNode(
node =
ModelNode(
modelInstance = modelInstance,
)
.apply {
playAnimation(0)
}
).apply {
}
}
isLoading = false
}
anchorNode = this
}
)
}
Properties that I am updating
configureSession { session, config ->
config.focusMode = Config.FocusMode.AUTO
config.lightEstimationMode = Config.LightEstimationMode.DISABLED
config.depthMode = Config.DepthMode.DISABLED
config.planeFindingMode = Config.PlaneFindingMode.DISABLED
config.updateMode = Config.UpdateMode.BLOCKING
if (session.isGeospatialModeSupported(Config.GeospatialMode.ENABLED))
config.geospatialMode = Config.GeospatialMode.ENABLED
drawNode(session)
}