itowns 2.44.3-next.40 → 2.44.3-next.42

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 (199) hide show
  1. package/README.md +3 -129
  2. package/package.json +16 -72
  3. package/CODING.md +0 -120
  4. package/CONTRIBUTING.md +0 -150
  5. package/CONTRIBUTORS.md +0 -56
  6. package/LICENSE.md +0 -44
  7. package/changelog.md +0 -1361
  8. package/dist/455.js +0 -2
  9. package/dist/455.js.map +0 -1
  10. package/dist/debug.js +0 -3
  11. package/dist/debug.js.LICENSE.txt +0 -13
  12. package/dist/debug.js.map +0 -1
  13. package/dist/itowns.js +0 -3
  14. package/dist/itowns.js.LICENSE.txt +0 -5
  15. package/dist/itowns.js.map +0 -1
  16. package/dist/itowns_lasparser.js +0 -2
  17. package/dist/itowns_lasparser.js.map +0 -1
  18. package/dist/itowns_lasworker.js +0 -2
  19. package/dist/itowns_lasworker.js.map +0 -1
  20. package/dist/itowns_potree2worker.js +0 -2
  21. package/dist/itowns_potree2worker.js.map +0 -1
  22. package/dist/itowns_widgets.js +0 -2
  23. package/dist/itowns_widgets.js.map +0 -1
  24. package/examples/.eslintrc.cjs +0 -35
  25. package/examples/jsm/.eslintrc.cjs +0 -38
  26. package/lib/Controls/FirstPersonControls.js +0 -308
  27. package/lib/Controls/FlyControls.js +0 -175
  28. package/lib/Controls/GlobeControls.js +0 -1179
  29. package/lib/Controls/PlanarControls.js +0 -1025
  30. package/lib/Controls/StateControl.js +0 -432
  31. package/lib/Controls/StreetControls.js +0 -392
  32. package/lib/Converter/Feature2Mesh.js +0 -614
  33. package/lib/Converter/Feature2Texture.js +0 -175
  34. package/lib/Converter/convertToTile.js +0 -70
  35. package/lib/Converter/textureConverter.js +0 -43
  36. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  37. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  38. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  39. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  40. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  41. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  42. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  43. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  44. package/lib/Core/AnimationPlayer.js +0 -142
  45. package/lib/Core/CopcNode.js +0 -174
  46. package/lib/Core/Deprecated/Undeprecator.js +0 -74
  47. package/lib/Core/EntwinePointTileNode.js +0 -126
  48. package/lib/Core/Feature.js +0 -489
  49. package/lib/Core/Geographic/CoordStars.js +0 -80
  50. package/lib/Core/Geographic/Coordinates.js +0 -331
  51. package/lib/Core/Geographic/Crs.js +0 -170
  52. package/lib/Core/Geographic/Extent.js +0 -550
  53. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  54. package/lib/Core/Label.js +0 -222
  55. package/lib/Core/MainLoop.js +0 -209
  56. package/lib/Core/Math/Ellipsoid.js +0 -185
  57. package/lib/Core/Picking.js +0 -255
  58. package/lib/Core/PointCloudNode.js +0 -42
  59. package/lib/Core/Potree2Node.js +0 -206
  60. package/lib/Core/Potree2PointAttributes.js +0 -139
  61. package/lib/Core/PotreeNode.js +0 -101
  62. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -295
  63. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -152
  64. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +0 -111
  65. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  66. package/lib/Core/Prefab/GlobeView.js +0 -156
  67. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -59
  68. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  69. package/lib/Core/Prefab/PlanarView.js +0 -62
  70. package/lib/Core/Prefab/TileBuilder.js +0 -82
  71. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -248
  72. package/lib/Core/Scheduler/Cache.js +0 -17
  73. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  74. package/lib/Core/Scheduler/Scheduler.js +0 -294
  75. package/lib/Core/Style.js +0 -660
  76. package/lib/Core/StyleOptions.js +0 -486
  77. package/lib/Core/System/Capabilities.js +0 -63
  78. package/lib/Core/Tile/Tile.js +0 -207
  79. package/lib/Core/Tile/TileGrid.js +0 -49
  80. package/lib/Core/TileGeometry.js +0 -124
  81. package/lib/Core/TileMesh.js +0 -108
  82. package/lib/Core/View.js +0 -1116
  83. package/lib/Layer/C3DTilesLayer.js +0 -459
  84. package/lib/Layer/ColorLayer.js +0 -154
  85. package/lib/Layer/CopcLayer.js +0 -63
  86. package/lib/Layer/ElevationLayer.js +0 -139
  87. package/lib/Layer/EntwinePointTileLayer.js +0 -71
  88. package/lib/Layer/FeatureGeometryLayer.js +0 -77
  89. package/lib/Layer/GeoidLayer.js +0 -80
  90. package/lib/Layer/GeometryLayer.js +0 -233
  91. package/lib/Layer/InfoLayer.js +0 -64
  92. package/lib/Layer/LabelLayer.js +0 -470
  93. package/lib/Layer/Layer.js +0 -335
  94. package/lib/Layer/LayerUpdateState.js +0 -89
  95. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  96. package/lib/Layer/OGC3DTilesLayer.js +0 -543
  97. package/lib/Layer/OrientedImageLayer.js +0 -228
  98. package/lib/Layer/PointCloudLayer.js +0 -405
  99. package/lib/Layer/Potree2Layer.js +0 -171
  100. package/lib/Layer/PotreeLayer.js +0 -72
  101. package/lib/Layer/RasterLayer.js +0 -37
  102. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  103. package/lib/Layer/TiledGeometryLayer.js +0 -459
  104. package/lib/Loader/LASLoader.js +0 -193
  105. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  106. package/lib/Loader/Potree2Loader.js +0 -207
  107. package/lib/Main.js +0 -115
  108. package/lib/MainBundle.js +0 -4
  109. package/lib/Parser/B3dmParser.js +0 -174
  110. package/lib/Parser/CameraCalibrationParser.js +0 -94
  111. package/lib/Parser/GDFParser.js +0 -72
  112. package/lib/Parser/GTXParser.js +0 -75
  113. package/lib/Parser/GeoJsonParser.js +0 -212
  114. package/lib/Parser/GpxParser.js +0 -25
  115. package/lib/Parser/ISGParser.js +0 -71
  116. package/lib/Parser/KMLParser.js +0 -25
  117. package/lib/Parser/LASParser.js +0 -137
  118. package/lib/Parser/MapBoxUrlParser.js +0 -83
  119. package/lib/Parser/PntsParser.js +0 -131
  120. package/lib/Parser/Potree2BinParser.js +0 -92
  121. package/lib/Parser/PotreeBinParser.js +0 -106
  122. package/lib/Parser/PotreeCinParser.js +0 -29
  123. package/lib/Parser/ShapefileParser.js +0 -78
  124. package/lib/Parser/VectorTileParser.js +0 -215
  125. package/lib/Parser/XbilParser.js +0 -120
  126. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  127. package/lib/Parser/iGLTFLoader.js +0 -168
  128. package/lib/Process/3dTilesProcessing.js +0 -304
  129. package/lib/Process/FeatureProcessing.js +0 -76
  130. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  131. package/lib/Process/ObjectRemovalHelper.js +0 -97
  132. package/lib/Process/handlerNodeError.js +0 -23
  133. package/lib/Provider/3dTilesProvider.js +0 -149
  134. package/lib/Provider/DataSourceProvider.js +0 -8
  135. package/lib/Provider/Fetcher.js +0 -233
  136. package/lib/Provider/PointCloudProvider.js +0 -45
  137. package/lib/Provider/TileProvider.js +0 -16
  138. package/lib/Provider/URLBuilder.js +0 -116
  139. package/lib/Renderer/Camera.js +0 -281
  140. package/lib/Renderer/Color.js +0 -56
  141. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  142. package/lib/Renderer/CommonMaterial.js +0 -31
  143. package/lib/Renderer/Label2DRenderer.js +0 -192
  144. package/lib/Renderer/LayeredMaterial.js +0 -243
  145. package/lib/Renderer/OBB.js +0 -151
  146. package/lib/Renderer/OrientedImageCamera.js +0 -118
  147. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  148. package/lib/Renderer/PointsMaterial.js +0 -485
  149. package/lib/Renderer/RasterTile.js +0 -208
  150. package/lib/Renderer/RenderMode.js +0 -31
  151. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  152. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  153. package/lib/Renderer/SphereHelper.js +0 -17
  154. package/lib/Renderer/WebXR.js +0 -51
  155. package/lib/Renderer/c3DEngine.js +0 -214
  156. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  157. package/lib/Source/C3DTilesIonSource.js +0 -54
  158. package/lib/Source/C3DTilesSource.js +0 -30
  159. package/lib/Source/CopcSource.js +0 -126
  160. package/lib/Source/EntwinePointTileSource.js +0 -72
  161. package/lib/Source/FileSource.js +0 -188
  162. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  163. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  164. package/lib/Source/OGC3DTilesSource.js +0 -21
  165. package/lib/Source/OrientedImageSource.js +0 -59
  166. package/lib/Source/Potree2Source.js +0 -167
  167. package/lib/Source/PotreeSource.js +0 -82
  168. package/lib/Source/Source.js +0 -203
  169. package/lib/Source/TMSSource.js +0 -144
  170. package/lib/Source/VectorTilesSource.js +0 -182
  171. package/lib/Source/WFSSource.js +0 -170
  172. package/lib/Source/WMSSource.js +0 -168
  173. package/lib/Source/WMTSSource.js +0 -92
  174. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  175. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -506
  176. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  177. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  178. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -400
  179. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2879
  180. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -709
  181. package/lib/ThreeExtended/math/ColorSpaces.js +0 -59
  182. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  183. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  184. package/lib/Utils/CameraUtils.js +0 -555
  185. package/lib/Utils/DEMUtils.js +0 -350
  186. package/lib/Utils/FeaturesUtils.js +0 -156
  187. package/lib/Utils/Gradients.js +0 -16
  188. package/lib/Utils/OrientationUtils.js +0 -457
  189. package/lib/Utils/ThreeUtils.js +0 -115
  190. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  191. package/lib/Utils/gui/Main.js +0 -7
  192. package/lib/Utils/gui/Minimap.js +0 -154
  193. package/lib/Utils/gui/Navigation.js +0 -245
  194. package/lib/Utils/gui/Scale.js +0 -107
  195. package/lib/Utils/gui/Searchbar.js +0 -234
  196. package/lib/Utils/gui/Widget.js +0 -80
  197. package/lib/Utils/placeObjectOnGround.js +0 -136
  198. package/lib/Worker/LASLoaderWorker.js +0 -19
  199. 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,156 +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 { ellipsoidSizes } from "../Math/Ellipsoid.js";
