@vcmap/ui 5.0.0-rc.18 → 5.0.0-rc.20

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 (379) hide show
  1. package/README.md +6 -6
  2. package/build/build.js +2 -2
  3. package/build/buildCesium.js +3 -3
  4. package/build/buildHelpers.js +2 -1
  5. package/config/base.config.json +0 -4
  6. package/config/dev.config.json +35 -14
  7. package/config/www.config.json +4 -0
  8. package/dist/assets/cesium/Workers/ArcType-ce2e50ab.js +37 -0
  9. package/dist/assets/cesium/Workers/AttributeCompression-b646d393.js +716 -0
  10. package/dist/assets/cesium/Workers/AxisAlignedBoundingBox-ff186ccc.js +258 -0
  11. package/dist/assets/cesium/Workers/BoundingRectangle-be5924f4.js +369 -0
  12. package/dist/assets/cesium/Workers/BoxGeometry-12eeccaf.js +884 -0
  13. package/dist/assets/cesium/Workers/Check-666ab1a0.js +290 -0
  14. package/dist/assets/cesium/Workers/Color-a84038cb.js +2262 -0
  15. package/dist/assets/cesium/Workers/ComponentDatatype-f7b11d02.js +341 -0
  16. package/dist/assets/cesium/Workers/CoplanarPolygonGeometryLibrary-3272c1b3.js +132 -0
  17. package/dist/assets/cesium/Workers/CorridorGeometryLibrary-0170e093.js +498 -0
  18. package/dist/assets/cesium/Workers/CylinderGeometry-7c5da648.js +467 -0
  19. package/dist/assets/cesium/Workers/CylinderGeometryLibrary-372c07d8.js +63 -0
  20. package/dist/assets/cesium/Workers/EllipseGeometry-797d580e.js +1304 -0
  21. package/dist/assets/cesium/Workers/EllipseGeometryLibrary-2939e1dc.js +366 -0
  22. package/dist/assets/cesium/Workers/EllipseOutlineGeometry-8b50870f.js +443 -0
  23. package/dist/assets/cesium/Workers/EllipsoidGeodesic-98c62a56.js +520 -0
  24. package/dist/assets/cesium/Workers/EllipsoidGeometry-21c0e3a5.js +637 -0
  25. package/dist/assets/cesium/Workers/EllipsoidOutlineGeometry-eff247c8.js +454 -0
  26. package/dist/assets/cesium/Workers/EllipsoidRhumbLine-19756602.js +741 -0
  27. package/dist/assets/cesium/Workers/EllipsoidTangentPlane-214683dc.js +373 -0
  28. package/dist/assets/cesium/Workers/EncodedCartesian3-81f70735.js +171 -0
  29. package/dist/assets/cesium/Workers/FrustumGeometry-ac42a6d9.js +2512 -0
  30. package/dist/assets/cesium/Workers/GeometryAttribute-7d6f1732.js +619 -0
  31. package/dist/assets/cesium/Workers/GeometryAttributes-f06a2792.js +91 -0
  32. package/dist/assets/cesium/Workers/GeometryInstance-451dc1cd.js +121 -0
  33. package/dist/assets/cesium/Workers/GeometryOffsetAttribute-04332ce7.js +16 -0
  34. package/dist/assets/cesium/Workers/GeometryPipeline-ce4339ed.js +3690 -0
  35. package/dist/assets/cesium/Workers/IndexDatatype-a55ceaa1.js +200 -0
  36. package/dist/assets/cesium/Workers/IntersectionTests-f6e6bd8a.js +1836 -0
  37. package/dist/assets/cesium/Workers/Math-2dbd6b93.js +1330 -0
  38. package/dist/assets/cesium/Workers/Matrix2-13178034.js +7086 -0
  39. package/dist/assets/cesium/Workers/Matrix3-315394f6.js +4283 -0
  40. package/dist/assets/cesium/Workers/OrientedBoundingBox-04920dc7.js +1257 -0
  41. package/dist/assets/cesium/Workers/Plane-900aa728.js +309 -0
  42. package/dist/assets/cesium/Workers/PolygonGeometryLibrary-a8680d96.js +1074 -0
  43. package/dist/assets/cesium/Workers/PolygonPipeline-844aab0a.js +1345 -0
  44. package/dist/assets/cesium/Workers/PolylinePipeline-32f36d2a.js +573 -0
  45. package/dist/assets/cesium/Workers/PolylineVolumeGeometryLibrary-a510d657.js +781 -0
  46. package/dist/assets/cesium/Workers/PrimitivePipeline-ba38434a.js +966 -0
  47. package/dist/assets/cesium/Workers/RectangleGeometryLibrary-bdba697e.js +280 -0
  48. package/dist/assets/cesium/Workers/RuntimeError-06c93819.js +68 -0
  49. package/dist/assets/cesium/Workers/TerrainEncoding-833187da.js +1227 -0
  50. package/dist/assets/cesium/Workers/Transforms-40229881.js +14696 -0
  51. package/dist/assets/cesium/Workers/VertexFormat-6b480673.js +312 -0
  52. package/dist/assets/cesium/Workers/WallGeometryLibrary-919eed92.js +211 -0
  53. package/dist/assets/cesium/Workers/WebGLConstants-a8cc3e8c.js +620 -0
  54. package/dist/assets/cesium/Workers/WebMercatorProjection-13a90d41.js +151 -0
  55. package/dist/assets/cesium/Workers/arrayRemoveDuplicates-c2038105.js +129 -0
  56. package/dist/assets/cesium/Workers/cesiumWorkerBootstrapper.js +1336 -4
  57. package/dist/assets/cesium/Workers/combine-ca22a614.js +82 -0
  58. package/dist/assets/cesium/Workers/combineGeometry.js +17 -25
  59. package/dist/assets/cesium/Workers/createBoxGeometry.js +12 -25
  60. package/dist/assets/cesium/Workers/createBoxOutlineGeometry.js +313 -25
  61. package/dist/assets/cesium/Workers/createCircleGeometry.js +213 -25
  62. package/dist/assets/cesium/Workers/createCircleOutlineGeometry.js +160 -25
  63. package/dist/assets/cesium/Workers/createCoplanarPolygonGeometry.js +586 -25
  64. package/dist/assets/cesium/Workers/createCoplanarPolygonOutlineGeometry.js +236 -25
  65. package/dist/assets/cesium/Workers/createCorridorGeometry.js +1407 -25
  66. package/dist/assets/cesium/Workers/createCorridorOutlineGeometry.js +603 -25
  67. package/dist/assets/cesium/Workers/createCylinderGeometry.js +12 -25
  68. package/dist/assets/cesium/Workers/createCylinderOutlineGeometry.js +265 -25
  69. package/dist/assets/cesium/Workers/createEllipseGeometry.js +14 -25
  70. package/dist/assets/cesium/Workers/createEllipseOutlineGeometry.js +14 -25
  71. package/dist/assets/cesium/Workers/createEllipsoidGeometry.js +12 -25
  72. package/dist/assets/cesium/Workers/createEllipsoidOutlineGeometry.js +15 -25
  73. package/dist/assets/cesium/Workers/createFrustumGeometry.js +12 -25
  74. package/dist/assets/cesium/Workers/createFrustumOutlineGeometry.js +251 -25
  75. package/dist/assets/cesium/Workers/createGeometry.js +55 -25
  76. package/dist/assets/cesium/Workers/createGroundPolylineGeometry.js +2134 -25
  77. package/dist/assets/cesium/Workers/createPlaneGeometry.js +250 -25
  78. package/dist/assets/cesium/Workers/createPlaneOutlineGeometry.js +115 -25
  79. package/dist/assets/cesium/Workers/createPolygonGeometry.js +1420 -25
  80. package/dist/assets/cesium/Workers/createPolygonOutlineGeometry.js +683 -25
  81. package/dist/assets/cesium/Workers/createPolylineGeometry.js +571 -25
  82. package/dist/assets/cesium/Workers/createPolylineVolumeGeometry.js +411 -25
  83. package/dist/assets/cesium/Workers/createPolylineVolumeOutlineGeometry.js +301 -25
  84. package/dist/assets/cesium/Workers/createRectangleGeometry.js +1476 -25
  85. package/dist/assets/cesium/Workers/createRectangleOutlineGeometry.js +535 -25
  86. package/dist/assets/cesium/Workers/createSimplePolylineGeometry.js +458 -25
  87. package/dist/assets/cesium/Workers/createSphereGeometry.js +123 -25
  88. package/dist/assets/cesium/Workers/createSphereOutlineGeometry.js +126 -25
  89. package/dist/assets/cesium/Workers/createTaskProcessorWorker.js +127 -25
  90. package/dist/assets/cesium/Workers/createVectorTileClampedPolylines.js +535 -25
  91. package/dist/assets/cesium/Workers/createVectorTileGeometries.js +445 -25
  92. package/dist/assets/cesium/Workers/createVectorTilePoints.js +79 -25
  93. package/dist/assets/cesium/Workers/createVectorTilePolygons.js +406 -25
  94. package/dist/assets/cesium/Workers/createVectorTilePolylines.js +254 -25
  95. package/dist/assets/cesium/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +640 -25
  96. package/dist/assets/cesium/Workers/createVerticesFromHeightmap.js +2711 -27
  97. package/dist/assets/cesium/Workers/createVerticesFromQuantizedTerrainMesh.js +994 -25
  98. package/dist/assets/cesium/Workers/createWallGeometry.js +623 -25
  99. package/dist/assets/cesium/Workers/createWallOutlineGeometry.js +432 -25
  100. package/dist/assets/cesium/Workers/decodeDraco.js +381 -25
  101. package/dist/assets/cesium/Workers/decodeGoogleEarthEnterprisePacket.js +3687 -25
  102. package/dist/assets/cesium/Workers/decodeI3S.js +1040 -0
  103. package/dist/assets/cesium/Workers/defaultValue-0a909f67.js +51 -0
  104. package/dist/assets/cesium/Workers/package.js +2 -2
  105. package/dist/assets/cesium/Workers/transcodeKTX2.js +1516 -25
  106. package/dist/assets/cesium/Workers/transferTypedArrayTest.js +18 -2
  107. package/dist/assets/cesium/Workers/upsampleQuantizedTerrainMesh.js +1023 -25
  108. package/dist/assets/{cesium.2f992f.js → cesium.adbd45.js} +112161 -108735
  109. package/dist/assets/cesium.js +1 -1
  110. package/dist/assets/{core.cb0408.js → core.60e74d.js} +1616 -1629
  111. package/dist/assets/core.f198cf.js +15993 -0
  112. package/dist/assets/core.js +1 -1
  113. package/dist/assets/{index.bccdf969.js → index.884a53ef.js} +1 -1
  114. package/dist/assets/{ol.5e3fd0.js → ol.c6ff35.js} +6992 -6972
  115. package/dist/assets/ol.dbd604.js +44299 -0
  116. package/dist/assets/ol.js +1 -1
  117. package/dist/assets/ui.bf504d.css +1 -0
  118. package/dist/assets/{ui.08c48f.js → ui.bf504d.js} +6121 -6785
  119. package/dist/assets/ui.js +1 -1
  120. package/dist/assets/{vue.228ead.js → vue.75b819.js} +0 -0
  121. package/dist/assets/vue.a831f1.js +4675 -0
  122. package/dist/assets/vue.js +2 -2
  123. package/dist/assets/{vuetify.0b5039.css → vuetify.0d7360.css} +0 -0
  124. package/dist/assets/{vuetify.0b5039.js → vuetify.0d7360.js} +1 -1
  125. package/dist/assets/vuetify.js +2 -2
  126. package/dist/index.html +1 -1
  127. package/index.js +2 -1
  128. package/lib/cesium.js +1 -1
  129. package/package.json +3 -4
  130. package/plugins/{simple-graph → @vcmap/simple-graph}/README.md +1 -1
  131. package/plugins/{simple-graph → @vcmap/simple-graph}/SimpleGraphComponent.vue +0 -0
  132. package/plugins/{simple-graph → @vcmap/simple-graph}/index.js +0 -0
  133. package/plugins/{simple-graph → @vcmap/simple-graph}/package.json +0 -0
  134. package/plugins/{simple-graph → @vcmap/simple-graph}/simpleGraphView.js +0 -0
  135. package/plugins/@vcmap-show-case/README.md +20 -0
  136. package/plugins/{buttonExamples/ButtonExamples.vue → @vcmap-show-case/buttons-example/ButtonsExample.vue} +1 -1
  137. package/plugins/@vcmap-show-case/buttons-example/README.md +4 -0
  138. package/plugins/{buttonExamples → @vcmap-show-case/buttons-example}/index.js +16 -8
  139. package/plugins/@vcmap-show-case/buttons-example/package.json +5 -0
  140. package/plugins/{categoryTest → @vcmap-show-case/category-tester}/Categories.vue +7 -6
  141. package/plugins/{categoryTest → @vcmap-show-case/category-tester}/Category.vue +4 -3
  142. package/plugins/@vcmap-show-case/category-tester/README.md +3 -0
  143. package/plugins/{categoryTest → @vcmap-show-case/category-tester}/index.js +12 -4
  144. package/plugins/@vcmap-show-case/category-tester/package.json +5 -0
  145. package/plugins/@vcmap-show-case/config-editor/README.md +3 -0
  146. package/plugins/{test → @vcmap-show-case/config-editor}/editor.vue +0 -0
  147. package/plugins/@vcmap-show-case/config-editor/index.js +47 -0
  148. package/plugins/@vcmap-show-case/config-editor/package.json +5 -0
  149. package/plugins/@vcmap-show-case/context-menu-tester/README.md +3 -0
  150. package/plugins/@vcmap-show-case/context-menu-tester/index.js +33 -0
  151. package/plugins/@vcmap-show-case/context-menu-tester/package.json +5 -0
  152. package/plugins/{@vcmap/pluginExample/pluginExampleComponent.vue → @vcmap-show-case/form-inputs-example/FormInputsExample.vue} +14 -13
  153. package/plugins/@vcmap-show-case/form-inputs-example/README.md +4 -0
  154. package/plugins/@vcmap-show-case/form-inputs-example/config.json +5 -0
  155. package/plugins/{@vcmap/pluginExample → @vcmap-show-case/form-inputs-example}/exampleActions.js +1 -1
  156. package/plugins/{@vcmap/pluginExample → @vcmap-show-case/form-inputs-example}/index.js +23 -22
  157. package/plugins/@vcmap-show-case/form-inputs-example/package.json +5 -0
  158. package/plugins/{@vcmap/pluginExample → @vcmap-show-case/form-inputs-example}/validation.js +0 -0
  159. package/plugins/@vcmap-show-case/icons-example/README.md +5 -0
  160. package/plugins/@vcmap-show-case/icons-example/allIconsComponent.vue +51 -0
  161. package/plugins/@vcmap-show-case/icons-example/index.js +44 -0
  162. package/plugins/@vcmap-show-case/icons-example/package.json +5 -0
  163. package/plugins/{test/testList.vue → @vcmap-show-case/list-example/ListExample.vue} +1 -1
  164. package/plugins/@vcmap-show-case/list-example/README.md +3 -0
  165. package/plugins/@vcmap-show-case/list-example/index.js +44 -0
  166. package/plugins/@vcmap-show-case/list-example/package.json +5 -0
  167. package/plugins/@vcmap-show-case/notifier-tester/README.md +3 -0
  168. package/plugins/{notifier → @vcmap-show-case/notifier-tester}/index.js +11 -6
  169. package/plugins/{notifier → @vcmap-show-case/notifier-tester}/notifierTester.vue +0 -0
  170. package/plugins/@vcmap-show-case/notifier-tester/package.json +5 -0
  171. package/plugins/@vcmap-show-case/textfields-example/README.md +3 -0
  172. package/plugins/{example/mySuperComponent.vue → @vcmap-show-case/textfields-example/TextfieldsExample.vue} +1 -7
  173. package/plugins/{example → @vcmap-show-case/textfields-example}/index.js +58 -62
  174. package/plugins/@vcmap-show-case/textfields-example/package.json +5 -0
  175. package/plugins/@vcmap-show-case/window-tester/README.md +3 -0
  176. package/plugins/{test/windowManagerExample.vue → @vcmap-show-case/window-tester/WindowExample.vue} +36 -20
  177. package/plugins/{test → @vcmap-show-case/window-tester}/emptyComponent.vue +8 -3
  178. package/plugins/@vcmap-show-case/window-tester/index.js +62 -0
  179. package/plugins/{test → @vcmap-show-case/window-tester}/myCustomHeader.vue +0 -0
  180. package/plugins/@vcmap-show-case/window-tester/package.json +5 -0
  181. package/plugins/{test → @vcmap-show-case/window-tester}/toolbox-data.js +9 -9
  182. package/plugins/{test/vcsContent.vue → @vcmap-show-case/window-tester/windowExampleContent.vue} +1 -5
  183. package/plugins/@vcmap-show-case/wizard-example/README.md +3 -0
  184. package/plugins/{wizardExample → @vcmap-show-case/wizard-example}/index.js +12 -6
  185. package/plugins/@vcmap-show-case/wizard-example/package.json +5 -0
  186. package/plugins/@vcmap-show-case/wizard-example/wizardExample.vue +95 -0
  187. package/plugins/package.json +2 -1
  188. package/src/actions/actionHelper.js +1 -3
  189. package/src/actions/stateRefAction.js +0 -10
  190. package/src/application/VcsApp.vue +42 -23
  191. package/src/application/VcsMap.vue +9 -0
  192. package/src/components/buttons/VcsActionButtonList.vue +1 -0
  193. package/src/components/form-inputs-controls/VcsCheckbox.vue +3 -1
  194. package/src/components/form-inputs-controls/VcsWizard.vue +17 -20
  195. package/src/components/form-inputs-controls/VcsWizardStep.vue +160 -0
  196. package/src/{icons → components/icons}/+all.js +0 -0
  197. package/src/{icons → components/icons}/2DAreaIcon.vue +0 -0
  198. package/src/{icons → components/icons}/2DDistanceIcon.vue +0 -0
  199. package/src/{icons → components/icons}/3DAreaIcon.vue +0 -0
  200. package/src/{icons → components/icons}/3DDistanceIcon.vue +0 -0
  201. package/src/{icons → components/icons}/3DHeightIcon.vue +0 -0
  202. package/src/{icons → components/icons}/AngleIcon.vue +0 -0
  203. package/src/{icons → components/icons}/AssociationsIcon.vue +0 -0
  204. package/src/{icons → components/icons}/AxisIcon.vue +0 -0
  205. package/src/{icons → components/icons}/BoundingBoxIcon.vue +0 -0
  206. package/src/{icons → components/icons}/CheckboxCheckedIcon.vue +0 -0
  207. package/src/{icons → components/icons}/CheckboxIcon.vue +0 -0
  208. package/src/{icons → components/icons}/CheckboxIndeterminateIcon.vue +0 -0
  209. package/src/{icons → components/icons}/CircleIcon.vue +0 -0
  210. package/src/{icons → components/icons}/ClippingHorizontalIcon.vue +0 -0
  211. package/src/{icons → components/icons}/ClippingIcon.vue +0 -0
  212. package/src/{icons → components/icons}/ClippingVerticalIcon.vue +0 -0
  213. package/src/{icons → components/icons}/ColorPickerIcon.vue +0 -0
  214. package/src/{icons → components/icons}/ColorSwatchIcon.vue +0 -0
  215. package/src/{icons → components/icons}/CommentIcon.vue +0 -0
  216. package/src/{icons → components/icons}/CompassIcon.vue +0 -0
  217. package/src/{icons → components/icons}/ComponentsIcon.vue +0 -0
  218. package/src/{icons → components/icons}/ConeIcon.vue +0 -0
  219. package/src/{icons → components/icons}/DimensionsHouseIcon.vue +0 -0
  220. package/src/{icons → components/icons}/EditIcon.vue +0 -0
  221. package/src/{icons → components/icons}/ElevationProfileIcon.vue +0 -0
  222. package/src/{icons → components/icons}/ExportAreaIcon.vue +0 -0
  223. package/src/{icons → components/icons}/ExportFlightIcon.vue +0 -0
  224. package/src/{icons → components/icons}/ExportIcon.vue +0 -0
  225. package/src/{icons → components/icons}/ExternalLinkIcon.vue +0 -0
  226. package/src/{icons → components/icons}/EyeIcon.vue +0 -0
  227. package/src/{icons → components/icons}/FastForwardIcon.vue +0 -0
  228. package/src/{icons → components/icons}/FilterIcon.vue +0 -0
  229. package/src/{icons → components/icons}/GlobalTerrainIcon.vue +0 -0
  230. package/src/{icons → components/icons}/GlobeNatureIcon.vue +0 -0
  231. package/src/{icons → components/icons}/GroundIcon.vue +0 -0
  232. package/src/{icons → components/icons}/HealthCareIndustriesIcon.vue +0 -0
  233. package/src/{icons → components/icons}/HelpIcon.vue +0 -0
  234. package/src/{icons → components/icons}/HideIcon.vue +0 -0
  235. package/src/{icons → components/icons}/HomePointIcon.vue +0 -0
  236. package/src/{icons → components/icons}/HospitalsIcon.vue +0 -0
  237. package/src/{icons → components/icons}/HouseIcon.vue +0 -0
  238. package/src/{icons → components/icons}/ImportIcon.vue +0 -0
  239. package/src/{icons → components/icons}/InfoIcon.vue +0 -0
  240. package/src/{icons → components/icons}/KebabIcon.vue +0 -0
  241. package/src/{icons → components/icons}/LabelIcon.vue +0 -0
  242. package/src/{icons → components/icons}/LayersIcon.vue +0 -0
  243. package/src/{icons → components/icons}/LegendIcon.vue +0 -0
  244. package/src/{icons → components/icons}/LineIcon.vue +0 -0
  245. package/src/{icons → components/icons}/LinkIcon.vue +0 -0
  246. package/src/{icons → components/icons}/LogoutIcon.vue +0 -0
  247. package/src/{icons → components/icons}/MapIcon.vue +0 -0
  248. package/src/{icons → components/icons}/MenuIcon.vue +0 -0
  249. package/src/{icons → components/icons}/MinusIcon.vue +0 -0
  250. package/src/{icons → components/icons}/ObjectAttributeIcon.vue +0 -0
  251. package/src/{icons → components/icons}/ObjectSelectIcon.vue +0 -0
  252. package/src/{icons → components/icons}/ObliqueViewIcon.vue +0 -0
  253. package/src/{icons → components/icons}/PdfIcon.vue +0 -0
  254. package/src/{icons → components/icons}/PedestrianIcon.vue +0 -0
  255. package/src/{icons → components/icons}/PenIcon.vue +0 -0
  256. package/src/{icons → components/icons}/PlayCircleIcon.vue +0 -0
  257. package/src/{icons → components/icons}/PlusIcon.vue +0 -0
  258. package/src/{icons → components/icons}/PoiIcon.vue +0 -0
  259. package/src/{icons → components/icons}/PointSelectIcon.vue +0 -0
  260. package/src/{icons → components/icons}/PolygonIcon.vue +0 -0
  261. package/src/{icons → components/icons}/PresentationModeIcon.vue +0 -0
  262. package/src/{icons → components/icons}/ProgressIcon.vue +0 -0
  263. package/src/{icons → components/icons}/QueryIcon.vue +0 -0
  264. package/src/{icons → components/icons}/RectangleIcon.vue +0 -0
  265. package/src/{icons → components/icons}/ReturnIcon.vue +0 -0
  266. package/src/{icons → components/icons}/RewindIcon.vue +0 -0
  267. package/src/{icons → components/icons}/RotateLeftIcon.vue +0 -0
  268. package/src/{icons → components/icons}/RotateRightIcon.vue +0 -0
  269. package/src/{icons → components/icons}/ScreenshotIcon.vue +0 -0
  270. package/src/{icons → components/icons}/SearchIcon.vue +0 -0
  271. package/src/{icons → components/icons}/ShadowIcon.vue +0 -0
  272. package/src/{icons → components/icons}/ShapesIcon.vue +0 -0
  273. package/src/{icons → components/icons}/ShareIcon.vue +0 -0
  274. package/src/{icons → components/icons}/SimpleCircleFilledIcon.vue +0 -0
  275. package/src/{icons → components/icons}/SimpleCircleHalfFilledIcon.vue +0 -0
  276. package/src/{icons → components/icons}/SimpleCircleOutlinedIcon.vue +0 -0
  277. package/src/{icons → components/icons}/SkipNextIcon.vue +0 -0
  278. package/src/{icons → components/icons}/SkipPreviousIcon.vue +0 -0
  279. package/src/{icons → components/icons}/SplitViewIcon.vue +0 -0
  280. package/src/{icons → components/icons}/TerrainBoxIcon.vue +0 -0
  281. package/src/{icons → components/icons}/TextStyleIcon.vue +0 -0
  282. package/src/{icons → components/icons}/ThreeDimensionsIcon.vue +0 -0
  283. package/src/{icons → components/icons}/ToolsIcon.vue +0 -0
  284. package/src/{icons → components/icons}/TouchIcon.vue +0 -0
  285. package/src/{icons → components/icons}/TrashCanIcon.vue +0 -0
  286. package/src/{icons → components/icons}/TriangleIcon.vue +0 -0
  287. package/src/{icons → components/icons}/TwoDimensionsIcon.vue +0 -0
  288. package/src/{icons → components/icons}/UploadIcon.vue +0 -0
  289. package/src/{icons → components/icons}/UserProfileIcon.vue +0 -0
  290. package/src/{icons → components/icons}/UserShareIcon.vue +0 -0
  291. package/src/{icons → components/icons}/VideoRecorderIcon.vue +0 -0
  292. package/src/{icons → components/icons}/ViewpointFlightIcon.vue +0 -0
  293. package/src/{icons → components/icons}/ViewpointIcon.vue +0 -0
  294. package/src/{icons → components/icons}/Viewshed360Icon.vue +0 -0
  295. package/src/{icons → components/icons}/ViewshedConeIcon.vue +0 -0
  296. package/src/{icons → components/icons}/ViewshedIcon.vue +0 -0
  297. package/src/{icons → components/icons}/WalkingIcon.vue +0 -0
  298. package/src/{icons → components/icons}/WallIcon.vue +0 -0
  299. package/src/{icons → components/icons}/WandIcon.vue +0 -0
  300. package/src/components/lists/VcsList.vue +21 -12
  301. package/src/components/lists/VcsTreeviewLeaf.vue +14 -2
  302. package/src/components/notification/VcsTooltip.vue +1 -1
  303. package/src/featureInfo/abstractFeatureInfoView.js +1 -1
  304. package/src/featureInfo/addressBalloonFeatureInfoView.js +1 -1
  305. package/src/featureInfo/balloonFeatureInfoView.js +1 -1
  306. package/src/featureInfo/balloonHelper.js +6 -6
  307. package/src/featureInfo/featureInfo.js +2 -2
  308. package/src/i18n/de.js +2 -6
  309. package/src/i18n/en.js +2 -6
  310. package/src/legend/legendHelper.js +4 -3
  311. package/src/legend/vcsLegend.vue +21 -2
  312. package/src/manager/window/WindowComponent.vue +42 -4
  313. package/src/manager/window/WindowComponentHeader.vue +1 -1
  314. package/src/manager/window/windowHelper.js +7 -11
  315. package/src/manager/window/windowManager.js +15 -11
  316. package/src/navigation/mapNavCompass.vue +13 -7
  317. package/src/navigation/mapNavigation.vue +66 -4
  318. package/src/navigation/orientationToolsButton.vue +1 -1
  319. package/src/navigation/overviewMap.js +26 -10
  320. package/src/navigation/vcsCompass.vue +4 -73
  321. package/src/setup.js +1 -1
  322. package/src/vuePlugins/vuetify.js +1 -1
  323. package/dist/assets/cesium/Workers/ArcType-c9b2b290.js +0 -25
  324. package/dist/assets/cesium/Workers/AttributeCompression-7b0f288d.js +0 -25
  325. package/dist/assets/cesium/Workers/AxisAlignedBoundingBox-d0c22774.js +0 -25
  326. package/dist/assets/cesium/Workers/BoundingRectangle-201b1a81.js +0 -25
  327. package/dist/assets/cesium/Workers/BoxGeometry-4985457c.js +0 -25
  328. package/dist/assets/cesium/Workers/Color-cc8c18b3.js +0 -25
  329. package/dist/assets/cesium/Workers/ComponentDatatype-0200bf8c.js +0 -25
  330. package/dist/assets/cesium/Workers/CoplanarPolygonGeometryLibrary-4345acdf.js +0 -25
  331. package/dist/assets/cesium/Workers/CorridorGeometryLibrary-850a6c35.js +0 -25
  332. package/dist/assets/cesium/Workers/CylinderGeometry-57a1051a.js +0 -25
  333. package/dist/assets/cesium/Workers/CylinderGeometryLibrary-62ce5a1f.js +0 -25
  334. package/dist/assets/cesium/Workers/EllipseGeometry-8627398f.js +0 -25
  335. package/dist/assets/cesium/Workers/EllipseGeometryLibrary-e5919563.js +0 -25
  336. package/dist/assets/cesium/Workers/EllipseOutlineGeometry-96fd4ae1.js +0 -25
  337. package/dist/assets/cesium/Workers/EllipsoidGeodesic-8bfefbff.js +0 -25
  338. package/dist/assets/cesium/Workers/EllipsoidGeometry-377329b9.js +0 -25
  339. package/dist/assets/cesium/Workers/EllipsoidOutlineGeometry-e6e16e49.js +0 -25
  340. package/dist/assets/cesium/Workers/EllipsoidRhumbLine-03528f73.js +0 -25
  341. package/dist/assets/cesium/Workers/EllipsoidTangentPlane-c080fd1b.js +0 -25
  342. package/dist/assets/cesium/Workers/EncodedCartesian3-ea0e408f.js +0 -25
  343. package/dist/assets/cesium/Workers/FrustumGeometry-a8b5d817.js +0 -25
  344. package/dist/assets/cesium/Workers/GeometryAttribute-8458a8fd.js +0 -25
  345. package/dist/assets/cesium/Workers/GeometryAttributes-ac0f8485.js +0 -25
  346. package/dist/assets/cesium/Workers/GeometryInstance-ee3aa3ba.js +0 -25
  347. package/dist/assets/cesium/Workers/GeometryOffsetAttribute-08ae0c50.js +0 -25
  348. package/dist/assets/cesium/Workers/GeometryPipeline-33ca229c.js +0 -25
  349. package/dist/assets/cesium/Workers/IndexDatatype-e713bfd2.js +0 -25
  350. package/dist/assets/cesium/Workers/IntersectionTests-eb4db8e0.js +0 -25
  351. package/dist/assets/cesium/Workers/Matrix2-eefef8eb.js +0 -25
  352. package/dist/assets/cesium/Workers/OrientedBoundingBox-5193f9a2.js +0 -25
  353. package/dist/assets/cesium/Workers/Plane-b0299683.js +0 -25
  354. package/dist/assets/cesium/Workers/PolygonGeometryLibrary-b61295f3.js +0 -25
  355. package/dist/assets/cesium/Workers/PolygonPipeline-eb527514.js +0 -25
  356. package/dist/assets/cesium/Workers/PolylinePipeline-0f23dd84.js +0 -25
  357. package/dist/assets/cesium/Workers/PolylineVolumeGeometryLibrary-2d903430.js +0 -25
  358. package/dist/assets/cesium/Workers/PrimitivePipeline-e2640413.js +0 -25
  359. package/dist/assets/cesium/Workers/RectangleGeometryLibrary-ae8bf8a5.js +0 -25
  360. package/dist/assets/cesium/Workers/RuntimeError-5baf5c66.js +0 -25
  361. package/dist/assets/cesium/Workers/TerrainEncoding-bc10ab54.js +0 -25
  362. package/dist/assets/cesium/Workers/Transforms-d2e5867e.js +0 -63
  363. package/dist/assets/cesium/Workers/VertexFormat-5ec0d9ff.js +0 -25
  364. package/dist/assets/cesium/Workers/WallGeometryLibrary-1a33e416.js +0 -25
  365. package/dist/assets/cesium/Workers/WebGLConstants-5b50ced1.js +0 -25
  366. package/dist/assets/cesium/Workers/WebMercatorProjection-cd2f30c2.js +0 -25
  367. package/dist/assets/cesium/Workers/_commonjsHelpers-bc29abbc.js +0 -25
  368. package/dist/assets/cesium/Workers/arrayRemoveDuplicates-f13aceb1.js +0 -25
  369. package/dist/assets/cesium/Workers/combine-7533016d.js +0 -25
  370. package/dist/assets/cesium/Workers/defaultValue-0c475b81.js +0 -25
  371. package/dist/assets/cesium/Workers/package.json +0 -1
  372. package/dist/assets/ui.08c48f.css +0 -1
  373. package/plugins/@vcmap/pluginExample/config.json +0 -6
  374. package/plugins/@vcmap/pluginExample/package.json +0 -7
  375. package/plugins/categoryTest/ItemEditor.vue +0 -13
  376. package/plugins/test/allIconsComponent.vue +0 -50
  377. package/plugins/test/index.js +0 -209
  378. package/plugins/wizardExample/wizardExample.vue +0 -77
  379. package/src/components/form-inputs-controls/VcsColorPicker.vue +0 -85
