简体   繁体   English

如何在 ARCore Sceneform 中为节点创建动画(更改缩放、旋转或位置)?

[英]How to create Animation (changing Scaling, Rotation or Position) for a Node in ARCore Sceneform?

I'm using ARCore Sceneform libraries in Android Studio.我在 Android Studio 中使用 ARCore Sceneform库。 I'm having trouble to find a method to perform a scaling animation to a node when it is set to enable (like the Quaternion used to rotate a node in Solar System by Google).当节点设置为启用时,我很难找到对节点执行缩放动画的方法(例如 Google 用于在太阳系中旋转节点的Quaternion )。

//On Tap Listener
scannerVisual.setOnTapListener(((hitTestResult, motionEvent) -> {

        // NodeAnimator arrow = new NodeAnimator(true);
        //arrow.setParent(scanner);

        Node arrowVisual = new Node();

        //StackOverflow Solution
        arrowVisual.setLocalPosition(new Vector3(0.5f, 0.0f, 0.0f));
        arrowVisual.setLocalScale(new Vector3(0.03f, 0.03f, 0.06f));
        arrowVisual.setRenderable(arrowRenderable);
        arrowVisual.setParent(scanner);

        // arrowVisual.setLocalRotation(Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 90));
    })
);

I have something like this.我有这样的事情。

You need to set a local scale of the node before setting its parent. before设置其父节点before您需要设置节点的本地比例。 The code should look like this:代码应如下所示:

Anchor anchor = hitResult.createAnchor();
AnchorNode anchorNode = new AnchorNode(anchor);

node.getScaleController().setMinScale(0.5f);
node.getScaleController().setMaxScale(3.0f);

node.setLocalScale(new Vector3(2.25f, 2.25f, 2.25f));
node.setParent(anchorNode);

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM