@types/three 0.150.2 → 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.
Files changed (96) hide show
  1. three/README.md +1 -1
  2. three/examples/jsm/controls/MapControls.d.ts +21 -0
  3. three/examples/jsm/controls/OrbitControls.d.ts +1 -5
  4. three/examples/jsm/controls/PointerLockControls.d.ts +3 -0
  5. three/examples/jsm/controls/TrackballControls.d.ts +2 -0
  6. three/examples/jsm/helpers/ViewHelper.d.ts +3 -4
  7. three/examples/jsm/loaders/GLTFLoader.d.ts +2 -4
  8. three/examples/jsm/loaders/SVGLoader.d.ts +15 -3
  9. three/examples/jsm/nodes/Nodes.d.ts +130 -226
  10. three/examples/jsm/nodes/{core → code}/CodeNode.d.ts +2 -3
  11. three/examples/jsm/nodes/{core → code}/ExpressionNode.d.ts +2 -2
  12. three/examples/jsm/nodes/{core → code}/FunctionCallNode.d.ts +2 -2
  13. three/examples/jsm/nodes/{core → code}/FunctionNode.d.ts +4 -4
  14. three/examples/jsm/nodes/core/InputNode.d.ts +4 -0
  15. three/examples/jsm/nodes/core/NodeBuilder.d.ts +1 -3
  16. three/examples/jsm/nodes/core/NodeUtils.d.ts +8 -2
  17. three/examples/jsm/nodes/core/{VaryNode.d.ts → VaryingNode.d.ts} +1 -1
  18. three/examples/jsm/nodes/fog/FogNode.d.ts +1 -1
  19. three/examples/jsm/nodes/geometry/RangeNode.d.ts +2 -1
  20. three/examples/jsm/nodes/lighting/PointLightNode.d.ts +10 -0
  21. three/examples/jsm/nodes/lighting/SpotLightNode.d.ts +15 -0
  22. three/examples/jsm/nodes/math/MathNode.d.ts +2 -2
  23. three/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.d.ts +2 -2
  24. three/examples/jsm/objects/{GroundProjectedEnv.d.ts → GroundProjectedSkybox.d.ts} +1 -1
  25. three/examples/jsm/postprocessing/Pass.d.ts +2 -0
  26. three/examples/jsm/renderers/CSS2DRenderer.d.ts +2 -1
  27. three/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.d.ts +0 -1
  28. three/examples/jsm/utils/BufferGeometryUtils.d.ts +12 -2
  29. three/index.d.ts +1 -1
  30. three/package.json +2 -2
  31. three/src/Three.d.ts +1 -0
  32. three/src/core/Raycaster.d.ts +1 -0
  33. three/src/extras/DataUtils.d.ts +13 -0
  34. three/src/extras/Earcut.d.ts +12 -0
  35. three/src/extras/ImageUtils.d.ts +20 -20
  36. three/src/extras/PMREMGenerator.d.ts +66 -0
  37. three/src/extras/ShapeUtils.d.ts +19 -1
  38. three/src/extras/core/Curve.d.ts +86 -31
  39. three/src/extras/core/CurvePath.d.ts +46 -4
  40. three/src/extras/core/Interpolations.d.ts +36 -0
  41. three/src/extras/core/Path.d.ts +122 -15
  42. three/src/extras/core/Shape.d.ts +56 -6
  43. three/src/extras/core/ShapePath.d.ts +73 -8
  44. three/src/extras/curves/ArcCurve.d.ts +35 -3
  45. three/src/extras/curves/CatmullRomCurve3.d.ts +62 -15
  46. three/src/extras/curves/CubicBezierCurve.d.ts +48 -7
  47. three/src/extras/curves/CubicBezierCurve3.d.ts +48 -7
  48. three/src/extras/curves/EllipseCurve.d.ts +73 -18
  49. three/src/extras/curves/LineCurve.d.ts +26 -5
  50. three/src/extras/curves/LineCurve3.d.ts +26 -5
  51. three/src/extras/curves/QuadraticBezierCurve.d.ts +44 -6
  52. three/src/extras/curves/QuadraticBezierCurve3.d.ts +44 -6
  53. three/src/extras/curves/SplineCurve.d.ts +39 -3
  54. three/src/helpers/ArrowHelper.d.ts +47 -16
  55. three/src/helpers/AxesHelper.d.ts +35 -3
  56. three/src/helpers/Box3Helper.d.ts +28 -4
  57. three/src/helpers/BoxHelper.d.ts +44 -4
  58. three/src/helpers/CameraHelper.d.ts +38 -19
  59. three/src/helpers/DirectionalLightHelper.d.ts +57 -10
  60. three/src/helpers/GridHelper.d.ts +32 -6
  61. three/src/helpers/HemisphereLightHelper.d.ts +56 -3
  62. three/src/helpers/PlaneHelper.d.ts +31 -8
  63. three/src/helpers/PointLightHelper.d.ts +54 -6
  64. three/src/helpers/PolarGridHelper.d.ts +35 -8
  65. three/src/helpers/SkeletonHelper.d.ts +56 -8
  66. three/src/helpers/SpotLightHelper.d.ts +59 -4
  67. three/src/lights/AmbientLight.d.ts +23 -10
  68. three/src/lights/AmbientLightProbe.d.ts +18 -0
  69. three/src/lights/DirectionalLight.d.ts +75 -20
  70. three/src/lights/DirectionalLightShadow.d.ts +68 -2
  71. three/src/lights/HemisphereLight.d.ts +45 -12
  72. three/src/lights/HemisphereLightProbe.d.ts +19 -0
  73. three/src/lights/Light.d.ts +40 -43
  74. three/src/lights/LightProbe.d.ts +32 -5
  75. three/src/lights/LightShadow.d.ts +100 -18
  76. three/src/lights/PointLight.d.ts +57 -12
  77. three/src/lights/PointLightShadow.d.ts +18 -2
  78. three/src/lights/RectAreaLight.d.ts +60 -8
  79. three/src/lights/SpotLight.d.ts +105 -20
  80. three/src/lights/SpotLightShadow.d.ts +63 -3
  81. three/src/materials/LineBasicMaterial.d.ts +7 -1
  82. three/src/materials/MeshDistanceMaterial.d.ts +0 -15
  83. three/src/math/Color.d.ts +23 -2
  84. three/src/math/Quaternion.d.ts +6 -0
  85. three/src/math/Triangle.d.ts +40 -0
  86. three/src/math/Vector2.d.ts +5 -0
  87. three/src/math/Vector3.d.ts +10 -3
  88. three/src/objects/InstancedMesh.d.ts +22 -30
  89. three/src/objects/LineSegments.d.ts +2 -0
  90. three/src/objects/Skeleton.d.ts +5 -1
  91. three/src/objects/SkinnedMesh.d.ts +37 -25
  92. three/src/renderers/WebGLRenderer.d.ts +16 -0
  93. three/src/renderers/shaders/ShaderChunk.d.ts +58 -37
  94. three/src/renderers/shaders/UniformsLib.d.ts +88 -57
  95. three/src/textures/Texture.d.ts +5 -22
  96. three/examples/jsm/nodes/lighting/PunctualLightNode.d.ts +0 -12