@@ -0,0 +1,3690 @@
1
+ define(['exports', './AttributeCompression-b646d393', './Matrix2-13178034', './Matrix3-315394f6', './Check-666ab1a0', './defaultValue-0a909f67', './Math-2dbd6b93', './Transforms-40229881', './ComponentDatatype-f7b11d02', './EncodedCartesian3-81f70735', './GeometryAttribute-7d6f1732', './IndexDatatype-a55ceaa1', './IntersectionTests-f6e6bd8a', './Plane-900aa728'], (function (exports, AttributeCompression, Matrix2, Matrix3, Check, defaultValue, Math$1, Transforms, ComponentDatatype, EncodedCartesian3, GeometryAttribute, IndexDatatype, IntersectionTests, Plane) { 'use strict';
2
+
3
+ const scratchCartesian1 = new Matrix3.Cartesian3();
4
+ const scratchCartesian2$1 = new Matrix3.Cartesian3();
5
+ const scratchCartesian3$1 = new Matrix3.Cartesian3();
6
+
7
+ /**
8
+ * Computes the barycentric coordinates for a point with respect to a triangle.
9
+ *
10
+ * @function
11
+ *
12
+ * @param {Cartesian2|Cartesian3} point The point to test.
13
+ * @param {Cartesian2|Cartesian3} p0 The first point of the triangle, corresponding to the barycentric x-axis.
14
+ * @param {Cartesian2|Cartesian3} p1 The second point of the triangle, corresponding to the barycentric y-axis.
15
+ * @param {Cartesian2|Cartesian3} p2 The third point of the triangle, corresponding to the barycentric z-axis.
16
+ * @param {Cartesian3} [result] The object onto which to store the result.
17
+ * @returns {Cartesian3|undefined} The modified result parameter or a new Cartesian3 instance if one was not provided. If the triangle is degenerate the function will return undefined.
18
+ *
19
+ * @example
20
+ * // Returns Cartesian3.UNIT_X
21
+ * const p = new Cesium.Cartesian3(-1.0, 0.0, 0.0);
22
+ * const b = Cesium.barycentricCoordinates(p,
23
+ * new Cesium.Cartesian3(-1.0, 0.0, 0.0),
24
+ * new Cesium.Cartesian3( 1.0, 0.0, 0.0),
25
+ * new Cesium.Cartesian3( 0.0, 1.0, 1.0));
26
+ */
27
+ function barycentricCoordinates(point, p0, p1, p2, result) {
28
+ //>>includeStart('debug', pragmas.debug);
29
+ Check.Check.defined("point", point);
30
+ Check.Check.defined("p0", p0);
31
+ Check.Check.defined("p1", p1);
32
+ Check.Check.defined("p2", p2);
33
+ //>>includeEnd('debug');
34
+
35
+ if (!defaultValue.defined(result)) {
36
+ result = new Matrix3.Cartesian3();
37
+ }
38
+
39
+ // Implementation based on http://www.blackpawn.com/texts/pointinpoly/default.html.
40
+ let v0;
41
+ let v1;
42
+ let v2;
43
+ let dot00;
44
+ let dot01;
45
+ let dot02;
46
+ let dot11;
47
+ let dot12;
48
+
49
+ if (!defaultValue.defined(p0.z)) {
50
+ if (Matrix2.Cartesian2.equalsEpsilon(point, p0, Math$1.CesiumMath.EPSILON14)) {
51
+ return Matrix3.Cartesian3.clone(Matrix3.Cartesian3.UNIT_X, result);
52
+ }
53
+ if (Matrix2.Cartesian2.equalsEpsilon(point, p1, Math$1.CesiumMath.EPSILON14)) {
54
+ return Matrix3.Cartesian3.clone(Matrix3.Cartesian3.UNIT_Y, result);
55
+ }
56
+ if (Matrix2.Cartesian2.equalsEpsilon(point, p2, Math$1.CesiumMath.EPSILON14)) {
57
+ return Matrix3.Cartesian3.clone(Matrix3.Cartesian3.UNIT_Z, result);
58
+ }
59
+
60
+ v0 = Matrix2.Cartesian2.subtract(p1, p0, scratchCartesian1);
61
+ v1 = Matrix2.Cartesian2.subtract(p2, p0, scratchCartesian2$1);
62
+ v2 = Matrix2.Cartesian2.subtract(point, p0, scratchCartesian3$1);
63
+
64
+ dot00 = Matrix2.Cartesian2.dot(v0, v0);
65
+ dot01 = Matrix2.Cartesian2.dot(v0, v1);
66
+ dot02 = Matrix2.Cartesian2.dot(v0, v2);
67
+ dot11 = Matrix2.Cartesian2.dot(v1, v1);
68
+ dot12 = Matrix2.Cartesian2.dot(v1, v2);
69
+ } else {
70
+ if (Matrix3.Cartesian3.equalsEpsilon(point, p0, Math$1.CesiumMath.EPSILON14)) {
71
+ return Matrix3.Cartesian3.clone(Matrix3.Cartesian3.UNIT_X, result);
72
+ }
73
+ if (Matrix3.Cartesian3.equalsEpsilon(point, p1, Math$1.CesiumMath.EPSILON14)) {
74
+ return Matrix3.Cartesian3.clone(Matrix3.Cartesian3.UNIT_Y, result);
75
+ }
76
+ if (Matrix3.Cartesian3.equalsEpsilon(point, p2, Math$1.CesiumMath.EPSILON14)) {
77
+ return Matrix3.Cartesian3.clone(Matrix3.Cartesian3.UNIT_Z, result);
78
+ }
79
+
80
+ v0 = Matrix3.Cartesian3.subtract(p1, p0, scratchCartesian1);
81
+ v1 = Matrix3.Cartesian3.subtract(p2, p0, scratchCartesian2$1);
82
+ v2 = Matrix3.Cartesian3.subtract(point, p0, scratchCartesian3$1);
83
+
84
+ dot00 = Matrix3.Cartesian3.dot(v0, v0);
85
+ dot01 = Matrix3.Cartesian3.dot(v0, v1);
86
+ dot02 = Matrix3.Cartesian3.dot(v0, v2);
87
+ dot11 = Matrix3.Cartesian3.dot(v1, v1);
88
+ dot12 = Matrix3.Cartesian3.dot(v1, v2);
89
+ }
90
+
91
+ result.y = dot11 * dot02 - dot01 * dot12;
92
+ result.z = dot00 * dot12 - dot01 * dot02;
93
+ const q = dot00 * dot11 - dot01 * dot01;
94
+
95
+ // Triangle is degenerate
96
+ if (q === 0) {
97
+ return undefined;
98
+ }
99
+
100
+ result.y /= q;
101
+ result.z /= q;
102
+ result.x = 1.0 - result.y - result.z;
103
+ return result;
104
+ }
105
+
106
+ /**
107
+ * Encapsulates an algorithm to optimize triangles for the post
108
+ * vertex-shader cache. This is based on the 2007 SIGGRAPH paper
109
+ * 'Fast Triangle Reordering for Vertex Locality and Reduced Overdraw.'
110
+ * The runtime is linear but several passes are made.
111
+ *
112
+ * @namespace Tipsify
113
+ *
114
+ * @see <a href='http://gfx.cs.princeton.edu/pubs/Sander_2007_%3ETR/tipsy.pdf'>
115
+ * Fast Triangle Reordering for Vertex Locality and Reduced Overdraw</a>
116
+ * by Sander, Nehab, and Barczak
117
+ *
118
+ * @private
119
+ */
120
+ const Tipsify = {};
121
+
122
+ /**
123
+ * Calculates the average cache miss ratio (ACMR) for a given set of indices.
124
+ *
125
+ * @param {Object} options Object with the following properties:
126
+ * @param {Number[]} options.indices Lists triads of numbers corresponding to the indices of the vertices
127
+ * in the vertex buffer that define the geometry's triangles.
128
+ * @param {Number} [options.maximumIndex] The maximum value of the elements in <code>args.indices</code>.
129
+ * If not supplied, this value will be computed.
130
+ * @param {Number} [options.cacheSize=24] The number of vertices that can be stored in the cache at any one time.
131
+ * @returns {Number} The average cache miss ratio (ACMR).
132
+ *
133
+ * @exception {DeveloperError} indices length must be a multiple of three.
134
+ * @exception {DeveloperError} cacheSize must be greater than two.
135
+ *
136
+ * @example
137
+ * const indices = [0, 1, 2, 3, 4, 5];
138
+ * const maxIndex = 5;
139
+ * const cacheSize = 3;
140
+ * const acmr = Cesium.Tipsify.calculateACMR({indices : indices, maxIndex : maxIndex, cacheSize : cacheSize});
141
+ */
142
+ Tipsify.calculateACMR = function (options) {
143
+ options = defaultValue.defaultValue(options, defaultValue.defaultValue.EMPTY_OBJECT);
144
+ const indices = options.indices;
145
+ let maximumIndex = options.maximumIndex;
146
+ const cacheSize = defaultValue.defaultValue(options.cacheSize, 24);
147
+
148
+ //>>includeStart('debug', pragmas.debug);
149
+ if (!defaultValue.defined(indices)) {
150
+ throw new Check.DeveloperError("indices is required.");
151
+ }
152
+ //>>includeEnd('debug');
153
+
154
+ const numIndices = indices.length;
155
+
156
+ //>>includeStart('debug', pragmas.debug);
157
+ if (numIndices < 3 || numIndices % 3 !== 0) {
158
+ throw new Check.DeveloperError("indices length must be a multiple of three.");
159
+ }
160
+ if (maximumIndex <= 0) {
161
+ throw new Check.DeveloperError("maximumIndex must be greater than zero.");
162
+ }
163
+ if (cacheSize < 3) {
164
+ throw new Check.DeveloperError("cacheSize must be greater than two.");
165
+ }
166
+ //>>includeEnd('debug');
167
+
168
+ // Compute the maximumIndex if not given
169
+ if (!defaultValue.defined(maximumIndex)) {
170
+ maximumIndex = 0;
171
+ let currentIndex = 0;
172
+ let intoIndices = indices[currentIndex];
173
+ while (currentIndex < numIndices) {
174
+ if (intoIndices > maximumIndex) {
175
+ maximumIndex = intoIndices;
176
+ }
177
+ ++currentIndex;
178
+ intoIndices = indices[currentIndex];
179
+ }
180
+ }
181
+
182
+ // Vertex time stamps
183
+ const vertexTimeStamps = [];
184
+ for (let i = 0; i < maximumIndex + 1; i++) {
185
+ vertexTimeStamps[i] = 0;
186
+ }
187
+
188
+ // Cache processing
189
+ let s = cacheSize + 1;
190
+ for (let j = 0; j < numIndices; ++j) {
191
+ if (s - vertexTimeStamps[indices[j]] > cacheSize) {
192
+ vertexTimeStamps[indices[j]] = s;
193
+ ++s;
194
+ }
195
+ }
196
+
197
+ return (s - cacheSize + 1) / (numIndices / 3);
198
+ };
199
+
200
+ /**
201
+ * Optimizes triangles for the post-vertex shader cache.
202
+ *
203
+ * @param {Object} options Object with the following properties:
204
+ * @param {Number[]} options.indices Lists triads of numbers corresponding to the indices of the vertices
205
+ * in the vertex buffer that define the geometry's triangles.
206
+ * @param {Number} [options.maximumIndex] The maximum value of the elements in <code>args.indices</code>.
207
+ * If not supplied, this value will be computed.
208
+ * @param {Number} [options.cacheSize=24] The number of vertices that can be stored in the cache at any one time.
209
+ * @returns {Number[]} A list of the input indices in an optimized order.
210
+ *
211
+ * @exception {DeveloperError} indices length must be a multiple of three.
212
+ * @exception {DeveloperError} cacheSize must be greater than two.
213
+ *
214
+ * @example
215
+ * const indices = [0, 1, 2, 3, 4, 5];
216
+ * const maxIndex = 5;
217
+ * const cacheSize = 3;
218
+ * const reorderedIndices = Cesium.Tipsify.tipsify({indices : indices, maxIndex : maxIndex, cacheSize : cacheSize});
219
+ */
220
+ Tipsify.tipsify = function (options) {
221
+ options = defaultValue.defaultValue(options, defaultValue.defaultValue.EMPTY_OBJECT);
222
+ const indices = options.indices;
223
+ const maximumIndex = options.maximumIndex;
224
+ const cacheSize = defaultValue.defaultValue(options.cacheSize, 24);
225
+
226
+ let cursor;
227
+
228
+ function skipDeadEnd(vertices, deadEnd, indices, maximumIndexPlusOne) {
229
+ while (deadEnd.length >= 1) {
230
+ // while the stack is not empty
231
+ const d = deadEnd[deadEnd.length - 1]; // top of the stack
232
+ deadEnd.splice(deadEnd.length - 1, 1); // pop the stack
233
+
234
+ if (vertices[d].numLiveTriangles > 0) {
235
+ return d;
236
+ }
237
+ }
238
+
239
+ while (cursor < maximumIndexPlusOne) {
240
+ if (vertices[cursor].numLiveTriangles > 0) {
241
+ ++cursor;
242
+ return cursor - 1;
243
+ }
244
+ ++cursor;
245
+ }
246
+ return -1;
247
+ }
248
+
249
+ function getNextVertex(
250
+ indices,
251
+ cacheSize,
252
+ oneRing,
253
+ vertices,
254
+ s,
255
+ deadEnd,
256
+ maximumIndexPlusOne
257
+ ) {
258
+ let n = -1;
259
+ let p;
260
+ let m = -1;
261
+ let itOneRing = 0;
262
+ while (itOneRing < oneRing.length) {
263
+ const index = oneRing[itOneRing];
264
+ if (vertices[index].numLiveTriangles) {
265
+ p = 0;
266
+ if (
267
+ s -
268
+ vertices[index].timeStamp +
269
+ 2 * vertices[index].numLiveTriangles <=
270
+ cacheSize
271
+ ) {
272
+ p = s - vertices[index].timeStamp;
273
+ }
274
+ if (p > m || m === -1) {
275
+ m = p;
276
+ n = index;
277
+ }
278
+ }
279
+ ++itOneRing;
280
+ }
281
+ if (n === -1) {
282
+ return skipDeadEnd(vertices, deadEnd, indices, maximumIndexPlusOne);
283
+ }
284
+ return n;
285
+ }
286
+
287
+ //>>includeStart('debug', pragmas.debug);
288
+ if (!defaultValue.defined(indices)) {
289
+ throw new Check.DeveloperError("indices is required.");
290
+ }
291
+ //>>includeEnd('debug');
292
+
293
+ const numIndices = indices.length;
294
+
295
+ //>>includeStart('debug', pragmas.debug);
296
+ if (numIndices < 3 || numIndices % 3 !== 0) {
297
+ throw new Check.DeveloperError("indices length must be a multiple of three.");
298
+ }
299
+ if (maximumIndex <= 0) {
300
+ throw new Check.DeveloperError("maximumIndex must be greater than zero.");
301
+ }
302
+ if (cacheSize < 3) {
303
+ throw new Check.DeveloperError("cacheSize must be greater than two.");
304
+ }
305
+ //>>includeEnd('debug');
306
+
307
+ // Determine maximum index
308
+ let maximumIndexPlusOne = 0;
309
+ let currentIndex = 0;
310
+ let intoIndices = indices[currentIndex];
311
+ const endIndex = numIndices;
312
+ if (defaultValue.defined(maximumIndex)) {
313
+ maximumIndexPlusOne = maximumIndex + 1;
314
+ } else {
315
+ while (currentIndex < endIndex) {
316
+ if (intoIndices > maximumIndexPlusOne) {
317
+ maximumIndexPlusOne = intoIndices;
318
+ }
319
+ ++currentIndex;
320
+ intoIndices = indices[currentIndex];
321
+ }
322
+ if (maximumIndexPlusOne === -1) {
323
+ return 0;
324
+ }
325
+ ++maximumIndexPlusOne;
326
+ }
327
+
328
+ // Vertices
329
+ const vertices = [];
330
+ let i;
331
+ for (i = 0; i < maximumIndexPlusOne; i++) {
332
+ vertices[i] = {
333
+ numLiveTriangles: 0,
334
+ timeStamp: 0,
335
+ vertexTriangles: [],
336
+ };
337
+ }
338
+ currentIndex = 0;
339
+ let triangle = 0;
340
+ while (currentIndex < endIndex) {
341
+ vertices[indices[currentIndex]].vertexTriangles.push(triangle);
342
+ ++vertices[indices[currentIndex]].numLiveTriangles;
343
+ vertices[indices[currentIndex + 1]].vertexTriangles.push(triangle);
344
+ ++vertices[indices[currentIndex + 1]].numLiveTriangles;
345
+ vertices[indices[currentIndex + 2]].vertexTriangles.push(triangle);
346
+ ++vertices[indices[currentIndex + 2]].numLiveTriangles;
347
+ ++triangle;
348
+ currentIndex += 3;
349
+ }
350
+
351
+ // Starting index
352
+ let f = 0;
353
+
354
+ // Time Stamp
355
+ let s = cacheSize + 1;
356
+ cursor = 1;
357
+
358
+ // Process
359
+ let oneRing = [];
360
+ const deadEnd = []; //Stack
361
+ let vertex;
362
+ let intoVertices;
363
+ let currentOutputIndex = 0;
364
+ const outputIndices = [];
365
+ const numTriangles = numIndices / 3;
366
+ const triangleEmitted = [];
367
+ for (i = 0; i < numTriangles; i++) {
368
+ triangleEmitted[i] = false;
369
+ }
370
+ let index;
371
+ let limit;
372
+ while (f !== -1) {
373
+ oneRing = [];
374
+ intoVertices = vertices[f];
375
+ limit = intoVertices.vertexTriangles.length;
376
+ for (let k = 0; k < limit; ++k) {
377
+ triangle = intoVertices.vertexTriangles[k];
378
+ if (!triangleEmitted[triangle]) {
379
+ triangleEmitted[triangle] = true;
380
+ currentIndex = triangle + triangle + triangle;
381
+ for (let j = 0; j < 3; ++j) {
382
+ // Set this index as a possible next index
383
+ index = indices[currentIndex];
384
+ oneRing.push(index);
385
+ deadEnd.push(index);
386
+
387
+ // Output index
388
+ outputIndices[currentOutputIndex] = index;
389
+ ++currentOutputIndex;
390
+
391
+ // Cache processing
392
+ vertex = vertices[index];
393
+ --vertex.numLiveTriangles;
394
+ if (s - vertex.timeStamp > cacheSize) {
395
+ vertex.timeStamp = s;
396
+ ++s;
397
+ }
398
+ ++currentIndex;
399
+ }
400
+ }
401
+ }
402
+ f = getNextVertex(
403
+ indices,
404
+ cacheSize,
405
+ oneRing,
406
+ vertices,
407
+ s,
408
+ deadEnd,
409
+ maximumIndexPlusOne
410
+ );
411
+ }
412
+
413
+ return outputIndices;
414
+ };
415
+ var Tipsify$1 = Tipsify;
416
+
417
+ /**
418
+ * Content pipeline functions for geometries.
419
+ *
420
+ * @namespace GeometryPipeline
421
+ *
422
+ * @see Geometry
423
+ */
424
+ const GeometryPipeline = {};
425
+
426
+ function addTriangle(lines, index, i0, i1, i2) {
427
+ lines[index++] = i0;
428
+ lines[index++] = i1;
429
+
430
+ lines[index++] = i1;
431
+ lines[index++] = i2;
432
+
433
+ lines[index++] = i2;
434
+ lines[index] = i0;
435
+ }
436
+
437
+ function trianglesToLines(triangles) {
438
+ const count = triangles.length;
439
+ const size = (count / 3) * 6;
440
+ const lines = IndexDatatype.IndexDatatype.createTypedArray(count, size);
441
+
442
+ let index = 0;
443
+ for (let i = 0; i < count; i += 3, index += 6) {
444
+ addTriangle(lines, index, triangles[i], triangles[i + 1], triangles[i + 2]);
445
+ }
446
+
447
+ return lines;
448
+ }
449
+
450
+ function triangleStripToLines(triangles) {
451
+ const count = triangles.length;
452
+ if (count >= 3) {
453
+ const size = (count - 2) * 6;
454
+ const lines = IndexDatatype.IndexDatatype.createTypedArray(count, size);
455
+
456
+ addTriangle(lines, 0, triangles[0], triangles[1], triangles[2]);
457
+ let index = 6;
458
+
459
+ for (let i = 3; i < count; ++i, index += 6) {
460
+ addTriangle(
461
+ lines,
462
+ index,
463
+ triangles[i - 1],
464
+ triangles[i],
465
+ triangles[i - 2]
466
+ );
467
+ }
468
+
469
+ return lines;
470
+ }
471
+
472
+ return new Uint16Array();
473
+ }
474
+
475
+ function triangleFanToLines(triangles) {
476
+ if (triangles.length > 0) {
477
+ const count = triangles.length - 1;
478
+ const size = (count - 1) * 6;
479
+ const lines = IndexDatatype.IndexDatatype.createTypedArray(count, size);
480
+
481
+ const base = triangles[0];
482
+ let index = 0;
483
+ for (let i = 1; i < count; ++i, index += 6) {
484
+ addTriangle(lines, index, base, triangles[i], triangles[i + 1]);
485
+ }
486
+
487
+ return lines;
488
+ }
489
+
490
+ return new Uint16Array();
491
+ }
492
+
493
+ /**
494
+ * Converts a geometry's triangle indices to line indices. If the geometry has an <code>indices</code>
495
+ * and its <code>primitiveType</code> is <code>TRIANGLES</code>, <code>TRIANGLE_STRIP</code>,
496
+ * <code>TRIANGLE_FAN</code>, it is converted to <code>LINES</code>; otherwise, the geometry is not changed.
497
+ * <p>
498
+ * This is commonly used to create a wireframe geometry for visual debugging.
499
+ * </p>
500
+ *
501
+ * @param {Geometry} geometry The geometry to modify.
502
+ * @returns {Geometry} The modified <code>geometry</code> argument, with its triangle indices converted to lines.
503
+ *
504
+ * @exception {DeveloperError} geometry.primitiveType must be TRIANGLES, TRIANGLE_STRIP, or TRIANGLE_FAN.
505
+ *
506
+ * @example
507
+ * geometry = Cesium.GeometryPipeline.toWireframe(geometry);
508
+ */
509
+ GeometryPipeline.toWireframe = function (geometry) {
510
+ //>>includeStart('debug', pragmas.debug);
511
+ if (!defaultValue.defined(geometry)) {
512
+ throw new Check.DeveloperError("geometry is required.");
513
+ }
514
+ //>>includeEnd('debug');
515
+
516
+ const indices = geometry.indices;
517
+ if (defaultValue.defined(indices)) {
518
+ switch (geometry.primitiveType) {
519
+ case GeometryAttribute.PrimitiveType.TRIANGLES:
520
+ geometry.indices = trianglesToLines(indices);
521
+ break;
522
+ case GeometryAttribute.PrimitiveType.TRIANGLE_STRIP:
523
+ geometry.indices = triangleStripToLines(indices);
524
+ break;
525
+ case GeometryAttribute.PrimitiveType.TRIANGLE_FAN:
526
+ geometry.indices = triangleFanToLines(indices);
527
+ break;
528
+ //>>includeStart('debug', pragmas.debug);
529
+ default:
530
+ throw new Check.DeveloperError(
531
+ "geometry.primitiveType must be TRIANGLES, TRIANGLE_STRIP, or TRIANGLE_FAN."
532
+ );
533
+ //>>includeEnd('debug');
534
+ }
535
+
536
+ geometry.primitiveType = GeometryAttribute.PrimitiveType.LINES;
537
+ }
538
+
539
+ return geometry;
540
+ };
541
+
542
+ /**
543
+ * Creates a new {@link Geometry} with <code>LINES</code> representing the provided
544
+ * attribute (<code>attributeName</code>) for the provided geometry. This is used to
545
+ * visualize vector attributes like normals, tangents, and bitangents.
546
+ *
547
+ * @param {Geometry} geometry The <code>Geometry</code> instance with the attribute.
548
+ * @param {String} [attributeName='normal'] The name of the attribute.
549
+ * @param {Number} [length=10000.0] The length of each line segment in meters. This can be negative to point the vector in the opposite direction.
550
+ * @returns {Geometry} A new <code>Geometry</code> instance with line segments for the vector.
551
+ *
552
+ * @exception {DeveloperError} geometry.attributes must have an attribute with the same name as the attributeName parameter.
553
+ *
554
+ * @example
555
+ * const geometry = Cesium.GeometryPipeline.createLineSegmentsForVectors(instance.geometry, 'bitangent', 100000.0);
556
+ */
557
+ GeometryPipeline.createLineSegmentsForVectors = function (
558
+ geometry,
559
+ attributeName,
560
+ length
561
+ ) {
562
+ attributeName = defaultValue.defaultValue(attributeName, "normal");
563
+
564
+ //>>includeStart('debug', pragmas.debug);
565
+ if (!defaultValue.defined(geometry)) {
566
+ throw new Check.DeveloperError("geometry is required.");
567
+ }
568
+ if (!defaultValue.defined(geometry.attributes.position)) {
569
+ throw new Check.DeveloperError("geometry.attributes.position is required.");
570
+ }
571
+ if (!defaultValue.defined(geometry.attributes[attributeName])) {
572
+ throw new Check.DeveloperError(
573
+ `geometry.attributes must have an attribute with the same name as the attributeName parameter, ${attributeName}.`
574
+ );
575
+ }
576
+ //>>includeEnd('debug');
577
+
578
+ length = defaultValue.defaultValue(length, 10000.0);
579
+
580
+ const positions = geometry.attributes.position.values;
581
+ const vectors = geometry.attributes[attributeName].values;
582
+ const positionsLength = positions.length;
583
+
584
+ const newPositions = new Float64Array(2 * positionsLength);
585
+
586
+ let j = 0;
587
+ for (let i = 0; i < positionsLength; i += 3) {
588
+ newPositions[j++] = positions[i];
589
+ newPositions[j++] = positions[i + 1];
590
+ newPositions[j++] = positions[i + 2];
591
+
592
+ newPositions[j++] = positions[i] + vectors[i] * length;
593
+ newPositions[j++] = positions[i + 1] + vectors[i + 1] * length;
594
+ newPositions[j++] = positions[i + 2] + vectors[i + 2] * length;
595
+ }
596
+
597
+ let newBoundingSphere;
598
+ const bs = geometry.boundingSphere;
599
+ if (defaultValue.defined(bs)) {
600
+ newBoundingSphere = new Transforms.BoundingSphere(bs.center, bs.radius + length);
601
+ }
602
+
603
+ return new GeometryAttribute.Geometry({
604
+ attributes: {
605
+ position: new GeometryAttribute.GeometryAttribute({
606
+ componentDatatype: ComponentDatatype.ComponentDatatype.DOUBLE,
607
+ componentsPerAttribute: 3,
608
+ values: newPositions,
609
+ }),
610
+ },
611
+ primitiveType: GeometryAttribute.PrimitiveType.LINES,
612
+ boundingSphere: newBoundingSphere,
613
+ });
614
+ };
615
+
616
+ /**
617
+ * Creates an object that maps attribute names to unique locations (indices)
618
+ * for matching vertex attributes and shader programs.
619
+ *
620
+ * @param {Geometry} geometry The geometry, which is not modified, to create the object for.
621
+ * @returns {Object} An object with attribute name / index pairs.
622
+ *
623
+ * @example
624
+ * const attributeLocations = Cesium.GeometryPipeline.createAttributeLocations(geometry);
625
+ * // Example output
626
+ * // {
627
+ * // 'position' : 0,
628
+ * // 'normal' : 1
629
+ * // }
630
+ */
631
+ GeometryPipeline.createAttributeLocations = function (geometry) {
632
+ //>>includeStart('debug', pragmas.debug);
633
+ if (!defaultValue.defined(geometry)) {
634
+ throw new Check.DeveloperError("geometry is required.");
635
+ }
636
+ //>>includeEnd('debug')
637
+
638
+ // There can be a WebGL performance hit when attribute 0 is disabled, so
639
+ // assign attribute locations to well-known attributes.
640
+ const semantics = [
641
+ "position",
642
+ "positionHigh",
643
+ "positionLow",
644
+
645
+ // From VertexFormat.position - after 2D projection and high-precision encoding
646
+ "position3DHigh",
647
+ "position3DLow",
648
+ "position2DHigh",
649
+ "position2DLow",
650
+
651
+ // From Primitive
652
+ "pickColor",
653
+
654
+ // From VertexFormat
655
+ "normal",
656
+ "st",
657
+ "tangent",
658
+ "bitangent",
659
+
660
+ // For shadow volumes
661
+ "extrudeDirection",
662
+
663
+ // From compressing texture coordinates and normals
664
+ "compressedAttributes",
665
+ ];
666
+
667
+ const attributes = geometry.attributes;
668
+ const indices = {};
669
+ let j = 0;
670
+ let i;
671
+ const len = semantics.length;
672
+
673
+ // Attribute locations for well-known attributes
674
+ for (i = 0; i < len; ++i) {
675
+ const semantic = semantics[i];
676
+
677
+ if (defaultValue.defined(attributes[semantic])) {
678
+ indices[semantic] = j++;
679
+ }
680
+ }
681
+
682
+ // Locations for custom attributes
683
+ for (const name in attributes) {
684
+ if (attributes.hasOwnProperty(name) && !defaultValue.defined(indices[name])) {
685
+ indices[name] = j++;
686
+ }
687
+ }
688
+
689
+ return indices;
690
+ };
691
+
692
+ /**
693
+ * Reorders a geometry's attributes and <code>indices</code> to achieve better performance from the GPU's pre-vertex-shader cache.
694
+ *
695
+ * @param {Geometry} geometry The geometry to modify.
696
+ * @returns {Geometry} The modified <code>geometry</code> argument, with its attributes and indices reordered for the GPU's pre-vertex-shader cache.
697
+ *
698
+ * @exception {DeveloperError} Each attribute array in geometry.attributes must have the same number of attributes.
699
+ *
700
+ *
701
+ * @example
702
+ * geometry = Cesium.GeometryPipeline.reorderForPreVertexCache(geometry);
703
+ *
704
+ * @see GeometryPipeline.reorderForPostVertexCache
705
+ */
706
+ GeometryPipeline.reorderForPreVertexCache = function (geometry) {
707
+ //>>includeStart('debug', pragmas.debug);
708
+ if (!defaultValue.defined(geometry)) {
709
+ throw new Check.DeveloperError("geometry is required.");
710
+ }
711
+ //>>includeEnd('debug');
712
+
713
+ const numVertices = GeometryAttribute.Geometry.computeNumberOfVertices(geometry);
714
+
715
+ const indices = geometry.indices;
716
+ if (defaultValue.defined(indices)) {
717
+ const indexCrossReferenceOldToNew = new Int32Array(numVertices);
718
+ for (let i = 0; i < numVertices; i++) {
719
+ indexCrossReferenceOldToNew[i] = -1;
720
+ }
721
+
722
+ // Construct cross reference and reorder indices
723
+ const indicesIn = indices;
724
+ const numIndices = indicesIn.length;
725
+ const indicesOut = IndexDatatype.IndexDatatype.createTypedArray(numVertices, numIndices);
726
+
727
+ let intoIndicesIn = 0;
728
+ let intoIndicesOut = 0;
729
+ let nextIndex = 0;
730
+ let tempIndex;
731
+ while (intoIndicesIn < numIndices) {
732
+ tempIndex = indexCrossReferenceOldToNew[indicesIn[intoIndicesIn]];
733
+ if (tempIndex !== -1) {
734
+ indicesOut[intoIndicesOut] = tempIndex;
735
+ } else {
736
+ tempIndex = indicesIn[intoIndicesIn];
737
+ indexCrossReferenceOldToNew[tempIndex] = nextIndex;
738
+
739
+ indicesOut[intoIndicesOut] = nextIndex;
740
+ ++nextIndex;
741
+ }
742
+ ++intoIndicesIn;
743
+ ++intoIndicesOut;
744
+ }
745
+ geometry.indices = indicesOut;
746
+
747
+ // Reorder attributes
748
+ const attributes = geometry.attributes;
749
+ for (const property in attributes) {
750
+ if (
751
+ attributes.hasOwnProperty(property) &&
752
+ defaultValue.defined(attributes[property]) &&
753
+ defaultValue.defined(attributes[property].values)
754
+ ) {
755
+ const attribute = attributes[property];
756
+ const elementsIn = attribute.values;
757
+ let intoElementsIn = 0;
758
+ const numComponents = attribute.componentsPerAttribute;
759
+ const elementsOut = ComponentDatatype.ComponentDatatype.createTypedArray(
760
+ attribute.componentDatatype,
761
+ nextIndex * numComponents
762
+ );
763
+ while (intoElementsIn < numVertices) {
764
+ const temp = indexCrossReferenceOldToNew[intoElementsIn];
765
+ if (temp !== -1) {
766
+ for (let j = 0; j < numComponents; j++) {
767
+ elementsOut[numComponents * temp + j] =
768
+ elementsIn[numComponents * intoElementsIn + j];
769
+ }
770
+ }
771
+ ++intoElementsIn;
772
+ }
773
+ attribute.values = elementsOut;
774
+ }
775
+ }
776
+ }
777
+
778
+ return geometry;
779
+ };
780
+
781
+ /**
782
+ * Reorders a geometry's <code>indices</code> to achieve better performance from the GPU's
783
+ * post vertex-shader cache by using the Tipsify algorithm. If the geometry <code>primitiveType</code>
784
+ * is not <code>TRIANGLES</code> or the geometry does not have an <code>indices</code>, this function has no effect.
785
+ *
786
+ * @param {Geometry} geometry The geometry to modify.
787
+ * @param {Number} [cacheCapacity=24] The number of vertices that can be held in the GPU's vertex cache.
788
+ * @returns {Geometry} The modified <code>geometry</code> argument, with its indices reordered for the post-vertex-shader cache.
789
+ *
790
+ * @exception {DeveloperError} cacheCapacity must be greater than two.
791
+ *
792
+ *
793
+ * @example
794
+ * geometry = Cesium.GeometryPipeline.reorderForPostVertexCache(geometry);
795
+ *
796
+ * @see GeometryPipeline.reorderForPreVertexCache
797
+ * @see {@link http://gfx.cs.princ0eton.edu/pubs/Sander_2007_%3ETR/tipsy.pdf|Fast Triangle Reordering for Vertex Locality and Reduced Overdraw}
798
+ * by Sander, Nehab, and Barczak
799
+ */
800
+ GeometryPipeline.reorderForPostVertexCache = function (
801
+ geometry,
802
+ cacheCapacity
803
+ ) {
804
+ //>>includeStart('debug', pragmas.debug);
805
+ if (!defaultValue.defined(geometry)) {
806
+ throw new Check.DeveloperError("geometry is required.");
807
+ }
808
+ //>>includeEnd('debug');
809
+
810
+ const indices = geometry.indices;
811
+ if (geometry.primitiveType === GeometryAttribute.PrimitiveType.TRIANGLES && defaultValue.defined(indices)) {
812
+ const numIndices = indices.length;
813
+ let maximumIndex = 0;
814
+ for (let j = 0; j < numIndices; j++) {
815
+ if (indices[j] > maximumIndex) {
816
+ maximumIndex = indices[j];
817
+ }
818
+ }
819
+ geometry.indices = Tipsify$1.tipsify({
820
+ indices: indices,
821
+ maximumIndex: maximumIndex,
822
+ cacheSize: cacheCapacity,
823
+ });
824
+ }
825
+
826
+ return geometry;
827
+ };
828
+
829
+ function copyAttributesDescriptions(attributes) {
830
+ const newAttributes = {};
831
+
832
+ for (const attribute in attributes) {
833
+ if (
834
+ attributes.hasOwnProperty(attribute) &&
835
+ defaultValue.defined(attributes[attribute]) &&
836
+ defaultValue.defined(attributes[attribute].values)
837
+ ) {
838
+ const attr = attributes[attribute];
839
+ newAttributes[attribute] = new GeometryAttribute.GeometryAttribute({
840
+ componentDatatype: attr.componentDatatype,
841
+ componentsPerAttribute: attr.componentsPerAttribute,
842
+ normalize: attr.normalize,
843
+ values: [],
844
+ });
845
+ }
846
+ }
847
+
848
+ return newAttributes;
849
+ }
850
+
851
+ function copyVertex(destinationAttributes, sourceAttributes, index) {
852
+ for (const attribute in sourceAttributes) {
853
+ if (
854
+ sourceAttributes.hasOwnProperty(attribute) &&
855
+ defaultValue.defined(sourceAttributes[attribute]) &&
856
+ defaultValue.defined(sourceAttributes[attribute].values)
857
+ ) {
858
+ const attr = sourceAttributes[attribute];
859
+
860
+ for (let k = 0; k < attr.componentsPerAttribute; ++k) {
861
+ destinationAttributes[attribute].values.push(
862
+ attr.values[index * attr.componentsPerAttribute + k]
863
+ );
864
+ }
865
+ }
866
+ }
867
+ }
868
+
869
+ /**
870
+ * Splits a geometry into multiple geometries, if necessary, to ensure that indices in the
871
+ * <code>indices</code> fit into unsigned shorts. This is used to meet the WebGL requirements
872
+ * when unsigned int indices are not supported.
873
+ * <p>
874
+ * If the geometry does not have any <code>indices</code>, this function has no effect.
875
+ * </p>
876
+ *
877
+ * @param {Geometry} geometry The geometry to be split into multiple geometries.
878
+ * @returns {Geometry[]} An array of geometries, each with indices that fit into unsigned shorts.
879
+ *
880
+ * @exception {DeveloperError} geometry.primitiveType must equal to PrimitiveType.TRIANGLES, PrimitiveType.LINES, or PrimitiveType.POINTS
881
+ * @exception {DeveloperError} All geometry attribute lists must have the same number of attributes.
882
+ *
883
+ * @example
884
+ * const geometries = Cesium.GeometryPipeline.fitToUnsignedShortIndices(geometry);
885
+ */
886
+ GeometryPipeline.fitToUnsignedShortIndices = function (geometry) {
887
+ //>>includeStart('debug', pragmas.debug);
888
+ if (!defaultValue.defined(geometry)) {
889
+ throw new Check.DeveloperError("geometry is required.");
890
+ }
891
+ if (
892
+ defaultValue.defined(geometry.indices) &&
893
+ geometry.primitiveType !== GeometryAttribute.PrimitiveType.TRIANGLES &&
894
+ geometry.primitiveType !== GeometryAttribute.PrimitiveType.LINES &&
895
+ geometry.primitiveType !== GeometryAttribute.PrimitiveType.POINTS
896
+ ) {
897
+ throw new Check.DeveloperError(
898
+ "geometry.primitiveType must equal to PrimitiveType.TRIANGLES, PrimitiveType.LINES, or PrimitiveType.POINTS."
899
+ );
900
+ }
901
+ //>>includeEnd('debug');
902
+
903
+ const geometries = [];
904
+
905
+ // If there's an index list and more than 64K attributes, it is possible that
906
+ // some indices are outside the range of unsigned short [0, 64K - 1]
907
+ const numberOfVertices = GeometryAttribute.Geometry.computeNumberOfVertices(geometry);
908
+ if (
909
+ defaultValue.defined(geometry.indices) &&
910
+ numberOfVertices >= Math$1.CesiumMath.SIXTY_FOUR_KILOBYTES
911
+ ) {
912
+ let oldToNewIndex = [];
913
+ let newIndices = [];
914
+ let currentIndex = 0;
915
+ let newAttributes = copyAttributesDescriptions(geometry.attributes);
916
+
917
+ const originalIndices = geometry.indices;
918
+ const numberOfIndices = originalIndices.length;
919
+
920
+ let indicesPerPrimitive;
921
+
922
+ if (geometry.primitiveType === GeometryAttribute.PrimitiveType.TRIANGLES) {
923
+ indicesPerPrimitive = 3;
924
+ } else if (geometry.primitiveType === GeometryAttribute.PrimitiveType.LINES) {
925
+ indicesPerPrimitive = 2;
926
+ } else if (geometry.primitiveType === GeometryAttribute.PrimitiveType.POINTS) {
927
+ indicesPerPrimitive = 1;
928
+ }
929
+
930
+ for (let j = 0; j < numberOfIndices; j += indicesPerPrimitive) {
931
+ for (let k = 0; k < indicesPerPrimitive; ++k) {
932
+ const x = originalIndices[j + k];
933
+ let i = oldToNewIndex[x];
934
+ if (!defaultValue.defined(i)) {
935
+ i = currentIndex++;
936
+ oldToNewIndex[x] = i;
937
+ copyVertex(newAttributes, geometry.attributes, x);
938
+ }
939
+ newIndices.push(i);
940
+ }
941
+
942
+ if (
943
+ currentIndex + indicesPerPrimitive >=
944
+ Math$1.CesiumMath.SIXTY_FOUR_KILOBYTES
945
+ ) {
946
+ geometries.push(
947
+ new GeometryAttribute.Geometry({
948
+ attributes: newAttributes,
949
+ indices: newIndices,
950
+ primitiveType: geometry.primitiveType,
951
+ boundingSphere: geometry.boundingSphere,
952
+ boundingSphereCV: geometry.boundingSphereCV,
953
+ })
954
+ );
955
+
956
+ // Reset for next vertex-array
957
+ oldToNewIndex = [];
958
+ newIndices = [];
959
+ currentIndex = 0;
960
+ newAttributes = copyAttributesDescriptions(geometry.attributes);
961
+ }
962
+ }
963
+
964
+ if (newIndices.length !== 0) {
965
+ geometries.push(
966
+ new GeometryAttribute.Geometry({
967
+ attributes: newAttributes,
968
+ indices: newIndices,
969
+ primitiveType: geometry.primitiveType,
970
+ boundingSphere: geometry.boundingSphere,
971
+ boundingSphereCV: geometry.boundingSphereCV,
972
+ })
973
+ );
974
+ }
975
+ } else {
976
+ // No need to split into multiple geometries
977
+ geometries.push(geometry);
978
+ }
979
+
980
+ return geometries;
981
+ };
982
+
983
+ const scratchProjectTo2DCartesian3 = new Matrix3.Cartesian3();
984
+ const scratchProjectTo2DCartographic = new Matrix3.Cartographic();
985
+
986
+ /**
987
+ * Projects a geometry's 3D <code>position</code> attribute to 2D, replacing the <code>position</code>
988
+ * attribute with separate <code>position3D</code> and <code>position2D</code> attributes.
989
+ * <p>
990
+ * If the geometry does not have a <code>position</code>, this function has no effect.
991
+ * </p>
992
+ *
993
+ * @param {Geometry} geometry The geometry to modify.
994
+ * @param {String} attributeName The name of the attribute.
995
+ * @param {String} attributeName3D The name of the attribute in 3D.
996
+ * @param {String} attributeName2D The name of the attribute in 2D.
997
+ * @param {Object} [projection=new GeographicProjection()] The projection to use.
998
+ * @returns {Geometry} The modified <code>geometry</code> argument with <code>position3D</code> and <code>position2D</code> attributes.
999
+ *
1000
+ * @exception {DeveloperError} geometry must have attribute matching the attributeName argument.
1001
+ * @exception {DeveloperError} The attribute componentDatatype must be ComponentDatatype.DOUBLE.
1002
+ * @exception {DeveloperError} Could not project a point to 2D.
1003
+ *
1004
+ * @example
1005
+ * geometry = Cesium.GeometryPipeline.projectTo2D(geometry, 'position', 'position3D', 'position2D');
1006
+ */
1007
+ GeometryPipeline.projectTo2D = function (
1008
+ geometry,
1009
+ attributeName,
1010
+ attributeName3D,
1011
+ attributeName2D,
1012
+ projection
1013
+ ) {
1014
+ //>>includeStart('debug', pragmas.debug);
1015
+ if (!defaultValue.defined(geometry)) {
1016
+ throw new Check.DeveloperError("geometry is required.");
1017
+ }
1018
+ if (!defaultValue.defined(attributeName)) {
1019
+ throw new Check.DeveloperError("attributeName is required.");
1020
+ }
1021
+ if (!defaultValue.defined(attributeName3D)) {
1022
+ throw new Check.DeveloperError("attributeName3D is required.");
1023
+ }
1024
+ if (!defaultValue.defined(attributeName2D)) {
1025
+ throw new Check.DeveloperError("attributeName2D is required.");
1026
+ }
1027
+ if (!defaultValue.defined(geometry.attributes[attributeName])) {
1028
+ throw new Check.DeveloperError(
1029
+ `geometry must have attribute matching the attributeName argument: ${attributeName}.`
1030
+ );
1031
+ }
1032
+ if (
1033
+ geometry.attributes[attributeName].componentDatatype !==
1034
+ ComponentDatatype.ComponentDatatype.DOUBLE
1035
+ ) {
1036
+ throw new Check.DeveloperError(
1037
+ "The attribute componentDatatype must be ComponentDatatype.DOUBLE."
1038
+ );
1039
+ }
1040
+ //>>includeEnd('debug');
1041
+
1042
+ const attribute = geometry.attributes[attributeName];
1043
+ projection = defaultValue.defined(projection) ? projection : new Transforms.GeographicProjection();
1044
+ const ellipsoid = projection.ellipsoid;
1045
+
1046
+ // Project original values to 2D.
1047
+ const values3D = attribute.values;
1048
+ const projectedValues = new Float64Array(values3D.length);
1049
+ let index = 0;
1050
+
1051
+ for (let i = 0; i < values3D.length; i += 3) {
1052
+ const value = Matrix3.Cartesian3.fromArray(
1053
+ values3D,
1054
+ i,
1055
+ scratchProjectTo2DCartesian3
1056
+ );
1057
+
1058
+ const lonLat = ellipsoid.cartesianToCartographic(
1059
+ value,
1060
+ scratchProjectTo2DCartographic
1061
+ );
1062
+ //>>includeStart('debug', pragmas.debug);
1063
+ if (!defaultValue.defined(lonLat)) {
1064
+ throw new Check.DeveloperError(
1065
+ `Could not project point (${value.x}, ${value.y}, ${value.z}) to 2D.`
1066
+ );
1067
+ }
1068
+ //>>includeEnd('debug');
1069
+
1070
+ const projectedLonLat = projection.project(
1071
+ lonLat,
1072
+ scratchProjectTo2DCartesian3
1073
+ );
1074
+
1075
+ projectedValues[index++] = projectedLonLat.x;
1076
+ projectedValues[index++] = projectedLonLat.y;
1077
+ projectedValues[index++] = projectedLonLat.z;
1078
+ }
1079
+
1080
+ // Rename original cartesians to WGS84 cartesians.
1081
+ geometry.attributes[attributeName3D] = attribute;
1082
+
1083
+ // Replace original cartesians with 2D projected cartesians
1084
+ geometry.attributes[attributeName2D] = new GeometryAttribute.GeometryAttribute({
1085
+ componentDatatype: ComponentDatatype.ComponentDatatype.DOUBLE,
1086
+ componentsPerAttribute: 3,
1087
+ values: projectedValues,
1088
+ });
1089
+ delete geometry.attributes[attributeName];
1090
+
1091
+ return geometry;
1092
+ };
1093
+
1094
+ const encodedResult = {
1095
+ high: 0.0,
1096
+ low: 0.0,
1097
+ };
1098
+
1099
+ /**
1100
+ * Encodes floating-point geometry attribute values as two separate attributes to improve
1101
+ * rendering precision.
1102
+ * <p>
1103
+ * This is commonly used to create high-precision position vertex attributes.
1104
+ * </p>
1105
+ *
1106
+ * @param {Geometry} geometry The geometry to modify.
1107
+ * @param {String} attributeName The name of the attribute.
1108
+ * @param {String} attributeHighName The name of the attribute for the encoded high bits.
1109
+ * @param {String} attributeLowName The name of the attribute for the encoded low bits.
1110
+ * @returns {Geometry} The modified <code>geometry</code> argument, with its encoded attribute.
1111
+ *
1112
+ * @exception {DeveloperError} geometry must have attribute matching the attributeName argument.
1113
+ * @exception {DeveloperError} The attribute componentDatatype must be ComponentDatatype.DOUBLE.
1114
+ *
1115
+ * @example
1116
+ * geometry = Cesium.GeometryPipeline.encodeAttribute(geometry, 'position3D', 'position3DHigh', 'position3DLow');
1117
+ */
1118
+ GeometryPipeline.encodeAttribute = function (
1119
+ geometry,
1120
+ attributeName,
1121
+ attributeHighName,
1122
+ attributeLowName
1123
+ ) {
1124
+ //>>includeStart('debug', pragmas.debug);
1125
+ if (!defaultValue.defined(geometry)) {
1126
+ throw new Check.DeveloperError("geometry is required.");
1127
+ }
1128
+ if (!defaultValue.defined(attributeName)) {
1129
+ throw new Check.DeveloperError("attributeName is required.");
1130
+ }
1131
+ if (!defaultValue.defined(attributeHighName)) {
1132
+ throw new Check.DeveloperError("attributeHighName is required.");
1133
+ }
1134
+ if (!defaultValue.defined(attributeLowName)) {
1135
+ throw new Check.DeveloperError("attributeLowName is required.");
1136
+ }
1137
+ if (!defaultValue.defined(geometry.attributes[attributeName])) {
1138
+ throw new Check.DeveloperError(
1139
+ `geometry must have attribute matching the attributeName argument: ${attributeName}.`
1140
+ );
1141
+ }
1142
+ if (
1143
+ geometry.attributes[attributeName].componentDatatype !==
1144
+ ComponentDatatype.ComponentDatatype.DOUBLE
1145
+ ) {
1146
+ throw new Check.DeveloperError(
1147
+ "The attribute componentDatatype must be ComponentDatatype.DOUBLE."
1148
+ );
1149
+ }
1150
+ //>>includeEnd('debug');
1151
+
1152
+ const attribute = geometry.attributes[attributeName];
1153
+ const values = attribute.values;
1154
+ const length = values.length;
1155
+ const highValues = new Float32Array(length);
1156
+ const lowValues = new Float32Array(length);
1157
+
1158
+ for (let i = 0; i < length; ++i) {
1159
+ EncodedCartesian3.EncodedCartesian3.encode(values[i], encodedResult);
1160
+ highValues[i] = encodedResult.high;
1161
+ lowValues[i] = encodedResult.low;
1162
+ }
1163
+
1164
+ const componentsPerAttribute = attribute.componentsPerAttribute;
1165
+
1166
+ geometry.attributes[attributeHighName] = new GeometryAttribute.GeometryAttribute({
1167
+ componentDatatype: ComponentDatatype.ComponentDatatype.FLOAT,
1168
+ componentsPerAttribute: componentsPerAttribute,
1169
+ values: highValues,
1170
+ });
1171
+ geometry.attributes[attributeLowName] = new GeometryAttribute.GeometryAttribute({
1172
+ componentDatatype: ComponentDatatype.ComponentDatatype.FLOAT,
1173
+ componentsPerAttribute: componentsPerAttribute,
1174
+ values: lowValues,
1175
+ });
1176
+ delete geometry.attributes[attributeName];
1177
+
1178
+ return geometry;
1179
+ };
1180
+
1181
+ let scratchCartesian3 = new Matrix3.Cartesian3();
1182
+
1183
+ function transformPoint(matrix, attribute) {
1184
+ if (defaultValue.defined(attribute)) {
1185
+ const values = attribute.values;
1186
+ const length = values.length;
1187
+ for (let i = 0; i < length; i += 3) {
1188
+ Matrix3.Cartesian3.unpack(values, i, scratchCartesian3);
1189
+ Matrix2.Matrix4.multiplyByPoint(matrix, scratchCartesian3, scratchCartesian3);
1190
+ Matrix3.Cartesian3.pack(scratchCartesian3, values, i);
1191
+ }
1192
+ }
1193
+ }
1194
+
1195
+ function transformVector(matrix, attribute) {
1196
+ if (defaultValue.defined(attribute)) {
1197
+ const values = attribute.values;
1198
+ const length = values.length;
1199
+ for (let i = 0; i < length; i += 3) {
1200
+ Matrix3.Cartesian3.unpack(values, i, scratchCartesian3);
1201
+ Matrix3.Matrix3.multiplyByVector(matrix, scratchCartesian3, scratchCartesian3);
1202
+ scratchCartesian3 = Matrix3.Cartesian3.normalize(
1203
+ scratchCartesian3,
1204
+ scratchCartesian3
1205
+ );
1206
+ Matrix3.Cartesian3.pack(scratchCartesian3, values, i);
1207
+ }
1208
+ }
1209
+ }
1210
+
1211
+ const inverseTranspose = new Matrix2.Matrix4();
1212
+ const normalMatrix = new Matrix3.Matrix3();
1213
+
1214
+ /**
1215
+ * Transforms a geometry instance to world coordinates. This changes
1216
+ * the instance's <code>modelMatrix</code> to {@link Matrix4.IDENTITY} and transforms the
1217
+ * following attributes if they are present: <code>position</code>, <code>normal</code>,
1218
+ * <code>tangent</code>, and <code>bitangent</code>.
1219
+ *
1220
+ * @param {GeometryInstance} instance The geometry instance to modify.
1221
+ * @returns {GeometryInstance} The modified <code>instance</code> argument, with its attributes transforms to world coordinates.
1222
+ *
1223
+ * @example
1224
+ * Cesium.GeometryPipeline.transformToWorldCoordinates(instance);
1225
+ */
1226
+ GeometryPipeline.transformToWorldCoordinates = function (instance) {
1227
+ //>>includeStart('debug', pragmas.debug);
1228
+ if (!defaultValue.defined(instance)) {
1229
+ throw new Check.DeveloperError("instance is required.");
1230
+ }
1231
+ //>>includeEnd('debug');
1232
+
1233
+ const modelMatrix = instance.modelMatrix;
1234
+
1235
+ if (Matrix2.Matrix4.equals(modelMatrix, Matrix2.Matrix4.IDENTITY)) {
1236
+ // Already in world coordinates
1237
+ return instance;
1238
+ }
1239
+
1240
+ const attributes = instance.geometry.attributes;
1241
+
1242
+ // Transform attributes in known vertex formats
1243
+ transformPoint(modelMatrix, attributes.position);
1244
+ transformPoint(modelMatrix, attributes.prevPosition);
1245
+ transformPoint(modelMatrix, attributes.nextPosition);
1246
+
1247
+ if (
1248
+ defaultValue.defined(attributes.normal) ||
1249
+ defaultValue.defined(attributes.tangent) ||
1250
+ defaultValue.defined(attributes.bitangent)
1251
+ ) {
1252
+ Matrix2.Matrix4.inverse(modelMatrix, inverseTranspose);
1253
+ Matrix2.Matrix4.transpose(inverseTranspose, inverseTranspose);
1254
+ Matrix2.Matrix4.getMatrix3(inverseTranspose, normalMatrix);
1255
+
1256
+ transformVector(normalMatrix, attributes.normal);
1257
+ transformVector(normalMatrix, attributes.tangent);
1258
+ transformVector(normalMatrix, attributes.bitangent);
1259
+ }
1260
+
1261
+ const boundingSphere = instance.geometry.boundingSphere;
1262
+ if (defaultValue.defined(boundingSphere)) {
1263
+ instance.geometry.boundingSphere = Transforms.BoundingSphere.transform(
1264
+ boundingSphere,
1265
+ modelMatrix,
1266
+ boundingSphere
1267
+ );
1268
+ }
1269
+
1270
+ instance.modelMatrix = Matrix2.Matrix4.clone(Matrix2.Matrix4.IDENTITY);
1271
+
1272
+ return instance;
1273
+ };
1274
+
1275
+ function findAttributesInAllGeometries(instances, propertyName) {
1276
+ const length = instances.length;
1277
+
1278
+ const attributesInAllGeometries = {};
1279
+
1280
+ const attributes0 = instances[0][propertyName].attributes;
1281
+ let name;
1282
+
1283
+ for (name in attributes0) {
1284
+ if (
1285
+ attributes0.hasOwnProperty(name) &&
1286
+ defaultValue.defined(attributes0[name]) &&
1287
+ defaultValue.defined(attributes0[name].values)
1288
+ ) {
1289
+ const attribute = attributes0[name];
1290
+ let numberOfComponents = attribute.values.length;
1291
+ let inAllGeometries = true;
1292
+
1293
+ // Does this same attribute exist in all geometries?
1294
+ for (let i = 1; i < length; ++i) {
1295
+ const otherAttribute = instances[i][propertyName].attributes[name];
1296
+
1297
+ if (
1298
+ !defaultValue.defined(otherAttribute) ||
1299
+ attribute.componentDatatype !== otherAttribute.componentDatatype ||
1300
+ attribute.componentsPerAttribute !==
1301
+ otherAttribute.componentsPerAttribute ||
1302
+ attribute.normalize !== otherAttribute.normalize
1303
+ ) {
1304
+ inAllGeometries = false;
1305
+ break;
1306
+ }
1307
+
1308
+ numberOfComponents += otherAttribute.values.length;
1309
+ }
1310
+
1311
+ if (inAllGeometries) {
1312
+ attributesInAllGeometries[name] = new GeometryAttribute.GeometryAttribute({
1313
+ componentDatatype: attribute.componentDatatype,
1314
+ componentsPerAttribute: attribute.componentsPerAttribute,
1315
+ normalize: attribute.normalize,
1316
+ values: ComponentDatatype.ComponentDatatype.createTypedArray(
1317
+ attribute.componentDatatype,
1318
+ numberOfComponents
1319
+ ),
1320
+ });
1321
+ }
1322
+ }
1323
+ }
1324
+
1325
+ return attributesInAllGeometries;
1326
+ }
1327
+
1328
+ const tempScratch = new Matrix3.Cartesian3();
1329
+
1330
+ function combineGeometries(instances, propertyName) {
1331
+ const length = instances.length;
1332
+
1333
+ let name;
1334
+ let i;
1335
+ let j;
1336
+ let k;
1337
+
1338
+ const m = instances[0].modelMatrix;
1339
+ const haveIndices = defaultValue.defined(instances[0][propertyName].indices);
1340
+ const primitiveType = instances[0][propertyName].primitiveType;
1341
+
1342
+ //>>includeStart('debug', pragmas.debug);
1343
+ for (i = 1; i < length; ++i) {
1344
+ if (!Matrix2.Matrix4.equals(instances[i].modelMatrix, m)) {
1345
+ throw new Check.DeveloperError("All instances must have the same modelMatrix.");
1346
+ }
1347
+ if (defaultValue.defined(instances[i][propertyName].indices) !== haveIndices) {
1348
+ throw new Check.DeveloperError(
1349
+ "All instance geometries must have an indices or not have one."
1350
+ );
1351
+ }
1352
+ if (instances[i][propertyName].primitiveType !== primitiveType) {
1353
+ throw new Check.DeveloperError(
1354
+ "All instance geometries must have the same primitiveType."
1355
+ );
1356
+ }
1357
+ }
1358
+ //>>includeEnd('debug');
1359
+
1360
+ // Find subset of attributes in all geometries
1361
+ const attributes = findAttributesInAllGeometries(instances, propertyName);
1362
+ let values;
1363
+ let sourceValues;
1364
+ let sourceValuesLength;
1365
+
1366
+ // Combine attributes from each geometry into a single typed array
1367
+ for (name in attributes) {
1368
+ if (attributes.hasOwnProperty(name)) {
1369
+ values = attributes[name].values;
1370
+
1371
+ k = 0;
1372
+ for (i = 0; i < length; ++i) {
1373
+ sourceValues = instances[i][propertyName].attributes[name].values;
1374
+ sourceValuesLength = sourceValues.length;
1375
+
1376
+ for (j = 0; j < sourceValuesLength; ++j) {
1377
+ values[k++] = sourceValues[j];
1378
+ }
1379
+ }
1380
+ }
1381
+ }
1382
+
1383
+ // Combine index lists
1384
+ let indices;
1385
+
1386
+ if (haveIndices) {
1387
+ let numberOfIndices = 0;
1388
+ for (i = 0; i < length; ++i) {
1389
+ numberOfIndices += instances[i][propertyName].indices.length;
1390
+ }
1391
+
1392
+ const numberOfVertices = GeometryAttribute.Geometry.computeNumberOfVertices(
1393
+ new GeometryAttribute.Geometry({
1394
+ attributes: attributes,
1395
+ primitiveType: GeometryAttribute.PrimitiveType.POINTS,
1396
+ })
1397
+ );
1398
+ const destIndices = IndexDatatype.IndexDatatype.createTypedArray(
1399
+ numberOfVertices,
1400
+ numberOfIndices
1401
+ );
1402
+
1403
+ let destOffset = 0;
1404
+ let offset = 0;
1405
+
1406
+ for (i = 0; i < length; ++i) {
1407
+ const sourceIndices = instances[i][propertyName].indices;
1408
+ const sourceIndicesLen = sourceIndices.length;
1409
+
1410
+ for (k = 0; k < sourceIndicesLen; ++k) {
1411
+ destIndices[destOffset++] = offset + sourceIndices[k];
1412
+ }
1413
+
1414
+ offset += GeometryAttribute.Geometry.computeNumberOfVertices(instances[i][propertyName]);
1415
+ }
1416
+
1417
+ indices = destIndices;
1418
+ }
1419
+
1420
+ // Create bounding sphere that includes all instances
1421
+ let center = new Matrix3.Cartesian3();
1422
+ let radius = 0.0;
1423
+ let bs;
1424
+
1425
+ for (i = 0; i < length; ++i) {
1426
+ bs = instances[i][propertyName].boundingSphere;
1427
+ if (!defaultValue.defined(bs)) {
1428
+ // If any geometries have an undefined bounding sphere, then so does the combined geometry
1429
+ center = undefined;
1430
+ break;
1431
+ }
1432
+
1433
+ Matrix3.Cartesian3.add(bs.center, center, center);
1434
+ }
1435
+
1436
+ if (defaultValue.defined(center)) {
1437
+ Matrix3.Cartesian3.divideByScalar(center, length, center);
1438
+
1439
+ for (i = 0; i < length; ++i) {
1440
+ bs = instances[i][propertyName].boundingSphere;
1441
+ const tempRadius =
1442
+ Matrix3.Cartesian3.magnitude(
1443
+ Matrix3.Cartesian3.subtract(bs.center, center, tempScratch)
1444
+ ) + bs.radius;
1445
+
1446
+ if (tempRadius > radius) {
1447
+ radius = tempRadius;
1448
+ }
1449
+ }
1450
+ }
1451
+
1452
+ return new GeometryAttribute.Geometry({
1453
+ attributes: attributes,
1454
+ indices: indices,
1455
+ primitiveType: primitiveType,
1456
+ boundingSphere: defaultValue.defined(center)
1457
+ ? new Transforms.BoundingSphere(center, radius)
1458
+ : undefined,
1459
+ });
1460
+ }
1461
+
1462
+ /**
1463
+ * Combines geometry from several {@link GeometryInstance} objects into one geometry.
1464
+ * This concatenates the attributes, concatenates and adjusts the indices, and creates
1465
+ * a bounding sphere encompassing all instances.
1466
+ * <p>
1467
+ * If the instances do not have the same attributes, a subset of attributes common
1468
+ * to all instances is used, and the others are ignored.
1469
+ * </p>
1470
+ * <p>
1471
+ * This is used by {@link Primitive} to efficiently render a large amount of static data.
1472
+ * </p>
1473
+ *
1474
+ * @private
1475
+ *
1476
+ * @param {GeometryInstance[]} [instances] The array of {@link GeometryInstance} objects whose geometry will be combined.
1477
+ * @returns {Geometry} A single geometry created from the provided geometry instances.
1478
+ *
1479
+ * @exception {DeveloperError} All instances must have the same modelMatrix.
1480
+ * @exception {DeveloperError} All instance geometries must have an indices or not have one.
1481
+ * @exception {DeveloperError} All instance geometries must have the same primitiveType.
1482
+ *
1483
+ *
1484
+ * @example
1485
+ * for (let i = 0; i < instances.length; ++i) {
1486
+ * Cesium.GeometryPipeline.transformToWorldCoordinates(instances[i]);
1487
+ * }
1488
+ * const geometries = Cesium.GeometryPipeline.combineInstances(instances);
1489
+ *
1490
+ * @see GeometryPipeline.transformToWorldCoordinates
1491
+ */
1492
+ GeometryPipeline.combineInstances = function (instances) {
1493
+ //>>includeStart('debug', pragmas.debug);
1494
+ if (!defaultValue.defined(instances) || instances.length < 1) {
1495
+ throw new Check.DeveloperError(
1496
+ "instances is required and must have length greater than zero."
1497
+ );
1498
+ }
1499
+ //>>includeEnd('debug');
1500
+
1501
+ const instanceGeometry = [];
1502
+ const instanceSplitGeometry = [];
1503
+ const length = instances.length;
1504
+ for (let i = 0; i < length; ++i) {
1505
+ const instance = instances[i];
1506
+
1507
+ if (defaultValue.defined(instance.geometry)) {
1508
+ instanceGeometry.push(instance);
1509
+ } else if (
1510
+ defaultValue.defined(instance.westHemisphereGeometry) &&
1511
+ defaultValue.defined(instance.eastHemisphereGeometry)
1512
+ ) {
1513
+ instanceSplitGeometry.push(instance);
1514
+ }
1515
+ }
1516
+
1517
+ const geometries = [];
1518
+ if (instanceGeometry.length > 0) {
1519
+ geometries.push(combineGeometries(instanceGeometry, "geometry"));
1520
+ }
1521
+
1522
+ if (instanceSplitGeometry.length > 0) {
1523
+ geometries.push(
1524
+ combineGeometries(instanceSplitGeometry, "westHemisphereGeometry")
1525
+ );
1526
+ geometries.push(
1527
+ combineGeometries(instanceSplitGeometry, "eastHemisphereGeometry")
1528
+ );
1529
+ }
1530
+
1531
+ return geometries;
1532
+ };
1533
+
1534
+ const normal = new Matrix3.Cartesian3();
1535
+ const v0 = new Matrix3.Cartesian3();
1536
+ const v1 = new Matrix3.Cartesian3();
1537
+ const v2 = new Matrix3.Cartesian3();
1538
+
1539
+ /**
1540
+ * Computes per-vertex normals for a geometry containing <code>TRIANGLES</code> by averaging the normals of
1541
+ * all triangles incident to the vertex. The result is a new <code>normal</code> attribute added to the geometry.
1542
+ * This assumes a counter-clockwise winding order.
1543
+ *
1544
+ * @param {Geometry} geometry The geometry to modify.
1545
+ * @returns {Geometry} The modified <code>geometry</code> argument with the computed <code>normal</code> attribute.
1546
+ *
1547
+ * @exception {DeveloperError} geometry.indices length must be greater than 0 and be a multiple of 3.
1548
+ * @exception {DeveloperError} geometry.primitiveType must be {@link PrimitiveType.TRIANGLES}.
1549
+ *
1550
+ * @example
1551
+ * Cesium.GeometryPipeline.computeNormal(geometry);
1552
+ */
1553
+ GeometryPipeline.computeNormal = function (geometry) {
1554
+ //>>includeStart('debug', pragmas.debug);
1555
+ if (!defaultValue.defined(geometry)) {
1556
+ throw new Check.DeveloperError("geometry is required.");
1557
+ }
1558
+ if (
1559
+ !defaultValue.defined(geometry.attributes.position) ||
1560
+ !defaultValue.defined(geometry.attributes.position.values)
1561
+ ) {
1562
+ throw new Check.DeveloperError(
1563
+ "geometry.attributes.position.values is required."
1564
+ );
1565
+ }
1566
+ if (!defaultValue.defined(geometry.indices)) {
1567
+ throw new Check.DeveloperError("geometry.indices is required.");
1568
+ }
1569
+ if (geometry.indices.length < 2 || geometry.indices.length % 3 !== 0) {
1570
+ throw new Check.DeveloperError(
1571
+ "geometry.indices length must be greater than 0 and be a multiple of 3."
1572
+ );
1573
+ }
1574
+ if (geometry.primitiveType !== GeometryAttribute.PrimitiveType.TRIANGLES) {
1575
+ throw new Check.DeveloperError(
1576
+ "geometry.primitiveType must be PrimitiveType.TRIANGLES."
1577
+ );
1578
+ }
1579
+ //>>includeEnd('debug');
1580
+
1581
+ const indices = geometry.indices;
1582
+ const attributes = geometry.attributes;
1583
+ const vertices = attributes.position.values;
1584
+ const numVertices = attributes.position.values.length / 3;
1585
+ const numIndices = indices.length;
1586
+ const normalsPerVertex = new Array(numVertices);
1587
+ const normalsPerTriangle = new Array(numIndices / 3);
1588
+ const normalIndices = new Array(numIndices);
1589
+ let i;
1590
+ for (i = 0; i < numVertices; i++) {
1591
+ normalsPerVertex[i] = {
1592
+ indexOffset: 0,
1593
+ count: 0,
1594
+ currentCount: 0,
1595
+ };
1596
+ }
1597
+
1598
+ let j = 0;
1599
+ for (i = 0; i < numIndices; i += 3) {
1600
+ const i0 = indices[i];
1601
+ const i1 = indices[i + 1];
1602
+ const i2 = indices[i + 2];
1603
+ const i03 = i0 * 3;
1604
+ const i13 = i1 * 3;
1605
+ const i23 = i2 * 3;
1606
+
1607
+ v0.x = vertices[i03];
1608
+ v0.y = vertices[i03 + 1];
1609
+ v0.z = vertices[i03 + 2];
1610
+ v1.x = vertices[i13];
1611
+ v1.y = vertices[i13 + 1];
1612
+ v1.z = vertices[i13 + 2];
1613
+ v2.x = vertices[i23];
1614
+ v2.y = vertices[i23 + 1];
1615
+ v2.z = vertices[i23 + 2];
1616
+
1617
+ normalsPerVertex[i0].count++;
1618
+ normalsPerVertex[i1].count++;
1619
+ normalsPerVertex[i2].count++;
1620
+
1621
+ Matrix3.Cartesian3.subtract(v1, v0, v1);
1622
+ Matrix3.Cartesian3.subtract(v2, v0, v2);
1623
+ normalsPerTriangle[j] = Matrix3.Cartesian3.cross(v1, v2, new Matrix3.Cartesian3());
1624
+ j++;
1625
+ }
1626
+
1627
+ let indexOffset = 0;
1628
+ for (i = 0; i < numVertices; i++) {
1629
+ normalsPerVertex[i].indexOffset += indexOffset;
1630
+ indexOffset += normalsPerVertex[i].count;
1631
+ }
1632
+
1633
+ j = 0;
1634
+ let vertexNormalData;
1635
+ for (i = 0; i < numIndices; i += 3) {
1636
+ vertexNormalData = normalsPerVertex[indices[i]];
1637
+ let index = vertexNormalData.indexOffset + vertexNormalData.currentCount;
1638
+ normalIndices[index] = j;
1639
+ vertexNormalData.currentCount++;
1640
+
1641
+ vertexNormalData = normalsPerVertex[indices[i + 1]];
1642
+ index = vertexNormalData.indexOffset + vertexNormalData.currentCount;
1643
+ normalIndices[index] = j;
1644
+ vertexNormalData.currentCount++;
1645
+
1646
+ vertexNormalData = normalsPerVertex[indices[i + 2]];
1647
+ index = vertexNormalData.indexOffset + vertexNormalData.currentCount;
1648
+ normalIndices[index] = j;
1649
+ vertexNormalData.currentCount++;
1650
+
1651
+ j++;
1652
+ }
1653
+
1654
+ const normalValues = new Float32Array(numVertices * 3);
1655
+ for (i = 0; i < numVertices; i++) {
1656
+ const i3 = i * 3;
1657
+ vertexNormalData = normalsPerVertex[i];
1658
+ Matrix3.Cartesian3.clone(Matrix3.Cartesian3.ZERO, normal);
1659
+ if (vertexNormalData.count > 0) {
1660
+ for (j = 0; j < vertexNormalData.count; j++) {
1661
+ Matrix3.Cartesian3.add(
1662
+ normal,
1663
+ normalsPerTriangle[normalIndices[vertexNormalData.indexOffset + j]],
1664
+ normal
1665
+ );
1666
+ }
1667
+
1668
+ // We can run into an issue where a vertex is used with 2 primitives that have opposite winding order.
1669
+ if (
1670
+ Matrix3.Cartesian3.equalsEpsilon(Matrix3.Cartesian3.ZERO, normal, Math$1.CesiumMath.EPSILON10)
1671
+ ) {
1672
+ Matrix3.Cartesian3.clone(
1673
+ normalsPerTriangle[normalIndices[vertexNormalData.indexOffset]],
1674
+ normal
1675
+ );
1676
+ }
1677
+ }
1678
+
1679
+ // We end up with a zero vector probably because of a degenerate triangle
1680
+ if (
1681
+ Matrix3.Cartesian3.equalsEpsilon(Matrix3.Cartesian3.ZERO, normal, Math$1.CesiumMath.EPSILON10)
1682
+ ) {
1683
+ // Default to (0,0,1)
1684
+ normal.z = 1.0;
1685
+ }
1686
+
1687
+ Matrix3.Cartesian3.normalize(normal, normal);
1688
+ normalValues[i3] = normal.x;
1689
+ normalValues[i3 + 1] = normal.y;
1690
+ normalValues[i3 + 2] = normal.z;
1691
+ }
1692
+
1693
+ geometry.attributes.normal = new GeometryAttribute.GeometryAttribute({
1694
+ componentDatatype: ComponentDatatype.ComponentDatatype.FLOAT,
1695
+ componentsPerAttribute: 3,
1696
+ values: normalValues,
1697
+ });
1698
+
1699
+ return geometry;
1700
+ };
1701
+
1702
+ const normalScratch = new Matrix3.Cartesian3();
1703
+ const normalScale = new Matrix3.Cartesian3();
1704
+ const tScratch = new Matrix3.Cartesian3();
1705
+
1706
+ /**
1707
+ * Computes per-vertex tangents and bitangents for a geometry containing <code>TRIANGLES</code>.
1708
+ * The result is new <code>tangent</code> and <code>bitangent</code> attributes added to the geometry.
1709
+ * This assumes a counter-clockwise winding order.
1710
+ * <p>
1711
+ * Based on <a href="http://www.terathon.com/code/tangent.html">Computing Tangent Space Basis Vectors
1712
+ * for an Arbitrary Mesh</a> by Eric Lengyel.
1713
+ * </p>
1714
+ *
1715
+ * @param {Geometry} geometry The geometry to modify.
1716
+ * @returns {Geometry} The modified <code>geometry</code> argument with the computed <code>tangent</code> and <code>bitangent</code> attributes.
1717
+ *
1718
+ * @exception {DeveloperError} geometry.indices length must be greater than 0 and be a multiple of 3.
1719
+ * @exception {DeveloperError} geometry.primitiveType must be {@link PrimitiveType.TRIANGLES}.
1720
+ *
1721
+ * @example
1722
+ * Cesium.GeometryPipeline.computeTangentAndBiTangent(geometry);
1723
+ */
1724
+ GeometryPipeline.computeTangentAndBitangent = function (geometry) {
1725
+ //>>includeStart('debug', pragmas.debug);
1726
+ if (!defaultValue.defined(geometry)) {
1727
+ throw new Check.DeveloperError("geometry is required.");
1728
+ }
1729
+ //>>includeEnd('debug');
1730
+
1731
+ const attributes = geometry.attributes;
1732
+ const indices = geometry.indices;
1733
+
1734
+ //>>includeStart('debug', pragmas.debug);
1735
+ if (!defaultValue.defined(attributes.position) || !defaultValue.defined(attributes.position.values)) {
1736
+ throw new Check.DeveloperError(
1737
+ "geometry.attributes.position.values is required."
1738
+ );
1739
+ }
1740
+ if (!defaultValue.defined(attributes.normal) || !defaultValue.defined(attributes.normal.values)) {
1741
+ throw new Check.DeveloperError("geometry.attributes.normal.values is required.");
1742
+ }
1743
+ if (!defaultValue.defined(attributes.st) || !defaultValue.defined(attributes.st.values)) {
1744
+ throw new Check.DeveloperError("geometry.attributes.st.values is required.");
1745
+ }
1746
+ if (!defaultValue.defined(indices)) {
1747
+ throw new Check.DeveloperError("geometry.indices is required.");
1748
+ }
1749
+ if (indices.length < 2 || indices.length % 3 !== 0) {
1750
+ throw new Check.DeveloperError(
1751
+ "geometry.indices length must be greater than 0 and be a multiple of 3."
1752
+ );
1753
+ }
1754
+ if (geometry.primitiveType !== GeometryAttribute.PrimitiveType.TRIANGLES) {
1755
+ throw new Check.DeveloperError(
1756
+ "geometry.primitiveType must be PrimitiveType.TRIANGLES."
1757
+ );
1758
+ }
1759
+ //>>includeEnd('debug');
1760
+
1761
+ const vertices = geometry.attributes.position.values;
1762
+ const normals = geometry.attributes.normal.values;
1763
+ const st = geometry.attributes.st.values;
1764
+
1765
+ const numVertices = geometry.attributes.position.values.length / 3;
1766
+ const numIndices = indices.length;
1767
+ const tan1 = new Array(numVertices * 3);
1768
+
1769
+ let i;
1770
+ for (i = 0; i < tan1.length; i++) {
1771
+ tan1[i] = 0;
1772
+ }
1773
+
1774
+ let i03;
1775
+ let i13;
1776
+ let i23;
1777
+ for (i = 0; i < numIndices; i += 3) {
1778
+ const i0 = indices[i];
1779
+ const i1 = indices[i + 1];
1780
+ const i2 = indices[i + 2];
1781
+ i03 = i0 * 3;
1782
+ i13 = i1 * 3;
1783
+ i23 = i2 * 3;
1784
+ const i02 = i0 * 2;
1785
+ const i12 = i1 * 2;
1786
+ const i22 = i2 * 2;
1787
+
1788
+ const ux = vertices[i03];
1789
+ const uy = vertices[i03 + 1];
1790
+ const uz = vertices[i03 + 2];
1791
+
1792
+ const wx = st[i02];
1793
+ const wy = st[i02 + 1];
1794
+ const t1 = st[i12 + 1] - wy;
1795
+ const t2 = st[i22 + 1] - wy;
1796
+
1797
+ const r = 1.0 / ((st[i12] - wx) * t2 - (st[i22] - wx) * t1);
1798
+ const sdirx = (t2 * (vertices[i13] - ux) - t1 * (vertices[i23] - ux)) * r;
1799
+ const sdiry =
1800
+ (t2 * (vertices[i13 + 1] - uy) - t1 * (vertices[i23 + 1] - uy)) * r;
1801
+ const sdirz =
1802
+ (t2 * (vertices[i13 + 2] - uz) - t1 * (vertices[i23 + 2] - uz)) * r;
1803
+
1804
+ tan1[i03] += sdirx;
1805
+ tan1[i03 + 1] += sdiry;
1806
+ tan1[i03 + 2] += sdirz;
1807
+
1808
+ tan1[i13] += sdirx;
1809
+ tan1[i13 + 1] += sdiry;
1810
+ tan1[i13 + 2] += sdirz;
1811
+
1812
+ tan1[i23] += sdirx;
1813
+ tan1[i23 + 1] += sdiry;
1814
+ tan1[i23 + 2] += sdirz;
1815
+ }
1816
+
1817
+ const tangentValues = new Float32Array(numVertices * 3);
1818
+ const bitangentValues = new Float32Array(numVertices * 3);
1819
+
1820
+ for (i = 0; i < numVertices; i++) {
1821
+ i03 = i * 3;
1822
+ i13 = i03 + 1;
1823
+ i23 = i03 + 2;
1824
+
1825
+ const n = Matrix3.Cartesian3.fromArray(normals, i03, normalScratch);
1826
+ const t = Matrix3.Cartesian3.fromArray(tan1, i03, tScratch);
1827
+ const scalar = Matrix3.Cartesian3.dot(n, t);
1828
+ Matrix3.Cartesian3.multiplyByScalar(n, scalar, normalScale);
1829
+ Matrix3.Cartesian3.normalize(Matrix3.Cartesian3.subtract(t, normalScale, t), t);
1830
+
1831
+ tangentValues[i03] = t.x;
1832
+ tangentValues[i13] = t.y;
1833
+ tangentValues[i23] = t.z;
1834
+
1835
+ Matrix3.Cartesian3.normalize(Matrix3.Cartesian3.cross(n, t, t), t);
1836
+
1837
+ bitangentValues[i03] = t.x;
1838
+ bitangentValues[i13] = t.y;
1839
+ bitangentValues[i23] = t.z;
1840
+ }
1841
+
1842
+ geometry.attributes.tangent = new GeometryAttribute.GeometryAttribute({
1843
+ componentDatatype: ComponentDatatype.ComponentDatatype.FLOAT,
1844
+ componentsPerAttribute: 3,
1845
+ values: tangentValues,
1846
+ });
1847
+
1848
+ geometry.attributes.bitangent = new GeometryAttribute.GeometryAttribute({
1849
+ componentDatatype: ComponentDatatype.ComponentDatatype.FLOAT,
1850
+ componentsPerAttribute: 3,
1851
+ values: bitangentValues,
1852
+ });
1853
+
1854
+ return geometry;
1855
+ };
1856
+
1857
+ const scratchCartesian2 = new Matrix2.Cartesian2();
1858
+ const toEncode1 = new Matrix3.Cartesian3();
1859
+ const toEncode2 = new Matrix3.Cartesian3();
1860
+ const toEncode3 = new Matrix3.Cartesian3();
1861
+ let encodeResult2 = new Matrix2.Cartesian2();
1862
+ /**
1863
+ * Compresses and packs geometry normal attribute values to save memory.
1864
+ *
1865
+ * @param {Geometry} geometry The geometry to modify.
1866
+ * @returns {Geometry} The modified <code>geometry</code> argument, with its normals compressed and packed.
1867
+ *
1868
+ * @example
1869
+ * geometry = Cesium.GeometryPipeline.compressVertices(geometry);
1870
+ */
1871
+ GeometryPipeline.compressVertices = function (geometry) {
1872
+ //>>includeStart('debug', pragmas.debug);
1873
+ if (!defaultValue.defined(geometry)) {
1874
+ throw new Check.DeveloperError("geometry is required.");
1875
+ }
1876
+ //>>includeEnd('debug');
1877
+
1878
+ const extrudeAttribute = geometry.attributes.extrudeDirection;
1879
+ let i;
1880
+ let numVertices;
1881
+ if (defaultValue.defined(extrudeAttribute)) {
1882
+ //only shadow volumes use extrudeDirection, and shadow volumes use vertexFormat: POSITION_ONLY so we don't need to check other attributes
1883
+ const extrudeDirections = extrudeAttribute.values;
1884
+ numVertices = extrudeDirections.length / 3.0;
1885
+ const compressedDirections = new Float32Array(numVertices * 2);
1886
+
1887
+ let i2 = 0;
1888
+ for (i = 0; i < numVertices; ++i) {
1889
+ Matrix3.Cartesian3.fromArray(extrudeDirections, i * 3.0, toEncode1);
1890
+ if (Matrix3.Cartesian3.equals(toEncode1, Matrix3.Cartesian3.ZERO)) {
1891
+ i2 += 2;
1892
+ continue;
1893
+ }
1894
+ encodeResult2 = AttributeCompression.AttributeCompression.octEncodeInRange(
1895
+ toEncode1,
1896
+ 65535,
1897
+ encodeResult2
1898
+ );
1899
+ compressedDirections[i2++] = encodeResult2.x;
1900
+ compressedDirections[i2++] = encodeResult2.y;
1901
+ }
1902
+
1903
+ geometry.attributes.compressedAttributes = new GeometryAttribute.GeometryAttribute({
1904
+ componentDatatype: ComponentDatatype.ComponentDatatype.FLOAT,
1905
+ componentsPerAttribute: 2,
1906
+ values: compressedDirections,
1907
+ });
1908
+ delete geometry.attributes.extrudeDirection;
1909
+ return geometry;
1910
+ }
1911
+
1912
+ const normalAttribute = geometry.attributes.normal;
1913
+ const stAttribute = geometry.attributes.st;
1914
+
1915
+ const hasNormal = defaultValue.defined(normalAttribute);
1916
+ const hasSt = defaultValue.defined(stAttribute);
1917
+ if (!hasNormal && !hasSt) {
1918
+ return geometry;
1919
+ }
1920
+
1921
+ const tangentAttribute = geometry.attributes.tangent;
1922
+ const bitangentAttribute = geometry.attributes.bitangent;
1923
+
1924
+ const hasTangent = defaultValue.defined(tangentAttribute);
1925
+ const hasBitangent = defaultValue.defined(bitangentAttribute);
1926
+
1927
+ let normals;
1928
+ let st;
1929
+ let tangents;
1930
+ let bitangents;
1931
+
1932
+ if (hasNormal) {
1933
+ normals = normalAttribute.values;
1934
+ }
1935
+ if (hasSt) {
1936
+ st = stAttribute.values;
1937
+ }
1938
+ if (hasTangent) {
1939
+ tangents = tangentAttribute.values;
1940
+ }
1941
+ if (hasBitangent) {
1942
+ bitangents = bitangentAttribute.values;
1943
+ }
1944
+
1945
+ const length = hasNormal ? normals.length : st.length;
1946
+ const numComponents = hasNormal ? 3.0 : 2.0;
1947
+ numVertices = length / numComponents;
1948
+
1949
+ let compressedLength = numVertices;
1950
+ let numCompressedComponents = hasSt && hasNormal ? 2.0 : 1.0;
1951
+ numCompressedComponents += hasTangent || hasBitangent ? 1.0 : 0.0;
1952
+ compressedLength *= numCompressedComponents;
1953
+
1954
+ const compressedAttributes = new Float32Array(compressedLength);
1955
+
1956
+ let normalIndex = 0;
1957
+ for (i = 0; i < numVertices; ++i) {
1958
+ if (hasSt) {
1959
+ Matrix2.Cartesian2.fromArray(st, i * 2.0, scratchCartesian2);
1960
+ compressedAttributes[
1961
+ normalIndex++
1962
+ ] = AttributeCompression.AttributeCompression.compressTextureCoordinates(scratchCartesian2);
1963
+ }
1964
+
1965
+ const index = i * 3.0;
1966
+ if (hasNormal && defaultValue.defined(tangents) && defaultValue.defined(bitangents)) {
1967
+ Matrix3.Cartesian3.fromArray(normals, index, toEncode1);
1968
+ Matrix3.Cartesian3.fromArray(tangents, index, toEncode2);
1969
+ Matrix3.Cartesian3.fromArray(bitangents, index, toEncode3);
1970
+
1971
+ AttributeCompression.AttributeCompression.octPack(
1972
+ toEncode1,
1973
+ toEncode2,
1974
+ toEncode3,
1975
+ scratchCartesian2
1976
+ );
1977
+ compressedAttributes[normalIndex++] = scratchCartesian2.x;
1978
+ compressedAttributes[normalIndex++] = scratchCartesian2.y;
1979
+ } else {
1980
+ if (hasNormal) {
1981
+ Matrix3.Cartesian3.fromArray(normals, index, toEncode1);
1982
+ compressedAttributes[
1983
+ normalIndex++
1984
+ ] = AttributeCompression.AttributeCompression.octEncodeFloat(toEncode1);
1985
+ }
1986
+
1987
+ if (hasTangent) {
1988
+ Matrix3.Cartesian3.fromArray(tangents, index, toEncode1);
1989
+ compressedAttributes[
1990
+ normalIndex++
1991
+ ] = AttributeCompression.AttributeCompression.octEncodeFloat(toEncode1);
1992
+ }
1993
+
1994
+ if (hasBitangent) {
1995
+ Matrix3.Cartesian3.fromArray(bitangents, index, toEncode1);
1996
+ compressedAttributes[
1997
+ normalIndex++
1998
+ ] = AttributeCompression.AttributeCompression.octEncodeFloat(toEncode1);
1999
+ }
2000
+ }
2001
+ }
2002
+
2003
+ geometry.attributes.compressedAttributes = new GeometryAttribute.GeometryAttribute({
2004
+ componentDatatype: ComponentDatatype.ComponentDatatype.FLOAT,
2005
+ componentsPerAttribute: numCompressedComponents,
2006
+ values: compressedAttributes,
2007
+ });
2008
+
2009
+ if (hasNormal) {
2010
+ delete geometry.attributes.normal;
2011
+ }
2012
+ if (hasSt) {
2013
+ delete geometry.attributes.st;
2014
+ }
2015
+ if (hasBitangent) {
2016
+ delete geometry.attributes.bitangent;
2017
+ }
2018
+ if (hasTangent) {
2019
+ delete geometry.attributes.tangent;
2020
+ }
2021
+
2022
+ return geometry;
2023
+ };
2024
+
2025
+ function indexTriangles(geometry) {
2026
+ if (defaultValue.defined(geometry.indices)) {
2027
+ return geometry;
2028
+ }
2029
+ const numberOfVertices = GeometryAttribute.Geometry.computeNumberOfVertices(geometry);
2030
+
2031
+ //>>includeStart('debug', pragmas.debug);
2032
+ if (numberOfVertices < 3) {
2033
+ throw new Check.DeveloperError("The number of vertices must be at least three.");
2034
+ }
2035
+ if (numberOfVertices % 3 !== 0) {
2036
+ throw new Check.DeveloperError(
2037
+ "The number of vertices must be a multiple of three."
2038
+ );
2039
+ }
2040
+ //>>includeEnd('debug');
2041
+
2042
+ const indices = IndexDatatype.IndexDatatype.createTypedArray(
2043
+ numberOfVertices,
2044
+ numberOfVertices
2045
+ );
2046
+ for (let i = 0; i < numberOfVertices; ++i) {
2047
+ indices[i] = i;
2048
+ }
2049
+
2050
+ geometry.indices = indices;
2051
+ return geometry;
2052
+ }
2053
+
2054
+ function indexTriangleFan(geometry) {
2055
+ const numberOfVertices = GeometryAttribute.Geometry.computeNumberOfVertices(geometry);
2056
+
2057
+ //>>includeStart('debug', pragmas.debug);
2058
+ if (numberOfVertices < 3) {
2059
+ throw new Check.DeveloperError("The number of vertices must be at least three.");
2060
+ }
2061
+ //>>includeEnd('debug');
2062
+
2063
+ const indices = IndexDatatype.IndexDatatype.createTypedArray(
2064
+ numberOfVertices,
2065
+ (numberOfVertices - 2) * 3
2066
+ );
2067
+ indices[0] = 1;
2068
+ indices[1] = 0;
2069
+ indices[2] = 2;
2070
+
2071
+ let indicesIndex = 3;
2072
+ for (let i = 3; i < numberOfVertices; ++i) {
2073
+ indices[indicesIndex++] = i - 1;
2074
+ indices[indicesIndex++] = 0;
2075
+ indices[indicesIndex++] = i;
2076
+ }
2077
+
2078
+ geometry.indices = indices;
2079
+ geometry.primitiveType = GeometryAttribute.PrimitiveType.TRIANGLES;
2080
+ return geometry;
2081
+ }
2082
+
2083
+ function indexTriangleStrip(geometry) {
2084
+ const numberOfVertices = GeometryAttribute.Geometry.computeNumberOfVertices(geometry);
2085
+
2086
+ //>>includeStart('debug', pragmas.debug);
2087
+ if (numberOfVertices < 3) {
2088
+ throw new Check.DeveloperError("The number of vertices must be at least 3.");
2089
+ }
2090
+ //>>includeEnd('debug');
2091
+
2092
+ const indices = IndexDatatype.IndexDatatype.createTypedArray(
2093
+ numberOfVertices,
2094
+ (numberOfVertices - 2) * 3
2095
+ );
2096
+ indices[0] = 0;
2097
+ indices[1] = 1;
2098
+ indices[2] = 2;
2099
+
2100
+ if (numberOfVertices > 3) {
2101
+ indices[3] = 0;
2102
+ indices[4] = 2;
2103
+ indices[5] = 3;
2104
+ }
2105
+
2106
+ let indicesIndex = 6;
2107
+ for (let i = 3; i < numberOfVertices - 1; i += 2) {
2108
+ indices[indicesIndex++] = i;
2109
+ indices[indicesIndex++] = i - 1;
2110
+ indices[indicesIndex++] = i + 1;
2111
+
2112
+ if (i + 2 < numberOfVertices) {
2113
+ indices[indicesIndex++] = i;
2114
+ indices[indicesIndex++] = i + 1;
2115
+ indices[indicesIndex++] = i + 2;
2116
+ }
2117
+ }
2118
+
2119
+ geometry.indices = indices;
2120
+ geometry.primitiveType = GeometryAttribute.PrimitiveType.TRIANGLES;
2121
+ return geometry;
2122
+ }
2123
+
2124
+ function indexLines(geometry) {
2125
+ if (defaultValue.defined(geometry.indices)) {
2126
+ return geometry;
2127
+ }
2128
+ const numberOfVertices = GeometryAttribute.Geometry.computeNumberOfVertices(geometry);
2129
+
2130
+ //>>includeStart('debug', pragmas.debug);
2131
+ if (numberOfVertices < 2) {
2132
+ throw new Check.DeveloperError("The number of vertices must be at least two.");
2133
+ }
2134
+ if (numberOfVertices % 2 !== 0) {
2135
+ throw new Check.DeveloperError("The number of vertices must be a multiple of 2.");
2136
+ }
2137
+ //>>includeEnd('debug');
2138
+
2139
+ const indices = IndexDatatype.IndexDatatype.createTypedArray(
2140
+ numberOfVertices,
2141
+ numberOfVertices
2142
+ );
2143
+ for (let i = 0; i < numberOfVertices; ++i) {
2144
+ indices[i] = i;
2145
+ }
2146
+
2147
+ geometry.indices = indices;
2148
+ return geometry;
2149
+ }
2150
+
2151
+ function indexLineStrip(geometry) {
2152
+ const numberOfVertices = GeometryAttribute.Geometry.computeNumberOfVertices(geometry);
2153
+
2154
+ //>>includeStart('debug', pragmas.debug);
2155
+ if (numberOfVertices < 2) {
2156
+ throw new Check.DeveloperError("The number of vertices must be at least two.");
2157
+ }
2158
+ //>>includeEnd('debug');
2159
+
2160
+ const indices = IndexDatatype.IndexDatatype.createTypedArray(
2161
+ numberOfVertices,
2162
+ (numberOfVertices - 1) * 2
2163
+ );
2164
+ indices[0] = 0;
2165
+ indices[1] = 1;
2166
+ let indicesIndex = 2;
2167
+ for (let i = 2; i < numberOfVertices; ++i) {
2168
+ indices[indicesIndex++] = i - 1;
2169
+ indices[indicesIndex++] = i;
2170
+ }
2171
+
2172
+ geometry.indices = indices;
2173
+ geometry.primitiveType = GeometryAttribute.PrimitiveType.LINES;
2174
+ return geometry;
2175
+ }
2176
+
2177
+ function indexLineLoop(geometry) {
2178
+ const numberOfVertices = GeometryAttribute.Geometry.computeNumberOfVertices(geometry);
2179
+
2180
+ //>>includeStart('debug', pragmas.debug);
2181
+ if (numberOfVertices < 2) {
2182
+ throw new Check.DeveloperError("The number of vertices must be at least two.");
2183
+ }
2184
+ //>>includeEnd('debug');
2185
+
2186
+ const indices = IndexDatatype.IndexDatatype.createTypedArray(
2187
+ numberOfVertices,
2188
+ numberOfVertices * 2
2189
+ );
2190
+
2191
+ indices[0] = 0;
2192
+ indices[1] = 1;
2193
+
2194
+ let indicesIndex = 2;
2195
+ for (let i = 2; i < numberOfVertices; ++i) {
2196
+ indices[indicesIndex++] = i - 1;
2197
+ indices[indicesIndex++] = i;
2198
+ }
2199
+
2200
+ indices[indicesIndex++] = numberOfVertices - 1;
2201
+ indices[indicesIndex] = 0;
2202
+
2203
+ geometry.indices = indices;
2204
+ geometry.primitiveType = GeometryAttribute.PrimitiveType.LINES;
2205
+ return geometry;
2206
+ }
2207
+
2208
+ function indexPrimitive(geometry) {
2209
+ switch (geometry.primitiveType) {
2210
+ case GeometryAttribute.PrimitiveType.TRIANGLE_FAN:
2211
+ return indexTriangleFan(geometry);
2212
+ case GeometryAttribute.PrimitiveType.TRIANGLE_STRIP:
2213
+ return indexTriangleStrip(geometry);
2214
+ case GeometryAttribute.PrimitiveType.TRIANGLES:
2215
+ return indexTriangles(geometry);
2216
+ case GeometryAttribute.PrimitiveType.LINE_STRIP:
2217
+ return indexLineStrip(geometry);
2218
+ case GeometryAttribute.PrimitiveType.LINE_LOOP:
2219
+ return indexLineLoop(geometry);
2220
+ case GeometryAttribute.PrimitiveType.LINES:
2221
+ return indexLines(geometry);
2222
+ }
2223
+
2224
+ return geometry;
2225
+ }
2226
+
2227
+ function offsetPointFromXZPlane(p, isBehind) {
2228
+ if (Math.abs(p.y) < Math$1.CesiumMath.EPSILON6) {
2229
+ if (isBehind) {
2230
+ p.y = -Math$1.CesiumMath.EPSILON6;
2231
+ } else {
2232
+ p.y = Math$1.CesiumMath.EPSILON6;
2233
+ }
2234
+ }
2235
+ }
2236
+
2237
+ function offsetTriangleFromXZPlane(p0, p1, p2) {
2238
+ if (p0.y !== 0.0 && p1.y !== 0.0 && p2.y !== 0.0) {
2239
+ offsetPointFromXZPlane(p0, p0.y < 0.0);
2240
+ offsetPointFromXZPlane(p1, p1.y < 0.0);
2241
+ offsetPointFromXZPlane(p2, p2.y < 0.0);
2242
+ return;
2243
+ }
2244
+
2245
+ const p0y = Math.abs(p0.y);
2246
+ const p1y = Math.abs(p1.y);
2247
+ const p2y = Math.abs(p2.y);
2248
+
2249
+ let sign;
2250
+ if (p0y > p1y) {
2251
+ if (p0y > p2y) {
2252
+ sign = Math$1.CesiumMath.sign(p0.y);
2253
+ } else {
2254
+ sign = Math$1.CesiumMath.sign(p2.y);
2255
+ }
2256
+ } else if (p1y > p2y) {
2257
+ sign = Math$1.CesiumMath.sign(p1.y);
2258
+ } else {
2259
+ sign = Math$1.CesiumMath.sign(p2.y);
2260
+ }
2261
+
2262
+ const isBehind = sign < 0.0;
2263
+ offsetPointFromXZPlane(p0, isBehind);
2264
+ offsetPointFromXZPlane(p1, isBehind);
2265
+ offsetPointFromXZPlane(p2, isBehind);
2266
+ }
2267
+
2268
+ const c3 = new Matrix3.Cartesian3();
2269
+ function getXZIntersectionOffsetPoints(p, p1, u1, v1) {
2270
+ Matrix3.Cartesian3.add(
2271
+ p,
2272
+ Matrix3.Cartesian3.multiplyByScalar(
2273
+ Matrix3.Cartesian3.subtract(p1, p, c3),
2274
+ p.y / (p.y - p1.y),
2275
+ c3
2276
+ ),
2277
+ u1
2278
+ );
2279
+ Matrix3.Cartesian3.clone(u1, v1);
2280
+ offsetPointFromXZPlane(u1, true);
2281
+ offsetPointFromXZPlane(v1, false);
2282
+ }
2283
+
2284
+ const u1 = new Matrix3.Cartesian3();
2285
+ const u2 = new Matrix3.Cartesian3();
2286
+ const q1 = new Matrix3.Cartesian3();
2287
+ const q2 = new Matrix3.Cartesian3();
2288
+
2289
+ const splitTriangleResult = {
2290
+ positions: new Array(7),
2291
+ indices: new Array(3 * 3),
2292
+ };
2293
+
2294
+ function splitTriangle(p0, p1, p2) {
2295
+ // In WGS84 coordinates, for a triangle approximately on the
2296
+ // ellipsoid to cross the IDL, first it needs to be on the
2297
+ // negative side of the plane x = 0.
2298
+ if (p0.x >= 0.0 || p1.x >= 0.0 || p2.x >= 0.0) {
2299
+ return undefined;
2300
+ }
2301
+
2302
+ offsetTriangleFromXZPlane(p0, p1, p2);
2303
+
2304
+ const p0Behind = p0.y < 0.0;
2305
+ const p1Behind = p1.y < 0.0;
2306
+ const p2Behind = p2.y < 0.0;
2307
+
2308
+ let numBehind = 0;
2309
+ numBehind += p0Behind ? 1 : 0;
2310
+ numBehind += p1Behind ? 1 : 0;
2311
+ numBehind += p2Behind ? 1 : 0;
2312
+
2313
+ const indices = splitTriangleResult.indices;
2314
+
2315
+ if (numBehind === 1) {
2316
+ indices[1] = 3;
2317
+ indices[2] = 4;
2318
+ indices[5] = 6;
2319
+ indices[7] = 6;
2320
+ indices[8] = 5;
2321
+
2322
+ if (p0Behind) {
2323
+ getXZIntersectionOffsetPoints(p0, p1, u1, q1);
2324
+ getXZIntersectionOffsetPoints(p0, p2, u2, q2);
2325
+
2326
+ indices[0] = 0;
2327
+ indices[3] = 1;
2328
+ indices[4] = 2;
2329
+ indices[6] = 1;
2330
+ } else if (p1Behind) {
2331
+ getXZIntersectionOffsetPoints(p1, p2, u1, q1);
2332
+ getXZIntersectionOffsetPoints(p1, p0, u2, q2);
2333
+
2334
+ indices[0] = 1;
2335
+ indices[3] = 2;
2336
+ indices[4] = 0;
2337
+ indices[6] = 2;
2338
+ } else if (p2Behind) {
2339
+ getXZIntersectionOffsetPoints(p2, p0, u1, q1);
2340
+ getXZIntersectionOffsetPoints(p2, p1, u2, q2);
2341
+
2342
+ indices[0] = 2;
2343
+ indices[3] = 0;
2344
+ indices[4] = 1;
2345
+ indices[6] = 0;
2346
+ }
2347
+ } else if (numBehind === 2) {
2348
+ indices[2] = 4;
2349
+ indices[4] = 4;
2350
+ indices[5] = 3;
2351
+ indices[7] = 5;
2352
+ indices[8] = 6;
2353
+
2354
+ if (!p0Behind) {
2355
+ getXZIntersectionOffsetPoints(p0, p1, u1, q1);
2356
+ getXZIntersectionOffsetPoints(p0, p2, u2, q2);
2357
+
2358
+ indices[0] = 1;
2359
+ indices[1] = 2;
2360
+ indices[3] = 1;
2361
+ indices[6] = 0;
2362
+ } else if (!p1Behind) {
2363
+ getXZIntersectionOffsetPoints(p1, p2, u1, q1);
2364
+ getXZIntersectionOffsetPoints(p1, p0, u2, q2);
2365
+
2366
+ indices[0] = 2;
2367
+ indices[1] = 0;
2368
+ indices[3] = 2;
2369
+ indices[6] = 1;
2370
+ } else if (!p2Behind) {
2371
+ getXZIntersectionOffsetPoints(p2, p0, u1, q1);
2372
+ getXZIntersectionOffsetPoints(p2, p1, u2, q2);
2373
+
2374
+ indices[0] = 0;
2375
+ indices[1] = 1;
2376
+ indices[3] = 0;
2377
+ indices[6] = 2;
2378
+ }
2379
+ }
2380
+
2381
+ const positions = splitTriangleResult.positions;
2382
+ positions[0] = p0;
2383
+ positions[1] = p1;
2384
+ positions[2] = p2;
2385
+ positions.length = 3;
2386
+
2387
+ if (numBehind === 1 || numBehind === 2) {
2388
+ positions[3] = u1;
2389
+ positions[4] = u2;
2390
+ positions[5] = q1;
2391
+ positions[6] = q2;
2392
+ positions.length = 7;
2393
+ }
2394
+
2395
+ return splitTriangleResult;
2396
+ }
2397
+
2398
+ function updateGeometryAfterSplit(geometry, computeBoundingSphere) {
2399
+ const attributes = geometry.attributes;
2400
+
2401
+ if (attributes.position.values.length === 0) {
2402
+ return undefined;
2403
+ }
2404
+
2405
+ for (const property in attributes) {
2406
+ if (
2407
+ attributes.hasOwnProperty(property) &&
2408
+ defaultValue.defined(attributes[property]) &&
2409
+ defaultValue.defined(attributes[property].values)
2410
+ ) {
2411
+ const attribute = attributes[property];
2412
+ attribute.values = ComponentDatatype.ComponentDatatype.createTypedArray(
2413
+ attribute.componentDatatype,
2414
+ attribute.values
2415
+ );
2416
+ }
2417
+ }
2418
+
2419
+ const numberOfVertices = GeometryAttribute.Geometry.computeNumberOfVertices(geometry);
2420
+ geometry.indices = IndexDatatype.IndexDatatype.createTypedArray(
2421
+ numberOfVertices,
2422
+ geometry.indices
2423
+ );
2424
+
2425
+ if (computeBoundingSphere) {
2426
+ geometry.boundingSphere = Transforms.BoundingSphere.fromVertices(
2427
+ attributes.position.values
2428
+ );
2429
+ }
2430
+
2431
+ return geometry;
2432
+ }
2433
+
2434
+ function copyGeometryForSplit(geometry) {
2435
+ const attributes = geometry.attributes;
2436
+ const copiedAttributes = {};
2437
+
2438
+ for (const property in attributes) {
2439
+ if (
2440
+ attributes.hasOwnProperty(property) &&
2441
+ defaultValue.defined(attributes[property]) &&
2442
+ defaultValue.defined(attributes[property].values)
2443
+ ) {
2444
+ const attribute = attributes[property];
2445
+ copiedAttributes[property] = new GeometryAttribute.GeometryAttribute({
2446
+ componentDatatype: attribute.componentDatatype,
2447
+ componentsPerAttribute: attribute.componentsPerAttribute,
2448
+ normalize: attribute.normalize,
2449
+ values: [],
2450
+ });
2451
+ }
2452
+ }
2453
+
2454
+ return new GeometryAttribute.Geometry({
2455
+ attributes: copiedAttributes,
2456
+ indices: [],
2457
+ primitiveType: geometry.primitiveType,
2458
+ });
2459
+ }
2460
+
2461
+ function updateInstanceAfterSplit(instance, westGeometry, eastGeometry) {
2462
+ const computeBoundingSphere = defaultValue.defined(instance.geometry.boundingSphere);
2463
+
2464
+ westGeometry = updateGeometryAfterSplit(westGeometry, computeBoundingSphere);
2465
+ eastGeometry = updateGeometryAfterSplit(eastGeometry, computeBoundingSphere);
2466
+
2467
+ if (defaultValue.defined(eastGeometry) && !defaultValue.defined(westGeometry)) {
2468
+ instance.geometry = eastGeometry;
2469
+ } else if (!defaultValue.defined(eastGeometry) && defaultValue.defined(westGeometry)) {
2470
+ instance.geometry = westGeometry;
2471
+ } else {
2472
+ instance.westHemisphereGeometry = westGeometry;
2473
+ instance.eastHemisphereGeometry = eastGeometry;
2474
+ instance.geometry = undefined;
2475
+ }
2476
+ }
2477
+
2478
+ function generateBarycentricInterpolateFunction(
2479
+ CartesianType,
2480
+ numberOfComponents
2481
+ ) {
2482
+ const v0Scratch = new CartesianType();
2483
+ const v1Scratch = new CartesianType();
2484
+ const v2Scratch = new CartesianType();
2485
+
2486
+ return function (
2487
+ i0,
2488
+ i1,
2489
+ i2,
2490
+ coords,
2491
+ sourceValues,
2492
+ currentValues,
2493
+ insertedIndex,
2494
+ normalize
2495
+ ) {
2496
+ const v0 = CartesianType.fromArray(
2497
+ sourceValues,
2498
+ i0 * numberOfComponents,
2499
+ v0Scratch
2500
+ );
2501
+ const v1 = CartesianType.fromArray(
2502
+ sourceValues,
2503
+ i1 * numberOfComponents,
2504
+ v1Scratch
2505
+ );
2506
+ const v2 = CartesianType.fromArray(
2507
+ sourceValues,
2508
+ i2 * numberOfComponents,
2509
+ v2Scratch
2510
+ );
2511
+
2512
+ CartesianType.multiplyByScalar(v0, coords.x, v0);
2513
+ CartesianType.multiplyByScalar(v1, coords.y, v1);
2514
+ CartesianType.multiplyByScalar(v2, coords.z, v2);
2515
+
2516
+ const value = CartesianType.add(v0, v1, v0);
2517
+ CartesianType.add(value, v2, value);
2518
+
2519
+ if (normalize) {
2520
+ CartesianType.normalize(value, value);
2521
+ }
2522
+
2523
+ CartesianType.pack(
2524
+ value,
2525
+ currentValues,
2526
+ insertedIndex * numberOfComponents
2527
+ );
2528
+ };
2529
+ }
2530
+
2531
+ const interpolateAndPackCartesian4 = generateBarycentricInterpolateFunction(
2532
+ Matrix2.Cartesian4,
2533
+ 4
2534
+ );
2535
+ const interpolateAndPackCartesian3 = generateBarycentricInterpolateFunction(
2536
+ Matrix3.Cartesian3,
2537
+ 3
2538
+ );
2539
+ const interpolateAndPackCartesian2 = generateBarycentricInterpolateFunction(
2540
+ Matrix2.Cartesian2,
2541
+ 2
2542
+ );
2543
+ const interpolateAndPackBoolean = function (
2544
+ i0,
2545
+ i1,
2546
+ i2,
2547
+ coords,
2548
+ sourceValues,
2549
+ currentValues,
2550
+ insertedIndex
2551
+ ) {
2552
+ const v1 = sourceValues[i0] * coords.x;
2553
+ const v2 = sourceValues[i1] * coords.y;
2554
+ const v3 = sourceValues[i2] * coords.z;
2555
+ currentValues[insertedIndex] = v1 + v2 + v3 > Math$1.CesiumMath.EPSILON6 ? 1 : 0;
2556
+ };
2557
+
2558
+ const p0Scratch = new Matrix3.Cartesian3();
2559
+ const p1Scratch = new Matrix3.Cartesian3();
2560
+ const p2Scratch = new Matrix3.Cartesian3();
2561
+ const barycentricScratch = new Matrix3.Cartesian3();
2562
+
2563
+ function computeTriangleAttributes(
2564
+ i0,
2565
+ i1,
2566
+ i2,
2567
+ point,
2568
+ positions,
2569
+ normals,
2570
+ tangents,
2571
+ bitangents,
2572
+ texCoords,
2573
+ extrudeDirections,
2574
+ applyOffset,
2575
+ currentAttributes,
2576
+ customAttributeNames,
2577
+ customAttributesLength,
2578
+ allAttributes,
2579
+ insertedIndex
2580
+ ) {
2581
+ if (
2582
+ !defaultValue.defined(normals) &&
2583
+ !defaultValue.defined(tangents) &&
2584
+ !defaultValue.defined(bitangents) &&
2585
+ !defaultValue.defined(texCoords) &&
2586
+ !defaultValue.defined(extrudeDirections) &&
2587
+ customAttributesLength === 0
2588
+ ) {
2589
+ return;
2590
+ }
2591
+
2592
+ const p0 = Matrix3.Cartesian3.fromArray(positions, i0 * 3, p0Scratch);
2593
+ const p1 = Matrix3.Cartesian3.fromArray(positions, i1 * 3, p1Scratch);
2594
+ const p2 = Matrix3.Cartesian3.fromArray(positions, i2 * 3, p2Scratch);
2595
+ const coords = barycentricCoordinates(point, p0, p1, p2, barycentricScratch);
2596
+ if (!defaultValue.defined(coords)) {
2597
+ return;
2598
+ }
2599
+
2600
+ if (defaultValue.defined(normals)) {
2601
+ interpolateAndPackCartesian3(
2602
+ i0,
2603
+ i1,
2604
+ i2,
2605
+ coords,
2606
+ normals,
2607
+ currentAttributes.normal.values,
2608
+ insertedIndex,
2609
+ true
2610
+ );
2611
+ }
2612
+
2613
+ if (defaultValue.defined(extrudeDirections)) {
2614
+ const d0 = Matrix3.Cartesian3.fromArray(extrudeDirections, i0 * 3, p0Scratch);
2615
+ const d1 = Matrix3.Cartesian3.fromArray(extrudeDirections, i1 * 3, p1Scratch);
2616
+ const d2 = Matrix3.Cartesian3.fromArray(extrudeDirections, i2 * 3, p2Scratch);
2617
+
2618
+ Matrix3.Cartesian3.multiplyByScalar(d0, coords.x, d0);
2619
+ Matrix3.Cartesian3.multiplyByScalar(d1, coords.y, d1);
2620
+ Matrix3.Cartesian3.multiplyByScalar(d2, coords.z, d2);
2621
+
2622
+ let direction;
2623
+ if (
2624
+ !Matrix3.Cartesian3.equals(d0, Matrix3.Cartesian3.ZERO) ||
2625
+ !Matrix3.Cartesian3.equals(d1, Matrix3.Cartesian3.ZERO) ||
2626
+ !Matrix3.Cartesian3.equals(d2, Matrix3.Cartesian3.ZERO)
2627
+ ) {
2628
+ direction = Matrix3.Cartesian3.add(d0, d1, d0);
2629
+ Matrix3.Cartesian3.add(direction, d2, direction);
2630
+ Matrix3.Cartesian3.normalize(direction, direction);
2631
+ } else {
2632
+ direction = p0Scratch;
2633
+ direction.x = 0;
2634
+ direction.y = 0;
2635
+ direction.z = 0;
2636
+ }
2637
+ Matrix3.Cartesian3.pack(
2638
+ direction,
2639
+ currentAttributes.extrudeDirection.values,
2640
+ insertedIndex * 3
2641
+ );
2642
+ }
2643
+
2644
+ if (defaultValue.defined(applyOffset)) {
2645
+ interpolateAndPackBoolean(
2646
+ i0,
2647
+ i1,
2648
+ i2,
2649
+ coords,
2650
+ applyOffset,
2651
+ currentAttributes.applyOffset.values,
2652
+ insertedIndex
2653
+ );
2654
+ }
2655
+
2656
+ if (defaultValue.defined(tangents)) {
2657
+ interpolateAndPackCartesian3(
2658
+ i0,
2659
+ i1,
2660
+ i2,
2661
+ coords,
2662
+ tangents,
2663
+ currentAttributes.tangent.values,
2664
+ insertedIndex,
2665
+ true
2666
+ );
2667
+ }
2668
+
2669
+ if (defaultValue.defined(bitangents)) {
2670
+ interpolateAndPackCartesian3(
2671
+ i0,
2672
+ i1,
2673
+ i2,
2674
+ coords,
2675
+ bitangents,
2676
+ currentAttributes.bitangent.values,
2677
+ insertedIndex,
2678
+ true
2679
+ );
2680
+ }
2681
+
2682
+ if (defaultValue.defined(texCoords)) {
2683
+ interpolateAndPackCartesian2(
2684
+ i0,
2685
+ i1,
2686
+ i2,
2687
+ coords,
2688
+ texCoords,
2689
+ currentAttributes.st.values,
2690
+ insertedIndex
2691
+ );
2692
+ }
2693
+
2694
+ if (customAttributesLength > 0) {
2695
+ for (let i = 0; i < customAttributesLength; i++) {
2696
+ const attributeName = customAttributeNames[i];
2697
+ genericInterpolate(
2698
+ i0,
2699
+ i1,
2700
+ i2,
2701
+ coords,
2702
+ insertedIndex,
2703
+ allAttributes[attributeName],
2704
+ currentAttributes[attributeName]
2705
+ );
2706
+ }
2707
+ }
2708
+ }
2709
+
2710
+ function genericInterpolate(
2711
+ i0,
2712
+ i1,
2713
+ i2,
2714
+ coords,
2715
+ insertedIndex,
2716
+ sourceAttribute,
2717
+ currentAttribute
2718
+ ) {
2719
+ const componentsPerAttribute = sourceAttribute.componentsPerAttribute;
2720
+ const sourceValues = sourceAttribute.values;
2721
+ const currentValues = currentAttribute.values;
2722
+ switch (componentsPerAttribute) {
2723
+ case 4:
2724
+ interpolateAndPackCartesian4(
2725
+ i0,
2726
+ i1,
2727
+ i2,
2728
+ coords,
2729
+ sourceValues,
2730
+ currentValues,
2731
+ insertedIndex,
2732
+ false
2733
+ );
2734
+ break;
2735
+ case 3:
2736
+ interpolateAndPackCartesian3(
2737
+ i0,
2738
+ i1,
2739
+ i2,
2740
+ coords,
2741
+ sourceValues,
2742
+ currentValues,
2743
+ insertedIndex,
2744
+ false
2745
+ );
2746
+ break;
2747
+ case 2:
2748
+ interpolateAndPackCartesian2(
2749
+ i0,
2750
+ i1,
2751
+ i2,
2752
+ coords,
2753
+ sourceValues,
2754
+ currentValues,
2755
+ insertedIndex,
2756
+ false
2757
+ );
2758
+ break;
2759
+ default:
2760
+ currentValues[insertedIndex] =
2761
+ sourceValues[i0] * coords.x +
2762
+ sourceValues[i1] * coords.y +
2763
+ sourceValues[i2] * coords.z;
2764
+ }
2765
+ }
2766
+
2767
+ function insertSplitPoint(
2768
+ currentAttributes,
2769
+ currentIndices,
2770
+ currentIndexMap,
2771
+ indices,
2772
+ currentIndex,
2773
+ point
2774
+ ) {
2775
+ const insertIndex = currentAttributes.position.values.length / 3;
2776
+
2777
+ if (currentIndex !== -1) {
2778
+ const prevIndex = indices[currentIndex];
2779
+ const newIndex = currentIndexMap[prevIndex];
2780
+
2781
+ if (newIndex === -1) {
2782
+ currentIndexMap[prevIndex] = insertIndex;
2783
+ currentAttributes.position.values.push(point.x, point.y, point.z);
2784
+ currentIndices.push(insertIndex);
2785
+ return insertIndex;
2786
+ }
2787
+
2788
+ currentIndices.push(newIndex);
2789
+ return newIndex;
2790
+ }
2791
+
2792
+ currentAttributes.position.values.push(point.x, point.y, point.z);
2793
+ currentIndices.push(insertIndex);
2794
+ return insertIndex;
2795
+ }
2796
+
2797
+ const NAMED_ATTRIBUTES = {
2798
+ position: true,
2799
+ normal: true,
2800
+ bitangent: true,
2801
+ tangent: true,
2802
+ st: true,
2803
+ extrudeDirection: true,
2804
+ applyOffset: true,
2805
+ };
2806
+ function splitLongitudeTriangles(instance) {
2807
+ const geometry = instance.geometry;
2808
+ const attributes = geometry.attributes;
2809
+ const positions = attributes.position.values;
2810
+ const normals = defaultValue.defined(attributes.normal)
2811
+ ? attributes.normal.values
2812
+ : undefined;
2813
+ const bitangents = defaultValue.defined(attributes.bitangent)
2814
+ ? attributes.bitangent.values
2815
+ : undefined;
2816
+ const tangents = defaultValue.defined(attributes.tangent)
2817
+ ? attributes.tangent.values
2818
+ : undefined;
2819
+ const texCoords = defaultValue.defined(attributes.st) ? attributes.st.values : undefined;
2820
+ const extrudeDirections = defaultValue.defined(attributes.extrudeDirection)
2821
+ ? attributes.extrudeDirection.values
2822
+ : undefined;
2823
+ const applyOffset = defaultValue.defined(attributes.applyOffset)
2824
+ ? attributes.applyOffset.values
2825
+ : undefined;
2826
+ const indices = geometry.indices;
2827
+
2828
+ const customAttributeNames = [];
2829
+ for (const attributeName in attributes) {
2830
+ if (
2831
+ attributes.hasOwnProperty(attributeName) &&
2832
+ !NAMED_ATTRIBUTES[attributeName] &&
2833
+ defaultValue.defined(attributes[attributeName])
2834
+ ) {
2835
+ customAttributeNames.push(attributeName);
2836
+ }
2837
+ }
2838
+ const customAttributesLength = customAttributeNames.length;
2839
+
2840
+ const eastGeometry = copyGeometryForSplit(geometry);
2841
+ const westGeometry = copyGeometryForSplit(geometry);
2842
+
2843
+ let currentAttributes;
2844
+ let currentIndices;
2845
+ let currentIndexMap;
2846
+ let insertedIndex;
2847
+ let i;
2848
+
2849
+ const westGeometryIndexMap = [];
2850
+ westGeometryIndexMap.length = positions.length / 3;
2851
+
2852
+ const eastGeometryIndexMap = [];
2853
+ eastGeometryIndexMap.length = positions.length / 3;
2854
+
2855
+ for (i = 0; i < westGeometryIndexMap.length; ++i) {
2856
+ westGeometryIndexMap[i] = -1;
2857
+ eastGeometryIndexMap[i] = -1;
2858
+ }
2859
+
2860
+ const len = indices.length;
2861
+ for (i = 0; i < len; i += 3) {
2862
+ const i0 = indices[i];
2863
+ const i1 = indices[i + 1];
2864
+ const i2 = indices[i + 2];
2865
+
2866
+ let p0 = Matrix3.Cartesian3.fromArray(positions, i0 * 3);
2867
+ let p1 = Matrix3.Cartesian3.fromArray(positions, i1 * 3);
2868
+ let p2 = Matrix3.Cartesian3.fromArray(positions, i2 * 3);
2869
+
2870
+ const result = splitTriangle(p0, p1, p2);
2871
+ if (defaultValue.defined(result) && result.positions.length > 3) {
2872
+ const resultPositions = result.positions;
2873
+ const resultIndices = result.indices;
2874
+ const resultLength = resultIndices.length;
2875
+
2876
+ for (let j = 0; j < resultLength; ++j) {
2877
+ const resultIndex = resultIndices[j];
2878
+ const point = resultPositions[resultIndex];
2879
+
2880
+ if (point.y < 0.0) {
2881
+ currentAttributes = westGeometry.attributes;
2882
+ currentIndices = westGeometry.indices;
2883
+ currentIndexMap = westGeometryIndexMap;
2884
+ } else {
2885
+ currentAttributes = eastGeometry.attributes;
2886
+ currentIndices = eastGeometry.indices;
2887
+ currentIndexMap = eastGeometryIndexMap;
2888
+ }
2889
+
2890
+ insertedIndex = insertSplitPoint(
2891
+ currentAttributes,
2892
+ currentIndices,
2893
+ currentIndexMap,
2894
+ indices,
2895
+ resultIndex < 3 ? i + resultIndex : -1,
2896
+ point
2897
+ );
2898
+ computeTriangleAttributes(
2899
+ i0,
2900
+ i1,
2901
+ i2,
2902
+ point,
2903
+ positions,
2904
+ normals,
2905
+ tangents,
2906
+ bitangents,
2907
+ texCoords,
2908
+ extrudeDirections,
2909
+ applyOffset,
2910
+ currentAttributes,
2911
+ customAttributeNames,
2912
+ customAttributesLength,
2913
+ attributes,
2914
+ insertedIndex
2915
+ );
2916
+ }
2917
+ } else {
2918
+ if (defaultValue.defined(result)) {
2919
+ p0 = result.positions[0];
2920
+ p1 = result.positions[1];
2921
+ p2 = result.positions[2];
2922
+ }
2923
+
2924
+ if (p0.y < 0.0) {
2925
+ currentAttributes = westGeometry.attributes;
2926
+ currentIndices = westGeometry.indices;
2927
+ currentIndexMap = westGeometryIndexMap;
2928
+ } else {
2929
+ currentAttributes = eastGeometry.attributes;
2930
+ currentIndices = eastGeometry.indices;
2931
+ currentIndexMap = eastGeometryIndexMap;
2932
+ }
2933
+
2934
+ insertedIndex = insertSplitPoint(
2935
+ currentAttributes,
2936
+ currentIndices,
2937
+ currentIndexMap,
2938
+ indices,
2939
+ i,
2940
+ p0
2941
+ );
2942
+ computeTriangleAttributes(
2943
+ i0,
2944
+ i1,
2945
+ i2,
2946
+ p0,
2947
+ positions,
2948
+ normals,
2949
+ tangents,
2950
+ bitangents,
2951
+ texCoords,
2952
+ extrudeDirections,
2953
+ applyOffset,
2954
+ currentAttributes,
2955
+ customAttributeNames,
2956
+ customAttributesLength,
2957
+ attributes,
2958
+ insertedIndex
2959
+ );
2960
+
2961
+ insertedIndex = insertSplitPoint(
2962
+ currentAttributes,
2963
+ currentIndices,
2964
+ currentIndexMap,
2965
+ indices,
2966
+ i + 1,
2967
+ p1
2968
+ );
2969
+ computeTriangleAttributes(
2970
+ i0,
2971
+ i1,
2972
+ i2,
2973
+ p1,
2974
+ positions,
2975
+ normals,
2976
+ tangents,
2977
+ bitangents,
2978
+ texCoords,
2979
+ extrudeDirections,
2980
+ applyOffset,
2981
+ currentAttributes,
2982
+ customAttributeNames,
2983
+ customAttributesLength,
2984
+ attributes,
2985
+ insertedIndex
2986
+ );
2987
+
2988
+ insertedIndex = insertSplitPoint(
2989
+ currentAttributes,
2990
+ currentIndices,
2991
+ currentIndexMap,
2992
+ indices,
2993
+ i + 2,
2994
+ p2
2995
+ );
2996
+ computeTriangleAttributes(
2997
+ i0,
2998
+ i1,
2999
+ i2,
3000
+ p2,
3001
+ positions,
3002
+ normals,
3003
+ tangents,
3004
+ bitangents,
3005
+ texCoords,
3006
+ extrudeDirections,
3007
+ applyOffset,
3008
+ currentAttributes,
3009
+ customAttributeNames,
3010
+ customAttributesLength,
3011
+ attributes,
3012
+ insertedIndex
3013
+ );
3014
+ }
3015
+ }
3016
+
3017
+ updateInstanceAfterSplit(instance, westGeometry, eastGeometry);
3018
+ }
3019
+
3020
+ const xzPlane = Plane.Plane.fromPointNormal(Matrix3.Cartesian3.ZERO, Matrix3.Cartesian3.UNIT_Y);
3021
+
3022
+ const offsetScratch = new Matrix3.Cartesian3();
3023
+ const offsetPointScratch = new Matrix3.Cartesian3();
3024
+
3025
+ function computeLineAttributes(
3026
+ i0,
3027
+ i1,
3028
+ point,
3029
+ positions,
3030
+ insertIndex,
3031
+ currentAttributes,
3032
+ applyOffset
3033
+ ) {
3034
+ if (!defaultValue.defined(applyOffset)) {
3035
+ return;
3036
+ }
3037
+
3038
+ const p0 = Matrix3.Cartesian3.fromArray(positions, i0 * 3, p0Scratch);
3039
+ if (Matrix3.Cartesian3.equalsEpsilon(p0, point, Math$1.CesiumMath.EPSILON10)) {
3040
+ currentAttributes.applyOffset.values[insertIndex] = applyOffset[i0];
3041
+ } else {
3042
+ currentAttributes.applyOffset.values[insertIndex] = applyOffset[i1];
3043
+ }
3044
+ }
3045
+
3046
+ function splitLongitudeLines(instance) {
3047
+ const geometry = instance.geometry;
3048
+ const attributes = geometry.attributes;
3049
+ const positions = attributes.position.values;
3050
+ const applyOffset = defaultValue.defined(attributes.applyOffset)
3051
+ ? attributes.applyOffset.values
3052
+ : undefined;
3053
+ const indices = geometry.indices;
3054
+
3055
+ const eastGeometry = copyGeometryForSplit(geometry);
3056
+ const westGeometry = copyGeometryForSplit(geometry);
3057
+
3058
+ let i;
3059
+ const length = indices.length;
3060
+
3061
+ const westGeometryIndexMap = [];
3062
+ westGeometryIndexMap.length = positions.length / 3;
3063
+
3064
+ const eastGeometryIndexMap = [];
3065
+ eastGeometryIndexMap.length = positions.length / 3;
3066
+
3067
+ for (i = 0; i < westGeometryIndexMap.length; ++i) {
3068
+ westGeometryIndexMap[i] = -1;
3069
+ eastGeometryIndexMap[i] = -1;
3070
+ }
3071
+
3072
+ for (i = 0; i < length; i += 2) {
3073
+ const i0 = indices[i];
3074
+ const i1 = indices[i + 1];
3075
+
3076
+ const p0 = Matrix3.Cartesian3.fromArray(positions, i0 * 3, p0Scratch);
3077
+ const p1 = Matrix3.Cartesian3.fromArray(positions, i1 * 3, p1Scratch);
3078
+ let insertIndex;
3079
+
3080
+ if (Math.abs(p0.y) < Math$1.CesiumMath.EPSILON6) {
3081
+ if (p0.y < 0.0) {
3082
+ p0.y = -Math$1.CesiumMath.EPSILON6;
3083
+ } else {
3084
+ p0.y = Math$1.CesiumMath.EPSILON6;
3085
+ }
3086
+ }
3087
+
3088
+ if (Math.abs(p1.y) < Math$1.CesiumMath.EPSILON6) {
3089
+ if (p1.y < 0.0) {
3090
+ p1.y = -Math$1.CesiumMath.EPSILON6;
3091
+ } else {
3092
+ p1.y = Math$1.CesiumMath.EPSILON6;
3093
+ }
3094
+ }
3095
+
3096
+ let p0Attributes = eastGeometry.attributes;
3097
+ let p0Indices = eastGeometry.indices;
3098
+ let p0IndexMap = eastGeometryIndexMap;
3099
+ let p1Attributes = westGeometry.attributes;
3100
+ let p1Indices = westGeometry.indices;
3101
+ let p1IndexMap = westGeometryIndexMap;
3102
+
3103
+ const intersection = IntersectionTests.IntersectionTests.lineSegmentPlane(
3104
+ p0,
3105
+ p1,
3106
+ xzPlane,
3107
+ p2Scratch
3108
+ );
3109
+ if (defaultValue.defined(intersection)) {
3110
+ // move point on the xz-plane slightly away from the plane
3111
+ const offset = Matrix3.Cartesian3.multiplyByScalar(
3112
+ Matrix3.Cartesian3.UNIT_Y,
3113
+ 5.0 * Math$1.CesiumMath.EPSILON9,
3114
+ offsetScratch
3115
+ );
3116
+ if (p0.y < 0.0) {
3117
+ Matrix3.Cartesian3.negate(offset, offset);
3118
+
3119
+ p0Attributes = westGeometry.attributes;
3120
+ p0Indices = westGeometry.indices;
3121
+ p0IndexMap = westGeometryIndexMap;
3122
+ p1Attributes = eastGeometry.attributes;
3123
+ p1Indices = eastGeometry.indices;
3124
+ p1IndexMap = eastGeometryIndexMap;
3125
+ }
3126
+
3127
+ const offsetPoint = Matrix3.Cartesian3.add(
3128
+ intersection,
3129
+ offset,
3130
+ offsetPointScratch
3131
+ );
3132
+
3133
+ insertIndex = insertSplitPoint(
3134
+ p0Attributes,
3135
+ p0Indices,
3136
+ p0IndexMap,
3137
+ indices,
3138
+ i,
3139
+ p0
3140
+ );
3141
+ computeLineAttributes(
3142
+ i0,
3143
+ i1,
3144
+ p0,
3145
+ positions,
3146
+ insertIndex,
3147
+ p0Attributes,
3148
+ applyOffset
3149
+ );
3150
+
3151
+ insertIndex = insertSplitPoint(
3152
+ p0Attributes,
3153
+ p0Indices,
3154
+ p0IndexMap,
3155
+ indices,
3156
+ -1,
3157
+ offsetPoint
3158
+ );
3159
+ computeLineAttributes(
3160
+ i0,
3161
+ i1,
3162
+ offsetPoint,
3163
+ positions,
3164
+ insertIndex,
3165
+ p0Attributes,
3166
+ applyOffset
3167
+ );
3168
+
3169
+ Matrix3.Cartesian3.negate(offset, offset);
3170
+ Matrix3.Cartesian3.add(intersection, offset, offsetPoint);
3171
+ insertIndex = insertSplitPoint(
3172
+ p1Attributes,
3173
+ p1Indices,
3174
+ p1IndexMap,
3175
+ indices,
3176
+ -1,
3177
+ offsetPoint
3178
+ );
3179
+ computeLineAttributes(
3180
+ i0,
3181
+ i1,
3182
+ offsetPoint,
3183
+ positions,
3184
+ insertIndex,
3185
+ p1Attributes,
3186
+ applyOffset
3187
+ );
3188
+
3189
+ insertIndex = insertSplitPoint(
3190
+ p1Attributes,
3191
+ p1Indices,
3192
+ p1IndexMap,
3193
+ indices,
3194
+ i + 1,
3195
+ p1
3196
+ );
3197
+ computeLineAttributes(
3198
+ i0,
3199
+ i1,
3200
+ p1,
3201
+ positions,
3202
+ insertIndex,
3203
+ p1Attributes,
3204
+ applyOffset
3205
+ );
3206
+ } else {
3207
+ let currentAttributes;
3208
+ let currentIndices;
3209
+ let currentIndexMap;
3210
+
3211
+ if (p0.y < 0.0) {
3212
+ currentAttributes = westGeometry.attributes;
3213
+ currentIndices = westGeometry.indices;
3214
+ currentIndexMap = westGeometryIndexMap;
3215
+ } else {
3216
+ currentAttributes = eastGeometry.attributes;
3217
+ currentIndices = eastGeometry.indices;
3218
+ currentIndexMap = eastGeometryIndexMap;
3219
+ }
3220
+
3221
+ insertIndex = insertSplitPoint(
3222
+ currentAttributes,
3223
+ currentIndices,
3224
+ currentIndexMap,
3225
+ indices,
3226
+ i,
3227
+ p0
3228
+ );
3229
+ computeLineAttributes(
3230
+ i0,
3231
+ i1,
3232
+ p0,
3233
+ positions,
3234
+ insertIndex,
3235
+ currentAttributes,
3236
+ applyOffset
3237
+ );
3238
+
3239
+ insertIndex = insertSplitPoint(
3240
+ currentAttributes,
3241
+ currentIndices,
3242
+ currentIndexMap,
3243
+ indices,
3244
+ i + 1,
3245
+ p1
3246
+ );
3247
+ computeLineAttributes(
3248
+ i0,
3249
+ i1,
3250
+ p1,
3251
+ positions,
3252
+ insertIndex,
3253
+ currentAttributes,
3254
+ applyOffset
3255
+ );
3256
+ }
3257
+ }
3258
+
3259
+ updateInstanceAfterSplit(instance, westGeometry, eastGeometry);
3260
+ }
3261
+
3262
+ const cartesian2Scratch0 = new Matrix2.Cartesian2();
3263
+ const cartesian2Scratch1 = new Matrix2.Cartesian2();
3264
+
3265
+ const cartesian3Scratch0 = new Matrix3.Cartesian3();
3266
+ const cartesian3Scratch2 = new Matrix3.Cartesian3();
3267
+ const cartesian3Scratch3 = new Matrix3.Cartesian3();
3268
+ const cartesian3Scratch4 = new Matrix3.Cartesian3();
3269
+ const cartesian3Scratch5 = new Matrix3.Cartesian3();
3270
+ const cartesian3Scratch6 = new Matrix3.Cartesian3();
3271
+
3272
+ const cartesian4Scratch0 = new Matrix2.Cartesian4();
3273
+
3274
+ function updateAdjacencyAfterSplit(geometry) {
3275
+ const attributes = geometry.attributes;
3276
+ const positions = attributes.position.values;
3277
+ const prevPositions = attributes.prevPosition.values;
3278
+ const nextPositions = attributes.nextPosition.values;
3279
+
3280
+ const length = positions.length;
3281
+ for (let j = 0; j < length; j += 3) {
3282
+ const position = Matrix3.Cartesian3.unpack(positions, j, cartesian3Scratch0);
3283
+ if (position.x > 0.0) {
3284
+ continue;
3285
+ }
3286
+
3287
+ const prevPosition = Matrix3.Cartesian3.unpack(
3288
+ prevPositions,
3289
+ j,
3290
+ cartesian3Scratch2
3291
+ );
3292
+ if (
3293
+ (position.y < 0.0 && prevPosition.y > 0.0) ||
3294
+ (position.y > 0.0 && prevPosition.y < 0.0)
3295
+ ) {
3296
+ if (j - 3 > 0) {
3297
+ prevPositions[j] = positions[j - 3];
3298
+ prevPositions[j + 1] = positions[j - 2];
3299
+ prevPositions[j + 2] = positions[j - 1];
3300
+ } else {
3301
+ Matrix3.Cartesian3.pack(position, prevPositions, j);
3302
+ }
3303
+ }
3304
+
3305
+ const nextPosition = Matrix3.Cartesian3.unpack(
3306
+ nextPositions,
3307
+ j,
3308
+ cartesian3Scratch3
3309
+ );
3310
+ if (
3311
+ (position.y < 0.0 && nextPosition.y > 0.0) ||
3312
+ (position.y > 0.0 && nextPosition.y < 0.0)
3313
+ ) {
3314
+ if (j + 3 < length) {
3315
+ nextPositions[j] = positions[j + 3];
3316
+ nextPositions[j + 1] = positions[j + 4];
3317
+ nextPositions[j + 2] = positions[j + 5];
3318
+ } else {
3319
+ Matrix3.Cartesian3.pack(position, nextPositions, j);
3320
+ }
3321
+ }
3322
+ }
3323
+ }
3324
+
3325
+ const offsetScalar = 5.0 * Math$1.CesiumMath.EPSILON9;
3326
+ const coplanarOffset = Math$1.CesiumMath.EPSILON6;
3327
+
3328
+ function splitLongitudePolyline(instance) {
3329
+ const geometry = instance.geometry;
3330
+ const attributes = geometry.attributes;
3331
+ const positions = attributes.position.values;
3332
+ const prevPositions = attributes.prevPosition.values;
3333
+ const nextPositions = attributes.nextPosition.values;
3334
+ const expandAndWidths = attributes.expandAndWidth.values;
3335
+
3336
+ const texCoords = defaultValue.defined(attributes.st) ? attributes.st.values : undefined;
3337
+ const colors = defaultValue.defined(attributes.color)
3338
+ ? attributes.color.values
3339
+ : undefined;
3340
+
3341
+ const eastGeometry = copyGeometryForSplit(geometry);
3342
+ const westGeometry = copyGeometryForSplit(geometry);
3343
+
3344
+ let i;
3345
+ let j;
3346
+ let index;
3347
+
3348
+ let intersectionFound = false;
3349
+
3350
+ const length = positions.length / 3;
3351
+ for (i = 0; i < length; i += 4) {
3352
+ const i0 = i;
3353
+ const i2 = i + 2;
3354
+
3355
+ const p0 = Matrix3.Cartesian3.fromArray(positions, i0 * 3, cartesian3Scratch0);
3356
+ const p2 = Matrix3.Cartesian3.fromArray(positions, i2 * 3, cartesian3Scratch2);
3357
+
3358
+ // Offset points that are close to the 180 longitude and change the previous/next point
3359
+ // to be the same offset point so it can be projected to 2D. There is special handling in the
3360
+ // shader for when position == prevPosition || position == nextPosition.
3361
+ if (Math.abs(p0.y) < coplanarOffset) {
3362
+ p0.y = coplanarOffset * (p2.y < 0.0 ? -1.0 : 1.0);
3363
+ positions[i * 3 + 1] = p0.y;
3364
+ positions[(i + 1) * 3 + 1] = p0.y;
3365
+
3366
+ for (j = i0 * 3; j < i0 * 3 + 4 * 3; j += 3) {
3367
+ prevPositions[j] = positions[i * 3];
3368
+ prevPositions[j + 1] = positions[i * 3 + 1];
3369
+ prevPositions[j + 2] = positions[i * 3 + 2];
3370
+ }
3371
+ }
3372
+
3373
+ // Do the same but for when the line crosses 180 longitude in the opposite direction.
3374
+ if (Math.abs(p2.y) < coplanarOffset) {
3375
+ p2.y = coplanarOffset * (p0.y < 0.0 ? -1.0 : 1.0);
3376
+ positions[(i + 2) * 3 + 1] = p2.y;
3377
+ positions[(i + 3) * 3 + 1] = p2.y;
3378
+
3379
+ for (j = i0 * 3; j < i0 * 3 + 4 * 3; j += 3) {
3380
+ nextPositions[j] = positions[(i + 2) * 3];
3381
+ nextPositions[j + 1] = positions[(i + 2) * 3 + 1];
3382
+ nextPositions[j + 2] = positions[(i + 2) * 3 + 2];
3383
+ }
3384
+ }
3385
+
3386
+ let p0Attributes = eastGeometry.attributes;
3387
+ let p0Indices = eastGeometry.indices;
3388
+ let p2Attributes = westGeometry.attributes;
3389
+ let p2Indices = westGeometry.indices;
3390
+
3391
+ const intersection = IntersectionTests.IntersectionTests.lineSegmentPlane(
3392
+ p0,
3393
+ p2,
3394
+ xzPlane,
3395
+ cartesian3Scratch4
3396
+ );
3397
+ if (defaultValue.defined(intersection)) {
3398
+ intersectionFound = true;
3399
+
3400
+ // move point on the xz-plane slightly away from the plane
3401
+ const offset = Matrix3.Cartesian3.multiplyByScalar(
3402
+ Matrix3.Cartesian3.UNIT_Y,
3403
+ offsetScalar,
3404
+ cartesian3Scratch5
3405
+ );
3406
+ if (p0.y < 0.0) {
3407
+ Matrix3.Cartesian3.negate(offset, offset);
3408
+ p0Attributes = westGeometry.attributes;
3409
+ p0Indices = westGeometry.indices;
3410
+ p2Attributes = eastGeometry.attributes;
3411
+ p2Indices = eastGeometry.indices;
3412
+ }
3413
+
3414
+ const offsetPoint = Matrix3.Cartesian3.add(
3415
+ intersection,
3416
+ offset,
3417
+ cartesian3Scratch6
3418
+ );
3419
+ p0Attributes.position.values.push(p0.x, p0.y, p0.z, p0.x, p0.y, p0.z);
3420
+ p0Attributes.position.values.push(
3421
+ offsetPoint.x,
3422
+ offsetPoint.y,
3423
+ offsetPoint.z
3424
+ );
3425
+ p0Attributes.position.values.push(
3426
+ offsetPoint.x,
3427
+ offsetPoint.y,
3428
+ offsetPoint.z
3429
+ );
3430
+
3431
+ p0Attributes.prevPosition.values.push(
3432
+ prevPositions[i0 * 3],
3433
+ prevPositions[i0 * 3 + 1],
3434
+ prevPositions[i0 * 3 + 2]
3435
+ );
3436
+ p0Attributes.prevPosition.values.push(
3437
+ prevPositions[i0 * 3 + 3],
3438
+ prevPositions[i0 * 3 + 4],
3439
+ prevPositions[i0 * 3 + 5]
3440
+ );
3441
+ p0Attributes.prevPosition.values.push(p0.x, p0.y, p0.z, p0.x, p0.y, p0.z);
3442
+
3443
+ p0Attributes.nextPosition.values.push(
3444
+ offsetPoint.x,
3445
+ offsetPoint.y,
3446
+ offsetPoint.z
3447
+ );
3448
+ p0Attributes.nextPosition.values.push(
3449
+ offsetPoint.x,
3450
+ offsetPoint.y,
3451
+ offsetPoint.z
3452
+ );
3453
+ p0Attributes.nextPosition.values.push(
3454
+ offsetPoint.x,
3455
+ offsetPoint.y,
3456
+ offsetPoint.z
3457
+ );
3458
+ p0Attributes.nextPosition.values.push(
3459
+ offsetPoint.x,
3460
+ offsetPoint.y,
3461
+ offsetPoint.z
3462
+ );
3463
+
3464
+ Matrix3.Cartesian3.negate(offset, offset);
3465
+ Matrix3.Cartesian3.add(intersection, offset, offsetPoint);
3466
+ p2Attributes.position.values.push(
3467
+ offsetPoint.x,
3468
+ offsetPoint.y,
3469
+ offsetPoint.z
3470
+ );
3471
+ p2Attributes.position.values.push(
3472
+ offsetPoint.x,
3473
+ offsetPoint.y,
3474
+ offsetPoint.z
3475
+ );
3476
+ p2Attributes.position.values.push(p2.x, p2.y, p2.z, p2.x, p2.y, p2.z);
3477
+
3478
+ p2Attributes.prevPosition.values.push(
3479
+ offsetPoint.x,
3480
+ offsetPoint.y,
3481
+ offsetPoint.z
3482
+ );
3483
+ p2Attributes.prevPosition.values.push(
3484
+ offsetPoint.x,
3485
+ offsetPoint.y,
3486
+ offsetPoint.z
3487
+ );
3488
+ p2Attributes.prevPosition.values.push(
3489
+ offsetPoint.x,
3490
+ offsetPoint.y,
3491
+ offsetPoint.z
3492
+ );
3493
+ p2Attributes.prevPosition.values.push(
3494
+ offsetPoint.x,
3495
+ offsetPoint.y,
3496
+ offsetPoint.z
3497
+ );
3498
+
3499
+ p2Attributes.nextPosition.values.push(p2.x, p2.y, p2.z, p2.x, p2.y, p2.z);
3500
+ p2Attributes.nextPosition.values.push(
3501
+ nextPositions[i2 * 3],
3502
+ nextPositions[i2 * 3 + 1],
3503
+ nextPositions[i2 * 3 + 2]
3504
+ );
3505
+ p2Attributes.nextPosition.values.push(
3506
+ nextPositions[i2 * 3 + 3],
3507
+ nextPositions[i2 * 3 + 4],
3508
+ nextPositions[i2 * 3 + 5]
3509
+ );
3510
+
3511
+ const ew0 = Matrix2.Cartesian2.fromArray(
3512
+ expandAndWidths,
3513
+ i0 * 2,
3514
+ cartesian2Scratch0
3515
+ );
3516
+ const width = Math.abs(ew0.y);
3517
+
3518
+ p0Attributes.expandAndWidth.values.push(-1, width, 1, width);
3519
+ p0Attributes.expandAndWidth.values.push(-1, -width, 1, -width);
3520
+ p2Attributes.expandAndWidth.values.push(-1, width, 1, width);
3521
+ p2Attributes.expandAndWidth.values.push(-1, -width, 1, -width);
3522
+
3523
+ let t = Matrix3.Cartesian3.magnitudeSquared(
3524
+ Matrix3.Cartesian3.subtract(intersection, p0, cartesian3Scratch3)
3525
+ );
3526
+ t /= Matrix3.Cartesian3.magnitudeSquared(
3527
+ Matrix3.Cartesian3.subtract(p2, p0, cartesian3Scratch3)
3528
+ );
3529
+
3530
+ if (defaultValue.defined(colors)) {
3531
+ const c0 = Matrix2.Cartesian4.fromArray(colors, i0 * 4, cartesian4Scratch0);
3532
+ const c2 = Matrix2.Cartesian4.fromArray(colors, i2 * 4, cartesian4Scratch0);
3533
+
3534
+ const r = Math$1.CesiumMath.lerp(c0.x, c2.x, t);
3535
+ const g = Math$1.CesiumMath.lerp(c0.y, c2.y, t);
3536
+ const b = Math$1.CesiumMath.lerp(c0.z, c2.z, t);
3537
+ const a = Math$1.CesiumMath.lerp(c0.w, c2.w, t);
3538
+
3539
+ for (j = i0 * 4; j < i0 * 4 + 2 * 4; ++j) {
3540
+ p0Attributes.color.values.push(colors[j]);
3541
+ }
3542
+ p0Attributes.color.values.push(r, g, b, a);
3543
+ p0Attributes.color.values.push(r, g, b, a);
3544
+ p2Attributes.color.values.push(r, g, b, a);
3545
+ p2Attributes.color.values.push(r, g, b, a);
3546
+ for (j = i2 * 4; j < i2 * 4 + 2 * 4; ++j) {
3547
+ p2Attributes.color.values.push(colors[j]);
3548
+ }
3549
+ }
3550
+
3551
+ if (defaultValue.defined(texCoords)) {
3552
+ const s0 = Matrix2.Cartesian2.fromArray(texCoords, i0 * 2, cartesian2Scratch0);
3553
+ const s3 = Matrix2.Cartesian2.fromArray(
3554
+ texCoords,
3555
+ (i + 3) * 2,
3556
+ cartesian2Scratch1
3557
+ );
3558
+
3559
+ const sx = Math$1.CesiumMath.lerp(s0.x, s3.x, t);
3560
+
3561
+ for (j = i0 * 2; j < i0 * 2 + 2 * 2; ++j) {
3562
+ p0Attributes.st.values.push(texCoords[j]);
3563
+ }
3564
+ p0Attributes.st.values.push(sx, s0.y);
3565
+ p0Attributes.st.values.push(sx, s3.y);
3566
+ p2Attributes.st.values.push(sx, s0.y);
3567
+ p2Attributes.st.values.push(sx, s3.y);
3568
+ for (j = i2 * 2; j < i2 * 2 + 2 * 2; ++j) {
3569
+ p2Attributes.st.values.push(texCoords[j]);
3570
+ }
3571
+ }
3572
+
3573
+ index = p0Attributes.position.values.length / 3 - 4;
3574
+ p0Indices.push(index, index + 2, index + 1);
3575
+ p0Indices.push(index + 1, index + 2, index + 3);
3576
+
3577
+ index = p2Attributes.position.values.length / 3 - 4;
3578
+ p2Indices.push(index, index + 2, index + 1);
3579
+ p2Indices.push(index + 1, index + 2, index + 3);
3580
+ } else {
3581
+ let currentAttributes;
3582
+ let currentIndices;
3583
+
3584
+ if (p0.y < 0.0) {
3585
+ currentAttributes = westGeometry.attributes;
3586
+ currentIndices = westGeometry.indices;
3587
+ } else {
3588
+ currentAttributes = eastGeometry.attributes;
3589
+ currentIndices = eastGeometry.indices;
3590
+ }
3591
+
3592
+ currentAttributes.position.values.push(p0.x, p0.y, p0.z);
3593
+ currentAttributes.position.values.push(p0.x, p0.y, p0.z);
3594
+ currentAttributes.position.values.push(p2.x, p2.y, p2.z);
3595
+ currentAttributes.position.values.push(p2.x, p2.y, p2.z);
3596
+
3597
+ for (j = i * 3; j < i * 3 + 4 * 3; ++j) {
3598
+ currentAttributes.prevPosition.values.push(prevPositions[j]);
3599
+ currentAttributes.nextPosition.values.push(nextPositions[j]);
3600
+ }
3601
+
3602
+ for (j = i * 2; j < i * 2 + 4 * 2; ++j) {
3603
+ currentAttributes.expandAndWidth.values.push(expandAndWidths[j]);
3604
+ if (defaultValue.defined(texCoords)) {
3605
+ currentAttributes.st.values.push(texCoords[j]);
3606
+ }
3607
+ }
3608
+
3609
+ if (defaultValue.defined(colors)) {
3610
+ for (j = i * 4; j < i * 4 + 4 * 4; ++j) {
3611
+ currentAttributes.color.values.push(colors[j]);
3612
+ }
3613
+ }
3614
+
3615
+ index = currentAttributes.position.values.length / 3 - 4;
3616
+ currentIndices.push(index, index + 2, index + 1);
3617
+ currentIndices.push(index + 1, index + 2, index + 3);
3618
+ }
3619
+ }
3620
+
3621
+ if (intersectionFound) {
3622
+ updateAdjacencyAfterSplit(westGeometry);
3623
+ updateAdjacencyAfterSplit(eastGeometry);
3624
+ }
3625
+
3626
+ updateInstanceAfterSplit(instance, westGeometry, eastGeometry);
3627
+ }
3628
+
3629
+ /**
3630
+ * Splits the instances's geometry, by introducing new vertices and indices,that
3631
+ * intersect the International Date Line and Prime Meridian so that no primitives cross longitude
3632
+ * -180/180 degrees. This is not required for 3D drawing, but is required for
3633
+ * correcting drawing in 2D and Columbus view.
3634
+ *
3635
+ * @private
3636
+ *
3637
+ * @param {GeometryInstance} instance The instance to modify.
3638
+ * @returns {GeometryInstance} The modified <code>instance</code> argument, with it's geometry split at the International Date Line.
3639
+ *
3640
+ * @example
3641
+ * instance = Cesium.GeometryPipeline.splitLongitude(instance);
3642
+ */
3643
+ GeometryPipeline.splitLongitude = function (instance) {
3644
+ //>>includeStart('debug', pragmas.debug);
3645
+ if (!defaultValue.defined(instance)) {
3646
+ throw new Check.DeveloperError("instance is required.");
3647
+ }
3648
+ //>>includeEnd('debug');
3649
+
3650
+ const geometry = instance.geometry;
3651
+ const boundingSphere = geometry.boundingSphere;
3652
+ if (defaultValue.defined(boundingSphere)) {
3653
+ const minX = boundingSphere.center.x - boundingSphere.radius;
3654
+ if (
3655
+ minX > 0 ||
3656
+ Transforms.BoundingSphere.intersectPlane(boundingSphere, Plane.Plane.ORIGIN_ZX_PLANE) !==
3657
+ Transforms.Intersect.INTERSECTING
3658
+ ) {
3659
+ return instance;
3660
+ }
3661
+ }
3662
+
3663
+ if (geometry.geometryType !== GeometryAttribute.GeometryType.NONE) {
3664
+ switch (geometry.geometryType) {
3665
+ case GeometryAttribute.GeometryType.POLYLINES:
3666
+ splitLongitudePolyline(instance);
3667
+ break;
3668
+ case GeometryAttribute.GeometryType.TRIANGLES:
3669
+ splitLongitudeTriangles(instance);
3670
+ break;
3671
+ case GeometryAttribute.GeometryType.LINES:
3672
+ splitLongitudeLines(instance);
3673
+ break;
3674
+ }
3675
+ } else {
3676
+ indexPrimitive(geometry);
3677
+ if (geometry.primitiveType === GeometryAttribute.PrimitiveType.TRIANGLES) {
3678
+ splitLongitudeTriangles(instance);
3679
+ } else if (geometry.primitiveType === GeometryAttribute.PrimitiveType.LINES) {
3680
+ splitLongitudeLines(instance);
3681
+ }
3682
+ }
3683
+
3684
+ return instance;
3685
+ };
3686
+ var GeometryPipeline$1 = GeometryPipeline;
3687
+
3688
+ exports.GeometryPipeline = GeometryPipeline$1;
3689
+
3690
+ }));