JavaFX:如何制作发光球体?

JavaFX:如何制作发光球体?,javafx,Javafx,我是JavaFX新手,我正在尝试制作太阳系。 现在,我想 我试过: Glow g = new Glow(100); sphere.setEffect(g); 但它不起作用。 有什么解决办法吗?谢谢。来源 import javafx.application.Application; import javafx.scene.PerspectiveCamera; import javafx.scene.Scene; import javafx.scene.image.Image; import ja

我是JavaFX新手,我正在尝试制作太阳系。 现在,我想 我试过:

Glow g = new Glow(100);
sphere.setEffect(g);
但它不起作用。
有什么解决办法吗?谢谢。

来源

import javafx.application.Application;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.scene.paint.ImagePattern;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

public class Main extends Application
{
    public static void main(String[] args)
    {
        Application.launch(args);
    }

    @Override
    public void start(Stage stage)
    {
        // Create a rectangle
        Rectangle rect = new Rectangle(75, 75);
        rect.setTranslateX(300);
        rect.setTranslateY(-5);
        rect.setTranslateZ(400);

        // Load an image
        rect.setFill(new ImagePattern(new Image("file:spark2.png")));

        // Create a Camera to view the 3D Shapes
        PerspectiveCamera camera = new PerspectiveCamera(false);
        camera.setTranslateX(100);
        camera.setTranslateY(-50);
        camera.setTranslateZ(300);

        // Add the Shapes and the Light to the Group
        AnchorPane root = new AnchorPane(rect);
        // Create a Scene with depth buffer enabled
        Scene scene = new Scene(root, 800, 800, true);
        // Fill the background with black
        scene.setFill(Color.BLACK);
        // Add the Camera to the Scene
        scene.setCamera(camera);

        // Add the Scene to the Stage
        stage.setScene(scene);
        // Set the Title of the Stage
        stage.setTitle("An Example");
        // Display the Stage
        stage.show();
    }
}
输出:

闪光图像:


我想在那里做日光效果->[link]I.stack.imgur.com/vCsDL.png(环绕太阳的效果)@YozoZChomutova检查我的上一次编辑,这是你要找的吗?这是一个非常简单的应用于矩形的星光纹理。是的,这就是我要找的。你是怎么做到的?