@plastic-software/three 0.178.0 → 0.180.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 (245) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +950 -230
  3. package/build/three.core.js +754 -138
  4. package/build/three.core.min.js +1 -1
  5. package/build/three.module.js +197 -96
  6. package/build/three.module.min.js +1 -1
  7. package/build/three.tsl.js +99 -25
  8. package/build/three.tsl.min.js +1 -1
  9. package/build/three.webgpu.js +4586 -1499
  10. package/build/three.webgpu.min.js +1 -1
  11. package/build/three.webgpu.nodes.js +4544 -1499
  12. package/build/three.webgpu.nodes.min.js +1 -1
  13. package/examples/jsm/Addons.js +2 -3
  14. package/examples/jsm/capabilities/WebGPU.js +1 -1
  15. package/examples/jsm/controls/ArcballControls.js +7 -7
  16. package/examples/jsm/controls/DragControls.js +6 -56
  17. package/examples/jsm/controls/FirstPersonControls.js +2 -2
  18. package/examples/jsm/controls/PointerLockControls.js +0 -8
  19. package/examples/jsm/csm/CSMShadowNode.js +4 -4
  20. package/examples/jsm/environments/RoomEnvironment.js +8 -3
  21. package/examples/jsm/exporters/GLTFExporter.js +30 -22
  22. package/examples/jsm/exporters/KTX2Exporter.js +4 -2
  23. package/examples/jsm/exporters/PLYExporter.js +1 -1
  24. package/examples/jsm/exporters/USDZExporter.js +676 -299
  25. package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
  26. package/examples/jsm/interactive/HTMLMesh.js +5 -3
  27. package/examples/jsm/libs/ktx-parse.module.js +1 -1
  28. package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
  29. package/examples/jsm/lights/LightProbeGenerator.js +14 -3
  30. package/examples/jsm/lines/Line2.js +3 -3
  31. package/examples/jsm/lines/LineGeometry.js +1 -1
  32. package/examples/jsm/lines/LineSegments2.js +2 -2
  33. package/examples/jsm/lines/Wireframe.js +2 -2
  34. package/examples/jsm/lines/WireframeGeometry2.js +1 -1
  35. package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
  36. package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
  37. package/examples/jsm/loaders/ColladaLoader.js +1 -1
  38. package/examples/jsm/loaders/EXRLoader.js +210 -22
  39. package/examples/jsm/loaders/FBXLoader.js +1 -1
  40. package/examples/jsm/loaders/GLTFLoader.js +9 -5
  41. package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
  42. package/examples/jsm/loaders/HDRLoader.js +486 -0
  43. package/examples/jsm/loaders/KTX2Loader.js +112 -32
  44. package/examples/jsm/loaders/MaterialXLoader.js +212 -30
  45. package/examples/jsm/loaders/RGBELoader.js +7 -473
  46. package/examples/jsm/loaders/TTFLoader.js +13 -1
  47. package/examples/jsm/loaders/USDLoader.js +219 -0
  48. package/examples/jsm/loaders/USDZLoader.js +4 -892
  49. package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
  50. package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
  51. package/examples/jsm/loaders/usd/USDAParser.js +741 -0
  52. package/examples/jsm/loaders/usd/USDCParser.js +17 -0
  53. package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
  54. package/examples/jsm/math/ColorSpaces.js +19 -1
  55. package/examples/jsm/math/ConvexHull.js +2 -2
  56. package/examples/jsm/math/Lut.js +2 -2
  57. package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
  58. package/examples/jsm/misc/ProgressiveLightMap.js +1 -1
  59. package/examples/jsm/misc/Volume.js +1 -1
  60. package/examples/jsm/objects/LensflareMesh.js +3 -3
  61. package/examples/jsm/objects/SkyMesh.js +2 -2
  62. package/examples/jsm/physics/RapierPhysics.js +14 -5
  63. package/examples/jsm/postprocessing/GTAOPass.js +10 -9
  64. package/examples/jsm/postprocessing/OutlinePass.js +17 -17
  65. package/examples/jsm/postprocessing/SSAOPass.js +10 -9
  66. package/examples/jsm/postprocessing/SSRPass.js +37 -8
  67. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
  68. package/examples/jsm/transpiler/GLSLDecoder.js +23 -20
  69. package/examples/jsm/transpiler/TSLEncoder.js +2 -10
  70. package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
  71. package/examples/jsm/tsl/display/AnamorphicNode.js +27 -4
  72. package/examples/jsm/tsl/display/BloomNode.js +7 -6
  73. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
  74. package/examples/jsm/tsl/display/DepthOfFieldNode.js +439 -90
  75. package/examples/jsm/tsl/display/GTAONode.js +8 -0
  76. package/examples/jsm/tsl/display/GaussianBlurNode.js +51 -41
  77. package/examples/jsm/tsl/display/OutlineNode.js +2 -2
  78. package/examples/jsm/tsl/display/SSRNode.js +180 -65
  79. package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
  80. package/examples/jsm/tsl/display/boxBlur.js +64 -0
  81. package/examples/jsm/tsl/display/hashBlur.js +15 -18
  82. package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
  83. package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
  84. package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
  85. package/examples/jsm/webxr/OculusHandModel.js +1 -1
  86. package/package.json +1 -1
  87. package/src/Three.Core.js +2 -0
  88. package/src/Three.TSL.js +98 -24
  89. package/src/animation/AnimationClip.js +17 -2
  90. package/src/animation/KeyframeTrack.js +1 -1
  91. package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
  92. package/src/animation/tracks/StringKeyframeTrack.js +1 -1
  93. package/src/cameras/Camera.js +14 -0
  94. package/src/cameras/OrthographicCamera.js +1 -1
  95. package/src/cameras/PerspectiveCamera.js +1 -1
  96. package/src/constants.js +11 -3
  97. package/src/core/BufferGeometry.js +2 -2
  98. package/{examples/jsm/misc → src/core}/Timer.js +4 -42
  99. package/src/extras/PMREMGenerator.js +11 -0
  100. package/src/extras/TextureUtils.js +2 -1
  101. package/src/extras/lib/earcut.js +1 -1
  102. package/src/helpers/CameraHelper.js +41 -11
  103. package/src/helpers/SkeletonHelper.js +35 -6
  104. package/src/lights/LightShadow.js +21 -8
  105. package/src/lights/PointLightShadow.js +1 -1
  106. package/src/lights/webgpu/ProjectorLight.js +1 -1
  107. package/src/loaders/FileLoader.js +25 -2
  108. package/src/loaders/ImageBitmapLoader.js +23 -0
  109. package/src/loaders/Loader.js +14 -0
  110. package/src/loaders/LoadingManager.js +23 -0
  111. package/src/materials/Material.js +12 -0
  112. package/src/materials/MeshBasicMaterial.js +1 -1
  113. package/src/materials/MeshDistanceMaterial.js +1 -1
  114. package/src/materials/nodes/Line2NodeMaterial.js +0 -8
  115. package/src/materials/nodes/NodeMaterial.js +1 -1
  116. package/src/materials/nodes/PointsNodeMaterial.js +86 -28
  117. package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
  118. package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
  119. package/src/math/ColorManagement.js +7 -1
  120. package/src/math/Frustum.js +19 -8
  121. package/src/math/FrustumArray.js +10 -5
  122. package/src/math/Line3.js +129 -2
  123. package/src/math/Matrix4.js +48 -27
  124. package/src/math/Spherical.js +2 -2
  125. package/src/nodes/Nodes.js +4 -0
  126. package/src/nodes/TSL.js +4 -0
  127. package/src/nodes/accessors/BufferNode.js +1 -1
  128. package/src/nodes/accessors/Camera.js +142 -16
  129. package/src/nodes/accessors/ClippingNode.js +6 -5
  130. package/src/nodes/accessors/CubeTextureNode.js +2 -2
  131. package/src/nodes/accessors/InstanceNode.js +3 -1
  132. package/src/nodes/accessors/Normal.js +11 -11
  133. package/src/nodes/accessors/Object3DNode.js +1 -1
  134. package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
  135. package/src/nodes/accessors/ReferenceNode.js +19 -4
  136. package/src/nodes/accessors/SceneNode.js +1 -1
  137. package/src/nodes/accessors/StorageTextureNode.js +1 -1
  138. package/src/nodes/accessors/Texture3DNode.js +13 -0
  139. package/src/nodes/accessors/TextureNode.js +83 -19
  140. package/src/nodes/code/FunctionCallNode.js +19 -0
  141. package/src/nodes/code/FunctionNode.js +23 -0
  142. package/src/nodes/core/ArrayNode.js +12 -0
  143. package/src/nodes/core/AssignNode.js +6 -2
  144. package/src/nodes/core/ContextNode.js +44 -1
  145. package/src/nodes/core/Node.js +30 -22
  146. package/src/nodes/core/NodeBuilder.js +71 -32
  147. package/src/nodes/core/NodeFrame.js +1 -1
  148. package/src/nodes/core/NodeUniform.js +1 -1
  149. package/src/nodes/core/NodeUtils.js +5 -3
  150. package/src/nodes/core/StackNode.js +71 -4
  151. package/src/nodes/core/StructNode.js +5 -5
  152. package/src/nodes/core/StructTypeNode.js +1 -0
  153. package/src/nodes/core/SubBuildNode.js +2 -2
  154. package/src/nodes/core/UniformNode.js +79 -14
  155. package/src/nodes/core/VarNode.js +83 -15
  156. package/src/nodes/display/FrontFacingNode.js +4 -8
  157. package/src/nodes/display/PassNode.js +148 -2
  158. package/src/nodes/display/ScreenNode.js +42 -13
  159. package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
  160. package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
  161. package/src/nodes/display/ViewportTextureNode.js +94 -4
  162. package/src/nodes/functions/PhysicalLightingModel.js +2 -2
  163. package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
  164. package/src/nodes/gpgpu/ComputeNode.js +67 -23
  165. package/src/nodes/gpgpu/SubgroupFunctionNode.js +430 -0
  166. package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
  167. package/src/nodes/lighting/LightsNode.js +1 -1
  168. package/src/nodes/lighting/ProjectorLightNode.js +19 -6
  169. package/src/nodes/lighting/ShadowFilterNode.js +1 -1
  170. package/src/nodes/materialx/MaterialXNodes.js +131 -2
  171. package/src/nodes/materialx/lib/mx_noise.js +165 -1
  172. package/src/nodes/math/BitcastNode.js +156 -0
  173. package/src/nodes/math/ConditionalNode.js +19 -3
  174. package/src/nodes/math/MathNode.js +72 -60
  175. package/src/nodes/math/OperatorNode.js +26 -25
  176. package/src/nodes/tsl/TSLCore.js +477 -142
  177. package/src/nodes/utils/DebugNode.js +1 -1
  178. package/src/nodes/utils/EventNode.js +83 -0
  179. package/src/nodes/utils/JoinNode.js +3 -1
  180. package/src/nodes/utils/MemberNode.js +58 -7
  181. package/src/nodes/utils/RTTNode.js +10 -1
  182. package/src/nodes/utils/ReflectorNode.js +51 -7
  183. package/src/nodes/utils/SampleNode.js +12 -2
  184. package/src/nodes/utils/SplitNode.js +11 -0
  185. package/src/nodes/utils/Timer.js +0 -47
  186. package/src/objects/BatchedMesh.js +6 -4
  187. package/src/objects/LOD.js +1 -1
  188. package/src/objects/Sprite.js +2 -2
  189. package/src/renderers/WebGLRenderer.js +21 -31
  190. package/src/renderers/common/Attributes.js +1 -1
  191. package/src/renderers/common/Backend.js +19 -1
  192. package/src/renderers/common/Bindings.js +21 -18
  193. package/src/renderers/common/ChainMap.js +1 -1
  194. package/src/renderers/common/Color4.js +2 -2
  195. package/src/renderers/common/DataMap.js +1 -1
  196. package/src/renderers/common/Pipelines.js +1 -1
  197. package/src/renderers/common/PostProcessing.js +60 -5
  198. package/src/renderers/common/RenderContext.js +2 -2
  199. package/src/renderers/common/RenderObject.js +14 -2
  200. package/src/renderers/common/Renderer.js +55 -32
  201. package/src/renderers/common/SampledTexture.js +4 -72
  202. package/src/renderers/common/Sampler.js +91 -0
  203. package/src/renderers/common/Storage3DTexture.js +21 -0
  204. package/src/renderers/common/StorageArrayTexture.js +21 -0
  205. package/src/renderers/common/StorageTexture.js +19 -0
  206. package/src/renderers/common/Textures.js +52 -14
  207. package/src/renderers/common/TimestampQueryPool.js +3 -3
  208. package/src/renderers/common/XRManager.js +51 -17
  209. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  210. package/src/renderers/common/nodes/NodeLibrary.js +5 -5
  211. package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
  212. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
  213. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  214. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
  215. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
  216. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +21 -11
  217. package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
  218. package/src/renderers/webgl/WebGLCapabilities.js +2 -2
  219. package/src/renderers/webgl/WebGLMaterials.js +6 -6
  220. package/src/renderers/webgl/WebGLProgram.js +24 -18
  221. package/src/renderers/webgl/WebGLPrograms.js +4 -4
  222. package/src/renderers/webgl/WebGLShadowMap.js +11 -1
  223. package/src/renderers/webgl/WebGLTextures.js +20 -7
  224. package/src/renderers/webgl/WebGLUtils.js +3 -2
  225. package/src/renderers/webgl-fallback/WebGLBackend.js +207 -146
  226. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +112 -19
  227. package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -1
  228. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -3
  229. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -10
  230. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
  231. package/src/renderers/webgpu/WebGPUBackend.js +87 -44
  232. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +169 -99
  233. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +35 -31
  234. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -2
  235. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +10 -19
  236. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +120 -84
  237. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +3 -3
  238. package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
  239. package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
  240. package/src/renderers/webxr/WebXRManager.js +86 -11
  241. package/src/textures/ExternalTexture.js +56 -0
  242. package/src/textures/FramebufferTexture.js +2 -2
  243. package/src/textures/Source.js +12 -2
  244. package/src/textures/VideoTexture.js +27 -2
  245. package/examples/jsm/loaders/RGBMLoader.js +0 -1148
