Points
The points() function creates a point cloud from an array of positions. Use it for particle-style
visuals or large datasets.
points([ [0, 0, 0], [40, 40, 0], [-40, 40, 0], [40, -40, 0], [-40, -40, 0] ]) .color([ "red", "orange", "magenta", "green", "cyan"] ) .pointSize(5);
Returns the Points object:
Points
Example usage:
points.pointSize(3).color("orange");
field
mesh: THREE.Points
The underlying THREE.Points mesh representing the point cloud.
Example
points.mesh.rotation.y = Math.PI / 6;
method
pos(position: Vec3): Points
Set the position of the object.
param position
A vector-like object representing the position.Example
points.pos([0, 0, 2]);
method
color(color: PointsColor): Points
Set the color of the object.
param color
A color input for this object.Example
points.color(["tomato", "gold"]);
method
material(material: THREE.Material): Points
Set the material of the object.
param material
A THREE.Material instance.Example
points.material(new THREE.PointsMaterial({ size: 3 }));
method
pointSize(size: number): Points
Sets the size of the points in the point cloud.
param size
The new size for the points.Example
points.pointSize(4);
field
pointCount: number
Gets the number of points in the point cloud.
returns
Number of points.Example
const total = points.pointCount;
method
getPosition(index: number): Vec3
Gets the position of a specific point.
param index
Index of the point to get the position for.returns
Position of the specified point.Example
const p0 = points.getPosition(0);
method
setPosition(index: number, position: Vec3): void
Sets the position of a specific point.
param index
Index of the point to set the position for.param position
New position for the point.Example
points.setPosition(0, [1, 0, 0]);
method
getColor(index: number): THREE.Color
Gets the color of a specific point.
param index
Index of the point to get the color for.returns
Color of the specified point.Example
const tint = points.getColor(0);
method
setColor(index: number, color: THREE.ColorRepresentation, alpha?: number): void
Sets the color of a specific point.
param index
Index of the point to set the color for.param color
New color for the point.param alpha
New alpha for the point.Example
points.setColor(0, "deepskyblue", 0.6);
method
getAlpha(index: number): number
Gets the alpha of a specific point.
param index
Index of the point to get the alpha for.returns
Alpha of the specified point.Example
const a = points.getAlpha(0);
method
setAlpha(index: number, alpha: number): void
Sets the alpha of a specific point.
param index
Index of the point to set the alpha for.param alpha
New alpha for the point.Example
points.setAlpha(0, 0.5);