Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translucent appearances break transparent backgrounds. #1921

Closed
mramato opened this issue Jul 15, 2014 · 1 comment · Fixed by #5200
Closed

Translucent appearances break transparent backgrounds. #1921

mramato opened this issue Jul 15, 2014 · 1 comment · Fixed by #5200

Comments

@mramato
Copy link
Member

mramato commented Jul 15, 2014

As reported on the mailing list, https://groups.google.com/d/msg/cesium-dev/dh3O12530hA/7IqwI3x71lgJ, having geometry with a translucent appearance will cause the alpha value of scene.backgroundColor to be ignored. Below is a complete sandcastle example which shows the problem.

If the appearance or scene.backgroundColor is opaque, everything works as expected, it's only when the appearance and background are both translucent does the background alpha get thrown out.

require(['Cesium'], function(Cesium) {
    "use strict";

    document.body.style.background = '#0F0';

    var viewer = new Cesium.Viewer('cesiumContainer', {
      contextOptions : {
          webgl : {
              alpha : true
          }
      }
    });

    viewer.scene.skyBox.destroy();
    viewer.scene.skyBox = undefined;
    viewer.scene.sun.destroy();
    viewer.scene.sun = undefined;
    viewer.scene.moon.destroy();
    viewer.scene.moon = undefined;
    viewer.scene.skyAtmosphere.destroy();
    viewer.scene.skyAtmosphere = undefined;

    viewer.scene.backgroundColor = new Cesium.Color(0,0,0,0);

    Sandcastle.addToolbarButton('Draw Box', function() {
        var primitives = viewer.scene.primitives;

        // Create box and position with a model matrix
        var dimensions = new Cesium.Cartesian3(400000.0, 300000.0, 500000.0);
        var positionOnEllipsoid = Cesium.Cartesian3.fromDegrees(-105.0, 45.0);
        var boxModelMatrix = Cesium.Matrix4.multiplyByTranslation(
            Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid),
            new Cesium.Cartesian3(0.0, 0.0, dimensions.z * 0.5));

        var boxGeometry = Cesium.BoxGeometry.fromDimensions({
            vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
            dimensions : dimensions
        });

        var boxGeometryInstance = new Cesium.GeometryInstance({
            geometry : boxGeometry,
            modelMatrix : boxModelMatrix,
            attributes : {
                color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5))
            }
        });

        primitives.add(new Cesium.Primitive({
            geometryInstances : boxGeometryInstance,
            appearance : new Cesium.PerInstanceColorAppearance({
                closed: true
            })
        }));
    });

    Sandcastle.finishedLoading();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants