Reputation: 11
I use SceneView library to present my 3D models. Normally I load 3D models from the assets folder and my application works fine.
Scene(
modifier = Modifier.fillMaxSize(),
engine = engine,
modelLoader = modelLoader,
cameraNode = cameraNode,
childNodes = listOf(centerNode,
rememberNode {
ModelNode(
modelInstance = modelLoader.createModelInstance(
assetFileLocation = "models/$aircraftModelName" ), //works correctly!
scaleToUnits = 1.5f
)
}),
environment = environmentLoader.createHDREnvironment(
assetFileLocation = "environments/sky_2k.hdr"
)!!,
onFrame = {
centerNode.rotation = cameraRotation
cameraNode.lookAt(centerNode)
}
)
But this time I want my application to load the 3D model from the internal storage after it is downloaded. But the problem is that when I give the address of the file in the internal storage folder to the library, instead of opening the file, it shows me the folder where the model file is located.
val fileName = "a4.glb"
val file = File(context.filesDir, fileName)
val modelAddress :String = file.absolutePath
Scene(
modifier = Modifier.fillMaxSize(),
engine = engine,
modelLoader = modelLoader,
cameraNode = cameraNode,
childNodes = listOf(centerNode,
rememberNode {
ModelNode(
modelInstance = modelLoader.createModelInstance(
assetFileLocation = modelAddress ), // here is model address
scaleToUnits = 1.5f
)
}),
environment = environmentLoader.createHDREnvironment(
assetFileLocation = "environments/sky_2k.hdr"
)!!,
onFrame = {
centerNode.rotation = cameraRotation
cameraNode.lookAt(centerNode)
}
)
I have tried different addressing methods but they all have the same result and instead of displaying the 3D model they just open the model folder.
Upvotes: 0
Views: 26