The Shape.extractPoints()
method is a function from the Three.js library which is used to extract a list of 2D points from a Shape. A Shape is a geometrical object that can be created by defining one or more paths, each consisting of a series of connected points.
Shape.extractPoints( divisions: Integer ): Array<Vector2>
divisions
(optional): An integer representing the number of segments that each curved path will be divided into. Default value is 12.An array of Vector2
instances representing the 2D points that make up the Shape.
// Create a shape
const shape = new THREE.Shape();
// Define a path for the shape
shape.moveTo(0,0);
shape.lineTo(0,1);
shape.bezierCurveTo(2,2,3,-2,4,0);
shape.lineTo(4,1);
// Extract points from the shape
const points = shape.extractPoints();
// Log the extracted points to the console
console.log(points);
In this example, a Shape is created and a path with straight and curved segments is defined. The extractPoints()
method is then called to extract the 2D points from the Shape. The resulting array of Vector2 instances is logged to the console.
The Shape.extractPoints()
method is useful for a variety of purposes, such as:
It is important to note that the Shape.extractPoints()
method only extracts the points from a Shape's path data; it does not actually create any Three.js objects or geometries. It is up to the user to use the extracted points to create the desired objects or perform additional calculations.