itowns 2.44.3-next.4 → 2.44.3-next.41

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 (217) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +123 -48
  3. package/examples/config.json +3 -10
  4. package/examples/copc_simple_loader.html +15 -5
  5. package/examples/effects_stereo.html +2 -2
  6. package/examples/entwine_3d_loader.html +3 -1
  7. package/examples/entwine_simple_loader.html +1 -1
  8. package/examples/images/itowns_logo.svg +123 -0
  9. package/examples/js/plugins/COGParser.js +1 -1
  10. package/examples/jsm/OGC3DTilesHelper.js +6 -1
  11. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  12. package/examples/misc_collada.html +2 -2
  13. package/examples/source_file_geojson_3d.html +0 -1
  14. package/examples/source_file_kml_raster_usgs.html +0 -1
  15. package/examples/source_stream_wfs_raster.html +0 -7
  16. package/examples/vector_tile_mapbox_raster.html +91 -0
  17. package/examples/view_3d_map_webxr.html +3 -1
  18. package/examples/view_multi_25d.html +2 -2
  19. package/package.json +21 -75
  20. package/CODING.md +0 -120
  21. package/CONTRIBUTING.md +0 -150
  22. package/CONTRIBUTORS.md +0 -55
  23. package/LICENSE.md +0 -44
  24. package/changelog.md +0 -1361
  25. package/dist/455.js +0 -2
  26. package/dist/455.js.map +0 -1
  27. package/dist/debug.js +0 -3
  28. package/dist/debug.js.LICENSE.txt +0 -13
  29. package/dist/debug.js.map +0 -1
  30. package/dist/itowns.js +0 -3
  31. package/dist/itowns.js.LICENSE.txt +0 -7
  32. package/dist/itowns.js.map +0 -1
  33. package/dist/itowns_lasparser.js +0 -2
  34. package/dist/itowns_lasparser.js.map +0 -1
  35. package/dist/itowns_lasworker.js +0 -2
  36. package/dist/itowns_lasworker.js.map +0 -1
  37. package/dist/itowns_potree2worker.js +0 -2
  38. package/dist/itowns_potree2worker.js.map +0 -1
  39. package/dist/itowns_widgets.js +0 -2
  40. package/dist/itowns_widgets.js.map +0 -1
  41. package/examples/.eslintrc.cjs +0 -35
  42. package/examples/3dtiles_25d.html +0 -120
  43. package/examples/3dtiles_basic.html +0 -94
  44. package/examples/3dtiles_batch_table.html +0 -86
  45. package/examples/3dtiles_ion.html +0 -126
  46. package/examples/3dtiles_pointcloud.html +0 -95
  47. package/examples/jsm/.eslintrc.cjs +0 -38
  48. package/lib/Controls/FirstPersonControls.js +0 -308
  49. package/lib/Controls/FlyControls.js +0 -175
  50. package/lib/Controls/GlobeControls.js +0 -1162
  51. package/lib/Controls/PlanarControls.js +0 -1025
  52. package/lib/Controls/StateControl.js +0 -429
  53. package/lib/Controls/StreetControls.js +0 -392
  54. package/lib/Converter/Feature2Mesh.js +0 -608
  55. package/lib/Converter/Feature2Texture.js +0 -170
  56. package/lib/Converter/convertToTile.js +0 -75
  57. package/lib/Converter/textureConverter.js +0 -44
  58. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  59. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  60. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  61. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  62. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  63. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  64. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  65. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  66. package/lib/Core/AnimationPlayer.js +0 -142
  67. package/lib/Core/CopcNode.js +0 -174
  68. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  69. package/lib/Core/EntwinePointTileNode.js +0 -126
  70. package/lib/Core/Feature.js +0 -490
  71. package/lib/Core/Geographic/CoordStars.js +0 -80
  72. package/lib/Core/Geographic/Coordinates.js +0 -320
  73. package/lib/Core/Geographic/Crs.js +0 -175
  74. package/lib/Core/Geographic/Extent.js +0 -726
  75. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  76. package/lib/Core/Label.js +0 -222
  77. package/lib/Core/MainLoop.js +0 -211
  78. package/lib/Core/Math/Ellipsoid.js +0 -144
  79. package/lib/Core/Picking.js +0 -255
  80. package/lib/Core/PointCloudNode.js +0 -42
  81. package/lib/Core/Potree2Node.js +0 -206
  82. package/lib/Core/Potree2PointAttributes.js +0 -139
  83. package/lib/Core/PotreeNode.js +0 -101
  84. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  85. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  86. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  87. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  88. package/lib/Core/Prefab/GlobeView.js +0 -161
  89. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  90. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  91. package/lib/Core/Prefab/PlanarView.js +0 -62
  92. package/lib/Core/Prefab/TileBuilder.js +0 -80
  93. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  94. package/lib/Core/Scheduler/Cache.js +0 -256
  95. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  96. package/lib/Core/Scheduler/Scheduler.js +0 -294
  97. package/lib/Core/Style.js +0 -1121
  98. package/lib/Core/System/Capabilities.js +0 -63
  99. package/lib/Core/TileGeometry.js +0 -40
  100. package/lib/Core/TileMesh.js +0 -108
  101. package/lib/Core/View.js +0 -1109
  102. package/lib/Layer/C3DTilesLayer.js +0 -455
  103. package/lib/Layer/ColorLayer.js +0 -128
  104. package/lib/Layer/CopcLayer.js +0 -58
  105. package/lib/Layer/ElevationLayer.js +0 -107
  106. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  107. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  108. package/lib/Layer/GeoidLayer.js +0 -80
  109. package/lib/Layer/GeometryLayer.js +0 -202
  110. package/lib/Layer/InfoLayer.js +0 -64
  111. package/lib/Layer/LabelLayer.js +0 -452
  112. package/lib/Layer/Layer.js +0 -304
  113. package/lib/Layer/LayerUpdateState.js +0 -89
  114. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  115. package/lib/Layer/OGC3DTilesLayer.js +0 -387
  116. package/lib/Layer/OrientedImageLayer.js +0 -222
  117. package/lib/Layer/PointCloudLayer.js +0 -359
  118. package/lib/Layer/Potree2Layer.js +0 -164
  119. package/lib/Layer/PotreeLayer.js +0 -65
  120. package/lib/Layer/RasterLayer.js +0 -27
  121. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  122. package/lib/Layer/TiledGeometryLayer.js +0 -403
  123. package/lib/Loader/LASLoader.js +0 -193
  124. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  125. package/lib/Loader/Potree2Loader.js +0 -207
  126. package/lib/Main.js +0 -115
  127. package/lib/MainBundle.js +0 -4
  128. package/lib/Parser/B3dmParser.js +0 -174
  129. package/lib/Parser/CameraCalibrationParser.js +0 -94
  130. package/lib/Parser/GDFParser.js +0 -72
  131. package/lib/Parser/GTXParser.js +0 -75
  132. package/lib/Parser/GeoJsonParser.js +0 -212
  133. package/lib/Parser/GpxParser.js +0 -25
  134. package/lib/Parser/ISGParser.js +0 -71
  135. package/lib/Parser/KMLParser.js +0 -25
  136. package/lib/Parser/LASParser.js +0 -137
  137. package/lib/Parser/MapBoxUrlParser.js +0 -83
  138. package/lib/Parser/PntsParser.js +0 -131
  139. package/lib/Parser/Potree2BinParser.js +0 -92
  140. package/lib/Parser/PotreeBinParser.js +0 -106
  141. package/lib/Parser/PotreeCinParser.js +0 -29
  142. package/lib/Parser/ShapefileParser.js +0 -78
  143. package/lib/Parser/VectorTileParser.js +0 -202
  144. package/lib/Parser/XbilParser.js +0 -108
  145. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  146. package/lib/Parser/iGLTFLoader.js +0 -168
  147. package/lib/Process/3dTilesProcessing.js +0 -304
  148. package/lib/Process/FeatureProcessing.js +0 -76
  149. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  150. package/lib/Process/ObjectRemovalHelper.js +0 -97
  151. package/lib/Process/handlerNodeError.js +0 -23
  152. package/lib/Provider/3dTilesProvider.js +0 -149
  153. package/lib/Provider/DataSourceProvider.js +0 -8
  154. package/lib/Provider/Fetcher.js +0 -229
  155. package/lib/Provider/PointCloudProvider.js +0 -45
  156. package/lib/Provider/TileProvider.js +0 -16
  157. package/lib/Provider/URLBuilder.js +0 -105
  158. package/lib/Renderer/Camera.js +0 -281
  159. package/lib/Renderer/Color.js +0 -56
  160. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  161. package/lib/Renderer/CommonMaterial.js +0 -31
  162. package/lib/Renderer/Label2DRenderer.js +0 -190
  163. package/lib/Renderer/LayeredMaterial.js +0 -243
  164. package/lib/Renderer/OBB.js +0 -153
  165. package/lib/Renderer/OrientedImageCamera.js +0 -118
  166. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  167. package/lib/Renderer/PointsMaterial.js +0 -485
  168. package/lib/Renderer/RasterTile.js +0 -209
  169. package/lib/Renderer/RenderMode.js +0 -31
  170. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  171. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  172. package/lib/Renderer/SphereHelper.js +0 -23
  173. package/lib/Renderer/WebXR.js +0 -51
  174. package/lib/Renderer/c3DEngine.js +0 -214
  175. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  176. package/lib/Source/C3DTilesIonSource.js +0 -54
  177. package/lib/Source/C3DTilesSource.js +0 -30
  178. package/lib/Source/CopcSource.js +0 -115
  179. package/lib/Source/EntwinePointTileSource.js +0 -62
  180. package/lib/Source/FileSource.js +0 -189
  181. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  182. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  183. package/lib/Source/OGC3DTilesSource.js +0 -21
  184. package/lib/Source/OrientedImageSource.js +0 -59
  185. package/lib/Source/Potree2Source.js +0 -167
  186. package/lib/Source/PotreeSource.js +0 -82
  187. package/lib/Source/Source.js +0 -223
  188. package/lib/Source/TMSSource.js +0 -143
  189. package/lib/Source/VectorTilesSource.js +0 -178
  190. package/lib/Source/WFSSource.js +0 -165
  191. package/lib/Source/WMSSource.js +0 -130
  192. package/lib/Source/WMTSSource.js +0 -86
  193. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  194. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  195. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  196. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  197. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  198. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  199. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  200. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  201. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  202. package/lib/Utils/CameraUtils.js +0 -555
  203. package/lib/Utils/DEMUtils.js +0 -350
  204. package/lib/Utils/FeaturesUtils.js +0 -156
  205. package/lib/Utils/Gradients.js +0 -16
  206. package/lib/Utils/OrientationUtils.js +0 -457
  207. package/lib/Utils/ThreeUtils.js +0 -115
  208. package/lib/Utils/gui/C3DTilesStyle.js +0 -216
  209. package/lib/Utils/gui/Main.js +0 -7
  210. package/lib/Utils/gui/Minimap.js +0 -154
  211. package/lib/Utils/gui/Navigation.js +0 -245
  212. package/lib/Utils/gui/Scale.js +0 -107
  213. package/lib/Utils/gui/Searchbar.js +0 -234
  214. package/lib/Utils/gui/Widget.js +0 -80
  215. package/lib/Utils/placeObjectOnGround.js +0 -137
  216. package/lib/Worker/LASLoaderWorker.js +0 -19
  217. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,78 +0,0 @@
