Skip to content

Commit

Permalink
Added back deprecated properties
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Aug 2, 2016
1 parent 4578bd6 commit 35c12c7
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 22 deletions.
18 changes: 3 additions & 15 deletions Apps/Sandcastle/gallery/development/Shadows.html
Original file line number Diff line number Diff line change
Expand Up @@ -358,18 +358,6 @@
freeformLightCamera.lookAt(center, offset);
}

function getShadowMode(castShadows, receiveShadows) {
if (castShadows && receiveShadows) {
return Cesium.ShadowMode.ENABLED;
} else if (castShadows) {
return Cesium.ShadowMode.CAST_ONLY;
} else if (receiveShadows) {
return Cesium.ShadowMode.RECEIVE_ONLY;
} else {
return Cesium.ShadowMode.DISABLED;
}
}

function updateSettings() {
shadowMap.maximumDistance = Number(viewModel.distance);
shadowMap._pointLightRadius = Number(viewModel.radius);
Expand Down Expand Up @@ -402,7 +390,7 @@
// Force all derived commands to update
shadowMap.dirty = true;

globe.shadows = getShadowMode(viewModel.terrainCast, viewModel.terrainReceive);
globe.shadows = Cesium.ShadowMode.fromCastReceive(viewModel.terrainCast, viewModel.terrainReceive);
globe.show = viewModel.globe;
scene.skyAtmosphere.show = viewModel.globe;
}
Expand Down Expand Up @@ -721,7 +709,7 @@
if (Cesium.defined(picked) && Cesium.defined(picked.primitive)) {
var castShadows = Cesium.ShadowMode.castShadows(picked.primitive.shadows);
var receiveShadows = Cesium.ShadowMode.receiveShadows(picked.primitive.shadows);
picked.primitive.shadows = getShadowMode(!castShadows, receiveShadows);
picked.primitive.shadows = Cesium.ShadowMode.fromCastReceive(!castShadows, receiveShadows);
}
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);

Expand All @@ -731,7 +719,7 @@
if (Cesium.defined(picked)) {
var castShadows = Cesium.ShadowMode.castShadows(picked.primitive.shadows);
var receiveShadows = Cesium.ShadowMode.receiveShadows(picked.primitive.shadows);
picked.primitive.shadows = getShadowMode(castShadows, !receiveShadows);
picked.primitive.shadows = Cesium.ShadowMode.fromCastReceive(castShadows, !receiveShadows);
}
}, Cesium.ScreenSpaceEventType.MIDDLE_DOUBLE_CLICK);

