xtk

XTK - rendering volume in multiple renderers without .onShowtime()?


I'm wondering if someone can explain to me why I can't render the same volume in a 4 panel setup (3D, X, Y, Z) just like in XTK Tutorial 13, without the .onShowtime function. I tried altering the code to do this, rather than call the .onShowtimes function:

volume = new X.volume();
volume.file = 'http://x.babymri.org/?vol.nrrd';

sliceX.add(volume);
sliceX.render();

sliceY.add(volume);
sliceY.render();

sliceZ.add(volume);
sliceZ.render();

but when I do this, I get the load bars in the 3 display panels, but after loading, only the sliceX panel will display an image, the others remain black. Do I always have to have a main renderer and make the other renderers listen to it, as the tutorial suggests?

Thanks, Dave


Solution

  • It is because the first call to 'render' is going to trigger the downloading of the data.

    Once it has been downloaded 1 time and rendered the first time, we add/render it in the other renderers.

    When we call 'render' on the next renderers, it will not try to download the data again since it has already been downloaded once.

    If we call renderer as you are doing it right now, it tries to download the volume 3 times and it can mess up the internals of the object.

    So long answer short, it is to avoid some race conditions but I agree we should improve that if possible.

    Thanks