1
- /**
2
- * @author zz85 / https://github.com/zz85
3
- *
4
- * Based on "A Practical Analytic Model for Daylight"
5
- * aka The Preetham Model, the de facto standard analytic skydome model
6
- * http://www.cs.utah.edu/~shirley/papers/sunsky/sunsky.pdf
7
- *
8
- * First implemented by Simon Wallner
9
- * http://www.simonwallner.at/projects/atmospheric-scattering
10
- *
11
- * Improved by Martin Upitis
12
- * http://blenderartists.org/forum/showthread.php?245954-preethams-sky-impementation-HDR
13
- *
14
- * Three.js integration by zz85 http://twitter.com/blurspline
15
- */
16
-
17
- import * as THREE from 'three';
18
- const skyShader = {
19
- uniforms: {
20
- luminance: {
21
- type: 'f',
22
- value: 1
23
- },
24
- turbidity: {
25
- type: 'f',
26
- value: 2
27
- },
28
- reileigh: {
29
- type: 'f',
30
- value: 1
31
- },
32
- mieCoefficient: {
33
- type: 'f',
34
- value: 0.005
35
- },
36
- mieDirectionalG: {
37
- type: 'f',
38
- value: 0.8
39
- },
40
- v3LightPosition: {
41
- type: 'v3',
42
- value: new THREE.Vector3()
43
- },
44
- up: {
45
- type: 'v3',
46
- value: new THREE.Vector3(0.0, 1.0, 0.0)
47
- }
48
- },
49
- vertexShader: ['varying vec3 vWorldPosition;', 'void main() {', 'vec4 worldPosition = modelMatrix * vec4( cameraPosition + position, 1.0 );', 'vWorldPosition = worldPosition.xyz;', 'gl_Position = projectionMatrix * modelViewMatrix * vec4( cameraPosition + position, 1.0 );', '}'].join('\n'),
50
- fragmentShader: ['uniform sampler2D skySampler;', 'uniform vec3 v3LightPosition;', 'uniform vec3 up;', 'varying vec3 vWorldPosition;',
51
- // "vec3 cameraPos = cameraPosition; //vec3(0., 0., 0.);",
52
- '// uniform sampler2D sDiffuse;', '// const float turbidity = 10.0; //', '// const float reileigh = 2.; //', '// const float luminance = 1.0; //', '// const float mieCoefficient = 0.005;', '// const float mieDirectionalG = 0.8;', 'uniform float luminance;', 'uniform float turbidity;', 'uniform float reileigh;', 'uniform float mieCoefficient;', 'uniform float mieDirectionalG;', '// constants for atmospheric scattering', 'const float e = 2.71828182845904523536028747135266249775724709369995957;', 'const float pi = 3.141592653589793238462643383279502884197169;', 'const float n = 1.0003; // refractive index of air', 'const float N = 2.545E25; // number of molecules per unit volume for air at', '// 288.15K and 1013mb (sea level -45 celsius)', 'const float pn = 0.035; // depolatization factor for standard air', '// wavelength of used primaries, according to preetham', 'const vec3 lambda = vec3(680E-9, 550E-9, 450E-9);', '// mie stuff', '// K coefficient for the primaries', 'const vec3 K = vec3(0.686, 0.678, 0.666);', 'const float v = 4.0;', '// optical length at zenith for molecules', 'const float rayleighZenithLength = 8.4E3;', 'const float mieZenithLength = 1.25E3;',
53
- // "const vec3 up = vec3(0.0, 1.0, 0.0);",
54
-
55
- 'const float EE = 1000.0;', 'const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;', '// 66 arc seconds -> degrees, and the cosine of that', '// earth shadow hack', 'const float cutoffAngle = pi/1.95;', 'const float steepness = 1.5;', 'vec3 totalRayleigh(vec3 lambda)', '{', 'return (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn));', '}',
56
- // see http://blenderartists.org/forum/showthread.php?321110-Shaders-and-Skybox-madness
57
- '// A simplied version of the total Reayleigh scattering to works on browsers that use ANGLE', 'vec3 simplifiedRayleigh()', '{', 'return 0.0005 / vec3(94, 40, 18);',
58
- // return 0.00054532832366 / (3.0 * 2.545E25 * pow(vec3(680E-9, 550E-9, 450E-9), vec3(4.0)) * 6.245);
59
- '}', 'float rayleighPhase(float cosTheta)', '{ ', 'return (3.0 / (16.0*pi)) * (1.0 + pow(cosTheta, 2.0));', '// return (1.0 / (3.0*pi)) * (1.0 + pow(cosTheta, 2.0));', '// return (3.0 / 4.0) * (1.0 + pow(cosTheta, 2.0));', '}', 'vec3 totalMie(vec3 lambda, vec3 K, float T)', '{', 'float c = (0.2 * T ) * 10E-18;', 'return 0.434 * c * pi * pow((2.0 * pi) / lambda, vec3(v - 2.0)) * K;', '}', 'float hgPhase(float cosTheta, float g)', '{', 'return (1.0 / (4.0*pi)) * ((1.0 - pow(g, 2.0)) / pow(1.0 - 2.0*g*cosTheta + pow(g, 2.0), 1.5));', '}', 'float sunIntensity(float zenithAngleCos)', '{', 'return EE * max(0.0, 1.0 - exp(-((cutoffAngle - acos(zenithAngleCos))/steepness)));', '}', '// float logLuminance(vec3 c)', '// {', '// return log(c.r * 0.2126 + c.g * 0.7152 + c.b * 0.0722);', '// }', '// Filmic ToneMapping http://filmicgames.com/archives/75', 'float A = 0.15;', 'float B = 0.50;', 'float C = 0.10;', 'float D = 0.20;', 'float E = 0.02;', 'float F = 0.30;', 'float W = 1000.0;', 'vec3 Uncharted2Tonemap(vec3 x)', '{', 'return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;', '}', 'void main() ', '{', 'vec3 up2 = normalize(cameraPosition.xyz);', 'float sunfade = 1.0-clamp(1.0-exp((v3LightPosition.y/450000.0)),0.0,1.0);', 'float reileighCoefficient = reileigh - (1.0* (1.0-sunfade));', 'vec3 sunDirection = normalize(v3LightPosition);', 'float sunE = sunIntensity(dot(sunDirection, up2));', '// extinction (absorbtion + out scattering) ', '// rayleigh coefficients',
60
- // "vec3 betaR = totalRayleigh(lambda) * reileighCoefficient;",
61
- 'vec3 betaR = simplifiedRayleigh() * reileighCoefficient;', '// mie coefficients', 'vec3 betaM = totalMie(lambda, K, turbidity) * mieCoefficient;', '// optical length', '// cutoff angle at 90 to avoid singularity in next formula.', 'float zenithAngle = acos(max(0.0, dot(up2, normalize(vWorldPosition - cameraPosition))));', 'float sR = rayleighZenithLength / (cos(zenithAngle) + 0.15 * pow(93.885 - ((zenithAngle * 180.0) / pi), -1.253));', 'float sM = mieZenithLength / (cos(zenithAngle) + 0.15 * pow(93.885 - ((zenithAngle * 180.0) / pi), -1.253));', '// combined extinction factor', 'vec3 Fex = exp(-(betaR * sR + betaM * sM));', '// in scattering', 'float cosTheta = dot(normalize(vWorldPosition - cameraPosition), sunDirection);', 'float rPhase = rayleighPhase(cosTheta*0.5+0.5);', 'vec3 betaRTheta = betaR * rPhase;', 'float mPhase = hgPhase(cosTheta, mieDirectionalG);', 'vec3 betaMTheta = betaM * mPhase;', 'vec3 Lin = pow(sunE * ((betaRTheta + betaMTheta) / (betaR + betaM)) * (1.0 - Fex),vec3(1.5));', 'Lin *= mix(vec3(1.0),pow(sunE * ((betaRTheta + betaMTheta) / (betaR + betaM)) * Fex,vec3(1.0/2.0)),clamp(pow(1.0-dot(up2, sunDirection),5.0),0.0,1.0));', '//nightsky', 'vec3 direction = normalize(vWorldPosition - cameraPosition);', 'float theta = acos(direction.y); // elevation --> y-axis, [-pi/2, pi/2]', 'float phi = atan(direction.z, direction.x); // azimuth --> x-axis [-pi/2, pi/2]', 'vec2 uv = vec2(phi, theta) / vec2(2.0*pi, pi) + vec2(0.5, 0.0);', '// vec3 L0 = texture2D(skySampler, uv).rgb+0.1 * Fex;', 'vec3 L0 = vec3(0.1) * Fex;', '// composition + solar disc', '//if (cosTheta > sunAngularDiameterCos)', 'float sundisk = smoothstep(sunAngularDiameterCos,sunAngularDiameterCos+0.00002,cosTheta);', '// if (normalize(vWorldPosition - cameraPosition).y>0.0)', 'L0 += (sunE * 19000.0 * Fex)*sundisk;', 'vec3 whiteScale = 1.0/Uncharted2Tonemap(vec3(W));', 'vec3 texColor = (Lin+L0); ', 'texColor *= 0.04 ;', 'texColor += vec3(0.0,0.001,0.0025)*0.3;', 'float g_fMaxLuminance = 1.0;', 'float fLumScaled = 0.1 / luminance; ', 'float fLumCompressed = (fLumScaled * (1.0 + (fLumScaled / (g_fMaxLuminance * g_fMaxLuminance)))) / (1.0 + fLumScaled); ', 'float ExposureBias = fLumCompressed;', 'vec3 curr = Uncharted2Tonemap((log2(2.0/pow(luminance,4.0)))*texColor);', 'vec3 color = curr*whiteScale;', 'vec3 retColor = pow(color,vec3(1.0/(1.2+(1.2*sunfade))));', 'gl_FragColor.rgb = retColor;', 'gl_FragColor.a = 1. - ( (length(cameraPosition) - 6400000.) / 1000.);', '}'].join('\n')
62
- };
63
- class Sky extends THREE.Mesh {
64
- constructor() {
65
- const skyUniforms = THREE.UniformsUtils.clone(skyShader.uniforms);
66
- const skyMat = new THREE.ShaderMaterial({
67
- fragmentShader: skyShader.fragmentShader,
68
- vertexShader: skyShader.vertexShader,
69
- uniforms: skyUniforms,
70
- side: THREE.BackSide,
71
- transparent: true,
72
- depthWrite: false
73
- });
74
- const skyGeo = new THREE.SphereGeometry(40000, 32, 15);
75
- super(skyGeo, skyMat);
76
- }
77
- }
78
- export default Sky;
@@ -1,161 +0,0 @@
1
- import * as THREE from 'three';
2
- import View, { VIEW_EVENTS } from "../View.js";
3
- import GlobeControls from "../../Controls/GlobeControls.js";
4
- import Coordinates from "../Geographic/Coordinates.js";
5
- import GlobeLayer from "./Globe/GlobeLayer.js";
6
- import Atmosphere from "./Globe/Atmosphere.js";
7
- import CameraUtils from "../../Utils/CameraUtils.js";
8
- import CRS from "../Geographic/Crs.js";
9
- import { ellipsoidSizes } from "../Math/Ellipsoid.js";
10
-
11
- /**
12
- * Fires when the view is completely loaded. Controls and view's functions can be called then.
13
- * @event GlobeView#initialized
14
- * @property target {view} dispatched on view
15
- * @property type {string} initialized
16
- */
17
- /**
18
- * Fires when a layer is added
19
- * @event GlobeView#layer-added
20
- * @property layerId {string} the id of the layer
21
- * @property target {view} dispatched on view
22
- * @property type {string} layers-added
23
- */
24
- /**
25
- * Fires when a layer is removed
26
- * @event GlobeView#layer-removed
27
- * @property layerId {string} the id of the layer
28
- * @property target {view} dispatched on view
29
- * @property type {string} layers-added
30
- */
31
- /**
32
- * Fires when the layers oder has changed
33
- * @event GlobeView#layers-order-changed
34
- * @property new {object}
35
- * @property new.sequence {array}
36
- * @property new.sequence.0 {number} the new layer at position 0
37
- * @property new.sequence.1 {number} the new layer at position 1
38
- * @property new.sequence.2 {number} the new layer at position 2
39
- * @property previous {object}
40
- * @property previous.sequence {array}
41
- * @property previous.sequence.0 {number} the previous layer at position 0
42
- * @property previous.sequence.1 {number} the previous layer at position 1
43
- * @property previous.sequence.2 {number} the previous layer at position 2
44
- * @property target {view} dispatched on view
45
- * @property type {string} layers-order-changed
46
- */
47
-
48
- /**
49
- * Globe's EVENT
50
- * @property GLOBE_INITIALIZED {string} Deprecated: emit one time when globe is initialized (use VIEW_EVENTS.INITIALIZED instead).
51
- * @property LAYER_ADDED {string} Deprecated: emit when layer id added in viewer (use VIEW_EVENTS.LAYER_ADDED instead).
52
- * @property LAYER_REMOVED {string} Deprecated: emit when layer id removed in viewer (use VIEW_EVENTS.LAYER_REMOVED instead).
53
- * @property COLOR_LAYERS_ORDER_CHANGED {string} Deprecated: emit when color layers order change (use VIEW_EVENTS.COLOR_LAYERS_ORDER_CHANGED instead).
54
- */
55
-
56
- export const GLOBE_VIEW_EVENTS = {
57
- GLOBE_INITIALIZED: VIEW_EVENTS.INITIALIZED,
58
- LAYER_ADDED: VIEW_EVENTS.LAYER_ADDED,
59
- LAYER_REMOVED: VIEW_EVENTS.LAYER_REMOVED,
60
- COLOR_LAYERS_ORDER_CHANGED: VIEW_EVENTS.COLOR_LAYERS_ORDER_CHANGED
61
- };
62
- class GlobeView extends View {
63
- /**
64
- * Creates a view of a globe.
65
- *
66
- * @extends View
67
- *
68
- * @example <caption><b>Instance GlobeView.</b></caption>
69
- * var viewerDiv = document.getElementById('viewerDiv');
70
- * const placement = {
71
- * coord: new itowns.Coordinates('EPSG:4326', 2.351323, 48.856712),
72
- * range: 25000000,
73
- * }
74
- * var view = new itowns.GlobeView(viewerDiv, placement);
75
- *
76
- * @param {HTMLDivElement} viewerDiv - Where to attach the view and display it
77
- * in the DOM.
78
- * @param {CameraTransformOptions|Extent} placement - An object to place view
79
- * @param {object} [options] - See options of {@link View}.
80
- * @param {Object} [options.controls] - See options of {@link GlobeControls}
81
- */
82
- constructor(viewerDiv) {
83
- let placement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
84
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
85
- THREE.Object3D.DEFAULT_UP.set(0, 0, 1);
86
- // Setup View
87
- super('EPSG:4978', viewerDiv, options);
88
- this.isGlobeView = true;
89
- this.camera3D.near = Math.max(15.0, 0.000002352 * ellipsoidSizes.x);
90
- this.camera3D.far = ellipsoidSizes.x * 10;
91
- const tileLayer = new GlobeLayer('globe', options.object3d, options);
92
- this.mainLoop.gfxEngine.label2dRenderer.infoTileLayer = tileLayer.info;
93
- const sun = new THREE.DirectionalLight();
94
- sun.position.set(-0.5, 0, 1);
95
- sun.updateMatrixWorld(true);
96
- this.scene.add(sun);
97
- this.addLayer(tileLayer);
98
- this.tileLayer = tileLayer;
99
- if (!placement.isExtent) {
100
- placement.coord = placement.coord || new Coordinates('EPSG:4326', 0, 0);
101
- placement.tilt = placement.tilt || 89.5;
102
- placement.heading = placement.heading || 0;
103
- placement.range = placement.range || ellipsoidSizes.x * 2.0;
104
- }
105
- if (options.noControls) {
106
- CameraUtils.transformCameraToLookAtTarget(this, this.camera3D, placement);
107
- } else {
108
- this.controls = new GlobeControls(this, placement, options.controls);
109
- this.controls.handleCollision = typeof options.handleCollision !== 'undefined' ? options.handleCollision : true;
110
- }
111
- this.addLayer(new Atmosphere('atmosphere', options.atmosphere));
112
-
113
- // GlobeView needs this.camera.resize to set perpsective matrix camera
114
- this.camera.resize(viewerDiv.clientWidth, viewerDiv.clientHeight);
115
- }
116
-
117
- /**
118
- * Add layer in viewer.
119
- * The layer id must be unique.
120
- *
121
- * The `layer.whenReady` is a promise that resolves when
122
- * the layer is done. This promise is also returned by
123
- * `addLayer` allowing to chain call.
124
- *
125
- * The layer added is attached, by default to `GlobeLayer` (`GlobeView.tileLayer`).
126
- * If you want add a unattached layer use `View#addLayer` parent method.
127
- *
128
- * @param {LayerOptions|Layer|GeometryLayer} layer The layer to add in view.
129
- * @return {Promise} a promise resolved with the new layer object when it is fully initialized or rejected if any error occurred.
130
- */
131
- addLayer(layer) {
132
- if (!layer || !layer.isLayer) {
133
- return Promise.reject(new Error('Add Layer type object'));
134
- }
135
- if (layer.isColorLayer) {
136
- if (!this.tileLayer.tileMatrixSets.includes(CRS.formatToTms(layer.source.crs))) {
137
- return layer._reject(`Only ${this.tileLayer.tileMatrixSets} tileMatrixSet are currently supported for color layers`);
138
- }
139
- } else if (layer.isElevationLayer) {
140
- if (CRS.formatToTms(layer.source.crs) !== this.tileLayer.tileMatrixSets[0]) {
141
- return layer._reject(`Only ${this.tileLayer.tileMatrixSets[0]} tileMatrixSet is currently supported for elevation layers`);
142
- }
143
- }
144
- return super.addLayer(layer, this.tileLayer);
145
- }
146
- getPixelsToDegrees() {
147
- let pixels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
148
- let screenCoord = arguments.length > 1 ? arguments[1] : undefined;
149
- return this.getMetersToDegrees(this.getPixelsToMeters(pixels, screenCoord));
150
- }
151
- getPixelsToDegreesFromDistance() {
152
- let pixels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
153
- let distance = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
154
- return this.getMetersToDegrees(this.getPixelsToMetersFromDistance(pixels, distance));
155
- }
156
- getMetersToDegrees() {
157
- let meters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
158
- return THREE.MathUtils.radToDeg(2 * Math.asin(meters / (2 * ellipsoidSizes.x)));
159
- }
160
- }
161
- export default GlobeView;
@@ -1,53 +0,0 @@
1
- import * as THREE from 'three';
2
- import TiledGeometryLayer from "../../../Layer/TiledGeometryLayer.js";
3
- import { globalExtentTMS } from "../../Geographic/Extent.js";
4
- import CRS from "../../Geographic/Crs.js";
5
- import PlanarTileBuilder from "./PlanarTileBuilder.js";
6
-
7
- /**
8
- * @property {boolean} isPlanarLayer - Used to checkout whether this layer is a
9
- * PlanarLayer. Default is true. You should not change this, as it is used
10
- * internally for optimisation.
11
- */
12
- class PlanarLayer extends TiledGeometryLayer {
13
- /**
14
- * A {@link TiledGeometryLayer} to use with a {@link PlanarView}. It has
15
- * specific method for updating and subdivising its grid.
16
- *
17
- * @extends TiledGeometryLayer
18
- *
19
- * @param {string} id - The id of the layer, that should be unique. It is
20
- * not mandatory, but an error will be emitted if this layer is added a
21
- * {@link View} that already has a layer going by that id.
22
- * @param {Extent} extent - The extent to define the layer within.
23
- * @param {THREE.Object3d} [object3d=THREE.Group] - The object3d used to
24
- * contain the geometry of the TiledGeometryLayer. It is usually a
25
- * `THREE.Group`, but it can be anything inheriting from a `THREE.Object3d`.
26
- * @param {Object} [config] - Optional configuration, all elements in it
27
- * will be merged as is in the layer. For example, if the configuration
28
- * contains three elements `name, protocol, extent`, these elements will be
29
- * available using `layer.name` or something else depending on the property
30
- * name.
31
- * @param {number} [config.maxSubdivisionLevel=5] - Maximum subdivision
32
- * level for this tiled layer.
33
- *
34
- * @throws {Error} `object3d` must be a valid `THREE.Object3d`.
35
- */
36
- constructor(id, extent, object3d) {
37
- let config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
38
- const tms = CRS.formatToTms(extent.crs);
39
- if (!globalExtentTMS.get(extent.crs)) {
40
- // Add new global extent for this new crs projection.
41
- globalExtentTMS.set(extent.crs, extent);
42
- }
43
- config.tileMatrixSets = [tms];
44
- super(id, object3d || new THREE.Group(), [extent], new PlanarTileBuilder({
45
- crs: extent.crs
46
- }), config);
47
- this.isPlanarLayer = true;
48
- this.extent = extent;
49
- this.minSubdivisionLevel = this.minSubdivisionLevel == undefined ? 0 : this.minSubdivisionLevel;
50
- this.maxSubdivisionLevel = this.maxSubdivisionLevel == undefined ? 5 : this.maxSubdivisionLevel;
51
- }
52
- }
53
- export default PlanarLayer;
@@ -1,72 +0,0 @@
1
- import * as THREE from 'three';
2
- import Coordinates from "../../Geographic/Coordinates.js";
3
- import Extent from "../../Geographic/Extent.js";
4
- const quaternion = new THREE.Quaternion();
5
- const center = new THREE.Vector3();
6
- class PlanarTileBuilder {
7
- constructor() {
8
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9
- /* istanbul ignore next */
10
- if (options.projection) {
11
- console.warn('PlanarTileBuilder projection parameter is deprecated, use crs instead.');
12
- options.crs = options.crs || options.projection;
13
- }
14
- if (options.crs) {
15
- this.crs = options.crs;
16
- } else {
17
- throw new Error('options.crs is mandatory for PlanarTileBuilder');
18
- }
19
- this.tmp = {
20
- coords: new Coordinates('EPSG:4326', 0, 0),
21
- position: new THREE.Vector3(),
22
- normal: new THREE.Vector3(0, 0, 1)
23
- };
24
- this.uvCount = options.uvCount || 1;
25
- }
26
- // prepare params
27
- // init projected object -> params.projected
28
- prepare(params) {
29
- params.nbRow = 2 ** (params.zoom + 1.0);
30
- params.projected = new THREE.Vector3();
31
- }
32
-
33
- // get center tile in cartesian 3D
34
- center(extent) {
35
- extent.center(this.tmp.coords);
36
- center.set(this.tmp.coords.x, this.tmp.coords.y, 0);
37
- return center;
38
- }
39
-
40
- // get position 3D cartesian
41
- vertexPosition(params) {
42
- this.tmp.position.set(params.projected.x, params.projected.y, 0);
43
- return this.tmp.position;
44
- }
45
-
46
- // get normal for last vertex
47
- vertexNormal() {
48
- return this.tmp.normal;
49
- }
50
-
51
- // coord u tile to projected
52
- uProjecte(u, params) {
53
- params.projected.x = params.extent.west + u * (params.extent.east - params.extent.west);
54
- }
55
-
56
- // coord v tile to projected
57
- vProjecte(v, params) {
58
- params.projected.y = params.extent.south + v * (params.extent.north - params.extent.south);
59
- }
60
- computeSharableExtent(extent) {
61
- // compute sharable extent to pool the geometries
62
- // the geometry in common extent is identical to the existing input
63
- // with a translation
64
- const sharableExtent = new Extent(extent.crs, 0, Math.abs(extent.west - extent.east), 0, Math.abs(extent.north - extent.south));
65
- return {
66
- sharableExtent,
67
- quaternion,
68
- position: this.center(extent).clone()
69
- };
70
- }
71
- }
72
- export default PlanarTileBuilder;
@@ -1,62 +0,0 @@
1
- import * as THREE from 'three';
2
- import View from "../View.js";
3
- import CameraUtils from "../../Utils/CameraUtils.js";
4
- import PlanarControls from "../../Controls/PlanarControls.js";
5
- import PlanarLayer from "./Planar/PlanarLayer.js";
6
- class PlanarView extends View {
7
- /**
8
- * @extends View
9
- *
10
- * @example <caption><b>Instance with placement on the ground.</b></caption>
11
- * var viewerDiv = document.getElementById('viewerDiv');
12
- * const extent = new Extent('EPSG:3946', 1837816.94334, 1847692.32501, 5170036.4587, 5178412.82698);
13
- * var view = new itowns.PlanarView(viewerDiv, extent, { placement: { heading: -49.6, range: 6200, tilt: 17 } });
14
- *
15
- * @param {HTMLDivElement} viewerDiv - Where to attach the view and display it
16
- * in the DOM.
17
- * @param {Extent} extent - The ground extent.
18
- * @param {Object} [options] - See options of {@link View}.
19
- * @param {boolean} [options.noControls=false] - If true, no controls are associated to the view.
20
- * @param {Object} [options.controls] - options for the {@link PlanarControls} associated to the view, if
21
- * `options.noControls` is false.
22
- * @param {CameraUtils~CameraTransformOptions|Extent} [options.placement] - The
23
- * {@link CameraUtils~CameraTransformOptions} to apply to view's camera or the extent it must display at
24
- * initialization. By default, camera will display the view's extent (given in `extent` parameter).
25
- */
26
- constructor(viewerDiv, extent) {
27
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
28
- THREE.Object3D.DEFAULT_UP.set(0, 0, 1);
29
-
30
- // Setup View
31
- super(extent.crs, viewerDiv, options);
32
- this.isPlanarView = true;
33
-
34
- // Configure camera
35
- const dim = extent.planarDimensions();
36
- const max = Math.max(dim.x, dim.y);
37
- this.camera3D.near = 0.1;
38
- this.camera3D.far = this.camera3D.isOrthographicCamera ? 2000 : 2 * max;
39
- this.camera3D.updateProjectionMatrix();
40
- const tileLayer = new PlanarLayer('planar', extent, options.object3d, options);
41
- this.mainLoop.gfxEngine.label2dRenderer.infoTileLayer = tileLayer.info;
42
- this.addLayer(tileLayer);
43
-
44
- // Configure camera
45
- const placement = options.placement || {};
46
- if (!placement.isExtent) {
47
- placement.coord = placement.coord || extent.center();
48
- placement.tilt = placement.tilt || 90;
49
- placement.heading = placement.heading || 0;
50
- placement.range = placement.range || max;
51
- }
52
- CameraUtils.transformCameraToLookAtTarget(this, this.camera3D, placement);
53
- if (!options.noControls) {
54
- this.controls = new PlanarControls(this, options.controls);
55
- }
56
- this.tileLayer = tileLayer;
57
- }
58
- addLayer(layer) {
59
- return super.addLayer(layer, this.tileLayer);
60
- }
61
- }
62
- export default PlanarView;
@@ -1,80 +0,0 @@
1
- import * as THREE from 'three';
2
- import TileGeometry from "../TileGeometry.js";
3
- import Cache from "../Scheduler/Cache.js";
4
- import computeBuffers from "./computeBufferTileGeometry.js";
5
- import OBB from "../../Renderer/OBB.js";
6
- const cacheBuffer = new Map();
7
- const cacheTile = new Cache();
8
- export default function newTileGeometry(builder, params) {
9
- const {
10
- sharableExtent,
11
- quaternion,
12
- position
13
- } = builder.computeSharableExtent(params.extent);
14
- const south = sharableExtent.south.toFixed(6);
15
- const bufferKey = `${builder.crs}_${params.disableSkirt ? 0 : 1}_${params.segments}`;
16
- let promiseGeometry = cacheTile.get(south, params.level, bufferKey);
17
-
18
- // build geometry if doesn't exist
19
- if (!promiseGeometry) {
20
- let resolve;
21
- promiseGeometry = new Promise(r => {
22
- resolve = r;
23
- });
24
- cacheTile.set(promiseGeometry, south, params.level, bufferKey);
25
- params.extent = sharableExtent;
26
- params.center = builder.center(params.extent).clone();
27
- // Read previously cached values (index and uv.wgs84 only depend on the # of triangles)
28
- let cachedBuffers = cacheBuffer.get(bufferKey);
29
- params.buildIndexAndUv_0 = !cachedBuffers;
30
- params.builder = builder;
31
- let buffers;
32
- try {
33
- buffers = computeBuffers(params);
34
- } catch (e) {
35
- return Promise.reject(e);
36
- }
37
- if (!cachedBuffers) {
38
- cachedBuffers = {};
39
- cachedBuffers.index = new THREE.BufferAttribute(buffers.index, 1);
40
- cachedBuffers.uv = new THREE.BufferAttribute(buffers.uvs[0], 2);
41
-
42
- // Update cacheBuffer
43
- cacheBuffer.set(bufferKey, cachedBuffers);
44
- }
45
- buffers.index = cachedBuffers.index;
46
- buffers.uvs[0] = cachedBuffers.uv;
47
- buffers.position = new THREE.BufferAttribute(buffers.position, 3);
48
- buffers.normal = new THREE.BufferAttribute(buffers.normal, 3);
49
- if (params.builder.uvCount > 1) {
50
- buffers.uvs[1] = new THREE.BufferAttribute(buffers.uvs[1], 1);
51
- }
52
- const geometry = new TileGeometry(params, buffers);
53
- geometry.OBB = new OBB(geometry.boundingBox.min, geometry.boundingBox.max);
54
- geometry._count = 0;
55
- geometry.dispose = () => {
56
- geometry._count--;
57
- if (geometry._count <= 0) {
58
- // To avoid remove index buffer and attribute buffer uv
59
- // error un-bound buffer in webgl with VAO rendering.
60
- // Could be removed if the attribute buffer deleting is
61
- // taken into account in the buffer binding state (in THREE.WebGLBindingStates code).
62
- geometry.index = null;
63
- delete geometry.attributes.uv;
64
- THREE.BufferGeometry.prototype.dispose.call(geometry);
65
- cacheTile.delete(south, params.level, bufferKey);
66
- }
67
- };
68
- resolve(geometry);
69
- return Promise.resolve({
70
- geometry,
71
- quaternion,
72
- position
73
- });
74
- }
75
- return promiseGeometry.then(geometry => ({
76
- geometry,
77
- quaternion,
78
- position
79
- }));
80
- }