XTK Lesson 12
Curvature!
author(s):
XTK
HTML
<script src="https://get.goXTK.com/xtk_xdat.gui.js"></script>
CSS
html, body {
background-color:#000;
margin: 0;
padding: 0;
height: 100%;
overflow: hidden !important;
}
JavaScript
window.onload = function() {
// create and initialize a 3D renderer
var r = new X.renderer3D();
r.init();
// create a new X.mesh
mesh = new X.mesh();
// change the color to grey
mesh.color = [0.5, 0.5, 0.5];
// and attach a freesurfer mesh
mesh.file = 'https://fly.cs.umb.edu/data/X/lh.smoothwm';
// load curvature values from a .crv file
// it would also be possible to create an X.scalars object and
// configure an array using 'X.scalars.array = arr;' to be independent from a
// file format
// in this case we choose the 'C' curvature as the default
mesh.scalars.file = 'https://fly.cs.umb.edu/data/X/lh.smoothwm.C.crv';
// we want to map the scalars linear between blue and white
mesh.scalars.minColor = [0, 0, 1];
mesh.scalars.maxColor = [1, 1, 1];
// .. add the mesh
r.add(mesh);
// .. and start the loading/rendering
r.render();
//
// The GUI
//
gui = null; // we need to re-load the gui after we change the curvature type
// here are the available curvature types (looks a little cryptic but is just
// text) and files
curvatureTypes = ['C (mm⁻²)', 'k₁ (mm⁻¹)',
'H (mm⁻¹)'];
curvatureFiles = ['lh.smoothwm.C.crv', 'lh.smoothwm.K1.crv',
'lh.smoothwm.H.crv'];
// we need this Loader as a container to keep track of the current curvature
var _loader = {
// default type
Type: 'C (mm⁻²)'
};
// the onShowtime method gets executed after all files were fully loaded and
// just before the first rendering attempt
r.onShowtime = function() {
if (gui) {
// if we already have a gui, destroy it
// .. it will be re-created immediately
gui.destroy();
gui = null;
}
//
// create the GUI panel
//
gui = new dat.GUI();
var meshgui = gui.addFolder('Mesh');
var meshColorController = meshgui.addColor(mesh, 'color');
...