@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.
Files changed (118) hide show
  1. three/README.md +2 -2
  2. three/build/three.min.d.ts +2 -0
  3. three/build/three.module.min.d.ts +2 -0
  4. three/examples/jsm/controls/MapControls.d.ts +21 -0
  5. three/examples/jsm/controls/OrbitControls.d.ts +1 -5
  6. three/examples/jsm/controls/PointerLockControls.d.ts +3 -0
  7. three/examples/jsm/controls/TrackballControls.d.ts +2 -0
  8. three/examples/jsm/helpers/ViewHelper.d.ts +3 -4
  9. three/examples/jsm/libs/tween.module.d.ts +2 -0
  10. three/examples/jsm/loaders/GLTFLoader.d.ts +2 -4
  11. three/examples/jsm/loaders/SVGLoader.d.ts +15 -3
  12. three/examples/jsm/nodes/Nodes.d.ts +131 -226
  13. three/examples/jsm/nodes/{core → code}/CodeNode.d.ts +2 -3
  14. three/examples/jsm/nodes/{core → code}/ExpressionNode.d.ts +2 -2
  15. three/examples/jsm/nodes/{core → code}/FunctionCallNode.d.ts +2 -2
  16. three/examples/jsm/nodes/{core → code}/FunctionNode.d.ts +4 -4
  17. three/examples/jsm/nodes/core/InputNode.d.ts +4 -0
  18. three/examples/jsm/nodes/core/NodeBuilder.d.ts +1 -11
  19. three/examples/jsm/nodes/core/NodeUtils.d.ts +8 -2
  20. three/examples/jsm/nodes/core/{VaryNode.d.ts → VaryingNode.d.ts} +1 -1
  21. three/examples/jsm/nodes/core/constants.d.ts +1 -0
  22. three/examples/jsm/nodes/fog/FogNode.d.ts +1 -1
  23. three/examples/jsm/nodes/geometry/RangeNode.d.ts +2 -1
  24. three/examples/jsm/nodes/lighting/LightUtils.d.ts +4 -0
  25. three/examples/jsm/nodes/lighting/PointLightNode.d.ts +10 -0
  26. three/examples/jsm/nodes/lighting/SpotLightNode.d.ts +15 -0
  27. three/examples/jsm/nodes/materials/LineBasicNodeMaterial.d.ts +0 -7
  28. three/examples/jsm/nodes/materials/MeshBasicNodeMaterial.d.ts +0 -9
  29. three/examples/jsm/nodes/materials/MeshStandardNodeMaterial.d.ts +0 -9
  30. three/examples/jsm/nodes/materials/NodeMaterial.d.ts +17 -1
  31. three/examples/jsm/nodes/math/MathNode.d.ts +2 -2
  32. three/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.d.ts +2 -2
  33. three/examples/jsm/nodes/shadernode/ShaderNodeElements.d.ts +0 -2
  34. three/examples/jsm/objects/{GroundProjectedEnv.d.ts → GroundProjectedSkybox.d.ts} +1 -1
  35. three/examples/jsm/postprocessing/Pass.d.ts +2 -0
  36. three/examples/jsm/renderers/CSS2DRenderer.d.ts +2 -1
  37. three/examples/jsm/renderers/CSS3DRenderer.d.ts +2 -2
  38. three/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.d.ts +1 -21
  39. three/examples/jsm/utils/BufferGeometryUtils.d.ts +12 -2
  40. three/examples/jsm/utils/SkeletonUtils.d.ts +3 -19
  41. three/index.d.ts +1 -1
  42. three/package.json +3 -2
  43. three/src/Three.d.ts +1 -0
  44. three/src/constants.d.ts +3 -23
  45. three/src/core/BufferGeometry.d.ts +60 -33
  46. three/src/core/Raycaster.d.ts +2 -1
  47. three/src/extras/DataUtils.d.ts +13 -0
  48. three/src/extras/Earcut.d.ts +12 -0
  49. three/src/extras/ImageUtils.d.ts +20 -20
  50. three/src/extras/PMREMGenerator.d.ts +66 -0
  51. three/src/extras/ShapeUtils.d.ts +19 -1
  52. three/src/extras/core/Curve.d.ts +86 -31
  53. three/src/extras/core/CurvePath.d.ts +46 -4
  54. three/src/extras/core/Interpolations.d.ts +36 -0
  55. three/src/extras/core/Path.d.ts +122 -15
  56. three/src/extras/core/Shape.d.ts +56 -6
  57. three/src/extras/core/ShapePath.d.ts +73 -8
  58. three/src/extras/curves/ArcCurve.d.ts +35 -3
  59. three/src/extras/curves/CatmullRomCurve3.d.ts +62 -15
  60. three/src/extras/curves/CubicBezierCurve.d.ts +48 -7
  61. three/src/extras/curves/CubicBezierCurve3.d.ts +48 -7
  62. three/src/extras/curves/EllipseCurve.d.ts +73 -18
  63. three/src/extras/curves/LineCurve.d.ts +26 -5
  64. three/src/extras/curves/LineCurve3.d.ts +26 -5
  65. three/src/extras/curves/QuadraticBezierCurve.d.ts +44 -6
  66. three/src/extras/curves/QuadraticBezierCurve3.d.ts +44 -6
  67. three/src/extras/curves/SplineCurve.d.ts +39 -3
  68. three/src/helpers/ArrowHelper.d.ts +47 -16
  69. three/src/helpers/AxesHelper.d.ts +35 -3
  70. three/src/helpers/Box3Helper.d.ts +28 -4
  71. three/src/helpers/BoxHelper.d.ts +44 -4
  72. three/src/helpers/CameraHelper.d.ts +38 -19
  73. three/src/helpers/DirectionalLightHelper.d.ts +57 -10
  74. three/src/helpers/GridHelper.d.ts +32 -6
  75. three/src/helpers/HemisphereLightHelper.d.ts +56 -3
  76. three/src/helpers/PlaneHelper.d.ts +31 -8
  77. three/src/helpers/PointLightHelper.d.ts +54 -6
  78. three/src/helpers/PolarGridHelper.d.ts +35 -8
  79. three/src/helpers/SkeletonHelper.d.ts +56 -8
  80. three/src/helpers/SpotLightHelper.d.ts +59 -4
  81. three/src/lights/AmbientLight.d.ts +23 -10
  82. three/src/lights/AmbientLightProbe.d.ts +18 -0
  83. three/src/lights/DirectionalLight.d.ts +75 -20
  84. three/src/lights/DirectionalLightShadow.d.ts +68 -2
  85. three/src/lights/HemisphereLight.d.ts +45 -12
  86. three/src/lights/HemisphereLightProbe.d.ts +19 -0
  87. three/src/lights/Light.d.ts +40 -43
  88. three/src/lights/LightProbe.d.ts +32 -5
  89. three/src/lights/LightShadow.d.ts +100 -18
  90. three/src/lights/PointLight.d.ts +57 -12
  91. three/src/lights/PointLightShadow.d.ts +18 -2
  92. three/src/lights/RectAreaLight.d.ts +60 -8
  93. three/src/lights/SpotLight.d.ts +105 -20
  94. three/src/lights/SpotLightShadow.d.ts +63 -3
  95. three/src/materials/LineBasicMaterial.d.ts +7 -1
  96. three/src/materials/MeshDistanceMaterial.d.ts +0 -15
  97. three/src/materials/ShaderMaterial.d.ts +1 -1
  98. three/src/math/Color.d.ts +23 -2
  99. three/src/math/Quaternion.d.ts +6 -0
  100. three/src/math/Triangle.d.ts +40 -0
  101. three/src/math/Vector2.d.ts +5 -0
  102. three/src/math/Vector3.d.ts +10 -3
  103. three/src/objects/InstancedMesh.d.ts +22 -30
  104. three/src/objects/LineSegments.d.ts +2 -0
  105. three/src/objects/Points.d.ts +7 -6
  106. three/src/objects/Skeleton.d.ts +5 -1
  107. three/src/objects/SkinnedMesh.d.ts +37 -25
  108. three/src/renderers/WebGLRenderTarget.d.ts +3 -0
  109. three/src/renderers/WebGLRenderer.d.ts +25 -1
  110. three/src/renderers/shaders/ShaderChunk.d.ts +58 -37
  111. three/src/renderers/shaders/UniformsLib.d.ts +88 -57
  112. three/src/textures/CanvasTexture.d.ts +0 -1
  113. three/src/textures/CompressedTexture.d.ts +3 -2
  114. three/src/textures/CubeTexture.d.ts +3 -4
  115. three/src/textures/DataTexture.d.ts +3 -3
  116. three/src/textures/Texture.d.ts +37 -24
  117. three/examples/jsm/nodes/functions/light/getDistanceAttenuation.d.ts +0 -5
  118. three/examples/jsm/nodes/lighting/PunctualLightNode.d.ts +0 -12
