itowns 2.45.1 → 2.45.2-next.1

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 (224) hide show
  1. package/dist/455.js +1 -1
  2. package/dist/455.js.map +1 -1
  3. package/dist/debug.js +1 -1
  4. package/dist/debug.js.LICENSE.txt +8 -2
  5. package/dist/debug.js.map +1 -1
  6. package/dist/itowns.js +1 -1
  7. package/dist/itowns.js.LICENSE.txt +1 -1
  8. package/dist/itowns.js.map +1 -1
  9. package/dist/itowns_lasparser.js +1 -1
  10. package/dist/itowns_lasparser.js.map +1 -1
  11. package/dist/itowns_lasworker.js +1 -1
  12. package/dist/itowns_lasworker.js.map +1 -1
  13. package/dist/itowns_potree2worker.js +1 -1
  14. package/dist/itowns_potree2worker.js.map +1 -1
  15. package/dist/itowns_widgets.js +1 -1
  16. package/dist/itowns_widgets.js.map +1 -1
  17. package/examples/copc_simple_loader.html +3 -3
  18. package/examples/entwine_3d_loader.html +2 -2
  19. package/examples/entwine_simple_loader.html +10 -6
  20. package/examples/potree2_25d_map.html +2 -2
  21. package/examples/potree_25d_map.html +2 -2
  22. package/examples/potree_3d_map.html +2 -2
  23. package/examples/view_3d_map_webxr.html +2 -5
  24. package/lib/Controls/FirstPersonControls.d.ts +90 -0
  25. package/lib/Controls/FlyControls.d.ts +36 -0
  26. package/lib/Controls/GlobeControls.d.ts +274 -0
  27. package/lib/Controls/PlanarControls.d.ts +339 -0
  28. package/lib/Controls/StateControl.d.ts +140 -0
  29. package/lib/Controls/StreetControls.d.ts +134 -0
  30. package/lib/Controls/VRControls.d.ts +56 -0
  31. package/lib/Controls/VRControls.js +409 -0
  32. package/lib/Converter/Feature2Mesh.d.ts +42 -0
  33. package/lib/Converter/Feature2Texture.d.ts +5 -0
  34. package/lib/Converter/convertToTile.d.ts +5 -0
  35. package/lib/Converter/convertToTile.js +2 -2
  36. package/lib/Converter/textureConverter.d.ts +4 -0
  37. package/lib/Core/3DTiles/C3DTBatchTable.d.ts +49 -0
  38. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.d.ts +37 -0
  39. package/lib/Core/3DTiles/C3DTBoundingVolume.d.ts +39 -0
  40. package/lib/Core/3DTiles/C3DTExtensions.d.ts +75 -0
  41. package/lib/Core/3DTiles/C3DTFeature.d.ts +47 -0
  42. package/lib/Core/3DTiles/C3DTilesEnums.d.ts +14 -0
  43. package/lib/Core/3DTiles/C3DTileset.d.ts +46 -0
  44. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.d.ts +14 -0
  45. package/lib/Core/AnimationPlayer.d.ts +53 -0
  46. package/lib/Core/CopcNode.d.ts +68 -0
  47. package/lib/Core/CopcNode.js +57 -74
  48. package/lib/Core/Deprecated/Undeprecator.d.ts +6 -0
  49. package/lib/Core/EntwinePointTileNode.d.ts +59 -0
  50. package/lib/Core/EntwinePointTileNode.js +16 -41
  51. package/lib/Core/Feature.d.ts +323 -0
  52. package/lib/Core/Geographic/GeoidGrid.d.ts +86 -0
  53. package/lib/Core/Label.d.ts +86 -0
  54. package/lib/Core/MainLoop.d.ts +23 -0
  55. package/lib/Core/Picking.d.ts +6 -0
  56. package/lib/Core/Picking.js +4 -0
  57. package/lib/Core/PointCloudNode.d.ts +16 -0
  58. package/lib/Core/PointCloudNode.js +34 -4
  59. package/lib/Core/Potree2Node.d.ts +11 -0
  60. package/lib/Core/Potree2Node.js +5 -60
  61. package/lib/Core/Potree2PointAttributes.d.ts +97 -0
  62. package/lib/Core/PotreeNode.d.ts +14 -0
  63. package/lib/Core/PotreeNode.js +28 -18
  64. package/lib/Core/Prefab/Globe/Atmosphere.d.ts +66 -0
  65. package/lib/Core/Prefab/Globe/Atmosphere.js +10 -5
  66. package/lib/Core/Prefab/Globe/GlobeLayer.d.ts +48 -0
  67. package/lib/Core/Prefab/Globe/GlobeTileBuilder.d.ts +38 -0
  68. package/lib/Core/Prefab/Globe/SkyShader.d.ts +5 -0
  69. package/lib/Core/Prefab/Globe/SkyShader.js +3 -3
  70. package/lib/Core/Prefab/GlobeView.d.ts +65 -0
  71. package/lib/Core/Prefab/GlobeView.js +9 -0
  72. package/lib/Core/Prefab/Planar/PlanarLayer.d.ts +38 -0
  73. package/lib/Core/Prefab/Planar/PlanarTileBuilder.d.ts +32 -0
  74. package/lib/Core/Prefab/PlanarView.d.ts +33 -0
  75. package/lib/Core/Prefab/TileBuilder.d.ts +63 -0
  76. package/lib/Core/Prefab/computeBufferTileGeometry.d.ts +17 -0
  77. package/lib/Core/Scheduler/Cache.d.ts +25 -0
  78. package/lib/Core/Scheduler/CancelledCommandException.d.ts +12 -0
  79. package/lib/Core/Scheduler/Scheduler.d.ts +106 -0
  80. package/lib/Core/Style.d.ts +248 -0
  81. package/lib/Core/StyleOptions.d.ts +455 -0
  82. package/lib/Core/System/Capabilities.d.ts +9 -0
  83. package/lib/Core/Tile/Tile.d.ts +70 -0
  84. package/lib/Core/Tile/TileGrid.d.ts +12 -0
  85. package/lib/Core/TileGeometry.d.ts +46 -0
  86. package/lib/Core/TileMesh.d.ts +50 -0
  87. package/lib/Core/TileMesh.js +2 -4
  88. package/lib/Core/View.d.ts +403 -0
  89. package/lib/Core/View.js +1 -7
  90. package/lib/Layer/C3DTilesLayer.d.ts +140 -0
  91. package/lib/Layer/ColorLayer.d.ts +128 -0
  92. package/lib/Layer/ColorLayer.js +4 -4
  93. package/lib/Layer/CopcLayer.d.ts +42 -0
  94. package/lib/Layer/CopcLayer.js +3 -6
  95. package/lib/Layer/ElevationLayer.d.ts +96 -0
  96. package/lib/Layer/ElevationLayer.js +3 -3
  97. package/lib/Layer/EntwinePointTileLayer.d.ts +56 -0
  98. package/lib/Layer/EntwinePointTileLayer.js +4 -3
  99. package/lib/Layer/FeatureGeometryLayer.d.ts +62 -0
  100. package/lib/Layer/GeoidLayer.d.ts +41 -0
  101. package/lib/Layer/GeometryLayer.d.ts +120 -0
  102. package/lib/Layer/InfoLayer.d.ts +24 -0
  103. package/lib/Layer/InfoLayer.js +1 -1
  104. package/lib/Layer/LabelLayer.d.ts +93 -0
  105. package/lib/Layer/LabelLayer.js +2 -2
  106. package/lib/Layer/Layer.d.ts +185 -0
  107. package/lib/Layer/LayerUpdateState.d.ts +24 -0
  108. package/lib/Layer/LayerUpdateStrategy.d.ts +11 -0
  109. package/lib/Layer/LayerUpdateStrategy.js +2 -7
  110. package/lib/Layer/OGC3DTilesLayer.d.ts +277 -0
  111. package/lib/Layer/OGC3DTilesLayer.js +21 -0
  112. package/lib/Layer/OrientedImageLayer.d.ts +53 -0
  113. package/lib/Layer/PointCloudLayer.d.ts +103 -0
  114. package/lib/Layer/PointCloudLayer.js +8 -11
  115. package/lib/Layer/Potree2Layer.d.ts +56 -0
  116. package/lib/Layer/Potree2Layer.js +0 -2
  117. package/lib/Layer/PotreeLayer.d.ts +55 -0
  118. package/lib/Layer/RasterLayer.d.ts +8 -0
  119. package/lib/Layer/RasterLayer.js +2 -2
  120. package/lib/Layer/ReferencingLayerProperties.d.ts +2 -0
  121. package/lib/Layer/ReferencingLayerProperties.js +0 -12
  122. package/lib/Layer/TiledGeometryLayer.d.ts +192 -0
  123. package/lib/Layer/TiledGeometryLayer.js +4 -3
  124. package/lib/Main.d.ts +89 -0
  125. package/lib/Main.js +3 -1
  126. package/lib/Parser/B3dmParser.d.ts +26 -0
  127. package/lib/Parser/CameraCalibrationParser.d.ts +32 -0
  128. package/lib/Parser/GDFParser.d.ts +24 -0
  129. package/lib/Parser/GTXParser.d.ts +28 -0
  130. package/lib/Parser/GeoJsonParser.d.ts +12 -0
  131. package/lib/Parser/GpxParser.d.ts +12 -0
  132. package/lib/Parser/ISGParser.d.ts +23 -0
  133. package/lib/Parser/KMLParser.d.ts +12 -0
  134. package/lib/Parser/LASParser.d.ts +61 -0
  135. package/lib/Parser/MapBoxUrlParser.d.ts +9 -0
  136. package/lib/Parser/PntsParser.d.ts +4 -0
  137. package/lib/Parser/Potree2BinParser.d.ts +8 -0
  138. package/lib/Parser/PotreeBinParser.d.ts +4 -0
  139. package/lib/Parser/PotreeCinParser.d.ts +4 -0
  140. package/lib/Parser/ShapefileParser.d.ts +25 -0
  141. package/lib/Parser/VectorTileParser.d.ts +34 -0
  142. package/lib/Parser/XbilParser.d.ts +18 -0
  143. package/lib/Parser/deprecated/LegacyGLTFLoader.d.ts +32 -0
  144. package/lib/Parser/iGLTFLoader.d.ts +104 -0
  145. package/lib/Process/3dTilesProcessing.d.ts +43 -0
  146. package/lib/Process/FeatureProcessing.d.ts +4 -0
  147. package/lib/Process/LayeredMaterialNodeProcessing.d.ts +3 -0
  148. package/lib/Process/LayeredMaterialNodeProcessing.js +12 -12
  149. package/lib/Process/ObjectRemovalHelper.d.ts +32 -0
  150. package/lib/Process/handlerNodeError.d.ts +1 -0
  151. package/lib/Provider/3dTilesProvider.d.ts +7 -0
  152. package/lib/Provider/DataSourceProvider.d.ts +4 -0
  153. package/lib/Provider/Fetcher.d.ts +101 -0
  154. package/lib/Provider/PointCloudProvider.d.ts +4 -0
  155. package/lib/Provider/TileProvider.d.ts +4 -0
  156. package/lib/Provider/URLBuilder.d.ts +28 -0
  157. package/lib/Renderer/Camera.d.ts +95 -0
  158. package/lib/Renderer/Color.d.ts +3 -0
  159. package/lib/Renderer/ColorLayersOrdering.d.ts +38 -0
  160. package/lib/Renderer/ColorLayersOrdering.js +2 -2
  161. package/lib/Renderer/CommonMaterial.d.ts +6 -0
  162. package/lib/Renderer/Label2DRenderer.d.ts +31 -0
  163. package/lib/Renderer/LayeredMaterial.d.ts +121 -0
  164. package/lib/Renderer/LayeredMaterial.js +221 -141
  165. package/lib/Renderer/OBB.d.ts +65 -0
  166. package/lib/Renderer/OrientedImageCamera.d.ts +36 -0
  167. package/lib/Renderer/OrientedImageMaterial.d.ts +68 -0
  168. package/lib/Renderer/PointsMaterial.d.ts +226 -0
  169. package/lib/Renderer/PointsMaterial.js +60 -22
  170. package/lib/Renderer/RasterTile.d.ts +53 -0
  171. package/lib/Renderer/RasterTile.js +8 -9
  172. package/lib/Renderer/RenderMode.d.ts +11 -0
  173. package/lib/Renderer/RenderMode.js +1 -0
  174. package/lib/Renderer/Shader/ShaderChunk.d.ts +78 -0
  175. package/lib/Renderer/Shader/ShaderUtils.d.ts +5 -0
  176. package/lib/Renderer/WebXR.d.ts +33 -0
  177. package/lib/Renderer/WebXR.js +128 -47
  178. package/lib/Renderer/c3DEngine.d.ts +55 -0
  179. package/lib/Renderer/c3DEngine.js +5 -1
  180. package/lib/Source/C3DTilesGoogleSource.d.ts +38 -0
  181. package/lib/Source/C3DTilesIonSource.d.ts +31 -0
  182. package/lib/Source/C3DTilesSource.d.ts +17 -0
  183. package/lib/Source/CopcSource.d.ts +79 -0
  184. package/lib/Source/EntwinePointTileSource.d.ts +40 -0
  185. package/lib/Source/EntwinePointTileSource.js +0 -5
  186. package/lib/Source/FileSource.d.ts +118 -0
  187. package/lib/Source/OGC3DTilesGoogleSource.d.ts +24 -0
  188. package/lib/Source/OGC3DTilesIonSource.d.ts +26 -0
  189. package/lib/Source/OGC3DTilesSource.d.ts +21 -0
  190. package/lib/Source/OrientedImageSource.d.ts +48 -0
  191. package/lib/Source/Potree2Source.d.ts +157 -0
  192. package/lib/Source/PotreeSource.d.ts +69 -0
  193. package/lib/Source/Source.d.ts +122 -0
  194. package/lib/Source/TMSSource.d.ts +77 -0
  195. package/lib/Source/VectorTilesSource.d.ts +56 -0
  196. package/lib/Source/WFSSource.d.ts +110 -0
  197. package/lib/Source/WMSSource.d.ts +85 -0
  198. package/lib/Source/WMTSSource.d.ts +65 -0
  199. package/lib/ThreeExtended/capabilities/WebGL.d.ts +9 -0
  200. package/lib/ThreeExtended/libs/ktx-parse.module.d.ts +274 -0
  201. package/lib/ThreeExtended/libs/motion-controllers.module.d.ts +64 -0
  202. package/lib/ThreeExtended/libs/motion-controllers.module.js +375 -0
  203. package/lib/ThreeExtended/libs/zstddec.module.d.ts +6 -0
  204. package/lib/ThreeExtended/loaders/DDSLoader.js +40 -1
  205. package/lib/ThreeExtended/loaders/DRACOLoader.d.ts +41 -0
  206. package/lib/ThreeExtended/loaders/GLTFLoader.d.ts +16 -0
  207. package/lib/ThreeExtended/loaders/GLTFLoader.js +22 -3
  208. package/lib/ThreeExtended/loaders/KTX2Loader.d.ts +116 -0
  209. package/lib/ThreeExtended/loaders/KTX2Loader.js +9 -2
  210. package/lib/ThreeExtended/math/ColorSpaces.d.ts +56 -0
  211. package/lib/ThreeExtended/utils/BufferGeometryUtils.d.ts +62 -0
  212. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +2 -2
  213. package/lib/ThreeExtended/utils/WorkerPool.d.ts +19 -0
  214. package/lib/ThreeExtended/webxr/XRControllerModelFactory.d.ts +25 -0
  215. package/lib/ThreeExtended/webxr/XRControllerModelFactory.js +209 -0
  216. package/lib/Utils/CameraUtils.d.ts +132 -0
  217. package/lib/Utils/DEMUtils.d.ts +84 -0
  218. package/lib/Utils/DEMUtils.js +2 -2
  219. package/lib/Utils/FeaturesUtils.d.ts +17 -0
  220. package/lib/Utils/Gradients.d.ts +13 -0
  221. package/lib/Utils/ThreeUtils.d.ts +14 -0
  222. package/lib/Utils/placeObjectOnGround.d.ts +28 -0
  223. package/lib/global.d.js +0 -0
  224. package/package.json +18 -15
