@cesium/engine 10.0.0 → 11.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 (234) hide show
  1. package/Build/Workers/{chunk-AA4GZKOT.js → chunk-2EDC3QGH.js} +1 -1
  2. package/Build/Workers/{chunk-DKVHRNFY.js → chunk-2MKRG7L7.js} +5 -5
  3. package/Build/Workers/{chunk-X23FRWHJ.js → chunk-2RZYNSMR.js} +6 -6
  4. package/Build/Workers/{chunk-TO2PVHKI.js → chunk-4NBRIKB3.js} +2 -2
  5. package/Build/Workers/{chunk-GRAT5GE7.js → chunk-4TK5YR6Q.js} +5 -5
  6. package/Build/Workers/{chunk-XD445VDH.js → chunk-54VC7SCM.js} +7 -7
  7. package/Build/Workers/{chunk-G3YR53LY.js → chunk-5IY5BXCT.js} +13 -13
  8. package/Build/Workers/{chunk-O3JCMSS3.js → chunk-6FFGOENI.js} +54 -7
  9. package/Build/Workers/{chunk-7XGC6YB2.js → chunk-6PJIHPQB.js} +13 -13
  10. package/Build/Workers/{chunk-GR3CDLCP.js → chunk-6ZREIBKS.js} +7 -7
  11. package/Build/Workers/{chunk-4MSUJ4I7.js → chunk-AI3O7UN2.js} +6 -6
  12. package/Build/Workers/{chunk-COYFZ5VA.js → chunk-AS7P4BHI.js} +6 -6
  13. package/Build/Workers/{chunk-JYAHOGGL.js → chunk-AUM45VEG.js} +16 -15
  14. package/Build/Workers/{chunk-BDFNKFOE.js → chunk-BBO6BGLC.js} +13 -13
  15. package/Build/Workers/{chunk-AVI4IUWC.js → chunk-BH5ZEN4I.js} +10 -10
  16. package/Build/Workers/{chunk-4BAE4PWO.js → chunk-BJ3WF5RW.js} +6 -6
  17. package/Build/Workers/{chunk-Q55ECN3Y.js → chunk-BUOFSNFW.js} +1 -1
  18. package/Build/Workers/{chunk-QX5XS4LC.js → chunk-BZXF3GNX.js} +2 -2
  19. package/Build/Workers/{chunk-PYHLO636.js → chunk-DJXXI7UF.js} +5 -5
  20. package/Build/Workers/{chunk-LCLJJ2MZ.js → chunk-DVAIU7A4.js} +17 -17
  21. package/Build/Workers/{chunk-SYCPRK3D.js → chunk-FJT3ERV7.js} +9 -9
  22. package/Build/Workers/{chunk-L6RTJ3RE.js → chunk-GOHDOWU5.js} +14 -14
  23. package/Build/Workers/{chunk-MSKXMXJI.js → chunk-HA6TZ3XT.js} +4 -4
  24. package/Build/Workers/{chunk-PCP4YQST.js → chunk-HBZSCVZC.js} +11 -11
  25. package/Build/Workers/{chunk-5S7OLEPK.js → chunk-HC7RYWPZ.js} +12 -12
  26. package/Build/Workers/{chunk-VE7BFUIX.js → chunk-HFMJM3SX.js} +1 -1
  27. package/Build/Workers/{chunk-OOK53QUQ.js → chunk-HFPMX5L2.js} +1 -1
  28. package/Build/Workers/{chunk-VFBNELXB.js → chunk-HO2NTC7I.js} +6 -6
  29. package/Build/Workers/{chunk-DOXCPOG4.js → chunk-HZPMWR4H.js} +7 -7
  30. package/Build/Workers/{chunk-I2RC4XVN.js → chunk-IBG5FVXC.js} +4 -4
  31. package/Build/Workers/{chunk-LEABCTLP.js → chunk-IXLNNST6.js} +4 -4
  32. package/Build/Workers/{chunk-4YSNMHZ4.js → chunk-JYUCC5NV.js} +6 -6
  33. package/Build/Workers/{chunk-BCL4PHHT.js → chunk-KFW4UNQH.js} +10 -10
  34. package/Build/Workers/{chunk-R6B7UCQB.js → chunk-KKAEXHDY.js} +2 -2
  35. package/Build/Workers/{chunk-BJF5LOWE.js → chunk-L6FARMF6.js} +7 -7
  36. package/Build/Workers/{chunk-C2CGMAIU.js → chunk-N3BIL6WA.js} +13 -13
  37. package/Build/Workers/{chunk-STBBMQGG.js → chunk-O5SSW3B3.js} +6 -6
  38. package/Build/Workers/{chunk-S3PI2KFM.js → chunk-OC4MYPVW.js} +2 -2
  39. package/Build/Workers/{chunk-MDHQR3ZS.js → chunk-OOA6GXKD.js} +7 -7
  40. package/Build/Workers/{chunk-AD5HBJ2F.js → chunk-OSCHEWSG.js} +7 -7
  41. package/Build/Workers/{chunk-NTXTUNEF.js → chunk-QGT2GMOK.js} +4 -4
  42. package/Build/Workers/{chunk-VO3ACQB2.js → chunk-RFQYEYAL.js} +17 -17
  43. package/Build/Workers/{chunk-KUN2ZA5X.js → chunk-RJF5ZP76.js} +4 -4
  44. package/Build/Workers/{chunk-QD4KM3GO.js → chunk-SIZXFNJY.js} +6 -5
  45. package/Build/Workers/{chunk-FXIHSF7O.js → chunk-SRZJCF7G.js} +9 -9
  46. package/Build/Workers/{chunk-T77JILCU.js → chunk-T4MB73MC.js} +2 -2
  47. package/Build/Workers/{chunk-3WUV74WM.js → chunk-TTI2SUWJ.js} +2 -2
  48. package/Build/Workers/{chunk-QMLTCCYG.js → chunk-VHJ5ESXF.js} +1 -1
  49. package/Build/Workers/{chunk-2J3JKXCP.js → chunk-VSFFJGTA.js} +9 -5
  50. package/Build/Workers/{chunk-DGS5QNIO.js → chunk-WQRXRDCZ.js} +11 -11
  51. package/Build/Workers/{chunk-OORVMGDU.js → chunk-WXDGOYTT.js} +12 -7
  52. package/Build/Workers/{chunk-RJYML24O.js → chunk-XLCZE6DD.js} +423 -448
  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 +24 -24
  57. package/Build/Workers/createCircleOutlineGeometry.js +17 -17
  58. package/Build/Workers/createCoplanarPolygonGeometry.js +31 -31
  59. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
  60. package/Build/Workers/createCorridorGeometry.js +27 -27
  61. package/Build/Workers/createCorridorOutlineGeometry.js +26 -26
  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 +20 -20
  72. package/Build/Workers/createPlaneGeometry.js +14 -14
  73. package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
  74. package/Build/Workers/createPolygonGeometry.js +30 -30
  75. package/Build/Workers/createPolygonOutlineGeometry.js +28 -28
  76. package/Build/Workers/createPolylineGeometry.js +23 -23
  77. package/Build/Workers/createPolylineVolumeGeometry.js +29 -29
  78. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -25
  79. package/Build/Workers/createRectangleGeometry.js +25 -25
  80. package/Build/Workers/createRectangleOutlineGeometry.js +18 -18
  81. package/Build/Workers/createSimplePolylineGeometry.js +21 -21
  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 +24 -20
  92. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
  93. package/Build/Workers/createWallGeometry.js +22 -22
  94. package/Build/Workers/createWallOutlineGeometry.js +21 -21
  95. package/Build/Workers/decodeDraco.js +11 -11
  96. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +28 -5
  97. package/Build/Workers/decodeI3S.js +10 -10
  98. package/Build/Workers/transcodeKTX2.js +20 -22
  99. package/Build/Workers/transferTypedArrayTest.js +1 -1
  100. package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
  101. package/Source/Core/CompressedTextureBuffer.js +11 -0
  102. package/Source/Core/Ion.js +1 -1
  103. package/Source/Core/KTX2Transcoder.js +9 -16
  104. package/Source/Core/PixelFormat.js +1 -15
  105. package/Source/Core/Simon1994PlanetaryPositions.js +2 -1
  106. package/Source/Core/Transforms.js +137 -2
  107. package/Source/DataSources/BillboardGraphics.js +16 -0
  108. package/Source/DataSources/BillboardVisualizer.js +7 -0
  109. package/Source/DataSources/CallbackProperty.js +8 -2
  110. package/Source/DataSources/CheckerboardMaterialProperty.js +7 -1
  111. package/Source/DataSources/ColorMaterialProperty.js +7 -1
  112. package/Source/DataSources/CompositeMaterialProperty.js +5 -4
  113. package/Source/DataSources/CompositePositionProperty.js +7 -1
  114. package/Source/DataSources/CompositeProperty.js +5 -5
  115. package/Source/DataSources/ConstantPositionProperty.js +7 -1
  116. package/Source/DataSources/Entity.js +1 -1
  117. package/Source/DataSources/GridMaterialProperty.js +7 -1
  118. package/Source/DataSources/ImageMaterialProperty.js +8 -1
  119. package/Source/DataSources/MaterialProperty.js +7 -1
  120. package/Source/DataSources/NodeTransformationProperty.js +7 -1
  121. package/Source/DataSources/PathVisualizer.js +4 -4
  122. package/Source/DataSources/PointGraphics.js +17 -0
  123. package/Source/DataSources/PointVisualizer.js +12 -0
  124. package/Source/DataSources/PolylineArrowMaterialProperty.js +7 -1
  125. package/Source/DataSources/PolylineDashMaterialProperty.js +7 -1
  126. package/Source/DataSources/PolylineGlowMaterialProperty.js +7 -1
  127. package/Source/DataSources/PolylineOutlineMaterialProperty.js +7 -1
  128. package/Source/DataSources/PositionProperty.js +5 -8
  129. package/Source/DataSources/PositionPropertyArray.js +7 -1
  130. package/Source/DataSources/Property.js +1 -1
  131. package/Source/DataSources/PropertyArray.js +5 -5
  132. package/Source/DataSources/PropertyBag.js +5 -4
  133. package/Source/DataSources/ReferenceProperty.js +7 -1
  134. package/Source/DataSources/SampledPositionProperty.js +7 -1
  135. package/Source/DataSources/SampledProperty.js +6 -4
  136. package/Source/DataSources/ScaledPositionProperty.js +6 -0
  137. package/Source/DataSources/StripeMaterialProperty.js +7 -1
  138. package/Source/DataSources/TerrainOffsetProperty.js +9 -0
  139. package/Source/DataSources/TimeIntervalCollectionPositionProperty.js +7 -1
  140. package/Source/DataSources/TimeIntervalCollectionProperty.js +5 -5
  141. package/Source/DataSources/VelocityOrientationProperty.js +6 -1
  142. package/Source/DataSources/VelocityVectorProperty.js +3 -5
  143. package/Source/Renderer/AutomaticUniforms.js +3 -18
  144. package/Source/Renderer/Context.js +15 -0
  145. package/Source/Renderer/CubeMap.js +326 -348
  146. package/Source/Renderer/CubeMapFace.js +26 -48
  147. package/Source/Renderer/PixelDatatype.js +23 -0
  148. package/Source/Renderer/Sampler.js +7 -13
  149. package/Source/Renderer/ShaderProgram.js +7 -0
  150. package/Source/Renderer/Texture.js +396 -332
  151. package/Source/Renderer/UniformState.js +8 -33
  152. package/Source/Renderer/demodernizeShader.js +2 -0
  153. package/Source/Renderer/loadCubeMap.js +3 -8
  154. package/Source/Scene/ArcGisMapService.js +1 -1
  155. package/Source/Scene/Billboard.js +29 -2
  156. package/Source/Scene/BillboardCollection.js +49 -0
  157. package/Source/Scene/BingMapsImageryProvider.js +10 -1
  158. package/Source/Scene/CameraEventAggregator.js +49 -5
  159. package/Source/Scene/Globe.js +1 -1
  160. package/Source/Scene/GlobeSurfaceShaderSet.js +29 -24
  161. package/Source/Scene/GlobeSurfaceTileProvider.js +5 -3
  162. package/Source/Scene/ImageBasedLighting.js +36 -36
  163. package/Source/Scene/Label.js +2 -2
  164. package/Source/Scene/Material.js +24 -2
  165. package/Source/Scene/Model/ImageBasedLightingPipelineStage.js +7 -15
  166. package/Source/Scene/Model/Model.js +1 -1
  167. package/Source/Scene/PointPrimitive.js +28 -2
  168. package/Source/Scene/PointPrimitiveCollection.js +22 -9
  169. package/Source/Scene/PostProcessStageCollection.js +45 -15
  170. package/Source/Scene/PostProcessStageLibrary.js +26 -0
  171. package/Source/Scene/Scene.js +20 -22
  172. package/Source/Scene/SceneTransforms.js +0 -62
  173. package/Source/Scene/ScreenSpaceCameraController.js +11 -4
  174. package/Source/Scene/SkyBox.js +13 -19
  175. package/Source/Scene/SpecularEnvironmentCubeMap.js +240 -0
  176. package/Source/Scene/Tonemapper.js +35 -23
  177. package/Source/Scene/VoxelPrimitive.js +0 -29
  178. package/Source/Scene/VoxelRenderResources.js +0 -3
  179. package/Source/Shaders/BillboardCollectionFS.glsl +4 -0
  180. package/Source/Shaders/BillboardCollectionFS.js +4 -0
  181. package/Source/Shaders/BillboardCollectionVS.glsl +3 -1
  182. package/Source/Shaders/BillboardCollectionVS.js +3 -1
  183. package/Source/Shaders/BrdfLutGeneratorFS.glsl +30 -13
  184. package/Source/Shaders/BrdfLutGeneratorFS.js +30 -13
  185. package/Source/Shaders/Builtin/CzmBuiltins.js +2 -2
  186. package/Source/Shaders/Builtin/Functions/pbrLighting.glsl +42 -41
  187. package/Source/Shaders/Builtin/Functions/pbrLighting.js +42 -41
  188. package/Source/Shaders/Builtin/Functions/pbrNeutralTonemapping.glsl +23 -0
  189. package/Source/Shaders/Builtin/Functions/pbrNeutralTonemapping.js +25 -0
  190. package/Source/Shaders/Builtin/Functions/textureCube.glsl +21 -2
  191. package/Source/Shaders/Builtin/Functions/textureCube.js +21 -2
  192. package/Source/Shaders/Builtin/Structs/materialInput.glsl +2 -0
  193. package/Source/Shaders/Builtin/Structs/materialInput.js +2 -0
  194. package/Source/Shaders/GlobeFS.glsl +10 -4
  195. package/Source/Shaders/GlobeFS.js +10 -4
  196. package/Source/Shaders/Materials/WaterMaskMaterial.glsl +15 -0
  197. package/Source/Shaders/Materials/WaterMaskMaterial.js +17 -0
  198. package/Source/Shaders/Model/AtmosphereStageFS.glsl +1 -1
  199. package/Source/Shaders/Model/AtmosphereStageFS.js +1 -1
  200. package/Source/Shaders/Model/ImageBasedLightingStageFS.glsl +57 -46
  201. package/Source/Shaders/Model/ImageBasedLightingStageFS.js +57 -46
  202. package/Source/Shaders/Model/LightingStageFS.glsl +8 -7
  203. package/Source/Shaders/Model/LightingStageFS.js +8 -7
  204. package/Source/Shaders/Model/MaterialStageFS.glsl +10 -14
  205. package/Source/Shaders/Model/MaterialStageFS.js +10 -14
  206. package/Source/Shaders/PointPrimitiveCollectionFS.glsl +4 -0
  207. package/Source/Shaders/PointPrimitiveCollectionFS.js +4 -0
  208. package/Source/Shaders/PointPrimitiveCollectionVS.glsl +9 -7
  209. package/Source/Shaders/PointPrimitiveCollectionVS.js +9 -7
  210. package/Source/Shaders/PostProcessStages/AcesTonemappingStage.glsl +4 -0
  211. package/Source/Shaders/PostProcessStages/AcesTonemappingStage.js +4 -0
  212. package/Source/Shaders/PostProcessStages/FilmicTonemapping.glsl +4 -0
  213. package/Source/Shaders/PostProcessStages/FilmicTonemapping.js +4 -0
  214. package/Source/Shaders/PostProcessStages/ModifiedReinhardTonemapping.glsl +4 -0
  215. package/Source/Shaders/PostProcessStages/ModifiedReinhardTonemapping.js +4 -0
  216. package/Source/Shaders/PostProcessStages/PbrNeutralTonemapping.glsl +25 -0
  217. package/Source/Shaders/PostProcessStages/PbrNeutralTonemapping.js +27 -0
  218. package/Source/Shaders/PostProcessStages/ReinhardTonemapping.glsl +4 -0
  219. package/Source/Shaders/PostProcessStages/ReinhardTonemapping.js +4 -0
  220. package/Source/Shaders/SkyAtmosphereFS.glsl +1 -1
  221. package/Source/Shaders/SkyAtmosphereFS.js +1 -1
  222. package/Source/Widget/CesiumWidget.js +1 -1
  223. package/index.d.ts +191 -106
  224. package/index.js +133 -134
  225. package/package.json +4 -4
  226. package/Source/Scene/OctahedralProjectedCubeMap.js +0 -445
  227. package/Source/Shaders/Builtin/Functions/sampleOctahedralProjection.glsl +0 -78
  228. package/Source/Shaders/Builtin/Functions/sampleOctahedralProjection.js +0 -80
  229. package/Source/Shaders/OctahedralProjectionAtlasFS.glsl +0 -89
  230. package/Source/Shaders/OctahedralProjectionAtlasFS.js +0 -91
  231. package/Source/Shaders/OctahedralProjectionFS.glsl +0 -14
  232. package/Source/Shaders/OctahedralProjectionFS.js +0 -16
  233. package/Source/Shaders/OctahedralProjectionVS.glsl +0 -10
  234. package/Source/Shaders/OctahedralProjectionVS.js +0 -12
