@cesium/engine 6.2.0 → 8.0.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 (268) hide show
  1. package/Build/ThirdParty/Workers/z-worker-pako.js +568 -407
  2. package/Build/Workers/{chunk-RH4N2ONY.js → chunk-23UFSGND.js} +7 -7
  3. package/Build/Workers/{chunk-HPP4JLNH.js → chunk-2A75IWRS.js} +7 -7
  4. package/Build/Workers/{chunk-5IRLXUTA.js → chunk-2FRVPMCS.js} +10 -10
  5. package/Build/Workers/{chunk-ZQRZBHYI.js → chunk-2FWRMUTY.js} +4 -4
  6. package/Build/Workers/{chunk-Z2SIPUKB.js → chunk-2UPKWTMJ.js} +6 -6
  7. package/Build/Workers/{chunk-434ZTTFX.js → chunk-34FXV7D7.js} +2 -2
  8. package/Build/Workers/{chunk-MW3CJYLX.js → chunk-3VAZEH7M.js} +2 -2
  9. package/Build/Workers/{chunk-HUPNRBWW.js → chunk-4DO5W5XZ.js} +6 -6
  10. package/Build/Workers/{chunk-PIXK6KHB.js → chunk-4H7PY4U5.js} +2 -2
  11. package/Build/Workers/{chunk-BP467WX3.js → chunk-5QULIR53.js} +4 -4
  12. package/Build/Workers/{chunk-R3HUGXBH.js → chunk-7TC63SJW.js} +8 -8
  13. package/Build/Workers/{chunk-SQVTYRZY.js → chunk-7ZFGPDJA.js} +4 -4
  14. package/Build/Workers/{chunk-TIXXVKUY.js → chunk-A5DWLWCY.js} +10 -10
  15. package/Build/Workers/{chunk-CWJQGBWT.js → chunk-BBWDMCVU.js} +1 -1
  16. package/Build/Workers/{chunk-4KP73B43.js → chunk-BG4UCVXN.js} +3 -3
  17. package/Build/Workers/{chunk-Y4OJ4B23.js → chunk-BIKA3NRA.js} +5 -5
  18. package/Build/Workers/{chunk-DR5XZ6K5.js → chunk-BROJAZRZ.js} +13 -13
  19. package/Build/Workers/{chunk-FWGNCYP6.js → chunk-DDUQAJ4P.js} +7 -7
  20. package/Build/Workers/{chunk-QRBRVGZC.js → chunk-EERJKOAF.js} +4 -4
  21. package/Build/Workers/{chunk-52VSIKEA.js → chunk-EG6PTBY2.js} +15 -15
  22. package/Build/Workers/{chunk-O43GWBSF.js → chunk-EHWHNOEX.js} +1 -1
  23. package/Build/Workers/{chunk-MN34FIF5.js → chunk-F3YA3Y2Z.js} +1 -1
  24. package/Build/Workers/{chunk-GF5TNNKP.js → chunk-F4HFJMGM.js} +6 -6
  25. package/Build/Workers/{chunk-HOT2SNXP.js → chunk-FJKNFAKQ.js} +133 -553
  26. package/Build/Workers/{chunk-TMPVBFJQ.js → chunk-FNIRWHJB.js} +10 -10
  27. package/Build/Workers/{chunk-DMCSY5BU.js → chunk-FZRIVR7Y.js} +5 -5
  28. package/Build/Workers/{chunk-Z4JUBRHP.js → chunk-G43QFN4Q.js} +6 -6
  29. package/Build/Workers/{chunk-HPH5HSFE.js → chunk-GATZHF3K.js} +2 -2
  30. package/Build/Workers/{chunk-CSIZ3BGT.js → chunk-GRC2ZTAF.js} +14 -14
  31. package/Build/Workers/{chunk-NE4JNU6H.js → chunk-HU6N6EXB.js} +10 -10
  32. package/Build/Workers/{chunk-GVL5I7TC.js → chunk-I46ZRR5W.js} +17 -17
  33. package/Build/Workers/{chunk-5GDBZTHX.js → chunk-JURN7NPV.js} +17 -17
  34. package/Build/Workers/{chunk-H5DUXHCV.js → chunk-KKCR2YOP.js} +11 -11
  35. package/Build/Workers/{chunk-LX6XV4DK.js → chunk-LPR3YNP2.js} +5 -5
  36. package/Build/Workers/{chunk-HFKSAB5K.js → chunk-M7ERACJJ.js} +13 -13
  37. package/Build/Workers/{chunk-BUZDZBUH.js → chunk-MDWEGWPA.js} +10 -10
  38. package/Build/Workers/{chunk-LGJUI2CE.js → chunk-OGXZVPPM.js} +9 -5
  39. package/Build/Workers/{chunk-PZ2WJWUG.js → chunk-PGSJK77E.js} +6 -6
  40. package/Build/Workers/{chunk-ARPTYYKS.js → chunk-PPH7OFP3.js} +5 -5
  41. package/Build/Workers/{chunk-R4OZKBXH.js → chunk-SH5USDPI.js} +6 -6
  42. package/Build/Workers/{chunk-SV7DDPAC.js → chunk-SOWMRMWA.js} +1 -1
  43. package/Build/Workers/{chunk-RIDPF7PO.js → chunk-STW2DGFI.js} +2 -2
  44. package/Build/Workers/{chunk-CDGHUKQ4.js → chunk-T3XIFPYR.js} +13 -13
  45. package/Build/Workers/chunk-TTUZP4BO.js +501 -0
  46. package/Build/Workers/{chunk-QTZQZY2C.js → chunk-UEXTBDBE.js} +34 -10
  47. package/Build/Workers/{chunk-XUTVA4K5.js → chunk-VOXYEYJT.js} +11 -11
  48. package/Build/Workers/{chunk-AXFRNOVC.js → chunk-X4356LRH.js} +12 -12
  49. package/Build/Workers/{chunk-5HLGKKG3.js → chunk-XGI5BXZY.js} +2 -2
  50. package/Build/Workers/{chunk-SNN7WOC2.js → chunk-Y2ME2IJV.js} +13 -13
  51. package/Build/Workers/{chunk-LGL4P5KL.js → chunk-Y5UQJLYE.js} +6 -6
  52. package/Build/Workers/{chunk-3PW6ZBN4.js → chunk-YJEBABKH.js} +7 -7
  53. package/Build/Workers/{chunk-YBKFS53K.js → chunk-YWTJ2B4B.js} +1 -1
  54. package/Build/Workers/{chunk-5SK36PU4.js → chunk-Z3TIFFGF.js} +7 -7
  55. package/Build/Workers/{chunk-JGG36SQV.js → chunk-ZT7KWISZ.js} +4 -4
  56. package/Build/Workers/combineGeometry.js +24 -23
  57. package/Build/Workers/createBoxGeometry.js +18 -17
  58. package/Build/Workers/createBoxOutlineGeometry.js +16 -15
  59. package/Build/Workers/createCircleGeometry.js +26 -25
  60. package/Build/Workers/createCircleOutlineGeometry.js +19 -18
  61. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -32
  62. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -30
  63. package/Build/Workers/createCorridorGeometry.js +29 -29
  64. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  65. package/Build/Workers/createCylinderGeometry.js +20 -19
  66. package/Build/Workers/createCylinderOutlineGeometry.js +18 -17
  67. package/Build/Workers/createEllipseGeometry.js +26 -25
  68. package/Build/Workers/createEllipseOutlineGeometry.js +19 -18
  69. package/Build/Workers/createEllipsoidGeometry.js +19 -18
  70. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -17
  71. package/Build/Workers/createFrustumGeometry.js +18 -17
  72. package/Build/Workers/createFrustumOutlineGeometry.js +18 -17
  73. package/Build/Workers/createGeometry.js +54 -33
  74. package/Build/Workers/createGroundPolylineGeometry.js +22 -21
  75. package/Build/Workers/createPlaneGeometry.js +16 -15
  76. package/Build/Workers/createPlaneOutlineGeometry.js +15 -14
  77. package/Build/Workers/createPolygonGeometry.js +32 -166
  78. package/Build/Workers/createPolygonOutlineGeometry.js +30 -29
  79. package/Build/Workers/createPolylineGeometry.js +25 -24
  80. package/Build/Workers/createPolylineVolumeGeometry.js +32 -33
  81. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  82. package/Build/Workers/createRectangleGeometry.js +27 -26
  83. package/Build/Workers/createRectangleOutlineGeometry.js +20 -19
  84. package/Build/Workers/createSimplePolylineGeometry.js +23 -22
  85. package/Build/Workers/createSphereGeometry.js +19 -18
  86. package/Build/Workers/createSphereOutlineGeometry.js +18 -17
  87. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  88. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  89. package/Build/Workers/createVectorTileGeometries.js +24 -23
  90. package/Build/Workers/createVectorTilePoints.js +12 -12
  91. package/Build/Workers/createVectorTilePolygons.js +22 -21
  92. package/Build/Workers/createVectorTilePolylines.js +14 -14
  93. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -21
  94. package/Build/Workers/createVerticesFromHeightmap.js +22 -21
  95. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -18
  96. package/Build/Workers/createWallGeometry.js +24 -23
  97. package/Build/Workers/createWallOutlineGeometry.js +23 -22
  98. package/Build/Workers/decodeDraco.js +11 -11
  99. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  100. package/Build/Workers/decodeI3S.js +601 -92
  101. package/Build/Workers/transcodeKTX2.js +7 -7
  102. package/Build/Workers/transferTypedArrayTest.js +1 -1
  103. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -21
  104. package/LICENSE.md +1 -1
  105. package/Source/Assets/approximateTerrainHeights.json +1 -1
  106. package/Source/Core/Ellipsoid.js +6 -0
  107. package/Source/Core/GregorianDate.js +85 -0
  108. package/Source/Core/HeadingPitchRange.js +2 -2
  109. package/Source/Core/IntersectionTests.js +6 -3
  110. package/Source/Core/Ion.js +1 -1
  111. package/Source/Core/PixelFormat.js +5 -0
  112. package/Source/Core/PolygonGeometry.js +0 -169
  113. package/Source/Core/Resource.js +30 -69
  114. package/Source/Core/Transforms.js +30 -18
  115. package/Source/Core/createWorldBathymetryAsync.js +45 -0
  116. package/Source/Core/srgbToLinear.js +32 -0
  117. package/Source/DataSources/CzmlDataSource.js +51 -23
  118. package/Source/DataSources/DataSourceDisplay.js +27 -0
  119. package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -4
  120. package/Source/DataSources/Entity.js +28 -7
  121. package/Source/DataSources/EntityCollection.js +1 -2
  122. package/Source/DataSources/GeometryUpdater.js +1 -2
  123. package/Source/DataSources/GeometryUpdaterSet.js +114 -0
  124. package/Source/DataSources/GeometryVisualizer.js +19 -83
  125. package/Source/DataSources/GroundGeometryUpdater.js +6 -3
  126. package/Source/DataSources/ModelVisualizer.js +19 -98
  127. package/Source/DataSources/PolygonGeometryUpdater.js +14 -2
  128. package/Source/DataSources/PolylineGeometryUpdater.js +9 -8
  129. package/Source/DataSources/TerrainOffsetProperty.js +15 -23
  130. package/Source/Renderer/AutomaticUniforms.js +121 -1
  131. package/Source/Renderer/Context.js +10 -0
  132. package/Source/Renderer/ContextLimits.js +2 -0
  133. package/Source/Renderer/UniformState.js +127 -0
  134. package/Source/Renderer/demodernizeShader.js +4 -1
  135. package/Source/Scene/ArcGisMapService.js +1 -1
  136. package/Source/Scene/Atmosphere.js +127 -0
  137. package/Source/Scene/Axis.js +12 -7
  138. package/Source/Scene/Billboard.js +29 -26
  139. package/Source/Scene/BillboardCollection.js +3 -3
  140. package/Source/Scene/Camera.js +47 -5
  141. package/Source/Scene/Cesium3DTile.js +1 -0
  142. package/Source/Scene/Cesium3DTileContent.js +14 -0
  143. package/Source/Scene/Cesium3DTileset.js +364 -45
  144. package/Source/Scene/Cesium3DTilesetBaseTraversal.js +2 -4
  145. package/Source/Scene/Cesium3DTilesetTraversal.js +4 -0
  146. package/Source/Scene/Composite3DTileContent.js +42 -0
  147. package/Source/Scene/DynamicAtmosphereLightingType.js +56 -0
  148. package/Source/Scene/Empty3DTileContent.js +4 -0
  149. package/Source/Scene/Fog.js +1 -0
  150. package/Source/Scene/FrameState.js +14 -1
  151. package/Source/Scene/Geometry3DTileContent.js +4 -0
  152. package/Source/Scene/Globe.js +3 -2
  153. package/Source/Scene/GlobeSurfaceTileProvider.js +3 -1
  154. package/Source/Scene/GlobeTranslucencyState.js +1 -1
  155. package/Source/Scene/GltfLoader.js +15 -5
  156. package/Source/Scene/GltfPipeline/updateVersion.js +69 -68
  157. package/Source/Scene/HeightReference.js +59 -2
  158. package/Source/Scene/I3SDataProvider.js +270 -53
  159. package/Source/Scene/I3SDecoder.js +8 -1
  160. package/Source/Scene/I3SFeature.js +2 -5
  161. package/Source/Scene/I3SField.js +136 -31
  162. package/Source/Scene/I3SGeometry.js +70 -2
  163. package/Source/Scene/I3SLayer.js +55 -10
  164. package/Source/Scene/I3SNode.js +175 -18
  165. package/Source/Scene/I3SStatistics.js +94 -0
  166. package/Source/Scene/I3SSublayer.js +176 -0
  167. package/Source/Scene/I3SSymbology.js +337 -0
  168. package/Source/Scene/Implicit3DTileContent.js +4 -0
  169. package/Source/Scene/KeyframeNode.js +1 -1
  170. package/Source/Scene/LabelCollection.js +2 -2
  171. package/Source/Scene/Model/AtmospherePipelineStage.js +59 -0
  172. package/Source/Scene/Model/B3dmLoader.js +4 -0
  173. package/Source/Scene/Model/FeatureIdPipelineStage.js +25 -2
  174. package/Source/Scene/Model/I3dmLoader.js +4 -0
  175. package/Source/Scene/Model/InstancingPipelineStage.js +24 -6
  176. package/Source/Scene/Model/MetadataPipelineStage.js +31 -3
  177. package/Source/Scene/Model/Model.js +82 -32
  178. package/Source/Scene/Model/Model3DTileContent.js +31 -0
  179. package/Source/Scene/Model/ModelAnimationChannel.js +16 -15
  180. package/Source/Scene/Model/ModelSceneGraph.js +6 -0
  181. package/Source/Scene/Model/pickModel.js +426 -0
  182. package/Source/Scene/Multiple3DTileContent.js +42 -0
  183. package/Source/Scene/PickFramebuffer.js +37 -2
  184. package/Source/Scene/Picking.js +113 -39
  185. package/Source/Scene/Primitive.js +6 -2
  186. package/Source/Scene/QuadtreePrimitive.js +1 -1
  187. package/Source/Scene/Scene.js +312 -46
  188. package/Source/Scene/ScreenSpaceCameraController.js +23 -13
  189. package/Source/Scene/SensorVolumePortionToDisplay.js +69 -0
  190. package/Source/Scene/SkyAtmosphere.js +5 -6
  191. package/Source/Scene/SpatialNode.js +12 -19
  192. package/Source/Scene/StructuralMetadata.js +1 -1
  193. package/Source/Scene/Terrain.js +49 -0
  194. package/Source/Scene/TileBoundingS2Cell.js +2 -2
  195. package/Source/Scene/Tileset3DTileContent.js +4 -0
  196. package/Source/Scene/Vector3DTileContent.js +4 -0
  197. package/Source/Scene/VoxelBoxShape.js +76 -0
  198. package/Source/Scene/VoxelCell.js +273 -0
  199. package/Source/Scene/VoxelCylinderShape.js +114 -43
  200. package/Source/Scene/VoxelEllipsoidShape.js +158 -116
  201. package/Source/Scene/VoxelPrimitive.js +3 -1
  202. package/Source/Scene/VoxelRenderResources.js +3 -0
  203. package/Source/Scene/VoxelShape.js +13 -0
  204. package/Source/Scene/VoxelTraversal.js +76 -54
  205. package/Source/Scene/buildVoxelDrawCommands.js +23 -0
  206. package/Source/Scene/createGooglePhotorealistic3DTileset.js +1 -0
  207. package/Source/Scene/processVoxelProperties.js +2 -0
  208. package/Source/Shaders/AtmosphereCommon.glsl +3 -11
  209. package/Source/Shaders/AtmosphereCommon.js +3 -11
  210. package/Source/Shaders/Builtin/CzmBuiltins.js +12 -0
  211. package/Source/Shaders/Builtin/Functions/applyHSBShift.glsl +32 -0
  212. package/Source/Shaders/Builtin/Functions/applyHSBShift.js +34 -0
  213. package/Source/Shaders/Builtin/Functions/approximateTanh.glsl +10 -0
  214. package/Source/Shaders/Builtin/Functions/approximateTanh.js +12 -0
  215. package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.glsl +44 -0
  216. package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.js +46 -0
  217. package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.glsl +30 -0
  218. package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.js +32 -0
  219. package/Source/Shaders/Builtin/Functions/computeScattering.glsl +150 -0
  220. package/Source/Shaders/Builtin/Functions/computeScattering.js +152 -0
  221. package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.glsl +22 -0
  222. package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.js +24 -0
  223. package/Source/Shaders/Builtin/Functions/translateRelativeToEye.glsl +5 -0
  224. package/Source/Shaders/Builtin/Functions/translateRelativeToEye.js +5 -0
  225. package/Source/Shaders/GlobeFS.glsl +16 -25
  226. package/Source/Shaders/GlobeFS.js +16 -25
  227. package/Source/Shaders/GlobeVS.glsl +1 -1
  228. package/Source/Shaders/GlobeVS.js +1 -1
  229. package/Source/Shaders/Model/AtmosphereStageFS.glsl +111 -0
  230. package/Source/Shaders/Model/AtmosphereStageFS.js +113 -0
  231. package/Source/Shaders/Model/AtmosphereStageVS.glsl +12 -0
  232. package/Source/Shaders/Model/AtmosphereStageVS.js +14 -0
  233. package/Source/Shaders/Model/GeometryStageFS.glsl +1 -1
  234. package/Source/Shaders/Model/GeometryStageFS.js +1 -1
  235. package/Source/Shaders/Model/GeometryStageVS.glsl +4 -4
  236. package/Source/Shaders/Model/GeometryStageVS.js +4 -4
  237. package/Source/Shaders/Model/ModelColorStageFS.glsl +1 -1
  238. package/Source/Shaders/Model/ModelColorStageFS.js +2 -1
  239. package/Source/Shaders/Model/ModelFS.glsl +4 -0
  240. package/Source/Shaders/Model/ModelFS.js +4 -0
  241. package/Source/Shaders/Model/ModelVS.glsl +9 -4
  242. package/Source/Shaders/Model/ModelVS.js +9 -4
  243. package/Source/Shaders/SkyAtmosphereCommon.glsl +3 -13
  244. package/Source/Shaders/SkyAtmosphereCommon.js +3 -13
  245. package/Source/Shaders/SkyAtmosphereFS.glsl +5 -10
  246. package/Source/Shaders/SkyAtmosphereFS.js +5 -10
  247. package/Source/Shaders/SkyAtmosphereVS.glsl +3 -2
  248. package/Source/Shaders/SkyAtmosphereVS.js +3 -2
  249. package/Source/Shaders/Voxels/IntersectCylinder.glsl +14 -111
  250. package/Source/Shaders/Voxels/IntersectCylinder.js +14 -111
  251. package/Source/Shaders/Voxels/IntersectEllipsoid.glsl +32 -113
  252. package/Source/Shaders/Voxels/IntersectEllipsoid.js +32 -113
  253. package/Source/Shaders/Voxels/IntersectLongitude.glsl +102 -0
  254. package/Source/Shaders/Voxels/IntersectLongitude.js +104 -0
  255. package/Source/Shaders/Voxels/VoxelFS.glsl +39 -1
  256. package/Source/Shaders/Voxels/VoxelFS.js +39 -1
  257. package/Source/Shaders/Voxels/convertUvToCylinder.glsl +19 -37
  258. package/Source/Shaders/Voxels/convertUvToCylinder.js +19 -37
  259. package/Source/Shaders/Voxels/convertUvToEllipsoid.glsl +24 -44
  260. package/Source/Shaders/Voxels/convertUvToEllipsoid.js +24 -44
  261. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  262. package/Source/ThirdParty/draco_decoder.wasm +0 -0
  263. package/Source/Workers/createGeometry.js +40 -11
  264. package/Source/Workers/decodeI3S.js +720 -94
  265. package/index.d.ts +574 -71
  266. package/index.js +217 -196
  267. package/package.json +3 -3
  268. package/Build/Workers/chunk-ATB2I7OS.js +0 -55
