@plastic-software/three 0.178.0 → 0.179.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 (141) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +856 -196
  3. package/build/three.core.js +647 -123
  4. package/build/three.core.min.js +1 -1
  5. package/build/three.module.js +211 -76
  6. package/build/three.module.min.js +1 -1
  7. package/build/three.tsl.js +70 -21
  8. package/build/three.tsl.min.js +1 -1
  9. package/build/three.webgpu.js +1796 -557
  10. package/build/three.webgpu.min.js +1 -1
  11. package/build/three.webgpu.nodes.js +1754 -557
  12. package/build/three.webgpu.nodes.min.js +1 -1
  13. package/examples/jsm/Addons.js +1 -2
  14. package/examples/jsm/capabilities/WebGPU.js +1 -1
  15. package/examples/jsm/csm/CSMShadowNode.js +4 -4
  16. package/examples/jsm/environments/RoomEnvironment.js +8 -3
  17. package/examples/jsm/exporters/USDZExporter.js +676 -299
  18. package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
  19. package/examples/jsm/interactive/HTMLMesh.js +5 -3
  20. package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
  21. package/examples/jsm/lights/LightProbeGenerator.js +14 -3
  22. package/examples/jsm/loaders/EXRLoader.js +210 -22
  23. package/examples/jsm/loaders/FBXLoader.js +1 -1
  24. package/examples/jsm/loaders/MaterialXLoader.js +212 -30
  25. package/examples/jsm/loaders/TTFLoader.js +13 -1
  26. package/examples/jsm/loaders/USDLoader.js +219 -0
  27. package/examples/jsm/loaders/USDZLoader.js +4 -892
  28. package/examples/jsm/loaders/usd/USDAParser.js +741 -0
  29. package/examples/jsm/loaders/usd/USDCParser.js +17 -0
  30. package/examples/jsm/objects/LensflareMesh.js +3 -3
  31. package/examples/jsm/objects/SkyMesh.js +2 -2
  32. package/examples/jsm/physics/RapierPhysics.js +14 -5
  33. package/examples/jsm/postprocessing/GTAOPass.js +10 -9
  34. package/examples/jsm/postprocessing/OutlinePass.js +17 -17
  35. package/examples/jsm/postprocessing/SSAOPass.js +10 -9
  36. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
  37. package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
  38. package/examples/jsm/tsl/display/BloomNode.js +8 -7
  39. package/examples/jsm/tsl/display/GaussianBlurNode.js +6 -8
  40. package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
  41. package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
  42. package/package.json +1 -1
  43. package/src/Three.Core.js +1 -0
  44. package/src/Three.TSL.js +69 -20
  45. package/src/animation/KeyframeTrack.js +1 -1
  46. package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
  47. package/src/animation/tracks/StringKeyframeTrack.js +1 -1
  48. package/src/cameras/Camera.js +14 -0
  49. package/src/cameras/OrthographicCamera.js +1 -1
  50. package/src/cameras/PerspectiveCamera.js +1 -1
  51. package/src/constants.js +1 -1
  52. package/{examples/jsm/misc → src/core}/Timer.js +4 -42
  53. package/src/extras/PMREMGenerator.js +11 -0
  54. package/src/helpers/CameraHelper.js +41 -11
  55. package/src/helpers/SkeletonHelper.js +35 -6
  56. package/src/lights/LightShadow.js +21 -8
  57. package/src/lights/PointLightShadow.js +1 -1
  58. package/src/loaders/FileLoader.js +25 -2
  59. package/src/loaders/ImageBitmapLoader.js +23 -0
  60. package/src/loaders/Loader.js +14 -0
  61. package/src/loaders/LoadingManager.js +23 -0
  62. package/src/materials/MeshBasicMaterial.js +1 -1
  63. package/src/materials/nodes/Line2NodeMaterial.js +0 -8
  64. package/src/materials/nodes/NodeMaterial.js +1 -1
  65. package/src/materials/nodes/PointsNodeMaterial.js +5 -0
  66. package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
  67. package/src/math/Frustum.js +19 -8
  68. package/src/math/FrustumArray.js +10 -5
  69. package/src/math/Line3.js +129 -2
  70. package/src/math/Matrix4.js +48 -27
  71. package/src/math/Spherical.js +2 -2
  72. package/src/nodes/Nodes.js +1 -0
  73. package/src/nodes/TSL.js +1 -0
  74. package/src/nodes/accessors/Camera.js +12 -12
  75. package/src/nodes/accessors/Normal.js +11 -11
  76. package/src/nodes/accessors/ReferenceNode.js +18 -3
  77. package/src/nodes/accessors/SceneNode.js +1 -1
  78. package/src/nodes/accessors/StorageTextureNode.js +1 -1
  79. package/src/nodes/accessors/TextureNode.js +12 -0
  80. package/src/nodes/core/ArrayNode.js +12 -0
  81. package/src/nodes/core/AssignNode.js +3 -0
  82. package/src/nodes/core/ContextNode.js +20 -1
  83. package/src/nodes/core/Node.js +14 -2
  84. package/src/nodes/core/NodeBuilder.js +25 -20
  85. package/src/nodes/core/NodeUtils.js +4 -1
  86. package/src/nodes/core/StackNode.js +42 -0
  87. package/src/nodes/core/UniformNode.js +63 -5
  88. package/src/nodes/core/VarNode.js +91 -2
  89. package/src/nodes/display/PassNode.js +148 -2
  90. package/src/nodes/display/ViewportTextureNode.js +67 -7
  91. package/src/nodes/functions/PhysicalLightingModel.js +2 -2
  92. package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
  93. package/src/nodes/gpgpu/ComputeNode.js +67 -23
  94. package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
  95. package/src/nodes/lighting/ProjectorLightNode.js +19 -6
  96. package/src/nodes/lighting/ShadowFilterNode.js +1 -1
  97. package/src/nodes/materialx/MaterialXNodes.js +131 -2
  98. package/src/nodes/materialx/lib/mx_noise.js +165 -1
  99. package/src/nodes/math/ConditionalNode.js +1 -1
  100. package/src/nodes/math/MathNode.js +78 -54
  101. package/src/nodes/math/OperatorNode.js +22 -22
  102. package/src/nodes/tsl/TSLCore.js +64 -9
  103. package/src/nodes/utils/DebugNode.js +1 -1
  104. package/src/nodes/utils/EventNode.js +83 -0
  105. package/src/nodes/utils/RTTNode.js +9 -0
  106. package/src/objects/BatchedMesh.js +4 -2
  107. package/src/renderers/WebGLRenderer.js +21 -22
  108. package/src/renderers/common/Bindings.js +19 -18
  109. package/src/renderers/common/Color4.js +2 -2
  110. package/src/renderers/common/PostProcessing.js +60 -5
  111. package/src/renderers/common/Renderer.js +18 -15
  112. package/src/renderers/common/SampledTexture.js +3 -71
  113. package/src/renderers/common/Sampler.js +79 -0
  114. package/src/renderers/common/Storage3DTexture.js +21 -0
  115. package/src/renderers/common/StorageArrayTexture.js +21 -0
  116. package/src/renderers/common/StorageTexture.js +19 -0
  117. package/src/renderers/common/Textures.js +19 -3
  118. package/src/renderers/common/XRManager.js +26 -8
  119. package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
  120. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
  121. package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
  122. package/src/renderers/webgl/WebGLCapabilities.js +2 -2
  123. package/src/renderers/webgl/WebGLMaterials.js +6 -6
  124. package/src/renderers/webgl/WebGLProgram.js +22 -16
  125. package/src/renderers/webgl/WebGLPrograms.js +4 -4
  126. package/src/renderers/webgl/WebGLShadowMap.js +11 -1
  127. package/src/renderers/webgl/WebGLTextures.js +19 -7
  128. package/src/renderers/webgl-fallback/WebGLBackend.js +22 -12
  129. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +2 -2
  130. package/src/renderers/webgpu/WebGPUBackend.js +54 -15
  131. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +53 -73
  132. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +35 -31
  133. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1 -1
  134. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +11 -64
  135. package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
  136. package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
  137. package/src/renderers/webxr/WebXRManager.js +68 -8
  138. package/src/textures/ExternalTexture.js +45 -0
  139. package/src/textures/FramebufferTexture.js +2 -2
  140. package/src/textures/Source.js +11 -1
  141. package/src/textures/VideoTexture.js +30 -2
package/build/three.cjs CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  'use strict';
7
7
 
8
- const REVISION = '178';
8
+ const REVISION = '179';
9
9
 
