BoundingBox.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. module INSPECTOR{
  2. /** Any object implementing this interface should
  3. * provide methods to toggle its bounding box
  4. */
  5. export interface IToolBoundingBox {
  6. isBoxVisible : () => boolean,
  7. setBoxVisible : (b:boolean) => void;
  8. }
  9. /**
  10. * Checkbox to display/hide the primitive
  11. */
  12. export class BoundingBox extends AbstractTreeTool{
  13. private _obj : IToolBoundingBox;
  14. constructor(obj:IToolBoundingBox) {
  15. super ();
  16. this._obj = obj;
  17. this._elem.classList.add('fa-cube');
  18. this._on = this._obj.isBoxVisible();
  19. this._check();
  20. }
  21. // For a checkbox, set visible/invisible the corresponding prim
  22. protected action() {
  23. super.action();
  24. // update object and gui according to the new status
  25. this._check();
  26. }
  27. private _check() {
  28. if (this._on) {
  29. // set icon eye
  30. this._elem.classList.add('active');
  31. }else {
  32. // set icon eye-slash
  33. this._elem.classList.remove('active');
  34. }
  35. this._obj.setBoxVisible(this._on);
  36. }
  37. }
  38. }