@@ -0,0 +1,426 @@
1
+ import AttributeCompression from "../../Core/AttributeCompression.js";
2
+ import BoundingSphere from "../../Core/BoundingSphere.js";
3
+ import Cartesian3 from "../../Core/Cartesian3.js";
4
+ import Cartographic from "../../Core/Cartographic.js";
5
+ import Check from "../../Core/Check.js";
6
+ import ComponentDatatype from "../../Core/ComponentDatatype.js";
7
+ import defaultValue from "../../Core/defaultValue.js";
8
+ import defined from "../../Core/defined.js";
9
+ import Ellipsoid from "../../Core/Ellipsoid.js";
10
+ import IndexDatatype from "../../Core/IndexDatatype.js";
11
+ import IntersectionTests from "../../Core/IntersectionTests.js";
12
+ import Ray from "../../Core/Ray.js";
13
+ import Matrix4 from "../../Core/Matrix4.js";
14
+ import Transforms from "../../Core/Transforms.js";
15
+ import VerticalExaggeration from "../../Core/VerticalExaggeration.js";
16
+ import AttributeType from "../AttributeType.js";
17
+ import SceneMode from "../SceneMode.js";
18
+ import VertexAttributeSemantic from "../VertexAttributeSemantic.js";
19
+ import ModelUtility from "./ModelUtility.js";
20
+
21
+ const scratchV0 = new Cartesian3();
22
+ const scratchV1 = new Cartesian3();
23
+ const scratchV2 = new Cartesian3();
24
+ const scratchNodeComputedTransform = new Matrix4();
25
+ const scratchModelMatrix = new Matrix4();
26
+ const scratchcomputedModelMatrix = new Matrix4();
27
+ const scratchPickCartographic = new Cartographic();
28
+ const scratchBoundingSphere = new BoundingSphere();
29
+
30
+ /**
31
+ * Find an intersection between a ray and the model surface that was rendered. The ray must be given in world coordinates.
32
+ *
33
+ * @param {Model} model The model to pick.
34
+ * @param {Ray} ray The ray to test for intersection.
35
+ * @param {FrameState} frameState The frame state.
36
+ * @param {number} [verticalExaggeration=1.0] A scalar used to exaggerate the height of a position relative to the ellipsoid. If the value is 1.0 there will be no effect.
37
+ * @param {number} [relativeHeight=0.0] The ellipsoid height relative to which a position is exaggerated. If the value is 0.0 the position will be exaggerated relative to the ellipsoid surface.
38
+ * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid to which the exaggerated position is relative.
39
+ * @param {Cartesian3|undefined} [result] The intersection or <code>undefined</code> if none was found.
40
+ * @returns {Cartesian3|undefined} The intersection or <code>undefined</code> if none was found.
41
+ *
42
+ * @private
43
+ */
44
+ export default function pickModel(
45
+ model,
46
+ ray,
47
+ frameState,
48
+ verticalExaggeration,
49
+ relativeHeight,
50
+ ellipsoid,
51
+ result
52
+ ) {
53
+ //>>includeStart('debug', pragmas.debug);
54
+ Check.typeOf.object("model", model);
55
+ Check.typeOf.object("ray", ray);
56
+ Check.typeOf.object("frameState", frameState);
57
+ //>>includeEnd('debug');
58
+
59
+ if (!model._ready || frameState.mode === SceneMode.MORPHING) {
60
+ return;
61
+ }
62
+
63
+ let minT = Number.MAX_VALUE;
64
+ const sceneGraph = model.sceneGraph;
65
+
66
+ const nodes = sceneGraph._runtimeNodes;
67
+ for (let i = 0; i < nodes.length; i++) {
68
+ const runtimeNode = nodes[i];
69
+ const node = runtimeNode.node;
70
+
71
+ let nodeComputedTransform = Matrix4.clone(
72
+ runtimeNode.computedTransform,
73
+ scratchNodeComputedTransform
74
+ );
75
+ let modelMatrix = Matrix4.clone(
76
+ sceneGraph.computedModelMatrix,
77
+ scratchModelMatrix
78
+ );
79
+
80
+ const instances = node.instances;
81
+ if (defined(instances)) {
82
+ if (instances.transformInWorldSpace) {
83
+ // Replicate the multiplication order in LegacyInstancingStageVS.
84
+ modelMatrix = Matrix4.multiplyTransformation(
85
+ model.modelMatrix,
86
+ sceneGraph.components.transform,
87
+ modelMatrix
88
+ );
89
+
90
+ nodeComputedTransform = Matrix4.multiplyTransformation(
91
+ sceneGraph.axisCorrectionMatrix,
92
+ runtimeNode.computedTransform,
93
+ nodeComputedTransform
94
+ );
95
+ }
96
+ }
97
+
98
+ let computedModelMatrix = Matrix4.multiplyTransformation(
99
+ modelMatrix,
100
+ nodeComputedTransform,
101
+ scratchcomputedModelMatrix
102
+ );
103
+
104
+ if (frameState.mode !== SceneMode.SCENE3D) {
105
+ computedModelMatrix = Transforms.basisTo2D(
106
+ frameState.mapProjection,
107
+ computedModelMatrix,
108
+ computedModelMatrix
109
+ );
110
+ }
111
+
112
+ const transforms = [];
113
+ if (defined(instances)) {
114
+ const transformsCount = instances.attributes[0].count;
115
+ const instanceComponentDatatype =
116
+ instances.attributes[0].componentDatatype;
117
+
118
+ const transformElements = 12;
119
+ let transformsTypedArray = runtimeNode.transformsTypedArray;
120
+ if (!defined(transformsTypedArray)) {
121
+ const instanceTransformsBuffer = runtimeNode.instancingTransformsBuffer;
122
+ if (defined(instanceTransformsBuffer) && frameState.context.webgl2) {
123
+ transformsTypedArray = ComponentDatatype.createTypedArray(
124
+ instanceComponentDatatype,
125
+ transformsCount * transformElements
126
+ );
127
+ instanceTransformsBuffer.getBufferData(transformsTypedArray);
128
+ }
129
+ }
130
+
131
+ if (defined(transformsTypedArray)) {
132
+ for (let i = 0; i < transformsCount; i++) {
133
+ const index = i * transformElements;
134
+
135
+ const transform = new Matrix4(
136
+ transformsTypedArray[index],
137
+ transformsTypedArray[index + 1],
138
+ transformsTypedArray[index + 2],
139
+ transformsTypedArray[index + 3],
140
+ transformsTypedArray[index + 4],
141
+ transformsTypedArray[index + 5],
142
+ transformsTypedArray[index + 6],
143
+ transformsTypedArray[index + 7],
144
+ transformsTypedArray[index + 8],
145
+ transformsTypedArray[index + 9],
146
+ transformsTypedArray[index + 10],
147
+ transformsTypedArray[index + 11],
148
+ 0,
149
+ 0,
150
+ 0,
151
+ 1
152
+ );
153
+
154
+ if (instances.transformInWorldSpace) {
155
+ Matrix4.multiplyTransformation(
156
+ transform,
157
+ nodeComputedTransform,
158
+ transform
159
+ );
160
+ Matrix4.multiplyTransformation(modelMatrix, transform, transform);
161
+ } else {
162
+ Matrix4.multiplyTransformation(
163
+ transform,
164
+ computedModelMatrix,
165
+ transform
166
+ );
167
+ }
168
+ transforms.push(transform);
169
+ }
170
+ }
171
+ }
172
+
173
+ if (transforms.length === 0) {
174
+ transforms.push(computedModelMatrix);
175
+ }
176
+
177
+ const primitivesLength = runtimeNode.runtimePrimitives.length;
178
+ for (let j = 0; j < primitivesLength; j++) {
179
+ const runtimePrimitive = runtimeNode.runtimePrimitives[j];
180
+ const primitive = runtimePrimitive.primitive;
181
+
182
+ if (defined(runtimePrimitive.boundingSphere) && !defined(instances)) {
183
+ const boundingSphere = BoundingSphere.transform(
184
+ runtimePrimitive.boundingSphere,
185
+ computedModelMatrix,
186
+ scratchBoundingSphere
187
+ );
188
+ const boundsIntersection = IntersectionTests.raySphere(
189
+ ray,
190
+ boundingSphere
191
+ );
192
+ if (!defined(boundsIntersection)) {
193
+ continue;
194
+ }
195
+ }
196
+
197
+ const positionAttribute = ModelUtility.getAttributeBySemantic(
198
+ primitive,
199
+ VertexAttributeSemantic.POSITION
200
+ );
201
+ const byteOffset = positionAttribute.byteOffset;
202
+ const byteStride = positionAttribute.byteStride;
203
+ const vertexCount = positionAttribute.count;
204
+
205
+ if (!defined(primitive.indices)) {
206
+ // Point clouds
207
+ continue;
208
+ }
209
+
210
+ let indices = primitive.indices.typedArray;
211
+ if (!defined(indices)) {
212
+ const indicesBuffer = primitive.indices.buffer;
213
+ const indicesCount = primitive.indices.count;
214
+ const indexDatatype = primitive.indices.indexDatatype;
215
+ if (defined(indicesBuffer) && frameState.context.webgl2) {
216
+ if (indexDatatype === IndexDatatype.UNSIGNED_BYTE) {
217
+ indices = new Uint8Array(indicesCount);
218
+ } else if (indexDatatype === IndexDatatype.UNSIGNED_SHORT) {
219
+ indices = new Uint16Array(indicesCount);
220
+ } else if (indexDatatype === IndexDatatype.UNSIGNED_INT) {
221
+ indices = new Uint32Array(indicesCount);
222
+ }
223
+
224
+ indicesBuffer.getBufferData(indices);
225
+ }
226
+ }
227
+
228
+ let vertices = positionAttribute.typedArray;
229
+ let componentDatatype = positionAttribute.componentDatatype;
230
+ let attributeType = positionAttribute.type;
231
+
232
+ const quantization = positionAttribute.quantization;
233
+ if (defined(quantization)) {
234
+ componentDatatype = positionAttribute.quantization.componentDatatype;
235
+ attributeType = positionAttribute.quantization.type;
236
+ }
237
+
238
+ const numComponents = AttributeType.getNumberOfComponents(attributeType);
239
+ const bytes = ComponentDatatype.getSizeInBytes(componentDatatype);
240
+ const isInterleaved =
241
+ !defined(vertices) &&
242
+ defined(byteStride) &&
243
+ byteStride !== numComponents * bytes;
244
+
245
+ let elementStride = numComponents;
246
+ let offset = 0;
247
+ if (isInterleaved) {
248
+ elementStride = byteStride / bytes;
249
+ offset = byteOffset / bytes;
250
+ }
251
+ const elementCount = vertexCount * elementStride;
252
+
253
+ if (!defined(vertices)) {
254
+ const verticesBuffer = positionAttribute.buffer;
255
+
256
+ if (defined(verticesBuffer) && frameState.context.webgl2) {
257
+ vertices = ComponentDatatype.createTypedArray(
258
+ componentDatatype,
259
+ elementCount
260
+ );
261
+ verticesBuffer.getBufferData(
262
+ vertices,
263
+ isInterleaved ? 0 : byteOffset,
264
+ 0,
265
+ elementCount
266
+ );
267
+ }
268
+
269
+ if (quantization && positionAttribute.normalized) {
270
+ vertices = AttributeCompression.dequantize(
271
+ vertices,
272
+ componentDatatype,
273
+ attributeType,
274
+ vertexCount
275
+ );
276
+ }
277
+ }
278
+
279
+ if (!defined(indices) || !defined(vertices)) {
280
+ return;
281
+ }
282
+
283
+ ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);
284
+ verticalExaggeration = defaultValue(verticalExaggeration, 1.0);
285
+ relativeHeight = defaultValue(relativeHeight, 0.0);
286
+
287
+ const indicesLength = indices.length;
288
+ for (let i = 0; i < indicesLength; i += 3) {
289
+ const i0 = indices[i];
290
+ const i1 = indices[i + 1];
291
+ const i2 = indices[i + 2];
292
+
293
+ for (const instanceTransform of transforms) {
294
+ const v0 = getVertexPosition(
295
+ vertices,
296
+ i0,
297
+ offset,
298
+ elementStride,
299
+ quantization,
300
+ instanceTransform,
301
+ verticalExaggeration,
302
+ relativeHeight,
303
+ ellipsoid,
304
+ scratchV0
305
+ );
306
+ const v1 = getVertexPosition(
307
+ vertices,
308
+ i1,
309
+ offset,
310
+ elementStride,
311
+ quantization,
312
+ instanceTransform,
313
+ verticalExaggeration,
314
+ relativeHeight,
315
+ ellipsoid,
316
+ scratchV1
317
+ );
318
+ const v2 = getVertexPosition(
319
+ vertices,
320
+ i2,
321
+ offset,
322
+ elementStride,
323
+ quantization,
324
+ instanceTransform,
325
+ verticalExaggeration,
326
+ relativeHeight,
327
+ ellipsoid,
328
+ scratchV2
329
+ );
330
+
331
+ const t = IntersectionTests.rayTriangleParametric(
332
+ ray,
333
+ v0,
334
+ v1,
335
+ v2,
336
+ defaultValue(model.backFaceCulling, true)
337
+ );
338
+
339
+ if (defined(t)) {
340
+ if (t < minT && t >= 0.0) {
341
+ minT = t;
342
+ }
343
+ }
344
+ }
345
+ }
346
+ }
347
+ }
348
+
349
+ if (minT === Number.MAX_VALUE) {
350
+ return undefined;
351
+ }
352
+
353
+ result = Ray.getPoint(ray, minT, result);
354
+ if (frameState.mode !== SceneMode.SCENE3D) {
355
+ Cartesian3.fromElements(result.y, result.z, result.x, result);
356
+
357
+ const projection = frameState.mapProjection;
358
+ const ellipsoid = projection.ellipsoid;
359
+
360
+ const cartographic = projection.unproject(result, scratchPickCartographic);
361
+ ellipsoid.cartographicToCartesian(cartographic, result);
362
+ }
363
+
364
+ return result;
365
+ }
366
+
367
+ function getVertexPosition(
368
+ vertices,
369
+ index,
370
+ offset,
371
+ numElements,
372
+ quantization,
373
+ instanceTransform,
374
+ verticalExaggeration,
375
+ relativeHeight,
376
+ ellipsoid,
377
+ result
378
+ ) {
379
+ const i = offset + index * numElements;
380
+ result.x = vertices[i];
381
+ result.y = vertices[i + 1];
382
+ result.z = vertices[i + 2];
383
+
384
+ if (defined(quantization)) {
385
+ if (quantization.octEncoded) {
386
+ result = AttributeCompression.octDecodeInRange(
387
+ result,
388
+ quantization.normalizationRange,
389
+ result
390
+ );
391
+
392
+ if (quantization.octEncodedZXY) {
393
+ const x = result.x;
394
+ result.x = result.z;
395
+ result.z = result.y;
396
+ result.y = x;
397
+ }
398
+ } else {
399
+ result = Cartesian3.multiplyComponents(
400
+ result,
401
+ quantization.quantizedVolumeStepSize,
402
+ result
403
+ );
404
+
405
+ result = Cartesian3.add(
406
+ result,
407
+ quantization.quantizedVolumeOffset,
408
+ result
409
+ );
410
+ }
411
+ }
412
+
413
+ result = Matrix4.multiplyByPoint(instanceTransform, result, result);
414
+
415
+ if (verticalExaggeration !== 1.0) {
416
+ VerticalExaggeration.getPosition(
417
+ result,
418
+ ellipsoid,
419
+ verticalExaggeration,
420
+ relativeHeight,
421
+ result
422
+ );
423
+ }
424
+
425
+ return result;
426
+ }
@@ -1,3 +1,4 @@
1
+ import Cartesian3 from "../Core/Cartesian3.js";
1
2
  import defined from "../Core/defined.js";
