@types/three 0.150.2 → 0.152.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 +2 -2
- three/build/three.min.d.ts +2 -0
- three/build/three.module.min.d.ts +2 -0
- 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/libs/tween.module.d.ts +2 -0
- 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 +131 -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 -11
- 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/core/constants.d.ts +1 -0
- 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/LightUtils.d.ts +4 -0
- three/examples/jsm/nodes/lighting/PointLightNode.d.ts +10 -0
- three/examples/jsm/nodes/lighting/SpotLightNode.d.ts +15 -0
- three/examples/jsm/nodes/materials/LineBasicNodeMaterial.d.ts +0 -7
- three/examples/jsm/nodes/materials/MeshBasicNodeMaterial.d.ts +0 -9
- three/examples/jsm/nodes/materials/MeshStandardNodeMaterial.d.ts +0 -9
- three/examples/jsm/nodes/materials/NodeMaterial.d.ts +17 -1
- three/examples/jsm/nodes/math/MathNode.d.ts +2 -2
- three/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.d.ts +2 -2
- three/examples/jsm/nodes/shadernode/ShaderNodeElements.d.ts +0 -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/CSS3DRenderer.d.ts +2 -2
- three/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.d.ts +1 -21
- three/examples/jsm/utils/BufferGeometryUtils.d.ts +12 -2
- three/examples/jsm/utils/SkeletonUtils.d.ts +3 -19
- three/index.d.ts +1 -1
- three/package.json +3 -2
- three/src/Three.d.ts +1 -0
- three/src/constants.d.ts +3 -23
- three/src/core/BufferGeometry.d.ts +60 -33
- three/src/core/Raycaster.d.ts +2 -1
- 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 +47 -16
- three/src/helpers/AxesHelper.d.ts +35 -3
- three/src/helpers/Box3Helper.d.ts +28 -4
- three/src/helpers/BoxHelper.d.ts +44 -4
- three/src/helpers/CameraHelper.d.ts +38 -19
- three/src/helpers/DirectionalLightHelper.d.ts +57 -10
- three/src/helpers/GridHelper.d.ts +32 -6
- three/src/helpers/HemisphereLightHelper.d.ts +56 -3
- three/src/helpers/PlaneHelper.d.ts +31 -8
- three/src/helpers/PointLightHelper.d.ts +54 -6
- three/src/helpers/PolarGridHelper.d.ts +35 -8
- three/src/helpers/SkeletonHelper.d.ts +56 -8
- three/src/helpers/SpotLightHelper.d.ts +59 -4
- three/src/lights/AmbientLight.d.ts +23 -10
- three/src/lights/AmbientLightProbe.d.ts +18 -0
- three/src/lights/DirectionalLight.d.ts +75 -20
- three/src/lights/DirectionalLightShadow.d.ts +68 -2
- three/src/lights/HemisphereLight.d.ts +45 -12
- three/src/lights/HemisphereLightProbe.d.ts +19 -0
- 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 +57 -12
- three/src/lights/PointLightShadow.d.ts +18 -2
- three/src/lights/RectAreaLight.d.ts +60 -8
- three/src/lights/SpotLight.d.ts +105 -20
- three/src/lights/SpotLightShadow.d.ts +63 -3
- three/src/materials/LineBasicMaterial.d.ts +7 -1
- three/src/materials/MeshDistanceMaterial.d.ts +0 -15
- three/src/materials/ShaderMaterial.d.ts +1 -1
- three/src/math/Color.d.ts +23 -2
- 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/Points.d.ts +7 -6
- three/src/objects/Skeleton.d.ts +5 -1
- three/src/objects/SkinnedMesh.d.ts +37 -25
- three/src/renderers/WebGLRenderTarget.d.ts +3 -0
- three/src/renderers/WebGLRenderer.d.ts +25 -1
- three/src/renderers/shaders/ShaderChunk.d.ts +58 -37
- three/src/renderers/shaders/UniformsLib.d.ts +88 -57
- three/src/textures/CanvasTexture.d.ts +0 -1
- three/src/textures/CompressedTexture.d.ts +3 -2
- three/src/textures/CubeTexture.d.ts +3 -4
- three/src/textures/DataTexture.d.ts +3 -3
- three/src/textures/Texture.d.ts +37 -24
- three/examples/jsm/nodes/functions/light/getDistanceAttenuation.d.ts +0 -5
- three/examples/jsm/nodes/lighting/PunctualLightNode.d.ts +0 -12
three/src/extras/ImageUtils.d.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { Mapping } from '../constants';
|
|
2
2
|
import { Texture } from '../textures/Texture';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* A class containing utility functions for images.
|
|
6
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/ImageUtils | Official Documentation}
|
|
7
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/ImageUtils.js | Source}
|
|
8
|
+
*/
|
|
4
9
|
export namespace ImageUtils {
|
|
5
|
-
function getDataURL(image: any): string;
|
|
6
|
-
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
11
|
+
* Returns a data URI containing a representation of the given image.
|
|
12
|
+
* @param image The image object.
|
|
9
13
|
*/
|
|
10
|
-
|
|
14
|
+
function getDataURL(
|
|
15
|
+
image: HTMLImageElement | HTMLCanvasElement | CanvasImageSource | ImageBitmap | ImageData,
|
|
16
|
+
): string;
|
|
11
17
|
|
|
12
18
|
/**
|
|
13
|
-
*
|
|
19
|
+
* Converts the given sRGB image data to linear color space.
|
|
20
|
+
* @param image
|
|
14
21
|
*/
|
|
15
|
-
function
|
|
16
|
-
url: string,
|
|
17
|
-
mapping?: Mapping,
|
|
18
|
-
onLoad?: (texture: Texture) => void,
|
|
19
|
-
onError?: (message: string) => void,
|
|
20
|
-
): Texture;
|
|
22
|
+
function sRGBToLinear(image: HTMLImageElement | HTMLCanvasElement | ImageBitmap): HTMLCanvasElement;
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
|
-
*
|
|
25
|
+
* Converts the given sRGB image data to linear color space.
|
|
26
|
+
* @param image
|
|
24
27
|
*/
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
): Texture;
|
|
31
|
-
|
|
32
|
-
function sRGBToLinear(image: any): HTMLCanvasElement | { data: number[]; width: number; height: number };
|
|
28
|
+
function sRGBToLinear(image: ImageData): {
|
|
29
|
+
data: ImageData['data'];
|
|
30
|
+
width: ImageData['width'];
|
|
31
|
+
height: ImageData['height'];
|
|
32
|
+
};
|
|
33
33
|
}
|
|
@@ -4,12 +4,78 @@ import { Texture } from '../textures/Texture';
|
|
|
4
4
|
import { CubeTexture } from '../textures/CubeTexture';
|
|
5
5
|
import { Scene } from '../scenes/Scene';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* This class generates a Prefiltered, Mipmapped Radiance Environment Map (PMREM) from a cubeMap environment texture.
|
|
9
|
+
* @remarks
|
|
10
|
+
* This allows different levels of blur to be quickly accessed based on material roughness
|
|
11
|
+
* Unlike a traditional mipmap chain, it only goes down to the LOD_MIN level (above), and then creates extra even more filtered 'mips' at the same LOD_MIN resolution,
|
|
12
|
+
* associated with higher roughness levels
|
|
13
|
+
* In this way we maintain resolution to smoothly interpolate diffuse lighting while limiting sampling computation.
|
|
14
|
+
* @remarks
|
|
15
|
+
* Note: The minimum {@link THREE.MeshStandardMaterial | MeshStandardMaterial}'s roughness depends on the size of the provided texture
|
|
16
|
+
* If your render has small dimensions or the shiny parts have a lot of curvature, you may still be able to get away with a smaller texture size.
|
|
17
|
+
*
|
|
18
|
+
* | texture size | minimum roughness |
|
|
19
|
+
* |--------------|--------------------|
|
|
20
|
+
* | 16 | 0.21 |
|
|
21
|
+
* | 32 | 0.15 |
|
|
22
|
+
* | 64 | 0.11 |
|
|
23
|
+
* | 128 | 0.076 |
|
|
24
|
+
* | 256 | 0.054 |
|
|
25
|
+
* | 512 | 0.038 |
|
|
26
|
+
* | 1024 | 0.027 |
|
|
27
|
+
*
|
|
28
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/PMREMGenerator | Official Documentation}
|
|
29
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/PMREMGenerator.js | Source}
|
|
30
|
+
*/
|
|
7
31
|
export class PMREMGenerator {
|
|
32
|
+
/**
|
|
33
|
+
* This constructor creates a new PMREMGenerator.
|
|
34
|
+
* @param renderer
|
|
35
|
+
*/
|
|
8
36
|
constructor(renderer: WebGLRenderer);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Generates a PMREM from a supplied Scene, which can be faster than using an image if networking bandwidth is low
|
|
40
|
+
* @remarks
|
|
41
|
+
* Optional near and far planes ensure the scene is rendered in its entirety (the cubeCamera is placed at the origin).
|
|
42
|
+
* @param scene The given scene.
|
|
43
|
+
* @param sigma Specifies a blur radius in radians to be applied to the scene before PMREM generation. Default `0`.
|
|
44
|
+
* @param near The near plane value. Default `0.1`.
|
|
45
|
+
* @param far The far plane value. Default `100`.
|
|
46
|
+
*/
|
|
9
47
|
fromScene(scene: Scene, sigma?: number, near?: number, far?: number): WebGLRenderTarget;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Generates a PMREM from an equirectangular texture.
|
|
51
|
+
* @param equirectangular The equirectangular texture.
|
|
52
|
+
*/
|
|
10
53
|
fromEquirectangular(equirectangular: Texture, renderTarget?: WebGLRenderTarget | null): WebGLRenderTarget;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Generates a PMREM from an cubemap texture.
|
|
57
|
+
* @param cubemap The cubemap texture.
|
|
58
|
+
*/
|
|
11
59
|
fromCubemap(cubemap: CubeTexture, renderTarget?: WebGLRenderTarget | null): WebGLRenderTarget;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Pre-compiles the cubemap shader
|
|
63
|
+
* @remarks
|
|
64
|
+
* You can get faster start-up by invoking this method during your texture's network fetch for increased concurrency.
|
|
65
|
+
*/
|
|
12
66
|
compileCubemapShader(): void;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Pre-compiles the equirectangular shader
|
|
70
|
+
* @remarks
|
|
71
|
+
* You can get faster start-up by invoking this method during your texture's network fetch for increased concurrency.
|
|
72
|
+
*/
|
|
13
73
|
compileEquirectangularShader(): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Frees the GPU-related resources allocated by this instance
|
|
77
|
+
* @remarks
|
|
78
|
+
* Call this method whenever this instance is no longer used in your app.
|
|
79
|
+
*/
|
|
14
80
|
dispose(): void;
|
|
15
81
|
}
|
three/src/extras/ShapeUtils.d.ts
CHANGED
|
@@ -3,8 +3,26 @@ export interface Vec2 {
|
|
|
3
3
|
y: number;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* A class containing utility functions for shapes.
|
|
8
|
+
* @remarks Note that these are all linear functions so it is necessary to calculate separately for x, y (and z, w if present) components of a vector.
|
|
9
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/ShapeUtils | Official Documentation}
|
|
10
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/ShapeUtils.js | Source}
|
|
11
|
+
*/
|
|
6
12
|
export namespace ShapeUtils {
|
|
13
|
+
/**
|
|
14
|
+
* Calculate area of a ( 2D ) contour polygon.
|
|
15
|
+
*/
|
|
7
16
|
function area(contour: Vec2[]): number;
|
|
8
|
-
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Note that this is a linear function so it is necessary to calculate separately for x, y components of a polygon.
|
|
20
|
+
* @remarks Used internally by {@link THREE.Path | Path}, {@link THREE.ExtrudeGeometry | ExtrudeGeometry} and {@link THREE.ShapeGeometry | ShapeGeometry}.
|
|
21
|
+
*/
|
|
9
22
|
function isClockWise(pts: Vec2[]): boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Used internally by {@link THREE.ExtrudeGeometry | ExtrudeGeometry} and {@link THREE.ShapeGeometry | ShapeGeometry} to calculate faces in shapes with holes.
|
|
26
|
+
*/
|
|
27
|
+
function triangulateShape(contour: Vec2[], holes: Vec2[][]): number[][];
|
|
10
28
|
}
|
three/src/extras/core/Curve.d.ts
CHANGED
|
@@ -1,84 +1,128 @@
|
|
|
1
1
|
import { Vector } from './../../math/Vector2';
|
|
2
2
|
import { Vector3 } from './../../math/Vector3';
|
|
3
3
|
|
|
4
|
-
// Extras / Core /////////////////////////////////////////////////////////////////////
|
|
5
|
-
|
|
6
4
|
/**
|
|
7
|
-
* An
|
|
8
|
-
*
|
|
5
|
+
* An abstract base class for creating a {@link Curve} object that contains methods for interpolation
|
|
6
|
+
* @remarks
|
|
7
|
+
* For an array of Curves see {@link THREE.CurvePath | CurvePath}.
|
|
8
|
+
* @remarks
|
|
9
|
+
* This following curves inherit from THREE.Curve:
|
|
10
|
+
*
|
|
11
|
+
* **2D curves**
|
|
12
|
+
* - {@link THREE.ArcCurve}
|
|
13
|
+
* - {@link THREE.CubicBezierCurve}
|
|
14
|
+
* - {@link THREE.EllipseCurve}
|
|
15
|
+
* - {@link THREE.LineCurve}
|
|
16
|
+
* - {@link THREE.QuadraticBezierCurve}
|
|
17
|
+
* - {@link THREE.SplineCurve}
|
|
18
|
+
*
|
|
19
|
+
* **3D curves**
|
|
20
|
+
* - {@link THREE.CatmullRomCurve3}
|
|
21
|
+
* - {@link THREE.CubicBezierCurve3}
|
|
22
|
+
* - {@link THREE.LineCurve3}
|
|
23
|
+
* - {@link THREE.QuadraticBezierCurve3}
|
|
24
|
+
*
|
|
25
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/core/Curve | Official Documentation}
|
|
26
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/core/Curve.js | Source}
|
|
9
27
|
*/
|
|
10
|
-
export class Curve<T extends Vector> {
|
|
28
|
+
export abstract class Curve<T extends Vector> {
|
|
29
|
+
protected constructor();
|
|
30
|
+
|
|
11
31
|
/**
|
|
12
|
-
*
|
|
32
|
+
* A Read-only _string_ to check if `this` object type.
|
|
33
|
+
* @remarks Sub-classes will update this value.
|
|
34
|
+
* @defaultValue `Curve`
|
|
13
35
|
*/
|
|
14
|
-
type: string;
|
|
36
|
+
readonly type: string | 'Curve';
|
|
15
37
|
|
|
16
38
|
/**
|
|
17
|
-
* This value determines the amount of divisions when calculating the cumulative segment lengths of a
|
|
18
|
-
*
|
|
19
|
-
* @
|
|
39
|
+
* This value determines the amount of divisions when calculating the cumulative segment lengths of a {@link Curve}
|
|
40
|
+
* via {@link .getLengths}.
|
|
41
|
+
* To ensure precision when using methods like {@link .getSpacedPoints}, it is recommended to increase {@link .arcLengthDivisions} if the {@link Curve} is very large.
|
|
42
|
+
* @defaultValue `200`
|
|
43
|
+
* @remarks Expects a `Integer`
|
|
20
44
|
*/
|
|
21
45
|
arcLengthDivisions: number;
|
|
22
46
|
|
|
23
47
|
/**
|
|
24
|
-
* Returns a vector for
|
|
25
|
-
*
|
|
48
|
+
* Returns a vector for a given position on the curve.
|
|
49
|
+
* @param t A position on the curve. Must be in the range `[ 0, 1 ]`. Expects a `Float`
|
|
50
|
+
* @param optionalTarget If specified, the result will be copied into this Vector, otherwise a new Vector will be created. Default `new T`.
|
|
26
51
|
*/
|
|
27
52
|
getPoint(t: number, optionalTarget?: T): T;
|
|
28
53
|
|
|
29
54
|
/**
|
|
30
|
-
* Returns a vector for
|
|
31
|
-
*
|
|
55
|
+
* Returns a vector for a given position on the {@link Curve} according to the arc length.
|
|
56
|
+
* @param u A position on the {@link Curve} according to the arc length. Must be in the range `[ 0, 1 ]`. Expects a `Float`
|
|
57
|
+
* @param optionalTarget If specified, the result will be copied into this Vector, otherwise a new Vector will be created. Default `new T`.
|
|
32
58
|
*/
|
|
33
59
|
getPointAt(u: number, optionalTarget?: T): T;
|
|
34
60
|
|
|
35
61
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
62
|
+
* Returns a set of divisions `+1` points using {@link .getPoint | getPoint(t)}.
|
|
63
|
+
* @param divisions Number of pieces to divide the {@link Curve} into. Expects a `Integer`. Default `5`
|
|
38
64
|
*/
|
|
39
65
|
getPoints(divisions?: number): T[];
|
|
40
66
|
|
|
41
67
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
68
|
+
* Returns a set of divisions `+1` equi-spaced points using {@link .getPointAt | getPointAt(u)}.
|
|
69
|
+
* @param divisions Number of pieces to divide the {@link Curve} into. Expects a `Integer`. Default `5`
|
|
44
70
|
*/
|
|
45
71
|
getSpacedPoints(divisions?: number): T[];
|
|
46
72
|
|
|
47
73
|
/**
|
|
48
|
-
* Get total
|
|
74
|
+
* Get total {@link Curve} arc length.
|
|
49
75
|
*/
|
|
50
76
|
getLength(): number;
|
|
51
77
|
|
|
52
78
|
/**
|
|
53
|
-
* Get list of cumulative segment lengths
|
|
79
|
+
* Get list of cumulative segment lengths.
|
|
80
|
+
* @param divisions Expects a `Integer`
|
|
54
81
|
*/
|
|
55
82
|
getLengths(divisions?: number): number[];
|
|
56
83
|
|
|
57
84
|
/**
|
|
58
85
|
* Update the cumlative segment distance cache
|
|
86
|
+
* @remarks
|
|
87
|
+
* The method must be called every time {@link Curve} parameters are changed
|
|
88
|
+
* If an updated {@link Curve} is part of a composed {@link Curve} like {@link THREE.CurvePath | CurvePath},
|
|
89
|
+
* {@link .updateArcLengths}() must be called on the composed curve, too.
|
|
59
90
|
*/
|
|
60
91
|
updateArcLengths(): void;
|
|
61
92
|
|
|
62
93
|
/**
|
|
63
|
-
* Given u
|
|
94
|
+
* Given u in the range `[ 0, 1 ]`,
|
|
95
|
+
* @remarks
|
|
96
|
+
* `u` and `t` can then be used to give you points which are equidistant from the ends of the curve, using {@link .getPoint}.
|
|
97
|
+
* @param u Expects a `Float`
|
|
98
|
+
* @param distance Expects a `Float`
|
|
99
|
+
* @returns `t` also in the range `[ 0, 1 ]`. Expects a `Float`.
|
|
64
100
|
*/
|
|
65
101
|
getUtoTmapping(u: number, distance: number): number;
|
|
66
102
|
|
|
67
103
|
/**
|
|
68
|
-
* Returns a unit vector tangent at t
|
|
69
|
-
*
|
|
70
|
-
*
|
|
104
|
+
* Returns a unit vector tangent at t
|
|
105
|
+
* @remarks
|
|
106
|
+
* If the derived {@link Curve} does not implement its tangent derivation, two points a small delta apart will be used to find its gradient which seems to give a reasonable approximation.
|
|
107
|
+
* @param t A position on the curve. Must be in the range `[ 0, 1 ]`. Expects a `Float`
|
|
108
|
+
* @param optionalTarget If specified, the result will be copied into this Vector, otherwise a new Vector will be created.
|
|
71
109
|
*/
|
|
72
110
|
getTangent(t: number, optionalTarget?: T): T;
|
|
73
111
|
|
|
74
112
|
/**
|
|
75
|
-
* Returns tangent at
|
|
76
|
-
*
|
|
113
|
+
* Returns tangent at a point which is equidistant to the ends of the {@link Curve} from the point given in {@link .getTangent}.
|
|
114
|
+
* @param u A position on the {@link Curve} according to the arc length. Must be in the range `[ 0, 1 ]`. Expects a `Float`
|
|
115
|
+
* @param optionalTarget If specified, the result will be copied into this Vector, otherwise a new Vector will be created.
|
|
77
116
|
*/
|
|
78
117
|
getTangentAt(u: number, optionalTarget?: T): T;
|
|
79
118
|
|
|
80
119
|
/**
|
|
81
|
-
*
|
|
120
|
+
* Generates the Frenet Frames
|
|
121
|
+
* @remarks
|
|
122
|
+
* Requires a {@link Curve} definition in 3D space
|
|
123
|
+
* Used in geometries like {@link THREE.TubeGeometry | TubeGeometry} or {@link THREE.ExtrudeGeometry | ExtrudeGeometry}.
|
|
124
|
+
* @param segments Expects a `Integer`
|
|
125
|
+
* @param closed
|
|
82
126
|
*/
|
|
83
127
|
computeFrenetFrames(
|
|
84
128
|
segments: number,
|
|
@@ -89,13 +133,24 @@ export class Curve<T extends Vector> {
|
|
|
89
133
|
binormals: Vector3[];
|
|
90
134
|
};
|
|
91
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Creates a clone of this instance.
|
|
138
|
+
*/
|
|
92
139
|
clone(): this;
|
|
140
|
+
/**
|
|
141
|
+
* Copies another {@link Curve} object to this instance.
|
|
142
|
+
* @param source
|
|
143
|
+
*/
|
|
93
144
|
copy(source: Curve<T>): this;
|
|
94
|
-
toJSON(): object;
|
|
95
|
-
fromJSON(json: object): this;
|
|
96
145
|
|
|
97
146
|
/**
|
|
98
|
-
*
|
|
147
|
+
* Returns a JSON object representation of this instance.
|
|
148
|
+
*/
|
|
149
|
+
toJSON(): {};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Copies the data from the given JSON object to this instance.
|
|
153
|
+
* @param json
|
|
99
154
|
*/
|
|
100
|
-
|
|
155
|
+
fromJSON(json: {}): this;
|
|
101
156
|
}
|
|
@@ -1,26 +1,68 @@
|
|
|
1
1
|
import { Curve } from './Curve';
|
|
2
2
|
import { Vector } from './../../math/Vector2';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Curved Path - a curve path is simply a array of connected curves, but retains the api of a curve.
|
|
6
|
+
* @remarks
|
|
7
|
+
* A {@link CurvePath} is simply an array of connected curves, but retains the api of a curve.
|
|
8
|
+
* @see {@link https://threejs.org/docs/index.html#api/en/extras/core/CurvePath | Official Documentation}
|
|
9
|
+
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/core/CurvePath.js | Source}
|
|
10
|
+
*/
|
|
4
11
|
export class CurvePath<T extends Vector> extends Curve<T> {
|
|
12
|
+
/**
|
|
13
|
+
* The constructor take no parameters.
|
|
14
|
+
*/
|
|
5
15
|
constructor();
|
|
6
16
|
|
|
7
17
|
/**
|
|
8
|
-
*
|
|
18
|
+
* A Read-only _string_ to check if `this` object type.
|
|
19
|
+
* @remarks Sub-classes will update this value.
|
|
20
|
+
* @defaultValue `CurvePath`
|
|
9
21
|
*/
|
|
10
|
-
type: string;
|
|
22
|
+
override readonly type: string | 'CurvePath';
|
|
11
23
|
|
|
12
24
|
/**
|
|
13
|
-
* @
|
|
25
|
+
* The array of {@link Curve | Curves}.
|
|
26
|
+
* @defaultValue `[]`
|
|
14
27
|
*/
|
|
15
28
|
curves: Array<Curve<T>>;
|
|
16
29
|
|
|
17
30
|
/**
|
|
18
|
-
*
|
|
31
|
+
* Whether or not to automatically close the path.
|
|
32
|
+
* @defaultValue false
|
|
19
33
|
*/
|
|
20
34
|
autoClose: boolean;
|
|
21
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Add a curve to the {@link .curves} array.
|
|
38
|
+
* @param curve
|
|
39
|
+
*/
|
|
22
40
|
add(curve: Curve<T>): void;
|
|
41
|
+
/**
|
|
42
|
+
* Adds a {@link LineCurve | lineCurve} to close the path.
|
|
43
|
+
*/
|
|
23
44
|
closePath(): void;
|
|
45
|
+
|
|
24
46
|
getPoint(t: number, optionalTarget?: T): T;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get list of cumulative curve lengths of the curves in the {@link .curves} array.
|
|
50
|
+
*/
|
|
25
51
|
getCurveLengths(): number[];
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Returns an array of points representing a sequence of curves
|
|
55
|
+
* @remarks
|
|
56
|
+
* The `division` parameter defines the number of pieces each curve is divided into
|
|
57
|
+
* However, for optimization and quality purposes, the actual sampling resolution for each curve depends on its type
|
|
58
|
+
* For example, for a {@link THREE.LineCurve | LineCurve}, the returned number of points is always just 2.
|
|
59
|
+
* @param divisions Number of pieces to divide the curve into. Expects a `Integer`. Default `12`
|
|
60
|
+
*/
|
|
61
|
+
override getPoints(divisions?: number): T[];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Returns a set of divisions `+1` equi-spaced points using {@link .getPointAt | getPointAt(u)}.
|
|
65
|
+
* @param divisions Number of pieces to divide the curve into. Expects a `Integer`. Default `40`
|
|
66
|
+
*/
|
|
67
|
+
override getSpacedPoints(divisions?: number): T[];
|
|
26
68
|
}
|
|
@@ -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
|
}
|