olexale / arkit_flutter_plugin

ARKit Flutter Plugin
MIT License
790 stars 223 forks source link

ARKitGltfNode name parameter not working. #223

Open ivaylopenevmg opened 4 months ago

ivaylopenevmg commented 4 months ago

Hello, I'm using ARKitGltfNode to show custom nodes from .glb files on the camera. When clicking on this nodes, I need to differentiate them in order to show additional UI with text related to them. For this I was storing some text info in the name. Then the onNodeTap callback returns the name of the clicked node.

This logic was working all fine when I was using ARKitNode, however with ARKitGltfNode the name value is always the same: Sketchfab_model. I wonder if this comes from the .glb binary. So in this case I'm unable to make a difference between nodes.

  PinterInfo(
      {required this.distance,
      required this.x,
      required this.y,
      required this.title,
      required this.info,
      required this.type}) {
    arKitNode = ARKitGltfNode(
      name: "$title%$info",
      assetType: AssetType.flutterAsset,
      url: "assets/glb/map_pin.glb",
      scale: vector.Vector3(0.04, 0.04, 0.04),
      position: vector.Vector3(x, y, -0.5),
    );
  }

  @override
  Widget build(BuildContext context) {
    filteredItems =
        widget.pointers.where((item) => filters[item.type]!).toList();

    return Scaffold(
        body: Stack(children: [
      Positioned.fill(
          child: ARKitSceneView(
              enableTapRecognizer: true,
              onARKitViewCreated: onARKitViewCreated)),
      Positioned.fill(child: pointersMenu())
    ]));
  }

  void onARKitViewCreated(ARKitController arkitController) {
    this.arkitController = arkitController;

    this.arkitController.onNodeTap = (tap) {
      showItemDialog(tap);
    };

    filteredItems.forEach((element) {
      this.arkitController.add(element.arKitNode);
    });
  }
JesusMrn commented 1 month ago

Same problem here, it seems the name in .glb file is set to every Node no matter what name you provide to ARKitGltfNode. I have to the same file duplicated changing the name inside the file so I can distinct what node I'm tapping on.