@cesium/engine 2.2.0 → 2.4.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 (139) hide show
  1. package/Build/Workers/{AttributeCompression-8a5a065e.js → AttributeCompression-f9f6c717.js} +1 -1
  2. package/Build/Workers/{AxisAlignedBoundingBox-379015ef.js → AxisAlignedBoundingBox-4bfd84f3.js} +1 -1
  3. package/Build/Workers/{BoundingRectangle-57f2b24f.js → BoundingRectangle-5fd6403a.js} +1 -1
  4. package/Build/Workers/{BoxGeometry-ecabfc78.js → BoxGeometry-af7d05ef.js} +1 -1
  5. package/Build/Workers/{Color-14d1a36d.js → Color-e5bfda3f.js} +1 -1
  6. package/Build/Workers/{CoplanarPolygonGeometryLibrary-048c3c14.js → CoplanarPolygonGeometryLibrary-59c69b0a.js} +1 -1
  7. package/Build/Workers/{CorridorGeometryLibrary-520c8619.js → CorridorGeometryLibrary-63907365.js} +1 -1
  8. package/Build/Workers/{CylinderGeometry-119068b8.js → CylinderGeometry-dbaa1678.js} +1 -1
  9. package/Build/Workers/{CylinderGeometryLibrary-135b0858.js → CylinderGeometryLibrary-7bf291b4.js} +1 -1
  10. package/Build/Workers/{EllipseGeometry-2dfc3523.js → EllipseGeometry-6508b78b.js} +1 -1
  11. package/Build/Workers/{EllipseGeometryLibrary-0a1e0170.js → EllipseGeometryLibrary-21262a28.js} +1 -1
  12. package/Build/Workers/{EllipseOutlineGeometry-c5251669.js → EllipseOutlineGeometry-2a2510bb.js} +1 -1
  13. package/Build/Workers/{EllipsoidGeodesic-dcff5cbd.js → EllipsoidGeodesic-5b3623dc.js} +1 -1
  14. package/Build/Workers/{EllipsoidGeometry-d10a5221.js → EllipsoidGeometry-8155e3a2.js} +1 -1
  15. package/Build/Workers/{EllipsoidOutlineGeometry-7039a0ae.js → EllipsoidOutlineGeometry-c045678d.js} +1 -1
  16. package/Build/Workers/{EllipsoidRhumbLine-b672d507.js → EllipsoidRhumbLine-ef872433.js} +1 -1
  17. package/Build/Workers/{EllipsoidTangentPlane-857186be.js → EllipsoidTangentPlane-546c0d5e.js} +1 -1
  18. package/Build/Workers/{EncodedCartesian3-e8bbca36.js → EncodedCartesian3-57415c8a.js} +1 -1
  19. package/Build/Workers/{FrustumGeometry-400fa1b7.js → FrustumGeometry-d3ff16d0.js} +31 -3
  20. package/Build/Workers/{GeometryAttribute-7a2de5c6.js → GeometryAttribute-13da9466.js} +1 -1
  21. package/Build/Workers/{GeometryInstance-3fb607b7.js → GeometryInstance-34d9e21e.js} +1 -1
  22. package/Build/Workers/{GeometryPipeline-916636fa.js → GeometryPipeline-03bc5709.js} +1 -1
  23. package/Build/Workers/{IndexDatatype-b8f3e09d.js → IndexDatatype-2643aa47.js} +1 -1
  24. package/Build/Workers/{IntersectionTests-b4d02d4d.js → IntersectionTests-85350792.js} +1 -1
  25. package/Build/Workers/{Math-dad82b4d.js → Math-0a2ac845.js} +12 -2
  26. package/Build/Workers/{Matrix2-1e403d0e.js → Matrix2-e1298525.js} +1 -1
  27. package/Build/Workers/{Matrix3-fa806b97.js → Matrix3-41c58dde.js} +1 -1
  28. package/Build/Workers/{OrientedBoundingBox-96fe1752.js → OrientedBoundingBox-29fb0fcd.js} +1 -1
  29. package/Build/Workers/{Plane-c27e1ac6.js → Plane-4c3d403b.js} +1 -1
  30. package/Build/Workers/{PolygonGeometryLibrary-931f1ec6.js → PolygonGeometryLibrary-d447448d.js} +1 -1
  31. package/Build/Workers/PolygonPipeline-460cce4e.js +1344 -0
  32. package/Build/Workers/{PolylinePipeline-6d5c63e5.js → PolylinePipeline-7119eb3f.js} +1 -1
  33. package/Build/Workers/{PolylineVolumeGeometryLibrary-f068c1fb.js → PolylineVolumeGeometryLibrary-d25f0050.js} +1 -1
  34. package/Build/Workers/{PrimitivePipeline-879f996a.js → PrimitivePipeline-e648752b.js} +1 -1
  35. package/Build/Workers/{RectangleGeometryLibrary-2d6f36f3.js → RectangleGeometryLibrary-bb378fb6.js} +1 -1
  36. package/Build/Workers/{TerrainEncoding-82882059.js → TerrainEncoding-c8e029a2.js} +1 -1
  37. package/Build/Workers/Transforms-e2d4a55a.js +14713 -0
  38. package/Build/Workers/{WallGeometryLibrary-db7a64fb.js → WallGeometryLibrary-3e0819ec.js} +1 -1
  39. package/Build/Workers/{WebMercatorProjection-76a3fcc0.js → WebMercatorProjection-13ed1a6e.js} +1 -1
  40. package/Build/Workers/{arrayRemoveDuplicates-fac118a8.js → arrayRemoveDuplicates-d2061e85.js} +1 -1
  41. package/Build/Workers/cesiumWorkerBootstrapper.js +1 -1
  42. package/Build/Workers/combineGeometry.js +1 -1
  43. package/Build/Workers/createBoxGeometry.js +1 -1
  44. package/Build/Workers/createBoxOutlineGeometry.js +1 -1
  45. package/Build/Workers/createCircleGeometry.js +1 -1
  46. package/Build/Workers/createCircleOutlineGeometry.js +1 -1
  47. package/Build/Workers/createCoplanarPolygonGeometry.js +1 -1
  48. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +1 -1
  49. package/Build/Workers/createCorridorGeometry.js +1 -1
  50. package/Build/Workers/createCorridorOutlineGeometry.js +1 -1
  51. package/Build/Workers/createCylinderGeometry.js +1 -1
  52. package/Build/Workers/createCylinderOutlineGeometry.js +1 -1
  53. package/Build/Workers/createEllipseGeometry.js +1 -1
  54. package/Build/Workers/createEllipseOutlineGeometry.js +1 -1
  55. package/Build/Workers/createEllipsoidGeometry.js +1 -1
  56. package/Build/Workers/createEllipsoidOutlineGeometry.js +1 -1
  57. package/Build/Workers/createFrustumGeometry.js +1 -1
  58. package/Build/Workers/createFrustumOutlineGeometry.js +1 -1
  59. package/Build/Workers/createGeometry.js +1 -1
  60. package/Build/Workers/createGroundPolylineGeometry.js +1 -1
  61. package/Build/Workers/createPlaneGeometry.js +1 -1
  62. package/Build/Workers/createPlaneOutlineGeometry.js +1 -1
  63. package/Build/Workers/createPolygonGeometry.js +1 -1
  64. package/Build/Workers/createPolygonOutlineGeometry.js +1 -1
  65. package/Build/Workers/createPolylineGeometry.js +1 -1
  66. package/Build/Workers/createPolylineVolumeGeometry.js +1 -1
  67. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +1 -1
  68. package/Build/Workers/createRectangleGeometry.js +1 -1
  69. package/Build/Workers/createRectangleOutlineGeometry.js +1 -1
  70. package/Build/Workers/createSimplePolylineGeometry.js +1 -1
  71. package/Build/Workers/createSphereGeometry.js +1 -1
  72. package/Build/Workers/createSphereOutlineGeometry.js +1 -1
  73. package/Build/Workers/createVectorTileClampedPolylines.js +1 -1
  74. package/Build/Workers/createVectorTileGeometries.js +1 -1
  75. package/Build/Workers/createVectorTilePoints.js +1 -1
  76. package/Build/Workers/createVectorTilePolygons.js +1 -1
  77. package/Build/Workers/createVectorTilePolylines.js +1 -1
  78. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +1 -1
  79. package/Build/Workers/createVerticesFromHeightmap.js +5 -8
  80. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +1 -1
  81. package/Build/Workers/createWallGeometry.js +1 -1
  82. package/Build/Workers/createWallOutlineGeometry.js +1 -1
  83. package/Build/Workers/decodeDraco.js +1 -1
  84. package/Build/Workers/decodeI3S.js +1 -1
  85. package/Build/Workers/package.js +1 -1
  86. package/Build/Workers/transferTypedArrayTest.js +1 -1
  87. package/Build/Workers/upsampleQuantizedTerrainMesh.js +1 -1
  88. package/Source/Core/BingMapsGeocoderService.js +19 -1
  89. package/Source/Core/CartographicGeocoderService.js +15 -0
  90. package/Source/Core/Credit.js +1 -1
  91. package/Source/Core/FrustumGeometry.js +3 -2
  92. package/Source/Core/GeocoderService.js +32 -1
  93. package/Source/Core/GoogleMaps.js +56 -0
  94. package/Source/Core/Ion.js +2 -1
  95. package/Source/Core/IonGeocoderService.js +17 -2
  96. package/Source/Core/OpenCageGeocoderService.js +18 -1
  97. package/Source/Core/OrthographicFrustum.js +13 -0
  98. package/Source/Core/PeliasGeocoderService.js +14 -1
  99. package/Source/Core/PerspectiveFrustum.js +14 -0
  100. package/Source/Core/Request.js +3 -2
  101. package/Source/Core/RequestScheduler.js +10 -4
  102. package/Source/Core/Resource.js +240 -233
  103. package/Source/DataSources/DataSourceDisplay.js +2 -2
  104. package/Source/DataSources/EntityCluster.js +126 -128
  105. package/Source/DataSources/ModelVisualizer.js +5 -3
  106. package/Source/Renderer/UniformState.js +3 -2
  107. package/Source/Renderer/demodernizeShader.js +5 -5
  108. package/Source/Scene/ArcGisBaseMapType.js +12 -0
  109. package/Source/Scene/ArcGisMapServerImageryProvider.js +162 -20
  110. package/Source/Scene/ArcGisMapService.js +84 -0
  111. package/Source/Scene/Camera.js +8 -7
  112. package/Source/Scene/Cesium3DTile.js +4 -3
  113. package/Source/Scene/Cesium3DTileset.js +6 -5
  114. package/Source/Scene/CreditDisplay.js +112 -16
  115. package/Source/Scene/GlobeSurfaceTileProvider.js +4 -4
  116. package/Source/Scene/GltfJsonLoader.js +12 -0
  117. package/Source/Scene/GltfLoader.js +6 -37
  118. package/Source/Scene/IonImageryProvider.js +11 -11
  119. package/Source/Scene/Model/MaterialPipelineStage.js +12 -12
  120. package/Source/Scene/Model/Model.js +90 -47
  121. package/Source/Scene/Model/UniformType.js +1 -1
  122. package/Source/Scene/Picking.js +3 -2
  123. package/Source/Scene/QuadtreePrimitive.js +3 -2
  124. package/Source/Scene/SceneTransforms.js +3 -2
  125. package/Source/Scene/ScreenSpaceCameraController.js +140 -32
  126. package/Source/Scene/Vector3DTilePoints.js +25 -13
  127. package/Source/Scene/createGooglePhotorealistic3DTileset.js +53 -0
  128. package/Source/Shaders/AtmosphereCommon.glsl +51 -8
  129. package/Source/Shaders/AtmosphereCommon.js +51 -8
  130. package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.glsl +1 -1
  131. package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.js +1 -1
  132. package/Source/Shaders/PostProcessStages/AmbientOcclusionModulate.glsl +3 -3
  133. package/Source/Shaders/PostProcessStages/AmbientOcclusionModulate.js +3 -3
  134. package/Source/Widget/CesiumWidget.js +12 -0
  135. package/index.d.ts +244 -17
  136. package/index.js +14 -10
  137. package/package.json +4 -4
  138. package/Build/Workers/PolygonPipeline-32fc92cc.js +0 -1345
  139. package/Build/Workers/Transforms-9052372a.js +0 -14715
@@ -0,0 +1,53 @@
1
+ import Cesium3DTileset from "./Cesium3DTileset.js";
2
+ import defaultValue from "../Core/defaultValue.js";
3
+ import defined from "../Core/defined.js";
4
+ import GoogleMaps from "../Core/GoogleMaps.js";
5
+ import Resource from "../Core/Resource.js";
6
+
7
+ /**
8
+ * Creates a {@link Cesium3DTileset} instance for the Google Photorealistic 3D Tiles tileset.
9
+ *
10
+ * @function
11
+ *
12
+ * @param {string} [key=GoogleMaps.defaultApiKey] Your API key to access Google Photorealistic 3D Tiles. See {@link https://developers.google.com/maps/documentation/javascript/get-api-key} for instructions on how to create your own key.
13
+ * @param {Cesium3DTileset.ConstructorOptions} [options] An object describing initialization options.
14
+ * @returns {Promise<Cesium3DTileset>}
15
+ *
16
+ * @see GoogleMaps
17
+ *
18
+ * @example
19
+ * Cesium.GoogleMaps.defaultApiKey = "your-api-key";
20
+ *
21
+ * const viewer = new Cesium.Viewer("cesiumContainer");
22
+ *
23
+ * try {
24
+ * const tileset = await Cesium.createGooglePhotorealistic3DTileset();
25
+ * viewer.scene.primitives.add(tileset));
26
+ * } catch (error) {
27
+ * console.log(`Error creating tileset: ${error}`);
28
+ * }
29
+ */
30
+ async function createGooglePhotorealistic3DTileset(key, options) {
31
+ key = defaultValue(key, GoogleMaps.defaultApiKey);
32
+
33
+ let credits;
34
+ const credit = GoogleMaps.getDefaultApiKeyCredit(key);
35
+ if (defined(credit)) {
36
+ credits = [credit];
37
+ }
38
+
39
+ options = defaultValue(options, {});
40
+ options.showCreditsOnScreen = true;
41
+
42
+ const resource = new Resource({
43
+ url: `${GoogleMaps.mapTilesApiEndpoint}3dtiles/root.json`,
44
+ queryParameters: {
45
+ key: key,
46
+ },
47
+ credits: credits,
48
+ });
49
+
50
+ return Cesium3DTileset.fromUrl(resource, options);
51
+ }
52
+
53
+ export default createGooglePhotorealistic3DTileset;
@@ -8,8 +8,16 @@ uniform vec3 u_atmosphereRayleighCoefficient;
8
8
  uniform vec3 u_atmosphereMieCoefficient;
9
9
 
10
10
  const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in meters.
11
- const int PRIMARY_STEPS = 16; // Number of times the ray from the camera to the world position (primary ray) is sampled.
12
- const int LIGHT_STEPS = 4; // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
11
+ const int PRIMARY_STEPS_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.
12
+ const int LIGHT_STEPS_MAX = 4; // Maximum number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
13
+
14
+ /**
15
+ * Rational approximation to tanh(x)
16
+ */
17
+ float approximateTanh(float x) {
18
+ float x2 = x * x;
19
+ return max(-1.0, min(+1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));
20
+ }
13
21
 
14
22
  /**
15
23
  * This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as
@@ -50,14 +58,36 @@ void computeScattering(
50
58
  return;
51
59
  }
52
60
 
61
+ // To deal with smaller values of PRIMARY_STEPS (e.g. 4)
62
+ // we implement a split strategy: sky or horizon.
63
+ // For performance reasons, instead of a if/else branch
64
+ // a soft choice is implemented through a weight 0.0 <= w_stop_gt_lprl <= 1.0
65
+ float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength);
66
+ // Value close to 0.0: close to the horizon
67
+ // Value close to 1.0: above in the sky
68
+ float w_stop_gt_lprl = 0.5 * (1.0 + approximateTanh(x));
69
+
53
70
  // The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.
71
+ float start_0 = primaryRayAtmosphereIntersect.start;
54
72
  primaryRayAtmosphereIntersect.start = max(primaryRayAtmosphereIntersect.start, 0.0);
55
73
  // The ray should end at the exit from the atmosphere or at the distance to the vertex, whichever is smaller.
56
74
  primaryRayAtmosphereIntersect.stop = min(primaryRayAtmosphereIntersect.stop, length(primaryRayLength));
57
75
 
76
+ // For the number of ray steps, distinguish inside or outside atmosphere (outer space)
77
+ // (1) from outer space we have to use more ray steps to get a realistic rendering
78
+ // (2) within atmosphere we need fewer steps for faster rendering
79
+ float x_o_a = start_0 - ATMOSPHERE_THICKNESS; // ATMOSPHERE_THICKNESS used as an ad-hoc constant, no precise meaning here, only the order of magnitude matters
80
+ float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + approximateTanh(x_o_a));
81
+ int PRIMARY_STEPS = PRIMARY_STEPS_MAX - int(w_inside_atmosphere * 12.0); // Number of times the ray from the camera to the world position (primary ray) is sampled.
82
+ int LIGHT_STEPS = LIGHT_STEPS_MAX - int(w_inside_atmosphere * 2.0); // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
83
+
58
84
  // Setup for sampling positions along the ray - starting from the intersection with the outer ring of the atmosphere.
59
- float rayStepLength = (primaryRayAtmosphereIntersect.stop - primaryRayAtmosphereIntersect.start) / float(PRIMARY_STEPS);
60
85
  float rayPositionLength = primaryRayAtmosphereIntersect.start;
86
+ // (1) Outside the atmosphere: constant rayStepLength
87
+ // (2) Inside atmosphere: variable rayStepLength to compensate the rough rendering of the smaller number of ray steps
88
+ float totalRayLength = primaryRayAtmosphereIntersect.stop - rayPositionLength;
89
+ float rayStepLengthIncrease = w_inside_atmosphere * ((1.0 - w_stop_gt_lprl) * totalRayLength / (float(PRIMARY_STEPS * (PRIMARY_STEPS + 1)) / 2.0));
90
+ float rayStepLength = max(1.0 - w_inside_atmosphere, w_stop_gt_lprl) * totalRayLength / max(7.0 * w_inside_atmosphere, float(PRIMARY_STEPS));
61
91
 
62
92
  vec3 rayleighAccumulation = vec3(0.0);
63
93
  vec3 mieAccumulation = vec3(0.0);
@@ -65,10 +95,17 @@ void computeScattering(
65
95
  vec2 heightScale = vec2(u_atmosphereRayleighScaleHeight, u_atmosphereMieScaleHeight);
66
96
 
67
97
  // Sample positions on the primary ray.
68
- for (int i = 0; i < PRIMARY_STEPS; i++) {
98
+ for (int i = 0; i < PRIMARY_STEPS_MAX; ++i) {
99
+
100
+ // The loop should be: for (int i = 0; i < PRIMARY_STEPS; ++i) {...} but WebGL1 cannot
101
+ // loop with non-constant condition, so it has to break early instead
102
+ if (i >= PRIMARY_STEPS) {
103
+ break;
104
+ }
105
+
69
106
  // Calculate sample position along viewpoint ray.
70
107
  vec3 samplePosition = primaryRay.origin + primaryRay.direction * (rayPositionLength + rayStepLength);
71
-
108
+
72
109
  // Calculate height of sample position above ellipsoid.
73
110
  float sampleHeight = length(samplePosition) - atmosphereInnerRadius;
74
111
 
@@ -79,14 +116,20 @@ void computeScattering(
79
116
  // Generate ray from the sample position segment to the light source, up to the outer ring of the atmosphere.
80
117
  czm_ray lightRay = czm_ray(samplePosition, lightDirection);
81
118
  czm_raySegment lightRayAtmosphereIntersect = czm_raySphereIntersectionInterval(lightRay, origin, atmosphereOuterRadius);
82
-
119
+
83
120
  float lightStepLength = lightRayAtmosphereIntersect.stop / float(LIGHT_STEPS);
84
121
  float lightPositionLength = 0.0;
85
122
 
86
123
  vec2 lightOpticalDepth = vec2(0.0);
87
124
 
88
125
  // Sample positions along the light ray, to accumulate incidence of light on the latest sample segment.
89
- for (int j = 0; j < LIGHT_STEPS; j++) {
126
+ for (int j = 0; j < LIGHT_STEPS_MAX; ++j) {
127
+
128
+ // The loop should be: for (int j = 0; i < LIGHT_STEPS; ++j) {...} but WebGL1 cannot
129
+ // loop with non-constant condition, so it has to break early instead
130
+ if (j >= LIGHT_STEPS) {
131
+ break;
132
+ }
90
133
 
91
134
  // Calculate sample position along light ray.
92
135
  vec3 lightPosition = samplePosition + lightDirection * (lightPositionLength + lightStepLength * 0.5);
@@ -109,7 +152,7 @@ void computeScattering(
109
152
  mieAccumulation += sampleDensity.y * attenuation;
110
153
 
111
154
  // Increment distance on primary ray.
112
- rayPositionLength += rayStepLength;
155
+ rayPositionLength += (rayStepLength += rayStepLengthIncrease);
113
156
  }
114
157
 
115
158
  // Compute the scattering amount.
@@ -9,8 +9,16 @@ uniform vec3 u_atmosphereRayleighCoefficient;\n\
9
9
  uniform vec3 u_atmosphereMieCoefficient;\n\
10
10
  \n\
11
11
  const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in meters.\n\
12
- const int PRIMARY_STEPS = 16; // Number of times the ray from the camera to the world position (primary ray) is sampled.\n\
13
- const int LIGHT_STEPS = 4; // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.\n\
12
+ const int PRIMARY_STEPS_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.\n\
13
+ const int LIGHT_STEPS_MAX = 4; // Maximum number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.\n\
14
+ \n\
15
+ /**\n\
16
+ * Rational approximation to tanh(x)\n\
17
+ */\n\
18
+ float approximateTanh(float x) {\n\
19
+ float x2 = x * x;\n\
20
+ return max(-1.0, min(+1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));\n\
21
+ }\n\
14
22
  \n\
