@abi-software/scaffoldvuer 1.21.1-beta.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -12
- package/dist/index.html +9 -6
- package/dist/scaffoldvuer.js +14095 -13154
- package/dist/scaffoldvuer.umd.cjs +48 -48
- package/dist/style.css +1 -1
- package/eslint.config.js +37 -9
- package/package.json +10 -3
- package/public/index.html +9 -6
- package/src/App.vue +312 -279
- package/src/ScaffoldVuer-wc.js +4 -4
- package/src/app/DropZone.vue +11 -27
- package/src/app/ModelsInformation.js +22 -19
- package/src/app/ModelsTable.vue +42 -65
- package/src/app/TextureDemos.js +38 -64
- package/src/assets/_variables.scss +12 -10
- package/src/components/GlyphsControls.vue +3 -23
- package/src/components/LinesControls.vue +27 -66
- package/src/components/OpacityControls.vue +22 -26
- package/src/components/PointsControls.vue +20 -71
- package/src/components/PrimitiveControls.vue +35 -49
- package/src/components/ScaffoldOverlay.vue +63 -63
- package/src/components/ScaffoldTooltip.vue +36 -49
- package/src/components/ScaffoldTreeControls.vue +81 -129
- package/src/components/ScaffoldVuer.vue +509 -498
- package/src/components/TextureSlidesControls.vue +22 -64
- package/src/components/TransformationControls.vue +15 -42
- package/src/components/index.js +2 -2
- package/src/main.js +16 -18
- package/src/scripts/Annotation.js +3 -3
- package/src/scripts/BaseModule.js +26 -30
- package/src/scripts/EventNotifier.js +30 -36
- package/src/scripts/GraphicsHighlight.js +43 -50
- package/src/scripts/LocalFilesHelper.js +27 -26
- package/src/scripts/MappedNerves.js +2139 -697
- package/src/scripts/MappedOrgans.js +24 -25
- package/src/scripts/OrgansRenderer.js +445 -425
- package/src/scripts/RendererModule.js +133 -122
- package/src/scripts/Search.js +135 -151
- package/src/scripts/Utilities.js +129 -127
- package/src/scripts/WebGL.js +57 -91
- package/src/scripts/niftiHelper.js +3 -3
- package/src/store/index.js +7 -7
- package/vite.config.js +51 -50
- package/vite.static-build.js +7 -7
- package/vuese-generator.js +48 -56
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import GPU_SUPPORT from './WebGL';
|
|
2
2
|
import Zinc from 'zincjs';
|
|
3
3
|
const THREE = Zinc.THREE;
|
|
4
4
|
import { BaseModule } from './BaseModule';
|
|
5
|
-
import { EVENT_TYPE } from
|
|
6
|
-
import GraphicsHighlight from
|
|
7
|
-
import { objectsToZincObjects } from
|
|
5
|
+
import { EVENT_TYPE } from './EventNotifier';
|
|
6
|
+
import GraphicsHighlight from './GraphicsHighlight';
|
|
7
|
+
import { objectsToZincObjects } from './Utilities';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Create a {@link Zinc.Renderer} on the dom element with corresponding elementID.
|
|
@@ -12,22 +12,29 @@ import { objectsToZincObjects } from "./Utilities";
|
|
|
12
12
|
* @returns {Zinc.Renderer}
|
|
13
13
|
*/
|
|
14
14
|
const createRenderer = async function () {
|
|
15
|
-
const localContainer = document.createElement(
|
|
16
|
-
let localRenderer = undefined
|
|
17
|
-
localContainer.style.height =
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
const localContainer = document.createElement('div');
|
|
16
|
+
let localRenderer = undefined;
|
|
17
|
+
localContainer.style.height = '100%';
|
|
18
|
+
if (await GPU_SUPPORT.isRendererSupported()) {
|
|
19
|
+
try {
|
|
20
|
+
localRenderer = new Zinc.Renderer(localContainer, window);
|
|
21
|
+
Zinc.defaultMaterialColor = 0xffff9c;
|
|
22
|
+
await localRenderer.initialiseVisualisation();
|
|
23
|
+
localRenderer.playAnimation = false;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
//Device or context creation can still fail after the support check.
|
|
26
|
+
console.error('Failed to initialise the renderer.', error);
|
|
27
|
+
localRenderer = undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (!localRenderer) {
|
|
31
|
+
const warning = GPU_SUPPORT.getErrorMessage();
|
|
25
32
|
localContainer.appendChild(warning);
|
|
26
33
|
}
|
|
27
|
-
return {Zinc,
|
|
28
|
-
}
|
|
34
|
+
return { Zinc, renderer: localRenderer, container: localContainer };
|
|
35
|
+
};
|
|
29
36
|
|
|
30
|
-
const RendererModule = function()
|
|
37
|
+
const RendererModule = function () {
|
|
31
38
|
BaseModule.call(this);
|
|
32
39
|
this.scene = undefined;
|
|
33
40
|
this.rendererContainer = undefined;
|
|
@@ -39,20 +46,18 @@ const RendererModule = function() {
|
|
|
39
46
|
this.selectedCenter = undefined;
|
|
40
47
|
this.liveUpdatesObjects = undefined;
|
|
41
48
|
this.ignorePreviousSelected = false;
|
|
42
|
-
}
|
|
49
|
+
};
|
|
43
50
|
|
|
44
51
|
RendererModule.prototype = Object.create(BaseModule.prototype);
|
|
45
52
|
|
|
46
|
-
RendererModule.prototype.getIntersectedObject = function(intersects) {
|
|
47
|
-
|
|
48
|
-
const typeMap = intersects.map(intersect => {
|
|
49
|
-
if (intersect && intersect.object &&
|
|
50
|
-
intersect.object.userData) {
|
|
53
|
+
RendererModule.prototype.getIntersectedObject = function (intersects) {
|
|
54
|
+
if (intersects) {
|
|
55
|
+
const typeMap = intersects.map((intersect) => {
|
|
56
|
+
if (intersect && intersect.object && intersect.object.userData) {
|
|
51
57
|
if (intersect.object.userData.isMarker) {
|
|
52
58
|
return 1;
|
|
53
|
-
} else if (intersect.object.name &&
|
|
54
|
-
intersect.object.
|
|
55
|
-
if (intersect.object.name === "_Unnamed") {
|
|
59
|
+
} else if (intersect.object.name && intersect.object.userData.isZincObject) {
|
|
60
|
+
if (intersect.object.name === '_Unnamed') {
|
|
56
61
|
return 3;
|
|
57
62
|
} else {
|
|
58
63
|
return 2;
|
|
@@ -68,14 +73,13 @@ RendererModule.prototype.getIntersectedObject = function(intersects) {
|
|
|
68
73
|
}
|
|
69
74
|
//Proritise objects that is not called _Unnamed
|
|
70
75
|
i = typeMap.indexOf(2);
|
|
71
|
-
i =
|
|
76
|
+
i = i > -1 ? i : typeMap.indexOf(3);
|
|
72
77
|
return intersects[i];
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
};
|
|
77
81
|
|
|
78
|
-
RendererModule.prototype.getAnnotationsFromObjects = function(objects, extraData) {
|
|
82
|
+
RendererModule.prototype.getAnnotationsFromObjects = function (objects, extraData) {
|
|
79
83
|
const annotations = [];
|
|
80
84
|
for (var i = 0; i < objects.length; i++) {
|
|
81
85
|
const zincObject = objects[i].userData;
|
|
@@ -90,7 +94,7 @@ RendererModule.prototype.getAnnotationsFromObjects = function(objects, extraData
|
|
|
90
94
|
if (annotation && annotation.data) {
|
|
91
95
|
if (extraData && 'instanceId' in extraData) {
|
|
92
96
|
annotation.data.id = glyphset.getLabel(extraData.instanceId);
|
|
93
|
-
} else if (objects[i].name && objects[i].name !=
|
|
97
|
+
} else if (objects[i].name && objects[i].name != '') {
|
|
94
98
|
annotation.data.id = objects[i].name;
|
|
95
99
|
} else {
|
|
96
100
|
annotation.data.id = glyphset.groupName;
|
|
@@ -98,7 +102,7 @@ RendererModule.prototype.getAnnotationsFromObjects = function(objects, extraData
|
|
|
98
102
|
}
|
|
99
103
|
} else {
|
|
100
104
|
annotation = zincObject.userData ? zincObject.userData.annotation : undefined;
|
|
101
|
-
if (annotation && annotation.data){
|
|
105
|
+
if (annotation && annotation.data) {
|
|
102
106
|
annotation.data.id = objects[i].name;
|
|
103
107
|
}
|
|
104
108
|
}
|
|
@@ -108,20 +112,24 @@ RendererModule.prototype.getAnnotationsFromObjects = function(objects, extraData
|
|
|
108
112
|
annotation.data.zincObject = zincObject;
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
|
-
if (annotation)
|
|
112
|
-
annotations.push(annotation);
|
|
115
|
+
if (annotation) annotations.push(annotation);
|
|
113
116
|
}
|
|
114
|
-
|
|
115
|
-
}
|
|
117
|
+
return annotations;
|
|
118
|
+
};
|
|
116
119
|
|
|
117
|
-
RendererModule.prototype.setHighlightedByObjects = function(
|
|
118
|
-
objects,
|
|
120
|
+
RendererModule.prototype.setHighlightedByObjects = function (
|
|
121
|
+
objects,
|
|
122
|
+
coords,
|
|
123
|
+
extraData,
|
|
124
|
+
propagateChanges,
|
|
125
|
+
) {
|
|
119
126
|
const zincObjects = objectsToZincObjects(objects);
|
|
120
127
|
const changed = this.graphicsHighlight.setHighlighted(objects);
|
|
128
|
+
//Some highlights are applied to THREE.js materials directly
|
|
129
|
+
if (changed) this.zincRenderer?.invalidate?.();
|
|
121
130
|
if (propagateChanges) {
|
|
122
131
|
let eventType = EVENT_TYPE.MOVE;
|
|
123
|
-
if (changed)
|
|
124
|
-
eventType = EVENT_TYPE.HIGHLIGHTED;
|
|
132
|
+
if (changed) eventType = EVENT_TYPE.HIGHLIGHTED;
|
|
125
133
|
const annotations = this.getAnnotationsFromObjects(objects, extraData);
|
|
126
134
|
if (annotations.length > 0) {
|
|
127
135
|
annotations[0].coords = coords;
|
|
@@ -130,25 +138,27 @@ RendererModule.prototype.setHighlightedByObjects = function(
|
|
|
130
138
|
this.publishChanges(annotations, eventType, zincObjects);
|
|
131
139
|
}
|
|
132
140
|
return changed;
|
|
133
|
-
}
|
|
141
|
+
};
|
|
134
142
|
|
|
143
|
+
RendererModule.prototype.setHighlightedByZincObjects = function (
|
|
144
|
+
zincObjects,
|
|
145
|
+
coords,
|
|
146
|
+
extraData,
|
|
147
|
+
propagateChanges,
|
|
148
|
+
) {
|
|
149
|
+
let morphs = [];
|
|
150
|
+
if (zincObjects) {
|
|
151
|
+
zincObjects.forEach((zincObject) => {
|
|
152
|
+
if (zincObject && zincObject.getMorph()) morphs.push(zincObject.getMorph());
|
|
153
|
+
});
|
|
154
|
+
}
|
|
135
155
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
let morphs = [];
|
|
139
|
-
if (zincObjects) {
|
|
140
|
-
zincObjects.forEach(zincObject => {
|
|
141
|
-
if (zincObject && zincObject.getMorph())
|
|
142
|
-
morphs.push(zincObject.getMorph());
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return this.setHighlightedByObjects(morphs, coords, extraData, propagateChanges);
|
|
147
|
-
}
|
|
156
|
+
return this.setHighlightedByObjects(morphs, coords, extraData, propagateChanges);
|
|
157
|
+
};
|
|
148
158
|
|
|
149
|
-
RendererModule.prototype.setupLiveCoordinates = function(zincObjects) {
|
|
159
|
+
RendererModule.prototype.setupLiveCoordinates = function (zincObjects) {
|
|
150
160
|
this.liveUpdatesObjects = zincObjects;
|
|
151
|
-
if (zincObjects &&
|
|
161
|
+
if (zincObjects && zincObjects.length > 0) {
|
|
152
162
|
const boundingBox = this.scene.getBoundingBoxOfZincObjects(zincObjects);
|
|
153
163
|
let newSelectedCenter = new THREE.Vector3();
|
|
154
164
|
if (boundingBox) {
|
|
@@ -164,14 +174,19 @@ RendererModule.prototype.setupLiveCoordinates = function(zincObjects) {
|
|
|
164
174
|
} else {
|
|
165
175
|
this.selectedCenter = undefined;
|
|
166
176
|
}
|
|
167
|
-
}
|
|
177
|
+
};
|
|
168
178
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
179
|
+
RendererModule.prototype.setSelectedByObjects = function (
|
|
180
|
+
objects,
|
|
181
|
+
coords,
|
|
182
|
+
extraData,
|
|
183
|
+
propagateChanges,
|
|
184
|
+
) {
|
|
185
|
+
let changed;
|
|
173
186
|
if (this.selectObjectOnPick) {
|
|
174
187
|
changed = this.graphicsHighlight.setSelected(objects);
|
|
188
|
+
//Some highlights are applied to THREE.js materials directly
|
|
189
|
+
if (changed) this.zincRenderer?.invalidate?.();
|
|
175
190
|
} else {
|
|
176
191
|
changed = true;
|
|
177
192
|
}
|
|
@@ -191,13 +206,17 @@ RendererModule.prototype.setSelectedByObjects = function(
|
|
|
191
206
|
}
|
|
192
207
|
}
|
|
193
208
|
return changed;
|
|
194
|
-
}
|
|
209
|
+
};
|
|
195
210
|
|
|
196
|
-
RendererModule.prototype.setSelectedByZincObjects = function(
|
|
197
|
-
zincObjects,
|
|
211
|
+
RendererModule.prototype.setSelectedByZincObjects = function (
|
|
212
|
+
zincObjects,
|
|
213
|
+
coords,
|
|
214
|
+
extraData,
|
|
215
|
+
propagateChanges,
|
|
216
|
+
) {
|
|
198
217
|
let morphs = [];
|
|
199
218
|
if (zincObjects) {
|
|
200
|
-
zincObjects.forEach(zincObject => {
|
|
219
|
+
zincObjects.forEach((zincObject) => {
|
|
201
220
|
if (zincObject) {
|
|
202
221
|
const morph = zincObject.getMorph();
|
|
203
222
|
if (morph) {
|
|
@@ -208,101 +227,93 @@ RendererModule.prototype.setSelectedByZincObjects = function(
|
|
|
208
227
|
}
|
|
209
228
|
|
|
210
229
|
return this.setSelectedByObjects(morphs, coords, extraData, propagateChanges);
|
|
211
|
-
}
|
|
230
|
+
};
|
|
212
231
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
232
|
+
// Unused function, but keep it for reference.
|
|
233
|
+
// const addGlyphToArray = function (objects) {
|
|
234
|
+
// return function (glyph) {
|
|
235
|
+
// objects.push(glyph.getMesh());
|
|
236
|
+
// };
|
|
237
|
+
// };
|
|
218
238
|
|
|
219
|
-
RendererModule.prototype.findObjectsByGroupName = function(groupName) {
|
|
239
|
+
RendererModule.prototype.findObjectsByGroupName = function (groupName) {
|
|
220
240
|
return this.scene.findObjectsWithGroupName(groupName);
|
|
221
|
-
}
|
|
241
|
+
};
|
|
222
242
|
|
|
223
|
-
RendererModule.prototype.setHighlightedByGroupName = function(groupName, propagateChanges) {
|
|
243
|
+
RendererModule.prototype.setHighlightedByGroupName = function (groupName, propagateChanges) {
|
|
224
244
|
const objects = this.findObjectsByGroupName(groupName);
|
|
225
245
|
return this.setHighlightedByObjects(objects, undefined, {}, propagateChanges);
|
|
226
|
-
}
|
|
246
|
+
};
|
|
227
247
|
|
|
228
|
-
RendererModule.prototype.setSelectedByGroupName = function(groupName, propagateChanges) {
|
|
248
|
+
RendererModule.prototype.setSelectedByGroupName = function (groupName, propagateChanges) {
|
|
229
249
|
const objects = this.findObjectsByGroupName(groupName);
|
|
230
250
|
return this.setSelectedByObjects(objects, undefined, {}, propagateChanges);
|
|
231
|
-
}
|
|
251
|
+
};
|
|
232
252
|
|
|
233
|
-
RendererModule.prototype.changeBackgroundColour = function(backgroundColourString) {
|
|
253
|
+
RendererModule.prototype.changeBackgroundColour = function (backgroundColourString) {
|
|
234
254
|
const colour = new THREE.Color(backgroundColourString);
|
|
235
255
|
if (this.zincRenderer) {
|
|
236
256
|
let internalRenderer = this.zincRenderer.getThreeJSRenderer();
|
|
237
|
-
internalRenderer.setClearColor(
|
|
257
|
+
internalRenderer.setClearColor(colour, 1);
|
|
238
258
|
}
|
|
239
|
-
}
|
|
259
|
+
};
|
|
240
260
|
|
|
241
|
-
RendererModule.prototype.resetView = function() {
|
|
242
|
-
if (this.zincRenderer)
|
|
243
|
-
|
|
244
|
-
}
|
|
261
|
+
RendererModule.prototype.resetView = function () {
|
|
262
|
+
if (this.zincRenderer) this.zincRenderer.resetView();
|
|
263
|
+
};
|
|
245
264
|
|
|
246
|
-
RendererModule.prototype.viewAll = function() {
|
|
247
|
-
if (this.zincRenderer)
|
|
248
|
-
|
|
249
|
-
}
|
|
265
|
+
RendererModule.prototype.viewAll = function () {
|
|
266
|
+
if (this.zincRenderer) this.zincRenderer.viewAll();
|
|
267
|
+
};
|
|
250
268
|
|
|
251
269
|
/**
|
|
252
270
|
* Start the animation and let the renderer to processs with
|
|
253
271
|
* time progression
|
|
254
272
|
*/
|
|
255
|
-
RendererModule.prototype.playAnimation = function(flag) {
|
|
256
|
-
if (this.zincRenderer)
|
|
257
|
-
|
|
258
|
-
}
|
|
273
|
+
RendererModule.prototype.playAnimation = function (flag) {
|
|
274
|
+
if (this.zincRenderer) this.zincRenderer.playAnimation = flag;
|
|
275
|
+
};
|
|
259
276
|
|
|
260
277
|
/**
|
|
261
|
-
* Set the speed of playback
|
|
262
|
-
*/
|
|
263
|
-
RendererModule.prototype.setPlayRate = function(value) {
|
|
264
|
-
if (this.zincRenderer)
|
|
265
|
-
|
|
266
|
-
}
|
|
278
|
+
* Set the speed of playback
|
|
279
|
+
*/
|
|
280
|
+
RendererModule.prototype.setPlayRate = function (value) {
|
|
281
|
+
if (this.zincRenderer) this.zincRenderer.setPlayRate(value);
|
|
282
|
+
};
|
|
267
283
|
|
|
268
284
|
/**
|
|
269
|
-
* Get the speed of playback
|
|
270
|
-
*/
|
|
271
|
-
RendererModule.prototype.getPlayRate = function(
|
|
272
|
-
if (this.zincRenderer)
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
return 0.0;
|
|
276
|
-
}
|
|
285
|
+
* Get the speed of playback
|
|
286
|
+
*/
|
|
287
|
+
RendererModule.prototype.getPlayRate = function (_value) {
|
|
288
|
+
if (this.zincRenderer) return this.zincRenderer.getPlayRate();
|
|
289
|
+
else return 0.0;
|
|
290
|
+
};
|
|
277
291
|
|
|
278
|
-
|
|
292
|
+
/** Initialise everything in the renderer, including the 3D renderer,
|
|
279
293
|
* and picker for the 3D renderer.
|
|
280
294
|
*
|
|
281
295
|
*/
|
|
282
|
-
RendererModule.prototype.initialiseRenderer = async function(displayAreaIn) {
|
|
296
|
+
RendererModule.prototype.initialiseRenderer = async function (displayAreaIn) {
|
|
283
297
|
if (this.zincRenderer === undefined || this.rendererContainer === undefined) {
|
|
284
298
|
let returnedValue = await createRenderer();
|
|
285
|
-
this.Zinc = returnedValue[
|
|
286
|
-
this.zincRenderer = returnedValue[
|
|
287
|
-
this.rendererContainer = returnedValue[
|
|
299
|
+
this.Zinc = returnedValue['Zinc'];
|
|
300
|
+
this.zincRenderer = returnedValue['renderer'];
|
|
301
|
+
this.rendererContainer = returnedValue['container'];
|
|
288
302
|
}
|
|
289
303
|
if (displayAreaIn) {
|
|
290
304
|
this.displayArea = displayAreaIn;
|
|
291
|
-
this.displayArea.appendChild(
|
|
292
|
-
if (this.zincRenderer)
|
|
293
|
-
this.zincRenderer.animate();
|
|
305
|
+
this.displayArea.appendChild(this.rendererContainer);
|
|
306
|
+
if (this.zincRenderer) this.zincRenderer.animate();
|
|
294
307
|
}
|
|
295
|
-
}
|
|
308
|
+
};
|
|
296
309
|
|
|
297
|
-
RendererModule.prototype.destroy = function() {
|
|
310
|
+
RendererModule.prototype.destroy = function () {
|
|
298
311
|
if (this.zincRenderer) {
|
|
299
312
|
this.zincRenderer.dispose();
|
|
300
313
|
this.zincRenderer.getThreeJSRenderer().dispose();
|
|
301
314
|
this.zincRenderer = undefined;
|
|
302
315
|
}
|
|
303
|
-
BaseModule.prototype.destroy.call(
|
|
304
|
-
}
|
|
316
|
+
BaseModule.prototype.destroy.call(this);
|
|
317
|
+
};
|
|
305
318
|
|
|
306
|
-
export {
|
|
307
|
-
RendererModule
|
|
308
|
-
}
|
|
319
|
+
export { RendererModule };
|