2
3
  import destroyObject from "../Core/destroyObject.js";
3
4
  import DeveloperError from "../Core/DeveloperError.js";
@@ -650,6 +651,47 @@ Multiple3DTileContent.prototype.update = function (tileset, frameState) {
650
651
  }
651
652
  };
652
653
 
654
+ /**
655
+ * Find an intersection between a ray and the tile content surface that was rendered. The ray must be given in world coordinates.
656
+ *
657
+ * @param {Ray} ray The ray to test for intersection.
658
+ * @param {FrameState} frameState The frame state.
659
+ * @param {Cartesian3|undefined} [result] The intersection or <code>undefined</code> if none was found.
660
+ * @returns {Cartesian3|undefined} The intersection or <code>undefined</code> if none was found.
661
+ *
662
+ * @private
663
+ */
664
+ Multiple3DTileContent.prototype.pick = function (ray, frameState, result) {
665
+ if (!this._ready) {
666
+ return undefined;
667
+ }
668
+
669
+ let intersection;
670
+ let minDistance = Number.POSITIVE_INFINITY;
671
+ const contents = this._contents;
672
+ const length = contents.length;
673
+
674
+ for (let i = 0; i < length; ++i) {
675
+ const candidate = contents[i].pick(ray, frameState, result);
676
+
677
+ if (!defined(candidate)) {
678
+ continue;
679
+ }
680
+
681
+ const distance = Cartesian3.distance(ray.origin, candidate);
682
+ if (distance < minDistance) {
683
+ intersection = candidate;
684
+ minDistance = distance;
685
+ }
686
+ }
687
+
688
+ if (!defined(intersection)) {
689
+ return undefined;
690
+ }
691
+
692
+ return result;
693
+ };
694
+
653
695
  Multiple3DTileContent.prototype.isDestroyed = function () {
654
696
  return false;
655
697
  };
