Sceneform-android-sdk: RotationController should allow to set the rotation axis

Created on 11 May 2018  路  5Comments  路  Source: google-ar/sceneform-android-sdk

The rotation axis of an object is intuitively the surface normal vector of the plane. When changing world rotation of a node, you'd either expect the RotationController to respect that or have the ability to have it changed.

feature request

Most helpful comment

Please suggest a way to rotate Views on the X and Y axis.

All 5 comments

Thanks for the feedback! Right now, the transformation controllers are geared towards transformations on horizontal planes. Can you describe the use case where you are running into a problem?

Currently, the RotationController works by rotating the Node along it's local y-axis. If the node is a child of an AnchorNode anchored to an ARCore plane, then the normal direction of the node should match the normal direction of the plane.

Thanks,

Dan

The snippet I'm using is:

    arFragment.setOnTapArPlaneListener(
        (HitResult hitResult, Plane plane, MotionEvent motionEvent) -> {
          if (mCards.isEmpty()) {
            return;
          }

          // Create the Anchor.
          Anchor anchor = hitResult.createAnchor();
          AnchorNode anchorNode = new AnchorNode(anchor);
          anchorNode.setParent(arFragment.getArSceneView().getScene());

          TransformableNode cardNode = new TransformableNode(arFragment.getTransformationSystem());
          ScaleController scaleController = cardNode.getScaleController();
          scaleController.setMinScale(0.01f);
          scaleController.setMaxScale(0.1f);
          scaleController.setSensitivity(0.4f);

          Card firstCard = mCards.get(mLastCardSelectionIndex);
          ViewRenderable.builder()
              .setView(context, getCardView(context, firstCard))
              .build()
              .thenAccept(
                  (viewRenderable) -> {
                    cardNode.setRenderable(viewRenderable);

                    // Change the rotation
                    if (plane.getType() ==  Plane.Type.VERTICAL) {
                      float[] yAxis = plane.getCenterPose().getYAxis();
                      Vector3 planeNormal = new Vector3(yAxis[0], yAxis[1], yAxis[2]);
                      Quaternion upQuat = Quaternion.lookRotation(planeNormal, Vector3.up());
                      cardNode.setWorldRotation(upQuat);
                    }
                  }
              )
              .exceptionally(
                  (throwable -> {
                    throw new AssertionError("Could not load card view renderable.", throwable);
                  })
              );

          cardNode.setParent(anchorNode);
          cardNode.select();
          mLastCardSelectionIndex = (mLastCardSelectionIndex + 1) % mCards.size();
        });

The original issue was that ViewRenderable was "sticking out" of the vertical surface, which doesn't make sense for a view intended to be read. So I changed its world rotation to be readable to someone looking at the ViewRenderable, i.e. laying it flat on the vertical surface.

Below is the world rotation corrected view renderables (the 3 cards)

And here is what they look like rotated:

The expected axis for rotation controller is the normal "sticking out" of a plane. This looks different for vertical vs horizontal planes since the normal will be horizontal or vertical respectively.

To get the same behavior between walls & tabletops I might insert a new node as a parent that rotates the axis of rotation from horizontal to vertical when given a vertical plane. Or you could skip the new parent and directly set the rotation as you did in your code above.

The Transformation System was designed for horizontal user experiences. We worked closely with our UX designers and researchers to design it in Sceneform 1.0.

As a matter of style, I don't think it translates to vertical tasks without making a lot more changes than changing the axis of rotation. Updating the UX for vertical interfaces will have to be something we do for a future releases.

Closing due to inactivity.

Please suggest a way to rotate Views on the X and Y axis.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dementia2029 picture dementia2029  路  3Comments

tigran-babajanyan picture tigran-babajanyan  路  3Comments

KamikX picture KamikX  路  4Comments

arilotter picture arilotter  路  3Comments

rohitagarwal3011 picture rohitagarwal3011  路  4Comments