cesium 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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,441 @@
1
+ /*global define*/
2
+ define([
3
+ '../Core/defaultValue',
4
+ '../Core/DeveloperError',
5
+ '../Core/destroyObject',
6
+ '../Core/BoundingSphere',
7
+ '../Core/Cartesian3',
8
+ '../Core/Color',
9
+ '../Core/PolylinePipeline'
10
+ ], function(
11
+ defaultValue,
12
+ DeveloperError,
13
+ destroyObject,
14
+ BoundingSphere,
15
+ Cartesian3,
16
+ Color,
17
+ PolylinePipeline) {
18
+ "use strict";
19
+
20
+ var EMPTY_OBJECT = {};
21
+
22
+ /**
23
+ * DOC_TBA
24
+ *
25
+ * @alias Polyline
26
+ * @internalConstructor
27
+ */
28
+ var Polyline = function(description, polylineCollection) {
29
+ description = defaultValue(description, EMPTY_OBJECT);
30
+
31
+ this._show = defaultValue(description.show, true);
32
+ this._width = defaultValue(description.width, 1.0);
33
+ this._outlineWidth = defaultValue(description.outlineWidth, 1.0);
34
+ this._color = Color.clone(defaultValue(description.color, Color.WHITE));
35
+ this._outlineColor = Color.clone(defaultValue(description.outlineColor, Color.WHITE));
36
+
37
+ var positions = description.positions;
38
+ if (typeof positions === 'undefined') {
39
+ positions = [];
40
+ }
41
+
42
+ this._positions = positions;
43
+ this._positionsLength = positions.length;
44
+ this._actualLength = positions.length;
45
+
46
+ this._propertiesChanged = new Uint32Array(NUMBER_OF_PROPERTIES);
47
+ this._polylineCollection = polylineCollection;
48
+ this._dirty = false;
49
+ this._pickId = undefined;
50
+ this._pickIdThis = description._pickIdThis;
51
+ this._segments = undefined;
52
+ this._boundingVolume = BoundingSphere.fromPoints(this._positions);
53
+ this._boundingVolume2D = new BoundingSphere(); // modified in PolylineCollection
54
+ };
55
+
56
+ var SHOW_INDEX = Polyline.SHOW_INDEX = 0;
57
+ var POSITION_INDEX = Polyline.POSITION_INDEX = 1;
58
+ var COLOR_INDEX = Polyline.COLOR_INDEX = 2;
59
+ var OUTLINE_COLOR_INDEX = Polyline.OUTLINE_COLOR_INDEX = 3;
60
+ var WIDTH_INDEX = Polyline.WIDTH_INDEX = 4;
61
+ var OUTLINE_WIDTH_INDEX = Polyline.OUTLINE_WIDTH_INDEX = 5;
62
+ var POSITION_SIZE_INDEX = Polyline.POSITION_SIZE_INDEX = 6;
63
+ var NUMBER_OF_PROPERTIES = Polyline.NUMBER_OF_PROPERTIES = 7;
64
+
65
+ function makeDirty(polyline, propertyChanged) {
66
+ ++polyline._propertiesChanged[propertyChanged];
67
+ var polylineCollection = polyline._polylineCollection;
68
+ if (typeof polylineCollection !== 'undefined') {
69
+ polylineCollection._updatePolyline(polyline, propertyChanged);
70
+ polyline._dirty = true;
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Returns true if this polyline will be shown. Call {@link Polyline#setShow}
76
+ * to hide or show a polyline, instead of removing it and re-adding it to the collection.
77
+ *
78
+ * @memberof Polyline
79
+ *
80
+ * @return {Boolean} <code>true</code> if this polyline will be shown; otherwise, <code>false</code>.
81
+ *
82
+ * @see Polyline#setShow
83
+ */
84
+ Polyline.prototype.getShow = function() {
85
+ return this._show;
86
+ };
87
+
88
+ /**
89
+ * Determines if this polyline will be shown. Call this to hide or show a polyline, instead
90
+ * of removing it and re-adding it to the collection.
91
+ *
92
+ * @memberof Polyline
93
+ *
94
+ * @param {Boolean} value Indicates if this polyline will be shown.
95
+ *
96
+ * @exception {DeveloperError} value is required.
97
+ *
98
+ * @see Polyline#getShow
99
+ */
100
+ Polyline.prototype.setShow = function(value) {
101
+ if (typeof value === 'undefined') {
102
+ throw new DeveloperError('value is required.');
103
+ }
104
+
105
+ if (value !== this._show) {
106
+ this._show = value;
107
+ makeDirty(this, SHOW_INDEX);
108
+ }
109
+ };
110
+
111
+ /**
112
+ * Returns the polyline's positions.
113
+ *
114
+ * @memberof Polyline
115
+ *
116
+ * @see Polyline#setPositions
117
+ */
118
+ Polyline.prototype.getPositions = function() {
119
+ return this._positions;
120
+ };
121
+
122
+ /**
123
+ * Defines the positions of the polyline.
124
+ *
125
+ * @memberof Polyline
126
+ *
127
+ * @param {Array} value The positions of the polyline.
128
+ *
129
+ * @exception {DeveloperError} value is required.
130
+ *
131
+ * @see Polyline#getPositions
132
+ *
133
+ * @example
134
+ * polyline.setPositions(
135
+ * ellipsoid.cartographicArrayToCartesianArray([
136
+ * new Cartographic3(...),
137
+ * new Cartographic3(...),
138
+ * new Cartographic3(...)
139
+ * ])
140
+ * );
141
+ */
142
+ Polyline.prototype.setPositions = function(value) {
143
+ if (typeof value === 'undefined') {
144
+ throw new DeveloperError('value is required.');
145
+ }
146
+
147
+ if (this._positionsLength !== value.length) {
148
+ this._positionsLength = value.length;
149
+ makeDirty(this, POSITION_SIZE_INDEX);
150
+ }
151
+
152
+ this._positions = value;
153
+ this._boundingVolume = BoundingSphere.fromPoints(this._positions, this._boundingVolume);
154
+ makeDirty(this, POSITION_INDEX);
155
+ };
156
+
157
+ /**
158
+ * Returns the color of the polyline.
159
+ *
160
+ * @memberof Polyline
161
+ *
162
+ * @return {Color} The color of the polyline.
163
+ *
164
+ * @see Polyline#setColor
165
+ */
166
+ Polyline.prototype.getColor = function() {
167
+ return this._color;
168
+ };
169
+
170
+ /**
171
+ * Sets the color of the polyline.
172
+ *
173
+ * @memberof Polyline
174
+ *
175
+ * @param {Color} value The color of the polyline.
176
+ *
177
+ * @exception {DeveloperError} value is required.
178
+ *
179
+ * @see Polyline#getColor
180
+ */
181
+ Polyline.prototype.setColor = function(value) {
182
+ if (typeof value === 'undefined') {
183
+ throw new DeveloperError('value is required.');
184
+ }
185
+
186
+ var color = this._color;
187
+ if (!Color.equals(color, value)) {
188
+ Color.clone(value, color);
189
+ makeDirty(this, COLOR_INDEX);
190
+ }
191
+ };
192
+
193
+ /**
194
+ * Gets the width of the polyline.
195
+ * The actual width used is clamped to the minimum and maximum width supported by
196
+ * the WebGL implementation. These can be queried with
197
+ * {@link Context#getMinimumAliasedLineWidth} and {@link Context#getMaximumAliasedLineWidth}.
198
+ *
199
+ * @memberof Polyline
200
+ *
201
+ * @return {Number} The width of the polyline.
202
+ *
203
+ * @see Polyline#setWidth
204
+ * @see Context#getMinimumAliasedLineWidth
205
+ * @see Context#getMaximumAliasedLineWidth
206
+ *
207
+ * @example
208
+ * // 3 pixel total width, 1 pixel interior width
209
+ * polyline.width = 1.0;
210
+ * polyline.outlineWidth = 3.0;
211
+ */
212
+ Polyline.prototype.getWidth = function() {
213
+ return this._width;
214
+ };
215
+
216
+ /**
217
+ * Sets the width of the polyline.
218
+ * The actual width used is clamped to the minimum and maximum width supported by
219
+ * the WebGL implementation. These can be queried with
220
+ * {@link Context#getMinimumAliasedLineWidth} and {@link Context#getMaximumAliasedLineWidth}.
221
+ *
222
+ * @param {Number} value The width of the polyline.
223
+ *
224
+ * @exception {DeveloperError} value is required.
225
+ *
226
+ * @see Polyline#getWidth
227
+ * @see Context#getMinimumAliasedLineWidth
228
+ * @see Context#getMaximumAliasedLineWidth
229
+ *
230
+ * @example
231
+ * // 3 pixel total width, 1 pixel interior width
232
+ * polyline.width = 1.0;
233
+ * polyline.outlineWidth = 3.0;
234
+ */
235
+ Polyline.prototype.setWidth = function(value) {
236
+ if (typeof value === 'undefined') {
237
+ throw new DeveloperError('value is required.');
238
+ }
239
+
240
+ var width = this._width;
241
+ if (value !== width) {
242
+ this._width = value;
243
+ makeDirty(this, WIDTH_INDEX);
244
+ }
245
+ };
246
+
247
+
248
+ /**
249
+ * Gets the outline width of the polyline.
250
+ * The actual width used is clamped to the minimum and maximum width supported by
251
+ * the WebGL implementation. These can be queried with
252
+ * {@link Context#getMinimumAliasedLineWidth} and {@link Context#getMaximumAliasedLineWidth}.
253
+ *
254
+ * @return {Number} The outline width of the polyline.
255
+ *
256
+ * @see Polyline#setOutlineWidth
257
+ * @see Context#getMinimumAliasedLineWidth
258
+ * @see Context#getMaximumAliasedLineWidth
259
+ *
260
+ * @example
261
+ * // 3 pixel total width, 1 pixel interior width
262
+ * polyline.width = 1.0;
263
+ * polyline.outlineWidth = 3.0;
264
+ */
265
+ Polyline.prototype.getOutlineWidth = function() {
266
+ return this._outlineWidth;
267
+ };
268
+
269
+ /**
270
+ * Sets the outline width of the polyline.
271
+ * The actual width used is clamped to the minimum and maximum width supported by
272
+ * the WebGL implementation. These can be queried with
273
+ * {@link Context#getMinimumAliasedLineWidth} and {@link Context#getMaximumAliasedLineWidth}.
274
+ *
275
+ * @param {Number} value The outline width of the polyline.
276
+ *
277
+ * @exception {DeveloperError} value is required.
278
+ *
279
+ * @see Polyline#getOutlineWidth
280
+ * @see Context#getMinimumAliasedLineWidth
281
+ * @see Context#getMaximumAliasedLineWidth
282
+ *
283
+ * @example
284
+ * // 3 pixel total width, 1 pixel interior width
285
+ * polyline.width = 1.0;
286
+ * polyline.outlineWidth = 3.0;
287
+ */
288
+ Polyline.prototype.setOutlineWidth = function(value) {
289
+ if (typeof value === 'undefined') {
290
+ throw new DeveloperError('value is required.');
291
+ }
292
+
293
+ var outlineWidth = this._outlineWidth;
294
+ if (value !== outlineWidth) {
295
+ this._outlineWidth = value;
296
+ makeDirty(this, OUTLINE_WIDTH_INDEX);
297
+ }
298
+ };
299
+
300
+ /**
301
+ * Gets the outline color of the polyline.
302
+ *
303
+ * @memberof Polyline
304
+ *
305
+ * @return {Color} The outline color of the polyline.
306
+ *
307
+ * @see Polyline#setOutlineColor
308
+ */
309
+ Polyline.prototype.getOutlineColor = function() {
310
+ return this._outlineColor;
311
+ };
312
+
313
+ /**
314
+ * Sets the outline color of the polyline.
315
+ *
316
+ * @memberof Polyline
317
+ *
318
+ * @param {Color} value The outline color of the polyline.
319
+ *
320
+ * @exception {DeveloperError} value is required.
321
+ *
322
+ * @see Polyline#getOutlineColor
323
+ */
324
+ Polyline.prototype.setOutlineColor = function(value) {
325
+ if (typeof value === 'undefined') {
326
+ throw new DeveloperError('value is required.');
327
+ }
328
+
329
+ var outlineColor = this._outlineColor;
330
+ if (!Color.equals(outlineColor, value)) {
331
+ Color.clone(value, outlineColor);
332
+ makeDirty(this, OUTLINE_COLOR_INDEX);
333
+ }
334
+ };
335
+
336
+ Polyline.prototype.getPickId = function(context) {
337
+ this._pickId = this._pickId || context.createPickId(this._pickIdThis || this);
338
+ return this._pickId;
339
+ };
340
+
341
+ Polyline.prototype._clean = function() {
342
+ this._dirty = false;
343
+ var properties = this._propertiesChanged;
344
+ for ( var k = 0; k < NUMBER_OF_PROPERTIES - 1; ++k) {
345
+ properties[k] = 0;
346
+ }
347
+ };
348
+
349
+ Polyline.prototype._getPositions2D = function() {
350
+ var segments = this._segments;
351
+ var positions = [];
352
+ var numberOfSegments = segments.length;
353
+
354
+ for ( var i = 0; i < numberOfSegments; ++i) {
355
+ var segment = segments[i];
356
+ var segmentLength = segment.length;
357
+ for ( var n = 0; n < segmentLength; ++n) {
358
+ positions.push(segment[n].cartesian);
359
+ }
360
+ }
361
+ return positions;
362
+ };
363
+
364
+ Polyline.prototype._createSegments = function(ellipsoid) {
365
+ return PolylinePipeline.wrapLongitude(ellipsoid, this.getPositions());
366
+ };
367
+
368
+ Polyline.prototype._setSegments = function(segments) {
369
+ this._segments = segments;
370
+ var numberOfSegments = segments.length;
371
+ var length = 0;
372
+ for ( var i = 0; i < numberOfSegments; ++i) {
373
+ var segment = segments[i];
374
+ var segmentLength = segment.length;
375
+ length += segmentLength;
376
+ }
377
+ return length;
378
+ };
379
+
380
+ Polyline.prototype._getSegments = function() {
381
+ return this._segments;
382
+ };
383
+
384
+ Polyline.prototype._segmentsLengthChanged = function(newSegments) {
385
+ var origSegments = this._segments;
386
+ if (typeof origSegments !== 'undefined') {
387
+ var numberOfSegments = newSegments.length;
388
+ if (numberOfSegments !== origSegments.length) {
389
+ return true;
390
+ }
391
+ for ( var i = 0; i < numberOfSegments; ++i) {
392
+ if (newSegments[i].length !== origSegments[i].length) {
393
+ return true;
394
+ }
395
+ }
396
+ return false;
397
+ }
398
+ return true;
399
+ };
400
+
401
+ /**
402
+ * Determines if this polyline equals another polyline. Polylines are equal if all their properties
403
+ * are equal. Polylines in different collections can be equal.
404
+ *
405
+ * @memberof Polyline
406
+ *
407
+ * @param {Polyline} other The polyline to compare for equality.
408
+ *
409
+ * @return {Boolean} <code>true</code> if the polylines are equal; otherwise, <code>false</code>.
410
+ */
411
+ Polyline.prototype.equals = function(other) {
412
+ return this === other ||
413
+ typeof other !== 'undefined' &&
414
+ this._show === other._show &&
415
+ this._width === other._width &&
416
+ this._outlineWidth === other._outlineWidth &&
417
+ this._horizontalOrigin === other._horizontalOrigin &&
418
+ cartesian3ArrayEquals(this._positions, other._positions) &&
419
+ Color.equals(this._color, other._color) &&
420
+ Color.equals(this._outlineColor, other._outlineColor);
421
+ };
422
+
423
+ function cartesian3ArrayEquals(a, b) {
424
+ if (a.length !== b.length) {
425
+ return false;
426
+ }
427
+ for ( var i = 0, len = a.length; i < len; ++i) {
428
+ if (!Cartesian3.equals(a[i], b[i])) {
429
+ return false;
430
+ }
431
+ }
432
+ return true;
433
+ }
434
+
435
+ Polyline.prototype._destroy = function() {
436
+ this._pickId = this._pickId && this._pickId.destroy();
437
+ this._polylineCollection = undefined;
438
+ };
439
+
440
+ return Polyline;
441
+ });
@@ -0,0 +1,1532 @@
1
+ /*global define*/
2
+ define([
3
+ '../Core/DeveloperError',
4
+ '../Core/combine',
5
+ '../Core/destroyObject',
6
+ '../Core/Cartesian3',
7
+ '../Core/Cartesian4',
8
+ '../Core/EncodedCartesian3',
9
+ '../Core/Matrix4',
10
+ '../Core/ComponentDatatype',
11
+ '../Core/IndexDatatype',
12
+ '../Core/PrimitiveType',
13
+ '../Core/Color',
14
+ '../Core/BoundingSphere',
15
+ '../Core/Intersect',
16
+ '../Renderer/BlendingState',
17
+ '../Renderer/BufferUsage',
18
+ '../Renderer/CommandLists',
19
+ '../Renderer/DrawCommand',
20
+ './SceneMode',
21
+ './Polyline',
22
+ '../Shaders/PolylineVS',
23
+ '../Shaders/PolylineFS',
24
+ '../Renderer/StencilFunction',
25
+ '../Renderer/StencilOperation'
26
+ ], function(
27
+ DeveloperError,
28
+ combine,
29
+ destroyObject,
30
+ Cartesian3,
31
+ Cartesian4,
32
+ EncodedCartesian3,
33
+ Matrix4,
34
+ ComponentDatatype,
35
+ IndexDatatype,
36
+ PrimitiveType,
37
+ Color,
38
+ BoundingSphere,
39
+ Intersect,
40
+ BlendingState,
41
+ BufferUsage,
42
+ CommandLists,
43
+ DrawCommand,
44
+ SceneMode,
45
+ Polyline,
46
+ PolylineVS,
47
+ PolylineFS,
48
+ StencilFunction,
49
+ StencilOperation) {
50
+ "use strict";
51
+
52
+ var SHOW_INDEX = Polyline.SHOW_INDEX;
53
+ var POSITION_INDEX = Polyline.POSITION_INDEX;
54
+ var COLOR_INDEX = Polyline.COLOR_INDEX;
55
+ var OUTLINE_COLOR_INDEX = Polyline.OUTLINE_COLOR_INDEX;
56
+ var WIDTH_INDEX = Polyline.WIDTH_INDEX;
57
+ var OUTLINE_WIDTH_INDEX = Polyline.OUTLINE_WIDTH_INDEX;
58
+ //POSITION_SIZE_INDEX is needed for when the polyline's position array changes size.
59
+ //When it does, we need to recreate the indicesBuffer.
60
+ var POSITION_SIZE_INDEX = Polyline.POSITION_SIZE_INDEX;
61
+ var NUMBER_OF_PROPERTIES = Polyline.NUMBER_OF_PROPERTIES;
62
+ var SIXTYFOURK = 64 * 1024;
63
+
64
+ var attributeIndices = {
65
+ position3DHigh : 0,
66
+ position3DLow : 1,
67
+ position2DHigh : 2,
68
+ position2DLow : 3,
69
+ color : 4,
70
+ pickColor : 5,
71
+ show : 6
72
+ };
73
+
74
+ /**
75
+ * A renderable collection of polylines.
76
+ * <br /><br />
77
+ * <div align="center">
78
+ * <img src="images/Polyline.png" width="400" height="300" /><br />
79
+ * Example polylines
80
+ * </div>
81
+ * <br /><br />
82
+ * Polylines are added and removed from the collection using {@link PolylineCollection#add}
83
+ * and {@link PolylineCollection#remove}.
84
+ *
85
+ * @alias PolylineCollection
86
+ * @constructor
87
+ *
88
+ * @performance For best performance, prefer a few collections, each with many polylines, to
89
+ * many collections with only a few polylines each. Organize collections so that polylines
90
+ * with the same update frequency are in the same collection, i.e., polylines that do not
91
+ * change should be in one collection; polylines that change every frame should be in another
92
+ * collection; and so on.
93
+ *
94
+ * @see PolylineCollection#add
95
+ * @see PolylineCollection#remove
96
+ * @see Polyline
97
+ * @see LabelCollection
98
+ *
99
+ * @example
100
+ * // Create a polyline collection with two polylines
101
+ * var polylines = new PolylineCollection(undefined);
102
+ * polylines.add({positions:ellipsoid.cartographicDegreesToCartesians([
103
+ * new Cartographic2(-75.10, 39.57),
104
+ * new Cartographic2(-77.02, 38.53),
105
+ * new Cartographic2(-80.50, 35.14),
106
+ * new Cartographic2(-80.12, 25.46)]),
107
+ width:2
108
+ });
109
+
110
+ * polylines.add({positions:ellipsoid.cartographicDegreesToCartesians([
111
+ * new Cartographic2(-73.10, 37.57),
112
+ * new Cartographic2(-75.02, 36.53),
113
+ * new Cartographic2(-78.50, 33.14),
114
+ * new Cartographic2(-78.12, 23.46)]),
115
+ * width:4
116
+ * });
117
+ */
118
+ var PolylineCollection = function() {
119
+ /**
120
+ * The current morph transition time between 2D/Columbus View and 3D,
121
+ * with 0.0 being 2D or Columbus View and 1.0 being 3D.
122
+ *
123
+ * @type Number
124
+ */
125
+ this.morphTime = 1.0;
126
+
127
+ /**
128
+ * The 4x4 transformation matrix that transforms each polyline in this collection from model to world coordinates.
129
+ * When this is the identity matrix, the polylines are drawn in world coordinates, i.e., Earth's WGS84 coordinates.
130
+ * Local reference frames can be used by providing a different transformation matrix, like that returned
131
+ * by {@link Transforms.eastNorthUpToFixedFrame}. This matrix is available to GLSL vertex and fragment
132
+ * shaders via {@link czm_model} and derived uniforms.
133
+ *
134
+ * @type Matrix4
135
+ *
136
+ * @see Transforms.eastNorthUpToFixedFrame
137
+ * @see czm_model
138
+ */
139
+ this.modelMatrix = Matrix4.IDENTITY.clone();
140
+ this._modelMatrix = Matrix4.IDENTITY.clone();
141
+ this._sp = undefined;
142
+
143
+ this._boundingVolume = undefined;
144
+ this._boundingVolume2D = undefined;
145
+
146
+ this._commandLists = new CommandLists();
147
+
148
+ this._polylinesUpdated = false;
149
+ this._polylinesRemoved = false;
150
+ this._createVertexArray = false;
151
+ this._propertiesChanged = new Uint32Array(NUMBER_OF_PROPERTIES);
152
+ this._polylines = [];
153
+ this._polylineBuckets = {};
154
+
155
+ // The buffer usage for each attribute is determined based on the usage of the attribute over time.
156
+ this._buffersUsage = [
157
+ {bufferUsage: BufferUsage.STATIC_DRAW, frameCount:0},// SHOW_INDEX
158
+ {bufferUsage: BufferUsage.STATIC_DRAW, frameCount:0}, // POSITION_INDEX
159
+ {bufferUsage: BufferUsage.STATIC_DRAW, frameCount:0}, // COLOR_INDEX
160
+ {bufferUsage: BufferUsage.STATIC_DRAW, frameCount:0}, // OUTLINE_COLOR_INDEX
161
+ {bufferUsage: BufferUsage.STATIC_DRAW, frameCount:0}, // WIDTH_INDEX
162
+ {bufferUsage: BufferUsage.STATIC_DRAW, frameCount:0} // OUTLINE_WIDTH_INDEX
163
+ ];
164
+
165
+ this._mode = undefined;
166
+ var that = this;
167
+
168
+ this._uniforms = {
169
+ u_morphTime : function() {
170
+ return that.morphTime;
171
+ }
172
+ };
173
+
174
+ this._polylinesToUpdate = [];
175
+ this._colorVertexArrays = [];
176
+ this._outlineColorVertexArrays = [];
177
+ this._pickColorVertexArrays = [];
178
+ this._positionBuffer = undefined;
179
+ this._outlineColorBuffer = undefined;
180
+ this._colorBuffer = undefined;
181
+ this._pickColorBuffer = undefined;
182
+ this._showBuffer = undefined;
183
+ };
184
+
185
+ /**
186
+ * Creates and adds a polyline with the specified initial properties to the collection.
187
+ * The added polyline is returned so it can be modified or removed from the collection later.
188
+ *
189
+ * @memberof PolylineCollection
190
+ *
191
+ * @param {Object}[polyline=undefined] A template describing the polyline's properties as shown in Example 1.
192
+ *
193
+ * @return {Polyline} The polyline that was added to the collection.
194
+ *
195
+ * @performance After calling <code>add</code>, {@link PolylineCollection#update} is called and
196
+ * the collection's vertex buffer is rewritten - an <code>O(n)</code> operation that also incurs CPU to GPU overhead.
197
+ * For best performance, add as many polylines as possible before calling <code>update</code>.
198
+ *
199
+ * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
200
+ *
201
+ * @see PolylineCollection#remove
202
+ * @see PolylineCollection#removeAll
203
+ * @see PolylineCollection#update
204
+ *
205
+ * @example
206
+ * // Example 1: Add a polyline, specifying all the default values.
207
+ * var p = polylines.add({
208
+ * show : true,
209
+ * positions : ellipsoid.cartographicDegreesToCartesians([
210
+ * new Cartographic2(-75.10, 39.57),
211
+ * new Cartographic2(-77.02, 38.53)]),
212
+ * color : { red : 1.0, green : 1.0, blue : 1.0, alpha : 1.0 },
213
+ * width : 1,
214
+ * outlineWidth : 2
215
+ * });
216
+ *
217
+ */
218
+ PolylineCollection.prototype.add = function(polyline) {
219
+ var p = new Polyline(polyline, this);
220
+ p._index = this._polylines.length;
221
+ this._polylines.push(p);
222
+ this._createVertexArray = true;
223
+ return p;
224
+ };
225
+
226
+ /**
227
+ * Removes a polyline from the collection.
228
+ *
229
+ * @memberof PolylineCollection
230
+ *
231
+ * @param {Polyline} polyline The polyline to remove.
232
+ *
233
+ * @return {Boolean} <code>true</code> if the polyline was removed; <code>false</code> if the polyline was not found in the collection.
234
+ *
235
+ * @performance After calling <code>remove</code>, {@link PolylineCollection#update} is called and
236
+ * the collection's vertex buffer is rewritten - an <code>O(n)</code> operation that also incurs CPU to GPU overhead.
237
+ * For best performance, remove as many polylines as possible before calling <code>update</code>.
238
+ * If you intend to temporarily hide a polyline, it is usually more efficient to call
239
+ * {@link Polyline#setShow} instead of removing and re-adding the polyline.
240
+ *
241
+ * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
242
+ *
243
+ * @see PolylineCollection#add
244
+ * @see PolylineCollection#removeAll
245
+ * @see PolylineCollection#update
246
+ * @see Polyline#setShow
247
+ *
248
+ * @example
249
+ * var p = polylines.add(...);
250
+ * polylines.remove(p); // Returns true
251
+ */
252
+ PolylineCollection.prototype.remove = function(polyline) {
253
+ if (this.contains(polyline)) {
254
+ this._polylines[polyline._index] = null; // Removed later
255
+ this._polylinesRemoved = true;
256
+ this._createVertexArray = true;
257
+ polyline._destroy();
258
+ return true;
259
+ }
260
+
261
+ return false;
262
+ };
263
+
264
+ /**
265
+ * Removes all polylines from the collection.
266
+ *
267
+ * @performance <code>O(n)</code>. It is more efficient to remove all the polylines
268
+ * from a collection and then add new ones than to create a new collection entirely.
269
+ *
270
+ * @memberof PolylineCollection
271
+ *
272
+ * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
273
+ *
274
+ * @see PolylineCollection#add
275
+ * @see PolylineCollection#remove
276
+ * @see PolylineCollection#update
277
+ *
278
+ * @example
279
+ * polylines.add(...);
280
+ * polylines.add(...);
281
+ * polylines.removeAll();
282
+ */
283
+ PolylineCollection.prototype.removeAll = function() {
284
+ this._destroyPolylines();
285
+ this._polylineBuckets = {};
286
+ this._polylinesRemoved = false;
287
+ this._polylines.length = 0;
288
+ this._polylinesToUpdate.length = 0;
289
+ this._createVertexArray = true;
290
+ };
291
+
292
+ /**
293
+ * Determines if this collection contains the specified polyline.
294
+ *
295
+ * @memberof PolylineCollection
296
+ *
297
+ * @param {Polyline} polyline The polyline to check for.
298
+ *
299
+ * @return {Boolean} true if this collection contains the billboard, false otherwise.
300
+ *
301
+ * @see PolylineCollection#get
302
+ */
303
+ PolylineCollection.prototype.contains = function(polyline) {
304
+ return typeof polyline !== 'undefined' && polyline._polylineCollection === this;
305
+ };
306
+
307
+ /**
308
+ * Returns the polyline in the collection at the specified index. Indices are zero-based
309
+ * and increase as polylines are added. Removing a polyline shifts all polylines after
310
+ * it to the left, changing their indices. This function is commonly used with
311
+ * {@link PolylineCollection#getLength} to iterate over all the polylines
312
+ * in the collection.
313
+ *
314
+ * @memberof PolylineCollection
315
+ *
316
+ * @param {Number} index The zero-based index of the polyline.
317
+ *
318
+ * @return {Polyline} The polyline at the specified index.
319
+ *
320
+ * @performance If polylines were removed from the collection and
321
+ * {@link PolylineCollection#update} was not called, an implicit <code>O(n)</code>
322
+ * operation is performed.
323
+ *
324
+ * @exception {DeveloperError} index is required.
325
+ * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
326
+ *
327
+ * @see PolylineCollection#getLength
328
+ *
329
+ * @example
330
+ * // Toggle the show property of every polyline in the collection
331
+ * var len = polylines.getLength();
332
+ * for (var i = 0; i < len; ++i) {
333
+ * var p = polylines.get(i);
334
+ * p.setShow(!p.getShow());
335
+ * }
336
+ */
337
+ PolylineCollection.prototype.get = function(index) {
338
+ if (typeof index === 'undefined') {
339
+ throw new DeveloperError('index is required.');
340
+ }
341
+
342
+ this._removePolylines();
343
+ return this._polylines[index];
344
+ };
345
+
346
+ /**
347
+ * Returns the number of polylines in this collection. This is commonly used with
348
+ * {@link PolylineCollection#get} to iterate over all the polylines
349
+ * in the collection.
350
+ *
351
+ * @memberof PolylineCollection
352
+ *
353
+ * @return {Number} The number of polylines in this collection.
354
+ *
355
+ * @performance If polylines were removed from the collection and
356
+ * {@link PolylineCollection#update} was not called, an implicit <code>O(n)</code>
357
+ * operation is performed.
358
+ *
359
+ * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
360
+ *
361
+ * @see PolylineCollection#get
362
+ *
363
+ * @example
364
+ * // Toggle the show property of every polyline in the collection
365
+ * var len = polylines.getLength();
366
+ * for (var i = 0; i < len; ++i) {
367
+ * var p = polylines.get(i);
368
+ * p.setShow(!p.getShow());
369
+ * }
370
+ */
371
+ PolylineCollection.prototype.getLength = function() {
372
+ this._removePolylines();
373
+ return this._polylines.length;
374
+ };
375
+
376
+ /**
377
+ * Commits changes to properties before rendering by updating the object's WebGL resources.
378
+ *
379
+ * @memberof PolylineCollection
380
+ */
381
+ PolylineCollection.prototype.update = function(context, frameState, commandList) {
382
+ if (typeof this._sp === 'undefined') {
383
+ this._sp = context.getShaderCache().getShaderProgram(PolylineVS, PolylineFS, attributeIndices);
384
+ }
385
+ this._removePolylines();
386
+ this._updateMode(frameState);
387
+
388
+ var bucket;
389
+ var polyline;
390
+ var length;
391
+ var buckets;
392
+ var polylineBuckets;
393
+ var bucketLength;
394
+ var bucketLocator;
395
+
396
+ var properties = this._propertiesChanged;
397
+ if (this._createVertexArray || this._computeNewBuffersUsage()) {
398
+ this._createVertexArrays(context);
399
+ } else if (this._polylinesUpdated) {
400
+ // Polylines were modified, but no polylines were added or removed.
401
+ var polylinesToUpdate = this._polylinesToUpdate;
402
+ var createVertexArrays = false;
403
+ if (this._mode !== SceneMode.SCENE3D) {
404
+ var updateLength = polylinesToUpdate.length;
405
+ for ( var i = 0; i < updateLength; ++i) {
406
+ polyline = polylinesToUpdate[i];
407
+ var changedProperties = polyline._propertiesChanged;
408
+ if (changedProperties[POSITION_INDEX]) {
409
+ if (intersectsIDL(polyline)) {
410
+ var newSegments = polyline._createSegments(this._projection._ellipsoid);
411
+ if (polyline._segmentsLengthChanged(newSegments)) {
412
+ createVertexArrays = true;
413
+ break;
414
+ }
415
+ polyline._setSegments(newSegments);
416
+ }
417
+ }
418
+ }
419
+ }
420
+ //if a polyline's positions size changes, we need to recreate the vertex arrays and vertex buffers because the indices will be different.
421
+ if (properties[POSITION_SIZE_INDEX] || properties[WIDTH_INDEX] || properties[OUTLINE_WIDTH_INDEX] || createVertexArrays) {
422
+ this._createVertexArrays(context);
423
+ } else {
424
+ length = polylinesToUpdate.length;
425
+ polylineBuckets = this._polylineBuckets;
426
+ for ( var ii = 0; ii < length; ++ii) {
427
+ polyline = polylinesToUpdate[ii];
428
+ properties = polyline._propertiesChanged;
429
+ bucket = polyline._bucket;
430
+ var index = 0;
431
+ for ( var x in polylineBuckets) {
432
+ if (polylineBuckets.hasOwnProperty(x)) {
433
+ if (polylineBuckets[x] === bucket) {
434
+ if (properties[POSITION_INDEX]) {
435
+ bucket.writePositionsUpdate(index, polyline, this._positionBuffer);
436
+ }
437
+ if (properties[COLOR_INDEX]) {
438
+ bucket.writeColorUpdate(index, polyline, this._colorBuffer);
439
+ }
440
+ if (properties[OUTLINE_COLOR_INDEX]) {
441
+ bucket.writeColorUpdate(index, polyline, this._outlineColorBuffer);
442
+ }
443
+ if (properties[SHOW_INDEX]) {
444
+ bucket.writeShowUpdate(index, polyline, this._showBuffer);
445
+ }
446
+ break;
447
+ }
448
+ index += polylineBuckets[x].lengthOfPositions;
449
+ }
450
+ }
451
+ polyline._clean();
452
+ }
453
+ }
454
+ polylinesToUpdate.length = 0;
455
+ this._polylinesUpdated = false;
456
+ }
457
+
458
+ for ( var k = 0; k < NUMBER_OF_PROPERTIES; ++k) {
459
+ properties[k] = 0;
460
+ }
461
+
462
+ var boundingVolume;
463
+ var modelMatrix = Matrix4.IDENTITY;
464
+
465
+ if (frameState.mode === SceneMode.SCENE3D) {
466
+ boundingVolume = this._boundingVolume;
467
+ modelMatrix = this.modelMatrix;
468
+ } else if (frameState.mode === SceneMode.COLUMBUS_VIEW || frameState.mode === SceneMode.SCENE2D) {
469
+ boundingVolume = this._boundingVolume2D;
470
+ } else {
471
+ boundingVolume = this._boundingVolume && this._boundingVolume2D && this._boundingVolume.union(this._boundingVolume2D);
472
+ }
473
+
474
+ var pass = frameState.passes;
475
+ var commands;
476
+ var command;
477
+ polylineBuckets = this._polylineBuckets;
478
+ var sp = this._sp;
479
+ this._commandLists.removeAll();
480
+ if (typeof polylineBuckets !== 'undefined') {
481
+ if (pass.color) {
482
+ length = this._colorVertexArrays.length;
483
+ commands = this._commandLists.colorList;
484
+ for ( var m = 0; m < length; ++m) {
485
+ var vaColor = this._colorVertexArrays[m];
486
+ var vaOutlineColor = this._outlineColorVertexArrays[m];
487
+ buckets = this._colorVertexArrays[m].buckets;
488
+ bucketLength = buckets.length;
489
+ var p = commands.length;
490
+ commands.length += bucketLength * 3;
491
+ for ( var n = 0; n < bucketLength; ++n, p += 3) {
492
+ bucketLocator = buckets[n];
493
+
494
+ command = commands[p];
495
+ if (typeof command === 'undefined') {
496
+ command = commands[p] = new DrawCommand();
497
+ }
498
+
499
+ command.boundingVolume = boundingVolume;
500
+ command.modelMatrix = modelMatrix;
501
+ command.primitiveType = PrimitiveType.LINES;
502
+ command.count = bucketLocator.count;
503
+ command.offset = bucketLocator.offset;
504
+ command.shaderProgram = sp;
505
+ command.uniformMap = this._uniforms;
506
+ command.vertexArray = vaOutlineColor.va;
507
+ command.renderState = bucketLocator.rsOne;
508
+
509
+ command = commands[p + 1];
510
+ if (typeof command === 'undefined') {
511
+ command = commands[p + 1] = new DrawCommand();
512
+ }
513
+
514
+ command.boundingVolume = boundingVolume;
515
+ command.modelMatrix = modelMatrix;
516
+ command.primitiveType = PrimitiveType.LINES;
517
+ command.count = bucketLocator.count;
518
+ command.offset = bucketLocator.offset;
519
+ command.shaderProgram = sp;
520
+ command.uniformMap = this._uniforms;
521
+ command.vertexArray = vaColor.va;
522
+ command.renderState = bucketLocator.rsTwo;
523
+
524
+ command = commands[p + 2];
525
+ if (typeof command === 'undefined') {
526
+ command = commands[p + 2] = new DrawCommand();
527
+ }
528
+
529
+ command.boundingVolume = boundingVolume;
530
+ command.modelMatrix = modelMatrix;
531
+ command.primitiveType = PrimitiveType.LINES;
532
+ command.count = bucketLocator.count;
533
+ command.offset = bucketLocator.offset;
534
+ command.shaderProgram = sp;
535
+ command.uniformMap = this._uniforms;
536
+ command.vertexArray = vaOutlineColor.va;
537
+ command.renderState = bucketLocator.rsThree;
538
+ }
539
+ }
540
+ }
541
+ if (pass.pick) {
542
+ length = this._pickColorVertexArrays.length;
543
+ commands = this._commandLists.pickList;
544
+ for ( var a = 0; a < length; ++a) {
545
+ var vaPickColor = this._pickColorVertexArrays[a];
546
+ buckets = vaPickColor.buckets;
547
+ bucketLength = buckets.length;
548
+ commands.length += bucketLength;
549
+ for ( var b = 0; b < bucketLength; ++b) {
550
+ bucketLocator = buckets[b];
551
+
552
+ command = commands[b];
553
+ if (typeof command === 'undefined') {
554
+ command = commands[b] = new DrawCommand();
555
+ }
556
+
557
+ command.boundingVolume = boundingVolume;
558
+ command.modelMatrix = modelMatrix;
559
+ command.primitiveType = PrimitiveType.LINES;
560
+ command.count = bucketLocator.count;
561
+ command.offset = bucketLocator.offset;
562
+ command.shaderProgram = sp;
563
+ command.uniformMap = this._uniforms;
564
+ command.vertexArray = vaPickColor.va;
565
+ command.renderState = bucketLocator.rsPick;
566
+ }
567
+ }
568
+ }
569
+ }
570
+
571
+ if (!this._commandLists.empty()) {
572
+ commandList.push(this._commandLists);
573
+ }
574
+ };
575
+
576
+ /**
577
+ * Returns true if this object was destroyed; otherwise, false.
578
+ * <br /><br />
579
+ * If this object was destroyed, it should not be used; calling any function other than
580
+ * <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
581
+ *
582
+ * @memberof PolylineCollection
583
+ *
584
+ * @return {Boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
585
+ *
586
+ * @see PolylineCollection#destroy
587
+ */
588
+ PolylineCollection.prototype.isDestroyed = function() {
589
+ return false;
590
+ };
591
+
592
+ /**
593
+ * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
594
+ * release of WebGL resources, instead of relying on the garbage collector to destroy this object.
595
+ * <br /><br />
596
+ * Once an object is destroyed, it should not be used; calling any function other than
597
+ * <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
598
+ * assign the return value (<code>undefined</code>) to the object as done in the example.
599
+ *
600
+ * @memberof PolylineCollection
601
+ *
602
+ * @return {undefined}
603
+ *
604
+ * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
605
+ *
606
+ * @see PolylineCollection#isDestroyed
607
+ *
608
+ * @example
609
+ * polylines = polylines && polylines.destroy();
610
+ */
611
+ PolylineCollection.prototype.destroy = function() {
612
+ this._sp = this._sp && this._sp.release();
613
+ this._destroyVertexArrays();
614
+ this._destroyPolylines();
615
+ return destroyObject(this);
616
+ };
617
+
618
+ PolylineCollection.prototype._computeNewBuffersUsage = function() {
619
+ var buffersUsage = this._buffersUsage;
620
+ var usageChanged = false;
621
+
622
+ var properties = this._propertiesChanged;
623
+ //subtract 1 from NUMBER_OF_PROPERTIES because we don't care about POSITION_SIZE_INDEX property change.
624
+ for ( var k = 0; k < NUMBER_OF_PROPERTIES - 1; ++k) {
625
+ var bufferUsage = buffersUsage[k];
626
+ if (properties[k]) {
627
+ if (bufferUsage.bufferUsage !== BufferUsage.STREAM_DRAW) {
628
+ usageChanged = true;
629
+ bufferUsage.bufferUsage = BufferUsage.STREAM_DRAW;
630
+ bufferUsage.frameCount = 100;
631
+ } else {
632
+ bufferUsage.frameCount = 100;
633
+ }
634
+ } else {
635
+ if (bufferUsage.bufferUsage !== BufferUsage.STATIC_DRAW) {
636
+ if (bufferUsage.frameCount === 0) {
637
+ usageChanged = true;
638
+ bufferUsage.bufferUsage = BufferUsage.STATIC_DRAW;
639
+ } else {
640
+ bufferUsage.frameCount--;
641
+ }
642
+ }
643
+ }
644
+ }
645
+ return usageChanged;
646
+ };
647
+
648
+ PolylineCollection.prototype._createVertexArrays = function(context) {
649
+ this._createVertexArray = false;
650
+ this._destroyVertexArrays();
651
+ this._sortPolylinesIntoBuckets();
652
+ //stores all of the individual indices arrays.
653
+ var totalIndices = [];
654
+ var indices = [];
655
+
656
+ //used to determine the vertexBuffer offset if the indicesArray goes over 64k.
657
+ //if it's the same polyline while it goes over 64k, the offset needs to backtrack componentsPerAttribute * componentDatatype bytes
658
+ //so that the polyline looks contiguous.
659
+ //if the polyline ends at the 64k mark, then the offset is just 64k * componentsPerAttribute * componentDatatype
660
+ var vertexBufferOffset = [0];
661
+ totalIndices.push(indices);
662
+ var offset = 0;
663
+ var useDepthTest = (this.morphTime !== 0.0);
664
+ var vertexArrayBuckets = [[]];
665
+ var totalLength = 0;
666
+ var polylineBuckets = this._polylineBuckets;
667
+ var x;
668
+ var bucket;
669
+ for (x in polylineBuckets) {
670
+ if (polylineBuckets.hasOwnProperty(x)) {
671
+ bucket = polylineBuckets[x];
672
+ bucket.updateRenderState(context, useDepthTest);
673
+ totalLength += bucket.lengthOfPositions;
674
+ }
675
+ }
676
+ if (totalLength > 0) {
677
+ var positionArray = new Float32Array(2 * totalLength * 3);
678
+ var outlineColorArray = new Uint8Array(totalLength * 4);
679
+ var colorArray = new Uint8Array(totalLength * 4);
680
+ var pickColorArray = new Uint8Array(totalLength * 4);
681
+ var showArray = new Uint8Array(totalLength);
682
+ var position3DArray;
683
+
684
+ var positionIndex = 0;
685
+ var colorIndex = 0;
686
+ var showIndex = 0;
687
+ for (x in polylineBuckets) {
688
+ if (polylineBuckets.hasOwnProperty(x)) {
689
+ bucket = polylineBuckets[x];
690
+ bucket.write(positionArray, colorArray, outlineColorArray, pickColorArray, showArray, positionIndex, showIndex, colorIndex, context);
691
+ if (this._mode === SceneMode.MORPHING) {
692
+ if (typeof position3DArray === 'undefined') {
693
+ position3DArray = new Float32Array(2 * totalLength * 3);
694
+ }
695
+ bucket.writeForMorph(position3DArray, positionIndex);
696
+ }
697
+ var bucketLength = bucket.lengthOfPositions;
698
+ positionIndex += 2 * bucketLength * 3;
699
+ showIndex += bucketLength;
700
+ colorIndex += bucketLength * 4;
701
+ offset = bucket.updateIndices(totalIndices, vertexBufferOffset, vertexArrayBuckets, offset);
702
+ }
703
+ }
704
+ this._positionBuffer = context.createVertexBuffer(positionArray, this._buffersUsage[POSITION_INDEX].bufferUsage);
705
+ var position3DBuffer;
706
+ if (typeof position3DArray !== 'undefined') {
707
+ position3DBuffer = context.createVertexBuffer(position3DArray, this._buffersUsage[POSITION_INDEX].bufferUsage);
708
+ }
709
+ this._outlineColorBuffer = context.createVertexBuffer(outlineColorArray, this._buffersUsage[OUTLINE_COLOR_INDEX].bufferUsage);
710
+ this._colorBuffer = context.createVertexBuffer(colorArray, this._buffersUsage[COLOR_INDEX].bufferUsage);
711
+ this._pickColorBuffer = context.createVertexBuffer(pickColorArray, BufferUsage.STATIC_DRAW);
712
+ this._showBuffer = context.createVertexBuffer(showArray, this._buffersUsage[SHOW_INDEX].bufferUsage);
713
+ var colorSizeInBytes = 4 * Uint8Array.BYTES_PER_ELEMENT;
714
+ var positionSizeInBytes = 3 * Float32Array.BYTES_PER_ELEMENT;
715
+ var vbo = 0;
716
+ var numberOfIndicesArrays = totalIndices.length;
717
+ for ( var k = 0; k < numberOfIndicesArrays; ++k) {
718
+ indices = totalIndices[k];
719
+ if (indices.length > 0) {
720
+ var indicesArray = new Uint16Array(indices);
721
+ var indexBuffer = context.createIndexBuffer(indicesArray, BufferUsage.STATIC_DRAW, IndexDatatype.UNSIGNED_SHORT);
722
+ indexBuffer.setVertexArrayDestroyable(false);
723
+ vbo += vertexBufferOffset[k];
724
+ var positionHighOffset = 2 * (k * (positionSizeInBytes * SIXTYFOURK) - vbo * positionSizeInBytes);//componentsPerAttribute(3) * componentDatatype(4)
725
+ var positionLowOffset = positionSizeInBytes + positionHighOffset;
726
+ var vertexColorBufferOffset = k * (colorSizeInBytes * SIXTYFOURK) - vbo * colorSizeInBytes;
727
+ var vertexShowBufferOffset = k * SIXTYFOURK - vbo;
728
+ var attributes = [{
729
+ index : attributeIndices.position3DHigh,
730
+ componentsPerAttribute : 3,
731
+ componentDatatype : ComponentDatatype.FLOAT,
732
+ offsetInBytes : positionHighOffset,
733
+ strideInBytes : 2 * positionSizeInBytes
734
+ }, {
735
+ index : attributeIndices.position3DLow,
736
+ componentsPerAttribute : 3,
737
+ componentDatatype : ComponentDatatype.FLOAT,
738
+ offsetInBytes : positionLowOffset,
739
+ strideInBytes : 2 * positionSizeInBytes
740
+ }, {
741
+ index : attributeIndices.position2DHigh,
742
+ componentsPerAttribute : 3,
743
+ componentDatatype : ComponentDatatype.FLOAT,
744
+ offsetInBytes : positionHighOffset,
745
+ strideInBytes : 2 * positionSizeInBytes
746
+ }, {
747
+ index : attributeIndices.position2DLow,
748
+ componentsPerAttribute : 3,
749
+ componentDatatype : ComponentDatatype.FLOAT,
750
+ offsetInBytes : positionLowOffset,
751
+ strideInBytes : 2 * positionSizeInBytes
752
+ }, {
753
+ index : attributeIndices.color,
754
+ componentsPerAttribute : 4,
755
+ normalize : true,
756
+ componentDatatype : ComponentDatatype.UNSIGNED_BYTE,
757
+ vertexBuffer : this._colorBuffer,
758
+ offsetInBytes : vertexColorBufferOffset
759
+ }, {
760
+ index : attributeIndices.show,
761
+ componentsPerAttribute : 1,
762
+ componentDatatype : ComponentDatatype.UNSIGNED_BYTE,
763
+ vertexBuffer : this._showBuffer,
764
+ offsetInBytes : vertexShowBufferOffset
765
+ }];
766
+
767
+ var attributesOutlineColor = [{
768
+ index : attributeIndices.position3DHigh,
769
+ componentsPerAttribute : 3,
770
+ componentDatatype : ComponentDatatype.FLOAT,
771
+ offsetInBytes : positionHighOffset,
772
+ strideInBytes : 2 * positionSizeInBytes
773
+ }, {
774
+ index : attributeIndices.position3DLow,
775
+ componentsPerAttribute : 3,
776
+ componentDatatype : ComponentDatatype.FLOAT,
777
+ offsetInBytes : positionLowOffset,
778
+ strideInBytes : 2 * positionSizeInBytes
779
+ }, {
780
+ index : attributeIndices.position2DHigh,
781
+ componentsPerAttribute : 3,
782
+ componentDatatype : ComponentDatatype.FLOAT,
783
+ offsetInBytes : positionHighOffset,
784
+ strideInBytes : 2 * positionSizeInBytes
785
+ }, {
786
+ index : attributeIndices.position2DLow,
787
+ componentsPerAttribute : 3,
788
+ componentDatatype : ComponentDatatype.FLOAT,
789
+ offsetInBytes : positionLowOffset,
790
+ strideInBytes : 2 * positionSizeInBytes
791
+ }, {
792
+ index : attributeIndices.color,
793
+ componentsPerAttribute : 4,
794
+ normalize : true,
795
+ componentDatatype : ComponentDatatype.UNSIGNED_BYTE,
796
+ vertexBuffer : this._outlineColorBuffer,
797
+ offsetInBytes : vertexColorBufferOffset
798
+ }, {
799
+ index : attributeIndices.show,
800
+ componentsPerAttribute : 1,
801
+ componentDatatype : ComponentDatatype.UNSIGNED_BYTE,
802
+ vertexBuffer : this._showBuffer,
803
+ offsetInBytes : vertexShowBufferOffset
804
+ }];
805
+
806
+ var attributesPickColor = [{
807
+ index : attributeIndices.position3DHigh,
808
+ componentsPerAttribute : 3,
809
+ componentDatatype : ComponentDatatype.FLOAT,
810
+ offsetInBytes : positionHighOffset,
811
+ strideInBytes : 2 * positionSizeInBytes
812
+ }, {
813
+ index : attributeIndices.position3DLow,
814
+ componentsPerAttribute : 3,
815
+ componentDatatype : ComponentDatatype.FLOAT,
816
+ offsetInBytes : positionLowOffset,
817
+ strideInBytes : 2 * positionSizeInBytes
818
+ }, {
819
+ index : attributeIndices.position2DHigh,
820
+ componentsPerAttribute : 3,
821
+ componentDatatype : ComponentDatatype.FLOAT,
822
+ offsetInBytes : positionHighOffset,
823
+ strideInBytes : 2 * positionSizeInBytes
824
+ }, {
825
+ index : attributeIndices.position2DLow,
826
+ componentsPerAttribute : 3,
827
+ componentDatatype : ComponentDatatype.FLOAT,
828
+ offsetInBytes : positionLowOffset,
829
+ strideInBytes : 2 * positionSizeInBytes
830
+ }, {
831
+ index : attributeIndices.color,
832
+ componentsPerAttribute : 4,
833
+ normalize : true,
834
+ componentDatatype : ComponentDatatype.UNSIGNED_BYTE,
835
+ vertexBuffer : this._pickColorBuffer,
836
+ offsetInBytes : vertexColorBufferOffset
837
+ }, {
838
+ index : attributeIndices.show,
839
+ componentsPerAttribute : 1,
840
+ componentDatatype : ComponentDatatype.UNSIGNED_BYTE,
841
+ vertexBuffer : this._showBuffer,
842
+ offsetInBytes : vertexShowBufferOffset
843
+ }];
844
+
845
+ if (this._mode === SceneMode.SCENE3D) {
846
+ attributes[0].vertexBuffer = this._positionBuffer;
847
+ attributes[1].vertexBuffer = this._positionBuffer;
848
+ attributes[2].value = [0.0, 0.0, 0.0];
849
+ attributes[3].value = [0.0, 0.0, 0.0];
850
+ attributesOutlineColor[0].vertexBuffer = this._positionBuffer;
851
+ attributesOutlineColor[1].vertexBuffer = this._positionBuffer;
852
+ attributesOutlineColor[2].value = [0.0, 0.0, 0.0];
853
+ attributesOutlineColor[3].value = [0.0, 0.0, 0.0];
854
+ attributesPickColor[0].vertexBuffer = this._positionBuffer;
855
+ attributesPickColor[1].vertexBuffer = this._positionBuffer;
856
+ attributesPickColor[2].value = [0.0, 0.0, 0.0];
857
+ attributesPickColor[3].value = [0.0, 0.0, 0.0];
858
+ } else if (this._mode === SceneMode.SCENE2D || this._mode === SceneMode.COLUMBUS_VIEW) {
859
+ attributes[0].value = [0.0, 0.0, 0.0];
860
+ attributes[1].value = [0.0, 0.0, 0.0];
861
+ attributes[2].vertexBuffer = this._positionBuffer;
862
+ attributes[3].vertexBuffer = this._positionBuffer;
863
+ attributesOutlineColor[0].value = [0.0, 0.0, 0.0];
864
+ attributesOutlineColor[1].value = [0.0, 0.0, 0.0];
865
+ attributesOutlineColor[2].vertexBuffer = this._positionBuffer;
866
+ attributesOutlineColor[3].vertexBuffer = this._positionBuffer;
867
+ attributesPickColor[0].value = [0.0, 0.0, 0.0];
868
+ attributesPickColor[1].value = [0.0, 0.0, 0.0];
869
+ attributesPickColor[2].vertexBuffer = this._positionBuffer;
870
+ attributesPickColor[3].vertexBuffer = this._positionBuffer;
871
+ } else {
872
+ attributes[0].vertexBuffer = position3DBuffer;
873
+ attributes[1].vertexBuffer = position3DBuffer;
874
+ attributes[2].vertexBuffer = this._positionBuffer;
875
+ attributes[3].vertexBuffer = this._positionBuffer;
876
+ attributesOutlineColor[0].vertexBuffer = position3DBuffer;
877
+ attributesOutlineColor[1].vertexBuffer = position3DBuffer;
878
+ attributesOutlineColor[2].vertexBuffer = this._positionBuffer;
879
+ attributesOutlineColor[3].vertexBuffer = this._positionBuffer;
880
+ attributesPickColor[0].vertexBuffer = position3DBuffer;
881
+ attributesPickColor[1].vertexBuffer = position3DBuffer;
882
+ attributesPickColor[2].vertexBuffer = this._positionBuffer;
883
+ attributesPickColor[3].vertexBuffer = this._positionBuffer;
884
+ }
885
+ var va = context.createVertexArray(attributes, indexBuffer);
886
+ var vaOutlineColor = context.createVertexArray(attributesOutlineColor, indexBuffer);
887
+ var vaPickColor = context.createVertexArray(attributesPickColor, indexBuffer);
888
+
889
+ this._colorVertexArrays.push({
890
+ va : va,
891
+ buckets : vertexArrayBuckets[k]
892
+ });
893
+ this._outlineColorVertexArrays.push({
894
+ va : vaOutlineColor,
895
+ buckets : vertexArrayBuckets[k]
896
+ });
897
+ this._pickColorVertexArrays.push({
898
+ va : vaPickColor,
899
+ buckets : vertexArrayBuckets[k]
900
+ });
901
+ }
902
+ }
903
+ }
904
+ };
905
+
906
+ PolylineCollection.prototype._sortPolylinesIntoBuckets = function() {
907
+ var polylineBuckets = this._polylineBuckets = {};
908
+ var polylines = this._polylines;
909
+ var length = polylines.length;
910
+ for ( var i = 0; i < length; ++i) {
911
+ var p = polylines[i];
912
+ var outlineWidth = p.getOutlineWidth();
913
+ var width = p.getWidth();
914
+ var hash = 'OL' + outlineWidth + 'W' + width;
915
+ var value = polylineBuckets[hash];
916
+ if (typeof value === 'undefined') {
917
+ value = polylineBuckets[hash] = new PolylineBucket(outlineWidth, width, this._mode, this._projection, this._modelMatrix);
918
+ }
919
+ value.addPolyline(p);
920
+ }
921
+ };
922
+
923
+ PolylineCollection.prototype._updateMode = function(frameState) {
924
+ var mode = frameState.mode;
925
+ var projection = frameState.scene2D.projection;
926
+ if (this._mode !== mode && typeof mode.morphTime !== 'undefined') {
927
+ this.morphTime = mode.morphTime;
928
+ }
929
+ if (this._mode !== mode || (this._projection !== projection) || (!this._modelMatrix.equals(this.modelMatrix))) {
930
+ this._mode = mode;
931
+ this._projection = projection;
932
+ this._modelMatrix = this.modelMatrix.clone();
933
+ this._createVertexArray = true;
934
+ }
935
+ };
936
+
937
+ PolylineCollection.prototype._removePolylines = function() {
938
+ if (this._polylinesRemoved) {
939
+ this._polylinesRemoved = false;
940
+
941
+ var polylines = [];
942
+
943
+ var length = this._polylines.length;
944
+ for ( var i = 0, j = 0; i < length; ++i) {
945
+ var polyline = this._polylines[i];
946
+ if (polyline) {
947
+ polyline._index = j++;
948
+ polylines.push(polyline);
949
+ }
950
+ }
951
+
952
+ this._polylines = polylines;
953
+ }
954
+ };
955
+
956
+ PolylineCollection.prototype._destroyVertexArrays = function() {
957
+ var length = this._colorVertexArrays.length;
958
+ for ( var t = 0; t < length; ++t) {
959
+ this._colorVertexArrays[t].va.destroy();
960
+ this._pickColorVertexArrays[t].va.destroy();
961
+ this._outlineColorVertexArrays[t].va.destroy();
962
+ }
963
+ this._colorVertexArrays.length = 0;
964
+ this._pickColorVertexArrays.length = 0;
965
+ this._outlineColorVertexArrays.length = 0;
966
+ };
967
+
968
+ PolylineCollection.prototype._updatePolyline = function(polyline, propertyChanged) {
969
+ this._polylinesUpdated = true;
970
+ this._polylinesToUpdate.push(polyline);
971
+ ++this._propertiesChanged[propertyChanged];
972
+ };
973
+
974
+ PolylineCollection.prototype._destroyPolylines = function() {
975
+ var polylines = this._polylines;
976
+ var length = polylines.length;
977
+ for ( var i = 0; i < length; ++i) {
978
+ if (polylines[i]) {
979
+ polylines[i]._destroy();
980
+ }
981
+ }
982
+ };
983
+
984
+ /**
985
+ * @private
986
+ */
987
+ function VertexArrayBucketLocator(count, offset, bucket) {
988
+ this.count = count;
989
+ this.offset = offset;
990
+ this.rsOne = bucket.rsOne;
991
+ this.rsTwo = bucket.rsTwo;
992
+ this.rsThree = bucket.rsThree;
993
+ this.rsPick = bucket.rsPick;
994
+ }
995
+
996
+ /**
997
+ * @private
998
+ */
999
+ var PolylineBucket = function(outlineWidth, width, mode, projection, modelMatrix) {
1000
+ this.width = width;
1001
+ this.outlineWidth = outlineWidth;
1002
+ this.polylines = [];
1003
+ this.lengthOfPositions = 0;
1004
+ this.rsOne = undefined;
1005
+ this.rsTwo = undefined;
1006
+ this.rsThree = undefined;
1007
+ this.rsPick = undefined;
1008
+ this.mode = mode;
1009
+ this.projection = projection;
1010
+ this.ellipsoid = projection.getEllipsoid();
1011
+ this.modelMatrix = modelMatrix;
1012
+ };
1013
+
1014
+ /**
1015
+ * @private
1016
+ */
1017
+ PolylineBucket.prototype.addPolyline = function(p) {
1018
+ var polylines = this.polylines;
1019
+ polylines.push(p);
1020
+ p._actualLength = this.getPolylinePositionsLength(p);
1021
+ this.lengthOfPositions += p._actualLength;
1022
+ p._bucket = this;
1023
+ };
1024
+
1025
+ /**
1026
+ * @private
1027
+ */
1028
+ PolylineBucket.prototype.updateRenderState = function(context, useDepthTest) {
1029
+ var width = this._clampWidth(context, this.width);
1030
+ var outlineWidth = this._clampWidth(context, this.outlineWidth);
1031
+ var rsOne = this.rsOne || context.createRenderState({
1032
+ colorMask : {
1033
+ red : false,
1034
+ green : false,
1035
+ blue : false,
1036
+ alpha : false
1037
+ },
1038
+ lineWidth : 1,
1039
+ blending : BlendingState.ALPHA_BLEND,
1040
+ stencilTest : {
1041
+ enabled : true,
1042
+ frontFunction : StencilFunction.ALWAYS,
1043
+ backFunction : StencilFunction.ALWAYS,
1044
+ reference : 0,
1045
+ mask : ~0,
1046
+ frontOperation : {
1047
+ fail : StencilOperation.REPLACE,
1048
+ zFail : StencilOperation.REPLACE,
1049
+ zPass : StencilOperation.REPLACE
1050
+ },
1051
+ backOperation : {
1052
+ fail : StencilOperation.REPLACE,
1053
+ zFail : StencilOperation.REPLACE,
1054
+ zPass : StencilOperation.REPLACE
1055
+ }
1056
+ }
1057
+ });
1058
+ rsOne.depthMask = !useDepthTest;
1059
+ rsOne.depthTest.enabled = useDepthTest;
1060
+ rsOne.lineWidth = outlineWidth;
1061
+ this.rsOne = rsOne;
1062
+ var rsTwo = this.rsTwo || context.createRenderState({
1063
+ lineWidth : 1,
1064
+ depthMask : false,
1065
+ blending : BlendingState.ALPHA_BLEND,
1066
+ stencilTest : {
1067
+ enabled : true,
1068
+ frontFunction : StencilFunction.ALWAYS,
1069
+ backFunction : StencilFunction.ALWAYS,
1070
+ reference : 1,
1071
+ mask : ~0,
1072
+ frontOperation : {
1073
+ fail : StencilOperation.KEEP,
1074
+ zFail : StencilOperation.KEEP,
1075
+ zPass : StencilOperation.REPLACE
1076
+ },
1077
+ backOperation : {
1078
+ fail : StencilOperation.KEEP,
1079
+ zFail : StencilOperation.KEEP,
1080
+ zPass : StencilOperation.REPLACE
1081
+ }
1082
+ }
1083
+ });
1084
+ rsTwo.depthTest.enabled = useDepthTest;
1085
+ rsTwo.lineWidth = width;
1086
+ this.rsTwo = rsTwo;
1087
+ var rsThree = this.rsThree || context.createRenderState({
1088
+ lineWidth : 1,
1089
+ depthMask : false,
1090
+ blending : BlendingState.ALPHA_BLEND,
1091
+ stencilTest : {
1092
+ enabled : true,
1093
+ frontFunction : StencilFunction.NOT_EQUAL,
1094
+ backFunction : StencilFunction.NOT_EQUAL,
1095
+ reference : 1,
1096
+ mask : ~0,
1097
+ frontOperation : {
1098
+ fail : StencilOperation.KEEP,
1099
+ zFail : StencilOperation.KEEP,
1100
+ zPass : StencilOperation.KEEP
1101
+ },
1102
+ backOperation : {
1103
+ fail : StencilOperation.KEEP,
1104
+ zFail : StencilOperation.KEEP,
1105
+ zPass : StencilOperation.KEEP
1106
+ }
1107
+ }
1108
+ });
1109
+ rsThree.lineWidth = this.outlineWidth;
1110
+ rsThree.depthTest.enabled = useDepthTest;
1111
+ this.rsThree = rsThree;
1112
+
1113
+ var rsPick = this.rsPick || context.createRenderState();
1114
+ rsPick.depthTest.enabled = useDepthTest;
1115
+ rsPick.lineWidth = outlineWidth;
1116
+ rsPick.depthMask = !useDepthTest;
1117
+ this.rsPick = rsPick;
1118
+ };
1119
+
1120
+ function intersectsIDL(polyline) {
1121
+ return Cartesian3.dot(Cartesian3.UNIT_X, polyline._boundingVolume.center) < 0 ||
1122
+ polyline._boundingVolume.intersect(Cartesian4.UNIT_Y) === Intersect.INTERSECTING;
1123
+ }
1124
+
1125
+ /**
1126
+ * @private
1127
+ */
1128
+ PolylineBucket.prototype.getPolylinePositionsLength = function(polyline) {
1129
+ if (this.mode === SceneMode.SCENE3D || !intersectsIDL(polyline)) {
1130
+ return polyline.getPositions().length;
1131
+ }
1132
+ var segments = polyline._createSegments(this.ellipsoid);
1133
+ return polyline._setSegments(segments);
1134
+ };
1135
+
1136
+ var scratchWritePosition = new Cartesian3();
1137
+
1138
+ /**
1139
+ * @private
1140
+ */
1141
+ PolylineBucket.prototype.write = function(positionArray, colorArray, outlineColorArray, pickColorArray, showArray, positionIndex, showIndex, colorIndex, context) {
1142
+ var polylines = this.polylines;
1143
+ var length = polylines.length;
1144
+ for ( var i = 0; i < length; ++i) {
1145
+ var polyline = polylines[i];
1146
+ var color = polyline.getColor();
1147
+ var show = polyline.getShow();
1148
+ var outlineColor = polyline.getOutlineColor();
1149
+ var pickColor = polyline.getPickId(context).unnormalizedRgb;
1150
+ var positions = this._getPositions(polyline);
1151
+ var positionsLength = positions.length;
1152
+ for ( var j = 0; j < positionsLength; ++j) {
1153
+ var position = positions[j];
1154
+ scratchWritePosition.x = position.x;
1155
+ scratchWritePosition.y = position.y;
1156
+ scratchWritePosition.z = (this.mode !== SceneMode.SCENE2D) ? position.z : 0.0;
1157
+ EncodedCartesian3.writeElements(scratchWritePosition, positionArray, positionIndex);
1158
+ outlineColorArray[colorIndex] = Color.floatToByte(outlineColor.red);
1159
+ outlineColorArray[colorIndex + 1] = Color.floatToByte(outlineColor.green);
1160
+ outlineColorArray[colorIndex + 2] = Color.floatToByte(outlineColor.blue);
1161
+ outlineColorArray[colorIndex + 3] = Color.floatToByte(outlineColor.alpha);
1162
+ colorArray[colorIndex] = Color.floatToByte(color.red);
1163
+ colorArray[colorIndex + 1] = Color.floatToByte(color.green);
1164
+ colorArray[colorIndex + 2] = Color.floatToByte(color.blue);
1165
+ colorArray[colorIndex + 3] = Color.floatToByte(color.alpha);
1166
+ pickColorArray[colorIndex] = pickColor.red;
1167
+ pickColorArray[colorIndex + 1] = pickColor.green;
1168
+ pickColorArray[colorIndex + 2] = pickColor.blue;
1169
+ pickColorArray[colorIndex + 3] = 255;
1170
+ showArray[showIndex++] = show;
1171
+ positionIndex += 6;
1172
+ colorIndex += 4;
1173
+ }
1174
+ }
1175
+ };
1176
+
1177
+ /**
1178
+ * @private
1179
+ */
1180
+ PolylineBucket.prototype.writeForMorph = function(positionArray, positionIndex) {
1181
+ var modelMatrix = this.modelMatrix;
1182
+ var position;
1183
+ var polylines = this.polylines;
1184
+ var length = polylines.length;
1185
+ for ( var i = 0; i < length; ++i) {
1186
+ var polyline = polylines[i];
1187
+ var positions = polyline.getPositions();
1188
+
1189
+ var numberOfSegments;
1190
+ var j;
1191
+ if (intersectsIDL(polyline)) {
1192
+ var segments = polyline._getSegments();
1193
+ numberOfSegments = segments.length;
1194
+ for ( j = 0; j < numberOfSegments; ++j) {
1195
+ var segment = segments[j];
1196
+ var segmentLength = segment.length;
1197
+ for ( var n = 0; n < segmentLength; ++n) {
1198
+ position = positions[segment[n].index];
1199
+ position = modelMatrix.multiplyByPoint(position);
1200
+ EncodedCartesian3.writeElements(position, positionArray, positionIndex);
1201
+ positionIndex += 6;
1202
+ }
1203
+ }
1204
+ } else {
1205
+ numberOfSegments = positions.length;
1206
+ for ( j = 0; j < numberOfSegments; ++j) {
1207
+ position = positions[j];
1208
+ position = modelMatrix.multiplyByPoint(position);
1209
+ EncodedCartesian3.writeElements(position, positionArray, positionIndex);
1210
+ positionIndex += 6;
1211
+ }
1212
+ }
1213
+ }
1214
+ };
1215
+
1216
+ /**
1217
+ * @private
1218
+ */
1219
+ PolylineBucket.prototype._clampWidth = function(context, value) {
1220
+ var min = context.getMinimumAliasedLineWidth();
1221
+ var max = context.getMaximumAliasedLineWidth();
1222
+
1223
+ return Math.min(Math.max(value, min), max);
1224
+ };
1225
+
1226
+ /**
1227
+ * @private
1228
+ */
1229
+ PolylineBucket.prototype._updateIndices3D = function(totalIndices, vertexBufferOffset, vertexArrayBuckets, offset) {
1230
+ var vaCount = vertexArrayBuckets.length - 1;
1231
+ var bucketLocator = new VertexArrayBucketLocator(0, offset, this);
1232
+ vertexArrayBuckets[vaCount].push(bucketLocator);
1233
+ var count = 0;
1234
+ var indices = totalIndices[totalIndices.length - 1];
1235
+ var indicesCount = 0;
1236
+ if (indices.length > 0) {
1237
+ indicesCount = indices[indices.length - 1] + 1;
1238
+ }
1239
+ var polylines = this.polylines;
1240
+ var length = polylines.length;
1241
+ for ( var i = 0; i < length; ++i) {
1242
+ var polyline = polylines[i];
1243
+ var positions = polyline.getPositions();
1244
+ var positionsLength = positions.length;
1245
+ if (positions.length > 0) {
1246
+ for ( var j = 0; j < positionsLength; ++j) {
1247
+ if (j !== positionsLength - 1) {
1248
+ if (indicesCount === SIXTYFOURK - 1) {
1249
+ vertexBufferOffset.push(1);
1250
+ indices = [];
1251
+ totalIndices.push(indices);
1252
+ indicesCount = 0;
1253
+ bucketLocator.count = count;
1254
+ count = 0;
1255
+ offset = 0;
1256
+ bucketLocator = new VertexArrayBucketLocator(0, 0, this);
1257
+ vertexArrayBuckets[++vaCount] = [bucketLocator];
1258
+ }
1259
+ count += 2;
1260
+ offset += 2;
1261
+ indices.push(indicesCount++);
1262
+ indices.push(indicesCount);
1263
+ }
1264
+ }
1265
+ if (indicesCount < SIXTYFOURK - 1) {
1266
+ indicesCount++;
1267
+ } else {
1268
+ vertexBufferOffset.push(0);
1269
+ indices = [];
1270
+ totalIndices.push(indices);
1271
+ indicesCount = 0;
1272
+ bucketLocator.count = count;
1273
+ offset = 0;
1274
+ count = 0;
1275
+ bucketLocator = new VertexArrayBucketLocator(0, 0, this);
1276
+ vertexArrayBuckets[++vaCount] = [bucketLocator];
1277
+ }
1278
+ }
1279
+ polyline._clean();
1280
+ }
1281
+ bucketLocator.count = count;
1282
+ return offset;
1283
+ };
1284
+
1285
+ /**
1286
+ * @private
1287
+ */
1288
+ PolylineBucket.prototype._updateIndices2D = function(totalIndices, vertexBufferOffset, vertexArrayBuckets, offset) {
1289
+ var vaCount = vertexArrayBuckets.length - 1;
1290
+ var bucketLocator = new VertexArrayBucketLocator(0, offset, this);
1291
+ vertexArrayBuckets[vaCount].push(bucketLocator);
1292
+ var count = 0;
1293
+ var indices = totalIndices[totalIndices.length - 1];
1294
+ var indicesCount = 0;
1295
+ if (indices.length > 0) {
1296
+ indicesCount = indices[indices.length - 1] + 1;
1297
+ }
1298
+ var polylines = this.polylines;
1299
+ var length = polylines.length;
1300
+ for ( var i = 0; i < length; ++i) {
1301
+ var polyline = polylines[i];
1302
+ if (intersectsIDL(polyline)) {
1303
+ var segments = polyline._segments;
1304
+ var numberOfSegments = segments.length;
1305
+ if (numberOfSegments > 0) {
1306
+ for ( var k = 0; k < numberOfSegments; ++k) {
1307
+ var segment = segments[k];
1308
+ var segmentLength = segment.length;
1309
+ for ( var n = 0; n < segmentLength; ++n) {
1310
+ if (n !== segmentLength - 1) {
1311
+ if (indicesCount === SIXTYFOURK - 1) {
1312
+ vertexBufferOffset.push(1);
1313
+ indices = [];
1314
+ totalIndices.push(indices);
1315
+ indicesCount = 0;
1316
+ bucketLocator.count = count;
1317
+ count = 0;
1318
+ offset = 0;
1319
+ bucketLocator = new VertexArrayBucketLocator(0, 0, this);
1320
+ vertexArrayBuckets[++vaCount] = [bucketLocator];
1321
+ }
1322
+ count += 2;
1323
+ offset += 2;
1324
+ indices.push(indicesCount++);
1325
+ indices.push(indicesCount);
1326
+ }
1327
+ }
1328
+ if (k !== numberOfSegments - 1) {
1329
+ indicesCount++;
1330
+ }
1331
+ }
1332
+
1333
+ if (indicesCount < SIXTYFOURK - 1) {
1334
+ indicesCount++;
1335
+ } else {
1336
+ vertexBufferOffset.push(0);
1337
+ indices = [];
1338
+ totalIndices.push(indices);
1339
+ indicesCount = 0;
1340
+ bucketLocator.count = count;
1341
+ offset = 0;
1342
+ count = 0;
1343
+ bucketLocator = new VertexArrayBucketLocator(0, 0, this);
1344
+ vertexArrayBuckets[++vaCount] = [bucketLocator];
1345
+ }
1346
+ }
1347
+ } else {
1348
+ var positions = polyline.getPositions();
1349
+ var positionsLength = positions.length;
1350
+ for ( var j = 0; j < positionsLength; ++j) {
1351
+ if (j !== positionsLength - 1) {
1352
+ if (indicesCount === SIXTYFOURK - 1) {
1353
+ vertexBufferOffset.push(1);
1354
+ indices = [];
1355
+ totalIndices.push(indices);
1356
+ indicesCount = 0;
1357
+ bucketLocator.count = count;
1358
+ count = 0;
1359
+ offset = 0;
1360
+ bucketLocator = new VertexArrayBucketLocator(0, 0, this);
1361
+ vertexArrayBuckets[++vaCount] = [bucketLocator];
1362
+ }
1363
+ count += 2;
1364
+ offset += 2;
1365
+ indices.push(indicesCount++);
1366
+ indices.push(indicesCount);
1367
+ }
1368
+ }
1369
+
1370
+ if (indicesCount < SIXTYFOURK - 1) {
1371
+ indicesCount++;
1372
+ } else {
1373
+ vertexBufferOffset.push(0);
1374
+ indices = [];
1375
+ totalIndices.push(indices);
1376
+ indicesCount = 0;
1377
+ bucketLocator.count = count;
1378
+ offset = 0;
1379
+ count = 0;
1380
+ bucketLocator = new VertexArrayBucketLocator(0, 0, this);
1381
+ vertexArrayBuckets[++vaCount] = [bucketLocator];
1382
+ }
1383
+ }
1384
+ polyline._clean();
1385
+ }
1386
+ bucketLocator.count = count;
1387
+ return offset;
1388
+ };
1389
+
1390
+ /**
1391
+ * @private
1392
+ */
1393
+ PolylineBucket.prototype.updateIndices = function(totalIndices, vertexBufferOffset, vertexArrayBuckets, offset) {
1394
+ if (this.mode === SceneMode.SCENE3D) {
1395
+ return this._updateIndices3D(totalIndices, vertexBufferOffset, vertexArrayBuckets, offset);
1396
+ }
1397
+ return this._updateIndices2D(totalIndices, vertexBufferOffset, vertexArrayBuckets, offset);
1398
+ };
1399
+
1400
+ /**
1401
+ * @private
1402
+ */
1403
+ PolylineBucket.prototype._getPolylineStartIndex = function(polyline) {
1404
+ var polylines = this.polylines;
1405
+ var positionIndex = 0;
1406
+ var length = polylines.length;
1407
+ for ( var i = 0; i < length; ++i) {
1408
+ var p = polylines[i];
1409
+ if (p === polyline) {
1410
+ break;
1411
+ }
1412
+ positionIndex += p._actualLength;
1413
+ }
1414
+ return positionIndex;
1415
+ };
1416
+
1417
+ /**
1418
+ * @private
1419
+ */
1420
+ PolylineBucket.prototype._getPositions = function(polyline) {
1421
+ var positions = polyline.getPositions();
1422
+
1423
+ if (positions.length > 0) {
1424
+ if (typeof polyline._polylineCollection._boundingVolume === 'undefined') {
1425
+ polyline._polylineCollection._boundingVolume = BoundingSphere.clone(polyline._boundingVolume);
1426
+ } else {
1427
+ polyline._polylineCollection._boundingVolume = polyline._polylineCollection._boundingVolume.union(polyline._boundingVolume, polyline._polylineCollection._boundingVolume);
1428
+ }
1429
+ }
1430
+
1431
+ if (this.mode === SceneMode.SCENE3D) {
1432
+ return positions;
1433
+ }
1434
+ if (intersectsIDL(polyline)) {
1435
+ positions = polyline._getPositions2D();
1436
+ }
1437
+
1438
+ var ellipsoid = this.ellipsoid;
1439
+ var projection = this.projection;
1440
+ var newPositions = [];
1441
+ var modelMatrix = this.modelMatrix;
1442
+ var length = positions.length;
1443
+ var position;
1444
+ var p;
1445
+
1446
+ for ( var n = 0; n < length; ++n) {
1447
+ position = positions[n];
1448
+ p = modelMatrix.multiplyByPoint(position);
1449
+ newPositions.push(projection.project(ellipsoid.cartesianToCartographic(Cartesian3.fromCartesian4(p))));
1450
+ }
1451
+
1452
+ if (newPositions.length > 0) {
1453
+ polyline._boundingVolume2D = BoundingSphere.fromPoints(newPositions, polyline._boundingVolume2D);
1454
+ var center2D = polyline._boundingVolume2D.center;
1455
+ polyline._boundingVolume2D.center = new Cartesian3(center2D.z, center2D.x, center2D.y);
1456
+ if (typeof polyline._polylineCollection._boundingVolume2D === 'undefined') {
1457
+ polyline._polylineCollection._boundingVolume2D = BoundingSphere.clone(polyline._boundingVolume2D);
1458
+ } else {
1459
+ polyline._polylineCollection._boundingVolume2D = polyline._polylineCollection._boundingVolume2D.union(polyline._boundingVolume2D, polyline._polylineCollection._boundingVolume2D);
1460
+ }
1461
+ }
1462
+
1463
+ return newPositions;
1464
+ };
1465
+
1466
+ /**
1467
+ * @private
1468
+ */
1469
+ PolylineBucket.prototype.writePositionsUpdate = function(positionIndex, polyline, buffer) {
1470
+ var positionsLength = polyline._actualLength;
1471
+ if (positionsLength) {
1472
+ positionIndex += this._getPolylineStartIndex(polyline);
1473
+ var positionArray = new Float32Array(2 * positionsLength * 3);
1474
+ var index = 0;
1475
+ var positions = this._getPositions(polyline);
1476
+ for ( var i = 0; i < positionsLength; ++i) {
1477
+ var position = positions[i];
1478
+ scratchWritePosition.x = position.x;
1479
+ scratchWritePosition.y = position.y;
1480
+ scratchWritePosition.z = (this.mode !== SceneMode.SCENE2D) ? position.z : 0.0;
1481
+ EncodedCartesian3.writeElements(scratchWritePosition, positionArray, index);
1482
+ index += 6;
1483
+ }
1484
+
1485
+ buffer.copyFromArrayView(positionArray, 2 * 12 * positionIndex);
1486
+ }
1487
+ };
1488
+
1489
+ /**
1490
+ * @private
1491
+ */
1492
+ PolylineBucket.prototype.writeColorUpdate = function(positionIndex, polyline, buffer) {
1493
+ var positionsLength = polyline._actualLength;
1494
+ if (positionsLength) {
1495
+ positionIndex += this._getPolylineStartIndex(polyline);
1496
+
1497
+ var index = 0;
1498
+ var color = polyline.getColor();
1499
+ var red = Color.floatToByte(color.red);
1500
+ var green = Color.floatToByte(color.green);
1501
+ var blue = Color.floatToByte(color.blue);
1502
+ var alpha = Color.floatToByte(color.alpha);
1503
+ var colorsArray = new Uint8Array(positionsLength * 4);
1504
+ for ( var j = 0; j < positionsLength; ++j) {
1505
+ colorsArray[index] = red;
1506
+ colorsArray[index + 1] = green;
1507
+ colorsArray[index + 2] = blue;
1508
+ colorsArray[index + 3] = alpha;
1509
+ index += 4;
1510
+ }
1511
+ buffer.copyFromArrayView(colorsArray, 4 * positionIndex);
1512
+ }
1513
+ };
1514
+
1515
+ /**
1516
+ * @private
1517
+ */
1518
+ PolylineBucket.prototype.writeShowUpdate = function(positionIndex, polyline, buffer) {
1519
+ var positionsLength = polyline._actualLength;
1520
+ if (positionsLength) {
1521
+ positionIndex += this._getPolylineStartIndex(polyline);
1522
+ var show = polyline.getShow();
1523
+ var showArray = new Uint8Array(positionsLength);
1524
+ for ( var j = 0; j < positionsLength; ++j) {
1525
+ showArray[j] = show;
1526
+ }
1527
+ buffer.copyFromArrayView(showArray, positionIndex);
1528
+ }
1529
+ };
1530
+
1531
+ return PolylineCollection;
1532
+ });