@cesium/engine 9.2.0 → 10.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 (220) hide show
  1. package/Build/Workers/{chunk-WOYQB5HM.js → chunk-2J3JKXCP.js} +5 -5
  2. package/Build/Workers/{chunk-IXYFH7DV.js → chunk-3WUV74WM.js} +2 -2
  3. package/Build/Workers/{chunk-3PV5HQ2R.js → chunk-4BAE4PWO.js} +6 -6
  4. package/Build/Workers/{chunk-WHDEZSAL.js → chunk-4MSUJ4I7.js} +8 -8
  5. package/Build/Workers/{chunk-ZHJDE6JN.js → chunk-4YSNMHZ4.js} +6 -6
  6. package/Build/Workers/{chunk-LZFFO4KB.js → chunk-5S7OLEPK.js} +12 -12
  7. package/Build/Workers/{chunk-GX2BWBN2.js → chunk-7XGC6YB2.js} +14 -14
  8. package/Build/Workers/{chunk-IF2OX6R4.js → chunk-AA4GZKOT.js} +1 -1
  9. package/Build/Workers/{chunk-26NE4LRW.js → chunk-AD5HBJ2F.js} +11 -8
  10. package/Build/Workers/{chunk-4RG6WOXH.js → chunk-AVI4IUWC.js} +11 -11
  11. package/Build/Workers/{chunk-3VDHTBY5.js → chunk-BCL4PHHT.js} +10 -10
  12. package/Build/Workers/{chunk-WP3LCUOE.js → chunk-BDFNKFOE.js} +13 -13
  13. package/Build/Workers/{chunk-KTZK2UDR.js → chunk-BJF5LOWE.js} +7 -7
  14. package/Build/Workers/{chunk-W4OS542B.js → chunk-C2CGMAIU.js} +13 -13
  15. package/Build/Workers/{chunk-EJZVBTX4.js → chunk-COYFZ5VA.js} +6 -6
  16. package/Build/Workers/{chunk-PHT53MCH.js → chunk-DGS5QNIO.js} +13 -13
  17. package/Build/Workers/{chunk-UYKG3UFK.js → chunk-DKVHRNFY.js} +5 -5
  18. package/Build/Workers/{chunk-7PFZ4Z7C.js → chunk-DOXCPOG4.js} +11 -9
  19. package/Build/Workers/{chunk-A5CSB5ZE.js → chunk-FXIHSF7O.js} +9 -9
  20. package/Build/Workers/{chunk-GOQEANLM.js → chunk-G3YR53LY.js} +13 -13
  21. package/Build/Workers/{chunk-7HLZRYGD.js → chunk-GR3CDLCP.js} +7 -7
  22. package/Build/Workers/{chunk-YGNQJ4YI.js → chunk-GRAT5GE7.js} +5 -5
  23. package/Build/Workers/{chunk-SC3TBKST.js → chunk-I2RC4XVN.js} +4 -4
  24. package/Build/Workers/{chunk-26XJDV3D.js → chunk-JYAHOGGL.js} +15 -15
  25. package/Build/Workers/{chunk-RRUO4QEK.js → chunk-KUN2ZA5X.js} +4 -4
  26. package/Build/Workers/{chunk-BBBTT36L.js → chunk-L6RTJ3RE.js} +14 -14
  27. package/Build/Workers/{chunk-RDR4KVPA.js → chunk-LCLJJ2MZ.js} +18 -18
  28. package/Build/Workers/{chunk-BNT2SNWU.js → chunk-LEABCTLP.js} +4 -4
  29. package/Build/Workers/{chunk-I6CW7ZE5.js → chunk-MDHQR3ZS.js} +10 -8
  30. package/Build/Workers/{chunk-ETC45PHH.js → chunk-MSKXMXJI.js} +4 -4
  31. package/Build/Workers/{chunk-QZIWFSRM.js → chunk-NTXTUNEF.js} +4 -4
  32. package/Build/Workers/{chunk-GUFV24F4.js → chunk-O3JCMSS3.js} +17 -17
  33. package/Build/Workers/{chunk-UICVDDCQ.js → chunk-OOK53QUQ.js} +1 -1
  34. package/Build/Workers/{chunk-G7IAO7CW.js → chunk-OORVMGDU.js} +7 -7
  35. package/Build/Workers/{chunk-OYP23VAL.js → chunk-PCP4YQST.js} +11 -11
  36. package/Build/Workers/{chunk-GX5LMUGZ.js → chunk-PYHLO636.js} +42 -13
  37. package/Build/Workers/{chunk-TDIGL45B.js → chunk-Q55ECN3Y.js} +1 -1
  38. package/Build/Workers/{chunk-5OK5JFDP.js → chunk-QD4KM3GO.js} +5 -5
  39. package/Build/Workers/{chunk-CVCVMOQA.js → chunk-QMLTCCYG.js} +1 -1
  40. package/Build/Workers/{chunk-AROLUUGS.js → chunk-QX5XS4LC.js} +2 -2
  41. package/Build/Workers/{chunk-TP4FFUAH.js → chunk-R6B7UCQB.js} +2 -2
  42. package/Build/Workers/{chunk-U6MTSO6A.js → chunk-RJYML24O.js} +11 -11
  43. package/Build/Workers/{chunk-DIVFF6DK.js → chunk-S3PI2KFM.js} +2 -2
  44. package/Build/Workers/{chunk-PUQR43HZ.js → chunk-STBBMQGG.js} +6 -6
  45. package/Build/Workers/{chunk-CFBGPZU6.js → chunk-SYCPRK3D.js} +10 -10
  46. package/Build/Workers/{chunk-U2LSTOMA.js → chunk-T77JILCU.js} +2 -2
  47. package/Build/Workers/{chunk-RTIT7UDN.js → chunk-TO2PVHKI.js} +2 -2
  48. package/Build/Workers/{chunk-EODIOQ35.js → chunk-VE7BFUIX.js} +1 -1
  49. package/Build/Workers/{chunk-K5F23SZO.js → chunk-VFBNELXB.js} +7 -7
  50. package/Build/Workers/{chunk-YGTWKLFY.js → chunk-VO3ACQB2.js} +19 -19
  51. package/Build/Workers/{chunk-UKJCFXVV.js → chunk-X23FRWHJ.js} +6 -6
  52. package/Build/Workers/{chunk-2TRB253J.js → chunk-XD445VDH.js} +7 -7
  53. package/Build/Workers/combineGeometry.js +22 -22
  54. package/Build/Workers/createBoxGeometry.js +16 -16
  55. package/Build/Workers/createBoxOutlineGeometry.js +14 -14
  56. package/Build/Workers/createCircleGeometry.js +29 -25
  57. package/Build/Workers/createCircleOutlineGeometry.js +17 -17
  58. package/Build/Workers/createCoplanarPolygonGeometry.js +32 -32
  59. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
  60. package/Build/Workers/createCorridorGeometry.js +29 -29
  61. package/Build/Workers/createCorridorOutlineGeometry.js +27 -27
  62. package/Build/Workers/createCylinderGeometry.js +18 -18
  63. package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
  64. package/Build/Workers/createEllipseGeometry.js +24 -24
  65. package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
  66. package/Build/Workers/createEllipsoidGeometry.js +17 -17
  67. package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
  68. package/Build/Workers/createFrustumGeometry.js +16 -16
  69. package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
  70. package/Build/Workers/createGeometry.js +22 -22
  71. package/Build/Workers/createGroundPolylineGeometry.js +24 -24
  72. package/Build/Workers/createPlaneGeometry.js +14 -14
  73. package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
  74. package/Build/Workers/createPolygonGeometry.js +32 -32
  75. package/Build/Workers/createPolygonOutlineGeometry.js +29 -29
  76. package/Build/Workers/createPolylineGeometry.js +24 -24
  77. package/Build/Workers/createPolylineVolumeGeometry.js +30 -30
  78. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +26 -26
  79. package/Build/Workers/createRectangleGeometry.js +27 -27
  80. package/Build/Workers/createRectangleOutlineGeometry.js +19 -19
  81. package/Build/Workers/createSimplePolylineGeometry.js +22 -22
  82. package/Build/Workers/createSphereGeometry.js +17 -17
  83. package/Build/Workers/createSphereOutlineGeometry.js +16 -16
  84. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  85. package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
  86. package/Build/Workers/createVectorTileGeometries.js +22 -22
  87. package/Build/Workers/createVectorTilePoints.js +12 -12
  88. package/Build/Workers/createVectorTilePolygons.js +20 -20
  89. package/Build/Workers/createVectorTilePolylines.js +13 -13
  90. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
  91. package/Build/Workers/createVerticesFromHeightmap.js +21 -21
  92. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
  93. package/Build/Workers/createWallGeometry.js +23 -23
  94. package/Build/Workers/createWallOutlineGeometry.js +22 -22
  95. package/Build/Workers/decodeDraco.js +11 -11
  96. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  97. package/Build/Workers/decodeI3S.js +10 -10
  98. package/Build/Workers/transcodeKTX2.js +7 -7
  99. package/Build/Workers/transferTypedArrayTest.js +1 -1
  100. package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
  101. package/Source/Core/ApproximateTerrainHeights.js +4 -4
  102. package/Source/Core/ArcGISTiledElevationTerrainProvider.js +12 -8
  103. package/Source/Core/BoundingRectangle.js +2 -0
  104. package/Source/Core/BoundingSphere.js +4 -2
  105. package/Source/Core/Cartesian3.js +13 -10
  106. package/Source/Core/Cartographic.js +11 -8
  107. package/Source/Core/CesiumTerrainProvider.js +3 -2
  108. package/Source/Core/CircleGeometry.js +6 -2
  109. package/Source/Core/CircleOutlineGeometry.js +1 -1
  110. package/Source/Core/CoplanarPolygonGeometry.js +3 -3
  111. package/Source/Core/CorridorGeometry.js +4 -4
  112. package/Source/Core/CorridorOutlineGeometry.js +2 -2
  113. package/Source/Core/Credit.js +3 -2
  114. package/Source/Core/CustomHeightmapTerrainProvider.js +17 -3
  115. package/Source/Core/EllipseGeometry.js +4 -4
  116. package/Source/Core/EllipseOutlineGeometry.js +2 -2
  117. package/Source/Core/Ellipsoid.js +34 -0
  118. package/Source/Core/EllipsoidGeodesic.js +2 -2
  119. package/Source/Core/EllipsoidRhumbLine.js +4 -4
  120. package/Source/Core/EllipsoidTangentPlane.js +3 -3
  121. package/Source/Core/EllipsoidTerrainProvider.js +3 -3
  122. package/Source/Core/GeographicProjection.js +4 -3
  123. package/Source/Core/GeographicTilingScheme.js +3 -3
  124. package/Source/Core/GeometryPipeline.js +2 -2
  125. package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +1 -1
  126. package/Source/Core/GoogleMaps.js +1 -1
  127. package/Source/Core/GroundPolylineGeometry.js +1 -1
  128. package/Source/Core/HeightmapTessellator.js +2 -2
  129. package/Source/Core/Ion.js +1 -1
  130. package/Source/Core/Occluder.js +3 -3
  131. package/Source/Core/OrientedBoundingBox.js +2 -2
  132. package/Source/Core/PolygonGeometry.js +4 -4
  133. package/Source/Core/PolygonGeometryLibrary.js +1 -1
  134. package/Source/Core/PolygonOutlineGeometry.js +3 -3
  135. package/Source/Core/PolygonPipeline.js +2 -2
  136. package/Source/Core/PolylineGeometry.js +2 -2
  137. package/Source/Core/PolylinePipeline.js +6 -6
  138. package/Source/Core/PolylineVolumeGeometry.js +2 -2
  139. package/Source/Core/PolylineVolumeOutlineGeometry.js +2 -2
  140. package/Source/Core/Rectangle.js +6 -6
  141. package/Source/Core/RectangleGeometry.js +6 -6
  142. package/Source/Core/RectangleGeometryLibrary.js +3 -0
  143. package/Source/Core/RectangleOutlineGeometry.js +2 -2
  144. package/Source/Core/Simon1994PlanetaryPositions.js +3 -2
  145. package/Source/Core/SimplePolylineGeometry.js +2 -2
  146. package/Source/Core/Stereographic.js +2 -2
  147. package/Source/Core/Transforms.js +17 -17
  148. package/Source/Core/VRTheWorldTerrainProvider.js +2 -2
  149. package/Source/Core/WallGeometry.js +3 -3
  150. package/Source/Core/WallOutlineGeometry.js +3 -3
  151. package/Source/Core/WebMercatorTilingScheme.js +3 -3
  152. package/Source/Core/createWorldTerrainAsync.js +2 -0
  153. package/Source/DataSources/BoxGeometryUpdater.js +2 -2
  154. package/Source/DataSources/CylinderGeometryUpdater.js +2 -2
  155. package/Source/DataSources/CzmlDataSource.js +8 -8
  156. package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -3
  157. package/Source/DataSources/EntityCluster.js +1 -1
  158. package/Source/DataSources/EntityView.js +2 -2
  159. package/Source/DataSources/KmlDataSource.js +4 -4
  160. package/Source/DataSources/ModelVisualizer.js +1 -2
  161. package/Source/DataSources/PolygonGeometryUpdater.js +1 -1
  162. package/Source/DataSources/PolylineGeometryUpdater.js +3 -2
  163. package/Source/DataSources/RectangleGeometryUpdater.js +1 -1
  164. package/Source/DataSources/ScaledPositionProperty.js +2 -2
  165. package/Source/DataSources/TerrainOffsetProperty.js +3 -7
  166. package/Source/DataSources/VelocityOrientationProperty.js +2 -2
  167. package/Source/DataSources/exportKml.js +2 -2
  168. package/Source/Renderer/UniformState.js +1 -1
  169. package/Source/Scene/ArcGisMapServerImageryProvider.js +2 -2
  170. package/Source/Scene/ArcGisMapService.js +1 -1
  171. package/Source/Scene/Billboard.js +6 -4
  172. package/Source/Scene/BingMapsImageryProvider.js +1 -1
  173. package/Source/Scene/Camera.js +16 -10
  174. package/Source/Scene/Cesium3DTileset.js +1 -1
  175. package/Source/Scene/ClippingPolygon.js +2 -2
  176. package/Source/Scene/ClippingPolygonCollection.js +1 -1
  177. package/Source/Scene/CreditDisplay.js +94 -104
  178. package/Source/Scene/Globe.js +16 -13
  179. package/Source/Scene/GltfLoaderUtil.js +2 -4
  180. package/Source/Scene/GoogleEarthEnterpriseImageryProvider.js +1 -1
  181. package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +1 -1
  182. package/Source/Scene/GridImageryProvider.js +2 -2
  183. package/Source/Scene/ImageryLayerCollection.js +2 -2
  184. package/Source/Scene/MapboxImageryProvider.js +1 -1
  185. package/Source/Scene/MapboxStyleImageryProvider.js +1 -1
  186. package/Source/Scene/MetadataSemantic.js +4 -4
  187. package/Source/Scene/Model/InstancingPipelineStage.js +3 -3
  188. package/Source/Scene/Model/MaterialPipelineStage.js +49 -0
  189. package/Source/Scene/Model/Model.js +7 -4
  190. package/Source/Scene/Model/ModelSceneGraph.js +1 -1
  191. package/Source/Scene/Model/SceneMode2DPipelineStage.js +3 -3
  192. package/Source/Scene/Model/pickModel.js +2 -2
  193. package/Source/Scene/ModelComponents.js +9 -0
  194. package/Source/Scene/Picking.js +4 -13
  195. package/Source/Scene/PointPrimitive.js +5 -2
  196. package/Source/Scene/Scene.js +39 -31
  197. package/Source/Scene/SceneTransforms.js +78 -20
  198. package/Source/Scene/SceneTransitioner.js +2 -2
  199. package/Source/Scene/ScreenSpaceCameraController.js +29 -19
  200. package/Source/Scene/SkyBox.js +26 -0
  201. package/Source/Scene/Sun.js +1 -1
  202. package/Source/Shaders/Builtin/CzmBuiltins.js +2 -2
  203. package/Source/Shaders/Builtin/Functions/ellipsoidTextureCoordinates.glsl +10 -0
  204. package/Source/Shaders/Builtin/Functions/{ellipsoidWgs84TextureCoordinates.js → ellipsoidTextureCoordinates.js} +3 -3
  205. package/Source/Shaders/Builtin/Structs/materialInput.glsl +1 -1
  206. package/Source/Shaders/Builtin/Structs/materialInput.js +1 -1
  207. package/Source/Shaders/Builtin/Structs/modelMaterial.glsl +2 -0
  208. package/Source/Shaders/Builtin/Structs/modelMaterial.js +2 -0
  209. package/Source/Shaders/EllipsoidFS.glsl +1 -1
  210. package/Source/Shaders/EllipsoidFS.js +1 -1
  211. package/Source/Shaders/GlobeFS.glsl +2 -2
  212. package/Source/Shaders/GlobeFS.js +2 -2
  213. package/Source/Shaders/Model/MaterialStageFS.glsl +21 -12
  214. package/Source/Shaders/Model/MaterialStageFS.js +21 -12
  215. package/Source/Widget/CesiumWidget.css +0 -5
  216. package/Source/Widget/CesiumWidget.js +29 -28
  217. package/index.d.ts +181 -113
  218. package/index.js +208 -208
  219. package/package.json +2 -2
  220. package/Source/Shaders/Builtin/Functions/ellipsoidWgs84TextureCoordinates.glsl +0 -10
