我一直在尝试加载 GLB 文件,但是即使PNG文件位于相同的 assets 文件夹中,它的纹理也似乎无法加载。
代码如下:
val GLTF_ASSET = "model.glb"
ModelRenderable.builder()
.setSource(
this, RenderableSource.builder().setSource(
this,
Uri.parse(GLTF_ASSET),
RenderableSource.SourceType.GLB
)
.setScale(0.5f)
.setRecenterMode(RenderableSource.RecenterMode.ROOT)
.build()
)
.setRegistryId(GLTF_ASSET)
.build()
.thenAccept {
loadModel(it)
}
.exceptionally {
val builder = AlertDialog.Builder(this)
builder.setMessage(it.message)
.setTitle("error!")
val dialog = builder.create()
dialog.show()
return@exceptionally null
}
我在日志中收到此消息:
W/ImpView: 1 textures declared in source assets were not found:
2019-10-17 17:30:48.453 22579-22682/com.example.arcore_test W/ImpView: missing: '49264a5c-5cb7-44cf-bc52-04c4d26f0457.png'
2019-10-17 17:30:48.453 22579-22682/com.example.arcore_test W/ImpView: (use -I to add other search folders)
2019-10-17 17:30:55.806 22579-22579/com.example.arcore_test W/Filament: setMaterialInstanceAt() on primitive 0 of Renderable at 1: declared attributes [POSITION, TANGENTS, UV0] do no satisfy required attributes [POSITION, TANGENTS, COLOR, UV0]
2019-10-17 17:30:55.806 22579-22579/com.example.arcore_test W/Filament: [instance=1, primitive @ 0] missing required attributes (0xf), declared=0xb
2019-10-17 17:30:55.806 22579-22579/com.example.arcore_test W/Filament: setMaterialInstanceAt() on primitive 1 of Renderable at 1: declared attributes [POSITION, TANGENTS, UV0] do no satisfy required attributes [POSITION, TANGENTS, COLOR, UV0]
2019-10-17 17:30:55.806 22579-22579/com.example.arcore_test W/Filament: [instance=1, primitive @ 1] missing required attributes (0xf), declared=0xb
2019-10-17 17:30:55.807 22579-22579/com.example.arcore_test W/Filament: setMaterialInstanceAt() on primitive 2 of Renderable at 1: declared attributes [POSITION, TANGENTS, UV0] do no satisfy required attributes [POSITION, TANGENTS, COLOR, UV0]
2019-10-17 17:30:55.807 22579-22579/com.example.arcore_test W/Filament: [instance=1, primitive @ 2] missing required attributes (0xf), declared=0xb
2019-10-17 17:30:55.807 22579-22579/com.example.arcore_test W/Filament: setMaterialInstanceAt() on primitive 3 of Renderable at 1: declared attributes [POSITION, TANGENTS, UV0] do no satisfy required attributes [POSITION, TANGENTS, COLOR, UV0]
2019-10-17 17:30:55.807 22579-22579/com.example.arcore_test W/Filament: [instance=1, primitive @ 3] missing required attributes (0xf), declared=0xb
2019-10-17 17:30:55.807 22579-22579/com.example.arcore_test W/Filament: setMaterialInstanceAt() on primitive 4 of Renderable at 1: declared attributes [POSITION, TANGENTS, UV0] do no satisfy required attributes [POSITION, TANGENTS, COLOR, UV0]
2019-10-17 17:30:55.807 22579-22579/com.example.arcore_test W/Filament: [instance=1, primitive @ 4] missing required attributes (0xf), declared=0xb
2019-10-17 17:30:55.807 22579-22579/com.example.arcore_test W/Filament: setMaterialInstanceAt() on primitive 5 of Renderable at 1: declared attributes [POSITION, TANGENTS, UV0] do no satisfy required attributes [POSITION, TANGENTS, COLOR, UV0]
2019-10-17 17:30:55.807 22579-22579/com.example.arcore_test W/Filament: [instance=1, primitive @ 5] missing required attributes (0xf), declared=0xb
2019-10-17 17:30:55.808 22579-22579/com.example.arcore_test W/Filament: setMaterialInstanceAt() on primitive 6 of Renderable at 1: declared attributes [POSITION, TANGENTS, UV0] do no satisfy required attributes [POSITION, TANGENTS, COLOR, UV0]
2019-10-17 17:30:55.808 22579-22579/com.example.arcore_test W/Filament: [instance=1, primitive @ 6] missing required attributes (0xf), declared=0xb
答案 0 :(得分:1)
这通常意味着您在GLTF文件中声明了资源纹理,并且使用该纹理的路径无效。
确认您的GLTF文件已正确打包并包含纹理。
在我看来,您就像在对待SFB文件或DAE文件一样,在图像文件中分别具有纹理。让您的设计师将它们导出为打包的纹理,您应该会很好。