我正在尝试从Flutter中的Web视图打开关注脚本:
<model-viewer src="https://dashboard.impiattalo.com/storage/app/public/259/bistecca.gltf" alt="A 3D model of an astronaut" auto-rotate camera-controls ar ar-modes="web-xr scene-viewer quick-look fallback" ar-scale="auto"></model-viewer>
当我尝试从Chrome打开ar时,它运行得很好,在颤动的Web视图中它不起作用,这给了我这个错误。
这是我使用的代码:
child: WebView(
initialUrl:
'https://dashboard.impiattalo.com/3DViewer?url=${_con.food?.fbx_model?.url}',
javascriptMode: JavascriptMode.unrestricted,
gestureRecognizers: <
Factory<OneSequenceGestureRecognizer>>{
Factory<VerticalDragGestureRecognizer>(
() => VerticalDragGestureRecognizer()
..onUpdate = (_) {},
)
},
),
这是pubspec:
webview_flutter: ^0.3.20+2
您有什么建议吗?谢谢建议
答案 0 :(得分:0)
您遇到的错误与已知问题google/model-viewer#743有关:没有解决方法,无法从Android WebView启动Google的场景查看器。
要使它与Flutter一起使用,您可以仅使用Flutter的Model Viewer程序包,该程序包嵌入Google的<model-viewer>
Web组件,并包含必要的解决方法(请参见drydart/model_viewer.dart#4):>
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text("Model Viewer")),
body: ModelViewer(
backgroundColor: Color.fromARGB(0xFF, 0xEE, 0xEE, 0xEE),
src: 'https://dashboard.impiattalo.com/storage/app/public/259/bistecca.gltf',
alt: "Bistecca",
ar: true,
autoRotate: true,
cameraControls: true,
),
),
);
}
}
请注意,由于主机名可能是非公开的,因此我实际上无法使用您的模型URL进行尝试,但是上面的代码可用于其他模型。
$ host dashboard.impiattalo.com
Host dashboard.impiattalo.com not found: 3(NXDOMAIN)