diff --git a/CHANGES.md b/CHANGES.md index f23bfa536ea0..76fdfb03e6cc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,13 @@ # Change Log +### 1.121 - 2024-09-01 + +#### @cesium/engine + +##### Additions :tada: + +- Made the `time` parameter optional for `Property`, using `JulianDate.now()` as default. [#12099](https://github.com/CesiumGS/cesium/pull/12099) + ### 1.120 - 2024-08-01 #### @cesium/engine diff --git a/packages/engine/Source/DataSources/CallbackProperty.js b/packages/engine/Source/DataSources/CallbackProperty.js index c3609030cd92..3611241ed407 100644 --- a/packages/engine/Source/DataSources/CallbackProperty.js +++ b/packages/engine/Source/DataSources/CallbackProperty.js @@ -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. @@ -46,14 +47,19 @@ Object.defineProperties(CallbackProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * 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(timeScratch); + } return this._callback(time, result); }; @@ -104,7 +110,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. */ diff --git a/packages/engine/Source/DataSources/CheckerboardMaterialProperty.js b/packages/engine/Source/DataSources/CheckerboardMaterialProperty.js index 547e29eafba4..4dfc5c297e18 100644 --- a/packages/engine/Source/DataSources/CheckerboardMaterialProperty.js +++ b/packages/engine/Source/DataSources/CheckerboardMaterialProperty.js @@ -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"; @@ -105,14 +106,19 @@ CheckerboardMaterialProperty.prototype.getType = function (time) { return "Checkerboard"; }; +const timeScratch = new JulianDate(); + /** * 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(timeScratch); + } if (!defined(result)) { result = {}; } diff --git a/packages/engine/Source/DataSources/ColorMaterialProperty.js b/packages/engine/Source/DataSources/ColorMaterialProperty.js index c6abf36e56d4..26928fad14c4 100644 --- a/packages/engine/Source/DataSources/ColorMaterialProperty.js +++ b/packages/engine/Source/DataSources/ColorMaterialProperty.js @@ -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"; @@ -69,14 +70,19 @@ ColorMaterialProperty.prototype.getType = function (time) { return "Color"; }; +const timeScratch = new JulianDate(); + /** * 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(timeScratch); + } if (!defined(result)) { result = {}; } diff --git a/packages/engine/Source/DataSources/CompositeMaterialProperty.js b/packages/engine/Source/DataSources/CompositeMaterialProperty.js index 7827c7ad61f6..303d90c90c46 100644 --- a/packages/engine/Source/DataSources/CompositeMaterialProperty.js +++ b/packages/engine/Source/DataSources/CompositeMaterialProperty.js @@ -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"; @@ -82,19 +83,19 @@ CompositeMaterialProperty.prototype.getType = function (time) { return undefined; }; +const timeScratch = new JulianDate(); + /** * 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(timeScratch); } - //>>includeEnd('debug'); const innerProperty = this._composite._intervals.findDataForIntervalContainingDate( time diff --git a/packages/engine/Source/DataSources/CompositePositionProperty.js b/packages/engine/Source/DataSources/CompositePositionProperty.js index e5e74a7951eb..202b6fe43026 100644 --- a/packages/engine/Source/DataSources/CompositePositionProperty.js +++ b/packages/engine/Source/DataSources/CompositePositionProperty.js @@ -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"; @@ -82,14 +83,19 @@ Object.defineProperties(CompositePositionProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * 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(timeScratch); + } return this.getValueInReferenceFrame(time, ReferenceFrame.FIXED, result); }; diff --git a/packages/engine/Source/DataSources/CompositeProperty.js b/packages/engine/Source/DataSources/CompositeProperty.js index 703d7d5df478..4af69c9f0eed 100644 --- a/packages/engine/Source/DataSources/CompositeProperty.js +++ b/packages/engine/Source/DataSources/CompositeProperty.js @@ -1,7 +1,7 @@ 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 JulianDate from "../Core/JulianDate.js"; import TimeIntervalCollection from "../Core/TimeIntervalCollection.js"; import Property from "./Property.js"; @@ -103,19 +103,19 @@ Object.defineProperties(CompositeProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * 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(timeScratch); } - //>>includeEnd('debug'); const innerProperty = this._intervals.findDataForIntervalContainingDate(time); if (defined(innerProperty)) { diff --git a/packages/engine/Source/DataSources/ConstantPositionProperty.js b/packages/engine/Source/DataSources/ConstantPositionProperty.js index 7fe47c720e81..b2a436383bf5 100644 --- a/packages/engine/Source/DataSources/ConstantPositionProperty.js +++ b/packages/engine/Source/DataSources/ConstantPositionProperty.js @@ -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"; @@ -65,14 +66,19 @@ Object.defineProperties(ConstantPositionProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * 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(timeScratch); + } return this.getValueInReferenceFrame(time, ReferenceFrame.FIXED, result); }; diff --git a/packages/engine/Source/DataSources/GridMaterialProperty.js b/packages/engine/Source/DataSources/GridMaterialProperty.js index 1304ddd745e0..77ea417ec67c 100644 --- a/packages/engine/Source/DataSources/GridMaterialProperty.js +++ b/packages/engine/Source/DataSources/GridMaterialProperty.js @@ -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"; @@ -134,14 +135,19 @@ GridMaterialProperty.prototype.getType = function (time) { return "Grid"; }; +const timeScratch = new JulianDate(); + /** * 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(timeScratch); + } if (!defined(result)) { result = {}; } diff --git a/packages/engine/Source/DataSources/ImageMaterialProperty.js b/packages/engine/Source/DataSources/ImageMaterialProperty.js index 5aa8c5b713fa..97f00224bc02 100644 --- a/packages/engine/Source/DataSources/ImageMaterialProperty.js +++ b/packages/engine/Source/DataSources/ImageMaterialProperty.js @@ -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"; @@ -114,14 +115,20 @@ ImageMaterialProperty.prototype.getType = function (time) { return "Image"; }; +const timeScratch = new JulianDate(); + /** * 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(timeScratch); + } + if (!defined(result)) { result = {}; } diff --git a/packages/engine/Source/DataSources/MaterialProperty.js b/packages/engine/Source/DataSources/MaterialProperty.js index c6a957f79e77..0c2ec6f866a5 100644 --- a/packages/engine/Source/DataSources/MaterialProperty.js +++ b/packages/engine/Source/DataSources/MaterialProperty.js @@ -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"; /** @@ -62,7 +63,7 @@ MaterialProperty.prototype.getType = DeveloperError.throwInstantiationError; * Gets the value of the property at the provided time. * @function * - * @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. */ @@ -78,11 +79,16 @@ MaterialProperty.prototype.getValue = DeveloperError.throwInstantiationError; */ MaterialProperty.prototype.equals = DeveloperError.throwInstantiationError; +const timeScratch = new JulianDate(); + /** * @private */ MaterialProperty.getValue = function (time, materialProperty, material) { let type; + if (!defined(time)) { + time = JulianDate.now(timeScratch); + } if (defined(materialProperty)) { type = materialProperty.getType(time); diff --git a/packages/engine/Source/DataSources/NodeTransformationProperty.js b/packages/engine/Source/DataSources/NodeTransformationProperty.js index f6513cd05972..b71017dc363a 100644 --- a/packages/engine/Source/DataSources/NodeTransformationProperty.js +++ b/packages/engine/Source/DataSources/NodeTransformationProperty.js @@ -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"; @@ -92,14 +93,19 @@ Object.defineProperties(NodeTransformationProperty.prototype, { scale: createPropertyDescriptor("scale"), }); +const timeScratch = new JulianDate(); + /** * 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(timeScratch); + } if (!defined(result)) { result = new TranslationRotationScale(); } diff --git a/packages/engine/Source/DataSources/PolylineArrowMaterialProperty.js b/packages/engine/Source/DataSources/PolylineArrowMaterialProperty.js index 78ad0b87c94d..0550b9f46992 100644 --- a/packages/engine/Source/DataSources/PolylineArrowMaterialProperty.js +++ b/packages/engine/Source/DataSources/PolylineArrowMaterialProperty.js @@ -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"; @@ -67,14 +68,19 @@ PolylineArrowMaterialProperty.prototype.getType = function (time) { return "PolylineArrow"; }; +const timeScratch = new JulianDate(); + /** * 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(timeScratch); + } if (!defined(result)) { result = {}; } diff --git a/packages/engine/Source/DataSources/PolylineDashMaterialProperty.js b/packages/engine/Source/DataSources/PolylineDashMaterialProperty.js index 1ff9c6675f99..3335017ba128 100644 --- a/packages/engine/Source/DataSources/PolylineDashMaterialProperty.js +++ b/packages/engine/Source/DataSources/PolylineDashMaterialProperty.js @@ -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"; @@ -110,14 +111,19 @@ PolylineDashMaterialProperty.prototype.getType = function (time) { return "PolylineDash"; }; +const timeScratch = new JulianDate(); + /** * 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(timeScratch); + } if (!defined(result)) { result = {}; } diff --git a/packages/engine/Source/DataSources/PolylineGlowMaterialProperty.js b/packages/engine/Source/DataSources/PolylineGlowMaterialProperty.js index 11ac0f10a9e8..50b5c2db007a 100644 --- a/packages/engine/Source/DataSources/PolylineGlowMaterialProperty.js +++ b/packages/engine/Source/DataSources/PolylineGlowMaterialProperty.js @@ -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"; @@ -95,14 +96,19 @@ PolylineGlowMaterialProperty.prototype.getType = function (time) { return "PolylineGlow"; }; +const timeScratch = new JulianDate(); + /** * 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(timeScratch); + } if (!defined(result)) { result = {}; } diff --git a/packages/engine/Source/DataSources/PolylineOutlineMaterialProperty.js b/packages/engine/Source/DataSources/PolylineOutlineMaterialProperty.js index 27851e59ba78..bb13942d3736 100644 --- a/packages/engine/Source/DataSources/PolylineOutlineMaterialProperty.js +++ b/packages/engine/Source/DataSources/PolylineOutlineMaterialProperty.js @@ -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"; @@ -102,14 +103,19 @@ PolylineOutlineMaterialProperty.prototype.getType = function (time) { return "PolylineOutline"; }; +const timeScratch = new JulianDate(); + /** * 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(timeScratch); + } if (!defined(result)) { result = {}; } diff --git a/packages/engine/Source/DataSources/PositionProperty.js b/packages/engine/Source/DataSources/PositionProperty.js index 5f6b8fa6699f..66a9c384b67a 100644 --- a/packages/engine/Source/DataSources/PositionProperty.js +++ b/packages/engine/Source/DataSources/PositionProperty.js @@ -61,7 +61,7 @@ Object.defineProperties(PositionProperty.prototype, { * Gets the value of the property at the provided time in the fixed frame. * @function * - * @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. */ diff --git a/packages/engine/Source/DataSources/PositionPropertyArray.js b/packages/engine/Source/DataSources/PositionPropertyArray.js index ac8853533a67..fc8c3f4e54b5 100644 --- a/packages/engine/Source/DataSources/PositionPropertyArray.js +++ b/packages/engine/Source/DataSources/PositionPropertyArray.js @@ -3,6 +3,7 @@ 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 JulianDate from "../Core/JulianDate.js"; import ReferenceFrame from "../Core/ReferenceFrame.js"; import Property from "./Property.js"; @@ -76,14 +77,19 @@ Object.defineProperties(PositionPropertyArray.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * 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 {Cartesian3[]} [result] The object to store the value into, if omitted, a new instance is created and returned. * @returns {Cartesian3[]} The modified result parameter or a new instance if the result parameter was not supplied. */ PositionPropertyArray.prototype.getValue = function (time, result) { + if (!defined(time)) { + time = JulianDate.now(timeScratch); + } return this.getValueInReferenceFrame(time, ReferenceFrame.FIXED, result); }; diff --git a/packages/engine/Source/DataSources/Property.js b/packages/engine/Source/DataSources/Property.js index 5bb13ab71b49..49092eb3ebff 100644 --- a/packages/engine/Source/DataSources/Property.js +++ b/packages/engine/Source/DataSources/Property.js @@ -52,7 +52,7 @@ Object.defineProperties(Property.prototype, { * Gets the value of the property at the provided time. * @function * - * @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. */ diff --git a/packages/engine/Source/DataSources/PropertyArray.js b/packages/engine/Source/DataSources/PropertyArray.js index 305e3c0c9401..b0a1322d865c 100644 --- a/packages/engine/Source/DataSources/PropertyArray.js +++ b/packages/engine/Source/DataSources/PropertyArray.js @@ -1,7 +1,7 @@ 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 JulianDate from "../Core/JulianDate.js"; import Property from "./Property.js"; /** @@ -60,19 +60,19 @@ Object.defineProperties(PropertyArray.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * 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, which is an array of values produced by evaluating each of the contained properties at the given time or a new instance if the result parameter was not supplied. */ PropertyArray.prototype.getValue = function (time, result) { - //>>includeStart('debug', pragmas.debug); if (!defined(time)) { - throw new DeveloperError("time is required."); + time = JulianDate.now(timeScratch); } - //>>includeEnd('debug'); const value = this._value; if (!defined(value)) { diff --git a/packages/engine/Source/DataSources/PropertyBag.js b/packages/engine/Source/DataSources/PropertyBag.js index a5b0220f400b..f98a3305aab8 100644 --- a/packages/engine/Source/DataSources/PropertyBag.js +++ b/packages/engine/Source/DataSources/PropertyBag.js @@ -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 ConstantProperty from "./ConstantProperty.js"; import createPropertyDescriptor from "./createPropertyDescriptor.js"; import Property from "./Property.js"; @@ -157,21 +158,21 @@ PropertyBag.prototype.removeProperty = function (propertyName) { this._definitionChanged.raiseEvent(this); }; +const timeScratch = new JulianDate(); + /** * Gets the value of this property. Each contained property will be evaluated at the given time, and the overall * result will be an object, mapping property names to those values. * - * @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. * Note that any properties in result which are not part of this PropertyBag will be left as-is. * @returns {object} The modified result parameter or a new instance if the result parameter was not supplied. */ PropertyBag.prototype.getValue = function (time, result) { - //>>includeStart('debug', pragmas.debug); if (!defined(time)) { - throw new DeveloperError("time is required."); + time = JulianDate.now(timeScratch); } - //>>includeEnd('debug'); if (!defined(result)) { result = {}; diff --git a/packages/engine/Source/DataSources/ReferenceProperty.js b/packages/engine/Source/DataSources/ReferenceProperty.js index 88218e81d0db..175c3e41705f 100644 --- a/packages/engine/Source/DataSources/ReferenceProperty.js +++ b/packages/engine/Source/DataSources/ReferenceProperty.js @@ -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 Property from "./Property.js"; function resolve(that) { @@ -254,15 +255,20 @@ ReferenceProperty.fromString = function (targetCollection, referenceString) { return new ReferenceProperty(targetCollection, identifier, values); }; +const timeScratch = new JulianDate(); + /** * 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. */ ReferenceProperty.prototype.getValue = function (time, result) { const target = resolve(this); + if (!defined(time)) { + time = JulianDate.now(timeScratch); + } return defined(target) ? target.getValue(time, result) : undefined; }; diff --git a/packages/engine/Source/DataSources/SampledPositionProperty.js b/packages/engine/Source/DataSources/SampledPositionProperty.js index 001fba3465bc..fb72ce8aae8f 100644 --- a/packages/engine/Source/DataSources/SampledPositionProperty.js +++ b/packages/engine/Source/DataSources/SampledPositionProperty.js @@ -4,6 +4,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"; import Property from "./Property.js"; @@ -178,14 +179,19 @@ Object.defineProperties(SampledPositionProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * Gets the position 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 {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. */ SampledPositionProperty.prototype.getValue = function (time, result) { + if (!defined(time)) { + time = JulianDate.now(timeScratch); + } return this.getValueInReferenceFrame(time, ReferenceFrame.FIXED, result); }; diff --git a/packages/engine/Source/DataSources/SampledProperty.js b/packages/engine/Source/DataSources/SampledProperty.js index 39248a3a39e3..2c015283c4f9 100644 --- a/packages/engine/Source/DataSources/SampledProperty.js +++ b/packages/engine/Source/DataSources/SampledProperty.js @@ -359,17 +359,19 @@ Object.defineProperties(SampledProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * 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. */ SampledProperty.prototype.getValue = function (time, result) { - //>>includeStart('debug', pragmas.debug); - Check.defined("time", time); - //>>includeEnd('debug'); + if (!defined(time)) { + time = JulianDate.now(timeScratch); + } const times = this._times; const timesLength = times.length; diff --git a/packages/engine/Source/DataSources/ScaledPositionProperty.js b/packages/engine/Source/DataSources/ScaledPositionProperty.js index e4608c4bb1d0..ec89e9386674 100644 --- a/packages/engine/Source/DataSources/ScaledPositionProperty.js +++ b/packages/engine/Source/DataSources/ScaledPositionProperty.js @@ -2,6 +2,7 @@ import defined from "../Core/defined.js"; import DeveloperError from "../Core/DeveloperError.js"; import Ellipsoid from "../Core/Ellipsoid.js"; import Event from "../Core/Event.js"; +import JulianDate from "../Core/JulianDate.js"; import ReferenceFrame from "../Core/ReferenceFrame.js"; import Property from "./Property.js"; @@ -37,7 +38,12 @@ Object.defineProperties(ScaledPositionProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + ScaledPositionProperty.prototype.getValue = function (time, result) { + if (!defined(time)) { + time = JulianDate.now(timeScratch); + } return this.getValueInReferenceFrame(time, ReferenceFrame.FIXED, result); }; diff --git a/packages/engine/Source/DataSources/StripeMaterialProperty.js b/packages/engine/Source/DataSources/StripeMaterialProperty.js index c778483802a2..8fb83fe4f720 100644 --- a/packages/engine/Source/DataSources/StripeMaterialProperty.js +++ b/packages/engine/Source/DataSources/StripeMaterialProperty.js @@ -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"; import StripeOrientation from "./StripeOrientation.js"; @@ -135,14 +136,19 @@ StripeMaterialProperty.prototype.getType = function (time) { return "Stripe"; }; +const timeScratch = new JulianDate(); + /** * 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. */ StripeMaterialProperty.prototype.getValue = function (time, result) { + if (!defined(time)) { + time = JulianDate.now(timeScratch); + } if (!defined(result)) { result = {}; } diff --git a/packages/engine/Source/DataSources/TerrainOffsetProperty.js b/packages/engine/Source/DataSources/TerrainOffsetProperty.js index 42247f453ba8..329d1b136a2f 100644 --- a/packages/engine/Source/DataSources/TerrainOffsetProperty.js +++ b/packages/engine/Source/DataSources/TerrainOffsetProperty.js @@ -5,6 +5,7 @@ import defined from "../Core/defined.js"; import destroyObject from "../Core/destroyObject.js"; import Event from "../Core/Event.js"; import Iso8601 from "../Core/Iso8601.js"; +import JulianDate from "../Core/JulianDate.js"; import CesiumMath from "../Core/Math.js"; import HeightReference, { isHeightReferenceRelative, @@ -146,12 +147,20 @@ TerrainOffsetProperty.prototype._updateClamping = function () { ); }; +const timeScratch = new JulianDate(); + /** * Gets the height relative to the terrain based on the positions. * + * @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 {Cartesian3} The offset */ TerrainOffsetProperty.prototype.getValue = function (time, result) { + if (!defined(time)) { + time = JulianDate.now(timeScratch); + } + const heightReference = Property.getValueOrDefault( this._heightReference, time, diff --git a/packages/engine/Source/DataSources/TimeIntervalCollectionPositionProperty.js b/packages/engine/Source/DataSources/TimeIntervalCollectionPositionProperty.js index 9fd6a16a7a4a..7813010f98c4 100644 --- a/packages/engine/Source/DataSources/TimeIntervalCollectionPositionProperty.js +++ b/packages/engine/Source/DataSources/TimeIntervalCollectionPositionProperty.js @@ -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 TimeIntervalCollection from "../Core/TimeIntervalCollection.js"; import PositionProperty from "./PositionProperty.js"; @@ -78,10 +79,12 @@ Object.defineProperties(TimeIntervalCollectionPositionProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * 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 {Cartesian3 | undefined} The modified result parameter or a new instance if the result parameter was not supplied. */ @@ -89,6 +92,9 @@ TimeIntervalCollectionPositionProperty.prototype.getValue = function ( time, result ) { + if (!defined(time)) { + time = JulianDate.now(timeScratch); + } return this.getValueInReferenceFrame(time, ReferenceFrame.FIXED, result); }; diff --git a/packages/engine/Source/DataSources/TimeIntervalCollectionProperty.js b/packages/engine/Source/DataSources/TimeIntervalCollectionProperty.js index 3c7f5a4b8f82..f6325bc8a148 100644 --- a/packages/engine/Source/DataSources/TimeIntervalCollectionProperty.js +++ b/packages/engine/Source/DataSources/TimeIntervalCollectionProperty.js @@ -1,6 +1,6 @@ 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 TimeIntervalCollection from "../Core/TimeIntervalCollection.js"; import Property from "./Property.js"; @@ -91,19 +91,19 @@ Object.defineProperties(TimeIntervalCollectionProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * 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. */ TimeIntervalCollectionProperty.prototype.getValue = function (time, result) { - //>>includeStart('debug', pragmas.debug); if (!defined(time)) { - throw new DeveloperError("time is required"); + time = JulianDate.now(timeScratch); } - //>>includeEnd('debug'); const value = this._intervals.findDataForIntervalContainingDate(time); if (defined(value) && typeof value.clone === "function") { diff --git a/packages/engine/Source/DataSources/VelocityOrientationProperty.js b/packages/engine/Source/DataSources/VelocityOrientationProperty.js index 1b14c1d2a10a..a4ab53537a23 100644 --- a/packages/engine/Source/DataSources/VelocityOrientationProperty.js +++ b/packages/engine/Source/DataSources/VelocityOrientationProperty.js @@ -3,6 +3,7 @@ import defaultValue from "../Core/defaultValue.js"; import defined from "../Core/defined.js"; import Ellipsoid from "../Core/Ellipsoid.js"; import Event from "../Core/Event.js"; +import JulianDate from "../Core/JulianDate.js"; import Matrix3 from "../Core/Matrix3.js"; import Quaternion from "../Core/Quaternion.js"; import Transforms from "../Core/Transforms.js"; @@ -104,15 +105,19 @@ Object.defineProperties(VelocityOrientationProperty.prototype, { const positionScratch = new Cartesian3(); const velocityScratch = new Cartesian3(); const rotationScratch = new Matrix3(); +const timeScratch = new JulianDate(); /** * 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 {Quaternion} [result] The object to store the value into, if omitted, a new instance is created and returned. * @returns {Quaternion} The modified result parameter or a new instance if the result parameter was not supplied. */ VelocityOrientationProperty.prototype.getValue = function (time, result) { + if (!defined(time)) { + time = JulianDate.now(timeScratch); + } const velocity = this._velocityVectorProperty._getValue( time, velocityScratch, diff --git a/packages/engine/Source/DataSources/VelocityVectorProperty.js b/packages/engine/Source/DataSources/VelocityVectorProperty.js index 0184422ffd05..3d0b9d900c83 100644 --- a/packages/engine/Source/DataSources/VelocityVectorProperty.js +++ b/packages/engine/Source/DataSources/VelocityVectorProperty.js @@ -1,7 +1,6 @@ import Cartesian3 from "../Core/Cartesian3.js"; 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 Property from "./Property.js"; @@ -119,12 +118,13 @@ Object.defineProperties(VelocityVectorProperty.prototype, { const position1Scratch = new Cartesian3(); const position2Scratch = new Cartesian3(); const timeScratch = new JulianDate(); +const timeNowScratch = new JulianDate(); const step = 1.0 / 60.0; /** * 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 {Cartesian3} [result] The object to store the value into, if omitted, a new instance is created and returned. * @returns {Cartesian3} The modified result parameter or a new instance if the result parameter was not supplied. */ @@ -140,11 +140,9 @@ VelocityVectorProperty.prototype._getValue = function ( velocityResult, positionResult ) { - //>>includeStart('debug', pragmas.debug); if (!defined(time)) { - throw new DeveloperError("time is required"); + time = JulianDate.now(timeNowScratch); } - //>>includeEnd('debug'); if (!defined(velocityResult)) { velocityResult = new Cartesian3(); diff --git a/packages/engine/Specs/DataSources/CallbackPropertySpec.js b/packages/engine/Specs/DataSources/CallbackPropertySpec.js index f72b0da1c341..11240f3eb827 100644 --- a/packages/engine/Specs/DataSources/CallbackPropertySpec.js +++ b/packages/engine/Specs/DataSources/CallbackPropertySpec.js @@ -20,6 +20,19 @@ describe("DataSources/CallbackProperty", function () { expect(property.getValue(time, result)).toBe(result); }); + it("getValue uses JulianDate.now() if time parameter is undefined", function () { + spyOn(JulianDate, "now").and.callThrough(); + + const result = "some time independent result"; + const callback = function (_time, _result) { + return result; + }; + const property = new CallbackProperty(callback, true); + const actualResult = property.getValue(); + expect(JulianDate.now).toHaveBeenCalled(); + expect(actualResult).toBe(result); + }); + it("isConstant returns correct value", function () { const property = new CallbackProperty(function () {}, true); expect(property.isConstant).toBe(true); diff --git a/packages/engine/Specs/DataSources/CompositeMaterialPropertySpec.js b/packages/engine/Specs/DataSources/CompositeMaterialPropertySpec.js index c41d56b30224..bec339efa7cf 100644 --- a/packages/engine/Specs/DataSources/CompositeMaterialPropertySpec.js +++ b/packages/engine/Specs/DataSources/CompositeMaterialPropertySpec.js @@ -164,11 +164,12 @@ describe("DataSources/CompositeMaterialProperty", function () { expect(listener.calls.count()).toBe(2); }); - it("getValue throws with no time parameter", function () { + it("getValue uses JulianDate.now() if time parameter is undefined", function () { + spyOn(JulianDate, "now").and.callThrough(); + const property = new CompositeMaterialProperty(); - expect(function () { - property.getValue(undefined); - }).toThrowDeveloperError(); + property.getValue(); + expect(JulianDate.now).toHaveBeenCalled(); }); it("getType throws with no time parameter", function () { diff --git a/packages/engine/Specs/DataSources/CompositePositionPropertySpec.js b/packages/engine/Specs/DataSources/CompositePositionPropertySpec.js index c812e21db846..8d9263c0f7ba 100644 --- a/packages/engine/Specs/DataSources/CompositePositionPropertySpec.js +++ b/packages/engine/Specs/DataSources/CompositePositionPropertySpec.js @@ -272,11 +272,12 @@ describe("DataSources/CompositePositionProperty", function () { expect(left.equals(right)).toEqual(false); }); - it("getValue throws with no time parameter", function () { + it("getValue uses JulianDate.now() if time parameter is undefined", function () { + spyOn(JulianDate, "now").and.callThrough(); + const property = new CompositePositionProperty(); - expect(function () { - property.getValue(undefined); - }).toThrowDeveloperError(); + property.getValue(); + expect(JulianDate.now).toHaveBeenCalled(); }); it("getValueInReferenceFrame throws with no referenceFrame parameter", function () { diff --git a/packages/engine/Specs/DataSources/CompositePropertySpec.js b/packages/engine/Specs/DataSources/CompositePropertySpec.js index cede395cbc1f..bcf83f966316 100644 --- a/packages/engine/Specs/DataSources/CompositePropertySpec.js +++ b/packages/engine/Specs/DataSources/CompositePropertySpec.js @@ -159,10 +159,11 @@ describe("DataSources/CompositeProperty", function () { expect(listener.calls.count()).toBe(2); }); - it("getValue throws with no time parameter", function () { + it("getValue uses JulianDate.now() if time parameter is undefined", function () { + spyOn(JulianDate, "now").and.callThrough(); + const property = new CompositeProperty(); - expect(function () { - property.getValue(undefined); - }).toThrowDeveloperError(); + property.getValue(); + expect(JulianDate.now).toHaveBeenCalled(); }); }); diff --git a/packages/engine/Specs/DataSources/ConstantPositionPropertySpec.js b/packages/engine/Specs/DataSources/ConstantPositionPropertySpec.js index 868b161f2551..7c1442cdef94 100644 --- a/packages/engine/Specs/DataSources/ConstantPositionPropertySpec.js +++ b/packages/engine/Specs/DataSources/ConstantPositionPropertySpec.js @@ -164,11 +164,12 @@ describe("DataSources/ConstantPositionProperty", function () { expect(left.equals(right)).toEqual(false); }); - it("getValue throws without time parameter", function () { + it("getValue uses JulianDate.now() if time parameter is undefined", function () { + spyOn(JulianDate, "now").and.callThrough(); + const property = new ConstantPositionProperty(new Cartesian3(1, 2, 3)); - expect(function () { - property.getValue(undefined); - }).toThrowDeveloperError(); + property.getValue(); + expect(JulianDate.now).toHaveBeenCalled(); }); it("getValueInReferenceFrame throws with no referenceFrame parameter", function () { diff --git a/packages/engine/Specs/DataSources/SampledPositionPropertySpec.js b/packages/engine/Specs/DataSources/SampledPositionPropertySpec.js index 81fde1130959..366de65df190 100644 --- a/packages/engine/Specs/DataSources/SampledPositionPropertySpec.js +++ b/packages/engine/Specs/DataSources/SampledPositionPropertySpec.js @@ -454,11 +454,12 @@ describe("DataSources/SampledPositionProperty", function () { ).toBeUndefined(); }); - it("throws with no time parameter", function () { + it("getValue uses JulianDate.now() if time parameter is undefined", function () { + spyOn(JulianDate, "now").and.callThrough(); + const property = new SampledPositionProperty(); - expect(function () { - property.getValue(undefined); - }).toThrowDeveloperError(); + property.getValue(); + expect(JulianDate.now).toHaveBeenCalled(); }); it("throws with no reference frame parameter", function () { diff --git a/packages/engine/Specs/DataSources/TimeIntervalCollectionPositionPropertySpec.js b/packages/engine/Specs/DataSources/TimeIntervalCollectionPositionPropertySpec.js index df58614475c9..ca98185ffac1 100644 --- a/packages/engine/Specs/DataSources/TimeIntervalCollectionPositionPropertySpec.js +++ b/packages/engine/Specs/DataSources/TimeIntervalCollectionPositionPropertySpec.js @@ -189,11 +189,12 @@ describe("DataSources/TimeIntervalCollectionPositionProperty", function () { expect(result).toBeUndefined(); }); - it("throws with no time parameter", function () { + it("getValue uses JulianDate.now() if time parameter is undefined", function () { + spyOn(JulianDate, "now").and.callThrough(); + const property = new TimeIntervalCollectionPositionProperty(); - expect(function () { - property.getValue(undefined); - }).toThrowDeveloperError(); + property.getValue(); + expect(JulianDate.now).toHaveBeenCalled(); }); it("throws with no reference frame parameter", function () { diff --git a/packages/engine/Specs/DataSources/TimeIntervalCollectionPropertySpec.js b/packages/engine/Specs/DataSources/TimeIntervalCollectionPropertySpec.js index b8347624d87c..0ce39a4dcd28 100644 --- a/packages/engine/Specs/DataSources/TimeIntervalCollectionPropertySpec.js +++ b/packages/engine/Specs/DataSources/TimeIntervalCollectionPropertySpec.js @@ -89,11 +89,12 @@ describe("DataSources/TimeIntervalCollectionProperty", function () { expect(result2).toEqual(interval2.data); }); - it("throws with no time parameter", function () { + it("getValue uses JulianDate.now() if time parameter is undefined", function () { + spyOn(JulianDate, "now").and.callThrough(); + const property = new TimeIntervalCollectionProperty(); - expect(function () { - property.getValue(undefined); - }).toThrowDeveloperError(); + property.getValue(); + expect(JulianDate.now).toHaveBeenCalled(); }); it("equals works for differing basic type intervals", function () { diff --git a/packages/engine/Specs/DataSources/VelocityOrientationPropertySpec.js b/packages/engine/Specs/DataSources/VelocityOrientationPropertySpec.js index ae17da7489b0..75228c1d99d7 100644 --- a/packages/engine/Specs/DataSources/VelocityOrientationPropertySpec.js +++ b/packages/engine/Specs/DataSources/VelocityOrientationPropertySpec.js @@ -215,10 +215,11 @@ describe("DataSources/VelocityOrientationProperty", function () { expect(left.equals(right)).toBe(true); }); - it("getValue throws without time", function () { + it("getValue uses JulianDate.now() if time parameter is undefined", function () { + spyOn(JulianDate, "now").and.callThrough(); + const property = new VelocityOrientationProperty(); - expect(function () { - property.getValue(); - }).toThrowDeveloperError(); + property.getValue(); + expect(JulianDate.now).toHaveBeenCalled(); }); }); diff --git a/packages/engine/Specs/DataSources/VelocityVectorPropertySpec.js b/packages/engine/Specs/DataSources/VelocityVectorPropertySpec.js index 7a65f3b3b3a9..c9d59660e9cc 100644 --- a/packages/engine/Specs/DataSources/VelocityVectorPropertySpec.js +++ b/packages/engine/Specs/DataSources/VelocityVectorPropertySpec.js @@ -241,10 +241,11 @@ describe("DataSources/VelocityVectorProperty", function () { expect(left.equals(right)).toBe(true); }); - it("getValue throws without time", function () { + it("getValue uses JulianDate.now() if time parameter is undefined", function () { + spyOn(JulianDate, "now").and.callThrough(); + const property = new VelocityVectorProperty(); - expect(function () { - property.getValue(); - }).toThrowDeveloperError(); + property.getValue(); + expect(JulianDate.now).toHaveBeenCalled(); }); });