@Override
    public void setSpatial(Spatial spatial) {
        Spatial oldSpatial = this.spatial;
        super.setSpatial(spatial);
        updateTargetsAndMaterials(spatial);

        if (oldSpatial != null) {
            oldSpatial.removeMatParamOverride(numberOfJointsParam);
            oldSpatial.removeMatParamOverride(jointMatricesParam);
        }

        if (spatial != null) {
            spatial.removeMatParamOverride(numberOfJointsParam);
            spatial.removeMatParamOverride(jointMatricesParam);
            spatial.addMatParamOverride(numberOfJointsParam);
            spatial.addMatParamOverride(jointMatricesParam);
        }
    }
If specified the geometry has an animated mesh, add its mesh and material
to the lists of animation targets.
jme3-core/src/main/java/com/jme3/anim/SkinningControl.java