Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 修改 Viewer.js
- buildContextMenu() {
- // ... other code snippets
- const callBack = (key) => {
- let objects, dbId;
- switch (key) {
- case 'hide-selected':
- if (this.selection.length <= 0) return;
- dbId = this.selection[0];
- this.clearSelection();
- objects = this.models.map(m => m.getObjectById(dbId));
- if (!objects || objects.length <= 0) return;
- objects.forEach(obj => obj.visible = false);
- break;
- case 'isolate-selected':
- if (this.selection.length <= 0) return;
- dbId = this.selection[0];
- this.clearSelection();
- this.models.forEach(m => {
- m.traverse(child => {
- if (child.type !== 'Mesh') return;
- if (child.id === dbId) {
- child.visible = true;
- return;
- }
- child.visible = false;
- });
- });
- break;
- case 'show-all':
- this.models.forEach(m => {
- m.traverse(child => {
- if (child.type !== 'Mesh' || child.visible) return;
- child.visible = true;
- });
- });
- break;
- }
- };
- // ... other code snippets
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement