sceneview-android
sceneview-android copied to clipboard
How to show a Label(or text ) over Node
I need to display labels or text annotations above specific nodes. I've successfully added child nodes to my AnchorNode, but I'm unable to find a straightforward way to attach labels to these nodes.
fun addChildNodeToAnchor(parentNode: Node, position: Position) { Node(binding.arSceneView.engine).apply { isEditable = false name = "child node" lifecycleScope.launch { withContext(Dispatchers.Main) { val modelNode = buildModelNode("child", position, "myModel.glb", 0.25f) modelNode?.let { addChildNode(it) it.position = Position(x = position[0], y = position[1], z = position[2]) } parent = parentNode } } } }
fun buildModelNode(
nodeName: String,
position: Position,
modelToLoad: String,
scaleToUnits: Float
): ModelNode? {
binding.arSceneView.modelLoader.loadModelInstance(
modelToLoad
)?.let { modelInstance ->
return ModelNode(
modelInstance = modelInstance,
autoAnimate = false,
scaleToUnits = scaleToUnits,
centerOrigin = position
).apply {
name = nodeName
isEditable = true
}
}
return null
}
`