I have tried to morph a thin rectangular cube to coil by three.js and tween.js. I've searched questions that already has been ask but none of them guide me.
Which morph function should I use, and how can I create a coil shape?
I have tried to morph a thin rectangular cube to coil by three.js and tween.js. I've searched questions that already has been ask but none of them guide me.
Which morph function should I use, and how can I create a coil shape?
Copyright © 2021 Jogjafile Inc.

have your tube stored as a set of
NslicesYou need center point and normal vector for each (circle) slice.
Init it to tube at start (aligned to y axis)
write visualization code for such mesh representation
You need to obtain the circumference points of each slice and join them with QUAD_STRIP or what ever primitive you are using for the tube surface. The top and bottom is best with TRIANGLE_FAN around center point.
You can obtain the points with my glCircle3D in C++ just instead of drawing them store/use them as you need ...
interpolate between tube and helix
If the above is workung you can turn the centers position and normals into helix with variable radius
rand fixed screwsm. So I would try:The normal can be computed similary but I do not have the time for testing it right now and my imagination is not that good so i would instead do this:
Just copy the normal from slice 1 to slice 0 and you should be fine.
animate
Just animate the mesh with changing
rfrom zero to someR. If you want continuous effect you can dor=R*sin(t)wheretis increasing with some step ...[edit1] C++ OpenGL example
If you put all the above together you should get something like this:
Which renders helix in OpenGL. it starts from
(0,0,0)and ends in(0,h,0)where:ris the radius of the tubeRis the radius of the screwshis helix height/sizeNis number of screws perhIt generates Vertex and Normal info so you can use lighting. for animation I use this:
As you can see half of the sin wave is neglected so you can have time to actually see the tube without the screws. Here output with lighting:
On the left is the unscrewed tube (
R=0). On the right is fully morphed screw and in the middle is something in between.PS if you want to make the morph more interesting you can also animate the
Nparameter from0to some constant.