API

Class GreasedLineTools

Tool functions for GreasedLine

Index
  • Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.

    Parameters

    • name: string

      name of the texture

    • colors: Color3[]

      Uint8Array of colors

    • colorsSampling: number

      sampling mode of the created texture

    • scene: Scene

      Scene

    Returns RawTexture

    the colors texture

  • Parameters

    • position: Vector3

      position of the arrow cap (mainly you want to create a triangle, set widthUp and widthDown to the same value and omit widthStartUp and widthStartDown)

    • direction: Vector3

      direction which the arrow points to

    • length: number

      length (size) of the arrow cap itself

    • widthUp: number

      the arrow width above the line

    • widthDown: number

      the arrow width belove the line

    • widthStartUp: number = 0

      the arrow width at the start of the arrow above the line. In most scenarios this is 0.

    • widthStartDown: number = 0

      the arrow width at the start of the arrow below the line. In most scenarios this is 0.

    Returns { points: Vector3[]; widths: number[] }

  • Creates lines in a shape of circle/arc. A segment is a part of the line between it's two points.

    Parameters

    • radiusX: number

      radiusX of the circle

    • segments: number

      number of segments in the circle

    • z: number = 0

      z coordinate of the points. Defaults to 0.

    • radiusY: number = radiusX

      radiusY of the circle - you can draw an oval if using different values

    • segmentAngle: number = ...

      angle offset of the segments. Defaults to Math.PI * 2 / segments. Change this value to draw a part of the circle.

    Returns Vector3[]

    line points

  • Gets the length from the beginning to each point of the line as array.

    Parameters

    • data: number[]

      array of line points

    • Optionalbuf: ArrayBuffer

      optional pre-allocated buffer to reduce memory pressure, should be at least data.length * 4 / 3 bytes

    Returns Float32Array

    length array of the line

  • Gets the minimum and the maximum length of a line segment in the line. A segment is a part of the line between it's two points.

    Parameters

    Returns { max: number; min: number }

  • Calculates the sum of points of every line and the number of points in each line. This function is useful when you are drawing multiple lines in one mesh and you want to know the counts. For example for creating an offsets table.

    Parameters

    • points: number[][]

      point array

    Returns { counts: number[]; total: number }

    points count info

  • Gets 3D positions of points from a text and font

    Parameters

    • text: string

      Text

    • size: number

      Size of the font

    • resolution: number

      Resolution of the font

    • fontData: IFontData

      defines the font data (can be generated with http://gero3.github.io/facetype.js/)

    • z: number = 0

      z coordinate

    • includeInner: boolean = true

      include the inner parts of the font in the result. Default true. If false, only the outlines will be returned.

    Returns number[][]

    number[][] of 3D positions

  • Finds the last visible position in world space of the line according to the visibility parameter

    Parameters

    • lineSegments: { length: number; point1: Vector3; point2: Vector3 }[]

      segments of the line

    • lineLength: number

      total length of the line

    • visbility: number

      normalized value of visibility

    • localSpace: boolean = false

      if true the result will be in local space (default is false)

    Returns Vector3

    world space coordinate of the last visible piece of the line

  • Divides a line into segments. A segment is a part of the line between it's two points.

    Parameters

    • what: number[] | Vector3[] | { length: number; point1: Vector3; point2: Vector3 }[]

      line points

    • segmentLength: number

      length of each segment of the resulting line (distance between two line points)

    Returns Vector3[]

    line point

  • Divides a segment into smaller segments. A segment is a part of the line between it's two points.

    Parameters

    • point1: Vector3

      first point of the line

    • point2: Vector3

      second point of the line

    • segmentCount: number

      number of segments we want to have in the divided line

    Returns Vector3[]

  • Gets a number array from a Vector3 array. You can you for example to convert your Vector3[] offsets to the required number[] for the offsets option.

    Parameters

    Returns number[]

    an array of x, y, z coordinates as numbers [x, y, z, x, y, z, x, y, z, ....]