Actions.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import * as THREE from "../libs/three.js/build/three.module.js";
  2. export class Action extends THREE.EventDispatcher {
  3. constructor (args = {}) {
  4. super();
  5. this.icon = args.icon || '';
  6. this.tooltip = args.tooltip;
  7. if (args.onclick !== undefined) {
  8. this.onclick = args.onclick;
  9. }
  10. }
  11. onclick (event) {
  12. }
  13. pairWith (object) {
  14. }
  15. setIcon (newIcon) {
  16. let oldIcon = this.icon;
  17. if (newIcon === oldIcon) {
  18. return;
  19. }
  20. this.icon = newIcon;
  21. this.dispatchEvent({
  22. type: 'icon_changed',
  23. action: this,
  24. icon: newIcon,
  25. oldIcon: oldIcon
  26. });
  27. }
  28. };
  29. //Potree.Actions = {};
  30. //
  31. //Potree.Actions.ToggleAnnotationVisibility = class ToggleAnnotationVisibility extends Potree.Action {
  32. // constructor (args = {}) {
  33. // super(args);
  34. //
  35. // this.icon = Potree.resourcePath + '/icons/eye.svg';
  36. // this.showIn = 'sidebar';
  37. // this.tooltip = 'toggle visibility';
  38. // }
  39. //
  40. // pairWith (annotation) {
  41. // if (annotation.visible) {
  42. // this.setIcon(Potree.resourcePath + '/icons/eye.svg');
  43. // } else {
  44. // this.setIcon(Potree.resourcePath + '/icons/eye_crossed.svg');
  45. // }
  46. //
  47. // annotation.addEventListener('visibility_changed', e => {
  48. // let annotation = e.annotation;
  49. //
  50. // if (annotation.visible) {
  51. // this.setIcon(Potree.resourcePath + '/icons/eye.svg');
  52. // } else {
  53. // this.setIcon(Potree.resourcePath + '/icons/eye_crossed.svg');
  54. // }
  55. // });
  56. // }
  57. //
  58. // onclick (event) {
  59. // let annotation = event.annotation;
  60. //
  61. // annotation.visible = !annotation.visible;
  62. //
  63. // if (annotation.visible) {
  64. // this.setIcon(Potree.resourcePath + '/icons/eye.svg');
  65. // } else {
  66. // this.setIcon(Potree.resourcePath + '/icons/eye_crossed.svg');
  67. // }
  68. // }
  69. //};