From 7b1513134ee185f9c69646c92fdeb9ce7e64a9ab Mon Sep 17 00:00:00 2001 From: Anne Gropler Date: Tue, 30 Jul 2024 14:08:42 +0200 Subject: [PATCH 1/3] Make time parameter optional for all Properties --- CHANGES.md | 1 + .../engine/Source/DataSources/CallbackProperty.js | 8 ++++++-- .../DataSources/CheckerboardMaterialProperty.js | 6 +++++- .../Source/DataSources/ColorMaterialProperty.js | 6 +++++- .../Source/DataSources/CompositeMaterialProperty.js | 7 +++---- .../Source/DataSources/CompositePositionProperty.js | 6 +++++- .../engine/Source/DataSources/CompositeProperty.js | 8 +++----- .../Source/DataSources/ConstantPositionProperty.js | 6 +++++- .../Source/DataSources/GridMaterialProperty.js | 6 +++++- .../Source/DataSources/ImageMaterialProperty.js | 7 ++++++- .../engine/Source/DataSources/MaterialProperty.js | 4 ++++ .../DataSources/NodeTransformationProperty.js | 6 +++++- .../DataSources/PolylineArrowMaterialProperty.js | 6 +++++- .../DataSources/PolylineDashMaterialProperty.js | 6 +++++- .../DataSources/PolylineGlowMaterialProperty.js | 6 +++++- .../DataSources/PolylineOutlineMaterialProperty.js | 6 +++++- .../Source/DataSources/PositionPropertyArray.js | 6 +++++- packages/engine/Source/DataSources/Property.js | 2 +- packages/engine/Source/DataSources/PropertyArray.js | 8 +++----- packages/engine/Source/DataSources/PropertyBag.js | 7 +++---- .../engine/Source/DataSources/ReferenceProperty.js | 6 +++++- .../Source/DataSources/SampledPositionProperty.js | 6 +++++- .../engine/Source/DataSources/SampledProperty.js | 8 ++++---- .../Source/DataSources/ScaledPositionProperty.js | 4 ++++ .../Source/DataSources/StripeMaterialProperty.js | 6 +++++- .../Source/DataSources/TerrainOffsetProperty.js | 7 +++++++ .../TimeIntervalCollectionPositionProperty.js | 6 +++++- .../DataSources/TimeIntervalCollectionProperty.js | 8 +++----- .../DataSources/VelocityOrientationProperty.js | 6 +++++- .../Source/DataSources/VelocityVectorProperty.js | 7 ++----- .../Specs/DataSources/CallbackPropertySpec.js | 13 +++++++++++++ .../DataSources/CompositeMaterialPropertySpec.js | 9 +++++---- .../DataSources/CompositePositionPropertySpec.js | 9 +++++---- .../Specs/DataSources/CompositePropertySpec.js | 9 +++++---- .../DataSources/ConstantPositionPropertySpec.js | 9 +++++---- .../DataSources/SampledPositionPropertySpec.js | 9 +++++---- .../TimeIntervalCollectionPositionPropertySpec.js | 9 +++++---- .../TimeIntervalCollectionPropertySpec.js | 9 +++++---- .../DataSources/VelocityOrientationPropertySpec.js | 9 +++++---- .../Specs/DataSources/VelocityVectorPropertySpec.js | 9 +++++---- 40 files changed, 188 insertions(+), 88 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e43311e3a506..88d45fd3b103 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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: diff --git a/packages/engine/Source/DataSources/CallbackProperty.js b/packages/engine/Source/DataSources/CallbackProperty.js index c3609030cd92..d7c0c829b8a2 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. @@ -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); }; @@ -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. */ diff --git a/packages/engine/Source/DataSources/CheckerboardMaterialProperty.js b/packages/engine/Source/DataSources/CheckerboardMaterialProperty.js index 547e29eafba4..83ff33ea6a77 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"; @@ -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 = {}; } diff --git a/packages/engine/Source/DataSources/ColorMaterialProperty.js b/packages/engine/Source/DataSources/ColorMaterialProperty.js index c6abf36e56d4..bd7a7005c464 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"; @@ -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 = {}; } diff --git a/packages/engine/Source/DataSources/CompositeMaterialProperty.js b/packages/engine/Source/DataSources/CompositeMaterialProperty.js index 7827c7ad61f6..71b2e84b29ea 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"; @@ -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 diff --git a/packages/engine/Source/DataSources/CompositePositionProperty.js b/packages/engine/Source/DataSources/CompositePositionProperty.js index e5e74a7951eb..24744b533b9d 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"; @@ -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); }; diff --git a/packages/engine/Source/DataSources/CompositeProperty.js b/packages/engine/Source/DataSources/CompositeProperty.js index 703d7d5df478..ee23394d3cc7 100644 --- a/packages/engine/Source/DataSources/CompositeProperty.js +++ b/packages/engine/Source/DataSources/CompositeProperty.js @@ -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"; @@ -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)) { diff --git a/packages/engine/Source/DataSources/ConstantPositionProperty.js b/packages/engine/Source/DataSources/ConstantPositionProperty.js index 7fe47c720e81..8cf47910999e 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"; @@ -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); }; diff --git a/packages/engine/Source/DataSources/GridMaterialProperty.js b/packages/engine/Source/DataSources/GridMaterialProperty.js index 1304ddd745e0..b3c33791f145 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"; @@ -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 = {}; } diff --git a/packages/engine/Source/DataSources/ImageMaterialProperty.js b/packages/engine/Source/DataSources/ImageMaterialProperty.js index 5aa8c5b713fa..5d7b249fb5fb 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"; @@ -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 = {}; } diff --git a/packages/engine/Source/DataSources/MaterialProperty.js b/packages/engine/Source/DataSources/MaterialProperty.js index c6a957f79e77..0dc7058b8896 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"; /** @@ -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); diff --git a/packages/engine/Source/DataSources/NodeTransformationProperty.js b/packages/engine/Source/DataSources/NodeTransformationProperty.js index f6513cd05972..cc75e3cb0167 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"; @@ -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(); } diff --git a/packages/engine/Source/DataSources/PolylineArrowMaterialProperty.js b/packages/engine/Source/DataSources/PolylineArrowMaterialProperty.js index 78ad0b87c94d..49071af1c517 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"; @@ -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 = {}; } diff --git a/packages/engine/Source/DataSources/PolylineDashMaterialProperty.js b/packages/engine/Source/DataSources/PolylineDashMaterialProperty.js index 1ff9c6675f99..f41afbb744dc 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"; @@ -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 = {}; } diff --git a/packages/engine/Source/DataSources/PolylineGlowMaterialProperty.js b/packages/engine/Source/DataSources/PolylineGlowMaterialProperty.js index 11ac0f10a9e8..4a88682a74c7 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"; @@ -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 = {}; } diff --git a/packages/engine/Source/DataSources/PolylineOutlineMaterialProperty.js b/packages/engine/Source/DataSources/PolylineOutlineMaterialProperty.js index 27851e59ba78..bd61624b6a01 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"; @@ -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 = {}; } diff --git a/packages/engine/Source/DataSources/PositionPropertyArray.js b/packages/engine/Source/DataSources/PositionPropertyArray.js index ac8853533a67..89b50f4076ad 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"; @@ -79,11 +80,14 @@ Object.defineProperties(PositionPropertyArray.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 {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(); + } 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..8524a703e952 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"; /** @@ -63,16 +63,14 @@ Object.defineProperties(PropertyArray.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, 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(); } - //>>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..2dc54cddf311 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"; @@ -161,17 +162,15 @@ PropertyBag.prototype.removeProperty = function (propertyName) { * 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(); } - //>>includeEnd('debug'); if (!defined(result)) { result = {}; diff --git a/packages/engine/Source/DataSources/ReferenceProperty.js b/packages/engine/Source/DataSources/ReferenceProperty.js index 88218e81d0db..796daf56066e 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) { @@ -257,12 +258,15 @@ ReferenceProperty.fromString = function (targetCollection, referenceString) { /** * 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(); + } 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..7fa4e35b2538 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"; @@ -181,11 +182,14 @@ Object.defineProperties(SampledPositionProperty.prototype, { /** * 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(); + } 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..b5a99d1dd322 100644 --- a/packages/engine/Source/DataSources/SampledProperty.js +++ b/packages/engine/Source/DataSources/SampledProperty.js @@ -362,14 +362,14 @@ Object.defineProperties(SampledProperty.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. */ SampledProperty.prototype.getValue = function (time, result) { - //>>includeStart('debug', pragmas.debug); - Check.defined("time", time); - //>>includeEnd('debug'); + if (!defined(time)) { + time = JulianDate.now(); + } 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..12d2c446bd24 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"; @@ -38,6 +39,9 @@ Object.defineProperties(ScaledPositionProperty.prototype, { }); ScaledPositionProperty.prototype.getValue = function (time, result) { + if (!defined(time)) { + time = JulianDate.now(); + } 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..7c0520516944 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"; @@ -138,11 +139,14 @@ StripeMaterialProperty.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. */ StripeMaterialProperty.prototype.getValue = function (time, result) { + if (!defined(time)) { + time = JulianDate.now(); + } if (!defined(result)) { result = {}; } diff --git a/packages/engine/Source/DataSources/TerrainOffsetProperty.js b/packages/engine/Source/DataSources/TerrainOffsetProperty.js index 42247f453ba8..71cc74fb44df 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, @@ -149,9 +150,15 @@ TerrainOffsetProperty.prototype._updateClamping = function () { /** * 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(); + } + 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..bde198aa5a99 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"; @@ -81,7 +82,7 @@ Object.defineProperties(TimeIntervalCollectionPositionProperty.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 {Cartesian3 | undefined} The modified result parameter or a new instance if the result parameter was not supplied. */ @@ -89,6 +90,9 @@ TimeIntervalCollectionPositionProperty.prototype.getValue = function ( time, result ) { + if (!defined(time)) { + time = JulianDate.now(); + } 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..ed9fb92ccd42 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"; @@ -94,16 +94,14 @@ Object.defineProperties(TimeIntervalCollectionProperty.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. */ TimeIntervalCollectionProperty.prototype.getValue = function (time, result) { - //>>includeStart('debug', pragmas.debug); if (!defined(time)) { - throw new DeveloperError("time is required"); + time = JulianDate.now(); } - //>>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..ae13603e1151 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"; @@ -108,11 +109,14 @@ const rotationScratch = new Matrix3(); /** * 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(); + } 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..e774cf4b8e24 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"; @@ -124,7 +123,7 @@ 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 +139,9 @@ VelocityVectorProperty.prototype._getValue = function ( velocityResult, positionResult ) { - //>>includeStart('debug', pragmas.debug); if (!defined(time)) { - throw new DeveloperError("time is required"); + time = JulianDate.now(); } - //>>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(); }); }); From 9b4562281dd75d79cfa90a0c72dc9c77ea174b9f Mon Sep 17 00:00:00 2001 From: Anne Gropler Date: Thu, 1 Aug 2024 09:59:32 +0200 Subject: [PATCH 2/3] use scratch variable for time parameter --- packages/engine/Source/DataSources/CallbackProperty.js | 4 +++- .../Source/DataSources/CheckerboardMaterialProperty.js | 4 +++- packages/engine/Source/DataSources/ColorMaterialProperty.js | 4 +++- .../engine/Source/DataSources/CompositeMaterialProperty.js | 4 +++- .../engine/Source/DataSources/CompositePositionProperty.js | 4 +++- packages/engine/Source/DataSources/CompositeProperty.js | 6 ++++-- .../engine/Source/DataSources/ConstantPositionProperty.js | 4 +++- packages/engine/Source/DataSources/GridMaterialProperty.js | 4 +++- packages/engine/Source/DataSources/ImageMaterialProperty.js | 4 +++- packages/engine/Source/DataSources/MaterialProperty.js | 6 ++++-- .../engine/Source/DataSources/NodeTransformationProperty.js | 4 +++- .../Source/DataSources/PolylineArrowMaterialProperty.js | 4 +++- .../Source/DataSources/PolylineDashMaterialProperty.js | 4 +++- .../Source/DataSources/PolylineGlowMaterialProperty.js | 4 +++- .../Source/DataSources/PolylineOutlineMaterialProperty.js | 4 +++- packages/engine/Source/DataSources/PositionProperty.js | 2 +- packages/engine/Source/DataSources/PositionPropertyArray.js | 4 +++- packages/engine/Source/DataSources/PropertyArray.js | 4 +++- packages/engine/Source/DataSources/PropertyBag.js | 4 +++- packages/engine/Source/DataSources/ReferenceProperty.js | 4 +++- .../engine/Source/DataSources/SampledPositionProperty.js | 4 +++- packages/engine/Source/DataSources/SampledProperty.js | 4 +++- .../engine/Source/DataSources/ScaledPositionProperty.js | 4 +++- .../engine/Source/DataSources/StripeMaterialProperty.js | 4 +++- packages/engine/Source/DataSources/TerrainOffsetProperty.js | 4 +++- .../DataSources/TimeIntervalCollectionPositionProperty.js | 4 +++- .../Source/DataSources/TimeIntervalCollectionProperty.js | 4 +++- .../Source/DataSources/VelocityOrientationProperty.js | 3 ++- .../engine/Source/DataSources/VelocityVectorProperty.js | 3 ++- 29 files changed, 85 insertions(+), 31 deletions(-) diff --git a/packages/engine/Source/DataSources/CallbackProperty.js b/packages/engine/Source/DataSources/CallbackProperty.js index d7c0c829b8a2..3611241ed407 100644 --- a/packages/engine/Source/DataSources/CallbackProperty.js +++ b/packages/engine/Source/DataSources/CallbackProperty.js @@ -47,6 +47,8 @@ Object.defineProperties(CallbackProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * Gets the value of the property. * @@ -56,7 +58,7 @@ Object.defineProperties(CallbackProperty.prototype, { */ CallbackProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + time = JulianDate.now(timeScratch); } return this._callback(time, result); }; diff --git a/packages/engine/Source/DataSources/CheckerboardMaterialProperty.js b/packages/engine/Source/DataSources/CheckerboardMaterialProperty.js index 83ff33ea6a77..4dfc5c297e18 100644 --- a/packages/engine/Source/DataSources/CheckerboardMaterialProperty.js +++ b/packages/engine/Source/DataSources/CheckerboardMaterialProperty.js @@ -106,6 +106,8 @@ CheckerboardMaterialProperty.prototype.getType = function (time) { return "Checkerboard"; }; +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -115,7 +117,7 @@ CheckerboardMaterialProperty.prototype.getType = function (time) { */ CheckerboardMaterialProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + 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 bd7a7005c464..26928fad14c4 100644 --- a/packages/engine/Source/DataSources/ColorMaterialProperty.js +++ b/packages/engine/Source/DataSources/ColorMaterialProperty.js @@ -70,6 +70,8 @@ ColorMaterialProperty.prototype.getType = function (time) { return "Color"; }; +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -79,7 +81,7 @@ ColorMaterialProperty.prototype.getType = function (time) { */ ColorMaterialProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + 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 71b2e84b29ea..303d90c90c46 100644 --- a/packages/engine/Source/DataSources/CompositeMaterialProperty.js +++ b/packages/engine/Source/DataSources/CompositeMaterialProperty.js @@ -83,6 +83,8 @@ CompositeMaterialProperty.prototype.getType = function (time) { return undefined; }; +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -92,7 +94,7 @@ CompositeMaterialProperty.prototype.getType = function (time) { */ CompositeMaterialProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + time = JulianDate.now(timeScratch); } const innerProperty = this._composite._intervals.findDataForIntervalContainingDate( diff --git a/packages/engine/Source/DataSources/CompositePositionProperty.js b/packages/engine/Source/DataSources/CompositePositionProperty.js index 24744b533b9d..202b6fe43026 100644 --- a/packages/engine/Source/DataSources/CompositePositionProperty.js +++ b/packages/engine/Source/DataSources/CompositePositionProperty.js @@ -83,6 +83,8 @@ Object.defineProperties(CompositePositionProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time in the fixed frame. * @@ -92,7 +94,7 @@ Object.defineProperties(CompositePositionProperty.prototype, { */ CompositePositionProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + 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 ee23394d3cc7..4af69c9f0eed 100644 --- a/packages/engine/Source/DataSources/CompositeProperty.js +++ b/packages/engine/Source/DataSources/CompositeProperty.js @@ -1,7 +1,7 @@ -import { JulianDate } from "@cesium/engine"; import defined from "../Core/defined.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,6 +103,8 @@ Object.defineProperties(CompositeProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -112,7 +114,7 @@ Object.defineProperties(CompositeProperty.prototype, { */ CompositeProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + time = JulianDate.now(timeScratch); } const innerProperty = this._intervals.findDataForIntervalContainingDate(time); diff --git a/packages/engine/Source/DataSources/ConstantPositionProperty.js b/packages/engine/Source/DataSources/ConstantPositionProperty.js index 8cf47910999e..b2a436383bf5 100644 --- a/packages/engine/Source/DataSources/ConstantPositionProperty.js +++ b/packages/engine/Source/DataSources/ConstantPositionProperty.js @@ -66,6 +66,8 @@ Object.defineProperties(ConstantPositionProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time in the fixed frame. * @@ -75,7 +77,7 @@ Object.defineProperties(ConstantPositionProperty.prototype, { */ ConstantPositionProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + 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 b3c33791f145..77ea417ec67c 100644 --- a/packages/engine/Source/DataSources/GridMaterialProperty.js +++ b/packages/engine/Source/DataSources/GridMaterialProperty.js @@ -135,6 +135,8 @@ GridMaterialProperty.prototype.getType = function (time) { return "Grid"; }; +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -144,7 +146,7 @@ GridMaterialProperty.prototype.getType = function (time) { */ GridMaterialProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + 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 5d7b249fb5fb..97f00224bc02 100644 --- a/packages/engine/Source/DataSources/ImageMaterialProperty.js +++ b/packages/engine/Source/DataSources/ImageMaterialProperty.js @@ -115,6 +115,8 @@ ImageMaterialProperty.prototype.getType = function (time) { return "Image"; }; +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -124,7 +126,7 @@ ImageMaterialProperty.prototype.getType = function (time) { */ ImageMaterialProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + time = JulianDate.now(timeScratch); } if (!defined(result)) { diff --git a/packages/engine/Source/DataSources/MaterialProperty.js b/packages/engine/Source/DataSources/MaterialProperty.js index 0dc7058b8896..0c2ec6f866a5 100644 --- a/packages/engine/Source/DataSources/MaterialProperty.js +++ b/packages/engine/Source/DataSources/MaterialProperty.js @@ -63,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. */ @@ -79,13 +79,15 @@ 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(); + time = JulianDate.now(timeScratch); } if (defined(materialProperty)) { diff --git a/packages/engine/Source/DataSources/NodeTransformationProperty.js b/packages/engine/Source/DataSources/NodeTransformationProperty.js index cc75e3cb0167..b71017dc363a 100644 --- a/packages/engine/Source/DataSources/NodeTransformationProperty.js +++ b/packages/engine/Source/DataSources/NodeTransformationProperty.js @@ -93,6 +93,8 @@ Object.defineProperties(NodeTransformationProperty.prototype, { scale: createPropertyDescriptor("scale"), }); +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -102,7 +104,7 @@ Object.defineProperties(NodeTransformationProperty.prototype, { */ NodeTransformationProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + 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 49071af1c517..0550b9f46992 100644 --- a/packages/engine/Source/DataSources/PolylineArrowMaterialProperty.js +++ b/packages/engine/Source/DataSources/PolylineArrowMaterialProperty.js @@ -68,6 +68,8 @@ PolylineArrowMaterialProperty.prototype.getType = function (time) { return "PolylineArrow"; }; +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -77,7 +79,7 @@ PolylineArrowMaterialProperty.prototype.getType = function (time) { */ PolylineArrowMaterialProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + 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 f41afbb744dc..3335017ba128 100644 --- a/packages/engine/Source/DataSources/PolylineDashMaterialProperty.js +++ b/packages/engine/Source/DataSources/PolylineDashMaterialProperty.js @@ -111,6 +111,8 @@ PolylineDashMaterialProperty.prototype.getType = function (time) { return "PolylineDash"; }; +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -120,7 +122,7 @@ PolylineDashMaterialProperty.prototype.getType = function (time) { */ PolylineDashMaterialProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + 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 4a88682a74c7..50b5c2db007a 100644 --- a/packages/engine/Source/DataSources/PolylineGlowMaterialProperty.js +++ b/packages/engine/Source/DataSources/PolylineGlowMaterialProperty.js @@ -96,6 +96,8 @@ PolylineGlowMaterialProperty.prototype.getType = function (time) { return "PolylineGlow"; }; +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -105,7 +107,7 @@ PolylineGlowMaterialProperty.prototype.getType = function (time) { */ PolylineGlowMaterialProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + 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 bd61624b6a01..bb13942d3736 100644 --- a/packages/engine/Source/DataSources/PolylineOutlineMaterialProperty.js +++ b/packages/engine/Source/DataSources/PolylineOutlineMaterialProperty.js @@ -103,6 +103,8 @@ PolylineOutlineMaterialProperty.prototype.getType = function (time) { return "PolylineOutline"; }; +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -112,7 +114,7 @@ PolylineOutlineMaterialProperty.prototype.getType = function (time) { */ PolylineOutlineMaterialProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + 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 89b50f4076ad..fc8c3f4e54b5 100644 --- a/packages/engine/Source/DataSources/PositionPropertyArray.js +++ b/packages/engine/Source/DataSources/PositionPropertyArray.js @@ -77,6 +77,8 @@ Object.defineProperties(PositionPropertyArray.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * Gets the value of the property. * @@ -86,7 +88,7 @@ Object.defineProperties(PositionPropertyArray.prototype, { */ PositionPropertyArray.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + time = JulianDate.now(timeScratch); } return this.getValueInReferenceFrame(time, ReferenceFrame.FIXED, result); }; diff --git a/packages/engine/Source/DataSources/PropertyArray.js b/packages/engine/Source/DataSources/PropertyArray.js index 8524a703e952..b0a1322d865c 100644 --- a/packages/engine/Source/DataSources/PropertyArray.js +++ b/packages/engine/Source/DataSources/PropertyArray.js @@ -60,6 +60,8 @@ Object.defineProperties(PropertyArray.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * Gets the value of the property. * @@ -69,7 +71,7 @@ Object.defineProperties(PropertyArray.prototype, { */ PropertyArray.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + time = JulianDate.now(timeScratch); } const value = this._value; diff --git a/packages/engine/Source/DataSources/PropertyBag.js b/packages/engine/Source/DataSources/PropertyBag.js index 2dc54cddf311..f98a3305aab8 100644 --- a/packages/engine/Source/DataSources/PropertyBag.js +++ b/packages/engine/Source/DataSources/PropertyBag.js @@ -158,6 +158,8 @@ 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. @@ -169,7 +171,7 @@ PropertyBag.prototype.removeProperty = function (propertyName) { */ PropertyBag.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + time = JulianDate.now(timeScratch); } if (!defined(result)) { diff --git a/packages/engine/Source/DataSources/ReferenceProperty.js b/packages/engine/Source/DataSources/ReferenceProperty.js index 796daf56066e..175c3e41705f 100644 --- a/packages/engine/Source/DataSources/ReferenceProperty.js +++ b/packages/engine/Source/DataSources/ReferenceProperty.js @@ -255,6 +255,8 @@ 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. * @@ -265,7 +267,7 @@ ReferenceProperty.fromString = function (targetCollection, referenceString) { ReferenceProperty.prototype.getValue = function (time, result) { const target = resolve(this); if (!defined(time)) { - time = JulianDate.now(); + 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 7fa4e35b2538..fb72ce8aae8f 100644 --- a/packages/engine/Source/DataSources/SampledPositionProperty.js +++ b/packages/engine/Source/DataSources/SampledPositionProperty.js @@ -179,6 +179,8 @@ Object.defineProperties(SampledPositionProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * Gets the position at the provided time. * @@ -188,7 +190,7 @@ Object.defineProperties(SampledPositionProperty.prototype, { */ SampledPositionProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + 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 b5a99d1dd322..2c015283c4f9 100644 --- a/packages/engine/Source/DataSources/SampledProperty.js +++ b/packages/engine/Source/DataSources/SampledProperty.js @@ -359,6 +359,8 @@ Object.defineProperties(SampledProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -368,7 +370,7 @@ Object.defineProperties(SampledProperty.prototype, { */ SampledProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + time = JulianDate.now(timeScratch); } const times = this._times; diff --git a/packages/engine/Source/DataSources/ScaledPositionProperty.js b/packages/engine/Source/DataSources/ScaledPositionProperty.js index 12d2c446bd24..ec89e9386674 100644 --- a/packages/engine/Source/DataSources/ScaledPositionProperty.js +++ b/packages/engine/Source/DataSources/ScaledPositionProperty.js @@ -38,9 +38,11 @@ Object.defineProperties(ScaledPositionProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + ScaledPositionProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + 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 7c0520516944..8fb83fe4f720 100644 --- a/packages/engine/Source/DataSources/StripeMaterialProperty.js +++ b/packages/engine/Source/DataSources/StripeMaterialProperty.js @@ -136,6 +136,8 @@ StripeMaterialProperty.prototype.getType = function (time) { return "Stripe"; }; +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -145,7 +147,7 @@ StripeMaterialProperty.prototype.getType = function (time) { */ StripeMaterialProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + 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 71cc74fb44df..329d1b136a2f 100644 --- a/packages/engine/Source/DataSources/TerrainOffsetProperty.js +++ b/packages/engine/Source/DataSources/TerrainOffsetProperty.js @@ -147,6 +147,8 @@ TerrainOffsetProperty.prototype._updateClamping = function () { ); }; +const timeScratch = new JulianDate(); + /** * Gets the height relative to the terrain based on the positions. * @@ -156,7 +158,7 @@ TerrainOffsetProperty.prototype._updateClamping = function () { */ TerrainOffsetProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + time = JulianDate.now(timeScratch); } const heightReference = Property.getValueOrDefault( diff --git a/packages/engine/Source/DataSources/TimeIntervalCollectionPositionProperty.js b/packages/engine/Source/DataSources/TimeIntervalCollectionPositionProperty.js index bde198aa5a99..7813010f98c4 100644 --- a/packages/engine/Source/DataSources/TimeIntervalCollectionPositionProperty.js +++ b/packages/engine/Source/DataSources/TimeIntervalCollectionPositionProperty.js @@ -79,6 +79,8 @@ Object.defineProperties(TimeIntervalCollectionPositionProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time in the fixed frame. * @@ -91,7 +93,7 @@ TimeIntervalCollectionPositionProperty.prototype.getValue = function ( result ) { if (!defined(time)) { - time = JulianDate.now(); + 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 ed9fb92ccd42..f6325bc8a148 100644 --- a/packages/engine/Source/DataSources/TimeIntervalCollectionProperty.js +++ b/packages/engine/Source/DataSources/TimeIntervalCollectionProperty.js @@ -91,6 +91,8 @@ Object.defineProperties(TimeIntervalCollectionProperty.prototype, { }, }); +const timeScratch = new JulianDate(); + /** * Gets the value of the property at the provided time. * @@ -100,7 +102,7 @@ Object.defineProperties(TimeIntervalCollectionProperty.prototype, { */ TimeIntervalCollectionProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + time = JulianDate.now(timeScratch); } const value = this._intervals.findDataForIntervalContainingDate(time); diff --git a/packages/engine/Source/DataSources/VelocityOrientationProperty.js b/packages/engine/Source/DataSources/VelocityOrientationProperty.js index ae13603e1151..a4ab53537a23 100644 --- a/packages/engine/Source/DataSources/VelocityOrientationProperty.js +++ b/packages/engine/Source/DataSources/VelocityOrientationProperty.js @@ -105,6 +105,7 @@ 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. @@ -115,7 +116,7 @@ const rotationScratch = new Matrix3(); */ VelocityOrientationProperty.prototype.getValue = function (time, result) { if (!defined(time)) { - time = JulianDate.now(); + time = JulianDate.now(timeScratch); } const velocity = this._velocityVectorProperty._getValue( time, diff --git a/packages/engine/Source/DataSources/VelocityVectorProperty.js b/packages/engine/Source/DataSources/VelocityVectorProperty.js index e774cf4b8e24..3d0b9d900c83 100644 --- a/packages/engine/Source/DataSources/VelocityVectorProperty.js +++ b/packages/engine/Source/DataSources/VelocityVectorProperty.js @@ -118,6 +118,7 @@ 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; /** @@ -140,7 +141,7 @@ VelocityVectorProperty.prototype._getValue = function ( positionResult ) { if (!defined(time)) { - time = JulianDate.now(); + time = JulianDate.now(timeNowScratch); } if (!defined(velocityResult)) { From ea3edb3a939b00e7f2880e30af000c520008c215 Mon Sep 17 00:00:00 2001 From: Anne Gropler Date: Fri, 2 Aug 2024 15:30:34 +0200 Subject: [PATCH 3/3] update Changes.md for #12099 --- CHANGES.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index ed8bdbed9720..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 @@ -9,7 +17,6 @@ - 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: