0

我正在尝试使用 android studio 在增强现实中旋转球(sfb)资产文件。我通过参考谷歌的太阳能系统应用程序尝试了一些代码来旋转球。但我不知道为什么球会旋转?我需要一些建议,我在我的代码上犯了错误。

 private void addModelToScene(Anchor anchor, ModelRenderable modelRenderable) {
        AnchorNode anchorNode = new AnchorNode(anchor);
        TransformableNode transformableNode = new 
        TransformableNode(arFragment.getTransformationSystem());
        RotatingNode rotatingNode = new RotatingNode();
        arFragment.getArSceneView().getScene().addChild(anchorNode); 
         rotatingNode.setParent(anchorNode);
        rotatingNode.setRenderable(modelRenderable);
        transformableNode.select();
    }
//this is my RotatingNode
private ObjectAnimator createAnimation(){
Quaternion orientation1 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 0);
        Quaternion orientation2 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 120);
        Quaternion orientation3 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 240);
        Quaternion orientation4 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 360);
        ObjectAnimator orbitAnimation = new ObjectAnimator();
        orbitAnimation.setObjectValues(orientation1, orientation2, orientation3, orientation4);
        orbitAnimation.setPropertyName("localRotation");
        orbitAnimation.setEvaluator(new QuaternionEvaluator());
        orbitAnimation.setRepeatCount(ObjectAnimator.INFINITE);
        orbitAnimation.setRepeatMode(ObjectAnimator.RESTART);
        orbitAnimation.setInterpolator(new LinearInterpolator());
        orbitAnimation.setAutoCancel(true);
        return orbitAnimation;
}

我希望输出能够旋转球,但只能放置球。

4

0 回答 0