Odd results with Vector3f and getLocalScale()

I got an error posting. I don’t know if it was posted or not. I’ll try it again and try to delete it if its a duplicate.
I’m trying to make a ball squish over time. If I put getLocalScale in a Vector3f, my results wander (too many decimal places) and my squishing doesn’t look right. If I hard code the scale, I get clean results, but I want it to work at any scale.

Sorry for all the redundant casting. I was trying to see if it would help. The if (true) changes the input/output. How can I get clean results with Vector3f?

good results
Ant.antSquash()-localScale=(100.0, 100.0, 100.0)
Ant.antSquish(float)-scale = 0.1
Ant.antSquash()-tx=110.0, ty=90.0, tz=110.0
Ant.antSquash()-localScale=(110.0, 90.0, 110.0)
Ant.antSquish(float)-scale = 0.2
Ant.antSquash()-tx=120.00001, ty=80.0, tz=120.00001
Ant.antSquash()-localScale=(120.00001, 80.0, 120.00001)
Ant.antSquish(float)-scale = 0.3
Ant.antSquash()-tx=130.0, ty=70.0, tz=130.0
Ant.antSquash()-localScale=(130.0, 70.0, 130.0)
Ant.antSquish(float)-scale = 0.4
Ant.antSquash()-tx=140.0, ty=60.000004, tz=140.0
Ant.antSquash()-localScale=(140.0, 60.000004, 140.0)
Ant.antSquish(float)-scale = 0.5
Ant.antSquash()-tx=150.0, ty=50.0, tz=150.0
Ant.antSquash()-localScale=(150.0, 50.0, 150.0)

bad results
Ant.antSquash()-localScale=(100.0, 100.0, 100.0)
Ant.antSquish(float)-scale = 0.1
Ant.antSquash()-scale is +(110.0, 90.0, 110.0)
Ant.antSquash()-localScale=(110.0, 90.0, 110.0)
Ant.antSquish(float)-scale = 0.2
Ant.antSquash()-scale is +(132.0, 72.0, 132.0)
Ant.antSquash()-localScale=(132.0, 72.0, 132.0)
Ant.antSquish(float)-scale = 0.3
Ant.antSquash()-scale is +(171.59999, 50.399998, 171.59999)
Ant.antSquash()-localScale=(171.59999, 50.399998, 171.59999)
Ant.antSquish(float)-scale = 0.4
Ant.antSquash()-scale is +(240.23999, 30.24, 240.23999)
Ant.antSquash()-localScale=(240.23999, 30.24, 240.23999)
Ant.antSquish(float)-scale = 0.5
Ant.antSquash()-scale is +(360.36, 15.12, 360.36)
Ant.antSquash()-localScale=(360.36, 15.12, 360.36)

int        step = 0;
float    scaleFactor = 0f;
Vector3f    antScale = new Vector3f();
//this should squisn anything at any scale
public boolean antSquash(float tpf){
    Quaternion Q = new Quaternion();
    if (step == 0){
        setLocalRotation(Q.fromAngleAxis(0f, new Vector3f())) ;
        antScale = getLocalScale();
        System.out.println("Ant.antSquash()-localScale=" + getLocalScale());
        scaleFactor = 0f;
        step++;
        return(false);
    }

    float tx, ty, tz;
    switch (step){
        case 1:
            scaleFactor = scaleFactor + (0.1f);
            System.out.println("Ant.antSquish(float)-scale = " + scaleFactor);
            if (true){//bad output
                antScale.x = antScale.x * (1f + scaleFactor);
                antScale.y = antScale.y * (1f - scaleFactor);
                antScale.z = antScale.z * (1f + scaleFactor);
            System.out.println("Ant.antSquash()-scale is +" + antScale);
            setLocalScale(antScale);
            }
            else{//good output - not flexable (for any scale)
                tx = (float)100f * (1f + scaleFactor);
                ty = (float)100f * (1f - scaleFactor);
                tz = (float)100f * (1f + scaleFactor);
            System.out.println("Ant.antSquash()-tx=" + tx + ", ty=" + ty + ", tz=" + tz);
            setLocalScale(tx, ty, tz);
            }
            System.out.println("Ant.antSquash()-localScale=" + getLocalScale());

            if (scaleFactor >= 0.5){
                step++;
                return(true);//end here - data makes no sense
            }
            break;
            //end here - data makes no sense
        case 2:
            setLocalScale(antScale.x * (1 + scaleFactor), antScale.y * (1 - scaleFactor), antScale.z * (1 + scaleFactor));
            scaleFactor += (0.5 * tpf);
            if (scaleFactor >= 1){
                step++;
                //return(false);
            }
            break;
        case 3:
        System.out.println("Ant.antSquish(float)-done");
            setLocalScale(antScale.x, antScale.y, antScale.z);
            scaleFactor = 0;
            step = 0;
            return(true);
        }
    return(false);
}

	public boolean antStretch(float tpf){
		if (step == 0){
			System.out.println("Ant.antStretch(float)");
			step = 1;
			return(false);
		}

The “bad” output happens because when you get the local scale after the first scale is not (100, 100, 100) but (110, 90, 110), when you multiply each value by 0.2 you will obviously get a different result

If you want it to work on any scale, store the original scale in a vector3f at the beginning.

        antScale.x = originalScale.x * (1f + scaleFactor);
        antScale.y = originalScale.y * (1f - scaleFactor);
        antScale.z = originalScale.z * (1f + scaleFactor);
        System.out.println("Ant.antSquash()-scale is +" + antScale);
        setLocalScale(antScale);

That was it.
Oddly, i had to make a ‘new’ copy of the vector.

    orgAntScale = new Vector3f(getLocalScale());

TY!

Not oddly. getLocalScale() returns the actual Vector3f used by the spatial… not a copy… because creating a copy every time someone wanted to ask about scale would be extremely wasteful.