@plastic-software/three 0.179.0 → 0.180.1

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 (173) hide show
  1. package/build/three.cjs +167 -107
  2. package/build/three.core.js +112 -20
  3. package/build/three.core.min.js +1 -1
  4. package/build/three.module.js +56 -90
  5. package/build/three.module.min.js +1 -1
  6. package/build/three.tsl.js +30 -5
  7. package/build/three.tsl.min.js +1 -1
  8. package/build/three.webgpu.js +2896 -1048
  9. package/build/three.webgpu.min.js +1 -1
  10. package/build/three.webgpu.nodes.js +2896 -1048
  11. package/build/three.webgpu.nodes.min.js +1 -1
  12. package/examples/jsm/Addons.js +1 -1
  13. package/examples/jsm/controls/ArcballControls.js +7 -7
  14. package/examples/jsm/controls/DragControls.js +6 -56
  15. package/examples/jsm/controls/FirstPersonControls.js +2 -2
  16. package/examples/jsm/controls/PointerLockControls.js +0 -8
  17. package/examples/jsm/exporters/GLTFExporter.js +30 -22
  18. package/examples/jsm/exporters/KTX2Exporter.js +4 -2
  19. package/examples/jsm/exporters/PLYExporter.js +1 -1
  20. package/examples/jsm/libs/ktx-parse.module.js +1 -1
  21. package/examples/jsm/lines/Line2.js +3 -3
  22. package/examples/jsm/lines/LineGeometry.js +1 -1
  23. package/examples/jsm/lines/LineSegments2.js +2 -2
  24. package/examples/jsm/lines/Wireframe.js +2 -2
  25. package/examples/jsm/lines/WireframeGeometry2.js +1 -1
  26. package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
  27. package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
  28. package/examples/jsm/loaders/ColladaLoader.js +1 -1
  29. package/examples/jsm/loaders/EXRLoader.js +5 -5
  30. package/examples/jsm/loaders/GLTFLoader.js +9 -5
  31. package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
  32. package/examples/jsm/loaders/HDRLoader.js +486 -0
  33. package/examples/jsm/loaders/KTX2Loader.js +112 -32
  34. package/examples/jsm/loaders/RGBELoader.js +7 -473
  35. package/examples/jsm/loaders/TTFLoader.js +4 -4
  36. package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
  37. package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
  38. package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
  39. package/examples/jsm/math/ColorSpaces.js +19 -1
  40. package/examples/jsm/math/ConvexHull.js +2 -2
  41. package/examples/jsm/math/Lut.js +2 -2
  42. package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
  43. package/examples/jsm/misc/ProgressiveLightMap.js +1 -1
  44. package/examples/jsm/misc/Volume.js +1 -1
  45. package/examples/jsm/postprocessing/OutlinePass.js +1 -1
  46. package/examples/jsm/postprocessing/SSRPass.js +37 -8
  47. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +1 -1
  48. package/examples/jsm/transpiler/GLSLDecoder.js +22 -19
  49. package/examples/jsm/transpiler/TSLEncoder.js +2 -10
  50. package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
  51. package/examples/jsm/tsl/display/AnamorphicNode.js +27 -4
  52. package/examples/jsm/tsl/display/BloomNode.js +3 -3
  53. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
  54. package/examples/jsm/tsl/display/DepthOfFieldNode.js +439 -90
  55. package/examples/jsm/tsl/display/GTAONode.js +8 -0
  56. package/examples/jsm/tsl/display/GaussianBlurNode.js +47 -35
  57. package/examples/jsm/tsl/display/OutlineNode.js +2 -2
  58. package/examples/jsm/tsl/display/SSRNode.js +180 -65
  59. package/examples/jsm/tsl/display/TRAANode.js +1 -1
  60. package/examples/jsm/tsl/display/boxBlur.js +64 -0
  61. package/examples/jsm/tsl/display/hashBlur.js +15 -18
  62. package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
  63. package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
  64. package/examples/jsm/webxr/OculusHandModel.js +1 -1
  65. package/package.json +1 -1
  66. package/src/Three.Core.js +1 -0
  67. package/src/Three.TSL.js +29 -4
  68. package/src/animation/AnimationClip.js +17 -2
  69. package/src/constants.js +11 -3
  70. package/src/core/BufferGeometry.js +2 -2
  71. package/src/extras/TextureUtils.js +2 -1
  72. package/src/extras/lib/earcut.js +1 -1
  73. package/src/lights/webgpu/ProjectorLight.js +1 -1
  74. package/src/materials/Material.js +12 -0
  75. package/src/materials/MeshDistanceMaterial.js +1 -1
  76. package/src/materials/nodes/PointsNodeMaterial.js +81 -28
  77. package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
  78. package/src/materials/nodes/manager/NodeMaterialObserver.js +1 -1
  79. package/src/math/ColorManagement.js +7 -1
  80. package/src/nodes/Nodes.js +3 -0
  81. package/src/nodes/TSL.js +3 -0
  82. package/src/nodes/accessors/BufferNode.js +1 -1
  83. package/src/nodes/accessors/Camera.js +133 -7
  84. package/src/nodes/accessors/ClippingNode.js +6 -5
  85. package/src/nodes/accessors/CubeTextureNode.js +2 -2
  86. package/src/nodes/accessors/InstanceNode.js +3 -1
  87. package/src/nodes/accessors/Object3DNode.js +1 -1
  88. package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
  89. package/src/nodes/accessors/ReferenceNode.js +1 -1
  90. package/src/nodes/accessors/Texture3DNode.js +13 -0
  91. package/src/nodes/accessors/TextureNode.js +71 -19
  92. package/src/nodes/code/FunctionCallNode.js +19 -0
  93. package/src/nodes/code/FunctionNode.js +23 -0
  94. package/src/nodes/core/AssignNode.js +4 -3
  95. package/src/nodes/core/ContextNode.js +24 -0
  96. package/src/nodes/core/Node.js +16 -20
  97. package/src/nodes/core/NodeBuilder.js +48 -14
  98. package/src/nodes/core/NodeFrame.js +1 -1
  99. package/src/nodes/core/NodeUniform.js +1 -1
  100. package/src/nodes/core/NodeUtils.js +1 -2
  101. package/src/nodes/core/StackNode.js +29 -4
  102. package/src/nodes/core/StructNode.js +5 -5
  103. package/src/nodes/core/StructTypeNode.js +1 -0
  104. package/src/nodes/core/SubBuildNode.js +2 -2
  105. package/src/nodes/core/UniformNode.js +16 -9
  106. package/src/nodes/core/VarNode.js +0 -21
  107. package/src/nodes/display/FrontFacingNode.js +4 -8
  108. package/src/nodes/display/PassNode.js +1 -1
  109. package/src/nodes/display/ScreenNode.js +42 -13
  110. package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
  111. package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
  112. package/src/nodes/display/ViewportTextureNode.js +42 -12
  113. package/src/nodes/gpgpu/SubgroupFunctionNode.js +430 -0
  114. package/src/nodes/lighting/LightsNode.js +1 -1
  115. package/src/nodes/math/BitcastNode.js +156 -0
  116. package/src/nodes/math/ConditionalNode.js +18 -2
  117. package/src/nodes/math/MathNode.js +3 -15
  118. package/src/nodes/math/OperatorNode.js +4 -3
  119. package/src/nodes/tsl/TSLCore.js +432 -152
  120. package/src/nodes/utils/JoinNode.js +3 -1
  121. package/src/nodes/utils/MemberNode.js +58 -7
  122. package/src/nodes/utils/RTTNode.js +1 -1
  123. package/src/nodes/utils/ReflectorNode.js +51 -7
  124. package/src/nodes/utils/SampleNode.js +12 -2
  125. package/src/nodes/utils/SplitNode.js +11 -0
  126. package/src/nodes/utils/Timer.js +0 -47
  127. package/src/objects/BatchedMesh.js +2 -2
  128. package/src/objects/LOD.js +1 -1
  129. package/src/objects/Sprite.js +2 -2
  130. package/src/renderers/WebGLRenderer.js +1 -10
  131. package/src/renderers/common/Attributes.js +1 -1
  132. package/src/renderers/common/Backend.js +19 -1
  133. package/src/renderers/common/Bindings.js +2 -0
  134. package/src/renderers/common/ChainMap.js +1 -1
  135. package/src/renderers/common/DataMap.js +1 -1
  136. package/src/renderers/common/Pipelines.js +1 -1
  137. package/src/renderers/common/RenderContext.js +2 -2
  138. package/src/renderers/common/RenderObject.js +14 -2
  139. package/src/renderers/common/Renderer.js +39 -19
  140. package/src/renderers/common/SampledTexture.js +1 -1
  141. package/src/renderers/common/Sampler.js +25 -13
  142. package/src/renderers/common/Textures.js +34 -12
  143. package/src/renderers/common/TimestampQueryPool.js +3 -3
  144. package/src/renderers/common/XRManager.js +35 -19
  145. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  146. package/src/renderers/common/nodes/NodeLibrary.js +5 -5
  147. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
  148. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  149. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
  150. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
  151. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -15
  152. package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -1
  153. package/src/renderers/webgl/WebGLProgram.js +4 -4
  154. package/src/renderers/webgl/WebGLShadowMap.js +1 -1
  155. package/src/renderers/webgl/WebGLTextures.js +1 -0
  156. package/src/renderers/webgl/WebGLUtils.js +3 -2
  157. package/src/renderers/webgl-fallback/WebGLBackend.js +186 -135
  158. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +110 -17
  159. package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -1
  160. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -3
  161. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -10
  162. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
  163. package/src/renderers/webgpu/WebGPUBackend.js +35 -31
  164. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +124 -34
  165. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -2
  166. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +9 -18
  167. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +114 -25
  168. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +3 -3
  169. package/src/renderers/webxr/WebXRManager.js +39 -24
  170. package/src/textures/ExternalTexture.js +15 -4
  171. package/src/textures/Source.js +1 -1
  172. package/src/textures/VideoTexture.js +0 -3
  173. package/examples/jsm/loaders/RGBMLoader.js +0 -1148
