yskang

threejs-viewer-24

May 5th, 2021
643
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 修改 Viewer.js
  2. buildContextMenu() {
  3.  
  4.     // ... other code snippets
  5.  
  6.     this.container.addEventListener('contextmenu', () => {
  7.       const hideSelectedMenuItem1 = document.querySelector('#contextMenu li[data-key="hide-selected"]');
  8.       const hideSelectedMenuItem2 = document.querySelector('#contextMenu li[data-key="isolate-selected"]');
  9.  
  10.       if (this.selection.length > 0) {
  11.         hideSelectedMenuItem1.style.display = 'block';
  12.         hideSelectedMenuItem2.style.display = 'block';
  13.       } else {
  14.         hideSelectedMenuItem1.style.display = 'none';
  15.         hideSelectedMenuItem2.style.display = 'none';
  16.       }
  17.     });
  18.  
  19.     document.addEventListener('keydown', (event) => {
  20.       if ((event.key == 'Escape' || event.key == 'Esc' || event.keyCode == 27)) {
  21.         event.preventDefault();
  22.  
  23.         this.clearSelection();
  24.  
  25.         return false;
  26.       }
  27.     });
  28.   }
RAW Paste Data