Expand Down
1 change: 0 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Change Log
* Deprecated
* Deprecated `castShadows` and `receiveShadows` properties from `Model`, `Primitive`, and `Globe`. They will be removed in 1.26. Use `shadows` instead with the `ShadowMode` enum, e.g. `model.shadows = ShadowMode.ENABLED`.
* `Viewer.terrainShadows` now uses the `ShadowMode` enum instead of a Boolean, e.g. `viewer.terrainShadows = ShadowMode.RECEIVE_ONLY`. Boolean support will be dropped in 1.26.
* Entity `model.shadows` now uses the `ShadowMode` enum instead of a Boolean, e.g. `entity.model.shadows = ShadowMode.ENABLED`. Boolean support will be dropped in 1.26.
* Added `shadows` property to the entity API for `Box`, `Corridor`, `Cylinder`, `Ellipse`, `Ellipsoid`, `Polygon`, `Polyline`, `PoylineVolume`, `Rectangle`, and `Wall`. [#4005](https://github.com/AnalyticalGraphicsInc/cesium/pull/4005)

### 1.24 - 2016-08-01
Expand Down
2 changes: 2 additions & 0 deletions Source/DataSources/CzmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,8 @@ define([
processPacketData(Number, model, 'maximumScale', modelData.maximumScale, interval, sourceUri, entityCollection);
processPacketData(Boolean, model, 'incrementallyLoadTextures', modelData.incrementallyLoadTextures, interval, sourceUri, entityCollection);
processPacketData(Boolean, model, 'runAnimations', modelData.runAnimations, interval, sourceUri, entityCollection);
processPacketData(Boolean, model, 'castShadows', modelData.castShadows, interval, sourceUri, entityCollection);
processPacketData(Boolean, model, 'receiveShadows', modelData.receiveShadows, interval, sourceUri, entityCollection);
processPacketData(ShadowMode, model, 'shadows', modelData.shadows, interval, sourceUri, entityCollection);
processPacketData(HeightReference, model, 'heightReference', modelData.heightReference, interval, sourceUri, entityCollection);

Expand Down
28 changes: 28 additions & 0 deletions Source/DataSources/ModelGraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ define([
* @param {Property} [options.incrementallyLoadTextures=true] Determine if textures may continue to stream in after the model is loaded.
* @param {Property} [options.runAnimations=true] A boolean Property specifying if glTF animations specified in the model should be started.
* @param {Property} [options.nodeTransformations] An object, where keys are names of nodes, and values are {@link TranslationRotationScale} Properties describing the transformation to apply to that node.
* @param {Property} [options.castShadows=true] Deprecated, use options.shadows instead. A boolean Property specifying whether the model casts shadows from each light source.
* @param {Property} [options.receiveShadows=true] Deprecated, use options.shadows instead. A boolean Property specifying whether the model receives shadows from shadow casters in the scene.
* @param {Property} [options.shadows=ShadowMode.ENABLED] An enum Property specifying whether the model casts or receives shadows from each light source.
* @param {Property} [options.heightReference=HeightReference.NONE] A Property specifying what the height is relative to.
*
Expand All @@ -64,6 +66,10 @@ define([
this._maximumScaleSubscription = undefined;
this._incrementallyLoadTextures = undefined;
this._incrementallyLoadTexturesSubscription = undefined;
this._castShadows = undefined;
this._castShadowsSubscription = undefined;
this._receiveShadows = undefined;
this._receiveShadowsSubscription = undefined;
this._shadows = undefined;
this._shadowsSubscription = undefined;
this._uri = undefined;
Expand Down Expand Up @@ -138,6 +144,24 @@ define([
*/
incrementallyLoadTextures : createPropertyDescriptor('incrementallyLoadTextures'),

/**
* Get or sets the boolean Property specifying whether the model
* casts shadows from each light source.
* @memberof ModelGraphics.prototype
* @type {Property}
* @deprecated
*/
castShadows : createPropertyDescriptor('castShadows'),

/**
* Get or sets the boolean Property specifying whether the model
* receives shadows from shadow casters in the scene.
* @memberof ModelGraphics.prototype
* @type {Property}
* @deprecated
*/
receiveShadows : createPropertyDescriptor('receiveShadows'),

/**
* Get or sets the enum Property specifying whether the model
* casts or receives shadows from each light source.
Expand Down Expand Up @@ -194,6 +218,8 @@ define([
result.minimumPixelSize = this.minimumPixelSize;
result.maximumScale = this.maximumScale;
result.incrementallyLoadTextures = this.incrementallyLoadTextures;
result.castShadows = this.castShadows;
result.receiveShadows = this.receiveShadows;
result.shadows = this.shadows;
result.uri = this.uri;
result.runAnimations = this.runAnimations;
Expand Down Expand Up @@ -221,6 +247,8 @@ define([
this.minimumPixelSize = defaultValue(this.minimumPixelSize, source.minimumPixelSize);
this.maximumScale = defaultValue(this.maximumScale, source.maximumScale);
this.incrementallyLoadTextures = defaultValue(this.incrementallyLoadTextures, source.incrementallyLoadTextures);
this.castShadows = defaultValue(this.castShadows, source.castShadows);
this.receiveShadows = defaultValue(this.receiveShadows, source.receiveShadows);
this.shadows = defaultValue(this.shadows, source.shadows);
this.uri = defaultValue(this.uri, source.uri);
this.runAnimations = defaultValue(this.runAnimations, source.runAnimations);
Expand Down
11 changes: 10 additions & 1 deletion Source/DataSources/ModelVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,21 @@ define([
modelHash[entity.id] = modelData;
}

var shadows = defaultShadows;
if (defined(modelGraphics._shadows)) {
shadows = Property.getValueOrDefault(modelGraphics._shadows, time, defaultShadows);
} else if (defined(modelGraphics._castShadows) || defined(modelGraphics._receiveShadows)) {
var castShadows = Property.getValueOrDefault(modelGraphics._castShadows, time, true);
var receiveShadows = Property.getValueOrDefault(modelGraphics.receiveShadows, time, true);
shadows = ShadowMode.fromCastReceive(castShadows, receiveShadows);
}

model.show = true;
model.scale = Property.getValueOrDefault(modelGraphics._scale, time, defaultScale);
model.minimumPixelSize = Property.getValueOrDefault(modelGraphics._minimumPixelSize, time, defaultMinimumPixelSize);
model.maximumScale = Property.getValueOrUndefined(modelGraphics._maximumScale, time);
model.shadows = Property.getValueOrDefault(modelGraphics._shadows, time, defaultShadows);
model.modelMatrix = Matrix4.clone(modelMatrix, model.modelMatrix);
model.shadows = shadows;
model.heightReference = Property.getValueOrDefault(modelGraphics._heightReference, time, defaultHeightReference);

if (model.ready) {
Expand Down
42 changes: 42 additions & 0 deletions Source/Scene/Globe.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ define([
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/deprecationWarning',
'../Core/destroyObject',
'../Core/DeveloperError',
'../Core/Ellipsoid',
Expand Down Expand Up @@ -37,6 +38,7 @@ define([
defaultValue,
defined,
defineProperties,
deprecationWarning,
destroyObject,
DeveloperError,
Ellipsoid,
Expand Down Expand Up @@ -279,6 +281,46 @@ define([
get: function() {
return this._surface.tileLoadProgressEvent;
}
},

/**
* Determines whether the globe casts shadows from each light source.
*
* @memberof Globe.prototype
* @type {Boolean}
* @deprecated
*/
castShadows : {
get : function() {
deprecationWarning('Globe.castShadows', 'Globe.castShadows was deprecated in Cesium 1.25. It will be removed in 1.26. Use Globe.shadows instead.');
return ShadowMode.castShadows(this.shadows);
},
set : function(value) {
deprecationWarning('Globe.castShadows', 'Globe.castShadows was deprecated in Cesium 1.25. It will be removed in 1.26. Use Globe.shadows instead.');
var castShadows = value;
var receiveShadows = ShadowMode.receiveShadows(this.shadows);
this.shadows = ShadowMode.fromCastReceive(castShadows, receiveShadows);
}
},

/**
* Determines whether the globe receives shadows from shadow casters in the scene.
*
* @memberof Globe.prototype
* @type {Boolean}
* @deprecated
*/
receiveShadows : {
get : function() {
deprecationWarning('Globe.receiveShadows', 'Globe.receiveShadows was deprecated in Cesium 1.25. It will be removed in 1.26. Use Globe.shadows instead.');
return ShadowMode.receiveShadows(this.shadows);
},
set : function(value) {
deprecationWarning('Globe.receiveShadows', 'Globe.receiveShadows was deprecated in Cesium 1.25. It will be removed in 1.26. Use Globe.shadows instead.');
var castShadows = ShadowMode.castShadows(this.shadows);
var receiveShadows = value;
this.shadows = ShadowMode.fromCastReceive(castShadows, receiveShadows);
}
}
});

Expand Down
54 changes: 53 additions & 1 deletion Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ define([
'../Core/defined',
'../Core/defineProperties',
'../Core/destroyObject',
'../Core/deprecationWarning',
'../Core/DeveloperError',
'../Core/FeatureDetection',
'../Core/getAbsoluteUri',
Expand Down Expand Up @@ -71,6 +72,7 @@ define([
defined,
defineProperties,
destroyObject,
deprecationWarning,
DeveloperError,
FeatureDetection,
getAbsoluteUri,
Expand Down Expand Up @@ -313,6 +315,8 @@ define([
* @param {Boolean} [options.allowPicking=true] When <code>true</code>, each glTF mesh and primitive is pickable with {@link Scene#pick}.
* @param {Boolean} [options.incrementallyLoadTextures=true] Determine if textures may continue to stream in after the model is loaded.
* @param {Boolean} [options.asynchronous=true] Determines if model WebGL resource creation will be spread out over several frames or block until completion once all glTF files are loaded.
* @param {Boolean} [options.castShadows=true] Deprecated, use options.shadows instead. Determines whether the model casts shadows from each light source.
* @param {Boolean} [options.receiveShadows=true] Deprecated, use options.shadows instead. Determines whether the model receives shadows from shadow casters in the scene.
* @param {ShadowMode} [options.shadows=ShadowMode.ENABLED] Determines whether the model casts or receives shadows from each light source.
* @param {Boolean} [options.debugShowBoundingVolume=false] For debugging only. Draws the bounding sphere for each draw command in the model.
* @param {Boolean} [options.debugWireframe=false] For debugging only. Draws the model in wireframe.
Expand Down Expand Up @@ -503,14 +507,18 @@ define([
this._incrementallyLoadTextures = defaultValue(options.incrementallyLoadTextures, true);
this._asynchronous = defaultValue(options.asynchronous, true);

// Deprecated options
var castShadows = defaultValue(options.castShadows, true);
var receiveShadows = defaultValue(options.receiveShadows, true);

/**
* Determines whether the model casts or receives shadows from each light source.
*
* @type {ShadowMode}
*
* @default ShadowMode.ENABLED
*/
this.shadows = defaultValue(options.shadows, ShadowMode.ENABLED);
this.shadows = defaultValue(options.shadows, ShadowMode.fromCastReceive(castShadows, receiveShadows));
this._shadows = this.shadows;

/**
Expand Down Expand Up @@ -859,6 +867,50 @@ define([
get : function() {
return this._dirty;
}
},

/**
* Determines whether the model casts shadows from each light source.
*
* @memberof Model.prototype
*
* @type {Boolean}
*
* @deprecated
*/
castShadows : {
get : function() {
deprecationWarning('Model.castShadows', 'Model.castShadows was deprecated in Cesium 1.25. It will be removed in 1.26. Use Model.shadows instead.');
return ShadowMode.castShadows(this.shadows);
},
set : function(value) {
deprecationWarning('Model.castShadows', 'Model.castShadows was deprecated in Cesium 1.25. It will be removed in 1.26. Use Model.shadows instead.');
var castShadows = value;
var receiveShadows = ShadowMode.receiveShadows(this.shadows);
this.shadows = ShadowMode.fromCastReceive(castShadows, receiveShadows);
}
},

/**
* Determines whether the model receives shadows from shadow casters in the scene.
*
* @memberof Model.prototype
*
* @type {Boolean}
*
* @deprecated
*/
receiveShadows : {
get : function() {
deprecationWarning('Model.receiveShadows', 'Model.receiveShadows was deprecated in Cesium 1.25. It will be removed in 1.26. Use Model.shadows instead.');
return ShadowMode.receiveShadows(this.shadows);
},
set : function(value) {
deprecationWarning('Model.receiveShadows', 'Model.receiveShadows was deprecated in Cesium 1.25. It will be removed in 1.26. Use Model.shadows instead.');
var castShadows = ShadowMode.castShadows(this.shadows);
var receiveShadows = value;
this.shadows = ShadowMode.fromCastReceive(castShadows, receiveShadows);
}
}
});

Expand Down
Loading

0 comments on commit 35c12c7

Please sign in to comment.