[英]How can I build with Flutter and ARKit a custom object?
I use the plugin arkit_plugin with the version 1.0.5 https://pub.dev/packages/arkit_plugin我使用版本为 1.0.5 https://pub.dev/packages/arkit_plugin 的插件 arkit_plugin
My Flutter version is 2.5.3我的Flutter版本是2.5.3
The plugin has an example in it's documentation for custom objects.该插件在其自定义对象的文档中有一个示例。 Therefore I copy pasted the example to test it.因此我复制粘贴了这个例子来测试它。 In my case the object is not showing at all.在我的情况下, object 根本没有显示。 It is a.dae file and I tried it with a.obj file too but it didn't work either.它是 a.dae 文件,我也尝试使用 a.obj 文件,但它也不起作用。
class ArkitSceneView extends StatefulWidget {
const ArkitSceneView({Key? key}) : super(key: key);
@override
State<ArkitSceneView> createState() => _ArkitSceneViewState();
}
class _ArkitSceneViewState extends State<ArkitSceneView> {
late ARKitController arkitController;
ARKitReferenceNode? node;
@override
void dispose() {
arkitController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ARKitSceneView(
onARKitViewCreated: onARKitViewCreated
);
}
void onARKitViewCreated(ARKitController arkitController) {
this.arkitController = arkitController;
arkitController.addCoachingOverlay(CoachingOverlayGoal.horizontalPlane);
arkitController.onAddNodeForAnchor = _handleAddAnchor;
}
void _handleAddAnchor(ARKitAnchor anchor) {
if (anchor is ARKitPlaneAnchor) {
_addPlane(arkitController, anchor);
}
}
void _addPlane(ARKitController controller, ARKitPlaneAnchor anchor) {
if (node != null) {
controller.remove(node!.name);
}
node = ARKitReferenceNode(
url: 'models.scnassets/dash.dae',
scale: vector.Vector3.all(0.3),
);
controller.add(node!, parentNodeName: anchor.nodeName);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.