olexale / arkit_flutter_plugin

ARKit Flutter Plugin
MIT License
797 stars 225 forks source link

eulerAngles #70

Closed dariocavada closed 3 years ago

dariocavada commented 4 years ago

I've tried to rotate a cone, but eulerAngles seems not to work. The cone is in the same position with the same rotation. Looking in the NodeBuilder.swift code, there is no eulerAngles. Also tried rotation, but it is not clear how it works ... maybe rotation with respect to the camera? Following the code:

 _testRotation(ARKitImageAnchor anchor) {
    final anchorPos = anchor.transform.getColumn(3);
    final double rot = -pi / 2;
    final material =
        ARKitMaterial(diffuse: ARKitMaterialProperty(color: Colors.blue));

    final cone = ARKitCone(
        height: 0.1,
        topRadius: 0.00,
        bottomRadius: 0.02,
        materials: [material]);

    /* Node Cone */
    final nodeCone = ARKitNode(
      geometry: cone,
      position: vector.Vector3(anchorPos.x, anchorPos.y, anchorPos.z),
      eulerAngles: vector.Vector3(rot, rot, rot),
    );

    this.arkitController.add(nodeCone);

  }

Thanks in advance for the help.

cone-no-rotation

olexale commented 4 years ago

That's an epic fail from my side. It seems that during huge refactoring of version 0.5 I've messed up with Euler angles. It is possible to set them though as the method onEulerAnglesChanged is in place. Hence you may add a node to the scene and change its angles next line.

This issue will be autofixed as soon as I'll finish with the transformation matrix refactoring. Sorry for the inconvenience.

olexale commented 3 years ago

This should be fixed in 0.6.0 as I, at last, had enough time to refactor the transformation matrix. Feel free to re-open the issue in case you face any problems. Thanks!