cesium 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/Cesium.js +5 -2
  3. data/app/assets/javascripts/Core/Cartesian2.js +58 -0
  4. data/app/assets/javascripts/Core/Cartesian3.js +67 -7
  5. data/app/assets/javascripts/Core/Cartesian4.js +63 -0
  6. data/app/assets/javascripts/Core/CatmullRomSpline.js +183 -163
  7. data/app/assets/javascripts/Core/CorridorGeometry.js +2 -2
  8. data/app/assets/javascripts/Core/Ellipsoid.js +16 -0
  9. data/app/assets/javascripts/Core/ExtentGeometry.js +9 -2
  10. data/app/assets/javascripts/Core/ExtentOutlineGeometry.js +2 -2
  11. data/app/assets/javascripts/Core/GeometryPipeline.js +23 -23
  12. data/app/assets/javascripts/Core/HermiteSpline.js +260 -155
  13. data/app/assets/javascripts/Core/IndexDatatype.js +43 -34
  14. data/app/assets/javascripts/Core/LinearSpline.js +118 -0
  15. data/app/assets/javascripts/Core/Math.js +34 -3
  16. data/app/assets/javascripts/Core/Matrix2.js +26 -0
  17. data/app/assets/javascripts/Core/Matrix3.js +98 -0
  18. data/app/assets/javascripts/Core/Matrix4.js +42 -0
  19. data/app/assets/javascripts/Core/ObjectOrientedBoundingBox.js +396 -0
  20. data/app/assets/javascripts/Core/PolygonGeometry.js +87 -47
  21. data/app/assets/javascripts/Core/PolygonGeometryLibrary.js +20 -17
  22. data/app/assets/javascripts/Core/PolygonOutlineGeometry.js +68 -40
  23. data/app/assets/javascripts/Core/PolygonPipeline.js +19 -9
  24. data/app/assets/javascripts/Core/PrimitiveType.js +33 -36
  25. data/app/assets/javascripts/Core/Quaternion.js +147 -1
  26. data/app/assets/javascripts/Core/QuaternionSpline.js +160 -0
  27. data/app/assets/javascripts/Core/Spline.js +121 -0
  28. data/app/assets/javascripts/Core/Transforms.js +0 -2
  29. data/app/assets/javascripts/Core/loadArrayBuffer.js +5 -1
  30. data/app/assets/javascripts/Core/loadBlob.js +5 -1
  31. data/app/assets/javascripts/Core/loadText.js +4 -1
  32. data/app/assets/javascripts/Core/loadWithXhr.js +30 -14
  33. data/app/assets/javascripts/DynamicScene/PolylineOutlineMaterialProperty.js +2 -2
  34. data/app/assets/javascripts/Renderer/AutomaticUniforms.js +41 -41
  35. data/app/assets/javascripts/Renderer/Context.js +171 -201
  36. data/app/assets/javascripts/Renderer/CubeMapFace.js +2 -2
  37. data/app/assets/javascripts/Renderer/DrawCommand.js +2 -2
  38. data/app/assets/javascripts/Renderer/PixelFormat.js +22 -28
  39. data/app/assets/javascripts/Renderer/ShaderProgram.js +65 -46
  40. data/app/assets/javascripts/Renderer/Texture.js +1 -1
  41. data/app/assets/javascripts/Renderer/TextureMagnificationFilter.js +7 -9
  42. data/app/assets/javascripts/Renderer/TextureMinificationFilter.js +19 -25
  43. data/app/assets/javascripts/Renderer/TextureWrap.js +11 -13
  44. data/app/assets/javascripts/Renderer/UniformDatatype.js +29 -29
  45. data/app/assets/javascripts/Renderer/VertexArray.js +43 -35
  46. data/app/assets/javascripts/Scene/ArcGisMapServerImageryProvider.js +1 -2
  47. data/app/assets/javascripts/Scene/BillboardCollection.js +10 -1
  48. data/app/assets/javascripts/Scene/CameraFlightPath.js +58 -101
  49. data/app/assets/javascripts/Scene/CentralBody.js +1 -4
  50. data/app/assets/javascripts/Scene/CentralBodySurface.js +1 -2
  51. data/app/assets/javascripts/Scene/CesiumTerrainProvider.js +1 -2
  52. data/app/assets/javascripts/Scene/CustomSensorVolume.js +17 -3
  53. data/app/assets/javascripts/Scene/EllipsoidPrimitive.js +20 -5
  54. data/app/assets/javascripts/Scene/EllipsoidSurfaceAppearance.js +1 -2
  55. data/app/assets/javascripts/Scene/FrameState.js +1 -3
  56. data/app/assets/javascripts/Scene/GoogleEarthImageryProvider.js +2 -5
  57. data/app/assets/javascripts/Scene/OpenStreetMapImageryProvider.js +1 -2
  58. data/app/assets/javascripts/Scene/OrthographicFrustum.js +1 -2
  59. data/app/assets/javascripts/Scene/PerspectiveOffCenterFrustum.js +1 -2
  60. data/app/assets/javascripts/Scene/Polygon.js +1 -3
  61. data/app/assets/javascripts/Scene/Polyline.js +5 -2
  62. data/app/assets/javascripts/Scene/PolylineCollection.js +4 -6
  63. data/app/assets/javascripts/Scene/Primitive.js +19 -13
  64. data/app/assets/javascripts/Scene/PrimitivePipeline.js +1 -1
  65. data/app/assets/javascripts/Scene/Scene.js +7 -10
  66. data/app/assets/javascripts/Scene/SceneTransforms.js +1 -3
  67. data/app/assets/javascripts/Scene/SceneTransitioner.js +11 -11
  68. data/app/assets/javascripts/Scene/SingleTileImageryProvider.js +1 -2
  69. data/app/assets/javascripts/Scene/TexturePool.js +1 -1
  70. data/app/assets/javascripts/Scene/TileMapServiceImageryProvider.js +1 -2
  71. data/app/assets/javascripts/Scene/VRTheWorldTerrainProvider.js +1 -2
  72. data/app/assets/javascripts/Scene/ViewportQuad.js +1 -3
  73. data/app/assets/javascripts/Scene/WebMapServiceImageryProvider.js +1 -2
  74. data/app/assets/javascripts/ThirdParty/knockout-3.0.0.js +6 -3
  75. data/app/assets/javascripts/Widgets/CesiumWidget/CesiumWidget.js +4 -3
  76. data/app/assets/javascripts/Widgets/SceneModePicker/SceneModePickerViewModel.js +1 -1
  77. data/app/assets/javascripts/Widgets/Viewer/Viewer.js +5 -5
  78. data/app/assets/javascripts/Widgets/Viewer/viewerDragDropMixin.js +13 -13
  79. data/app/assets/javascripts/Widgets/Viewer/viewerDynamicObjectMixin.js +6 -6
  80. data/app/assets/javascripts/Widgets/widgets.css +1 -1
  81. data/lib/cesium/version.rb +1 -1
  82. metadata +6 -3
  83. data/app/assets/javascripts/Core/OrientationInterpolator.js +0 -106
