ImaginAR/ImaginAR-master/app/src/main/java/com/vesit/imaginar/one/RotatingNode.java
/** Returns an ObjectAnimator that makes this node rotate. */
Returns an ObjectAnimator that makes this node rotate.
Returns an ObjectAnimator that makes this node rotate .
private static ObjectAnimator createAnimator(boolean clockwise, float axisTiltDeg) {
        Quaternion[] orientations = new Quaternion[4];
        Quaternion baseOrientation = Quaternion.axisAngle(new Vector3(1.0f, 0f, 0.0f), axisTiltDeg);
        for (int i = 0; i < orientations.length; i++) {
            float angle = i * 360 / (orientations.length - 1);
            if (clockwise) {
                angle = 360 - angle;
            }
            Quaternion orientation = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), angle);
            orientations[i] = Quaternion.multiply(baseOrientation, orientation);
        }
        ObjectAnimator orbitAnimation = new ObjectAnimator();
        orbitAnimation.setObjectValues((Object[]) orientations);
        orbitAnimation.setPropertyName("localRotation");
        orbitAnimation.setEvaluator(new QuaternionEvaluator());
        orbitAnimation.setRepeatCount(ObjectAnimator.INFINITE);
        orbitAnimation.setRepeatMode(ObjectAnimator.RESTART);
        orbitAnimation.setInterpolator(new LinearInterpolator());
        orbitAnimation.setAutoCancel(true);
        return orbitAnimation;
    }
private static ObjectAnimator createAnimator ( boolean clockwise , float axisTiltDeg ) { Quaternion [ ] orientations = new Quaternion [ 4 ] ; Quaternion baseOrientation = Quaternion . axisAngle ( new Vector3 ( 1.0f , 0f , 0.0f ) , axisTiltDeg ) ; for ( int i = 0 ; i < orientations . length ; i ++ ) { float angle = i * 360 / ( orientations . length - 1 ) ; if ( clockwise ) { angle = 360 - angle ; } Quaternion orientation = Quaternion . axisAngle ( new Vector3 ( 0.0f , 1.0f , 0.0f ) , angle ) ; orientations [ i ] = Quaternion . multiply ( baseOrientation , orientation ) ; } ObjectAnimator orbitAnimation = new ObjectAnimator ( ) ; orbitAnimation . setObjectValues ( ( Object [ ] ) orientations ) ; orbitAnimation . setPropertyName ( "localRotation" ) ; orbitAnimation . setEvaluator ( new QuaternionEvaluator ( ) ) ; orbitAnimation . setRepeatCount ( ObjectAnimator . INFINITE ) ; orbitAnimation . setRepeatMode ( ObjectAnimator . RESTART ) ; orbitAnimation . setInterpolator ( new LinearInterpolator ( ) ) ; orbitAnimation . setAutoCancel ( true ) ; return orbitAnimation ; }
Returns an ObjectAnimator that makes this node rotate.
Returns an ObjectAnimator that makes this node rotate .
// Node's setLocalRotation method accepts Quaternions as parameters. // First, set up orientations that will animate a circle. // Rotation to apply first, to tilt its axis. // Cast to Object[] to make sure the varargs overload is called. // Next, give it the localRotation property. // Use Sceneform's QuaternionEvaluator. //  Allow orbitAnimation to repeat forever