@types/three 0.174.0 → 0.176.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 (102) hide show
  1. three/README.md +2 -2
  2. three/examples/jsm/Addons.d.ts +1 -1
  3. three/examples/jsm/controls/PointerLockControls.d.ts +4 -1
  4. three/examples/jsm/geometries/ParametricFunctions.d.ts +8 -0
  5. three/examples/jsm/helpers/RapierHelper.d.ts +13 -0
  6. three/examples/jsm/interactive/HTMLMesh.d.ts +9 -2
  7. three/examples/jsm/loaders/LUTImageLoader.d.ts +2 -2
  8. three/examples/jsm/loaders/LottieLoader.d.ts +4 -0
  9. three/examples/jsm/misc/MD2CharacterComplex.d.ts +1 -1
  10. three/examples/jsm/physics/RapierPhysics.d.ts +12 -0
  11. three/examples/jsm/postprocessing/BokehPass.d.ts +2 -2
  12. three/examples/jsm/postprocessing/HalftonePass.d.ts +1 -1
  13. three/examples/jsm/postprocessing/LUTPass.d.ts +1 -1
  14. three/examples/jsm/postprocessing/SMAAPass.d.ts +1 -1
  15. three/examples/jsm/transpiler/AST.d.ts +218 -1
  16. three/examples/jsm/transpiler/TSLEncoder.d.ts +35 -1
  17. three/examples/jsm/tsl/shadows/TileShadowNode.d.ts +14 -0
  18. three/examples/jsm/tsl/shadows/TileShadowNodeHelper.d.ts +14 -0
  19. three/examples/jsm/webxr/VRButton.d.ts +4 -2
  20. three/package.json +4 -3
  21. three/src/Three.Core.d.ts +2 -0
  22. three/src/Three.TSL.d.ts +11 -1
  23. three/src/animation/AnimationAction.d.ts +219 -19
  24. three/src/animation/AnimationClip.d.ts +140 -28
  25. three/src/animation/AnimationMixer.d.ts +100 -8
  26. three/src/animation/AnimationObjectGroup.d.ts +55 -14
  27. three/src/animation/AnimationUtils.d.ts +154 -43
  28. three/src/animation/KeyframeTrack.d.ts +134 -25
  29. three/src/animation/PropertyBinding.d.ts +89 -31
  30. three/src/animation/PropertyMixer.d.ts +62 -5
  31. three/src/animation/tracks/BooleanKeyframeTrack.d.ts +12 -4
  32. three/src/animation/tracks/ColorKeyframeTrack.d.ts +10 -4
  33. three/src/animation/tracks/NumberKeyframeTrack.d.ts +10 -4
  34. three/src/animation/tracks/QuaternionKeyframeTrack.d.ts +10 -4
  35. three/src/animation/tracks/StringKeyframeTrack.d.ts +12 -4
  36. three/src/animation/tracks/VectorKeyframeTrack.d.ts +10 -4
  37. three/src/audio/AudioListener.d.ts +1 -1
  38. three/src/cameras/ArrayCamera.d.ts +5 -0
  39. three/src/constants.d.ts +18 -17
  40. three/src/core/BufferAttribute.d.ts +11 -0
  41. three/src/core/BufferGeometry.d.ts +1 -3
  42. three/src/core/RenderTarget.d.ts +9 -0
  43. three/src/extras/Controls.d.ts +1 -1
  44. three/src/extras/Earcut.d.ts +5 -3
  45. three/src/extras/ImageUtils.d.ts +1 -0
  46. three/src/geometries/CapsuleGeometry.d.ts +10 -3
  47. three/src/lights/LightShadow.d.ts +8 -0
  48. three/src/lights/PointLight.d.ts +1 -1
  49. three/src/loaders/FileLoader.d.ts +2 -2
  50. three/src/loaders/LoaderUtils.d.ts +0 -5
  51. three/src/materials/Material.d.ts +6 -8
  52. three/src/materials/ShaderMaterial.d.ts +1 -1
  53. three/src/materials/nodes/NodeMaterial.d.ts +10 -2
  54. three/src/materials/nodes/manager/NodeMaterialObserver.d.ts +8 -0
  55. three/src/math/FrustumArray.d.ts +27 -0
  56. three/src/nodes/Nodes.d.ts +1 -0
  57. three/src/nodes/TSL.d.ts +1 -0
  58. three/src/nodes/accessors/BufferAttributeNode.d.ts +11 -4
  59. three/src/nodes/accessors/InstanceNode.d.ts +2 -3
  60. three/src/nodes/accessors/Object3DNode.d.ts +6 -6
  61. three/src/nodes/accessors/SkinningNode.d.ts +4 -3
  62. three/src/nodes/accessors/StorageTextureNode.d.ts +2 -2
  63. three/src/nodes/accessors/TextureNode.d.ts +3 -1
  64. three/src/nodes/accessors/VertexColorNode.d.ts +1 -1
  65. three/src/nodes/code/ExpressionNode.d.ts +3 -2
  66. three/src/nodes/code/ScriptableNode.d.ts +1 -1
  67. three/src/nodes/code/ScriptableValueNode.d.ts +1 -1
  68. three/src/nodes/core/Node.d.ts +8 -5
  69. three/src/nodes/core/NodeVarying.d.ts +11 -1
  70. three/src/nodes/core/StackNode.d.ts +7 -1
  71. three/src/nodes/core/StructTypeNode.d.ts +1 -1
  72. three/src/nodes/core/VaryingNode.d.ts +6 -0
  73. three/src/nodes/gpgpu/AtomicFunctionNode.d.ts +3 -14
  74. three/src/nodes/lighting/ShadowFilterNode.d.ts +28 -0
  75. three/src/nodes/lighting/ShadowNode.d.ts +26 -24
  76. three/src/nodes/math/ConditionalNode.d.ts +4 -4
  77. three/src/nodes/math/MathNode.d.ts +20 -12
  78. three/src/nodes/math/OperatorNode.d.ts +65 -25
  79. three/src/nodes/tsl/TSLBase.d.ts +1 -0
  80. three/src/nodes/tsl/TSLCore.d.ts +34 -26
  81. three/src/nodes/utils/DebugNode.d.ts +21 -0
  82. three/src/nodes/utils/ReflectorNode.d.ts +1 -1
  83. three/src/nodes/utils/SpriteSheetUVNode.d.ts +2 -2
  84. three/src/renderers/common/Animation.d.ts +4 -4
  85. three/src/renderers/common/Attributes.d.ts +1 -1
  86. three/src/renderers/common/Color4.d.ts +1 -1
  87. three/src/renderers/common/CubeRenderTarget.d.ts +6 -0
  88. three/src/renderers/common/RenderList.d.ts +2 -2
  89. three/src/renderers/common/RenderObject.d.ts +1 -1
  90. three/src/renderers/common/RenderObjects.d.ts +2 -2
  91. three/src/renderers/common/Renderer.d.ts +55 -27
  92. three/src/renderers/common/Textures.d.ts +0 -7
  93. three/src/renderers/common/TimestampQueryPool.d.ts +1 -0
  94. three/src/renderers/common/XRManager.d.ts +79 -4
  95. three/src/renderers/common/nodes/NodeBuilderState.d.ts +3 -3
  96. three/src/renderers/webgpu/WebGPUBackend.d.ts +1 -0
  97. three/src/renderers/webgpu/utils/WebGPUConstants.d.ts +1 -1
  98. three/src/textures/CanvasTexture.d.ts +1 -1
  99. three/src/textures/DepthArrayTexture.d.ts +14 -0
  100. three/src/textures/Texture.d.ts +8 -1
  101. three/src/textures/VideoFrameTexture.d.ts +1 -1
  102. three/examples/jsm/geometries/ParametricGeometries.d.ts +0 -32
