Path

Summary

A list of transforms that usually represents a path in 3D space. These form the basis for brush strokes and camera paths

Instance Properties

NameReturn TypeDescription

count

number Read-only

Returns the number of points in this path

this[index]

Transform Read-only

Returns the point at the specified index

last

Transform Read-only

Returns the last point in this path

Class Methods

Path:New()

Creates a new empty Path

Returns: Path

Example

myPath = Path:New()

Path:New(transformList)

Creates a path from a list of Transforms

Returns: Path

Parameters:

NameTypeDefaultDescription

transformList

Transform[]

The list of transforms

Example

myPath = Path:New({transform1, transform2, transform3})

Path:New(positionList)

Creates a path from a list of Vector3 positions

Returns: Path

Parameters:

NameTypeDefaultDescription

positionList

Vector3[]

The list of positions

Example

myPath = Path:New({position1, position2, position3})

Path:Hermite(startTransform, endTransform, startTangent, endTangent, resolution, tangentStrength)

Generates a hermite spline

Returns: Path (A new Path)

Parameters:

NameTypeDefaultDescription

startTransform

Starting transformation

endTransform

End transformation

startTangent

Starting tangent

endTangent

End tangent

resolution

number

Resolution of the spline

tangentStrength

number

1

Strength of the tangent

Example

myPath:Hermite(startTransform, endTransform, startTangent, endTangent, resolution, tangentStrength)

Instance Methods

path:GetDirection(index)

Returns a vector representing the direction of the path at the given point

Returns: Vector3

Parameters:

NameTypeDefaultDescription

index

number

Index of control point to use

Example

myPath:GetDirection(3)

path:GetNormal(index)

Returns a vector representing the normal of the path at the given point

Returns: Vector3

Parameters:

NameTypeDefaultDescription

index

number

Index of control point to use

Example

myPath:GetNormal(3)

path:GetTangent(index)

Returns a vector representing the tangent of the path at the given point

Returns: Vector3

Parameters:

NameTypeDefaultDescription

index

number

Index of control point to use

Example

myPath:GetTangent(3)

path:Draw()

Draws this path as a brush stroke using current settings

Returns: nil

Example

myPath:Draw()

path:Insert(transform)

Inserts a new point at the end of the path

Returns: nil

Parameters:

NameTypeDefaultDescription

transform

The transform to be inserted at the end of the path

Example

myPath:Insert(myTransform

path:Insert(transform, index)

Inserts a new point at the specified index

Returns: nil

Parameters:

NameTypeDefaultDescription

transform

The transform to be inserted

index

number

The index at which to insert the transform

Example

myPath:Insert(transform, index)

path:TransformBy(transform)

Transforms all points in the path by the specific amount

Returns: nil

Parameters:

NameTypeDefaultDescription

transform

The transform to be applied to all points in the path

Example

myPath:TransformBy(transform)

path:TranslateBy(amount)

Changes the position of all points in the path by a given amount

Returns: nil

Parameters:

NameTypeDefaultDescription

amount

The distance to move the points

Example

myPath:TranslateBy(Vector3:up)

path:RotateBy(amount)

Rotates all points in the path around the origin by a given amount

Returns: nil

Parameters:

NameTypeDefaultDescription

amount

The amount by which to rotate the path

Example

myPath:RotateBy(Rotation.New(45, 0, 0)

path:ScaleBy(scale)

Scales the path

Returns: nil

Parameters:

NameTypeDefaultDescription

scale

The scaling factor to apply to the path

Example

myPath:ScaleBy(Vector3:New(2, 1, 1)

path:Center()

Moves all points on the path so that their common center is the origin

Returns: nil

Example

myPath:Center()

path:StartingFrom(index)

Reorders the points so that point at the given index is shifted to be the first point

Returns: nil

Parameters:

NameTypeDefaultDescription

index

number

The index of the point to make the new first point

Example

myPath:StartingFrom(3)

path:FindClosest(point)

Returns the index of the point closest to the given position

Returns: number

Parameters:

NameTypeDefaultDescription

point

The 3D position that we are seeking the closest to

Example

myPath:FindClosest(Vector3:New(10, 2, 4)

path:FindMinimumX()

Returns the index of the point with the smallest X value

Returns: number

Example

myPath:FindMinimumX()

path:FindMinimumY()

Returns the index of the point with the smallest Y value

Returns: number

Example

myPath:FindMinimumY()

path:FindMinimumZ()

Returns the index of the point with the smallest Z value

Returns: number

Example

myPath:FindMinimumZ()

path:FindMaximumX()

Returns the index of the point with the biggest X value

Returns: number

Example

myPath:FindMaximumX()

path:FindMaximumY()

Returns the index of the point with the biggest Y value

Returns: number

Example

myPath:FindMaximumY()

path:FindMaximumZ()

Returns the index of the point with the biggest Z value

Returns: number

Example

myPath:FindMaximumZ()

path:Normalize(size)

Scales and shifts all points so that they fit in a cube of the given size at the origin

Returns: nil

Parameters:

NameTypeDefaultDescription

size

number

1

The size of the cube to fit the path into

Example

myPath:Normalize(size)

path:SampleByDistance(spacing)

Resamples the path evenly by distance

Returns: nil (The new path)

Parameters:

NameTypeDefaultDescription

spacing

number

The space between points in the new path

Example

myPath:SampleByDistance(spacing)

path:SampleByCount(count)

Resamples the path evenly into the specified number of points

Returns: nil (The new path)

Parameters:

NameTypeDefaultDescription

count

number

The number of points in the new path

Example

myPath:SampleByCount(count)

path:SubdivideSegments(parts)

Subdivides each path segment into the specified number of parts

Returns: nil (The new path)

Parameters:

NameTypeDefaultDescription

parts

number

Number of parts to subdivide into

Example

myPath:SubdivideSegments(parts)

Last updated