Revolve (or radially sweep) a profile in the XY plane around the x axis to
form a 3D surface. The profile y values must be greater than or equal to 0.
Profiles can be open (start and end point are different) or closed (start
and end point are equal).
For predictable lighting results, profiles should be created with the
following rules:
An open profile's start points should have an x value less than its end
point
Closed profiles where all points have y > 0 should be defined in the
clockwise direction when looking at the XY plane from the +z axis.
If an open profile's start and ends points are at y = 0, then the final shape
will look solid.
If an open profile's start and/or ends points have y > 0, then the final
shape will look like a surface open at the ends with y > 0. As a surface can
have only one color, then looking inside the shape the surface lighting will
be opposite to that expected. To create open ended solids with lighting that
is as expected, create the outside and inside surface with a closed profile.
// If creating a shell, then also create the inside surface as this will make // lighting more correct (note there is not shaddows). // Ensure to close the shell by adding the first point to the end of the // profile figure.add({ make:'revolve', profile: [[0, 0.15], [0.5, 0.3], [0.5, 0.29], [0, 0.14], [0, 0.15]], color: [1, 0, 0, 1], sides:30, normals:'curveRadial', });
// Make a torus by revolving a polygon around the axis. As the polygon is above // the x axis, a hole will be created // Try using `normals: 'curve'`, `normals: 'curveProfile'`, and // `normals: 'curveRadial'` to see different curve options. const { polygon } = Fig; figure.add({ make:'revolve', profile:polygon({ radius:0.1, center: [0, 0.3], sides:20, direction: -1, close:true, }), color: [1, 0, 0, 1], sides:30, });
Revolve shape options object that extends OBJ_Generic3All and OBJ_FigurePrimitive.
Revolve (or radially sweep) a profile in the XY plane around the x axis to form a 3D surface. The profile y values must be greater than or equal to 0.
Profiles can be open (start and end point are different) or closed (start and end point are equal).
For predictable lighting results, profiles should be created with the following rules:
If an open profile's start and ends points are at y = 0, then the final shape will look solid.
If an open profile's start and/or ends points have y > 0, then the final shape will look like a surface open at the ends with y > 0. As a surface can have only one color, then looking inside the shape the surface lighting will be opposite to that expected. To create open ended solids with lighting that is as expected, create the outside and inside surface with a closed profile.
See
To test examples, append them to the boilerplate
Example
Example
Example
Example
Example
Example
Example
Example