CariusLars / ar_flutter_plugin

Flutter Plugin for AR (Augmented Reality) - Supports ARKit on iOS and ARCore on Android devices
MIT License
317 stars 228 forks source link

Restrciting User to place a object #195

Open Suryanshomar7240 opened 1 year ago

Suryanshomar7240 commented 1 year ago

I am facing an issue. I want that if the user places an object which should not be placed in the horizontal plane then it will restrict the user from placing the thing. I have tried to restrict it after consider the world transform matrix from the singleHitTestResult but unable to it

`Future onPlaneOrPointTapped( List hitTestResults) async { var singleHitTestResult = hitTestResults.firstWhere( (hitTestResult) => hitTestResult.type == ARHitTestResultType.plane);

if (singleHitTestResult != null) {
  var newAnchor =
      ARPlaneAnchor(transformation: singleHitTestResult.worldTransform);

  final worldTransform = singleHitTestResult.worldTransform;

  // Extract the rotation components from the world transform matrix
  final rotationMatrix = worldTransform.getRotation();

  final rotationQuaternion =
      vector.Quaternion.fromRotation(rotationMatrix).axis;

    print("roation: $rotationQuaternion");

  if (rotationQuaternion[0] > 0) {
    //create the anchor
     // then add the object in the anchor

} '

can anyone help me to solve this issue