Function buildVectorTextGeometry

  • Creates wireframe vector text as a SceneGeometry.

    This function generates the geometry data for rendering text as a wireframe. Each character is represented as a series of lines, with the position of each vertex specified in 3D space. The text is provided as input, and the function constructs the wireframe representation for each character. The resulting geometry can be used for rendering text in 3D environments.

    To create wireframe vector text geometry, simply call the function and pass the appropriate configuration object. For example:

    const textGeometry = buildVectorTextGeometry({
    size: 2,
    origin: [0, 0, 0],
    text: "Hello, World!"
    });

    This creates a wireframe mesh for the text "Hello, World!" with each character sized at 2 units, centered at the origin.

    Parameters

    • cfg: { origin: number[]; size: number; text: string } = ...

      Configuration object for generating the text geometry.

      • origin: number[]

        A 3D point (array of 3 numbers) indicating the top-left corner of the text in the 3D space. This sets the initial position for the first character of the text.

      • size: number

        The size of each character in the text. Default is 1.

      • text: string

        The text string to display. It can include multiple lines (using \n).

        Returns a SceneGeometry object with the wireframe representation of the provided text, including the necessary positions, indices, and primitive type for rendering.

        const textGeometry = buildVectorTextGeometry({
        size: 1.5,
        origin: [0, 0, 0],
        text: "Sample Text"
        });
        • The function assumes that the characters are defined in a pre-existing letters object, where each character is mapped to its wireframe geometry (points and width).
        • The geometry is created by breaking down each character into a series of points, connecting those points with lines to form the wireframe.
        • The size parameter scales the text, and the mag constant adjusts the scaling factor for the points' positions.

    Returns GeometryArrays

    The geometry data for the wireframe vector text.