@@ -9,7 +9,7 @@ import ConvertNode from "../utils/ConvertNode.js";
9
9
  export interface NodeElements {
10
10
  toGlobal: (node: Node) => Node;
11
11
 
12
- append: typeof append;
12
+ toStack: typeof Stack;
13
13
 
14
14
  toColor: typeof color;
15
15
  toFloat: typeof float;
@@ -34,6 +34,8 @@ export interface NodeElements {
34
34
 
35
35
  element: typeof element;
36
36
  convert: typeof convert;
37
+
38
+ append: typeof append;
37
39
  }
38
40
 
39
41
  export function addMethodChaining(name: string, nodeElement: unknown): void;
@@ -113,7 +115,7 @@ type RemoveHeadAndTail<T extends readonly [...unknown[]]> = T extends [unknown,
113
115
  *
114
116
  * We use an object instead of tuple or union as it makes stuff easier, especially in Typescript 4.0.
115
117
  */
116
- interface Construtors<
118
+ interface Constructors<
117
119
  A extends undefined | [...unknown[]],
118
120
  B extends undefined | [...unknown[]],
119
121
  C extends undefined | [...unknown[]],
@@ -136,20 +138,20 @@ type OverloadedConstructorsOf<T> = T extends {
136
138
  new(...args: infer A2): unknown;
137
139
  new(...args: infer A3): unknown;
138
140
  new(...args: infer A4): unknown;
139
- } ? Construtors<A1, A2, A3, A4>
141
+ } ? Constructors<A1, A2, A3, A4>
140
142
  : T extends {
141
143
  new(...args: infer A1): unknown;
142
144
  new(...args: infer A2): unknown;
143
145
  new(...args: infer A3): unknown;
144
- } ? Construtors<A1, A2, A3, undefined>
146
+ } ? Constructors<A1, A2, A3, undefined>
145
147
  : T extends {
146
148
  new(...args: infer A1): unknown;
147
149
  new(...args: infer A2): unknown;
148
- } ? Construtors<A1, A2, undefined, undefined>
149
- : T extends new(...args: infer A) => unknown ? Construtors<A, undefined, undefined, undefined>
150
- : Construtors<undefined, undefined, undefined, undefined>;
150
+ } ? Constructors<A1, A2, undefined, undefined>
151
+ : T extends new(...args: infer A) => unknown ? Constructors<A, undefined, undefined, undefined>
152
+ : Constructors<undefined, undefined, undefined, undefined>;
151
153
 
152
- type AnyConstructors = Construtors<any, any, any, any>;
154
+ type AnyConstructors = Constructors<any, any, any, any>;
153
155
 
