# Extrude splines

## Recommended Posts

Hello World,

does anybody know how I can extrude splines with babylon.js

greetz from germany!
Alberto

##### Share on other sites

Hello could you elaborate a bit more? (BTW I love your avatar )

How are represented your splines ?

##### Share on other sites

thx 4 the praise
Splines are intresting to create tweens (e.g.:moving cam) or build shapes to extrude.Define splines with vectors, nurbs or importing svg or font types (e.g. ttf). With three.js you can define a curve:

`spline = new THREE.SplineCurve3([new THREE.Vector3(0, 0, 0),new THREE.Vector3(0, 200, 0),new THREE.Vector3(150, 150, 0),new THREE.Vector3(150, 50, 0),new THREE.Vector3(250, 100, 0),new THREE.Vector3(250, 300, 0)]);`

An another clever way are formulas to create splines/meshes:

`THREE.Curves = {};THREE.Curves.HeartCurve = THREE.Curve.create(function(s) {    this.scale = (s === undefined) ? 5 : s;},function(t) {    t *= 2 * Math.PI;    var tx = 16 * Math.pow(Math.sin(t), 3);    ty = 13 * Math.cos(t) - 5 * Math.cos(2 * t) - 2 * Math.cos(3 * t) - Math.cos(4 * t), tz = 0;    return new THREE.Vector3(tx, ty, tz).multiplyScalar(this.scale);});`

By this method you can do complex things with few lines of code.

http://wiki.blender.org/index.php/Doc:2.6/Manual/Modeling/Meshes/Editing/Duplicating/Extrude

Formular demo on google

##### Share on other sites

So given a curve you want to extrude it but along which axis? it will create a flat mesh right?

##### Share on other sites

extrude a line you got a plane, extrude a plane you got a cube. But how you can do it with babylon.js

##### Share on other sites

No way to do that right now but I find it really interesting. I can add it to the roadmap unless someone wants to implement it!

##### Share on other sites

I implemented a basic extrusion method, based on poly2tri.js. I will do a pull request within the next few days.

There is no spline support unfortunately, but you can extrude points along a path, so with some discretization on your part, it will do the trick

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.