@@ -95,7 +95,9 @@ class JoinNode extends TempNode {
95
95
 
96
96
  if ( inputPrimitiveType !== primitiveType ) {
97
97
 
98
- inputSnippet = builder.format( inputSnippet, inputPrimitiveType, primitiveType );
98
+ const targetType = builder.getTypeFromLength( inputTypeLength, primitiveType );
99
+
100
+ inputSnippet = builder.format( inputSnippet, inputType, targetType );
99
101
 
100
102
  }
101
103
 
@@ -15,21 +15,21 @@ class MemberNode extends Node {
15
15
  }
16
16
 
17
17
  /**
18
- * Constructs an array element node.
18
+ * Constructs a member node.
19
19
  *
20
- * @param {Node} node - The array-like node.
20
+ * @param {Node} structNode - The struct node.
21
21
  * @param {string} property - The property name.
22
22
  */
23
- constructor( node, property ) {
23
+ constructor( structNode, property ) {
24
24
 
25
25
  super();
26
26
 
27
27
  /**
28
- * The array-like node.
28
+ * The struct node.
29
29
  *
30
30
  * @type {Node}
31
31
  */
32
- this.node = node;
32
+ this.structNode = structNode;
33
33
 
34
34
  /**
35
35
  * The property name.
@@ -49,15 +49,66 @@ class MemberNode extends Node {
49
49
 
50
50
  }
51
51
 
52
+ hasMember( builder ) {
53
+
54
+ if ( this.structNode.isMemberNode ) {
55
+
56
+ if ( this.structNode.hasMember( builder ) === false ) {
57
+
58
+ return false;
59
+
60
+ }
61
+
62
+ }
63
+
64
+ return this.structNode.getMemberType( builder, this.property ) !== 'void';
65
+
66
+ }
67
+
52
68
  getNodeType( builder ) {
53
69
 
54
- return this.node.getMemberType( builder, this.property );
70
+ if ( this.hasMember( builder ) === false ) {
71
+
72
+ // default type if member does not exist
73
+
74
+ return 'float';
75
+
76
+ }
77
+
78
+ return this.structNode.getMemberType( builder, this.property );
79
+
80
+ }
81
+
82
+ getMemberType( builder, name ) {
83
+
84
+ if ( this.hasMember( builder ) === false ) {
85
+
86
+ // default type if member does not exist
87
+
88
+ return 'float';
89
+
90
+ }
91
+
92
+ const type = this.getNodeType( builder );
93
+ const struct = builder.getStructTypeNode( type );
94
+
95
+ return struct.getMemberType( builder, name );
55
96
 
56
97
  }
57
98
 
58
99
  generate( builder ) {
59
100
 
60
- const propertyName = this.node.build( builder );
101
+ if ( this.hasMember( builder ) === false ) {
102
+
103
+ console.warn( `THREE.TSL: Member "${ this.property }" does not exist in struct.` );
104
+
105
+ const type = this.getNodeType( builder );
106
+
107
+ return builder.generateConst( type );
108
+
109
+ }
110
+
111
+ const propertyName = this.structNode.build( builder );
61
112
 
62
113
  return propertyName + '.' + this.property;
63
114
 
@@ -271,7 +271,7 @@ export const rtt = ( node, ...params ) => nodeObject( new RTTNode( nodeObject( n
271
271
  */
272
272
  export const convertToTexture = ( node, ...params ) => {
273
273
 
274
- if ( node.isTextureNode ) return node;
274
+ if ( node.isSampleNode || node.isTextureNode ) return node;
275
275
  if ( node.isPassNode ) return node.getTextureNode();
276
276
 
277
277
  return rtt( node, ...params );
@@ -13,6 +13,7 @@ import { Vector4 } from '../../math/Vector4.js';
13
13
  import { Matrix4 } from '../../math/Matrix4.js';
14
14
  import { RenderTarget } from '../../core/RenderTarget.js';
15
15
  import { DepthTexture } from '../../textures/DepthTexture.js';
16
+ import { warnOnce } from '../../utils.js';
16
17
 
17
18
  const _reflectorPlane = new Plane();
18
19
  const _normal = new Vector3();
@@ -61,10 +62,11 @@ class ReflectorNode extends TextureNode {
61
62
  *
62
63
  * @param {Object} [parameters={}] - An object holding configuration parameters.
63
64
  * @param {Object3D} [parameters.target=new Object3D()] - The 3D object the reflector is linked to.
64
- * @param {number} [parameters.resolution=1] - The resolution scale.
65
+ * @param {number} [parameters.resolutionScale=1] - The resolution scale.
65
66
  * @param {boolean} [parameters.generateMipmaps=false] - Whether mipmaps should be generated or not.
66
67
  * @param {boolean} [parameters.bounces=true] - Whether reflectors can render other reflector nodes or not.
67
68
  * @param {boolean} [parameters.depth=false] - Whether depth data should be generated or not.
69
+ * @param {number} [parameters.samples] - Anti-Aliasing samples of the internal render-target.
68
70
  * @param {TextureNode} [parameters.defaultTexture] - The default texture node.
69
71
  * @param {ReflectorBaseNode} [parameters.reflector] - The reflector base node.
70
72
  */
@@ -204,10 +206,11 @@ class ReflectorBaseNode extends Node {
204
206
  * @param {TextureNode} textureNode - Represents the rendered reflections as a texture node.
205
207
  * @param {Object} [parameters={}] - An object holding configuration parameters.
206
208
  * @param {Object3D} [parameters.target=new Object3D()] - The 3D object the reflector is linked to.
207
- * @param {number} [parameters.resolution=1] - The resolution scale.
209
+ * @param {number} [parameters.resolutionScale=1] - The resolution scale.
208
210
  * @param {boolean} [parameters.generateMipmaps=false] - Whether mipmaps should be generated or not.
209
211
  * @param {boolean} [parameters.bounces=true] - Whether reflectors can render other reflector nodes or not.
210
212
  * @param {boolean} [parameters.depth=false] - Whether depth data should be generated or not.
213
+ * @param {number} [parameters.samples] - Anti-Aliasing samples of the internal render-target.
211
214
  */
212
215
  constructor( textureNode, parameters = {} ) {
213
216
 
@@ -215,10 +218,11 @@ class ReflectorBaseNode extends Node {
215
218
 
216
219
  const {
217
220
  target = new Object3D(),
218
- resolution = 1,
221
+ resolutionScale = 1,
219
222
  generateMipmaps = false,
220
223
  bounces = true,
221
- depth = false
224
+ depth = false,
225
+ samples = 0
222
226
  } = parameters;
223
227
 
224
228
  /**
@@ -242,7 +246,15 @@ class ReflectorBaseNode extends Node {
242
246
  * @type {number}
243
247
  * @default {1}
244
248
  */
245
- this.resolution = resolution;
249
+ this.resolutionScale = resolutionScale;
250
+
251
+ if ( parameters.resolution !== undefined ) {
252
+
253
+ warnOnce( 'THREE.ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".' ); // @deprecated r180
254
+
255
+ this.resolutionScale = parameters.resolution;
256
+
257
+ }
246
258
 
247
259
  /**
248
260
  * Whether mipmaps should be generated or not.
@@ -268,6 +280,14 @@ class ReflectorBaseNode extends Node {
268
280
  */
269
281
  this.depth = depth;
270
282
 
283
+ /**
284
+ * The number of anti-aliasing samples for the render-target
285
+ *
286
+ * @type {number}
287
+ * @default {0}
288
+ */
289
+ this.samples = samples;
290
+
271
291
  /**
272
292
  * The `updateBeforeType` is set to `NodeUpdateType.RENDER` when {@link ReflectorBaseNode#bounces}
273
293
  * is `true`. Otherwise it's `NodeUpdateType.FRAME`.
@@ -321,7 +341,7 @@ class ReflectorBaseNode extends Node {
321
341
  */
322
342
  _updateResolution( renderTarget, renderer ) {
323
343
 
324
- const resolution = this.resolution;
344
+ const resolution = this.resolutionScale;
325
345
 
326
346
  renderer.getDrawingBufferSize( _size );
327
347
 
@@ -388,7 +408,7 @@ class ReflectorBaseNode extends Node {
388
408
 
389
409
  if ( renderTarget === undefined ) {
390
410
 
391
- renderTarget = new RenderTarget( 0, 0, { type: HalfFloatType } );
411
+ renderTarget = new RenderTarget( 0, 0, { type: HalfFloatType, samples: this.samples } );
392
412
 
393
413
  if ( this.generateMipmaps === true ) {
394
414
 
@@ -557,6 +577,29 @@ class ReflectorBaseNode extends Node {
557
577
 
558
578
  }
559
579
 
580
+ /**
581
+ * The resolution scale.
582
+ *
583
+ * @deprecated
584
+ * @type {number}
585
+ * @default {1}
586
+ */
587
+ get resolution() {
588
+
589
+ warnOnce( 'THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".' ); // @deprecated r180
590
+
591
+ return this.resolutionScale;
592
+
593
+ }
594
+
595
+ set resolution( value ) {
596
+
597
+ warnOnce( 'THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".' ); // @deprecated r180
598
+
599
+ this.resolutionScale = value;
600
+
601
+ }
602
+
560
603
  }
561
604
 
562
605
  /**
@@ -570,6 +613,7 @@ class ReflectorBaseNode extends Node {
570
613
  * @param {boolean} [parameters.generateMipmaps=false] - Whether mipmaps should be generated or not.
571
614
  * @param {boolean} [parameters.bounces=true] - Whether reflectors can render other reflector nodes or not.
572
615
  * @param {boolean} [parameters.depth=false] - Whether depth data should be generated or not.
616
+ * @param {number} [parameters.samples] - Anti-Aliasing samples of the internal render-target.
573
617
  * @param {TextureNode} [parameters.defaultTexture] - The default texture node.
574
618
  * @param {ReflectorBaseNode} [parameters.reflector] - The reflector base node.
575
619
  * @returns {ReflectorNode}
@@ -26,13 +26,22 @@ class SampleNode extends Node {
26
26
  * Creates an instance of SampleNode.
27
27
  *
28
28
  * @param {Function} callback - The function to be called when sampling. Should accept a UV node and return a value.
29
+ * @param {?Node<vec2>} [uvNode=null] - The UV node to be used in the texture sampling.
29
30
  */
30
- constructor( callback ) {
31
+ constructor( callback, uvNode = null ) {
31
32
 
32
33
  super();
33
34
 
34
35
  this.callback = callback;
35
36
 
37
+ /**
38
+ * Represents the texture coordinates.
39
+ *
40
+ * @type {?Node<vec2|vec3>}
41
+ * @default null
42
+ */
43
+ this.uvNode = uvNode;
44
+
36
45
  /**
37
46
  * This flag can be used for type testing.
38
47
  *
@@ -76,6 +85,7 @@ export default SampleNode;
76
85
  *
77
86
  * @function
78
87
  * @param {Function} callback - The function to be called when sampling. Should accept a UV node and return a value.
88
+ * @param {?Node<vec2>} [uv=null] - The UV node to be used in the texture sampling.
79
89
  * @returns {SampleNode} The created SampleNode instance wrapped as a node object.
80
90
  */
81
- export const sample = ( callback ) => nodeObject( new SampleNode( callback ) );
91
+ export const sample = ( callback, uv = null ) => nodeObject( new SampleNode( callback, nodeObject( uv ) ) );
@@ -100,6 +100,17 @@ class SplitNode extends Node {
100
100
 
101
101
  }
102
102
 
103
+ /**
104
+ * Returns the scope of the node.
105
+ *
106
+ * @return {Node} The scope of the node.
107
+ */
108
+ getScope() {
109
+
110
+ return this.node.getScope();
111
+
112
+ }
113
+
103
114
  generate( builder, output ) {
104
115
 
105
116
  const node = this.node;
@@ -24,50 +24,3 @@ export const deltaTime = /*@__PURE__*/ uniform( 0 ).setGroup( renderGroup ).onRe
24
24
  * @type {UniformNode<uint>}
25
25
  */
26
26
  export const frameId = /*@__PURE__*/ uniform( 0, 'uint' ).setGroup( renderGroup ).onRenderUpdate( ( frame ) => frame.frameId );
27
-
28
- // Deprecated
29
-
30
- /**
31
- * @tsl
32
- * @function
33
- * @deprecated since r170. Use {@link time} instead.
34
- *
35
- * @param {number} [timeScale=1] - The time scale.
36
- * @returns {UniformNode<float>}
37
- */
38
- export const timerLocal = ( timeScale = 1 ) => { // @deprecated, r170
39
-
40
- console.warn( 'TSL: timerLocal() is deprecated. Use "time" instead.' );
41
- return time.mul( timeScale );
42
-
43
- };
44
-
45
- /**
46
- * @tsl
47
- * @function
48
- * @deprecated since r170. Use {@link time} instead.
49
- *
50
- * @param {number} [timeScale=1] - The time scale.
51
- * @returns {UniformNode<float>}
52
- */
53
- export const timerGlobal = ( timeScale = 1 ) => { // @deprecated, r170
54
-
55
- console.warn( 'TSL: timerGlobal() is deprecated. Use "time" instead.' );
56
- return time.mul( timeScale );
57
-
58
- };
59
-
60
- /**
61
- * @tsl
62
- * @function
63
- * @deprecated since r170. Use {@link deltaTime} instead.
64
- *
65
- * @param {number} [timeScale=1] - The time scale.
66
- * @returns {UniformNode<float>}
67
- */
68
- export const timerDelta = ( timeScale = 1 ) => { // @deprecated, r170
69
-
70
- console.warn( 'TSL: timerDelta() is deprecated. Use "deltaTime" instead.' );
71
- return deltaTime.mul( timeScale );
72
-
73
- };
@@ -971,7 +971,7 @@ class BatchedMesh extends Mesh {
971
971
  *
972
972
  * @param {number} geometryId - The ID of the geometry to return the bounding box for.
973
973
  * @param {Box3} target - The target object that is used to store the method's result.
974
- * @return {Box3|null} The geometry's bounding box. Returns `null` if no geometry has been found for the given ID.
974
+ * @return {?Box3} The geometry's bounding box. Returns `null` if no geometry has been found for the given ID.
975
975
  */
976
976
  getBoundingBoxAt( geometryId, target ) {
977
977
 
@@ -1016,7 +1016,7 @@ class BatchedMesh extends Mesh {
1016
1016
  *
1017
1017
  * @param {number} geometryId - The ID of the geometry to return the bounding sphere for.
1018
1018
  * @param {Sphere} target - The target object that is used to store the method's result.
1019
- * @return {Sphere|null} The geometry's bounding sphere. Returns `null` if no geometry has been found for the given ID.
1019
+ * @return {?Sphere} The geometry's bounding sphere. Returns `null` if no geometry has been found for the given ID.
1020
1020
  */
1021
1021
  getBoundingSphereAt( geometryId, target ) {
1022
1022
 
@@ -183,7 +183,7 @@ class LOD extends Object3D {
183
183
  * the given distance.
184
184
  *
185
185
  * @param {number} distance - The LOD distance.
186
- * @return {Object3D|null} The found 3D object. `null` if no 3D object has been found.
186
+ * @return {?Object3D} The found 3D object. `null` if no 3D object has been found.
187
187
  */
188
188
  getObjectForDistance( distance ) {
189
189
 
@@ -48,7 +48,7 @@ class Sprite extends Object3D {
48
48
  /**
49
49
  * Constructs a new sprite.
50
50
  *
51
- * @param {SpriteMaterial} [material] - The sprite material.
51
+ * @param {(SpriteMaterial|SpriteNodeMaterial)} [material] - The sprite material.
52
52
  */
53
53
  constructor( material = new SpriteMaterial() ) {
54
54
 
@@ -94,7 +94,7 @@ class Sprite extends Object3D {
94
94
  /**
95
95
  * The sprite material.
96
96
  *
97
- * @type {SpriteMaterial}
97
+ * @type {(SpriteMaterial|SpriteNodeMaterial)}
98
98
  */
99
99
  this.material = material;
100
100
 
@@ -1096,7 +1096,7 @@ class WebGLRenderer {
1096
1096
 
1097
1097
  if ( scene === null ) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)
1098
1098
 
1099
- const frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 );
1099
+ const frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 ) || ( object.isBatchedMesh && object._frontFaceCW );
1100
1100
 
1101
1101
  const program = setProgram( camera, scene, geometry, material, object );
1102
1102
 
@@ -3314,15 +3314,6 @@ class WebGLRenderer {
3314
3314
 
3315
3315
  };
3316
3316
 
3317
- this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
3318
-
3319
- // @deprecated, r170
3320
- warnOnce( 'WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.' );
3321
-
3322
- return this.copyTextureToTexture( srcTexture, dstTexture, srcRegion, dstPosition, level );
3323
-
3324
- };
3325
-
3326
3317
  /**
3327
3318
  * Initializes the given WebGLRenderTarget memory. Useful for initializing a render target so data
3328
3319
  * can be copied into it using {@link WebGLRenderer#copyTextureToTexture} before it has been
@@ -33,7 +33,7 @@ class Attributes extends DataMap {
33
33
  * Deletes the data for the given attribute.
34
34
  *
35
35
  * @param {BufferAttribute} attribute - The attribute.
36
- * @return {Object|null} The deleted attribute data.
36
+ * @return {?Object} The deleted attribute data.
37
37
  */
38
38
  delete( attribute ) {
39
39
 
@@ -38,7 +38,7 @@ class Backend {
38
38
  * This weak map holds backend-specific data of objects
39
39
  * like textures, attributes or render targets.
40
40
  *
41
- * @type {WeakMap}
41
+ * @type {WeakMap<Object, Object>}
42
42
  */
43
43
  this.data = new WeakMap();
44
44
 
@@ -439,6 +439,24 @@ class Backend {
439
439
 
440
440
  // utils
441
441
 
442
+ /**
443
+ * Returns a unique identifier for the given render context that can be used
444
+ * to allocate resources like occlusion queries or timestamp queries.
445
+ *
446
+ * @param {RenderContext|ComputeNode} abstractRenderContext - The render context.
447
+ * @return {string} The unique identifier.
448
+ */
449
+ getTimestampUID( abstractRenderContext ) {
450
+
451
+ const contextData = this.get( abstractRenderContext );
452
+
453
+ let uid = abstractRenderContext.isComputeNode === true ? 'c' : 'r';
454
+ uid += ':' + contextData.frameCalls + ':' + abstractRenderContext.id;
455
+
456
+ return uid;
457
+
458
+ }
459
+
442
460
  /**
443
461
  * Returns `true` if the given 3D object is fully occluded by other
444
462
  * 3D objects in the scene. Backends must implement this method by using
@@ -267,6 +267,8 @@ class Bindings extends DataMap {
267
267
 
268
268
  needsBindingsUpdate = true;
269
269
 
270
+ cacheBindings = false;
271
+
270
272
  }
271
273
 
272
274
  }
@@ -16,7 +16,7 @@ class ChainMap {
16
16
  /**
17
17
  * The root Weak Map.
18
18
  *
19
- * @type {WeakMap}
19
+ * @type {WeakMap<Object, WeakMap>}
20
20
  */
21
21
  this.weakMap = new WeakMap();
22
22
 
@@ -15,7 +15,7 @@ class DataMap {
15
15
  * `DataMap` internally uses a weak map
16
16
  * to manage its data.
17
17
  *
18
- * @type {WeakMap}
18
+ * @type {WeakMap<Object, Object>}
19
19
  */
20
20
  this.data = new WeakMap();
21
21
 
@@ -58,7 +58,7 @@ class Pipelines extends DataMap {
58
58
  * fragment and compute) the programmable stage objects which
59
59
  * represent the actual shader code.
60
60
  *
61
- * @type {Object<string,Map>}
61
+ * @type {Object<string,Map<string, ProgrammableStage>>}
62
62
  */
63
63
  this.programs = {
64
64
  vertex: new Map(),
@@ -248,9 +248,9 @@ class RenderContext {
248
248
  */
249
249
  export function getCacheKey( renderContext ) {
250
250
 
251
- const { textures, activeCubeFace } = renderContext;
251
+ const { textures, activeCubeFace, activeMipmapLevel } = renderContext;
252
252
 
253
- const values = [ activeCubeFace ];
253
+ const values = [ activeCubeFace, activeMipmapLevel ];
254
254
 
255
255
  for ( const texture of textures ) {
256
256
 
@@ -682,7 +682,7 @@ class RenderObject {
682
682
  */
683
683
  getMaterialCacheKey() {
684
684
 
685
- const { object, material } = this;
685
+ const { object, material, renderer } = this;
686
686
 
687
687
  let cacheKey = material.customProgramCacheKey();
688
688
 
@@ -712,6 +712,18 @@ class RenderObject {
712
712
 
713
713
  valueKey += value.mapping;
714
714
 
715
+ // WebGPU must honor the sampler data because they are part of the bindings
716
+
717
+ if ( renderer.backend.isWebGPUBackend === true ) {
718
+
719
+ valueKey += value.magFilter;
720
+ valueKey += value.minFilter;
721
+ valueKey += value.wrapS;
722
+ valueKey += value.wrapT;
723
+ valueKey += value.wrapR;
724
+
725
+ }
726
+
715
727
  }
716
728
 
717
729
  valueKey += '}';
@@ -758,7 +770,7 @@ class RenderObject {
758
770
 
759
771
  }
760
772
 
761
- if ( object.count > 1 ) {
773
+ if ( object.isInstancedMesh || object.count > 1 ) {
762
774
 
763
775
  // TODO: https://github.com/mrdoob/three.js/pull/29066#issuecomment-2269400850
764
776
 
@@ -1450,8 +1450,8 @@ class Renderer {
1450
1450
 
1451
1451
  renderContext.textures = null;
1452
1452
  renderContext.depthTexture = null;
1453
- renderContext.width = this.domElement.width;
1454
- renderContext.height = this.domElement.height;
1453
+ renderContext.width = _drawingBufferSize.width;
1454
+ renderContext.height = _drawingBufferSize.height;
1455
1455
  renderContext.depth = this.depth;
1456
1456
  renderContext.stencil = this.stencil;
1457
1457
 
@@ -1465,6 +1465,22 @@ class Renderer {
1465
1465
 
1466
1466
  //
1467
1467
 
1468
+ renderContext.scissorValue.max( _vector4.set( 0, 0, 0, 0 ) );
1469
+
1470
+ if ( renderContext.scissorValue.x + renderContext.scissorValue.width > renderContext.width ) {
1471
+
1472
+ renderContext.scissorValue.width = Math.max( renderContext.width - renderContext.scissorValue.x, 0 );
1473
+
1474
+ }
1475
+
1476
+ if ( renderContext.scissorValue.y + renderContext.scissorValue.height > renderContext.height ) {
1477
+
1478
+ renderContext.scissorValue.height = Math.max( renderContext.height - renderContext.scissorValue.y, 0 );
1479
+
1480
+ }
1481
+
1482
+ //
1483
+
1468
1484
  this._background.update( sceneRef, renderList, renderContext );
1469
1485
 
1470
1486
  //
@@ -2171,25 +2187,29 @@ class Renderer {
2171
2187
  */
2172
2188
  dispose() {
2173
2189
 
2174
- this.info.dispose();
2175
- this.backend.dispose();
2190
+ if ( this._initialized === true ) {
2176
2191
 
2177
- this._animation.dispose();
2178
- this._objects.dispose();
2179
- this._pipelines.dispose();
2180
- this._nodes.dispose();
2181
- this._bindings.dispose();
2182
- this._renderLists.dispose();
2183
- this._renderContexts.dispose();
2184
- this._textures.dispose();
2192
+ this.info.dispose();
2193
+ this.backend.dispose();
2185
2194
 
2186
- if ( this._frameBufferTarget !== null ) this._frameBufferTarget.dispose();
2195
+ this._animation.dispose();
2196
+ this._objects.dispose();
2197
+ this._pipelines.dispose();
2198
+ this._nodes.dispose();
2199
+ this._bindings.dispose();
2200
+ this._renderLists.dispose();
2201
+ this._renderContexts.dispose();
2202
+ this._textures.dispose();
2187
2203
 
2188
- Object.values( this.backend.timestampQueryPool ).forEach( queryPool => {
2204
+ if ( this._frameBufferTarget !== null ) this._frameBufferTarget.dispose();
2189
2205
 
2190
- if ( queryPool !== null ) queryPool.dispose();
2206
+ Object.values( this.backend.timestampQueryPool ).forEach( queryPool => {
2191
2207
 
2192
- } );
2208
+ if ( queryPool !== null ) queryPool.dispose();
2209
+
2210
+ } );
2211
+
2212
+ }
2193
2213
 
2194
2214
  this.setRenderTarget( null );
2195
2215
  this.setAnimationLoop( null );
@@ -2309,7 +2329,7 @@ class Renderer {
2309
2329
  * if the renderer has been initialized.
2310
2330
  *
2311
2331
  * @param {Node|Array<Node>} computeNodes - The compute node(s).
2312
- * @param {Array<number>|number} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
2332
+ * @param {?(Array<number>|number)} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
2313
2333
  * @return {Promise|undefined} A Promise that resolve when the compute has finished. Only returned when the renderer has not been initialized.
2314
2334
  */
2315
2335
  compute( computeNodes, dispatchSizeOrCount = null ) {
@@ -2408,7 +2428,7 @@ class Renderer {
2408
2428
  *
2409
2429
  * @async
2410
2430
  * @param {Node|Array<Node>} computeNodes - The compute node(s).
2411
- * @param {Array<number>|number} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
2431
+ * @param {?(Array<number>|number)} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
2412
2432
  * @return {Promise} A Promise that resolve when the compute has finished.
2413
2433
  */
2414
2434
  async computeAsync( computeNodes, dispatchSizeOrCount = null ) {
@@ -2514,7 +2534,7 @@ class Renderer {
2514
2534
  * Copies the current bound framebuffer into the given texture.
2515
2535
  *
2516
2536
  * @param {FramebufferTexture} framebufferTexture - The texture.
2517
- * @param {?Vector2|Vector4} [rectangle=null] - A two or four dimensional vector that defines the rectangular portion of the framebuffer that should be copied.
2537
+ * @param {?(Vector2|Vector4)} [rectangle=null] - A two or four dimensional vector that defines the rectangular portion of the framebuffer that should be copied.
2518
2538
  */
2519
2539
  copyFramebufferToTexture( framebufferTexture, rectangle = null ) {
2520
2540
 
@@ -6,7 +6,7 @@ let _id = 0;
6
6
  * Represents a sampled texture binding type.
7
7
  *
8
8
  * @private
9
- * @augments Binding
9
+ * @augments Sampler
10
10
  */
11
11
  class SampledTexture extends Sampler {
12
12