154
156
  /**
155
157
  * Returns all constructors where the first paramter is assignable to given "scope"
@@ -259,30 +261,14 @@ export function Fn<T extends { readonly [key: string]: unknown }>(
259
261
  jsFunc: (args: T) => void,
260
262
  ): ShaderNodeFn<[ProxiedObject<T>]>;
261
263
 
262
- /**
263
- * @deprecated tslFn() has been renamed to Fn()
264
- */
265
- export function tslFn<R extends Node = ShaderNodeObject<Node>>(jsFunc: () => R): () => R;
266
- /**
267
- * @deprecated tslFn() has been renamed to Fn()
268
- */
269
- export function tslFn<T extends any[], R extends Node = ShaderNodeObject<Node>>(
270
- jsFunc: (args: T) => R,
271
- ): (...args: ProxiedTuple<T>) => R;
272
- /**
273
- * @deprecated tslFn() has been renamed to Fn()
274
- */
275
- export function tslFn<T extends { [key: string]: unknown }, R extends Node = ShaderNodeObject<Node>>(
276
- jsFunc: (args: T) => R,
277
- ): (args: ProxiedObject<T>) => R;
278
-
279
264
  export const setCurrentStack: (stack: StackNode | null) => void;
280
265
 
281
266
  export const getCurrentStack: () => StackNode | null;
282
267
 
283
268
  export const If: (boolNode: Node, method: () => void) => StackNode;
269
+ export const Switch: (expression: NodeRepresentation) => StackNode;
284
270
 
285
- export function append(node: Node): Node;
271
+ export function Stack(node: Node): Node;
286
272
 
