sceneform-android icon indicating copy to clipboard operation
sceneform-android copied to clipboard

AR object is completely black

Open Shubi-khanduri opened this issue 1 year ago • 0 comments

I am rendering .glb file in my app. I am getting .glb file from the local storage of mobile objects color is completely black IDK what is happening. but when I am getting the same file from asset in Android studio it is working perfectly fine all the colour of object are showing perfectly even if I am getting the year object from URL it is working fine here is but I am doing please help me with this. @ThomasGorisse, or someone else, do you know, how can I fix that? Is it possible? sceneView = findViewById<ARSceneView?>(R.id. sceneView ). apply { lifecycle = [email protected] planeRenderer.isEnabled = true configureSession { session, config -> config. depthMode = when (session.isDepthModeSupported(Config.DepthMode. AUTOMATIC )) { true -> Config.DepthMode. AUTOMATIC

else -> Config.DepthMode. DISABLED

} config. instantPlacementMode = Config.InstantPlacementMode. DISABLED

config. lightEstimationMode = Config.LightEstimationMode. ENVIRONMENTAL_HDR

} onSessionUpdated = { _, frame -> if (anchorNode == null) { frame. getUpdatedPlanes () . firstOrNull { it. type == Plane.Type. HORIZONTAL_UPWARD_FACING } ?. let { plane -> addAnchorNode(plane.createAnchor(plane. centerPose )) } } } onTrackingFailureChanged = { reason -> [email protected] = reason } }

fun addAnchorNode(anchor: Anchor, uri: Uri) {
    if (selectedFile == null) {
        Log.e("ARActivity", "Failed to copy file")
        return
    }
    Log.e("FileCheck", "File loading...")
    sceneView.addChildNode(
        AnchorNode(sceneView.engine, anchor)
            .apply {
                isEditable = true
                lifecycleScope.launch {
                    isLoading = true
                    buildModelNode1(selectedFile)?.let { addChildNode(it) }

// buildModelNode()?.let { addChildNode(it) } isLoading = false } anchorNode = this } ) }

fun addAnchorNode(anchor: Anchor) {

    sceneView.addChildNode(
        AnchorNode(sceneView.engine, anchor)
            .

apply { isEditable = true

lifecycleScope . launch { isLoading = true buildModelNode()?. let { addChildNode(it) } // buildViewNode()?.let { addChildNode(it) } isLoading = false } anchorNode = this } ) }

fun buildModelNode1(file: File?): ModelNode? { // val file = File(cacheDir, "DamagedHelmet.glb") if (file == null) { Log.e("FileCheck", "File does not exist: ") return null } Log.d("FileCheck", "File exists: ${file. absolutePath }") sceneView.modelLoader.createModelInstance(file = file). let { model -> return ModelNode( modelInstance = model, // Scale to fit in a 0.5 meters cube scaleToUnits = 0.5f, // Bottom origin instead of center so the model base is on floor // centerOrigin = Position(y = -0.5f) centerOrigin = Position(x = 0.0f, y = -1.0f, z = 0.0f) ). apply { isEditable = true } } }

WhatsApp Image 2024-09-24 at 7 21 40 PM WhatsApp Image 2024-09-24 at 7 21 57 PM

Shubi-khanduri avatar Sep 24 '24 13:09 Shubi-khanduri