@@ -4,6 +4,7 @@ import Cartesian3 from "../Core/Cartesian3.js";
4
4
  import Cartesian4 from "../Core/Cartesian4.js";
5
5
  import Cartographic from "../Core/Cartographic.js";
6
6
  import defined from "../Core/defined.js";
7
+ import deprecationWarning from "../Core/deprecationWarning.js";
7
8
  import DeveloperError from "../Core/DeveloperError.js";
8
9
  import CesiumMath from "../Core/Math.js";
9
10
  import Matrix4 from "../Core/Matrix4.js";
@@ -26,6 +27,32 @@ const scratchViewport = new BoundingRectangle();
26
27
  const scratchWindowCoord0 = new Cartesian2();
27
28
  const scratchWindowCoord1 = new Cartesian2();
28
29
 
30
+ /**
31
+ * Transforms a position in world (WGS84 or alternative ellipsoid) coordinates to window coordinates. This is commonly used to place an
32
+ * HTML element at the same screen position as an object in the scene.
33
+ *
34
+ * @param {Scene} scene The scene.
35
+ * @param {Cartesian3} position The position in world (WGS84 or alternative ellipsoid) coordinates.
36
+ * @param {Cartesian2} [result] An optional object to return the input position transformed to window coordinates.
37
+ * @returns {Cartesian2|undefined} The modified result parameter or a new Cartesian2 instance if one was not provided. This may be <code>undefined</code> if the input position is near the center of the ellipsoid.
38
+ *
39
+ * @example
40
+ * // Output the window position of longitude/latitude (0, 0) every time the mouse moves.
41
+ * const position = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
42
+ * const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
43
+ * handler.setInputAction(function(movement) {
44
+ * console.log(Cesium.SceneTransforms.worldToWindowCoordinates(scene, position));
45
+ * }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
46
+ */
47
+ SceneTransforms.worldToWindowCoordinates = function (scene, position, result) {
48
+ return SceneTransforms.worldWithEyeOffsetToWindowCoordinates(
49
+ scene,
50
+ position,
51
+ Cartesian3.ZERO,
52
+ result
53
+ );
54
+ };
55
+
29
56
  /**
30
57
  * Transforms a position in WGS84 coordinates to window coordinates. This is commonly used to place an
31
58
  * HTML element at the same screen position as an object in the scene.
@@ -33,12 +60,12 @@ const scratchWindowCoord1 = new Cartesian2();
33
60
  * @param {Scene} scene The scene.
34
61
  * @param {Cartesian3} position The position in WGS84 (world) coordinates.
35
62
  * @param {Cartesian2} [result] An optional object to return the input position transformed to window coordinates.
36
- * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided. This may be <code>undefined</code> if the input position is near the center of the ellipsoid.
63
+ * @returns {Cartesian2|undefined} The modified result parameter or a new Cartesian2 instance if one was not provided. This may be <code>undefined</code> if the input position is near the center of the ellipsoid.
37
64
  *
38
65
  * @example
39
66
  * // Output the window position of longitude/latitude (0, 0) every time the mouse moves.
40
67
  * const scene = widget.scene;
41
- * const ellipsoid = scene.globe.ellipsoid;
68
+ * const ellipsoid = scene.ellipsoid;
42
69
  * const position = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
43
70
  * const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
44
71
  * handler.setInputAction(function(movement) {
@@ -46,12 +73,11 @@ const scratchWindowCoord1 = new Cartesian2();
46
73
  * }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
47
74
  */