@@ -27,10 +27,10 @@ function PickFramebuffer(context) {
27
27
  this._width = 0;
28
28
  this._height = 0;
29
29
  }
30
+
30
31
  PickFramebuffer.prototype.begin = function (screenSpaceRectangle, viewport) {
31
32
  const context = this._context;
32
- const width = viewport.width;
33
- const height = viewport.height;
33
+ const { width, height } = viewport;
34
34
 
35
35
  BoundingRectangle.clone(
36
36
  screenSpaceRectangle,
@@ -51,6 +51,12 @@ PickFramebuffer.prototype.begin = function (screenSpaceRectangle, viewport) {
51
51
 
52
52
  const colorScratch = new Color();
53
53
 
54
+ /**
55
+ * Return the picked object rendered within a given rectangle.
56
+ *
57
+ * @param {BoundingRectangle} screenSpaceRectangle
58
+ * @returns {object|undefined} The object rendered in the middle of the rectangle, or undefined if nothing was rendered.
59
+ */
54
60
  PickFramebuffer.prototype.end = function (screenSpaceRectangle) {
55
61
  const width = defaultValue(screenSpaceRectangle.width, 1.0);
56
62
  const height = defaultValue(screenSpaceRectangle.height, 1.0);
@@ -114,6 +120,34 @@ PickFramebuffer.prototype.end = function (screenSpaceRectangle) {
114
120
  return undefined;
115
121
  };
116
122
 
123
+ /**
124
+ * Return voxel tile and sample information as rendered by a pickVoxel pass,
125
+ * within a given rectangle.
126
+ *
127
+ * @param {BoundingRectangle} screenSpaceRectangle
128
+ * @returns {TypedArray}
129
+ */
130
+ PickFramebuffer.prototype.readVoxelInfo = function (screenSpaceRectangle) {
131
+ const width = defaultValue(screenSpaceRectangle.width, 1.0);
132
+ const height = defaultValue(screenSpaceRectangle.height, 1.0);
133
+
134
+ const context = this._context;
135
+ const pixels = context.readPixels({
136
+ x: screenSpaceRectangle.x,
137
+ y: screenSpaceRectangle.y,
138
+ width: width,
139
+ height: height,
140
+ framebuffer: this._fb.framebuffer,
141
+ });
142
+
143
+ // Read the center pixel
144
+ const halfWidth = Math.floor(width * 0.5);
145
+ const halfHeight = Math.floor(height * 0.5);
146
+ const index = 4 * (halfHeight * width + halfWidth);
147
+
148
+ return pixels.slice(index, index + 4);
149
+ };
150
+
117
151
  PickFramebuffer.prototype.isDestroyed = function () {
118
152
  return false;
119
153
  };
@@ -122,4 +156,5 @@ PickFramebuffer.prototype.destroy = function () {
122
156
  this._fb.destroy();
123
157
  return destroyObject(this);
124
158
  };
159
+
125
160
  export default PickFramebuffer;