cesium 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (491) hide show
  1. data/LICENSE.md +259 -0
  2. data/README.rdoc +90 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/Assets/Assets.profile.js +8 -0
  5. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_0.json +1 -0
  6. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_1.json +1 -0
  7. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_10.json +1 -0
  8. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_11.json +1 -0
  9. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_12.json +1 -0
  10. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_13.json +1 -0
  11. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_14.json +1 -0
  12. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_15.json +1 -0
  13. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_16.json +1 -0
  14. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_17.json +1 -0
  15. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_18.json +1 -0
  16. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_19.json +1 -0
  17. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_2.json +1 -0
  18. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_20.json +1 -0
  19. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_21.json +1 -0
  20. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_22.json +1 -0
  21. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_23.json +1 -0
  22. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_24.json +1 -0
  23. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_25.json +1 -0
  24. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_26.json +1 -0
  25. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_27.json +1 -0
  26. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_3.json +1 -0
  27. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_4.json +1 -0
  28. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_5.json +1 -0
  29. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_6.json +1 -0
  30. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_7.json +1 -0
  31. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_8.json +1 -0
  32. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_9.json +1 -0
  33. data/app/assets/javascripts/Assets/Textures/NE2_LR_LC_SR_W_DR_2048.jpg +0 -0
  34. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_mx.jpg +0 -0
  35. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_my.jpg +0 -0
  36. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_mz.jpg +0 -0
  37. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_px.jpg +0 -0
  38. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_py.jpg +0 -0
  39. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_pz.jpg +0 -0
  40. data/app/assets/javascripts/Assets/Textures/waterNormals.jpg +0 -0
  41. data/app/assets/javascripts/Assets/package.json +6 -0
  42. data/app/assets/javascripts/Cesium.js +320 -0
  43. data/app/assets/javascripts/Core/AnimationController.js +148 -0
  44. data/app/assets/javascripts/Core/AxisAlignedBoundingBox.js +243 -0
  45. data/app/assets/javascripts/Core/BoundingRectangle.js +364 -0
  46. data/app/assets/javascripts/Core/BoundingSphere.js +819 -0
  47. data/app/assets/javascripts/Core/BoxTessellator.js +93 -0
  48. data/app/assets/javascripts/Core/Cartesian2.js +762 -0
  49. data/app/assets/javascripts/Core/Cartesian3.js +861 -0
  50. data/app/assets/javascripts/Core/Cartesian4.js +762 -0
  51. data/app/assets/javascripts/Core/Cartographic.js +211 -0
  52. data/app/assets/javascripts/Core/CatmullRomSpline.js +232 -0
  53. data/app/assets/javascripts/Core/Clock.js +195 -0
  54. data/app/assets/javascripts/Core/ClockRange.js +37 -0
  55. data/app/assets/javascripts/Core/ClockStep.js +32 -0
  56. data/app/assets/javascripts/Core/Color.js +1629 -0
  57. data/app/assets/javascripts/Core/ComponentDatatype.js +119 -0
  58. data/app/assets/javascripts/Core/Core.profile.js +8 -0
  59. data/app/assets/javascripts/Core/CubeMapEllipsoidTessellator.js +198 -0
  60. data/app/assets/javascripts/Core/CubicRealPolynomial.js +251 -0
  61. data/app/assets/javascripts/Core/DefaultProxy.js +30 -0
  62. data/app/assets/javascripts/Core/DeveloperError.js +60 -0
  63. data/app/assets/javascripts/Core/EarthOrientationParameters.js +383 -0
  64. data/app/assets/javascripts/Core/EarthOrientationParametersSample.js +50 -0
  65. data/app/assets/javascripts/Core/Ellipsoid.js +539 -0
  66. data/app/assets/javascripts/Core/EllipsoidTangentPlane.js +207 -0
  67. data/app/assets/javascripts/Core/EllipsoidalOccluder.js +151 -0
  68. data/app/assets/javascripts/Core/EncodedCartesian3.js +197 -0
  69. data/app/assets/javascripts/Core/Enumeration.js +67 -0
  70. data/app/assets/javascripts/Core/Event.js +122 -0
  71. data/app/assets/javascripts/Core/Extent.js +383 -0
  72. data/app/assets/javascripts/Core/ExtentTessellator.js +384 -0
  73. data/app/assets/javascripts/Core/FAR.js +13 -0
  74. data/app/assets/javascripts/Core/FeatureDetection.js +126 -0
  75. data/app/assets/javascripts/Core/Fullscreen.js +235 -0
  76. data/app/assets/javascripts/Core/GeographicProjection.js +107 -0
  77. data/app/assets/javascripts/Core/HermitePolynomialApproximation.js +176 -0
  78. data/app/assets/javascripts/Core/HermiteSpline.js +234 -0
  79. data/app/assets/javascripts/Core/Iau2006XysData.js +259 -0
  80. data/app/assets/javascripts/Core/Iau2006XysSample.js +36 -0
  81. data/app/assets/javascripts/Core/IndexDatatype.js +28 -0
  82. data/app/assets/javascripts/Core/Intersect.js +40 -0
  83. data/app/assets/javascripts/Core/IntersectionTests.js +359 -0
  84. data/app/assets/javascripts/Core/Interval.js +27 -0
  85. data/app/assets/javascripts/Core/Iso8601.js +46 -0
  86. data/app/assets/javascripts/Core/JulianDate.js +1228 -0
  87. data/app/assets/javascripts/Core/KeyboardEventModifier.js +38 -0
  88. data/app/assets/javascripts/Core/LagrangePolynomialApproximation.js +96 -0
  89. data/app/assets/javascripts/Core/LeapSecond.js +158 -0
  90. data/app/assets/javascripts/Core/LinearApproximation.js +98 -0
  91. data/app/assets/javascripts/Core/Math.js +532 -0
  92. data/app/assets/javascripts/Core/Matrix2.js +833 -0
  93. data/app/assets/javascripts/Core/Matrix3.js +1099 -0
  94. data/app/assets/javascripts/Core/Matrix4.js +2164 -0
  95. data/app/assets/javascripts/Core/MeshFilters.js +568 -0
  96. data/app/assets/javascripts/Core/Occluder.js +474 -0
  97. data/app/assets/javascripts/Core/OrientationInterpolator.js +109 -0
  98. data/app/assets/javascripts/Core/PlaneTessellator.js +74 -0
  99. data/app/assets/javascripts/Core/PolygonPipeline.js +792 -0
  100. data/app/assets/javascripts/Core/PolylinePipeline.js +90 -0
  101. data/app/assets/javascripts/Core/PrimitiveType.js +80 -0
  102. data/app/assets/javascripts/Core/QuadraticRealPolynomial.js +146 -0
  103. data/app/assets/javascripts/Core/QuarticRealPolynomial.js +339 -0
  104. data/app/assets/javascripts/Core/Quaternion.js +947 -0
  105. data/app/assets/javascripts/Core/Queue.js +95 -0
  106. data/app/assets/javascripts/Core/Ray.js +64 -0
  107. data/app/assets/javascripts/Core/ReferenceFrame.js +25 -0
  108. data/app/assets/javascripts/Core/RequestErrorEvent.js +35 -0
  109. data/app/assets/javascripts/Core/RuntimeError.js +59 -0
  110. data/app/assets/javascripts/Core/ScreenSpaceEventHandler.js +658 -0
  111. data/app/assets/javascripts/Core/ScreenSpaceEventType.js +149 -0
  112. data/app/assets/javascripts/Core/Shapes.js +230 -0
  113. data/app/assets/javascripts/Core/Spherical.js +192 -0
  114. data/app/assets/javascripts/Core/TaskProcessor.js +131 -0
  115. data/app/assets/javascripts/Core/TimeConstants.js +85 -0
  116. data/app/assets/javascripts/Core/TimeInterval.js +305 -0
  117. data/app/assets/javascripts/Core/TimeIntervalCollection.js +543 -0
  118. data/app/assets/javascripts/Core/TimeStandard.js +31 -0
  119. data/app/assets/javascripts/Core/Tipsify.js +285 -0
  120. data/app/assets/javascripts/Core/Transforms.js +614 -0
  121. data/app/assets/javascripts/Core/TridiagonalSystemSolver.js +102 -0
  122. data/app/assets/javascripts/Core/Visibility.js +38 -0
  123. data/app/assets/javascripts/Core/WebMercatorProjection.js +154 -0
  124. data/app/assets/javascripts/Core/WindingOrder.js +40 -0
  125. data/app/assets/javascripts/Core/binarySearch.js +69 -0
  126. data/app/assets/javascripts/Core/buildModuleUrl.js +77 -0
  127. data/app/assets/javascripts/Core/clone.js +21 -0
  128. data/app/assets/javascripts/Core/combine.js +81 -0
  129. data/app/assets/javascripts/Core/computeSunPosition.js +116 -0
  130. data/app/assets/javascripts/Core/createGuid.js +25 -0
  131. data/app/assets/javascripts/Core/defaultValue.js +22 -0
  132. data/app/assets/javascripts/Core/destroyObject.js +61 -0
  133. data/app/assets/javascripts/Core/freezeObject.js +20 -0
  134. data/app/assets/javascripts/Core/getImagePixels.js +46 -0
  135. data/app/assets/javascripts/Core/isLeapYear.js +30 -0
  136. data/app/assets/javascripts/Core/jsonp.js +116 -0
  137. data/app/assets/javascripts/Core/loadArrayBuffer.js +76 -0
  138. data/app/assets/javascripts/Core/loadImage.js +85 -0
  139. data/app/assets/javascripts/Core/loadJson.js +54 -0
  140. data/app/assets/javascripts/Core/loadText.js +78 -0
  141. data/app/assets/javascripts/Core/loadXML.js +76 -0
  142. data/app/assets/javascripts/Core/package.json +6 -0
  143. data/app/assets/javascripts/Core/pointInsideTriangle2D.js +41 -0
  144. data/app/assets/javascripts/Core/requestAnimationFrame.js +61 -0
  145. data/app/assets/javascripts/Core/throttleRequestByServer.js +74 -0
  146. data/app/assets/javascripts/Core/writeTextToCanvas.js +92 -0
  147. data/app/assets/javascripts/DynamicScene/CompositeDynamicObjectCollection.js +254 -0
  148. data/app/assets/javascripts/DynamicScene/CzmlBoolean.js +57 -0
  149. data/app/assets/javascripts/DynamicScene/CzmlCartesian2.js +96 -0
  150. data/app/assets/javascripts/DynamicScene/CzmlCartesian3.js +99 -0
  151. data/app/assets/javascripts/DynamicScene/CzmlCartographic.js +125 -0
  152. data/app/assets/javascripts/DynamicScene/CzmlColor.js +127 -0
  153. data/app/assets/javascripts/DynamicScene/CzmlDefaults.js +135 -0
  154. data/app/assets/javascripts/DynamicScene/CzmlHorizontalOrigin.js +59 -0
  155. data/app/assets/javascripts/DynamicScene/CzmlImage.js +61 -0
  156. data/app/assets/javascripts/DynamicScene/CzmlLabelStyle.js +59 -0
  157. data/app/assets/javascripts/DynamicScene/CzmlNumber.js +82 -0
  158. data/app/assets/javascripts/DynamicScene/CzmlString.js +56 -0
  159. data/app/assets/javascripts/DynamicScene/CzmlUnitCartesian3.js +99 -0
  160. data/app/assets/javascripts/DynamicScene/CzmlUnitQuaternion.js +172 -0
  161. data/app/assets/javascripts/DynamicScene/CzmlUnitSpherical.js +98 -0
  162. data/app/assets/javascripts/DynamicScene/CzmlVerticalOrigin.js +59 -0
  163. data/app/assets/javascripts/DynamicScene/DynamicBillboard.js +245 -0
  164. data/app/assets/javascripts/DynamicScene/DynamicBillboardVisualizer.js +347 -0
  165. data/app/assets/javascripts/DynamicScene/DynamicColorMaterial.js +78 -0
  166. data/app/assets/javascripts/DynamicScene/DynamicCone.js +291 -0
  167. data/app/assets/javascripts/DynamicScene/DynamicConeVisualizer.js +350 -0
  168. data/app/assets/javascripts/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js +389 -0
  169. data/app/assets/javascripts/DynamicScene/DynamicDirectionsProperty.js +163 -0
  170. data/app/assets/javascripts/DynamicScene/DynamicEllipsoid.js +158 -0
  171. data/app/assets/javascripts/DynamicScene/DynamicEllipsoidVisualizer.js +277 -0
  172. data/app/assets/javascripts/DynamicScene/DynamicImageMaterial.js +136 -0
  173. data/app/assets/javascripts/DynamicScene/DynamicLabel.js +286 -0
  174. data/app/assets/javascripts/DynamicScene/DynamicLabelVisualizer.js +341 -0
  175. data/app/assets/javascripts/DynamicScene/DynamicMaterialProperty.js +125 -0
  176. data/app/assets/javascripts/DynamicScene/DynamicObject.js +364 -0
  177. data/app/assets/javascripts/DynamicScene/DynamicObjectCollection.js +137 -0
  178. data/app/assets/javascripts/DynamicScene/DynamicObjectView.js +299 -0
  179. data/app/assets/javascripts/DynamicScene/DynamicPath.js +214 -0
  180. data/app/assets/javascripts/DynamicScene/DynamicPathVisualizer.js +402 -0
  181. data/app/assets/javascripts/DynamicScene/DynamicPoint.js +184 -0
  182. data/app/assets/javascripts/DynamicScene/DynamicPointVisualizer.js +323 -0
  183. data/app/assets/javascripts/DynamicScene/DynamicPolygon.js +138 -0
  184. data/app/assets/javascripts/DynamicScene/DynamicPolygonVisualizer.js +251 -0
  185. data/app/assets/javascripts/DynamicScene/DynamicPolyline.js +183 -0
  186. data/app/assets/javascripts/DynamicScene/DynamicPolylineVisualizer.js +268 -0
  187. data/app/assets/javascripts/DynamicScene/DynamicPositionProperty.js +525 -0
  188. data/app/assets/javascripts/DynamicScene/DynamicProperty.js +352 -0
  189. data/app/assets/javascripts/DynamicScene/DynamicPyramid.js +204 -0
  190. data/app/assets/javascripts/DynamicScene/DynamicPyramidVisualizer.js +302 -0
  191. data/app/assets/javascripts/DynamicScene/DynamicScene.profile.js +8 -0
  192. data/app/assets/javascripts/DynamicScene/DynamicVertexPositionsProperty.js +199 -0
  193. data/app/assets/javascripts/DynamicScene/ReferenceProperty.js +155 -0
  194. data/app/assets/javascripts/DynamicScene/VisualizerCollection.js +181 -0
  195. data/app/assets/javascripts/DynamicScene/package.json +6 -0
  196. data/app/assets/javascripts/DynamicScene/processCzml.js +77 -0
  197. data/app/assets/javascripts/Renderer/BlendEquation.js +52 -0
  198. data/app/assets/javascripts/Renderer/BlendFunction.js +158 -0
  199. data/app/assets/javascripts/Renderer/BlendingState.js +64 -0
  200. data/app/assets/javascripts/Renderer/Buffer.js +141 -0
  201. data/app/assets/javascripts/Renderer/BufferUsage.js +48 -0
  202. data/app/assets/javascripts/Renderer/ClearCommand.js +40 -0
  203. data/app/assets/javascripts/Renderer/CommandLists.js +42 -0
  204. data/app/assets/javascripts/Renderer/Context.js +2805 -0
  205. data/app/assets/javascripts/Renderer/CubeMap.js +358 -0
  206. data/app/assets/javascripts/Renderer/CubeMapFace.js +202 -0
  207. data/app/assets/javascripts/Renderer/CullFace.js +50 -0
  208. data/app/assets/javascripts/Renderer/DepthFunction.js +95 -0
  209. data/app/assets/javascripts/Renderer/DrawCommand.js +96 -0
  210. data/app/assets/javascripts/Renderer/Framebuffer.js +435 -0
  211. data/app/assets/javascripts/Renderer/MipmapHint.js +50 -0
  212. data/app/assets/javascripts/Renderer/PickFramebuffer.js +178 -0
  213. data/app/assets/javascripts/Renderer/PixelDatatype.js +86 -0
  214. data/app/assets/javascripts/Renderer/PixelFormat.js +113 -0
  215. data/app/assets/javascripts/Renderer/Renderbuffer.js +102 -0
  216. data/app/assets/javascripts/Renderer/RenderbufferFormat.js +77 -0
  217. data/app/assets/javascripts/Renderer/Renderer.profile.js +8 -0
  218. data/app/assets/javascripts/Renderer/ShaderCache.js +121 -0
  219. data/app/assets/javascripts/Renderer/ShaderProgram.js +2402 -0
  220. data/app/assets/javascripts/Renderer/StencilFunction.js +95 -0
  221. data/app/assets/javascripts/Renderer/StencilOperation.js +95 -0
  222. data/app/assets/javascripts/Renderer/Texture.js +395 -0
  223. data/app/assets/javascripts/Renderer/TextureAtlas.js +472 -0
  224. data/app/assets/javascripts/Renderer/TextureAtlasBuilder.js +133 -0
  225. data/app/assets/javascripts/Renderer/TextureMagnificationFilter.js +41 -0
  226. data/app/assets/javascripts/Renderer/TextureMinificationFilter.js +77 -0
  227. data/app/assets/javascripts/Renderer/TextureWrap.js +50 -0
  228. data/app/assets/javascripts/Renderer/UniformDatatype.js +218 -0
  229. data/app/assets/javascripts/Renderer/UniformState.js +799 -0
  230. data/app/assets/javascripts/Renderer/VertexArray.js +365 -0
  231. data/app/assets/javascripts/Renderer/VertexArrayFacade.js +574 -0
  232. data/app/assets/javascripts/Renderer/VertexLayout.js +49 -0
  233. data/app/assets/javascripts/Renderer/loadCubeMap.js +92 -0
  234. data/app/assets/javascripts/Renderer/package.json +6 -0
  235. data/app/assets/javascripts/Scene/AnimationCollection.js +249 -0
  236. data/app/assets/javascripts/Scene/ArcGisMapServerImageryProvider.js +384 -0
  237. data/app/assets/javascripts/Scene/Billboard.js +680 -0
  238. data/app/assets/javascripts/Scene/BillboardCollection.js +1209 -0
  239. data/app/assets/javascripts/Scene/BingMapsImageryProvider.js +460 -0
  240. data/app/assets/javascripts/Scene/BingMapsStyle.js +55 -0
  241. data/app/assets/javascripts/Scene/Camera.js +358 -0
  242. data/app/assets/javascripts/Scene/CameraColumbusViewMode.js +30 -0
  243. data/app/assets/javascripts/Scene/CameraController.js +1258 -0
  244. data/app/assets/javascripts/Scene/CameraEventAggregator.js +270 -0
  245. data/app/assets/javascripts/Scene/CameraEventType.js +53 -0
  246. data/app/assets/javascripts/Scene/CameraFlightPath.js +495 -0
  247. data/app/assets/javascripts/Scene/CentralBody.js +817 -0
  248. data/app/assets/javascripts/Scene/CentralBodySurface.js +1120 -0
  249. data/app/assets/javascripts/Scene/CentralBodySurfaceShaderSet.js +107 -0
  250. data/app/assets/javascripts/Scene/ComplexConicSensorVolume.js +511 -0
  251. data/app/assets/javascripts/Scene/CompositePrimitive.js +454 -0
  252. data/app/assets/javascripts/Scene/CullingVolume.js +59 -0
  253. data/app/assets/javascripts/Scene/CustomSensorVolume.js +440 -0
  254. data/app/assets/javascripts/Scene/DiscardMissingTileImagePolicy.js +134 -0
  255. data/app/assets/javascripts/Scene/EllipsoidPrimitive.js +412 -0
  256. data/app/assets/javascripts/Scene/EllipsoidTerrainProvider.js +182 -0
  257. data/app/assets/javascripts/Scene/FrameState.js +86 -0
  258. data/app/assets/javascripts/Scene/FrustumCommands.js +32 -0
  259. data/app/assets/javascripts/Scene/GeographicTilingScheme.js +265 -0
  260. data/app/assets/javascripts/Scene/HorizontalOrigin.js +39 -0
  261. data/app/assets/javascripts/Scene/Imagery.js +85 -0
  262. data/app/assets/javascripts/Scene/ImageryLayer.js +876 -0
  263. data/app/assets/javascripts/Scene/ImageryLayerCollection.js +403 -0
  264. data/app/assets/javascripts/Scene/ImageryProvider.js +185 -0
  265. data/app/assets/javascripts/Scene/ImageryProviderError.js +149 -0
  266. data/app/assets/javascripts/Scene/ImageryState.js +20 -0
  267. data/app/assets/javascripts/Scene/Label.js +706 -0
  268. data/app/assets/javascripts/Scene/LabelCollection.js +697 -0
  269. data/app/assets/javascripts/Scene/LabelStyle.js +39 -0
  270. data/app/assets/javascripts/Scene/Material.js +1177 -0
  271. data/app/assets/javascripts/Scene/NeverTileDiscardPolicy.js +38 -0
  272. data/app/assets/javascripts/Scene/OpenStreetMapImageryProvider.js +282 -0
  273. data/app/assets/javascripts/Scene/OrthographicFrustum.js +345 -0
  274. data/app/assets/javascripts/Scene/PerformanceDisplay.js +183 -0
  275. data/app/assets/javascripts/Scene/PerspectiveFrustum.js +239 -0
  276. data/app/assets/javascripts/Scene/PerspectiveOffCenterFrustum.js +394 -0
  277. data/app/assets/javascripts/Scene/Polygon.js +886 -0
  278. data/app/assets/javascripts/Scene/Polyline.js +441 -0
  279. data/app/assets/javascripts/Scene/PolylineCollection.js +1532 -0
  280. data/app/assets/javascripts/Scene/Projections.js +93 -0
  281. data/app/assets/javascripts/Scene/RectangularPyramidSensorVolume.js +224 -0
  282. data/app/assets/javascripts/Scene/Scene.js +632 -0
  283. data/app/assets/javascripts/Scene/Scene.profile.js +8 -0
  284. data/app/assets/javascripts/Scene/SceneMode.js +51 -0
  285. data/app/assets/javascripts/Scene/SceneTransitioner.js +776 -0
  286. data/app/assets/javascripts/Scene/ScreenSpaceCameraController.js +1063 -0
  287. data/app/assets/javascripts/Scene/SensorVolumeCollection.js +192 -0
  288. data/app/assets/javascripts/Scene/SingleTileImageryProvider.js +295 -0
  289. data/app/assets/javascripts/Scene/SkyAtmosphere.js +239 -0
  290. data/app/assets/javascripts/Scene/SkyBox.js +231 -0
  291. data/app/assets/javascripts/Scene/TerrainProvider.js +229 -0
  292. data/app/assets/javascripts/Scene/TexturePool.js +154 -0
  293. data/app/assets/javascripts/Scene/Tile.js +322 -0
  294. data/app/assets/javascripts/Scene/TileDiscardPolicy.js +42 -0
  295. data/app/assets/javascripts/Scene/TileImagery.js +36 -0
  296. data/app/assets/javascripts/Scene/TileLoadQueue.js +123 -0
  297. data/app/assets/javascripts/Scene/TileMapServiceImageryProvider.js +337 -0
  298. data/app/assets/javascripts/Scene/TileReplacementQueue.js +139 -0
  299. data/app/assets/javascripts/Scene/TileState.js +19 -0
  300. data/app/assets/javascripts/Scene/TilingScheme.js +213 -0
  301. data/app/assets/javascripts/Scene/VerticalOrigin.js +39 -0
  302. data/app/assets/javascripts/Scene/ViewportQuad.js +256 -0
  303. data/app/assets/javascripts/Scene/WebMapServiceImageryProvider.js +374 -0
  304. data/app/assets/javascripts/Scene/WebMercatorTilingScheme.js +291 -0
  305. data/app/assets/javascripts/Scene/package.json +6 -0
  306. data/app/assets/javascripts/Shaders/BillboardCollectionFS.glsl +30 -0
  307. data/app/assets/javascripts/Shaders/BillboardCollectionFS.js +31 -0
  308. data/app/assets/javascripts/Shaders/BillboardCollectionVS.glsl +68 -0
  309. data/app/assets/javascripts/Shaders/BillboardCollectionVS.js +54 -0
  310. data/app/assets/javascripts/Shaders/BuiltinFunctions.glsl +927 -0
  311. data/app/assets/javascripts/Shaders/BuiltinFunctions.js +322 -0
  312. data/app/assets/javascripts/Shaders/CentralBodyFS.glsl +106 -0
  313. data/app/assets/javascripts/Shaders/CentralBodyFS.js +82 -0
  314. data/app/assets/javascripts/Shaders/CentralBodyFSDepth.glsl +20 -0
  315. data/app/assets/javascripts/Shaders/CentralBodyFSDepth.js +22 -0
  316. data/app/assets/javascripts/Shaders/CentralBodyFSPole.glsl +29 -0
  317. data/app/assets/javascripts/Shaders/CentralBodyFSPole.js +28 -0
  318. data/app/assets/javascripts/Shaders/CentralBodyVS.glsl +88 -0
  319. data/app/assets/javascripts/Shaders/CentralBodyVS.js +69 -0
  320. data/app/assets/javascripts/Shaders/CentralBodyVSDepth.glsl +9 -0
  321. data/app/assets/javascripts/Shaders/CentralBodyVSDepth.js +13 -0
  322. data/app/assets/javascripts/Shaders/CentralBodyVSPole.glsl +12 -0
  323. data/app/assets/javascripts/Shaders/CentralBodyVSPole.js +15 -0
  324. data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeFS.glsl +448 -0
  325. data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeFS.js +361 -0
  326. data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeVS.glsl +19 -0
  327. data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeVS.js +20 -0
  328. data/app/assets/javascripts/Shaders/ConstructiveSolidGeometry.glsl +886 -0
  329. data/app/assets/javascripts/Shaders/ConstructiveSolidGeometry.js +586 -0
  330. data/app/assets/javascripts/Shaders/CustomSensorVolumeFS.glsl +126 -0
  331. data/app/assets/javascripts/Shaders/CustomSensorVolumeFS.js +95 -0
  332. data/app/assets/javascripts/Shaders/CustomSensorVolumeVS.glsl +14 -0
  333. data/app/assets/javascripts/Shaders/CustomSensorVolumeVS.js +18 -0
  334. data/app/assets/javascripts/Shaders/EllipsoidFS.glsl +40 -0
  335. data/app/assets/javascripts/Shaders/EllipsoidFS.js +38 -0
  336. data/app/assets/javascripts/Shaders/EllipsoidVS.glsl +26 -0
  337. data/app/assets/javascripts/Shaders/EllipsoidVS.js +16 -0
  338. data/app/assets/javascripts/Shaders/Materials/AsphaltMaterial.glsl +25 -0
  339. data/app/assets/javascripts/Shaders/Materials/AsphaltMaterial.js +23 -0
  340. data/app/assets/javascripts/Shaders/Materials/BlobMaterial.glsl +18 -0
  341. data/app/assets/javascripts/Shaders/Materials/BlobMaterial.js +19 -0
  342. data/app/assets/javascripts/Shaders/Materials/BrickMaterial.glsl +42 -0
  343. data/app/assets/javascripts/Shaders/Materials/BrickMaterial.js +36 -0
  344. data/app/assets/javascripts/Shaders/Materials/BumpMapMaterial.glsl +29 -0
  345. data/app/assets/javascripts/Shaders/Materials/BumpMapMaterial.js +27 -0
  346. data/app/assets/javascripts/Shaders/Materials/CementMaterial.glsl +19 -0
  347. data/app/assets/javascripts/Shaders/Materials/CementMaterial.js +20 -0
  348. data/app/assets/javascripts/Shaders/Materials/CheckerboardMaterial.glsl +38 -0
  349. data/app/assets/javascripts/Shaders/Materials/CheckerboardMaterial.js +32 -0
  350. data/app/assets/javascripts/Shaders/Materials/DotMaterial.glsl +17 -0
  351. data/app/assets/javascripts/Shaders/Materials/DotMaterial.js +18 -0
  352. data/app/assets/javascripts/Shaders/Materials/ErosionMaterial.glsl +23 -0
  353. data/app/assets/javascripts/Shaders/Materials/ErosionMaterial.js +24 -0
  354. data/app/assets/javascripts/Shaders/Materials/FacetMaterial.glsl +18 -0
  355. data/app/assets/javascripts/Shaders/Materials/FacetMaterial.js +19 -0
  356. data/app/assets/javascripts/Shaders/Materials/FresnelMaterial.glsl +12 -0
  357. data/app/assets/javascripts/Shaders/Materials/FresnelMaterial.js +15 -0
  358. data/app/assets/javascripts/Shaders/Materials/GrassMaterial.glsl +28 -0
  359. data/app/assets/javascripts/Shaders/Materials/GrassMaterial.js +26 -0
  360. data/app/assets/javascripts/Shaders/Materials/NormalMapMaterial.glsl +19 -0
  361. data/app/assets/javascripts/Shaders/Materials/NormalMapMaterial.js +21 -0
  362. data/app/assets/javascripts/Shaders/Materials/ReflectionMaterial.glsl +13 -0
  363. data/app/assets/javascripts/Shaders/Materials/ReflectionMaterial.js +16 -0
  364. data/app/assets/javascripts/Shaders/Materials/RefractionMaterial.glsl +14 -0
  365. data/app/assets/javascripts/Shaders/Materials/RefractionMaterial.js +17 -0
  366. data/app/assets/javascripts/Shaders/Materials/RimLightingMaterial.glsl +18 -0
  367. data/app/assets/javascripts/Shaders/Materials/RimLightingMaterial.js +19 -0
  368. data/app/assets/javascripts/Shaders/Materials/StripeMaterial.glsl +29 -0
  369. data/app/assets/javascripts/Shaders/Materials/StripeMaterial.js +26 -0
  370. data/app/assets/javascripts/Shaders/Materials/TieDyeMaterial.glsl +17 -0
  371. data/app/assets/javascripts/Shaders/Materials/TieDyeMaterial.js +19 -0
  372. data/app/assets/javascripts/Shaders/Materials/Water.glsl +91 -0
  373. data/app/assets/javascripts/Shaders/Materials/Water.js +60 -0
  374. data/app/assets/javascripts/Shaders/Materials/WoodMaterial.glsl +36 -0
  375. data/app/assets/javascripts/Shaders/Materials/WoodMaterial.js +31 -0
  376. data/app/assets/javascripts/Shaders/Noise.glsl +453 -0
  377. data/app/assets/javascripts/Shaders/Noise.js +242 -0
  378. data/app/assets/javascripts/Shaders/PolygonFS.glsl +27 -0
  379. data/app/assets/javascripts/Shaders/PolygonFS.js +23 -0
  380. data/app/assets/javascripts/Shaders/PolygonFSPick.glsl +6 -0
  381. data/app/assets/javascripts/Shaders/PolygonFSPick.js +11 -0
  382. data/app/assets/javascripts/Shaders/PolygonVS.glsl +38 -0
  383. data/app/assets/javascripts/Shaders/PolygonVS.js +39 -0
  384. data/app/assets/javascripts/Shaders/PolygonVSPick.glsl +30 -0
  385. data/app/assets/javascripts/Shaders/PolygonVSPick.js +32 -0
  386. data/app/assets/javascripts/Shaders/PolylineFS.glsl +6 -0
  387. data/app/assets/javascripts/Shaders/PolylineFS.js +11 -0
  388. data/app/assets/javascripts/Shaders/PolylineVS.glsl +34 -0
  389. data/app/assets/javascripts/Shaders/PolylineVS.js +35 -0
  390. data/app/assets/javascripts/Shaders/Ray.glsl +532 -0
  391. data/app/assets/javascripts/Shaders/Ray.js +357 -0
  392. data/app/assets/javascripts/Shaders/ReprojectWebMercatorFS.glsl +26 -0
  393. data/app/assets/javascripts/Shaders/ReprojectWebMercatorFS.js +22 -0
  394. data/app/assets/javascripts/Shaders/ReprojectWebMercatorVS.glsl +11 -0
  395. data/app/assets/javascripts/Shaders/ReprojectWebMercatorVS.js +14 -0
  396. data/app/assets/javascripts/Shaders/SensorVolume.glsl +43 -0
  397. data/app/assets/javascripts/Shaders/SensorVolume.js +31 -0
  398. data/app/assets/javascripts/Shaders/Shaders.profile.js +8 -0
  399. data/app/assets/javascripts/Shaders/SkyAtmosphereFS.glsl +70 -0
  400. data/app/assets/javascripts/Shaders/SkyAtmosphereFS.js +62 -0
  401. data/app/assets/javascripts/Shaders/SkyAtmosphereVS.glsl +131 -0
  402. data/app/assets/javascripts/Shaders/SkyAtmosphereVS.js +115 -0
  403. data/app/assets/javascripts/Shaders/SkyBoxFS.glsl +10 -0
  404. data/app/assets/javascripts/Shaders/SkyBoxFS.js +14 -0
  405. data/app/assets/javascripts/Shaders/SkyBoxVS.glsl +10 -0
  406. data/app/assets/javascripts/Shaders/SkyBoxVS.js +14 -0
  407. data/app/assets/javascripts/Shaders/ViewportQuadFS.glsl +16 -0
  408. data/app/assets/javascripts/Shaders/ViewportQuadFS.js +17 -0
  409. data/app/assets/javascripts/Shaders/ViewportQuadVS.glsl +10 -0
  410. data/app/assets/javascripts/Shaders/ViewportQuadVS.js +14 -0
  411. data/app/assets/javascripts/Shaders/package.json +6 -0
  412. data/app/assets/javascripts/ThirdParty/ThirdParty.profile.js +8 -0
  413. data/app/assets/javascripts/ThirdParty/Tween.js +678 -0
  414. data/app/assets/javascripts/ThirdParty/Uri.js +277 -0
  415. data/app/assets/javascripts/ThirdParty/measureText.js +197 -0
  416. data/app/assets/javascripts/ThirdParty/package.json +6 -0
  417. data/app/assets/javascripts/ThirdParty/sprintf.js +319 -0
  418. data/app/assets/javascripts/ThirdParty/when.js +748 -0
  419. data/app/assets/javascripts/Widgets/Dojo/CesiumViewerWidget.css +175 -0
  420. data/app/assets/javascripts/Widgets/Dojo/CesiumViewerWidget.html +52 -0
  421. data/app/assets/javascripts/Widgets/Dojo/CesiumViewerWidget.js +1237 -0
  422. data/app/assets/javascripts/Widgets/Dojo/CesiumWidget.html +4 -0
  423. data/app/assets/javascripts/Widgets/Dojo/CesiumWidget.js +349 -0
  424. data/app/assets/javascripts/Widgets/Dojo/TimelineWidget.css +1 -0
  425. data/app/assets/javascripts/Widgets/Dojo/TimelineWidget.js +47 -0
  426. data/app/assets/javascripts/Widgets/Dojo/checkForChromeFrame.js +71 -0
  427. data/app/assets/javascripts/Widgets/Images/Bing_Logo_51x19_White.png +0 -0
  428. data/app/assets/javascripts/Widgets/Images/Cesium_Logo_overlay.png +0 -0
  429. data/app/assets/javascripts/Widgets/Images/TimelineIcons.png +0 -0
  430. data/app/assets/javascripts/Widgets/Images/ajax-loader.gif +0 -0
  431. data/app/assets/javascripts/Widgets/Images/animationBar.png +0 -0
  432. data/app/assets/javascripts/Widgets/Images/viewControlBar.png +0 -0
  433. data/app/assets/javascripts/Widgets/Timeline.css +113 -0
  434. data/app/assets/javascripts/Widgets/Timeline.js +629 -0
  435. data/app/assets/javascripts/Widgets/TimelineHighlightRange.js +51 -0
  436. data/app/assets/javascripts/Widgets/TimelineTrack.js +54 -0
  437. data/app/assets/javascripts/Widgets/Widgets.profile.js +8 -0
  438. data/app/assets/javascripts/Widgets/package.json +6 -0
  439. data/app/assets/javascripts/Workers/Workers.profile.js +8 -0
  440. data/app/assets/javascripts/Workers/cesiumWorkerBootstrapper.js +2015 -0
  441. data/app/assets/javascripts/Workers/createTaskProcessorWorker.js +55 -0
  442. data/app/assets/javascripts/Workers/createVerticesFromExtent.js +24 -0
  443. data/app/assets/javascripts/Workers/package.json +6 -0
  444. data/app/assets/javascripts/copyrightHeader.js +22 -0
  445. data/app/assets/javascripts/main.js +10 -0
  446. data/app/assets/stylesheets/cesium.css +4 -0
  447. data/app/controllers/cesium_controller.rb +4 -0
  448. data/app/helpers/cesium_helper.rb +2 -0
  449. data/app/views/cesium/index.html.erb +3 -0
  450. data/config/routes.rb +3 -0
  451. data/lib/cesium.rb +4 -0
  452. data/lib/cesium/engine.rb +4 -0
  453. data/lib/cesium/version.rb +3 -0
  454. data/lib/tasks/cesium_tasks.rake +4 -0
  455. data/test/cesium_test.rb +7 -0
  456. data/test/dummy/README.rdoc +261 -0
  457. data/test/dummy/Rakefile +7 -0
  458. data/test/dummy/app/assets/javascripts/adapters/jquery-adapter.js.coffee +4 -0
  459. data/test/dummy/app/assets/javascripts/app.js.coffee +11 -0
  460. data/test/dummy/app/assets/javascripts/application.js.coffee +73 -0
  461. data/test/dummy/app/assets/stylesheets/application.css +12 -0
  462. data/test/dummy/app/controllers/application_controller.rb +4 -0
  463. data/test/dummy/app/helpers/application_helper.rb +2 -0
  464. data/test/dummy/app/views/layouts/application.html.erb +21 -0
  465. data/test/dummy/config.ru +4 -0
  466. data/test/dummy/config/application.rb +59 -0
  467. data/test/dummy/config/boot.rb +10 -0
  468. data/test/dummy/config/database.yml +25 -0
  469. data/test/dummy/config/environment.rb +5 -0
  470. data/test/dummy/config/environments/development.rb +37 -0
  471. data/test/dummy/config/environments/production.rb +67 -0
  472. data/test/dummy/config/environments/test.rb +37 -0
  473. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  474. data/test/dummy/config/initializers/inflections.rb +15 -0
  475. data/test/dummy/config/initializers/mime_types.rb +5 -0
  476. data/test/dummy/config/initializers/secret_token.rb +7 -0
  477. data/test/dummy/config/initializers/session_store.rb +8 -0
  478. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  479. data/test/dummy/config/locales/en.yml +5 -0
  480. data/test/dummy/config/requirejs.yml +10 -0
  481. data/test/dummy/config/routes.rb +3 -0
  482. data/test/dummy/public/404.html +26 -0
  483. data/test/dummy/public/422.html +26 -0
  484. data/test/dummy/public/500.html +25 -0
  485. data/test/dummy/public/favicon.ico +0 -0
  486. data/test/dummy/script/rails +6 -0
  487. data/test/functional/cesium_controller_test.rb +9 -0
  488. data/test/integration/navigation_test.rb +10 -0
  489. data/test/test_helper.rb +15 -0
  490. data/test/unit/helpers/cesium_helper_test.rb +4 -0
  491. metadata +641 -0
