Skip to content

Commit

Permalink
use scratch variable for time parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
anne-gropler committed Aug 1, 2024
1 parent 7b15131 commit 9b45622
Show file tree
Hide file tree
Showing 29 changed files with 85 additions and 31 deletions.
4 changes: 3 additions & 1 deletion packages/engine/Source/DataSources/CallbackProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Object.defineProperties(CallbackProperty.prototype, {
},
});

const timeScratch = new JulianDate();

/**
* Gets the value of the property.
*
Expand All @@ -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);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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 = {};
Expand Down
4 changes: 3 additions & 1 deletion packages/engine/Source/DataSources/ColorMaterialProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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 = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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);
};
Expand Down
6 changes: 4 additions & 2 deletions packages/engine/Source/DataSources/CompositeProperty.js
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -103,6 +103,8 @@ Object.defineProperties(CompositeProperty.prototype, {
},
});

const timeScratch = new JulianDate();

/**
* Gets the value of the property at the provided time.
*
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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);
};
Expand Down
4 changes: 3 additions & 1 deletion packages/engine/Source/DataSources/GridMaterialProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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 = {};
Expand Down
4 changes: 3 additions & 1 deletion packages/engine/Source/DataSources/ImageMaterialProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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)) {
Expand Down
6 changes: 4 additions & 2 deletions packages/engine/Source/DataSources/MaterialProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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 = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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 = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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 = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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 = {};
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/Source/DataSources/PositionProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
4 changes: 3 additions & 1 deletion packages/engine/Source/DataSources/PositionPropertyArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Object.defineProperties(PositionPropertyArray.prototype, {
},
});

const timeScratch = new JulianDate();

/**
* Gets the value of the property.
*
Expand All @@ -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);
};
Expand Down
4 changes: 3 additions & 1 deletion packages/engine/Source/DataSources/PropertyArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Object.defineProperties(PropertyArray.prototype, {
},
});

const timeScratch = new JulianDate();

/**
* Gets the value of the property.
*
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion packages/engine/Source/DataSources/PropertyBag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)) {
Expand Down
4 changes: 3 additions & 1 deletion packages/engine/Source/DataSources/ReferenceProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ Object.defineProperties(SampledPositionProperty.prototype, {
},
});

const timeScratch = new JulianDate();

/**
* Gets the position at the provided time.
*
Expand All @@ -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);
};
Expand Down
Loading

0 comments on commit 9b45622

Please sign in to comment.