FNNDSC / ami

AMI Medical Imaging (AMI) JS ToolKit
https://fnndsc.github.io/ami/#viewers_upload
MIT License
721 stars 213 forks source link

[Help] Stack world position at world origin #335

Open MuriloSchaefer opened 6 years ago

MuriloSchaefer commented 6 years ago

Description

Hi, I have three scenes with ortho cameras, and the stack isn't in the origin of the scene like can be seen in the figure below

image

Is there some way to move the stack to the origin? I try to move the stackHelper using:

stackHelper.applyMatrix( new THREE.Matrix4().makeTranslation( -centerLPS.x, -centerLPS.y, -centerLPS.z ) );

but only the plane changed, so it breaks the textures: image

PS:

PtiLuky commented 6 years ago

The stack position depends of the "real world" position, including the offset of your data. To move the data, use the registration matrix (stack.regMatrix) and don't forget to update IJK2LPS matrix and send the new one to the shader (with the uniform). Some details here : https://github.com/FNNDSC/ami/issues/125

MuriloSchaefer commented 6 years ago

it worked! Thanks :)

I'm putting the code here, just to let it documented, in case of other people have the same issue.

//move the stack to the origin of the scene
let centerLPS = stack.worldCenter();
stack.regMatrix = new THREE.Matrix4().makeTranslation(-centerLPS.x, -centerLPS.y,-centerLPS.z);
stack.computeIJK2LPS();