@types/three 0.150.1 → 0.151.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- three/README.md +1 -1
- three/examples/jsm/controls/MapControls.d.ts +21 -0
- three/examples/jsm/controls/OrbitControls.d.ts +1 -5
- three/examples/jsm/controls/PointerLockControls.d.ts +3 -0
- three/examples/jsm/controls/TrackballControls.d.ts +2 -0
- three/examples/jsm/helpers/ViewHelper.d.ts +3 -4
- three/examples/jsm/loaders/GLTFLoader.d.ts +2 -4
- three/examples/jsm/loaders/SVGLoader.d.ts +15 -3
- three/examples/jsm/nodes/Nodes.d.ts +130 -226
- three/examples/jsm/nodes/{core → code}/CodeNode.d.ts +2 -3
- three/examples/jsm/nodes/{core → code}/ExpressionNode.d.ts +2 -2
- three/examples/jsm/nodes/{core → code}/FunctionCallNode.d.ts +2 -2
- three/examples/jsm/nodes/{core → code}/FunctionNode.d.ts +4 -4
- three/examples/jsm/nodes/core/InputNode.d.ts +4 -0
- three/examples/jsm/nodes/core/NodeBuilder.d.ts +1 -3
- three/examples/jsm/nodes/core/NodeUtils.d.ts +8 -2
- three/examples/jsm/nodes/core/{VaryNode.d.ts → VaryingNode.d.ts} +1 -1
- three/examples/jsm/nodes/fog/FogNode.d.ts +1 -1
- three/examples/jsm/nodes/geometry/RangeNode.d.ts +2 -1
- three/examples/jsm/nodes/lighting/PointLightNode.d.ts +10 -0
- three/examples/jsm/nodes/lighting/SpotLightNode.d.ts +15 -0
- three/examples/jsm/nodes/math/MathNode.d.ts +2 -2
- three/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.d.ts +2 -2
- three/examples/jsm/objects/{GroundProjectedEnv.d.ts → GroundProjectedSkybox.d.ts} +1 -1
- three/examples/jsm/postprocessing/Pass.d.ts +2 -0
- three/examples/jsm/renderers/CSS2DRenderer.d.ts +2 -1
- three/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.d.ts +0 -1
- three/examples/jsm/utils/BufferGeometryUtils.d.ts +12 -2
- three/index.d.ts +1 -1
- three/package.json +2 -2
- three/src/Three.d.ts +1 -1
- three/src/core/Raycaster.d.ts +1 -0
- three/src/extras/DataUtils.d.ts +13 -0
- three/src/extras/Earcut.d.ts +12 -0
- three/src/extras/ImageUtils.d.ts +20 -20
- three/src/extras/PMREMGenerator.d.ts +66 -0
- three/src/extras/ShapeUtils.d.ts +19 -1
- three/src/extras/core/Curve.d.ts +86 -31
- three/src/extras/core/CurvePath.d.ts +46 -4
- three/src/extras/core/Interpolations.d.ts +36 -0
- three/src/extras/core/Path.d.ts +122 -15
- three/src/extras/core/Shape.d.ts +56 -6
- three/src/extras/core/ShapePath.d.ts +73 -8
- three/src/extras/curves/ArcCurve.d.ts +35 -3
- three/src/extras/curves/CatmullRomCurve3.d.ts +62 -15
- three/src/extras/curves/CubicBezierCurve.d.ts +48 -7
- three/src/extras/curves/CubicBezierCurve3.d.ts +48 -7
- three/src/extras/curves/EllipseCurve.d.ts +73 -18
- three/src/extras/curves/LineCurve.d.ts +26 -5
- three/src/extras/curves/LineCurve3.d.ts +26 -5
- three/src/extras/curves/QuadraticBezierCurve.d.ts +44 -6
- three/src/extras/curves/QuadraticBezierCurve3.d.ts +44 -6
- three/src/extras/curves/SplineCurve.d.ts +39 -3
- three/src/helpers/ArrowHelper.d.ts +48 -17
- three/src/helpers/AxesHelper.d.ts +35 -3
- three/src/helpers/Box3Helper.d.ts +28 -4
- three/src/helpers/BoxHelper.d.ts +45 -5
- three/src/helpers/CameraHelper.d.ts +38 -19
- three/src/helpers/DirectionalLightHelper.d.ts +58 -11
- three/src/helpers/GridHelper.d.ts +33 -7
- three/src/helpers/HemisphereLightHelper.d.ts +57 -5
- three/src/helpers/PlaneHelper.d.ts +31 -8
- three/src/helpers/PointLightHelper.d.ts +55 -7
- three/src/helpers/PolarGridHelper.d.ts +36 -9
- three/src/helpers/SkeletonHelper.d.ts +56 -8
- three/src/helpers/SpotLightHelper.d.ts +60 -5
- three/src/lights/AmbientLight.d.ts +24 -11
- three/src/lights/AmbientLightProbe.d.ts +19 -1
- three/src/lights/DirectionalLight.d.ts +76 -21
- three/src/lights/DirectionalLightShadow.d.ts +68 -2
- three/src/lights/HemisphereLight.d.ts +46 -14
- three/src/lights/HemisphereLightProbe.d.ts +20 -1
- three/src/lights/Light.d.ts +40 -43
- three/src/lights/LightProbe.d.ts +32 -5
- three/src/lights/LightShadow.d.ts +100 -18
- three/src/lights/PointLight.d.ts +58 -13
- three/src/lights/PointLightShadow.d.ts +18 -2
- three/src/lights/RectAreaLight.d.ts +61 -9
- three/src/lights/SpotLight.d.ts +106 -22
- three/src/lights/SpotLightShadow.d.ts +63 -3
- three/src/materials/LineBasicMaterial.d.ts +7 -2
- three/src/materials/MeshBasicMaterial.d.ts +1 -2
- three/src/materials/MeshDistanceMaterial.d.ts +0 -15
- three/src/materials/MeshLambertMaterial.d.ts +1 -2
- three/src/materials/MeshMatcapMaterial.d.ts +1 -2
- three/src/materials/MeshPhongMaterial.d.ts +1 -2
- three/src/materials/MeshStandardMaterial.d.ts +1 -2
- three/src/materials/MeshToonMaterial.d.ts +1 -2
- three/src/materials/PointsMaterial.d.ts +1 -2
- three/src/materials/ShadowMaterial.d.ts +1 -2
- three/src/materials/SpriteMaterial.d.ts +1 -2
- three/src/math/Color.d.ts +25 -5
- three/src/math/Quaternion.d.ts +6 -0
- three/src/math/Triangle.d.ts +40 -0
- three/src/math/Vector2.d.ts +5 -0
- three/src/math/Vector3.d.ts +10 -3
- three/src/objects/InstancedMesh.d.ts +22 -30
- three/src/objects/LineSegments.d.ts +2 -0
- three/src/objects/Skeleton.d.ts +5 -1
- three/src/objects/SkinnedMesh.d.ts +37 -25
- three/src/renderers/WebGLRenderer.d.ts +17 -2
- three/src/renderers/shaders/ShaderChunk.d.ts +58 -37
- three/src/renderers/shaders/UniformsLib.d.ts +88 -57
- three/src/scenes/Fog.d.ts +1 -2
- three/src/scenes/FogExp2.d.ts +1 -2
- three/src/textures/Texture.d.ts +5 -22
- three/examples/jsm/nodes/lighting/PunctualLightNode.d.ts +0 -12
- three/src/utils.d.ts +0 -6
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Used internally by {@link THREE.SplineCurve | SplineCurve}.
|
|
3
|
+
* @param t Interpolation weight. Expects a `Float`
|
|
4
|
+
* @param p0 Expects a `Float`
|
|
5
|
+
* @param p1 Expects a `Float`
|
|
6
|
+
* @param p2 Expects a `Float`
|
|
7
|
+
* @param p3 P0, p1, p2, the points defining the spline curve. Expects a `Float`
|
|
8
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/core/Interpolations | Official Documentation}
|
|
9
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/core/Interpolations.js | Source}
|
|
10
|
+
*/
|
|
11
|
+
declare function CatmullRom(t: number, p0: number, p1: number, p2: number, p3: number): number;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Used internally by {@link THREE.QuadraticBezierCurve3 | QuadraticBezierCurve3} and {@link THREE.QuadraticBezierCurve | QuadraticBezierCurve}.
|
|
15
|
+
* @param t Interpolation weight. Expects a `Float`
|
|
16
|
+
* @param p0 Expects a `Float`
|
|
17
|
+
* @param p1 Expects a `Float`
|
|
18
|
+
* @param p2 P0, p1, the starting, control and end points defining the curve. Expects a `Float`
|
|
19
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/core/Interpolations | Official Documentation}
|
|
20
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/core/Interpolations.js | Source}
|
|
21
|
+
*/
|
|
22
|
+
declare function QuadraticBezier(t: number, p0: number, p1: number, p2: number): number;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Used internally by {@link THREE.CubicBezierCurve3 | CubicBezierCurve3} and {@link THREE.CubicBezierCurve | CubicBezierCurve}.
|
|
26
|
+
* @param t Interpolation weight. Expects a `Float`
|
|
27
|
+
* @param p0 Expects a `Float`
|
|
28
|
+
* @param p1 Expects a `Float`
|
|
29
|
+
* @param p2 Expects a `Float`
|
|
30
|
+
* @param p3 P0, p1, p2, the starting, control(twice) and end points defining the curve. Expects a `Float`
|
|
31
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/core/Interpolations | Official Documentation}
|
|
32
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/core/Interpolations.js | Source}
|
|
33
|
+
*/
|
|
34
|
+
declare function CubicBezier(t: number, p0: number, p1: number, p2: number, p3: number): number;
|
|
35
|
+
|
|
36
|
+
export { CatmullRom, QuadraticBezier, CubicBezier };
|
three/src/extras/core/Path.d.ts
CHANGED
|
@@ -2,34 +2,72 @@ import { Vector2 } from './../../math/Vector2';
|
|
|
2
2
|
import { CurvePath } from './CurvePath';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* A 2D {@link Path} representation.
|
|
6
|
+
* @remarks
|
|
7
|
+
* The class provides methods for creating paths and contours of 2D shapes similar to the 2D Canvas API.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const {@link Path} = new THREE.Path();
|
|
11
|
+
* path.lineTo(0, 0.8);
|
|
12
|
+
* path.quadraticCurveTo(0, 1, 0.2, 1);
|
|
13
|
+
* path.lineTo(1, 1);
|
|
14
|
+
* const points = path.getPoints();
|
|
15
|
+
* const geometry = new THREE.BufferGeometry().setFromPoints(points);
|
|
16
|
+
* const material = new THREE.LineBasicMaterial({
|
|
17
|
+
* color: 0xffffff
|
|
18
|
+
* });
|
|
19
|
+
* const line = new THREE.Line(geometry, material);
|
|
20
|
+
* scene.add(line);
|
|
21
|
+
* ```
|
|
22
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/core/Path | Official Documentation}
|
|
23
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/core/Path.js | Source}
|
|
6
24
|
*/
|
|
7
25
|
export class Path extends CurvePath<Vector2> {
|
|
26
|
+
/**
|
|
27
|
+
* Creates a {@link Path} from the points
|
|
28
|
+
* @remarks
|
|
29
|
+
* The first point defines the offset, then successive points are added to the {@link CurvePath.curves | curves} array as {@link LineCurve | LineCurves}.
|
|
30
|
+
* If no points are specified, an empty {@link Path} is created and the {@link .currentPoint} is set to the origin.
|
|
31
|
+
* @param points Array of {@link Vector2 | Vector2s}.
|
|
32
|
+
*/
|
|
8
33
|
constructor(points?: Vector2[]);
|
|
9
34
|
|
|
10
35
|
/**
|
|
11
|
-
*
|
|
36
|
+
* A Read-only _string_ to check if `this` object type.
|
|
37
|
+
* @remarks Sub-classes will update this value.
|
|
38
|
+
* @defaultValue `Path`
|
|
12
39
|
*/
|
|
13
|
-
type: string;
|
|
40
|
+
override readonly type: string | 'Path';
|
|
14
41
|
|
|
15
42
|
/**
|
|
16
|
-
*
|
|
43
|
+
* The current offset of the path. Any new {@link THREE.Curve | Curve} added will start here.
|
|
44
|
+
* @defaultValue `new THREE.Vector2()`
|
|
17
45
|
*/
|
|
18
46
|
currentPoint: Vector2;
|
|
19
47
|
|
|
20
48
|
/**
|
|
21
|
-
*
|
|
49
|
+
* Adds an absolutely positioned {@link THREE.EllipseCurve | EllipseCurve} to the path.
|
|
50
|
+
* @param x Expects a `Float`
|
|
51
|
+
* @param y X, The absolute center of the arc. Expects a `Float`
|
|
52
|
+
* @param radius The radius of the arc. Expects a `Float`
|
|
53
|
+
* @param startAngle The start angle in radians. Expects a `Float`
|
|
54
|
+
* @param endAngle The end angle in radians. Expects a `Float`
|
|
55
|
+
* @param clockwise Sweep the arc clockwise. . Default `false`
|
|
22
56
|
*/
|
|
23
|
-
fromPoints(vectors: Vector2[]): this;
|
|
24
|
-
setFromPoints(vectors: Vector2[]): this;
|
|
25
|
-
moveTo(x: number, y: number): this;
|
|
26
|
-
lineTo(x: number, y: number): this;
|
|
27
|
-
quadraticCurveTo(aCPx: number, aCPy: number, aX: number, aY: number): this;
|
|
28
|
-
bezierCurveTo(aCP1x: number, aCP1y: number, aCP2x: number, aCP2y: number, aX: number, aY: number): this;
|
|
29
|
-
splineThru(pts: Vector2[]): this;
|
|
30
|
-
arc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): this;
|
|
31
57
|
absarc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): this;
|
|
32
|
-
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Adds an absolutely positioned {@link THREE.EllipseCurve | EllipseCurve} to the path.
|
|
61
|
+
* @param x Expects a `Float`
|
|
62
|
+
* @param y X, The absolute center of the ellipse. Expects a `Float`
|
|
63
|
+
* @param xRadius The radius of the ellipse in the x axis. Expects a `Float`
|
|
64
|
+
* @param yRadius The radius of the ellipse in the y axis. Expects a `Float`
|
|
65
|
+
* @param startAngle The start angle in radians. Expects a `Float`
|
|
66
|
+
* @param endAngle The end angle in radians. Expects a `Float`
|
|
67
|
+
* @param clockwise Sweep the ellipse clockwise. . Default `false`
|
|
68
|
+
* @param rotation The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. Optional, Expects a `Float`. Default `0`
|
|
69
|
+
*/
|
|
70
|
+
absellipse(
|
|
33
71
|
aX: number,
|
|
34
72
|
aY: number,
|
|
35
73
|
xRadius: number,
|
|
@@ -39,7 +77,41 @@ export class Path extends CurvePath<Vector2> {
|
|
|
39
77
|
aClockwise: boolean,
|
|
40
78
|
aRotation: number,
|
|
41
79
|
): this;
|
|
42
|
-
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Adds an {@link THREE.EllipseCurve | EllipseCurve} to the path, positioned relative to {@link .currentPoint}.
|
|
83
|
+
* @param x Expects a `Float`
|
|
84
|
+
* @param y X, The center of the arc offset from the last call. Expects a `Float`
|
|
85
|
+
* @param radius The radius of the arc. Expects a `Float`
|
|
86
|
+
* @param startAngle The start angle in radians. Expects a `Float`
|
|
87
|
+
* @param endAngle The end angle in radians. Expects a `Float`
|
|
88
|
+
* @param clockwise Sweep the arc clockwise. . Default `false`
|
|
89
|
+
*/
|
|
90
|
+
arc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): this;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* This creates a bezier curve from {@link .currentPoint} with (cp1X, cp1Y) and (cp2X, cp2Y) as control points and updates {@link .currentPoint} to x and y.
|
|
94
|
+
* @param cp1X Expects a `Float`
|
|
95
|
+
* @param cp1Y Expects a `Float`
|
|
96
|
+
* @param cp2X Expects a `Float`
|
|
97
|
+
* @param cp2Y Expects a `Float`
|
|
98
|
+
* @param x Expects a `Float`
|
|
99
|
+
* @param y Expects a `Float`
|
|
100
|
+
*/
|
|
101
|
+
bezierCurveTo(aCP1x: number, aCP1y: number, aCP2x: number, aCP2y: number, aX: number, aY: number): this;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Adds an {@link THREE.EllipseCurve | EllipseCurve} to the path, positioned relative to {@link .currentPoint}.
|
|
105
|
+
* @param x Expects a `Float`
|
|
106
|
+
* @param y X, The center of the ellipse offset from the last call. Expects a `Float`
|
|
107
|
+
* @param xRadius The radius of the ellipse in the x axis. Expects a `Float`
|
|
108
|
+
* @param yRadius The radius of the ellipse in the y axis. Expects a `Float`
|
|
109
|
+
* @param startAngle The start angle in radians. Expects a `Float`
|
|
110
|
+
* @param endAngle The end angle in radians. Expects a `Float`
|
|
111
|
+
* @param clockwise Sweep the ellipse clockwise. . Default `false`
|
|
112
|
+
* @param rotation The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. Optional, Expects a `Float`. Default `0`
|
|
113
|
+
*/
|
|
114
|
+
ellipse(
|
|
43
115
|
aX: number,
|
|
44
116
|
aY: number,
|
|
45
117
|
xRadius: number,
|
|
@@ -49,4 +121,39 @@ export class Path extends CurvePath<Vector2> {
|
|
|
49
121
|
aClockwise: boolean,
|
|
50
122
|
aRotation: number,
|
|
51
123
|
): this;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Connects a {@link THREE.LineCurve | LineCurve} from {@link .currentPoint} to x, y onto the path.
|
|
127
|
+
* @param x Expects a `Float`
|
|
128
|
+
* @param y Expects a `Float`
|
|
129
|
+
*/
|
|
130
|
+
lineTo(x: number, y: number): this;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Move the {@link .currentPoint} to x, y.
|
|
134
|
+
* @param x Expects a `Float`
|
|
135
|
+
* @param y Expects a `Float`
|
|
136
|
+
*/
|
|
137
|
+
moveTo(x: number, y: number): this;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Creates a quadratic curve from {@link .currentPoint} with cpX and cpY as control point and updates {@link .currentPoint} to x and y.
|
|
141
|
+
* @param cpX Expects a `Float`
|
|
142
|
+
* @param cpY Expects a `Float`
|
|
143
|
+
* @param x Expects a `Float`
|
|
144
|
+
* @param y Expects a `Float`
|
|
145
|
+
*/
|
|
146
|
+
quadraticCurveTo(aCPx: number, aCPy: number, aX: number, aY: number): this;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Points are added to the {@link CurvePath.curves | curves} array as {@link THREE.LineCurve | LineCurves}.
|
|
150
|
+
* @param vector2s
|
|
151
|
+
*/
|
|
152
|
+
setFromPoints(vectors: Vector2[]): this;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Connects a new {@link THREE.SplineCurve | SplineCurve} onto the path.
|
|
156
|
+
* @param points An array of {@link Vector2 | Vector2's}
|
|
157
|
+
*/
|
|
158
|
+
splineThru(pts: Vector2[]): this;
|
|
52
159
|
}
|
three/src/extras/core/Shape.d.ts
CHANGED
|
@@ -2,27 +2,77 @@ import { Vector2 } from './../../math/Vector2';
|
|
|
2
2
|
import { Path } from './Path';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Defines
|
|
5
|
+
* Defines an arbitrary 2d {@link Shape} plane using paths with optional holes
|
|
6
|
+
* @remarks
|
|
7
|
+
* It can be used with {@link THREE.ExtrudeGeometry | ExtrudeGeometry}, {@link THREE.ShapeGeometry | ShapeGeometry}, to get points, or to get triangulated faces.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const heartShape = new THREE.Shape();
|
|
11
|
+
* heartShape.moveTo(25, 25);
|
|
12
|
+
* heartShape.bezierCurveTo(25, 25, 20, 0, 0, 0);
|
|
13
|
+
* heartShape.bezierCurveTo(-30, 0, -30, 35, -30, 35);
|
|
14
|
+
* heartShape.bezierCurveTo(-30, 55, -10, 77, 25, 95);
|
|
15
|
+
* heartShape.bezierCurveTo(60, 77, 80, 55, 80, 35);
|
|
16
|
+
* heartShape.bezierCurveTo(80, 35, 80, 0, 50, 0);
|
|
17
|
+
* heartShape.bezierCurveTo(35, 0, 25, 25, 25, 25);
|
|
18
|
+
* const extrudeSettings = {
|
|
19
|
+
* depth: 8,
|
|
20
|
+
* bevelEnabled: true,
|
|
21
|
+
* bevelSegments: 2,
|
|
22
|
+
* steps: 2,
|
|
23
|
+
* bevelSize: 1,
|
|
24
|
+
* bevelThickness: 1
|
|
25
|
+
* };
|
|
26
|
+
* const geometry = new THREE.ExtrudeGeometry(heartShape, extrudeSettings);
|
|
27
|
+
* const mesh = new THREE.Mesh(geometry, new THREE.MeshPhongMaterial());
|
|
28
|
+
* ```
|
|
29
|
+
* @see Example: {@link https://threejs.org/examples/#webgl_geometry_shapes | geometry / shapes }
|
|
30
|
+
* @see Example: {@link https://threejs.org/examples/#webgl_geometry_extrude_shapes | geometry / extrude / shapes }
|
|
31
|
+
* @see Example: {@link https://threejs.org/examples/#webgl_geometry_extrude_shapes2 | geometry / extrude / shapes2 }
|
|
32
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/core/Shape | Official Documentation}
|
|
33
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/core/Shape.js | Source}
|
|
6
34
|
*/
|
|
7
35
|
export class Shape extends Path {
|
|
36
|
+
/**
|
|
37
|
+
* Creates a {@link Shape} from the points
|
|
38
|
+
* @remarks
|
|
39
|
+
* The first point defines the offset, then successive points are added to the {@link CurvePath.curves | curves} array as {@link THREE.LineCurve | LineCurves}.
|
|
40
|
+
* If no points are specified, an empty {@link Shape} is created and the {@link .currentPoint} is set to the origin.
|
|
41
|
+
* @param points Array of {@link Vector2 | Vector2s}.
|
|
42
|
+
*/
|
|
8
43
|
constructor(points?: Vector2[]);
|
|
9
44
|
|
|
10
45
|
/**
|
|
11
|
-
*
|
|
46
|
+
* A Read-only _string_ to check if `this` object type.
|
|
47
|
+
* @remarks Sub-classes will update this value.
|
|
48
|
+
* @defaultValue `Shape`
|
|
12
49
|
*/
|
|
13
|
-
type: string;
|
|
50
|
+
override readonly type: string | 'Shape';
|
|
14
51
|
|
|
52
|
+
/**
|
|
53
|
+
* {@link http://en.wikipedia.org/wiki/Universally_unique_identifier | UUID} of this object instance.
|
|
54
|
+
* @remarks This gets automatically assigned and shouldn't be edited.
|
|
55
|
+
*/
|
|
15
56
|
uuid: string;
|
|
16
57
|
|
|
17
58
|
/**
|
|
18
|
-
* @
|
|
59
|
+
* An array of {@link Path | paths} that define the holes in the shape.
|
|
60
|
+
* @defaultValue `[]`
|
|
19
61
|
*/
|
|
20
62
|
holes: Path[];
|
|
21
63
|
|
|
22
|
-
|
|
23
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Call {@link THREE.Curve.getPoints | getPoints} on the {@link Shape} and the {@link holes} array
|
|
66
|
+
* @param divisions The fineness of the result. Expects a `Integer`
|
|
67
|
+
*/
|
|
24
68
|
extractPoints(divisions: number): {
|
|
25
69
|
shape: Vector2[];
|
|
26
70
|
holes: Vector2[][];
|
|
27
71
|
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get an array of {@link Vector2 | Vector2's} that represent the holes in the shape.
|
|
75
|
+
* @param divisions The fineness of the result. Expects a `Integer`
|
|
76
|
+
*/
|
|
77
|
+
getPointsHoles(divisions: number): Vector2[][];
|
|
28
78
|
}
|
|
@@ -1,34 +1,99 @@
|
|
|
1
1
|
import { Vector2 } from './../../math/Vector2';
|
|
2
2
|
import { Shape } from './Shape';
|
|
3
3
|
import { Color } from '../../math/Color';
|
|
4
|
+
import { Path } from './Path';
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* This class is used to convert a series of shapes to an array of {@link THREE.Path | Path's},
|
|
8
|
+
* for example an SVG shape to a path (see the example below).
|
|
9
|
+
* @see Example: {@link https://threejs.org/examples/#webgl_geometry_extrude_shapes2 | geometry / extrude / shapes2}
|
|
10
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/core/ShapePath | Official Documentation}
|
|
11
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/core/ShapePath.js | Source}
|
|
12
|
+
*/
|
|
5
13
|
export class ShapePath {
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new {@link ShapePath}
|
|
16
|
+
* @remarks
|
|
17
|
+
* Unlike a {@link THREE.Path | Path}, no points are passed in as the {@link ShapePath} is designed to be generated after creation.
|
|
18
|
+
*/
|
|
6
19
|
constructor();
|
|
7
20
|
|
|
8
21
|
/**
|
|
9
|
-
*
|
|
22
|
+
* A Read-only _string_ to check if `this` object type.
|
|
23
|
+
* @remarks Sub-classes will update this value.
|
|
24
|
+
* @defaultValue `ShapePath`
|
|
10
25
|
*/
|
|
11
|
-
type:
|
|
26
|
+
readonly type: 'ShapePath';
|
|
12
27
|
|
|
13
28
|
/**
|
|
14
|
-
* @
|
|
29
|
+
* Array of {@link THREE.Path | Path's}s.
|
|
30
|
+
* @defaultValue `[]`
|
|
15
31
|
*/
|
|
16
|
-
|
|
32
|
+
subPaths: Path[];
|
|
17
33
|
|
|
18
34
|
/**
|
|
19
|
-
* @
|
|
35
|
+
* The current {@link THREE.Path | Path} that is being generated.
|
|
36
|
+
* @defaultValue `null`
|
|
20
37
|
*/
|
|
21
|
-
|
|
38
|
+
readonly currentPath: Path | null;
|
|
22
39
|
|
|
23
40
|
/**
|
|
24
|
-
* @default
|
|
41
|
+
* {@link THREE.Color | Color} of the shape, by default set to white _(0xffffff)_.
|
|
42
|
+
* @defaultValue `new THREE.Color()`
|
|
25
43
|
*/
|
|
26
|
-
|
|
44
|
+
color: Color;
|
|
27
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Starts a new {@link THREE.Path | Path} and calls {@link THREE.Path.moveTo | Path.moveTo}( x, y ) on that {@link THREE.Path | Path}
|
|
48
|
+
* @remarks
|
|
49
|
+
* Also points {@link ShapePath.currentPath | currentPath} to that {@link THREE.Path | Path}.
|
|
50
|
+
* @param x Expects a `Float`
|
|
51
|
+
* @param y Expects a `Float`
|
|
52
|
+
*/
|
|
28
53
|
moveTo(x: number, y: number): this;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* This creates a line from the {@link ShapePath.currentPath | currentPath}'s offset to X and Y and updates the offset to X and Y.
|
|
57
|
+
* @param x Expects a `Float`
|
|
58
|
+
* @param y Expects a `Float`
|
|
59
|
+
*/
|
|
29
60
|
lineTo(x: number, y: number): this;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* This creates a quadratic curve from the {@link ShapePath.currentPath | currentPath}'s
|
|
64
|
+
* offset to _x_ and _y_ with _cpX_ and _cpY_ as control point and updates the {@link ShapePath.currentPath | currentPath}'s offset to _x_ and _y_.
|
|
65
|
+
* @param cpX Expects a `Float`
|
|
66
|
+
* @param cpY Expects a `Float`
|
|
67
|
+
* @param x Expects a `Float`
|
|
68
|
+
* @param y Expects a `Float`
|
|
69
|
+
*/
|
|
30
70
|
quadraticCurveTo(aCPx: number, aCPy: number, aX: number, aY: number): this;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* This creates a bezier curve from the {@link ShapePath.currentPath | currentPath}'s
|
|
74
|
+
* offset to _x_ and _y_ with _cp1X_, _cp1Y_ and _cp2X_, _cp2Y_ as control points and
|
|
75
|
+
* updates the {@link ShapePath.currentPath | currentPath}'s offset to _x_ and _y_.
|
|
76
|
+
* @param cp1X Expects a `Float`
|
|
77
|
+
* @param cp1Y Expects a `Float`
|
|
78
|
+
* @param cp2X Expects a `Float`
|
|
79
|
+
* @param cp2Y Expects a `Float`
|
|
80
|
+
* @param x Expects a `Float`
|
|
81
|
+
* @param y Expects a `Float`
|
|
82
|
+
*/
|
|
31
83
|
bezierCurveTo(aCP1x: number, aCP1y: number, aCP2x: number, aCP2y: number, aX: number, aY: number): this;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Connects a new {@link THREE.SplineCurve | SplineCurve} onto the {@link ShapePath.currentPath | currentPath}.
|
|
87
|
+
* @param points An array of {@link THREE.Vector2 | Vector2}s
|
|
88
|
+
*/
|
|
32
89
|
splineThru(pts: Vector2[]): this;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Converts the {@link ShapePath.subPaths | subPaths} array into an array of Shapes
|
|
93
|
+
* @remarks
|
|
94
|
+
* By default solid shapes are defined clockwise (CW) and holes are defined counterclockwise (CCW)
|
|
95
|
+
* If isCCW is set to true, then those are flipped.
|
|
96
|
+
* @param isCCW Changes how solids and holes are generated
|
|
97
|
+
*/
|
|
33
98
|
toShapes(isCCW: boolean): Shape[];
|
|
34
99
|
}
|
|
@@ -1,9 +1,41 @@
|
|
|
1
1
|
import { EllipseCurve } from './EllipseCurve';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Alias for {@link THREE.EllipseCurve | EllipseCurve}.
|
|
5
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/curves/ArcCurve | Official Documentation}
|
|
6
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/curves/ArcCurve.js | Source}
|
|
7
|
+
*/
|
|
2
8
|
export class ArcCurve extends EllipseCurve {
|
|
3
|
-
|
|
9
|
+
/**
|
|
10
|
+
* This constructor creates a new {@link ArcCurve}.
|
|
11
|
+
* @param aX The X center of the ellipse. Expects a `Float`. Default is `0`.
|
|
12
|
+
* @param aY The Y center of the ellipse. Expects a `Float`. Default is `0`.
|
|
13
|
+
* @param xRadius The radius of the ellipse in the x direction. Expects a `Float`. Default is `1`.
|
|
14
|
+
* @param yRadius The radius of the ellipse in the y direction. Expects a `Float`. Default is `1`.
|
|
15
|
+
* @param aStartAngle The start angle of the curve in radians starting from the positive X axis. Default is `0`.
|
|
16
|
+
* @param aEndAngle The end angle of the curve in radians starting from the positive X axis. Default is `2 x Math.PI`.
|
|
17
|
+
* @param aClockwise Whether the ellipse is drawn clockwise. Default is `false`.
|
|
18
|
+
*/
|
|
19
|
+
constructor(
|
|
20
|
+
aX?: number,
|
|
21
|
+
aY?: number,
|
|
22
|
+
aRadius?: number,
|
|
23
|
+
aStartAngle?: number,
|
|
24
|
+
aEndAngle?: number,
|
|
25
|
+
aClockwise?: boolean,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Read-only flag to check if a given object is of type {@link ArcCurve}.
|
|
30
|
+
* @remarks This is a _constant_ value
|
|
31
|
+
* @defaultValue `true`
|
|
32
|
+
*/
|
|
33
|
+
readonly isArcCurve = true;
|
|
4
34
|
|
|
5
35
|
/**
|
|
6
|
-
*
|
|
36
|
+
* A Read-only _string_ to check if `this` object type.
|
|
37
|
+
* @remarks Sub-classes will update this value.
|
|
38
|
+
* @defaultValue `ArcCurve`
|
|
7
39
|
*/
|
|
8
|
-
type: string;
|
|
40
|
+
override readonly type: string | 'ArcCurve';
|
|
9
41
|
}
|
|
@@ -1,30 +1,77 @@
|
|
|
1
1
|
import { Vector3 } from './../../math/Vector3';
|
|
2
2
|
import { Curve } from './../core/Curve';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
export namespace CurveUtils {
|
|
6
|
-
function tangentQuadraticBezier(t: number, p0: number, p1: number, p2: number): number;
|
|
7
|
-
function tangentCubicBezier(t: number, p0: number, p1: number, p2: number, p3: number): number;
|
|
8
|
-
function tangentSpline(t: number, p0: number, p1: number, p2: number, p3: number): number;
|
|
9
|
-
function interpolate(p0: number, p1: number, p2: number, p3: number, t: number): number;
|
|
10
|
-
}
|
|
4
|
+
export type CurveType = 'centripetal' | 'chordal' | 'catmullrom';
|
|
11
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Create a smooth **3D** spline curve from a series of points using the {@link https://en.wikipedia.org/wiki/Centripetal_Catmull-Rom_spline | Catmull-Rom} algorithm.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* //Create a closed wavey loop
|
|
11
|
+
* const curve = new THREE.CatmullRomCurve3([
|
|
12
|
+
* new THREE.Vector3(-10, 0, 10),
|
|
13
|
+
* new THREE.Vector3(-5, 5, 5),
|
|
14
|
+
* new THREE.Vector3(0, 0, 0),
|
|
15
|
+
* new THREE.Vector3(5, -5, 5),
|
|
16
|
+
* new THREE.Vector3(10, 0, 10)]);
|
|
17
|
+
* const points = curve.getPoints(50);
|
|
18
|
+
* const geometry = new THREE.BufferGeometry().setFromPoints(points);
|
|
19
|
+
* const material = new THREE.LineBasicMaterial({
|
|
20
|
+
* color: 0xff0000
|
|
21
|
+
* });
|
|
22
|
+
* // Create the final object to add to the scene
|
|
23
|
+
* const curveObject = new THREE.Line(geometry, material);
|
|
24
|
+
* ```
|
|
25
|
+
* @see Example: {@link https://threejs.org/examples/#webgl_geometry_extrude_splines | WebGL / geometry / extrude / splines}
|
|
26
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/curves/CatmullRomCurve3 | Official Documentation}
|
|
27
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/curves/CatmullRomCurve3.js | Source}
|
|
28
|
+
*/
|
|
12
29
|
export class CatmullRomCurve3 extends Curve<Vector3> {
|
|
13
30
|
/**
|
|
14
|
-
* @
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
31
|
+
* This constructor creates a new {@link CatmullRomCurve3}.
|
|
32
|
+
* @param points An array of {@link THREE.Vector3 | Vector3} points
|
|
33
|
+
* @param closed Whether the curve is closed. Default `false`
|
|
34
|
+
* @param curveType Type of the curve. Default `centripetal`
|
|
35
|
+
* @param tension Tension of the curve. Expects a `Float`. Default `0.5`
|
|
36
|
+
*/
|
|
37
|
+
constructor(points?: Vector3[], closed?: boolean, curveType?: CurveType, tension?: number);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Read-only flag to check if a given object is of type {@link CatmullRomCurve3}.
|
|
41
|
+
* @remarks This is a _constant_ value
|
|
42
|
+
* @defaultValue `true`
|
|
43
|
+
*/
|
|
44
|
+
readonly isCatmullRomCurve3 = true;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A Read-only _string_ to check if `this` object type.
|
|
48
|
+
* @remarks Sub-classes will update this value.
|
|
49
|
+
* @defaultValue `CatmullRomCurve3`
|
|
18
50
|
*/
|
|
19
|
-
|
|
51
|
+
override readonly type: string | 'CatmullRomCurve3';
|
|
20
52
|
|
|
21
53
|
/**
|
|
22
|
-
*
|
|
54
|
+
* The curve will loop back onto itself when this is true.
|
|
55
|
+
* @defaultValue `false`
|
|
23
56
|
*/
|
|
24
|
-
|
|
57
|
+
closed: boolean;
|
|
25
58
|
|
|
26
59
|
/**
|
|
27
|
-
* @
|
|
60
|
+
* The array of {@link THREE.Vector3 | Vector3} points that define the curve.
|
|
61
|
+
* @remarks It needs at least two entries.
|
|
62
|
+
* @defaultValue `[]`
|
|
28
63
|
*/
|
|
29
64
|
points: Vector3[];
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Possible values are `centripetal`, `chordal` and `catmullrom`.
|
|
68
|
+
* @defaultValue `centripetal`
|
|
69
|
+
*/
|
|
70
|
+
curveType: CurveType;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* When {@link .curveType} is `catmullrom`, defines catmullrom's tension.
|
|
74
|
+
* @remarks Expects a `Float`
|
|
75
|
+
*/
|
|
76
|
+
tension: number;
|
|
30
77
|
}
|
|
@@ -1,31 +1,72 @@
|
|
|
1
1
|
import { Vector2 } from './../../math/Vector2';
|
|
2
2
|
import { Curve } from './../core/Curve';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Create a smooth **2D** {@link http://en.wikipedia.org/wiki/B%C3%A9zier_curve#mediaviewer/File:Bezier_curve.svg | cubic bezier curve},
|
|
6
|
+
* defined by a start point, endpoint and two control points.
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const curve = new THREE.CubicBezierCurve(
|
|
10
|
+
* new THREE.Vector2(-10, 0),
|
|
11
|
+
* new THREE.Vector2(-5, 15),
|
|
12
|
+
* new THREE.Vector2(20, 15),
|
|
13
|
+
* new THREE.Vector2(10, 0));
|
|
14
|
+
* const points = curve.getPoints(50);
|
|
15
|
+
* const geometry = new THREE.BufferGeometry().setFromPoints(points);
|
|
16
|
+
* const material = new THREE.LineBasicMaterial({
|
|
17
|
+
* color: 0xff0000
|
|
18
|
+
* });
|
|
19
|
+
* // Create the final object to add to the scene
|
|
20
|
+
* const curveObject = new THREE.Line(geometry, material);
|
|
21
|
+
* ```
|
|
22
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/curves/CubicBezierCurve | Official Documentation}
|
|
23
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/curves/CubicBezierCurve.js | Source}
|
|
24
|
+
*/
|
|
4
25
|
export class CubicBezierCurve extends Curve<Vector2> {
|
|
5
|
-
|
|
26
|
+
/**
|
|
27
|
+
* This constructor creates a new {@link CubicBezierCurve}.
|
|
28
|
+
* @param v0 The starting point. Default is `new THREE.Vector2()`.
|
|
29
|
+
* @param v1 The first control point. Default is `new THREE.Vector2()`.
|
|
30
|
+
* @param v2 The second control point. Default is `new THREE.Vector2()`.
|
|
31
|
+
* @param v3 The ending point. Default is `new THREE.Vector2()`.
|
|
32
|
+
*/
|
|
33
|
+
constructor(v0?: Vector2, v1?: Vector2, v2?: Vector2, v3?: Vector2);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Read-only flag to check if a given object is of type {@link CubicBezierCurve}.
|
|
37
|
+
* @remarks This is a _constant_ value
|
|
38
|
+
* @defaultValue `true`
|
|
39
|
+
*/
|
|
40
|
+
readonly isCubicBezierCurve = true;
|
|
6
41
|
|
|
7
42
|
/**
|
|
8
|
-
*
|
|
43
|
+
* A Read-only _string_ to check if `this` object type.
|
|
44
|
+
* @remarks Sub-classes will update this value.
|
|
45
|
+
* @defaultValue `CubicBezierCurve`
|
|
9
46
|
*/
|
|
10
|
-
type: string;
|
|
47
|
+
override readonly type: string | 'CubicBezierCurve';
|
|
11
48
|
|
|
12
49
|
/**
|
|
13
|
-
*
|
|
50
|
+
* The starting point.
|
|
51
|
+
* @defaultValue `new THREE.Vector2()`
|
|
14
52
|
*/
|
|
15
53
|
v0: Vector2;
|
|
16
54
|
|
|
17
55
|
/**
|
|
18
|
-
*
|
|
56
|
+
* The first control point.
|
|
57
|
+
* @defaultValue `new THREE.Vector2()`
|
|
19
58
|
*/
|
|
20
59
|
v1: Vector2;
|
|
21
60
|
|
|
22
61
|
/**
|
|
23
|
-
*
|
|
62
|
+
* The second control point.
|
|
63
|
+
* @defaultValue `new THREE.Vector2()`
|
|
24
64
|
*/
|
|
25
65
|
v2: Vector2;
|
|
26
66
|
|
|
27
67
|
/**
|
|
28
|
-
*
|
|
68
|
+
* The ending point.
|
|
69
|
+
* @defaultValue `new THREE.Vector2()`
|
|
29
70
|
*/
|
|
30
71
|
v3: Vector2;
|
|
31
72
|
}
|