10
10
  /**
11
11
  * Represents mouse buttons and interaction types in context of controls.
@@ -6285,38 +6285,6 @@ function probeAsync( gl, sync, interval ) {
6285
6285
 
6286
6286
  }
6287
6287
 
6288
- function toNormalizedProjectionMatrix( projectionMatrix ) {
6289
-
6290
- const m = projectionMatrix.elements;
6291
-
6292
- // Convert [-1, 1] to [0, 1] projection matrix
6293
- m[ 2 ] = 0.5 * m[ 2 ] + 0.5 * m[ 3 ];
6294
- m[ 6 ] = 0.5 * m[ 6 ] + 0.5 * m[ 7 ];
6295
- m[ 10 ] = 0.5 * m[ 10 ] + 0.5 * m[ 11 ];
6296
- m[ 14 ] = 0.5 * m[ 14 ] + 0.5 * m[ 15 ];
6297
-
6298
- }
6299
-
6300
- function toReversedProjectionMatrix( projectionMatrix ) {
6301
-
6302
- const m = projectionMatrix.elements;
6303
- const isPerspectiveMatrix = m[ 11 ] === -1;
6304
-
6305
- // Reverse [0, 1] projection matrix
6306
- if ( isPerspectiveMatrix ) {
6307
-
6308
- m[ 10 ] = - m[ 10 ] - 1;
6309
- m[ 14 ] = - m[ 14 ];
6310
-
6311
- } else {
6312
-
6313
- m[ 10 ] = - m[ 10 ];
6314
- m[ 14 ] = - m[ 14 ] + 1;
6315
-
6316
- }
6317
-
6318
- }
6319
-
6320
6288
  const LINEAR_REC709_TO_XYZ = /*@__PURE__*/ new Matrix3().set(
6321
6289
  0.4123908, 0.3575843, 0.1804808,
6322
6290
  0.2126390, 0.7151687, 0.0721923,
@@ -6728,13 +6696,23 @@ class Source {
6728
6696
 
6729
6697
  }
6730
6698
 
6699
+ /**
6700
+ * Returns the dimensions of the source into the given target vector.
6701
+ *
6702
+ * @param {(Vector2|Vector3)} target - The target object the result is written into.
6703
+ * @return {(Vector2|Vector3)} The dimensions of the source.
6704
+ */
6731
6705
  getSize( target ) {
6732
6706
 
6733
6707
  const data = this.data;
6734
6708
 
6735
6709
  if ( data instanceof HTMLVideoElement ) {
6736
6710
 
6737
- target.set( data.videoWidth, data.videoHeight );
6711
+ target.set( data.videoWidth, data.videoHeight, 0 );
6712
+
6713
+ } else if ( data instanceof VideoFrame ) {
6714
+
6715
+ target.set( data.displayHeight, data.displayWidth, 0 );
6738
6716
 
6739
6717
  } else if ( data !== null ) {
6740
6718
 
@@ -12417,11 +12395,13 @@ class Matrix4 {
12417
12395
  * @param {number} near - The distance from the camera to the near plane.
12418
12396
  * @param {number} far - The distance from the camera to the far plane.
12419
12397
  * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.
12398
+ * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
12420
12399
  * @return {Matrix4} A reference to this matrix.
12421
12400
  */
12422
- makePerspective( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem ) {
12401
+ makePerspective( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false ) {
12423
12402
 
12424
12403
  const te = this.elements;
12404
+
12425
12405
  const x = 2 * near / ( right - left );
12426
12406
  const y = 2 * near / ( top - bottom );
12427
12407
 
@@ -12430,19 +12410,28 @@ class Matrix4 {
12430
12410
 
12431
12411
  let c, d;
12432
12412
 
12433
- if ( coordinateSystem === WebGLCoordinateSystem ) {
12413
+ if ( reversedDepth ) {
12434
12414
 
12435
- c = - ( far + near ) / ( far - near );
12436
- d = ( -2 * far * near ) / ( far - near );
12415
+ c = near / ( far - near );
12416
+ d = ( far * near ) / ( far - near );
12437
12417
 
12438
- } else if ( coordinateSystem === WebGPUCoordinateSystem ) {
12418
+ } else {
12439
12419
 
12440
- c = - far / ( far - near );
12441
- d = ( - far * near ) / ( far - near );
12420
+ if ( coordinateSystem === WebGLCoordinateSystem ) {
12442
12421
 
12443
- } else {
12422
+ c = - ( far + near ) / ( far - near );
12423
+ d = ( -2 * far * near ) / ( far - near );
12444
12424
 
12445
- throw new Error( 'THREE.Matrix4.makePerspective(): Invalid coordinate system: ' + coordinateSystem );
12425
+ } else if ( coordinateSystem === WebGPUCoordinateSystem ) {
12426
+
12427
+ c = - far / ( far - near );
12428
+ d = ( - far * near ) / ( far - near );
12429
+
12430
+ } else {
12431
+
12432
+ throw new Error( 'THREE.Matrix4.makePerspective(): Invalid coordinate system: ' + coordinateSystem );
12433
+
12434
+ }
12446
12435
 
12447
12436
  }
12448
12437
 
@@ -12466,39 +12455,49 @@ class Matrix4 {
12466
12455
  * @param {number} near - The distance from the camera to the near plane.
12467
12456
  * @param {number} far - The distance from the camera to the far plane.
12468
12457
  * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.
12458
+ * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
12469
12459
  * @return {Matrix4} A reference to this matrix.
12470
12460
  */
12471
- makeOrthographic( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem ) {
12461
+ makeOrthographic( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false ) {
12472
12462
 
12473
12463
  const te = this.elements;
12474
- const w = 1.0 / ( right - left );
12475
- const h = 1.0 / ( top - bottom );
12476
- const p = 1.0 / ( far - near );
12477
-
12478
- const x = ( right + left ) * w;
12479
- const y = ( top + bottom ) * h;
12480
12464
 
12481
- let z, zInv;
12465
+ const x = 2 / ( right - left );
12466
+ const y = 2 / ( top - bottom );
12482
12467
 
12483
- if ( coordinateSystem === WebGLCoordinateSystem ) {
12468
+ const a = - ( right + left ) / ( right - left );
12469
+ const b = - ( top + bottom ) / ( top - bottom );
12484
12470
 
12485
- z = ( far + near ) * p;
12486
- zInv = -2 * p;
12471
+ let c, d;
12487
12472
 
12488
- } else if ( coordinateSystem === WebGPUCoordinateSystem ) {
12473
+ if ( reversedDepth ) {
12489
12474
 
12490
- z = near * p;
12491
- zInv = -1 * p;
12475
+ c = 1 / ( far - near );
12476
+ d = far / ( far - near );
12492
12477
 
12493
12478
  } else {
12494
12479
 
12495
- throw new Error( 'THREE.Matrix4.makeOrthographic(): Invalid coordinate system: ' + coordinateSystem );
12480
+ if ( coordinateSystem === WebGLCoordinateSystem ) {
12481
+
12482
+ c = -2 / ( far - near );
12483
+ d = - ( far + near ) / ( far - near );
12484
+
12485
+ } else if ( coordinateSystem === WebGPUCoordinateSystem ) {
12486
+
12487
+ c = -1 / ( far - near );
12488
+ d = - near / ( far - near );
12489
+
12490
+ } else {
12491
+
12492
+ throw new Error( 'THREE.Matrix4.makeOrthographic(): Invalid coordinate system: ' + coordinateSystem );
12493
+
12494
+ }
12496
12495
 
12497
12496
  }
12498
12497
 
12499
- te[ 0 ] = 2 * w; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = - x;
12500
- te[ 1 ] = 0; te[ 5 ] = 2 * h; te[ 9 ] = 0; te[ 13 ] = - y;
12501
- te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = zInv; te[ 14 ] = - z;
12498
+ te[ 0 ] = x; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = a;
12499
+ te[ 1 ] = 0; te[ 5 ] = y; te[ 9 ] = 0; te[ 13 ] = b;
12500
+ te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = c; te[ 14 ] = d;
12502
12501
  te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; te[ 15 ] = 1;
12503
12502
 
12504
12503
  return this;
@@ -17292,7 +17291,7 @@ class MeshBasicMaterial extends Material {
17292
17291
  * @type {Color}
17293
17292
  * @default (1,1,1)
17294
17293
  */
17295
- this.color = new Color( 0xffffff ); // emissive
17294
+ this.color = new Color( 0xffffff ); // diffuse
17296
17295
 
17297
17296
  /**
17298
17297
  * The color map. May optionally include an alpha channel, typically combined
@@ -21402,6 +21401,20 @@ class Camera extends Object3D {
21402
21401
  */
21403
21402
  this.coordinateSystem = WebGLCoordinateSystem;
21404
21403
 
21404
+ this._reversedDepth = false;
21405
+
21406
+ }
21407
+
21408
+ /**
21409
+ * The flag that indicates whether the camera uses a reversed depth buffer.
21410
+ *
21411
+ * @type {boolean}
21412
+ * @default false
21413
+ */
21414
+ get reversedDepth() {
21415
+
21416
+ return this._reversedDepth;
21417
+
21405
21418
  }
21406
21419
 
21407
21420
  copy( source, recursive ) {
@@ -21829,7 +21842,7 @@ class PerspectiveCamera extends Camera {
21829
21842
  const skew = this.filmOffset;
21830
21843
  if ( skew !== 0 ) left += near * skew / this.getFilmWidth();
21831
21844
 
21832
- this.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far, this.coordinateSystem );
21845
+ this.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far, this.coordinateSystem, this.reversedDepth );
21833
21846
 
21834
21847
  this.projectionMatrixInverse.copy( this.projectionMatrix ).invert();
21835
21848
 
@@ -26393,9 +26406,10 @@ class Frustum {
26393
26406
  *
26394
26407
  * @param {Matrix4} m - The projection matrix.
26395
26408
  * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} coordinateSystem - The coordinate system.
26409
+ * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
26396
26410
  * @return {Frustum} A reference to this frustum.
26397
26411
  */
26398
- setFromProjectionMatrix( m, coordinateSystem = WebGLCoordinateSystem ) {
26412
+ setFromProjectionMatrix( m, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false ) {
26399
26413
 
26400
26414
  const planes = this.planes;
26401
26415
  const me = m.elements;
@@ -26408,19 +26422,29 @@ class Frustum {
26408
26422
  planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();
26409
26423
  planes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();
26410
26424
  planes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();
26411
- planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();
26412
26425
 
26413
- if ( coordinateSystem === WebGLCoordinateSystem ) {
26426
+ if ( reversedDepth ) {
26414
26427
 
26415
- planes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize();
26428
+ planes[ 4 ].setComponents( me2, me6, me10, me14 ).normalize(); // far
26429
+ planes[ 5 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize(); // near
26416
26430
 
26417
- } else if ( coordinateSystem === WebGPUCoordinateSystem ) {
26431
+ } else {
26418
26432
 
26419
- planes[ 5 ].setComponents( me2, me6, me10, me14 ).normalize();
26433
+ planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize(); // far
26420
26434
 
26421
- } else {
26435
+ if ( coordinateSystem === WebGLCoordinateSystem ) {
26436
+
26437
+ planes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize(); // near
26438
+
26439
+ } else if ( coordinateSystem === WebGPUCoordinateSystem ) {
26422
26440
 
26423
- throw new Error( 'THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: ' + coordinateSystem );
26441
+ planes[ 5 ].setComponents( me2, me6, me10, me14 ).normalize(); // near
26442
+
26443
+ } else {
26444
+
26445
+ throw new Error( 'THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: ' + coordinateSystem );
26446
+
26447
+ }
26424
26448
 
26425
26449
  }
26426
26450
 
@@ -26626,7 +26650,8 @@ class FrustumArray {
26626
26650
 
26627
26651
  _frustum$1.setFromProjectionMatrix(
26628
26652
  _projScreenMatrix$2,
26629
- this.coordinateSystem
26653
+ camera.coordinateSystem,
26654
+ camera.reversedDepth
26630
26655
  );
26631
26656
 
26632
26657
  if ( _frustum$1.intersectsObject( object ) ) {
@@ -26668,7 +26693,8 @@ class FrustumArray {
26668
26693
 
26669
26694
  _frustum$1.setFromProjectionMatrix(
26670
26695
  _projScreenMatrix$2,
26671
- this.coordinateSystem
26696
+ camera.coordinateSystem,
26697
+ camera.reversedDepth
26672
26698
  );
26673
26699
 
26674
26700
  if ( _frustum$1.intersectsSprite( sprite ) ) {
@@ -26710,7 +26736,8 @@ class FrustumArray {
26710
26736
 
26711
26737
  _frustum$1.setFromProjectionMatrix(
26712
26738
  _projScreenMatrix$2,
26713
- this.coordinateSystem
26739
+ camera.coordinateSystem,
26740
+ camera.reversedDepth
26714
26741
  );
26715
26742
 
26716
26743
  if ( _frustum$1.intersectsSphere( sphere ) ) {
@@ -26752,7 +26779,8 @@ class FrustumArray {
26752
26779
 
26753
26780
  _frustum$1.setFromProjectionMatrix(
26754
26781
  _projScreenMatrix$2,
26755
- this.coordinateSystem
26782
+ camera.coordinateSystem,
26783
+ camera.reversedDepth
26756
26784
  );
26757
26785
 
26758
26786
  if ( _frustum$1.intersectsBox( box ) ) {
@@ -26794,7 +26822,8 @@ class FrustumArray {
26794
26822
 
26795
26823
  _frustum$1.setFromProjectionMatrix(
26796
26824
  _projScreenMatrix$2,
26797
- this.coordinateSystem
26825
+ camera.coordinateSystem,
26826
+ camera.reversedDepth
26798
26827
  );
26799
26828
 
26800
26829
  if ( _frustum$1.containsPoint( point ) ) {
@@ -28061,7 +28090,7 @@ class BatchedMesh extends Mesh {
28061
28090
  const availableInstanceIds = this._availableInstanceIds;
28062
28091
  const instanceInfo = this._instanceInfo;
28063
28092
  availableInstanceIds.sort( ascIdSort );
28064
- while ( availableInstanceIds[ availableInstanceIds.length - 1 ] === instanceInfo.length ) {
28093
+ while ( availableInstanceIds[ availableInstanceIds.length - 1 ] === instanceInfo.length - 1 ) {
28065
28094
 
28066
28095
  instanceInfo.pop();
28067
28096
  availableInstanceIds.pop();
@@ -28339,9 +28368,11 @@ class BatchedMesh extends Mesh {
28339
28368
  _matrix$1
28340
28369
  .multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse )
28341
28370
  .multiply( this.matrixWorld );
28371
+
28342
28372
  _frustum.setFromProjectionMatrix(
28343
28373
  _matrix$1,
28344
- renderer.coordinateSystem
28374
+ camera.coordinateSystem,
28375
+ camera.reversedDepth
28345
28376
  );
28346
28377
 
28347
28378
  }
@@ -29360,6 +29391,9 @@ function testPoint( point, index, localThresholdSq, matrixWorld, raycaster, inte
29360
29391
  * const texture = new THREE.VideoTexture( video );
29361
29392
  * ```
29362
29393
  *
29394
+ * Note: When using video textures with {@link WebGPURenderer}, {@link Texture#colorSpace} must be
29395
+ * set to THREE.SRGBColorSpace.
29396
+ *
29363
29397
  * Note: After the initial use of a texture, its dimensions, format, and type
29364
29398
  * cannot be changed. Instead, call {@link Texture#dispose} on the texture and instantiate a new one.
29365
29399
  *
@@ -29403,18 +29437,28 @@ class VideoTexture extends Texture {
29403
29437
  */
29404
29438
  this.generateMipmaps = false;
29405
29439
 
29440
+ /**
29441
+ * The video frame request callback identifier, which is a positive integer.
29442
+ *
29443
+ * Value of 0 represents no scheduled rVFC.
29444
+ *
29445
+ * @private
29446
+ * @type {number}
29447
+ */
29448
+ this._requestVideoFrameCallbackId = 0;
29449
+
29406
29450
  const scope = this;
29407
29451
 
29408
29452
  function updateVideo() {
29409
29453
 
29410
29454
  scope.needsUpdate = true;
29411
- video.requestVideoFrameCallback( updateVideo );
29455
+ scope._requestVideoFrameCallbackId = video.requestVideoFrameCallback( updateVideo );
29412
29456
 
29413
29457
  }
29414
29458
 
29415
29459
  if ( 'requestVideoFrameCallback' in video ) {
29416
29460
 
29417
- video.requestVideoFrameCallback( updateVideo );
29461
+ this._requestVideoFrameCallbackId = video.requestVideoFrameCallback( updateVideo );
29418
29462
 
29419
29463
  }
29420
29464
 
@@ -29445,6 +29489,21 @@ class VideoTexture extends Texture {
29445
29489
 
29446
29490
  }
29447
29491
 
29492
+ /**
29493
+ * @override
29494
+ */
29495
+ dispose() {
29496
+
29497
+ if ( this._requestVideoFrameCallbackId !== 0 ) {
29498
+
29499
+ this.source.data.cancelVideoFrameCallback( this._requestVideoFrameCallbackId );
29500
+
29501
+ }
29502
+
29503
+ super.dispose();
29504
+
29505
+ }
29506
+
29448
29507
  }
29449
29508
 
29450
29509
  /**
@@ -29545,8 +29604,8 @@ class FramebufferTexture extends Texture {
29545
29604
  /**
29546
29605
  * Constructs a new framebuffer texture.
29547
29606
  *
29548
- * @param {number} width - The width of the texture.
29549
- * @param {number} height - The height of the texture.
29607
+ * @param {number} [width] - The width of the texture.
29608
+ * @param {number} [height] - The height of the texture.
29550
29609
  */
29551
29610
  constructor( width, height ) {
29552
29611
 
@@ -41697,7 +41756,7 @@ class KeyframeTrack {
41697
41756
  *
41698
41757
  * @param {string} name - The keyframe track's name.
41699
41758
  * @param {Array<number>} times - A list of keyframe times.
41700
- * @param {Array<number>} values - A list of keyframe values.
41759
+ * @param {Array<number|string|boolean>} values - A list of keyframe values.
41701
41760
  * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} [interpolation] - The interpolation type.
41702
41761
  */
41703
41762
  constructor( name, times, values, interpolation ) {
@@ -42285,7 +42344,7 @@ class BooleanKeyframeTrack extends KeyframeTrack {
42285
42344
  *
42286
42345
  * @param {string} name - The keyframe track's name.
42287
42346
  * @param {Array<number>} times - A list of keyframe times.
42288
- * @param {Array<number>} values - A list of keyframe values.
42347
+ * @param {Array<boolean>} values - A list of keyframe values.
42289
42348
  */
42290
42349
  constructor( name, times, values ) {
42291
42350
 
@@ -42488,7 +42547,7 @@ class StringKeyframeTrack extends KeyframeTrack {
42488
42547
  *
42489
42548
  * @param {string} name - The keyframe track's name.
42490
42549
  * @param {Array<number>} times - A list of keyframe times.
42491
- * @param {Array<number>} values - A list of keyframe values.
42550
+ * @param {Array<string>} values - A list of keyframe values.
42492
42551
  */
42493
42552
  constructor( name, times, values ) {
42494
42553
 
@@ -43311,6 +43370,13 @@ class LoadingManager {
43311
43370
  */
43312
43371
  this.onError = onError;
43313
43372
 
43373
+ /**
43374
+ * Used for aborting ongoing requests in loaders using this manager.
43375
+ *
43376
+ * @type {AbortController}
43377
+ */
43378
+ this.abortController = new AbortController();
43379
+
43314
43380
  /**
43315
43381
  * This should be called by any loader using the manager when the loader
43316
43382
  * starts loading an item.
@@ -43511,6 +43577,22 @@ class LoadingManager {
43511
43577
 
43512
43578
  };
43513
43579
 
43580
+ /**
43581
+ * Can be used to abort ongoing loading requests in loaders using this manager.
43582
+ * The abort only works if the loaders implement {@link Loader#abort} and `AbortSignal.any()`
43583
+ * is supported in the browser.
43584
+ *
43585
+ * @return {LoadingManager} A reference to this loading manager.
43586
+ */
43587
+ this.abort = function () {
43588
+
43589
+ this.abortController.abort();
43590
+ this.abortController = new AbortController();
43591
+
43592
+ return this;
43593
+
43594
+ };
43595
+
43514
43596
  }
43515
43597
 
43516
43598
  }
@@ -43590,6 +43672,7 @@ class Loader {
43590
43672
  * This method needs to be implemented by all concrete loaders. It holds the
43591
43673
  * logic for loading assets from the backend.
43592
43674
  *
43675
+ * @abstract
43593
43676
  * @param {string} url - The path/URL of the file to be loaded.
43594
43677
  * @param {Function} onLoad - Executed when the loading process has been finished.
43595
43678
  * @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.
@@ -43620,6 +43703,7 @@ class Loader {
43620
43703
  * This method needs to be implemented by all concrete loaders. It holds the
43621
43704
  * logic for parsing the asset into three.js entities.
43622
43705
  *
43706
+ * @abstract
43623
43707
  * @param {any} data - The data to parse.
43624
43708
  */
43625
43709
  parse( /* data */ ) {}
@@ -43694,6 +43778,18 @@ class Loader {
43694
43778
 
43695
43779
  }
43696
43780
 
43781
+ /**
43782
+ * This method can be implemented in loaders for aborting ongoing requests.
43783
+ *
43784
+ * @abstract
43785
+ * @return {Loader} A reference to this instance.
43786
+ */
43787
+ abort() {
43788
+
43789
+ return this;
43790
+
43791
+ }
43792
+
43697
43793
  }
43698
43794
 
43699
43795
  /**
@@ -43762,7 +43858,8 @@ class FileLoader extends Loader {
43762
43858
  super( manager );
43763
43859
 
43764
43860
  /**
43765
- * The expected mime type.
43861
+ * The expected mime type. Valid values can be found
43862
+ * [here]{@link hhttps://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#mimetype}
43766
43863
  *
43767
43864
  * @type {string}
43768
43865
  */
@@ -43776,6 +43873,14 @@ class FileLoader extends Loader {
43776
43873
  */
43777
43874
  this.responseType = '';
43778
43875
 
43876
+ /**
43877
+ * Used for aborting requests.
43878
+ *
43879
+ * @private
43880
+ * @type {AbortController}
43881
+ */
43882
+ this._abortController = new AbortController();
43883
+
43779
43884
  }
43780
43885
 
43781
43886
  /**
@@ -43842,7 +43947,7 @@ class FileLoader extends Loader {
43842
43947
  const req = new Request( url, {
43843
43948
  headers: new Headers( this.requestHeader ),
43844
43949
  credentials: this.withCredentials ? 'include' : 'same-origin',
43845
- // An abort controller could be added within a future PR
43950
+ signal: ( typeof AbortSignal.any === 'function' ) ? AbortSignal.any( [ this._abortController.signal, this.manager.abortController.signal ] ) : this._abortController.signal
43846
43951
  } );
43847
43952
 
43848
43953
  // record states ( avoid data race )
@@ -44059,6 +44164,20 @@ class FileLoader extends Loader {
44059
44164
 
44060
44165
  }
44061
44166
 
44167
+ /**
44168
+ * Aborts ongoing fetch requests.
44169
+ *
44170
+ * @return {FileLoader} A reference to this instance.
44171
+ */
44172
+ abort() {
44173
+
44174
+ this._abortController.abort();
44175
+ this._abortController = new AbortController();
44176
+
44177
+ return this;
44178
+
44179
+ }
44180
+
44062
44181
  }
44063
44182
 
44064
44183
  /**
@@ -45122,14 +45241,27 @@ class LightShadow {
45122
45241
  shadowCamera.updateMatrixWorld();
45123
45242
 
45124
45243
  _projScreenMatrix$1.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
45125
- this._frustum.setFromProjectionMatrix( _projScreenMatrix$1 );
45244
+ this._frustum.setFromProjectionMatrix( _projScreenMatrix$1, shadowCamera.coordinateSystem, shadowCamera.reversedDepth );
45126
45245
 
45127
- shadowMatrix.set(
45128
- 0.5, 0.0, 0.0, 0.5,
45129
- 0.0, 0.5, 0.0, 0.5,
45130
- 0.0, 0.0, 0.5, 0.5,
45131
- 0.0, 0.0, 0.0, 1.0
45132
- );
45246
+ if ( shadowCamera.reversedDepth ) {
45247
+
45248
+ shadowMatrix.set(
45249
+ 0.5, 0.0, 0.0, 0.5,
45250
+ 0.0, 0.5, 0.0, 0.5,
45251
+ 0.0, 0.0, 1.0, 0.0,
45252
+ 0.0, 0.0, 0.0, 1.0
45253
+ );
45254
+
45255
+ } else {
45256
+
45257
+ shadowMatrix.set(
45258
+ 0.5, 0.0, 0.0, 0.5,
45259
+ 0.0, 0.5, 0.0, 0.5,
45260
+ 0.0, 0.0, 0.5, 0.5,
45261
+ 0.0, 0.0, 0.0, 1.0
45262
+ );
45263
+
45264
+ }
45133
45265
 
45134
45266
  shadowMatrix.multiply( _projScreenMatrix$1 );
45135
45267
 
@@ -45586,7 +45718,7 @@ class PointLightShadow extends LightShadow {
45586
45718
  shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z );
45587
45719
 
45588
45720
  _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
45589
- this._frustum.setFromProjectionMatrix( _projScreenMatrix );
45721
+ this._frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );
45590
45722
 
45591
45723
  }
45592
45724
 
@@ -45920,7 +46052,7 @@ class OrthographicCamera extends Camera {
45920
46052
 
45921
46053
  }
45922
46054
 
45923
- this.projectionMatrix.makeOrthographic( left, right, top, bottom, this.near, this.far, this.coordinateSystem );
46055
+ this.projectionMatrix.makeOrthographic( left, right, top, bottom, this.near, this.far, this.coordinateSystem, this.reversedDepth );
45924
46056
 
45925
46057
  this.projectionMatrixInverse.copy( this.projectionMatrix ).invert();
45926
46058
 
@@ -48660,6 +48792,14 @@ class ImageBitmapLoader extends Loader {
48660
48792
  */
48661
48793
  this.options = { premultiplyAlpha: 'none' };
48662
48794
 
48795
+ /**
48796
+ * Used for aborting requests.
48797
+ *
48798
+ * @private
48799
+ * @type {AbortController}
48800
+ */
48801
+ this._abortController = new AbortController();
48802
+
48663
48803
  }
48664
48804
 
48665
48805
  /**
@@ -48748,6 +48888,7 @@ class ImageBitmapLoader extends Loader {
48748
48888
  const fetchOptions = {};
48749
48889
  fetchOptions.credentials = ( this.crossOrigin === 'anonymous' ) ? 'same-origin' : 'include';
48750
48890
  fetchOptions.headers = this.requestHeader;
48891
+ fetchOptions.signal = ( typeof AbortSignal.any === 'function' ) ? AbortSignal.any( [ this._abortController.signal, this.manager.abortController.signal ] ) : this._abortController.signal;
48751
48892
 
48752
48893
  const promise = fetch( url, fetchOptions ).then( function ( res ) {
48753
48894
 
@@ -48785,6 +48926,20 @@ class ImageBitmapLoader extends Loader {
48785
48926
 
48786
48927
  }
48787
48928
 
48929
+ /**
48930
+ * Aborts ongoing fetch requests.
48931
+ *
48932
+ * @return {ImageBitmapLoader} A reference to this instance.
48933
+ */
48934
+ abort() {
48935
+
48936
+ this._abortController.abort();
48937
+ this._abortController = new AbortController();
48938
+
48939
+ return this;
48940
+
48941
+ }
48942
+
48788
48943
  }
48789
48944
 
48790
48945
  let _context;
@@ -54676,6 +54831,189 @@ function intersect( object, raycaster, intersects, recursive ) {
54676
54831
 
54677
54832
  }
54678
54833
 
54834
+ /**
54835
+ * This class is an alternative to {@link Clock} with a different API design and behavior.
54836
+ * The goal is to avoid the conceptual flaws that became apparent in `Clock` over time.
54837
+ *
54838
+ * - `Timer` has an `update()` method that updates its internal state. That makes it possible to
54839
+ * call `getDelta()` and `getElapsed()` multiple times per simulation step without getting different values.
54840
+ * - The class can make use of the Page Visibility API to avoid large time delta values when the app
54841
+ * is inactive (e.g. tab switched or browser hidden).
54842
+ *
54843
+ * ```js
54844
+ * const timer = new Timer();
54845
+ * timer.connect( document ); // use Page Visibility API
54846
+ * ```
54847
+ */
54848
+ class Timer {
54849
+
54850
+ /**
54851
+ * Constructs a new timer.
54852
+ */
54853
+ constructor() {
54854
+
54855
+ this._previousTime = 0;
54856
+ this._currentTime = 0;
54857
+ this._startTime = performance.now();
54858
+
54859
+ this._delta = 0;
54860
+ this._elapsed = 0;
54861
+
54862
+ this._timescale = 1;
54863
+
54864
+ this._document = null;
54865
+ this._pageVisibilityHandler = null;
54866
+
54867
+ }
54868
+
54869
+ /**
54870
+ * Connect the timer to the given document.Calling this method is not mandatory to
54871
+ * use the timer but enables the usage of the Page Visibility API to avoid large time
54872
+ * delta values.
54873
+ *
54874
+ * @param {Document} document - The document.
54875
+ */
54876
+ connect( document ) {
54877
+
54878
+ this._document = document;
54879
+
54880
+ // use Page Visibility API to avoid large time delta values
54881
+
54882
+ if ( document.hidden !== undefined ) {
54883
+
54884
+ this._pageVisibilityHandler = handleVisibilityChange.bind( this );
54885
+
54886
+ document.addEventListener( 'visibilitychange', this._pageVisibilityHandler, false );
54887
+
54888
+ }
54889
+
54890
+ }
54891
+
54892
+ /**
54893
+ * Disconnects the timer from the DOM and also disables the usage of the Page Visibility API.
54894
+ */
54895
+ disconnect() {
54896
+
54897
+ if ( this._pageVisibilityHandler !== null ) {
54898
+
54899
+ this._document.removeEventListener( 'visibilitychange', this._pageVisibilityHandler );
54900
+ this._pageVisibilityHandler = null;
54901
+
54902
+ }
54903
+
54904
+ this._document = null;
54905
+
54906
+ }
54907
+
54908
+ /**
54909
+ * Returns the time delta in seconds.
54910
+ *
54911
+ * @return {number} The time delta in second.
54912
+ */
54913
+ getDelta() {
54914
+
54915
+ return this._delta / 1000;
54916
+
54917
+ }
54918
+
54919
+ /**
54920
+ * Returns the elapsed time in seconds.
54921
+ *
54922
+ * @return {number} The elapsed time in second.
54923
+ */
54924
+ getElapsed() {
54925
+
54926
+ return this._elapsed / 1000;
54927
+
54928
+ }
54929
+
54930
+ /**
54931
+ * Returns the timescale.
54932
+ *
54933
+ * @return {number} The timescale.
54934
+ */
54935
+ getTimescale() {
54936
+
54937
+ return this._timescale;
54938
+
54939
+ }
54940
+
54941
+ /**
54942
+ * Sets the given timescale which scale the time delta computation
54943
+ * in `update()`.
54944
+ *
54945
+ * @param {number} timescale - The timescale to set.
54946
+ * @return {Timer} A reference to this timer.
54947
+ */
54948
+ setTimescale( timescale ) {
54949
+
54950
+ this._timescale = timescale;
54951
+
54952
+ return this;
54953
+
54954
+ }
54955
+
54956
+ /**
54957
+ * Resets the time computation for the current simulation step.
54958
+ *
54959
+ * @return {Timer} A reference to this timer.
54960
+ */
54961
+ reset() {
54962
+
54963
+ this._currentTime = performance.now() - this._startTime;
54964
+
54965
+ return this;
54966
+
54967
+ }
54968
+
54969
+ /**
54970
+ * Can be used to free all internal resources. Usually called when
54971
+ * the timer instance isn't required anymore.
54972
+ */
54973
+ dispose() {
54974
+
54975
+ this.disconnect();
54976
+
54977
+ }
54978
+
54979
+ /**
54980
+ * Updates the internal state of the timer. This method should be called
54981
+ * once per simulation step and before you perform queries against the timer
54982
+ * (e.g. via `getDelta()`).
54983
+ *
54984
+ * @param {number} timestamp - The current time in milliseconds. Can be obtained
54985
+ * from the `requestAnimationFrame` callback argument. If not provided, the current
54986
+ * time will be determined with `performance.now`.
54987
+ * @return {Timer} A reference to this timer.
54988
+ */
54989
+ update( timestamp ) {
54990
+
54991
+ if ( this._pageVisibilityHandler !== null && this._document.hidden === true ) {
54992
+
54993
+ this._delta = 0;
54994
+
54995
+ } else {
54996
+
54997
+ this._previousTime = this._currentTime;
54998
+ this._currentTime = ( timestamp !== undefined ? timestamp : performance.now() ) - this._startTime;
54999
+
55000
+ this._delta = ( this._currentTime - this._previousTime ) * this._timescale;
55001
+ this._elapsed += this._delta; // _elapsed is the accumulation of all previous deltas
55002
+
55003
+ }
55004
+
55005
+ return this;
55006
+
55007
+ }
55008
+
55009
+ }
55010
+
55011
+ function handleVisibilityChange() {
55012
+
55013
+ if ( this._document.hidden === false ) this.reset();
55014
+
55015
+ }
55016
+
54679
55017
  /**
54680
55018
  * This class can be used to represent points in 3D space as
54681
55019
  * [Spherical coordinates]{@link https://en.wikipedia.org/wiki/Spherical_coordinate_system}.
@@ -54783,8 +55121,8 @@ class Spherical {
54783
55121
  * Sets the spherical components from the given Cartesian coordinates.
54784
55122
  *
54785
55123
  * @param {number} x - The x value.
54786
- * @param {number} y - The x value.
54787
- * @param {number} z - The x value.
55124
+ * @param {number} y - The y value.
55125
+ * @param {number} z - The z value.
54788
55126
  * @return {Spherical} A reference to this spherical.
54789
55127
  */
54790
55128
  setFromCartesianCoords( x, y, z ) {
@@ -55445,6 +55783,12 @@ class Box2 {
55445
55783
  const _startP = /*@__PURE__*/ new Vector3();
55446
55784
  const _startEnd = /*@__PURE__*/ new Vector3();
55447
55785
 
55786
+ const _d1 = /*@__PURE__*/ new Vector3();
55787
+ const _d2 = /*@__PURE__*/ new Vector3();
55788
+ const _r = /*@__PURE__*/ new Vector3();
55789
+ const _c1 = /*@__PURE__*/ new Vector3();
55790
+ const _c2 = /*@__PURE__*/ new Vector3();
55791
+
55448
55792
  /**
55449
55793
  * An analytical line segment in 3D space represented by a start and end point.
55450
55794
  */
@@ -55592,11 +55936,11 @@ class Line3 {
55592
55936
  }
55593
55937
 
55594
55938
  /**
55595
- * Returns the closets point on the line for a given point.
55939
+ * Returns the closest point on the line for a given point.
55596
55940
  *
55597
55941
  * @param {Vector3} point - The point to compute the closest point on the line for.
55598
55942
  * @param {boolean} clampToLine - Whether to clamp the result to the range `[0,1]` or not.
55599
- * @param {Vector3} target - The target vector that is used to store the method's result.
55943
+ * @param {Vector3} target - The target vector that is used to store the method's result.
55600
55944
  * @return {Vector3} The closest point on the line.
55601
55945
  */
55602
55946
  closestPointToPoint( point, clampToLine, target ) {
@@ -55607,6 +55951,127 @@ class Line3 {
55607
55951
 
55608
55952
  }
55609
55953
 
55954
+ /**
55955
+ * Returns the closest squared distance between this line segment and the given one.
55956
+ *
55957
+ * @param {Line3} line - The line segment to compute the closest squared distance to.
55958
+ * @param {Vector3} [c1] - The closest point on this line segment.
55959
+ * @param {Vector3} [c2] - The closest point on the given line segment.
55960
+ * @return {number} The squared distance between this line segment and the given one.
55961
+ */
55962
+ distanceSqToLine3( line, c1 = _c1, c2 = _c2 ) {
55963
+
55964
+ // from Real-Time Collision Detection by Christer Ericson, chapter 5.1.9
55965
+
55966
+ // Computes closest points C1 and C2 of S1(s)=P1+s*(Q1-P1) and
55967
+ // S2(t)=P2+t*(Q2-P2), returning s and t. Function result is squared
55968
+ // distance between between S1(s) and S2(t)
55969
+
55970
+ const EPSILON = 1e-8 * 1e-8; // must be squared since we compare squared length
55971
+ let s, t;
55972
+
55973
+ const p1 = this.start;
55974
+ const p2 = line.start;
55975
+ const q1 = this.end;
55976
+ const q2 = line.end;
55977
+
55978
+ _d1.subVectors( q1, p1 ); // Direction vector of segment S1
55979
+ _d2.subVectors( q2, p2 ); // Direction vector of segment S2
55980
+ _r.subVectors( p1, p2 );
55981
+
55982
+ const a = _d1.dot( _d1 ); // Squared length of segment S1, always nonnegative
55983
+ const e = _d2.dot( _d2 ); // Squared length of segment S2, always nonnegative
55984
+ const f = _d2.dot( _r );
55985
+
55986
+ // Check if either or both segments degenerate into points
55987
+
55988
+ if ( a <= EPSILON && e <= EPSILON ) {
55989
+
55990
+ // Both segments degenerate into points
55991
+
55992
+ c1.copy( p1 );
55993
+ c2.copy( p2 );
55994
+
55995
+ c1.sub( c2 );
55996
+
55997
+ return c1.dot( c1 );
55998
+
55999
+ }
56000
+
56001
+ if ( a <= EPSILON ) {
56002
+
56003
+ // First segment degenerates into a point
56004
+
56005
+ s = 0;
56006
+ t = f / e; // s = 0 => t = (b*s + f) / e = f / e
56007
+ t = clamp( t, 0, 1 );
56008
+
56009
+
56010
+ } else {
56011
+
56012
+ const c = _d1.dot( _r );
56013
+
56014
+ if ( e <= EPSILON ) {
56015
+
56016
+ // Second segment degenerates into a point
56017
+
56018
+ t = 0;
56019
+ s = clamp( - c / a, 0, 1 ); // t = 0 => s = (b*t - c) / a = -c / a
56020
+
56021
+ } else {
56022
+
56023
+ // The general nondegenerate case starts here
56024
+
56025
+ const b = _d1.dot( _d2 );
56026
+ const denom = a * e - b * b; // Always nonnegative
56027
+
56028
+ // If segments not parallel, compute closest point on L1 to L2 and
56029
+ // clamp to segment S1. Else pick arbitrary s (here 0)
56030
+
56031
+ if ( denom !== 0 ) {
56032
+
56033
+ s = clamp( ( b * f - c * e ) / denom, 0, 1 );
56034
+
56035
+ } else {
56036
+
56037
+ s = 0;
56038
+
56039
+ }
56040
+
56041
+ // Compute point on L2 closest to S1(s) using
56042
+ // t = Dot((P1 + D1*s) - P2,D2) / Dot(D2,D2) = (b*s + f) / e
56043
+
56044
+ t = ( b * s + f ) / e;
56045
+
56046
+ // If t in [0,1] done. Else clamp t, recompute s for the new value
56047
+ // of t using s = Dot((P2 + D2*t) - P1,D1) / Dot(D1,D1)= (t*b - c) / a
56048
+ // and clamp s to [0, 1]
56049
+
56050
+ if ( t < 0 ) {
56051
+
56052
+ t = 0.;
56053
+ s = clamp( - c / a, 0, 1 );
56054
+
56055
+ } else if ( t > 1 ) {
56056
+
56057
+ t = 1;
56058
+ s = clamp( ( b - c ) / a, 0, 1 );
56059
+
56060
+ }
56061
+
56062
+ }
56063
+
56064
+ }
56065
+
56066
+ c1.copy( p1 ).add( _d1.multiplyScalar( s ) );
56067
+ c2.copy( p2 ).add( _d2.multiplyScalar( t ) );
56068
+
56069
+ c1.sub( c2 );
56070
+
56071
+ return c1.dot( c1 );
56072
+
56073
+ }
56074
+
55610
56075
  /**
55611
56076
  * Applies a 4x4 transformation matrix to this line segment.
55612
56077
  *
@@ -55806,7 +56271,7 @@ const _matrixWorldInv = /*@__PURE__*/ new Matrix4();
55806
56271
  class SkeletonHelper extends LineSegments {
55807
56272
 
55808
56273
  /**
55809
- * Constructs a new hemisphere light helper.
56274
+ * Constructs a new skeleton helper.
55810
56275
  *
55811
56276
  * @param {Object3D} object - Usually an instance of {@link SkinnedMesh}. However, any 3D object
55812
56277
  * can be used if it represents a hierarchy of bones (see {@link Bone}).
@@ -55820,9 +56285,6 @@ class SkeletonHelper extends LineSegments {
55820
56285
  const vertices = [];
55821
56286
  const colors = [];
55822
56287
 
55823
- const color1 = new Color( 0, 0, 1 );
55824
- const color2 = new Color( 0, 1, 0 );
55825
-
55826
56288
  for ( let i = 0; i < bones.length; i ++ ) {
55827
56289
 
55828
56290
  const bone = bones[ i ];
@@ -55831,8 +56293,8 @@ class SkeletonHelper extends LineSegments {
55831
56293
 
55832
56294
  vertices.push( 0, 0, 0 );
55833
56295
  vertices.push( 0, 0, 0 );
55834
- colors.push( color1.r, color1.g, color1.b );
55835
- colors.push( color2.r, color2.g, color2.b );
56296
+ colors.push( 0, 0, 0 );
56297
+ colors.push( 0, 0, 0 );
55836
56298
 
55837
56299
  }
55838
56300
 
@@ -55873,6 +56335,13 @@ class SkeletonHelper extends LineSegments {
55873
56335
  this.matrix = object.matrixWorld;
55874
56336
  this.matrixAutoUpdate = false;
55875
56337
 
56338
+ // colors
56339
+
56340
+ const color1 = new Color( 0x0000ff );
56341
+ const color2 = new Color( 0x00ff00 );
56342
+
56343
+ this.setColors( color1, color2 );
56344
+
55876
56345
  }
55877
56346
 
55878
56347
  updateMatrixWorld( force ) {
@@ -55910,6 +56379,31 @@ class SkeletonHelper extends LineSegments {
55910
56379
 
55911
56380
  }
55912
56381
 
56382
+ /**
56383
+ * Defines the colors of the helper.
56384
+ *
56385
+ * @param {Color} color1 - The first line color for each bone.
56386
+ * @param {Color} color2 - The second line color for each bone.
56387
+ * @return {SkeletonHelper} A reference to this helper.
56388
+ */
56389
+ setColors( color1, color2 ) {
56390
+
56391
+ const geometry = this.geometry;
56392
+ const colorAttribute = geometry.getAttribute( 'color' );
56393
+
56394
+ for ( let i = 0; i < colorAttribute.count; i += 2 ) {
56395
+
56396
+ colorAttribute.setXYZ( i, color1.r, color1.g, color1.b );
56397
+ colorAttribute.setXYZ( i + 1, color2.r, color2.g, color2.b );
56398
+
56399
+ }
56400
+
56401
+ colorAttribute.needsUpdate = true;
56402
+
56403
+ return this;
56404
+
56405
+ }
56406
+
55913
56407
  /**
55914
56408
  * Frees the GPU-related resources allocated by this instance. Call this
55915
56409
  * method whenever this instance is no longer used in your app.
@@ -56670,6 +57164,7 @@ class CameraHelper extends LineSegments {
56670
57164
  * @param {Color} up - The up line color.
56671
57165
  * @param {Color} target - The target line color.
56672
57166
  * @param {Color} cross - The cross line color.
57167
+ * @return {CameraHelper} A reference to this helper.
56673
57168
  */
56674
57169
  setColors( frustum, cone, up, target, cross ) {
56675
57170
 
@@ -56726,6 +57221,8 @@ class CameraHelper extends LineSegments {
56726
57221
 
56727
57222
  colorAttribute.needsUpdate = true;
56728
57223
 
57224
+ return this;
57225
+
56729
57226
  }
56730
57227
 
56731
57228
  /**
@@ -56738,48 +57235,75 @@ class CameraHelper extends LineSegments {
56738
57235
 
56739
57236
  const w = 1, h = 1;
56740
57237
 
57238
+ let nearZ, farZ;
57239
+
56741
57240
  // we need just camera projection matrix inverse
56742
57241
  // world matrix must be identity
56743
57242
 
56744
57243
  _camera.projectionMatrixInverse.copy( this.camera.projectionMatrixInverse );
56745
57244
 
56746
57245
  // Adjust z values based on coordinate system
56747
- const nearZ = this.camera.coordinateSystem === WebGLCoordinateSystem ? -1 : 0;
57246
+
57247
+ if ( this.camera.reversedDepth === true ) {
57248
+
57249
+ nearZ = 1;
57250
+ farZ = 0;
57251
+
57252
+ } else {
57253
+
57254
+ if ( this.camera.coordinateSystem === WebGLCoordinateSystem ) {
57255
+
57256
+ nearZ = -1;
57257
+ farZ = 1;
57258
+
57259
+ } else if ( this.camera.coordinateSystem === WebGPUCoordinateSystem ) {
57260
+
57261
+ nearZ = 0;
57262
+ farZ = 1;
57263
+
57264
+ } else {
57265
+
57266
+ throw new Error( 'THREE.CameraHelper.update(): Invalid coordinate system: ' + this.camera.coordinateSystem );
57267
+
57268
+ }
57269
+
57270
+ }
57271
+
56748
57272
 
56749
57273
  // center / target
56750
57274
  setPoint( 'c', pointMap, geometry, _camera, 0, 0, nearZ );
56751
- setPoint( 't', pointMap, geometry, _camera, 0, 0, 1 );
57275
+ setPoint( 't', pointMap, geometry, _camera, 0, 0, farZ );
56752
57276
 
56753
57277
  // near
56754
57278
 
56755
- setPoint( 'n1', pointMap, geometry, _camera, -1, -1, nearZ );
56756
- setPoint( 'n2', pointMap, geometry, _camera, w, -1, nearZ );
56757
- setPoint( 'n3', pointMap, geometry, _camera, -1, h, nearZ );
57279
+ setPoint( 'n1', pointMap, geometry, _camera, - w, - h, nearZ );
57280
+ setPoint( 'n2', pointMap, geometry, _camera, w, - h, nearZ );
57281
+ setPoint( 'n3', pointMap, geometry, _camera, - w, h, nearZ );
56758
57282
  setPoint( 'n4', pointMap, geometry, _camera, w, h, nearZ );
56759
57283
 
56760
57284
  // far
56761
57285
 
56762
- setPoint( 'f1', pointMap, geometry, _camera, -1, -1, 1 );
56763
- setPoint( 'f2', pointMap, geometry, _camera, w, -1, 1 );
56764
- setPoint( 'f3', pointMap, geometry, _camera, -1, h, 1 );
56765
- setPoint( 'f4', pointMap, geometry, _camera, w, h, 1 );
57286
+ setPoint( 'f1', pointMap, geometry, _camera, - w, - h, farZ );
57287
+ setPoint( 'f2', pointMap, geometry, _camera, w, - h, farZ );
57288
+ setPoint( 'f3', pointMap, geometry, _camera, - w, h, farZ );
57289
+ setPoint( 'f4', pointMap, geometry, _camera, w, h, farZ );
56766
57290
 
56767
57291
  // up
56768
57292
 
56769
57293
  setPoint( 'u1', pointMap, geometry, _camera, w * 0.7, h * 1.1, nearZ );
56770
- setPoint( 'u2', pointMap, geometry, _camera, -1 * 0.7, h * 1.1, nearZ );
57294
+ setPoint( 'u2', pointMap, geometry, _camera, - w * 0.7, h * 1.1, nearZ );
56771
57295
  setPoint( 'u3', pointMap, geometry, _camera, 0, h * 2, nearZ );
56772
57296
 
56773
57297
  // cross
56774
57298
 
56775
- setPoint( 'cf1', pointMap, geometry, _camera, -1, 0, 1 );
56776
- setPoint( 'cf2', pointMap, geometry, _camera, w, 0, 1 );
56777
- setPoint( 'cf3', pointMap, geometry, _camera, 0, -1, 1 );
56778
- setPoint( 'cf4', pointMap, geometry, _camera, 0, h, 1 );
57299
+ setPoint( 'cf1', pointMap, geometry, _camera, - w, 0, farZ );
57300
+ setPoint( 'cf2', pointMap, geometry, _camera, w, 0, farZ );
57301
+ setPoint( 'cf3', pointMap, geometry, _camera, 0, - h, farZ );
57302
+ setPoint( 'cf4', pointMap, geometry, _camera, 0, h, farZ );
56779
57303
 
56780
- setPoint( 'cn1', pointMap, geometry, _camera, -1, 0, nearZ );
57304
+ setPoint( 'cn1', pointMap, geometry, _camera, - w, 0, nearZ );
56781
57305
  setPoint( 'cn2', pointMap, geometry, _camera, w, 0, nearZ );
56782
- setPoint( 'cn3', pointMap, geometry, _camera, 0, -1, nearZ );
57306
+ setPoint( 'cn3', pointMap, geometry, _camera, 0, - h, nearZ );
56783
57307
  setPoint( 'cn4', pointMap, geometry, _camera, 0, h, nearZ );
56784
57308
 
56785
57309
  geometry.getAttribute( 'position' ).needsUpdate = true;
@@ -58628,7 +59152,7 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
58628
59152
 
58629
59153
  var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
58630
59154
 
58631
- var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif";
59155
+ var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\tfloat depth = unpackRGBAToDepth( texture2D( depths, uv ) );\n\t\t#ifdef USE_REVERSEDEPTHBUF\n\t\t\treturn step( depth, compare );\n\t\t#else\n\t\t\treturn step( compare, depth );\n\t\t#endif\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\t#ifdef USE_REVERSEDEPTHBUF\n\t\t\tfloat hard_shadow = step( distribution.x, compare );\n\t\t#else\n\t\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\t#endif\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif";
58632
59156
 
58633
59157
  var shadowmap_pars_vertex = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif";
58634
59158
 
@@ -58678,7 +59202,7 @@ const fragment$f = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform fl
58678
59202
 
58679
59203
  const vertex$e = "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <batching_vertex>\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}";
58680
59204
 
58681
- const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <triplanar_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}";
59205
+ const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <triplanar_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSEDEPTHBUF\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}";
58682
59206
 
58683
59207
  const vertex$d = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}";
58684
59208
 
@@ -60516,7 +61040,7 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
60516
61040
  }
60517
61041
 
60518
61042
  const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
60519
- const reverseDepthBuffer = parameters.reverseDepthBuffer === true && extensions.has( 'EXT_clip_control' );
61043
+ const reversedDepthBuffer = parameters.reversedDepthBuffer === true && extensions.has( 'EXT_clip_control' );
60520
61044
 
60521
61045
  const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
60522
61046
  const maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
@@ -60544,7 +61068,7 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
60544
61068
 
60545
61069
  precision: precision,
60546
61070
  logarithmicDepthBuffer: logarithmicDepthBuffer,
60547
- reverseDepthBuffer: reverseDepthBuffer,
61071
+ reversedDepthBuffer: reversedDepthBuffer,
60548
61072
 
60549
61073
  maxTextures: maxTextures,
60550
61074
  maxVertexTextures: maxVertexTextures,
@@ -61149,6 +61673,17 @@ class PMREMGenerator {
61149
61673
  renderer.toneMapping = NoToneMapping;
61150
61674
  renderer.autoClear = false;
61151
61675
 
61676
+ // https://github.com/mrdoob/three.js/issues/31413#issuecomment-3095966812
61677
+ const reversedDepthBuffer = renderer.state.buffers.depth.getReversed();
61678
+
61679
+ if ( reversedDepthBuffer ) {
61680
+
61681
+ renderer.setRenderTarget( cubeUVRenderTarget );
61682
+ renderer.clearDepth();
61683
+ renderer.setRenderTarget( null );
61684
+
61685
+ }
61686
+
61152
61687
  const backgroundMaterial = new MeshBasicMaterial( {
61153
61688
  name: 'PMREM.Background',
61154
61689
  side: BackSide,
@@ -63780,7 +64315,9 @@ function getEncodingComponents( colorSpace ) {
63780
64315
  function getShaderErrors( gl, shader, type ) {
63781
64316
 
63782
64317
  const status = gl.getShaderParameter( shader, gl.COMPILE_STATUS );
63783
- const errors = gl.getShaderInfoLog( shader ).trim();
64318
+
64319
+ const shaderInfoLog = gl.getShaderInfoLog( shader ) || '';
64320
+ const errors = shaderInfoLog.trim();
63784
64321
 
63785
64322
  if ( status && errors === '' ) return '';
63786
64323
 
@@ -64284,8 +64821,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64284
64821
  parameters.bumpMap ? '#define USE_BUMPMAP' : '',
64285
64822
  parameters.normalMap ? '#define USE_NORMALMAP' : '',
64286
64823
  parameters.normalMapMode === TriPlanarMapping ? '#define USE_NORMALMAP_TRIPLANAR' : parameters.normalMapMode === CylindricalMapping ? '#define USE_NORMALMAP_CYLINDRICAL' : parameters.normalMapMode === UVMapping ? '#define USE_NORMALMAP_UV' : '',
64287
- parameters.normalMapObjectSpace && [UVMapping, CylindricalMapping].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
64288
- parameters.normalMapTangentSpace && [UVMapping, CylindricalMapping].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
64824
+ parameters.normalMapObjectSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
64825
+ parameters.normalMapTangentSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
64289
64826
  parameters.displacementMap ? '#define USE_DISPLACEMENTMAP' : '',
64290
64827
  parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
64291
64828
 
@@ -64295,9 +64832,9 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64295
64832
  parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',
64296
64833
  parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
64297
64834
  parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',
64298
- parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
64299
- : parameters.clearcoatNormalMapMode === CylindricalMapping ? '#define USE_CLEARCOAT_NORMALMAP_CYLINDRICAL'
64300
- : parameters.clearcoatNormalMapMode === UVMapping ? '#define USE_CLEARCOAT_NORMALMAP_UV' : '',
64835
+ parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
64836
+ : parameters.clearcoatNormalMapMode === CylindricalMapping ? '#define USE_CLEARCOAT_NORMALMAP_CYLINDRICAL'
64837
+ : parameters.clearcoatNormalMapMode === UVMapping ? '#define USE_CLEARCOAT_NORMALMAP_UV' : '',
64301
64838
 
64302
64839
  parameters.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '',
64303
64840
  parameters.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '',
@@ -64385,7 +64922,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64385
64922
  parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
64386
64923
 
64387
64924
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
64388
- parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
64925
+ parameters.reversedDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
64389
64926
 
64390
64927
  'uniform mat4 modelMatrix;',
64391
64928
  'uniform mat4 modelViewMatrix;',
@@ -64491,8 +65028,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64491
65028
  parameters.bumpMap ? '#define USE_BUMPMAP' : '',
64492
65029
  parameters.normalMap ? '#define USE_NORMALMAP' : '',
64493
65030
  parameters.normalMapMode === TriPlanarMapping ? '#define USE_NORMALMAP_TRIPLANAR' : parameters.normalMapMode === CylindricalMapping ? '#define USE_NORMALMAP_CYLINDRICAL' : parameters.normalMapMode === UVMapping ? '#define USE_NORMALMAP_UV' : '',
64494
- parameters.normalMapObjectSpace && [UVMapping, CylindricalMapping].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
64495
- parameters.normalMapTangentSpace && [UVMapping, CylindricalMapping].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
65031
+ parameters.normalMapObjectSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
65032
+ parameters.normalMapTangentSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
64496
65033
  parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
64497
65034
 
64498
65035
  parameters.anisotropy ? '#define USE_ANISOTROPY' : '',
@@ -64502,9 +65039,9 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64502
65039
  parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',
64503
65040
  parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
64504
65041
  parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',
64505
- parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
64506
- : parameters.clearcoatNormalMapMode === CylindricalMapping ? '#define USE_CLEARCOAT_NORMALMAP_CYLINDRICAL'
64507
- : parameters.clearcoatNormalMapMode === UVMapping ? '#define USE_CLEARCOAT_NORMALMAP_UV' : '',
65042
+ parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
65043
+ : parameters.clearcoatNormalMapMode === CylindricalMapping ? '#define USE_CLEARCOAT_NORMALMAP_CYLINDRICAL'
65044
+ : parameters.clearcoatNormalMapMode === UVMapping ? '#define USE_CLEARCOAT_NORMALMAP_UV' : '',
64508
65045
 
64509
65046
  parameters.dispersion ? '#define USE_DISPERSION' : '',
64510
65047
 
@@ -64561,7 +65098,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64561
65098
  parameters.decodeVideoTextureEmissive ? '#define DECODE_VIDEO_TEXTURE_EMISSIVE' : '',
64562
65099
 
64563
65100
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
64564
- parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
65101
+ parameters.reversedDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
64565
65102
 
64566
65103
  'uniform mat4 modelViewMatrix;',
64567
65104
  'uniform mat4 viewMatrix;',
@@ -64662,9 +65199,13 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64662
65199
  // check for link errors
64663
65200
  if ( renderer.debug.checkShaderErrors ) {
64664
65201
 
64665
- const programLog = gl.getProgramInfoLog( program ).trim();
64666
- const vertexLog = gl.getShaderInfoLog( glVertexShader ).trim();
64667
- const fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();
65202
+ const programInfoLog = gl.getProgramInfoLog( program ) || '';
65203
+ const vertexShaderInfoLog = gl.getShaderInfoLog( glVertexShader ) || '';
65204
+ const fragmentShaderInfoLog = gl.getShaderInfoLog( glFragmentShader ) || '';
65205
+
65206
+ const programLog = programInfoLog.trim();
65207
+ const vertexLog = vertexShaderInfoLog.trim();
65208
+ const fragmentLog = fragmentShaderInfoLog.trim();
64668
65209
 
64669
65210
  let runnable = true;
64670
65211
  let haveDiagnostics = true;
@@ -65050,7 +65591,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
65050
65591
  }
65051
65592
 
65052
65593
  const currentRenderTarget = renderer.getRenderTarget();
65053
- const reverseDepthBuffer = renderer.state.buffers.depth.getReversed();
65594
+ const reversedDepthBuffer = renderer.state.buffers.depth.getReversed();
65054
65595
 
65055
65596
  const IS_INSTANCEDMESH = object.isInstancedMesh === true;
65056
65597
  const IS_BATCHEDMESH = object.isBatchedMesh === true;
@@ -65256,7 +65797,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
65256
65797
 
65257
65798
  sizeAttenuation: material.sizeAttenuation === true,
65258
65799
  logarithmicDepthBuffer: logarithmicDepthBuffer,
65259
- reverseDepthBuffer: reverseDepthBuffer,
65800
+ reversedDepthBuffer: reversedDepthBuffer,
65260
65801
 
65261
65802
  skinning: object.isSkinnedMesh === true,
65262
65803
 
@@ -65389,7 +65930,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
65389
65930
  array.push( parameters.anisotropyMapUv );
65390
65931
  array.push( parameters.clearcoatMapUv );
65391
65932
  array.push( parameters.clearcoatNormalMapUv );
65392
- array.push( parameters.clearcoatNormalMapMode);
65933
+ array.push( parameters.clearcoatNormalMapMode );
65393
65934
  array.push( parameters.clearcoatRoughnessMapUv );
65394
65935
  array.push( parameters.iridescenceMapUv );
65395
65936
  array.push( parameters.iridescenceThicknessMapUv );
@@ -65488,7 +66029,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
65488
66029
  _programLayers.enable( 2 );
65489
66030
  if ( parameters.logarithmicDepthBuffer )
65490
66031
  _programLayers.enable( 3 );
65491
- if ( parameters.reverseDepthBuffer )
66032
+ if ( parameters.reversedDepthBuffer )
65492
66033
  _programLayers.enable( 4 );
65493
66034
  if ( parameters.skinning )
65494
66035
  _programLayers.enable( 5 );
@@ -66655,7 +67196,17 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
66655
67196
 
66656
67197
  // Set GL state for depth map.
66657
67198
  _state.setBlending( NoBlending );
66658
- _state.buffers.color.setClear( 1, 1, 1, 1 );
67199
+
67200
+ if ( _state.buffers.depth.getReversed() ) {
67201
+
67202
+ _state.buffers.color.setClear( 0, 0, 0, 0 );
67203
+
67204
+ } else {
67205
+
67206
+ _state.buffers.color.setClear( 1, 1, 1, 1 );
67207
+
67208
+ }
67209
+
66659
67210
  _state.buffers.depth.setTest( true );
66660
67211
  _state.setScissorTest( false );
66661
67212
 
@@ -68829,7 +69380,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
68829
69380
 
68830
69381
  if ( texture.isVideoTexture ) updateVideoTexture( texture );
68831
69382
 
68832
- if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
69383
+ if ( texture.isRenderTargetTexture === false && texture.isExternalTexture !== true && texture.version > 0 && textureProperties.__version !== texture.version ) {
68833
69384
 
68834
69385
  const image = texture.image;
68835
69386
 
@@ -68848,6 +69399,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
68848
69399
 
68849
69400
  }
68850
69401
 
69402
+ } else if ( texture.isExternalTexture ) {
69403
+
69404
+ textureProperties.__webglTexture = texture.sourceTexture ? texture.sourceTexture : null;
69405
+
68851
69406
  }
68852
69407
 
68853
69408
  state.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
@@ -68858,7 +69413,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
68858
69413
 
68859
69414
  const textureProperties = properties.get( texture );
68860
69415
 
68861
- if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
69416
+ if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
68862
69417
 
68863
69418
  uploadTexture( textureProperties, texture, slot );
68864
69419
  return;
@@ -68873,7 +69428,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
68873
69428
 
68874
69429
  const textureProperties = properties.get( texture );
68875
69430
 
68876
- if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
69431
+ if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
68877
69432
 
68878
69433
  uploadTexture( textureProperties, texture, slot );
68879
69434
  return;
@@ -70316,13 +70871,21 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
70316
70871
  const attachment = textures[ i ];
70317
70872
  const attachmentProperties = properties.get( attachment );
70318
70873
 
70319
- state.bindTexture( _gl.TEXTURE_2D, attachmentProperties.__webglTexture );
70320
- setTextureParameters( _gl.TEXTURE_2D, attachment );
70321
- setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, 0 );
70874
+ let glTextureType = _gl.TEXTURE_2D;
70875
+
70876
+ if ( renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
70877
+
70878
+ glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
70879
+
70880
+ }
70881
+
70882
+ state.bindTexture( glTextureType, attachmentProperties.__webglTexture );
70883
+ setTextureParameters( glTextureType, attachment );
70884
+ setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, glTextureType, 0 );
70322
70885
 
70323
70886
  if ( textureNeedsGenerateMipmaps( attachment ) ) {
70324
70887
 
70325
- generateMipmap( _gl.TEXTURE_2D );
70888
+ generateMipmap( glTextureType );
70326
70889
 
70327
70890
  }
70328
70891
 
@@ -70843,6 +71406,48 @@ function WebGLUtils( gl, extensions ) {
70843
71406
 
70844
71407
  }
70845
71408
 
71409
+ /**
71410
+ * Represents a texture created externally from the renderer context.
71411
+ *
71412
+ * This may be a texture from a protected media stream, device camera feed,
71413
+ * or other data feeds like a depth sensor.
71414
+ *
71415
+ * Note that this class is only supported in {@link WebGLRenderer} right now.
71416
+ *
71417
+ * @augments Texture
71418
+ */
71419
+ class ExternalTexture extends Texture {
71420
+
71421
+ /**
71422
+ * Creates a new raw texture.
71423
+ *
71424
+ * @param {?WebGLTexture} [sourceTexture=null] - The external texture.
71425
+ */
71426
+ constructor( sourceTexture = null ) {
71427
+
71428
+ super();
71429
+
71430
+ /**
71431
+ * The external source texture.
71432
+ *
71433
+ * @type {?WebGLTexture}
71434
+ * @default null
71435
+ */
71436
+ this.sourceTexture = sourceTexture;
71437
+
71438
+ /**
71439
+ * This flag can be used for type testing.
71440
+ *
71441
+ * @type {boolean}
71442
+ * @readonly
71443
+ * @default true
71444
+ */
71445
+ this.isExternalTexture = true;
71446
+
71447
+ }
71448
+
71449
+ }
71450
+
70846
71451
  const _occlusion_vertex = `
70847
71452
  void main() {
70848
71453
 
@@ -70882,9 +71487,9 @@ class WebXRDepthSensing {
70882
71487
  constructor() {
70883
71488
 
70884
71489
  /**
70885
- * A texture representing the depth of the user's environment.
71490
+ * An opaque texture representing the depth of the user's environment.
70886
71491
  *
70887
- * @type {?Texture}
71492
+ * @type {?ExternalTexture}
70888
71493
  */
70889
71494
  this.texture = null;
70890
71495
 
@@ -70914,18 +71519,14 @@ class WebXRDepthSensing {
70914
71519
  /**
70915
71520
  * Inits the depth sensing module
70916
71521
  *
70917
- * @param {WebGLRenderer} renderer - The renderer.
70918
71522
  * @param {XRWebGLDepthInformation} depthData - The XR depth data.
70919
71523
  * @param {XRRenderState} renderState - The XR render state.
70920
71524
  */
70921
- init( renderer, depthData, renderState ) {
71525
+ init( depthData, renderState ) {
70922
71526
 
70923
71527
  if ( this.texture === null ) {
70924
71528
 
70925
- const texture = new Texture();
70926
-
70927
- const texProps = renderer.properties.get( texture );
70928
- texProps.__webglTexture = depthData.texture;
71529
+ const texture = new ExternalTexture( depthData.texture );
70929
71530
 
70930
71531
  if ( ( depthData.depthNear !== renderState.depthNear ) || ( depthData.depthFar !== renderState.depthFar ) ) {
70931
71532
 
@@ -70986,7 +71587,7 @@ class WebXRDepthSensing {
70986
71587
  /**
70987
71588
  * Returns a texture representing the depth of the user's environment.
70988
71589
  *
70989
- * @return {?Texture} The depth texture.
71590
+ * @return {?ExternalTexture} The depth texture.
70990
71591
  */
70991
71592
  getDepthTexture() {
70992
71593
 
@@ -71036,6 +71637,7 @@ class WebXRManager extends EventDispatcher {
71036
71637
  let xrFrame = null;
71037
71638
 
71038
71639
  const depthSensing = new WebXRDepthSensing();
71640
+ const cameraAccessTextures = {};
71039
71641
  const attributes = gl.getContextAttributes();
71040
71642
 
71041
71643
  let initialRenderTarget = null;
@@ -71216,6 +71818,11 @@ class WebXRManager extends EventDispatcher {
71216
71818
  _currentDepthFar = null;
71217
71819
 
71218
71820
  depthSensing.reset();
71821
+ for ( const key in cameraAccessTextures ) {
71822
+
71823
+ delete cameraAccessTextures[ key ];
71824
+
71825
+ }
71219
71826
 
71220
71827
  // restore framebuffer/rendering state
71221
71828
 
@@ -71382,9 +71989,15 @@ class WebXRManager extends EventDispatcher {
71382
71989
  currentPixelRatio = renderer.getPixelRatio();
71383
71990
  renderer.getSize( currentSize );
71384
71991
 
71992
+ if ( typeof XRWebGLBinding !== 'undefined' ) {
71993
+
71994
+ glBinding = new XRWebGLBinding( session, gl );
71995
+
71996
+ }
71997
+
71385
71998
  // Check that the browser implements the necessary APIs to use an
71386
71999
  // XRProjectionLayer rather than an XRWebGLLayer
71387
- const useLayers = typeof XRWebGLBinding !== 'undefined' && 'createProjectionLayer' in XRWebGLBinding.prototype;
72000
+ const useLayers = glBinding !== null && 'createProjectionLayer' in XRWebGLBinding.prototype;
71388
72001
 
71389
72002
  if ( ! useLayers ) {
71390
72003
 
@@ -71437,8 +72050,6 @@ class WebXRManager extends EventDispatcher {
71437
72050
  scaleFactor: framebufferScaleFactor
71438
72051
  };
71439
72052
 
71440
- glBinding = new XRWebGLBinding( session, gl );
71441
-
71442
72053
  glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );
71443
72054
 
71444
72055
  session.updateRenderState( { layers: [ glProjLayer ] } );
@@ -71706,9 +72317,10 @@ class WebXRManager extends EventDispatcher {
71706
72317
 
71707
72318
  }
71708
72319
 
71709
- cameraL.layers.mask = camera.layers.mask | 0b010;
71710
- cameraR.layers.mask = camera.layers.mask | 0b100;
71711
- cameraXR.layers.mask = cameraL.layers.mask | cameraR.layers.mask;
72320
+ // inherit camera layers and enable eye layers (1 = left, 2 = right)
72321
+ cameraXR.layers.mask = camera.layers.mask | 0b110;
72322
+ cameraL.layers.mask = cameraXR.layers.mask & 0b011;
72323
+ cameraR.layers.mask = cameraXR.layers.mask & 0b101;
71712
72324
 
71713
72325
  const parent = camera.parent;
71714
72326
  const cameras = cameraXR.cameras;
@@ -71789,7 +72401,7 @@ class WebXRManager extends EventDispatcher {
71789
72401
  /**
71790
72402
  * Returns the amount of foveation used by the XR compositor for the projection layer.
71791
72403
  *
71792
- * @return {number} The amount of foveation.
72404
+ * @return {number|undefined} The amount of foveation.
71793
72405
  */
71794
72406
  this.getFoveation = function () {
71795
72407
 
@@ -71852,6 +72464,19 @@ class WebXRManager extends EventDispatcher {
71852
72464
 
71853
72465
  };
71854
72466
 
72467
+ /**
72468
+ * Retrieves an opaque texture from the view-aligned {@link XRCamera}.
72469
+ * Only available during the current animation loop.
72470
+ *
72471
+ * @param {XRCamera} xrCamera - The camera to query.
72472
+ * @return {?Texture} An opaque texture representing the current raw camera frame.
72473
+ */
72474
+ this.getCameraTexture = function ( xrCamera ) {
72475
+
72476
+ return cameraAccessTextures[ xrCamera ];
72477
+
72478
+ };
72479
+
71855
72480
  // Animation Loop
71856
72481
 
71857
72482
  let onAnimationFrameCallback = null;
@@ -71957,7 +72582,42 @@ class WebXRManager extends EventDispatcher {
71957
72582
 
71958
72583
  if ( depthData && depthData.isValid && depthData.texture ) {
71959
72584
 
71960
- depthSensing.init( renderer, depthData, session.renderState );
72585
+ depthSensing.init( depthData, session.renderState );
72586
+
72587
+ }
72588
+
72589
+ }
72590
+
72591
+ const cameraAccessEnabled = enabledFeatures &&
72592
+ enabledFeatures.includes( 'camera-access' );
72593
+
72594
+ if ( cameraAccessEnabled ) {
72595
+
72596
+ renderer.state.unbindTexture();
72597
+
72598
+ if ( glBinding ) {
72599
+
72600
+ for ( let i = 0; i < views.length; i ++ ) {
72601
+
72602
+ const camera = views[ i ].camera;
72603
+
72604
+ if ( camera ) {
72605
+
72606
+ let cameraTex = cameraAccessTextures[ camera ];
72607
+
72608
+ if ( ! cameraTex ) {
72609
+
72610
+ cameraTex = new ExternalTexture();
72611
+ cameraAccessTextures[ camera ] = cameraTex;
72612
+
72613
+ }
72614
+
72615
+ const glTexture = glBinding.getCameraImage( camera );
72616
+ cameraTex.sourceTexture = glTexture;
72617
+
72618
+ }
72619
+
72620
+ }
71961
72621
 
71962
72622
  }
71963
72623
 
@@ -72146,17 +72806,17 @@ function WebGLMaterials( renderer, properties ) {
72146
72806
 
72147
72807
  }
72148
72808
 
72149
- if ( material.texture3DMatrix ) {
72809
+ if ( material.texture3DMatrix ) {
72150
72810
 
72151
- uniforms.texture3DMatrix.value.copy( material.texture3DMatrix );
72811
+ uniforms.texture3DMatrix.value.copy( material.texture3DMatrix );
72152
72812
 
72153
- }
72813
+ }
72154
72814
 
72155
- if ( material.triplanarHardness ) {
72815
+ if ( material.triplanarHardness ) {
72156
72816
 
72157
- uniforms.triplanarHardness.value = material.triplanarHardness;
72817
+ uniforms.triplanarHardness.value = material.triplanarHardness;
72158
72818
 
72159
- }
72819
+ }
72160
72820
 
72161
72821
  if ( material.alphaMap ) {
72162
72822
 
@@ -73020,7 +73680,7 @@ class WebGLRenderer {
73020
73680
  preserveDrawingBuffer = false,
73021
73681
  powerPreference = 'default',
73022
73682
  failIfMajorPerformanceCaveat = false,
73023
- reverseDepthBuffer = false,
73683
+ reversedDepthBuffer = false,
73024
73684
  } = parameters;
73025
73685
 
73026
73686
  /**
@@ -73253,7 +73913,6 @@ class WebGLRenderer {
73253
73913
 
73254
73914
  // camera matrices cache
73255
73915
 
73256
- const _currentProjectionMatrix = new Matrix4();
73257
73916
  const _projScreenMatrix = new Matrix4();
73258
73917
 
73259
73918
  const _vector3 = new Vector3();
@@ -73349,7 +74008,7 @@ class WebGLRenderer {
73349
74008
 
73350
74009
  state = new WebGLState( _gl, extensions );
73351
74010
 
73352
- if ( capabilities.reverseDepthBuffer && reverseDepthBuffer ) {
74011
+ if ( capabilities.reversedDepthBuffer && reversedDepthBuffer ) {
73353
74012
 
73354
74013
  state.buffers.depth.setReversed( true );
73355
74014
 
@@ -74497,7 +75156,7 @@ class WebGLRenderer {
74497
75156
  renderStateStack.push( currentRenderState );
74498
75157
 
74499
75158
  _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
74500
- _frustum.setFromProjectionMatrix( _projScreenMatrix );
75159
+ _frustum.setFromProjectionMatrix( _projScreenMatrix, WebGLCoordinateSystem, camera.reversedDepth );
74501
75160
 
74502
75161
  _localClippingEnabled = this.localClippingEnabled;
74503
75162
  _clippingEnabled = clipping.init( this.clippingPlanes, _localClippingEnabled );
@@ -75328,23 +75987,17 @@ class WebGLRenderer {
75328
75987
 
75329
75988
  // common camera uniforms
75330
75989
 
75331
- const reverseDepthBuffer = state.buffers.depth.getReversed();
75332
-
75333
- if ( reverseDepthBuffer ) {
75990
+ const reversedDepthBuffer = state.buffers.depth.getReversed();
75334
75991
 
75335
- _currentProjectionMatrix.copy( camera.projectionMatrix );
75336
-
75337
- toNormalizedProjectionMatrix( _currentProjectionMatrix );
75338
- toReversedProjectionMatrix( _currentProjectionMatrix );
75339
-
75340
- p_uniforms.setValue( _gl, 'projectionMatrix', _currentProjectionMatrix );
75341
-
75342
- } else {
75992
+ if ( reversedDepthBuffer && camera.reversedDepth !== true ) {
75343
75993
 
75344
- p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
75994
+ camera._reversedDepth = true;
75995
+ camera.updateProjectionMatrix();
75345
75996
 
75346
75997
  }
75347
75998
 
75999
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
76000
+
75348
76001
  p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
75349
76002
 
75350
76003
  const uCamPos = p_uniforms.map.cameraPosition;
@@ -75774,9 +76427,15 @@ class WebGLRenderer {
75774
76427
 
75775
76428
  } else if ( isRenderTarget3D ) {
75776
76429
 
75777
- const textureProperties = properties.get( renderTarget.texture );
75778
76430
  const layer = activeCubeFace;
75779
- _gl.framebufferTextureLayer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, activeMipmapLevel, layer );
76431
+
76432
+ for ( let i = 0; i < renderTarget.textures.length; i ++ ) {
76433
+
76434
+ const textureProperties = properties.get( renderTarget.textures[ i ] );
76435
+
76436
+ _gl.framebufferTextureLayer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, textureProperties.__webglTexture, activeMipmapLevel, layer );
76437
+
76438
+ }
75780
76439
 
75781
76440
  } else if ( renderTarget !== null && activeMipmapLevel !== 0 ) {
75782
76441
 
@@ -75928,7 +76587,7 @@ class WebGLRenderer {
75928
76587
  _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
75929
76588
  _gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
75930
76589
 
75931
- // when using MRT, select the corect color buffer for the subsequent read command
76590
+ // when using MRT, select the correct color buffer for the subsequent read command
75932
76591
 
75933
76592
  if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
75934
76593
 
@@ -76747,6 +77406,7 @@ exports.TetrahedronGeometry = TetrahedronGeometry;
76747
77406
  exports.Texture = Texture;
76748
77407
  exports.TextureLoader = TextureLoader;
76749
77408
  exports.TextureUtils = TextureUtils;
77409
+ exports.Timer = Timer;
76750
77410
  exports.TimestampQuery = TimestampQuery;
76751
77411
  exports.TorusGeometry = TorusGeometry;
76752
77412
  exports.TorusKnotGeometry = TorusKnotGeometry;