-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteCubes.js
More file actions
56 lines (46 loc) · 1.71 KB
/
deleteCubes.js
File metadata and controls
56 lines (46 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// deleteCubes.js
import { getData, setData } from './dataManager.js';
// For data operations
export function deleteSelectedFromData(pmidsToDelete) {
console.groupCollapsed('[deleteSelectedFromData] Deleting data for PMIDs:', pmidsToDelete);
const currentData = getData();
console.log('Current data count before deletion:', currentData.length);
if (!Array.isArray(pmidsToDelete)) {
console.warn('Invalid pmidsToDelete - expected array but got:', pmidsToDelete);
console.groupEnd();
return currentData;
}
const newData = currentData.filter(item => {
const shouldKeep = !pmidsToDelete.includes(item.PMID);
if (!shouldKeep) {
console.log('Removing article:', { pmid: item.PMID, title: item.Title });
}
return shouldKeep;
});
console.log('New data count after deletion:', newData.length);
console.log('Deleted count:', currentData.length - newData.length);
setData(newData);
console.groupEnd();
return newData;
}
// For scene operations
export function deleteSelectedCubes(selectedCubes, scene) {
console.groupCollapsed('[deleteSelectedCubes] Removing cubes from scene');
if (!selectedCubes || !selectedCubes.length) {
console.log('No cubes to delete');
console.groupEnd();
return [];
}
console.log('Deleting', selectedCubes.length, 'cubes');
selectedCubes.forEach(cube => {
console.log('Removing cube:', {
pmid: cube.userData.PMID,
position: cube.position,
title: cube.userData.Title
});
scene.remove(cube);
});
console.log('Deletion complete');
console.groupEnd();
return [];
}