Search in sources :

Example 1 with ParticleBurst

use of org.cesiumjs.cs.scene.particle.ParticleBurst in project gwt-cs by iSergio.

the class ParticleSystemFireworks method buildPanel.

@Override
public void buildPanel() {
    ViewerPanel csVPanel = new ViewerPanel();
    csVPanel.getViewer().scene().debugShowFramesPerSecond = true;
    Math.setRandomNumberSeed(315);
    ColorRandomOptions[] colorRandomOptions = new ColorRandomOptions[4];
    for (int i = 0; i < 4; i++) {
        colorRandomOptions[i] = new ColorRandomOptions();
    }
    colorRandomOptions[0].minimumRed = 0.75f;
    colorRandomOptions[0].green = 0.0f;
    colorRandomOptions[0].minimumBlue = 0.8f;
    colorRandomOptions[0].alpha = 1.0f;
    colorRandomOptions[1].red = 0.0f;
    colorRandomOptions[1].minimumGreen = 0.75f;
    colorRandomOptions[1].minimumBlue = 0.8f;
    colorRandomOptions[1].alpha = 1.0f;
    colorRandomOptions[2].red = 0.0f;
    colorRandomOptions[2].green = 0.0f;
    colorRandomOptions[2].minimumBlue = 0.8f;
    colorRandomOptions[2].alpha = 1.0f;
    colorRandomOptions[3].minimumRed = 0.75f;
    colorRandomOptions[3].minimumGreen = 0.75f;
    colorRandomOptions[3].blue = 0.0f;
    colorRandomOptions[3].alpha = 1.0f;
    for (int i = 0; i < numberOfFireworks; ++i) {
        double x = Math.randomBetween(xMin, xMax);
        double y = Math.randomBetween(yMin, yMax);
        double z = Math.randomBetween(zMin, zMax);
        Cartesian3 offset = new Cartesian3(x, y, z);
        Color color = Color.fromRandom(colorRandomOptions[i % colorRandomOptions.length]);
        List<ParticleBurst> bursts = new ArrayList<>();
        for (int j = 0; j < 3; ++j) {
            ParticleBurstOptions particleBurstOptions = new ParticleBurstOptions();
            particleBurstOptions.time = Math.nextRandomNumber() * lifetime;
            particleBurstOptions.minimum = burstSize;
            particleBurstOptions.maximum = burstSize;
            bursts.add(new ParticleBurst(particleBurstOptions));
        }
        createFirework(csVPanel.getViewer().scene(), offset, color, bursts.toArray(new ParticleBurst[bursts.size()]));
    }
    org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().scene().camera();
    Cartesian3 cameraOffset = new Cartesian3(-300.0, 0.0, 0.0);
    camera.lookAtTransform(modelMatrix, cameraOffset);
    camera.lookAtTransform(Matrix4.IDENTITY());
    Cartesian3 toFireworks = Cartesian3.subtract(emitterInitialLocation, cameraOffset, new Cartesian3());
    Cartesian3.normalize(toFireworks, toFireworks);
    double angle = Math.PI_OVER_TWO() - java.lang.Math.acos(Cartesian3.dot(toFireworks, Cartesian3.UNIT_Z()));
    camera.lookUp(angle);
    contentPanel.add(new HTML("<p></p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) ParticleBurst(org.cesiumjs.cs.scene.particle.ParticleBurst) ArrayList(java.util.ArrayList) ParticleBurstOptions(org.cesiumjs.cs.scene.particle.options.ParticleBurstOptions) HTML(com.google.gwt.user.client.ui.HTML) ColorRandomOptions(org.cesiumjs.cs.core.options.ColorRandomOptions)

Aggregations

HTML (com.google.gwt.user.client.ui.HTML)1 ArrayList (java.util.ArrayList)1 ColorRandomOptions (org.cesiumjs.cs.core.options.ColorRandomOptions)1 ParticleBurst (org.cesiumjs.cs.scene.particle.ParticleBurst)1 ParticleBurstOptions (org.cesiumjs.cs.scene.particle.options.ParticleBurstOptions)1 ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)1