# LineRenderer Line renderer
The line segment renderer component requires an array of two or more points in three-dimensional space. You can use the line segment renderer to draw anything, from a simple line segment to a complex spiral.
# In the IDE
To create in the IDE, you only need to select a node in the scene or Prefab and add it in the Inspector:
# Create with code
LineRenderer is a rendering component, so it needs to be mounted on a non-rendering node.
const line = entity.addComponent(engine.LineRenderer);
# Attributes
Property name | Type | Default value | Description |
---|---|---|---|
positions | engine.Vector3[] | [] | Array of vertices forming the line segment |
startWidth | number | 1 | Starting position width |
endWidth | number | 1 | End position width |
startColor | engine.Color | engine.Color.WHITE | Start position color |
endColor | engine.Color | engine.Color.WHITE | color at the end |
alignment | LineAlignment | LineAlignment.View | Currently only the patch is always facing the camera |
View | - | engine.LineRenderer.LineAlignment.View | Facing the camera plane. |
Local | - | engine.LineRenderer.LineAlignment.Local | Align with the transform of the Entity. |
useWorldSpace | boolean | true | positions is the position in world coordinates |
# method
getPosition(index: number): engine.Vector3 Get the position of the index vertex.
setPosition(index: number, position: Vector3): boolean Set the position information of index in the array.