@@ -1,12 +1,72 @@
1
1
  import { PerspectiveCamera } from './../cameras/PerspectiveCamera';
2
2
  import { LightShadow } from './LightShadow';
3
3
 
4
- export class SpotLightShadow extends LightShadow {
5
- camera: PerspectiveCamera;
4
+ /**
5
+ * This is used internally by {@link SpotLight | SpotLights} for calculating shadows.
6
+ * @example
7
+ * ```typescript
8
+ * //Create a WebGLRenderer and turn on shadows in the renderer
9
+ * const renderer = new THREE.WebGLRenderer();
10
+ * renderer.shadowMap.enabled = true;
11
+ * renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap
12
+ * //Create a SpotLight and turn on shadows for the light
13
+ * const light = new THREE.SpotLight(0xffffff);
14
+ * light.castShadow = true; // default false
15
+ * scene.add(light);
16
+ * //Set up shadow properties for the light
17
+ * light.shadow.mapSize.width = 512; // default
18
+ * light.shadow.mapSize.height = 512; // default
19
+ * light.shadow.camera.near = 0.5; // default
20
+ * light.shadow.camera.far = 500; // default
21
+ * light.shadow.focus = 1; // default
22
+ * //Create a sphere that cast shadows (but does not receive them)
23
+ * const sphereGeometry = new THREE.SphereGeometry(5, 32, 32);
24
+ * const sphereMaterial = new THREE.MeshStandardMaterial({
25
+ * color: 0xff0000
26
+ * });
27
+ * const sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);
28
+ * sphere.castShadow = true; //default is false
29
+ * sphere.receiveShadow = false; //default
30
+ * scene.add(sphere);
31
+ * //Create a plane that receives shadows (but does not cast them)
32
+ * const planeGeometry = new THREE.PlaneGeometry(20, 20, 32, 32);
33
+ * const planeMaterial = new THREE.MeshStandardMaterial({
34
+ * color: 0x00ff00
35
+ * })
36
+ * const plane = new THREE.Mesh(planeGeometry, planeMaterial);
37
+ * plane.receiveShadow = true;
38
+ * scene.add(plane);
39
+ * //Create a helper for the shadow camera (optional)
40
+ * const helper = new THREE.CameraHelper(light.shadow.camera);
41
+ * scene.add(helper);
42
+ * ```
43
+ * @see {@link https://threejs.org/docs/index.html#api/en/lights/shadows/SpotLightShadow | Official Documentation}
44
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/SpotLightShadow.js | Source}
45
+ */
46
+ export class SpotLightShadow extends LightShadow<PerspectiveCamera> {
47
+ /**
48
+ * Read-only flag to check if a given object is of type {@link SpotLightShadow}.
49
+ * @remarks This is a _constant_ value
50
+ * @defaultValue `true`
51
+ */
6
52
  readonly isSpotLightShadow: true;
7
53
 
8
54
  /**
9
- * @default 1
55
+ * The light's view of the world.
56
+ * @remarks This is used to generate a depth map of the scene; objects behind other objects from the light's perspective will be in shadow.
57
+ * @remarks
58
+ * The {@link THREE.PerspectiveCamera.fov | fov} will track the {@link THREE.SpotLight.angle | angle} property
59
+ * of the owning {@link SpotLight | SpotLight} via the {@link SpotLightShadow.update | update} method.
60
+ * Similarly, the {@link THREE.PerspectiveCamera.aspect | aspect} property will track the aspect of the {@link LightShadow.mapSize | mapSize}.
61
+ * If the {@link SpotLight.distance | distance} property of the light is set, the {@link THREE.PerspectiveCamera.far | far} clipping plane will track that, otherwise it defaults to `500`.
62
+ * @defaultValue is a {@link THREE.PerspectiveCamera | PerspectiveCamera} with {@link THREE.PerspectiveCamera.near | near} clipping plane at `0.5`.
63
+ */
64
+ camera: PerspectiveCamera;
65
+
66
+ /**
67
+ * Used to focus the shadow camera.
68
+ * @remarks The camera's field of view is set as a percentage of the spotlight's field-of-view. Range is `[0, 1]`. 0`.
69
+ * @defaultValue `1`
10
70
  */
11
71
  focus: number;
12
72
  }
@@ -1,5 +1,6 @@
1
- import { Color, ColorRepresentation } from './../math/Color';
1
+ import { Color, ColorRepresentation } from '../math/Color';
2
2
  import { MaterialParameters, Material } from './Material';
3
+ import { Texture } from '../textures/Texture';
3
4
 
4
5
  export interface LineBasicMaterialParameters extends MaterialParameters {
5
6
  color?: ColorRepresentation | undefined;
@@ -43,5 +44,10 @@ export class LineBasicMaterial extends Material {
43
44
  */
44
45
  linejoin: string;
45
46
 
47
+ /**
48
+ * Sets the color of the lines using data from a {@link Texture}.
49
+ */
50
+ map: Texture | null;
51
+
46
52
  setValues(parameters: LineBasicMaterialParameters): void;
47
53
  }
@@ -46,21 +46,6 @@ export class MeshDistanceMaterial extends Material {
46
46
  */
47
47
  displacementBias: number;
48
48
 
49
- /**
50
- * @default 1000
51
- */
52
- farDistance: number;
53
-
54
- /**
55
- * @default 1
56
- */
57
- nearDistance: number;
58
-
59
- /**
60
- * @default new THREE.Vector3()
61
- */
62
- referencePosition: Vector3;
63
-
64
49
  /**
65
50
  * @default false
66
51
  */
three/src/math/Color.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { ColorSpace } from '../constants';
2
+ import { Matrix3 } from './Matrix3';
3
+ import { Vector3 } from './Vector3';
2
4
 
3
- import { BufferAttribute } from './../core/BufferAttribute';
4
- import { InterleavedBufferAttribute } from './../core/InterleavedBufferAttribute';
5
+ import { BufferAttribute } from '../core/BufferAttribute';
6
+ import { InterleavedBufferAttribute } from '../core/InterleavedBufferAttribute';
5
7
 
6
8
  export { SRGBToLinear } from './ColorManagement';
7
9
 
@@ -203,6 +205,13 @@ export class Color {
203
205
  b: number;
204
206
 
205
207
  set(color: ColorRepresentation): Color;
208
+
209
+ /**
210
+ * Sets this color's {@link r}, {@link g} and {@link b} components from the x, y, and z components of the specified
211
+ * {@link Vector3 | vector}.
212
+ */
213
+ setFromVector3(vector: Vector3): this;
214
+
206
215
  setScalar(scalar: number): Color;
207
216
  setHex(hex: number, colorSpace?: ColorSpace): Color;
208
217
 
@@ -295,6 +304,12 @@ export class Color {
295
304
  add(color: Color): this;
296
305
  addColors(color1: Color, color2: Color): this;
297
306
  addScalar(s: number): this;
307
+
308
+ /**
309
+ * Applies the transform {@link Matrix3 | m} to this color's RGB components.
310
+ */
311
+ applyMatrix3(m: Matrix3): this;
312
+
298
313
  sub(color: Color): this;
299
314
  multiply(color: Color): this;
300
315
  multiplyScalar(s: number): this;
@@ -326,6 +341,12 @@ export class Color {
326
341
  */
327
342
  toArray(xyz: ArrayLike<number>, offset?: number): ArrayLike<number>;
328
343
 
344
+ /**
345
+ * This method defines the serialization result of Color.
346
+ * @return The color as a hexadecimal value.
347
+ */
348
+ toJSON(): number;
349
+
329
350
  fromBufferAttribute(attribute: BufferAttribute | InterleavedBufferAttribute, index: number): this;
330
351
 
331
352
  [Symbol.iterator](): Generator<number, void>;
@@ -138,6 +138,12 @@ export class Quaternion {
138
138
  */
139
139
  toArray(array: ArrayLike<number>, offset?: number): ArrayLike<number>;
140
140
 
141
+ /**
142
+ * This method defines the serialization result of Quaternion.
143
+ * @return The numerical elements of this quaternion in an array of format [x, y, z, w].
144
+ */
145
+ toJSON(): [number, number, number, number];
146
+
141
147
  /**
142
148
  * Sets x, y, z, w properties of this quaternion from the attribute.
143
149
  * @param attribute the source attribute.
@@ -1,5 +1,6 @@
1
1
  import { Vector2 } from './Vector2';
2
2
  import { Vector3 } from './Vector3';
3
+ import { Vector4 } from './Vector4';
3
4
  import { Plane } from './Plane';
4
5
  import { Box3 } from './Box3';
5
6
 
@@ -39,7 +40,13 @@ export class Triangle {
39
40
  getNormal(target: Vector3): Vector3;
40
41
  getPlane(target: Plane): Plane;
41
42
  getBarycoord(point: Vector3, target: Vector3): Vector3;
43
+ /**
44
+ * @deprecated Triangle.getUV() has been renamed to Triangle.getInterpolation().
45
+ */
42
46
  getUV(point: Vector3, uv1: Vector2, uv2: Vector2, uv3: Vector2, target: Vector2): Vector2;
47
+ getInterpolation(point: Vector3, v1: Vector2, v2: Vector2, v3: Vector2, target: Vector2): Vector2;
48
+ getInterpolation(point: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, target: Vector3): Vector3;
49
+ getInterpolation(point: Vector3, v1: Vector4, v2: Vector4, v3: Vector4, target: Vector4): Vector4;
43
50
  containsPoint(point: Vector3): boolean;
44
51
  intersectsBox(box: Box3): boolean;
45
52
  isFrontFacing(direction: Vector3): boolean;
@@ -49,6 +56,9 @@ export class Triangle {
49
56
  static getNormal(a: Vector3, b: Vector3, c: Vector3, target: Vector3): Vector3;
50
57
  static getBarycoord(point: Vector3, a: Vector3, b: Vector3, c: Vector3, target: Vector3): Vector3;
51
58
  static containsPoint(point: Vector3, a: Vector3, b: Vector3, c: Vector3): boolean;
59
+ /**
60
+ * @deprecated THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation().
61
+ */
52
62
  static getUV(
53
63
  point: Vector3,
54
64
  p1: Vector3,
@@ -59,5 +69,35 @@ export class Triangle {
59
69
  uv3: Vector2,
60
70
  target: Vector2,
61
71
  ): Vector2;
72
+ static getInterpolation(
73
+ point: Vector3,
74
+ p1: Vector3,
75
+ p2: Vector3,
76
+ p3: Vector3,
77
+ v1: Vector2,
78
+ v2: Vector2,
79
+ v3: Vector2,
80
+ target: Vector2,
81
+ ): Vector2;
82
+ static getInterpolation(
83
+ point: Vector3,
84
+ p1: Vector3,
85
+ p2: Vector3,
86
+ p3: Vector3,
87
+ v1: Vector3,
88
+ v2: Vector3,
89
+ v3: Vector3,
90
+ target: Vector3,
91
+ ): Vector3;
92
+ static getInterpolation(
93
+ point: Vector3,
94
+ p1: Vector3,
95
+ p2: Vector3,
96
+ p3: Vector3,
97
+ v1: Vector4,
98
+ v2: Vector4,
99
+ v3: Vector4,
100
+ target: Vector4,
101
+ ): Vector4;
62
102
  static isFrontFacing(a: Vector3, b: Vector3, c: Vector3, direction: Vector3): boolean;
63
103
  }
@@ -354,6 +354,11 @@ export class Vector2 implements Vector {
354
354
  */
355
355
  angle(): number;
356
356
 
357
+ /**
358
+ * Returns the angle between this vector and vector {@link Vector2 | v} in radians.
359
+ */
360
+ angleTo(v: Vector2): number;
361
+
357
362
  /**
358
363
  * Computes distance of this vector to v.
359
364
  */
@@ -2,12 +2,13 @@ import { Euler } from './Euler';
2
2
  import { Matrix3 } from './Matrix3';
3
3
  import { Matrix4 } from './Matrix4';
4
4
  import { Quaternion } from './Quaternion';
5
- import { Camera } from './../cameras/Camera';
5
+ import { Camera } from '../cameras/Camera';
6
6
  import { Spherical } from './Spherical';
7
7
  import { Cylindrical } from './Cylindrical';
8
- import { BufferAttribute } from './../core/BufferAttribute';
9
- import { InterleavedBufferAttribute } from './../core/InterleavedBufferAttribute';
8
+ import { BufferAttribute } from '../core/BufferAttribute';
9
+ import { InterleavedBufferAttribute } from '../core/InterleavedBufferAttribute';
10
10
  import { Vector } from './Vector2';
11
+ import { Color } from './Color';
11
12
 
12
13
  export type Vector3Tuple = [number, number, number];
13
14
 
@@ -68,6 +69,12 @@ export class Vector3 implements Vector {
68
69
 
69
70
  setComponent(index: number, value: number): this;
70
71
 
72
+ /**
73
+ * Sets this vector's {@link x}, {@link y} and {@link z} components from the r, g, and b components of the specified
74
+ * {@link Color | color}.
75
+ */
76
+ setFromColor(color: Color): this;
77
+
71
78
  getComponent(index: number): number;
72
79
 
73
80
  /**
@@ -39,23 +39,19 @@ export class InstancedMesh<
39
39
  */
40
40
  readonly isInstancedMesh: true;
41
41
 
42
- /////////////////////////////////////////////////
43
- // FUTURE - r151
44
- /////////////////////////////////////////////////
45
- // /**
46
- // * This bounding box encloses all instances of the {@link InstancedMesh},, which can be calculated with {@link computeBoundingBox | .computeBoundingBox()}.
47
- // * @remarks Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
48
- // * @defaultValue `null`
49
- // */
50
- // boundingBox: Box3 | null;
42
+ /**
43
+ * This bounding box encloses all instances of the {@link InstancedMesh},, which can be calculated with {@link computeBoundingBox | .computeBoundingBox()}.
44
+ * @remarks Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
45
+ * @defaultValue `null`
46
+ */
47
+ boundingBox: Box3 | null;
51
48
 
52
- // /**
53
- // * This bounding sphere encloses all instances of the {@link InstancedMesh}, which can be calculated with {@link computeBoundingSphere | .computeBoundingSphere()}.
54
- // * @remarks bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
55
- // * @defaultValue `null`
56
- // */
57
- // boundingSphere: Sphere | null;
58
- /////////////////////////////////////////////////
49
+ /**
50
+ * This bounding sphere encloses all instances of the {@link InstancedMesh}, which can be calculated with {@link computeBoundingSphere | .computeBoundingSphere()}.
51
+ * @remarks bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
52
+ * @defaultValue `null`
53
+ */
54
+ boundingSphere: Sphere | null;
59
55
 
60
56
  /**
61
57
  * The number of instances.
@@ -80,21 +76,17 @@ export class InstancedMesh<
80
76
  */
81
77
  instanceMatrix: InstancedBufferAttribute;
82
78
 
83
- /////////////////////////////////////////////////
84
- // FUTURE - r151
85
- /////////////////////////////////////////////////
86
- // /**
87
- // * Computes bounding box of the all instances, updating {@link boundingBox | .boundingBox} attribute.
88
- // * @remarks Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
89
- // */
90
- // computeBoundingBox(): void;
79
+ /**
80
+ * Computes bounding box of the all instances, updating {@link boundingBox | .boundingBox} attribute.
81
+ * @remarks Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
82
+ */
83
+ computeBoundingBox(): void;
91
84
 
92
- // /**
93
- // * Computes bounding sphere of the all instances, updating {@link boundingSphere | .boundingSphere} attribute.
94
- // * @remarks bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
95
- // */
96
- // computeBoundingSphere(): void;
97
- /////////////////////////////////////////////////
85
+ /**
86
+ * Computes bounding sphere of the all instances, updating {@link boundingSphere | .boundingSphere} attribute.
87
+ * @remarks bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
88
+ */
89
+ computeBoundingSphere(): void;
98
90
 
99
91
  /**
100
92
  * Get the color of the defined instance.
@@ -30,6 +30,8 @@ export class LineSegments<
30
30
  readonly isLineSegments: true;
31
31
 
32
32
  /**
33
+ * A Read-only _string_ to check if `this` object type.
34
+ * @remarks Sub-classes will update this value.
33
35
  * @override
34
36
  * @defaultValue `LineSegments`
35
37
  */
@@ -32,7 +32,7 @@ export class Skeleton {
32
32
  * @param bones The array of {@link THREE.Bone | bones}. Default `[]`.
33
33
  * @param boneInverses An array of {@link THREE.Matrix4 | Matrix4s}. Default `[]`.
34
34
  */
35
- constructor(bones: Bone[], boneInverses?: Matrix4[]);
35
+ constructor(bones?: Bone[], boneInverses?: Matrix4[]);
36
36
 
37
37
  /**
38
38
  * {@link http://en.wikipedia.org/wiki/Universally_unique_identifier | UUID} of this object instance.
@@ -112,4 +112,8 @@ export class Skeleton {
112
112
  * Call this method whenever this instance is no longer used in your app.
113
113
  */
114
114
  dispose(): void;
115
+
116
+ toJSON(): unknown;
117
+
118
+ fromJSON(json: unknown, bones: Record<string, Bone>): void;
115
119
  }
@@ -1,9 +1,11 @@
1
1
  import { Material } from './../materials/Material';
2
+ import { Box3 } from '../math/Box3';
2
3
  import { Matrix4 } from './../math/Matrix4';
3
4
  import { Vector3 } from './../math/Vector3';
4
5
  import { Skeleton } from './Skeleton';
5
6
  import { Mesh } from './Mesh';
6
7
  import { BufferGeometry } from '../core/BufferGeometry';
8
+ import { Sphere } from '../math/Sphere';
7
9
 
8
10
  /**
9
11
  * A mesh that has a {@link THREE.Skeleton | Skeleton} with {@link Bone | bones} that can then be used to animate the vertices of the geometry.
@@ -86,6 +88,18 @@ export class SkinnedMesh<
86
88
  */
87
89
  bindMatrixInverse: Matrix4;
88
90
 
91
+ /**
92
+ * The bounding box of the SkinnedMesh. Can be calculated with {@link computeBoundingBox | .computeBoundingBox()}.
93
+ * @default `null`
94
+ */
95
+ boundingBox: Box3;
96
+
97
+ /**
98
+ * The bounding box of the SkinnedMesh. Can be calculated with {@link computeBoundingSphere | .computeBoundingSphere()}.
99
+ * @default `null`
100
+ */
101
+ boundingSphere: Sphere;
102
+
89
103
  /**
90
104
  * {@link THREE.Skeleton | Skeleton} representing the bone hierarchy of the skinned mesh.
91
105
  */
@@ -100,6 +114,23 @@ export class SkinnedMesh<
100
114
  */
101
115
  bind(skeleton: Skeleton, bindMatrix?: Matrix4): void;
102
116
 
117
+ /**
118
+ * Computes the bounding box, updating {@link boundingBox | .boundingBox} attribute.
119
+ * @remarks
120
+ * Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are `null`. If an
121
+ * instance of SkinnedMesh is animated, this method should be called per frame to compute a correct bounding box.
122
+ */
123
+ computeBoundingBox(): void;
124
+
125
+ /**
126
+ * Computes the bounding sphere, updating {@link boundingSphere | .boundingSphere} attribute.
127
+ * @remarks
128
+ * Bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are `null`. If
129
+ * an instance of SkinnedMesh is animated, this method should be called per frame to compute a correct bounding
130
+ * sphere.
131
+ */
132
+ computeBoundingSphere(): void;
133
+
103
134
  /**
104
135
  * This method sets the skinned mesh in the rest pose (resets the pose).
105
136
  */
@@ -110,35 +141,16 @@ export class SkinnedMesh<
110
141
  */
111
142
  normalizeSkinWeights(): void;
112
143
 
113
- /////////////////////////////////////////////////
114
- // FUTURE - r151
115
- /////////////////////////////////////////////////
116
- // /**
117
- // * Applies the bone transform associated with the given index to the given position vector
118
- // * @remarks Returns the updated vector.
119
- // * @param index Expects a `Integer`
120
- // * @param vector
121
- // */
122
- // applyBoneTransform(index: number, vector: Vector3): Vector3;
123
-
124
- // /**
125
- // * @deprecated {@link THREE.SkinnedMesh}: {@link boneTransform | .boneTransform()} was renamed to {@link applyBoneTransform | .applyBoneTransform()} in **r151**.
126
- // */
127
- // boneTransform(index: number, target: Vector3): Vector3;
128
- /////////////////////////////////////////////////
129
-
130
144
  /**
131
- * Applies the bone transform associated with the given index to the given position vector.
132
- * Calculates the position of the vertex at the given index relative to the current bone transformations.
133
- * Target vector must be initialized with the vertex coordinates prior to the transformation:
134
- * ```typescript
135
- * const target = new THREE.Vector3();
136
- * target.fromBufferAttribute( mesh.geometry.attributes.position, index );
137
- * mesh.boneTransform( index, target );
138
- * ```
145
+ * Applies the bone transform associated with the given index to the given position vector
139
146
  * @remarks Returns the updated vector.
140
147
  * @param index Expects a `Integer`
141
148
  * @param vector
142
149
  */
150
+ applyBoneTransform(index: number, vector: Vector3): Vector3;
151
+
152
+ /**
153
+ * @deprecated {@link THREE.SkinnedMesh}: {@link boneTransform | .boneTransform()} was renamed to {@link applyBoneTransform | .applyBoneTransform()} in **r151**.
154
+ */
143
155
  boneTransform(index: number, target: Vector3): Vector3;
144
156
  }
@@ -22,6 +22,7 @@ import { Data3DTexture } from '../textures/Data3DTexture';
22
22
  import { Vector3 } from '../math/Vector3';
23
23
  import { Box3 } from '../math/Box3';
24
24
  import { DataArrayTexture } from '../textures/DataArrayTexture';
25
+ import { WebGLProgram } from './webgl/WebGLProgram';
25
26
 
26
27
  export interface Renderer {
27
28
  domElement: HTMLCanvasElement;
@@ -99,6 +100,21 @@ export interface WebGLDebug {
99
100
  * Enables error checking and reporting when shader programs are being compiled.
100
101
  */
101
102
  checkShaderErrors: boolean;
103
+
104
+ /**
105
+ * A callback function that can be used for custom error reporting. The callback receives the WebGL context, an
106
+ * instance of WebGLProgram as well two instances of WebGLShader representing the vertex and fragment shader.
107
+ * Assigning a custom function disables the default error reporting.
108
+ * @default `null`
109
+ */
110
+ onShaderError:
111
+ | ((
112
+ gl: WebGLRenderingContext,
113
+ program: WebGLProgram,
114
+ glVertexShader: WebGLShader,
115
+ glFragmentShader: WebGLShader,
116
+ ) => void)
117
+ | null;
102
118
  }
103
119
 
104
120
  /**