/**
* @class
* This objects holds references to the main components of the system: renderer,
* volume, surface, seedLine and parameters for the surface generation and rendering.
*
* It also provides functions to trigger recalculation of the surface and the rendered
* scene.
*/
function Options(seedLine, volume, surface, rendering, numIt) {
this.rendering = rendering;
this.volume = volume;
this.surface = surface;
this.numIt = numIt;
this.numPts = this.surface.positions.length;
this.seedLine = seedLine;
this.mode = 'Test 1';
this.refresh = function() {
this.surface.calculate(this.volume, this.seedLine, this.numIt);
this.rendering.initSurface(this.surface);
this.rendering.initScene(this.surface);
this.rendering.initSeedLine();
this.rendering.render();
this.numPts = this.surface.positions.length;
};
this.resetCam = function() {
this.rendering.resetCamera();
this.rendering.render();
}
};
/**
* This function initializes the graphical user interface.
*/
function initGUI(seedLine, volume, surface, rendering, numIt) {
var options = new Options(seedLine, volume, surface, rendering, numIt);
var gui = new dat.GUI();
var fSeedline = gui.addFolder('Seedline');
var x = fSeedline.add(options.seedLine.start, 'x', 0.0, 1.0).name('Start x');
x.onChange(
function(value) {
options.refresh();
}
);
x.listen();
x = fSeedline.add(options.seedLine.start, 'y', 0.0, 1.0).name('Start y');
x.onChange(
function(value) {
options.refresh();
}
);
x.listen();
x = fSeedline.add(options.seedLine.start, 'z', 0.0, 1.0).name('Start z');
x.onChange(
function(value) {
options.refresh();
}
);
x.listen();
x = fSeedline.add(options.seedLine.end, 'x', 0.0, 1.0).name('End x');
x.onChange(
function(value) {
options.refresh();
}
);
x.listen();
x = fSeedline.add(options.seedLine.end, 'y', 0.0, 1.0).name('End y');
x.onChange(
function(value) {
options.refresh();
}
);
x.listen();
x = fSeedline.add(options.seedLine.end, 'z', 0.0, 1.0).name('End z');
x.onChange(
function(value) {
options.refresh();
}
);
x.listen();
fSeedline.add(options.seedLine, 'interval', 0.005, 0.02).name('Point Interval').onChange(
function(value) {
options.refresh();
}
);
var fSurface = gui.addFolder('Surface Generation');
fSurface.add(options, 'numIt', 20, 200).name('# iterations').onChange(
function(value) {
options.refresh();
}
);
x = fSurface.add(options.rendering, 'colored', false);
x.onChange(
function(value) {
options.rendering.colored = value;
options.rendering.render();
}
);
x = fSurface.add(options, 'mode', ['Tornado', 'Test 1']);
x.name('Volume Data');
x.onChange(
function(value) {
if (value == 'Tornado') {
options.volume.generateTornado(10);
options.refresh();
} else if (value == 'Test 1') {
options.volume.generateTest1();
options.refresh();
}
}
);
fSurface.add(options, 'numPts').listen();
fSeedline.open();
fSurface.open();
gui.add(options, 'refresh').name('Refresh!');
gui.add(options, 'resetCam').name('Reset camera!');
}