@@ -1,445 +0,0 @@
1
- import Cartesian3 from "../Core/Cartesian3.js";
2
- import ComponentDatatype from "../Core/ComponentDatatype.js";
3
- import defined from "../Core/defined.js";
4
- import destroyObject from "../Core/destroyObject.js";
5
- import Event from "../Core/Event.js";
6
- import IndexDatatype from "../Core/IndexDatatype.js";
7
- import loadKTX2 from "../Core/loadKTX2.js";
8
- import PixelFormat from "../Core/PixelFormat.js";
9
- import Buffer from "../Renderer/Buffer.js";
10
- import BufferUsage from "../Renderer/BufferUsage.js";
11
- import ComputeCommand from "../Renderer/ComputeCommand.js";
12
- import CubeMap from "../Renderer/CubeMap.js";
13
- import PixelDatatype from "../Renderer/PixelDatatype.js";
14
- import ShaderProgram from "../Renderer/ShaderProgram.js";
15
- import ShaderSource from "../Renderer/ShaderSource.js";
16
- import Texture from "../Renderer/Texture.js";
17
- import VertexArray from "../Renderer/VertexArray.js";
18
- import OctahedralProjectionAtlasFS from "../Shaders/OctahedralProjectionAtlasFS.js";
19
- import OctahedralProjectionFS from "../Shaders/OctahedralProjectionFS.js";
20
- import OctahedralProjectionVS from "../Shaders/OctahedralProjectionVS.js";
21
-
22
- /**
23
- * Packs all mip levels of a cube map into a 2D texture atlas.
24
- *
25
- * Octahedral projection is a way of putting the cube maps onto a 2D texture
26
- * with minimal distortion and easy look up.
27
- * See Chapter 16 of WebGL Insights "HDR Image-Based Lighting on the Web" by Jeff Russell
28
- * and "Octahedron Environment Maps" for reference.
29
- *
30
- * @private
31
- */
32
- function OctahedralProjectedCubeMap(url) {
33
- this._url = url;
34
-
35
- this._cubeMapBuffers = undefined;
36
- this._cubeMaps = undefined;
37
- this._texture = undefined;
38
- this._mipTextures = undefined;
39
- this._va = undefined;
40
- this._sp = undefined;
41
-
42
- this._maximumMipmapLevel = undefined;
43
-
44
- this._loading = false;
45
- this._ready = false;
46
-
47
- this._errorEvent = new Event();
48
- }
49
-
50
- Object.defineProperties(OctahedralProjectedCubeMap.prototype, {
51
- /**
52
- * The url to the KTX2 file containing the specular environment map and convoluted mipmaps.
53
- * @memberof OctahedralProjectedCubeMap.prototype
54
- * @type {string}
55
- * @readonly
56
- */
57
- url: {
58
- get: function () {
59
- return this._url;
60
- },
61
- },
62
- /**
63
- * Gets an event that is raised when encountering an asynchronous error. By subscribing
64
- * to the event, you will be notified of the error and can potentially recover from it.
65
- * @memberof OctahedralProjectedCubeMap.prototype
66
- * @type {Event}
67
- * @readonly
68
- */
69
- errorEvent: {
70
- get: function () {
71
- return this._errorEvent;
72
- },
73
- },
74
- /**
75
- * A texture containing all the packed convolutions.
76
- * @memberof OctahedralProjectedCubeMap.prototype
77
- * @type {Texture}
78
- * @readonly
79
- */
80
- texture: {
81
- get: function () {
82
- return this._texture;
83
- },
84
- },
85
- /**
86
- * The maximum number of mip levels.
87
- * @memberOf OctahedralProjectedCubeMap.prototype
88
- * @type {number}
89
- * @readonly
90
- */
91
- maximumMipmapLevel: {
92
- get: function () {
93
- return this._maximumMipmapLevel;
94
- },
95
- },
96
- /**
97
- * Determines if the texture atlas is complete and ready to use.
98
- * @memberof OctahedralProjectedCubeMap.prototype
99
- * @type {boolean}
100
- * @readonly
101
- */
102
- ready: {
103
- get: function () {
104
- return this._ready;
105
- },
106
- },
107
- });
108
-
109
- OctahedralProjectedCubeMap.isSupported = function (context) {
110
- return (
111
- (context.colorBufferHalfFloat && context.halfFloatingPointTexture) ||
112
- (context.floatingPointTexture && context.colorBufferFloat)
113
- );
114
- };
115
-
116
- // These vertices are based on figure 1 from "Octahedron Environment Maps".
117
- const v1 = new Cartesian3(1.0, 0.0, 0.0);
118
- const v2 = new Cartesian3(0.0, 0.0, 1.0);
119
- const v3 = new Cartesian3(-1.0, 0.0, 0.0);
120
- const v4 = new Cartesian3(0.0, 0.0, -1.0);
121
- const v5 = new Cartesian3(0.0, 1.0, 0.0);
122
- const v6 = new Cartesian3(0.0, -1.0, 0.0);
123
-
124
- // top left, left, top, center, right, top right, bottom, bottom left, bottom right
125
- const cubeMapCoordinates = [v5, v3, v2, v6, v1, v5, v4, v5, v5];
126
- const length = cubeMapCoordinates.length;
127
- const flatCubeMapCoordinates = new Float32Array(length * 3);
128
-
129
- let offset = 0;
130
- for (let i = 0; i < length; ++i, offset += 3) {
131
- Cartesian3.pack(cubeMapCoordinates[i], flatCubeMapCoordinates, offset);
132
- }
133
-
134
- const flatPositions = new Float32Array([
135
- -1.0,
136
- 1.0, // top left
137
- -1.0,
138
- 0.0, // left
139
- 0.0,
140
- 1.0, // top
141
- 0.0,
142
- 0.0, // center
143
- 1.0,
144
- 0.0, // right
145
- 1.0,
146
- 1.0, // top right
147
- 0.0,
148
- -1.0, // bottom
149
- -1.0,
150
- -1.0, // bottom left
151
- 1.0,
152
- -1.0, // bottom right
153
- ]);
154
- const indices = new Uint16Array([
155
- 0,
156
- 1,
157
- 2, // top left, left, top,
158
- 2,
159
- 3,
160
- 1, // top, center, left,
161
- 7,
162
- 6,
163
- 1, // bottom left, bottom, left,
164
- 3,
165
- 6,
166
- 1, // center, bottom, left,
167
- 2,
168
- 5,
169
- 4, // top, top right, right,
170
- 3,
171
- 4,
172
- 2, // center, right, top,
173
- 4,
174
- 8,
175
- 6, // right, bottom right, bottom,
176
- 3,
177
- 4,
178
- 6, //center, right, bottom
179
- ]);
180
-
181
- function createVertexArray(context) {
182
- const positionBuffer = Buffer.createVertexBuffer({
183
- context: context,
184
- typedArray: flatPositions,
185
- usage: BufferUsage.STATIC_DRAW,
186
- });
187
- const cubeMapCoordinatesBuffer = Buffer.createVertexBuffer({
188
- context: context,
189
- typedArray: flatCubeMapCoordinates,
190
- usage: BufferUsage.STATIC_DRAW,
191
- });
192
- const indexBuffer = Buffer.createIndexBuffer({
193
- context: context,
194
- typedArray: indices,
195
- usage: BufferUsage.STATIC_DRAW,
196
- indexDatatype: IndexDatatype.UNSIGNED_SHORT,
197
- });
198
-
199
- const attributes = [
200
- {
201
- index: 0,
202
- vertexBuffer: positionBuffer,
203
- componentsPerAttribute: 2,
204
- componentDatatype: ComponentDatatype.FLOAT,
205
- },
206
- {
207
- index: 1,
208
- vertexBuffer: cubeMapCoordinatesBuffer,
209
- componentsPerAttribute: 3,
210
- componentDatatype: ComponentDatatype.FLOAT,
211
- },
212
- ];
213
- return new VertexArray({
214
- context: context,
215
- attributes: attributes,
216
- indexBuffer: indexBuffer,
217
- });
218
- }
219
-
220
- function createUniformTexture(texture) {
221
- return function () {
222
- return texture;
223
- };
224
- }
225
-
226
- function cleanupResources(map) {
227
- map._va = map._va && map._va.destroy();
228
- map._sp = map._sp && map._sp.destroy();
229
-
230
- let i;
231
- let length;
232
-
233
- const cubeMaps = map._cubeMaps;
234
- if (defined(cubeMaps)) {
235
- length = cubeMaps.length;
236
- for (i = 0; i < length; ++i) {
237
- cubeMaps[i].destroy();
238
- }
239
- }
240
- const mipTextures = map._mipTextures;
241
- if (defined(mipTextures)) {
242
- length = mipTextures.length;
243
- for (i = 0; i < length; ++i) {
244
- mipTextures[i].destroy();
245
- }
246
- }
247
-
248
- map._va = undefined;
249
- map._sp = undefined;
250
- map._cubeMaps = undefined;
251
- map._cubeMapBuffers = undefined;
252
- map._mipTextures = undefined;
253
- }
254
-
255
- /**
256
- * Creates compute commands to generate octahedral projections of each cube map
257
- * and then renders them to an atlas.
258
- * <p>
259
- * Only needs to be called twice. The first call queues the compute commands to generate the atlas.
260
- * The second call cleans up unused resources. Every call afterwards is a no-op.
261
- * </p>
262
- *
263
- * @param {FrameState} frameState The frame state.
264
- *
265
- * @private
266
- */
267
- OctahedralProjectedCubeMap.prototype.update = function (frameState) {
268
- const context = frameState.context;
269
-
270
- if (!OctahedralProjectedCubeMap.isSupported(context)) {
271
- return;
272
- }
273
-
274
- if (defined(this._texture) && defined(this._va)) {
275
- cleanupResources(this);
276
- }
277
- if (defined(this._texture)) {
278
- return;
279
- }
280
-
281
- if (!defined(this._texture) && !this._loading) {
282
- const cachedTexture = frameState.context.textureCache.getTexture(this._url);
283
- if (defined(cachedTexture)) {
284
- cleanupResources(this);
285
- this._texture = cachedTexture;
286
- this._maximumMipmapLevel = this._texture.maximumMipmapLevel;
287
- this._ready = true;
288
- }
289
- }
290
-
291
- const cubeMapBuffers = this._cubeMapBuffers;
292
- if (!defined(cubeMapBuffers) && !this._loading) {
293
- const that = this;
294
- loadKTX2(this._url)
295
- .then(function (buffers) {
296
- that._cubeMapBuffers = buffers;
297
- that._loading = false;
298
- })
299
- .catch(function (error) {
300
- if (that.isDestroyed()) {
301
- return;
302
- }
303
- that._errorEvent.raiseEvent(error);
304
- });
305
- this._loading = true;
306
- }
307
-
308
- if (!defined(this._cubeMapBuffers)) {
309
- return;
310
- }
311
-
312
- const defines = [];
313
- // Datatype is defined if it is a normalized type (i.e. ..._UNORM, ..._SFLOAT)
314
- let pixelDatatype = cubeMapBuffers[0].positiveX.pixelDatatype;
315
- if (!defined(pixelDatatype)) {
316
- pixelDatatype = context.halfFloatingPointTexture
317
- ? PixelDatatype.HALF_FLOAT
318
- : PixelDatatype.FLOAT;
319
- } else {
320
- defines.push("RGBA_NORMALIZED");
321
- }
322
- const pixelFormat = PixelFormat.RGBA;
323
-
324
- const fs = new ShaderSource({
325
- defines: defines,
326
- sources: [OctahedralProjectionFS],
327
- });
328
-
329
- this._va = createVertexArray(context);
330
- this._sp = ShaderProgram.fromCache({
331
- context: context,
332
- vertexShaderSource: OctahedralProjectionVS,
333
- fragmentShaderSource: fs,
334
- attributeLocations: {
335
- position: 0,
336
- cubeMapCoordinates: 1,
337
- },
338
- });
339
-
340
- // We only need up to 6 mip levels to avoid artifacts.
341
- const length = Math.min(cubeMapBuffers.length, 6);
342
- this._maximumMipmapLevel = length - 1;
343
- const cubeMaps = (this._cubeMaps = new Array(length));
344
- const mipTextures = (this._mipTextures = new Array(length));
345
- const originalSize = cubeMapBuffers[0].positiveX.width * 2.0;
346
- const uniformMap = {
347
- originalSize: function () {
348
- return originalSize;
349
- },
350
- };
351
-
352
- // First we project each cubemap onto a flat octahedron, and write that to a texture.
353
- for (let i = 0; i < length; ++i) {
354
- // Swap +Y/-Y faces since the octahedral projection expects this order.
355
- const positiveY = cubeMapBuffers[i].positiveY;
356
- cubeMapBuffers[i].positiveY = cubeMapBuffers[i].negativeY;
357
- cubeMapBuffers[i].negativeY = positiveY;
358
-
359
- const cubeMap = (cubeMaps[i] = new CubeMap({
360
- context: context,
361
- source: cubeMapBuffers[i],
362
- pixelDatatype: pixelDatatype,
363
- }));
364
- const size = cubeMaps[i].width * 2;
365
-
366
- const mipTexture = (mipTextures[i] = new Texture({
367
- context: context,
368
- width: size,
369
- height: size,
370
- pixelDatatype: pixelDatatype,
371
- pixelFormat: pixelFormat,
372
- }));
373
-
374
- const command = new ComputeCommand({
375
- vertexArray: this._va,
376
- shaderProgram: this._sp,
377
- uniformMap: {
378
- cubeMap: createUniformTexture(cubeMap),
379
- },
380
- outputTexture: mipTexture,
381
- persists: true,
382
- owner: this,
383
- });
384
- frameState.commandList.push(command);
385
-
386
- uniformMap[`texture${i}`] = createUniformTexture(mipTexture);
387
- }
388
-
389
- this._texture = new Texture({
390
- context: context,
391
- width: originalSize * 1.5 + 2.0, // We add a 1 pixel border to avoid linear sampling artifacts.
392
- height: originalSize,
393
- pixelDatatype: pixelDatatype,
394
- pixelFormat: pixelFormat,
395
- });
396
-
397
- this._texture.maximumMipmapLevel = this._maximumMipmapLevel;
398
- context.textureCache.addTexture(this._url, this._texture);
399
-
400
- const atlasCommand = new ComputeCommand({
401
- fragmentShaderSource: OctahedralProjectionAtlasFS,
402
- uniformMap: uniformMap,
403
- outputTexture: this._texture,
404
- persists: false,
405
- owner: this,
406
- });
407
- frameState.commandList.push(atlasCommand);
408
-
409
- this._ready = true;
410
- };
411
-
412
- /**
413
- * Returns true if this object was destroyed; otherwise, false.
414
- * <p>
415
- * If this object was destroyed, it should not be used; calling any function other than
416
- * <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
417
- * </p>
418
- *
419
- * @returns {boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
420
- *
421
- * @see OctahedralProjectedCubeMap#destroy
422
- */
423
- OctahedralProjectedCubeMap.prototype.isDestroyed = function () {
424
- return false;
425
- };
426
-
427
- /**
428
- * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
429
- * release of WebGL resources, instead of relying on the garbage collector to destroy this object.
430
- * <p>
431
- * Once an object is destroyed, it should not be used; calling any function other than
432
- * <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
433
- * assign the return value (<code>undefined</code>) to the object as done in the example.
434
- * </p>
435
- *
436
- * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
437
- *
438
- * @see OctahedralProjectedCubeMap#isDestroyed
439
- */
440
- OctahedralProjectedCubeMap.prototype.destroy = function () {
441
- cleanupResources(this);
442
- this._texture = this._texture && this._texture.destroy();
443
- return destroyObject(this);
444
- };
445
- export default OctahedralProjectedCubeMap;
@@ -1,78 +0,0 @@
1
- /**
2
- * Samples the 4 neighboring pixels and return the weighted average.
3
- *
4
- * @private
5
- */
6
- vec3 czm_sampleOctahedralProjectionWithFiltering(sampler2D projectedMap, vec2 textureSize, vec3 direction, float lod)
7
- {
8
- direction /= dot(vec3(1.0), abs(direction));
9
- vec2 rev = abs(direction.zx) - vec2(1.0);
10
- vec2 neg = vec2(direction.x < 0.0 ? rev.x : -rev.x,
11
- direction.z < 0.0 ? rev.y : -rev.y);
12
- vec2 uv = direction.y < 0.0 ? neg : direction.xz;
13
- vec2 coord = 0.5 * uv + vec2(0.5);
14
- vec2 pixel = 1.0 / textureSize;
15
-
16
- if (lod > 0.0)
17
- {
18
- // Each subseqeuent mip level is half the size
19
- float scale = 1.0 / pow(2.0, lod);
20
- float offset = ((textureSize.y + 1.0) / textureSize.x);
21
-
22
- coord.x *= offset;
23
- coord *= scale;
24
-
25
- coord.x += offset + pixel.x;
26
- coord.y += (1.0 - (1.0 / pow(2.0, lod - 1.0))) + pixel.y * (lod - 1.0) * 2.0;
27
- }
28
- else
29
- {
30
- coord.x *= (textureSize.y / textureSize.x);
31
- }
32
-
33
- // Do bilinear filtering
34
- #ifndef OES_texture_float_linear
35
- vec3 color1 = texture(projectedMap, coord + vec2(0.0, pixel.y)).rgb;
36
- vec3 color2 = texture(projectedMap, coord + vec2(pixel.x, 0.0)).rgb;
37
- vec3 color3 = texture(projectedMap, coord + pixel).rgb;
38
- vec3 color4 = texture(projectedMap, coord).rgb;
39
-
40
- vec2 texturePosition = coord * textureSize;
41
-
42
- float fu = fract(texturePosition.x);
43
- float fv = fract(texturePosition.y);
44
-
45
- vec3 average1 = mix(color4, color2, fu);
46
- vec3 average2 = mix(color1, color3, fu);
47
-
48
- vec3 color = mix(average1, average2, fv);
49
- #else
50
- vec3 color = texture(projectedMap, coord).rgb;
51
- #endif
52
-
53
- return color;
54
- }
55
-
56
-
57
- /**
58
- * Samples from a cube map that has been projected using an octahedral projection from the given direction.
59
- *
60
- * @name czm_sampleOctahedralProjection
61
- * @glslFunction
62
- *
63
- * @param {sampler2D} projectedMap The texture with the octahedral projected cube map.
64
- * @param {vec2} textureSize The width and height dimensions in pixels of the projected map.
65
- * @param {vec3} direction The normalized direction used to sample the cube map.
66
- * @param {float} lod The level of detail to sample.
67
- * @param {float} maxLod The maximum level of detail.
68
- * @returns {vec3} The color of the cube map at the direction.
69
- */
70
- vec3 czm_sampleOctahedralProjection(sampler2D projectedMap, vec2 textureSize, vec3 direction, float lod, float maxLod) {
71
- float currentLod = floor(lod + 0.5);
72
- float nextLod = min(currentLod + 1.0, maxLod);
73
-
74
- vec3 colorCurrentLod = czm_sampleOctahedralProjectionWithFiltering(projectedMap, textureSize, direction, currentLod);
75
- vec3 colorNextLod = czm_sampleOctahedralProjectionWithFiltering(projectedMap, textureSize, direction, nextLod);
76
-
77
- return mix(colorNextLod, colorCurrentLod, nextLod - lod);
78
- }
@@ -1,80 +0,0 @@
1
- //This file is automatically rebuilt by the Cesium build process.
2
- export default "/**\n\
3
- * Samples the 4 neighboring pixels and return the weighted average.\n\
4
- *\n\
5
- * @private\n\
6
- */\n\
7
- vec3 czm_sampleOctahedralProjectionWithFiltering(sampler2D projectedMap, vec2 textureSize, vec3 direction, float lod)\n\
8
- {\n\
9
- direction /= dot(vec3(1.0), abs(direction));\n\
10
- vec2 rev = abs(direction.zx) - vec2(1.0);\n\
11
- vec2 neg = vec2(direction.x < 0.0 ? rev.x : -rev.x,\n\
12
- direction.z < 0.0 ? rev.y : -rev.y);\n\
13
- vec2 uv = direction.y < 0.0 ? neg : direction.xz;\n\
14
- vec2 coord = 0.5 * uv + vec2(0.5);\n\
15
- vec2 pixel = 1.0 / textureSize;\n\
16
- \n\
17
- if (lod > 0.0)\n\
18
- {\n\
19
- // Each subseqeuent mip level is half the size\n\
20
- float scale = 1.0 / pow(2.0, lod);\n\
21
- float offset = ((textureSize.y + 1.0) / textureSize.x);\n\
22
- \n\
23
- coord.x *= offset;\n\
24
- coord *= scale;\n\
25
- \n\
26
- coord.x += offset + pixel.x;\n\
27
- coord.y += (1.0 - (1.0 / pow(2.0, lod - 1.0))) + pixel.y * (lod - 1.0) * 2.0;\n\
28
- }\n\
29
- else\n\
30
- {\n\
31
- coord.x *= (textureSize.y / textureSize.x);\n\
32
- }\n\
33
- \n\
34
- // Do bilinear filtering\n\
35
- #ifndef OES_texture_float_linear\n\
36
- vec3 color1 = texture(projectedMap, coord + vec2(0.0, pixel.y)).rgb;\n\
37
- vec3 color2 = texture(projectedMap, coord + vec2(pixel.x, 0.0)).rgb;\n\
38
- vec3 color3 = texture(projectedMap, coord + pixel).rgb;\n\
39
- vec3 color4 = texture(projectedMap, coord).rgb;\n\
40
- \n\
41
- vec2 texturePosition = coord * textureSize;\n\
42
- \n\
43
- float fu = fract(texturePosition.x);\n\
44
- float fv = fract(texturePosition.y);\n\
45
- \n\
46
- vec3 average1 = mix(color4, color2, fu);\n\
47
- vec3 average2 = mix(color1, color3, fu);\n\
48
- \n\
49
- vec3 color = mix(average1, average2, fv);\n\
50
- #else\n\
51
- vec3 color = texture(projectedMap, coord).rgb;\n\
52
- #endif\n\
53
- \n\
54
- return color;\n\
55
- }\n\
56
- \n\
57
- \n\
58
- /**\n\
59
- * Samples from a cube map that has been projected using an octahedral projection from the given direction.\n\
60
- *\n\
61
- * @name czm_sampleOctahedralProjection\n\
62
- * @glslFunction\n\
63
- *\n\
64
- * @param {sampler2D} projectedMap The texture with the octahedral projected cube map.\n\
65
- * @param {vec2} textureSize The width and height dimensions in pixels of the projected map.\n\
66
- * @param {vec3} direction The normalized direction used to sample the cube map.\n\
67
- * @param {float} lod The level of detail to sample.\n\
68
- * @param {float} maxLod The maximum level of detail.\n\
69
- * @returns {vec3} The color of the cube map at the direction.\n\
70
- */\n\
71
- vec3 czm_sampleOctahedralProjection(sampler2D projectedMap, vec2 textureSize, vec3 direction, float lod, float maxLod) {\n\
72
- float currentLod = floor(lod + 0.5);\n\
73
- float nextLod = min(currentLod + 1.0, maxLod);\n\
74
- \n\
75
- vec3 colorCurrentLod = czm_sampleOctahedralProjectionWithFiltering(projectedMap, textureSize, direction, currentLod);\n\
76
- vec3 colorNextLod = czm_sampleOctahedralProjectionWithFiltering(projectedMap, textureSize, direction, nextLod);\n\
77
- \n\
78
- return mix(colorNextLod, colorCurrentLod, nextLod - lod);\n\
79
- }\n\
80
- ";
@@ -1,89 +0,0 @@
1
- in vec2 v_textureCoordinates;
2
-
3
- uniform float originalSize;
4
- uniform sampler2D texture0;
5
- uniform sampler2D texture1;
6
- uniform sampler2D texture2;
7
- uniform sampler2D texture3;
8
- uniform sampler2D texture4;
9
- uniform sampler2D texture5;
10
-
11
- const float yMipLevel1 = 1.0 - (1.0 / pow(2.0, 1.0));
12
- const float yMipLevel2 = 1.0 - (1.0 / pow(2.0, 2.0));
13
- const float yMipLevel3 = 1.0 - (1.0 / pow(2.0, 3.0));
14
- const float yMipLevel4 = 1.0 - (1.0 / pow(2.0, 4.0));
15
-
16
- void main()
17
- {
18
- vec2 uv = v_textureCoordinates;
19
- vec2 textureSize = vec2(originalSize * 1.5 + 2.0, originalSize);
20
- vec2 pixel = 1.0 / textureSize;
21
-
22
- float mipLevel = 0.0;
23
-
24
- if (uv.x - pixel.x > (textureSize.y / textureSize.x))
25
- {
26
- mipLevel = 1.0;
27
- if (uv.y - pixel.y > yMipLevel1)
28
- {
29
- mipLevel = 2.0;
30
- if (uv.y - pixel.y * 3.0 > yMipLevel2)
31
- {
32
- mipLevel = 3.0;
33
- if (uv.y - pixel.y * 5.0 > yMipLevel3)
34
- {
35
- mipLevel = 4.0;
36
- if (uv.y - pixel.y * 7.0 > yMipLevel4)
37
- {
38
- mipLevel = 5.0;
39
- }
40
- }
41
- }
42
- }
43
- }
44
-
45
- if (mipLevel > 0.0)
46
- {
47
- float scale = pow(2.0, mipLevel);
48
-
49
- uv.y -= (pixel.y * (mipLevel - 1.0) * 2.0);
50
- uv.x *= ((textureSize.x - 2.0) / textureSize.y);
51
-
52
- uv.x -= 1.0 + pixel.x;
53
- uv.y -= (1.0 - (1.0 / pow(2.0, mipLevel - 1.0)));
54
- uv *= scale;
55
- }
56
- else
57
- {
58
- uv.x *= (textureSize.x / textureSize.y);
59
- }
60
-
61
- if(mipLevel == 0.0)
62
- {
63
- out_FragColor = texture(texture0, uv);
64
- }
65
- else if(mipLevel == 1.0)
66
- {
67
- out_FragColor = texture(texture1, uv);
68
- }
69
- else if(mipLevel == 2.0)
70
- {
71
- out_FragColor = texture(texture2, uv);
72
- }
73
- else if(mipLevel == 3.0)
74
- {
75
- out_FragColor = texture(texture3, uv);
76
- }
77
- else if(mipLevel == 4.0)
78
- {
79
- out_FragColor = texture(texture4, uv);
80
- }
81
- else if(mipLevel == 5.0)
82
- {
83
- out_FragColor = texture(texture5, uv);
84
- }
85
- else
86
- {
87
- out_FragColor = vec4(0.0);
88
- }
89
- }