@cesium/engine 26.2.0 → 26.3.1-wasm.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (393) hide show
  1. package/Build/ThirdParty/Workers/zip-web-worker.js +707 -600
  2. package/Build/Workers/chunk-2P3WKV6V.js +290 -0
  3. package/Build/Workers/{chunk-M6QKXVAU.js → chunk-2U5272QU.js} +17 -17
  4. package/Build/Workers/{chunk-NEFDMMLY.js → chunk-4KCOC6OZ.js} +8 -10
  5. package/Build/Workers/{chunk-SJYSIOEM.js → chunk-5FULJNWY.js} +11 -13
  6. package/Build/Workers/{chunk-NCL22ZUX.js → chunk-65ZF23AQ.js} +1 -1
  7. package/Build/Workers/{chunk-KP5QD7WU.js → chunk-6D5534B7.js} +10 -12
  8. package/Build/Workers/{chunk-FX3VEAIU.js → chunk-6GFMBHBD.js} +19 -19
  9. package/Build/Workers/{chunk-A62YI6S6.js → chunk-6VRGQF3D.js} +4 -4
  10. package/Build/Workers/{chunk-DSGLDRTI.js → chunk-6XUIECFB.js} +4 -6
  11. package/Build/Workers/{chunk-HDL4HOXZ.js → chunk-7KWUH6RK.js} +14 -14
  12. package/Build/Workers/{chunk-UAZUP4I5.js → chunk-7ZBJRQQT.js} +7 -7
  13. package/Build/Workers/{chunk-CRCGE4J4.js → chunk-AEHANE5A.js} +991 -5612
  14. package/Build/Workers/chunk-AUU74SIZ.js +2420 -0
  15. package/Build/Workers/{chunk-ARZICEEP.js → chunk-B6V5NMIE.js} +13 -11
  16. package/Build/Workers/{chunk-76FDC45O.js → chunk-BRQ52ASU.js} +15 -17
  17. package/Build/Workers/{chunk-SA2A2AN5.js → chunk-FVLSQBPH.js} +7 -14
  18. package/Build/Workers/{chunk-CUTRKXUQ.js → chunk-IFKM2GZR.js} +12 -12
  19. package/Build/Workers/{chunk-NSKZ6SBK.js → chunk-KF6OEWVT.js} +17 -17
  20. package/Build/Workers/{chunk-O3DKEX7Q.js → chunk-KOAXSU77.js} +5 -7
  21. package/Build/Workers/{chunk-2Z4ZLVOD.js → chunk-KRVYCMGN.js} +6 -6
  22. package/Build/Workers/{chunk-SXSP3JHS.js → chunk-LTZRLNQP.js} +1 -1
  23. package/Build/Workers/{chunk-6FZDPMTO.js → chunk-M7WEAGWT.js} +8 -8
  24. package/Build/Workers/{chunk-NXGQBQWE.js → chunk-MJTLGN63.js} +14 -14
  25. package/Build/Workers/{chunk-XCBZVTIV.js → chunk-MUNZ77KV.js} +1 -1
  26. package/Build/Workers/{chunk-NLLCQBX3.js → chunk-NC5BUJEF.js} +2 -2
  27. package/Build/Workers/chunk-NYKURYFR.js +2131 -0
  28. package/Build/Workers/{chunk-5LSOO2KD.js → chunk-NZAQG57U.js} +7 -7
  29. package/Build/Workers/{chunk-DZUFEE4L.js → chunk-O5GUOP2G.js} +5 -7
  30. package/Build/Workers/{chunk-D6AY775A.js → chunk-OQUOLQTN.js} +8 -10
  31. package/Build/Workers/{chunk-CDJDJ5LK.js → chunk-OUG5JB2K.js} +16 -14
  32. package/Build/Workers/{chunk-ACTVJHSP.js → chunk-P4SDLSGF.js} +13 -6
  33. package/Build/Workers/{chunk-MAAHFYPC.js → chunk-P6PC2OIM.js} +7 -7
  34. package/Build/Workers/{chunk-6YR6JBMY.js → chunk-PPRK3XQU.js} +31 -35
  35. package/Build/Workers/{chunk-IMBVP57H.js → chunk-QGTYLWOT.js} +2 -2
  36. package/Build/Workers/{chunk-FCP2QY4G.js → chunk-QHTLIQUH.js} +5 -7
  37. package/Build/Workers/{chunk-EZGQPOIG.js → chunk-ROHWZQZ5.js} +5 -5
  38. package/Build/Workers/{chunk-B3QHNA4A.js → chunk-SNUWISJO.js} +6 -8
  39. package/Build/Workers/{chunk-XDWCTQCZ.js → chunk-T67YY3KP.js} +4 -2
  40. package/Build/Workers/{chunk-IJZJMIUY.js → chunk-TF5473GK.js} +13 -13
  41. package/Build/Workers/{chunk-OZGPS7FB.js → chunk-THHFTMAL.js} +4 -6
  42. package/Build/Workers/{chunk-PRWUMCXF.js → chunk-UFCZ62WM.js} +15 -13
  43. package/Build/Workers/{chunk-27FWRTJI.js → chunk-UV2YC2Q5.js} +11 -11
  44. package/Build/Workers/{chunk-N7CCOFLX.js → chunk-V4ICCWYA.js} +1 -1
  45. package/Build/Workers/{chunk-GHXVQVUM.js → chunk-VC6XXI2Z.js} +9 -9
  46. package/Build/Workers/{chunk-I74ZH5LK.js → chunk-VXJ6P4UI.js} +10 -10
  47. package/Build/Workers/{chunk-KGXSYGBG.js → chunk-W2BKP7G7.js} +15 -17
  48. package/Build/Workers/{chunk-LDRQSYBN.js → chunk-WMVGNBSH.js} +2 -2
  49. package/Build/Workers/{chunk-SMTGMFBL.js → chunk-XFZMQZSZ.js} +4 -4
  50. package/Build/Workers/{chunk-7MM3N2VE.js → chunk-XJ532R6R.js} +20 -20
  51. package/Build/Workers/{chunk-NJVBJG63.js → chunk-YJNU4SM4.js} +5 -5
  52. package/Build/Workers/{chunk-DIGUUD6G.js → chunk-YJRDTEHQ.js} +8 -8
  53. package/Build/Workers/chunk-YUICDZKO.js +2660 -0
  54. package/Build/Workers/{chunk-O3XFXGPZ.js → chunk-Z3DEVGJV.js} +7 -7
  55. package/Build/Workers/{chunk-3PSS3T43.js → chunk-ZECGI7UZ.js} +4 -4
  56. package/Build/Workers/{chunk-QFSSCLLZ.js → chunk-ZFLPVPUJ.js} +6 -8
  57. package/Build/Workers/{chunk-2RGJPWQX.js → chunk-ZIM5H2DB.js} +11 -11
  58. package/Build/Workers/{chunk-GVA7XQI2.js → chunk-ZSQMGGSB.js} +14 -16
  59. package/Build/Workers/{chunk-FU4BGABC.js → chunk-ZWYRGMBK.js} +16 -18
  60. package/Build/Workers/{chunk-JKXV6PG5.js → chunk-ZY733NZA.js} +1 -1
  61. package/Build/Workers/combineGeometry.js +24 -24
  62. package/Build/Workers/createBoxGeometry.js +18 -18
  63. package/Build/Workers/createBoxOutlineGeometry.js +20 -19
  64. package/Build/Workers/createCircleGeometry.js +28 -27
  65. package/Build/Workers/createCircleOutlineGeometry.js +21 -20
  66. package/Build/Workers/createCoplanarPolygonGeometry.js +34 -34
  67. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +33 -32
  68. package/Build/Workers/createCorridorGeometry.js +31 -31
  69. package/Build/Workers/createCorridorOutlineGeometry.js +30 -30
  70. package/Build/Workers/createCylinderGeometry.js +20 -20
  71. package/Build/Workers/createCylinderOutlineGeometry.js +22 -21
  72. package/Build/Workers/createEllipseGeometry.js +26 -26
  73. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  74. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  75. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  76. package/Build/Workers/createFrustumGeometry.js +18 -18
  77. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  78. package/Build/Workers/createGeometry.js +27 -26
  79. package/Build/Workers/createGroundPolylineGeometry.js +27 -26
  80. package/Build/Workers/createPlaneGeometry.js +18 -17
  81. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  82. package/Build/Workers/createPolygonGeometry.js +35 -35
  83. package/Build/Workers/createPolygonOutlineGeometry.js +34 -34
  84. package/Build/Workers/createPolylineGeometry.js +28 -29
  85. package/Build/Workers/createPolylineVolumeGeometry.js +34 -35
  86. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +30 -31
  87. package/Build/Workers/createRectangleGeometry.js +30 -30
  88. package/Build/Workers/createRectangleOutlineGeometry.js +23 -24
  89. package/Build/Workers/createSimplePolylineGeometry.js +26 -27
  90. package/Build/Workers/createSphereGeometry.js +19 -19
  91. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  92. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  93. package/Build/Workers/createVectorTileClampedPolylines.js +17 -16
  94. package/Build/Workers/createVectorTileGeometries.js +24 -24
  95. package/Build/Workers/createVectorTilePoints.js +13 -13
  96. package/Build/Workers/createVectorTilePolygons.js +22 -22
  97. package/Build/Workers/createVectorTilePolylines.js +17 -16
  98. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +36 -26
  99. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +24 -24
  100. package/Build/Workers/createVerticesFromHeightmap.js +24 -25
  101. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  102. package/Build/Workers/createWallGeometry.js +27 -28
  103. package/Build/Workers/createWallOutlineGeometry.js +26 -27
  104. package/Build/Workers/decodeDraco.js +16 -12
  105. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +336 -337
  106. package/Build/Workers/decodeI3S.js +17 -12
  107. package/Build/Workers/{chunk-GXWQZBAI.js → decodeMeshopt.js} +23 -29
  108. package/Build/Workers/decodeSpz.js +1960 -0
  109. package/Build/Workers/gaussianSplatSorter.js +13 -6
  110. package/Build/Workers/gaussianSplatTextureGenerator.js +13 -6
  111. package/Build/Workers/incrementallyBuildTerrainPicker.js +9 -10
  112. package/Build/Workers/transcodeKTX2.js +26 -12
  113. package/Build/Workers/transferTypedArrayTest.js +1 -1
  114. package/Build/Workers/upsampleQuantizedTerrainMesh.js +24 -24
  115. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  116. package/Source/Core/Cesium3DTilesTerrainData.js +11 -1
  117. package/Source/Core/Cesium3DTilesTerrainGeometryProcessor.js +33 -23
  118. package/Source/Core/Ion.js +1 -1
  119. package/Source/Core/IonResource.js +5 -0
  120. package/Source/Core/IonSnapGeometryType.js +59 -0
  121. package/Source/Core/IonSnapHeat.js +33 -0
  122. package/Source/Core/IonSnapMode.js +45 -0
  123. package/Source/Core/IonSnapParentGeometryType.js +52 -0
  124. package/Source/Core/IonSnapService.js +369 -0
  125. package/Source/Core/KTX2Transcoder.js +99 -5
  126. package/Source/Core/Resource.js +2 -0
  127. package/Source/Core/SnapService.js +63 -0
  128. package/Source/Core/TaskProcessor.js +249 -129
  129. package/Source/Core/TrustedServers.js +34 -1
  130. package/Source/Core/VectorPipeline.js +139 -45
  131. package/Source/Core/VectorProvider.js +311 -71
  132. package/Source/Core/WebAssemblyWorkerInitializer.js +125 -0
  133. package/Source/Core/fetchWebAssemblyBinary.js +52 -0
  134. package/Source/Renderer/AutomaticUniforms.js +44 -2
  135. package/Source/Renderer/ShaderBuilder.js +1 -1
  136. package/Source/Renderer/UniformState.js +47 -1
  137. package/Source/Scene/ArcGisMapService.js +1 -1
  138. package/Source/Scene/BufferPointCollection.js +4 -7
  139. package/Source/Scene/BufferPolygonCollection.js +56 -27
  140. package/Source/Scene/BufferPolylineCollection.js +61 -8
  141. package/Source/Scene/BufferPolylineMaterial.js +6 -5
  142. package/Source/Scene/BufferPrimitiveCollection.js +199 -29
  143. package/Source/Scene/Cesium3DTile.js +12 -0
  144. package/Source/Scene/Cesium3DTileset.js +61 -8
  145. package/Source/Scene/Cesium3DTilesetBaseTraversal.js +15 -3
  146. package/Source/Scene/Cesium3DTilesetCache.js +15 -0
  147. package/Source/Scene/ClippingPolygon.js +154 -100
  148. package/Source/Scene/ClippingPolygonCollection.js +352 -694
  149. package/Source/Scene/CreditDisplay.js +62 -0
  150. package/Source/Scene/GaussianSplatPrimitive.js +153 -66
  151. package/Source/Scene/GeoJsonPrimitive.js +114 -24
  152. package/Source/Scene/GlobeSurfaceShaderSet.js +33 -54
  153. package/Source/Scene/GlobeSurfaceTile.js +14 -1
  154. package/Source/Scene/GlobeSurfaceTileProvider.js +232 -25
  155. package/Source/Scene/GltfBufferViewLoader.js +25 -13
  156. package/Source/Scene/GltfLoader.js +56 -6
  157. package/Source/Scene/GltfSpzLoader.js +5 -4
  158. package/Source/Scene/HeightReference.js +1 -1
  159. package/Source/Scene/MVTDataProvider.js +9 -0
  160. package/Source/Scene/Model/Model.js +242 -16
  161. package/Source/Scene/Model/Model3DTileContent.js +5 -0
  162. package/Source/Scene/Model/ModelClippingPolygonsPipelineStage.js +54 -19
  163. package/Source/Scene/Model/ModelRenderResources.js +2 -3
  164. package/Source/Scene/Model/ModelSceneGraph.js +10 -1
  165. package/Source/Scene/Model/ModelVectorLookupPipelineStage.js +205 -0
  166. package/Source/Scene/Model/PickingPipelineStage.js +4 -0
  167. package/Source/Scene/PostProcessStage.js +22 -3
  168. package/Source/Scene/Scene.js +56 -1
  169. package/Source/Scene/Snapping.js +57 -0
  170. package/Source/Scene/SpzDecoder.js +106 -0
  171. package/Source/Scene/UrlTemplate3DTilesDataProvider.js +12 -1
  172. package/Source/Scene/VectorGltf3DTileContent.js +10 -2
  173. package/Source/Scene/WebMapServiceImageryProvider.js +5 -1
  174. package/Source/Scene/WebMapTileServiceImageryProvider.js +6 -1
  175. package/Source/Scene/renderBufferPolylineCollection.js +5 -1
  176. package/Source/Shaders/BufferPolylineMaterialVS.glsl +14 -2
  177. package/Source/Shaders/BufferPolylineMaterialVS.js +14 -2
  178. package/Source/Shaders/Builtin/CzmBuiltins.js +2 -4
  179. package/Source/Shaders/Builtin/Functions/eyeToCartographicDelta.glsl +74 -0
  180. package/Source/Shaders/Builtin/Functions/eyeToCartographicDelta.js +76 -0
  181. package/Source/Shaders/GlobeFS.glsl +10 -9
  182. package/Source/Shaders/GlobeFS.js +11 -9
  183. package/Source/Shaders/GlobeVS.glsl +0 -32
  184. package/Source/Shaders/GlobeVS.js +0 -32
  185. package/Source/Shaders/Model/ModelClippingPolygonsStageFS.glsl +15 -3
  186. package/Source/Shaders/Model/ModelClippingPolygonsStageFS.js +15 -3
  187. package/Source/Shaders/Model/ModelClippingPolygonsStageVS.glsl +20 -24
  188. package/Source/Shaders/Model/ModelClippingPolygonsStageVS.js +20 -24
  189. package/Source/Shaders/Model/ModelFS.glsl +4 -0
  190. package/Source/Shaders/Model/ModelFS.js +4 -0
  191. package/Source/Shaders/Model/ModelVS.glsl +7 -2
  192. package/Source/Shaders/Model/ModelVS.js +7 -2
  193. package/Source/Shaders/Model/ModelVectorLookupStageFS.glsl +6 -0
  194. package/Source/Shaders/Model/ModelVectorLookupStageFS.js +8 -0
  195. package/Source/Shaders/Model/ModelVectorLookupStageVS.glsl +15 -0
  196. package/Source/Shaders/Model/ModelVectorLookupStageVS.js +17 -0
  197. package/Source/Shaders/Model/VerticalExaggerationStageVS.glsl +9 -10
  198. package/Source/Shaders/Model/VerticalExaggerationStageVS.js +9 -11
  199. package/Source/Shaders/VectorCommon.glsl +177 -50
  200. package/Source/Shaders/VectorCommon.js +251 -19
  201. package/Source/ThirdParty/Workers/zip-web-worker.js +1 -1
  202. package/Source/ThirdParty/zip-module.wasm +0 -0
  203. package/Source/Workers/createTaskProcessorWorker.js +2 -0
  204. package/Source/Workers/createVerticesFromCesium3DTilesTerrain.js +13 -1
  205. package/Source/Workers/decodeDraco.js +7 -3
  206. package/Source/Workers/decodeI3S.js +7 -3
  207. package/Source/Workers/decodeMeshopt.js +21 -0
  208. package/Source/Workers/decodeSpz.js +20 -0
  209. package/Source/Workers/gaussianSplatSorter.js +7 -3
  210. package/Source/Workers/gaussianSplatTextureGenerator.js +7 -3
  211. package/Source/Workers/transcodeKTX2.js +22 -5
  212. package/index.d.ts +649 -55
  213. package/index.js +23 -13
  214. package/package.json +6 -6
  215. package/Build/Workers/chunk-2EFYUSUY.js +0 -1483
  216. package/Build/Workers/chunk-2H5264K7.js +0 -1284
  217. package/Build/Workers/chunk-2H73KDBM.js +0 -511
  218. package/Build/Workers/chunk-2ZKH2QZB.js +0 -387
  219. package/Build/Workers/chunk-36NI5E6W.js +0 -3820
  220. package/Build/Workers/chunk-37SW7SYS.js +0 -778
  221. package/Build/Workers/chunk-3GHVJ3SO.js +0 -455
  222. package/Build/Workers/chunk-3LB4UVPU.js +0 -387
  223. package/Build/Workers/chunk-3PONLKEL.js +0 -778
  224. package/Build/Workers/chunk-3QR662HH.js +0 -3820
  225. package/Build/Workers/chunk-3SX2WYSO.js +0 -973
  226. package/Build/Workers/chunk-3UDN6LYX.js +0 -476
  227. package/Build/Workers/chunk-47MCBSXI.js +0 -9237
  228. package/Build/Workers/chunk-4E626OCE.js +0 -1067
  229. package/Build/Workers/chunk-4NW2MJKH.js +0 -455
  230. package/Build/Workers/chunk-52YK5BSN.js +0 -198
  231. package/Build/Workers/chunk-5RNAQZK6.js +0 -9234
  232. package/Build/Workers/chunk-5YPQBFRD.js +0 -519
  233. package/Build/Workers/chunk-6FHT43QR.js +0 -140
  234. package/Build/Workers/chunk-6HK6IXK2.js +0 -138
  235. package/Build/Workers/chunk-6R5X2GUA.js +0 -1284
  236. package/Build/Workers/chunk-7A2OGDHT.js +0 -305
  237. package/Build/Workers/chunk-7CGEQUM2.js +0 -305
  238. package/Build/Workers/chunk-7D2HZKH7.js +0 -455
  239. package/Build/Workers/chunk-7I325HV6.js +0 -1344
  240. package/Build/Workers/chunk-7KVKHY7O.js +0 -147
  241. package/Build/Workers/chunk-7TKLTCZW.js +0 -219
  242. package/Build/Workers/chunk-7UUKBDH6.js +0 -1054
  243. package/Build/Workers/chunk-7W6DUHAB.js +0 -693
  244. package/Build/Workers/chunk-7XM5JK5F.js +0 -162
  245. package/Build/Workers/chunk-7YG3ND3P.js +0 -454
  246. package/Build/Workers/chunk-A3O6EDBK.js +0 -73
  247. package/Build/Workers/chunk-A6X24AZI.js +0 -1992
  248. package/Build/Workers/chunk-A7TTWVTF.js +0 -2719
  249. package/Build/Workers/chunk-ADX3CBKD.js +0 -9234
  250. package/Build/Workers/chunk-AF7DTMJ7.js +0 -398
  251. package/Build/Workers/chunk-AHWAZRBV.js +0 -82
  252. package/Build/Workers/chunk-AJSFRY4U.js +0 -1344
  253. package/Build/Workers/chunk-B4CQSLZJ.js +0 -305
  254. package/Build/Workers/chunk-BKPQFCXH.js +0 -511
  255. package/Build/Workers/chunk-BSPCI2LO.js +0 -959
  256. package/Build/Workers/chunk-BUJWSX5S.js +0 -301
  257. package/Build/Workers/chunk-C7JQVRLM.js +0 -497
  258. package/Build/Workers/chunk-C7QDUNI3.js +0 -138
  259. package/Build/Workers/chunk-CEEZE3YZ.js +0 -476
  260. package/Build/Workers/chunk-CIV5DJOQ.js +0 -778
  261. package/Build/Workers/chunk-CLCTQVVL.js +0 -241
  262. package/Build/Workers/chunk-CQNFIAZU.js +0 -56
  263. package/Build/Workers/chunk-DBD5WWG2.js +0 -959
  264. package/Build/Workers/chunk-DZBQUULR.js +0 -138
  265. package/Build/Workers/chunk-E2NKV5YT.js +0 -3820
  266. package/Build/Workers/chunk-E7NZJOK7.js +0 -3792
  267. package/Build/Workers/chunk-EB3Y5P3A.js +0 -368
  268. package/Build/Workers/chunk-EHTS2YPT.js +0 -2719
  269. package/Build/Workers/chunk-ELE6SC2C.js +0 -837
  270. package/Build/Workers/chunk-ENNFMWDW.js +0 -789
  271. package/Build/Workers/chunk-EOWDZN5S.js +0 -288
  272. package/Build/Workers/chunk-ERKUET22.js +0 -3201
  273. package/Build/Workers/chunk-F2IMBMZY.js +0 -241
  274. package/Build/Workers/chunk-F4CSNRZO.js +0 -219
  275. package/Build/Workers/chunk-FBP4DUQJ.js +0 -693
  276. package/Build/Workers/chunk-FDK4K5IA.js +0 -280
  277. package/Build/Workers/chunk-FGQFQHN5.js +0 -1054
  278. package/Build/Workers/chunk-FJWZMGOQ.js +0 -1992
  279. package/Build/Workers/chunk-FQ42MT7M.js +0 -58
  280. package/Build/Workers/chunk-GGNWQWSB.js +0 -301
  281. package/Build/Workers/chunk-GNKXEN4C.js +0 -682
  282. package/Build/Workers/chunk-GSWMAFTE.js +0 -9230
  283. package/Build/Workers/chunk-GXDHRC4J.js +0 -1344
  284. package/Build/Workers/chunk-GYSYP6PC.js +0 -1067
  285. package/Build/Workers/chunk-H2WCFXLP.js +0 -241
  286. package/Build/Workers/chunk-HHV3MCGV.js +0 -162
  287. package/Build/Workers/chunk-HLW2ZRVK.js +0 -368
  288. package/Build/Workers/chunk-HS6AD4P2.js +0 -398
  289. package/Build/Workers/chunk-HT6FASOT.js +0 -973
  290. package/Build/Workers/chunk-IDVHUDZT.js +0 -352
  291. package/Build/Workers/chunk-IGAZBTFZ.js +0 -3201
  292. package/Build/Workers/chunk-ILME5BXA.js +0 -301
  293. package/Build/Workers/chunk-IOO7Z2AV.js +0 -57
  294. package/Build/Workers/chunk-IUIFLOYO.js +0 -44
  295. package/Build/Workers/chunk-J73T2VOY.js +0 -171
  296. package/Build/Workers/chunk-JALGQYDY.js +0 -288
  297. package/Build/Workers/chunk-JW6OZT4R.js +0 -288
  298. package/Build/Workers/chunk-JXYLJCTC.js +0 -124
  299. package/Build/Workers/chunk-K27QOAW6.js +0 -97
  300. package/Build/Workers/chunk-KMV25A63.js +0 -789
  301. package/Build/Workers/chunk-KZWFWJML.js +0 -2719
  302. package/Build/Workers/chunk-LCXRRALY.js +0 -387
  303. package/Build/Workers/chunk-LD64RPYV.js +0 -368
  304. package/Build/Workers/chunk-LGNDTZVX.js +0 -97
  305. package/Build/Workers/chunk-LNSQVXFH.js +0 -1800
  306. package/Build/Workers/chunk-M4JZ6TSZ.js +0 -959
  307. package/Build/Workers/chunk-MCJDRDJQ.js +0 -102
  308. package/Build/Workers/chunk-MEENMEAH.js +0 -198
  309. package/Build/Workers/chunk-NAWU5RF4.js +0 -162
  310. package/Build/Workers/chunk-NIWITKQK.js +0 -693
  311. package/Build/Workers/chunk-OA6MYL2C.js +0 -837
  312. package/Build/Workers/chunk-OBEU25PI.js +0 -1067
  313. package/Build/Workers/chunk-OHP4ELS7.js +0 -198
  314. package/Build/Workers/chunk-PCL3Y7H5.js +0 -82
  315. package/Build/Workers/chunk-PD4GK4EM.js +0 -57
  316. package/Build/Workers/chunk-PEDU33QG.js +0 -2342
  317. package/Build/Workers/chunk-PVTSNNVI.js +0 -288
  318. package/Build/Workers/chunk-QHPZH22L.js +0 -241
  319. package/Build/Workers/chunk-QIZDWZK6.js +0 -301
  320. package/Build/Workers/chunk-QV6DG2YX.js +0 -1483
  321. package/Build/Workers/chunk-QVLAFFJY.js +0 -56
  322. package/Build/Workers/chunk-R4FPNAZ2.js +0 -352
  323. package/Build/Workers/chunk-R4K7EHOU.js +0 -171
  324. package/Build/Workers/chunk-R7JGHDD6.js +0 -789
  325. package/Build/Workers/chunk-RASQEYD4.js +0 -1483
  326. package/Build/Workers/chunk-RG4F5R57.js +0 -454
  327. package/Build/Workers/chunk-RW6ITX7Q.js +0 -3820
  328. package/Build/Workers/chunk-RYSQVJR6.js +0 -398
  329. package/Build/Workers/chunk-S6RJU5NM.js +0 -1054
  330. package/Build/Workers/chunk-SDFHDNS4.js +0 -147
  331. package/Build/Workers/chunk-SF6K72D7.js +0 -124
  332. package/Build/Workers/chunk-SGRGNDOD.js +0 -682
  333. package/Build/Workers/chunk-SM2CDCYF.js +0 -198
  334. package/Build/Workers/chunk-SS5ABQGY.js +0 -102
  335. package/Build/Workers/chunk-T5QBPLE3.js +0 -414
  336. package/Build/Workers/chunk-TN35HP5B.js +0 -1067
  337. package/Build/Workers/chunk-TNWKJNUZ.js +0 -454
  338. package/Build/Workers/chunk-TOAF47AQ.js +0 -102
  339. package/Build/Workers/chunk-TQ4QCOXT.js +0 -2719
  340. package/Build/Workers/chunk-TSDSILQB.js +0 -124
  341. package/Build/Workers/chunk-TVZD72WJ.js +0 -778
  342. package/Build/Workers/chunk-U5LV3F3Z.js +0 -1054
  343. package/Build/Workers/chunk-UEY73NRN.js +0 -38
  344. package/Build/Workers/chunk-UF46SZEZ.js +0 -789
  345. package/Build/Workers/chunk-UNRTMCET.js +0 -398
  346. package/Build/Workers/chunk-UTB7U3O6.js +0 -1992
  347. package/Build/Workers/chunk-UVO6COT2.js +0 -352
  348. package/Build/Workers/chunk-V46YGZE6.js +0 -352
  349. package/Build/Workers/chunk-VAL7DYNR.js +0 -278
  350. package/Build/Workers/chunk-VDGOCROW.js +0 -57
  351. package/Build/Workers/chunk-VFWSSBPT.js +0 -511
  352. package/Build/Workers/chunk-VVYMXI3I.js +0 -1284
  353. package/Build/Workers/chunk-VXWHPYQM.js +0 -837
  354. package/Build/Workers/chunk-VXYUBRSB.js +0 -219
  355. package/Build/Workers/chunk-VZLDLEWI.js +0 -387
  356. package/Build/Workers/chunk-W5OCKMPJ.js +0 -101
  357. package/Build/Workers/chunk-WBSY7HDY.js +0 -837
  358. package/Build/Workers/chunk-WN3F4CVG.js +0 -3201
  359. package/Build/Workers/chunk-WPRUWXGV.js +0 -693
  360. package/Build/Workers/chunk-WTO2ERBP.js +0 -414
  361. package/Build/Workers/chunk-WVHMDVG4.js +0 -959
  362. package/Build/Workers/chunk-XGA23TAX.js +0 -73
  363. package/Build/Workers/chunk-XLQZNQ4Z.js +0 -163
  364. package/Build/Workers/chunk-XLXSDIP5.js +0 -973
  365. package/Build/Workers/chunk-XQ3SKCMM.js +0 -140
  366. package/Build/Workers/chunk-XQH66YJC.js +0 -147
  367. package/Build/Workers/chunk-XTA7BXJG.js +0 -682
  368. package/Build/Workers/chunk-XTIDAFRS.js +0 -476
  369. package/Build/Workers/chunk-XUEDWBUD.js +0 -682
  370. package/Build/Workers/chunk-XYFLRH3H.js +0 -124
  371. package/Build/Workers/chunk-Y7JRTRTO.js +0 -305
  372. package/Build/Workers/chunk-Y7QSMDCJ.js +0 -352
  373. package/Build/Workers/chunk-YCB5TYTR.js +0 -1483
  374. package/Build/Workers/chunk-YEYOSTJX.js +0 -219
  375. package/Build/Workers/chunk-YGFVAGYF.js +0 -630
  376. package/Build/Workers/chunk-YIIACKQO.js +0 -368
  377. package/Build/Workers/chunk-YJGSP6PE.js +0 -511
  378. package/Build/Workers/chunk-YKU2Q3A2.js +0 -1287
  379. package/Build/Workers/chunk-Z4LR5EHE.js +0 -454
  380. package/Build/Workers/chunk-Z66EVE2A.js +0 -44
  381. package/Build/Workers/chunk-ZHIHHHTB.js +0 -414
  382. package/Build/Workers/chunk-ZMBHFYOX.js +0 -1344
  383. package/Build/Workers/chunk-ZNWHFSLE.js +0 -171
  384. package/Build/Workers/chunk-ZQLZG4IN.js +0 -2342
  385. package/Build/Workers/chunk-ZRTSMUZ2.js +0 -414
  386. package/Build/Workers/chunk-ZSGUV73H.js +0 -2342
  387. package/Build/Workers/chunk-ZZUVT5BM.js +0 -476
  388. package/Source/Shaders/Builtin/Functions/clipPolygons.glsl +0 -37
  389. package/Source/Shaders/Builtin/Functions/clipPolygons.js +0 -39
  390. package/Source/Shaders/Builtin/Functions/unpackClippingExtents.glsl +0 -14
  391. package/Source/Shaders/Builtin/Functions/unpackClippingExtents.js +0 -15
  392. package/Source/Shaders/PolygonSignedDistanceFS.glsl +0 -131
  393. package/Source/Shaders/PolygonSignedDistanceFS.js +0 -132