package/build/three.cjs CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  'use strict';
7
7
 
8
- const REVISION = '178';
8
+ const REVISION = '180';
9
9
 
10
10
  /**
11
11
  * Represents mouse buttons and interaction types in context of controls.
@@ -731,6 +731,14 @@ const UnsignedInt248Type = 1020;
731
731
  */
732
732
  const UnsignedInt5999Type = 35902;
733
733
 
734
+ /**
735
+ * An unsigned int 10_11_11 (packed) data type for textures.
736
+ *
737
+ * @type {number}
738
+ * @constant
739
+ */
740
+ const UnsignedInt101111Type = 35899;
741
+
734
742
  /**
735
743
  * Discards the red, green and blue components and reads just the alpha component.
736
744
  *
@@ -1672,8 +1680,8 @@ const InterpolationSamplingMode = {
1672
1680
  * @property {string} NORMAL - Normal sampling mode.
1673
1681
  * @property {string} CENTROID - Centroid sampling mode.
1674
1682
  * @property {string} SAMPLE - Sample-specific sampling mode.
1675
- * @property {string} FLAT_FIRST - Flat interpolation using the first vertex.
1676
- * @property {string} FLAT_EITHER - Flat interpolation using either vertex.
1683
+ * @property {string} FIRST - Flat interpolation using the first vertex.
1684
+ * @property {string} EITHER - Flat interpolation using either vertex.
1677
1685
  */
1678
1686
 
1679
1687
  /**
@@ -6285,38 +6293,6 @@ function probeAsync( gl, sync, interval ) {
6285
6293
 
6286
6294
  }
6287
6295
 
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
6296
  const LINEAR_REC709_TO_XYZ = /*@__PURE__*/ new Matrix3().set(
6321
6297
  0.4123908, 0.3575843, 0.1804808,
6322
6298
  0.2126390, 0.7151687, 0.0721923,
@@ -6349,7 +6325,7 @@ function createColorManagement() {
6349
6325
  * - luminanceCoefficients: RGB luminance coefficients
6350
6326
  *
6351
6327
  * Optional:
6352
- * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace }
6328
+ * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace, toneMappingMode: 'extended' | 'standard' }
6353
6329
  * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }
6354
6330
  *
6355
6331
  * Reference:
@@ -6418,6 +6394,12 @@ function createColorManagement() {
6418
6394
 
6419
6395
  },
6420
6396
 
