teamfx / openjfx-8u-dev-rt

Mirror of OpenJFX repository 8u-dev/rt
GNU General Public License v2.0
15 stars 10 forks source link

3DViewer fails to cast NumberTangentInterpolator #6

Open omega09 opened 7 years ago

omega09 commented 7 years ago

In the 3DViewer sample, exporting a .ma model as .java fails due to a bad cast attempt.

In the file JavaSourceExporter, in the method private String toString(Interpolator interpolator) , there is a check if (interpolator instanceof NumberTangentInterpolator). However, the right side of the instanceof is com.javafx.experiments.utils3d.animation.NumberTangentInterpolator. The argument for the method is com.sun.scenario.animation.NumberTangentInterpolator. This causes the method to throw an UnsupportedOperationException even though the code for the classes is the same.

omega09 commented 7 years ago

A fix would be to add this type of interpolator to the method:

        // ...
        } else if (interpolator instanceof NumberTangentInterpolator) {
            NumberTangentInterpolator ti = (NumberTangentInterpolator)interpolator;
            return "Interpolator.TANGENT(Duration.millis("+ TickCalculation.toMillis((long)ti.getInTicks())+"d),"+ti.getInValue()
                    +"d,Duration.millis("+TickCalculation.toMillis((long)ti.getInTicks())+"d),"+ti.getOutValue()+"d)";
        } else if (interpolator instanceof com.sun.scenario.animation.NumberTangentInterpolator) {
            com.sun.scenario.animation.NumberTangentInterpolator ti = (com.sun.scenario.animation.NumberTangentInterpolator)interpolator;
            return "Interpolator.TANGENT(Duration.millis("+ TickCalculation.toMillis((long)ti.getInTicks())+"d),"+ti.getInValue()
                    +"d,Duration.millis("+TickCalculation.toMillis((long)ti.getInTicks())+"d),"+ti.getOutValue()+"d)";
        } else {
            throw new UnsupportedOperationException("Unknown Interpolator type: "+interpolator.getClass());
        }