3dmol / 3Dmol.js

WebGL accelerated JavaScript molecular graphics library
https://3dmol.org/
Other
794 stars 194 forks source link

Atom's coordinate movement #747

Closed heoSuKyeong closed 8 months ago

heoSuKyeong commented 8 months ago

I want to select an atom and rotate it. Is there a function that can move the atom's coordinates?

dkoes commented 8 months ago

You can multiply the coordinates by a rotation matrix. The math module isn't really documented, but there is a setRotationFromEuler function if you need assistance creating a rotation matrix.

heoSuKyeong commented 8 months ago

The rotation matrix was obtained through another method. But I'm not sure how to move the coordinates using that value.

atom.x = 10 atom.y = 20 atom.z = 30

Even if I enter arbitrary values, the atom does not move. Isn't this the way to approach it?

dkoes commented 8 months ago

Did you render the scene after changing the coordinates?

heoSuKyeong commented 8 months ago

I definitely did. I checked the coordinates before and after moving to the console. But it didn't move.

image

dkoes commented 8 months ago

When calling render call it with the regen option set to true to force a rebuild of the geometry (the first argument is a callback function): viewer.render(null, {regen: true});

dkoes commented 8 months ago

Alternatively, if you have multiple models and only want to force a rebuilt on the model you are change, you can call removegl on only that model.

heoSuKyeong commented 8 months ago

Wow, it was solved in the same way as above. Thank you so much.