cesium_retz.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="description" content="">
  6. <meta name="author" content="">
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
  8. <title>Potree Viewer</title>
  9. <link rel="stylesheet" type="text/css" href="../build/potree/potree.css">
  10. <link rel="stylesheet" type="text/css" href="../libs/jquery-ui/jquery-ui.min.css">
  11. <link rel="stylesheet" type="text/css" href="../libs/openlayers3/ol.css">
  12. <link rel="stylesheet" type="text/css" href="../libs/spectrum/spectrum.css">
  13. <link rel="stylesheet" type="text/css" href="../libs/jstree/themes/mixed/style.css">
  14. <link rel="stylesheet" type="text/css" href="../libs/Cesium/Widgets/CesiumWidget/CesiumWidget.css">
  15. </head>
  16. <body>
  17. <script src="../libs/jquery/jquery-3.1.1.min.js"></script>
  18. <script src="../libs/spectrum/spectrum.js"></script>
  19. <script src="../libs/jquery-ui/jquery-ui.min.js"></script>
  20. <script src="../libs/other/BinaryHeap.js"></script>
  21. <script src="../libs/tween/tween.min.js"></script>
  22. <script src="../libs/d3/d3.js"></script>
  23. <script src="../libs/proj4/proj4.js"></script>
  24. <script src="../libs/openlayers3/ol.js"></script>
  25. <script src="../libs/i18next/i18next.js"></script>
  26. <script src="../libs/jstree/jstree.js"></script>
  27. <script src="../build/potree/potree.js"></script>
  28. <script src="../libs/plasio/js/laslaz.js"></script>
  29. <script src="../libs/Cesium/Cesium.js"></script>
  30. <!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
  31. <!-- INCLUDE SETTINGS HERE -->
  32. <div class="potree_container" style="position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; ">
  33. <div id="potree_render_area" style="background-image: url('../build/potree/resources/images/background.jpg');">
  34. <div id="cesiumContainer" style="position: absolute; width: 100%; height: 100%; background-color:green"></div>
  35. </div>
  36. <div id="potree_sidebar_container"> </div>
  37. </div>
  38. <script type="module">
  39. import * as THREE from "../libs/three.js/build/three.module.js";
  40. window.cesiumViewer = new Cesium.Viewer('cesiumContainer', {
  41. useDefaultRenderLoop: false,
  42. animation: false,
  43. baseLayerPicker : false,
  44. fullscreenButton: false,
  45. geocoder: false,
  46. homeButton: false,
  47. infoBox: false,
  48. sceneModePicker: false,
  49. selectionIndicator: false,
  50. timeline: false,
  51. navigationHelpButton: false,
  52. imageryProvider : Cesium.createOpenStreetMapImageryProvider({url : 'https://a.tile.openstreetmap.org/'}),
  53. terrainShadows: Cesium.ShadowMode.DISABLED,
  54. });
  55. let cp = new Cesium.Cartesian3(4303414.154026048, 552161.235598733, 4660771.704035539);
  56. cesiumViewer.camera.setView({
  57. destination : cp,
  58. orientation: {
  59. heading : 10,
  60. pitch : -Cesium.Math.PI_OVER_TWO * 0.5,
  61. roll : 0.0
  62. }
  63. });
  64. window.potreeViewer = new Potree.Viewer(document.getElementById("potree_render_area"), {
  65. useDefaultRenderLoop: false
  66. });
  67. potreeViewer.setEDLEnabled(true);
  68. potreeViewer.setFOV(60);
  69. potreeViewer.setPointBudget(3_000_000);
  70. potreeViewer.setMinNodeSize(50);
  71. potreeViewer.loadSettingsFromURL();
  72. potreeViewer.setBackground(null);
  73. potreeViewer.useHQ = true;
  74. potreeViewer.setDescription(`
  75. Potree using <a href="https://cesiumjs.org/" target="_blank">Cesium</a> to display an
  76. <a href="https://www.openstreetmap.org" target="_blank">OpenStreetMap</a> map below.<br>
  77. Point cloud courtesy of <a href="http://riegl.com/" target="_blank">Riegl</a><br>`);
  78. potreeViewer.loadGUI(() => {
  79. potreeViewer.setLanguage('en');
  80. $("#menu_appearance").next().show();
  81. $("#menu_tools").next().show();
  82. $("#menu_scene").next().show();
  83. potreeViewer.toggleSidebar();
  84. });
  85. Potree.loadPointCloud("http://5.9.65.151/mschuetz/potree/resources/pointclouds/riegl/retz/cloud.js", "Retz", function(e){
  86. let scene = potreeViewer.scene;
  87. scene.addPointCloud(e.pointcloud);
  88. e.pointcloud.position.set(569277.402752, 5400050.599046, 0);
  89. e.pointcloud.rotation.set(0, 0, -0.035);
  90. let material = e.pointcloud.material;
  91. material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
  92. material.size = 0.7;
  93. material.elevationRange = [0, 70];
  94. material.weightRGB = 1.0;
  95. material.weightElevation = 1.0;
  96. scene.view.position.set(570975.577, 5398630.521, 1659.311);
  97. scene.view.lookAt(570115.285, 5400866.092, 30.009);
  98. {
  99. let aTownHall = new Potree.Annotation({
  100. position: [569879.768, 5400886.182, 80.691],
  101. title: "Town Hall",
  102. cameraPosition: [569955.329, 5400822.949, 98.807],
  103. cameraTarget: [569879.768, 5400886.182, 46.691]
  104. });
  105. scene.annotations.add(aTownHall);
  106. let aTrainStation = new Potree.Annotation({
  107. position: [570337.407, 5400522.730, 30],
  108. title: "Train Station",
  109. cameraPosition: [570377.074, 5400427.884, 100.576],
  110. cameraTarget: [570337.407, 5400522.730, 18.595]
  111. });
  112. scene.annotations.add(aTrainStation);
  113. { // Attribute Selector Annotation
  114. // Create title element with jquery
  115. let elTitle = $(`
  116. <span>
  117. Attribute:
  118. <img title="Elevation" name="action_elevation" src="${Potree.resourcePath}/icons/profile.svg" class="annotation-action-icon"/>
  119. <img title="RGB and Elevation" name="action_both" src="${Potree.resourcePath}/icons/rgb_elevation.png" class="annotation-action-icon"/>
  120. <img title="RGB" name="action_rgb" src="${Potree.resourcePath}/icons/rgb.svg" class="annotation-action-icon"/>
  121. </span>`);
  122. elTitle.find("img[name=action_elevation]").click( () => {
  123. scene.pointclouds.forEach( pc => pc.material.activeAttributeName = "elevation" );
  124. });
  125. elTitle.find("img[name=action_rgb]").click( () => {
  126. scene.pointclouds.forEach( pc => pc.material.activeAttributeName = "rgba" );
  127. });
  128. elTitle.find("img[name=action_both]").click( () => {
  129. scene.pointclouds.forEach( pc => pc.material.activeAttributeName = "composite" );
  130. });
  131. // Give the annotation a meaningful string representation for the sidebar
  132. elTitle.toString = () => "Color Setting";
  133. // Same as with other annotations, except title is a jquery object this time.
  134. let aActions = new Potree.Annotation({
  135. position: [569222.340, 5401213.625, 227],
  136. title: elTitle
  137. });
  138. scene.annotations.add(aActions);
  139. }
  140. { // Attribute Selector Annotation
  141. let elTitle = $(`
  142. <span>
  143. Quality:
  144. <span name="low" style="font-family: monospace; margin-left: 4px">low</span>
  145. <span name="med" style="font-family: monospace; margin-left: 4px">med</span>
  146. <span name="high" style="font-family: monospace; margin-left: 4px">high</span>
  147. </span>`);
  148. elTitle.find("span").mouseover( (e) => {
  149. $(e.target).css("filter", "drop-shadow(0px 0px 1px white)");
  150. }).mouseout( (e) => {
  151. $(e.target).css("filter", "");
  152. });
  153. elTitle.find("span[name=low]").click( () => {
  154. potreeViewer.setPointBudget(1_000_000);
  155. potreeViewer.useHQ = false;
  156. });
  157. elTitle.find("span[name=med]").click( () => {
  158. potreeViewer.setPointBudget(3_000_000);
  159. potreeViewer.useHQ = false;
  160. });
  161. elTitle.find("span[name=high]").click( () => {
  162. potreeViewer.setPointBudget(4_000_000);
  163. potreeViewer.useHQ = true;
  164. });
  165. // Give the annotation a meaningful string representation for the sidebar
  166. elTitle.toString = () => "Quality Setting";
  167. // Same as with other annotations, except title is a jquery object this time.
  168. let aActions = new Potree.Annotation({
  169. position: [570274.902, 5401873.626, 227],
  170. title: elTitle
  171. });
  172. scene.annotations.add(aActions);
  173. }
  174. }
  175. //let pointcloudProjection = e.pointcloud.projection;
  176. let pointcloudProjection = "+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
  177. let mapProjection = proj4.defs("WGS84");
  178. window.toMap = proj4(pointcloudProjection, mapProjection);
  179. window.toScene = proj4(mapProjection, pointcloudProjection);
  180. {
  181. let bb = potreeViewer.getBoundingBox();
  182. let minWGS84 = proj4(pointcloudProjection, mapProjection, bb.min.toArray());
  183. let maxWGS84 = proj4(pointcloudProjection, mapProjection, bb.max.toArray());
  184. }
  185. });
  186. function loop(timestamp){
  187. requestAnimationFrame(loop);
  188. potreeViewer.update(potreeViewer.clock.getDelta(), timestamp);
  189. potreeViewer.render();
  190. if(window.toMap !== undefined){
  191. {
  192. let camera = potreeViewer.scene.getActiveCamera();
  193. let pPos = new THREE.Vector3(0, 0, 0).applyMatrix4(camera.matrixWorld);
  194. let pRight = new THREE.Vector3(600, 0, 0).applyMatrix4(camera.matrixWorld);
  195. let pUp = new THREE.Vector3(0, 600, 0).applyMatrix4(camera.matrixWorld);
  196. let pTarget = potreeViewer.scene.view.getPivot();
  197. let toCes = (pos) => {
  198. let xy = [pos.x, pos.y];
  199. let height = pos.z;
  200. let deg = toMap.forward(xy);
  201. let cPos = Cesium.Cartesian3.fromDegrees(...deg, height);
  202. return cPos;
  203. };
  204. let cPos = toCes(pPos);
  205. let cUpTarget = toCes(pUp);
  206. let cTarget = toCes(pTarget);
  207. let cDir = Cesium.Cartesian3.subtract(cTarget, cPos, new Cesium.Cartesian3());
  208. let cUp = Cesium.Cartesian3.subtract(cUpTarget, cPos, new Cesium.Cartesian3());
  209. cDir = Cesium.Cartesian3.normalize(cDir, new Cesium.Cartesian3());
  210. cUp = Cesium.Cartesian3.normalize(cUp, new Cesium.Cartesian3());
  211. cesiumViewer.camera.setView({
  212. destination : cPos,
  213. orientation : {
  214. direction : cDir,
  215. up : cUp
  216. }
  217. });
  218. }
  219. let aspect = potreeViewer.scene.getActiveCamera().aspect;
  220. if(aspect < 1){
  221. let fovy = Math.PI * (potreeViewer.scene.getActiveCamera().fov / 180);
  222. cesiumViewer.camera.frustum.fov = fovy;
  223. }else{
  224. let fovy = Math.PI * (potreeViewer.scene.getActiveCamera().fov / 180);
  225. let fovx = Math.atan(Math.tan(0.5 * fovy) * aspect) * 2
  226. cesiumViewer.camera.frustum.fov = fovx;
  227. }
  228. }
  229. cesiumViewer.render();
  230. }
  231. requestAnimationFrame(loop);
  232. </script>
  233. </body>
  234. </html>