Skip to content

Commit bf38a9f

Browse files
committed
new API for the orthographic camera to allow user easily navigate between default, axial, coronal and sagittal views
1 parent 997b51c commit bf38a9f

File tree

8 files changed

+455
-66
lines changed

8 files changed

+455
-66
lines changed

examples/loader_nifti/loader_nifti.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ window.onload = function() {
8787

8888
// load vtk file
8989
var loader1 = new THREE.VTKLoader();
90-
loader1.load( '../../data/blood.vtk', function ( geometry ) {
90+
loader1.load( '../../blood1.vtk', function ( geometry ) {
9191
geometry.computeVertexNormals();
9292
console.log( geometry );
9393
var material = new THREE.MeshLambertMaterial( {
@@ -114,6 +114,7 @@ window.onload = function() {
114114
var files = t2.map(function(v) {
115115
return 'https://cdn.rawgit.com/FNNDSC/data/master/nifti/fetalatlas_brain/t2/' + v;
116116
});
117+
files = ['../../data/MRBrainTumor1_PIL.nii'];
117118

118119
// load sequence for each file
119120
let seriesContainer = [];

examples/viewers_compare/viewers_compare.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ function init() {
125125
controls = new ControlsOrthographic(camera, threeD);
126126
controls.staticMoving = true;
127127
controls.noRotate = true;
128+
camera.controls = controls;
128129

129130
animate();
130131
}
@@ -445,17 +446,21 @@ window.onload = function() {
445446
);
446447

447448
// box: {halfDimensions, center}
448-
let bbox = {
449+
let box = {
449450
center: stack.worldCenter().clone(),
450-
halfDimensions: new THREE.Vector3(lpsDims.x + 500, lpsDims.y + 500, lpsDims.z + 500)
451+
halfDimensions: new THREE.Vector3(lpsDims.x + 50, lpsDims.y + 50, lpsDims.z + 50)
451452
};
452453

453454
// init and zoom
454455
let canvas = {
455456
width: threeD.clientWidth,
456457
height: threeD.clientHeight
457458
};
458-
camera.init(stack.xCosine, stack.yCosine, stack.zCosine, controls, bbox, canvas);
459+
460+
camera.directions = [stack.xCosine, stack.yCosine, stack.zCosine];
461+
camera.box = box;
462+
camera.canvas = canvas;
463+
camera.update();
459464
camera.fitBox(2);
460465

461466
// CREATE LUT

examples/viewers_labelmap/viewers_labelmap.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ function init() {
9797
controls = new ControlsOrthographic(camera, threeD);
9898
controls.staticMoving = true;
9999
controls.noRotate = true;
100+
camera.controls = controls;
100101

101102
animate();
102103
}
@@ -573,7 +574,7 @@ let ds2 = [
573574
);
574575

575576
// box: {halfDimensions, center}
576-
let bbox = {
577+
let box = {
577578
center: stack.worldCenter().clone(),
578579
halfDimensions: new THREE.Vector3(lpsDims.x + 10, lpsDims.y + 10, lpsDims.z + 10)
579580
};
@@ -583,7 +584,10 @@ let ds2 = [
583584
width: threeD.clientWidth,
584585
height: threeD.clientHeight
585586
};
586-
camera.init(stack.xCosine, stack.yCosine, stack.zCosine, controls, bbox, canvas);
587+
camera.directions = [stack.xCosine, stack.yCosine, stack.zCosine];
588+
camera.box = box;
589+
camera.canvas = canvas;
590+
camera.update();
587591
camera.fitBox(2);
588592

589593
// CREATE LUT

examples/viewers_upload/viewers_upload.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ let drag = {
2020
let camUtils = {
2121
invertRows: false,
2222
invertColumns: false,
23-
rotate: false
23+
rotate: false,
24+
orientation: 'default',
25+
convention: 'radio'
2426
};
2527

2628
// FUNCTIONS
@@ -64,6 +66,7 @@ function init() {
6466
controls = new ControlsOrthographic(camera, threeD);
6567
controls.staticMoving = true;
6668
controls.noRotate = true;
69+
camera.controls = controls;
6770

6871
animate();
6972
}
@@ -137,6 +140,21 @@ window.onload = function() {
137140
camera.rotate();
138141
});
139142

143+
let orientationUpdate = cameraFolder.add(camUtils, 'orientation', ['default', 'axial', 'coronal', 'sagittal']);
144+
orientationUpdate.onChange(function(value) {
145+
camera.orientation = value;
146+
camera.update();
147+
camera.fitBox(2);
148+
stackHelper.orientation = camera.stackOrientation;
149+
});
150+
151+
let conventionUpdate = cameraFolder.add(camUtils, 'convention', ['radio', 'neuro']);
152+
conventionUpdate.onChange(function(value) {
153+
camera.convention = value;
154+
camera.update();
155+
camera.fitBox(2);
156+
});
157+
140158
cameraFolder.open();
141159
}
142160

@@ -233,7 +251,7 @@ window.onload = function() {
233251
);
234252

235253
// box: {halfDimensions, center}
236-
let bbox = {
254+
let box = {
237255
center: stack.worldCenter().clone(),
238256
halfDimensions: new THREE.Vector3(lpsDims.x + 10, lpsDims.y + 10, lpsDims.z + 10)
239257
};
@@ -243,7 +261,11 @@ window.onload = function() {
243261
width: threeD.clientWidth,
244262
height: threeD.clientHeight
245263
};
246-
camera.init(stack.xCosine, stack.yCosine, stack.zCosine, controls, bbox, canvas);
264+
265+
camera.directions = [stack.xCosine, stack.yCosine, stack.zCosine];
266+
camera.box = box;
267+
camera.canvas = canvas;
268+
camera.update();
247269
camera.fitBox(2);
248270

249271
buildGUI(stackHelper);

lessons/03/demo.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var camera = new CamerasOrthographic(container.clientWidth / -2, container.clien
2626
var controls = new ControlsOrthographic(camera, container);
2727
controls.staticMoving = true;
2828
controls.noRotate = true;
29+
camera.controls = controls;
2930

3031
// handle resize
3132
function onWindowResize() {
@@ -46,16 +47,19 @@ window.addEventListener('resize', onWindowResize, false);
4647
function gui(stackHelper){
4748

4849
var gui = new dat.GUI({
49-
autoPlace: false
50+
autoPlace: false
5051
});
52+
5153
var customContainer = document.getElementById('my-gui-container');
5254
customContainer.appendChild(gui.domElement);
5355
// only reason to use this object is to satusfy data.GUI
5456
var camUtils = {
5557
invertRows: false,
5658
invertColumns: false,
5759
rotate45: false,
58-
rotate: 0
60+
rotate: 0,
61+
orientation: 'default',
62+
convention: 'radio'
5963
};
6064

6165
// camera
@@ -77,6 +81,21 @@ function gui(stackHelper){
7781

7882
var rotate = cameraFolder.add(camera, 'angle', 0, 360).step(1).listen();
7983

84+
let orientationUpdate = cameraFolder.add(camUtils, 'orientation', ['default', 'axial', 'coronal', 'sagittal']);
85+
orientationUpdate.onChange(function(value) {
86+
camera.orientation = value;
87+
camera.update();
88+
camera.fitBox(2);
89+
stackHelper.orientation = camera.stackOrientation;
90+
});
91+
92+
let conventionUpdate = cameraFolder.add(camUtils, 'convention', ['radio', 'neuro']);
93+
conventionUpdate.onChange(function(value) {
94+
camera.convention = value;
95+
camera.update();
96+
camera.fitBox(2);
97+
});
98+
8099
cameraFolder.open();
81100

82101
// of course we can do everything from lesson 01!
@@ -100,13 +119,7 @@ animate();
100119

101120
// Setup loader
102121
var loader = new LoadersVolume(container);
103-
104-
var t2 = [
105-
'36444280', '36444294', '36444308', '36444322', '36444336'
106-
];
107-
var files = t2.map(function(v) {
108-
return 'https://cdn.rawgit.com/FNNDSC/data/master/dicom/adi_brain/' + v;
109-
});
122+
var files = ['https://cdn.rawgit.com/FNNDSC/data/master/nifti/adi_brain/adi_brain.nii.gz'];
110123

111124
// load sequence for each file
112125
// 1- fetch
@@ -173,7 +186,7 @@ Promise
173186
);
174187

175188
// box: {halfDimensions, center}
176-
var bbox = {
189+
var box = {
177190
center: stack.worldCenter().clone(),
178191
halfDimensions: new THREE.Vector3(lpsDims.x + 10, lpsDims.y + 10, lpsDims.z + 10)
179192
};
@@ -183,8 +196,13 @@ Promise
183196
width: container.clientWidth,
184197
height: container.clientHeight
185198
};
186-
camera.init(stack.xCosine, stack.yCosine, stack.zCosine, controls, bbox, canvas);
199+
200+
camera.directions = [stack.xCosine, stack.yCosine, stack.zCosine];
201+
camera.box = box;
202+
camera.canvas = canvas;
203+
camera.update();
187204
camera.fitBox(2);
205+
188206
})
189207
.catch(function(error) {
190208
window.console.log('oops... something went wrong...');

lessons/04/demo.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ function init() {
101101
controls = new ControlsOrthographic(camera, threeD);
102102
controls.staticMoving = true;
103103
controls.noRotate = true;
104+
camera.controls = controls;
104105

105106
animate();
106107
}
@@ -388,7 +389,7 @@ function handleSeries() {
388389
);
389390

390391
// box: {halfDimensions, center}
391-
var bbox = {
392+
var box = {
392393
center: stack.worldCenter().clone(),
393394
halfDimensions: new THREE.Vector3(lpsDims.x + 10, lpsDims.y + 10, lpsDims.z + 10)
394395
};
@@ -398,7 +399,10 @@ function handleSeries() {
398399
width: threeD.clientWidth,
399400
height: threeD.clientHeight
400401
};
401-
camera.init(stack.xCosine, stack.yCosine, stack.zCosine, controls, bbox, canvas, stack.referenceSpace);
402+
camera.directions = [stack.xCosine, stack.yCosine, stack.zCosine];
403+
camera.box = box;
404+
camera.canvas = canvas;
405+
camera.update();
402406
camera.fitBox(2);
403407

404408
// CREATE LUT

0 commit comments

Comments
 (0)