figureone
    Preparing search index...

    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:

    • 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.

    • sides number — number of sides in the radial sweep
    • profile TypeParsablePoint[] — XY plane profile to be radially swept around the x axis
    • normals flat | curve | curveProfile | curveRadialflat 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.
    • axis TypeParsablePoint — orient the draw space vertices of the shape so its axis is along this vector
    • rotation number — 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
    • lines boolean — 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.

    To test examples, append them to the boilerplate

    figure.add({
    make: 'revolve',
    profile: [[0, 0], [0, 0.05], [0.5, 0.05], [0.6, 0.1], [0.7, 0]],
    axis: [0, 1, 0],
    color: [1, 0, 0, 1],
    sides: 20,
    });
    // 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',
    });
    // Curvy vase like shape
    const x = Fig.range(0, 0.5, 0.01);
    const profile = x.map(_x => [_x, 0.1 + 0.05 * Math.sin(_x * 2 * Math.PI * 2)]);
    figure.add({
    make: 'revolve',
    profile: [...profile, [0.4, 0], [0, 0], [0, 0.1]],
    axis: [0, 1, 0],
    color: [1, 0, 0, 1],
    sides: 30,
    });
    // 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,
    });
    // Wire mesh arrow
    figure.add({
    make: 'revolve',
    profile: [[0, 0.03], [0.4, 0.03], [0.4, 0.09], [0.7, 0]],
    axis: [0, 1, 0],
    color: [1, 0, 0, 1],
    sides: 20,
    lines: true,
    });
    // Open profile y = 0 at ends
    figure.add({
    make: 'revolve',
    profile: [[0, 0], [0, 0.3], [0.5, 0.2], [1, 0.3], [1, 0]],
    color: [1, 0, 0, 1],
    sides: 30,
    });
    // Open profile y > 0 at ends
    figure.add({
    make: 'revolve',
    profile: [[0, 0.3], [0.5, 0.2], [1, 0.3]],
    color: [1, 0, 0, 1],
    sides: 30,
    });
    // Closed Profile
    figure.add({
    make: 'revolve',
    profile: [[0, 0.3], [0.5, 0.2], [1, 0.3], [1, 0.29], [0.5, 0.19], [0, 0.29], [0, 0.3]],
    color: [1, 0, 0, 1],
    sides: 30,
    });
    @interface