@cesium/engine 6.2.0 → 7.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 (210) hide show
  1. package/Build/ThirdParty/Workers/z-worker-pako.js +568 -407
  2. package/Build/Workers/{chunk-QRBRVGZC.js → chunk-2HJWSU7B.js} +4 -4
  3. package/Build/Workers/{chunk-ZQRZBHYI.js → chunk-46UD5ABS.js} +4 -4
  4. package/Build/Workers/{chunk-GVL5I7TC.js → chunk-4EBHOMFX.js} +17 -17
  5. package/Build/Workers/{chunk-CDGHUKQ4.js → chunk-5HDYHG3F.js} +13 -13
  6. package/Build/Workers/{chunk-CWJQGBWT.js → chunk-5M3U6ZMA.js} +1 -1
  7. package/Build/Workers/{chunk-Y4OJ4B23.js → chunk-5WQ523AW.js} +5 -5
  8. package/Build/Workers/{chunk-NE4JNU6H.js → chunk-5YLJ77FF.js} +10 -10
  9. package/Build/Workers/{chunk-SV7DDPAC.js → chunk-6HZQPRUS.js} +1 -1
  10. package/Build/Workers/{chunk-434ZTTFX.js → chunk-6VJVYK2V.js} +2 -2
  11. package/Build/Workers/{chunk-LGJUI2CE.js → chunk-72SANQJV.js} +5 -5
  12. package/Build/Workers/{chunk-QTZQZY2C.js → chunk-7XEAYGZK.js} +34 -10
  13. package/Build/Workers/{chunk-Z4JUBRHP.js → chunk-AIPU2VSX.js} +6 -6
  14. package/Build/Workers/{chunk-PZ2WJWUG.js → chunk-AR5DNBJ4.js} +6 -6
  15. package/Build/Workers/{chunk-BUZDZBUH.js → chunk-BZP4T2JJ.js} +10 -10
  16. package/Build/Workers/{chunk-Z2SIPUKB.js → chunk-DTAIXKTO.js} +6 -6
  17. package/Build/Workers/{chunk-HOT2SNXP.js → chunk-F6SE42BK.js} +127 -90
  18. package/Build/Workers/{chunk-TIXXVKUY.js → chunk-FP6GYBFX.js} +10 -10
  19. package/Build/Workers/{chunk-ARPTYYKS.js → chunk-GEJTYLCO.js} +5 -5
  20. package/Build/Workers/{chunk-XUTVA4K5.js → chunk-GV56Q4LU.js} +11 -11
  21. package/Build/Workers/{chunk-HPP4JLNH.js → chunk-IQBYFRVW.js} +7 -7
  22. package/Build/Workers/{chunk-O43GWBSF.js → chunk-IX2JCCNM.js} +1 -1
  23. package/Build/Workers/{chunk-H5DUXHCV.js → chunk-JCNXK6EL.js} +11 -11
  24. package/Build/Workers/{chunk-SQVTYRZY.js → chunk-JJ4VBOQ3.js} +4 -4
  25. package/Build/Workers/{chunk-RIDPF7PO.js → chunk-JXDC723O.js} +2 -2
  26. package/Build/Workers/{chunk-R3HUGXBH.js → chunk-JY5YEZFA.js} +8 -8
  27. package/Build/Workers/{chunk-GF5TNNKP.js → chunk-L2ZN645J.js} +6 -6
  28. package/Build/Workers/{chunk-5GDBZTHX.js → chunk-LZ7JIV3K.js} +17 -17
  29. package/Build/Workers/{chunk-52VSIKEA.js → chunk-LZGHD6NY.js} +15 -15
  30. package/Build/Workers/{chunk-RH4N2ONY.js → chunk-MY3VNFGQ.js} +7 -7
  31. package/Build/Workers/{chunk-MN34FIF5.js → chunk-NKPBIX7F.js} +1 -1
  32. package/Build/Workers/{chunk-AXFRNOVC.js → chunk-NY3K4IM3.js} +12 -12
  33. package/Build/Workers/{chunk-MW3CJYLX.js → chunk-ODW7WYM4.js} +2 -2
  34. package/Build/Workers/{chunk-R4OZKBXH.js → chunk-OVLG3FRS.js} +6 -6
  35. package/Build/Workers/{chunk-TMPVBFJQ.js → chunk-PNBGBETF.js} +10 -10
  36. package/Build/Workers/{chunk-DR5XZ6K5.js → chunk-PTQQUQC3.js} +13 -13
  37. package/Build/Workers/{chunk-3PW6ZBN4.js → chunk-QZAD5O7I.js} +7 -7
  38. package/Build/Workers/{chunk-5SK36PU4.js → chunk-R5X4OQT4.js} +7 -7
  39. package/Build/Workers/{chunk-DMCSY5BU.js → chunk-RAEV7K66.js} +5 -5
  40. package/Build/Workers/{chunk-BP467WX3.js → chunk-RV7ZYPFT.js} +4 -4
  41. package/Build/Workers/{chunk-5HLGKKG3.js → chunk-S4MAZ3SS.js} +2 -2
  42. package/Build/Workers/{chunk-LX6XV4DK.js → chunk-S6SKF6DT.js} +5 -5
  43. package/Build/Workers/{chunk-HUPNRBWW.js → chunk-U2VCRRQW.js} +6 -6
  44. package/Build/Workers/{chunk-SNN7WOC2.js → chunk-UAEW6HKG.js} +13 -13
  45. package/Build/Workers/{chunk-HFKSAB5K.js → chunk-UDO6BFSF.js} +13 -13
  46. package/Build/Workers/{chunk-YBKFS53K.js → chunk-UGK3FCDY.js} +1 -1
  47. package/Build/Workers/{chunk-PIXK6KHB.js → chunk-VK3EJHWI.js} +2 -2
  48. package/Build/Workers/{chunk-5IRLXUTA.js → chunk-VRGFV2UO.js} +7 -7
  49. package/Build/Workers/{chunk-JGG36SQV.js → chunk-WBQCVXR3.js} +4 -4
  50. package/Build/Workers/{chunk-4KP73B43.js → chunk-WZU2YLWG.js} +3 -3
  51. package/Build/Workers/{chunk-LGL4P5KL.js → chunk-XWXM2O2R.js} +6 -6
  52. package/Build/Workers/{chunk-FWGNCYP6.js → chunk-YUCVWAY6.js} +7 -7
  53. package/Build/Workers/{chunk-CSIZ3BGT.js → chunk-ZK5JOS3D.js} +14 -14
  54. package/Build/Workers/{chunk-HPH5HSFE.js → chunk-ZUA2UUNV.js} +2 -2
  55. package/Build/Workers/combineGeometry.js +23 -23
  56. package/Build/Workers/createBoxGeometry.js +17 -17
  57. package/Build/Workers/createBoxOutlineGeometry.js +15 -15
  58. package/Build/Workers/createCircleGeometry.js +25 -25
  59. package/Build/Workers/createCircleOutlineGeometry.js +18 -18
  60. package/Build/Workers/createCoplanarPolygonGeometry.js +32 -32
  61. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +30 -30
  62. package/Build/Workers/createCorridorGeometry.js +28 -29
  63. package/Build/Workers/createCorridorOutlineGeometry.js +27 -28
  64. package/Build/Workers/createCylinderGeometry.js +19 -19
  65. package/Build/Workers/createCylinderOutlineGeometry.js +17 -17
  66. package/Build/Workers/createEllipseGeometry.js +25 -25
  67. package/Build/Workers/createEllipseOutlineGeometry.js +18 -18
  68. package/Build/Workers/createEllipsoidGeometry.js +18 -18
  69. package/Build/Workers/createEllipsoidOutlineGeometry.js +17 -17
  70. package/Build/Workers/createFrustumGeometry.js +17 -17
  71. package/Build/Workers/createFrustumOutlineGeometry.js +17 -17
  72. package/Build/Workers/createGeometry.js +23 -23
  73. package/Build/Workers/createGroundPolylineGeometry.js +21 -21
  74. package/Build/Workers/createPlaneGeometry.js +15 -15
  75. package/Build/Workers/createPlaneOutlineGeometry.js +14 -14
  76. package/Build/Workers/createPolygonGeometry.js +31 -166
  77. package/Build/Workers/createPolygonOutlineGeometry.js +29 -29
  78. package/Build/Workers/createPolylineGeometry.js +24 -24
  79. package/Build/Workers/createPolylineVolumeGeometry.js +31 -33
  80. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +26 -27
  81. package/Build/Workers/createRectangleGeometry.js +26 -26
  82. package/Build/Workers/createRectangleOutlineGeometry.js +19 -19
  83. package/Build/Workers/createSimplePolylineGeometry.js +22 -22
  84. package/Build/Workers/createSphereGeometry.js +18 -18
  85. package/Build/Workers/createSphereOutlineGeometry.js +17 -17
  86. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  87. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  88. package/Build/Workers/createVectorTileGeometries.js +23 -23
  89. package/Build/Workers/createVectorTilePoints.js +12 -12
  90. package/Build/Workers/createVectorTilePolygons.js +21 -21
  91. package/Build/Workers/createVectorTilePolylines.js +14 -14
  92. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +21 -21
  93. package/Build/Workers/createVerticesFromHeightmap.js +21 -21
  94. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +18 -18
  95. package/Build/Workers/createWallGeometry.js +23 -23
  96. package/Build/Workers/createWallOutlineGeometry.js +22 -22
  97. package/Build/Workers/decodeDraco.js +11 -11
  98. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  99. package/Build/Workers/decodeI3S.js +9 -9
  100. package/Build/Workers/transcodeKTX2.js +7 -7
  101. package/Build/Workers/transferTypedArrayTest.js +1 -1
  102. package/Build/Workers/upsampleQuantizedTerrainMesh.js +21 -21
  103. package/LICENSE.md +1 -1
  104. package/Source/Assets/approximateTerrainHeights.json +1 -1
  105. package/Source/Core/GregorianDate.js +85 -0
  106. package/Source/Core/HeadingPitchRange.js +2 -2
  107. package/Source/Core/Ion.js +1 -1
  108. package/Source/Core/PolygonGeometry.js +0 -169
  109. package/Source/Core/Resource.js +30 -69
  110. package/Source/Core/Transforms.js +27 -18
  111. package/Source/Core/createWorldBathymetryAsync.js +45 -0
  112. package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -4
  113. package/Source/DataSources/Entity.js +8 -5
  114. package/Source/DataSources/EntityCollection.js +1 -2
  115. package/Source/DataSources/GeometryUpdater.js +1 -2
  116. package/Source/DataSources/GroundGeometryUpdater.js +6 -3
  117. package/Source/DataSources/ModelVisualizer.js +19 -98
  118. package/Source/DataSources/PolygonGeometryUpdater.js +14 -2
  119. package/Source/DataSources/PolylineGeometryUpdater.js +9 -8
  120. package/Source/DataSources/TerrainOffsetProperty.js +15 -23
  121. package/Source/Renderer/AutomaticUniforms.js +121 -1
  122. package/Source/Renderer/UniformState.js +127 -0
  123. package/Source/Scene/ArcGisMapService.js +1 -1
  124. package/Source/Scene/Atmosphere.js +127 -0
  125. package/Source/Scene/Billboard.js +29 -26
  126. package/Source/Scene/BillboardCollection.js +3 -3
  127. package/Source/Scene/Camera.js +1 -1
  128. package/Source/Scene/Cesium3DTile.js +1 -0
  129. package/Source/Scene/Cesium3DTileContent.js +14 -0
  130. package/Source/Scene/Cesium3DTileset.js +326 -45
  131. package/Source/Scene/Cesium3DTilesetTraversal.js +4 -0
  132. package/Source/Scene/Composite3DTileContent.js +42 -0
  133. package/Source/Scene/DynamicAtmosphereLightingType.js +56 -0
  134. package/Source/Scene/Empty3DTileContent.js +4 -0
  135. package/Source/Scene/Fog.js +1 -0
  136. package/Source/Scene/FrameState.js +9 -1
  137. package/Source/Scene/Geometry3DTileContent.js +4 -0
  138. package/Source/Scene/Globe.js +3 -2
  139. package/Source/Scene/GlobeSurfaceTileProvider.js +3 -1
  140. package/Source/Scene/GltfLoader.js +15 -5
  141. package/Source/Scene/HeightReference.js +59 -2
  142. package/Source/Scene/Implicit3DTileContent.js +4 -0
  143. package/Source/Scene/LabelCollection.js +2 -2
  144. package/Source/Scene/Model/AtmospherePipelineStage.js +59 -0
  145. package/Source/Scene/Model/B3dmLoader.js +4 -0
  146. package/Source/Scene/Model/FeatureIdPipelineStage.js +25 -2
  147. package/Source/Scene/Model/I3dmLoader.js +4 -0
  148. package/Source/Scene/Model/InstancingPipelineStage.js +24 -6
  149. package/Source/Scene/Model/MetadataPipelineStage.js +31 -3
  150. package/Source/Scene/Model/Model.js +82 -32
  151. package/Source/Scene/Model/Model3DTileContent.js +31 -0
  152. package/Source/Scene/Model/ModelAnimationChannel.js +16 -15
  153. package/Source/Scene/Model/ModelSceneGraph.js +6 -0
  154. package/Source/Scene/Model/pickModel.js +408 -0
  155. package/Source/Scene/Multiple3DTileContent.js +42 -0
  156. package/Source/Scene/QuadtreePrimitive.js +1 -1
  157. package/Source/Scene/Scene.js +198 -16
  158. package/Source/Scene/ScreenSpaceCameraController.js +2 -6
  159. package/Source/Scene/SkyAtmosphere.js +5 -6
  160. package/Source/Scene/Terrain.js +49 -0
  161. package/Source/Scene/TileBoundingS2Cell.js +2 -2
  162. package/Source/Scene/Tileset3DTileContent.js +4 -0
  163. package/Source/Scene/Vector3DTileContent.js +4 -0
  164. package/Source/Shaders/AtmosphereCommon.glsl +3 -11
  165. package/Source/Shaders/AtmosphereCommon.js +3 -11
  166. package/Source/Shaders/Builtin/CzmBuiltins.js +12 -0
  167. package/Source/Shaders/Builtin/Functions/applyHSBShift.glsl +32 -0
  168. package/Source/Shaders/Builtin/Functions/applyHSBShift.js +34 -0
  169. package/Source/Shaders/Builtin/Functions/approximateTanh.glsl +10 -0
  170. package/Source/Shaders/Builtin/Functions/approximateTanh.js +12 -0
  171. package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.glsl +44 -0
  172. package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.js +46 -0
  173. package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.glsl +30 -0
  174. package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.js +32 -0
  175. package/Source/Shaders/Builtin/Functions/computeScattering.glsl +150 -0
  176. package/Source/Shaders/Builtin/Functions/computeScattering.js +152 -0
  177. package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.glsl +22 -0
  178. package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.js +24 -0
  179. package/Source/Shaders/Builtin/Functions/translateRelativeToEye.glsl +5 -0
  180. package/Source/Shaders/Builtin/Functions/translateRelativeToEye.js +5 -0
  181. package/Source/Shaders/GlobeFS.glsl +16 -25
  182. package/Source/Shaders/GlobeFS.js +16 -25
  183. package/Source/Shaders/GlobeVS.glsl +1 -1
  184. package/Source/Shaders/GlobeVS.js +1 -1
  185. package/Source/Shaders/Model/AtmosphereStageFS.glsl +111 -0
  186. package/Source/Shaders/Model/AtmosphereStageFS.js +113 -0
  187. package/Source/Shaders/Model/AtmosphereStageVS.glsl +12 -0
  188. package/Source/Shaders/Model/AtmosphereStageVS.js +14 -0
  189. package/Source/Shaders/Model/GeometryStageFS.glsl +1 -1
  190. package/Source/Shaders/Model/GeometryStageFS.js +1 -1
  191. package/Source/Shaders/Model/GeometryStageVS.glsl +4 -4
  192. package/Source/Shaders/Model/GeometryStageVS.js +4 -4
  193. package/Source/Shaders/Model/ModelColorStageFS.glsl +1 -1
  194. package/Source/Shaders/Model/ModelColorStageFS.js +2 -1
  195. package/Source/Shaders/Model/ModelFS.glsl +4 -0
  196. package/Source/Shaders/Model/ModelFS.js +4 -0
  197. package/Source/Shaders/Model/ModelVS.glsl +9 -4
  198. package/Source/Shaders/Model/ModelVS.js +9 -4
  199. package/Source/Shaders/SkyAtmosphereCommon.glsl +3 -13
  200. package/Source/Shaders/SkyAtmosphereCommon.js +3 -13
  201. package/Source/Shaders/SkyAtmosphereFS.glsl +5 -10
  202. package/Source/Shaders/SkyAtmosphereFS.js +5 -10
  203. package/Source/Shaders/SkyAtmosphereVS.glsl +3 -2
  204. package/Source/Shaders/SkyAtmosphereVS.js +3 -2
  205. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  206. package/Source/ThirdParty/draco_decoder.wasm +0 -0
  207. package/index.d.ts +283 -65
  208. package/index.js +260 -247
  209. package/package.json +3 -3
  210. package/Build/Workers/chunk-ATB2I7OS.js +0 -55
