Skip to main content

CivilCurve

Represents an alignment curve of a civil engineering model.

Constructors

new CivilCurve()

new CivilCurve(index, mesh, data, alignment): CivilCurve

Constructs a new instance of CivilCurve.

Parameters

ParameterTypeDescription
indexnumberThe index of the curve.
meshCurveMesh<BufferGeometry<NormalBufferAttributes>, Material | Material[]>The mesh associated with the curve.
dataobjectAdditional data associated with the curve.
alignmentAlignmentThe alignment of the curve.

Returns

CivilCurve

Properties

alignment

alignment: Alignment

The alignment to which this curve belongs.


data

data: object

Additional data associated with the curve.

Index signature

[name: string]: any


index

index: number

The index of the curve. An alignment is a sequence of ordered curves, and this is the index of this curve in that sequence.


mesh

mesh: CurveMesh<BufferGeometry<NormalBufferAttributes>, Material | Material[]>

The THREE.js mesh containing the vertices of the curve.

Methods

getLength()

getLength(): number

Calculates the total length of the curve by summing up the lengths of all segments.

Returns

number

The total length of the curve.


getPercentageAt()

getPercentageAt(point, tolerance): null | number

Calculates the percentage of the curve that corresponds to the given point.

Parameters

ParameterTypeDefault valueDescription
pointVector3undefinedThe point for which to calculate the percentage.
tolerancenumber0.01The tolerance for determining if a point is on the curve. Default is 0.01.

Returns

null | number

The percentage of the curve that corresponds to the given point, or null if the point is not contained in this curve.

Remarks

The method works by iterating over each segment of the curve and checking if the given point is within the tolerance of the segment. If a point is found, it calculates the percentage of the curve that corresponds to the point. If no point is found, it returns null.


getPointAt()

getPointAt(percentage): Vector3

Calculates a point on the curve based on the given percentage.

Parameters

ParameterTypeDescription
percentagenumberThe percentage along the curve (between zero and one).

Returns

Vector3

A new THREE.Vector3 representing the point on the curve.

Remarks

The method works by first finding the segment that corresponds to the given percentage. It then normalizes the direction of the segment, multiplies it by the distance to the start of the segment, and adds it to the start point of the segment.

Throws

Will throw an error if the percentage is outside the range [0, 1].


getSegment()

getSegment(index): object

Retrieves a segment of the curve based on the given index.

Parameters

ParameterTypeDescription
indexnumberThe index of the segment.

Returns

object

An object containing the start and end points of the segment.

endPoint

endPoint: Vector3

startPoint

startPoint: Vector3

Remarks

The method calculates the start and end points of the segment based on the given index. It uses the index array and position attribute of the curve's geometry to determine the start and end points.

Throws

Will throw an error if the index is out of range.


getSegmentAt()

getSegmentAt(percentage): object

Calculates a segment of the curve based on the given percentage.

Parameters

ParameterTypeDescription
percentagenumberThe percentage along the curve (between zero and one).

Returns

object

An object containing the distance to the start of the segment, the index of the segment, and the start and end points of the segment.

distanceToStart

distanceToStart: number

endPoint

endPoint: Vector3

index

index: number

startPoint

startPoint: Vector3

Remarks

The method works by first finding the segment that corresponds to the given percentage. It then returns an object containing the distance to the start of the segment, the index of the segment, and the start and end points of the segment.

Throws

Will throw an error if the percentage is outside the range [0, 1].