287
273
  interface ColorFunction {
288
274
  (color?: ColorRepresentation): ShaderNodeObject<ConstNode<Color>>;
@@ -322,3 +308,25 @@ export const arrayBuffer: (value: ArrayBuffer) => ShaderNodeObject<ConstNode<Arr
322
308
  export const element: (node: NodeRepresentation, indexNode: NodeRepresentation) => ShaderNodeObject<Node>;
323
309
  export const convert: (node: NodeRepresentation, types: string) => ShaderNodeObject<Node>;
324
310
  export const split: (node: NodeRepresentation, channels?: string) => ShaderNodeObject<Node>;
311
+
312
+ /**
313
+ * @deprecated append() has been renamed to Stack().
314
+ */
315
+ export const append: (node: Node) => Node;
316
+
317
+ /**
318
+ * @deprecated tslFn() has been renamed to Fn()
319
+ */
320
+ export function tslFn<R extends Node = ShaderNodeObject<Node>>(jsFunc: () => R): () => R;
321
+ /**
322
+ * @deprecated tslFn() has been renamed to Fn()
323
+ */
324
+ export function tslFn<T extends any[], R extends Node = ShaderNodeObject<Node>>(
325
+ jsFunc: (args: T) => R,
326
+ ): (...args: ProxiedTuple<T>) => R;
327
+ /**
328
+ * @deprecated tslFn() has been renamed to Fn()
329
+ */
330
+ export function tslFn<T extends { [key: string]: unknown }, R extends Node = ShaderNodeObject<Node>>(
331
+ jsFunc: (args: T) => R,
332
+ ): (args: ProxiedObject<T>) => R;
@@ -0,0 +1,21 @@
1
+ import Node from "../core/Node.js";
2
+ import NodeBuilder from "../core/NodeBuilder.js";
3
+ import TempNode from "../core/TempNode.js";
4
+ import { NodeRepresentation, ShaderNodeObject } from "../tsl/TSLCore.js";
5
+
6
+ declare class DebugNode extends TempNode {
7
+ constructor(node: Node, callback?: ((code: string) => void) | null);
8
+ }
9
+
10
+ export default DebugNode;
11
+
12
+ export const debug: (
13
+ node: NodeRepresentation,
14
+ callback?: ((node: NodeBuilder, code: string) => void) | null,
15
+ ) => ShaderNodeObject<DebugNode>;
16
+
17
+ declare module "../tsl/TSLCore.js" {
18
+ interface NodeElements {
19
+ debug: typeof debug;
20
+ }
21
+ }
@@ -31,7 +31,7 @@ declare class ReflectorBaseNode extends Node {
31
31
  bounces: boolean;
32
32
 
33
33
  virtualCameras: WeakMap<Camera, Camera>;
34
- renderTargets: WeakMap<Camera, RenderTarget>;
34
+ renderTargets: Map<Camera, RenderTarget>;
35
35
  forceUpdate: boolean;
36
36
 
37
37
  constructor(textureNode: TextureNode, parameters?: ReflectorNodeParameters);
@@ -11,6 +11,6 @@ export default class SpriteSheetUVNode extends Node {
11
11
 
12
12
  export const spritesheetUV: (
13
13
  countNode: NodeRepresentation,
14
- uvNode?: NodeRepresentation,
15
- frameNode?: NodeRepresentation,
14
+ uvNode: NodeRepresentation | null,
15
+ frameNode: NodeRepresentation | null,
16
16
  ) => ShaderNodeObject<SpriteSheetUVNode>;
@@ -12,7 +12,7 @@ export interface AnimationContext {
12
12
  declare class Animation {
13
13
  nodes: Nodes;
14
14
  info: Info;
15
- _context: AnimationContext;
15
+ _context: AnimationContext | null;
16
16
  _animationLoop: ((time: DOMHighResTimeStamp, xrFrame?: XRFrame) => void) | null;
17
17
  _requestId: number | null;
18
18
  /**
@@ -33,13 +33,13 @@ declare class Animation {
33
33
  /**
34
34
  * Returns the user-level animation loop.
35
35
  *
36
- * @return {Function} The animation loop.
36
+ * @return {?Function} The animation loop.
37
37
  */
38
38
  getAnimationLoop(): ((time: DOMHighResTimeStamp, xrFrame?: XRFrame) => void) | null;
39
39
  /**
40
40
  * Defines the user-level animation loop.
41
41
  *
42
- * @param {Function} callback - The animation loop.
42
+ * @param {?Function} callback - The animation loop.
43
43
  */
44
44
  setAnimationLoop(callback: ((time: DOMHighResTimeStamp, xrFrame?: XRFrame) => void) | null): void;
45
45
  /**
@@ -47,7 +47,7 @@ declare class Animation {
47
47
  *
48
48
  * @return {Window|XRSession} The animation context.
49
49
  */
50
- getContext(): AnimationContext;
50
+ getContext(): AnimationContext | null;
51
51
  /**
52
52
  * Defines the context in which `requestAnimationFrame()` is executed.
53
53
  *
@@ -30,7 +30,7 @@ declare class Attributes extends DataMap<{
30
30
  * Deletes the data for the given attribute.
31
31
  *
32
32
  * @param {BufferAttribute} attribute - The attribute.
33
- * @return {Object} The deleted attribute data.
33
+ * @return {Object|null} The deleted attribute data.
34
34
  */
35
35
  delete(attribute: BufferAttribute | InterleavedBufferAttribute): Data;
36
36
  /**
@@ -26,7 +26,7 @@ declare class Color4 extends Color {
26
26
  * You can also pass a single THREE.Color, hex or
27
27
  * string argument to this method.
28
28
  *
29
- * @param {number|string} r - The red value.
29
+ * @param {number|string|Color} r - The red value.
30
30
  * @param {number} g - The green value.
31
31
  * @param {number} b - The blue value.
32
32
  * @param {number} [a=1] - The alpha value.
@@ -10,6 +10,12 @@ import { WebGLRenderer } from "../WebGLRenderer.js";
10
10
  */
11
11
  declare class CubeRenderTarget extends WebGLCubeRenderTarget {
12
12
  readonly isCubeRenderTarget: true;
13
+ /**
14
+ * Constructs a new cube render target.
15
+ *
16
+ * @param {number} [size=1] - The size of the render target.
17
+ * @param {RenderTarget~Options} [options] - The configuration object.
18
+ */
13
19
  constructor(size?: number, options?: RenderTargetOptions);
14
20
  /**
15
21
  * Converts the given equirectangular texture to a cube map.
@@ -144,8 +144,8 @@ declare class RenderList {
144
144
  /**
145
145
  * Sorts the internal render lists.
146
146
  *
147
- * @param {function(any, any): number} customOpaqueSort - A custom sort function for opaque objects.
148
- * @param {function(any, any): number} customTransparentSort - A custom sort function for transparent objects.
147
+ * @param {?function(any, any): number} customOpaqueSort - A custom sort function for opaque objects.
148
+ * @param {?function(any, any): number} customTransparentSort - A custom sort function for transparent objects.
149
149
  */
150
150
  sort(
151
151
  customOpaqueSort: ((a: RenderItem, b: RenderItem) => number) | null,
@@ -189,7 +189,7 @@ declare class RenderObject {
189
189
  /**
190
190
  * Returns the draw parameters for the render object.
191
191
  *
192
- * @return {{vertexCount: number, firstVertex: number, instanceCount: number, firstInstance: number}} The draw parameters.
192
+ * @return {?{vertexCount: number, firstVertex: number, instanceCount: number, firstInstance: number}} The draw parameters.
193
193
  */
194
194
  getDrawParameters(): {
195
195
  vertexCount: number;
@@ -56,7 +56,7 @@ declare class RenderObjects {
56
56
  * @param {LightsNode} lightsNode - The lights node.
57
57
  * @param {RenderContext} renderContext - The render context.
58
58
  * @param {ClippingContext} clippingContext - The clipping context.
59
- * @param {?string} passId - An optional ID for identifying the pass.
59
+ * @param {string} [passId] - An optional ID for identifying the pass.
60
60
  * @return {RenderObject} The render object.
61
61
  */
62
62
  get(
@@ -98,7 +98,7 @@ declare class RenderObjects {
98
98
  * @param {LightsNode} lightsNode - The lights node.
99
99
  * @param {RenderContext} renderContext - The render context.
100
100
  * @param {ClippingContext} clippingContext - The clipping context.
101
- * @param {?string} passId - An optional ID for identifying the pass.
101
+ * @param {string} [passId] - An optional ID for identifying the pass.
102
102
  * @return {RenderObject} The render object.
103
103
  */
104
104
  createRenderObject(
@@ -6,8 +6,10 @@ import { Object3D } from "../../core/Object3D.js";
6
6
  import { RenderTarget } from "../../core/RenderTarget.js";
7
7
  import { Material } from "../../materials/Material.js";
8
8
  import { Box2 } from "../../math/Box2.js";
9
+ import { Box3 } from "../../math/Box3.js";
9
10
  import { ColorRepresentation } from "../../math/Color.js";
10
11
  import { Vector2 } from "../../math/Vector2.js";
12
+ import { Vector3 } from "../../math/Vector3.js";
11
13
  import { Vector4 } from "../../math/Vector4.js";
12
14
  import MRTNode from "../../nodes/core/MRTNode.js";
13
15
  import ComputeNode from "../../nodes/gpgpu/ComputeNode.js";
@@ -60,6 +62,7 @@ export interface RendererParameters {
60
62
  samples?: number | undefined;
61
63
  getFallback?: ((error: unknown) => Backend) | null | undefined;
62
64
  colorBufferType?: TextureDataType | undefined;
65
+ multiview?: boolean | undefined;
63
66
  }
64
67
  /**
65
68
  * Base class for renderers.
@@ -183,20 +186,26 @@ declare class Renderer {
183
186
  };
184
187
  localClippingEnabled?: boolean | undefined;
185
188
  /**
186
- * Constructs a new renderer.
189
+ * Renderer options.
187
190
  *
188
- * @param {Backend} backend - The backend the renderer is targeting (e.g. WebGPU or WebGL 2).
189
- * @param {Object} parameters - The configuration parameter.
190
- * @param {boolean} [parameters.logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
191
- * @param {boolean} [parameters.alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
192
- * @param {boolean} [parameters.depth=true] - Whether the default framebuffer should have a depth buffer or not.
193
- * @param {boolean} [parameters.stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
194
- * @param {boolean} [parameters.antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
195
- * @param {number} [parameters.samples=0] - When `antialias` is `true`, `4` samples are used by default. This parameter can set to any other integer value than 0
191
+ * @typedef {Object} Renderer~Options
192
+ * @property {boolean} [logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
193
+ * @property {boolean} [alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
194
+ * @property {boolean} [depth=true] - Whether the default framebuffer should have a depth buffer or not.
195
+ * @property {boolean} [stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
196
+ * @property {boolean} [antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
197
+ * @property {number} [samples=0] - When `antialias` is `true`, `4` samples are used by default. This parameter can set to any other integer value than 0
196
198
  * to overwrite the default.
197
- * @param {?Function} [parameters.getFallback=null] - This callback function can be used to provide a fallback backend, if the primary backend can't be targeted.
198
- * @param {number} [parameters.colorBufferType=HalfFloatType] - Defines the type of color buffers. The default `HalfFloatType` is recommend for best
199
+ * @property {?Function} [getFallback=null] - This callback function can be used to provide a fallback backend, if the primary backend can't be targeted.
200
+ * @property {number} [colorBufferType=HalfFloatType] - Defines the type of color buffers. The default `HalfFloatType` is recommend for best
199
201
  * quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though.
202
+ * @property {boolean} [multiview=false] - If set to `true`, the renderer will use multiview during WebXR rendering if supported.
203
+ */
204
+ /**
205
+ * Constructs a new renderer.
206
+ *
207
+ * @param {Backend} backend - The backend the renderer is targeting (e.g. WebGPU or WebGL 2).
208
+ * @param {Renderer~Options} [parameters] - The configuration parameter.
200
209
  */
201
210
  constructor(backend: Backend, parameters?: RendererParameters);
202
211
  /**
@@ -227,8 +236,8 @@ declare class Renderer {
227
236
  * @async
228
237
  * @param {Object3D} scene - The scene or 3D object to precompile.
229
238
  * @param {Camera} camera - The camera that is used to render the scene.
230
- * @param {Scene} targetScene - If the first argument is a 3D object, this parameter must represent the scene the 3D object is going to be added.
231
- * @return {Promise<Array>} A Promise that resolves when the compile has been finished.
239
+ * @param {?Scene} targetScene - If the first argument is a 3D object, this parameter must represent the scene the 3D object is going to be added.
240
+ * @return {Promise<Array|undefined>} A Promise that resolves when the compile has been finished.
232
241
  */
233
242
  compileAsync(scene: Object3D, camera: Camera, targetScene?: Object3D | null): Promise<void>;
234
243
  /**
@@ -248,6 +257,23 @@ declare class Renderer {
248
257
  * @return {Promise} A Promise that resolves when synchronization has been finished.
249
258
  */
250
259
  waitForGPU(): Promise<void>;
260
+ /**
261
+ * Enables or disables high precision for model-view and normal-view matrices.
262
+ * When enabled, will use CPU 64-bit precision for higher precision instead of GPU 32-bit for higher performance.
263
+ *
264
+ * NOTE: 64-bit precision is not compatible with `InstancedMesh` and `SkinnedMesh`.
265
+ *
266
+ * @param {boolean} value - Whether to enable or disable high precision.
267
+ * @type {boolean}
268
+ */
269
+ set highPrecision(value: boolean);
270
+ /**
271
+ * Returns whether high precision is enabled or not.
272
+ *
273
+ * @return {boolean} Whether high precision is enabled or not.
274
+ * @type {boolean}
275
+ */
276
+ get highPrecision(): boolean;
251
277
  /**
252
278
  * Sets the given MRT configuration.
253
279
  *
@@ -280,7 +306,7 @@ declare class Renderer {
280
306
  * @private
281
307
  * @param {Object} bundle - Render bundle data.
282
308
  * @param {Scene} sceneRef - The scene the render bundle belongs to.
283
- * @param {LightsNode} lightsNode - The current lights node.
309
+ * @param {LightsNode} lightsNode - The lights node.
284
310
  */
285
311
  _renderBundle(bundle: Bundle, sceneRef: Scene, lightsNode: LightsNode): void;
286
312
  /**
@@ -346,7 +372,7 @@ declare class Renderer {
346
372
  * for best compatibility.
347
373
  *
348
374
  * @async
349
- * @param {Function} callback - The application's animation loop.
375
+ * @param {?Function} callback - The application's animation loop.
350
376
  * @return {Promise} A Promise that resolves when the set has been executed.
351
377
  */
352
378
  setAnimationLoop(callback: ((time: DOMHighResTimeStamp, frame?: XRFrame) => void) | null): Promise<void>;
@@ -382,7 +408,7 @@ declare class Renderer {
382
408
  * Returns the renderer's size in logical pixels. This method does not honor the pixel ratio.
383
409
  *
384
410
  * @param {Vector2} target - The method writes the result in this target object.
385
- * @return {Vector2} The drawing buffer size.
411
+ * @return {Vector2} The renderer's size in logical pixels.
386
412
  */
387
413
  getSize(target: Vector2): Vector2;
388
414
  /**
@@ -395,7 +421,7 @@ declare class Renderer {
395
421
  * This method allows to define the drawing buffer size by specifying
396
422
  * width, height and pixel ratio all at once. The size of the drawing
397
423
  * buffer is computed with this formula:
398
- * ````
424
+ * ```js
399
425
  * size.x = width * pixelRatio;
400
426
  * size.y = height * pixelRatio;
401
427
  * ```
@@ -711,7 +737,7 @@ declare class Renderer {
711
737
  * if the renderer has been initialized.
712
738
  *
713
739
  * @param {Node|Array<Node>} computeNodes - The compute node(s).
714
- * @return {?Promise} A Promise that resolve when the compute has finished. Only returned when the renderer has not been initialized.
740
+ * @return {Promise|undefined} A Promise that resolve when the compute has finished. Only returned when the renderer has not been initialized.
715
741
  */
716
742
  compute(computeNodes: ComputeNode | ComputeNode[]): Promise<void> | undefined;
717
743
  /**
@@ -755,7 +781,7 @@ declare class Renderer {
755
781
  */
756
782
  initTextureAsync(texture: Texture): Promise<void>;
757
783
  /**
758
- * Initializes the given textures. Useful for preloading a texture rather than waiting until first render
784
+ * Initializes the given texture. Useful for preloading a texture rather than waiting until first render
759
785
  * (which can cause noticeable lags due to decode and GPU upload overhead).
760
786
  *
761
787
  * This method can only be used if the renderer has been initialized.
@@ -767,24 +793,26 @@ declare class Renderer {
767
793
  * Copies the current bound framebuffer into the given texture.
768
794
  *
769
795
  * @param {FramebufferTexture} framebufferTexture - The texture.
770
- * @param {Vector2|Vector4} rectangle - A two or four dimensional vector that defines the rectangular portion of the framebuffer that should be copied.
796
+ * @param {?Vector2|Vector4} [rectangle=null] - A two or four dimensional vector that defines the rectangular portion of the framebuffer that should be copied.
771
797
  */
772
798
  copyFramebufferToTexture(framebufferTexture: FramebufferTexture, rectangle?: Rectangle | null): void;
773
799
  /**
774
- * Copies data of source texture into a destination texture.
800
+ * Copies data of the given source texture into a destination texture.
775
801
  *
776
802
  * @param {Texture} srcTexture - The source texture.
777
803
  * @param {Texture} dstTexture - The destination texture.
778
804
  * @param {Box2|Box3} [srcRegion=null] - A bounding box which describes the source region. Can be two or three-dimensional.
779
805
  * @param {Vector2|Vector3} [dstPosition=null] - A vector that represents the origin of the destination region. Can be two or three-dimensional.
780
- * @param {number} level - The mipmap level to copy.
806
+ * @param {number} [srcLevel=0] - The source mip level to copy from.
807
+ * @param {number} [dstLevel=0] - The destination mip level to copy to.
781
808
  */
782
809
  copyTextureToTexture(
783
810
  srcTexture: Texture,
784
811
  dstTexture: Texture,
785
- srcRegion?: Box2 | null,
786
- dstPosition?: Vector2 | null,
787
- level?: number,
812
+ srcRegion?: Box2 | Box3 | null,
813
+ dstPosition?: Vector2 | Vector3 | null,
814
+ srcLevel?: number,
815
+ dstLevel?: number,
788
816
  ): void;
789
817
  /**
790
818
  * Reads pixel data from the given render target.
@@ -879,7 +907,7 @@ declare class Renderer {
879
907
  * @param {Material} material - The object's material.
880
908
  * @param {?Object} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
881
909
  * @param {LightsNode} lightsNode - The current lights node.
882
- * @param {ClippingContext} clippingContext - The clipping context.
910
+ * @param {?ClippingContext} clippingContext - The clipping context.
883
911
  * @param {?string} [passId=null] - An optional ID for identifying the pass.
884
912
  */
885
913
  renderObject(
@@ -948,7 +976,7 @@ declare class Renderer {
948
976
  * @param {Object3D} scene - The scene or 3D object to precompile.
949
977
  * @param {Camera} camera - The camera that is used to render the scene.
950
978
  * @param {Scene} targetScene - If the first argument is a 3D object, this parameter must represent the scene the 3D object is going to be added.
951
- * @return {Promise} A Promise that resolves when the compile has been finished.
979
+ * @return {function(Object3D, Camera, ?Scene): Promise|undefined} A Promise that resolves when the compile has been finished.
952
980
  */
953
981
  get compile(): (scene: Object3D, camera: Camera, targetScene?: Object3D | null) => Promise<void>;
954
982
  }
@@ -116,13 +116,6 @@ declare class Textures extends DataMap<{
116
116
  * @return {boolean} Whether mipmaps are required or not.
117
117
  */
118
118
  needsMipmaps(texture: Texture): boolean;
119
- /**
120
- * Returns `true` if the given texture is an environment map.
121
- *
122
- * @param {Texture} texture - The texture.
123
- * @return {boolean} Whether the given texture is an environment map or not.
124
- */
125
- isEnvironmentTexture(texture: Texture): boolean;
126
119
  /**
127
120
  * Frees internal resource when the given texture isn't
128
121
  * required anymore.
@@ -23,6 +23,7 @@ declare abstract class TimestampQueryPool {
23
23
  *
24
24
  * @abstract
25
25
  * @param {Object} renderContext - The render context to allocate queries for.
26
+ * @returns {?number}
26
27
  */
27
28
  abstract allocateQueriesForContext(renderContext: RenderContext): number | null;
28
29
  /**
@@ -1,7 +1,14 @@
1
1
  import { ArrayCamera } from "../../cameras/ArrayCamera.js";
2
2
  import { PerspectiveCamera } from "../../cameras/PerspectiveCamera.js";
3
3
  import { EventDispatcher } from "../../core/EventDispatcher.js";
4
+ import { CylinderGeometry } from "../../geometries/CylinderGeometry.js";
5
+ import { PlaneGeometry } from "../../geometries/PlaneGeometry.js";
6
+ import { Material } from "../../materials/Material.js";
7
+ import { MeshBasicMaterial } from "../../materials/MeshBasicMaterial.js";
8
+ import { Quaternion } from "../../math/Quaternion.js";
4
9
  import { Vector2 } from "../../math/Vector2.js";
10
+ import { Vector3 } from "../../math/Vector3.js";
11
+ import { Mesh } from "../../objects/Mesh.js";
5
12
  import { WebXRController } from "../webxr/WebXRController.js";
6
13
  import { AnimationContext } from "./Animation.js";
7
14
  import Renderer from "./Renderer.js";
@@ -13,6 +20,39 @@ export interface XRManagerEventMap {
13
20
  data: XRFrame;
14
21
  };
15
22
  }
23
+ export interface XRQuadLayerObject {
24
+ type: "quad";
25
+ width: number;
26
+ height: number;
27
+ translation: Vector3;
28
+ quaternion: Quaternion;
29
+ pixelwidth: number;
30
+ pixelheight: number;
31
+ plane: Mesh;
32
+ material: Material;
33
+ rendercall: () => void;
34
+ renderTarget: XRRenderTarget;
35
+ xrlayer?: XRLayer;
36
+ }
37
+ export interface XRCylinderLayerObject {
38
+ type: "cylinder";
39
+ radius: number;
40
+ centralAngle: number;
41
+ aspectratio: number;
42
+ translation: Vector3;
43
+ quaternion: Quaternion;
44
+ pixelwidth: number;
45
+ pixelheight: number;
46
+ plane: Mesh;
47
+ material: Material;
48
+ rendercall: () => void;
49
+ renderTarget: XRRenderTarget;
50
+ xrlayer?: XRLayer;
51
+ }
52
+ export type XRLayerObject = XRQuadLayerObject | XRCylinderLayerObject;
53
+ export interface LayerAttributes {
54
+ stencil?: boolean | undefined;
55
+ }
16
56
  /**
17
57
  * The XR manager is built on top of the WebXR Device API to
18
58
  * manage XR sessions with `WebGPURenderer`.
@@ -35,6 +75,10 @@ declare class XRManager extends EventDispatcher<XRManagerEventMap> {
35
75
  _controllers: WebXRController[];
36
76
  _controllerInputSources: (XRInputSource | null)[];
37
77
  _xrRenderTarget: XRRenderTarget | null;
78
+ _layers: XRLayerObject[];
79
+ _supportsLayers: boolean;
80
+ _createXRLayer: (layer: XRLayerObject) => XRLayer;
81
+ _gl: WebGL2RenderingContext | null;
38
82
  _currentAnimationContext: AnimationContext | null;
39
83
  _currentAnimationLoop: ((time: DOMHighResTimeStamp, frame?: XRFrame) => void) | null;
40
84
  _currentPixelRatio: number | null;
@@ -54,12 +98,15 @@ declare class XRManager extends EventDispatcher<XRManagerEventMap> {
54
98
  _glProjLayer: XRProjectionLayer | null;
55
99
  _xrFrame: XRFrame | null;
56
100
  _useLayers: boolean;
101
+ _useMultiviewIfPossible: boolean;
102
+ _useMultiview: boolean;
57
103
  /**
58
104
  * Constructs a new XR manager.
59
105
  *
60
106
  * @param {Renderer} renderer - The renderer.
107
+ * @param {boolean} [multiview=false] - Enables multiview if the device supports it.
61
108
  */
62
- constructor(renderer: Renderer);
109
+ constructor(renderer: Renderer, multiview?: boolean);
63
110
  /**
64
111
  * Returns an instance of `THREE.Group` that represents the transformation
65
112
  * of a XR controller in target ray space. The requested controller is defined
@@ -117,7 +164,7 @@ declare class XRManager extends EventDispatcher<XRManagerEventMap> {
117
164
  /**
118
165
  * Returns the reference space type.
119
166
  *
120
- * @return {string} The reference space type.
167
+ * @return {XRReferenceSpaceType} The reference space type.
121
168
  */
122
169
  getReferenceSpaceType(): XRReferenceSpaceType;
123
170
  /**
@@ -125,7 +172,7 @@ declare class XRManager extends EventDispatcher<XRManagerEventMap> {
125
172
  *
126
173
  * This method can not be used during a XR session.
127
174
  *
128
- * @param {string} type - The reference space type.
175
+ * @param {XRReferenceSpaceType} type - The reference space type.
129
176
  */
130
177
  setReferenceSpaceType(type: XRReferenceSpaceType): void;
131
178
  /**
@@ -149,7 +196,7 @@ declare class XRManager extends EventDispatcher<XRManagerEventMap> {
149
196
  /**
150
197
  * Returns the environment blend mode from the current XR session.
151
198
  *
152
- * @return {?('opaque'|'additive'|'alpha-blend')} The environment blend mode. Returns `null` when used outside of a XR session.
199
+ * @return {'opaque'|'additive'|'alpha-blend'|undefined} The environment blend mode. Returns `undefined` when used outside of a XR session.
153
200
  */
154
201
  getEnvironmentBlendMode(): XREnvironmentBlendMode | undefined;
155
202
  /**
@@ -158,6 +205,34 @@ declare class XRManager extends EventDispatcher<XRManagerEventMap> {
158
205
  * @return {?XRFrame} The XR frame. Returns `null` when used outside a XR session.
159
206
  */
160
207
  getFrame(): XRFrame | null;
208
+ /**
209
+ * Returns `true` if the engine renders to a multiview target.
210
+ *
211
+ * @return {boolean} Whether the engine renders to a multiview render target or not.
212
+ */
213
+ useMultiview(): boolean;
214
+ createQuadLayer(
215
+ width: number,
216
+ height: number,
217
+ translation: Vector3,
218
+ quaternion: Quaternion,
219
+ pixelwidth: number,
220
+ pixelheight: number,
221
+ rendercall: () => void,
222
+ attributes?: LayerAttributes,
223
+ ): Mesh<PlaneGeometry, MeshBasicMaterial, import("../../core/Object3D.js").Object3DEventMap>;
224
+ createCylinderLayer(
225
+ radius: number,
226
+ centralAngle: number,
227
+ aspectratio: number,
228
+ translation: Vector3,
229
+ quaternion: Quaternion,
230
+ pixelwidth: number,
231
+ pixelheight: number,
232
+ rendercall: () => void,
233
+ attributes?: LayerAttributes,
234
+ ): Mesh<CylinderGeometry, MeshBasicMaterial, import("../../core/Object3D.js").Object3DEventMap>;
235
+ renderLayers(): void;
161
236
  /**
162
237
  * Returns the current XR session.
163
238
  *
@@ -26,9 +26,9 @@ declare class NodeBuilderState {
26
26
  /**
27
27
  * Constructs a new node builder state.
28
28
  *
29
- * @param {?string} vertexShader - The native vertex shader code.
30
- * @param {?string} fragmentShader - The native fragment shader code.
31
- * @param {?string} computeShader - The native compute shader code.
29
+ * @param {string} vertexShader - The native vertex shader code.
30
+ * @param {string} fragmentShader - The native fragment shader code.
31
+ * @param {string} computeShader - The native compute shader code.
32
32
  * @param {Array<NodeAttribute>} nodeAttributes - An array of node attributes.
33
33
  * @param {Array<BindGroup>} bindings - An array of bind groups.
34
34
  * @param {Array<Node>} updateNodes - An array of nodes that implement their `update()` method.
@@ -5,6 +5,7 @@ import Backend, { BackendParameters } from "../common/Backend.js";
5
5
 
6
6
  export interface WebGPUBackendParameters extends BackendParameters {
7
7
  alpha?: boolean | undefined;
8
+ compatibilityMode?: boolean | undefined;
8
9
  requiredLimits?: Record<string, GPUSize64> | undefined;
9
10
  trackTimestamp?: boolean | undefined;
10
11
  device?: GPUDevice | undefined;
@@ -112,7 +112,7 @@ export enum GPUTextureFormat {
112
112
  // Packed 32-bit formats
113
113
  RGB9E5UFloat = "rgb9e5ufloat",
114
114
  RGB10A2Unorm = "rgb10a2unorm",
115
- RG11B10uFloat = "rgb10a2unorm",
115
+ RG11B10UFloat = "rgb10a2unorm",
116
116
 
117
117
  // 64-bit formats
118
118