@@ -1,7 +1,13 @@
1
1
  import { NodeValueOption } from './constants';
2
2
  import Node from './Node';
3
3
 
4
- export function getNodesKeys(object: Node): string[];
4
+ export interface NodeChild {
5
+ property: string;
6
+ index?: number | string;
7
+ childNode: Node;
8
+ }
9
+
10
+ export function getCacheKey(object: Node): string;
11
+ export function getNodeChildren(object: Node): Generator<NodeChild, void>;
5
12
  export function getValueType(value: NodeValueOption): string | null;
6
13
  export function getValueFromType(type: string, ...params: number[]): NodeValueOption | null;
7
- export function getCacheKey(object: Node): string;
@@ -1,6 +1,6 @@
1
1
  import Node from './Node';
2
2
 
3
- export default class VaryNode extends Node {
3
+ export default class VaryingNode extends Node {
4
4
  node: Node;
5
5
  name: string | null;
6
6
 
@@ -9,6 +9,7 @@ export const NodeShaderStage: {
9
9
  export const NodeUpdateType: {
10
10
  NONE: 'none';
11
11
  FRAME: 'frame';
12
+ RENDER: 'render';
12
13
  OBJECT: 'object';
13
14
  };
14
15
 
@@ -6,5 +6,5 @@ export default class FogNode extends Node {
6
6
  factorNode: Node;
7
7
 
8
8
  constructor(colorNode: Node, factorNode: Node);
9
- mix(outputNode: Node): Node;
9
+ mixAssign(outputNode: Node): Node;
10
10
  }
@@ -1,5 +1,6 @@
1
1
  import { Color, Vector2, Vector3, Vector4 } from '../../../../src/Three';
2
2
  import Node from '../core/Node';
3
+ import NodeBuilder from '../core/NodeBuilder';
3
4
 
4
5
  export type RangeModeBound = number | Color | Vector2 | Vector3 | Vector4;
5
6
 
@@ -8,5 +9,5 @@ export default class RangeNode extends Node {
8
9
  max: RangeModeBound;
9
10
 
10
11
  constructor(min: RangeModeBound, max: RangeModeBound);
11
- getVectorLength(): number;
12
+ getVectorLength(builder: NodeBuilder): number;
12
13
  }
@@ -0,0 +1,4 @@
1
+ import { ShaderNode } from '../shadernode/ShaderNode';
2
+ import Node from '../core/Node';
3
+
4
+ export const getDistanceAttenuation: ShaderNode<{ lightDistance: Node; cutoffDistance: Node; decayExponent: Node }>;
@@ -0,0 +1,10 @@
1
+ import AnalyticLightNode from './AnalyticLightNode';
2
+ import Node from '../core/Node';
3
+ import { PointLight } from '../../../../src/Three';
4
+
5
+ export default class PointLightNode extends AnalyticLightNode<PointLight> {
6
+ cutoffDistanceNode: Node;
7
+ decayExponentNode: Node;
8
+
9
+ constructor(light?: PointLight | null);
10
+ }
@@ -0,0 +1,15 @@
1
+ import AnalyticLightNode from './AnalyticLightNode';
2
+ import Node from '../core/Node';
3
+ import { SpotLight } from '../../../../src/Three';
4
+
5
+ export default class PointLightNode extends AnalyticLightNode<SpotLight> {
6
+ directionNode: Node;
7
+
8
+ coneCosNode: Node;
9
+ penumbraCosNode: Node;
10
+
11
+ cutoffDistanceNode: Node;
12
+ decayExponentNode: Node;
13
+
14
+ constructor(light?: SpotLight | null);
15
+ }
@@ -1,16 +1,9 @@
1
1
  import NodeMaterial from './NodeMaterial';
2
2
  import { ShaderMaterialParameters } from '../../../../src/Three';
3
- import { Node } from '../Nodes';
4
3
 
5
4
  export default class LineBasicNodeMaterial extends NodeMaterial {
6
5
  isLineBasicNodeMaterial: true;
7
6
 
8
- colorNode: Node | null;
9
- opacityNode: Node | null;
10
- alphaTestNode: Node | null;
11
- lightNode: Node | null;
12
- positionNode: Node | null;
13
-
14
7
  constructor(parameters?: ShaderMaterialParameters);
15
8
  copy(source: LineBasicNodeMaterial): this;
16
9
  }
@@ -1,19 +1,10 @@
1
1
  import NodeMaterial from './NodeMaterial';
2
- import Node from '../core/Node';
3
2
  import { ShaderMaterialParameters } from '../../../../src/Three';
4
3
 
5
4
  export default class MeshBasicNodeMaterial extends NodeMaterial {
6
5
  isMeshBasicNodeMaterial: true;
7
6
  lights: true;
8
7
 
9
- colorNode: Node | null;
10
- opacityNode: Node | null;
11
-
12
- alphaTestNode: Node | null;
13
- lightNode: Node | null;
14
-
15
- positionNode: Node | null;
16
-
17
8
  constructor(paramters?: ShaderMaterialParameters);
18
9
  copy(source: MeshBasicNodeMaterial): this;
19
10
  }
@@ -5,10 +5,6 @@ import NodeMaterial from './NodeMaterial';
5
5
  export default class MeshStandardNodeMaterial extends NodeMaterial {
6
6
  isMeshStandardNodeMaterial: true;
7
7
 
8
- colorNode: Node | null;
9
- opacityNode: Node | null;
10
- alphaTestNode: Node | null;
11
- normalNode: Node | null;
12
8
  emissiveNode: Node | null;
13
9
 
14
10
  metalnessNode: Node | null;
@@ -17,11 +13,6 @@ export default class MeshStandardNodeMaterial extends NodeMaterial {
17
13
  clearcoatNode: Node | null;
18
14
  clearcoatRoughnessNode: Node | null;
19
15
 
20
- envNode: Node | null;
21
-
22
- lightsNode: Node | null;
23
- positionNode: Node | null;
24
-
25
16
  constructor(paramters?: ShaderMaterialParameters);
26
17
  copy(source: MeshStandardNodeMaterial): this;
27
18
  }
@@ -5,8 +5,24 @@ import { LightingModelNode } from '../lighting/LightingContextNode';
5
5
 
6
6
  export default class NodeMaterial extends ShaderMaterial {
7
7
  isNodeMaterial: true;
8
- lights: true;
8
+
9
9
  type: string;
10
+
11
+ lights: true;
12
+ normals: true;
13
+
14
+ lightsNode: Node | null;
15
+ envNode: Node | null;
16
+
17
+ colorNode: Node | null;
18
+ normalNode: Node | null;
19
+ opacityNode: Node | null;
20
+ backdropNode: Node | null;
21
+ backdropAlphaNode: Node | null;
22
+ alphaTestNode: Node | null;
23
+
24
+ positionNode: Node | null;
25
+
10
26
  constructor();
11
27
 
12
28
  build(builder: NodeBuilder): void;
@@ -24,7 +24,7 @@ export type MathNodeMethod1 =
24
24
  | typeof MathNode.SIGN
25
25
  | typeof MathNode.LENGTH
26
26
  | typeof MathNode.NEGATE
27
- | typeof MathNode.INVERT
27
+ | typeof MathNode.ONE_MINUS
28
28
  | typeof MathNode.DFDX
29
29
  | typeof MathNode.DFDY
30
30
  | typeof MathNode.ROUND;
@@ -76,7 +76,7 @@ export default class MathNode extends TempNode {
76
76
  static SIGN: 'sign';
77
77
  static LENGTH: 'length';
78
78
  static NEGATE: 'negate';
79
- static INVERT: 'invert';
79
+ static ONE_MINUS: 'oneMinus';
80
80
  static DFDX: 'dFdx';
81
81
  static DFDY: 'dFdy';
82
82
  static ROUND: 'round';
@@ -50,7 +50,7 @@ import {
50
50
  UserDataNode,
51
51
  UVNode,
52
52
  VarNode,
53
- VaryNode,
53
+ VaryingNode,
54
54
  } from '../Nodes';
55
55
  import StorageBufferNode from '../accessors/StorageBufferNode';
56
56
  import NodeCache from '../core/NodeCache';
@@ -130,7 +130,7 @@ export function fn<P extends FunctionNodeArguments>(
130
130
  export const instanceIndex: Swizzable<InstanceIndexNode>;
131
131
  export function label(node: NodeRepresentation, name?: string): Swizzable<VarNode>;
132
132
  export function temp(node: NodeRepresentation, name?: string): Swizzable<VarNode>;
133
- export function vary(node: NodeRepresentation, name?: string): Swizzable<VaryNode>;
133
+ export function vary(node: NodeRepresentation, name?: string): Swizzable<VaryingNode>;
134
134
 
135
135
  // accesors
136
136
 
@@ -56,8 +56,6 @@ export { default as DFGApprox } from '../functions/BSDF/DFGApprox';
56
56
  export { default as F_Schlick } from '../functions/BSDF/F_Schlick';
57
57
  export { default as V_GGX_SmithCorrelated } from '../functions/BSDF/V_GGX_SmithCorrelated';
58
58
 
59
- export { default as getDistanceAttenuation } from '../functions/light/getDistanceAttenuation';
60
-
61
59
  export { default as getGeometryRoughness } from '../functions/material/getGeometryRoughness';
62
60
  export { default as getRoughness } from '../functions/material/getRoughness';
63
61
 
@@ -1,6 +1,6 @@
1
1
  import { Mesh, IcosahedronGeometry, ShaderMaterial, Texture } from '../../../src/Three';
2
2
 
3
- export class GroundProjectedEnv extends Mesh<IcosahedronGeometry, ShaderMaterial> {
3
+ export class GroundProjectedSkybox extends Mesh<IcosahedronGeometry, ShaderMaterial> {
4
4
  constructor(texture: Texture, options?: { height?: number; radius?: number });
5
5
 
6
6
  set radius(radius: number);
@@ -2,6 +2,8 @@ import { Material, WebGLRenderer, WebGLRenderTarget } from '../../../src/Three';
2
2
 
3
3
  export class Pass {
4
4
  constructor();
5
+
6
+ isPass: boolean;
5
7
  enabled: boolean;
6
8
  needsSwap: boolean;
7
9
  clear: boolean;
@@ -1,8 +1,9 @@
1
- import { Object3D, Scene, Camera } from '../../../src/Three';
1
+ import { Object3D, Scene, Camera, Vector2 } from '../../../src/Three';
2
2
 
3
3
  export class CSS2DObject extends Object3D {
4
4
  constructor(element: HTMLElement);
5
5
  element: HTMLElement;
6
+ center: Vector2;
6
7
 
7
8
  onBeforeRender: (renderer: unknown, scene: Scene, camera: Camera) => void;
8
9
  onAfterRender: (renderer: unknown, scene: Scene, camera: Camera) => void;
@@ -12,9 +12,9 @@ export class CSS3DSprite extends CSS3DObject {
12
12
  constructor(element: HTMLElement);
13
13
  }
14
14
 
15
- export type CSS3DParameters = {
15
+ export interface CSS3DParameters {
16
16
  element?: HTMLElement;
17
- };
17
+ }
18
18
 
19
19
  export class CSS3DRenderer {
20
20
  constructor(parameters?: CSS3DParameters);
@@ -12,27 +12,7 @@ export class WebGLNodeBuilder extends NodeBuilder {
12
12
  );
13
13
 
14
14
  addSlot(shaderStage: NodeShaderStageOption, slotNode: SlotNode): Node;
15
- addFlowCode(code: string): string;
16
-
17
- getTexture(textureProperty: string, uvSnippet: string): string;
18
- getTextureBias(textureProperty: string, uvSnippet: string, biasSnippet: string): string;
19
-
20
- getTextureLevel(
21
- textureProperty: string,
22
- uvSnippet: string,
23
- biasSnippet: string,
24
- shaderStage?: NodeShaderStageOption,
25
- ): string;
26
- getCubeTexture(texturePropert: string, uvSnippet: string, shaderStage?: NodeShaderStageOption): string;
27
-
28
- getCubeTextureLevel(
29
- textureProperty: string,
30
- uvSnippet: string,
31
- biasSnippet: string,
32
- shaderStage?: NodeShaderStageOption,
33
- ): string;
34
-
35
- getCubeTextureBias(textureProperty: string, uvSnippet: string, biasSnippet: string): string;
15
+
36
16
  getUniforms(shaderStage: string): string;
37
17
 
38
18
  getAttributes(shaderStage: string): string;
@@ -11,8 +11,8 @@ import {
11
11
  } from '../../../src/Three';
12
12
 
13
13
  export function deepCloneAttribute(attribute: BufferAttribute): BufferAttribute;
14
- export function mergeBufferGeometries(geometries: BufferGeometry[], useGroups?: boolean): BufferGeometry;
15
- export function mergeBufferAttributes(attributes: BufferAttribute[]): BufferAttribute;
14
+ export function mergeGeometries(geometries: BufferGeometry[], useGroups?: boolean): BufferGeometry;
15
+ export function mergeAttributes(attributes: BufferAttribute[]): BufferAttribute;
16
16
  export function interleaveAttributes(attributes: BufferAttribute[]): InterleavedBufferAttribute;
17
17
  export function estimateBytesUsed(geometry: BufferGeometry): number;
18
18
  export function mergeVertices(geometry: BufferGeometry, tolerance?: number): BufferGeometry;
@@ -34,3 +34,13 @@ export function deinterleaveGeometry(geometry: BufferGeometry): void;
34
34
  * @param creaseAngle The crease angle.
35
35
  */
36
36
  export function toCreasedNormals(geometry: BufferGeometry, creaseAngle?: number): BufferGeometry;
37
+
38
+ /**
39
+ * @deprecated Use mergeGeometries instead.
40
+ */
41
+ export function mergeBufferGeometries(geometries: BufferGeometry[], useGroups?: boolean): BufferGeometry;
42
+
43
+ /**
44
+ * @deprecated Use mergeAttributes instead.
45
+ */
46
+ export function mergeBufferAttributes(attributes: BufferAttribute[]): BufferAttribute;
@@ -1,4 +1,6 @@
1
- import { AnimationClip, Bone, Matrix4, Object3D, Skeleton, SkeletonHelper } from '../../../src/Three';
1
+ import { AnimationClip, Object3D, Skeleton } from '../../../src/Three';
2
+
3
+ export function clone(source: Object3D): Object3D;
2
4
 
3
5
  export function retarget(target: Object3D | Skeleton, source: Object3D | Skeleton, options: {}): void;
4
6
 
@@ -8,21 +10,3 @@ export function retargetClip(
8
10
  clip: AnimationClip,
9
11
  options: {},
10
12
  ): AnimationClip;
11
-
12
- export function getHelperFromSkeleton(skeleton: Skeleton): SkeletonHelper;
13
-
14
- export function getSkeletonOffsets(target: Object3D | Skeleton, source: Object3D | Skeleton, options: {}): Matrix4[];
15
-
16
- export function renameBones(skeleton: Skeleton, names: {}): any;
17
-
18
- export function getBones(skeleton: Skeleton | Bone[]): Bone[];
19
-
20
- export function getBoneByName(name: string, skeleton: Skeleton): Bone;
21
-
22
- export function getNearestBone(bone: Bone, names: {}): Bone;
23
-
24
- export function findBoneTrackData(name: string, tracks: any[]): {};
25
-
26
- export function getEqualsBonesNames(skeleton: Skeleton, targetSkeleton: Skeleton): string[];
27
-
28
- export function clone(source: Object3D): Object3D;
three/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for three 0.150
1
+ // Type definitions for three 0.152
2
2
  // Project: https://threejs.org/
3
3
  // Definitions by: Josh Ellis <https://github.com/joshuaellis>
4
4
  // Nathan Bierema <https://github.com/Methuselah96>
three/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/three",
3
- "version": "0.150.2",
3
+ "version": "0.152.0",
4
4
  "description": "TypeScript definitions for three",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/three",
6
6
  "license": "MIT",
@@ -25,12 +25,13 @@
25
25
  },
26
26
  "scripts": {},
27
27
  "dependencies": {
28
+ "@tweenjs/tween.js": "~18.6.4",
28
29
  "@types/stats.js": "*",
29
30
  "@types/webxr": "*",
30
31
  "fflate": "~0.6.9",
31
32
  "lil-gui": "~0.17.0"
32
33
  },
33
- "typesPublisherContentHash": "c2191d62aed43403a160d31f1eda315dcee3ba0c3154b0cd4cd4fed4226f8434",
34
+ "typesPublisherContentHash": "c206b6e9fcb60fc53d60b9c172bf339b663fa61d521aa358641f9b16d55913ed",
34
35
  "typeScriptVersion": "4.4",
35
36
  "exports": {
36
37
  ".": {
three/src/Three.d.ts CHANGED
@@ -65,6 +65,7 @@ export * from './extras/core/Path';
65
65
  export * from './extras/core/ShapePath';
66
66
  export * from './extras/core/CurvePath';
67
67
  export * from './extras/core/Curve';
68
+ export * from './extras/core/Interpolations';
68
69
  export * as DataUtils from './extras/DataUtils';
69
70
  export * from './extras/ImageUtils';
70
71
  export * from './extras/ShapeUtils';
three/src/constants.d.ts CHANGED
@@ -681,11 +681,14 @@ export type TrianglesDrawModes = typeof TrianglesDrawMode | typeof TriangleStrip
681
681
  ///////////////////////////////////////////////////////////////////////////////
682
682
  // Texture Encodings
683
683
 
684
+ /** @deprecated Use {@link LinearSRGBColorSpace} or {@link NoColorSpace} in three.js r152+. */
684
685
  export const LinearEncoding: 3000;
686
+ /** @deprecated Use {@link SRGBColorSpace} in three.js r152+. */
685
687
  export const sRGBEncoding: 3001;
686
688
  /**
687
689
  * Texture Encodings.
688
690
  * @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
691
+ * @deprecated Use {@link ColorSpace} in three.js r152+.
689
692
  */
690
693
  export type TextureEncoding = typeof LinearEncoding | typeof sRGBEncoding;
691
694
 
@@ -901,26 +904,3 @@ export type PixelFormatGPU =
901
904
  | 'DEPTH_COMPONENT32F'
902
905
  | 'DEPTH24_STENCIL8'
903
906
  | 'DEPTH32F_STENCIL8';
904
-
905
- ///////////////////////////////////////////////////////////////////////////////
906
-
907
- export type BuiltinShaderAttributeName =
908
- | 'position'
909
- | 'normal'
910
- | 'uv'
911
- | 'color'
912
- | 'skinIndex'
913
- | 'skinWeight'
914
- | 'instanceMatrix'
915
- | 'morphTarget0'
916
- | 'morphTarget1'
917
- | 'morphTarget2'
918
- | 'morphTarget3'
919
- | 'morphTarget4'
920
- | 'morphTarget5'
921
- | 'morphTarget6'
922
- | 'morphTarget7'
923
- | 'morphNormal0'
924
- | 'morphNormal1'
925
- | 'morphNormal2'
926
- | 'morphNormal3';
@@ -1,15 +1,19 @@
1
1
  import { BufferAttribute } from './BufferAttribute';
2
2
  import { InterleavedBufferAttribute } from './InterleavedBufferAttribute';
3
- import { GLBufferAttribute } from './GLBufferAttribute';
4
- import { Box3 } from './../math/Box3';
5
- import { Sphere } from './../math/Sphere';
6
- import { Matrix4 } from './../math/Matrix4';
7
- import { Quaternion } from './../math/Quaternion';
8
- import { Vector2 } from './../math/Vector2';
9
- import { Vector3 } from './../math/Vector3';
3
+ import { Box3 } from '../math/Box3';
4
+ import { Sphere } from '../math/Sphere';
5
+ import { Matrix4 } from '../math/Matrix4';
6
+ import { Quaternion } from '../math/Quaternion';
7
+ import { Vector2 } from '../math/Vector2';
8
+ import { Vector3 } from '../math/Vector3';
10
9
  import { EventDispatcher } from './EventDispatcher';
11
- import { BuiltinShaderAttributeName } from '../constants';
12
- import * as BufferGeometryUtils from '../../examples/jsm/utils/BufferGeometryUtils';
10
+ import { GLBufferAttribute } from './GLBufferAttribute';
11
+
12
+ export type NormalBufferAttributes = Record<string, BufferAttribute | InterleavedBufferAttribute>;
13
+ export type NormalOrGLBufferAttributes = Record<
14
+ string,
15
+ BufferAttribute | InterleavedBufferAttribute | GLBufferAttribute
16
+ >;
13
17
 
14
18
  /**
15
19
  * A representation of mesh, line, or point geometry
@@ -19,20 +23,46 @@ import * as BufferGeometryUtils from '../../examples/jsm/utils/BufferGeometryUti
19
23
  * @example
20
24
  * ```typescript
21
25
  * const geometry = new THREE.BufferGeometry();
26
+ *
22
27
  * // create a simple square shape. We duplicate the top left and bottom right
23
28
  * // vertices because each vertex needs to appear once per triangle.
24
- * const vertices = new Float32Array([
25
- * -1.0, -1.0, 1.0,
26
- * 1.0, -1.0, 1.0,
27
- * 1.0, 1.0, 1.0,
29
+ * const vertices = new Float32Array( [
30
+ * -1.0, -1.0, 1.0, // v0
31
+ * 1.0, -1.0, 1.0, // v1
32
+ * 1.0, 1.0, 1.0, // v2
33
+ *
34
+ * 1.0, 1.0, 1.0, // v3
35
+ * -1.0, 1.0, 1.0, // v4
36
+ * -1.0, -1.0, 1.0 // v5
37
+ * ] );
28
38
  *
29
- * 1.0, 1.0, 1.0,
30
- * -1.0, 1.0, 1.0,
31
- * -1.0, -1.0, 1.0]);
32
39
  * // itemSize = 3 because there are 3 values (components) per vertex
33
- * geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
34
- * const material = new THREE.MeshBasicMaterial({ color: 0xff0000 });
35
- * const mesh = new THREE.Mesh(geometry, material);
40
+ * geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
41
+ * const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
42
+ * const mesh = new THREE.Mesh( geometry, material );
43
+ * ```
44
+ * @example
45
+ * ```typescript
46
+ * const geometry = new THREE.BufferGeometry();
47
+ *
48
+ * const vertices = new Float32Array( [
49
+ * -1.0, -1.0, 1.0, // v0
50
+ * 1.0, -1.0, 1.0, // v1
51
+ * 1.0, 1.0, 1.0, // v2
52
+ * -1.0, 1.0, 1.0, // v3
53
+ * ] );
54
+ * geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
55
+ *
56
+ * const indices = [
57
+ * 0, 1, 2,
58
+ * 2, 3, 0,
59
+ * ];
60
+ *
61
+ * geometry.setIndex( indices );
62
+ * geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
63
+ *
64
+ * const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
65
+ * const mesh = new THREE.Mesh( geometry, material );
36
66
  * ```
37
67
  * @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry | Mesh with non-indexed faces}
38
68
  * @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry_indexed | Mesh with indexed faces}
@@ -43,7 +73,9 @@ import * as BufferGeometryUtils from '../../examples/jsm/utils/BufferGeometryUti
43
73
  * @see {@link https://threejs.org/docs/index.html#api/en/core/BufferGeometry | Official Documentation}
44
74
  * @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/BufferGeometry.js | Source}
45
75
  */
46
- export class BufferGeometry extends EventDispatcher {
76
+ export class BufferGeometry<
77
+ Attributes extends NormalOrGLBufferAttributes = NormalBufferAttributes,
78
+ > extends EventDispatcher {
47
79
  /**
48
80
  * This creates a new {@link THREE.BufferGeometry | BufferGeometry} object.
49
81
  */
@@ -87,9 +119,7 @@ export class BufferGeometry extends EventDispatcher {
87
119
  * use {@link setAttribute | .setAttribute} and {@link getAttribute | .getAttribute} to access attributes of this geometry.
88
120
  * @defaultValue `{}`
89
121
  */
90
- attributes: {
91
- [name: string]: BufferAttribute | InterleavedBufferAttribute | GLBufferAttribute; // TODO Replace for 'Record<>'
92
- };
122
+ attributes: Attributes;
93
123
 
94
124
  /**
95
125
  * Hashmap of {@link THREE.BufferAttribute | BufferAttributes} holding details of the geometry's morph targets.
@@ -185,30 +215,25 @@ export class BufferGeometry extends EventDispatcher {
185
215
  * @param name
186
216
  * @param attribute
187
217
  */
188
- setAttribute(
189
- name: BuiltinShaderAttributeName | (string & {}),
190
- attribute: BufferAttribute | InterleavedBufferAttribute | GLBufferAttribute,
191
- ): this;
218
+ setAttribute<K extends keyof Attributes>(name: K, attribute: Attributes[K]): this;
192
219
 
193
220
  /**
194
221
  * Returns the {@link attributes | attribute} with the specified name.
195
222
  * @param name
196
223
  */
197
- getAttribute(
198
- name: BuiltinShaderAttributeName | (string & {}),
199
- ): BufferAttribute | InterleavedBufferAttribute | GLBufferAttribute;
224
+ getAttribute<K extends keyof Attributes>(name: K): Attributes[K];
200
225
 
201
226
  /**
202
227
  * Deletes the {@link attributes | attribute} with the specified name.
203
228
  * @param name
204
229
  */
205
- deleteAttribute(name: BuiltinShaderAttributeName | (string & {})): BufferGeometry;
230
+ deleteAttribute(name: keyof Attributes): this;
206
231
 
207
232
  /**
208
233
  * Returns true if the {@link attributes | attribute} with the specified name exists.
209
234
  * @param name
210
235
  */
211
- hasAttribute(name: BuiltinShaderAttributeName | (string & {})): boolean;
236
+ hasAttribute(name: keyof Attributes): boolean;
212
237
 
213
238
  /**
214
239
  * Adds a group to this geometry
@@ -329,7 +354,9 @@ export class BufferGeometry extends EventDispatcher {
329
354
  computeTangents(): void;
330
355
 
331
356
  /**
332
- * Computes vertex normals by averaging face normals.
357
+ * Computes vertex normals for the given vertex data. For indexed geometries, the method sets each vertex normal to
358
+ * be the average of the face normals of the faces that share that vertex. For non-indexed geometries, vertices are
359
+ * not shared, and the method sets each vertex normal to be the same as the face normal.
333
360
  */
334
361
  computeVertexNormals(): void;
335
362
 
@@ -27,7 +27,8 @@ export interface Intersection<TIntersected extends Object3D = Object3D> {
27
27
  /** The intersected object */
28
28
  object: TIntersected;
29
29
  uv?: Vector2 | undefined;
30
- uv2?: Vector2 | undefined;
30
+ uv1?: Vector2 | undefined;
31
+ normal?: Vector3;
31
32
  /** The index number of the instance where the ray intersects the {@link THREE.InstancedMesh | InstancedMesh } */
32
33
  instanceId?: number | undefined;
33
34
  }
@@ -1,2 +1,15 @@
1
+ /**
2
+ * Returns a half precision floating point value from the given single precision floating point value.
3
+ * @param val A single precision floating point value.
4
+ * @see {@link https://threejs.org/docs/index.html#api/en/extras/DataUtils | Official Documentation}
5
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/DataUtils.js | Source}
6
+ */
1
7
  export function toHalfFloat(val: number): number;
8
+
9
+ /**
10
+ * Returns a single precision floating point value from the given half precision floating point value.
11
+ * @param val A half precision floating point value.
12
+ * @see {@link https://threejs.org/docs/index.html#api/en/extras/DataUtils | Official Documentation}
13
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/DataUtils.js | Source}
14
+ */
2
15
  export function fromHalfFloat(val: number): number;
@@ -1,3 +1,15 @@
1
+ /**
2
+ * An implementation of the {@link Earcut} polygon triangulation algorithm
3
+ * @remarks
4
+ * The code is a port of {@link https://github.com/mapbox/earcut | mapbox/earcut}.
5
+ * @see {@link https://threejs.org/docs/index.html#api/en/extras/Earcut | Official Documentation}
6
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/Earcut.js | Source}
7
+ */
1
8
  export const Earcut: {
9
+ /**
10
+ * Triangulates the given shape definition by returning an array of triangles
11
+ * @remarks
12
+ * A triangle is defined by three consecutive integers representing vertex indices.
13
+ */
2
14
  triangulate(data: number[], holeIndices?: number[], dim?: number): number[];
3
15
  };