@@ -760,7 +760,7 @@ define(['Core/Cartesian3', 'Core/defaultValue', 'Core/defined', 'Core/DeveloperE
760
760
  // dot > 0, as the dot product approaches 1, the angle between the
761
761
  // quaternions vanishes. use linear interpolation.
762
762
  if (1.0 - dot < CesiumMath.EPSILON6) {
763
- return Quaternion.lerp(start, r, t);
763
+ return Quaternion.lerp(start, r, t, result);
764
764
  }
765
765
 
766
766
  var theta = Math.acos(dot);
@@ -770,6 +770,152 @@ define(['Core/Cartesian3', 'Core/defaultValue', 'Core/defined', 'Core/DeveloperE
770
770
  return Quaternion.multiplyByScalar(result, 1.0 / Math.sin(theta), result);
771
771
  };
772
772
 
773
+ /**
774
+ * The logarithmic quaternion function.
775
+ * @memberof Quaternion
776
+ *
777
+ * @param {Quaternion} quaternion The unit quaternion.
778
+ * @param {Cartesian3} [result] The object onto which to store the result.
779
+ * @returns {Cartesian3} The modified result parameter or a new instance if one was not provided.
780
+ *
781
+ * @exception {DeveloperError} quaternion is required.
782
+ */
783
+ Quaternion.log = function(quaternion, result) {
784
+ if (!defined(quaternion)) {
785
+ throw new DeveloperError('quaternion is required.');
786
+ }
787
+
788
+ var theta = Math.acos(CesiumMath.clamp(quaternion.w, -1.0, 1.0));
789
+ var thetaOverSinTheta = 0.0;
790
+
791
+ if (theta !== 0.0) {
792
+ thetaOverSinTheta = theta / Math.sin(theta);
793
+ }
794
+
795
+ if (!defined(result)) {
796
+ result = new Cartesian3();
797
+ }
798
+
799
+ return Cartesian3.multiplyByScalar(quaternion, thetaOverSinTheta, result);
800
+ };
801
+
802
+ var expScratch = new Cartesian3();
803
+
804
+ /**
805
+ * The exponential quaternion function.
806
+ * @memberof Quaternion
807
+ *
808
+ * @param {Cartesian3} cartesian The cartesian.
809
+ * @param {Quaternion} [result] The object onto which to store the result.
810
+ * @returns {Quaternion} The modified result parameter or a new instance if one was not provided.
811
+ *
812
+ * @exception {DeveloperError} cartesian is required.
813
+ */
814
+ Quaternion.exp = function(cartesian, result) {
815
+ if (!defined(cartesian)) {
816
+ throw new DeveloperError('cartesian is required.');
817
+ }
818
+
819
+ var theta = Cartesian3.magnitude(cartesian);
820
+ var sinThetaOverTheta = 0.0;
821
+
822
+ if (theta !== 0.0) {
823
+ sinThetaOverTheta = Math.sin(theta) / theta;
824
+ }
825
+
826
+ if (!defined(result)) {
827
+ result = new Quaternion();
828
+ }
829
+
830
+ result.x = cartesian.x * sinThetaOverTheta;
831
+ result.y = cartesian.y * sinThetaOverTheta;
832
+ result.z = cartesian.z * sinThetaOverTheta;
833
+ result.w = Math.cos(theta);
834
+
835
+ return result;
836
+ };
837
+
838
+ var squadScratchCartesian0 = new Cartesian3();
839
+ var squadScratchCartesian1 = new Cartesian3();
840
+ var squadScratchQuaternion0 = new Quaternion();
841
+ var squadScratchQuaternion1 = new Quaternion();
842
+
843
+ /**
844
+ * Computes an inner quadrangle point.
845
+ * <p>This will compute quaternions that ensure a squad curve is C<sup>1</sup>.</p>
846
+ * @memberof Quaternion
847
+ *
848
+ * @param {Quaternion} q0 The first quaternion.
849
+ * @param {Quaternion} q1 The second quaternion.
850
+ * @param {Quaternion} q2 The third quaternion.
851
+ * @param {Quaternion} [result] The object onto which to store the result.
852
+ * @returns {Quaternion} The modified result parameter or a new instance if none was provided.
853
+ *
854
+ * @exception {DeveloperError} q0, q1, and q2 are required.
855
+ *
856
+ * @see Quaternion#squad
857
+ */
858
+ Quaternion.innerQuadrangle = function(q0, q1, q2, result) {
859
+ if (!defined(q0) || !defined(q1) || !defined(q2)) {
860
+ throw new DeveloperError('q0, q1, and q2 are required.');
861
+ }
862
+
863
+ var qInv = Quaternion.conjugate(q1, squadScratchQuaternion0);
864
+ Quaternion.multiply(qInv, q2, squadScratchQuaternion1);
865
+ var cart0 = Quaternion.log(squadScratchQuaternion1, squadScratchCartesian0);
866
+
867
+ Quaternion.multiply(qInv, q0, squadScratchQuaternion1);
868
+ var cart1 = Quaternion.log(squadScratchQuaternion1, squadScratchCartesian1);
869
+
870
+ Cartesian3.add(cart0, cart1, cart0);
871
+ Cartesian3.multiplyByScalar(cart0, 0.25, cart0);
872
+ Cartesian3.negate(cart0, cart0);
873
+ Quaternion.exp(cart0, squadScratchQuaternion0);
874
+
875
+ return Quaternion.multiply(q1, squadScratchQuaternion0, result);
876
+ };
877
+
878
+ /**
879
+ * Computes the spherical quadrangle interpolation between quaternions.
880
+ * @memberof Quaternion
881
+ *
882
+ * @param {Quaternion} q0 The first quaternion.
883
+ * @param {Quaternion} q1 The second quaternion.
884
+ * @param {Quaternion} s0 The first inner quadrangle.
885
+ * @param {Quaternion} s1 The second inner quadrangle.
886
+ * @param {Number} t The time in [0,1] used to interpolate.
887
+ * @param {Quaternion} [result] The object onto which to store the result.
888
+ * @returns {Quaternion} The modified result parameter or a new instance if none was provided.
889
+ *
890
+ * @exception {DeveloperError} q0, q1, s0, and s1 are required.
891
+ * @exception {DeveloperError} t is required and must be a number.
892
+ *
893
+ * @see Quaternion#innerQuadrangle
894
+ *
895
+ * @example
896
+ * // 1. compute the squad interpolation between two quaternions on a curve
897
+ * var s0 = Quaternion.innerQuadrangle(quaternions[i - 1], quaternions[i], quaternions[i + 1]);
898
+ * var s1 = Quaternion.innerQuadrangle(quaternions[i], quaternions[i + 1], quaternions[i + 2]);
899
+ * var q = Quaternion.squad(quaternions[i], quaternions[i + 1], s0, s1, t);
900
+ *
901
+ * // 2. compute the squad interpolation as above but where the first quaternion is a end point.
902
+ * var s1 = Quaternion.innerQuadrangle(quaternions[0], quaternions[1], quaternions[2]);
903
+ * var q = Quaternion.squad(quaternions[0], quaternions[1], quaternions[0], s1, t);
904
+ */
905
+ Quaternion.squad = function(q0, q1, s0, s1, t, result) {
906
+ if (!defined(q0) || !defined(q1) || !defined(s0) || !defined(s1)) {
907
+ throw new DeveloperError('q0, q1, s0, and s1 are required.');
908
+ }
909
+
910
+ if (typeof t !== 'number') {
911
+ throw new DeveloperError('t is required and must be a number.');
912
+ }
913
+
914
+ var slerp0 = Quaternion.slerp(q0, q1, t, squadScratchQuaternion0);
915
+ var slerp1 = Quaternion.slerp(s0, s1, t, squadScratchQuaternion1);
916
+ return Quaternion.slerp(slerp0, slerp1, 2.0 * t * (1.0 - t), result);
917
+ };
918
+
773
919
  /**
774
920
  * Compares the provided quaternions componentwise and returns
775
921
  * <code>true</code> if they are equal, <code>false</code> otherwise.
@@ -0,0 +1,160 @@
1
+ /*global define*/
2
+ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/Spline', 'Core/Quaternion'], function(
3
+ defaultValue,
4
+ defined,
5
+ DeveloperError,
6
+ Spline,
7
+ Quaternion) {
8
+ "use strict";
9
+
10
+ function computeInnerQuadrangles(points, firstInnerQuadrangle, lastInnerQuadrangle) {
11
+ var length = points.length;
12
+ var quads = new Array(length);
13
+
14
+ quads[0] = defined(firstInnerQuadrangle) ? firstInnerQuadrangle : points[0];
15
+ quads[length - 1] = defined(lastInnerQuadrangle) ? lastInnerQuadrangle : points[length - 1];
16
+
17
+ for (var i = 1; i < length - 1; ++i) {
18
+ quads[i] = Quaternion.innerQuadrangle(points[i - 1], points[i], points[i + 1]);
19
+ }
20
+
21
+ return quads;
22
+ }
23
+
24
+ function createEvaluateFunction(spline) {
25
+ var points = spline.points;
26
+ var quads = spline.innerQuadrangles;
27
+ var times = spline.times;
28
+
29
+ // use slerp interpolation for 2 points
30
+ if (points.length < 3) {
31
+ var t0 = times[0];
32
+ var invSpan = 1.0 / (times[1] - t0);
33
+
34
+ var q0 = points[0];
35
+ var q1 = points[1];
36
+
37
+ return function(time, result) {
38
+ var u = (time - t0) * invSpan;
39
+ return Quaternion.slerp(q0, q1, u, result);
40
+ };
41
+ }
42
+
43
+ // use quad interpolation for more than 3 points
44
+ return function(time, result) {
45
+ var i = spline._lastTimeIndex = spline.findTimeInterval(time, spline._lastTimeIndex);
46
+ var u = (time - times[i]) / (times[i + 1] - times[i]);
47
+
48
+ var q0 = points[i];
49
+ var q1 = points[i + 1];
50
+ var s0 = quads[i];
51
+ var s1 = quads[i + 1];
52
+
53
+ return Quaternion.squad(q0, q1, s0, s1, u, result);
54
+ };
55
+ }
56
+
57
+ /**
58
+ * A spline that uses spherical quadrangle (squad) interpolation to create a quaternion curve.
59
+ * The generated curve is in the class C<sup>1</sup>.
60
+ *
61
+ * @alias QuaternionSpline
62
+ * @constructor
63
+ *
64
+ * @param {Array} options.times The array of control point times.
65
+ * @param {Array} options.points The array of control points.
66
+ * @param {Quaternion} [options.firstInnerQuadrangle] The inner quadrangle of the curve at the first control point.
67
+ * If the inner quadrangle is not given, it will be estimated.
68
+ * @param {Quaternion} [options.lastInnerQuadrangle] The inner quadrangle of the curve at the last control point.
69
+ * If the inner quadrangle is not given, it will be estimated.
70
+ *
71
+ * @exception {DeveloperError} points is required.
72
+ * @exception {DeveloperError} points.length must be greater than or equal to 2.
73
+ * @exception {DeveloperError} times is required.
74
+ * @exception {DeveloperError} times.length must be equal to points.length.
75
+ */
76
+ var QuaternionSpline = function(options) {
77
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
78
+
79
+ var points = options.points;
80
+ var times = options.times;
81
+ var firstInnerQuadrangle = options.firstInnerQuadrangle;
82
+ var lastInnerQuadrangle = options.lastInnerQuadrangle;
83
+
84
+ if (!defined(points)) {
85
+ throw new DeveloperError('points is required.');
86
+ }
87
+
88
+ if (points.length < 2) {
89
+ throw new DeveloperError('points.length must be greater than or equal to 2.');
90
+ }
91
+
92
+ if (!defined(times)) {
93
+ throw new DeveloperError('times is required.');
94
+ }
95
+
96
+ if (times.length !== points.length) {
97
+ throw new DeveloperError('times.length must be equal to points.length.');
98
+ }
99
+
100
+ var innerQuadrangles = computeInnerQuadrangles(points, firstInnerQuadrangle, lastInnerQuadrangle);
101
+
102
+ /**
103
+ * An array of times for the control points.
104
+ * @type {Array}
105
+ * @readonly
106
+ */
107
+ this.times = times;
108
+
109
+ /**
110
+ * An array of {@link Quaternion} control points.
111
+ * @type {Array}
112
+ * @readonly
113
+ */
114
+ this.points = points;
115
+
116
+ /**
117
+ * An array of {@link Quaternion} inner qradrangles for the control points.
118
+ * @type {Array}
119
+ * @readonly
120
+ */
121
+ this.innerQuadrangles = innerQuadrangles;
122
+
123
+ this._evaluateFunction = createEvaluateFunction(this);
124
+ this._lastTimeIndex = 0;
125
+ };
126
+
127
+ /**
128
+ * Finds an index <code>i</code> in <code>times</code> such that the parameter
129
+ * <code>time</code> is in the interval <code>[times[i], times[i + 1]]</code>.
130
+ * @memberof QuaternionSpline
131
+ *
132
+ * @param {Number} time The time.
133
+ * @returns {Number} The index for the element at the start of the interval.
134
+ *
135
+ * @exception {DeveloperError} time is required.
136
+ * @exception {DeveloperError} time must be in the range <code>[t<sub>0</sub>, t<sub>n</sub>]</code>, where <code>t<sub>0</sub></code>
137
+ * is the first element in the array <code>times</code> and <code>t<sub>n</sub></code> is the last element
138
+ * in the array <code>times</code>.
139
+ */
140
+ QuaternionSpline.prototype.findTimeInterval = Spline.prototype.findTimeInterval;
141
+
142
+ /**
143
+ * Evaluates the curve at a given time.
144
+ * @memberof QuaternionSpline
145
+ *
146
+ * @param {Number} time The time at which to evaluate the curve.
147
+ * @param {Quaternion} [result] The object onto which to store the result.
148
+ * @returns {Quaternion} The modified result parameter or a new instance of the point on the curve at the given time.
149
+ *
150
+ * @exception {DeveloperError} time is required.
151
+ * @exception {DeveloperError} time must be in the range <code>[t<sub>0</sub>, t<sub>n</sub>]</code>, where <code>t<sub>0</sub></code>
152
+ * is the first element in the array <code>times</code> and <code>t<sub>n</sub></code> is the last element
153
+ * in the array <code>times</code>.
154
+ */
155
+ QuaternionSpline.prototype.evaluate = function(time, result) {
156
+ return this._evaluateFunction(time, result);
157
+ };
158
+
159
+ return QuaternionSpline;
160
+ });
@@ -0,0 +1,121 @@
1
+ /*global define*/
2
+ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError'], function(
3
+ defaultValue,
4
+ defined,
5
+ DeveloperError) {
6
+ "use strict";
7
+
8
+ /**
9
+ * Creates a curve parameterized and evaluated by time. This type describes an interface
10
+ * and is not intended to be instantiated directly.
11
+ *
12
+ * @alias Spline
13
+ * @constructor
14
+ *
15
+ * @see CatmullRomSpline
16
+ * @see HermiteSpline
17
+ */
18
+ var Spline = function() {
19
+ /**
20
+ * An array of times for the control points.
21
+ * @type {Array}
22
+ * @default undefined
23
+ */
24
+ this.times = undefined;
25
+
26
+ /**
27
+ * An array of control points.
28
+ * @type {Array}
29
+ * @default undefined
30
+ */
31
+ this.points = undefined;
32
+
33
+ throw new DeveloperError('This type should not be instantiated directly.');
34
+ };
35
+
36
+ /**
37
+ * Evaluates the curve at a given time.
38
+ * @memberof Spline
39
+ *
40
+ * @param {Number} time The time at which to evaluate the curve.
41
+ * @param {Cartesian3|Quaternion} [result] The object onto which to store the result.
42
+ *
43
+ * @returns {Cartesian3|Quaternion} The modified result parameter or a new instance of the point on the curve at the given time.
44
+ *
45
+ * @exception {DeveloperError} time is required.
46
+ * @exception {DeveloperError} time must be in the range <code>[t<sub>0</sub>, t<sub>n</sub>]</code>, where <code>t<sub>0</sub></code>
47
+ * is the first element in the array <code>times</code> and <code>t<sub>n</sub></code> is the last element
48
+ * in the array <code>times</code>.
49
+ */
50
+ Spline.prototype.evaluate = function(time, result) {
51
+ throw new DeveloperError('This type should not be instantiated directly.');
52
+ };
53
+
54
+ /**
55
+ * Finds an index <code>i</code> in <code>times</code> such that the parameter
56
+ * <code>time</code> is in the interval <code>[times[i], times[i + 1]]</code>.
57
+ * @memberof Spline
58
+ *
59
+ * @param {Number} time The time.
60
+ * @param {Number} startIndex The index from which to start the search.
61
+ * @returns {Number} The index for the element at the start of the interval.
62
+ *
63
+ * @exception {DeveloperError} time is required.
64
+ * @exception {DeveloperError} time must be in the range <code>[t<sub>0</sub>, t<sub>n</sub>]</code>, where <code>t<sub>0</sub></code>
65
+ * is the first element in the array <code>times</code> and <code>t<sub>n</sub></code> is the last element
66
+ * in the array <code>times</code>.
67
+ */
68
+ Spline.prototype.findTimeInterval = function(time, startIndex) {
69
+ if (!defined(time)) {
70
+ throw new DeveloperError('time is required.');
71
+ }
72
+
73
+ var times = this.times;
74
+ var length = times.length;
75
+
76
+ if (time < times[0] || time > times[length - 1]) {
77
+ throw new DeveloperError('time is out of range.');
78
+ }
79
+
80
+ // Take advantage of temporal coherence by checking current, next and previous intervals
81
+ // for containment of time.
82
+ startIndex = defaultValue(startIndex, 0);
83
+
84
+ if (time >= times[startIndex]) {
85
+ if (startIndex + 1 < length && time < times[startIndex + 1]) {
86
+ return startIndex;
87
+ } else if (startIndex + 2 < length && time < times[startIndex + 2]) {
88
+ return startIndex + 1;
89
+ }
90
+ } else if (startIndex - 1 >= 0 && time >= times[startIndex - 1]) {
91
+ return startIndex - 1;
92
+ }
93
+
94
+ // The above failed so do a linear search. For the use cases so far, the
95
+ // length of the list is less than 10. In the future, if there is a bottle neck,
96
+ // it might be here.
97
+
98
+ var i;
99
+ if (time > times[startIndex]) {
100
+ for (i = startIndex; i < length - 1; ++i) {
101
+ if (time >= times[i] && time < times[i + 1]) {
102
+ break;
103
+ }
104
+ }
105
+ } else {
106
+ for (i = startIndex - 1; i >= 0; --i) {
107
+ if (time >= times[i] && time < times[i + 1]) {
108
+ break;
109
+ }
110
+ }
111
+ }
112
+
113
+ if (i === length - 1) {
114
+ i = length - 2;
115
+ }
116
+
117
+ return i;
118
+ };
119
+
120
+ return Spline;
121
+ });
@@ -258,7 +258,6 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/Iau200
258
258
  * function updateAndRender() {
259
259
  * var now = new JulianDate();
260
260
  * scene.initializeFrame();
261
- * scene.setSunPosition(Simon1994PlanetaryPositions.ComputeSunPositionInEarthInertialFrame(now));
262
261
  * scene.getCamera().transform = Matrix4.fromRotationTranslation(Transforms.computeTemeToPseudoFixedMatrix(now), Cartesian3.ZERO);
263
262
  * scene.render();
264
263
  * requestAnimationFrame(updateAndRender);
@@ -396,7 +395,6 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/Iau200
396
395
  * function updateAndRender() {
397
396
  * var now = new JulianDate();
398
397
  * scene.initializeFrame();
399
- * scene.setSunPosition(Simon1994PlanetaryPositions.ComputeSunPositionInEarthInertialFrame(now));
400
398
  * var icrfToFixed = Transforms.computeIcrfToFixedMatrix(now);
401
399
  * if (defined(icrfToFixed)) {
402
400
  * scene.getCamera().transform = Matrix4.fromRotationTranslation(icrfToFixed, Cartesian3.ZERO);