annotations.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. </head>
  15. <body>
  16. <script src="../libs/jquery/jquery-3.1.1.min.js"></script>
  17. <script src="../libs/spectrum/spectrum.js"></script>
  18. <script src="../libs/jquery-ui/jquery-ui.min.js"></script>
  19. <script src="../libs/other/BinaryHeap.js"></script>
  20. <script src="../libs/tween/tween.min.js"></script>
  21. <script src="../libs/d3/d3.js"></script>
  22. <script src="../libs/proj4/proj4.js"></script>
  23. <script src="../libs/openlayers3/ol.js"></script>
  24. <script src="../libs/i18next/i18next.js"></script>
  25. <script src="../libs/jstree/jstree.js"></script>
  26. <script src="../build/potree/potree.js"></script>
  27. <script src="../libs/plasio/js/laslaz.js"></script>
  28. <!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
  29. <!-- INCLUDE SETTINGS HERE -->
  30. <div class="potree_container" style="position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; ">
  31. <div id="potree_render_area" style="background-image: url('../build/potree/resources/images/background.jpg');"></div>
  32. <div id="potree_sidebar_container"> </div>
  33. </div>
  34. <script type="module">
  35. import * as THREE from "../libs/three.js/build/three.module.js";
  36. window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
  37. viewer.setEDLEnabled(true);
  38. viewer.setFOV(60);
  39. viewer.setPointBudget(1_000_000);
  40. viewer.loadSettingsFromURL();
  41. viewer.setBackground("skybox");
  42. viewer.loadGUI(() => {
  43. viewer.setLanguage('en');
  44. $("#menu_scene").next().show();
  45. viewer.toggleSidebar();
  46. });
  47. viewer.setDescription(`
  48. This example shows various ways to use annotations.
  49. They can be used to bookmark and describe locations,
  50. move the camera to a predefined point of view on click,
  51. and to provide programmable buttons at specific locations.
  52. `);
  53. let sceneSG = new Potree.Scene();
  54. let sceneLion = new Potree.Scene();
  55. viewer.setScene(sceneSG);
  56. // Sorvilier point cloud in scene 1
  57. Potree.loadPointCloud("../pointclouds/vol_total/cloud.js", "sigeom.sa", function(e){
  58. sceneSG.addPointCloud(e.pointcloud);
  59. sceneSG.view.position.set(590030, 231767, 1007);
  60. sceneSG.view.lookAt(new THREE.Vector3(589844, 231376, 710));
  61. let material = e.pointcloud.material;
  62. material.size = 1;
  63. material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
  64. {
  65. {
  66. let elTitle = $(`
  67. <span>
  68. About Annotations
  69. <img src="${Potree.resourcePath}/icons/goto.svg"
  70. name="action_set_scene"
  71. class="annotation-action-icon"
  72. style="filter: invert(1);" />
  73. </span>
  74. `);
  75. elTitle.find("img[name=action_set_scene]").click( (event) => {
  76. event.stopPropagation();
  77. viewer.setScene(sceneLion);
  78. });
  79. elTitle.toString = () => "About Annotations";
  80. let aAbout1 = new Potree.Annotation({
  81. position: [590043.63, 231490.79, 740.78],
  82. title: elTitle,
  83. cameraPosition: [590105.53, 231541.63, 782.05],
  84. cameraTarget: [590043.63, 231488.79, 740.78],
  85. description: `<ul><li>Click on the annotation label to move a predefined view.</li>
  86. <li>Click on the icon to execute the specified action.</li>
  87. In this case, the action will bring you to another scene and point cloud.</ul>`
  88. });
  89. sceneSG.annotations.add(aAbout1);
  90. }
  91. {
  92. let aAbout2 = new Potree.Annotation({
  93. position: [589621, 231437, 784],
  94. "cameraPosition": [589585.81, 231463.63, 804.00],
  95. "cameraTarget": [589625.86, 231439, 775.38],
  96. "title": "About Annotations 2",
  97. "description": `
  98. Suitable annotation positions and views can be obtained by
  99. looking up the current camera position and target in the "Scene" panel,
  100. or by evaluating following lines in your browser's developer console:<br><br>
  101. <code>viewer.scene.view.position</code><br>
  102. <code>viewer.scene.view.getPivot()</code><br>
  103. `
  104. });
  105. sceneSG.annotations.add(aAbout2);
  106. }
  107. { // Annotation with action icons
  108. // Create title element with jquery
  109. let elTitle = $(`
  110. <span>
  111. <img name="action_elevation" src="${Potree.resourcePath}/icons/profile.svg" class="annotation-action-icon"/>
  112. <img name="action_rgb" src="${Potree.resourcePath}/icons/rgb.svg" class="annotation-action-icon"/>
  113. </span>`);
  114. elTitle.find("img[name=action_elevation]").click( () => {
  115. viewer.scene.pointclouds.forEach( pc => pc.material.activeAttributeName = "elevation" );
  116. });
  117. elTitle.find("img[name=action_rgb]").click( () => {
  118. viewer.scene.pointclouds.forEach( pc => pc.material.activeAttributeName = "rgba" );
  119. });
  120. // Give the annotation a meaningful string representation for the sidebar
  121. elTitle.toString = () => "Elevation / RGB Actions";
  122. // Same as with other annotations, except title is a jquery object this time.
  123. let aActions = new Potree.Annotation({
  124. position: [590012.986, 231273.294, 787.162],
  125. title: elTitle
  126. });
  127. sceneSG.annotations.add(aActions);
  128. }
  129. { // Annotation with action icons
  130. // Create title element with jquery
  131. let schemes = [
  132. {name: "SPECTRAL", icon: `${Potree.resourcePath}/icons/gradients_spectral.png`},
  133. {name: "YELLOW_GREEN", icon: `${Potree.resourcePath}/icons/gradients_yellow_green.png`},
  134. {name: "PLASMA", icon: `${Potree.resourcePath}/icons/gradients_plasma.png`},
  135. {name: "GRAYSCALE", icon: `${Potree.resourcePath}/icons/gradients_grayscale.png`},
  136. {name: "RAINBOW", icon: `${Potree.resourcePath}/icons/gradients_rainbow.png`},
  137. ];
  138. let elTitle = $(`<span>Gradient Schemes:</span>`);
  139. for(let scheme of schemes){
  140. let button = $(`<img src="${scheme.icon}" class="annotation-action-icon" style="width: 2em; height: auto;"/>`);
  141. button.click( () => {
  142. for(let pointcloud of viewer.scene.pointclouds){
  143. pointcloud.material.activeAttributeName = "elevation";
  144. pointcloud.material.gradient = Potree.Gradients[scheme.name];
  145. }
  146. });
  147. elTitle.append(button);
  148. }
  149. // Give the annotation a meaningful string representation for the sidebar
  150. elTitle.toString = () => "Gradient Color Selection";
  151. // Same as with other annotations, except title is a jquery object this time.
  152. let aActions = new Potree.Annotation({
  153. position: [589577.396, 231267.514, 807.655],
  154. title: elTitle,
  155. });
  156. sceneSG.annotations.add(aActions);
  157. }
  158. {
  159. let aTrees = new Potree.Annotation({
  160. position: [589850.15, 231300.10, 770.94],
  161. title: "Trees",
  162. description: `Point cloud of a small section in Sorvilier, Switzerland. <br>
  163. Courtesy of sigeom.sa`,
  164. });
  165. aTrees.domElement.off("mouseenter");
  166. aTrees.domElement.off("mouseleave");
  167. aTrees.addEventListener("click", () => {
  168. aTrees.setHighlighted(!aTrees.isHighlighted);
  169. });
  170. sceneSG.annotations.add(aTrees);
  171. }
  172. }
  173. });
  174. // Lion point cloud in scene 2
  175. Potree.loadPointCloud("../pointclouds/lion_takanawa/cloud.js", "lion", function(e){
  176. sceneLion.addPointCloud(e.pointcloud);
  177. sceneLion.view.position.set(4.15, -6.12, 8.54);
  178. sceneLion.view.lookAt(new THREE.Vector3(0, -0.098, 4.23));
  179. e.pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
  180. sceneLion.addAnnotation([0.72, -1, 8], {
  181. "title": "Chinese Guardian Lion",
  182. "actions": [{
  183. "icon": Potree.resourcePath + "/icons/goto.svg",
  184. "onclick": function(){
  185. viewer.setScene(sceneSG);
  186. }
  187. }]
  188. });
  189. });
  190. </script>
  191. </body>
  192. </html>