Giter VIP home page Giter VIP logo

Comments (5)

ravir13 avatar ravir13 commented on July 26, 2024 8

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

from sceneform-android-sdk.

malik-at-work avatar malik-at-work commented on July 26, 2024 1

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.

from sceneform-android-sdk.

dsternfeld7 avatar dsternfeld7 commented on July 26, 2024

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

from sceneform-android-sdk.

radixdev avatar radixdev commented on July 26, 2024

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:

from sceneform-android-sdk.

dsternfeld7 avatar dsternfeld7 commented on July 26, 2024

Closing due to inactivity.

from sceneform-android-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.