@@ -0,0 +1,408 @@
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 vertexCount = positionAttribute.count;
202
+
203
+ if (!defined(primitive.indices)) {
204
+ // Point clouds
205
+ continue;
206
+ }
207
+
208
+ let indices = primitive.indices.typedArray;
209
+ if (!defined(indices)) {
210
+ const indicesBuffer = primitive.indices.buffer;
211
+ const indicesCount = primitive.indices.count;
212
+ const indexDatatype = primitive.indices.indexDatatype;
213
+ if (defined(indicesBuffer) && frameState.context.webgl2) {
214
+ if (indexDatatype === IndexDatatype.UNSIGNED_BYTE) {
215
+ indices = new Uint8Array(indicesCount);
216
+ } else if (indexDatatype === IndexDatatype.UNSIGNED_SHORT) {
217
+ indices = new Uint16Array(indicesCount);
218
+ } else if (indexDatatype === IndexDatatype.UNSIGNED_INT) {
219
+ indices = new Uint32Array(indicesCount);
220
+ }
221
+
222
+ indicesBuffer.getBufferData(indices);
223
+ }
224
+ }
225
+
226
+ let vertices = positionAttribute.typedArray;
227
+ let componentDatatype = positionAttribute.componentDatatype;
228
+ let attributeType = positionAttribute.type;
229
+
230
+ const quantization = positionAttribute.quantization;
231
+ if (defined(quantization)) {
232
+ componentDatatype = positionAttribute.quantization.componentDatatype;
233
+ attributeType = positionAttribute.quantization.type;
234
+ }
235
+
236
+ const numComponents = AttributeType.getNumberOfComponents(attributeType);
237
+ const elementCount = vertexCount * numComponents;
238
+
239
+ if (!defined(vertices)) {
240
+ const verticesBuffer = positionAttribute.buffer;
241
+
242
+ if (defined(verticesBuffer) && frameState.context.webgl2) {
243
+ vertices = ComponentDatatype.createTypedArray(
244
+ componentDatatype,
245
+ elementCount
246
+ );
247
+ verticesBuffer.getBufferData(
248
+ vertices,
249
+ positionAttribute.byteOffset,
250
+ 0,
251
+ elementCount
252
+ );
253
+ }
254
+
255
+ if (quantization && positionAttribute.normalized) {
256
+ vertices = AttributeCompression.dequantize(
257
+ vertices,
258
+ componentDatatype,
259
+ attributeType,
260
+ vertexCount
261
+ );
262
+ }
263
+ }
264
+
265
+ if (!defined(indices) || !defined(vertices)) {
266
+ return;
267
+ }
268
+
269
+ ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);
270
+ verticalExaggeration = defaultValue(verticalExaggeration, 1.0);
271
+ relativeHeight = defaultValue(relativeHeight, 0.0);
272
+
273
+ const indicesLength = indices.length;
274
+ for (let i = 0; i < indicesLength; i += 3) {
275
+ const i0 = indices[i];
276
+ const i1 = indices[i + 1];
277
+ const i2 = indices[i + 2];
278
+
279
+ for (const instanceTransform of transforms) {
280
+ const v0 = getVertexPosition(
281
+ vertices,
282
+ i0,
283
+ numComponents,
284
+ quantization,
285
+ instanceTransform,
286
+ verticalExaggeration,
287
+ relativeHeight,
288
+ ellipsoid,
289
+ scratchV0
290
+ );
291
+ const v1 = getVertexPosition(
292
+ vertices,
293
+ i1,
294
+ numComponents,
295
+ quantization,
296
+ instanceTransform,
297
+ verticalExaggeration,
298
+ relativeHeight,
299
+ ellipsoid,
300
+ scratchV1
301
+ );
302
+ const v2 = getVertexPosition(
303
+ vertices,
304
+ i2,
305
+ numComponents,
306
+ quantization,
307
+ instanceTransform,
308
+ verticalExaggeration,
309
+ relativeHeight,
310
+ ellipsoid,
311
+ scratchV2
312
+ );
313
+
314
+ const t = IntersectionTests.rayTriangleParametric(
315
+ ray,
316
+ v0,
317
+ v1,
318
+ v2,
319
+ defaultValue(model.backFaceCulling, true)
320
+ );
321
+
322
+ if (defined(t)) {
323
+ if (t < minT && t >= 0.0) {
324
+ minT = t;
325
+ }
326
+ }
327
+ }
328
+ }
329
+ }
330
+ }
331
+
332
+ if (minT === Number.MAX_VALUE) {
333
+ return undefined;
334
+ }
335
+
336
+ result = Ray.getPoint(ray, minT, result);
337
+ if (frameState.mode !== SceneMode.SCENE3D) {
338
+ Cartesian3.fromElements(result.y, result.z, result.x, result);
339
+
340
+ const projection = frameState.mapProjection;
341
+ const ellipsoid = projection.ellipsoid;
342
+
343
+ const cartographic = projection.unproject(result, scratchPickCartographic);
344
+ ellipsoid.cartographicToCartesian(cartographic, result);
345
+ }
346
+
347
+ return result;
348
+ }
349
+
350
+ function getVertexPosition(
351
+ vertices,
352
+ index,
353
+ numComponents,
354
+ quantization,
355
+ instanceTransform,
356
+ verticalExaggeration,
357
+ relativeHeight,
358
+ ellipsoid,
359
+ result
360
+ ) {
361
+ const i = index * numComponents;
362
+ result.x = vertices[i];
363
+ result.y = vertices[i + 1];
364
+ result.z = vertices[i + 2];
365
+
366
+ if (defined(quantization)) {
367
+ if (quantization.octEncoded) {
368
+ result = AttributeCompression.octDecodeInRange(
369
+ result,
370
+ quantization.normalizationRange,
371
+ result
372
+ );
373
+
374
+ if (quantization.octEncodedZXY) {
375
+ const x = result.x;
376
+ result.x = result.z;
377
+ result.z = result.y;
378
+ result.y = x;
379
+ }
380
+ } else {
381
+ result = Cartesian3.multiplyComponents(
382
+ result,
383
+ quantization.quantizedVolumeStepSize,
384
+ result
385
+ );
386
+
387
+ result = Cartesian3.add(
388
+ result,
389
+ quantization.quantizedVolumeOffset,
390
+ result
391
+ );
392
+ }
393
+ }
394
+
395
+ result = Matrix4.multiplyByPoint(instanceTransform, result, result);
396
+
397
+ if (verticalExaggeration !== 1.0) {
398
+ VerticalExaggeration.getPosition(
399
+ result,
400
+ ellipsoid,
401
+ verticalExaggeration,
402
+ relativeHeight,
403
+ result
404
+ );
405
+ }
406
+
407
+ return result;
408
+ }
@@ -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
  };
@@ -274,7 +274,7 @@ QuadtreePrimitive.prototype.forEachRenderedTile = function (tileFunction) {
274
274
  * is the cartesian position on the tile.
275
275
  *
276
276
  * @param {Cartographic} cartographic The cartographic position.
277
- * @param {Function} callback The function to be called when a new tile is loaded containing cartographic.
277
+ * @param {Function} callback The function to be called when a new tile is loaded containing the updated cartographic.
278
278
  * @returns {Function} The function to remove this callback from the quadtree.
279
279
  */
280
280
  QuadtreePrimitive.prototype.updateHeight = function (cartographic, callback) {