Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | 15x 15x 1x 1x 1x 1x 1x 3x 2x 1x 3x 2x 1x 6x 5x 5x 5x 1x 4x | import Check from "./Check.js";
import DeveloperError from "./DeveloperError.js";
import Spline from "./Spline.js";
/**
* A spline that evaluates to a constant value. Although this follows the {@link Spline} interface,
* it does not maintain an internal array of times since its value never changes.
*
* @alias ConstantSpline
* @constructor
*
* @param {number|Cartesian3|Quaternion} value The constant value that the spline evaluates to.
*
* @example
* const position = new Cesium.Cartesian3(1.0, 2.0, 3.0);
* const spline = new Cesium.ConstantSpline(position);
*
* const p0 = spline.evaluate(0.0);
*
* @see LinearSpline
* @see HermiteSpline
* @see CatmullRomSpline
* @see QuaternionSpline
* @see MorphWeightSpline
*/
function ConstantSpline(value) {
this._value = value;
this._valueType = Spline.getPointType(value);
}
Object.defineProperties(ConstantSpline.prototype, {
/**
* The constant value that the spline evaluates to.
*
* @memberof ConstantSpline.prototype
*
* @type {number|Cartesian3|Quaternion}
* @readonly
*/
value: {
get: function () {
return this._value;
},
},
});
/**
* Finds an index <code>i</code> in <code>times</code> such that the parameter
* <code>time</code> is in the interval <code>[times[i], times[i + 1]]</code>.
*
* Since a constant spline has no internal times array, this will throw an error.
* @function
*
* @param {number} time The time.
*
* @exception {DeveloperError} findTimeInterval cannot be called on a ConstantSpline.
*/
ConstantSpline.prototype.findTimeInterval = function (time) {
//>>includeStart('debug', pragmas.debug);
throw new DeveloperError(
"findTimeInterval cannot be called on a ConstantSpline.",
);
//>>includeEnd('debug');
};
/**
* Wraps the given time to the period covered by the spline.
* @function
*
* @param {number} time The time.
* @return {number} The time, wrapped around to the updated animation.
*/
ConstantSpline.prototype.wrapTime = function (time) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number("time", time);
//>>includeEnd('debug');
return 0.0;
};
/**
* Clamps the given time to the period covered by the spline.
* @function
*
* @param {number} time The time.
* @return {number} The time, clamped to the animation period.
*/
ConstantSpline.prototype.clampTime = function (time) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number("time", time);
//>>includeEnd('debug');
return 0.0;
};
/**
* Evaluates the curve at a given time.
* @function
*
* @param {number} time The time at which to evaluate the curve.
* @param {Cartesian3|Quaternion} [result] The object onto which to store the result.
* @returns {number|Cartesian3|Quaternion} The modified result parameter or the value that the constant spline represents.
*/
ConstantSpline.prototype.evaluate = function (time, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number("time", time);
//>>includeEnd('debug');
const value = this._value;
const ValueType = this._valueType;
if (ValueType === Number) {
return value;
}
return ValueType.clone(value, result);
};
export default ConstantSpline;
|