BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

Shape.extractPoints()

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.

Syntax

Shape.extractPoints( divisions: Integer ): Array<Vector2>

Parameters

  • divisions (optional): An integer representing the number of segments that each curved path will be divided into. Default value is 12.

Returns

An array of Vector2 instances representing the 2D points that make up the Shape.

Example

// 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.

Notes

The Shape.extractPoints() method is useful for a variety of purposes, such as:

  • Providing a representation of a Shape's geometry that can be used to create custom meshes or other Three.js objects.
  • Calculating the area, centroid, or other properties of a Shape based on its 2D points.
  • Performing boolean operations or other geometric transformations on a Shape's points.

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.