Cesium 1.22 shadows feature

I was going through Cesium new release 1.22 and tried to implement its shadows feature. I minimized the sample code to following to know how it works.

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

var woodTower = viewer.entities.add({
    name : 'Wood Tower',
    height : 0.0,
    model : {
        uri : 'SampleData/models/WoodTower/Wood_Tower.gltf'
    }
});

var locations = {
    Exton : {
        longitude : -1.31968,
        latitude : 0.698874,
        height : 74.14210186070714,
        date : 2457522.154792
    },
};

woodTower.position = Cesium.Cartesian3.fromRadians(locations.Exton.longitude, locations.Exton.latitude, woodTower.height);

function setEntity(entity) {
    viewer.trackedEntity = entity;
    viewer.clock.currentTime = new Cesium.JulianDate(2457530.154792);
    viewer.clock.multiplier = 1.0;
}
setEntity(woodTower);

It works fine if ‘Wood_Tower.gltf’ is loaded, but does not work if I change it to :

var woodTower = viewer.entities.add({
    name : 'Green1 extruded polygon',
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-109.0, 42.0,
                                                        -111.0, 42.0,
                                                        -112.0, 40.0]),
        extrudedHeight: 500000.0,
        material : Cesium.Color.GREEN
    }
});

What am I missing in it?

Any help is much appreciated!

Right now we don’t have shadows support for non-model entities, though we do have a branch where this is working: https://github.com/AnalyticalGraphicsInc/cesium/tree/shadows-entity. We weren’t sure how often users would enable shadows for shapes, so we decided to leave it out of this release. If you decide to check it out, make sure to also set castShadows and receiveShadows to true in the polygon because shadows are off by default for non-model entities. I’ll keep this thread up-to-date if we decide merge that branch into master.

Hi Sean,

I tried this with new cesium-shadows-entity checkout:

var cesiumAir = viewer.entities.add({

name : ‘Green1 extruded polygon’,

polygon : {

hierarchy : Cesium.Cartesian3.fromDegreesArray([-109.0, 42.0,

-111.0, 42.0,

-112.0, 40.0]),

extrudedHeight: 500000.0,

material : Cesium.Color.GREEN,

castShadows : true,

receiveShadows : true,

},

});

But this does not work :frowning:

Could you please post an example where this works?

Hi Sean, shadows for shapes is very important to many urban visualizations. Please include this in the next release.

Thanks,

Greg

Hi Greg, we are very likely going to ship it in the next release. Check out https://github.com/AnalyticalGraphicsInc/cesium/pull/3928 for details.

Hi Pat, right now the shadow implementation is geared towards views that are closer to Earth with more realistic sized objects. However we will look into making it work for cases like your example as well.

Here is an example that shows a polygon with shadows on the shadows-entity branch: http://cesium-dev.s3-website-us-east-1.amazonaws.com/cesium/shadows-entity/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=c41f2d61156b266190efd06e0508569c

I think it’s also important to point out that “urban visualization” will be covered by 3D Tiles, which will absolutely support shadows and this had more to do with trying to avoid bloat in the Entity API.

Hi Sean, did shadowing for shapes make it into 1.23?

Thanks,

Greg

Hello Greg,

It looks like entity shadows was not quite ready for the 1.23 release.

Keep an eye on this PR https://github.com/AnalyticalGraphicsInc/cesium/pull/4005

It should be ready by the 1.24 release.

Best,

Hannah

Great, thanks Hannah!

Hi Hannah, might you know if the entity shadows logic will be released in 1.25? I didn’t see it in the release notes for 1.24.

Best,

Greg

Greg, you can see that release 1.24 was 01AUG, https://cesiumjs.org/2016/08/01/Cesium-version-1.24-released/. and the PR https://github.com/AnalyticalGraphicsInc/cesium/pull/4005 mentioned was merged 9 dayes ago, ergo it can not be in 1.24 :slight_smile:

So i would assume you can use it in 1.25 :slight_smile: