123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- import defaultValue from "../Core/defaultValue.js";
- import defined from "../Core/defined.js";
- import DeveloperError from "../Core/DeveloperError.js";
- import CesiumMath from "../Core/Math.js";
- var Rotation = {
-
- packedLength: 1,
-
- pack: function (value, array, startingIndex) {
-
- if (!defined(value)) {
- throw new DeveloperError("value is required");
- }
- if (!defined(array)) {
- throw new DeveloperError("array is required");
- }
-
- startingIndex = defaultValue(startingIndex, 0);
- array[startingIndex] = value;
- return array;
- },
-
- unpack: function (array, startingIndex, result) {
-
- if (!defined(array)) {
- throw new DeveloperError("array is required");
- }
-
- startingIndex = defaultValue(startingIndex, 0);
- return array[startingIndex];
- },
-
- convertPackedArrayForInterpolation: function (
- packedArray,
- startingIndex,
- lastIndex,
- result
- ) {
-
- if (!defined(packedArray)) {
- throw new DeveloperError("packedArray is required");
- }
-
- if (!defined(result)) {
- result = [];
- }
- startingIndex = defaultValue(startingIndex, 0);
- lastIndex = defaultValue(lastIndex, packedArray.length);
- var previousValue;
- for (var i = 0, len = lastIndex - startingIndex + 1; i < len; i++) {
- var value = packedArray[startingIndex + i];
- if (i === 0 || Math.abs(previousValue - value) < Math.PI) {
- result[i] = value;
- } else {
- result[i] = value - CesiumMath.TWO_PI;
- }
- previousValue = value;
- }
- },
-
- unpackInterpolationResult: function (
- array,
- sourceArray,
- firstIndex,
- lastIndex,
- result
- ) {
-
- if (!defined(array)) {
- throw new DeveloperError("array is required");
- }
- if (!defined(sourceArray)) {
- throw new DeveloperError("sourceArray is required");
- }
-
- result = array[0];
- if (result < 0) {
- return result + CesiumMath.TWO_PI;
- }
- return result;
- },
- };
- export default Rotation;
|