@@ -0,0 +1,55 @@
1
+ /*global define*/
2
+ define(['../Core/Enumeration'], function(Enumeration) {
3
+ "use strict";
4
+
5
+ /**
6
+ * An enumeration of the types of imagery provided by Bing Maps.
7
+ *
8
+ * @exports BingMapsStyle
9
+ *
10
+ * @see BingMapsImageryProvider
11
+ */
12
+ var BingMapsStyle = {
13
+ /**
14
+ * Aerial imagery.
15
+ *
16
+ * @constant
17
+ * @type {Enumeration}
18
+ */
19
+ AERIAL : new Enumeration(0, 'AERIAL', { imagerySetName : 'Aerial' }),
20
+
21
+ /**
22
+ * Aerial imagery with a road overlay.
23
+ *
24
+ * @constant
25
+ * @type {Enumeration}
26
+ */
27
+ AERIAL_WITH_LABELS : new Enumeration(1, 'AERIAL_WITH_LABELS', { imagerySetName : 'AerialWithLabels' }),
28
+
29
+ /**
30
+ * Roads without additional imagery.
31
+ *
32
+ * @constant
33
+ * @type {Enumeration}
34
+ */
35
+ ROAD : new Enumeration(2, 'ROAD', { imagerySetName : 'Road' }),
36
+
37
+ /**
38
+ * Ordnance Survey imagery
39
+ *
40
+ * @constant
41
+ * @type {Enumeration}
42
+ */
43
+ ORDNANCE_SURVEY : new Enumeration(3, 'ORDNANCE_SURVEY', { imagerySetName : 'OrdnanceSurvey' }),
44
+
45
+ /**
46
+ * Collins Bart imagery.
47
+ *
48
+ * @constant
49
+ * @type {Enumeration}
50
+ */
51
+ COLLINS_BART : new Enumeration(4, 'COLLINS_BART', { imagerySetName : 'CollinsBart' })
52
+ };
53
+
54
+ return BingMapsStyle;
55
+ });
@@ -0,0 +1,358 @@
1
+ /*global define*/
2
+ define([
3
+ '../Core/DeveloperError',
4
+ '../Core/Math',
5
+ '../Core/Ellipsoid',
6
+ '../Core/Cartesian3',
7
+ '../Core/Cartesian4',
8
+ '../Core/Matrix4',
9
+ '../Core/Ray',
10
+ './CameraController',
11
+ './PerspectiveFrustum'
12
+ ], function(
13
+ DeveloperError,
14
+ CesiumMath,
15
+ Ellipsoid,
16
+ Cartesian3,
17
+ Cartesian4,
18
+ Matrix4,
19
+ Ray,
20
+ CameraController,
21
+ PerspectiveFrustum) {
22
+ "use strict";
23
+
24
+ /**
25
+ * The camera is defined by a position, orientation, and view frustum.
26
+ * <br /><br />
27
+ * The orientation forms an orthonormal basis with a view, up and right = view x up unit vectors.
28
+ * <br /><br />
29
+ * The viewing frustum is defined by 6 planes.
30
+ * Each plane is represented by a {Cartesian4} object, where the x, y, and z components
31
+ * define the unit vector normal to the plane, and the w component is the distance of the
32
+ * plane from the origin/camera position.
33
+ *
34
+ * @alias Camera
35
+ *
36
+ * @exception {DeveloperError} canvas is required.
37
+ *
38
+ * @constructor
39
+ *
40
+ * @example
41
+ * // Create a camera looking down the negative z-axis, positioned at the origin,
42
+ * // with a field of view of 60 degrees, and 1:1 aspect ratio.
43
+ * var camera = new Camera(canvas);
44
+ * camera.position = new Cartesian3();
45
+ * camera.direction = Cartesian3.UNIT_Z.negate();
46
+ * camera.up = Cartesian3.UNIT_Y;
47
+ * camera.frustum.fovy = CesiumMath.PI_OVER_THREE;
48
+ * camera.frustum.near = 1.0;
49
+ * camera.frustum.far = 2.0;
50
+ */
51
+ var Camera = function(canvas) {
52
+ if (typeof canvas === 'undefined') {
53
+ throw new DeveloperError('canvas is required.');
54
+ }
55
+
56
+ /**
57
+ * Modifies the camera's reference frame. The inverse of this transformation is appended to the view matrix.
58
+ *
59
+ * @type {Matrix4}
60
+ *
61
+ * @see Transforms
62
+ */
63
+ this.transform = Matrix4.IDENTITY.clone();
64
+ this._transform = this.transform.clone();
65
+ this._invTransform = Matrix4.IDENTITY.clone();
66
+
67
+ var maxRadii = Ellipsoid.WGS84.getMaximumRadius();
68
+ var position = new Cartesian3(0.0, -2.0, 1.0).normalize().multiplyByScalar(2.0 * maxRadii);
69
+
70
+ /**
71
+ * The position of the camera.
72
+ *
73
+ * @type {Cartesian3}
74
+ */
75
+ this.position = position.clone();
76
+ this._position = position;
77
+ this._positionWC = position;
78
+
79
+ var direction = Cartesian3.ZERO.subtract(position).normalize();
80
+
81
+ /**
82
+ * The view direction of the camera.
83
+ *
84
+ * @type {Cartesian3}
85
+ */
86
+ this.direction = direction.clone();
87
+ this._direction = direction;
88
+ this._directionWC = direction;
89
+
90
+ var right = direction.cross(Cartesian3.UNIT_Z).normalize();
91
+ var up = right.cross(direction);
92
+
93
+ /**
94
+ * The up direction of the camera.
95
+ *
96
+ * @type {Cartesian3}
97
+ */
98
+ this.up = up.clone();
99
+ this._up = up;
100
+ this._upWC = up;
101
+
102
+ right = direction.cross(up);
103
+
104
+ /**
105
+ * The right direction of the camera.
106
+ *
107
+ * @type {Cartesian3}
108
+ */
109
+ this.right = right.clone();
110
+ this._right = right;
111
+ this._rightWC = right;
112
+
113
+ /**
114
+ * The region of space in view.
115
+ *
116
+ * @type {Frustum}
117
+ *
118
+ * @see PerspectiveFrustum
119
+ * @see PerspectiveOffCenterFrustum
120
+ * @see OrthographicFrustum
121
+ */
122
+ this.frustum = new PerspectiveFrustum();
123
+ this.frustum.fovy = CesiumMath.toRadians(60.0);
124
+ this.frustum.aspectRatio = canvas.clientWidth / canvas.clientHeight;
125
+
126
+ /**
127
+ * Defines camera behavior. The controller can be used to perform common camera manipulations.
128
+ *
129
+ * @type {CameraController}
130
+ */
131
+ this.controller = new CameraController(this);
132
+
133
+ this._viewMatrix = undefined;
134
+ this._invViewMatrix = undefined;
135
+ updateViewMatrix(this);
136
+
137
+ this._canvas = canvas;
138
+ };
139
+
140
+ function updateViewMatrix(camera) {
141
+ var r = camera._right;
142
+ var u = camera._up;
143
+ var d = camera._direction;
144
+ var e = camera._position;
145
+
146
+ var viewMatrix = new Matrix4( r.x, r.y, r.z, -r.dot(e),
147
+ u.x, u.y, u.z, -u.dot(e),
148
+ -d.x, -d.y, -d.z, d.dot(e),
149
+ 0.0, 0.0, 0.0, 1.0);
150
+ camera._viewMatrix = viewMatrix.multiply(camera._invTransform);
151
+ camera._invViewMatrix = camera._viewMatrix.inverseTransformation();
152
+ }
153
+
154
+ function update(camera) {
155
+ var position = camera._position;
156
+ var positionChanged = !position.equals(camera.position);
157
+ if (positionChanged) {
158
+ position = camera._position = camera.position.clone();
159
+ }
160
+
161
+ var direction = camera._direction;
162
+ var directionChanged = !direction.equals(camera.direction);
163
+ if (directionChanged) {
164
+ direction = camera._direction = camera.direction.clone();
165
+ }
166
+
167
+ var up = camera._up;
168
+ var upChanged = !up.equals(camera.up);
169
+ if (upChanged) {
170
+ up = camera._up = camera.up.clone();
171
+ }
172
+
173
+ var right = camera._right;
174
+ var rightChanged = !right.equals(camera.right);
175
+ if (rightChanged) {
176
+ right = camera._right = camera.right.clone();
177
+ }
178
+
179
+ var transform = camera._transform;
180
+ var transformChanged = !transform.equals(camera.transform);
181
+ if (transformChanged) {
182
+ transform = camera._transform = camera.transform.clone();
183
+
184
+ camera._invTransform = camera._transform.inverseTransformation();
185
+ }
186
+
187
+ if (positionChanged || transformChanged) {
188
+ camera._positionWC = Cartesian3.fromCartesian4(transform.multiplyByPoint(position));
189
+ }
190
+
191
+ if (directionChanged || upChanged || rightChanged) {
192
+ var det = direction.dot(up.cross(right));
193
+ if (Math.abs(1.0 - det) > CesiumMath.EPSILON2) {
194
+ //orthonormalize axes
195
+ direction = camera._direction = direction.normalize();
196
+ camera.direction = direction.clone();
197
+
198
+ var invUpMag = 1.0 / up.magnitudeSquared();
199
+ var scalar = up.dot(direction) * invUpMag;
200
+ var w0 = direction.multiplyByScalar(scalar);
201
+ up = camera._up = up.subtract(w0).normalize();
202
+ camera.up = up.clone();
203
+
204
+ right = camera._right = direction.cross(up);
205
+ camera.right = right.clone();
206
+ }
207
+ }
208
+
209
+ if (directionChanged || transformChanged) {
210
+ camera._directionWC = Cartesian3.fromCartesian4(transform.multiplyByVector(new Cartesian4(direction.x, direction.y, direction.z, 0.0)));
211
+ }
212
+
213
+ if (upChanged || transformChanged) {
214
+ camera._upWC = Cartesian3.fromCartesian4(transform.multiplyByVector(new Cartesian4(up.x, up.y, up.z, 0.0)));
215
+ }
216
+
217
+ if (rightChanged || transformChanged) {
218
+ camera._rightWC = Cartesian3.fromCartesian4(transform.multiplyByVector(new Cartesian4(right.x, right.y, right.z, 0.0)));
219
+ }
220
+
221
+ if (positionChanged || directionChanged || upChanged || rightChanged || transformChanged) {
222
+ updateViewMatrix(camera);
223
+ }
224
+ }
225
+
226
+ /**
227
+ * DOC_TBA
228
+ *
229
+ * @memberof Camera
230
+ *
231
+ * @return {Matrix4} DOC_TBA
232
+ */
233
+ Camera.prototype.getInverseTransform = function() {
234
+ update(this);
235
+ return this._invTransform;
236
+ };
237
+
238
+ /**
239
+ * Returns the view matrix.
240
+ *
241
+ * @memberof Camera
242
+ *
243
+ * @return {Matrix4} The view matrix.
244
+ *
245
+ * @see UniformState#getView
246
+ * @see UniformState#setView
247
+ * @see czm_view
248
+ */
249
+ Camera.prototype.getViewMatrix = function() {
250
+ update(this);
251
+ return this._viewMatrix;
252
+ };
253
+
254
+ /**
255
+ * DOC_TBA
256
+ * @memberof Camera
257
+ */
258
+ Camera.prototype.getInverseViewMatrix = function() {
259
+ update(this);
260
+ return this._invViewMatrix;
261
+ };
262
+
263
+ /**
264
+ * The position of the camera in world coordinates.
265
+ *
266
+ * @type {Cartesian3}
267
+ */
268
+ Camera.prototype.getPositionWC = function() {
269
+ update(this);
270
+ return this._positionWC;
271
+ };
272
+
273
+ /**
274
+ * The view direction of the camera in world coordinates.
275
+ *
276
+ * @type {Cartesian3}
277
+ */
278
+ Camera.prototype.getDirectionWC = function() {
279
+ update(this);
280
+ return this._directionWC;
281
+ };
282
+
283
+ /**
284
+ * The up direction of the camera in world coordinates.
285
+ *
286
+ * @type {Cartesian3}
287
+ */
288
+ Camera.prototype.getUpWC = function() {
289
+ update(this);
290
+ return this._upWC;
291
+ };
292
+
293
+ /**
294
+ * The right direction of the camera in world coordinates.
295
+ *
296
+ * @type {Cartesian3}
297
+ */
298
+ Camera.prototype.getRightWC = function() {
299
+ update(this);
300
+ return this._rightWC;
301
+ };
302
+
303
+ /**
304
+ * Returns a duplicate of a Camera instance.
305
+ *
306
+ * @memberof Camera
307
+ *
308
+ * @return {Camera} A new copy of the Camera instance.
309
+ */
310
+ Camera.prototype.clone = function() {
311
+ var camera = new Camera(this._canvas);
312
+ camera.position = this.position.clone();
313
+ camera.direction = this.direction.clone();
314
+ camera.up = this.up.clone();
315
+ camera.right = this.right.clone();
316
+ camera.transform = this.transform.clone();
317
+ camera.frustum = this.frustum.clone();
318
+ return camera;
319
+ };
320
+
321
+ /**
322
+ * Transform a vector or point from world coordinates to the camera's reference frame.
323
+ * @memberof Camera
324
+ *
325
+ * @param {Cartesian4} cartesian The vector or point to transform.
326
+ * @param {Cartesian4} [result] The object onto which to store the result.
327
+ *
328
+ * @exception {DeveloperError} cartesian is required.
329
+ *
330
+ * @returns {Cartesian4} The transformed vector or point.
331
+ */
332
+ Camera.prototype.worldToCameraCoordinates = function(cartesian, result) {
333
+ if (typeof cartesian === 'undefined') {
334
+ throw new DeveloperError('cartesian is required.');
335
+ }
336
+ return Matrix4.multiplyByVector(this.getInverseTransform(), cartesian, result);
337
+ };
338
+
339
+ /**
340
+ * Transform a vector or point from the camera's reference frame to world coordinates.
341
+ * @memberof Camera
342
+ *
343
+ * @param {Cartesian4} vector The vector or point to transform.
344
+ * @param {Cartesian4} [result] The object onto which to store the result.
345
+ *
346
+ * @exception {DeveloperError} cartesian is required.
347
+ *
348
+ * @returns {Cartesian4} The transformed vector or point.
349
+ */
350
+ Camera.prototype.cameraToWorldCoordinates = function(cartesian, result) {
351
+ if (typeof cartesian === 'undefined') {
352
+ throw new DeveloperError('cartesian is required.');
353
+ }
354
+ return Matrix4.multiplyByVector(this.transform, cartesian, result);
355
+ };
356
+
357
+ return Camera;
358
+ });
@@ -0,0 +1,30 @@
1
+ /*global define*/
2
+ define(['../Core/Enumeration'], function(Enumeration) {
3
+ "use strict";
4
+
5
+ /**
6
+ * Specifies how to handle mouse events in columbus view mode.
7
+ *
8
+ * @exports CameraColumbusViewMode
9
+ * @see ScreenSpaceCameraController
10
+ */
11
+ var CameraColumbusViewMode = {
12
+ /**
13
+ * The camera is free to move about anywhere.
14
+ *
15
+ * @constant
16
+ * @type {Enumeration}
17
+ */
18
+ FREE : new Enumeration(0, 'FREE'),
19
+
20
+ /**
21
+ * The camera is locked looking at a location, but is free to rotate about that single point.
22
+ *
23
+ * @constant
24
+ * @type {Enumeration}
25
+ */
26
+ LOCKED : new Enumeration(1, 'LOCKED')
27
+ };
28
+
29
+ return CameraColumbusViewMode;
30
+ });
@@ -0,0 +1,1258 @@
1
+ /*global define*/
2
+ define([
3
+ '../Core/defaultValue',
4
+ '../Core/Cartesian2',
5
+ '../Core/Cartesian3',
6
+ '../Core/Cartesian4',
7
+ '../Core/Cartographic',
8
+ '../Core/DeveloperError',
9
+ '../Core/Ellipsoid',
10
+ '../Core/GeographicProjection',
11
+ '../Core/IntersectionTests',
12
+ '../Core/Math',
13
+ '../Core/Matrix3',
14
+ '../Core/Matrix4',
15
+ '../Core/Quaternion',
16
+ '../Core/Ray',
17
+ './SceneMode',
18
+ '../ThirdParty/Tween'
19
+ ], function(
20
+ defaultValue,
21
+ Cartesian2,
22
+ Cartesian3,
23
+ Cartesian4,
24
+ Cartographic,
25
+ DeveloperError,
26
+ Ellipsoid,
27
+ GeographicProjection,
28
+ IntersectionTests,
29
+ CesiumMath,
30
+ Matrix3,
31
+ Matrix4,
32
+ Quaternion,
33
+ Ray,
34
+ SceneMode,
35
+ Tween) {
36
+ "use strict";
37
+
38
+ /**
39
+ * Provides methods for common camera manipulations.
40
+ *
41
+ * @alias CameraController
42
+ * @constructor
43
+ *
44
+ * @exception {DeveloperError} camera is required.
45
+ */
46
+ var CameraController = function(camera) {
47
+ if (typeof camera === 'undefined') {
48
+ throw new DeveloperError('camera is required.');
49
+ }
50
+
51
+ this._camera = camera;
52
+ this._mode = SceneMode.SCENE3D;
53
+ this._projection = new GeographicProjection();
54
+
55
+ /**
56
+ * The default amount to move the camera when an argument is not
57
+ * provided to the move methods.
58
+ * @type {Number}
59
+ */
60
+ this.defaultMoveAmount = 100000.0;
61
+ /**
62
+ * The default amount to rotate the camera when an argument is not
63
+ * provided to the look methods.
64
+ * @type {Number}
65
+ */
66
+ this.defaultLookAmount = Math.PI / 60.0;
67
+ /**
68
+ * The default amount to rotate the camera when an argument is not
69
+ * provided to the rotate methods.
70
+ * @type {Number}
71
+ */
72
+ this.defaultRotateAmount = Math.PI / 3600.0;
73
+ /**
74
+ * The default amount to move the camera when an argument is not
75
+ * provided to the zoom methods.
76
+ * @type {Number}
77
+ */
78
+ this.defaultZoomAmount = 100000.0;
79
+ /**
80
+ * If set, the camera will not be able to rotate past this axis in either direction.
81
+ * @type Cartesian3
82
+ */
83
+ this.constrainedAxis = undefined;
84
+ /**
85
+ * The factor multiplied by the the map size used to determine where to clamp the camera position
86
+ * when translating across the surface. The default is 1.5. Only valid for 2D and Columbus view.
87
+ * @type Number
88
+ */
89
+ this.maximumTranslateFactor = 1.5;
90
+ /**
91
+ * The factor multiplied by the the map size used to determine where to clamp the camera position
92
+ * when zooming out from the surface. The default is 2.5. Only valid for 2D.
93
+ * @type Number
94
+ */
95
+ this.maximumZoomFactor = 2.5;
96
+
97
+ this._maxCoord = undefined;
98
+ this._frustum = undefined;
99
+ };
100
+
101
+ /**
102
+ * @private
103
+ */
104
+ CameraController.prototype.update = function(mode, scene2D) {
105
+ var updateFrustum = false;
106
+ if (mode !== this._mode) {
107
+ this._mode = mode;
108
+ updateFrustum = this._mode === SceneMode.SCENE2D;
109
+ }
110
+
111
+ var projection = scene2D.projection;
112
+ if (typeof projection !== 'undefined' && projection !== this._projection) {
113
+ this._projection = projection;
114
+ this._maxCoord = projection.project(new Cartographic(Math.PI, CesiumMath.PI_OVER_TWO));
115
+ }
116
+
117
+ if (updateFrustum) {
118
+ var frustum = this._frustum = this._camera.frustum.clone();
119
+ if (typeof frustum.left === 'undefined' || typeof frustum.right === 'undefined' ||
120
+ typeof frustum.top === 'undefined' || typeof frustum.bottom === 'undefined') {
121
+ throw new DeveloperError('The camera frustum is expected to be orthographic for 2D camera control.');
122
+ }
123
+
124
+ var maxZoomOut = 2.0;
125
+ var ratio = frustum.top / frustum.right;
126
+ frustum.right = this._maxCoord.x * maxZoomOut;
127
+ frustum.left = -frustum.right;
128
+ frustum.top = ratio * frustum.right;
129
+ frustum.bottom = -frustum.top;
130
+ }
131
+ };
132
+
133
+ function clampMove2D(controller, position) {
134
+ var maxX = controller._maxCoord.x * controller.maximumTranslateFactor;
135
+ if (position.x > maxX) {
136
+ position.x = maxX;
137
+ }
138
+ if (position.x < -maxX) {
139
+ position.x = -maxX;
140
+ }
141
+
142
+ var maxY = controller._maxCoord.y * controller.maximumTranslateFactor;
143
+ if (position.y > maxY) {
144
+ position.y = maxY;
145
+ }
146
+ if (position.y < -maxY) {
147
+ position.y = -maxY;
148
+ }
149
+ }
150
+
151
+ var moveScratch = new Cartesian3();
152
+ /**
153
+ * Translates the camera's position by <code>amount</code> along <code>direction</code>.
154
+ *
155
+ * @memberof CameraController
156
+ *
157
+ * @param {Cartesian3} direction The direction to move.
158
+ * @param {Number} [amount] The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.
159
+ *
160
+ * @exception {DeveloperError} direction is required.
161
+ *
162
+ * @see CameraController#moveBackward
163
+ * @see CameraController#moveForward
164
+ * @see CameraController#moveLeft
165
+ * @see CameraController#moveRight
166
+ * @see CameraController#moveUp
167
+ * @see CameraController#moveDown
168
+ */
169
+ CameraController.prototype.move = function(direction, amount) {
170
+ if (typeof direction === 'undefined') {
171
+ throw new DeveloperError('direction is required.');
172
+ }
173
+
174
+ var cameraPosition = this._camera.position;
175
+ Cartesian3.multiplyByScalar(direction, amount, moveScratch);
176
+ Cartesian3.add(cameraPosition, moveScratch, cameraPosition);
177
+
178
+ if (this._mode === SceneMode.SCENE2D) {
179
+ clampMove2D(this, cameraPosition);
180
+ }
181
+ };
182
+
183
+ /**
184
+ * Translates the camera's position by <code>amount</code> along the camera's view vector.
185
+ *
186
+ * @memberof CameraController
187
+ *
188
+ * @param {Number} [amount] The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.
189
+ *
190
+ * @see CameraController#moveBackward
191
+ */
192
+ CameraController.prototype.moveForward = function(amount) {
193
+ amount = defaultValue(amount, this.defaultMoveAmount);
194
+ this.move(this._camera.direction, amount);
195
+ };
196
+
197
+ /**
198
+ * Translates the camera's position by <code>amount</code> along the opposite direction
199
+ * of the camera's view vector.
200
+ *
201
+ * @memberof CameraController
202
+ *
203
+ * @param {Number} [amount] The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.
204
+ *
205
+ * @see CameraController#moveForward
206
+ */
207
+ CameraController.prototype.moveBackward = function(amount) {
208
+ amount = defaultValue(amount, this.defaultMoveAmount);
209
+ this.move(this._camera.direction, -amount);
210
+ };
211
+
212
+ /**
213
+ * Translates the camera's position by <code>amount</code> along the camera's up vector.
214
+ *
215
+ * @memberof CameraController
216
+ *
217
+ * @param {Number} [amount] The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.
218
+ *
219
+ * @see CameraController#moveDown
220
+ */
221
+ CameraController.prototype.moveUp = function(amount) {
222
+ amount = defaultValue(amount, this.defaultMoveAmount);
223
+ this.move(this._camera.up, amount);
224
+ };
225
+
226
+ /**
227
+ * Translates the camera's position by <code>amount</code> along the opposite direction
228
+ * of the camera's up vector.
229
+ *
230
+ * @memberof CameraController
231
+ *
232
+ * @param {Number} [amount] The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.
233
+ *
234
+ * @see CameraController#moveUp
235
+ */
236
+ CameraController.prototype.moveDown = function(amount) {
237
+ amount = defaultValue(amount, this.defaultMoveAmount);
238
+ this.move(this._camera.up, -amount);
239
+ };
240
+
241
+ /**
242
+ * Translates the camera's position by <code>amount</code> along the camera's right vector.
243
+ *
244
+ * @memberof CameraController
245
+ *
246
+ * @param {Number} [amount] The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.
247
+ *
248
+ * @see CameraController#moveLeft
249
+ */
250
+ CameraController.prototype.moveRight = function(amount) {
251
+ amount = defaultValue(amount, this.defaultMoveAmount);
252
+ this.move(this._camera.right, amount);
253
+ };
254
+
255
+ /**
256
+ * Translates the camera's position by <code>amount</code> along the opposite direction
257
+ * of the camera's right vector.
258
+ *
259
+ * @memberof CameraController
260
+ *
261
+ * @param {Number} [amount] The amount, in meters, to move. Defaults to <code>defaultMoveAmount</code>.
262
+ *
263
+ * @see CameraController#moveRight
264
+ */
265
+ CameraController.prototype.moveLeft = function(amount) {
266
+ amount = defaultValue(amount, this.defaultMoveAmount);
267
+ this.move(this._camera.right, -amount);
268
+ };
269
+
270
+ /**
271
+ * Rotates the camera around its up vector by amount, in radians, in the opposite direction
272
+ * of its right vector.
273
+ *
274
+ * @memberof CameraController
275
+ *
276
+ * @param {Number} [amount] The amount, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.
277
+ *
278
+ * @see CameraController#lookRight
279
+ */
280
+ CameraController.prototype.lookLeft = function(amount) {
281
+ amount = defaultValue(amount, this.defaultLookAmount);
282
+ this.look(this._camera.up, -amount);
283
+ };
284
+
285
+ /**
286
+ * Rotates the camera around its up vector by amount, in radians, in the direction
287
+ * of its right vector.
288
+ *
289
+ * @memberof CameraController
290
+ *
291
+ * @param {Number} [amount] The amount, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.
292
+ *
293
+ * @see CameraController#lookLeft
294
+ */
295
+ CameraController.prototype.lookRight = function(amount) {
296
+ amount = defaultValue(amount, this.defaultLookAmount);
297
+ this.look(this._camera.up, amount);
298
+ };
299
+
300
+ /**
301
+ * Rotates the camera around its right vector by amount, in radians, in the direction
302
+ * of its up vector.
303
+ *
304
+ * @memberof CameraController
305
+ *
306
+ * @param {Number} [amount] The amount, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.
307
+ *
308
+ * @see CameraController#lookDown
309
+ */
310
+ CameraController.prototype.lookUp = function(amount) {
311
+ amount = defaultValue(amount, this.defaultLookAmount);
312
+ this.look(this._camera.right, -amount);
313
+ };
314
+
315
+ /**
316
+ * Rotates the camera around its right vector by amount, in radians, in the opposite direction
317
+ * of its up vector.
318
+ *
319
+ * @memberof CameraController
320
+ *
321
+ * @param {Number} [amount] The amount, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.
322
+ *
323
+ * @see CameraController#lookUp
324
+ */
325
+ CameraController.prototype.lookDown = function(amount) {
326
+ amount = defaultValue(amount, this.defaultLookAmount);
327
+ this.look(this._camera.right, amount);
328
+ };
329
+
330
+ var lookScratchQuaternion = new Quaternion();
331
+ var lookScratchMatrix = new Matrix3();
332
+ /**
333
+ * Rotate each of the camera's orientation vectors around <code>axis</code> by <code>angle</code>
334
+ *
335
+ * @memberof CameraController
336
+ *
337
+ * @param {Cartesian3} axis The axis to rotate around.
338
+ * @param {Number} [angle] The angle, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.
339
+ *
340
+ * @exception {DeveloperError} axis is required.
341
+ *
342
+ * @see CameraController#lookUp
343
+ * @see CameraController#lookDown
344
+ * @see CameraController#lookLeft
345
+ * @see CameraController#lookRight
346
+ */
347
+ CameraController.prototype.look = function(axis, angle) {
348
+ if (typeof axis === 'undefined') {
349
+ throw new DeveloperError('axis is required.');
350
+ }
351
+
352
+ var turnAngle = defaultValue(angle, this.defaultLookAmount);
353
+ var rotation = Matrix3.fromQuaternion(Quaternion.fromAxisAngle(axis, turnAngle, lookScratchQuaternion), lookScratchMatrix);
354
+
355
+ var direction = this._camera.direction;
356
+ var up = this._camera.up;
357
+ var right = this._camera.right;
358
+
359
+ Matrix3.multiplyByVector(rotation, direction, direction);
360
+ Matrix3.multiplyByVector(rotation, up, up);
361
+ Matrix3.multiplyByVector(rotation, right, right);
362
+ };
363
+
364
+ /**
365
+ * Rotate the camera counter-clockwise around its direction vector by amount, in radians.
366
+ *
367
+ * @memberof CameraController
368
+ *
369
+ * @param {Number} [amount] The amount, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.
370
+ *
371
+ * @see CameraController#twistRight
372
+ */
373
+ CameraController.prototype.twistLeft = function(amount) {
374
+ amount = defaultValue(amount, this.defaultLookAmount);
375
+ this.look(this._camera.direction, amount);
376
+ };
377
+
378
+ /**
379
+ * Rotate the camera clockwise around its direction vector by amount, in radians.
380
+ *
381
+ * @memberof CameraController
382
+ *
383
+ * @param {Number} [amount] The amount, in radians, to rotate by. Defaults to <code>defaultLookAmount</code>.
384
+ *
385
+ * @see CameraController#twistLeft
386
+ */
387
+ CameraController.prototype.twistRight = function(amount) {
388
+ amount = defaultValue(amount, this.defaultLookAmount);
389
+ this.look(this._camera.direction, -amount);
390
+ };
391
+
392
+ var appendTransformPosition = Cartesian4.UNIT_W.clone();
393
+ var appendTransformUp = Cartesian4.ZERO.clone();
394
+ var appendTransformRight = Cartesian4.ZERO.clone();
395
+ var appendTransformDirection = Cartesian4.ZERO.clone();
396
+ function appendTransform(controller, transform) {
397
+ var camera = controller._camera;
398
+ var oldTransform;
399
+ if (typeof transform !== 'undefined') {
400
+ var position = Cartesian3.clone(camera.getPositionWC(), appendTransformPosition);
401
+ var up = Cartesian3.clone(camera.getUpWC(), appendTransformUp);
402
+ var right = Cartesian3.clone(camera.getRightWC(), appendTransformRight);
403
+ var direction = Cartesian3.clone(camera.getDirectionWC(), appendTransformDirection);
404
+
405
+ oldTransform = camera.transform;
406
+ camera.transform = transform.multiply(oldTransform);
407
+
408
+ var invTransform = camera.getInverseTransform();
409
+ Cartesian3.clone(Matrix4.multiplyByVector(invTransform, position, position), camera.position);
410
+ Cartesian3.clone(Matrix4.multiplyByVector(invTransform, up, up), camera.up);
411
+ Cartesian3.clone(Matrix4.multiplyByVector(invTransform, right, right), camera.right);
412
+ Cartesian3.clone(Matrix4.multiplyByVector(invTransform, direction, direction), camera.direction);
413
+ }
414
+ return oldTransform;
415
+ }
416
+
417
+ var revertTransformPosition = Cartesian4.UNIT_W.clone();
418
+ var revertTransformUp = Cartesian4.ZERO.clone();
419
+ var revertTransformRight = Cartesian4.ZERO.clone();
420
+ var revertTransformDirection = Cartesian4.ZERO.clone();
421
+ function revertTransform(controller, transform) {
422
+ if (typeof transform !== 'undefined') {
423
+ var camera = controller._camera;
424
+ var position = Cartesian3.clone(camera.getPositionWC(), revertTransformPosition);
425
+ var up = Cartesian3.clone(camera.getUpWC(), revertTransformUp);
426
+ var right = Cartesian3.clone(camera.getRightWC(), revertTransformRight);
427
+ var direction = Cartesian3.clone(camera.getDirectionWC(), revertTransformDirection);
428
+
429
+ camera.transform = transform;
430
+ transform = camera.getInverseTransform();
431
+
432
+ position = Cartesian3.clone(Matrix4.multiplyByVector(transform, position, position), camera.position);
433
+ up = Cartesian3.clone(Matrix4.multiplyByVector(transform, up, up), camera.up);
434
+ right = Cartesian3.clone(Matrix4.multiplyByVector(transform, right, right), camera.right);
435
+ direction = Cartesian3.clone(Matrix4.multiplyByVector(transform, direction, direction), camera.direction);
436
+ }
437
+ }
438
+
439
+ var rotateScratchQuaternion = new Quaternion();
440
+ var rotateScratchMatrix = new Matrix3();
441
+ /**
442
+ * Rotates the camera around <code>axis</code> by <code>angle</code>. The distance
443
+ * of the camera's position to the center of the camera's reference frame remains the same.
444
+ *
445
+ * @memberof CameraController
446
+ *
447
+ * @param {Cartesian3} axis The axis to rotate around given in world coordinates.
448
+ * @param {Number} [angle] The angle, in radians, to rotate by. Defaults to <code>defaultRotateAmount</code>.
449
+ * @param {Matrix4} [transform] A transform to append to the camera transform before the rotation. Does not alter the camera's transform.
450
+ *
451
+ * @exception {DeveloperError} axis is required.
452
+ *
453
+ * @see CameraController#rotateUp
454
+ * @see CameraController#rotateDown
455
+ * @see CameraController#rotateLeft
456
+ * @see CameraController#rotateRight
457
+ *
458
+ * @example
459
+ * // Rotate about a point on the earth.
460
+ * var center = ellipsoid.cartographicToCartesian(cartographic);
461
+ * var transform = Matrix4.fromTranslation(center);
462
+ * controller.rotate(axis, angle, transform);
463
+ */
464
+ CameraController.prototype.rotate = function(axis, angle, transform) {
465
+ if (typeof axis === 'undefined') {
466
+ throw new DeveloperError('axis is required.');
467
+ }
468
+
469
+ var camera = this._camera;
470
+
471
+ var turnAngle = defaultValue(angle, this.defaultRotateAmount);
472
+ var rotation = Matrix3.fromQuaternion(Quaternion.fromAxisAngle(axis, turnAngle, rotateScratchQuaternion), rotateScratchMatrix);
473
+
474
+ var oldTransform = appendTransform(this, transform);
475
+ Matrix3.multiplyByVector(rotation, camera.position, camera.position);
476
+ Matrix3.multiplyByVector(rotation, camera.direction, camera.direction);
477
+ Matrix3.multiplyByVector(rotation, camera.up, camera.up);
478
+ Cartesian3.cross(camera.direction, camera.up, camera.right);
479
+ Cartesian3.cross(camera.right, camera.direction, camera.up);
480
+ revertTransform(this, oldTransform);
481
+ };
482
+
483
+ /**
484
+ * Rotates the camera around the center of the camera's reference frame by angle downwards.
485
+ *
486
+ * @memberof CameraController
487
+ *
488
+ * @param {Number} [angle] The angle, in radians, to rotate by. Defaults to <code>defaultRotateAmount</code>.
489
+ * @param {Matrix4} [transform] A transform to append to the camera transform before the rotation. Does not alter the camera's transform.
490
+ *
491
+ * @see CameraController#rotateUp
492
+ * @see CameraController#rotate
493
+ */
494
+ CameraController.prototype.rotateDown = function(angle, transform) {
495
+ angle = defaultValue(angle, this.defaultRotateAmount);
496
+ rotateVertical(this, angle, transform);
497
+ };
498
+
499
+ /**
500
+ * Rotates the camera around the center of the camera's reference frame by angle upwards.
501
+ *
502
+ * @memberof CameraController
503
+ *
504
+ * @param {Number} [angle] The angle, in radians, to rotate by. Defaults to <code>defaultRotateAmount</code>.
505
+ * @param {Matrix4} [transform] A transform to append to the camera transform before the rotation. Does not alter the camera's transform.
506
+ *
507
+ * @see CameraController#rotateDown
508
+ * @see CameraController#rotate
509
+ */
510
+ CameraController.prototype.rotateUp = function(angle, transform) {
511
+ angle = defaultValue(angle, this.defaultRotateAmount);
512
+ rotateVertical(this, -angle, transform);
513
+ };
514
+
515
+ var rotateVertScratchP = new Cartesian3();
516
+ var rotateVertScratchA = new Cartesian3();
517
+ var rotateVertScratchTan = new Cartesian3();
518
+ function rotateVertical(controller, angle, transform) {
519
+ var camera = controller._camera;
520
+ var oldTransform = appendTransform(controller, transform);
521
+
522
+ var position = camera.position;
523
+ var p = Cartesian3.normalize(position, rotateVertScratchP);
524
+ if (typeof controller.constrainedAxis !== 'undefined') {
525
+ var northParallel = p.equalsEpsilon(controller.constrainedAxis, CesiumMath.EPSILON2);
526
+ var southParallel = p.equalsEpsilon(controller.constrainedAxis.negate(), CesiumMath.EPSILON2);
527
+ if ((!northParallel && !southParallel)) {
528
+ var constrainedAxis = Cartesian3.normalize(controller.constrainedAxis, rotateVertScratchA);
529
+
530
+ var dot = p.dot(constrainedAxis);
531
+ var angleToAxis = Math.acos(dot);
532
+ if (angle > 0 && angle > angleToAxis) {
533
+ angle = angleToAxis;
534
+ }
535
+
536
+ dot = p.dot(constrainedAxis.negate());
537
+ angleToAxis = Math.acos(dot);
538
+ if (angle < 0 && -angle > angleToAxis) {
539
+ angle = -angleToAxis;
540
+ }
541
+
542
+ var tangent = Cartesian3.cross(constrainedAxis, p, rotateVertScratchTan);
543
+ controller.rotate(tangent, angle);
544
+ } else if ((northParallel && angle < 0) || (southParallel && angle > 0)) {
545
+ controller.rotate(camera.right, angle);
546
+ }
547
+ } else {
548
+ controller.rotate(camera.right, angle);
549
+ }
550
+
551
+ revertTransform(controller, oldTransform);
552
+ }
553
+
554
+ /**
555
+ * Rotates the camera around the center of the camera's reference frame by angle to the right.
556
+ *
557
+ * @memberof CameraController
558
+ *
559
+ * @param {Number} [angle] The angle, in radians, to rotate by. Defaults to <code>defaultRotateAmount</code>.
560
+ * @param {Matrix4} [transform] A transform to append to the camera transform before the rotation. Does not alter the camera's transform.
561
+ *
562
+ * @see CameraController#rotateLeft
563
+ * @see CameraController#rotate
564
+ */
565
+ CameraController.prototype.rotateRight = function(angle, transform) {
566
+ angle = defaultValue(angle, this.defaultRotateAmount);
567
+ rotateHorizontal(this, -angle, transform);
568
+ };
569
+
570
+ /**
571
+ * Rotates the camera around the center of the camera's reference frame by angle to the left.
572
+ *
573
+ * @memberof CameraController
574
+ *
575
+ * @param {Number} [angle] The angle, in radians, to rotate by. Defaults to <code>defaultRotateAmount</code>.
576
+ * @param {Matrix4} [transform] A transform to append to the camera transform before the rotation. Does not alter the camera's transform.
577
+ *
578
+ * @see CameraController#rotateRight
579
+ * @see CameraController#rotate
580
+ */
581
+ CameraController.prototype.rotateLeft = function(angle, transform) {
582
+ angle = defaultValue(angle, this.defaultRotateAmount);
583
+ rotateHorizontal(this, angle, transform);
584
+ };
585
+
586
+ function rotateHorizontal(controller, angle, transform) {
587
+ if (typeof controller.constrainedAxis !== 'undefined') {
588
+ controller.rotate(controller.constrainedAxis, angle, transform);
589
+ } else {
590
+ controller.rotate(controller._camera.up, angle, transform);
591
+ }
592
+ }
593
+
594
+ function zoom2D(controller, amount) {
595
+ var frustum = controller._camera.frustum;
596
+
597
+ if (typeof frustum.left === 'undefined' || typeof frustum.right === 'undefined' ||
598
+ typeof frustum.top === 'undefined' || typeof frustum.bottom === 'undefined') {
599
+ throw new DeveloperError('The camera frustum is expected to be orthographic for 2D camera control.');
600
+ }
601
+
602
+ amount = amount * 0.5;
603
+ var newRight = frustum.right - amount;
604
+ var newLeft = frustum.left + amount;
605
+
606
+ var maxRight = controller._maxCoord.x * controller.maximumZoomFactor;
607
+ if (newRight > maxRight) {
608
+ newRight = maxRight;
609
+ newLeft = -maxRight;
610
+ }
611
+
612
+ var ratio = frustum.top / frustum.right;
613
+ frustum.right = newRight;
614
+ frustum.left = newLeft;
615
+ frustum.top = frustum.right * ratio;
616
+ frustum.bottom = -frustum.top;
617
+ }
618
+
619
+ function zoom3D(controller, amount) {
620
+ var camera = controller._camera;
621
+ controller.move(camera.direction, amount);
622
+ }
623
+
624
+ /**
625
+ * Zooms <code>amount</code> along the camera's view vector.
626
+ *
627
+ * @memberof CameraController
628
+ *
629
+ * @param {Number} [amount] The amount to move. Defaults to <code>defaultZoomAmount</code>.
630
+ *
631
+ * @see CameraController#zoomOut
632
+ */
633
+ CameraController.prototype.zoomIn = function(amount) {
634
+ amount = defaultValue(amount, this.defaultZoomAmount);
635
+ if (this._mode === SceneMode.SCENE2D) {
636
+ zoom2D(this, amount);
637
+ } else {
638
+ zoom3D(this, amount);
639
+ }
640
+ };
641
+
642
+ /**
643
+ * Zooms <code>amount</code> along the opposite direction of
644
+ * the camera's view vector.
645
+ *
646
+ * @memberof CameraController
647
+ *
648
+ * @param {Number} [amount] The amount to move. Defaults to <code>defaultZoomAmount</code>.
649
+ *
650
+ * @see CameraController#zoomIn
651
+ */
652
+ CameraController.prototype.zoomOut = function(amount) {
653
+ amount = defaultValue(amount, this.defaultZoomAmount);
654
+ if (this._mode === SceneMode.SCENE2D) {
655
+ zoom2D(this, -amount);
656
+ } else {
657
+ zoom3D(this, -amount);
658
+ }
659
+ };
660
+
661
+ /**
662
+ * Gets the magnitude of the camera position. In 3D, this is the vector magnitude. In 2D and
663
+ * Columbus view, this is the distance to the map.
664
+ * @memberof CameraController
665
+ * @returns {Number} The magnitude of the position.
666
+ */
667
+ CameraController.prototype.getMagnitude = function() {
668
+ var camera = this._camera;
669
+ if (this._mode === SceneMode.SCENE3D) {
670
+ return camera.position.magnitude();
671
+ } else if (this._mode === SceneMode.COLUMBUS_VIEW) {
672
+ return Math.abs(camera.position.z);
673
+ } else if (this._mode === SceneMode.SCENE2D) {
674
+ return Math.max(camera.frustum.right - camera.frustum.left, camera.frustum.top - camera.frustum.bottom);
675
+ }
676
+ };
677
+
678
+ function setPositionCartographic2D(controller, cartographic) {
679
+ var camera = controller._camera;
680
+ var newLeft = -cartographic.height * 0.5;
681
+ var newRight = -newLeft;
682
+
683
+ var frustum = camera.frustum;
684
+ if (newRight > newLeft) {
685
+ var ratio = frustum.top / frustum.right;
686
+ frustum.right = newRight;
687
+ frustum.left = newLeft;
688
+ frustum.top = frustum.right * ratio;
689
+ frustum.bottom = -frustum.top;
690
+ }
691
+
692
+ //We use Cartesian2 instead of 3 here because Z must be constant in 2D mode.
693
+ Cartesian2.clone(controller._projection.project(cartographic), camera.position);
694
+ Cartesian3.negate(Cartesian3.UNIT_Z, camera.direction);
695
+ Cartesian3.clone(Cartesian3.UNIT_Y, camera.up);
696
+ Cartesian3.clone(Cartesian3.UNIT_X, camera.right);
697
+ }
698
+
699
+ function setPositionCartographicCV(controller, cartographic) {
700
+ var camera = controller._camera;
701
+ var projection = controller._projection;
702
+ camera.position = projection.project(cartographic);
703
+ Cartesian3.negate(Cartesian3.UNIT_Z, camera.direction);
704
+ Cartesian3.clone(Cartesian3.UNIT_Y, camera.up);
705
+ Cartesian3.clone(Cartesian3.UNIT_X, camera.right);
706
+ }
707
+
708
+ function setPositionCartographic3D(controller, cartographic) {
709
+ var camera = controller._camera;
710
+ var ellipsoid = controller._projection.getEllipsoid();
711
+
712
+ ellipsoid.cartographicToCartesian(cartographic, camera.position);
713
+ Cartesian3.negate(camera.position, camera.direction);
714
+ Cartesian3.normalize(camera.direction, camera.direction);
715
+ Cartesian3.cross(camera.direction, Cartesian3.UNIT_Z, camera.right);
716
+ Cartesian3.cross(camera.right, camera.direction, camera.up);
717
+ Cartesian3.cross(camera.direction, camera.up, camera.right);
718
+ }
719
+
720
+ /**
721
+ * Moves the camera to the provided cartographic position.
722
+ * @memberof CameraController
723
+ *
724
+ * @param {Cartographic} cartographic The new camera position.
725
+ *
726
+ * @exception {DeveloperError} cartographic is required.
727
+ */
728
+ CameraController.prototype.setPositionCartographic = function(cartographic) {
729
+ if (typeof cartographic === 'undefined') {
730
+ throw new DeveloperError('cartographic is required.');
731
+ }
732
+
733
+ if (this._mode === SceneMode.SCENE2D) {
734
+ setPositionCartographic2D(this, cartographic);
735
+ } else if (this._mode === SceneMode.COLUMBUS_VIEW) {
736
+ setPositionCartographicCV(this, cartographic);
737
+ } else if (this._mode === SceneMode.SCENE3D) {
738
+ setPositionCartographic3D(this, cartographic);
739
+ }
740
+ };
741
+
742
+ /**
743
+ * Sets the camera position and orientation with an eye position, target, and up vector.
744
+ * This method is not supported in 2D mode because there is only one direction to look.
745
+ *
746
+ * @memberof CameraController
747
+ *
748
+ * @param {Cartesian3} eye The position of the camera.
749
+ * @param {Cartesian3} target The position to look at.
750
+ * @param {Cartesian3} up The up vector.
751
+ *
752
+ * @exception {DeveloperError} eye is required.
753
+ * @exception {DeveloperError} target is required.
754
+ * @exception {DeveloperError} up is required.
755
+ * @exception {DeveloperError} lookAt is not supported in 2D mode because there is only one direction to look.
756
+ * @exception {DeveloperError} lookAt is not supported while morphing.
757
+ */
758
+ CameraController.prototype.lookAt = function(eye, target, up) {
759
+ if (typeof eye === 'undefined') {
760
+ throw new DeveloperError('eye is required');
761
+ }
762
+ if (typeof target === 'undefined') {
763
+ throw new DeveloperError('target is required');
764
+ }
765
+ if (typeof up === 'undefined') {
766
+ throw new DeveloperError('up is required');
767
+ }
768
+ if (this._mode === SceneMode.SCENE2D) {
769
+ throw new DeveloperError('lookAt is not supported in 2D mode because there is only one direction to look.');
770
+ }
771
+ if (this._mode === SceneMode.MORPHING) {
772
+ throw new DeveloperError('lookAt is not supported while morphing.');
773
+ }
774
+
775
+ var camera = this._camera;
776
+ camera.position = Cartesian3.clone(eye, camera.position);
777
+ camera.direction = Cartesian3.subtract(target, eye, camera.direction).normalize(camera.direction);
778
+ camera.right = Cartesian3.cross(camera.direction, up, camera.right).normalize(camera.right);
779
+ camera.up = Cartesian3.cross(camera.right, camera.direction, camera.up);
780
+ };
781
+
782
+ var viewExtent3DCartographic = new Cartographic();
783
+ var viewExtent3DNorthEast = new Cartesian3();
784
+ var viewExtent3DSouthWest = new Cartesian3();
785
+ var viewExtent3DNorthWest = new Cartesian3();
786
+ var viewExtent3DSouthEast = new Cartesian3();
787
+ var viewExtent3DCenter = new Cartesian3();
788
+ function viewExtent3D(camera, extent, ellipsoid) {
789
+ var north = extent.north;
790
+ var south = extent.south;
791
+ var east = extent.east;
792
+ var west = extent.west;
793
+
794
+ // If we go across the International Date Line
795
+ if (west > east) {
796
+ east += CesiumMath.TWO_PI;
797
+ }
798
+
799
+ var cart = viewExtent3DCartographic;
800
+ cart.longitude = east;
801
+ cart.latitude = north;
802
+ var northEast = ellipsoid.cartographicToCartesian(cart, viewExtent3DNorthEast);
803
+ cart.latitude = south;
804
+ var southEast = ellipsoid.cartographicToCartesian(cart, viewExtent3DSouthEast);
805
+ cart.longitude = west;
806
+ var southWest = ellipsoid.cartographicToCartesian(cart, viewExtent3DSouthWest);
807
+ cart.latitude = north;
808
+ var northWest = ellipsoid.cartographicToCartesian(cart, viewExtent3DNorthWest);
809
+
810
+ var center = Cartesian3.subtract(northEast, southWest, viewExtent3DCenter);
811
+ Cartesian3.multiplyByScalar(center, 0.5, center);
812
+ Cartesian3.add(southWest, center, center);
813
+
814
+ Cartesian3.subtract(northWest, center, northWest);
815
+ Cartesian3.subtract(southEast, center, southEast);
816
+ Cartesian3.subtract(northEast, center, northEast);
817
+ Cartesian3.subtract(southWest, center, southWest);
818
+
819
+ var direction = ellipsoid.geodeticSurfaceNormal(center, camera.direction);
820
+ Cartesian3.negate(direction, direction);
821
+ Cartesian3.normalize(direction, direction);
822
+ var right = Cartesian3.cross(direction, Cartesian3.UNIT_Z, camera.right);
823
+ Cartesian3.normalize(right, right);
824
+ var up = Cartesian3.cross(right, direction, camera.up);
825
+
826
+ var height = Math.max(Math.abs(up.dot(northWest)), Math.abs(up.dot(southEast)), Math.abs(up.dot(northEast)), Math.abs(up.dot(southWest)));
827
+ var width = Math.max(Math.abs(right.dot(northWest)), Math.abs(right.dot(southEast)), Math.abs(right.dot(northEast)), Math.abs(right.dot(southWest)));
828
+
829
+ var tanPhi = Math.tan(camera.frustum.fovy * 0.5);
830
+ var tanTheta = camera.frustum.aspectRatio * tanPhi;
831
+ var d = Math.max(width / tanTheta, height / tanPhi);
832
+
833
+ var scalar = center.magnitude() + d;
834
+ Cartesian3.normalize(center, center);
835
+ Cartesian3.multiplyByScalar(center, scalar, camera.position);
836
+ }
837
+
838
+ var viewExtentCVCartographic = new Cartographic();
839
+ var viewExtentCVNorthEast = Cartesian4.UNIT_W.clone();
840
+ var viewExtentCVSouthWest = Cartesian4.UNIT_W.clone();
841
+ var viewExtentCVTransform = new Matrix4();
842
+ function viewExtentColumbusView(camera, extent, projection) {
843
+ var north = extent.north;
844
+ var south = extent.south;
845
+ var east = extent.east;
846
+ var west = extent.west;
847
+
848
+ var transform = Matrix4.clone(camera.transform, viewExtentCVTransform);
849
+ transform.setColumn(3, Cartesian4.UNIT_W);
850
+ var invTransform = camera.getInverseTransform();
851
+
852
+ var cart = viewExtentCVCartographic;
853
+ cart.longitude = east;
854
+ cart.latitude = north;
855
+ var position = projection.project(cart);
856
+ var northEast = Cartesian3.clone(position, viewExtentCVNorthEast);
857
+ Matrix4.multiplyByVector(transform, northEast, northEast);
858
+ Matrix4.multiplyByVector(invTransform, northEast, northEast);
859
+
860
+ cart.longitude = west;
861
+ cart.latitude = south;
862
+ position = projection.project(cart);
863
+ var southWest = Cartesian3.clone(position, viewExtentCVSouthWest);
864
+ Matrix4.multiplyByVector(transform, southWest, southWest);
865
+ Matrix4.multiplyByVector(invTransform, southWest, southWest);
866
+
867
+ var tanPhi = Math.tan(camera.frustum.fovy * 0.5);
868
+ var tanTheta = camera.frustum.aspectRatio * tanPhi;
869
+
870
+ position = camera.position;
871
+ position.x = (northEast.x - southWest.x) * 0.5 + southWest.x;
872
+ position.y = (northEast.y - southWest.y) * 0.5 + southWest.y;
873
+ position.z = Math.max((northEast.x - southWest.x) / tanTheta, (northEast.y - southWest.y) / tanPhi) * 0.5;
874
+
875
+ var direction = Cartesian3.clone(Cartesian3.UNIT_Z, camera.direction);
876
+ Cartesian3.negate(direction, direction);
877
+ var right = Cartesian3.clone(Cartesian3.UNIT_X, camera.right);
878
+ Cartesian3.cross(right, direction, camera.up);
879
+ }
880
+
881
+ var viewExtent2DCartographic = new Cartographic();
882
+ function viewExtent2D(camera, extent, projection) {
883
+ var north = extent.north;
884
+ var south = extent.south;
885
+ var east = extent.east;
886
+ var west = extent.west;
887
+
888
+ var cart = viewExtent2DCartographic;
889
+ cart.longitude = east;
890
+ cart.latitude = north;
891
+ var northEast = projection.project(cart);
892
+ cart.longitude = west;
893
+ cart.latitude = south;
894
+ var southWest = projection.project(cart);
895
+
896
+ var width = Math.abs(northEast.x - southWest.x) * 0.5;
897
+ var height = Math.abs(northEast.y - southWest.y) * 0.5;
898
+
899
+ var right, top;
900
+ var ratio = camera.frustum.right / camera.frustum.top;
901
+ var heightRatio = height * ratio;
902
+ if (width > heightRatio) {
903
+ right = width;
904
+ top = right / ratio;
905
+ } else {
906
+ top = height;
907
+ right = heightRatio;
908
+ }
909
+
910
+ camera.frustum.right = right;
911
+ camera.frustum.left = -right;
912
+ camera.frustum.top = top;
913
+ camera.frustum.bottom = -top;
914
+
915
+ camera.position.x = (northEast.x - southWest.x) * 0.5 + southWest.x;
916
+ camera.position.y = (northEast.y - southWest.y) * 0.5 + southWest.y;
917
+
918
+ //Orient the camera north.
919
+ var cameraRight = Cartesian3.clone(Cartesian3.UNIT_X, camera.right);
920
+ Cartesian3.cross(cameraRight, camera.direction, camera.up);
921
+ }
922
+
923
+ /**
924
+ * View an extent on an ellipsoid or map.
925
+ * @memberof CameraController
926
+ *
927
+ * @param {Extent} extent The extent to view.
928
+ * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid to view.
929
+ *
930
+ * @exception {DeveloperError} extent is required.
931
+ */
932
+ CameraController.prototype.viewExtent = function(extent, ellipsoid) {
933
+ if (typeof extent === 'undefined') {
934
+ throw new DeveloperError('extent is required.');
935
+ }
936
+ ellipsoid = (typeof ellipsoid === 'undefined') ? Ellipsoid.WGS84 : ellipsoid;
937
+
938
+ if (this._mode === SceneMode.SCENE3D) {
939
+ viewExtent3D(this._camera, extent, ellipsoid);
940
+ } else if (this._mode === SceneMode.COLUMBUS_VIEW) {
941
+ viewExtentColumbusView(this._camera, extent, this._projection);
942
+ } else if (this._mode === SceneMode.SCENE2D) {
943
+ viewExtent2D(this._camera, extent, this._projection);
944
+ }
945
+ };
946
+
947
+ var pickEllipsoid3DRay = new Ray();
948
+ function pickEllipsoid3D(controller, windowPosition, ellipsoid, result) {
949
+ ellipsoid = ellipsoid || Ellipsoid.WGS84;
950
+ var ray = controller.getPickRay(windowPosition, pickEllipsoid3DRay);
951
+ var intersection = IntersectionTests.rayEllipsoid(ray, ellipsoid);
952
+ if (!intersection) {
953
+ return undefined;
954
+ }
955
+
956
+ return ray.getPoint(intersection.start, result);
957
+ }
958
+
959
+ var pickEllipsoid2DRay = new Ray();
960
+ function pickMap2D(controller, windowPosition, projection, result) {
961
+ var ray = controller.getPickRay(windowPosition, pickEllipsoid2DRay);
962
+ var position = ray.origin;
963
+ position.z = 0.0;
964
+ var cart = projection.unproject(position);
965
+
966
+ if (cart.latitude < -CesiumMath.PI_OVER_TWO || cart.latitude > CesiumMath.PI_OVER_TWO ||
967
+ cart.longitude < - Math.PI || cart.longitude > Math.PI) {
968
+ return undefined;
969
+ }
970
+
971
+ return projection.getEllipsoid().cartographicToCartesian(cart, result);
972
+ }
973
+
974
+ var pickEllipsoidCVRay = new Ray();
975
+ function pickMapColumbusView(controller, windowPosition, projection, result) {
976
+ var ray = controller.getPickRay(windowPosition, pickEllipsoidCVRay);
977
+ var scalar = -ray.origin.x / ray.direction.x;
978
+ ray.getPoint(scalar, result);
979
+
980
+ var cart = projection.unproject(new Cartesian3(result.y, result.z, 0.0));
981
+
982
+ if (cart.latitude < -CesiumMath.PI_OVER_TWO || cart.latitude > CesiumMath.PI_OVER_TWO ||
983
+ cart.longitude < - Math.PI || cart.longitude > Math.PI) {
984
+ return undefined;
985
+ }
986
+
987
+ return projection.getEllipsoid().cartographicToCartesian(cart, result);
988
+ }
989
+
990
+ /**
991
+ * Pick an ellipsoid or map.
992
+ * @memberof CameraController
993
+ *
994
+ * @param {Cartesian2} windowPosition The x and y coordinates of a pixel.
995
+ * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid to pick.
996
+ * @param {Cartesian3} [result] The object onto which to store the result.
997
+ *
998
+ * @exception {DeveloperError} windowPosition is required.
999
+ *
1000
+ * @return {Cartesian3} If the ellipsoid or map was picked, returns the point on the surface of the ellipsoid or map
1001
+ * in world coordinates. If the ellipsoid or map was not picked, returns undefined.
1002
+ */
1003
+ CameraController.prototype.pickEllipsoid = function(windowPosition, ellipsoid, result) {
1004
+ if (typeof windowPosition === 'undefined') {
1005
+ throw new DeveloperError('windowPosition is required.');
1006
+ }
1007
+
1008
+ if (typeof result === 'undefined') {
1009
+ result = new Cartesian3();
1010
+ }
1011
+
1012
+ ellipsoid = ellipsoid || Ellipsoid.WGS84;
1013
+
1014
+ if (this._mode === SceneMode.SCENE3D) {
1015
+ result = pickEllipsoid3D(this, windowPosition, ellipsoid, result);
1016
+ } else if (this._mode === SceneMode.SCENE2D) {
1017
+ result = pickMap2D(this, windowPosition, this._projection, result);
1018
+ } else if (this._mode === SceneMode.COLUMBUS_VIEW) {
1019
+ result = pickMapColumbusView(this, windowPosition, this._projection, result);
1020
+ }
1021
+
1022
+ return result;
1023
+ };
1024
+
1025
+ var pickPerspCenter = new Cartesian3();
1026
+ var pickPerspXDir = new Cartesian3();
1027
+ var pickPerspYDir = new Cartesian3();
1028
+ function getPickRayPerspective(camera, windowPosition, result) {
1029
+ var width = camera._canvas.clientWidth;
1030
+ var height = camera._canvas.clientHeight;
1031
+
1032
+ var tanPhi = Math.tan(camera.frustum.fovy * 0.5);
1033
+ var tanTheta = camera.frustum.aspectRatio * tanPhi;
1034
+ var near = camera.frustum.near;
1035
+
1036
+ var x = (2.0 / width) * windowPosition.x - 1.0;
1037
+ var y = (2.0 / height) * (height - windowPosition.y) - 1.0;
1038
+
1039
+ var position = camera.getPositionWC();
1040
+ Cartesian3.clone(position, result.origin);
1041
+
1042
+ var nearCenter = Cartesian3.multiplyByScalar(camera.getDirectionWC(), near, pickPerspCenter);
1043
+ Cartesian3.add(position, nearCenter, nearCenter);
1044
+ var xDir = Cartesian3.multiplyByScalar(camera.getRightWC(), x * near * tanTheta, pickPerspXDir);
1045
+ var yDir = Cartesian3.multiplyByScalar(camera.getUpWC(), y * near * tanPhi, pickPerspYDir);
1046
+ var direction = Cartesian3.add(nearCenter, xDir, result.direction);
1047
+ Cartesian3.add(direction, yDir, direction);
1048
+ Cartesian3.subtract(direction, position, direction);
1049
+ Cartesian3.normalize(direction, direction);
1050
+
1051
+ return result;
1052
+ }
1053
+
1054
+ function getPickRayOrthographic(camera, windowPosition, result) {
1055
+ var width = camera._canvas.clientWidth;
1056
+ var height = camera._canvas.clientHeight;
1057
+
1058
+ var x = (2.0 / width) * windowPosition.x - 1.0;
1059
+ x *= (camera.frustum.right - camera.frustum.left) * 0.5;
1060
+ var y = (2.0 / height) * (height - windowPosition.y) - 1.0;
1061
+ y *= (camera.frustum.top - camera.frustum.bottom) * 0.5;
1062
+
1063
+ var origin = result.origin;
1064
+ Cartesian3.clone(camera.position, origin);
1065
+ origin.x += x;
1066
+ origin.y += y;
1067
+
1068
+ Cartesian3.clone(camera.getDirectionWC(), result.direction);
1069
+
1070
+ return result;
1071
+ }
1072
+
1073
+ /**
1074
+ * Create a ray from the camera position through the pixel at <code>windowPosition</code>
1075
+ * in world coordinates.
1076
+ *
1077
+ * @memberof CameraController
1078
+ *
1079
+ * @param {Cartesian2} windowPosition The x and y coordinates of a pixel.
1080
+ * @param {Ray} [result] The object onto which to store the result.
1081
+ *
1082
+ * @exception {DeveloperError} windowPosition is required.
1083
+ *
1084
+ * @return {Object} Returns the {@link Cartesian3} position and direction of the ray.
1085
+ */
1086
+ CameraController.prototype.getPickRay = function(windowPosition, result) {
1087
+ if (typeof windowPosition === 'undefined') {
1088
+ throw new DeveloperError('windowPosition is required.');
1089
+ }
1090
+
1091
+ if (typeof result === 'undefined') {
1092
+ result = new Ray();
1093
+ }
1094
+
1095
+ var camera = this._camera;
1096
+ var frustum = camera.frustum;
1097
+ if (typeof frustum.aspectRatio !== 'undefined' && typeof frustum.fovy !== 'undefined' && typeof frustum.near !== 'undefined') {
1098
+ return getPickRayPerspective(camera, windowPosition, result);
1099
+ }
1100
+
1101
+ return getPickRayOrthographic(camera, windowPosition, result);
1102
+ };
1103
+
1104
+ function createAnimation2D(controller, duration) {
1105
+ var camera = controller._camera;
1106
+
1107
+ var position = camera.position;
1108
+ var translateX = position.x < -controller._maxCoord.x || position.x > controller._maxCoord.x;
1109
+ var translateY = position.y < -controller._maxCoord.y || position.y > controller._maxCoord.y;
1110
+ var animatePosition = translateX || translateY;
1111
+
1112
+ var frustum = camera.frustum;
1113
+ var top = frustum.top;
1114
+ var bottom = frustum.bottom;
1115
+ var right = frustum.right;
1116
+ var left = frustum.left;
1117
+ var startFrustum = controller._frustum;
1118
+ var animateFrustum = right > controller._frustum.right;
1119
+
1120
+ if (animatePosition || animateFrustum) {
1121
+ var translatedPosition = position.clone();
1122
+
1123
+ if (translatedPosition.x > controller._maxCoord.x) {
1124
+ translatedPosition.x = controller._maxCoord.x;
1125
+ } else if (translatedPosition.x < -controller._maxCoord.x) {
1126
+ translatedPosition.x = -controller._maxCoord.x;
1127
+ }
1128
+
1129
+ if (translatedPosition.y > controller._maxCoord.y) {
1130
+ translatedPosition.y = controller._maxCoord.y;
1131
+ } else if (translatedPosition.y < -controller._maxCoord.y) {
1132
+ translatedPosition.y = -controller._maxCoord.y;
1133
+ }
1134
+
1135
+ var update2D = function(value) {
1136
+ if (animatePosition) {
1137
+ camera.position = position.lerp(translatedPosition, value.time);
1138
+ }
1139
+ if (animateFrustum) {
1140
+ camera.frustum.top = CesiumMath.lerp(top, startFrustum.top, value.time);
1141
+ camera.frustum.bottom = CesiumMath.lerp(bottom, startFrustum.bottom, value.time);
1142
+ camera.frustum.right = CesiumMath.lerp(right, startFrustum.right, value.time);
1143
+ camera.frustum.left = CesiumMath.lerp(left, startFrustum.left, value.time);
1144
+ }
1145
+ };
1146
+
1147
+ return {
1148
+ easingFunction : Tween.Easing.Exponential.Out,
1149
+ startValue : {
1150
+ time : 0.0
1151
+ },
1152
+ stopValue : {
1153
+ time : 1.0
1154
+ },
1155
+ duration : duration,
1156
+ onUpdate : update2D
1157
+ };
1158
+ }
1159
+
1160
+ return undefined;
1161
+ }
1162
+
1163
+ function createAnimationTemplateCV(controller, position, center, maxX, maxY, duration) {
1164
+ var newPosition = position.clone();
1165
+
1166
+ if (center.y > maxX) {
1167
+ newPosition.y -= center.y - maxX;
1168
+ } else if (center.y < -maxX) {
1169
+ newPosition.y += -maxX - center.y;
1170
+ }
1171
+
1172
+ if (center.z > maxY) {
1173
+ newPosition.z -= center.z - maxY;
1174
+ } else if (center.z < -maxY) {
1175
+ newPosition.z += -maxY - center.z;
1176
+ }
1177
+
1178
+ var camera = controller._camera;
1179
+ var updateCV = function(value) {
1180
+ var interp = position.lerp(newPosition, value.time);
1181
+ var pos = new Cartesian4(interp.x, interp.y, interp.z, 1.0);
1182
+ camera.position = Cartesian3.fromCartesian4(camera.getInverseTransform().multiplyByVector(pos));
1183
+ };
1184
+
1185
+ return {
1186
+ easingFunction : Tween.Easing.Exponential.Out,
1187
+ startValue : {
1188
+ time : 0.0
1189
+ },
1190
+ stopValue : {
1191
+ time : 1.0
1192
+ },
1193
+ duration : duration,
1194
+ onUpdate : updateCV
1195
+ };
1196
+ }
1197
+
1198
+ function createAnimationCV(controller, duration) {
1199
+ var camera = controller._camera;
1200
+ var ellipsoid = controller._projection.getEllipsoid();
1201
+ var position = camera.position;
1202
+ var direction = camera.direction;
1203
+
1204
+ var normal = Cartesian3.fromCartesian4(camera.getInverseTransform().multiplyByVector(Cartesian4.UNIT_X));
1205
+ var scalar = -normal.dot(position) / normal.dot(direction);
1206
+ var center = position.add(direction.multiplyByScalar(scalar));
1207
+ center = new Cartesian4(center.x, center.y, center.z, 1.0);
1208
+ var centerWC = camera.transform.multiplyByVector(center);
1209
+
1210
+ var cameraPosition = new Cartesian4(camera.position.x, camera.position.y, camera.position.z, 1.0);
1211
+ var positionWC = camera.transform.multiplyByVector(cameraPosition);
1212
+
1213
+ var tanPhi = Math.tan(controller._camera.frustum.fovy * 0.5);
1214
+ var tanTheta = controller._camera.frustum.aspectRatio * tanPhi;
1215
+ var distToC = positionWC.subtract(centerWC).magnitude();
1216
+ var dWidth = tanTheta * distToC;
1217
+ var dHeight = tanPhi * distToC;
1218
+
1219
+ var mapWidth = ellipsoid.getRadii().x * Math.PI;
1220
+ var mapHeight = ellipsoid.getRadii().y * CesiumMath.PI_OVER_TWO;
1221
+
1222
+ var maxX = Math.max(dWidth - mapWidth, mapWidth);
1223
+ var maxY = Math.max(dHeight - mapHeight, mapHeight);
1224
+
1225
+ if (positionWC.x < -maxX || positionWC.x > maxX || positionWC.y < -maxY || positionWC.y > maxY) {
1226
+ var translateX = centerWC.y < -maxX || centerWC.y > maxX;
1227
+ var translateY = centerWC.z < -maxY || centerWC.z > maxY;
1228
+ if (translateX || translateY) {
1229
+ return createAnimationTemplateCV(controller, Cartesian3.fromCartesian4(positionWC), Cartesian3.fromCartesian4(centerWC), maxX, maxY, duration);
1230
+ }
1231
+ }
1232
+
1233
+ return undefined;
1234
+ }
1235
+
1236
+ /**
1237
+ * Create an animation to move the map into view. This method is only valid for 2D and Columbus modes.
1238
+ * @memberof CameraController
1239
+ * @param {Number} duration The duration, in milliseconds, of the animation.
1240
+ * @exception {DeveloperException} duration is required.
1241
+ * @returns {Object} The animation or undefined if the scene mode is 3D or the map is already ion view.
1242
+ */
1243
+ CameraController.prototype.createCorrectPositionAnimation = function(duration) {
1244
+ if (typeof duration === 'undefined') {
1245
+ throw new DeveloperError('duration is required.');
1246
+ }
1247
+
1248
+ if (this._mode === SceneMode.SCENE2D) {
1249
+ return createAnimation2D(this, duration);
1250
+ } else if (this._mode === SceneMode.COLUMBUS_VIEW) {
1251
+ return createAnimationCV(this, duration);
1252
+ }
1253
+
1254
+ return undefined;
1255
+ };
1256
+
1257
+ return CameraController;
1258
+ });