6397
+ getToneMappingMode: function ( colorSpace ) {
6398
+
6399
+ return this.spaces[ colorSpace ].outputColorSpaceConfig.toneMappingMode || 'standard';
6400
+
6401
+ },
6402
+
6421
6403
  getLuminanceCoefficients: function ( target, colorSpace = this.workingColorSpace ) {
6422
6404
 
6423
6405
  return target.fromArray( this.spaces[ colorSpace ].luminanceCoefficients );
@@ -6728,13 +6710,23 @@ class Source {
6728
6710
 
6729
6711
  }
6730
6712
 
6713
+ /**
6714
+ * Returns the dimensions of the source into the given target vector.
6715
+ *
6716
+ * @param {(Vector2|Vector3)} target - The target object the result is written into.
6717
+ * @return {(Vector2|Vector3)} The dimensions of the source.
6718
+ */
6731
6719
  getSize( target ) {
6732
6720
 
6733
6721
  const data = this.data;
6734
6722
 
6735
- if ( data instanceof HTMLVideoElement ) {
6723
+ if ( ( typeof HTMLVideoElement !== 'undefined' ) && ( data instanceof HTMLVideoElement ) ) {
6724
+
6725
+ target.set( data.videoWidth, data.videoHeight, 0 );
6736
6726
 
6737
- target.set( data.videoWidth, data.videoHeight );
6727
+ } else if ( data instanceof VideoFrame ) {
6728
+
6729
+ target.set( data.displayHeight, data.displayWidth, 0 );
6738
6730
 
6739
6731
  } else if ( data !== null ) {
6740
6732
 
@@ -12417,11 +12409,13 @@ class Matrix4 {
12417
12409
  * @param {number} near - The distance from the camera to the near plane.
12418
12410
  * @param {number} far - The distance from the camera to the far plane.
12419
12411
  * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.
12412
+ * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
12420
12413
  * @return {Matrix4} A reference to this matrix.
12421
12414
  */
12422
- makePerspective( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem ) {
12415
+ makePerspective( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false ) {
12423
12416
 
12424
12417
  const te = this.elements;
12418
+
12425
12419
  const x = 2 * near / ( right - left );
12426
12420
  const y = 2 * near / ( top - bottom );
12427
12421
 
@@ -12430,19 +12424,28 @@ class Matrix4 {
12430
12424
 
12431
12425
  let c, d;
12432
12426
 
12433
- if ( coordinateSystem === WebGLCoordinateSystem ) {
12427
+ if ( reversedDepth ) {
12434
12428
 
12435
- c = - ( far + near ) / ( far - near );
12436
- d = ( -2 * far * near ) / ( far - near );
12429
+ c = near / ( far - near );
12430
+ d = ( far * near ) / ( far - near );
12437
12431
 
12438
- } else if ( coordinateSystem === WebGPUCoordinateSystem ) {
12432
+ } else {
12439
12433
 
12440
- c = - far / ( far - near );
12441
- d = ( - far * near ) / ( far - near );
12434
+ if ( coordinateSystem === WebGLCoordinateSystem ) {
12442
12435
 
12443
- } else {
12436
+ c = - ( far + near ) / ( far - near );
12437
+ d = ( -2 * far * near ) / ( far - near );
12438
+
12439
+ } else if ( coordinateSystem === WebGPUCoordinateSystem ) {
12444
12440
 
12445
- throw new Error( 'THREE.Matrix4.makePerspective(): Invalid coordinate system: ' + coordinateSystem );
12441
+ c = - far / ( far - near );
12442
+ d = ( - far * near ) / ( far - near );
12443
+
12444
+ } else {
12445
+
12446
+ throw new Error( 'THREE.Matrix4.makePerspective(): Invalid coordinate system: ' + coordinateSystem );
12447
+
12448
+ }
12446
12449
 
12447
12450
  }
12448
12451
 
@@ -12466,39 +12469,49 @@ class Matrix4 {
12466
12469
  * @param {number} near - The distance from the camera to the near plane.
12467
12470
  * @param {number} far - The distance from the camera to the far plane.
12468
12471
  * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.
12472
+ * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
12469
12473
  * @return {Matrix4} A reference to this matrix.
12470
12474
  */
12471
- makeOrthographic( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem ) {
12475
+ makeOrthographic( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false ) {
12472
12476
 
12473
12477
  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
 
12478
- const x = ( right + left ) * w;
12479
- const y = ( top + bottom ) * h;
12479
+ const x = 2 / ( right - left );
12480
+ const y = 2 / ( top - bottom );
12480
12481
 
12481
- let z, zInv;
12482
+ const a = - ( right + left ) / ( right - left );
12483
+ const b = - ( top + bottom ) / ( top - bottom );
12482
12484
 
12483
- if ( coordinateSystem === WebGLCoordinateSystem ) {
12484
-
12485
- z = ( far + near ) * p;
12486
- zInv = -2 * p;
12485
+ let c, d;
12487
12486
 
12488
- } else if ( coordinateSystem === WebGPUCoordinateSystem ) {
12487
+ if ( reversedDepth ) {
12489
12488
 
12490
- z = near * p;
12491
- zInv = -1 * p;
12489
+ c = 1 / ( far - near );
12490
+ d = far / ( far - near );
12492
12491
 
12493
12492
  } else {
12494
12493
 
12495
- throw new Error( 'THREE.Matrix4.makeOrthographic(): Invalid coordinate system: ' + coordinateSystem );
12494
+ if ( coordinateSystem === WebGLCoordinateSystem ) {
12495
+
12496
+ c = -2 / ( far - near );
12497
+ d = - ( far + near ) / ( far - near );
12498
+
12499
+ } else if ( coordinateSystem === WebGPUCoordinateSystem ) {
12500
+
12501
+ c = -1 / ( far - near );
12502
+ d = - near / ( far - near );
12503
+
12504
+ } else {
12505
+
12506
+ throw new Error( 'THREE.Matrix4.makeOrthographic(): Invalid coordinate system: ' + coordinateSystem );
12507
+
12508
+ }
12496
12509
 
12497
12510
  }
12498
12511
 
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;
12512
+ te[ 0 ] = x; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = a;
12513
+ te[ 1 ] = 0; te[ 5 ] = y; te[ 9 ] = 0; te[ 13 ] = b;
12514
+ te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = c; te[ 14 ] = d;
12502
12515
  te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; te[ 15 ] = 1;
12503
12516
 
12504
12517
  return this;
@@ -16918,6 +16931,18 @@ class Material extends EventDispatcher {
16918
16931
 
16919
16932
  }
16920
16933
 
16934
+ if ( this.sheenColorMap && this.sheenColorMap.isTexture ) {
16935
+
16936
+ data.sheenColorMap = this.sheenColorMap.toJSON( meta ).uuid;
16937
+
16938
+ }
16939
+
16940
+ if ( this.sheenRoughnessMap && this.sheenRoughnessMap.isTexture ) {
16941
+
16942
+ data.sheenRoughnessMap = this.sheenRoughnessMap.toJSON( meta ).uuid;
16943
+
16944
+ }
16945
+
16921
16946
  if ( this.dispersion !== undefined ) data.dispersion = this.dispersion;
16922
16947
 
16923
16948
  if ( this.iridescence !== undefined ) data.iridescence = this.iridescence;
@@ -17292,7 +17317,7 @@ class MeshBasicMaterial extends Material {
17292
17317
  * @type {Color}
17293
17318
  * @default (1,1,1)
17294
17319
  */
17295
- this.color = new Color( 0xffffff ); // emissive
17320
+ this.color = new Color( 0xffffff ); // diffuse
17296
17321
 
17297
17322
  /**
17298
17323
  * The color map. May optionally include an alpha channel, typically combined
@@ -18875,7 +18900,7 @@ class BufferGeometry extends EventDispatcher {
18875
18900
  /**
18876
18901
  * Bounding box for the geometry which can be calculated with `computeBoundingBox()`.
18877
18902
  *
18878
- * @type {Box3}
18903
+ * @type {?Box3}
18879
18904
  * @default null
18880
18905
  */
18881
18906
  this.boundingBox = null;
@@ -18883,7 +18908,7 @@ class BufferGeometry extends EventDispatcher {
18883
18908
  /**
18884
18909
  * Bounding sphere for the geometry which can be calculated with `computeBoundingSphere()`.
18885
18910
  *
18886
- * @type {Sphere}
18911
+ * @type {?Sphere}
18887
18912
  * @default null
18888
18913
  */
18889
18914
  this.boundingSphere = null;
@@ -21402,6 +21427,20 @@ class Camera extends Object3D {
21402
21427
  */
21403
21428
  this.coordinateSystem = WebGLCoordinateSystem;
21404
21429
 
21430
+ this._reversedDepth = false;
21431
+
21432
+ }
21433
+
21434
+ /**
21435
+ * The flag that indicates whether the camera uses a reversed depth buffer.
21436
+ *
21437
+ * @type {boolean}
21438
+ * @default false
21439
+ */
21440
+ get reversedDepth() {
21441
+
21442
+ return this._reversedDepth;
21443
+
21405
21444
  }
21406
21445
 
21407
21446
  copy( source, recursive ) {
@@ -21829,7 +21868,7 @@ class PerspectiveCamera extends Camera {
21829
21868
  const skew = this.filmOffset;
21830
21869
  if ( skew !== 0 ) left += near * skew / this.getFilmWidth();
21831
21870
 
21832
- this.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far, this.coordinateSystem );
21871
+ this.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far, this.coordinateSystem, this.reversedDepth );
21833
21872
 
21834
21873
  this.projectionMatrixInverse.copy( this.projectionMatrix ).invert();
21835
21874
 
@@ -24143,7 +24182,7 @@ class Sprite extends Object3D {
24143
24182
  /**
24144
24183
  * Constructs a new sprite.
24145
24184
  *
24146
- * @param {SpriteMaterial} [material] - The sprite material.
24185
+ * @param {(SpriteMaterial|SpriteNodeMaterial)} [material] - The sprite material.
24147
24186
  */
24148
24187
  constructor( material = new SpriteMaterial() ) {
24149
24188
 
@@ -24189,7 +24228,7 @@ class Sprite extends Object3D {
24189
24228
  /**
24190
24229
  * The sprite material.
24191
24230
  *
24192
- * @type {SpriteMaterial}
24231
+ * @type {(SpriteMaterial|SpriteNodeMaterial)}
24193
24232
  */
24194
24233
  this.material = material;
24195
24234
 
@@ -24518,7 +24557,7 @@ class LOD extends Object3D {
24518
24557
  * the given distance.
24519
24558
  *
24520
24559
  * @param {number} distance - The LOD distance.
24521
- * @return {Object3D|null} The found 3D object. `null` if no 3D object has been found.
24560
+ * @return {?Object3D} The found 3D object. `null` if no 3D object has been found.
24522
24561
  */
24523
24562
  getObjectForDistance( distance ) {
24524
24563
 
@@ -26393,9 +26432,10 @@ class Frustum {
26393
26432
  *
26394
26433
  * @param {Matrix4} m - The projection matrix.
26395
26434
  * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} coordinateSystem - The coordinate system.
26435
+ * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
26396
26436
  * @return {Frustum} A reference to this frustum.
26397
26437
  */
26398
- setFromProjectionMatrix( m, coordinateSystem = WebGLCoordinateSystem ) {
26438
+ setFromProjectionMatrix( m, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false ) {
26399
26439
 
26400
26440
  const planes = this.planes;
26401
26441
  const me = m.elements;
@@ -26408,19 +26448,29 @@ class Frustum {
26408
26448
  planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();
26409
26449
  planes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();
26410
26450
  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
26451
 
26413
- if ( coordinateSystem === WebGLCoordinateSystem ) {
26452
+ if ( reversedDepth ) {
26414
26453
 
26415
- planes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize();
26454
+ planes[ 4 ].setComponents( me2, me6, me10, me14 ).normalize(); // far
26455
+ planes[ 5 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize(); // near
26416
26456
 
26417
- } else if ( coordinateSystem === WebGPUCoordinateSystem ) {
26457
+ } else {
26418
26458
 
26419
- planes[ 5 ].setComponents( me2, me6, me10, me14 ).normalize();
26459
+ planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize(); // far
26420
26460
 
26421
- } else {
26461
+ if ( coordinateSystem === WebGLCoordinateSystem ) {
26462
+
26463
+ planes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize(); // near
26464
+
26465
+ } else if ( coordinateSystem === WebGPUCoordinateSystem ) {
26466
+
26467
+ planes[ 5 ].setComponents( me2, me6, me10, me14 ).normalize(); // near
26468
+
26469
+ } else {
26470
+
26471
+ throw new Error( 'THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: ' + coordinateSystem );
26422
26472
 
26423
- throw new Error( 'THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: ' + coordinateSystem );
26473
+ }
26424
26474
 
26425
26475
  }
26426
26476
 
@@ -26626,7 +26676,8 @@ class FrustumArray {
26626
26676
 
26627
26677
  _frustum$1.setFromProjectionMatrix(
26628
26678
  _projScreenMatrix$2,
26629
- this.coordinateSystem
26679
+ camera.coordinateSystem,
26680
+ camera.reversedDepth
26630
26681
  );
26631
26682
 
26632
26683
  if ( _frustum$1.intersectsObject( object ) ) {
@@ -26668,7 +26719,8 @@ class FrustumArray {
26668
26719
 
26669
26720
  _frustum$1.setFromProjectionMatrix(
26670
26721
  _projScreenMatrix$2,
26671
- this.coordinateSystem
26722
+ camera.coordinateSystem,
26723
+ camera.reversedDepth
26672
26724
  );
26673
26725
 
26674
26726
  if ( _frustum$1.intersectsSprite( sprite ) ) {
@@ -26710,7 +26762,8 @@ class FrustumArray {
26710
26762
 
26711
26763
  _frustum$1.setFromProjectionMatrix(
26712
26764
  _projScreenMatrix$2,
26713
- this.coordinateSystem
26765
+ camera.coordinateSystem,
26766
+ camera.reversedDepth
26714
26767
  );
26715
26768
 
26716
26769
  if ( _frustum$1.intersectsSphere( sphere ) ) {
@@ -26752,7 +26805,8 @@ class FrustumArray {
26752
26805
 
26753
26806
  _frustum$1.setFromProjectionMatrix(
26754
26807
  _projScreenMatrix$2,
26755
- this.coordinateSystem
26808
+ camera.coordinateSystem,
26809
+ camera.reversedDepth
26756
26810
  );
26757
26811
 
26758
26812
  if ( _frustum$1.intersectsBox( box ) ) {
@@ -26794,7 +26848,8 @@ class FrustumArray {
26794
26848
 
26795
26849
  _frustum$1.setFromProjectionMatrix(
26796
26850
  _projScreenMatrix$2,
26797
- this.coordinateSystem
26851
+ camera.coordinateSystem,
26852
+ camera.reversedDepth
26798
26853
  );
26799
26854
 
26800
26855
  if ( _frustum$1.containsPoint( point ) ) {
@@ -27781,7 +27836,7 @@ class BatchedMesh extends Mesh {
27781
27836
  *
27782
27837
  * @param {number} geometryId - The ID of the geometry to return the bounding box for.
27783
27838
  * @param {Box3} target - The target object that is used to store the method's result.
27784
- * @return {Box3|null} The geometry's bounding box. Returns `null` if no geometry has been found for the given ID.
27839
+ * @return {?Box3} The geometry's bounding box. Returns `null` if no geometry has been found for the given ID.
27785
27840
  */
27786
27841
  getBoundingBoxAt( geometryId, target ) {
27787
27842
 
@@ -27826,7 +27881,7 @@ class BatchedMesh extends Mesh {
27826
27881
  *
27827
27882
  * @param {number} geometryId - The ID of the geometry to return the bounding sphere for.
27828
27883
  * @param {Sphere} target - The target object that is used to store the method's result.
27829
- * @return {Sphere|null} The geometry's bounding sphere. Returns `null` if no geometry has been found for the given ID.
27884
+ * @return {?Sphere} The geometry's bounding sphere. Returns `null` if no geometry has been found for the given ID.
27830
27885
  */
27831
27886
  getBoundingSphereAt( geometryId, target ) {
27832
27887
 
@@ -28061,7 +28116,7 @@ class BatchedMesh extends Mesh {
28061
28116
  const availableInstanceIds = this._availableInstanceIds;
28062
28117
  const instanceInfo = this._instanceInfo;
28063
28118
  availableInstanceIds.sort( ascIdSort );
28064
- while ( availableInstanceIds[ availableInstanceIds.length - 1 ] === instanceInfo.length ) {
28119
+ while ( availableInstanceIds[ availableInstanceIds.length - 1 ] === instanceInfo.length - 1 ) {
28065
28120
 
28066
28121
  instanceInfo.pop();
28067
28122
  availableInstanceIds.pop();
@@ -28339,9 +28394,11 @@ class BatchedMesh extends Mesh {
28339
28394
  _matrix$1
28340
28395
  .multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse )
28341
28396
  .multiply( this.matrixWorld );
28397
+
28342
28398
  _frustum.setFromProjectionMatrix(
28343
28399
  _matrix$1,
28344
- renderer.coordinateSystem
28400
+ camera.coordinateSystem,
28401
+ camera.reversedDepth
28345
28402
  );
28346
28403
 
28347
28404
  }
@@ -29360,6 +29417,9 @@ function testPoint( point, index, localThresholdSq, matrixWorld, raycaster, inte
29360
29417
  * const texture = new THREE.VideoTexture( video );
29361
29418
  * ```
29362
29419
  *
29420
+ * Note: When using video textures with {@link WebGPURenderer}, {@link Texture#colorSpace} must be
29421
+ * set to THREE.SRGBColorSpace.
29422
+ *
29363
29423
  * Note: After the initial use of a texture, its dimensions, format, and type
29364
29424
  * cannot be changed. Instead, call {@link Texture#dispose} on the texture and instantiate a new one.
29365
29425
  *
@@ -29403,18 +29463,28 @@ class VideoTexture extends Texture {
29403
29463
  */
29404
29464
  this.generateMipmaps = false;
29405
29465
 
29466
+ /**
29467
+ * The video frame request callback identifier, which is a positive integer.
29468
+ *
29469
+ * Value of 0 represents no scheduled rVFC.
29470
+ *
29471
+ * @private
29472
+ * @type {number}
29473
+ */
29474
+ this._requestVideoFrameCallbackId = 0;
29475
+
29406
29476
  const scope = this;
29407
29477
 
29408
29478
  function updateVideo() {
29409
29479
 
29410
29480
  scope.needsUpdate = true;
29411
- video.requestVideoFrameCallback( updateVideo );
29481
+ scope._requestVideoFrameCallbackId = video.requestVideoFrameCallback( updateVideo );
29412
29482
 
29413
29483
  }
29414
29484
 
29415
29485
  if ( 'requestVideoFrameCallback' in video ) {
29416
29486
 
29417
- video.requestVideoFrameCallback( updateVideo );
29487
+ this._requestVideoFrameCallbackId = video.requestVideoFrameCallback( updateVideo );
29418
29488
 
29419
29489
  }
29420
29490
 
@@ -29445,6 +29515,18 @@ class VideoTexture extends Texture {
29445
29515
 
29446
29516
  }
29447
29517
 
29518
+ dispose() {
29519
+
29520
+ if ( this._requestVideoFrameCallbackId !== 0 ) {
29521
+
29522
+ this.source.data.cancelVideoFrameCallback( this._requestVideoFrameCallbackId );
29523
+
29524
+ }
29525
+
29526
+ super.dispose();
29527
+
29528
+ }
29529
+
29448
29530
  }
29449
29531
 
29450
29532
  /**
@@ -29545,8 +29627,8 @@ class FramebufferTexture extends Texture {
29545
29627
  /**
29546
29628
  * Constructs a new framebuffer texture.
29547
29629
  *
29548
- * @param {number} width - The width of the texture.
29549
- * @param {number} height - The height of the texture.
29630
+ * @param {number} [width] - The width of the texture.
29631
+ * @param {number} [height] - The height of the texture.
29550
29632
  */
29551
29633
  constructor( width, height ) {
29552
29634
 
@@ -29950,6 +30032,59 @@ class DepthTexture extends Texture {
29950
30032
 
29951
30033
  }
29952
30034
 
30035
+ /**
30036
+ * Represents a texture created externally with the same renderer context.
30037
+ *
30038
+ * This may be a texture from a protected media stream, device camera feed,
30039
+ * or other data feeds like a depth sensor.
30040
+ *
30041
+ * Note that this class is only supported in {@link WebGLRenderer}, and in
30042
+ * the {@link WebGPURenderer} WebGPU backend.
30043
+ *
30044
+ * @augments Texture
30045
+ */
30046
+ class ExternalTexture extends Texture {
30047
+
30048
+ /**
30049
+ * Creates a new raw texture.
30050
+ *
30051
+ * @param {?(WebGLTexture|GPUTexture)} [sourceTexture=null] - The external texture.
30052
+ */
30053
+ constructor( sourceTexture = null ) {
30054
+
30055
+ super();
30056
+
30057
+ /**
30058
+ * The external source texture.
30059
+ *
30060
+ * @type {?(WebGLTexture|GPUTexture)}
30061
+ * @default null
30062
+ */
30063
+ this.sourceTexture = sourceTexture;
30064
+
30065
+ /**
30066
+ * This flag can be used for type testing.
30067
+ *
30068
+ * @type {boolean}
30069
+ * @readonly
30070
+ * @default true
30071
+ */
30072
+ this.isExternalTexture = true;
30073
+
30074
+ }
30075
+
30076
+ copy( source ) {
30077
+
30078
+ super.copy( source );
30079
+
30080
+ this.sourceTexture = source.sourceTexture;
30081
+
30082
+ return this;
30083
+
30084
+ }
30085
+
30086
+ }
30087
+
29953
30088
  /**
29954
30089
  * A geometry class for representing a capsule.
29955
30090
  *
@@ -34687,7 +34822,7 @@ function pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, px, py) {
34687
34822
 
34688
34823
  // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
34689
34824
  function isValidDiagonal(a, b) {
34690
- return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
34825
+ return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // doesn't intersect other edges
34691
34826
  (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
34692
34827
  (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
34693
34828
  equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
@@ -40232,7 +40367,7 @@ class MeshDepthMaterial extends Material {
40232
40367
  * Can also be used to customize the shadow casting of an object by assigning
40233
40368
  * an instance of `MeshDistanceMaterial` to {@link Object3D#customDistanceMaterial}.
40234
40369
  * The following examples demonstrates this approach in order to ensure
40235
- * transparent parts of objects do no cast shadows.
40370
+ * transparent parts of objects do not cast shadows.
40236
40371
  *
40237
40372
  * @augments Material
40238
40373
  */
@@ -41697,7 +41832,7 @@ class KeyframeTrack {
41697
41832
  *
41698
41833
  * @param {string} name - The keyframe track's name.
41699
41834
  * @param {Array<number>} times - A list of keyframe times.
41700
- * @param {Array<number>} values - A list of keyframe values.
41835
+ * @param {Array<number|string|boolean>} values - A list of keyframe values.
41701
41836
  * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} [interpolation] - The interpolation type.
41702
41837
  */
41703
41838
  constructor( name, times, values, interpolation ) {
@@ -42285,7 +42420,7 @@ class BooleanKeyframeTrack extends KeyframeTrack {
42285
42420
  *
42286
42421
  * @param {string} name - The keyframe track's name.
42287
42422
  * @param {Array<number>} times - A list of keyframe times.
42288
- * @param {Array<number>} values - A list of keyframe values.
42423
+ * @param {Array<boolean>} values - A list of keyframe values.
42289
42424
  */
42290
42425
  constructor( name, times, values ) {
42291
42426
 
@@ -42488,7 +42623,7 @@ class StringKeyframeTrack extends KeyframeTrack {
42488
42623
  *
42489
42624
  * @param {string} name - The keyframe track's name.
42490
42625
  * @param {Array<number>} times - A list of keyframe times.
42491
- * @param {Array<number>} values - A list of keyframe values.
42626
+ * @param {Array<string>} values - A list of keyframe values.
42492
42627
  */
42493
42628
  constructor( name, times, values ) {
42494
42629
 
@@ -42613,6 +42748,14 @@ class AnimationClip {
42613
42748
  */
42614
42749
  this.uuid = generateUUID();
42615
42750
 
42751
+ /**
42752
+ * An object that can be used to store custom data about the animation clip.
42753
+ * It should not hold references to functions as these will not be cloned.
42754
+ *
42755
+ * @type {Object}
42756
+ */
42757
+ this.userData = {};
42758
+
42616
42759
  // this means it should figure out its duration by scanning the tracks
42617
42760
  if ( this.duration < 0 ) {
42618
42761
 
@@ -42644,6 +42787,8 @@ class AnimationClip {
42644
42787
  const clip = new this( json.name, json.duration, tracks, json.blendMode );
42645
42788
  clip.uuid = json.uuid;
42646
42789
 
42790
+ clip.userData = JSON.parse( json.userData || '{}' );
42791
+
42647
42792
  return clip;
42648
42793
 
42649
42794
  }
@@ -42666,7 +42811,8 @@ class AnimationClip {
42666
42811
  'duration': clip.duration,
42667
42812
  'tracks': tracks,
42668
42813
  'uuid': clip.uuid,
42669
- 'blendMode': clip.blendMode
42814
+ 'blendMode': clip.blendMode,
42815
+ 'userData': JSON.stringify( clip.userData ),
42670
42816
 
42671
42817
  };
42672
42818
 
@@ -43061,7 +43207,11 @@ class AnimationClip {
43061
43207
 
43062
43208
  }
43063
43209
 
43064
- return new this.constructor( this.name, this.duration, tracks, this.blendMode );
43210
+ const clip = new this.constructor( this.name, this.duration, tracks, this.blendMode );
43211
+
43212
+ clip.userData = JSON.parse( JSON.stringify( this.userData ) );
43213
+
43214
+ return clip;
43065
43215
 
43066
43216
  }
43067
43217
 
@@ -43311,6 +43461,13 @@ class LoadingManager {
43311
43461
  */
43312
43462
  this.onError = onError;
43313
43463
 
43464
+ /**
43465
+ * Used for aborting ongoing requests in loaders using this manager.
43466
+ *
43467
+ * @type {AbortController}
43468
+ */
43469
+ this.abortController = new AbortController();
43470
+
43314
43471
  /**
43315
43472
  * This should be called by any loader using the manager when the loader
43316
43473
  * starts loading an item.
@@ -43511,6 +43668,22 @@ class LoadingManager {
43511
43668
 
43512
43669
  };
43513
43670
 
43671
+ /**
43672
+ * Can be used to abort ongoing loading requests in loaders using this manager.
43673
+ * The abort only works if the loaders implement {@link Loader#abort} and `AbortSignal.any()`
43674
+ * is supported in the browser.
43675
+ *
43676
+ * @return {LoadingManager} A reference to this loading manager.
43677
+ */
43678
+ this.abort = function () {
43679
+
43680
+ this.abortController.abort();
43681
+ this.abortController = new AbortController();
43682
+
43683
+ return this;
43684
+
43685
+ };
43686
+
43514
43687
  }
43515
43688
 
43516
43689
  }
@@ -43590,6 +43763,7 @@ class Loader {
43590
43763
  * This method needs to be implemented by all concrete loaders. It holds the
43591
43764
  * logic for loading assets from the backend.
43592
43765
  *
43766
+ * @abstract
43593
43767
  * @param {string} url - The path/URL of the file to be loaded.
43594
43768
  * @param {Function} onLoad - Executed when the loading process has been finished.
43595
43769
  * @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.
@@ -43620,6 +43794,7 @@ class Loader {
43620
43794
  * This method needs to be implemented by all concrete loaders. It holds the
43621
43795
  * logic for parsing the asset into three.js entities.
43622
43796
  *
43797
+ * @abstract
43623
43798
  * @param {any} data - The data to parse.
43624
43799
  */
43625
43800
  parse( /* data */ ) {}
@@ -43694,6 +43869,18 @@ class Loader {
43694
43869
 
43695
43870
  }
43696
43871
 
43872
+ /**
43873
+ * This method can be implemented in loaders for aborting ongoing requests.
43874
+ *
43875
+ * @abstract
43876
+ * @return {Loader} A reference to this instance.
43877
+ */
43878
+ abort() {
43879
+
43880
+ return this;
43881
+
43882
+ }
43883
+
43697
43884
  }
43698
43885
 
43699
43886
  /**
@@ -43762,7 +43949,8 @@ class FileLoader extends Loader {
43762
43949
  super( manager );
43763
43950
 
43764
43951
  /**
43765
- * The expected mime type.
43952
+ * The expected mime type. Valid values can be found
43953
+ * [here]{@link hhttps://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#mimetype}
43766
43954
  *
43767
43955
  * @type {string}
43768
43956
  */
@@ -43776,6 +43964,14 @@ class FileLoader extends Loader {
43776
43964
  */
43777
43965
  this.responseType = '';
43778
43966
 
43967
+ /**
43968
+ * Used for aborting requests.
43969
+ *
43970
+ * @private
43971
+ * @type {AbortController}
43972
+ */
43973
+ this._abortController = new AbortController();
43974
+
43779
43975
  }
43780
43976
 
43781
43977
  /**
@@ -43842,7 +44038,7 @@ class FileLoader extends Loader {
43842
44038
  const req = new Request( url, {
43843
44039
  headers: new Headers( this.requestHeader ),
43844
44040
  credentials: this.withCredentials ? 'include' : 'same-origin',
43845
- // An abort controller could be added within a future PR
44041
+ signal: ( typeof AbortSignal.any === 'function' ) ? AbortSignal.any( [ this._abortController.signal, this.manager.abortController.signal ] ) : this._abortController.signal
43846
44042
  } );
43847
44043
 
43848
44044
  // record states ( avoid data race )
@@ -44059,6 +44255,20 @@ class FileLoader extends Loader {
44059
44255
 
44060
44256
  }
44061
44257
 
44258
+ /**
44259
+ * Aborts ongoing fetch requests.
44260
+ *
44261
+ * @return {FileLoader} A reference to this instance.
44262
+ */
44263
+ abort() {
44264
+
44265
+ this._abortController.abort();
44266
+ this._abortController = new AbortController();
44267
+
44268
+ return this;
44269
+
44270
+ }
44271
+
44062
44272
  }
44063
44273
 
44064
44274
  /**
@@ -45122,14 +45332,27 @@ class LightShadow {
45122
45332
  shadowCamera.updateMatrixWorld();
45123
45333
 
45124
45334
  _projScreenMatrix$1.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
45125
- this._frustum.setFromProjectionMatrix( _projScreenMatrix$1 );
45335
+ this._frustum.setFromProjectionMatrix( _projScreenMatrix$1, shadowCamera.coordinateSystem, shadowCamera.reversedDepth );
45126
45336
 
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
- );
45337
+ if ( shadowCamera.reversedDepth ) {
45338
+
45339
+ shadowMatrix.set(
45340
+ 0.5, 0.0, 0.0, 0.5,
45341
+ 0.0, 0.5, 0.0, 0.5,
45342
+ 0.0, 0.0, 1.0, 0.0,
45343
+ 0.0, 0.0, 0.0, 1.0
45344
+ );
45345
+
45346
+ } else {
45347
+
45348
+ shadowMatrix.set(
45349
+ 0.5, 0.0, 0.0, 0.5,
45350
+ 0.0, 0.5, 0.0, 0.5,
45351
+ 0.0, 0.0, 0.5, 0.5,
45352
+ 0.0, 0.0, 0.0, 1.0
45353
+ );
45354
+
45355
+ }
45133
45356
 
45134
45357
  shadowMatrix.multiply( _projScreenMatrix$1 );
45135
45358
 
@@ -45586,7 +45809,7 @@ class PointLightShadow extends LightShadow {
45586
45809
  shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z );
45587
45810
 
45588
45811
  _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
45589
- this._frustum.setFromProjectionMatrix( _projScreenMatrix );
45812
+ this._frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );
45590
45813
 
45591
45814
  }
45592
45815
 
@@ -45920,7 +46143,7 @@ class OrthographicCamera extends Camera {
45920
46143
 
45921
46144
  }
45922
46145
 
45923
- this.projectionMatrix.makeOrthographic( left, right, top, bottom, this.near, this.far, this.coordinateSystem );
46146
+ this.projectionMatrix.makeOrthographic( left, right, top, bottom, this.near, this.far, this.coordinateSystem, this.reversedDepth );
45924
46147
 
45925
46148
  this.projectionMatrixInverse.copy( this.projectionMatrix ).invert();
45926
46149
 
@@ -48660,6 +48883,14 @@ class ImageBitmapLoader extends Loader {
48660
48883
  */
48661
48884
  this.options = { premultiplyAlpha: 'none' };
48662
48885
 
48886
+ /**
48887
+ * Used for aborting requests.
48888
+ *
48889
+ * @private
48890
+ * @type {AbortController}
48891
+ */
48892
+ this._abortController = new AbortController();
48893
+
48663
48894
  }
48664
48895
 
48665
48896
  /**
@@ -48748,6 +48979,7 @@ class ImageBitmapLoader extends Loader {
48748
48979
  const fetchOptions = {};
48749
48980
  fetchOptions.credentials = ( this.crossOrigin === 'anonymous' ) ? 'same-origin' : 'include';
48750
48981
  fetchOptions.headers = this.requestHeader;
48982
+ fetchOptions.signal = ( typeof AbortSignal.any === 'function' ) ? AbortSignal.any( [ this._abortController.signal, this.manager.abortController.signal ] ) : this._abortController.signal;
48751
48983
 
48752
48984
  const promise = fetch( url, fetchOptions ).then( function ( res ) {
48753
48985
 
@@ -48785,6 +49017,20 @@ class ImageBitmapLoader extends Loader {
48785
49017
 
48786
49018
  }
48787
49019
 
49020
+ /**
49021
+ * Aborts ongoing fetch requests.
49022
+ *
49023
+ * @return {ImageBitmapLoader} A reference to this instance.
49024
+ */
49025
+ abort() {
49026
+
49027
+ this._abortController.abort();
49028
+ this._abortController = new AbortController();
49029
+
49030
+ return this;
49031
+
49032
+ }
49033
+
48788
49034
  }
48789
49035
 
48790
49036
  let _context;
@@ -54676,6 +54922,189 @@ function intersect( object, raycaster, intersects, recursive ) {
54676
54922
 
54677
54923
  }
54678
54924
 
54925
+ /**
54926
+ * This class is an alternative to {@link Clock} with a different API design and behavior.
54927
+ * The goal is to avoid the conceptual flaws that became apparent in `Clock` over time.
54928
+ *
54929
+ * - `Timer` has an `update()` method that updates its internal state. That makes it possible to
54930
+ * call `getDelta()` and `getElapsed()` multiple times per simulation step without getting different values.
54931
+ * - The class can make use of the Page Visibility API to avoid large time delta values when the app
54932
+ * is inactive (e.g. tab switched or browser hidden).
54933
+ *
54934
+ * ```js
54935
+ * const timer = new Timer();
54936
+ * timer.connect( document ); // use Page Visibility API
54937
+ * ```
54938
+ */
54939
+ class Timer {
54940
+
54941
+ /**
54942
+ * Constructs a new timer.
54943
+ */
54944
+ constructor() {
54945
+
54946
+ this._previousTime = 0;
54947
+ this._currentTime = 0;
54948
+ this._startTime = performance.now();
54949
+
54950
+ this._delta = 0;
54951
+ this._elapsed = 0;
54952
+
54953
+ this._timescale = 1;
54954
+
54955
+ this._document = null;
54956
+ this._pageVisibilityHandler = null;
54957
+
54958
+ }
54959
+
54960
+ /**
54961
+ * Connect the timer to the given document.Calling this method is not mandatory to
54962
+ * use the timer but enables the usage of the Page Visibility API to avoid large time
54963
+ * delta values.
54964
+ *
54965
+ * @param {Document} document - The document.
54966
+ */
54967
+ connect( document ) {
54968
+
54969
+ this._document = document;
54970
+
54971
+ // use Page Visibility API to avoid large time delta values
54972
+
54973
+ if ( document.hidden !== undefined ) {
54974
+
54975
+ this._pageVisibilityHandler = handleVisibilityChange.bind( this );
54976
+
54977
+ document.addEventListener( 'visibilitychange', this._pageVisibilityHandler, false );
54978
+
54979
+ }
54980
+
54981
+ }
54982
+
54983
+ /**
54984
+ * Disconnects the timer from the DOM and also disables the usage of the Page Visibility API.
54985
+ */
54986
+ disconnect() {
54987
+
54988
+ if ( this._pageVisibilityHandler !== null ) {
54989
+
54990
+ this._document.removeEventListener( 'visibilitychange', this._pageVisibilityHandler );
54991
+ this._pageVisibilityHandler = null;
54992
+
54993
+ }
54994
+
54995
+ this._document = null;
54996
+
54997
+ }
54998
+
54999
+ /**
55000
+ * Returns the time delta in seconds.
55001
+ *
55002
+ * @return {number} The time delta in second.
55003
+ */
55004
+ getDelta() {
55005
+
55006
+ return this._delta / 1000;
55007
+
55008
+ }
55009
+
55010
+ /**
55011
+ * Returns the elapsed time in seconds.
55012
+ *
55013
+ * @return {number} The elapsed time in second.
55014
+ */
55015
+ getElapsed() {
55016
+
55017
+ return this._elapsed / 1000;
55018
+
55019
+ }
55020
+
55021
+ /**
55022
+ * Returns the timescale.
55023
+ *
55024
+ * @return {number} The timescale.
55025
+ */
55026
+ getTimescale() {
55027
+
55028
+ return this._timescale;
55029
+
55030
+ }
55031
+
55032
+ /**
55033
+ * Sets the given timescale which scale the time delta computation
55034
+ * in `update()`.
55035
+ *
55036
+ * @param {number} timescale - The timescale to set.
55037
+ * @return {Timer} A reference to this timer.
55038
+ */
55039
+ setTimescale( timescale ) {
55040
+
55041
+ this._timescale = timescale;
55042
+
55043
+ return this;
55044
+
55045
+ }
55046
+
55047
+ /**
55048
+ * Resets the time computation for the current simulation step.
55049
+ *
55050
+ * @return {Timer} A reference to this timer.
55051
+ */
55052
+ reset() {
55053
+
55054
+ this._currentTime = performance.now() - this._startTime;
55055
+
55056
+ return this;
55057
+
55058
+ }
55059
+
55060
+ /**
55061
+ * Can be used to free all internal resources. Usually called when
55062
+ * the timer instance isn't required anymore.
55063
+ */
55064
+ dispose() {
55065
+
55066
+ this.disconnect();
55067
+
55068
+ }
55069
+
55070
+ /**
55071
+ * Updates the internal state of the timer. This method should be called
55072
+ * once per simulation step and before you perform queries against the timer
55073
+ * (e.g. via `getDelta()`).
55074
+ *
55075
+ * @param {number} timestamp - The current time in milliseconds. Can be obtained
55076
+ * from the `requestAnimationFrame` callback argument. If not provided, the current
55077
+ * time will be determined with `performance.now`.
55078
+ * @return {Timer} A reference to this timer.
55079
+ */
55080
+ update( timestamp ) {
55081
+
55082
+ if ( this._pageVisibilityHandler !== null && this._document.hidden === true ) {
55083
+
55084
+ this._delta = 0;
55085
+
55086
+ } else {
55087
+
55088
+ this._previousTime = this._currentTime;
55089
+ this._currentTime = ( timestamp !== undefined ? timestamp : performance.now() ) - this._startTime;
55090
+
55091
+ this._delta = ( this._currentTime - this._previousTime ) * this._timescale;
55092
+ this._elapsed += this._delta; // _elapsed is the accumulation of all previous deltas
55093
+
55094
+ }
55095
+
55096
+ return this;
55097
+
55098
+ }
55099
+
55100
+ }
55101
+
55102
+ function handleVisibilityChange() {
55103
+
55104
+ if ( this._document.hidden === false ) this.reset();
55105
+
55106
+ }
55107
+
54679
55108
  /**
54680
55109
  * This class can be used to represent points in 3D space as
54681
55110
  * [Spherical coordinates]{@link https://en.wikipedia.org/wiki/Spherical_coordinate_system}.
@@ -54783,8 +55212,8 @@ class Spherical {
54783
55212
  * Sets the spherical components from the given Cartesian coordinates.
54784
55213
  *
54785
55214
  * @param {number} x - The x value.
54786
- * @param {number} y - The x value.
54787
- * @param {number} z - The x value.
55215
+ * @param {number} y - The y value.
55216
+ * @param {number} z - The z value.
54788
55217
  * @return {Spherical} A reference to this spherical.
54789
55218
  */
54790
55219
  setFromCartesianCoords( x, y, z ) {
@@ -55445,6 +55874,12 @@ class Box2 {
55445
55874
  const _startP = /*@__PURE__*/ new Vector3();
55446
55875
  const _startEnd = /*@__PURE__*/ new Vector3();
55447
55876
 
55877
+ const _d1 = /*@__PURE__*/ new Vector3();
55878
+ const _d2 = /*@__PURE__*/ new Vector3();
55879
+ const _r = /*@__PURE__*/ new Vector3();
55880
+ const _c1 = /*@__PURE__*/ new Vector3();
55881
+ const _c2 = /*@__PURE__*/ new Vector3();
55882
+
55448
55883
  /**
55449
55884
  * An analytical line segment in 3D space represented by a start and end point.
55450
55885
  */
@@ -55592,11 +56027,11 @@ class Line3 {
55592
56027
  }
55593
56028
 
55594
56029
  /**
55595
- * Returns the closets point on the line for a given point.
56030
+ * Returns the closest point on the line for a given point.
55596
56031
  *
55597
56032
  * @param {Vector3} point - The point to compute the closest point on the line for.
55598
56033
  * @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.
56034
+ * @param {Vector3} target - The target vector that is used to store the method's result.
55600
56035
  * @return {Vector3} The closest point on the line.
55601
56036
  */
55602
56037
  closestPointToPoint( point, clampToLine, target ) {
@@ -55607,6 +56042,127 @@ class Line3 {
55607
56042
 
55608
56043
  }
55609
56044
 
56045
+ /**
56046
+ * Returns the closest squared distance between this line segment and the given one.
56047
+ *
56048
+ * @param {Line3} line - The line segment to compute the closest squared distance to.
56049
+ * @param {Vector3} [c1] - The closest point on this line segment.
56050
+ * @param {Vector3} [c2] - The closest point on the given line segment.
56051
+ * @return {number} The squared distance between this line segment and the given one.
56052
+ */
56053
+ distanceSqToLine3( line, c1 = _c1, c2 = _c2 ) {
56054
+
56055
+ // from Real-Time Collision Detection by Christer Ericson, chapter 5.1.9
56056
+
56057
+ // Computes closest points C1 and C2 of S1(s)=P1+s*(Q1-P1) and
56058
+ // S2(t)=P2+t*(Q2-P2), returning s and t. Function result is squared
56059
+ // distance between between S1(s) and S2(t)
56060
+
56061
+ const EPSILON = 1e-8 * 1e-8; // must be squared since we compare squared length
56062
+ let s, t;
56063
+
56064
+ const p1 = this.start;
56065
+ const p2 = line.start;
56066
+ const q1 = this.end;
56067
+ const q2 = line.end;
56068
+
56069
+ _d1.subVectors( q1, p1 ); // Direction vector of segment S1
56070
+ _d2.subVectors( q2, p2 ); // Direction vector of segment S2
56071
+ _r.subVectors( p1, p2 );
56072
+
56073
+ const a = _d1.dot( _d1 ); // Squared length of segment S1, always nonnegative
56074
+ const e = _d2.dot( _d2 ); // Squared length of segment S2, always nonnegative
56075
+ const f = _d2.dot( _r );
56076
+
56077
+ // Check if either or both segments degenerate into points
56078
+
56079
+ if ( a <= EPSILON && e <= EPSILON ) {
56080
+
56081
+ // Both segments degenerate into points
56082
+
56083
+ c1.copy( p1 );
56084
+ c2.copy( p2 );
56085
+
56086
+ c1.sub( c2 );
56087
+
56088
+ return c1.dot( c1 );
56089
+
56090
+ }
56091
+
56092
+ if ( a <= EPSILON ) {
56093
+
56094
+ // First segment degenerates into a point
56095
+
56096
+ s = 0;
56097
+ t = f / e; // s = 0 => t = (b*s + f) / e = f / e
56098
+ t = clamp( t, 0, 1 );
56099
+
56100
+
56101
+ } else {
56102
+
56103
+ const c = _d1.dot( _r );
56104
+
56105
+ if ( e <= EPSILON ) {
56106
+
56107
+ // Second segment degenerates into a point
56108
+
56109
+ t = 0;
56110
+ s = clamp( - c / a, 0, 1 ); // t = 0 => s = (b*t - c) / a = -c / a
56111
+
56112
+ } else {
56113
+
56114
+ // The general nondegenerate case starts here
56115
+
56116
+ const b = _d1.dot( _d2 );
56117
+ const denom = a * e - b * b; // Always nonnegative
56118
+
56119
+ // If segments not parallel, compute closest point on L1 to L2 and
56120
+ // clamp to segment S1. Else pick arbitrary s (here 0)
56121
+
56122
+ if ( denom !== 0 ) {
56123
+
56124
+ s = clamp( ( b * f - c * e ) / denom, 0, 1 );
56125
+
56126
+ } else {
56127
+
56128
+ s = 0;
56129
+
56130
+ }
56131
+
56132
+ // Compute point on L2 closest to S1(s) using
56133
+ // t = Dot((P1 + D1*s) - P2,D2) / Dot(D2,D2) = (b*s + f) / e
56134
+
56135
+ t = ( b * s + f ) / e;
56136
+
56137
+ // If t in [0,1] done. Else clamp t, recompute s for the new value
56138
+ // of t using s = Dot((P2 + D2*t) - P1,D1) / Dot(D1,D1)= (t*b - c) / a
56139
+ // and clamp s to [0, 1]
56140
+
56141
+ if ( t < 0 ) {
56142
+
56143
+ t = 0.;
56144
+ s = clamp( - c / a, 0, 1 );
56145
+
56146
+ } else if ( t > 1 ) {
56147
+
56148
+ t = 1;
56149
+ s = clamp( ( b - c ) / a, 0, 1 );
56150
+
56151
+ }
56152
+
56153
+ }
56154
+
56155
+ }
56156
+
56157
+ c1.copy( p1 ).add( _d1.multiplyScalar( s ) );
56158
+ c2.copy( p2 ).add( _d2.multiplyScalar( t ) );
56159
+
56160
+ c1.sub( c2 );
56161
+
56162
+ return c1.dot( c1 );
56163
+
56164
+ }
56165
+
55610
56166
  /**
55611
56167
  * Applies a 4x4 transformation matrix to this line segment.
55612
56168
  *
@@ -55806,7 +56362,7 @@ const _matrixWorldInv = /*@__PURE__*/ new Matrix4();
55806
56362
  class SkeletonHelper extends LineSegments {
55807
56363
 
55808
56364
  /**
55809
- * Constructs a new hemisphere light helper.
56365
+ * Constructs a new skeleton helper.
55810
56366
  *
55811
56367
  * @param {Object3D} object - Usually an instance of {@link SkinnedMesh}. However, any 3D object
55812
56368
  * can be used if it represents a hierarchy of bones (see {@link Bone}).
@@ -55820,9 +56376,6 @@ class SkeletonHelper extends LineSegments {
55820
56376
  const vertices = [];
55821
56377
  const colors = [];
55822
56378
 
55823
- const color1 = new Color( 0, 0, 1 );
55824
- const color2 = new Color( 0, 1, 0 );
55825
-
55826
56379
  for ( let i = 0; i < bones.length; i ++ ) {
55827
56380
 
55828
56381
  const bone = bones[ i ];
@@ -55831,8 +56384,8 @@ class SkeletonHelper extends LineSegments {
55831
56384
 
55832
56385
  vertices.push( 0, 0, 0 );
55833
56386
  vertices.push( 0, 0, 0 );
55834
- colors.push( color1.r, color1.g, color1.b );
55835
- colors.push( color2.r, color2.g, color2.b );
56387
+ colors.push( 0, 0, 0 );
56388
+ colors.push( 0, 0, 0 );
55836
56389
 
55837
56390
  }
55838
56391
 
@@ -55873,6 +56426,13 @@ class SkeletonHelper extends LineSegments {
55873
56426
  this.matrix = object.matrixWorld;
55874
56427
  this.matrixAutoUpdate = false;
55875
56428
 
56429
+ // colors
56430
+
56431
+ const color1 = new Color( 0x0000ff );
56432
+ const color2 = new Color( 0x00ff00 );
56433
+
56434
+ this.setColors( color1, color2 );
56435
+
55876
56436
  }
55877
56437
 
55878
56438
  updateMatrixWorld( force ) {
@@ -55910,6 +56470,31 @@ class SkeletonHelper extends LineSegments {
55910
56470
 
55911
56471
  }
55912
56472
 
56473
+ /**
56474
+ * Defines the colors of the helper.
56475
+ *
56476
+ * @param {Color} color1 - The first line color for each bone.
56477
+ * @param {Color} color2 - The second line color for each bone.
56478
+ * @return {SkeletonHelper} A reference to this helper.
56479
+ */
56480
+ setColors( color1, color2 ) {
56481
+
56482
+ const geometry = this.geometry;
56483
+ const colorAttribute = geometry.getAttribute( 'color' );
56484
+
56485
+ for ( let i = 0; i < colorAttribute.count; i += 2 ) {
56486
+
56487
+ colorAttribute.setXYZ( i, color1.r, color1.g, color1.b );
56488
+ colorAttribute.setXYZ( i + 1, color2.r, color2.g, color2.b );
56489
+
56490
+ }
56491
+
56492
+ colorAttribute.needsUpdate = true;
56493
+
56494
+ return this;
56495
+
56496
+ }
56497
+
55913
56498
  /**
55914
56499
  * Frees the GPU-related resources allocated by this instance. Call this
55915
56500
  * method whenever this instance is no longer used in your app.
@@ -56670,6 +57255,7 @@ class CameraHelper extends LineSegments {
56670
57255
  * @param {Color} up - The up line color.
56671
57256
  * @param {Color} target - The target line color.
56672
57257
  * @param {Color} cross - The cross line color.
57258
+ * @return {CameraHelper} A reference to this helper.
56673
57259
  */
56674
57260
  setColors( frustum, cone, up, target, cross ) {
56675
57261
 
@@ -56726,6 +57312,8 @@ class CameraHelper extends LineSegments {
56726
57312
 
56727
57313
  colorAttribute.needsUpdate = true;
56728
57314
 
57315
+ return this;
57316
+
56729
57317
  }
56730
57318
 
56731
57319
  /**
@@ -56738,48 +57326,75 @@ class CameraHelper extends LineSegments {
56738
57326
 
56739
57327
  const w = 1, h = 1;
56740
57328
 
57329
+ let nearZ, farZ;
57330
+
56741
57331
  // we need just camera projection matrix inverse
56742
57332
  // world matrix must be identity
56743
57333
 
56744
57334
  _camera.projectionMatrixInverse.copy( this.camera.projectionMatrixInverse );
56745
57335
 
56746
57336
  // Adjust z values based on coordinate system
56747
- const nearZ = this.camera.coordinateSystem === WebGLCoordinateSystem ? -1 : 0;
57337
+
57338
+ if ( this.camera.reversedDepth === true ) {
57339
+
57340
+ nearZ = 1;
57341
+ farZ = 0;
57342
+
57343
+ } else {
57344
+
57345
+ if ( this.camera.coordinateSystem === WebGLCoordinateSystem ) {
57346
+
57347
+ nearZ = -1;
57348
+ farZ = 1;
57349
+
57350
+ } else if ( this.camera.coordinateSystem === WebGPUCoordinateSystem ) {
57351
+
57352
+ nearZ = 0;
57353
+ farZ = 1;
57354
+
57355
+ } else {
57356
+
57357
+ throw new Error( 'THREE.CameraHelper.update(): Invalid coordinate system: ' + this.camera.coordinateSystem );
57358
+
57359
+ }
57360
+
57361
+ }
57362
+
56748
57363
 
56749
57364
  // center / target
56750
57365
  setPoint( 'c', pointMap, geometry, _camera, 0, 0, nearZ );
56751
- setPoint( 't', pointMap, geometry, _camera, 0, 0, 1 );
57366
+ setPoint( 't', pointMap, geometry, _camera, 0, 0, farZ );
56752
57367
 
56753
57368
  // near
56754
57369
 
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 );
57370
+ setPoint( 'n1', pointMap, geometry, _camera, - w, - h, nearZ );
57371
+ setPoint( 'n2', pointMap, geometry, _camera, w, - h, nearZ );
57372
+ setPoint( 'n3', pointMap, geometry, _camera, - w, h, nearZ );
56758
57373
  setPoint( 'n4', pointMap, geometry, _camera, w, h, nearZ );
56759
57374
 
56760
57375
  // far
56761
57376
 
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 );
57377
+ setPoint( 'f1', pointMap, geometry, _camera, - w, - h, farZ );
57378
+ setPoint( 'f2', pointMap, geometry, _camera, w, - h, farZ );
57379
+ setPoint( 'f3', pointMap, geometry, _camera, - w, h, farZ );
57380
+ setPoint( 'f4', pointMap, geometry, _camera, w, h, farZ );
56766
57381
 
56767
57382
  // up
56768
57383
 
56769
57384
  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 );
57385
+ setPoint( 'u2', pointMap, geometry, _camera, - w * 0.7, h * 1.1, nearZ );
56771
57386
  setPoint( 'u3', pointMap, geometry, _camera, 0, h * 2, nearZ );
56772
57387
 
56773
57388
  // cross
56774
57389
 
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 );
57390
+ setPoint( 'cf1', pointMap, geometry, _camera, - w, 0, farZ );
57391
+ setPoint( 'cf2', pointMap, geometry, _camera, w, 0, farZ );
57392
+ setPoint( 'cf3', pointMap, geometry, _camera, 0, - h, farZ );
57393
+ setPoint( 'cf4', pointMap, geometry, _camera, 0, h, farZ );
56779
57394
 
56780
- setPoint( 'cn1', pointMap, geometry, _camera, -1, 0, nearZ );
57395
+ setPoint( 'cn1', pointMap, geometry, _camera, - w, 0, nearZ );
56781
57396
  setPoint( 'cn2', pointMap, geometry, _camera, w, 0, nearZ );
56782
- setPoint( 'cn3', pointMap, geometry, _camera, 0, -1, nearZ );
57397
+ setPoint( 'cn3', pointMap, geometry, _camera, 0, - h, nearZ );
56783
57398
  setPoint( 'cn4', pointMap, geometry, _camera, 0, h, nearZ );
56784
57399
 
56785
57400
  geometry.getAttribute( 'position' ).needsUpdate = true;
@@ -58065,6 +58680,7 @@ function getTextureTypeByteLength( type ) {
58065
58680
  case FloatType:
58066
58681
  return { byteLength: 4, components: 1 };
58067
58682
  case UnsignedInt5999Type:
58683
+ case UnsignedInt101111Type:
58068
58684
  return { byteLength: 4, components: 3 };
58069
58685
 
58070
58686
  }
@@ -58560,13 +59176,13 @@ var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGH
58560
59176
 
58561
59177
  var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif";
58562
59178
 
58563
- var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
59179
+ var logdepthbuf_fragment = "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
58564
59180
 
58565
- var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif";
59181
+ var logdepthbuf_pars_fragment = "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif";
58566
59182
 
58567
- var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif";
59183
+ var logdepthbuf_pars_vertex = "#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif";
58568
59184
 
58569
- var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif";
59185
+ var logdepthbuf_vertex = "#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif";
58570
59186
 
58571
59187
  var map_fragment = "#ifdef USE_MAP\n\t#ifdef USE_MAP_TRIPLANAR\n\t\tvec4 sampledDiffuseColor = texture2DTriplanar( map, mapTransform, triplanarCoords, triplanarWeights );\n\t#else\n #if defined( USE_MAP_CYLINDRICAL )\n vec2 vMapUv = ( mapTransform * vec3( positionBasedUv, 1 ) ).xy;\n #endif\n\t\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#endif\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif";
58572
59188
 
@@ -58628,7 +59244,7 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
58628
59244
 
58629
59245
  var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
58630
59246
 
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";
59247
+ 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_REVERSED_DEPTH_BUFFER\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_REVERSED_DEPTH_BUFFER\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
59248
 
58633
59249
  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
59250
 
@@ -58678,7 +59294,7 @@ const fragment$f = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform fl
58678
59294
 
58679
59295
  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
59296
 
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}";
59297
+ 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_REVERSED_DEPTH_BUFFER\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
59298
 
58683
59299
  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
59300
 
@@ -60516,7 +61132,7 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
60516
61132
  }
60517
61133
 
60518
61134
  const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
60519
- const reverseDepthBuffer = parameters.reverseDepthBuffer === true && extensions.has( 'EXT_clip_control' );
61135
+ const reversedDepthBuffer = parameters.reversedDepthBuffer === true && extensions.has( 'EXT_clip_control' );
60520
61136
 
60521
61137
  const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
60522
61138
  const maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
@@ -60544,7 +61160,7 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
60544
61160
 
60545
61161
  precision: precision,
60546
61162
  logarithmicDepthBuffer: logarithmicDepthBuffer,
60547
- reverseDepthBuffer: reverseDepthBuffer,
61163
+ reversedDepthBuffer: reversedDepthBuffer,
60548
61164
 
60549
61165
  maxTextures: maxTextures,
60550
61166
  maxVertexTextures: maxVertexTextures,
@@ -61149,6 +61765,17 @@ class PMREMGenerator {
61149
61765
  renderer.toneMapping = NoToneMapping;
61150
61766
  renderer.autoClear = false;
61151
61767
 
61768
+ // https://github.com/mrdoob/three.js/issues/31413#issuecomment-3095966812
61769
+ const reversedDepthBuffer = renderer.state.buffers.depth.getReversed();
61770
+
61771
+ if ( reversedDepthBuffer ) {
61772
+
61773
+ renderer.setRenderTarget( cubeUVRenderTarget );
61774
+ renderer.clearDepth();
61775
+ renderer.setRenderTarget( null );
61776
+
61777
+ }
61778
+
61152
61779
  const backgroundMaterial = new MeshBasicMaterial( {
61153
61780
  name: 'PMREM.Background',
61154
61781
  side: BackSide,
@@ -63780,7 +64407,9 @@ function getEncodingComponents( colorSpace ) {
63780
64407
  function getShaderErrors( gl, shader, type ) {
63781
64408
 
63782
64409
  const status = gl.getShaderParameter( shader, gl.COMPILE_STATUS );
63783
- const errors = gl.getShaderInfoLog( shader ).trim();
64410
+
64411
+ const shaderInfoLog = gl.getShaderInfoLog( shader ) || '';
64412
+ const errors = shaderInfoLog.trim();
63784
64413
 
63785
64414
  if ( status && errors === '' ) return '';
63786
64415
 
@@ -64284,8 +64913,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64284
64913
  parameters.bumpMap ? '#define USE_BUMPMAP' : '',
64285
64914
  parameters.normalMap ? '#define USE_NORMALMAP' : '',
64286
64915
  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' : '',
64916
+ parameters.normalMapObjectSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
64917
+ parameters.normalMapTangentSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
64289
64918
  parameters.displacementMap ? '#define USE_DISPLACEMENTMAP' : '',
64290
64919
  parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
64291
64920
 
@@ -64295,9 +64924,9 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64295
64924
  parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',
64296
64925
  parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
64297
64926
  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' : '',
64927
+ parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
64928
+ : parameters.clearcoatNormalMapMode === CylindricalMapping ? '#define USE_CLEARCOAT_NORMALMAP_CYLINDRICAL'
64929
+ : parameters.clearcoatNormalMapMode === UVMapping ? '#define USE_CLEARCOAT_NORMALMAP_UV' : '',
64301
64930
 
64302
64931
  parameters.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '',
64303
64932
  parameters.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '',
@@ -64384,8 +65013,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64384
65013
 
64385
65014
  parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
64386
65015
 
64387
- parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
64388
- parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
65016
+ parameters.logarithmicDepthBuffer ? '#define USE_LOGARITHMIC_DEPTH_BUFFER' : '',
65017
+ parameters.reversedDepthBuffer ? '#define USE_REVERSED_DEPTH_BUFFER' : '',
64389
65018
 
64390
65019
  'uniform mat4 modelMatrix;',
64391
65020
  'uniform mat4 modelViewMatrix;',
@@ -64491,8 +65120,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64491
65120
  parameters.bumpMap ? '#define USE_BUMPMAP' : '',
64492
65121
  parameters.normalMap ? '#define USE_NORMALMAP' : '',
64493
65122
  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' : '',
65123
+ parameters.normalMapObjectSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
65124
+ parameters.normalMapTangentSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
64496
65125
  parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
64497
65126
 
64498
65127
  parameters.anisotropy ? '#define USE_ANISOTROPY' : '',
@@ -64502,9 +65131,9 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64502
65131
  parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',
64503
65132
  parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
64504
65133
  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' : '',
65134
+ parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
65135
+ : parameters.clearcoatNormalMapMode === CylindricalMapping ? '#define USE_CLEARCOAT_NORMALMAP_CYLINDRICAL'
65136
+ : parameters.clearcoatNormalMapMode === UVMapping ? '#define USE_CLEARCOAT_NORMALMAP_UV' : '',
64508
65137
 
64509
65138
  parameters.dispersion ? '#define USE_DISPERSION' : '',
64510
65139
 
@@ -64560,8 +65189,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64560
65189
  parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
64561
65190
  parameters.decodeVideoTextureEmissive ? '#define DECODE_VIDEO_TEXTURE_EMISSIVE' : '',
64562
65191
 
64563
- parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
64564
- parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
65192
+ parameters.logarithmicDepthBuffer ? '#define USE_LOGARITHMIC_DEPTH_BUFFER' : '',
65193
+ parameters.reversedDepthBuffer ? '#define USE_REVERSED_DEPTH_BUFFER' : '',
64565
65194
 
64566
65195
  'uniform mat4 modelViewMatrix;',
64567
65196
  'uniform mat4 viewMatrix;',
@@ -64662,9 +65291,13 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
64662
65291
  // check for link errors
64663
65292
  if ( renderer.debug.checkShaderErrors ) {
64664
65293
 
64665
- const programLog = gl.getProgramInfoLog( program ).trim();
64666
- const vertexLog = gl.getShaderInfoLog( glVertexShader ).trim();
64667
- const fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();
65294
+ const programInfoLog = gl.getProgramInfoLog( program ) || '';
65295
+ const vertexShaderInfoLog = gl.getShaderInfoLog( glVertexShader ) || '';
65296
+ const fragmentShaderInfoLog = gl.getShaderInfoLog( glFragmentShader ) || '';
65297
+
65298
+ const programLog = programInfoLog.trim();
65299
+ const vertexLog = vertexShaderInfoLog.trim();
65300
+ const fragmentLog = fragmentShaderInfoLog.trim();
64668
65301
 
64669
65302
  let runnable = true;
64670
65303
  let haveDiagnostics = true;
@@ -65050,7 +65683,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
65050
65683
  }
65051
65684
 
65052
65685
  const currentRenderTarget = renderer.getRenderTarget();
65053
- const reverseDepthBuffer = renderer.state.buffers.depth.getReversed();
65686
+ const reversedDepthBuffer = renderer.state.buffers.depth.getReversed();
65054
65687
 
65055
65688
  const IS_INSTANCEDMESH = object.isInstancedMesh === true;
65056
65689
  const IS_BATCHEDMESH = object.isBatchedMesh === true;
@@ -65256,7 +65889,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
65256
65889
 
65257
65890
  sizeAttenuation: material.sizeAttenuation === true,
65258
65891
  logarithmicDepthBuffer: logarithmicDepthBuffer,
65259
- reverseDepthBuffer: reverseDepthBuffer,
65892
+ reversedDepthBuffer: reversedDepthBuffer,
65260
65893
 
65261
65894
  skinning: object.isSkinnedMesh === true,
65262
65895
 
@@ -65389,7 +66022,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
65389
66022
  array.push( parameters.anisotropyMapUv );
65390
66023
  array.push( parameters.clearcoatMapUv );
65391
66024
  array.push( parameters.clearcoatNormalMapUv );
65392
- array.push( parameters.clearcoatNormalMapMode);
66025
+ array.push( parameters.clearcoatNormalMapMode );
65393
66026
  array.push( parameters.clearcoatRoughnessMapUv );
65394
66027
  array.push( parameters.iridescenceMapUv );
65395
66028
  array.push( parameters.iridescenceThicknessMapUv );
@@ -65488,7 +66121,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
65488
66121
  _programLayers.enable( 2 );
65489
66122
  if ( parameters.logarithmicDepthBuffer )
65490
66123
  _programLayers.enable( 3 );
65491
- if ( parameters.reverseDepthBuffer )
66124
+ if ( parameters.reversedDepthBuffer )
65492
66125
  _programLayers.enable( 4 );
65493
66126
  if ( parameters.skinning )
65494
66127
  _programLayers.enable( 5 );
@@ -66655,7 +67288,17 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
66655
67288
 
66656
67289
  // Set GL state for depth map.
66657
67290
  _state.setBlending( NoBlending );
66658
- _state.buffers.color.setClear( 1, 1, 1, 1 );
67291
+
67292
+ if ( _state.buffers.depth.getReversed() === true ) {
67293
+
67294
+ _state.buffers.color.setClear( 0, 0, 0, 0 );
67295
+
67296
+ } else {
67297
+
67298
+ _state.buffers.color.setClear( 1, 1, 1, 1 );
67299
+
67300
+ }
67301
+
66659
67302
  _state.buffers.depth.setTest( true );
66660
67303
  _state.setScissorTest( false );
66661
67304
 
@@ -68515,6 +69158,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
68515
69158
  if ( glFormat === _gl.RGB ) {
68516
69159
 
68517
69160
  if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
69161
+ if ( glType === _gl.UNSIGNED_INT_10F_11F_11F_REV ) internalFormat = _gl.R11F_G11F_B10F;
68518
69162
 
68519
69163
  }
68520
69164
 
@@ -68829,7 +69473,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
68829
69473
 
68830
69474
  if ( texture.isVideoTexture ) updateVideoTexture( texture );
68831
69475
 
68832
- if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
69476
+ if ( texture.isRenderTargetTexture === false && texture.isExternalTexture !== true && texture.version > 0 && textureProperties.__version !== texture.version ) {
68833
69477
 
68834
69478
  const image = texture.image;
68835
69479
 
@@ -68848,6 +69492,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
68848
69492
 
68849
69493
  }
68850
69494
 
69495
+ } else if ( texture.isExternalTexture ) {
69496
+
69497
+ textureProperties.__webglTexture = texture.sourceTexture ? texture.sourceTexture : null;
69498
+
68851
69499
  }
68852
69500
 
68853
69501
  state.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
@@ -68858,7 +69506,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
68858
69506
 
68859
69507
  const textureProperties = properties.get( texture );
68860
69508
 
68861
- if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
69509
+ if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
68862
69510
 
68863
69511
  uploadTexture( textureProperties, texture, slot );
68864
69512
  return;
@@ -68873,7 +69521,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
68873
69521
 
68874
69522
  const textureProperties = properties.get( texture );
68875
69523
 
68876
- if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
69524
+ if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
68877
69525
 
68878
69526
  uploadTexture( textureProperties, texture, slot );
68879
69527
  return;
@@ -70316,13 +70964,21 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
70316
70964
  const attachment = textures[ i ];
70317
70965
  const attachmentProperties = properties.get( attachment );
70318
70966
 
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 );
70967
+ let glTextureType = _gl.TEXTURE_2D;
70968
+
70969
+ if ( renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
70970
+
70971
+ glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
70972
+
70973
+ }
70974
+
70975
+ state.bindTexture( glTextureType, attachmentProperties.__webglTexture );
70976
+ setTextureParameters( glTextureType, attachment );
70977
+ setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, glTextureType, 0 );
70322
70978
 
70323
70979
  if ( textureNeedsGenerateMipmaps( attachment ) ) {
70324
70980
 
70325
- generateMipmap( _gl.TEXTURE_2D );
70981
+ generateMipmap( glTextureType );
70326
70982
 
70327
70983
  }
70328
70984
 
@@ -70648,6 +71304,7 @@ function WebGLUtils( gl, extensions ) {
70648
71304
  if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
70649
71305
  if ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;
70650
71306
  if ( p === UnsignedInt5999Type ) return gl.UNSIGNED_INT_5_9_9_9_REV;
71307
+ if ( p === UnsignedInt101111Type ) return gl.UNSIGNED_INT_10F_11F_11F_REV;
70651
71308
 
70652
71309
  if ( p === ByteType ) return gl.BYTE;
70653
71310
  if ( p === ShortType ) return gl.SHORT;
@@ -70816,7 +71473,7 @@ function WebGLUtils( gl, extensions ) {
70816
71473
 
70817
71474
  if ( extension !== null ) {
70818
71475
 
70819
- if ( p === RGBA_BPTC_Format ) return extension.COMPRESSED_RED_RGTC1_EXT;
71476
+ if ( p === RED_RGTC1_Format ) return extension.COMPRESSED_RED_RGTC1_EXT;
70820
71477
  if ( p === SIGNED_RED_RGTC1_Format ) return extension.COMPRESSED_SIGNED_RED_RGTC1_EXT;
70821
71478
  if ( p === RED_GREEN_RGTC2_Format ) return extension.COMPRESSED_RED_GREEN_RGTC2_EXT;
70822
71479
  if ( p === SIGNED_RED_GREEN_RGTC2_Format ) return extension.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
@@ -70882,9 +71539,9 @@ class WebXRDepthSensing {
70882
71539
  constructor() {
70883
71540
 
70884
71541
  /**
70885
- * A texture representing the depth of the user's environment.
71542
+ * An opaque texture representing the depth of the user's environment.
70886
71543
  *
70887
- * @type {?Texture}
71544
+ * @type {?ExternalTexture}
70888
71545
  */
70889
71546
  this.texture = null;
70890
71547
 
@@ -70914,18 +71571,14 @@ class WebXRDepthSensing {
70914
71571
  /**
70915
71572
  * Inits the depth sensing module
70916
71573
  *
70917
- * @param {WebGLRenderer} renderer - The renderer.
70918
71574
  * @param {XRWebGLDepthInformation} depthData - The XR depth data.
70919
71575
  * @param {XRRenderState} renderState - The XR render state.
70920
71576
  */
70921
- init( renderer, depthData, renderState ) {
71577
+ init( depthData, renderState ) {
70922
71578
 
70923
71579
  if ( this.texture === null ) {
70924
71580
 
70925
- const texture = new Texture();
70926
-
70927
- const texProps = renderer.properties.get( texture );
70928
- texProps.__webglTexture = depthData.texture;
71581
+ const texture = new ExternalTexture( depthData.texture );
70929
71582
 
70930
71583
  if ( ( depthData.depthNear !== renderState.depthNear ) || ( depthData.depthFar !== renderState.depthFar ) ) {
70931
71584
 
@@ -70986,7 +71639,7 @@ class WebXRDepthSensing {
70986
71639
  /**
70987
71640
  * Returns a texture representing the depth of the user's environment.
70988
71641
  *
70989
- * @return {?Texture} The depth texture.
71642
+ * @return {?ExternalTexture} The depth texture.
70990
71643
  */
70991
71644
  getDepthTexture() {
70992
71645
 
@@ -71035,7 +71688,10 @@ class WebXRManager extends EventDispatcher {
71035
71688
  let glBaseLayer = null;
71036
71689
  let xrFrame = null;
71037
71690
 
71691
+ const supportsGlBinding = typeof XRWebGLBinding !== 'undefined';
71692
+
71038
71693
  const depthSensing = new WebXRDepthSensing();
71694
+ const cameraAccessTextures = {};
71039
71695
  const attributes = gl.getContextAttributes();
71040
71696
 
71041
71697
  let initialRenderTarget = null;
@@ -71216,6 +71872,11 @@ class WebXRManager extends EventDispatcher {
71216
71872
  _currentDepthFar = null;
71217
71873
 
71218
71874
  depthSensing.reset();
71875
+ for ( const key in cameraAccessTextures ) {
71876
+
71877
+ delete cameraAccessTextures[ key ];
71878
+
71879
+ }
71219
71880
 
71220
71881
  // restore framebuffer/rendering state
71221
71882
 
@@ -71306,6 +71967,9 @@ class WebXRManager extends EventDispatcher {
71306
71967
  /**
71307
71968
  * Returns the current base layer.
71308
71969
  *
71970
+ * This is an `XRProjectionLayer` when the targeted XR device supports the
71971
+ * WebXR Layers API, or an `XRWebGLLayer` otherwise.
71972
+ *
71309
71973
  * @return {?(XRWebGLLayer|XRProjectionLayer)} The XR base layer.
71310
71974
  */
71311
71975
  this.getBaseLayer = function () {
@@ -71317,10 +71981,19 @@ class WebXRManager extends EventDispatcher {
71317
71981
  /**
71318
71982
  * Returns the current XR binding.
71319
71983
  *
71320
- * @return {?XRWebGLBinding} The XR binding.
71984
+ * Creates a new binding if needed and the browser is
71985
+ * capable of doing so.
71986
+ *
71987
+ * @return {?XRWebGLBinding} The XR binding. Returns `null` if one cannot be created.
71321
71988
  */
71322
71989
  this.getBinding = function () {
71323
71990
 
71991
+ if ( glBinding === null && supportsGlBinding ) {
71992
+
71993
+ glBinding = new XRWebGLBinding( session, gl );
71994
+
71995
+ }
71996
+
71324
71997
  return glBinding;
71325
71998
 
71326
71999
  };
@@ -71382,11 +72055,12 @@ class WebXRManager extends EventDispatcher {
71382
72055
  currentPixelRatio = renderer.getPixelRatio();
71383
72056
  renderer.getSize( currentSize );
71384
72057
 
72058
+
71385
72059
  // Check that the browser implements the necessary APIs to use an
71386
72060
  // XRProjectionLayer rather than an XRWebGLLayer
71387
- const useLayers = typeof XRWebGLBinding !== 'undefined' && 'createProjectionLayer' in XRWebGLBinding.prototype;
72061
+ const supportsLayers = supportsGlBinding && 'createProjectionLayer' in XRWebGLBinding.prototype;
71388
72062
 
71389
- if ( ! useLayers ) {
72063
+ if ( ! supportsLayers ) {
71390
72064
 
71391
72065
  const layerInit = {
71392
72066
  antialias: attributes.antialias,
@@ -71437,7 +72111,7 @@ class WebXRManager extends EventDispatcher {
71437
72111
  scaleFactor: framebufferScaleFactor
71438
72112
  };
71439
72113
 
71440
- glBinding = new XRWebGLBinding( session, gl );
72114
+ glBinding = this.getBinding();
71441
72115
 
71442
72116
  glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );
71443
72117
 
@@ -71498,6 +72172,8 @@ class WebXRManager extends EventDispatcher {
71498
72172
  /**
71499
72173
  * Returns the current depth texture computed via depth sensing.
71500
72174
  *
72175
+ * See {@link WebXRDepthSensing#getDepthTexture}.
72176
+ *
71501
72177
  * @return {?Texture} The depth texture.
71502
72178
  */
71503
72179
  this.getDepthTexture = function () {
@@ -71668,7 +72344,7 @@ class WebXRManager extends EventDispatcher {
71668
72344
 
71669
72345
  /**
71670
72346
  * Updates the state of the XR camera. Use this method on app level if you
71671
- * set cameraAutoUpdate` to `false`. The method requires the non-XR
72347
+ * set `cameraAutoUpdate` to `false`. The method requires the non-XR
71672
72348
  * camera of the scene as a parameter. The passed in camera's transformation
71673
72349
  * is automatically adjusted to the position of the XR camera when calling
71674
72350
  * this method.
@@ -71706,9 +72382,10 @@ class WebXRManager extends EventDispatcher {
71706
72382
 
71707
72383
  }
71708
72384
 
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;
72385
+ // inherit camera layers and enable eye layers (1 = left, 2 = right)
72386
+ cameraXR.layers.mask = camera.layers.mask | 0b110;
72387
+ cameraL.layers.mask = cameraXR.layers.mask & 0b011;
72388
+ cameraR.layers.mask = cameraXR.layers.mask & 0b101;
71712
72389
 
71713
72390
  const parent = camera.parent;
71714
72391
  const cameras = cameraXR.cameras;
@@ -71789,7 +72466,7 @@ class WebXRManager extends EventDispatcher {
71789
72466
  /**
71790
72467
  * Returns the amount of foveation used by the XR compositor for the projection layer.
71791
72468
  *
71792
- * @return {number} The amount of foveation.
72469
+ * @return {number|undefined} The amount of foveation.
71793
72470
  */
71794
72471
  this.getFoveation = function () {
71795
72472
 
@@ -71844,6 +72521,8 @@ class WebXRManager extends EventDispatcher {
71844
72521
  /**
71845
72522
  * Returns the depth sensing mesh.
71846
72523
  *
72524
+ * See {@link WebXRDepthSensing#getMesh}.
72525
+ *
71847
72526
  * @return {Mesh} The depth sensing mesh.
71848
72527
  */
71849
72528
  this.getDepthSensingMesh = function () {
@@ -71852,6 +72531,19 @@ class WebXRManager extends EventDispatcher {
71852
72531
 
71853
72532
  };
71854
72533
 
72534
+ /**
72535
+ * Retrieves an opaque texture from the view-aligned {@link XRCamera}.
72536
+ * Only available during the current animation loop.
72537
+ *
72538
+ * @param {XRCamera} xrCamera - The camera to query.
72539
+ * @return {?Texture} An opaque texture representing the current raw camera frame.
72540
+ */
72541
+ this.getCameraTexture = function ( xrCamera ) {
72542
+
72543
+ return cameraAccessTextures[ xrCamera ];
72544
+
72545
+ };
72546
+
71855
72547
  // Animation Loop
71856
72548
 
71857
72549
  let onAnimationFrameCallback = null;
@@ -71951,13 +72643,48 @@ class WebXRManager extends EventDispatcher {
71951
72643
  enabledFeatures.includes( 'depth-sensing' ) &&
71952
72644
  session.depthUsage == 'gpu-optimized';
71953
72645
 
71954
- if ( gpuDepthSensingEnabled && glBinding ) {
72646
+ if ( gpuDepthSensingEnabled && supportsGlBinding ) {
72647
+
72648
+ glBinding = scope.getBinding();
71955
72649
 
71956
72650
  const depthData = glBinding.getDepthInformation( views[ 0 ] );
71957
72651
 
71958
72652
  if ( depthData && depthData.isValid && depthData.texture ) {
71959
72653
 
71960
- depthSensing.init( renderer, depthData, session.renderState );
72654
+ depthSensing.init( depthData, session.renderState );
72655
+
72656
+ }
72657
+
72658
+ }
72659
+
72660
+ const cameraAccessEnabled = enabledFeatures &&
72661
+ enabledFeatures.includes( 'camera-access' );
72662
+
72663
+ if ( cameraAccessEnabled && supportsGlBinding ) {
72664
+
72665
+ renderer.state.unbindTexture();
72666
+
72667
+ glBinding = scope.getBinding();
72668
+
72669
+ for ( let i = 0; i < views.length; i ++ ) {
72670
+
72671
+ const camera = views[ i ].camera;
72672
+
72673
+ if ( camera ) {
72674
+
72675
+ let cameraTex = cameraAccessTextures[ camera ];
72676
+
72677
+ if ( ! cameraTex ) {
72678
+
72679
+ cameraTex = new ExternalTexture();
72680
+ cameraAccessTextures[ camera ] = cameraTex;
72681
+
72682
+ }
72683
+
72684
+ const glTexture = glBinding.getCameraImage( camera );
72685
+ cameraTex.sourceTexture = glTexture;
72686
+
72687
+ }
71961
72688
 
71962
72689
  }
71963
72690
 
@@ -72146,17 +72873,17 @@ function WebGLMaterials( renderer, properties ) {
72146
72873
 
72147
72874
  }
72148
72875
 
72149
- if ( material.texture3DMatrix ) {
72876
+ if ( material.texture3DMatrix ) {
72150
72877
 
72151
- uniforms.texture3DMatrix.value.copy( material.texture3DMatrix );
72878
+ uniforms.texture3DMatrix.value.copy( material.texture3DMatrix );
72152
72879
 
72153
- }
72880
+ }
72154
72881
 
72155
- if ( material.triplanarHardness ) {
72882
+ if ( material.triplanarHardness ) {
72156
72883
 
72157
- uniforms.triplanarHardness.value = material.triplanarHardness;
72884
+ uniforms.triplanarHardness.value = material.triplanarHardness;
72158
72885
 
72159
- }
72886
+ }
72160
72887
 
72161
72888
  if ( material.alphaMap ) {
72162
72889
 
@@ -73020,7 +73747,7 @@ class WebGLRenderer {
73020
73747
  preserveDrawingBuffer = false,
73021
73748
  powerPreference = 'default',
73022
73749
  failIfMajorPerformanceCaveat = false,
73023
- reverseDepthBuffer = false,
73750
+ reversedDepthBuffer = false,
73024
73751
  } = parameters;
73025
73752
 
73026
73753
  /**
@@ -73253,7 +73980,6 @@ class WebGLRenderer {
73253
73980
 
73254
73981
  // camera matrices cache
73255
73982
 
73256
- const _currentProjectionMatrix = new Matrix4();
73257
73983
  const _projScreenMatrix = new Matrix4();
73258
73984
 
73259
73985
  const _vector3 = new Vector3();
@@ -73349,7 +74075,7 @@ class WebGLRenderer {
73349
74075
 
73350
74076
  state = new WebGLState( _gl, extensions );
73351
74077
 
73352
- if ( capabilities.reverseDepthBuffer && reverseDepthBuffer ) {
74078
+ if ( capabilities.reversedDepthBuffer && reversedDepthBuffer ) {
73353
74079
 
73354
74080
  state.buffers.depth.setReversed( true );
73355
74081
 
@@ -74497,7 +75223,7 @@ class WebGLRenderer {
74497
75223
  renderStateStack.push( currentRenderState );
74498
75224
 
74499
75225
  _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
74500
- _frustum.setFromProjectionMatrix( _projScreenMatrix );
75226
+ _frustum.setFromProjectionMatrix( _projScreenMatrix, WebGLCoordinateSystem, camera.reversedDepth );
74501
75227
 
74502
75228
  _localClippingEnabled = this.localClippingEnabled;
74503
75229
  _clippingEnabled = clipping.init( this.clippingPlanes, _localClippingEnabled );
@@ -75328,23 +76054,17 @@ class WebGLRenderer {
75328
76054
 
75329
76055
  // common camera uniforms
75330
76056
 
75331
- const reverseDepthBuffer = state.buffers.depth.getReversed();
75332
-
75333
- if ( reverseDepthBuffer ) {
76057
+ const reversedDepthBuffer = state.buffers.depth.getReversed();
75334
76058
 
75335
- _currentProjectionMatrix.copy( camera.projectionMatrix );
76059
+ if ( reversedDepthBuffer && camera.reversedDepth !== true ) {
75336
76060
 
75337
- toNormalizedProjectionMatrix( _currentProjectionMatrix );
75338
- toReversedProjectionMatrix( _currentProjectionMatrix );
75339
-
75340
- p_uniforms.setValue( _gl, 'projectionMatrix', _currentProjectionMatrix );
75341
-
75342
- } else {
75343
-
75344
- p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
76061
+ camera._reversedDepth = true;
76062
+ camera.updateProjectionMatrix();
75345
76063
 
75346
76064
  }
75347
76065
 
76066
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
76067
+
75348
76068
  p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
75349
76069
 
75350
76070
  const uCamPos = p_uniforms.map.cameraPosition;
@@ -75774,9 +76494,15 @@ class WebGLRenderer {
75774
76494
 
75775
76495
  } else if ( isRenderTarget3D ) {
75776
76496
 
75777
- const textureProperties = properties.get( renderTarget.texture );
75778
76497
  const layer = activeCubeFace;
75779
- _gl.framebufferTextureLayer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, activeMipmapLevel, layer );
76498
+
76499
+ for ( let i = 0; i < renderTarget.textures.length; i ++ ) {
76500
+
76501
+ const textureProperties = properties.get( renderTarget.textures[ i ] );
76502
+
76503
+ _gl.framebufferTextureLayer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, textureProperties.__webglTexture, activeMipmapLevel, layer );
76504
+
76505
+ }
75780
76506
 
75781
76507
  } else if ( renderTarget !== null && activeMipmapLevel !== 0 ) {
75782
76508
 
@@ -75928,7 +76654,7 @@ class WebGLRenderer {
75928
76654
  _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
75929
76655
  _gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
75930
76656
 
75931
- // when using MRT, select the corect color buffer for the subsequent read command
76657
+ // when using MRT, select the correct color buffer for the subsequent read command
75932
76658
 
75933
76659
  if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
75934
76660
 
@@ -76255,15 +76981,6 @@ class WebGLRenderer {
76255
76981
 
76256
76982
  };
76257
76983
 
76258
- this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
76259
-
76260
- // @deprecated, r170
76261
- warnOnce( 'WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.' );
76262
-
76263
- return this.copyTextureToTexture( srcTexture, dstTexture, srcRegion, dstPosition, level );
76264
-
76265
- };
76266
-
76267
76984
  /**
76268
76985
  * Initializes the given WebGLRenderTarget memory. Useful for initializing a render target so data
76269
76986
  * can be copied into it using {@link WebGLRenderer#copyTextureToTexture} before it has been
@@ -76488,6 +77205,7 @@ exports.EquirectangularReflectionMapping = EquirectangularReflectionMapping;
76488
77205
  exports.EquirectangularRefractionMapping = EquirectangularRefractionMapping;
76489
77206
  exports.Euler = Euler;
76490
77207
  exports.EventDispatcher = EventDispatcher;
77208
+ exports.ExternalTexture = ExternalTexture;
76491
77209
  exports.ExtrudeGeometry = ExtrudeGeometry;
76492
77210
  exports.FileLoader = FileLoader;
76493
77211
  exports.Float16BufferAttribute = Float16BufferAttribute;
@@ -76747,6 +77465,7 @@ exports.TetrahedronGeometry = TetrahedronGeometry;
76747
77465
  exports.Texture = Texture;
76748
77466
  exports.TextureLoader = TextureLoader;
76749
77467
  exports.TextureUtils = TextureUtils;
77468
+ exports.Timer = Timer;
76750
77469
  exports.TimestampQuery = TimestampQuery;
76751
77470
  exports.TorusGeometry = TorusGeometry;
76752
77471
  exports.TorusKnotGeometry = TorusKnotGeometry;
@@ -76766,6 +77485,7 @@ exports.UniformsGroup = UniformsGroup;
76766
77485
  exports.UniformsLib = UniformsLib;
76767
77486
  exports.UniformsUtils = UniformsUtils;
76768
77487
  exports.UnsignedByteType = UnsignedByteType;
77488
+ exports.UnsignedInt101111Type = UnsignedInt101111Type;
76769
77489
  exports.UnsignedInt248Type = UnsignedInt248Type;
76770
77490
  exports.UnsignedInt5999Type = UnsignedInt5999Type;
76771
77491
  exports.UnsignedIntType = UnsignedIntType;