Three.js

Three.js

This project requires deep knowledge of Three.js. Please read requirements pretty well. The script can be a separate file or embedded inside the html file.
The final result should be 4 html files each with Three.js script that render the required graphs.
Let the part begin.

Problem 1
Inside an html file, a function utilizing Three.js script is required that renders a starburst of lines of length 2 as shown in
Figure 1 below. The function should accept 3 parameters: n as the number lines, an inner colour and an outer colour –
for example LineBurst(n, insideColour, outsideColour).
Figure 1 – Problem 1 image
Problem 2
Inside an html file, a function utilizing Three.js script is required that renders a cylinder as shown in Figure 2 below. The
function accepts two parameters: n the number of sides of the cylinder and colour. For instance, the function can look
like that – drawCylinder(n, Colour). Figure 2 is drawCylinder(10, red).
Figure 2 – Problem 2 image
Problem 3
Inside an html file, a function utilizing Three.js script is required that renders an open red box as shown in Figure 3
below. Although all faces or sides of the box has the same colour, the shading varies due to lighting in the scene.
Figure 3 – Problem 3 image
Problem 4
Inside an html file, a function utilizing Three.js script is required that returns a Geometry object that represents an nsided
regular polygon as shown in Figure 4 below. The polygon should be centered at the origin, lie in the xy-plane, and
have radius 2 (the distance from the origin to each of the polygon’s n vertices is equal to 2). The function should be in
this format: drawPolygon(n, insideColour, outsideColour), where n is the number of sides of the polygon. Colours get
interpolated from insideColour assigned to the polygon’s center to outsideColour assigned to its n vertices. Figure 4 is
showing a call of function drawPolygon(8, red, blue)
Figure 4 – Problem 4 image