9
-
10
- /**
11
- * Fires when the view is completely loaded. Controls and view's functions can be called then.
12
- * @event GlobeView#initialized
13
- * @property target {view} dispatched on view
14
- * @property type {string} initialized
15
- */
16
- /**
17
- * Fires when a layer is added
18
- * @event GlobeView#layer-added
19
- * @property layerId {string} the id of the layer
20
- * @property target {view} dispatched on view
21
- * @property type {string} layers-added
22
- */
23
- /**
24
- * Fires when a layer is removed
25
- * @event GlobeView#layer-removed
26
- * @property layerId {string} the id of the layer
27
- * @property target {view} dispatched on view
28
- * @property type {string} layers-added
29
- */
30
- /**
31
- * Fires when the layers oder has changed
32
- * @event GlobeView#layers-order-changed
33
- * @property new {object}
34
- * @property new.sequence {array}
35
- * @property new.sequence.0 {number} the new layer at position 0
36
- * @property new.sequence.1 {number} the new layer at position 1
37
- * @property new.sequence.2 {number} the new layer at position 2
38
- * @property previous {object}
39
- * @property previous.sequence {array}
40
- * @property previous.sequence.0 {number} the previous layer at position 0
41
- * @property previous.sequence.1 {number} the previous layer at position 1
42
- * @property previous.sequence.2 {number} the previous layer at position 2
43
- * @property target {view} dispatched on view
44
- * @property type {string} layers-order-changed
45
- */
46
-
47
- /**
48
- * Globe's EVENT
49
- * @property GLOBE_INITIALIZED {string} Deprecated: emit one time when globe is initialized (use VIEW_EVENTS.INITIALIZED instead).
50
- * @property LAYER_ADDED {string} Deprecated: emit when layer id added in viewer (use VIEW_EVENTS.LAYER_ADDED instead).
51
- * @property LAYER_REMOVED {string} Deprecated: emit when layer id removed in viewer (use VIEW_EVENTS.LAYER_REMOVED instead).
52
- * @property COLOR_LAYERS_ORDER_CHANGED {string} Deprecated: emit when color layers order change (use VIEW_EVENTS.COLOR_LAYERS_ORDER_CHANGED instead).
53
- */
54
-
55
- export const GLOBE_VIEW_EVENTS = {
56
- GLOBE_INITIALIZED: VIEW_EVENTS.INITIALIZED,
57
- LAYER_ADDED: VIEW_EVENTS.LAYER_ADDED,
58
- LAYER_REMOVED: VIEW_EVENTS.LAYER_REMOVED,
59
- COLOR_LAYERS_ORDER_CHANGED: VIEW_EVENTS.COLOR_LAYERS_ORDER_CHANGED
60
- };
61
- class GlobeView extends View {
62
- /**
63
- * Creates a view of a globe.
64
- *
65
- * @extends View
66
- *
67
- * @example <caption><b>Instance GlobeView.</b></caption>
68
- * var viewerDiv = document.getElementById('viewerDiv');
69
- * const placement = {
70
- * coord: new itowns.Coordinates('EPSG:4326', 2.351323, 48.856712),
71
- * range: 25000000,
72
- * }
73
- * var view = new itowns.GlobeView(viewerDiv, placement);
74
- *
75
- * @param {HTMLDivElement} viewerDiv - Where to attach the view and display it
76
- * in the DOM.
77
- * @param {CameraTransformOptions|Extent} placement - An object to place view
78
- * @param {object} [options] - See options of {@link View}.
79
- * @param {Object} [options.controls] - See options of {@link GlobeControls}
80
- */
81
- constructor(viewerDiv) {
82
- let placement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
83
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
84
- THREE.Object3D.DEFAULT_UP.set(0, 0, 1);
85
- // Setup View
86
- super('EPSG:4978', viewerDiv, options);
87
- this.isGlobeView = true;
88
- this.camera3D.near = Math.max(15.0, 0.000002352 * ellipsoidSizes.x);
89
- this.camera3D.far = ellipsoidSizes.x * 10;
90
- const tileLayer = new GlobeLayer('globe', options.object3d, options);
91
- this.mainLoop.gfxEngine.label2dRenderer.infoTileLayer = tileLayer.info;
92
- this.addLayer(tileLayer);
93
- this.tileLayer = tileLayer;
94
- if (!placement.isExtent) {
95
- placement.coord = placement.coord || new Coordinates('EPSG:4326', 0, 0);
96
- placement.tilt = placement.tilt || 89.5;
97
- placement.heading = placement.heading || 0;
98
- placement.range = placement.range || ellipsoidSizes.x * 2.0;
99
- }
100
- if (options.noControls) {
101
- CameraUtils.transformCameraToLookAtTarget(this, this.camera3D, placement);
102
- } else {
103
- this.controls = new GlobeControls(this, placement, options.controls);
104
- this.controls.handleCollision = typeof options.handleCollision !== 'undefined' ? options.handleCollision : true;
105
- }
106
- this.addLayer(new Atmosphere('atmosphere', options.atmosphere));
107
-
108
- // GlobeView needs this.camera.resize to set perpsective matrix camera
109
- this.camera.resize(viewerDiv.clientWidth, viewerDiv.clientHeight);
110
- }
111
-
112
- /**
113
- * Add layer in viewer.
114
- * The layer id must be unique.
115
- *
116
- * The `layer.whenReady` is a promise that resolves when
117
- * the layer is done. This promise is also returned by
118
- * `addLayer` allowing to chain call.
119
- *
120
- * The layer added is attached, by default to `GlobeLayer` (`GlobeView.tileLayer`).
121
- * If you want add a unattached layer use `View#addLayer` parent method.
122
- *
123
- * @param {LayerOptions|Layer|GeometryLayer} layer The layer to add in view.
124
- * @return {Promise} a promise resolved with the new layer object when it is fully initialized or rejected if any error occurred.
125
- */
126
- addLayer(layer) {
127
- if (!layer || !layer.isLayer) {
128
- return Promise.reject(new Error('Add Layer type object'));
129
- }
130
- if (layer.isColorLayer) {
131
- if (!this.tileLayer.tileMatrixSets.includes(layer.source.crs)) {
132
- return layer._reject(`Only ${this.tileLayer.tileMatrixSets} tileMatrixSet are currently supported for color layers`);
133
- }
134
- } else if (layer.isElevationLayer) {
135
- if (layer.source.crs !== this.tileLayer.tileMatrixSets[0]) {
136
- return layer._reject(`Only ${this.tileLayer.tileMatrixSets[0]} tileMatrixSet is currently supported for elevation layers`);
137
- }
138
- }
139
- return super.addLayer(layer, this.tileLayer);
140
- }
141
- getPixelsToDegrees() {
142
- let pixels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
143
- let screenCoord = arguments.length > 1 ? arguments[1] : undefined;
144
- return this.getMetersToDegrees(this.getPixelsToMeters(pixels, screenCoord));
145
- }
146
- getPixelsToDegreesFromDistance() {
147
- let pixels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
148
- let distance = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
149
- return this.getMetersToDegrees(this.getPixelsToMetersFromDistance(pixels, distance));
150
- }
151
- getMetersToDegrees() {
152
- let meters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
153
- return THREE.MathUtils.radToDeg(2 * Math.asin(meters / (2 * ellipsoidSizes.x)));
154
- }
155
- }
156
- export default GlobeView;
@@ -1,59 +0,0 @@
1
- import * as THREE from 'three';
2
- import TiledGeometryLayer from "../../../Layer/TiledGeometryLayer.js";
3
- import { globalExtentTMS } from "../../Tile/TileGrid.js";
4
- import { PlanarTileBuilder } from "./PlanarTileBuilder.js";
5
-
6
- /**
7
- * @property {boolean} isPlanarLayer - Used to checkout whether this layer is a
8
- * PlanarLayer. Default is true. You should not change this, as it is used
9
- * internally for optimisation.
10
- * @extends TiledGeometryLayer
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
- * @param {string} id - The id of the layer, that should be unique. It is
18
- * not mandatory, but an error will be emitted if this layer is added a
19
- * {@link View} that already has a layer going by that id.
20
- * @param {Extent} extent - The extent to define the layer within.
21
- * @param {THREE.Object3d} [object3d=THREE.Group] - The object3d used to
22
- * contain the geometry of the TiledGeometryLayer. It is usually a
23
- * `THREE.Group`, but it can be anything inheriting from a `THREE.Object3d`.
24
- * @param {Object} [config] - Optional configuration, all elements in it
25
- * will be merged as is in the layer. For example, if the configuration
26
- * contains three elements `name, protocol, extent`, these elements will be
27
- * available using `layer.name` or something else depending on the property
28
- * name.
29
- * @param {number} [config.maxSubdivisionLevel=5] - Maximum subdivision
30
- * level for this tiled layer.
31
- *
32
- * @throws {Error} `object3d` must be a valid `THREE.Object3d`.
33
- */
34
- constructor(id, extent, object3d) {
35
- let config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
36
- const {
37
- minSubdivisionLevel = 0,
38
- maxSubdivisionLevel = 5,
39
- ...tiledConfig
40
- } = config;
41
- const tileMatrixSets = [extent.crs];
42
- if (!globalExtentTMS.get(extent.crs)) {
43
- // Add new global extent for this new crs projection.
44
- globalExtentTMS.set(extent.crs, extent);
45
- }
46
- const builder = new PlanarTileBuilder({
47
- crs: extent.crs
48
- });
49
- super(id, object3d || new THREE.Group(), [extent], builder, {
50
- tileMatrixSets,
51
- ...tiledConfig
52
- });
53
- this.isPlanarLayer = true;
54
- this.extent = extent;
55
- this.minSubdivisionLevel = minSubdivisionLevel;
56
- this.maxSubdivisionLevel = maxSubdivisionLevel;
57
- }
58
- }
59
- 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
-
7
- /** Specialized parameters for the [PlanarTileBuilder]. */
8
-
9
- /**
10
- * TileBuilder implementation for the purpose of generating planar
11
- * tile arrangements.
12
- */
13
- export class PlanarTileBuilder {
14
- constructor(options) {
15
- if (options.projection) {
16
- console.warn('PlanarTileBuilder projection parameter is deprecated,' + ' use crs instead.');
17
- options.crs ??= options.projection;
18
- }
19
- this._crs = options.crs;
20
- this._transform = {
21
- coords: new Coordinates('EPSG:4326', 0, 0),
22
- position: new THREE.Vector3(),
23
- normal: new THREE.Vector3(0, 0, 1)
24
- };
25
- this._uvCount = options.uvCount ?? 1;
26
- }
27
- get uvCount() {
28
- return this._uvCount;
29
- }
30
- get crs() {
31
- return this._crs;
32
- }
33
- prepare(params) {
34
- const newParams = params;
35
- newParams.nbRow = 2 ** (params.level + 1.0);
36
- newParams.coordinates = new Coordinates(this.crs);
37
- return newParams;
38
- }
39
- center(extent) {
40
- extent.center(this._transform.coords);
41
- center.set(this._transform.coords.x, this._transform.coords.y, 0);
42
- return center;
43
- }
44
- vertexPosition(coordinates) {
45
- this._transform.position.set(coordinates.x, coordinates.y, 0);
46
- return this._transform.position;
47
- }
48
- vertexNormal() {
49
- return this._transform.normal;
50
- }
51
- uProject(u, extent) {
52
- return extent.west + u * (extent.east - extent.west);
53
- }
54
- vProject(v, extent) {
55
- return extent.south + v * (extent.north - extent.south);
56
- }
57
- computeShareableExtent(extent) {
58
- // compute shareable extent to pool the geometries
59
- // the geometry in common extent is identical to the existing input
60
- // with a translation
61
- return {
62
- shareableExtent: new Extent(extent.crs).setFromExtent({
63
- west: 0,
64
- east: Math.abs(extent.west - extent.east),
65
- south: 0,
66
- north: Math.abs(extent.north - extent.south)
67
- }),
68
- quaternion,
69
- position: this.center(extent).clone()
70
- };
71
- }
72
- }
@@ -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,82 +0,0 @@
1
- import * as THREE from 'three';
2
- import { TileGeometry } from "../TileGeometry.js";
3
- import { LRUCache } from 'lru-cache';
4
- import { computeBuffers } from "./computeBufferTileGeometry.js";
5
- import OBB from "../../Renderer/OBB.js";
6
- const cacheBuffer = new Map();
7
- const cacheTile = new LRUCache({
8
- max: 500
9
- });
10
-
11
- /**
12
- * Reference to a tile's extent with rigid transformations.
13
- * Enables reuse of geometry, saving a bit of memory.
14
- */
15
-
16
- export function newTileGeometry(builder, params) {
17
- const {
18
- shareableExtent,
19
- quaternion,
20
- position
21
- } = builder.computeShareableExtent(params.extent);
22
- const south = shareableExtent.south.toFixed(6);
23
- const bufferKey = `${builder.crs}_${params.disableSkirt ? 0 : 1}_${params.segments}`;
24
- const key = `s${south}l${params.level}bK${bufferKey}`;
25
- let promiseGeometry = cacheTile.get(key);
26
-
27
- // build geometry if doesn't exist
28
- if (!promiseGeometry) {
29
- let resolve;
30
- promiseGeometry = new Promise(r => {
31
- resolve = r;
32
- });
33
- cacheTile.set(key, promiseGeometry);
34
- params.extent = shareableExtent;
35
- params.center = builder.center(params.extent).clone();
36
- // Read previously cached values (index and uv.wgs84 only
37
- // depend on the # of triangles)
38
- let cachedBuffers = cacheBuffer.get(bufferKey);
39
- let buffers;
40
- try {
41
- buffers = computeBuffers(builder, params, cachedBuffers !== undefined ? {
42
- index: cachedBuffers.index.array,
43
- uv: cachedBuffers.uv.array
44
- } : undefined);
45
- } catch (e) {
46
- return Promise.reject(e);
47
- }
48
- if (!cachedBuffers) {
49
- // We know the fields will exist due to the condition
50
- // matching with the one for buildIndexAndUv_0.
51
- // TODO: Make this brain-based check compiler-based.
52
-
53
- cachedBuffers = {
54
- index: new THREE.BufferAttribute(buffers.index, 1),
55
- uv: new THREE.BufferAttribute(buffers.uvs[0], 2)
56
- };
57
-
58
- // Update cacheBuffer
59
- cacheBuffer.set(bufferKey, cachedBuffers);
60
- }
61
- const gpuBuffers = {
62
- index: cachedBuffers.index,
63
- uvs: [cachedBuffers.uv, ...(buffers.uvs[1] !== undefined ? [new THREE.BufferAttribute(buffers.uvs[1], 1)] : [])],
64
- position: new THREE.BufferAttribute(buffers.position, 3),
65
- normal: new THREE.BufferAttribute(buffers.normal, 3)
66
- };
67
- const geometry = new TileGeometry(builder, params, gpuBuffers);
68
- geometry.OBB = new OBB(geometry.boundingBox.min, geometry.boundingBox.max);
69
- geometry.initRefCount(cacheTile, key);
70
- resolve(geometry);
71
- return Promise.resolve({
72
- geometry,
73
- quaternion,
74
- position
75
- });
76
- }
77
- return promiseGeometry.then(geometry => ({
78
- geometry,
79
- quaternion,
80
- position
81
- }));
82
- }