Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Models not displaying right on device but they look ok on emulator with isOpaque = false #470

Open
andytriboletti opened this issue Apr 25, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@andytriboletti
Copy link

andytriboletti commented Apr 25, 2024

When I choose isOpaque = false to display a background image the models on my device don't show correctly. Is there another way to display a background image?

With my pixel 8, the models I am loading don't display correctly. see photo. on an emulator they are fine.

working on emulator:
sceneview_emulator_working

not working on device:
Screenshot_20240425-120312

my code:

@Composable
fun Apples() {
    DisposableEffect(Unit) {
        // Code to run on composition start
        println("Composable started")

        onDispose {
            // Code to run on composition end or recomposition
            println("Composable disposed")
            // Perform cleanup operations here
        }
    }

    val engine = rememberEngine()
    // Background Image
    val backgroundImage = painterResource(id = R.drawable.universe_background)
    val modelLoader = rememberModelLoader(engine)
//    val cameraNode = rememberCameraNode(engine) {
//        // Content
//
//        position = Position(z = 4.0f)
//    }
    //val cameraNode = SceneView.DefaultCameraNode(engine)
    val cameraNode = SceneView.createCameraNode(engine)
    //cameraNode = rememberCameraNode(engine).apply {
    //    position = Position(z = -4.0f)
    //} as SceneView.DefaultCameraNode
    //cameraNode.position  = Position(z = 100.0f)


    Box(
        modifier = Modifier.fillMaxSize()
    ) {
        // Background Image
//        Image(
//            painter = backgroundImage,
//            contentDescription = "Background Image",
//            modifier = Modifier.fillMaxSize(),
//            contentScale = ContentScale.FillBounds // Adjust content scale as needed
//        )
        Scene(
            modifier = Modifier.fillMaxSize(),
            engine = engine,
            modelLoader = modelLoader,
            isOpaque = false,
            cameraNode = cameraNode,
            activity = LocalContext.current as? ComponentActivity,
            lifecycle = LocalLifecycleOwner.current.lifecycle,
            view = rememberView(engine),
            childNodes = rememberNodes {
                add(ModelNode(modelLoader.createModelInstance("earth.glb")).apply {
                    // Position the first apple
                    position = Position(-5f, 0f, -30f)
                    scale = Scale(10f, 10f, 10f)
                })
                add(ModelNode(modelLoader.createModelInstance("spaceshipc.glb")).apply {
                    // Position the second apple
                    position = Position(5f, 0f, -30f)
                })
            },
            //environment = environmentLoader.createHDREnvironment("environment.hdr")!!
        )
    }


}
@andytriboletti andytriboletti changed the title Models not displaying right on device but they look ok on emulator. Models not displaying right on device but they look ok on emulator with isOpaque = false May 1, 2024
@ThomasGorisse ThomasGorisse added the bug Something isn't working label May 13, 2024
andytriboletti added a commit to andytriboletti/openspace-kotlin that referenced this issue Jul 3, 2024
Copy link

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.

@github-actions github-actions bot added the Stale label Aug 12, 2024
@andytriboletti
Copy link
Author

Yes, it still exists as far as I know.

@github-actions github-actions bot removed the Stale label Aug 13, 2024
@ghostship
Copy link

Could this be related: google/filament#7794

@bsautner
Copy link

bsautner commented Aug 21, 2024

I have the same issue trying to set the background. Just modifying the model-viewer-compose sample setting opaque to false results in my model being scrambled. Also on a pixel 7

Edit - confirmed this isn't an issue on a samsung device or emulator. It does look like a Pixel driver bug per the filament link above.

 Scene(
                        isOpaque = false,
                        modifier = Modifier.fillMaxSize(),
                        engine = engine,
                        modelLoader = modelLoader,
                        cameraNode = cameraNode as CameraNode,
                        cameraManipulator = rememberCameraManipulator(
                            orbitHomePosition = cameraNode.worldPosition,
                            targetPosition = centerNode.worldPosition
                        ),
                        childNodes = listOf(centerNode, modelNode),

                    ) 

@andytriboletti
Copy link
Author

Looks like there is some progress from filament:
google/filament#7794 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants