@cesium/engine 9.0.0 → 9.2.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 (189) hide show
  1. package/Build/ThirdParty/Workers/pako_deflate.min.js +108 -210
  2. package/Build/ThirdParty/Workers/pako_inflate.min.js +466 -568
  3. package/Build/ThirdParty/Workers/z-worker-pako.js +56 -105
  4. package/Build/Workers/{chunk-VR5RBW52.js → chunk-26NE4LRW.js} +7 -7
  5. package/Build/Workers/{chunk-P2YAAMT2.js → chunk-26XJDV3D.js} +15 -15
  6. package/Build/Workers/{chunk-L4BW3RUA.js → chunk-2TRB253J.js} +7 -7
  7. package/Build/Workers/{chunk-NP2GYYE5.js → chunk-3PV5HQ2R.js} +6 -6
  8. package/Build/Workers/{chunk-BCU2LH5T.js → chunk-3VDHTBY5.js} +10 -10
  9. package/Build/Workers/{chunk-WHUSTDIB.js → chunk-4RG6WOXH.js} +10 -10
  10. package/Build/Workers/{chunk-P4XKB3QZ.js → chunk-5OK5JFDP.js} +5 -5
  11. package/Build/Workers/{chunk-2ZBL3MVO.js → chunk-7HLZRYGD.js} +10 -12
  12. package/Build/Workers/chunk-7PFZ4Z7C.js +961 -0
  13. package/Build/Workers/{chunk-24YTYWNB.js → chunk-A5CSB5ZE.js} +11 -13
  14. package/Build/Workers/{chunk-RMOEYCZW.js → chunk-AROLUUGS.js} +2 -2
  15. package/Build/Workers/{chunk-3NCVAGDA.js → chunk-BBBTT36L.js} +14 -14
  16. package/Build/Workers/{chunk-QKBGRKKG.js → chunk-BNT2SNWU.js} +4 -4
  17. package/Build/Workers/{chunk-LQJ5FFFR.js → chunk-CFBGPZU6.js} +11 -13
  18. package/Build/Workers/{chunk-C6OI26DR.js → chunk-CVCVMOQA.js} +1 -1
  19. package/Build/Workers/{chunk-SS4ESNE3.js → chunk-DIVFF6DK.js} +2 -2
  20. package/Build/Workers/{chunk-PXB7T27O.js → chunk-EJZVBTX4.js} +6 -6
  21. package/Build/Workers/{chunk-TZORKRNK.js → chunk-EODIOQ35.js} +1 -1
  22. package/Build/Workers/{chunk-QCQUZGXI.js → chunk-ETC45PHH.js} +5 -6
  23. package/Build/Workers/{chunk-E6WXPSJS.js → chunk-G7IAO7CW.js} +7 -7
  24. package/Build/Workers/{chunk-X2F6BEPY.js → chunk-GOQEANLM.js} +16 -16
  25. package/Build/Workers/{chunk-7COR472O.js → chunk-GUFV24F4.js} +7197 -5096
  26. package/Build/Workers/{chunk-5TIV3L26.js → chunk-GX2BWBN2.js} +13 -13
  27. package/Build/Workers/{chunk-ADOVHYWO.js → chunk-GX5LMUGZ.js} +469 -6
  28. package/Build/Workers/{chunk-2632RVPI.js → chunk-I6CW7ZE5.js} +7 -7
  29. package/Build/Workers/{chunk-YDVSBWEO.js → chunk-IF2OX6R4.js} +3 -5
  30. package/Build/Workers/{chunk-RSJXEO2A.js → chunk-IXYFH7DV.js} +95 -155
  31. package/Build/Workers/{chunk-ZNVSKMQ2.js → chunk-K5F23SZO.js} +6 -6
  32. package/Build/Workers/{chunk-MWV7IZK4.js → chunk-KTZK2UDR.js} +7 -7
  33. package/Build/Workers/{chunk-HBQPB6IH.js → chunk-LZFFO4KB.js} +12 -12
  34. package/Build/Workers/{chunk-GFA4SMXV.js → chunk-OYP23VAL.js} +11 -11
  35. package/Build/Workers/{chunk-ZYPTP7GS.js → chunk-PHT53MCH.js} +11 -11
  36. package/Build/Workers/{chunk-TJBU6GML.js → chunk-PUQR43HZ.js} +6 -6
  37. package/Build/Workers/{chunk-CO35JNNE.js → chunk-QZIWFSRM.js} +4 -4
  38. package/Build/Workers/{chunk-C3XBUYBO.js → chunk-RDR4KVPA.js} +17 -17
  39. package/Build/Workers/{chunk-YV4H2Y7M.js → chunk-RRUO4QEK.js} +4 -4
  40. package/Build/Workers/{chunk-LAQP3SCC.js → chunk-RTIT7UDN.js} +2 -2
  41. package/Build/Workers/{chunk-Z7FQLK6N.js → chunk-SC3TBKST.js} +4 -4
  42. package/Build/Workers/{chunk-GXUXEOE2.js → chunk-TDIGL45B.js} +1 -1
  43. package/Build/Workers/{chunk-EOXYZ34O.js → chunk-TP4FFUAH.js} +2 -2
  44. package/Build/Workers/{chunk-N4KXMWQU.js → chunk-U2LSTOMA.js} +2 -2
  45. package/Build/Workers/{chunk-6WF3KIF5.js → chunk-U6MTSO6A.js} +47 -84
  46. package/Build/Workers/{chunk-I37B3MZ2.js → chunk-UICVDDCQ.js} +1 -1
  47. package/Build/Workers/{chunk-DPUSFA7S.js → chunk-UKJCFXVV.js} +6 -6
  48. package/Build/Workers/{chunk-EPKE7GE3.js → chunk-UYKG3UFK.js} +5 -5
  49. package/Build/Workers/{chunk-RV7ZOSS6.js → chunk-W4OS542B.js} +13 -13
  50. package/Build/Workers/{chunk-DGDUKCJJ.js → chunk-WHDEZSAL.js} +6 -6
  51. package/Build/Workers/{chunk-NZWNZA6S.js → chunk-WOYQB5HM.js} +5 -5
  52. package/Build/Workers/{chunk-M2AYBTNH.js → chunk-WP3LCUOE.js} +13 -13
  53. package/Build/Workers/{chunk-73FKKY52.js → chunk-YGNQJ4YI.js} +5 -5
  54. package/Build/Workers/{chunk-SE4PXOEA.js → chunk-YGTWKLFY.js} +19 -19
  55. package/Build/Workers/{chunk-5R6VWLMH.js → chunk-ZHJDE6JN.js} +6 -6
  56. package/Build/Workers/combineGeometry.js +22 -24
  57. package/Build/Workers/createBoxGeometry.js +16 -18
  58. package/Build/Workers/createBoxOutlineGeometry.js +14 -16
  59. package/Build/Workers/createCircleGeometry.js +24 -26
  60. package/Build/Workers/createCircleOutlineGeometry.js +17 -19
  61. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -34
  62. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -31
  63. package/Build/Workers/createCorridorGeometry.js +27 -29
  64. package/Build/Workers/createCorridorOutlineGeometry.js +26 -28
  65. package/Build/Workers/createCylinderGeometry.js +18 -20
  66. package/Build/Workers/createCylinderOutlineGeometry.js +16 -18
  67. package/Build/Workers/createEllipseGeometry.js +24 -26
  68. package/Build/Workers/createEllipseOutlineGeometry.js +17 -19
  69. package/Build/Workers/createEllipsoidGeometry.js +17 -19
  70. package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -18
  71. package/Build/Workers/createFrustumGeometry.js +16 -18
  72. package/Build/Workers/createFrustumOutlineGeometry.js +18 -19
  73. package/Build/Workers/createGeometry.js +22 -24
  74. package/Build/Workers/createGroundPolylineGeometry.js +23 -25
  75. package/Build/Workers/createPlaneGeometry.js +14 -16
  76. package/Build/Workers/createPlaneOutlineGeometry.js +13 -15
  77. package/Build/Workers/createPolygonGeometry.js +32 -34
  78. package/Build/Workers/createPolygonOutlineGeometry.js +28 -30
  79. package/Build/Workers/createPolylineGeometry.js +23 -25
  80. package/Build/Workers/createPolylineVolumeGeometry.js +29 -31
  81. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -27
  82. package/Build/Workers/createRectangleGeometry.js +27 -29
  83. package/Build/Workers/createRectangleOutlineGeometry.js +18 -20
  84. package/Build/Workers/createSimplePolylineGeometry.js +21 -23
  85. package/Build/Workers/createSphereGeometry.js +17 -19
  86. package/Build/Workers/createSphereOutlineGeometry.js +16 -18
  87. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  88. package/Build/Workers/createVectorTileClampedPolylines.js +14 -16
  89. package/Build/Workers/createVectorTileGeometries.js +22 -24
  90. package/Build/Workers/createVectorTilePoints.js +12 -12
  91. package/Build/Workers/createVectorTilePolygons.js +20 -22
  92. package/Build/Workers/createVectorTilePolylines.js +14 -16
  93. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +23 -25
  94. package/Build/Workers/createVerticesFromHeightmap.js +23 -25
  95. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -22
  96. package/Build/Workers/createWallGeometry.js +22 -24
  97. package/Build/Workers/createWallOutlineGeometry.js +21 -23
  98. package/Build/Workers/decodeDraco.js +11 -11
  99. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +12 -19
  100. package/Build/Workers/decodeI3S.js +10 -11
  101. package/Build/Workers/transcodeKTX2.js +44 -80
  102. package/Build/Workers/transferTypedArrayTest.js +1 -1
  103. package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -22
  104. package/Source/Core/Ion.js +1 -1
  105. package/Source/Core/Math.js +0 -5
  106. package/Source/Core/PixelFormat.js +1 -0
  107. package/Source/Core/Rectangle.js +89 -0
  108. package/Source/Core/TaskProcessor.js +19 -3
  109. package/Source/Core/sampleTerrain.js +3 -3
  110. package/Source/DataSources/DataSourceDisplay.js +5 -0
  111. package/Source/Renderer/ShaderBuilder.js +6 -3
  112. package/Source/Scene/ArcGisMapService.js +1 -1
  113. package/Source/Scene/Billboard.js +7 -5
  114. package/Source/Scene/Cesium3DTile.js +65 -0
  115. package/Source/Scene/Cesium3DTileset.js +48 -1
  116. package/Source/Scene/ClippingPolygon.js +212 -0
  117. package/Source/Scene/ClippingPolygonCollection.js +968 -0
  118. package/Source/Scene/Globe.js +14 -0
  119. package/Source/Scene/GlobeSurfaceShaderSet.js +81 -15
  120. package/Source/Scene/GlobeSurfaceTileProvider.js +81 -1
  121. package/Source/Scene/GltfLoader.js +458 -435
  122. package/Source/Scene/GltfLoaderUtil.js +3 -12
  123. package/Source/Scene/GltfPipeline/forEachTextureInMaterial.js +23 -7
  124. package/Source/Scene/GltfStructuralMetadataLoader.js +11 -9
  125. package/Source/Scene/Label.js +1 -1
  126. package/Source/Scene/Model/AlphaPipelineStage.js +1 -1
  127. package/Source/Scene/Model/GeometryPipelineStage.js +15 -43
  128. package/Source/Scene/Model/ImageBasedLightingPipelineStage.js +7 -0
  129. package/Source/Scene/Model/LightingPipelineStage.js +2 -4
  130. package/Source/Scene/Model/MaterialPipelineStage.js +346 -29
  131. package/Source/Scene/Model/Model.js +91 -3
  132. package/Source/Scene/Model/Model3DTileContent.js +21 -0
  133. package/Source/Scene/Model/ModelClippingPolygonsPipelineStage.js +92 -0
  134. package/Source/Scene/Model/ModelSceneGraph.js +5 -0
  135. package/Source/Scene/Model/ModelUtility.js +3 -0
  136. package/Source/Scene/Model/VerticalExaggerationPipelineStage.js +4 -6
  137. package/Source/Scene/ModelComponents.js +169 -1
  138. package/Source/Scene/PickDepth.js +23 -15
  139. package/Source/Scene/ResourceCache.js +41 -50
  140. package/Source/Scene/ResourceCacheKey.js +41 -53
  141. package/Source/Scene/Terrain.js +2 -2
  142. package/Source/Shaders/Builtin/CzmBuiltins.js +6 -8
  143. package/Source/Shaders/Builtin/Functions/clipPolygons.glsl +37 -0
  144. package/Source/Shaders/Builtin/Functions/clipPolygons.js +39 -0
  145. package/Source/Shaders/Builtin/Functions/maximumComponent.glsl +21 -0
  146. package/Source/Shaders/Builtin/Functions/maximumComponent.js +23 -0
  147. package/Source/Shaders/Builtin/Functions/pbrLighting.glsl +108 -44
  148. package/Source/Shaders/Builtin/Functions/pbrLighting.js +108 -44
  149. package/Source/Shaders/Builtin/Functions/unpackClippingExtents.glsl +14 -0
  150. package/Source/Shaders/Builtin/Functions/unpackClippingExtents.js +15 -0
  151. package/Source/Shaders/Builtin/Structs/modelMaterial.glsl +14 -0
  152. package/Source/Shaders/Builtin/Structs/modelMaterial.js +14 -0
  153. package/Source/Shaders/GlobeFS.glsl +13 -1
  154. package/Source/Shaders/GlobeFS.js +13 -1
  155. package/Source/Shaders/GlobeVS.glsl +32 -0
  156. package/Source/Shaders/GlobeVS.js +32 -0
  157. package/Source/Shaders/Model/GeometryStageVS.glsl +1 -1
  158. package/Source/Shaders/Model/GeometryStageVS.js +1 -1
  159. package/Source/Shaders/Model/ImageBasedLightingStageFS.glsl +211 -133
  160. package/Source/Shaders/Model/ImageBasedLightingStageFS.js +212 -133
  161. package/Source/Shaders/Model/LightingStageFS.glsl +113 -48
  162. package/Source/Shaders/Model/LightingStageFS.js +113 -48
  163. package/Source/Shaders/Model/MaterialStageFS.glsl +399 -137
  164. package/Source/Shaders/Model/MaterialStageFS.js +399 -137
  165. package/Source/Shaders/Model/ModelClippingPolygonsStageFS.glsl +6 -0
  166. package/Source/Shaders/Model/ModelClippingPolygonsStageFS.js +8 -0
  167. package/Source/Shaders/Model/ModelClippingPolygonsStageVS.glsl +27 -0
  168. package/Source/Shaders/Model/ModelClippingPolygonsStageVS.js +29 -0
  169. package/Source/Shaders/Model/ModelFS.glsl +6 -0
  170. package/Source/Shaders/Model/ModelFS.js +7 -1
  171. package/Source/Shaders/Model/ModelVS.glsl +4 -0
  172. package/Source/Shaders/Model/ModelVS.js +4 -0
  173. package/Source/Shaders/PolygonSignedDistanceFS.glsl +100 -0
  174. package/Source/Shaders/PolygonSignedDistanceFS.js +101 -0
  175. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  176. package/index.d.ts +230 -4
  177. package/index.js +234 -229
  178. package/package.json +1 -1
  179. package/Build/Workers/chunk-2KACWKS4.js +0 -501
  180. package/Build/Workers/chunk-2XPLH3JY.js +0 -2977
  181. package/Build/Workers/chunk-X6XOMPWL.js +0 -73
  182. package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.glsl +0 -16
  183. package/Source/Shaders/Builtin/Functions/defaultPbrMaterial.js +0 -18
  184. package/Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.glsl +0 -37
  185. package/Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.js +0 -39
  186. package/Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.glsl +0 -30
  187. package/Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.js +0 -32
  188. package/Source/Shaders/Builtin/Structs/pbrParameters.glsl +0 -16
  189. package/Source/Shaders/Builtin/Structs/pbrParameters.js +0 -18
