Skip to content

Commit

Permalink
Make time parameter optional for all Properties
Browse files Browse the repository at this point in the history
  • Loading branch information
anne-gropler committed Aug 1, 2024
1 parent 32d0410 commit 7b15131
Show file tree
Hide file tree
Showing 40 changed files with 188 additions and 88 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Added `Transforms.computeIcrfToMoonFixedMatrix` and `Transforms.computeMoonFixedToIcrfMatrix` to compute the transformations between the Moon's fixed frame and ICRF at a given time.
- Added `Transforms.computeIcrfToCentralBodyFixedMatrix` to specific the default ICRF to fixed frame transformation to use internally, including for lighting calculations.
- Added SplitDirection property for display PointPrimitive and Billboard relative to the `Scene.splitPosition`. [#11982](https://github.com/CesiumGS/cesium/pull/11982)
- Made the `time` parameter optional for `Property`, using `JulianDate.now()` as default. [#12099](https://github.com/CesiumGS/cesium/pull/12099)

##### Fixes :wrench:

Expand Down
8 changes: 6 additions & 2 deletions packages/engine/Source/DataSources/CallbackProperty.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import defined from "../Core/defined.js";
import DeveloperError from "../Core/DeveloperError.js";
import Event from "../Core/Event.js";
import JulianDate from "../Core/JulianDate.js";

/**
* A {@link Property} whose value is lazily evaluated by a callback function.
Expand Down Expand Up @@ -49,11 +50,14 @@ Object.defineProperties(CallbackProperty.prototype, {
/**
* Gets the value of the property.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {object} The modified result parameter or a new instance if the result parameter was not supplied or is unsupported.
*/
CallbackProperty.prototype.getValue = function (time, result) {
if (!defined(time)) {
time = JulianDate.now();
}
return this._callback(time, result);
};

Expand Down Expand Up @@ -104,7 +108,7 @@ CallbackProperty.prototype.equals = function (other) {
* A function that returns the value of the property.
* @callback CallbackProperty.Callback
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {object} [result] The object to store the value into. If omitted, the function must create and return a new instance.
* @returns {object} The modified result parameter, or a new instance if the result parameter was not supplied or is unsupported.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Color from "../Core/Color.js";
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import Event from "../Core/Event.js";
import JulianDate from "../Core/JulianDate.js";
import createPropertyDescriptor from "./createPropertyDescriptor.js";
import Property from "./Property.js";

Expand Down Expand Up @@ -108,11 +109,14 @@ CheckerboardMaterialProperty.prototype.getType = function (time) {
/**
* Gets the value of the property at the provided time.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
CheckerboardMaterialProperty.prototype.getValue = function (time, result) {
if (!defined(time)) {
time = JulianDate.now();
}
if (!defined(result)) {
result = {};
}
Expand Down
6 changes: 5 additions & 1 deletion packages/engine/Source/DataSources/ColorMaterialProperty.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Color from "../Core/Color.js";
import defined from "../Core/defined.js";
import Event from "../Core/Event.js";
import JulianDate from "../Core/JulianDate.js";
import createPropertyDescriptor from "./createPropertyDescriptor.js";
import Property from "./Property.js";

Expand Down Expand Up @@ -72,11 +73,14 @@ ColorMaterialProperty.prototype.getType = function (time) {
/**
* Gets the value of the property at the provided time.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
ColorMaterialProperty.prototype.getValue = function (time, result) {
if (!defined(time)) {
time = JulianDate.now();
}
if (!defined(result)) {
result = {};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import defined from "../Core/defined.js";
import DeveloperError from "../Core/DeveloperError.js";
import Event from "../Core/Event.js";
import JulianDate from "../Core/JulianDate.js";
import CompositeProperty from "./CompositeProperty.js";
import Property from "./Property.js";

Expand Down Expand Up @@ -85,16 +86,14 @@ CompositeMaterialProperty.prototype.getType = function (time) {
/**
* Gets the value of the property at the provided time.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
CompositeMaterialProperty.prototype.getValue = function (time, result) {
//>>includeStart('debug', pragmas.debug);
if (!defined(time)) {
throw new DeveloperError("time is required");
time = JulianDate.now();
}
//>>includeEnd('debug');

const innerProperty = this._composite._intervals.findDataForIntervalContainingDate(
time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import DeveloperError from "../Core/DeveloperError.js";
import Event from "../Core/Event.js";
import JulianDate from "../Core/JulianDate.js";
import ReferenceFrame from "../Core/ReferenceFrame.js";
import CompositeProperty from "./CompositeProperty.js";
import Property from "./Property.js";
Expand Down Expand Up @@ -85,11 +86,14 @@ Object.defineProperties(CompositePositionProperty.prototype, {
/**
* Gets the value of the property at the provided time in the fixed frame.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {Cartesian3} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {Cartesian3 | undefined} The modified result parameter or a new instance if the result parameter was not supplied.
*/
CompositePositionProperty.prototype.getValue = function (time, result) {
if (!defined(time)) {
time = JulianDate.now();
}
return this.getValueInReferenceFrame(time, ReferenceFrame.FIXED, result);
};

Expand Down
8 changes: 3 additions & 5 deletions packages/engine/Source/DataSources/CompositeProperty.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JulianDate } from "@cesium/engine";
import defined from "../Core/defined.js";
import DeveloperError from "../Core/DeveloperError.js";
import Event from "../Core/Event.js";
import EventHelper from "../Core/EventHelper.js";
import TimeIntervalCollection from "../Core/TimeIntervalCollection.js";
Expand Down Expand Up @@ -106,16 +106,14 @@ Object.defineProperties(CompositeProperty.prototype, {
/**
* Gets the value of the property at the provided time.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
CompositeProperty.prototype.getValue = function (time, result) {
//>>includeStart('debug', pragmas.debug);
if (!defined(time)) {
throw new DeveloperError("time is required");
time = JulianDate.now();
}
//>>includeEnd('debug');

const innerProperty = this._intervals.findDataForIntervalContainingDate(time);
if (defined(innerProperty)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import DeveloperError from "../Core/DeveloperError.js";
import Event from "../Core/Event.js";
import JulianDate from "../Core/JulianDate.js";
import ReferenceFrame from "../Core/ReferenceFrame.js";
import PositionProperty from "./PositionProperty.js";

Expand Down Expand Up @@ -68,11 +69,14 @@ Object.defineProperties(ConstantPositionProperty.prototype, {
/**
* Gets the value of the property at the provided time in the fixed frame.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
ConstantPositionProperty.prototype.getValue = function (time, result) {
if (!defined(time)) {
time = JulianDate.now();
}
return this.getValueInReferenceFrame(time, ReferenceFrame.FIXED, result);
};

Expand Down
6 changes: 5 additions & 1 deletion packages/engine/Source/DataSources/GridMaterialProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Color from "../Core/Color.js";
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import Event from "../Core/Event.js";
import JulianDate from "../Core/JulianDate.js";
import createPropertyDescriptor from "./createPropertyDescriptor.js";
import Property from "./Property.js";

Expand Down Expand Up @@ -137,11 +138,14 @@ GridMaterialProperty.prototype.getType = function (time) {
/**
* Gets the value of the property at the provided time.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
GridMaterialProperty.prototype.getValue = function (time, result) {
if (!defined(time)) {
time = JulianDate.now();
}
if (!defined(result)) {
result = {};
}
Expand Down
7 changes: 6 additions & 1 deletion packages/engine/Source/DataSources/ImageMaterialProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Color from "../Core/Color.js";
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import Event from "../Core/Event.js";
import JulianDate from "../Core/JulianDate.js";
import createPropertyDescriptor from "./createPropertyDescriptor.js";
import Property from "./Property.js";

Expand Down Expand Up @@ -117,11 +118,15 @@ ImageMaterialProperty.prototype.getType = function (time) {
/**
* Gets the value of the property at the provided time.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
ImageMaterialProperty.prototype.getValue = function (time, result) {
if (!defined(time)) {
time = JulianDate.now();
}

if (!defined(result)) {
result = {};
}
Expand Down
4 changes: 4 additions & 0 deletions packages/engine/Source/DataSources/MaterialProperty.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Color from "../Core/Color.js";
import defined from "../Core/defined.js";
import DeveloperError from "../Core/DeveloperError.js";
import JulianDate from "../Core/JulianDate.js";
import Material from "../Scene/Material.js";

/**
Expand Down Expand Up @@ -83,6 +84,9 @@ MaterialProperty.prototype.equals = DeveloperError.throwInstantiationError;
*/
MaterialProperty.getValue = function (time, materialProperty, material) {
let type;
if (!defined(time)) {
time = JulianDate.now();
}

if (defined(materialProperty)) {
type = materialProperty.getType(time);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import Event from "../Core/Event.js";
import JulianDate from "../Core/JulianDate.js";
import TranslationRotationScale from "../Core/TranslationRotationScale.js";
import createPropertyDescriptor from "./createPropertyDescriptor.js";
import Property from "./Property.js";
Expand Down Expand Up @@ -95,11 +96,14 @@ Object.defineProperties(NodeTransformationProperty.prototype, {
/**
* Gets the value of the property at the provided time.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {TranslationRotationScale} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {TranslationRotationScale} The modified result parameter or a new instance if the result parameter was not supplied.
*/
NodeTransformationProperty.prototype.getValue = function (time, result) {
if (!defined(time)) {
time = JulianDate.now();
}
if (!defined(result)) {
result = new TranslationRotationScale();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Color from "../Core/Color.js";
import defined from "../Core/defined.js";
import Event from "../Core/Event.js";
import JulianDate from "../Core/JulianDate.js";
import createPropertyDescriptor from "./createPropertyDescriptor.js";
import Property from "./Property.js";

Expand Down Expand Up @@ -70,11 +71,14 @@ PolylineArrowMaterialProperty.prototype.getType = function (time) {
/**
* Gets the value of the property at the provided time.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
PolylineArrowMaterialProperty.prototype.getValue = function (time, result) {
if (!defined(time)) {
time = JulianDate.now();
}
if (!defined(result)) {
result = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Color from "../Core/Color.js";
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import Event from "../Core/Event.js";
import JulianDate from "../Core/JulianDate.js";
import createPropertyDescriptor from "./createPropertyDescriptor.js";
import Property from "./Property.js";

Expand Down Expand Up @@ -113,11 +114,14 @@ PolylineDashMaterialProperty.prototype.getType = function (time) {
/**
* Gets the value of the property at the provided time.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
PolylineDashMaterialProperty.prototype.getValue = function (time, result) {
if (!defined(time)) {
time = JulianDate.now();
}
if (!defined(result)) {
result = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Color from "../Core/Color.js";
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import Event from "../Core/Event.js";
import JulianDate from "../Core/JulianDate.js";
import createPropertyDescriptor from "./createPropertyDescriptor.js";
import Property from "./Property.js";

Expand Down Expand Up @@ -98,11 +99,14 @@ PolylineGlowMaterialProperty.prototype.getType = function (time) {
/**
* Gets the value of the property at the provided time.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
PolylineGlowMaterialProperty.prototype.getValue = function (time, result) {
if (!defined(time)) {
time = JulianDate.now();
}
if (!defined(result)) {
result = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Color from "../Core/Color.js";
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import Event from "../Core/Event.js";
import JulianDate from "../Core/JulianDate.js";
import createPropertyDescriptor from "./createPropertyDescriptor.js";
import Property from "./Property.js";

Expand Down Expand Up @@ -105,11 +106,14 @@ PolylineOutlineMaterialProperty.prototype.getType = function (time) {
/**
* Gets the value of the property at the provided time.
*
* @param {JulianDate} time The time for which to retrieve the value.
* @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
* @param {object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
PolylineOutlineMaterialProperty.prototype.getValue = function (time, result) {
if (!defined(time)) {
time = JulianDate.now();
}
if (!defined(result)) {
result = {};
}
Expand Down
Loading

0 comments on commit 7b15131

Please sign in to comment.