Skip to content

Commit

Permalink
Only change shadows for the current entity to avoid crash in #4096
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Jul 7, 2016
1 parent 9b20891 commit a3bc2cc
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions Apps/Sandcastle/gallery/Shadows.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@
var entities = viewer.entities.values;
var entitiesLength = entities.length;

var currentEntity;
var entityShadows = Cesium.ShadowMode.ENABLED;

function setLocation(location) {
var longitude = location.longitude;
var latitude = location.latitude;
Expand Down Expand Up @@ -201,12 +204,26 @@

Sandcastle.addToolbarMenu(locationToolbarOptions);

function setEntityShadows(entity, shadows) {
if (Cesium.defined(entity.model)) {
entity.model.shadows = shadows
}
if (Cesium.defined(entity.box)) {
entity.box.shadows = shadows;
}
if (Cesium.defined(entity.ellipsoid)) {
entity.ellipsoid.shadows = shadows;
}
}

function setEntity(entity) {
for (i = 0; i < entitiesLength; ++i) {
entities[i].show = false;
}
entity.show = true;
viewer.trackedEntity = entity;
currentEntity = entity;
setEntityShadows(entity, entityShadows);
}

function setEntityFunction(entity) {
Expand All @@ -230,18 +247,9 @@
viewer.shadows = !viewer.shadows;
});

var entityShadows = Cesium.ShadowMode.ENABLED;
Sandcastle.addToolbarButton('Toggle Entity Shadows', function() {
if (entityShadows === Cesium.ShadowMode.ENABLED) {
entityShadows = Cesium.ShadowMode.DISABLED;
} else {
entityShadows = Cesium.ShadowMode.ENABLED;
}
for (i = 0; i < entitiesLength; ++i) {
var entity = entities[i];
var visual = entity.model || entity.box || entity.ellipsoid;
visual.shadows = entityShadows;
}
entityShadows = (entityShadows === Cesium.ShadowMode.ENABLED) ? Cesium.ShadowMode.DISABLED : Cesium.ShadowMode.ENABLED;
setEntityShadows(currentEntity, entityShadows);
});

Sandcastle.addToolbarButton('Toggle Terrain Shadows', function() {
Expand Down

0 comments on commit a3bc2cc

Please sign in to comment.