BabylonJS - Parametric Shapes



Parametric shapes refer to different shapes that can be achieved using the lines drawn with bends, twists, etc. It is a 2D form generated with mathematical equation like parabola, sine curve, cos curve, Bezier curve, etc. With the equation, we can find the coordinates (x, y) and draw the line for the same. We will see shapes like ribbon, lines, dashlines,tube, extrusion in this chapter. A free hand drawing of lines on the board can be achieved with the parametric shapes described below.

Sr.No. Parametric Shape & Description
1 Ribbon

Ribbon takes an array of paths as input and draws lines along those paths. It uses complex logic to get the co-ordinates. In the example given below, we have used Bezier curve equation to draw the ribbon. Bezier curves are mostly used in 3D games to model the smooth curves. The curve needs control points and the curve is drawn along the control points.

2 Line

Line is a basic element in 3D games. To draw a line, you need two points between which you can draw a line.

3 Tube

Tube is a curved cylinder shape. It can give different parametric shapes based on the equation (maths function) applied to it to get the co-ordinates.

4 Extrusion

Extrusion helps in transforming a 2D shape into a volumic shape.Suppose you want to create a star with 2D you will have x,y co-ordinates and z will be 0.Taking the 2D co-ordinates extrusion will convert the same to a 3D shape.So, the start of 2D with extrusion will turn out to be a 3D.You can try different 2D shapes and convert those into 3D.

Advertisements