我在使用以下代码从URL生成3D对象时遇到问题,它给了我一个错误,我不确定它是什么。如果有人能指出代码的错误所在,那就太棒了
我关注了谷歌的教程:https://developers.google.com/ar/develop/java/sceneform/create-renderables。但由于语法错误,必须进行一些修改。
(1)下面的代码用于从URL - ASSET_URL生成3D对象(我已经测试了这个URL )。
private AugmentedImage image;
private CompletableFuture<ModelRenderable> modelRenderable;
modelRenderable =
ModelRenderable.builder()
.setSource(context, RenderableSource.builder().setSource(
context,
Uri.parse(ASSET_URL),
RenderableSource.SourceType.GLTF2)
.setScale(0.5f) // Scale the original model to 50%.
.setRecenterMode(RenderableSource.RecenterMode.ROOT)
.build())
.setRegistryId(ASSET_URL)
.build();(2)以下代码用于将3D对象放置在图像上:
if(!modelRenderable.isDone()){
CompletableFuture.allOf(modelRenderable)
.thenAccept((Void aVoid) -> setImage(image))
.exceptionally(
throwable -> {
Log.e(TAG, "Exception loading", throwable);
return null;
}
);
return;
}(3)以下代码(我从sceneform示例augmentedImage中修改)从静态本地资源生成3D对象,这与代码(2)一起工作
// modelRenderable = ModelRenderable.builder()
// .setSource(context,Uri.parse("SubstanceMiku.sfb"))
// .build();我得到了一个错误
E/Filament: Panic
in filament::Material *filament::Material::Builder::build(filament::Engine &):85
reason: Material version mismatch. Expected 2 but received 1.
A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 16333 (tapp.cloudimage), pid 16333 (tapp.cloudimage)
I/native: tracking.cc:3027 no history. confidence : 1.0
I/native: tracking.cc:3027 no history. confidence : 1.0
I/native: motion_analysis_calculator.cc:611 Analyzed frame 101
Application terminated.发布于 2020-03-06 03:08:48
我有一个类似的问题,经过一些调试和搜索,它似乎与scenefrom plugin类路径有关。
如果您转到项目级别的评分构建文件,并将场景表单插件类路径更新为最新版本,请同步并重试,这为我消除了错误。
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.ar.sceneform:plugin:1.15.0' // <-- *THIS LINE*
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}顺便说一句,调试很棘手,可能是因为像ModelRenderable.builder这样的一些功能利用了不会崩溃的较低层,并像其他一些安卓层一样干净地抛出异常。即使崩溃是从builder中的.build生成的,通过一步一步地注释出代码来确认,“exceptionally”子句也没有被调用。
https://stackoverflow.com/questions/56722175
复制相似问题