package com.javamarcher.tweening; import org.joml.Vector3f; import aurelienribon.tweenengine.TweenAccessor; public class Vector3fTweenAccessor implements TweenAccessor<Vector3f> { public static final int POSITION_X = 1; public static final int POSITION_Y = 2; public static final int POSITION_Z = 3; public static final int POSITION_XYZ = 4; @Override public int getValues(Vector3f target, int tweenType, float[] returnValues) { switch(tweenType) { case POSITION_X: returnValues[0] = target.x; return 1; case POSITION_Y: returnValues[0] = target.y; return 1; case POSITION_Z: returnValues[0] = target.z; return 1; case POSITION_XYZ: returnValues[0] = target.x; returnValues[1] = target.y; returnValues[2] = target.z; return 3; default: assert false; return -1; } } @Override public void setValues(Vector3f target, int tweenType, float[] newValues) { switch(tweenType) { case POSITION_X: target.x = newValues[0]; break; case POSITION_Y: target.y = newValues[0]; break; case POSITION_Z: target.z = newValues[0]; break; case POSITION_XYZ: target.set(newValues[0], newValues[1], newValues[2]); break; default: assert false; break; } } }