@@ -1,2719 +0,0 @@
1
- /**
2
- * @license
3
- * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.144.0
5
- *
6
- * Copyright 2011-2022 Cesium Contributors
7
- *
8
- * Licensed under the Apache License, Version 2.0 (the "License");
9
- * you may not use this file except in compliance with the License.
10
- * You may obtain a copy of the License at
11
- *
12
- * http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- *
20
- * Columbus View (Pat. Pend.)
21
- *
22
- * Portions licensed separately.
23
- * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
24
- */
25
-
26
- import {
27
- AttributeCompression_default
28
- } from "./chunk-TNWKJNUZ.js";
29
- import {
30
- EncodedCartesian3_default
31
- } from "./chunk-3PSS3T43.js";
32
- import {
33
- IntersectionTests_default
34
- } from "./chunk-GHXVQVUM.js";
35
- import {
36
- Plane_default
37
- } from "./chunk-R4K7EHOU.js";
38
- import {
39
- IndexDatatype_default
40
- } from "./chunk-6FHT43QR.js";
41
- import {
42
- GeometryAttribute_default,
43
- GeometryType_default,
44
- Geometry_default,
45
- PrimitiveType_default
46
- } from "./chunk-QIZDWZK6.js";
47
- import {
48
- BoundingSphere_default,
49
- GeographicProjection_default
50
- } from "./chunk-2H5264K7.js";
51
- import {
52
- Intersect_default
53
- } from "./chunk-CQNFIAZU.js";
54
- import {
55
- Cartesian4_default,
56
- Matrix4_default
57
- } from "./chunk-ERKUET22.js";
58
- import {
59
- ComponentDatatype_default
60
- } from "./chunk-DSGLDRTI.js";
61
- import {
62
- Cartesian2_default,
63
- Cartographic_default
64
- } from "./chunk-UAZUP4I5.js";
65
- import {
66
- Cartesian3_default,
67
- Frozen_default,
68
- Matrix3_default
69
- } from "./chunk-SA2A2AN5.js";
70
- import {
71
- Math_default
72
- } from "./chunk-ACTVJHSP.js";
73
- import {
74
- Check_default,
75
- DeveloperError_default
76
- } from "./chunk-XLQZNQ4Z.js";
77
- import {
78
- defined_default
79
- } from "./chunk-PCL3Y7H5.js";
80
-
81
- // packages/engine/Source/Core/barycentricCoordinates.js
82
- var scratchCartesian1 = new Cartesian3_default();
83
- var scratchCartesian2 = new Cartesian3_default();
84
- var scratchCartesian3 = new Cartesian3_default();
85
- function barycentricCoordinates(point, p0, p1, p2, result) {
86
- Check_default.defined("point", point);
87
- Check_default.defined("p0", p0);
88
- Check_default.defined("p1", p1);
89
- Check_default.defined("p2", p2);
90
- if (!defined_default(result)) {
91
- result = new Cartesian3_default();
92
- }
93
- let v02;
94
- let v12;
95
- let v22;
96
- let dot00;
97
- let dot01;
98
- let dot02;
99
- let dot11;
100
- let dot12;
101
- if (!defined_default(p0.z)) {
102
- if (Cartesian2_default.equalsEpsilon(point, p0, Math_default.EPSILON14)) {
103
- return Cartesian3_default.clone(Cartesian3_default.UNIT_X, result);
104
- }
105
- if (Cartesian2_default.equalsEpsilon(point, p1, Math_default.EPSILON14)) {
106
- return Cartesian3_default.clone(Cartesian3_default.UNIT_Y, result);
107
- }
108
- if (Cartesian2_default.equalsEpsilon(point, p2, Math_default.EPSILON14)) {
109
- return Cartesian3_default.clone(Cartesian3_default.UNIT_Z, result);
110
- }
111
- v02 = Cartesian2_default.subtract(p1, p0, scratchCartesian1);
112
- v12 = Cartesian2_default.subtract(p2, p0, scratchCartesian2);
113
- v22 = Cartesian2_default.subtract(point, p0, scratchCartesian3);
114
- dot00 = Cartesian2_default.dot(v02, v02);
115
- dot01 = Cartesian2_default.dot(v02, v12);
116
- dot02 = Cartesian2_default.dot(v02, v22);
117
- dot11 = Cartesian2_default.dot(v12, v12);
118
- dot12 = Cartesian2_default.dot(v12, v22);
119
- } else {
120
- if (Cartesian3_default.equalsEpsilon(point, p0, Math_default.EPSILON14)) {
121
- return Cartesian3_default.clone(Cartesian3_default.UNIT_X, result);
122
- }
123
- if (Cartesian3_default.equalsEpsilon(point, p1, Math_default.EPSILON14)) {
124
- return Cartesian3_default.clone(Cartesian3_default.UNIT_Y, result);
125
- }
126
- if (Cartesian3_default.equalsEpsilon(point, p2, Math_default.EPSILON14)) {
127
- return Cartesian3_default.clone(Cartesian3_default.UNIT_Z, result);
128
- }
129
- v02 = Cartesian3_default.subtract(p1, p0, scratchCartesian1);
130
- v12 = Cartesian3_default.subtract(p2, p0, scratchCartesian2);
131
- v22 = Cartesian3_default.subtract(point, p0, scratchCartesian3);
132
- dot00 = Cartesian3_default.dot(v02, v02);
133
- dot01 = Cartesian3_default.dot(v02, v12);
134
- dot02 = Cartesian3_default.dot(v02, v22);
135
- dot11 = Cartesian3_default.dot(v12, v12);
136
- dot12 = Cartesian3_default.dot(v12, v22);
137
- }
138
- result.y = dot11 * dot02 - dot01 * dot12;
139
- result.z = dot00 * dot12 - dot01 * dot02;
140
- const q = dot00 * dot11 - dot01 * dot01;
141
- if (q === 0) {
142
- return void 0;
143
- }
144
- result.y /= q;
145
- result.z /= q;
146
- result.x = 1 - result.y - result.z;
147
- return result;
148
- }
149
- var barycentricCoordinates_default = barycentricCoordinates;
150
-
151
- // packages/engine/Source/Core/Tipsify.js
152
- var Tipsify = {};
153
- Tipsify.calculateACMR = function(options) {
154
- options = options ?? Frozen_default.EMPTY_OBJECT;
155
- const indices = options.indices;
156
- let maximumIndex = options.maximumIndex;
157
- const cacheSize = options.cacheSize ?? 24;
158
- if (!defined_default(indices)) {
159
- throw new DeveloperError_default("indices is required.");
160
- }
161
- const numIndices = indices.length;
162
- if (numIndices < 3 || numIndices % 3 !== 0) {
163
- throw new DeveloperError_default("indices length must be a multiple of three.");
164
- }
165
- if (maximumIndex <= 0) {
166
- throw new DeveloperError_default("maximumIndex must be greater than zero.");
167
- }
168
- if (cacheSize < 3) {
169
- throw new DeveloperError_default("cacheSize must be greater than two.");
170
- }
171
- if (!defined_default(maximumIndex)) {
172
- maximumIndex = 0;
173
- let currentIndex = 0;
174
- let intoIndices = indices[currentIndex];
175
- while (currentIndex < numIndices) {
176
- if (intoIndices > maximumIndex) {
177
- maximumIndex = intoIndices;
178
- }
179
- ++currentIndex;
180
- intoIndices = indices[currentIndex];
181
- }
182
- }
183
- const vertexTimeStamps = [];
184
- for (let i = 0; i < maximumIndex + 1; i++) {
185
- vertexTimeStamps[i] = 0;
186
- }
187
- let s = cacheSize + 1;
188
- for (let j = 0; j < numIndices; ++j) {
189
- if (s - vertexTimeStamps[indices[j]] > cacheSize) {
190
- vertexTimeStamps[indices[j]] = s;
191
- ++s;
192
- }
193
- }
194
- return (s - cacheSize + 1) / (numIndices / 3);
195
- };
196
- Tipsify.tipsify = function(options) {
197
- options = options ?? Frozen_default.EMPTY_OBJECT;
198
- const indices = options.indices;
199
- const maximumIndex = options.maximumIndex;
200
- const cacheSize = options.cacheSize ?? 24;
201
- let cursor;
202
- function skipDeadEnd(vertices2, deadEnd2, indices2, maximumIndexPlusOne2) {
203
- while (deadEnd2.length >= 1) {
204
- const d = deadEnd2[deadEnd2.length - 1];
205
- deadEnd2.splice(deadEnd2.length - 1, 1);
206
- if (vertices2[d].numLiveTriangles > 0) {
207
- return d;
208
- }
209
- }
210
- while (cursor < maximumIndexPlusOne2) {
211
- if (vertices2[cursor].numLiveTriangles > 0) {
212
- ++cursor;
213
- return cursor - 1;
214
- }
215
- ++cursor;
216
- }
217
- return -1;
218
- }
219
- function getNextVertex(indices2, cacheSize2, oneRing2, vertices2, s2, deadEnd2, maximumIndexPlusOne2) {
220
- let n = -1;
221
- let p;
222
- let m = -1;
223
- let itOneRing = 0;
224
- while (itOneRing < oneRing2.length) {
225
- const index2 = oneRing2[itOneRing];
226
- if (vertices2[index2].numLiveTriangles) {
227
- p = 0;
228
- if (s2 - vertices2[index2].timeStamp + 2 * vertices2[index2].numLiveTriangles <= cacheSize2) {
229
- p = s2 - vertices2[index2].timeStamp;
230
- }
231
- if (p > m || m === -1) {
232
- m = p;
233
- n = index2;
234
- }
235
- }
236
- ++itOneRing;
237
- }
238
- if (n === -1) {
239
- return skipDeadEnd(vertices2, deadEnd2, indices2, maximumIndexPlusOne2);
240
- }
241
- return n;
242
- }
243
- if (!defined_default(indices)) {
244
- throw new DeveloperError_default("indices is required.");
245
- }
246
- const numIndices = indices.length;
247
- if (numIndices < 3 || numIndices % 3 !== 0) {
248
- throw new DeveloperError_default("indices length must be a multiple of three.");
249
- }
250
- if (maximumIndex <= 0) {
251
- throw new DeveloperError_default("maximumIndex must be greater than zero.");
252
- }
253
- if (cacheSize < 3) {
254
- throw new DeveloperError_default("cacheSize must be greater than two.");
255
- }
256
- let maximumIndexPlusOne = 0;
257
- let currentIndex = 0;
258
- let intoIndices = indices[currentIndex];
259
- const endIndex = numIndices;
260
- if (defined_default(maximumIndex)) {
261
- maximumIndexPlusOne = maximumIndex + 1;
262
- } else {
263
- while (currentIndex < endIndex) {
264
- if (intoIndices > maximumIndexPlusOne) {
265
- maximumIndexPlusOne = intoIndices;
266
- }
267
- ++currentIndex;
268
- intoIndices = indices[currentIndex];
269
- }
270
- if (maximumIndexPlusOne === -1) {
271
- return 0;
272
- }
273
- ++maximumIndexPlusOne;
274
- }
275
- const vertices = [];
276
- let i;
277
- for (i = 0; i < maximumIndexPlusOne; i++) {
278
- vertices[i] = {
279
- numLiveTriangles: 0,
280
- timeStamp: 0,
281
- vertexTriangles: []
282
- };
283
- }
284
- currentIndex = 0;
285
- let triangle = 0;
286
- while (currentIndex < endIndex) {
287
- vertices[indices[currentIndex]].vertexTriangles.push(triangle);
288
- ++vertices[indices[currentIndex]].numLiveTriangles;
289
- vertices[indices[currentIndex + 1]].vertexTriangles.push(triangle);
290
- ++vertices[indices[currentIndex + 1]].numLiveTriangles;
291
- vertices[indices[currentIndex + 2]].vertexTriangles.push(triangle);
292
- ++vertices[indices[currentIndex + 2]].numLiveTriangles;
293
- ++triangle;
294
- currentIndex += 3;
295
- }
296
- let f = 0;
297
- let s = cacheSize + 1;
298
- cursor = 1;
299
- let oneRing;
300
- const deadEnd = [];
301
- let vertex;
302
- let intoVertices;
303
- let currentOutputIndex = 0;
304
- const outputIndices = [];
305
- const numTriangles = numIndices / 3;
306
- const triangleEmitted = [];
307
- for (i = 0; i < numTriangles; i++) {
308
- triangleEmitted[i] = false;
309
- }
310
- let index;
311
- let limit;
312
- while (f !== -1) {
313
- oneRing = [];
314
- intoVertices = vertices[f];
315
- limit = intoVertices.vertexTriangles.length;
316
- for (let k = 0; k < limit; ++k) {
317
- triangle = intoVertices.vertexTriangles[k];
318
- if (!triangleEmitted[triangle]) {
319
- triangleEmitted[triangle] = true;
320
- currentIndex = triangle + triangle + triangle;
321
- for (let j = 0; j < 3; ++j) {
322
- index = indices[currentIndex];
323
- oneRing.push(index);
324
- deadEnd.push(index);
325
- outputIndices[currentOutputIndex] = index;
326
- ++currentOutputIndex;
327
- vertex = vertices[index];
328
- --vertex.numLiveTriangles;
329
- if (s - vertex.timeStamp > cacheSize) {
330
- vertex.timeStamp = s;
331
- ++s;
332
- }
333
- ++currentIndex;
334
- }
335
- }
336
- }
337
- f = getNextVertex(
338
- indices,
339
- cacheSize,
340
- oneRing,
341
- vertices,
342
- s,
343
- deadEnd,
344
- maximumIndexPlusOne
345
- );
346
- }
347
- return outputIndices;
348
- };
349
- var Tipsify_default = Tipsify;
350
-
351
- // packages/engine/Source/Core/GeometryPipeline.js
352
- var GeometryPipeline = {};
353
- function addTriangle(lines, index, i0, i1, i2) {
354
- lines[index++] = i0;
355
- lines[index++] = i1;
356
- lines[index++] = i1;
357
- lines[index++] = i2;
358
- lines[index++] = i2;
359
- lines[index] = i0;
360
- }
361
- function trianglesToLines(triangles) {
362
- const count = triangles.length;
363
- const size = count / 3 * 6;
364
- const lines = IndexDatatype_default.createTypedArray(count, size);
365
- let index = 0;
366
- for (let i = 0; i < count; i += 3, index += 6) {
367
- addTriangle(lines, index, triangles[i], triangles[i + 1], triangles[i + 2]);
368
- }
369
- return lines;
370
- }
371
- function triangleStripToLines(triangles) {
372
- const count = triangles.length;
373
- if (count >= 3) {
374
- const size = (count - 2) * 6;
375
- const lines = IndexDatatype_default.createTypedArray(count, size);
376
- addTriangle(lines, 0, triangles[0], triangles[1], triangles[2]);
377
- let index = 6;
378
- for (let i = 3; i < count; ++i, index += 6) {
379
- addTriangle(
380
- lines,
381
- index,
382
- triangles[i - 1],
383
- triangles[i],
384
- triangles[i - 2]
385
- );
386
- }
387
- return lines;
388
- }
389
- return new Uint16Array();
390
- }
391
- function triangleFanToLines(triangles) {
392
- if (triangles.length > 0) {
393
- const count = triangles.length - 1;
394
- const size = (count - 1) * 6;
395
- const lines = IndexDatatype_default.createTypedArray(count, size);
396
- const base = triangles[0];
397
- let index = 0;
398
- for (let i = 1; i < count; ++i, index += 6) {
399
- addTriangle(lines, index, base, triangles[i], triangles[i + 1]);
400
- }
401
- return lines;
402
- }
403
- return new Uint16Array();
404
- }
405
- GeometryPipeline.toWireframe = function(geometry) {
406
- if (!defined_default(geometry)) {
407
- throw new DeveloperError_default("geometry is required.");
408
- }
409
- const indices = geometry.indices;
410
- if (defined_default(indices)) {
411
- switch (geometry.primitiveType) {
412
- case PrimitiveType_default.TRIANGLES:
413
- geometry.indices = trianglesToLines(indices);
414
- break;
415
- case PrimitiveType_default.TRIANGLE_STRIP:
416
- geometry.indices = triangleStripToLines(indices);
417
- break;
418
- case PrimitiveType_default.TRIANGLE_FAN:
419
- geometry.indices = triangleFanToLines(indices);
420
- break;
421
- //>>includeStart('debug', pragmas.debug);
422
- default:
423
- throw new DeveloperError_default(
424
- "geometry.primitiveType must be TRIANGLES, TRIANGLE_STRIP, or TRIANGLE_FAN."
425
- );
426
- }
427
- geometry.primitiveType = PrimitiveType_default.LINES;
428
- }
429
- return geometry;
430
- };
431
- GeometryPipeline.createLineSegmentsForVectors = function(geometry, attributeName, length) {
432
- attributeName = attributeName ?? "normal";
433
- if (!defined_default(geometry)) {
434
- throw new DeveloperError_default("geometry is required.");
435
- }
436
- if (!defined_default(geometry.attributes.position)) {
437
- throw new DeveloperError_default("geometry.attributes.position is required.");
438
- }
439
- if (!defined_default(geometry.attributes[attributeName])) {
440
- throw new DeveloperError_default(
441
- `geometry.attributes must have an attribute with the same name as the attributeName parameter, ${attributeName}.`
442
- );
443
- }
444
- length = length ?? 1e4;
445
- const positions = geometry.attributes.position.values;
446
- const vectors = geometry.attributes[attributeName].values;
447
- const positionsLength = positions.length;
448
- const newPositions = new Float64Array(2 * positionsLength);
449
- let j = 0;
450
- for (let i = 0; i < positionsLength; i += 3) {
451
- newPositions[j++] = positions[i];
452
- newPositions[j++] = positions[i + 1];
453
- newPositions[j++] = positions[i + 2];
454
- newPositions[j++] = positions[i] + vectors[i] * length;
455
- newPositions[j++] = positions[i + 1] + vectors[i + 1] * length;
456
- newPositions[j++] = positions[i + 2] + vectors[i + 2] * length;
457
- }
458
- let newBoundingSphere;
459
- const bs = geometry.boundingSphere;
460
- if (defined_default(bs)) {
461
- newBoundingSphere = new BoundingSphere_default(bs.center, bs.radius + length);
462
- }
463
- return new Geometry_default({
464
- attributes: {
465
- position: new GeometryAttribute_default({
466
- componentDatatype: ComponentDatatype_default.DOUBLE,
467
- componentsPerAttribute: 3,
468
- values: newPositions
469
- })
470
- },
471
- primitiveType: PrimitiveType_default.LINES,
472
- boundingSphere: newBoundingSphere
473
- });
474
- };
475
- GeometryPipeline.createAttributeLocations = function(geometry) {
476
- if (!defined_default(geometry)) {
477
- throw new DeveloperError_default("geometry is required.");
478
- }
479
- const semantics = [
480
- "position",
481
- "positionHigh",
482
- "positionLow",
483
- // From VertexFormat.position - after 2D projection and high-precision encoding
484
- "position3DHigh",
485
- "position3DLow",
486
- "position2DHigh",
487
- "position2DLow",
488
- // From Primitive
489
- "pickColor",
490
- // From VertexFormat
491
- "normal",
492
- "st",
493
- "tangent",
494
- "bitangent",
495
- // For shadow volumes
496
- "extrudeDirection",
497
- // From compressing texture coordinates and normals
498
- "compressedAttributes"
499
- ];
500
- const attributes = geometry.attributes;
501
- const indices = {};
502
- let j = 0;
503
- let i;
504
- const len = semantics.length;
505
- for (i = 0; i < len; ++i) {
506
- const semantic = semantics[i];
507
- if (defined_default(attributes[semantic])) {
508
- indices[semantic] = j++;
509
- }
510
- }
511
- for (const name in attributes) {
512
- if (attributes.hasOwnProperty(name) && !defined_default(indices[name])) {
513
- indices[name] = j++;
514
- }
515
- }
516
- return indices;
517
- };
518
- GeometryPipeline.reorderForPreVertexCache = function(geometry) {
519
- if (!defined_default(geometry)) {
520
- throw new DeveloperError_default("geometry is required.");
521
- }
522
- const numVertices = Geometry_default.computeNumberOfVertices(geometry);
523
- const indices = geometry.indices;
524
- if (defined_default(indices)) {
525
- const indexCrossReferenceOldToNew = new Int32Array(numVertices);
526
- for (let i = 0; i < numVertices; i++) {
527
- indexCrossReferenceOldToNew[i] = -1;
528
- }
529
- const indicesIn = indices;
530
- const numIndices = indicesIn.length;
531
- const indicesOut = IndexDatatype_default.createTypedArray(numVertices, numIndices);
532
- let intoIndicesIn = 0;
533
- let intoIndicesOut = 0;
534
- let nextIndex = 0;
535
- let tempIndex;
536
- while (intoIndicesIn < numIndices) {
537
- tempIndex = indexCrossReferenceOldToNew[indicesIn[intoIndicesIn]];
538
- if (tempIndex !== -1) {
539
- indicesOut[intoIndicesOut] = tempIndex;
540
- } else {
541
- tempIndex = indicesIn[intoIndicesIn];
542
- indexCrossReferenceOldToNew[tempIndex] = nextIndex;
543
- indicesOut[intoIndicesOut] = nextIndex;
544
- ++nextIndex;
545
- }
546
- ++intoIndicesIn;
547
- ++intoIndicesOut;
548
- }
549
- geometry.indices = indicesOut;
550
- const attributes = geometry.attributes;
551
- for (const property in attributes) {
552
- if (attributes.hasOwnProperty(property) && defined_default(attributes[property]) && defined_default(attributes[property].values)) {
553
- const attribute = attributes[property];
554
- const elementsIn = attribute.values;
555
- let intoElementsIn = 0;
556
- const numComponents = attribute.componentsPerAttribute;
557
- const elementsOut = ComponentDatatype_default.createTypedArray(
558
- attribute.componentDatatype,
559
- nextIndex * numComponents
560
- );
561
- while (intoElementsIn < numVertices) {
562
- const temp = indexCrossReferenceOldToNew[intoElementsIn];
563
- if (temp !== -1) {
564
- for (let j = 0; j < numComponents; j++) {
565
- elementsOut[numComponents * temp + j] = elementsIn[numComponents * intoElementsIn + j];
566
- }
567
- }
568
- ++intoElementsIn;
569
- }
570
- attribute.values = elementsOut;
571
- }
572
- }
573
- }
574
- return geometry;
575
- };
576
- GeometryPipeline.reorderForPostVertexCache = function(geometry, cacheCapacity) {
577
- if (!defined_default(geometry)) {
578
- throw new DeveloperError_default("geometry is required.");
579
- }
580
- const indices = geometry.indices;
581
- if (geometry.primitiveType === PrimitiveType_default.TRIANGLES && defined_default(indices)) {
582
- const numIndices = indices.length;
583
- let maximumIndex = 0;
584
- for (let j = 0; j < numIndices; j++) {
585
- if (indices[j] > maximumIndex) {
586
- maximumIndex = indices[j];
587
- }
588
- }
589
- geometry.indices = Tipsify_default.tipsify({
590
- indices,
591
- maximumIndex,
592
- cacheSize: cacheCapacity
593
- });
594
- }
595
- return geometry;
596
- };
597
- function copyAttributesDescriptions(attributes) {
598
- const newAttributes = {};
599
- for (const attribute in attributes) {
600
- if (attributes.hasOwnProperty(attribute) && defined_default(attributes[attribute]) && defined_default(attributes[attribute].values)) {
601
- const attr = attributes[attribute];
602
- newAttributes[attribute] = new GeometryAttribute_default({
603
- componentDatatype: attr.componentDatatype,
604
- componentsPerAttribute: attr.componentsPerAttribute,
605
- normalize: attr.normalize,
606
- values: []
607
- });
608
- }
609
- }
610
- return newAttributes;
611
- }
612
- function copyVertex(destinationAttributes, sourceAttributes, index) {
613
- for (const attribute in sourceAttributes) {
614
- if (sourceAttributes.hasOwnProperty(attribute) && defined_default(sourceAttributes[attribute]) && defined_default(sourceAttributes[attribute].values)) {
615
- const attr = sourceAttributes[attribute];
616
- for (let k = 0; k < attr.componentsPerAttribute; ++k) {
617
- destinationAttributes[attribute].values.push(
618
- attr.values[index * attr.componentsPerAttribute + k]
619
- );
620
- }
621
- }
622
- }
623
- }
624
- GeometryPipeline.fitToUnsignedShortIndices = function(geometry) {
625
- if (!defined_default(geometry)) {
626
- throw new DeveloperError_default("geometry is required.");
627
- }
628
- if (defined_default(geometry.indices) && geometry.primitiveType !== PrimitiveType_default.TRIANGLES && geometry.primitiveType !== PrimitiveType_default.LINES && geometry.primitiveType !== PrimitiveType_default.POINTS) {
629
- throw new DeveloperError_default(
630
- "geometry.primitiveType must equal to PrimitiveType.TRIANGLES, PrimitiveType.LINES, or PrimitiveType.POINTS."
631
- );
632
- }
633
- const geometries = [];
634
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
635
- if (defined_default(geometry.indices) && numberOfVertices >= Math_default.SIXTY_FOUR_KILOBYTES) {
636
- let oldToNewIndex = [];
637
- let newIndices = [];
638
- let currentIndex = 0;
639
- let newAttributes = copyAttributesDescriptions(geometry.attributes);
640
- const originalIndices = geometry.indices;
641
- const numberOfIndices = originalIndices.length;
642
- let indicesPerPrimitive;
643
- if (geometry.primitiveType === PrimitiveType_default.TRIANGLES) {
644
- indicesPerPrimitive = 3;
645
- } else if (geometry.primitiveType === PrimitiveType_default.LINES) {
646
- indicesPerPrimitive = 2;
647
- } else if (geometry.primitiveType === PrimitiveType_default.POINTS) {
648
- indicesPerPrimitive = 1;
649
- }
650
- for (let j = 0; j < numberOfIndices; j += indicesPerPrimitive) {
651
- for (let k = 0; k < indicesPerPrimitive; ++k) {
652
- const x = originalIndices[j + k];
653
- let i = oldToNewIndex[x];
654
- if (!defined_default(i)) {
655
- i = currentIndex++;
656
- oldToNewIndex[x] = i;
657
- copyVertex(newAttributes, geometry.attributes, x);
658
- }
659
- newIndices.push(i);
660
- }
661
- if (currentIndex + indicesPerPrimitive >= Math_default.SIXTY_FOUR_KILOBYTES) {
662
- geometries.push(
663
- new Geometry_default({
664
- attributes: newAttributes,
665
- indices: newIndices,
666
- primitiveType: geometry.primitiveType,
667
- boundingSphere: geometry.boundingSphere,
668
- boundingSphereCV: geometry.boundingSphereCV
669
- })
670
- );
671
- oldToNewIndex = [];
672
- newIndices = [];
673
- currentIndex = 0;
674
- newAttributes = copyAttributesDescriptions(geometry.attributes);
675
- }
676
- }
677
- if (newIndices.length !== 0) {
678
- geometries.push(
679
- new Geometry_default({
680
- attributes: newAttributes,
681
- indices: newIndices,
682
- primitiveType: geometry.primitiveType,
683
- boundingSphere: geometry.boundingSphere,
684
- boundingSphereCV: geometry.boundingSphereCV
685
- })
686
- );
687
- }
688
- } else {
689
- geometries.push(geometry);
690
- }
691
- return geometries;
692
- };
693
- var scratchProjectTo2DCartesian3 = new Cartesian3_default();
694
- var scratchProjectTo2DCartographic = new Cartographic_default();
695
- GeometryPipeline.projectTo2D = function(geometry, attributeName, attributeName3D, attributeName2D, projection) {
696
- if (!defined_default(geometry)) {
697
- throw new DeveloperError_default("geometry is required.");
698
- }
699
- if (!defined_default(attributeName)) {
700
- throw new DeveloperError_default("attributeName is required.");
701
- }
702
- if (!defined_default(attributeName3D)) {
703
- throw new DeveloperError_default("attributeName3D is required.");
704
- }
705
- if (!defined_default(attributeName2D)) {
706
- throw new DeveloperError_default("attributeName2D is required.");
707
- }
708
- if (!defined_default(geometry.attributes[attributeName])) {
709
- throw new DeveloperError_default(
710
- `geometry must have attribute matching the attributeName argument: ${attributeName}.`
711
- );
712
- }
713
- if (geometry.attributes[attributeName].componentDatatype !== ComponentDatatype_default.DOUBLE) {
714
- throw new DeveloperError_default(
715
- "The attribute componentDatatype must be ComponentDatatype.DOUBLE."
716
- );
717
- }
718
- const attribute = geometry.attributes[attributeName];
719
- projection = defined_default(projection) ? projection : new GeographicProjection_default();
720
- const ellipsoid = projection.ellipsoid;
721
- const values3D = attribute.values;
722
- const projectedValues = new Float64Array(values3D.length);
723
- let index = 0;
724
- for (let i = 0; i < values3D.length; i += 3) {
725
- const value = Cartesian3_default.fromArray(
726
- values3D,
727
- i,
728
- scratchProjectTo2DCartesian3
729
- );
730
- const lonLat = ellipsoid.cartesianToCartographic(
731
- value,
732
- scratchProjectTo2DCartographic
733
- );
734
- if (!defined_default(lonLat)) {
735
- throw new DeveloperError_default(
736
- `Could not project point (${value.x}, ${value.y}, ${value.z}) to 2D.`
737
- );
738
- }
739
- const projectedLonLat = projection.project(
740
- lonLat,
741
- scratchProjectTo2DCartesian3
742
- );
743
- projectedValues[index++] = projectedLonLat.x;
744
- projectedValues[index++] = projectedLonLat.y;
745
- projectedValues[index++] = projectedLonLat.z;
746
- }
747
- geometry.attributes[attributeName3D] = attribute;
748
- geometry.attributes[attributeName2D] = new GeometryAttribute_default({
749
- componentDatatype: ComponentDatatype_default.DOUBLE,
750
- componentsPerAttribute: 3,
751
- values: projectedValues
752
- });
753
- delete geometry.attributes[attributeName];
754
- return geometry;
755
- };
756
- var encodedResult = {
757
- high: 0,
758
- low: 0
759
- };
760
- GeometryPipeline.encodeAttribute = function(geometry, attributeName, attributeHighName, attributeLowName) {
761
- if (!defined_default(geometry)) {
762
- throw new DeveloperError_default("geometry is required.");
763
- }
764
- if (!defined_default(attributeName)) {
765
- throw new DeveloperError_default("attributeName is required.");
766
- }
767
- if (!defined_default(attributeHighName)) {
768
- throw new DeveloperError_default("attributeHighName is required.");
769
- }
770
- if (!defined_default(attributeLowName)) {
771
- throw new DeveloperError_default("attributeLowName is required.");
772
- }
773
- if (!defined_default(geometry.attributes[attributeName])) {
774
- throw new DeveloperError_default(
775
- `geometry must have attribute matching the attributeName argument: ${attributeName}.`
776
- );
777
- }
778
- if (geometry.attributes[attributeName].componentDatatype !== ComponentDatatype_default.DOUBLE) {
779
- throw new DeveloperError_default(
780
- "The attribute componentDatatype must be ComponentDatatype.DOUBLE."
781
- );
782
- }
783
- const attribute = geometry.attributes[attributeName];
784
- const values = attribute.values;
785
- const length = values.length;
786
- const highValues = new Float32Array(length);
787
- const lowValues = new Float32Array(length);
788
- for (let i = 0; i < length; ++i) {
789
- EncodedCartesian3_default.encode(values[i], encodedResult);
790
- highValues[i] = encodedResult.high;
791
- lowValues[i] = encodedResult.low;
792
- }
793
- const componentsPerAttribute = attribute.componentsPerAttribute;
794
- geometry.attributes[attributeHighName] = new GeometryAttribute_default({
795
- componentDatatype: ComponentDatatype_default.FLOAT,
796
- componentsPerAttribute,
797
- values: highValues
798
- });
799
- geometry.attributes[attributeLowName] = new GeometryAttribute_default({
800
- componentDatatype: ComponentDatatype_default.FLOAT,
801
- componentsPerAttribute,
802
- values: lowValues
803
- });
804
- delete geometry.attributes[attributeName];
805
- return geometry;
806
- };
807
- var scratchCartesian32 = new Cartesian3_default();
808
- function transformPoint(matrix, attribute) {
809
- if (defined_default(attribute)) {
810
- const values = attribute.values;
811
- const length = values.length;
812
- for (let i = 0; i < length; i += 3) {
813
- Cartesian3_default.unpack(values, i, scratchCartesian32);
814
- Matrix4_default.multiplyByPoint(matrix, scratchCartesian32, scratchCartesian32);
815
- Cartesian3_default.pack(scratchCartesian32, values, i);
816
- }
817
- }
818
- }
819
- function transformVector(matrix, attribute) {
820
- if (defined_default(attribute)) {
821
- const values = attribute.values;
822
- const length = values.length;
823
- for (let i = 0; i < length; i += 3) {
824
- Cartesian3_default.unpack(values, i, scratchCartesian32);
825
- Matrix3_default.multiplyByVector(matrix, scratchCartesian32, scratchCartesian32);
826
- scratchCartesian32 = Cartesian3_default.normalize(
827
- scratchCartesian32,
828
- scratchCartesian32
829
- );
830
- Cartesian3_default.pack(scratchCartesian32, values, i);
831
- }
832
- }
833
- }
834
- var inverseTranspose = new Matrix4_default();
835
- var normalMatrix = new Matrix3_default();
836
- GeometryPipeline.transformToWorldCoordinates = function(instance) {
837
- if (!defined_default(instance)) {
838
- throw new DeveloperError_default("instance is required.");
839
- }
840
- const modelMatrix = instance.modelMatrix;
841
- if (Matrix4_default.equals(modelMatrix, Matrix4_default.IDENTITY)) {
842
- return instance;
843
- }
844
- const attributes = instance.geometry.attributes;
845
- transformPoint(modelMatrix, attributes.position);
846
- transformPoint(modelMatrix, attributes.prevPosition);
847
- transformPoint(modelMatrix, attributes.nextPosition);
848
- if (defined_default(attributes.normal) || defined_default(attributes.tangent) || defined_default(attributes.bitangent)) {
849
- Matrix4_default.inverse(modelMatrix, inverseTranspose);
850
- Matrix4_default.transpose(inverseTranspose, inverseTranspose);
851
- Matrix4_default.getMatrix3(inverseTranspose, normalMatrix);
852
- transformVector(normalMatrix, attributes.normal);
853
- transformVector(normalMatrix, attributes.tangent);
854
- transformVector(normalMatrix, attributes.bitangent);
855
- }
856
- const boundingSphere = instance.geometry.boundingSphere;
857
- if (defined_default(boundingSphere)) {
858
- instance.geometry.boundingSphere = BoundingSphere_default.transform(
859
- boundingSphere,
860
- modelMatrix,
861
- boundingSphere
862
- );
863
- }
864
- instance.modelMatrix = Matrix4_default.clone(Matrix4_default.IDENTITY);
865
- return instance;
866
- };
867
- function findAttributesInAllGeometries(instances, propertyName) {
868
- const length = instances.length;
869
- const attributesInAllGeometries = {};
870
- const attributes0 = instances[0][propertyName].attributes;
871
- let name;
872
- for (name in attributes0) {
873
- if (attributes0.hasOwnProperty(name) && defined_default(attributes0[name]) && defined_default(attributes0[name].values)) {
874
- const attribute = attributes0[name];
875
- let numberOfComponents = attribute.values.length;
876
- let inAllGeometries = true;
877
- for (let i = 1; i < length; ++i) {
878
- const otherAttribute = instances[i][propertyName].attributes[name];
879
- if (!defined_default(otherAttribute) || attribute.componentDatatype !== otherAttribute.componentDatatype || attribute.componentsPerAttribute !== otherAttribute.componentsPerAttribute || attribute.normalize !== otherAttribute.normalize) {
880
- inAllGeometries = false;
881
- break;
882
- }
883
- numberOfComponents += otherAttribute.values.length;
884
- }
885
- if (inAllGeometries) {
886
- attributesInAllGeometries[name] = new GeometryAttribute_default({
887
- componentDatatype: attribute.componentDatatype,
888
- componentsPerAttribute: attribute.componentsPerAttribute,
889
- normalize: attribute.normalize,
890
- values: ComponentDatatype_default.createTypedArray(
891
- attribute.componentDatatype,
892
- numberOfComponents
893
- )
894
- });
895
- }
896
- }
897
- }
898
- return attributesInAllGeometries;
899
- }
900
- var tempScratch = new Cartesian3_default();
901
- function combineGeometries(instances, propertyName) {
902
- const length = instances.length;
903
- let name;
904
- let i;
905
- let j;
906
- let k;
907
- const m = instances[0].modelMatrix;
908
- const haveIndices = defined_default(instances[0][propertyName].indices);
909
- const primitiveType = instances[0][propertyName].primitiveType;
910
- for (i = 1; i < length; ++i) {
911
- if (!Matrix4_default.equals(instances[i].modelMatrix, m)) {
912
- throw new DeveloperError_default("All instances must have the same modelMatrix.");
913
- }
914
- if (defined_default(instances[i][propertyName].indices) !== haveIndices) {
915
- throw new DeveloperError_default(
916
- "All instance geometries must have an indices or not have one."
917
- );
918
- }
919
- if (instances[i][propertyName].primitiveType !== primitiveType) {
920
- throw new DeveloperError_default(
921
- "All instance geometries must have the same primitiveType."
922
- );
923
- }
924
- }
925
- const attributes = findAttributesInAllGeometries(instances, propertyName);
926
- let values;
927
- let sourceValues;
928
- let sourceValuesLength;
929
- for (name in attributes) {
930
- if (attributes.hasOwnProperty(name)) {
931
- values = attributes[name].values;
932
- k = 0;
933
- for (i = 0; i < length; ++i) {
934
- sourceValues = instances[i][propertyName].attributes[name].values;
935
- sourceValuesLength = sourceValues.length;
936
- for (j = 0; j < sourceValuesLength; ++j) {
937
- values[k++] = sourceValues[j];
938
- }
939
- }
940
- }
941
- }
942
- let indices;
943
- if (haveIndices) {
944
- let numberOfIndices = 0;
945
- for (i = 0; i < length; ++i) {
946
- numberOfIndices += instances[i][propertyName].indices.length;
947
- }
948
- const numberOfVertices = Geometry_default.computeNumberOfVertices(
949
- new Geometry_default({
950
- attributes,
951
- primitiveType: PrimitiveType_default.POINTS
952
- })
953
- );
954
- const destIndices = IndexDatatype_default.createTypedArray(
955
- numberOfVertices,
956
- numberOfIndices
957
- );
958
- let destOffset = 0;
959
- let offset = 0;
960
- for (i = 0; i < length; ++i) {
961
- const sourceIndices = instances[i][propertyName].indices;
962
- const sourceIndicesLen = sourceIndices.length;
963
- for (k = 0; k < sourceIndicesLen; ++k) {
964
- destIndices[destOffset++] = offset + sourceIndices[k];
965
- }
966
- offset += Geometry_default.computeNumberOfVertices(instances[i][propertyName]);
967
- }
968
- indices = destIndices;
969
- }
970
- let center = new Cartesian3_default();
971
- let radius = 0;
972
- let bs;
973
- for (i = 0; i < length; ++i) {
974
- bs = instances[i][propertyName].boundingSphere;
975
- if (!defined_default(bs)) {
976
- center = void 0;
977
- break;
978
- }
979
- Cartesian3_default.add(bs.center, center, center);
980
- }
981
- if (defined_default(center)) {
982
- Cartesian3_default.divideByScalar(center, length, center);
983
- for (i = 0; i < length; ++i) {
984
- bs = instances[i][propertyName].boundingSphere;
985
- const tempRadius = Cartesian3_default.magnitude(
986
- Cartesian3_default.subtract(bs.center, center, tempScratch)
987
- ) + bs.radius;
988
- if (tempRadius > radius) {
989
- radius = tempRadius;
990
- }
991
- }
992
- }
993
- return new Geometry_default({
994
- attributes,
995
- indices,
996
- primitiveType,
997
- boundingSphere: defined_default(center) ? new BoundingSphere_default(center, radius) : void 0
998
- });
999
- }
1000
- GeometryPipeline.combineInstances = function(instances) {
1001
- if (!defined_default(instances) || instances.length < 1) {
1002
- throw new DeveloperError_default(
1003
- "instances is required and must have length greater than zero."
1004
- );
1005
- }
1006
- const instanceGeometry = [];
1007
- const instanceSplitGeometry = [];
1008
- const length = instances.length;
1009
- for (let i = 0; i < length; ++i) {
1010
- const instance = instances[i];
1011
- if (defined_default(instance.geometry)) {
1012
- instanceGeometry.push(instance);
1013
- } else if (defined_default(instance.westHemisphereGeometry) && defined_default(instance.eastHemisphereGeometry)) {
1014
- instanceSplitGeometry.push(instance);
1015
- }
1016
- }
1017
- const geometries = [];
1018
- if (instanceGeometry.length > 0) {
1019
- geometries.push(combineGeometries(instanceGeometry, "geometry"));
1020
- }
1021
- if (instanceSplitGeometry.length > 0) {
1022
- geometries.push(
1023
- combineGeometries(instanceSplitGeometry, "westHemisphereGeometry")
1024
- );
1025
- geometries.push(
1026
- combineGeometries(instanceSplitGeometry, "eastHemisphereGeometry")
1027
- );
1028
- }
1029
- return geometries;
1030
- };
1031
- var normal = new Cartesian3_default();
1032
- var v0 = new Cartesian3_default();
1033
- var v1 = new Cartesian3_default();
1034
- var v2 = new Cartesian3_default();
1035
- GeometryPipeline.computeNormal = function(geometry) {
1036
- if (!defined_default(geometry)) {
1037
- throw new DeveloperError_default("geometry is required.");
1038
- }
1039
- if (!defined_default(geometry.attributes.position) || !defined_default(geometry.attributes.position.values)) {
1040
- throw new DeveloperError_default(
1041
- "geometry.attributes.position.values is required."
1042
- );
1043
- }
1044
- if (!defined_default(geometry.indices)) {
1045
- throw new DeveloperError_default("geometry.indices is required.");
1046
- }
1047
- if (geometry.indices.length < 2 || geometry.indices.length % 3 !== 0) {
1048
- throw new DeveloperError_default(
1049
- "geometry.indices length must be greater than 0 and be a multiple of 3."
1050
- );
1051
- }
1052
- if (geometry.primitiveType !== PrimitiveType_default.TRIANGLES) {
1053
- throw new DeveloperError_default(
1054
- "geometry.primitiveType must be PrimitiveType.TRIANGLES."
1055
- );
1056
- }
1057
- const indices = geometry.indices;
1058
- const attributes = geometry.attributes;
1059
- const vertices = attributes.position.values;
1060
- const numVertices = attributes.position.values.length / 3;
1061
- const numIndices = indices.length;
1062
- const normalsPerVertex = new Array(numVertices);
1063
- const normalsPerTriangle = new Array(numIndices / 3);
1064
- const normalIndices = new Array(numIndices);
1065
- let i;
1066
- for (i = 0; i < numVertices; i++) {
1067
- normalsPerVertex[i] = {
1068
- indexOffset: 0,
1069
- count: 0,
1070
- currentCount: 0
1071
- };
1072
- }
1073
- let j = 0;
1074
- for (i = 0; i < numIndices; i += 3) {
1075
- const i0 = indices[i];
1076
- const i1 = indices[i + 1];
1077
- const i2 = indices[i + 2];
1078
- const i03 = i0 * 3;
1079
- const i13 = i1 * 3;
1080
- const i23 = i2 * 3;
1081
- v0.x = vertices[i03];
1082
- v0.y = vertices[i03 + 1];
1083
- v0.z = vertices[i03 + 2];
1084
- v1.x = vertices[i13];
1085
- v1.y = vertices[i13 + 1];
1086
- v1.z = vertices[i13 + 2];
1087
- v2.x = vertices[i23];
1088
- v2.y = vertices[i23 + 1];
1089
- v2.z = vertices[i23 + 2];
1090
- normalsPerVertex[i0].count++;
1091
- normalsPerVertex[i1].count++;
1092
- normalsPerVertex[i2].count++;
1093
- Cartesian3_default.subtract(v1, v0, v1);
1094
- Cartesian3_default.subtract(v2, v0, v2);
1095
- normalsPerTriangle[j] = Cartesian3_default.cross(v1, v2, new Cartesian3_default());
1096
- j++;
1097
- }
1098
- let indexOffset = 0;
1099
- for (i = 0; i < numVertices; i++) {
1100
- normalsPerVertex[i].indexOffset += indexOffset;
1101
- indexOffset += normalsPerVertex[i].count;
1102
- }
1103
- j = 0;
1104
- let vertexNormalData;
1105
- for (i = 0; i < numIndices; i += 3) {
1106
- vertexNormalData = normalsPerVertex[indices[i]];
1107
- let index = vertexNormalData.indexOffset + vertexNormalData.currentCount;
1108
- normalIndices[index] = j;
1109
- vertexNormalData.currentCount++;
1110
- vertexNormalData = normalsPerVertex[indices[i + 1]];
1111
- index = vertexNormalData.indexOffset + vertexNormalData.currentCount;
1112
- normalIndices[index] = j;
1113
- vertexNormalData.currentCount++;
1114
- vertexNormalData = normalsPerVertex[indices[i + 2]];
1115
- index = vertexNormalData.indexOffset + vertexNormalData.currentCount;
1116
- normalIndices[index] = j;
1117
- vertexNormalData.currentCount++;
1118
- j++;
1119
- }
1120
- const normalValues = new Float32Array(numVertices * 3);
1121
- for (i = 0; i < numVertices; i++) {
1122
- const i3 = i * 3;
1123
- vertexNormalData = normalsPerVertex[i];
1124
- Cartesian3_default.clone(Cartesian3_default.ZERO, normal);
1125
- if (vertexNormalData.count > 0) {
1126
- for (j = 0; j < vertexNormalData.count; j++) {
1127
- Cartesian3_default.add(
1128
- normal,
1129
- normalsPerTriangle[normalIndices[vertexNormalData.indexOffset + j]],
1130
- normal
1131
- );
1132
- }
1133
- if (Cartesian3_default.equalsEpsilon(Cartesian3_default.ZERO, normal, Math_default.EPSILON10)) {
1134
- Cartesian3_default.clone(
1135
- normalsPerTriangle[normalIndices[vertexNormalData.indexOffset]],
1136
- normal
1137
- );
1138
- }
1139
- }
1140
- if (Cartesian3_default.equalsEpsilon(Cartesian3_default.ZERO, normal, Math_default.EPSILON10)) {
1141
- normal.z = 1;
1142
- }
1143
- Cartesian3_default.normalize(normal, normal);
1144
- normalValues[i3] = normal.x;
1145
- normalValues[i3 + 1] = normal.y;
1146
- normalValues[i3 + 2] = normal.z;
1147
- }
1148
- geometry.attributes.normal = new GeometryAttribute_default({
1149
- componentDatatype: ComponentDatatype_default.FLOAT,
1150
- componentsPerAttribute: 3,
1151
- values: normalValues
1152
- });
1153
- return geometry;
1154
- };
1155
- var normalScratch = new Cartesian3_default();
1156
- var normalScale = new Cartesian3_default();
1157
- var tScratch = new Cartesian3_default();
1158
- GeometryPipeline.computeTangentAndBitangent = function(geometry) {
1159
- if (!defined_default(geometry)) {
1160
- throw new DeveloperError_default("geometry is required.");
1161
- }
1162
- const attributes = geometry.attributes;
1163
- const indices = geometry.indices;
1164
- if (!defined_default(attributes.position) || !defined_default(attributes.position.values)) {
1165
- throw new DeveloperError_default(
1166
- "geometry.attributes.position.values is required."
1167
- );
1168
- }
1169
- if (!defined_default(attributes.normal) || !defined_default(attributes.normal.values)) {
1170
- throw new DeveloperError_default("geometry.attributes.normal.values is required.");
1171
- }
1172
- if (!defined_default(attributes.st) || !defined_default(attributes.st.values)) {
1173
- throw new DeveloperError_default("geometry.attributes.st.values is required.");
1174
- }
1175
- if (!defined_default(indices)) {
1176
- throw new DeveloperError_default("geometry.indices is required.");
1177
- }
1178
- if (indices.length < 2 || indices.length % 3 !== 0) {
1179
- throw new DeveloperError_default(
1180
- "geometry.indices length must be greater than 0 and be a multiple of 3."
1181
- );
1182
- }
1183
- if (geometry.primitiveType !== PrimitiveType_default.TRIANGLES) {
1184
- throw new DeveloperError_default(
1185
- "geometry.primitiveType must be PrimitiveType.TRIANGLES."
1186
- );
1187
- }
1188
- const vertices = geometry.attributes.position.values;
1189
- const normals = geometry.attributes.normal.values;
1190
- const st = geometry.attributes.st.values;
1191
- const numVertices = geometry.attributes.position.values.length / 3;
1192
- const numIndices = indices.length;
1193
- const tan1 = new Array(numVertices * 3);
1194
- let i;
1195
- for (i = 0; i < tan1.length; i++) {
1196
- tan1[i] = 0;
1197
- }
1198
- let i03;
1199
- let i13;
1200
- let i23;
1201
- for (i = 0; i < numIndices; i += 3) {
1202
- const i0 = indices[i];
1203
- const i1 = indices[i + 1];
1204
- const i2 = indices[i + 2];
1205
- i03 = i0 * 3;
1206
- i13 = i1 * 3;
1207
- i23 = i2 * 3;
1208
- const i02 = i0 * 2;
1209
- const i12 = i1 * 2;
1210
- const i22 = i2 * 2;
1211
- const ux = vertices[i03];
1212
- const uy = vertices[i03 + 1];
1213
- const uz = vertices[i03 + 2];
1214
- const wx = st[i02];
1215
- const wy = st[i02 + 1];
1216
- const t1 = st[i12 + 1] - wy;
1217
- const t2 = st[i22 + 1] - wy;
1218
- const r = 1 / ((st[i12] - wx) * t2 - (st[i22] - wx) * t1);
1219
- const sdirx = (t2 * (vertices[i13] - ux) - t1 * (vertices[i23] - ux)) * r;
1220
- const sdiry = (t2 * (vertices[i13 + 1] - uy) - t1 * (vertices[i23 + 1] - uy)) * r;
1221
- const sdirz = (t2 * (vertices[i13 + 2] - uz) - t1 * (vertices[i23 + 2] - uz)) * r;
1222
- tan1[i03] += sdirx;
1223
- tan1[i03 + 1] += sdiry;
1224
- tan1[i03 + 2] += sdirz;
1225
- tan1[i13] += sdirx;
1226
- tan1[i13 + 1] += sdiry;
1227
- tan1[i13 + 2] += sdirz;
1228
- tan1[i23] += sdirx;
1229
- tan1[i23 + 1] += sdiry;
1230
- tan1[i23 + 2] += sdirz;
1231
- }
1232
- const tangentValues = new Float32Array(numVertices * 3);
1233
- const bitangentValues = new Float32Array(numVertices * 3);
1234
- for (i = 0; i < numVertices; i++) {
1235
- i03 = i * 3;
1236
- i13 = i03 + 1;
1237
- i23 = i03 + 2;
1238
- const n = Cartesian3_default.fromArray(normals, i03, normalScratch);
1239
- const t = Cartesian3_default.fromArray(tan1, i03, tScratch);
1240
- const scalar = Cartesian3_default.dot(n, t);
1241
- Cartesian3_default.multiplyByScalar(n, scalar, normalScale);
1242
- Cartesian3_default.normalize(Cartesian3_default.subtract(t, normalScale, t), t);
1243
- tangentValues[i03] = t.x;
1244
- tangentValues[i13] = t.y;
1245
- tangentValues[i23] = t.z;
1246
- Cartesian3_default.normalize(Cartesian3_default.cross(n, t, t), t);
1247
- bitangentValues[i03] = t.x;
1248
- bitangentValues[i13] = t.y;
1249
- bitangentValues[i23] = t.z;
1250
- }
1251
- geometry.attributes.tangent = new GeometryAttribute_default({
1252
- componentDatatype: ComponentDatatype_default.FLOAT,
1253
- componentsPerAttribute: 3,
1254
- values: tangentValues
1255
- });
1256
- geometry.attributes.bitangent = new GeometryAttribute_default({
1257
- componentDatatype: ComponentDatatype_default.FLOAT,
1258
- componentsPerAttribute: 3,
1259
- values: bitangentValues
1260
- });
1261
- return geometry;
1262
- };
1263
- var scratchCartesian22 = new Cartesian2_default();
1264
- var toEncode1 = new Cartesian3_default();
1265
- var toEncode2 = new Cartesian3_default();
1266
- var toEncode3 = new Cartesian3_default();
1267
- var encodeResult2 = new Cartesian2_default();
1268
- GeometryPipeline.compressVertices = function(geometry) {
1269
- if (!defined_default(geometry)) {
1270
- throw new DeveloperError_default("geometry is required.");
1271
- }
1272
- const extrudeAttribute = geometry.attributes.extrudeDirection;
1273
- let i;
1274
- let numVertices;
1275
- if (defined_default(extrudeAttribute)) {
1276
- const extrudeDirections = extrudeAttribute.values;
1277
- numVertices = extrudeDirections.length / 3;
1278
- const compressedDirections = new Float32Array(numVertices * 2);
1279
- let i2 = 0;
1280
- for (i = 0; i < numVertices; ++i) {
1281
- Cartesian3_default.fromArray(extrudeDirections, i * 3, toEncode1);
1282
- if (Cartesian3_default.equals(toEncode1, Cartesian3_default.ZERO)) {
1283
- i2 += 2;
1284
- continue;
1285
- }
1286
- encodeResult2 = AttributeCompression_default.octEncodeInRange(
1287
- toEncode1,
1288
- 65535,
1289
- encodeResult2
1290
- );
1291
- compressedDirections[i2++] = encodeResult2.x;
1292
- compressedDirections[i2++] = encodeResult2.y;
1293
- }
1294
- geometry.attributes.compressedAttributes = new GeometryAttribute_default({
1295
- componentDatatype: ComponentDatatype_default.FLOAT,
1296
- componentsPerAttribute: 2,
1297
- values: compressedDirections
1298
- });
1299
- delete geometry.attributes.extrudeDirection;
1300
- return geometry;
1301
- }
1302
- const normalAttribute = geometry.attributes.normal;
1303
- const stAttribute = geometry.attributes.st;
1304
- const hasNormal = defined_default(normalAttribute);
1305
- const hasSt = defined_default(stAttribute);
1306
- if (!hasNormal && !hasSt) {
1307
- return geometry;
1308
- }
1309
- const tangentAttribute = geometry.attributes.tangent;
1310
- const bitangentAttribute = geometry.attributes.bitangent;
1311
- const hasTangent = defined_default(tangentAttribute);
1312
- const hasBitangent = defined_default(bitangentAttribute);
1313
- let normals;
1314
- let st;
1315
- let tangents;
1316
- let bitangents;
1317
- if (hasNormal) {
1318
- normals = normalAttribute.values;
1319
- }
1320
- if (hasSt) {
1321
- st = stAttribute.values;
1322
- }
1323
- if (hasTangent) {
1324
- tangents = tangentAttribute.values;
1325
- }
1326
- if (hasBitangent) {
1327
- bitangents = bitangentAttribute.values;
1328
- }
1329
- const length = hasNormal ? normals.length : st.length;
1330
- const numComponents = hasNormal ? 3 : 2;
1331
- numVertices = length / numComponents;
1332
- let compressedLength = numVertices;
1333
- let numCompressedComponents = hasSt && hasNormal ? 2 : 1;
1334
- numCompressedComponents += hasTangent || hasBitangent ? 1 : 0;
1335
- compressedLength *= numCompressedComponents;
1336
- const compressedAttributes = new Float32Array(compressedLength);
1337
- let normalIndex = 0;
1338
- for (i = 0; i < numVertices; ++i) {
1339
- if (hasSt) {
1340
- Cartesian2_default.fromArray(st, i * 2, scratchCartesian22);
1341
- compressedAttributes[normalIndex++] = AttributeCompression_default.compressTextureCoordinates(scratchCartesian22);
1342
- }
1343
- const index = i * 3;
1344
- if (hasNormal && defined_default(tangents) && defined_default(bitangents)) {
1345
- Cartesian3_default.fromArray(normals, index, toEncode1);
1346
- Cartesian3_default.fromArray(tangents, index, toEncode2);
1347
- Cartesian3_default.fromArray(bitangents, index, toEncode3);
1348
- AttributeCompression_default.octPack(
1349
- toEncode1,
1350
- toEncode2,
1351
- toEncode3,
1352
- scratchCartesian22
1353
- );
1354
- compressedAttributes[normalIndex++] = scratchCartesian22.x;
1355
- compressedAttributes[normalIndex++] = scratchCartesian22.y;
1356
- } else {
1357
- if (hasNormal) {
1358
- Cartesian3_default.fromArray(normals, index, toEncode1);
1359
- compressedAttributes[normalIndex++] = AttributeCompression_default.octEncodeFloat(toEncode1);
1360
- }
1361
- if (hasTangent) {
1362
- Cartesian3_default.fromArray(tangents, index, toEncode1);
1363
- compressedAttributes[normalIndex++] = AttributeCompression_default.octEncodeFloat(toEncode1);
1364
- }
1365
- if (hasBitangent) {
1366
- Cartesian3_default.fromArray(bitangents, index, toEncode1);
1367
- compressedAttributes[normalIndex++] = AttributeCompression_default.octEncodeFloat(toEncode1);
1368
- }
1369
- }
1370
- }
1371
- geometry.attributes.compressedAttributes = new GeometryAttribute_default({
1372
- componentDatatype: ComponentDatatype_default.FLOAT,
1373
- componentsPerAttribute: numCompressedComponents,
1374
- values: compressedAttributes
1375
- });
1376
- if (hasNormal) {
1377
- delete geometry.attributes.normal;
1378
- }
1379
- if (hasSt) {
1380
- delete geometry.attributes.st;
1381
- }
1382
- if (hasBitangent) {
1383
- delete geometry.attributes.bitangent;
1384
- }
1385
- if (hasTangent) {
1386
- delete geometry.attributes.tangent;
1387
- }
1388
- return geometry;
1389
- };
1390
- function indexTriangles(geometry) {
1391
- if (defined_default(geometry.indices)) {
1392
- return geometry;
1393
- }
1394
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1395
- if (numberOfVertices < 3) {
1396
- throw new DeveloperError_default("The number of vertices must be at least three.");
1397
- }
1398
- if (numberOfVertices % 3 !== 0) {
1399
- throw new DeveloperError_default(
1400
- "The number of vertices must be a multiple of three."
1401
- );
1402
- }
1403
- const indices = IndexDatatype_default.createTypedArray(
1404
- numberOfVertices,
1405
- numberOfVertices
1406
- );
1407
- for (let i = 0; i < numberOfVertices; ++i) {
1408
- indices[i] = i;
1409
- }
1410
- geometry.indices = indices;
1411
- return geometry;
1412
- }
1413
- function indexTriangleFan(geometry) {
1414
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1415
- if (numberOfVertices < 3) {
1416
- throw new DeveloperError_default("The number of vertices must be at least three.");
1417
- }
1418
- const indices = IndexDatatype_default.createTypedArray(
1419
- numberOfVertices,
1420
- (numberOfVertices - 2) * 3
1421
- );
1422
- indices[0] = 1;
1423
- indices[1] = 0;
1424
- indices[2] = 2;
1425
- let indicesIndex = 3;
1426
- for (let i = 3; i < numberOfVertices; ++i) {
1427
- indices[indicesIndex++] = i - 1;
1428
- indices[indicesIndex++] = 0;
1429
- indices[indicesIndex++] = i;
1430
- }
1431
- geometry.indices = indices;
1432
- geometry.primitiveType = PrimitiveType_default.TRIANGLES;
1433
- return geometry;
1434
- }
1435
- function indexTriangleStrip(geometry) {
1436
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1437
- if (numberOfVertices < 3) {
1438
- throw new DeveloperError_default("The number of vertices must be at least 3.");
1439
- }
1440
- const indices = IndexDatatype_default.createTypedArray(
1441
- numberOfVertices,
1442
- (numberOfVertices - 2) * 3
1443
- );
1444
- indices[0] = 0;
1445
- indices[1] = 1;
1446
- indices[2] = 2;
1447
- if (numberOfVertices > 3) {
1448
- indices[3] = 0;
1449
- indices[4] = 2;
1450
- indices[5] = 3;
1451
- }
1452
- let indicesIndex = 6;
1453
- for (let i = 3; i < numberOfVertices - 1; i += 2) {
1454
- indices[indicesIndex++] = i;
1455
- indices[indicesIndex++] = i - 1;
1456
- indices[indicesIndex++] = i + 1;
1457
- if (i + 2 < numberOfVertices) {
1458
- indices[indicesIndex++] = i;
1459
- indices[indicesIndex++] = i + 1;
1460
- indices[indicesIndex++] = i + 2;
1461
- }
1462
- }
1463
- geometry.indices = indices;
1464
- geometry.primitiveType = PrimitiveType_default.TRIANGLES;
1465
- return geometry;
1466
- }
1467
- function indexLines(geometry) {
1468
- if (defined_default(geometry.indices)) {
1469
- return geometry;
1470
- }
1471
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1472
- if (numberOfVertices < 2) {
1473
- throw new DeveloperError_default("The number of vertices must be at least two.");
1474
- }
1475
- if (numberOfVertices % 2 !== 0) {
1476
- throw new DeveloperError_default("The number of vertices must be a multiple of 2.");
1477
- }
1478
- const indices = IndexDatatype_default.createTypedArray(
1479
- numberOfVertices,
1480
- numberOfVertices
1481
- );
1482
- for (let i = 0; i < numberOfVertices; ++i) {
1483
- indices[i] = i;
1484
- }
1485
- geometry.indices = indices;
1486
- return geometry;
1487
- }
1488
- function indexLineStrip(geometry) {
1489
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1490
- if (numberOfVertices < 2) {
1491
- throw new DeveloperError_default("The number of vertices must be at least two.");
1492
- }
1493
- const indices = IndexDatatype_default.createTypedArray(
1494
- numberOfVertices,
1495
- (numberOfVertices - 1) * 2
1496
- );
1497
- indices[0] = 0;
1498
- indices[1] = 1;
1499
- let indicesIndex = 2;
1500
- for (let i = 2; i < numberOfVertices; ++i) {
1501
- indices[indicesIndex++] = i - 1;
1502
- indices[indicesIndex++] = i;
1503
- }
1504
- geometry.indices = indices;
1505
- geometry.primitiveType = PrimitiveType_default.LINES;
1506
- return geometry;
1507
- }
1508
- function indexLineLoop(geometry) {
1509
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1510
- if (numberOfVertices < 2) {
1511
- throw new DeveloperError_default("The number of vertices must be at least two.");
1512
- }
1513
- const indices = IndexDatatype_default.createTypedArray(
1514
- numberOfVertices,
1515
- numberOfVertices * 2
1516
- );
1517
- indices[0] = 0;
1518
- indices[1] = 1;
1519
- let indicesIndex = 2;
1520
- for (let i = 2; i < numberOfVertices; ++i) {
1521
- indices[indicesIndex++] = i - 1;
1522
- indices[indicesIndex++] = i;
1523
- }
1524
- indices[indicesIndex++] = numberOfVertices - 1;
1525
- indices[indicesIndex] = 0;
1526
- geometry.indices = indices;
1527
- geometry.primitiveType = PrimitiveType_default.LINES;
1528
- return geometry;
1529
- }
1530
- function indexPrimitive(geometry) {
1531
- switch (geometry.primitiveType) {
1532
- case PrimitiveType_default.TRIANGLE_FAN:
1533
- return indexTriangleFan(geometry);
1534
- case PrimitiveType_default.TRIANGLE_STRIP:
1535
- return indexTriangleStrip(geometry);
1536
- case PrimitiveType_default.TRIANGLES:
1537
- return indexTriangles(geometry);
1538
- case PrimitiveType_default.LINE_STRIP:
1539
- return indexLineStrip(geometry);
1540
- case PrimitiveType_default.LINE_LOOP:
1541
- return indexLineLoop(geometry);
1542
- case PrimitiveType_default.LINES:
1543
- return indexLines(geometry);
1544
- }
1545
- return geometry;
1546
- }
1547
- function offsetPointFromXZPlane(p, isBehind) {
1548
- if (Math.abs(p.y) < Math_default.EPSILON6) {
1549
- if (isBehind) {
1550
- p.y = -Math_default.EPSILON6;
1551
- } else {
1552
- p.y = Math_default.EPSILON6;
1553
- }
1554
- }
1555
- }
1556
- function offsetTriangleFromXZPlane(p0, p1, p2) {
1557
- if (p0.y !== 0 && p1.y !== 0 && p2.y !== 0) {
1558
- offsetPointFromXZPlane(p0, p0.y < 0);
1559
- offsetPointFromXZPlane(p1, p1.y < 0);
1560
- offsetPointFromXZPlane(p2, p2.y < 0);
1561
- return;
1562
- }
1563
- const p0y = Math.abs(p0.y);
1564
- const p1y = Math.abs(p1.y);
1565
- const p2y = Math.abs(p2.y);
1566
- let sign;
1567
- if (p0y > p1y) {
1568
- if (p0y > p2y) {
1569
- sign = Math_default.sign(p0.y);
1570
- } else {
1571
- sign = Math_default.sign(p2.y);
1572
- }
1573
- } else if (p1y > p2y) {
1574
- sign = Math_default.sign(p1.y);
1575
- } else {
1576
- sign = Math_default.sign(p2.y);
1577
- }
1578
- const isBehind = sign < 0;
1579
- offsetPointFromXZPlane(p0, isBehind);
1580
- offsetPointFromXZPlane(p1, isBehind);
1581
- offsetPointFromXZPlane(p2, isBehind);
1582
- }
1583
- var c3 = new Cartesian3_default();
1584
- function getXZIntersectionOffsetPoints(p, p1, u12, v12) {
1585
- Cartesian3_default.add(
1586
- p,
1587
- Cartesian3_default.multiplyByScalar(
1588
- Cartesian3_default.subtract(p1, p, c3),
1589
- p.y / (p.y - p1.y),
1590
- c3
1591
- ),
1592
- u12
1593
- );
1594
- Cartesian3_default.clone(u12, v12);
1595
- offsetPointFromXZPlane(u12, true);
1596
- offsetPointFromXZPlane(v12, false);
1597
- }
1598
- var u1 = new Cartesian3_default();
1599
- var u2 = new Cartesian3_default();
1600
- var q1 = new Cartesian3_default();
1601
- var q2 = new Cartesian3_default();
1602
- var splitTriangleResult = {
1603
- positions: new Array(7),
1604
- indices: new Array(3 * 3)
1605
- };
1606
- function splitTriangle(p0, p1, p2) {
1607
- if (p0.x >= 0 || p1.x >= 0 || p2.x >= 0) {
1608
- return void 0;
1609
- }
1610
- offsetTriangleFromXZPlane(p0, p1, p2);
1611
- const p0Behind = p0.y < 0;
1612
- const p1Behind = p1.y < 0;
1613
- const p2Behind = p2.y < 0;
1614
- let numBehind = 0;
1615
- numBehind += p0Behind ? 1 : 0;
1616
- numBehind += p1Behind ? 1 : 0;
1617
- numBehind += p2Behind ? 1 : 0;
1618
- const indices = splitTriangleResult.indices;
1619
- if (numBehind === 1) {
1620
- indices[1] = 3;
1621
- indices[2] = 4;
1622
- indices[5] = 6;
1623
- indices[7] = 6;
1624
- indices[8] = 5;
1625
- if (p0Behind) {
1626
- getXZIntersectionOffsetPoints(p0, p1, u1, q1);
1627
- getXZIntersectionOffsetPoints(p0, p2, u2, q2);
1628
- indices[0] = 0;
1629
- indices[3] = 1;
1630
- indices[4] = 2;
1631
- indices[6] = 1;
1632
- } else if (p1Behind) {
1633
- getXZIntersectionOffsetPoints(p1, p2, u1, q1);
1634
- getXZIntersectionOffsetPoints(p1, p0, u2, q2);
1635
- indices[0] = 1;
1636
- indices[3] = 2;
1637
- indices[4] = 0;
1638
- indices[6] = 2;
1639
- } else if (p2Behind) {
1640
- getXZIntersectionOffsetPoints(p2, p0, u1, q1);
1641
- getXZIntersectionOffsetPoints(p2, p1, u2, q2);
1642
- indices[0] = 2;
1643
- indices[3] = 0;
1644
- indices[4] = 1;
1645
- indices[6] = 0;
1646
- }
1647
- } else if (numBehind === 2) {
1648
- indices[2] = 4;
1649
- indices[4] = 4;
1650
- indices[5] = 3;
1651
- indices[7] = 5;
1652
- indices[8] = 6;
1653
- if (!p0Behind) {
1654
- getXZIntersectionOffsetPoints(p0, p1, u1, q1);
1655
- getXZIntersectionOffsetPoints(p0, p2, u2, q2);
1656
- indices[0] = 1;
1657
- indices[1] = 2;
1658
- indices[3] = 1;
1659
- indices[6] = 0;
1660
- } else if (!p1Behind) {
1661
- getXZIntersectionOffsetPoints(p1, p2, u1, q1);
1662
- getXZIntersectionOffsetPoints(p1, p0, u2, q2);
1663
- indices[0] = 2;
1664
- indices[1] = 0;
1665
- indices[3] = 2;
1666
- indices[6] = 1;
1667
- } else if (!p2Behind) {
1668
- getXZIntersectionOffsetPoints(p2, p0, u1, q1);
1669
- getXZIntersectionOffsetPoints(p2, p1, u2, q2);
1670
- indices[0] = 0;
1671
- indices[1] = 1;
1672
- indices[3] = 0;
1673
- indices[6] = 2;
1674
- }
1675
- }
1676
- const positions = splitTriangleResult.positions;
1677
- positions[0] = p0;
1678
- positions[1] = p1;
1679
- positions[2] = p2;
1680
- positions.length = 3;
1681
- if (numBehind === 1 || numBehind === 2) {
1682
- positions[3] = u1;
1683
- positions[4] = u2;
1684
- positions[5] = q1;
1685
- positions[6] = q2;
1686
- positions.length = 7;
1687
- }
1688
- return splitTriangleResult;
1689
- }
1690
- function updateGeometryAfterSplit(geometry, computeBoundingSphere) {
1691
- const attributes = geometry.attributes;
1692
- if (attributes.position.values.length === 0) {
1693
- return void 0;
1694
- }
1695
- for (const property in attributes) {
1696
- if (attributes.hasOwnProperty(property) && defined_default(attributes[property]) && defined_default(attributes[property].values)) {
1697
- const attribute = attributes[property];
1698
- attribute.values = ComponentDatatype_default.createTypedArray(
1699
- attribute.componentDatatype,
1700
- attribute.values
1701
- );
1702
- }
1703
- }
1704
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1705
- geometry.indices = IndexDatatype_default.createTypedArray(
1706
- numberOfVertices,
1707
- geometry.indices
1708
- );
1709
- if (computeBoundingSphere) {
1710
- geometry.boundingSphere = BoundingSphere_default.fromVertices(
1711
- attributes.position.values
1712
- );
1713
- }
1714
- return geometry;
1715
- }
1716
- function copyGeometryForSplit(geometry) {
1717
- const attributes = geometry.attributes;
1718
- const copiedAttributes = {};
1719
- for (const property in attributes) {
1720
- if (attributes.hasOwnProperty(property) && defined_default(attributes[property]) && defined_default(attributes[property].values)) {
1721
- const attribute = attributes[property];
1722
- copiedAttributes[property] = new GeometryAttribute_default({
1723
- componentDatatype: attribute.componentDatatype,
1724
- componentsPerAttribute: attribute.componentsPerAttribute,
1725
- normalize: attribute.normalize,
1726
- values: []
1727
- });
1728
- }
1729
- }
1730
- return new Geometry_default({
1731
- attributes: copiedAttributes,
1732
- indices: [],
1733
- primitiveType: geometry.primitiveType
1734
- });
1735
- }
1736
- function updateInstanceAfterSplit(instance, westGeometry, eastGeometry) {
1737
- const computeBoundingSphere = defined_default(instance.geometry.boundingSphere);
1738
- westGeometry = updateGeometryAfterSplit(westGeometry, computeBoundingSphere);
1739
- eastGeometry = updateGeometryAfterSplit(eastGeometry, computeBoundingSphere);
1740
- if (defined_default(eastGeometry) && !defined_default(westGeometry)) {
1741
- instance.geometry = eastGeometry;
1742
- } else if (!defined_default(eastGeometry) && defined_default(westGeometry)) {
1743
- instance.geometry = westGeometry;
1744
- } else {
1745
- instance.westHemisphereGeometry = westGeometry;
1746
- instance.eastHemisphereGeometry = eastGeometry;
1747
- instance.geometry = void 0;
1748
- }
1749
- }
1750
- function generateBarycentricInterpolateFunction(CartesianType, numberOfComponents) {
1751
- const v0Scratch = new CartesianType();
1752
- const v1Scratch = new CartesianType();
1753
- const v2Scratch = new CartesianType();
1754
- return function(i0, i1, i2, coords, sourceValues, currentValues, insertedIndex, normalize) {
1755
- const v02 = CartesianType.fromArray(
1756
- sourceValues,
1757
- i0 * numberOfComponents,
1758
- v0Scratch
1759
- );
1760
- const v12 = CartesianType.fromArray(
1761
- sourceValues,
1762
- i1 * numberOfComponents,
1763
- v1Scratch
1764
- );
1765
- const v22 = CartesianType.fromArray(
1766
- sourceValues,
1767
- i2 * numberOfComponents,
1768
- v2Scratch
1769
- );
1770
- CartesianType.multiplyByScalar(v02, coords.x, v02);
1771
- CartesianType.multiplyByScalar(v12, coords.y, v12);
1772
- CartesianType.multiplyByScalar(v22, coords.z, v22);
1773
- const value = CartesianType.add(v02, v12, v02);
1774
- CartesianType.add(value, v22, value);
1775
- if (normalize) {
1776
- CartesianType.normalize(value, value);
1777
- }
1778
- CartesianType.pack(
1779
- value,
1780
- currentValues,
1781
- insertedIndex * numberOfComponents
1782
- );
1783
- };
1784
- }
1785
- var interpolateAndPackCartesian4 = generateBarycentricInterpolateFunction(
1786
- Cartesian4_default,
1787
- 4
1788
- );
1789
- var interpolateAndPackCartesian3 = generateBarycentricInterpolateFunction(
1790
- Cartesian3_default,
1791
- 3
1792
- );
1793
- var interpolateAndPackCartesian2 = generateBarycentricInterpolateFunction(
1794
- Cartesian2_default,
1795
- 2
1796
- );
1797
- var interpolateAndPackBoolean = function(i0, i1, i2, coords, sourceValues, currentValues, insertedIndex) {
1798
- const v12 = sourceValues[i0] * coords.x;
1799
- const v22 = sourceValues[i1] * coords.y;
1800
- const v3 = sourceValues[i2] * coords.z;
1801
- currentValues[insertedIndex] = v12 + v22 + v3 > Math_default.EPSILON6 ? 1 : 0;
1802
- };
1803
- var p0Scratch = new Cartesian3_default();
1804
- var p1Scratch = new Cartesian3_default();
1805
- var p2Scratch = new Cartesian3_default();
1806
- var barycentricScratch = new Cartesian3_default();
1807
- function computeTriangleAttributes(i0, i1, i2, point, positions, normals, tangents, bitangents, texCoords, extrudeDirections, applyOffset, currentAttributes, customAttributeNames, customAttributesLength, allAttributes, insertedIndex) {
1808
- if (!defined_default(normals) && !defined_default(tangents) && !defined_default(bitangents) && !defined_default(texCoords) && !defined_default(extrudeDirections) && customAttributesLength === 0) {
1809
- return;
1810
- }
1811
- const p0 = Cartesian3_default.fromArray(positions, i0 * 3, p0Scratch);
1812
- const p1 = Cartesian3_default.fromArray(positions, i1 * 3, p1Scratch);
1813
- const p2 = Cartesian3_default.fromArray(positions, i2 * 3, p2Scratch);
1814
- const coords = barycentricCoordinates_default(point, p0, p1, p2, barycentricScratch);
1815
- if (!defined_default(coords)) {
1816
- return;
1817
- }
1818
- if (defined_default(normals)) {
1819
- interpolateAndPackCartesian3(
1820
- i0,
1821
- i1,
1822
- i2,
1823
- coords,
1824
- normals,
1825
- currentAttributes.normal.values,
1826
- insertedIndex,
1827
- true
1828
- );
1829
- }
1830
- if (defined_default(extrudeDirections)) {
1831
- const d0 = Cartesian3_default.fromArray(extrudeDirections, i0 * 3, p0Scratch);
1832
- const d1 = Cartesian3_default.fromArray(extrudeDirections, i1 * 3, p1Scratch);
1833
- const d2 = Cartesian3_default.fromArray(extrudeDirections, i2 * 3, p2Scratch);
1834
- Cartesian3_default.multiplyByScalar(d0, coords.x, d0);
1835
- Cartesian3_default.multiplyByScalar(d1, coords.y, d1);
1836
- Cartesian3_default.multiplyByScalar(d2, coords.z, d2);
1837
- let direction;
1838
- if (!Cartesian3_default.equals(d0, Cartesian3_default.ZERO) || !Cartesian3_default.equals(d1, Cartesian3_default.ZERO) || !Cartesian3_default.equals(d2, Cartesian3_default.ZERO)) {
1839
- direction = Cartesian3_default.add(d0, d1, d0);
1840
- Cartesian3_default.add(direction, d2, direction);
1841
- Cartesian3_default.normalize(direction, direction);
1842
- } else {
1843
- direction = p0Scratch;
1844
- direction.x = 0;
1845
- direction.y = 0;
1846
- direction.z = 0;
1847
- }
1848
- Cartesian3_default.pack(
1849
- direction,
1850
- currentAttributes.extrudeDirection.values,
1851
- insertedIndex * 3
1852
- );
1853
- }
1854
- if (defined_default(applyOffset)) {
1855
- interpolateAndPackBoolean(
1856
- i0,
1857
- i1,
1858
- i2,
1859
- coords,
1860
- applyOffset,
1861
- currentAttributes.applyOffset.values,
1862
- insertedIndex
1863
- );
1864
- }
1865
- if (defined_default(tangents)) {
1866
- interpolateAndPackCartesian3(
1867
- i0,
1868
- i1,
1869
- i2,
1870
- coords,
1871
- tangents,
1872
- currentAttributes.tangent.values,
1873
- insertedIndex,
1874
- true
1875
- );
1876
- }
1877
- if (defined_default(bitangents)) {
1878
- interpolateAndPackCartesian3(
1879
- i0,
1880
- i1,
1881
- i2,
1882
- coords,
1883
- bitangents,
1884
- currentAttributes.bitangent.values,
1885
- insertedIndex,
1886
- true
1887
- );
1888
- }
1889
- if (defined_default(texCoords)) {
1890
- interpolateAndPackCartesian2(
1891
- i0,
1892
- i1,
1893
- i2,
1894
- coords,
1895
- texCoords,
1896
- currentAttributes.st.values,
1897
- insertedIndex
1898
- );
1899
- }
1900
- if (customAttributesLength > 0) {
1901
- for (let i = 0; i < customAttributesLength; i++) {
1902
- const attributeName = customAttributeNames[i];
1903
- genericInterpolate(
1904
- i0,
1905
- i1,
1906
- i2,
1907
- coords,
1908
- insertedIndex,
1909
- allAttributes[attributeName],
1910
- currentAttributes[attributeName]
1911
- );
1912
- }
1913
- }
1914
- }
1915
- function genericInterpolate(i0, i1, i2, coords, insertedIndex, sourceAttribute, currentAttribute) {
1916
- const componentsPerAttribute = sourceAttribute.componentsPerAttribute;
1917
- const sourceValues = sourceAttribute.values;
1918
- const currentValues = currentAttribute.values;
1919
- switch (componentsPerAttribute) {
1920
- case 4:
1921
- interpolateAndPackCartesian4(
1922
- i0,
1923
- i1,
1924
- i2,
1925
- coords,
1926
- sourceValues,
1927
- currentValues,
1928
- insertedIndex,
1929
- false
1930
- );
1931
- break;
1932
- case 3:
1933
- interpolateAndPackCartesian3(
1934
- i0,
1935
- i1,
1936
- i2,
1937
- coords,
1938
- sourceValues,
1939
- currentValues,
1940
- insertedIndex,
1941
- false
1942
- );
1943
- break;
1944
- case 2:
1945
- interpolateAndPackCartesian2(
1946
- i0,
1947
- i1,
1948
- i2,
1949
- coords,
1950
- sourceValues,
1951
- currentValues,
1952
- insertedIndex,
1953
- false
1954
- );
1955
- break;
1956
- default:
1957
- currentValues[insertedIndex] = sourceValues[i0] * coords.x + sourceValues[i1] * coords.y + sourceValues[i2] * coords.z;
1958
- }
1959
- }
1960
- function insertSplitPoint(currentAttributes, currentIndices, currentIndexMap, indices, currentIndex, point) {
1961
- const insertIndex = currentAttributes.position.values.length / 3;
1962
- if (currentIndex !== -1) {
1963
- const prevIndex = indices[currentIndex];
1964
- const newIndex = currentIndexMap[prevIndex];
1965
- if (newIndex === -1) {
1966
- currentIndexMap[prevIndex] = insertIndex;
1967
- currentAttributes.position.values.push(point.x, point.y, point.z);
1968
- currentIndices.push(insertIndex);
1969
- return insertIndex;
1970
- }
1971
- currentIndices.push(newIndex);
1972
- return newIndex;
1973
- }
1974
- currentAttributes.position.values.push(point.x, point.y, point.z);
1975
- currentIndices.push(insertIndex);
1976
- return insertIndex;
1977
- }
1978
- var NAMED_ATTRIBUTES = {
1979
- position: true,
1980
- normal: true,
1981
- bitangent: true,
1982
- tangent: true,
1983
- st: true,
1984
- extrudeDirection: true,
1985
- applyOffset: true
1986
- };
1987
- function splitLongitudeTriangles(instance) {
1988
- const geometry = instance.geometry;
1989
- const attributes = geometry.attributes;
1990
- const positions = attributes.position.values;
1991
- const normals = defined_default(attributes.normal) ? attributes.normal.values : void 0;
1992
- const bitangents = defined_default(attributes.bitangent) ? attributes.bitangent.values : void 0;
1993
- const tangents = defined_default(attributes.tangent) ? attributes.tangent.values : void 0;
1994
- const texCoords = defined_default(attributes.st) ? attributes.st.values : void 0;
1995
- const extrudeDirections = defined_default(attributes.extrudeDirection) ? attributes.extrudeDirection.values : void 0;
1996
- const applyOffset = defined_default(attributes.applyOffset) ? attributes.applyOffset.values : void 0;
1997
- const indices = geometry.indices;
1998
- const customAttributeNames = [];
1999
- for (const attributeName in attributes) {
2000
- if (attributes.hasOwnProperty(attributeName) && !NAMED_ATTRIBUTES[attributeName] && defined_default(attributes[attributeName])) {
2001
- customAttributeNames.push(attributeName);
2002
- }
2003
- }
2004
- const customAttributesLength = customAttributeNames.length;
2005
- const eastGeometry = copyGeometryForSplit(geometry);
2006
- const westGeometry = copyGeometryForSplit(geometry);
2007
- let currentAttributes;
2008
- let currentIndices;
2009
- let currentIndexMap;
2010
- let insertedIndex;
2011
- let i;
2012
- const westGeometryIndexMap = [];
2013
- westGeometryIndexMap.length = positions.length / 3;
2014
- const eastGeometryIndexMap = [];
2015
- eastGeometryIndexMap.length = positions.length / 3;
2016
- for (i = 0; i < westGeometryIndexMap.length; ++i) {
2017
- westGeometryIndexMap[i] = -1;
2018
- eastGeometryIndexMap[i] = -1;
2019
- }
2020
- const len = indices.length;
2021
- for (i = 0; i < len; i += 3) {
2022
- const i0 = indices[i];
2023
- const i1 = indices[i + 1];
2024
- const i2 = indices[i + 2];
2025
- let p0 = Cartesian3_default.fromArray(positions, i0 * 3);
2026
- let p1 = Cartesian3_default.fromArray(positions, i1 * 3);
2027
- let p2 = Cartesian3_default.fromArray(positions, i2 * 3);
2028
- const result = splitTriangle(p0, p1, p2);
2029
- if (defined_default(result) && result.positions.length > 3) {
2030
- const resultPositions = result.positions;
2031
- const resultIndices = result.indices;
2032
- const resultLength = resultIndices.length;
2033
- for (let j = 0; j < resultLength; ++j) {
2034
- const resultIndex = resultIndices[j];
2035
- const point = resultPositions[resultIndex];
2036
- if (point.y < 0) {
2037
- currentAttributes = westGeometry.attributes;
2038
- currentIndices = westGeometry.indices;
2039
- currentIndexMap = westGeometryIndexMap;
2040
- } else {
2041
- currentAttributes = eastGeometry.attributes;
2042
- currentIndices = eastGeometry.indices;
2043
- currentIndexMap = eastGeometryIndexMap;
2044
- }
2045
- insertedIndex = insertSplitPoint(
2046
- currentAttributes,
2047
- currentIndices,
2048
- currentIndexMap,
2049
- indices,
2050
- resultIndex < 3 ? i + resultIndex : -1,
2051
- point
2052
- );
2053
- computeTriangleAttributes(
2054
- i0,
2055
- i1,
2056
- i2,
2057
- point,
2058
- positions,
2059
- normals,
2060
- tangents,
2061
- bitangents,
2062
- texCoords,
2063
- extrudeDirections,
2064
- applyOffset,
2065
- currentAttributes,
2066
- customAttributeNames,
2067
- customAttributesLength,
2068
- attributes,
2069
- insertedIndex
2070
- );
2071
- }
2072
- } else {
2073
- if (defined_default(result)) {
2074
- p0 = result.positions[0];
2075
- p1 = result.positions[1];
2076
- p2 = result.positions[2];
2077
- }
2078
- if (p0.y < 0) {
2079
- currentAttributes = westGeometry.attributes;
2080
- currentIndices = westGeometry.indices;
2081
- currentIndexMap = westGeometryIndexMap;
2082
- } else {
2083
- currentAttributes = eastGeometry.attributes;
2084
- currentIndices = eastGeometry.indices;
2085
- currentIndexMap = eastGeometryIndexMap;
2086
- }
2087
- insertedIndex = insertSplitPoint(
2088
- currentAttributes,
2089
- currentIndices,
2090
- currentIndexMap,
2091
- indices,
2092
- i,
2093
- p0
2094
- );
2095
- computeTriangleAttributes(
2096
- i0,
2097
- i1,
2098
- i2,
2099
- p0,
2100
- positions,
2101
- normals,
2102
- tangents,
2103
- bitangents,
2104
- texCoords,
2105
- extrudeDirections,
2106
- applyOffset,
2107
- currentAttributes,
2108
- customAttributeNames,
2109
- customAttributesLength,
2110
- attributes,
2111
- insertedIndex
2112
- );
2113
- insertedIndex = insertSplitPoint(
2114
- currentAttributes,
2115
- currentIndices,
2116
- currentIndexMap,
2117
- indices,
2118
- i + 1,
2119
- p1
2120
- );
2121
- computeTriangleAttributes(
2122
- i0,
2123
- i1,
2124
- i2,
2125
- p1,
2126
- positions,
2127
- normals,
2128
- tangents,
2129
- bitangents,
2130
- texCoords,
2131
- extrudeDirections,
2132
- applyOffset,
2133
- currentAttributes,
2134
- customAttributeNames,
2135
- customAttributesLength,
2136
- attributes,
2137
- insertedIndex
2138
- );
2139
- insertedIndex = insertSplitPoint(
2140
- currentAttributes,
2141
- currentIndices,
2142
- currentIndexMap,
2143
- indices,
2144
- i + 2,
2145
- p2
2146
- );
2147
- computeTriangleAttributes(
2148
- i0,
2149
- i1,
2150
- i2,
2151
- p2,
2152
- positions,
2153
- normals,
2154
- tangents,
2155
- bitangents,
2156
- texCoords,
2157
- extrudeDirections,
2158
- applyOffset,
2159
- currentAttributes,
2160
- customAttributeNames,
2161
- customAttributesLength,
2162
- attributes,
2163
- insertedIndex
2164
- );
2165
- }
2166
- }
2167
- updateInstanceAfterSplit(instance, westGeometry, eastGeometry);
2168
- }
2169
- var xzPlane = Plane_default.fromPointNormal(Cartesian3_default.ZERO, Cartesian3_default.UNIT_Y);
2170
- var offsetScratch = new Cartesian3_default();
2171
- var offsetPointScratch = new Cartesian3_default();
2172
- function computeLineAttributes(i0, i1, point, positions, insertIndex, currentAttributes, applyOffset) {
2173
- if (!defined_default(applyOffset)) {
2174
- return;
2175
- }
2176
- const p0 = Cartesian3_default.fromArray(positions, i0 * 3, p0Scratch);
2177
- if (Cartesian3_default.equalsEpsilon(p0, point, Math_default.EPSILON10)) {
2178
- currentAttributes.applyOffset.values[insertIndex] = applyOffset[i0];
2179
- } else {
2180
- currentAttributes.applyOffset.values[insertIndex] = applyOffset[i1];
2181
- }
2182
- }
2183
- function splitLongitudeLines(instance) {
2184
- const geometry = instance.geometry;
2185
- const attributes = geometry.attributes;
2186
- const positions = attributes.position.values;
2187
- const applyOffset = defined_default(attributes.applyOffset) ? attributes.applyOffset.values : void 0;
2188
- const indices = geometry.indices;
2189
- const eastGeometry = copyGeometryForSplit(geometry);
2190
- const westGeometry = copyGeometryForSplit(geometry);
2191
- let i;
2192
- const length = indices.length;
2193
- const westGeometryIndexMap = [];
2194
- westGeometryIndexMap.length = positions.length / 3;
2195
- const eastGeometryIndexMap = [];
2196
- eastGeometryIndexMap.length = positions.length / 3;
2197
- for (i = 0; i < westGeometryIndexMap.length; ++i) {
2198
- westGeometryIndexMap[i] = -1;
2199
- eastGeometryIndexMap[i] = -1;
2200
- }
2201
- for (i = 0; i < length; i += 2) {
2202
- const i0 = indices[i];
2203
- const i1 = indices[i + 1];
2204
- const p0 = Cartesian3_default.fromArray(positions, i0 * 3, p0Scratch);
2205
- const p1 = Cartesian3_default.fromArray(positions, i1 * 3, p1Scratch);
2206
- let insertIndex;
2207
- if (Math.abs(p0.y) < Math_default.EPSILON6) {
2208
- if (p0.y < 0) {
2209
- p0.y = -Math_default.EPSILON6;
2210
- } else {
2211
- p0.y = Math_default.EPSILON6;
2212
- }
2213
- }
2214
- if (Math.abs(p1.y) < Math_default.EPSILON6) {
2215
- if (p1.y < 0) {
2216
- p1.y = -Math_default.EPSILON6;
2217
- } else {
2218
- p1.y = Math_default.EPSILON6;
2219
- }
2220
- }
2221
- let p0Attributes = eastGeometry.attributes;
2222
- let p0Indices = eastGeometry.indices;
2223
- let p0IndexMap = eastGeometryIndexMap;
2224
- let p1Attributes = westGeometry.attributes;
2225
- let p1Indices = westGeometry.indices;
2226
- let p1IndexMap = westGeometryIndexMap;
2227
- const intersection = IntersectionTests_default.lineSegmentPlane(
2228
- p0,
2229
- p1,
2230
- xzPlane,
2231
- p2Scratch
2232
- );
2233
- if (defined_default(intersection)) {
2234
- const offset = Cartesian3_default.multiplyByScalar(
2235
- Cartesian3_default.UNIT_Y,
2236
- 5 * Math_default.EPSILON9,
2237
- offsetScratch
2238
- );
2239
- if (p0.y < 0) {
2240
- Cartesian3_default.negate(offset, offset);
2241
- p0Attributes = westGeometry.attributes;
2242
- p0Indices = westGeometry.indices;
2243
- p0IndexMap = westGeometryIndexMap;
2244
- p1Attributes = eastGeometry.attributes;
2245
- p1Indices = eastGeometry.indices;
2246
- p1IndexMap = eastGeometryIndexMap;
2247
- }
2248
- const offsetPoint = Cartesian3_default.add(
2249
- intersection,
2250
- offset,
2251
- offsetPointScratch
2252
- );
2253
- insertIndex = insertSplitPoint(
2254
- p0Attributes,
2255
- p0Indices,
2256
- p0IndexMap,
2257
- indices,
2258
- i,
2259
- p0
2260
- );
2261
- computeLineAttributes(
2262
- i0,
2263
- i1,
2264
- p0,
2265
- positions,
2266
- insertIndex,
2267
- p0Attributes,
2268
- applyOffset
2269
- );
2270
- insertIndex = insertSplitPoint(
2271
- p0Attributes,
2272
- p0Indices,
2273
- p0IndexMap,
2274
- indices,
2275
- -1,
2276
- offsetPoint
2277
- );
2278
- computeLineAttributes(
2279
- i0,
2280
- i1,
2281
- offsetPoint,
2282
- positions,
2283
- insertIndex,
2284
- p0Attributes,
2285
- applyOffset
2286
- );
2287
- Cartesian3_default.negate(offset, offset);
2288
- Cartesian3_default.add(intersection, offset, offsetPoint);
2289
- insertIndex = insertSplitPoint(
2290
- p1Attributes,
2291
- p1Indices,
2292
- p1IndexMap,
2293
- indices,
2294
- -1,
2295
- offsetPoint
2296
- );
2297
- computeLineAttributes(
2298
- i0,
2299
- i1,
2300
- offsetPoint,
2301
- positions,
2302
- insertIndex,
2303
- p1Attributes,
2304
- applyOffset
2305
- );
2306
- insertIndex = insertSplitPoint(
2307
- p1Attributes,
2308
- p1Indices,
2309
- p1IndexMap,
2310
- indices,
2311
- i + 1,
2312
- p1
2313
- );
2314
- computeLineAttributes(
2315
- i0,
2316
- i1,
2317
- p1,
2318
- positions,
2319
- insertIndex,
2320
- p1Attributes,
2321
- applyOffset
2322
- );
2323
- } else {
2324
- let currentAttributes;
2325
- let currentIndices;
2326
- let currentIndexMap;
2327
- if (p0.y < 0) {
2328
- currentAttributes = westGeometry.attributes;
2329
- currentIndices = westGeometry.indices;
2330
- currentIndexMap = westGeometryIndexMap;
2331
- } else {
2332
- currentAttributes = eastGeometry.attributes;
2333
- currentIndices = eastGeometry.indices;
2334
- currentIndexMap = eastGeometryIndexMap;
2335
- }
2336
- insertIndex = insertSplitPoint(
2337
- currentAttributes,
2338
- currentIndices,
2339
- currentIndexMap,
2340
- indices,
2341
- i,
2342
- p0
2343
- );
2344
- computeLineAttributes(
2345
- i0,
2346
- i1,
2347
- p0,
2348
- positions,
2349
- insertIndex,
2350
- currentAttributes,
2351
- applyOffset
2352
- );
2353
- insertIndex = insertSplitPoint(
2354
- currentAttributes,
2355
- currentIndices,
2356
- currentIndexMap,
2357
- indices,
2358
- i + 1,
2359
- p1
2360
- );
2361
- computeLineAttributes(
2362
- i0,
2363
- i1,
2364
- p1,
2365
- positions,
2366
- insertIndex,
2367
- currentAttributes,
2368
- applyOffset
2369
- );
2370
- }
2371
- }
2372
- updateInstanceAfterSplit(instance, westGeometry, eastGeometry);
2373
- }
2374
- var cartesian2Scratch0 = new Cartesian2_default();
2375
- var cartesian2Scratch1 = new Cartesian2_default();
2376
- var cartesian3Scratch0 = new Cartesian3_default();
2377
- var cartesian3Scratch2 = new Cartesian3_default();
2378
- var cartesian3Scratch3 = new Cartesian3_default();
2379
- var cartesian3Scratch4 = new Cartesian3_default();
2380
- var cartesian3Scratch5 = new Cartesian3_default();
2381
- var cartesian3Scratch6 = new Cartesian3_default();
2382
- var cartesian4Scratch0 = new Cartesian4_default();
2383
- function updateAdjacencyAfterSplit(geometry) {
2384
- const attributes = geometry.attributes;
2385
- const positions = attributes.position.values;
2386
- const prevPositions = attributes.prevPosition.values;
2387
- const nextPositions = attributes.nextPosition.values;
2388
- const length = positions.length;
2389
- for (let j = 0; j < length; j += 3) {
2390
- const position = Cartesian3_default.unpack(positions, j, cartesian3Scratch0);
2391
- if (position.x > 0) {
2392
- continue;
2393
- }
2394
- const prevPosition = Cartesian3_default.unpack(
2395
- prevPositions,
2396
- j,
2397
- cartesian3Scratch2
2398
- );
2399
- if (position.y < 0 && prevPosition.y > 0 || position.y > 0 && prevPosition.y < 0) {
2400
- if (j - 3 > 0) {
2401
- prevPositions[j] = positions[j - 3];
2402
- prevPositions[j + 1] = positions[j - 2];
2403
- prevPositions[j + 2] = positions[j - 1];
2404
- } else {
2405
- Cartesian3_default.pack(position, prevPositions, j);
2406
- }
2407
- }
2408
- const nextPosition = Cartesian3_default.unpack(
2409
- nextPositions,
2410
- j,
2411
- cartesian3Scratch3
2412
- );
2413
- if (position.y < 0 && nextPosition.y > 0 || position.y > 0 && nextPosition.y < 0) {
2414
- if (j + 3 < length) {
2415
- nextPositions[j] = positions[j + 3];
2416
- nextPositions[j + 1] = positions[j + 4];
2417
- nextPositions[j + 2] = positions[j + 5];
2418
- } else {
2419
- Cartesian3_default.pack(position, nextPositions, j);
2420
- }
2421
- }
2422
- }
2423
- }
2424
- var offsetScalar = 5 * Math_default.EPSILON9;
2425
- var coplanarOffset = Math_default.EPSILON6;
2426
- function splitLongitudePolyline(instance) {
2427
- const geometry = instance.geometry;
2428
- const attributes = geometry.attributes;
2429
- const positions = attributes.position.values;
2430
- const prevPositions = attributes.prevPosition.values;
2431
- const nextPositions = attributes.nextPosition.values;
2432
- const expandAndWidths = attributes.expandAndWidth.values;
2433
- const texCoords = defined_default(attributes.st) ? attributes.st.values : void 0;
2434
- const colors = defined_default(attributes.color) ? attributes.color.values : void 0;
2435
- const eastGeometry = copyGeometryForSplit(geometry);
2436
- const westGeometry = copyGeometryForSplit(geometry);
2437
- let i;
2438
- let j;
2439
- let index;
2440
- let intersectionFound = false;
2441
- const length = positions.length / 3;
2442
- for (i = 0; i < length; i += 4) {
2443
- const i0 = i;
2444
- const i2 = i + 2;
2445
- const p0 = Cartesian3_default.fromArray(positions, i0 * 3, cartesian3Scratch0);
2446
- const p2 = Cartesian3_default.fromArray(positions, i2 * 3, cartesian3Scratch2);
2447
- if (Math.abs(p0.y) < coplanarOffset) {
2448
- p0.y = coplanarOffset * (p2.y < 0 ? -1 : 1);
2449
- positions[i * 3 + 1] = p0.y;
2450
- positions[(i + 1) * 3 + 1] = p0.y;
2451
- for (j = i0 * 3; j < i0 * 3 + 4 * 3; j += 3) {
2452
- prevPositions[j] = positions[i * 3];
2453
- prevPositions[j + 1] = positions[i * 3 + 1];
2454
- prevPositions[j + 2] = positions[i * 3 + 2];
2455
- }
2456
- }
2457
- if (Math.abs(p2.y) < coplanarOffset) {
2458
- p2.y = coplanarOffset * (p0.y < 0 ? -1 : 1);
2459
- positions[(i + 2) * 3 + 1] = p2.y;
2460
- positions[(i + 3) * 3 + 1] = p2.y;
2461
- for (j = i0 * 3; j < i0 * 3 + 4 * 3; j += 3) {
2462
- nextPositions[j] = positions[(i + 2) * 3];
2463
- nextPositions[j + 1] = positions[(i + 2) * 3 + 1];
2464
- nextPositions[j + 2] = positions[(i + 2) * 3 + 2];
2465
- }
2466
- }
2467
- let p0Attributes = eastGeometry.attributes;
2468
- let p0Indices = eastGeometry.indices;
2469
- let p2Attributes = westGeometry.attributes;
2470
- let p2Indices = westGeometry.indices;
2471
- const intersection = IntersectionTests_default.lineSegmentPlane(
2472
- p0,
2473
- p2,
2474
- xzPlane,
2475
- cartesian3Scratch4
2476
- );
2477
- if (defined_default(intersection)) {
2478
- intersectionFound = true;
2479
- const offset = Cartesian3_default.multiplyByScalar(
2480
- Cartesian3_default.UNIT_Y,
2481
- offsetScalar,
2482
- cartesian3Scratch5
2483
- );
2484
- if (p0.y < 0) {
2485
- Cartesian3_default.negate(offset, offset);
2486
- p0Attributes = westGeometry.attributes;
2487
- p0Indices = westGeometry.indices;
2488
- p2Attributes = eastGeometry.attributes;
2489
- p2Indices = eastGeometry.indices;
2490
- }
2491
- const offsetPoint = Cartesian3_default.add(
2492
- intersection,
2493
- offset,
2494
- cartesian3Scratch6
2495
- );
2496
- p0Attributes.position.values.push(p0.x, p0.y, p0.z, p0.x, p0.y, p0.z);
2497
- p0Attributes.position.values.push(
2498
- offsetPoint.x,
2499
- offsetPoint.y,
2500
- offsetPoint.z
2501
- );
2502
- p0Attributes.position.values.push(
2503
- offsetPoint.x,
2504
- offsetPoint.y,
2505
- offsetPoint.z
2506
- );
2507
- p0Attributes.prevPosition.values.push(
2508
- prevPositions[i0 * 3],
2509
- prevPositions[i0 * 3 + 1],
2510
- prevPositions[i0 * 3 + 2]
2511
- );
2512
- p0Attributes.prevPosition.values.push(
2513
- prevPositions[i0 * 3 + 3],
2514
- prevPositions[i0 * 3 + 4],
2515
- prevPositions[i0 * 3 + 5]
2516
- );
2517
- p0Attributes.prevPosition.values.push(p0.x, p0.y, p0.z, p0.x, p0.y, p0.z);
2518
- p0Attributes.nextPosition.values.push(
2519
- offsetPoint.x,
2520
- offsetPoint.y,
2521
- offsetPoint.z
2522
- );
2523
- p0Attributes.nextPosition.values.push(
2524
- offsetPoint.x,
2525
- offsetPoint.y,
2526
- offsetPoint.z
2527
- );
2528
- p0Attributes.nextPosition.values.push(
2529
- offsetPoint.x,
2530
- offsetPoint.y,
2531
- offsetPoint.z
2532
- );
2533
- p0Attributes.nextPosition.values.push(
2534
- offsetPoint.x,
2535
- offsetPoint.y,
2536
- offsetPoint.z
2537
- );
2538
- Cartesian3_default.negate(offset, offset);
2539
- Cartesian3_default.add(intersection, offset, offsetPoint);
2540
- p2Attributes.position.values.push(
2541
- offsetPoint.x,
2542
- offsetPoint.y,
2543
- offsetPoint.z
2544
- );
2545
- p2Attributes.position.values.push(
2546
- offsetPoint.x,
2547
- offsetPoint.y,
2548
- offsetPoint.z
2549
- );
2550
- p2Attributes.position.values.push(p2.x, p2.y, p2.z, p2.x, p2.y, p2.z);
2551
- p2Attributes.prevPosition.values.push(
2552
- offsetPoint.x,
2553
- offsetPoint.y,
2554
- offsetPoint.z
2555
- );
2556
- p2Attributes.prevPosition.values.push(
2557
- offsetPoint.x,
2558
- offsetPoint.y,
2559
- offsetPoint.z
2560
- );
2561
- p2Attributes.prevPosition.values.push(
2562
- offsetPoint.x,
2563
- offsetPoint.y,
2564
- offsetPoint.z
2565
- );
2566
- p2Attributes.prevPosition.values.push(
2567
- offsetPoint.x,
2568
- offsetPoint.y,
2569
- offsetPoint.z
2570
- );
2571
- p2Attributes.nextPosition.values.push(p2.x, p2.y, p2.z, p2.x, p2.y, p2.z);
2572
- p2Attributes.nextPosition.values.push(
2573
- nextPositions[i2 * 3],
2574
- nextPositions[i2 * 3 + 1],
2575
- nextPositions[i2 * 3 + 2]
2576
- );
2577
- p2Attributes.nextPosition.values.push(
2578
- nextPositions[i2 * 3 + 3],
2579
- nextPositions[i2 * 3 + 4],
2580
- nextPositions[i2 * 3 + 5]
2581
- );
2582
- const ew0 = Cartesian2_default.fromArray(
2583
- expandAndWidths,
2584
- i0 * 2,
2585
- cartesian2Scratch0
2586
- );
2587
- const width = Math.abs(ew0.y);
2588
- p0Attributes.expandAndWidth.values.push(-1, width, 1, width);
2589
- p0Attributes.expandAndWidth.values.push(-1, -width, 1, -width);
2590
- p2Attributes.expandAndWidth.values.push(-1, width, 1, width);
2591
- p2Attributes.expandAndWidth.values.push(-1, -width, 1, -width);
2592
- let t = Cartesian3_default.magnitudeSquared(
2593
- Cartesian3_default.subtract(intersection, p0, cartesian3Scratch3)
2594
- );
2595
- t /= Cartesian3_default.magnitudeSquared(
2596
- Cartesian3_default.subtract(p2, p0, cartesian3Scratch3)
2597
- );
2598
- if (defined_default(colors)) {
2599
- const c0 = Cartesian4_default.fromArray(colors, i0 * 4, cartesian4Scratch0);
2600
- const c2 = Cartesian4_default.fromArray(colors, i2 * 4, cartesian4Scratch0);
2601
- const r = Math_default.lerp(c0.x, c2.x, t);
2602
- const g = Math_default.lerp(c0.y, c2.y, t);
2603
- const b = Math_default.lerp(c0.z, c2.z, t);
2604
- const a = Math_default.lerp(c0.w, c2.w, t);
2605
- for (j = i0 * 4; j < i0 * 4 + 2 * 4; ++j) {
2606
- p0Attributes.color.values.push(colors[j]);
2607
- }
2608
- p0Attributes.color.values.push(r, g, b, a);
2609
- p0Attributes.color.values.push(r, g, b, a);
2610
- p2Attributes.color.values.push(r, g, b, a);
2611
- p2Attributes.color.values.push(r, g, b, a);
2612
- for (j = i2 * 4; j < i2 * 4 + 2 * 4; ++j) {
2613
- p2Attributes.color.values.push(colors[j]);
2614
- }
2615
- }
2616
- if (defined_default(texCoords)) {
2617
- const s0 = Cartesian2_default.fromArray(texCoords, i0 * 2, cartesian2Scratch0);
2618
- const s3 = Cartesian2_default.fromArray(
2619
- texCoords,
2620
- (i + 3) * 2,
2621
- cartesian2Scratch1
2622
- );
2623
- const sx = Math_default.lerp(s0.x, s3.x, t);
2624
- for (j = i0 * 2; j < i0 * 2 + 2 * 2; ++j) {
2625
- p0Attributes.st.values.push(texCoords[j]);
2626
- }
2627
- p0Attributes.st.values.push(sx, s0.y);
2628
- p0Attributes.st.values.push(sx, s3.y);
2629
- p2Attributes.st.values.push(sx, s0.y);
2630
- p2Attributes.st.values.push(sx, s3.y);
2631
- for (j = i2 * 2; j < i2 * 2 + 2 * 2; ++j) {
2632
- p2Attributes.st.values.push(texCoords[j]);
2633
- }
2634
- }
2635
- index = p0Attributes.position.values.length / 3 - 4;
2636
- p0Indices.push(index, index + 2, index + 1);
2637
- p0Indices.push(index + 1, index + 2, index + 3);
2638
- index = p2Attributes.position.values.length / 3 - 4;
2639
- p2Indices.push(index, index + 2, index + 1);
2640
- p2Indices.push(index + 1, index + 2, index + 3);
2641
- } else {
2642
- let currentAttributes;
2643
- let currentIndices;
2644
- if (p0.y < 0) {
2645
- currentAttributes = westGeometry.attributes;
2646
- currentIndices = westGeometry.indices;
2647
- } else {
2648
- currentAttributes = eastGeometry.attributes;
2649
- currentIndices = eastGeometry.indices;
2650
- }
2651
- currentAttributes.position.values.push(p0.x, p0.y, p0.z);
2652
- currentAttributes.position.values.push(p0.x, p0.y, p0.z);
2653
- currentAttributes.position.values.push(p2.x, p2.y, p2.z);
2654
- currentAttributes.position.values.push(p2.x, p2.y, p2.z);
2655
- for (j = i * 3; j < i * 3 + 4 * 3; ++j) {
2656
- currentAttributes.prevPosition.values.push(prevPositions[j]);
2657
- currentAttributes.nextPosition.values.push(nextPositions[j]);
2658
- }
2659
- for (j = i * 2; j < i * 2 + 4 * 2; ++j) {
2660
- currentAttributes.expandAndWidth.values.push(expandAndWidths[j]);
2661
- if (defined_default(texCoords)) {
2662
- currentAttributes.st.values.push(texCoords[j]);
2663
- }
2664
- }
2665
- if (defined_default(colors)) {
2666
- for (j = i * 4; j < i * 4 + 4 * 4; ++j) {
2667
- currentAttributes.color.values.push(colors[j]);
2668
- }
2669
- }
2670
- index = currentAttributes.position.values.length / 3 - 4;
2671
- currentIndices.push(index, index + 2, index + 1);
2672
- currentIndices.push(index + 1, index + 2, index + 3);
2673
- }
2674
- }
2675
- if (intersectionFound) {
2676
- updateAdjacencyAfterSplit(westGeometry);
2677
- updateAdjacencyAfterSplit(eastGeometry);
2678
- }
2679
- updateInstanceAfterSplit(instance, westGeometry, eastGeometry);
2680
- }
2681
- GeometryPipeline.splitLongitude = function(instance) {
2682
- if (!defined_default(instance)) {
2683
- throw new DeveloperError_default("instance is required.");
2684
- }
2685
- const geometry = instance.geometry;
2686
- const boundingSphere = geometry.boundingSphere;
2687
- if (defined_default(boundingSphere)) {
2688
- const minX = boundingSphere.center.x - boundingSphere.radius;
2689
- if (minX > 0 || BoundingSphere_default.intersectPlane(boundingSphere, Plane_default.ORIGIN_ZX_PLANE) !== Intersect_default.INTERSECTING) {
2690
- return instance;
2691
- }
2692
- }
2693
- if (geometry.geometryType !== GeometryType_default.NONE) {
2694
- switch (geometry.geometryType) {
2695
- case GeometryType_default.POLYLINES:
2696
- splitLongitudePolyline(instance);
2697
- break;
2698
- case GeometryType_default.TRIANGLES:
2699
- splitLongitudeTriangles(instance);
2700
- break;
2701
- case GeometryType_default.LINES:
2702
- splitLongitudeLines(instance);
2703
- break;
2704
- }
2705
- } else {
2706
- indexPrimitive(geometry);
2707
- if (geometry.primitiveType === PrimitiveType_default.TRIANGLES) {
2708
- splitLongitudeTriangles(instance);
2709
- } else if (geometry.primitiveType === PrimitiveType_default.LINES) {
2710
- splitLongitudeLines(instance);
2711
- }
2712
- }
2713
- return instance;
2714
- };
2715
- var GeometryPipeline_default = GeometryPipeline;
2716
-
2717
- export {
2718
- GeometryPipeline_default
2719
- };