@@ -255,6 +255,27 @@ Model3DTileContent.prototype.update = function (tileset, frameState) {
255
255
  model._clippingPlanesState = 0;
256
256
  }
257
257
 
258
+ // Updating clipping polygons requires more effort because of ownership checks
259
+ const tilesetClippingPolygons = tileset.clippingPolygons;
260
+ if (defined(tilesetClippingPolygons) && tile.clippingPolygonsDirty) {
261
+ // Dereference the clipping polygons from the model if they are irrelevant.
262
+ model._clippingPolygons =
263
+ tilesetClippingPolygons.enabled && tile._isClippedByPolygon
264
+ ? tilesetClippingPolygons
265
+ : undefined;
266
+ }
267
+
268
+ // If the model references a different ClippingPolygonCollection from the tileset,
269
+ // update the model to use the new ClippingPolygonCollection.
270
+ if (
271
+ defined(tilesetClippingPolygons) &&
272
+ defined(model._clippingPolygons) &&
273
+ model._clippingPolygons !== tilesetClippingPolygons
274
+ ) {
275
+ model._clippingPolygons = tilesetClippingPolygons;
276
+ model._clippingPolygonsState = 0;
277
+ }
278
+
258
279
  model.update(frameState);
259
280
 
260
281
  if (!this._ready && model.ready) {
@@ -0,0 +1,92 @@
1
+ import combine from "../../Core/combine.js";
2
+ import ModelClippingPolygonsStageVS from "../../Shaders/Model/ModelClippingPolygonsStageVS.js";
3
+ import ModelClippingPolygonsStageFS from "../../Shaders/Model/ModelClippingPolygonsStageFS.js";
4
+ import ShaderDestination from "../../Renderer/ShaderDestination.js";
5
+
6
+ /**
7
+ * The model clipping planes stage is responsible for applying clipping planes to the model.
8
+ *
9
+ * @namespace ModelClippingPolygonsPipelineStage
10
+ *
11
+ * @private
12
+ */
13
+ const ModelClippingPolygonsPipelineStage = {
14
+ name: "ModelClippingPolygonsPipelineStage", // Helps with debugging
15
+ };
16
+
17
+ /**
18
+ * Process a model for polygon clipping. This modifies the following parts of the render resources:
19
+ *
20
+ * <ul>
21
+ * <li>adds a define to both the vertex and fragment shaders to indicate that the model has clipping polygons</li>
22
+ * <li>adds the defines to both the vertex and fragment shaders for parameters related to clipping polygons, such as the number of polygons</li>
23
+ * <li>adds a function to the vertex shader to determine lookup uvs</li>
24
+ * <li>adds a function to the fragment shader to discard clipped regions</li>
25
+ * <li>adds the uniforms to the vertex and fragment shaders for the clipping extents texture and clipping distance respectively</li>
26
+ * <li>adds a varying for lookup uvs in the clipping texture</li>
27
+ *</ul>
28
+ *
29
+ * @param {ModelRenderResources} renderResources The render resources for this model.
30
+ * @param {Model} model The model.
31
+ * @param {FrameState} frameState The frameState.
32
+ *
33
+ * @private
34
+ */
35
+ ModelClippingPolygonsPipelineStage.process = function (
36
+ renderResources,
37
+ model,
38
+ frameState
39
+ ) {
40
+ const clippingPolygons = model.clippingPolygons;
41
+ const shaderBuilder = renderResources.shaderBuilder;
42
+
43
+ shaderBuilder.addDefine(
44
+ "ENABLE_CLIPPING_POLYGONS",
45
+ undefined,
46
+ ShaderDestination.BOTH
47
+ );
48
+
49
+ if (clippingPolygons.inverse) {
50
+ shaderBuilder.addDefine(
51
+ "CLIPPING_INVERSE",
52
+ undefined,
53
+ ShaderDestination.FRAGMENT
54
+ );
55
+ }
56
+
57
+ shaderBuilder.addDefine(
58
+ "CLIPPING_POLYGON_REGIONS_LENGTH",
59
+ clippingPolygons.extentsCount,
60
+ ShaderDestination.BOTH
61
+ );
62
+
63
+ shaderBuilder.addUniform(
64
+ "sampler2D",
65
+ "model_clippingDistance",
66
+ ShaderDestination.FRAGMENT
67
+ );
68
+
69
+ shaderBuilder.addUniform(
70
+ "sampler2D",
71
+ "model_clippingExtents",
72
+ ShaderDestination.VERTEX
73
+ );
74
+
75
+ shaderBuilder.addVarying("vec2", "v_clippingPosition");
76
+ shaderBuilder.addVarying("int", "v_regionIndex", "flat");
77
+ shaderBuilder.addVertexLines(ModelClippingPolygonsStageVS);
78
+ shaderBuilder.addFragmentLines(ModelClippingPolygonsStageFS);
79
+
80
+ const uniformMap = {
81
+ model_clippingDistance: function () {
82
+ return clippingPolygons.clippingTexture;
83
+ },
84
+ model_clippingExtents: function () {
85
+ return clippingPolygons.extentsTexture;
86
+ },
87
+ };
88
+
89
+ renderResources.uniformMap = combine(uniformMap, renderResources.uniformMap);
90
+ };
91
+
92
+ export default ModelClippingPolygonsPipelineStage;
@@ -14,6 +14,7 @@ import ImageBasedLightingPipelineStage from "./ImageBasedLightingPipelineStage.j
14
14
  import ModelArticulation from "./ModelArticulation.js";
15
15
  import ModelColorPipelineStage from "./ModelColorPipelineStage.js";
16
16
  import ModelClippingPlanesPipelineStage from "./ModelClippingPlanesPipelineStage.js";
17
+ import ModelClippingPolygonsPipelineStage from "./ModelClippingPolygonsPipelineStage.js";
17
18
  import ModelNode from "./ModelNode.js";
18
19
  import ModelRuntimeNode from "./ModelRuntimeNode.js";
19
20
  import ModelRuntimePrimitive from "./ModelRuntimePrimitive.js";
@@ -626,6 +627,10 @@ ModelSceneGraph.prototype.configurePipeline = function (frameState) {
626
627
  modelPipelineStages.push(ModelClippingPlanesPipelineStage);
627
628
  }
628
629
 
630
+ if (model.isClippingPolygonsEnabled()) {
631
+ modelPipelineStages.push(ModelClippingPolygonsPipelineStage);
632
+ }
633
+
629
634
  if (model.hasSilhouette(frameState)) {
630
635
  modelPipelineStages.push(ModelSilhouettePipelineStage);
631
636
  }
@@ -357,6 +357,9 @@ ModelUtility.supportedExtensions = {
357
357
  KHR_techniques_webgl: true,
358
358
  KHR_materials_common: true,
359
359
  KHR_materials_pbrSpecularGlossiness: true,
360
+ KHR_materials_specular: true,
361
+ KHR_materials_anisotropy: true,
362
+ KHR_materials_clearcoat: true,
360
363
  KHR_materials_unlit: true,
361
364
  KHR_mesh_quantization: true,
362
365
  KHR_texture_basisu: true,
@@ -3,11 +3,9 @@ import ShaderDestination from "../../Renderer/ShaderDestination.js";
3
3
  import VerticalExaggerationStageVS from "../../Shaders/Model/VerticalExaggerationStageVS.js";
4
4
 
5
5
  /**
6
- * The custom shader pipeline stage takes GLSL callbacks from the
7
- * {@link CustomShader} and inserts them into the overall shader code for the
8
- * {@link Model}. The input to the callback is a struct with many
9
- * properties that depend on the attributes of the primitive. This shader code
10
- * is automatically generated by this stage.
6
+ * The vertical exaggeration pipeline stage transforms the vertex
7
+ * positions based on the values of {@link Scene#verticalExaggeration} and
8
+ * {@link Scene#verticalExaggerationRelativeHeight}
11
9
  *
12
10
  * @namespace VerticalExaggerationPipelineStage
13
11
  *
@@ -20,7 +18,7 @@ const VerticalExaggerationPipelineStage = {
20
18
  const scratchExaggerationUniform = new Cartesian2();
21
19
 
22
20
  /**
23
- * Add vertical exaggeration to a shader
21
+ * Add defines and uniforms for vertical exaggeration calculations in the vertex shader
24
22
  *
25
23
  * @param {PrimitiveRenderResources} renderResources The render resources for the primitive
26
24
  * @param {ModelComponents.Primitive} primitive The primitive to be rendered
@@ -1337,10 +1337,151 @@ SpecularGlossiness.DEFAULT_SPECULAR_FACTOR = Cartesian3.ONE;
1337
1337
  */
1338
1338
  SpecularGlossiness.DEFAULT_GLOSSINESS_FACTOR = 1.0;
1339
1339
 
1340
+ function Specular() {
1341
+ /**
1342
+ * The specular factor.
1343
+ *
1344
+ * @type {number}
1345
+ * @default 1.0
1346
+ * @private
1347
+ */
1348
+ this.specularFactor = Specular.DEFAULT_SPECULAR_FACTOR;
1349
+
1350
+ /**
1351
+ * The specular texture reader.
1352
+ *
1353
+ * @type {ModelComponents.TextureReader}
1354
+ * @private
1355
+ */
1356
+ this.specularTexture = undefined;
1357
+
1358
+ /**
1359
+ * The specular color factor.
1360
+ *
1361
+ * @type {Cartesian3}
1362
+ * @default new Cartesian3(1.0, 1.0, 1.0)
1363
+ * @private
1364
+ */
1365
+ this.specularColorFactor = Cartesian3.clone(
1366
+ Specular.DEFAULT_SPECULAR_COLOR_FACTOR
1367
+ );
1368
+
1369
+ /**
1370
+ * The specular color texture reader.
1371
+ *
1372
+ * @type {ModelComponents.TextureReader}
1373
+ * @private
1374
+ */
1375
+ this.specularColorTexture = undefined;
1376
+ }
1377
+
1378
+ /**
1379
+ * @private
1380
+ */
1381
+ Specular.DEFAULT_SPECULAR_FACTOR = 1.0;
1382
+
1383
+ /**
1384
+ * @private
1385
+ */
1386
+ Specular.DEFAULT_SPECULAR_COLOR_FACTOR = Cartesian3.ONE;
1387
+
1388
+ function Anisotropy() {
1389
+ /**
1390
+ * The anisotropy strength.
1391
+ *
1392
+ * @type {number}
1393
+ * @default 0.0
1394
+ * @private
1395
+ */
1396
+ this.anisotropyStrength = Anisotropy.DEFAULT_ANISOTROPY_STRENGTH;
1397
+
1398
+ /**
1399
+ * The rotation of the anisotropy in tangent, bitangent space,
1400
+ * measured in radians counter-clockwise from the tangent.
1401
+ *
1402
+ * @type {number}
1403
+ * @default 0.0
1404
+ * @private
1405
+ */
1406
+ this.anisotropyRotation = Anisotropy.DEFAULT_ANISOTROPY_ROTATION;
1407
+
1408
+ /**
1409
+ * The anisotropy texture reader.
1410
+ *
1411
+ * @type {ModelComponents.TextureReader}
1412
+ * @private
1413
+ */
1414
+ this.anisotropyTexture = undefined;
1415
+ }
1416
+
1417
+ /**
1418
+ * @private
1419
+ */
1420
+ Anisotropy.DEFAULT_ANISOTROPY_STRENGTH = 0.0;
1421
+
1422
+ /**
1423
+ * @private
1424
+ */
1425
+ Anisotropy.DEFAULT_ANISOTROPY_ROTATION = 0.0;
1426
+
1427
+ function Clearcoat() {
1428
+ /**
1429
+ * The clearcoat layer intensity.
1430
+ *
1431
+ * @type {number}
1432
+ * @default 0.0
1433
+ * @private
1434
+ */
1435
+ this.clearcoatFactor = Clearcoat.DEFAULT_CLEARCOAT_FACTOR;
1436
+
1437
+ /**
1438
+ * The clearcoat layer intensity texture reader.
1439
+ *
1440
+ * @type {ModelComponents.TextureReader}
1441
+ * @private
1442
+ */
1443
+ this.clearcoatTexture = undefined;
1444
+
1445
+ /**
1446
+ * The clearcoat layer roughness.
1447
+ *
1448
+ * @type {number}
1449
+ * @default 0.0
1450
+ * @private
1451
+ */
1452
+ this.clearcoatRoughnessFactor = Clearcoat.DEFAULT_CLEARCOAT_ROUGHNESS_FACTOR;
1453
+
1454
+ /**
1455
+ * The clearcoat layer roughness texture.
1456
+ *
1457
+ * @type {ModelComponents.TextureReader}
1458
+ * @private
1459
+ */
1460
+ this.clearcoatRoughnessTexture = undefined;
1461
+
1462
+ /**
1463
+ * The clearcoat normal map texture.
1464
+ *
1465
+ * @type {ModelComponents.TextureReader}
1466
+ * @private
1467
+ */
1468
+ this.clearcoatNormalTexture = undefined;
1469
+ }
1470
+
1471
+ /**
1472
+ * @private
1473
+ */
1474
+ Clearcoat.DEFAULT_CLEARCOAT_FACTOR = 0.0;
1475
+
1476
+ /**
1477
+ * @private
1478
+ */
1479
+ Clearcoat.DEFAULT_CLEARCOAT_ROUGHNESS_FACTOR = 0.0;
1480
+
1340
1481
  /**
1341
1482
  * The material appearance of a primitive.
1342
1483
  *
1343
- * @alias ModelComponent.Material
1484
+ * @alias ModelComponents.Material
1344
1485
  * @constructor
1345
1486
  *
1346
1487
  * @private
@@ -1362,6 +1503,30 @@ function Material() {
1362
1503
  */
1363
1504
  this.specularGlossiness = undefined;
1364
1505
 
1506
+ /**
1507
+ * Material properties for the PBR specular shading model.
1508
+ *
1509
+ * @type {ModelComponents.Specular}
1510
+ * @private
1511
+ */
1512
+ this.specular = undefined;
1513
+
1514
+ /**
1515
+ * Material properties for the PBR anisotropy shading model.
1516
+ *
1517
+ * @type {ModelComponents.Anisotropy}
1518
+ * @private
1519
+ */
1520
+ this.anisotropy = undefined;
1521
+
1522
+ /**
1523
+ * Material properties for the PBR clearcoat shading model.
1524
+ *
1525
+ * @type {ModelComponents.Clearcoat}
1526
+ * @private
1527
+ */
1528
+ this.clearcoat = undefined;
1529
+
1365
1530
  /**
1366
1531
  * The emissive texture reader.
1367
1532
  *
@@ -1461,6 +1626,9 @@ ModelComponents.Components = Components;
1461
1626
  ModelComponents.TextureReader = TextureReader;
1462
1627
  ModelComponents.MetallicRoughness = MetallicRoughness;
1463
1628
  ModelComponents.SpecularGlossiness = SpecularGlossiness;
1629
+ ModelComponents.Specular = Specular;
1630
+ ModelComponents.Anisotropy = Anisotropy;
1631
+ ModelComponents.Clearcoat = Clearcoat;
1464
1632
  ModelComponents.Material = Material;
1465
1633
 
1466
1634
  export default ModelComponents;
@@ -30,22 +30,30 @@ function updateFramebuffers(pickDepth, context, depthTexture) {
30
30
 
31
31
  function updateCopyCommands(pickDepth, context, depthTexture) {
32
32
  if (!defined(pickDepth._copyDepthCommand)) {
33
- const fs =
34
- "uniform highp sampler2D u_texture;\n" +
35
- "in vec2 v_textureCoordinates;\n" +
36
- "void main()\n" +
37
- "{\n" +
38
- " out_FragColor = czm_packDepth(texture(u_texture, v_textureCoordinates).r);\n" +
39
- "}\n";
40
- pickDepth._copyDepthCommand = context.createViewportQuadCommand(fs, {
41
- renderState: RenderState.fromCache(),
42
- uniformMap: {
43
- u_texture: function () {
44
- return pickDepth._textureToCopy;
33
+ pickDepth._copyDepthCommand = context.createViewportQuadCommand(
34
+ `uniform highp sampler2D colorTexture;
35
+
36
+ in vec2 v_textureCoordinates;
37
+
38
+ void main()
39
+ {
40
+ vec4 globeDepthPacked = texture(czm_globeDepthTexture, v_textureCoordinates);
41
+ float globeDepth = czm_unpackDepth(globeDepthPacked);
42
+ float depth = texture(colorTexture, v_textureCoordinates).r;
43
+ out_FragColor = czm_branchFreeTernary(globeDepth <= 0.0 || globeDepth >= 1.0 || depth < globeDepth && depth > 0.0 && depth < 1.0,
44
+ czm_packDepth(depth), globeDepthPacked);
45
+ }
46
+ `,
47
+ {
48
+ renderState: RenderState.fromCache(),
49
+ uniformMap: {
50
+ colorTexture: function () {
51
+ return pickDepth._textureToCopy;
52
+ },
45
53
  },
46
- },
47
- owner: pickDepth,
48
- });
54
+ owner: pickDepth,
55
+ }
56
+ );
49
57
  }
50
58
 
51
59
  pickDepth._textureToCopy = depthTexture;
@@ -146,8 +146,7 @@ ResourceCache.unload = function (resourceLoader) {
146
146
  */
147
147
  ResourceCache.getSchemaLoader = function (options) {
148
148
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
149
- const schema = options.schema;
150
- const resource = options.resource;
149
+ const { schema, resource } = options;
151
150
 
152
151
  //>>includeStart('debug', pragmas.debug);
153
152
  if (defined(schema) === defined(resource)) {
@@ -189,9 +188,7 @@ ResourceCache.getSchemaLoader = function (options) {
189
188
  */
190
189
  ResourceCache.getEmbeddedBufferLoader = function (options) {
191
190
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
192
- const parentResource = options.parentResource;
193
- const bufferId = options.bufferId;
194
- const typedArray = options.typedArray;
191
+ const { parentResource, bufferId, typedArray } = options;
195
192
 
196
193
  //>>includeStart('debug', pragmas.debug);
197
194
  Check.typeOf.object("options.parentResource", parentResource);
@@ -231,7 +228,7 @@ ResourceCache.getEmbeddedBufferLoader = function (options) {
231
228
  */
232
229
  ResourceCache.getExternalBufferLoader = function (options) {
233
230
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
234
- const resource = options.resource;
231
+ const { resource } = options;
235
232
 
236
233
  //>>includeStart('debug', pragmas.debug);
237
234
  Check.typeOf.object("options.resource", resource);
@@ -268,10 +265,7 @@ ResourceCache.getExternalBufferLoader = function (options) {
268
265
  */
269
266
  ResourceCache.getGltfJsonLoader = function (options) {
270
267
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
271
- const gltfResource = options.gltfResource;
272
- const baseResource = options.baseResource;
273
- const typedArray = options.typedArray;
274
- const gltfJson = options.gltfJson;
268
+ const { gltfResource, baseResource, typedArray, gltfJson } = options;
275
269
 
276
270
  //>>includeStart('debug', pragmas.debug);
277
271
  Check.typeOf.object("options.gltfResource", gltfResource);
@@ -313,10 +307,7 @@ ResourceCache.getGltfJsonLoader = function (options) {
313
307
  */
314
308
  ResourceCache.getBufferViewLoader = function (options) {
315
309
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
316
- const gltf = options.gltf;
317
- const bufferViewId = options.bufferViewId;
318
- const gltfResource = options.gltfResource;
319
- const baseResource = options.baseResource;
310
+ const { gltf, bufferViewId, gltfResource, baseResource } = options;
320
311
 
321
312
  //>>includeStart('debug', pragmas.debug);
322
313
  Check.typeOf.object("options.gltf", gltf);
@@ -363,10 +354,7 @@ ResourceCache.getBufferViewLoader = function (options) {
363
354
  */
364
355
  ResourceCache.getDracoLoader = function (options) {
365
356
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
366
- const gltf = options.gltf;
367
- const draco = options.draco;
368
- const gltfResource = options.gltfResource;
369
- const baseResource = options.baseResource;
357
+ const { gltf, draco, gltfResource, baseResource } = options;
370
358
 
371
359
  //>>includeStart('debug', pragmas.debug);
372
360
  Check.typeOf.object("options.gltf", gltf);
@@ -424,18 +412,20 @@ ResourceCache.getDracoLoader = function (options) {
424
412
  */
425
413
  ResourceCache.getVertexBufferLoader = function (options) {
426
414
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
427
- const gltf = options.gltf;
428
- const gltfResource = options.gltfResource;
429
- const baseResource = options.baseResource;
430
- const frameState = options.frameState;
431
- const bufferViewId = options.bufferViewId;
432
- const draco = options.draco;
433
- const attributeSemantic = options.attributeSemantic;
434
- const accessorId = options.accessorId;
435
- const asynchronous = defaultValue(options.asynchronous, true);
436
- const dequantize = defaultValue(options.dequantize, false);
437
- const loadBuffer = defaultValue(options.loadBuffer, false);
438
- const loadTypedArray = defaultValue(options.loadTypedArray, false);
415
+ const {
416
+ gltf,
417
+ gltfResource,
418
+ baseResource,
419
+ frameState,
420
+ bufferViewId,
421
+ draco,
422
+ attributeSemantic,
423
+ accessorId,
424
+ asynchronous = true,
425
+ dequantize = false,
426
+ loadBuffer = false,
427
+ loadTypedArray = false,
428
+ } = options;
439
429
 
440
430
  //>>includeStart('debug', pragmas.debug);
441
431
  Check.typeOf.object("options.gltf", gltf);
@@ -541,15 +531,17 @@ function hasDracoCompression(draco, semantic) {
541
531
  */
542
532
  ResourceCache.getIndexBufferLoader = function (options) {
543
533
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
544
- const gltf = options.gltf;
545
- const accessorId = options.accessorId;
546
- const gltfResource = options.gltfResource;
547
- const baseResource = options.baseResource;
548
- const frameState = options.frameState;
549
- const draco = options.draco;
550
- const asynchronous = defaultValue(options.asynchronous, true);
551
- const loadBuffer = defaultValue(options.loadBuffer, false);
552
- const loadTypedArray = defaultValue(options.loadTypedArray, false);
534
+ const {
535
+ gltf,
536
+ accessorId,
537
+ gltfResource,
538
+ baseResource,
539
+ frameState,
540
+ draco,
541
+ asynchronous = true,
542
+ loadBuffer = false,
543
+ loadTypedArray = false,
544
+ } = options;
553
545
 
554
546
  //>>includeStart('debug', pragmas.debug);
555
547
  Check.typeOf.object("options.gltf", gltf);
@@ -610,10 +602,7 @@ ResourceCache.getIndexBufferLoader = function (options) {
610
602
  */
611
603
  ResourceCache.getImageLoader = function (options) {
612
604
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
613
- const gltf = options.gltf;
614
- const imageId = options.imageId;
615
- const gltfResource = options.gltfResource;
616
- const baseResource = options.baseResource;
605
+ const { gltf, imageId, gltfResource, baseResource } = options;
617
606
 
618
607
  //>>includeStart('debug', pragmas.debug);
619
608
  Check.typeOf.object("options.gltf", gltf);
@@ -663,13 +652,15 @@ ResourceCache.getImageLoader = function (options) {
663
652
  */
664
653
  ResourceCache.getTextureLoader = function (options) {
665
654
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
666
- const gltf = options.gltf;
667
- const textureInfo = options.textureInfo;
668
- const gltfResource = options.gltfResource;
669
- const baseResource = options.baseResource;
670
- const supportedImageFormats = options.supportedImageFormats;
671
- const frameState = options.frameState;
672
- const asynchronous = defaultValue(options.asynchronous, true);
655
+ const {
656
+ gltf,
657
+ textureInfo,
658
+ gltfResource,
659
+ baseResource,
660
+ supportedImageFormats,
661
+ frameState,
662
+ asynchronous = true,
663
+ } = options;
673
664
 
674
665
  //>>includeStart('debug', pragmas.debug);
675
666
  Check.typeOf.object("options.gltf", gltf);