Class GreasedLineTools
Index
Constructors
Methods
Constructors
constructor
-
Returns GreasedLineTools
Methods
StaticBoolean To Number
-
Converts boolean to number.
Parameters
Optionalbool: booleanthe bool value
Returns 0 | 1
1 if true, 0 if false.
StaticColor3to RGBA Uint8
-
Converts an array of Color3 to Uint8Array
Parameters
- colors: Color3[]
Arrray of Color3
Returns Uint8Array
Uin8Array of colors [r, g, b, a, r, g, b, a, ...]
- colors: Color3[]
StaticConvert Points
-
Converts GreasedLinePoints to number[][]
Parameters
- points: GreasedLinePoints
GreasedLinePoints
Optionaloptions: GreasedLinePointsOptionsGreasedLineToolsConvertPointsOptions
Returns number[][]
number[][] with x, y, z coordinates of the points, like [[x, y, z, x, y, z, ...], [x, y, z, ...]]
- points: GreasedLinePoints
StaticCreate Colors Texture
-
CreateColorsTexture(
name: string,
colors: Color3[],
colorsSampling: number,
scene: Scene,
): RawTextureCreates a RawTexture from an RGBA color array and sets it on the plugin material instance.
Parameters
Returns RawTexture
the colors texture
StaticDispose Empty Colors Texture
-
Diposes the shared empty colors texture
Returns void
StaticGet Arrow Cap
-
GetArrowCap(
position: Vector3,
direction: Vector3,
length: number,
widthUp: number,
widthDown: number,
widthStartUp?: number,
widthStartDown?: number,
): { points: Vector3[]; widths: number[] }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[] }
- position: Vector3
StaticGet Bezier Line Points
StaticGet Circle Line Points
-
GetCircleLinePoints(
radiusX: number,
segments: number,
z?: number,
radiusY?: number,
segmentAngle?: number,
): Vector3[]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
- radiusX: number
StaticGet Line Length
-
Gets the length of the line counting all it's segments length
Parameters
- data: number[] | Vector3[]
array of line points
Returns number
length of the line
- data: number[] | Vector3[]
StaticGet Line Length Array
-
Gets the length from the beginning to each point of the line as array.
Parameters
- data: number[]
array of line points
Optionalbuf: ArrayBufferoptional pre-allocated buffer to reduce memory pressure, should be at least
data.length * 4 / 3bytes
Returns Float32Array
length array of the line
- data: number[]
StaticGet Line Segments
StaticGet Min Max Segment Length
-
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
- points: Vector3[]
line points
Returns { max: number; min: number }
- points: Vector3[]
StaticGet Points Count Info
-
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
- points: number[][]
StaticGet Points From Text
-
GetPointsFromText(
text: string,
size: number,
resolution: number,
fontData: IFontData,
z?: number,
includeInner?: boolean,
): number[][]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
- text: string
StaticGet Position On Line By Visibility
-
GetPositionOnLineByVisibility(
lineSegments: { length: number; point1: Vector3; point2: Vector3 }[],
lineLength: number,
visbility: number,
localSpace?: boolean,
): Vector3Finds the last visible position in world space of the line according to the visibility parameter
Parameters
Returns Vector3
world space coordinate of the last visible piece of the line
StaticMeshes To Lines
-
MeshesToLines(
meshes: AbstractMesh[],
predicate?: (
p1: Vector3,
p2: Vector3,
p3: Vector3,
points: Vector3[][],
indiceIndex: number,
vertexIndex: number,
mesh: AbstractMesh,
meshIndex: number,
vertices: FloatArray,
indices: IndicesArray,
) => Vector3[][],
): Vector3[][]Gets mesh triangles as line positions
Parameters
- meshes: AbstractMesh[]
array of meshes
Optionalpredicate: (
p1: Vector3,
p2: Vector3,
p3: Vector3,
points: Vector3[][],
indiceIndex: number,
vertexIndex: number,
mesh: AbstractMesh,
meshIndex: number,
vertices: FloatArray,
indices: IndicesArray,
) => Vector3[][]predicate function which decides whether to include the mesh triangle/face in the ouput
Returns Vector3[][]
array of arrays of points
- meshes: AbstractMesh[]
StaticOmit Duplicates Predicate
StaticOmit Zero Length Predicate
StaticPrepare Empty Colors Texture
-
A minimum size texture for the colors sampler2D when there is no colors texture defined yet. For fast switching using the useColors property without the need to use defines.
Parameters
- scene: Scene
Scene
Returns RawTexture
empty colors texture
- scene: Scene
StaticSegmentize Line By Segment Count
StaticSegmentize Line By Segment Length
StaticSegmentize Segment By Count
StaticTo Number Array
-
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
- points: Vector3[]
Vector3 array
Returns number[]
an array of x, y, z coordinates as numbers [x, y, z, x, y, z, x, y, z, ....]
- points: Vector3[]
Tool functions for GreasedLine