# How can I make a tube and bend it in run time

**URL:** <https://discourse.threejs.org/t/how-can-i-make-a-tube-and-bend-it-in-run-time/9494>\
**Category:** Questions\
**Tags:** geometry\
**Created:** [September 6, 2019, 7:24pm UTC](https://discourse.threejs.org/t/how-can-i-make-a-tube-and-bend-it-in-run-time/9494 "2019-09-06T19:24:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jauregui](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/jauregui/32/5119_2.png) [@jauregui](https://discourse.threejs.org/u/jauregui)\
**Post date:** [September 6, 2019, 7:24pm UTC](https://discourse.threejs.org/t/how-can-i-make-a-tube-and-bend-it-in-run-time/9494/1 "2019-09-06T19:24:58Z")

</div>

Sorry for bother you guys but I am kind of bad in Math, I want to make like a tube and bend it using curve radius in a run time giving some inputs data like angle and distance.

Some one have an idea where and how to start?

Thanks.

---

<div class="post-metadata">

**Author:** ![marquizzo](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/marquizzo/32/25192_2.png) [@marquizzo](https://discourse.threejs.org/u/marquizzo)\
**Post date:** [September 6, 2019, 7:51pm UTC](https://discourse.threejs.org/t/how-can-i-make-a-tube-and-bend-it-in-run-time/9494/2 "2019-09-06T19:51:05Z")

</div>

Maybe these conversations can get you started in the right direction:

> [@How to convert this geometry opengl code to three.js?](https://discourse.threejs.org/t/how-to-convert-this-geometry-opengl-code-to-three-js/5708):
>
> Hi there, I am trying to follow this tutorial, where they show how to make a bending cylinder in C and opengl (at Edit2) Would anyone who knows C be willing to turn this into a three.js codepen? Or explain how to do it in three.js

> [@How to bend a cylindrical geometry by X degrees at X height (and do it multiple times)](https://discourse.threejs.org/t/how-to-bend-a-cylindrical-geometry-by-x-degrees-at-x-height-and-do-it-multiple-times/5588):
>
> Hi there, i’m working on this pen where i’m attempting to bend a long geometry at X height by X degrees and for X area of effect. [https://codepen.io/funianrun/pen/QzQQJB](https://codepen.io/funianrun/pen/QzQQJB) I’ve managed to bend it in a long arcing motion. However i’d like to confine the bend to only a section of the cylinder and not the entire thing. In my main project, the geometry is bent after applying effects like waves, and after extruding it from a bezier curve created in a 2D canvas. I tried lerping from the original ve…

Also, I think @prisoner849 might be able to chime in with other good examples. 😉

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [September 7, 2019, 6:06am UTC](https://discourse.threejs.org/t/how-can-i-make-a-tube-and-bend-it-in-run-time/9494/3 "2019-09-07T06:06:48Z")

</div>

Another option:  
[https://threejs.org/docs/index.html#api/en/objects/SkinnedMesh](https://threejs.org/docs/index.html#api/en/objects/SkinnedMesh)

---

<div class="post-metadata">

**Author:** ![EliasHasle](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/eliashasle/32/3010_2.png) [@EliasHasle](https://discourse.threejs.org/u/EliasHasle)\
**Post date:** [September 7, 2019, 7:51am UTC](https://discourse.threejs.org/t/how-can-i-make-a-tube-and-bend-it-in-run-time/9494/4 "2019-09-07T07:51:46Z")

</div>

If it is a constant bending radius, or any other bending whose position and rotation offsets can be expressed in closed form, you can have a transform in the vertex shader that takes a straight, axis-aligned tube and transforms it to the desired bend, before applying the `projectionMatrix*modelViewMatrix`. Ideally, you will also find a way to transform normals. (I don’t know how to do that for any specific case, and certainly not for the general case.)

---

<div class="post-metadata">

**Author:** ![hofk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/hofk/32/44944_2.png) [@hofk](https://discourse.threejs.org/u/hofk)\
**Post date:** [September 7, 2019, 12:28pm UTC](https://discourse.threejs.org/t/how-can-i-make-a-tube-and-bend-it-in-run-time/9494/5 "2019-09-07T12:28:17Z")

</div>

Maybe there’s something for you ❓

* * *

[https://hofk.de/main/threejs/skeleton/03\_skeleton.html](https://hofk.de/main/threejs/skeleton/03_skeleton.html)  
[https://hofk.de/main/threejs/Hummel%20Mara/14\_hummel\_bumblebee.html](https://hofk.de/main/threejs/Hummel%20Mara/14_hummel_bumblebee.html)  
Comments unfortunately only in German, but easy to translate with [deepl.com/translator](http://deepl.com/translator) ( I always take).

* * *

[https://hofk.de/main/threejs/skeleton/00\_skeletonBasic.html](https://hofk.de/main/threejs/skeleton/00_skeletonBasic.html)

* * *

[https://hofk.de/main/threejs/sandboxthreef/formLibrary.html](https://hofk.de/main/threejs/sandboxthreef/formLibrary.html)  
to the addon see [THREEf geometries](https://hofk.de/main/threejs/sandboxthreef/) and [Addon. Produces almost infinite many time-varying geometries with functions](https://discourse.threejs.org/t/addon-produces-almost-infinite-many-time-varying-geometries-with-functions/262)
