I am working on simulating a pipe being bent into a specified configuration read in from a file. The file will only contain data about the length of pipe, the spacing of each bend, and the angle of each bend. The 3d object will be created within three.js. The 3d object must then be animated to go through the bends in real time.
I am inexperienced with three.js and so I’ve been researching the best way to go about this. From this it seems to me that the best way would be to create a CatmullRomCurve object with points spaced along along it corresponding to each bend. I then create an extrude geometry with a circular cross section following the curve.
The main issue I’m having now is figuring out how to animate the curve going from an unbent state to a bent state. I’m trying to use the clock and then re-positioning the points at increments over time. So far the only thing I’ve accomplished is crashing the program.
I’ve done some reading on animation frames but I’m not sure how they would be implemented in this case.
I’ve also looked into morphing geometries but it seemed more complicated than using the curve object and just updating the points but I very well may be wrong about that.
If anyone has advice on ways I can go about this or have worked on something similar that they can show me as an example I would be grateful. Thank you.
You maybe can use morph target animation to solve this issue. If you create a morph target attribute based on the vertices of the bend state, you can try to animate between the default state and the bend one. This can be done by manually modulating the correct entry of Mesh.morphTargetInfluences like in the following example.
https://threejs.org/examples/webgl_morphtargets
Or you use the animation system.
I’ve made some progress. I’m now using a skeleton and skinned cylindrical mesh like in this example https://threejs.org/docs/scenes/bones-browser.html.
I’m now attempting to increase the accuracy of my bends with the skeleton by building the segments of the pipe that will be bent from tiny bones and the parts that will remain straight from one large bone. The issue I’m having with this is that my mesh no longer follows the bend path of the skeleton accurately.
I’m looking for a way to fix that so the mesh will follow the bone structure exactly.