48
75
  SceneTransforms.wgs84ToWindowCoordinates = function (scene, position, result) {
49
- return SceneTransforms.wgs84WithEyeOffsetToWindowCoordinates(
50
- scene,
51
- position,
52
- Cartesian3.ZERO,
53
- result
76
+ deprecationWarning(
77
+ "SceneTransforms.wgs84ToWindowCoordinates",
78
+ "SceneTransforms.wgs84ToWindowCoordinates has been deprecated. It will be removed in 1.21. Use SceneTransforms.worldToWindowCoordinates instead."
54
79
  );
80
+ return SceneTransforms.worldToWindowCoordinates(scene, position, result);
55
81
  };
56
82
 
57
83
  const scratchCartesian4 = new Cartesian4();
@@ -98,7 +124,7 @@ const scratchCameraPosition = new Cartesian3();
98
124
  /**
99
125
  * @private
100
126
  */
101
- SceneTransforms.wgs84WithEyeOffsetToWindowCoordinates = function (
127
+ SceneTransforms.worldWithEyeOffsetToWindowCoordinates = function (
102
128
  scene,
103
129
  position,
104
130
  eyeOffset,
@@ -115,7 +141,7 @@ SceneTransforms.wgs84WithEyeOffsetToWindowCoordinates = function (
115
141
 
116
142
  // Transform for 3D, 2D, or Columbus view
117
143
  const frameState = scene.frameState;
118
- const actualPosition = SceneTransforms.computeActualWgs84Position(
144
+ const actualPosition = SceneTransforms.computeActualEllipsoidPosition(
119
145
  frameState,
120
146
  position,
121
147
  actualPositionScratch
@@ -265,30 +291,28 @@ SceneTransforms.wgs84WithEyeOffsetToWindowCoordinates = function (
265
291
  };
266
292
 
267
293
  /**
268
- * Transforms a position in WGS84 coordinates to drawing buffer coordinates. This may produce different
269
- * results from SceneTransforms.wgs84ToWindowCoordinates when the browser zoom is not 100%, or on high-DPI displays.
294
+ * Transforms a position in world coordinates to drawing buffer coordinates. This may produce different
295
+ * results from SceneTransforms.worldToWindowCoordinates when the browser zoom is not 100%, or on high-DPI displays.
270
296
  *
271
297
  * @param {Scene} scene The scene.
272
- * @param {Cartesian3} position The position in WGS84 (world) coordinates.
298
+ * @param {Cartesian3} position The position in world (WGS84 or alternative ellipsoid) coordinates.
273
299
  * @param {Cartesian2} [result] An optional object to return the input position transformed to window coordinates.
274
- * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided. This may be <code>undefined</code> if the input position is near the center of the ellipsoid.
300
+ * @returns {Cartesian2|undefined} The modified result parameter or a new Cartesian2 instance if one was not provided. This may be <code>undefined</code> if the input position is near the center of the ellipsoid.
275
301
  *
276
302
  * @example
277
303
  * // Output the window position of longitude/latitude (0, 0) every time the mouse moves.
278
- * const scene = widget.scene;
279
- * const ellipsoid = scene.globe.ellipsoid;
280
304
  * const position = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
281
305
  * const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
282
306
  * handler.setInputAction(function(movement) {
283
- * console.log(Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, position));
307
+ * console.log(Cesium.SceneTransforms.worldToDrawingBufferCoordinates(scene, position));
284
308
  * }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
285
309
  */
286
- SceneTransforms.wgs84ToDrawingBufferCoordinates = function (
310
+ SceneTransforms.worldToDrawingBufferCoordinates = function (
287
311
  scene,
288
312
  position,
289
313
  result
290
314
  ) {
291
- result = SceneTransforms.wgs84ToWindowCoordinates(scene, position, result);
315
+ result = SceneTransforms.worldToWindowCoordinates(scene, position, result);
292
316
  if (!defined(result)) {
293
317
  return undefined;
294
318
  }
@@ -296,13 +320,47 @@ SceneTransforms.wgs84ToDrawingBufferCoordinates = function (
296
320
  return SceneTransforms.transformWindowToDrawingBuffer(scene, result, result);
297
321
  };
298
322
 
323
+ /**
324
+ * Transforms a position in world coordinates to drawing buffer coordinates. This may produce different
325
+ * results from SceneTransforms.wgs84ToWindowCoordinates when the browser zoom is not 100%, or on high-DPI displays.
326
+ *
327
+ * @param {Scene} scene The scene.
328
+ * @param {Cartesian3} position The position in world (WGS84 or alternative ellipsoid) coordinates.
329
+ * @param {Cartesian2} [result] An optional object to return the input position transformed to window coordinates.
330
+ * @returns {Cartesian2|undefined} The modified result parameter or a new Cartesian2 instance if one was not provided. This may be <code>undefined</code> if the input position is near the center of the ellipsoid.
331
+ *
332
+ * @example
333
+ * // Output the window position of longitude/latitude (0, 0) every time the mouse moves.
334
+ * const position = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
335
+ * const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
336
+ * handler.setInputAction(function(movement) {
337
+ * console.log(Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, position));
338
+ * }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
339
+ */
340
+ SceneTransforms.wgs84ToDrawingBufferCoordinates = function (
341
+ scene,
342
+ position,
343
+ result
344
+ ) {
345
+ deprecationWarning(
346
+ "SceneTransforms.wgs84ToDrawingBufferCoordinates",
347
+ "SceneTransforms.wgs84ToDrawingBufferCoordinates has been deprecated. It will be removed in 1.21. Use SceneTransforms.worldToDrawingBufferCoordinates instead."
348
+ );
349
+
350
+ return SceneTransforms.worldToDrawingBufferCoordinates(
351
+ scene,
352
+ position,
353
+ result
354
+ );
355
+ };
356
+
299
357
  const projectedPosition = new Cartesian3();
300
358
  const positionInCartographic = new Cartographic();
301
359
 
302
360
  /**
303
361
  * @private
304
362
  */
305
- SceneTransforms.computeActualWgs84Position = function (
363
+ SceneTransforms.computeActualEllipsoidPosition = function (
306
364
  frameState,
307
365
  position,
308
366
  result
@@ -398,7 +456,7 @@ const scratchWorldCoords = new Cartesian4();
398
456
  /**
399
457
  * @private
400
458
  */
401
- SceneTransforms.drawingBufferToWgs84Coordinates = function (
459
+ SceneTransforms.drawingBufferToWorldCoordinates = function (
402
460
  scene,
403
461
  drawingBufferPosition,
404
462
  depth,
@@ -627,7 +627,7 @@ function morphFromColumbusViewTo2D(transitioner, duration) {
627
627
 
628
628
  if (duration > 0.0) {
629
629
  Cartesian3.clone(Cartesian3.ZERO, scratchCVTo2DEndPos);
630
- endPos.z = 5.0 * scene.mapProjection.ellipsoid.maximumRadius;
630
+ endPos.z = 5.0 * scene.ellipsoid.maximumRadius;
631
631
  } else {
632
632
  Cartesian3.clone(startPos, scratchCVTo2DEndPos);
633
633
 
@@ -1050,7 +1050,7 @@ function complete2DCallback(camera2D) {
1050
1050
 
1051
1051
  const camera = scene.camera;
1052
1052
  Cartesian3.clone(camera2D.position, camera.position);
1053
- camera.position.z = scene.mapProjection.ellipsoid.maximumRadius * 2.0;
1053
+ camera.position.z = scene.ellipsoid.maximumRadius * 2.0;
1054
1054
  Cartesian3.clone(camera2D.direction, camera.direction);
1055
1055
  Cartesian3.clone(camera2D.up, camera.up);
1056
1056
  Cartesian3.cross(camera.direction, camera.up, camera.right);
@@ -216,33 +216,46 @@ function ScreenSpaceCameraController(scene) {
216
216
  eventType: CameraEventType.LEFT_DRAG,
217
217
  modifier: KeyboardEventModifier.SHIFT,
218
218
  };
219
+
220
+ const ellipsoid = defaultValue(scene.ellipsoid, Ellipsoid.default);
221
+
219
222
  /**
220
- * The minimum height the camera must be before picking the terrain or scene content instead of the ellipsoid.
223
+ * The minimum height the camera must be before picking the terrain or scene content instead of the ellipsoid. Defaults to scene.ellipsoid.minimumRadius * 0.025 when another ellipsoid than WGS84 is used.
221
224
  * @type {number}
222
- * @default 150000.0
225
+ * @default 150000.0 or scene.ellipsoid.minimumRadius * 0.025
223
226
  */
224
- this.minimumPickingTerrainHeight = 150000.0;
227
+ this.minimumPickingTerrainHeight = Ellipsoid.WGS84.equals(ellipsoid)
228
+ ? 150000.0
229
+ : ellipsoid.minimumRadius * 0.025;
225
230
  this._minimumPickingTerrainHeight = this.minimumPickingTerrainHeight;
226
231
  /**
227
- * The minimum distance the camera must be before testing for collision with terrain when zoom with inertia.
232
+ * The minimum distance the camera must be before testing for collision with terrain when zoom with inertia. Default to scene.ellipsoid.minimumRadius * 0.00063 when another ellipsoid than WGS84 is used.
228
233
  * @type {number}
229
- * @default 4000.0
234
+ * @default 4000.0 or scene.ellipsoid.minimumRadius * 0.00063
230
235
  */
231
- this.minimumPickingTerrainDistanceWithInertia = 4000.0;
236
+ this.minimumPickingTerrainDistanceWithInertia = Ellipsoid.WGS84.equals(
237
+ ellipsoid
238
+ )
239
+ ? 4000.0
240
+ : ellipsoid.minimumRadius * 0.00063;
232
241
  /**
233
- * The minimum height the camera must be before testing for collision with terrain.
242
+ * The minimum height the camera must be before testing for collision with terrain. Default to scene.ellipsoid.minimumRadius * 0.0025 when another ellipsoid than WGS84 is used.
234
243
  * @type {number}
235
- * @default 15000.0
244
+ * @default 15000.0 or scene.ellipsoid.minimumRadius * 0.0025.
236
245
  */
237
- this.minimumCollisionTerrainHeight = 15000.0;
246
+ this.minimumCollisionTerrainHeight = Ellipsoid.WGS84.equals(ellipsoid)
247
+ ? 15000.0
248
+ : ellipsoid.minimumRadius * 0.0025;
238
249
  this._minimumCollisionTerrainHeight = this.minimumCollisionTerrainHeight;
239
250
  /**
240
251
  * The minimum height the camera must be before switching from rotating a track ball to
241
- * free look when clicks originate on the sky or in space.
252
+ * free look when clicks originate on the sky or in space. Defaults to ellipsoid.minimumRadius * 1.175 when another ellipsoid than WGS84 is used.
242
253
  * @type {number}
243
- * @default 7500000.0
254
+ * @default 7500000.0 or scene.ellipsoid.minimumRadius * 1.175
244
255
  */
245
- this.minimumTrackBallHeight = 7500000.0;
256
+ this.minimumTrackBallHeight = Ellipsoid.WGS84.equals(ellipsoid)
257
+ ? 7500000.0
258
+ : ellipsoid.minimumRadius * 1.175;
246
259
  this._minimumTrackBallHeight = this.minimumTrackBallHeight;
247
260
  /**
248
261
  * When disabled, the values of <code>maximumZoomDistance</code> and <code>minimumZoomDistance</code> are ignored.
@@ -253,7 +266,7 @@ function ScreenSpaceCameraController(scene) {
253
266
 
254
267
  this._scene = scene;
255
268
  this._globe = undefined;
256
- this._ellipsoid = undefined;
269
+ this._ellipsoid = ellipsoid;
257
270
 
258
271
  this._lastGlobeHeight = 0.0;
259
272
 
@@ -920,7 +933,7 @@ function handleZoom(
920
933
 
921
934
  if ((!sameStartPosition && zoomOnVector) || zoomingOnVector) {
922
935
  let ray;
923
- const zoomMouseStart = SceneTransforms.wgs84ToWindowCoordinates(
936
+ const zoomMouseStart = SceneTransforms.worldToWindowCoordinates(
924
937
  scene,
925
938
  object._zoomWorldPosition,
926
939
  scratchZoomOffset
@@ -2861,14 +2874,13 @@ function adjustHeightForTerrain(controller, cameraChanged) {
2861
2874
 
2862
2875
  const scene = controller._scene;
2863
2876
  const mode = scene.mode;
2864
- const globe = scene.globe;
2865
2877
 
2866
2878
  if (mode === SceneMode.SCENE2D || mode === SceneMode.MORPHING) {
2867
2879
  return;
2868
2880
  }
2869
2881
 
2870
2882
  const camera = scene.camera;
2871
- const ellipsoid = defaultValue(globe?.ellipsoid, Ellipsoid.WGS84);
2883
+ const ellipsoid = defaultValue(scene.ellipsoid, Ellipsoid.WGS84);
2872
2884
  const projection = scene.mapProjection;
2873
2885
 
2874
2886
  let transform;
@@ -2967,9 +2979,7 @@ ScreenSpaceCameraController.prototype.update = function () {
2967
2979
  this._ellipsoid = Ellipsoid.UNIT_SPHERE;
2968
2980
  } else {
2969
2981
  this._globe = globe;
2970
- this._ellipsoid = defined(this._globe)
2971
- ? this._globe.ellipsoid
2972
- : scene.mapProjection.ellipsoid;
2982
+ this._ellipsoid = defaultValue(scene.ellipsoid, Ellipsoid.default);
2973
2983
  }
2974
2984
 
2975
2985
  const { verticalExaggeration, verticalExaggerationRelativeHeight } = scene;
@@ -1,3 +1,4 @@
1
+ import buildModuleUrl from "../Core/buildModuleUrl.js";
1
2
  import BoxGeometry from "../Core/BoxGeometry.js";
2
3
  import Cartesian3 from "../Core/Cartesian3.js";
3
4
  import defaultValue from "../Core/defaultValue.js";
@@ -249,4 +250,29 @@ SkyBox.prototype.destroy = function () {
249
250
  this._cubeMap = this._cubeMap && this._cubeMap.destroy();
250
251
  return destroyObject(this);
251
252
  };
253
+
254
+ function getDefaultSkyBoxUrl(suffix) {
255
+ return buildModuleUrl(`Assets/Textures/SkyBox/tycho2t3_80_${suffix}.jpg`);
256
+ }
257
+
258
+ /**
259
+ * Creates a skybox instance with the default starmap for the Earth.
260
+ * @return {SkyBox} The default skybox for the Earth
261
+ *
262
+ * @example
263
+ * viewer.scene.skyBox = Cesium.SkyBox.createEarthSkyBox();
264
+ */
265
+ SkyBox.createEarthSkyBox = function () {
266
+ return new SkyBox({
267
+ sources: {
268
+ positiveX: getDefaultSkyBoxUrl("px"),
269
+ negativeX: getDefaultSkyBoxUrl("mx"),
270
+ positiveY: getDefaultSkyBoxUrl("py"),
271
+ negativeY: getDefaultSkyBoxUrl("my"),
272
+ positiveZ: getDefaultSkyBoxUrl("pz"),
273
+ negativeZ: getDefaultSkyBoxUrl("mz"),
274
+ },
275
+ });
276
+ };
277
+
252
278
  export default SkyBox;
@@ -267,7 +267,7 @@ Sun.prototype.update = function (frameState, passState, useHdr) {
267
267
  BoundingSphere.clone(boundingVolume2D, drawCommand.boundingVolume);
268
268
  }
269
269
 
270
- const position = SceneTransforms.computeActualWgs84Position(
270
+ const position = SceneTransforms.computeActualEllipsoidPosition(
271
271
  frameState,
272
272
  sunPosition,
273
273
  scratchCartesian4
@@ -74,7 +74,7 @@ import czm_decompressTextureCoordinates from './Functions/decompressTextureCoord
74
74
  import czm_depthClamp from './Functions/depthClamp.js'
75
75
  import czm_eastNorthUpToEyeCoordinates from './Functions/eastNorthUpToEyeCoordinates.js'
76
76
  import czm_ellipsoidContainsPoint from './Functions/ellipsoidContainsPoint.js'
77
- import czm_ellipsoidWgs84TextureCoordinates from './Functions/ellipsoidWgs84TextureCoordinates.js'
77
+ import czm_ellipsoidTextureCoordinates from './Functions/ellipsoidTextureCoordinates.js'
78
78
  import czm_equalsEpsilon from './Functions/equalsEpsilon.js'
79
79
  import czm_eyeOffset from './Functions/eyeOffset.js'
80
80
  import czm_eyeToWindowCoordinates from './Functions/eyeToWindowCoordinates.js'
@@ -212,7 +212,7 @@ export default {
212
212
  czm_depthClamp : czm_depthClamp,
213
213
  czm_eastNorthUpToEyeCoordinates : czm_eastNorthUpToEyeCoordinates,
214
214
  czm_ellipsoidContainsPoint : czm_ellipsoidContainsPoint,
215
- czm_ellipsoidWgs84TextureCoordinates : czm_ellipsoidWgs84TextureCoordinates,
215
+ czm_ellipsoidTextureCoordinates : czm_ellipsoidTextureCoordinates,
216
216
  czm_equalsEpsilon : czm_equalsEpsilon,
217
217
  czm_eyeOffset : czm_eyeOffset,
218
218
  czm_eyeToWindowCoordinates : czm_eyeToWindowCoordinates,
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Approximate uv coordinates based on the ellipsoid normal.
3
+ *
4
+ * @name czm_ellipsoidTextureCoordinates
5
+ * @glslFunction
6
+ */
7
+ vec2 czm_ellipsoidTextureCoordinates(vec3 normal)
8
+ {
9
+ return vec2(atan(normal.y, normal.x) * czm_oneOverTwoPi + 0.5, asin(normal.z) * czm_oneOverPi + 0.5);
10
+ }
@@ -1,11 +1,11 @@
1
1
  //This file is automatically rebuilt by the Cesium build process.
2
2
  export default "/**\n\
3
- * DOC_TBA\n\
3
+ * Approximate uv coordinates based on the ellipsoid normal.\n\
4
4
  *\n\
5
- * @name czm_ellipsoidWgs84TextureCoordinates\n\
5
+ * @name czm_ellipsoidTextureCoordinates\n\
6
6
  * @glslFunction\n\
7
7
  */\n\
8
- vec2 czm_ellipsoidWgs84TextureCoordinates(vec3 normal)\n\
8
+ vec2 czm_ellipsoidTextureCoordinates(vec3 normal)\n\
9
9
  {\n\
10
10
  return vec2(atan(normal.y, normal.x) * czm_oneOverTwoPi + 0.5, asin(normal.z) * czm_oneOverPi + 0.5);\n\
11
11
  }\n\
@@ -10,7 +10,7 @@
10
10
  * @property {vec3} normalEC Unperturbed surface normal in eye coordinates.
11
11
  * @property {mat3} tangentToEyeMatrix Matrix for converting a tangent space normal to eye space.
12
12
  * @property {vec3} positionToEyeEC Vector from the fragment to the eye in eye coordinates. The magnitude is the distance in meters from the fragment to the eye.
13
- * @property {float} height The height of the terrain in meters above or below the WGS84 ellipsoid. Only available for globe materials.
13
+ * @property {float} height The height of the terrain in meters above or below the ellipsoid. Only available for globe materials.
14
14
  * @property {float} slope The slope of the terrain in radians. 0 is flat; pi/2 is vertical. Only available for globe materials.
15
15
  * @property {float} aspect The aspect of the terrain in radians. 0 is East, pi/2 is North, pi is West, 3pi/2 is South. Only available for globe materials.
16
16
  */
@@ -11,7 +11,7 @@ export default "/**\n\
11
11
  * @property {vec3} normalEC Unperturbed surface normal in eye coordinates.\n\
12
12
  * @property {mat3} tangentToEyeMatrix Matrix for converting a tangent space normal to eye space.\n\
13
13
  * @property {vec3} positionToEyeEC Vector from the fragment to the eye in eye coordinates. The magnitude is the distance in meters from the fragment to the eye.\n\
14
- * @property {float} height The height of the terrain in meters above or below the WGS84 ellipsoid. Only available for globe materials.\n\
14
+ * @property {float} height The height of the terrain in meters above or below the ellipsoid. Only available for globe materials.\n\
15
15
  * @property {float} slope The slope of the terrain in radians. 0 is flat; pi/2 is vertical. Only available for globe materials.\n\
16
16
  * @property {float} aspect The aspect of the terrain in radians. 0 is East, pi/2 is North, pi is West, 3pi/2 is South. Only available for globe materials.\n\
17
17
  */\n\
@@ -10,6 +10,7 @@
10
10
  * @name czm_modelMaterial
11
11
  * @glslStruct
12
12
  *
13
+ * @property {vec4} baseColor The base color of the material.
13
14
  * @property {vec3} diffuse Incoming light that scatters evenly in all directions.
14
15
  * @property {float} alpha Alpha of this material. 0.0 is completely transparent; 1.0 is completely opaque.
15
16
  * @property {vec3} specular Color of reflected light at normal incidence in PBR materials. This is sometimes referred to as f0 in the literature.
@@ -19,6 +20,7 @@
19
20
  * @property {vec3} emissive Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light.
20
21
  */
21
22
  struct czm_modelMaterial {
23
+ vec4 baseColor;
22
24
  vec3 diffuse;
23
25
  float alpha;
24
26
  vec3 specular;
@@ -11,6 +11,7 @@ export default "/**\n\
11
11
  * @name czm_modelMaterial\n\
12
12
  * @glslStruct\n\
13
13
  *\n\
14
+ * @property {vec4} baseColor The base color of the material.\n\
14
15
  * @property {vec3} diffuse Incoming light that scatters evenly in all directions.\n\
15
16
  * @property {float} alpha Alpha of this material. 0.0 is completely transparent; 1.0 is completely opaque.\n\
16
17
  * @property {vec3} specular Color of reflected light at normal incidence in PBR materials. This is sometimes referred to as f0 in the literature.\n\
@@ -20,6 +21,7 @@ export default "/**\n\
20
21
  * @property {vec3} emissive Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light.\n\
21
22
  */\n\
22
23
  struct czm_modelMaterial {\n\
24
+ vec4 baseColor;\n\
23
25
  vec3 diffuse;\n\
24
26
  float alpha;\n\
25
27
  vec3 specular;\n\
@@ -12,7 +12,7 @@ vec4 computeEllipsoidColor(czm_ray ray, float intersection, float side)
12
12
  vec3 normalMC = geodeticNormal * side; // normalized surface normal (always facing the viewer) in model coordinates
13
13
  vec3 normalEC = normalize(czm_normal * normalMC); // normalized surface normal in eye coordinates
14
14
 
15
- vec2 st = czm_ellipsoidWgs84TextureCoordinates(sphericalNormal);
15
+ vec2 st = czm_ellipsoidTextureCoordinates(sphericalNormal);
16
16
  vec3 positionToEyeEC = -positionEC;
17
17
 
18
18
  czm_materialInput materialInput;
@@ -13,7 +13,7 @@ vec4 computeEllipsoidColor(czm_ray ray, float intersection, float side)\n\
13
13
  vec3 normalMC = geodeticNormal * side; // normalized surface normal (always facing the viewer) in model coordinates\n\
14
14
  vec3 normalEC = normalize(czm_normal * normalMC); // normalized surface normal in eye coordinates\n\
15
15
  \n\
16
- vec2 st = czm_ellipsoidWgs84TextureCoordinates(sphericalNormal);\n\
16
+ vec2 st = czm_ellipsoidTextureCoordinates(sphericalNormal);\n\
17
17
  vec3 positionToEyeEC = -positionEC;\n\
18
18
  \n\
19
19
  czm_materialInput materialInput;\n\
@@ -374,8 +374,8 @@ void main()
374
374
  {
375
375
  mat3 enuToEye = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalEC);
376
376
 
377
- vec2 ellipsoidTextureCoordinates = czm_ellipsoidWgs84TextureCoordinates(normalMC);
378
- vec2 ellipsoidFlippedTextureCoordinates = czm_ellipsoidWgs84TextureCoordinates(normalMC.zyx);
377
+ vec2 ellipsoidTextureCoordinates = czm_ellipsoidTextureCoordinates(normalMC);
378
+ vec2 ellipsoidFlippedTextureCoordinates = czm_ellipsoidTextureCoordinates(normalMC.zyx);
379
379
 
380
380
  vec2 textureCoordinates = mix(ellipsoidTextureCoordinates, ellipsoidFlippedTextureCoordinates, czm_morphTime * smoothstep(0.9, 0.95, normalMC.z));
381
381
 
@@ -375,8 +375,8 @@ void main()\n\
375
375
  {\n\
376
376
  mat3 enuToEye = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalEC);\n\
377
377
  \n\
378
- vec2 ellipsoidTextureCoordinates = czm_ellipsoidWgs84TextureCoordinates(normalMC);\n\
379
- vec2 ellipsoidFlippedTextureCoordinates = czm_ellipsoidWgs84TextureCoordinates(normalMC.zyx);\n\
378
+ vec2 ellipsoidTextureCoordinates = czm_ellipsoidTextureCoordinates(normalMC);\n\
379
+ vec2 ellipsoidFlippedTextureCoordinates = czm_ellipsoidTextureCoordinates(normalMC.zyx);\n\
380
380
  \n\
381
381
  vec2 textureCoordinates = mix(ellipsoidTextureCoordinates, ellipsoidFlippedTextureCoordinates, czm_morphTime * smoothstep(0.9, 0.95, normalMC.z));\n\
382
382
  \n\
@@ -65,7 +65,11 @@ NormalInfo getNormalInfo(ProcessedAttributes attributes)
65
65
  #ifdef HAS_NORMAL_TEXTURE
66
66
  mat3 tbn = mat3(tangent, bitangent, geometryNormal);
67
67
  vec3 normalSample = texture(u_normalTexture, normalTexCoords).rgb;
68
- vec3 normal = normalize(tbn * (2.0 * normalSample - 1.0));
68
+ normalSample = 2.0 * normalSample - 1.0;
69
+ #ifdef HAS_NORMAL_TEXTURE_SCALE
70
+ normalSample.xy *= u_normalTextureScale;
71
+ #endif
72
+ vec3 normal = normalize(tbn * normalSample);
69
73
  #else
70
74
  vec3 normal = geometryNormal;
71
75
  #endif
@@ -105,10 +109,12 @@ vec3 getNormalFromTexture(ProcessedAttributes attributes, vec3 geometryNormal)
105
109
  #endif
106
110
 
107
111
  mat3 tbn = mat3(t, b, geometryNormal);
108
- vec3 n = texture(u_normalTexture, normalTexCoords).rgb;
109
- vec3 textureNormal = normalize(tbn * (2.0 * n - 1.0));
110
-
111
- return textureNormal;
112
+ vec3 normalSample = texture(u_normalTexture, normalTexCoords).rgb;
113
+ normalSample = 2.0 * normalSample - 1.0;
114
+ #ifdef HAS_NORMAL_TEXTURE_SCALE
115
+ normalSample.xy *= u_normalTextureScale;
116
+ #endif
117
+ return normalize(tbn * normalSample);
112
118
  }
113
119
  #endif
114
120
 
@@ -131,10 +137,12 @@ vec3 getClearcoatNormalFromTexture(ProcessedAttributes attributes, vec3 geometry
131
137
  #endif
132
138
 
133
139
  mat3 tbn = mat3(t, b, geometryNormal);
134
- vec3 n = texture(u_clearcoatNormalTexture, normalTexCoords).rgb;
135
- vec3 textureNormal = normalize(tbn * (2.0 * n - 1.0));
136
-
137
- return textureNormal;
140
+ vec3 normalSample = texture(u_clearcoatNormalTexture, normalTexCoords).rgb;
141
+ normalSample = 2.0 * normalSample - 1.0;
142
+ #ifdef HAS_CLEARCOAT_NORMAL_TEXTURE_SCALE
143
+ normalSample.xy *= u_clearcoatNormalTextureScale;
144
+ #endif
145
+ return normalize(tbn * normalSample);
138
146
  }
139
147
  #endif
140
148
 
@@ -288,12 +296,12 @@ float setMetallicRoughness(inout czm_modelMaterial material)
288
296
 
289
297
  // dielectrics use f0 = 0.04, metals use albedo as f0
290
298
  const vec3 REFLECTANCE_DIELECTRIC = vec3(0.04);
291
- vec3 f0 = mix(REFLECTANCE_DIELECTRIC, material.diffuse, metalness);
299
+ vec3 f0 = mix(REFLECTANCE_DIELECTRIC, material.baseColor.rgb, metalness);
292
300
 
293
301
  material.specular = f0;
294
302
 
295
303
  // diffuse only applies to dielectrics.
296
- material.diffuse = material.diffuse * (1.0 - f0) * (1.0 - metalness);
304
+ material.diffuse = mix(material.baseColor.rgb, vec3(0.0), metalness);
297
305
 
298
306
  // roughness is authored as perceptual roughness
299
307
  // square it to get material roughness
@@ -341,7 +349,7 @@ void setSpecular(inout czm_modelMaterial material, in float metalness)
341
349
  material.specularWeight = specularWeight;
342
350
  vec3 f0 = material.specular;
343
351
  vec3 dielectricSpecularF0 = min(f0 * specularColorFactor, vec3(1.0));
344
- material.specular = mix(dielectricSpecularF0, material.diffuse, metalness);
352
+ material.specular = mix(dielectricSpecularF0, material.baseColor.rgb, metalness);
345
353
  }
346
354
  #endif
347
355
  #ifdef USE_ANISOTROPY
@@ -450,6 +458,7 @@ void materialStage(inout czm_modelMaterial material, ProcessedAttributes attribu
450
458
  baseColorWithAlpha *= color;
451
459
  #endif
452
460
 
461
+ material.baseColor = baseColorWithAlpha;
453
462
  material.diffuse = baseColorWithAlpha.rgb;
454
463
  material.alpha = baseColorWithAlpha.a;
455
464
 
@@ -66,7 +66,11 @@ NormalInfo getNormalInfo(ProcessedAttributes attributes)\n\
66
66
  #ifdef HAS_NORMAL_TEXTURE\n\
67
67
  mat3 tbn = mat3(tangent, bitangent, geometryNormal);\n\
68
68
  vec3 normalSample = texture(u_normalTexture, normalTexCoords).rgb;\n\
69
- vec3 normal = normalize(tbn * (2.0 * normalSample - 1.0));\n\
69
+ normalSample = 2.0 * normalSample - 1.0;\n\
70
+ #ifdef HAS_NORMAL_TEXTURE_SCALE\n\
71
+ normalSample.xy *= u_normalTextureScale;\n\
72
+ #endif\n\
73
+ vec3 normal = normalize(tbn * normalSample);\n\
70
74
  #else\n\
71
75
  vec3 normal = geometryNormal;\n\
72
76
  #endif\n\
@@ -106,10 +110,12 @@ vec3 getNormalFromTexture(ProcessedAttributes attributes, vec3 geometryNormal)\n
106
110
  #endif\n\
107
111
  \n\
108
112
  mat3 tbn = mat3(t, b, geometryNormal);\n\
109
- vec3 n = texture(u_normalTexture, normalTexCoords).rgb;\n\
110
- vec3 textureNormal = normalize(tbn * (2.0 * n - 1.0));\n\
111
- \n\
112
- return textureNormal;\n\
113
+ vec3 normalSample = texture(u_normalTexture, normalTexCoords).rgb;\n\
114
+ normalSample = 2.0 * normalSample - 1.0;\n\
115
+ #ifdef HAS_NORMAL_TEXTURE_SCALE\n\
116
+ normalSample.xy *= u_normalTextureScale;\n\
117
+ #endif\n\
118
+ return normalize(tbn * normalSample);\n\
113
119
  }\n\
114
120
  #endif\n\
115
121
  \n\
@@ -132,10 +138,12 @@ vec3 getClearcoatNormalFromTexture(ProcessedAttributes attributes, vec3 geometry
132
138
  #endif\n\
133
139
  \n\
134
140
  mat3 tbn = mat3(t, b, geometryNormal);\n\
135
- vec3 n = texture(u_clearcoatNormalTexture, normalTexCoords).rgb;\n\
136
- vec3 textureNormal = normalize(tbn * (2.0 * n - 1.0));\n\
137
- \n\
138
- return textureNormal;\n\
141
+ vec3 normalSample = texture(u_clearcoatNormalTexture, normalTexCoords).rgb;\n\
142
+ normalSample = 2.0 * normalSample - 1.0;\n\
143
+ #ifdef HAS_CLEARCOAT_NORMAL_TEXTURE_SCALE\n\
144
+ normalSample.xy *= u_clearcoatNormalTextureScale;\n\
145
+ #endif\n\
146
+ return normalize(tbn * normalSample);\n\
139
147
  }\n\
140
148
  #endif\n\
141
149
  \n\
@@ -289,12 +297,12 @@ float setMetallicRoughness(inout czm_modelMaterial material)\n\
289
297
  \n\
290
298
  // dielectrics use f0 = 0.04, metals use albedo as f0\n\
291
299
  const vec3 REFLECTANCE_DIELECTRIC = vec3(0.04);\n\
292
- vec3 f0 = mix(REFLECTANCE_DIELECTRIC, material.diffuse, metalness);\n\
300
+ vec3 f0 = mix(REFLECTANCE_DIELECTRIC, material.baseColor.rgb, metalness);\n\
293
301
  \n\
294
302
  material.specular = f0;\n\
295
303
  \n\
296
304
  // diffuse only applies to dielectrics.\n\
297
- material.diffuse = material.diffuse * (1.0 - f0) * (1.0 - metalness);\n\
305
+ material.diffuse = mix(material.baseColor.rgb, vec3(0.0), metalness);\n\
298
306
  \n\
299
307
  // roughness is authored as perceptual roughness\n\
300
308
  // square it to get material roughness\n\
@@ -342,7 +350,7 @@ void setSpecular(inout czm_modelMaterial material, in float metalness)\n\
342
350
  material.specularWeight = specularWeight;\n\
343
351
  vec3 f0 = material.specular;\n\
344
352
  vec3 dielectricSpecularF0 = min(f0 * specularColorFactor, vec3(1.0));\n\
345
- material.specular = mix(dielectricSpecularF0, material.diffuse, metalness);\n\
353
+ material.specular = mix(dielectricSpecularF0, material.baseColor.rgb, metalness);\n\
346
354
  }\n\
347
355
  #endif\n\
348
356
  #ifdef USE_ANISOTROPY\n\
@@ -451,6 +459,7 @@ void materialStage(inout czm_modelMaterial material, ProcessedAttributes attribu
451
459
  baseColorWithAlpha *= color;\n\
452
460
  #endif\n\
453
461
  \n\
462
+ material.baseColor = baseColorWithAlpha;\n\
454
463
  material.diffuse = baseColorWithAlpha.rgb;\n\
455
464
  material.alpha = baseColorWithAlpha.a;\n\
456
465
  \n\