sceneview-android
sceneview-android copied to clipboard
ImageNode not rendering full image
I used the samples/ar-model-viewer-compose project and made some small changes. Instead of using a ModelNode I wanted to try out an ImageNode.
fun createAnchorNode(
engine: Engine,
materialLoader: MaterialLoader,
anchor: Anchor
): AnchorNode {
val anchorNode = AnchorNode(engine = engine, anchor = anchor)
val imageNode = ImageNode(
materialLoader = materialLoader,
imageResId = R.drawable.img_1,
normal = Direction(0f)
).apply {
transform(
position = Position(
this.position.x,
this.position.y + 1.6f,
this.position.z - 2f
)
)
}
anchorNode.addChildNode(imageNode)
return anchorNode
}
The Image should be pointing at the camera and be located in mid air. This totally works but there is a huge problem/bug while rendering.
As you can see, the image is diagonally cut in half. I tried with multiple files and it always resulted with the same problem.
Also having same issue, image is diagonally cut in half.
I also tried adding the image as a ViewNode, but I was not able to achieve to render anything. Nevertheless, using a ViewNode instead of the ImageNode would be a good workaround until the ImageNode issue is resolved.
@Composable
fun ar() {
val engine = rememberEngine()
val modelLoader = rememberModelLoader(engine)
val context = LocalContext.current
val childNodes = rememberNodes()
var frame by remember { mutableStateOf<Frame?>(null) }
var sceneView by remember { mutableStateOf<View?>(null)}
ArScene(
...
...
onSessionUpdated = {session, updatedFrame ->
frame = updatedFrame
if (childNodes.isEmpty()) {
updatedFrame.getUpdatedPlanes()
.firstOrNull { it.type == Plane.Type.HORIZONTAL_UPWARD_FACING }
?.let { it.createAnchorOrNull(it.centerPose)}?.let { anchor ->
createAnchorNode(
engine = engine,
anchor = anchor,
context = context,
modelLoader = modelLoader,
sceneView = sceneView
) {
childNodes += it
}
}
},
onViewCreated = {
sceneView = this
}
)
}
fun createAnchorNode(
engine: Engine,
context: Context,
anchor: Anchor,
modelLoader: ModelLoader,
sceneView: View?,
cB: (AnchorNode) -> Unit
) {
val anchorNode = AnchorNode(engine = engine, anchor = anchor)
if (sceneView == null) return
ViewRenderable
.builder()
.setView(context, R.layout.test)
.build(engine)
.thenAccept { viewRenderable ->
val viewNode = ViewNode(
engine = engine,
modelLoader = modelLoader,
viewAttachmentManager = ViewAttachmentManager(context, sceneView)
).apply {
this.setRenderable(viewRenderable)
this.scale = Scale(5f)
}
anchorNode.addChildNode(viewNode)
cB(anchorNode)
}
}
Sadly there is no example in the sample apps where either ImageNode or ViewNode is used.
I opened an issue https://github.com/SceneView/sceneview-android/issues/379 3 weeks ago and it should be fixed on next version. PR has been merged : https://github.com/SceneView/sceneview-android/pull/392
Me too facing the same issue. Please also help me if we can create a textnode to place text content and any sample code for the same.
Was this "fixed" in 2.0.3 with #392? I am still experiencing similar shearing of models in the latest release.
Fixed in 2.0.4
I'm not sure this is fixed or I have a different issue. In 2.0.4, I continue to see an occasional diagonal cutting off a ModelNode image when moving the camera around for a model with Google geospatial anchors.