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.
sidesnumber — number of sides in the radial sweep
profileTypeParsablePoint[] — XY plane profile to be radially
swept around the x axis
normalsflat | curve | curveProfile | curveRadial — flat normals will make shading (from a light source) across a face of the
object a constant color. curveProfile will gradiate the shading along the
profile. curveRadial will gradiate the shading around the radial sweep.
curve will gradiate the shading both around the radial sweep and along the
profile. Use curve, curveProfile, or curveRadial to make a surface
look more round with fewer number of sides.
axisTypeParsablePoint — orient the draw space vertices of the
shape so its axis is along this vector
rotationnumber — by default the profile will start in the XY
plane and sweep around the x axis following the right hand rule. Use
rotation to start the sweep at some angle where 0º is in the XY for +y and
90º is in the XZ plane for +z. initial angle of the revolve rotation
linesboolean — if true then points representing
the edes of the faces will be returned. If false, then points
representing two triangles per face and an
associated normal for each point will be returned.
// 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.
sidesnumber— number of sides in the radial sweepprofileTypeParsablePoint[] — XY plane profile to be radially swept around the x axisnormalsflat|curve|curveProfile|curveRadial—flatnormals will make shading (from a light source) across a face of the object a constant color.curveProfilewill gradiate the shading along the profile.curveRadialwill gradiate the shading around the radial sweep.curvewill gradiate the shading both around the radial sweep and along the profile. Usecurve,curveProfile, orcurveRadialto make a surface look more round with fewer number of sides.axisTypeParsablePoint — orient the draw space vertices of the shape so its axis is along this vectorrotationnumber— by default the profile will start in the XY plane and sweep around the x axis following the right hand rule. Userotationto start the sweep at some angle where 0º is in the XY for +y and 90º is in the XZ plane for +z. initial angle of the revolve rotationlinesboolean— iftruethen points representing the edes of the faces will be returned. Iffalse, then points representing two triangles per face and an associated normal for each point will be returned.See
To test examples, append them to the boilerplate
Example
Example
Example
Example
Example
Example
Example
Example