@@ -1,4 +1,7 @@
1
1
  import * as THREE from 'three';
2
+ const size = new THREE.Vector3();
3
+ const position = new THREE.Vector3();
4
+ const translation = new THREE.Vector3();
2
5
  class PointCloudNode extends THREE.EventDispatcher {
3
6
  constructor() {
4
7
  let numPoints = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
@@ -10,16 +13,43 @@ class PointCloudNode extends THREE.EventDispatcher {
10
13
  this.bbox = new THREE.Box3();
11
14
  this.sse = -1;
12
15
  }
16
+ get pointSpacing() {
17
+ return this.layer.spacing / 2 ** this.depth;
18
+ }
19
+ get id() {
20
+ throw new Error('In extended PointCloudNode, you have to implement the getter id!');
21
+ }
13
22
  add(node, indexChild) {
14
23
  this.children.push(node);
15
24
  node.parent = this;
16
25
  this.createChildAABB(node, indexChild);
17
26
  }
27
+ createChildAABB(node) {
28
+ // factor to apply, based on the depth difference (can be > 1)
29
+ const f = 2 ** (node.depth - this.depth);
30
+
31
+ // size of the child node bbox (Vector3), based on the size of the
32
+ // parent node, and divided by the factor
33
+ this.bbox.getSize(size).divideScalar(f);
34
+
35
+ // initialize the child node bbox at the location of the parent node bbox
36
+ node.bbox.min.copy(this.bbox.min);
37
+
38
+ // position of the parent node, if it was at the same depth than the
39
+ // child, found by multiplying the tree position by the factor
40
+ position.copy(this).multiplyScalar(f);
41
+
42
+ // difference in position between the two nodes, at child depth, and
43
+ // scale it using the size
44
+ translation.subVectors(node, position).multiply(size);
45
+
46
+ // apply the translation to the child node bbox
47
+ node.bbox.min.add(translation);
48
+
49
+ // use the size computed above to set the max
50
+ node.bbox.max.copy(node.bbox.min).add(size);
51
+ }
18
52
  load() {
19
- // Query octree/HRC if we don't have children potreeNode yet.
20
- if (!this.octreeIsLoaded) {
21
- this.loadOctree();
22
- }
23
53
  return this.layer.source.fetcher(this.url, this.layer.source.networkOptions).then(file => this.layer.source.parse(file, {
24
54
  out: this.layer,
25
55
  in: this.layer.source
@@ -0,0 +1,11 @@
1
+ export default Potree2Node;
2
+ declare class Potree2Node extends PotreeNode {
3
+ networkOptions(byteOffset: any, byteSize: any): any;
4
+ load(): Promise<any>;
5
+ loaded: boolean | undefined;
6
+ loading: boolean | undefined;
7
+ loadOctree(): Promise<void>;
8
+ loadHierarchy(): Promise<void>;
9
+ parseHierarchy(buffer: any): void;
10
+ }
11
+ import PotreeNode from '../Core/PotreeNode';
@@ -33,72 +33,18 @@ of the authors and should not be interpreted as representing official policies,
33
33
  either expressed or implied, of the FreeBSD Project.
34
34
  */
35
35
 
36
- import * as THREE from 'three';
37
- import PointCloudNode from "./PointCloudNode.js";
38
-
39
- // Create an A(xis)A(ligned)B(ounding)B(ox) for the child `childIndex` of one aabb.
40
- // (PotreeConverter protocol builds implicit octree hierarchy by applying the same
41
- // subdivision algo recursively)
42
- const dHalfLength = new THREE.Vector3();
36
+ import PotreeNode from "./PotreeNode.js";
43
37
  const NODE_TYPE = {
44
38
  NORMAL: 0,
45
39
  LEAF: 1,
46
40
  PROXY: 2
47
41
  };
48
- class Potree2Node extends PointCloudNode {
42
+ class Potree2Node extends PotreeNode {
49
43
  constructor() {
50
44
  let numPoints = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
51
45
  let childrenBitField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
52
46
  let layer = arguments.length > 2 ? arguments[2] : undefined;
53
- super(numPoints, layer);
54
- this.childrenBitField = childrenBitField;
55
- this.id = '';
56
- this.depth = 0;
57
- this.baseurl = layer.source.baseurl;
58
- }
59
- add(node, indexChild) {
60
- super.add(node, indexChild);
61
- node.id = this.id + indexChild;
62
- node.depth = this.depth + 1;
63
- }
64
- createChildAABB(node, childIndex) {
65
- // Code inspired from potree
66
- node.bbox.copy(this.bbox);
67
- this.bbox.getCenter(node.bbox.max);
68
- dHalfLength.copy(node.bbox.max).sub(this.bbox.min);
69
- if (childIndex === 1) {
70
- node.bbox.min.z += dHalfLength.z;
71
- node.bbox.max.z += dHalfLength.z;
72
- } else if (childIndex === 3) {
73
- node.bbox.min.z += dHalfLength.z;
74
- node.bbox.max.z += dHalfLength.z;
75
- node.bbox.min.y += dHalfLength.y;
76
- node.bbox.max.y += dHalfLength.y;
77
- } else if (childIndex === 0) {
78
- //
79
- } else if (childIndex === 2) {
80
- node.bbox.min.y += dHalfLength.y;
81
- node.bbox.max.y += dHalfLength.y;
82
- } else if (childIndex === 5) {
83
- node.bbox.min.z += dHalfLength.z;
84
- node.bbox.max.z += dHalfLength.z;
85
- node.bbox.min.x += dHalfLength.x;
86
- node.bbox.max.x += dHalfLength.x;
87
- } else if (childIndex === 7) {
88
- node.bbox.min.add(dHalfLength);
89
- node.bbox.max.add(dHalfLength);
90
- } else if (childIndex === 4) {
91
- node.bbox.min.x += dHalfLength.x;
92
- node.bbox.max.x += dHalfLength.x;
93
- } else if (childIndex === 6) {
94
- node.bbox.min.y += dHalfLength.y;
95
- node.bbox.max.y += dHalfLength.y;
96
- node.bbox.min.x += dHalfLength.x;
97
- node.bbox.max.x += dHalfLength.x;
98
- }
99
- }
100
- get octreeIsLoaded() {
101
- return !(this.childrenBitField && this.children.length === 0);
47
+ super(numPoints, childrenBitField, layer);
102
48
  }
103
49
  get url() {
104
50
  return `${this.baseurl}/octree.bin`;
@@ -146,8 +92,8 @@ class Potree2Node extends PointCloudNode {
146
92
  return this.nodeType === NODE_TYPE.PROXY ? this.loadHierarchy() : Promise.resolve();
147
93
  }
148
94
  async loadHierarchy() {
149
- const hierarchyPath = `${this.baseurl}/hierarchy.bin`;
150
- const buffer = await this.layer.source.fetcher(hierarchyPath, this.networkOptions(this.hierarchyByteOffset, this.hierarchyByteSize));
95
+ const hierarchyUrl = `${this.baseurl}/hierarchy.bin`;
96
+ const buffer = await this.layer.source.fetcher(hierarchyUrl, this.networkOptions(this.hierarchyByteOffset, this.hierarchyByteSize));
151
97
  this.parseHierarchy(buffer);
152
98
  }
153
99
  parseHierarchy(buffer) {
@@ -196,7 +142,6 @@ class Potree2Node extends PointCloudNode {
196
142
  continue;
197
143
  }
198
144
  const child = new Potree2Node(numPoints, childMask, this.layer);
199
- child.spacing = current.spacing / 2;
200
145
  current.add(child, childIndex);
201
146
  stack.push(child);
202
147
  }
@@ -0,0 +1,97 @@
1
+ export class Potree2PointAttributes {
2
+ attributes: any[];
3
+ byteSize: number;
4
+ size: number;
5
+ vectors: any[];
6
+ add(pointAttribute: any): void;
7
+ addVector(vector: any): void;
8
+ hasNormals(): boolean;
9
+ }
10
+ export namespace PointAttributeTypes {
11
+ namespace DATA_TYPE_DOUBLE {
12
+ let name: string;
13
+ let size: number;
14
+ }
15
+ namespace DATA_TYPE_FLOAT {
16
+ let name_1: string;
17
+ export { name_1 as name };
18
+ let size_1: number;
19
+ export { size_1 as size };
20
+ }
21
+ namespace DATA_TYPE_INT8 {
22
+ let name_2: string;
23
+ export { name_2 as name };
24
+ let size_2: number;
25
+ export { size_2 as size };
26
+ }
27
+ namespace DATA_TYPE_UINT8 {
28
+ let name_3: string;
29
+ export { name_3 as name };
30
+ let size_3: number;
31
+ export { size_3 as size };
32
+ }
33
+ namespace DATA_TYPE_INT16 {
34
+ let name_4: string;
35
+ export { name_4 as name };
36
+ let size_4: number;
37
+ export { size_4 as size };
38
+ }
39
+ namespace DATA_TYPE_UINT16 {
40
+ let name_5: string;
41
+ export { name_5 as name };
42
+ let size_5: number;
43
+ export { size_5 as size };
44
+ }
45
+ namespace DATA_TYPE_INT32 {
46
+ let name_6: string;
47
+ export { name_6 as name };
48
+ let size_6: number;
49
+ export { size_6 as size };
50
+ }
51
+ namespace DATA_TYPE_UINT32 {
52
+ let name_7: string;
53
+ export { name_7 as name };
54
+ let size_7: number;
55
+ export { size_7 as size };
56
+ }
57
+ namespace DATA_TYPE_INT64 {
58
+ let name_8: string;
59
+ export { name_8 as name };
60
+ let size_8: number;
61
+ export { size_8 as size };
62
+ }
63
+ namespace DATA_TYPE_UINT64 {
64
+ let name_9: string;
65
+ export { name_9 as name };
66
+ let size_9: number;
67
+ export { size_9 as size };
68
+ }
69
+ }
70
+ export class PointAttribute {
71
+ constructor(name: any, type: any, numElements: any);
72
+ name: any;
73
+ type: any;
74
+ numElements: any;
75
+ byteSize: number;
76
+ description: string;
77
+ range: number[];
78
+ }
79
+ export namespace PointAttribute {
80
+ export let POSITION_CARTESIAN: PointAttribute;
81
+ export let RGBA_PACKED: PointAttribute;
82
+ import COLOR_PACKED = RGBA_PACKED;
83
+ export { COLOR_PACKED };
84
+ export let RGB_PACKED: PointAttribute;
85
+ export let NORMAL_FLOATS: PointAttribute;
86
+ export let INTENSITY: PointAttribute;
87
+ export let CLASSIFICATION: PointAttribute;
88
+ export let NORMAL_SPHEREMAPPED: PointAttribute;
89
+ export let NORMAL_OCT16: PointAttribute;
90
+ export let NORMAL: PointAttribute;
91
+ export let RETURN_NUMBER: PointAttribute;
92
+ export let NUMBER_OF_RETURNS: PointAttribute;
93
+ export let SOURCE_ID: PointAttribute;
94
+ export let INDICES: PointAttribute;
95
+ export let SPACING: PointAttribute;
96
+ export let GPS_TIME: PointAttribute;
97
+ }
@@ -0,0 +1,14 @@
1
+ export default PotreeNode;
2
+ declare class PotreeNode extends PointCloudNode {
3
+ constructor(numPoints: number | undefined, childrenBitField: number | undefined, layer: any);
4
+ childrenBitField: number;
5
+ depth: number;
6
+ hierarchyKey: string;
7
+ baseurl: any;
8
+ get octreeIsLoaded(): boolean;
9
+ get url(): string;
10
+ get id(): string;
11
+ createChildAABB(node: any, childIndex: any): void;
12
+ loadOctree(): any;
13
+ }
14
+ import PointCloudNode from '../Core/PointCloudNode';
@@ -12,19 +12,23 @@ class PotreeNode extends PointCloudNode {
12
12
  let layer = arguments.length > 2 ? arguments[2] : undefined;
13
13
  super(numPoints, layer);
14
14
  this.childrenBitField = childrenBitField;
15
- this.id = '';
16
15
  this.depth = 0;
16
+ this.hierarchyKey = 'r';
17
17
  this.baseurl = layer.source.baseurl;
18
18
  }
19
- add(node, indexChild, root) {
19
+ get octreeIsLoaded() {
20
+ return !(this.childrenBitField && this.children.length === 0);
21
+ }
22
+ get url() {
23
+ return `${this.baseurl}/${this.hierarchyKey}.${this.layer.source.extension}`;
24
+ }
25
+ get id() {
26
+ return this.hierarchyKey;
27
+ }
28
+ add(node, indexChild) {
29
+ node.hierarchyKey = this.hierarchyKey + indexChild;
30
+ node.depth = this.depth + 1;
20
31
  super.add(node, indexChild);
21
- node.id = this.id + indexChild;
22
- node.depth = node.id.length;
23
- if (node.id.length % this.layer.hierarchyStepSize == 0) {
24
- node.baseurl = `${root.baseurl}/${node.id.substr(root.id.length)}`;
25
- } else {
26
- node.baseurl = root.baseurl;
27
- }
28
32
  }
29
33
  createChildAABB(node, childIndex) {
30
34
  // Code inspired from potree
@@ -62,14 +66,15 @@ class PotreeNode extends PointCloudNode {
62
66
  node.bbox.max.x += dHalfLength.x;
63
67
  }
64
68
  }
65
- get octreeIsLoaded() {
66
- return !(this.childrenBitField && this.children.length === 0);
67
- }
68
- get url() {
69
- return `${this.baseurl}/r${this.id}.${this.layer.source.extension}`;
69
+ load() {
70
+ // Query octree/HRC if we don't have children potreeNode yet.
71
+ if (!this.octreeIsLoaded) {
72
+ this.loadOctree();
73
+ }
74
+ return super.load();
70
75
  }
71
76
  loadOctree() {
72
- const octreeUrl = `${this.baseurl}/r${this.id}.${this.layer.source.extensionOctree}`;
77
+ const octreeUrl = `${this.baseurl}/${this.hierarchyKey}.${this.layer.source.extensionOctree}`;
73
78
  return this.layer.source.fetcher(octreeUrl, this.layer.source.networkOptions).then(blob => {
74
79
  const view = new DataView(blob);
75
80
  const stack = [];
@@ -89,9 +94,14 @@ class PotreeNode extends PointCloudNode {
89
94
  offset += 1;
90
95
  const numPoints = view.getUint32(offset, true) || this.numPoints;
91
96
  offset += 4;
92
- const item = new PotreeNode(numPoints, childrenBitField, this.layer);
93
- snode.add(item, indexChild, this);
94
- stack.push(item);
97
+ const child = new PotreeNode(numPoints, childrenBitField, this.layer);
98
+ snode.add(child, indexChild);
99
+ if (child.id.length % this.layer.hierarchyStepSize == 0) {
100
+ child.baseurl = `${this.baseurl}/${child.id}`;
101
+ } else {
102
+ child.baseurl = this.baseurl;
103
+ }
104
+ stack.push(child);
95
105
  }
96
106
  }
97
107
  }
@@ -0,0 +1,66 @@
1
+ export default Atmosphere;
2
+ /**
3
+ * @extends GeometryLayer
4
+ */
5
+ declare class Atmosphere extends GeometryLayer {
6
+ /**
7
+ * It's layer to simulate Globe atmosphere.
8
+ * There's 2 modes : simple and realistic (atmospheric-scattering).
9
+ *
10
+ * The atmospheric-scattering it is taken from :
11
+ * * [Atmosphere Shader From Space (Atmospheric scattering)](http://stainlessbeer.weebly.com/planets-9-atmospheric-scattering.html)
12
+ * * [Accurate Atmospheric Scattering (NVIDIA GPU Gems 2)](https://developer.nvidia.com/gpugems/gpugems2/part-ii-shading-lighting-and-shadows/chapter-16-accurate-atmospheric-scattering).
13
+ *
14
+ * @param {string} id - The id of the layer Atmosphere.
15
+ * @param {Object} [options] - options layer.
16
+ * @param {number} [options.Kr] - `Kr` is the rayleigh scattering constant.
17
+ * @param {number} [options.Km] - `Km` is the Mie scattering constant.
18
+ * @param {number} [options.ESun] - `ESun` is the brightness of the sun.
19
+ * @param {number} [options.g] - constant `g` that affects the symmetry of the scattering.
20
+ * @param {number} [options.innerRadius] - The inner (planetary) radius
21
+ * @param {number} [options.outerRadius] - The outer (Atmosphere) radius
22
+ * @param {number[]} [options.wavelength] - The constant is the `wavelength` (or color) of light.
23
+ * @param {number} [options.scaleDepth] - The `scale depth` (i.e. the altitude at which the atmosphere's average density is found).
24
+ * @param {number} [options.mieScaleDepth] - not used.
25
+ */
26
+ constructor(id?: string, options?: {
27
+ Kr?: number | undefined;
28
+ Km?: number | undefined;
29
+ ESun?: number | undefined;
30
+ g?: number | undefined;
31
+ innerRadius?: number | undefined;
32
+ outerRadius?: number | undefined;
33
+ wavelength?: number[] | undefined;
34
+ scaleDepth?: number | undefined;
35
+ mieScaleDepth?: number | undefined;
36
+ });
37
+ isAtmosphere: boolean;
38
+ basicAtmosphere: THREE.Object3D<THREE.Object3DEventMap>;
39
+ realisticAtmosphere: THREE.Object3D<THREE.Object3DEventMap>;
40
+ realisticLightingPosition: {
41
+ x: number;
42
+ y: number;
43
+ z: number;
44
+ };
45
+ fog: {
46
+ enable: boolean;
47
+ distance: number;
48
+ };
49
+ realisticAtmosphereInitParams: {
50
+ Kr?: number | undefined;
51
+ Km?: number | undefined;
52
+ ESun?: number | undefined;
53
+ g?: number | undefined;
54
+ innerRadius?: number | undefined;
55
+ outerRadius?: number | undefined;
56
+ wavelength?: number[] | undefined;
57
+ scaleDepth?: number | undefined;
58
+ mieScaleDepth?: number | undefined;
59
+ };
60
+ update(context: any, layer: any, node: any): void;
61
+ preUpdate(context: any, srcs: any): void;
62
+ _initRealisticLighning(): void;
63
+ setRealisticOn(bool: any): void;
64
+ }
65
+ import GeometryLayer from '../../../Layer/GeometryLayer';
66
+ import * as THREE from 'three';
@@ -75,6 +75,7 @@ class Atmosphere extends GeometryLayer {
75
75
  const sphereGeometry = new THREE.SphereGeometry(1, 64, 64);
76
76
  const basicAtmosphereOut = new THREE.Mesh(sphereGeometry, material);
77
77
  basicAtmosphereOut.scale.copy(ellipsoidSizes).multiplyScalar(1.14);
78
+ basicAtmosphereOut.renderOrder = 1;
78
79
  this.basicAtmosphere = new THREE.Object3D();
79
80
  this.realisticAtmosphere = new THREE.Object3D();
80
81
  this.realisticAtmosphere.visible = false;
@@ -101,6 +102,7 @@ class Atmosphere extends GeometryLayer {
101
102
  });
102
103
  const basicAtmosphereIn = new THREE.Mesh(sphereGeometry, materialAtmoIn);
103
104
  basicAtmosphereIn.scale.copy(ellipsoidSizes).multiplyScalar(1.002);
105
+ basicAtmosphereIn.renderOrder = 2;
104
106
  this.basicAtmosphere.add(basicAtmosphereIn);
105
107
  this.realisticLightingPosition = {
106
108
  x: -0.5,
@@ -130,9 +132,9 @@ class Atmosphere extends GeometryLayer {
130
132
  }
131
133
  update(context, layer, node) {
132
134
  // update uniforms
133
- node.material.fogDistance = this.fog.distance;
134
- node.material.lightingEnabled = this.realisticAtmosphere.visible;
135
- node.material.lightPosition = this.realisticLightingPosition;
135
+ node.material.setUniform('fogDistance', this.fog.distance);
136
+ node.material.setUniform('lightingEnabled', this.realisticAtmosphere.visible);
137
+ node.material.setUniform('lightPosition', this.realisticLightingPosition);
136
138
  }
137
139
 
138
140
  // eslint-disable-next-line no-unused-vars
@@ -245,6 +247,7 @@ class Atmosphere extends GeometryLayer {
245
247
  depthWrite: false
246
248
  });
247
249
  const ground = new THREE.Mesh(geometryAtmosphereIn, materialAtmosphereIn);
250
+ ground.renderOrder = 2;
248
251
  const geometryAtmosphereOut = new THREE.SphereGeometry(atmosphere.outerRadius, 196, 196);
249
252
  const materialAtmosphereOut = new THREE.ShaderMaterial({
250
253
  uniforms: uniformsAtmosphere,
@@ -254,7 +257,9 @@ class Atmosphere extends GeometryLayer {
254
257
  side: THREE.BackSide
255
258
  });
256
259
  const sky = new THREE.Mesh(geometryAtmosphereOut, materialAtmosphereOut);
260
+ sky.renderOrder = 1;
257
261
  const skyDome = new Sky();
262
+ skyDome.renderOrder = 1;
258
263
  skyDome.frustumCulled = false;
259
264
  this.realisticAtmosphere.add(ground);
260
265
  this.realisticAtmosphere.add(sky);
@@ -264,7 +269,7 @@ class Atmosphere extends GeometryLayer {
264
269
  reileigh: 2,
265
270
  mieCoefficient: 0.005,
266
271
  mieDirectionalG: 0.8,
267
- luminance: 1,
272
+ luminanceAtmosphere: 1,
268
273
  inclination: 0.49,
269
274
  // elevation / inclination
270
275
  azimuth: 0.25,
@@ -273,7 +278,7 @@ class Atmosphere extends GeometryLayer {
273
278
  };
274
279
  skyDome.material.uniforms.turbidity.value = effectController.turbidity;
275
280
  skyDome.material.uniforms.reileigh.value = effectController.reileigh;
276
- skyDome.material.uniforms.luminance.value = effectController.luminance;
281
+ skyDome.material.uniforms.luminanceAtmosphere.value = effectController.luminanceAtmosphere;
277
282
  skyDome.material.uniforms.mieCoefficient.value = effectController.mieCoefficient;
278
283
  skyDome.material.uniforms.mieDirectionalG.value = effectController.mieDirectionalG;
279
284
  skyDome.material.uniforms.up.value = new THREE.Vector3(); // no more necessary, estimate normal from cam..
@@ -0,0 +1,48 @@
1
+ export default GlobeLayer;
2
+ /**
3
+ * @property {boolean} isGlobeLayer - Used to checkout whether this layer is a
4
+ * GlobeLayer. Default is true. You should not change this, as it is used
5
+ * internally for optimisation.
6
+ *
7
+ * @extends TiledGeometryLayer
8
+ */
9
+ declare class GlobeLayer extends TiledGeometryLayer {
10
+ static horizonCulling(point: any): boolean;
11
+ /**
12
+ * A {@link TiledGeometryLayer} to use with a {@link GlobeView}. It has
13
+ * specific method for updating and subdivising its grid.
14
+ *
15
+ * @param {string} id - The id of the layer, that should be unique. It is
16
+ * not mandatory, but an error will be emitted if this layer is added a
17
+ * {@link View} that already has a layer going by that id.
18
+ * @param {THREE.Object3D} [object3d=THREE.Group] - The object3d used to
19
+ * contain the geometry of the TiledGeometryLayer. It is usually a
20
+ * `THREE.Group`, but it can be anything inheriting from a `THREE.Object3d`.
21
+ * @param {Object} [config] - Optional configuration, all elements in it
22
+ * will be merged as is in the layer. For example, if the configuration
23
+ * contains three elements `name, protocol, extent`, these elements will be
24
+ * available using `layer.name` or something else depending on the property
25
+ * name.
26
+ * @param {number} [config.minSubdivisionLevel=2] - Minimum subdivision
27
+ * level for this tiled layer.
28
+ * @param {number} [config.maxSubdivisionLevel=18] - Maximum subdivision
29
+ * level for this tiled layer.
30
+ * @param {number} [config.sseSubdivisionThreshold=1] - Threshold level for
31
+ * the SSE.
32
+ *
33
+ * @throws {Error} `object3d` must be a valid `THREE.Object3d`.
34
+ */
35
+ constructor(id: string, object3d?: THREE.Object3D, config?: {
36
+ minSubdivisionLevel?: number | undefined;
37
+ maxSubdivisionLevel?: number | undefined;
38
+ sseSubdivisionThreshold?: number | undefined;
39
+ });
40
+ isGlobeLayer: boolean;
41
+ extent: any;
42
+ preUpdate(context: any, changeSources: any): TileMesh[];
43
+ subdivision(context: any, layer: any, node: any): boolean;
44
+ computeTileZoomFromDistanceCamera(distance: any, camera: any): number;
45
+ computeDistanceCameraFromTileZoom(zoom: any, camera: any): number;
46
+ }
47
+ import TiledGeometryLayer from '../../../Layer/TiledGeometryLayer';
48
+ import * as THREE from 'three';
@@ -0,0 +1,38 @@
1
+ import * as THREE from 'three';
2
+ import { Coordinates, Extent } from '@itowns/geographic';
3
+ import { ShareableExtent, TileBuilder, TileBuilderParams } from '../TileBuilder';
4
+ /** Specialized parameters for the [GlobeTileBuilder]. */
5
+ export interface GlobeTileBuilderParams extends TileBuilderParams {
6
+ /** Number of rows of tiles, essentially the resolution of the globe. */
7
+ nbRow: number;
8
+ /** Offset of the second texture set. */
9
+ deltaUV1: number;
10
+ /** Transformation to align a tile's normal to the Z axis. */
11
+ quatNormalToZ: THREE.Quaternion;
12
+ }
13
+ /**
14
+ * TileBuilder implementation for the purpose of generating globe (or more
15
+ * precisely ellipsoidal) tile arrangements.
16
+ */
17
+ export declare class GlobeTileBuilder implements TileBuilder<GlobeTileBuilderParams> {
18
+ private static _crs;
19
+ private static _computeExtraOffset;
20
+ /**
21
+ * Buffer holding information about the tile/vertex currently being
22
+ * processed.
23
+ */
24
+ private _transform;
25
+ computeExtraOffset?: (params: GlobeTileBuilderParams) => number;
26
+ get crs(): string;
27
+ constructor(options: {
28
+ /** Number of unaligned texture sets. */
29
+ uvCount: number;
30
+ });
31
+ prepare(params: TileBuilderParams): GlobeTileBuilderParams;
32
+ center(extent: Extent): THREE.Vector3;
33
+ vertexPosition(coordinates: Coordinates): THREE.Vector3;
34
+ vertexNormal(): THREE.Vector3;
35
+ uProject(u: number, extent: Extent): number;
36
+ vProject(v: number, extent: Extent): number;
37
+ computeShareableExtent(extent: Extent): ShareableExtent;
38
+ }
@@ -0,0 +1,5 @@
1
+ export default Sky;
2
+ declare class Sky extends THREE.Mesh<THREE.BufferGeometry<THREE.NormalBufferAttributes>, THREE.Material | THREE.Material[], THREE.Object3DEventMap> {
3
+ constructor();
4
+ }
5
+ import * as THREE from 'three';
@@ -17,7 +17,7 @@
17
17
  import * as THREE from 'three';
18
18
  const skyShader = {
19
19
  uniforms: {
20
- luminance: {
20
+ luminanceAtmosphere: {
21
21
  type: 'f',
22
22
  value: 1
23
23
  },
@@ -49,7 +49,7 @@ const skyShader = {
49
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
50
  fragmentShader: ['uniform sampler2D skySampler;', 'uniform vec3 v3LightPosition;', 'uniform vec3 up;', 'varying vec3 vWorldPosition;',
51
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;',
52
+ '// uniform sampler2D sDiffuse;', '// const float turbidity = 10.0; //', '// const float reileigh = 2.; //', '// const float luminanceAtmosphere = 1.0; //', '// const float mieCoefficient = 0.005;', '// const float mieDirectionalG = 0.8;', 'uniform float luminanceAtmosphere;', '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
53
  // "const vec3 up = vec3(0.0, 1.0, 0.0);",
54
54
 
55
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));', '}',
@@ -58,7 +58,7 @@ const skyShader = {
58
58
  // return 0.00054532832366 / (3.0 * 2.545E25 * pow(vec3(680E-9, 550E-9, 450E-9), vec3(4.0)) * 6.245);
59
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
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')
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 / luminanceAtmosphere; ', 'float fLumCompressed = (fLumScaled * (1.0 + (fLumScaled / (g_fMaxLuminance * g_fMaxLuminance)))) / (1.0 + fLumScaled); ', 'float ExposureBias = fLumCompressed;', 'vec3 curr = Uncharted2Tonemap((log2(2.0/pow(luminanceAtmosphere,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
62
  };
63
63
  class Sky extends THREE.Mesh {
64
64
  constructor() {