15
23
  /**\n\
16
24
  * This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as\n\
@@ -51,14 +59,36 @@ void computeScattering(\n\
51
59
  return;\n\
52
60
  }\n\
53
61
  \n\
62
+ // To deal with smaller values of PRIMARY_STEPS (e.g. 4)\n\
63
+ // we implement a split strategy: sky or horizon.\n\
64
+ // For performance reasons, instead of a if/else branch\n\
65
+ // a soft choice is implemented through a weight 0.0 <= w_stop_gt_lprl <= 1.0\n\
66
+ float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength);\n\
67
+ // Value close to 0.0: close to the horizon\n\
68
+ // Value close to 1.0: above in the sky\n\
69
+ float w_stop_gt_lprl = 0.5 * (1.0 + approximateTanh(x));\n\
70
+ \n\
54
71
  // The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.\n\
72
+ float start_0 = primaryRayAtmosphereIntersect.start;\n\
55
73
  primaryRayAtmosphereIntersect.start = max(primaryRayAtmosphereIntersect.start, 0.0);\n\
56
74
  // The ray should end at the exit from the atmosphere or at the distance to the vertex, whichever is smaller.\n\
57
75
  primaryRayAtmosphereIntersect.stop = min(primaryRayAtmosphereIntersect.stop, length(primaryRayLength));\n\
76
+ \n\
77
+ // For the number of ray steps, distinguish inside or outside atmosphere (outer space)\n\
78
+ // (1) from outer space we have to use more ray steps to get a realistic rendering\n\
79
+ // (2) within atmosphere we need fewer steps for faster rendering\n\
80
+ float x_o_a = start_0 - ATMOSPHERE_THICKNESS; // ATMOSPHERE_THICKNESS used as an ad-hoc constant, no precise meaning here, only the order of magnitude matters\n\
81
+ float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + approximateTanh(x_o_a));\n\
82
+ int PRIMARY_STEPS = PRIMARY_STEPS_MAX - int(w_inside_atmosphere * 12.0); // Number of times the ray from the camera to the world position (primary ray) is sampled.\n\
83
+ int LIGHT_STEPS = LIGHT_STEPS_MAX - int(w_inside_atmosphere * 2.0); // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.\n\
58
84
  \n\
59
85
  // Setup for sampling positions along the ray - starting from the intersection with the outer ring of the atmosphere.\n\
60
- float rayStepLength = (primaryRayAtmosphereIntersect.stop - primaryRayAtmosphereIntersect.start) / float(PRIMARY_STEPS);\n\
61
86
  float rayPositionLength = primaryRayAtmosphereIntersect.start;\n\
87
+ // (1) Outside the atmosphere: constant rayStepLength\n\
88
+ // (2) Inside atmosphere: variable rayStepLength to compensate the rough rendering of the smaller number of ray steps\n\
89
+ float totalRayLength = primaryRayAtmosphereIntersect.stop - rayPositionLength;\n\
90
+ float rayStepLengthIncrease = w_inside_atmosphere * ((1.0 - w_stop_gt_lprl) * totalRayLength / (float(PRIMARY_STEPS * (PRIMARY_STEPS + 1)) / 2.0));\n\
91
+ float rayStepLength = max(1.0 - w_inside_atmosphere, w_stop_gt_lprl) * totalRayLength / max(7.0 * w_inside_atmosphere, float(PRIMARY_STEPS));\n\
62
92
  \n\
63
93
  vec3 rayleighAccumulation = vec3(0.0);\n\
64
94
  vec3 mieAccumulation = vec3(0.0);\n\
@@ -66,10 +96,17 @@ void computeScattering(\n\
66
96
  vec2 heightScale = vec2(u_atmosphereRayleighScaleHeight, u_atmosphereMieScaleHeight);\n\
67
97
  \n\
68
98
  // Sample positions on the primary ray.\n\
69
- for (int i = 0; i < PRIMARY_STEPS; i++) {\n\
99
+ for (int i = 0; i < PRIMARY_STEPS_MAX; ++i) {\n\
100
+ \n\
101
+ // The loop should be: for (int i = 0; i < PRIMARY_STEPS; ++i) {...} but WebGL1 cannot\n\
102
+ // loop with non-constant condition, so it has to break early instead\n\
103
+ if (i >= PRIMARY_STEPS) {\n\
104
+ break;\n\
105
+ }\n\
106
+ \n\
70
107
  // Calculate sample position along viewpoint ray.\n\
71
108
  vec3 samplePosition = primaryRay.origin + primaryRay.direction * (rayPositionLength + rayStepLength);\n\
72
- \n\
109
+ \n\
73
110
  // Calculate height of sample position above ellipsoid.\n\
74
111
  float sampleHeight = length(samplePosition) - atmosphereInnerRadius;\n\
75
112
  \n\
@@ -80,14 +117,20 @@ void computeScattering(\n\
80
117
  // Generate ray from the sample position segment to the light source, up to the outer ring of the atmosphere.\n\
81
118
  czm_ray lightRay = czm_ray(samplePosition, lightDirection);\n\
82
119
  czm_raySegment lightRayAtmosphereIntersect = czm_raySphereIntersectionInterval(lightRay, origin, atmosphereOuterRadius);\n\
83
- \n\
120
+ \n\
84
121
  float lightStepLength = lightRayAtmosphereIntersect.stop / float(LIGHT_STEPS);\n\
85
122
  float lightPositionLength = 0.0;\n\
86
123
  \n\
87
124
  vec2 lightOpticalDepth = vec2(0.0);\n\
88
125
  \n\
89
126
  // Sample positions along the light ray, to accumulate incidence of light on the latest sample segment.\n\
90
- for (int j = 0; j < LIGHT_STEPS; j++) {\n\
127
+ for (int j = 0; j < LIGHT_STEPS_MAX; ++j) {\n\
128
+ \n\
129
+ // The loop should be: for (int j = 0; i < LIGHT_STEPS; ++j) {...} but WebGL1 cannot\n\
130
+ // loop with non-constant condition, so it has to break early instead\n\
131
+ if (j >= LIGHT_STEPS) {\n\
132
+ break;\n\
133
+ }\n\
91
134
  \n\
92
135
  // Calculate sample position along light ray.\n\
93
136
  vec3 lightPosition = samplePosition + lightDirection * (lightPositionLength + lightStepLength * 0.5);\n\
@@ -110,7 +153,7 @@ void computeScattering(\n\
110
153
  mieAccumulation += sampleDensity.y * attenuation;\n\
111
154
  \n\
112
155
  // Increment distance on primary ray.\n\
113
- rayPositionLength += rayStepLength;\n\
156
+ rayPositionLength += (rayStepLength += rayStepLengthIncrease);\n\
114
157
  }\n\
115
158
  \n\
116
159
  // Compute the scattering amount.\n\
@@ -58,7 +58,7 @@ void main(void)
58
58
  float gapAngle = 90.0 * czm_radiansPerDegree;
59
59
 
60
60
  // RandomNoise
61
- float randomVal = texture(randomTexture, v_textureCoordinates).x;
61
+ float randomVal = texture(randomTexture, v_textureCoordinates / pixelSize / 255.0).x;
62
62
 
63
63
  //Loop for each direction
64
64
  for (int i = 0; i < 4; i++)
@@ -59,7 +59,7 @@ void main(void)\n\
59
59
  float gapAngle = 90.0 * czm_radiansPerDegree;\n\
60
60
  \n\
61
61
  // RandomNoise\n\
62
- float randomVal = texture(randomTexture, v_textureCoordinates).x;\n\
62
+ float randomVal = texture(randomTexture, v_textureCoordinates / pixelSize / 255.0).x;\n\
63
63
  \n\
64
64
  //Loop for each direction\n\
65
65
  for (int i = 0; i < 4; i++)\n\
@@ -5,7 +5,7 @@ in vec2 v_textureCoordinates;
5
5
 
6
6
  void main(void)
7
7
  {
8
- vec3 color = texture(colorTexture, v_textureCoordinates).rgb;
9
- vec3 ao = texture(ambientOcclusionTexture, v_textureCoordinates).rgb;
10
- out_FragColor.rgb = ambientOcclusionOnly ? ao : ao * color;
8
+ vec4 color = texture(colorTexture, v_textureCoordinates);
9
+ vec4 ao = texture(ambientOcclusionTexture, v_textureCoordinates);
10
+ out_FragColor = ambientOcclusionOnly ? ao : ao * color;
11
11
  }
@@ -6,8 +6,8 @@ in vec2 v_textureCoordinates;\n\
6
6
  \n\
7
7
  void main(void)\n\
8
8
  {\n\
9
- vec3 color = texture(colorTexture, v_textureCoordinates).rgb;\n\
10
- vec3 ao = texture(ambientOcclusionTexture, v_textureCoordinates).rgb;\n\
11
- out_FragColor.rgb = ambientOcclusionOnly ? ao : ao * color;\n\
9
+ vec4 color = texture(colorTexture, v_textureCoordinates);\n\
10
+ vec4 ao = texture(ambientOcclusionTexture, v_textureCoordinates);\n\
11
+ out_FragColor = ambientOcclusionOnly ? ao : ao * color;\n\
12
12
  }\n\
13
13
  ";
@@ -520,6 +520,18 @@ Object.defineProperties(CesiumWidget.prototype, {
520
520
  },
521
521
  },
522
522
 
523
+ /**
524
+ * Manages the list of credits to display on screen and in the lightbox.
525
+ * @memberof CesiumWidget.prototype
526
+ *
527
+ * @type {CreditDisplay}
528
+ */
529
+ creditDisplay: {
530
+ get: function () {
531
+ return this._scene.frameState.creditDisplay;
532
+ },
533
+ },
534
+
523
535
  /**
524
536
  * Gets the camera.
525
537
  * @memberof CesiumWidget.prototype