1

it seems to me that PointLight do not light the scene properly when running an app on Android. Event though this was coded using Gluon Mobile, it seems to me that this is a javafxport or JavaFX 3D issue.

Here's a demo View that demonstrate the issue:

import com.gluonhq.charm.glisten.application.MobileApplication;
import com.gluonhq.charm.glisten.control.AppBar;
import com.gluonhq.charm.glisten.mvc.View;
import com.gluonhq.charm.glisten.visual.MaterialDesignIcon;
import javafx.animation.Interpolator;
import javafx.animation.TranslateTransition;
import javafx.scene.PointLight;
import javafx.scene.SubScene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Sphere;
import javafx.util.Duration;


public final class LightView extends View {

    public LightView() {
        setOnShown(event -> build3DContent());
    }

    private void build3DContent() {
        Sphere sphere = new Sphere();
        sphere.setRadius(100);
        sphere.setTranslateX(getWidth() / 2d);
        sphere.setTranslateY(getHeight() / 2d);
        final PointLight light = new PointLight(Color.WHITE);
        light.getScope().add(sphere);
        light.setTranslateZ(-300);
        light.setTranslateY(getHeight() / 2d);
        final Pane root = new Pane();
        root.getChildren().addAll(sphere, light);
        SubScene subScene = new SubScene(root, getWidth(), getHeight());
        setCenter(subScene);
        final TranslateTransition animation = new TranslateTransition(Duration.seconds(2));
        animation.setNode(light);
        animation.setToX(getWidth());
        animation.setAutoReverse(true);
        animation.setCycleCount(TranslateTransition.INDEFINITE);
        animation.setInterpolator(Interpolator.EASE_BOTH);
        animation.playFromStart();
    }    

    @Override
    protected void updateAppBar(AppBar appBar) {
        appBar.getActionItems().add(MaterialDesignIcon.ARROW_BACK.button(event -> MobileApplication.getInstance().switchView(MobileApplication.HOME_VIEW)));
    }
}

When running on desktop on Windows, the PointLight is centered on the Y axis and the animation makes it move left and right of the sphere. The sphere itself is also centered on the Y axis so the light runs though its equator. But when running on Android, the sphere is centered but the light only illuminates the top of the sphere. Coordinates of the PointLight appear correct though. This was not tested on ARM (Pi), iOS simulator or iOS device or any other desktop OS.

Desktop version Android version

Here's another more complex example with a planet illuminated by 3 point lights. Light1 is positioned center left and in front of the sphere, light2 is positioned center right and behind the sphere and light 3 is positioned freely in front of the sphere by moving the white dot with the mouse or by tap moving. All point lights coordinates appear correct but the illuminations are definitely not correct when running on Android. Everything looks fine when running on Windows.

Desktop version Android version

Additional info:

Windows 10 Version 10.0.16299.371

JDK 9.0.1

Android Samsung Galaxy 8 Plus Android 8.0.0 security patch April 2018

Intellij IDEA 2018.1.1

Gluon (from build.graddle)

JavaFXPorts 2.0.19

source compatibility 1.8

target compatibility 1.8

Gluon Charm 5.0.0-jdk9

Gluon Charm Down config 3.8.0

Note: I was suggested to post this issue to StackOverflow after I contacted Gluon's support directly.

EDIT - spelling

  • I've run your first sample with different OS, different JDKs and different devices... and I get different results for each case. Shaders (ultimately responsible for rendering the light over the mesh) are quite complex and their implementation is different for each platform (Windows uses d3d, Mac es2, ...). This is something related to the JavaFX core, so I'd suggest filing an issue [here](http://bugreport.java.com/). – José Pereda May 10 '18 at 17:27
  • Thanks for the answer. In the mean time and I run a "Gluon-less" JavaFX app with similar sphere + running light setup on my Windows 10 computer using JDK 8_144, 9.01, 10.0, on MacOS using JDK 10.0, Ubuntu 16 (running in Virtual Box) using JDK 1.8_162 and Raspberry PI using JDK 1.8.0_121 + javafxports 8.60.9 and the light on the sphere renders OK. – Fabrice Bouyé May 14 '18 at 04:46

0 Answers0