@plastic-software/three 0.175.14 → 0.179.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (572) hide show
  1. package/README.md +4 -4
  2. package/build/three.cjs +8402 -6787
  3. package/build/three.core.js +8007 -6688
  4. package/build/three.core.min.js +1 -1
  5. package/build/three.module.js +397 -102
  6. package/build/three.module.min.js +1 -1
  7. package/build/three.tsl.js +84 -27
  8. package/build/three.tsl.min.js +1 -1
  9. package/build/three.webgpu.js +6831 -2838
  10. package/build/three.webgpu.min.js +1 -1
  11. package/build/three.webgpu.nodes.js +6648 -2838
  12. package/build/three.webgpu.nodes.min.js +1 -1
  13. package/examples/jsm/Addons.js +1 -3
  14. package/examples/jsm/animation/AnimationClipCreator.js +1 -0
  15. package/examples/jsm/animation/CCDIKSolver.js +6 -3
  16. package/examples/jsm/capabilities/WebGL.js +1 -27
  17. package/examples/jsm/capabilities/WebGPU.js +2 -1
  18. package/examples/jsm/controls/ArcballControls.js +15 -4
  19. package/examples/jsm/controls/DragControls.js +1 -0
  20. package/examples/jsm/controls/FirstPersonControls.js +1 -0
  21. package/examples/jsm/controls/FlyControls.js +1 -0
  22. package/examples/jsm/controls/MapControls.js +1 -0
  23. package/examples/jsm/controls/OrbitControls.js +1 -0
  24. package/examples/jsm/controls/PointerLockControls.js +5 -3
  25. package/examples/jsm/controls/TrackballControls.js +1 -0
  26. package/examples/jsm/controls/TransformControls.js +62 -14
  27. package/examples/jsm/csm/CSM.js +2 -0
  28. package/examples/jsm/csm/CSMFrustum.js +2 -0
  29. package/examples/jsm/csm/CSMHelper.js +1 -0
  30. package/examples/jsm/csm/CSMShader.js +4 -1
  31. package/examples/jsm/csm/CSMShadowNode.js +22 -8
  32. package/examples/jsm/curves/CurveExtras.js +14 -0
  33. package/examples/jsm/curves/NURBSCurve.js +1 -0
  34. package/examples/jsm/curves/NURBSSurface.js +2 -0
  35. package/examples/jsm/curves/NURBSUtils.js +4 -1
  36. package/examples/jsm/curves/NURBSVolume.js +2 -0
  37. package/examples/jsm/effects/AnaglyphEffect.js +2 -0
  38. package/examples/jsm/effects/AsciiEffect.js +2 -0
  39. package/examples/jsm/effects/OutlineEffect.js +2 -0
  40. package/examples/jsm/effects/ParallaxBarrierEffect.js +2 -0
  41. package/examples/jsm/effects/StereoEffect.js +2 -0
  42. package/examples/jsm/environments/DebugEnvironment.js +1 -0
  43. package/examples/jsm/environments/RoomEnvironment.js +57 -38
  44. package/examples/jsm/exporters/DRACOExporter.js +4 -2
  45. package/examples/jsm/exporters/EXRExporter.js +2 -0
  46. package/examples/jsm/exporters/GLTFExporter.js +7 -4
  47. package/examples/jsm/exporters/KTX2Exporter.js +2 -0
  48. package/examples/jsm/exporters/OBJExporter.js +3 -1
  49. package/examples/jsm/exporters/PLYExporter.js +4 -2
  50. package/examples/jsm/exporters/STLExporter.js +2 -0
  51. package/examples/jsm/exporters/USDZExporter.js +679 -300
  52. package/examples/jsm/geometries/BoxLineGeometry.js +1 -0
  53. package/examples/jsm/geometries/ConvexGeometry.js +1 -0
  54. package/examples/jsm/geometries/DecalGeometry.js +1 -0
  55. package/examples/jsm/geometries/ParametricFunctions.js +4 -1
  56. package/examples/jsm/geometries/ParametricGeometry.js +1 -0
  57. package/examples/jsm/geometries/RoundedBoxGeometry.js +48 -8
  58. package/examples/jsm/geometries/TeapotGeometry.js +1 -0
  59. package/examples/jsm/geometries/TextGeometry.js +1 -0
  60. package/examples/jsm/helpers/LightProbeHelper.js +1 -0
  61. package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -0
  62. package/examples/jsm/helpers/OctreeHelper.js +1 -0
  63. package/examples/jsm/helpers/PositionalAudioHelper.js +1 -0
  64. package/examples/jsm/helpers/RapierHelper.js +59 -0
  65. package/examples/jsm/helpers/RectAreaLightHelper.js +1 -0
  66. package/examples/jsm/helpers/TextureHelper.js +1 -0
  67. package/examples/jsm/helpers/TextureHelperGPU.js +5 -4
  68. package/examples/jsm/helpers/VertexNormalsHelper.js +1 -0
  69. package/examples/jsm/helpers/VertexTangentsHelper.js +1 -0
  70. package/examples/jsm/helpers/ViewHelper.js +1 -0
  71. package/examples/jsm/interactive/HTMLMesh.js +11 -2
  72. package/examples/jsm/interactive/InteractiveGroup.js +1 -0
  73. package/examples/jsm/interactive/SelectionBox.js +2 -0
  74. package/examples/jsm/interactive/SelectionHelper.js +2 -0
  75. package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
  76. package/examples/jsm/lighting/TiledLighting.js +1 -0
  77. package/examples/jsm/lights/LightProbeGenerator.js +15 -3
  78. package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -0
  79. package/examples/jsm/lights/RectAreaLightUniformsLib.js +1 -0
  80. package/examples/jsm/lines/Line2.js +1 -0
  81. package/examples/jsm/lines/LineGeometry.js +1 -0
  82. package/examples/jsm/lines/LineMaterial.js +4 -4
  83. package/examples/jsm/lines/LineSegments2.js +1 -0
  84. package/examples/jsm/lines/LineSegmentsGeometry.js +1 -0
  85. package/examples/jsm/lines/Wireframe.js +1 -0
  86. package/examples/jsm/lines/WireframeGeometry2.js +1 -0
  87. package/examples/jsm/lines/webgpu/Line2.js +1 -0
  88. package/examples/jsm/lines/webgpu/LineSegments2.js +3 -1
  89. package/examples/jsm/lines/webgpu/Wireframe.js +1 -0
  90. package/examples/jsm/loaders/3DMLoader.js +1 -0
  91. package/examples/jsm/loaders/3MFLoader.js +1 -0
  92. package/examples/jsm/loaders/AMFLoader.js +1 -0
  93. package/examples/jsm/loaders/BVHLoader.js +1 -0
  94. package/examples/jsm/loaders/ColladaLoader.js +6 -5
  95. package/examples/jsm/loaders/DDSLoader.js +1 -0
  96. package/examples/jsm/loaders/DRACOLoader.js +2 -1
  97. package/examples/jsm/loaders/EXRLoader.js +211 -22
  98. package/examples/jsm/loaders/FBXLoader.js +25 -23
  99. package/examples/jsm/loaders/FontLoader.js +1 -0
  100. package/examples/jsm/loaders/GCodeLoader.js +1 -0
  101. package/examples/jsm/loaders/GLTFLoader.js +10 -82
  102. package/examples/jsm/loaders/HDRCubeTextureLoader.js +1 -0
  103. package/examples/jsm/loaders/IESLoader.js +1 -0
  104. package/examples/jsm/loaders/KMZLoader.js +1 -0
  105. package/examples/jsm/loaders/KTX2Loader.js +67 -26
  106. package/examples/jsm/loaders/KTXLoader.js +1 -0
  107. package/examples/jsm/loaders/LDrawLoader.js +55 -3
  108. package/examples/jsm/loaders/LUT3dlLoader.js +1 -0
  109. package/examples/jsm/loaders/LUTCubeLoader.js +1 -0
  110. package/examples/jsm/loaders/LUTImageLoader.js +1 -0
  111. package/examples/jsm/loaders/LWOLoader.js +1 -13
  112. package/examples/jsm/loaders/LottieLoader.js +15 -0
  113. package/examples/jsm/loaders/MD2Loader.js +1 -0
  114. package/examples/jsm/loaders/MDDLoader.js +1 -0
  115. package/examples/jsm/loaders/MTLLoader.js +4 -3
  116. package/examples/jsm/loaders/MaterialXLoader.js +213 -30
  117. package/examples/jsm/loaders/NRRDLoader.js +1 -0
  118. package/examples/jsm/loaders/OBJLoader.js +1 -0
  119. package/examples/jsm/loaders/PCDLoader.js +122 -19
  120. package/examples/jsm/loaders/PDBLoader.js +1 -0
  121. package/examples/jsm/loaders/PLYLoader.js +1 -0
  122. package/examples/jsm/loaders/PVRLoader.js +1 -0
  123. package/examples/jsm/loaders/RGBELoader.js +1 -0
  124. package/examples/jsm/loaders/RGBMLoader.js +1 -0
  125. package/examples/jsm/loaders/STLLoader.js +1 -0
  126. package/examples/jsm/loaders/SVGLoader.js +1 -0
  127. package/examples/jsm/loaders/TDSLoader.js +1 -0
  128. package/examples/jsm/loaders/TGALoader.js +1 -0
  129. package/examples/jsm/loaders/TIFFLoader.js +1 -0
  130. package/examples/jsm/loaders/TTFLoader.js +14 -1
  131. package/examples/jsm/loaders/USDLoader.js +219 -0
  132. package/examples/jsm/loaders/USDZLoader.js +4 -891
  133. package/examples/jsm/loaders/UltraHDRLoader.js +1 -0
  134. package/examples/jsm/loaders/VOXLoader.js +1 -0
  135. package/examples/jsm/loaders/VRMLLoader.js +3 -2
  136. package/examples/jsm/loaders/VTKLoader.js +1 -0
  137. package/examples/jsm/loaders/XYZLoader.js +1 -0
  138. package/examples/jsm/loaders/lwo/IFFParser.js +74 -74
  139. package/examples/jsm/loaders/usd/USDAParser.js +741 -0
  140. package/examples/jsm/loaders/usd/USDCParser.js +17 -0
  141. package/examples/jsm/materials/LDrawConditionalLineMaterial.js +1 -0
  142. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -0
  143. package/examples/jsm/materials/MeshPostProcessingMaterial.js +1 -0
  144. package/examples/jsm/math/Capsule.js +2 -0
  145. package/examples/jsm/math/ColorConverter.js +1 -0
  146. package/examples/jsm/math/ConvexHull.js +2 -0
  147. package/examples/jsm/math/ImprovedNoise.js +19 -14
  148. package/examples/jsm/math/Lut.js +2 -0
  149. package/examples/jsm/math/MeshSurfaceSampler.js +2 -0
  150. package/examples/jsm/math/OBB.js +2 -0
  151. package/examples/jsm/math/Octree.js +20 -1
  152. package/examples/jsm/math/SimplexNoise.js +2 -0
  153. package/examples/jsm/misc/ConvexObjectBreaker.js +3 -1
  154. package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
  155. package/examples/jsm/misc/Gyroscope.js +1 -0
  156. package/examples/jsm/misc/MD2Character.js +2 -0
  157. package/examples/jsm/misc/MD2CharacterComplex.js +5 -3
  158. package/examples/jsm/misc/MorphAnimMesh.js +1 -0
  159. package/examples/jsm/misc/MorphBlendMesh.js +1 -0
  160. package/examples/jsm/misc/ProgressiveLightMap.js +2 -0
  161. package/examples/jsm/misc/ProgressiveLightMapGPU.js +2 -0
  162. package/examples/jsm/misc/RollerCoaster.js +5 -0
  163. package/examples/jsm/misc/TubePainter.js +1 -0
  164. package/examples/jsm/misc/Volume.js +2 -0
  165. package/examples/jsm/misc/VolumeSlice.js +1 -0
  166. package/examples/jsm/modifiers/CurveModifier.js +3 -0
  167. package/examples/jsm/modifiers/CurveModifierGPU.js +2 -0
  168. package/examples/jsm/modifiers/EdgeSplitModifier.js +2 -0
  169. package/examples/jsm/modifiers/SimplifyModifier.js +2 -0
  170. package/examples/jsm/modifiers/TessellateModifier.js +2 -0
  171. package/examples/jsm/objects/GroundedSkybox.js +1 -0
  172. package/examples/jsm/objects/Lensflare.js +3 -0
  173. package/examples/jsm/objects/LensflareMesh.js +4 -3
  174. package/examples/jsm/objects/MarchingCubes.js +2 -0
  175. package/examples/jsm/objects/Reflector.js +1 -0
  176. package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
  177. package/examples/jsm/objects/Refractor.js +1 -0
  178. package/examples/jsm/objects/ShadowMesh.js +1 -0
  179. package/examples/jsm/objects/Sky.js +2 -1
  180. package/examples/jsm/objects/SkyMesh.js +22 -19
  181. package/examples/jsm/objects/Water.js +1 -0
  182. package/examples/jsm/objects/Water2.js +1 -0
  183. package/examples/jsm/objects/Water2Mesh.js +3 -1
  184. package/examples/jsm/objects/WaterMesh.js +2 -1
  185. package/examples/jsm/physics/AmmoPhysics.js +1 -0
  186. package/examples/jsm/physics/JoltPhysics.js +1 -0
  187. package/examples/jsm/physics/RapierPhysics.js +149 -13
  188. package/examples/jsm/postprocessing/AfterimagePass.js +20 -2
  189. package/examples/jsm/postprocessing/BloomPass.js +2 -1
  190. package/examples/jsm/postprocessing/BokehPass.js +2 -1
  191. package/examples/jsm/postprocessing/ClearPass.js +1 -0
  192. package/examples/jsm/postprocessing/CubeTexturePass.js +1 -0
  193. package/examples/jsm/postprocessing/DotScreenPass.js +1 -0
  194. package/examples/jsm/postprocessing/EffectComposer.js +4 -2
  195. package/examples/jsm/postprocessing/FXAAPass.js +40 -0
  196. package/examples/jsm/postprocessing/FilmPass.js +1 -0
  197. package/examples/jsm/postprocessing/GTAOPass.js +14 -12
  198. package/examples/jsm/postprocessing/GlitchPass.js +2 -1
  199. package/examples/jsm/postprocessing/HalftonePass.js +2 -1
  200. package/examples/jsm/postprocessing/LUTPass.js +1 -0
  201. package/examples/jsm/postprocessing/MaskPass.js +1 -0
  202. package/examples/jsm/postprocessing/OutlinePass.js +22 -19
  203. package/examples/jsm/postprocessing/OutputPass.js +1 -0
  204. package/examples/jsm/postprocessing/Pass.js +3 -1
  205. package/examples/jsm/postprocessing/RenderPass.js +1 -0
  206. package/examples/jsm/postprocessing/RenderPixelatedPass.js +2 -1
  207. package/examples/jsm/postprocessing/RenderTransitionPass.js +4 -3
  208. package/examples/jsm/postprocessing/SAOPass.js +3 -2
  209. package/examples/jsm/postprocessing/SMAAPass.js +3 -2
  210. package/examples/jsm/postprocessing/SSAARenderPass.js +2 -1
  211. package/examples/jsm/postprocessing/SSAOPass.js +12 -10
  212. package/examples/jsm/postprocessing/SSRPass.js +4 -3
  213. package/examples/jsm/postprocessing/SavePass.js +2 -1
  214. package/examples/jsm/postprocessing/ShaderPass.js +1 -0
  215. package/examples/jsm/postprocessing/TAARenderPass.js +1 -0
  216. package/examples/jsm/postprocessing/TexturePass.js +1 -0
  217. package/examples/jsm/postprocessing/UnrealBloomPass.js +2 -1
  218. package/examples/jsm/renderers/CSS2DRenderer.js +3 -0
  219. package/examples/jsm/renderers/CSS3DRenderer.js +4 -0
  220. package/examples/jsm/renderers/Projector.js +2 -0
  221. package/examples/jsm/renderers/SVGRenderer.js +3 -0
  222. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +4 -1
  223. package/examples/jsm/shaders/AfterimageShader.js +4 -1
  224. package/examples/jsm/shaders/BasicShader.js +4 -1
  225. package/examples/jsm/shaders/BleachBypassShader.js +4 -1
  226. package/examples/jsm/shaders/BlendShader.js +4 -1
  227. package/examples/jsm/shaders/BokehShader.js +4 -1
  228. package/examples/jsm/shaders/BokehShader2.js +4 -1
  229. package/examples/jsm/shaders/BrightnessContrastShader.js +4 -1
  230. package/examples/jsm/shaders/ColorCorrectionShader.js +4 -1
  231. package/examples/jsm/shaders/ColorifyShader.js +4 -1
  232. package/examples/jsm/shaders/ConvolutionShader.js +4 -1
  233. package/examples/jsm/shaders/CopyShader.js +4 -1
  234. package/examples/jsm/shaders/DOFMipMapShader.js +4 -1
  235. package/examples/jsm/shaders/DepthLimitedBlurShader.js +4 -1
  236. package/examples/jsm/shaders/DigitalGlitch.js +4 -1
  237. package/examples/jsm/shaders/DotScreenShader.js +4 -1
  238. package/examples/jsm/shaders/ExposureShader.js +4 -1
  239. package/examples/jsm/shaders/FXAAShader.js +4 -1
  240. package/examples/jsm/shaders/FilmShader.js +4 -1
  241. package/examples/jsm/shaders/FocusShader.js +4 -1
  242. package/examples/jsm/shaders/FreiChenShader.js +4 -1
  243. package/examples/jsm/shaders/GTAOShader.js +4 -1
  244. package/examples/jsm/shaders/GammaCorrectionShader.js +4 -1
  245. package/examples/jsm/shaders/GodRaysShader.js +4 -1
  246. package/examples/jsm/shaders/HalftoneShader.js +4 -1
  247. package/examples/jsm/shaders/HorizontalBlurShader.js +4 -1
  248. package/examples/jsm/shaders/HorizontalTiltShiftShader.js +4 -1
  249. package/examples/jsm/shaders/HueSaturationShader.js +4 -1
  250. package/examples/jsm/shaders/KaleidoShader.js +4 -1
  251. package/examples/jsm/shaders/LuminosityHighPassShader.js +4 -1
  252. package/examples/jsm/shaders/LuminosityShader.js +4 -1
  253. package/examples/jsm/shaders/MirrorShader.js +4 -1
  254. package/examples/jsm/shaders/NormalMapShader.js +4 -1
  255. package/examples/jsm/shaders/OutputShader.js +4 -1
  256. package/examples/jsm/shaders/PoissonDenoiseShader.js +4 -1
  257. package/examples/jsm/shaders/RGBShiftShader.js +4 -1
  258. package/examples/jsm/shaders/SAOShader.js +4 -1
  259. package/examples/jsm/shaders/SMAAShader.js +1 -0
  260. package/examples/jsm/shaders/SSAOShader.js +4 -1
  261. package/examples/jsm/shaders/SSRShader.js +1 -0
  262. package/examples/jsm/shaders/SepiaShader.js +4 -1
  263. package/examples/jsm/shaders/SobelOperatorShader.js +4 -1
  264. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +4 -1
  265. package/examples/jsm/shaders/TechnicolorShader.js +4 -1
  266. package/examples/jsm/shaders/ToonShader.js +2 -1
  267. package/examples/jsm/shaders/TriangleBlurShader.js +4 -1
  268. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +15 -3
  269. package/examples/jsm/shaders/VelocityShader.js +4 -1
  270. package/examples/jsm/shaders/VerticalBlurShader.js +4 -1
  271. package/examples/jsm/shaders/VerticalTiltShiftShader.js +4 -1
  272. package/examples/jsm/shaders/VignetteShader.js +4 -1
  273. package/examples/jsm/shaders/VolumeShader.js +5 -2
  274. package/examples/jsm/shaders/WaterRefractionShader.js +4 -1
  275. package/examples/jsm/textures/FlakesTexture.js +2 -0
  276. package/examples/jsm/transpiler/AST.js +381 -30
  277. package/examples/jsm/transpiler/GLSLDecoder.js +227 -88
  278. package/examples/jsm/transpiler/Linker.js +327 -0
  279. package/examples/jsm/transpiler/TSLEncoder.js +234 -85
  280. package/examples/jsm/transpiler/Transpiler.js +19 -1
  281. package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
  282. package/examples/jsm/transpiler/WGSLEncoder.js +788 -0
  283. package/examples/jsm/tsl/display/AfterImageNode.js +2 -3
  284. package/examples/jsm/tsl/display/AnaglyphPassNode.js +1 -0
  285. package/examples/jsm/tsl/display/AnamorphicNode.js +5 -4
  286. package/examples/jsm/tsl/display/BloomNode.js +9 -7
  287. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +206 -0
  288. package/examples/jsm/tsl/display/DenoiseNode.js +33 -33
  289. package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -0
  290. package/examples/jsm/tsl/display/DotScreenNode.js +1 -0
  291. package/examples/jsm/tsl/display/FXAANode.js +3 -2
  292. package/examples/jsm/tsl/display/FilmNode.js +1 -0
  293. package/examples/jsm/tsl/display/GTAONode.js +1 -0
  294. package/examples/jsm/tsl/display/GaussianBlurNode.js +9 -36
  295. package/examples/jsm/tsl/display/LensflareNode.js +1 -0
  296. package/examples/jsm/tsl/display/Lut3DNode.js +1 -0
  297. package/examples/jsm/tsl/display/OutlineNode.js +1 -0
  298. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +1 -0
  299. package/examples/jsm/tsl/display/PixelationPassNode.js +1 -0
  300. package/examples/jsm/tsl/display/RGBShiftNode.js +1 -0
  301. package/examples/jsm/tsl/display/SMAANode.js +9 -8
  302. package/examples/jsm/tsl/display/SSAAPassNode.js +5 -4
  303. package/examples/jsm/tsl/display/SSRNode.js +1 -0
  304. package/examples/jsm/tsl/display/SobelOperatorNode.js +1 -0
  305. package/examples/jsm/tsl/display/StereoCompositePassNode.js +1 -0
  306. package/examples/jsm/tsl/display/StereoPassNode.js +1 -0
  307. package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +184 -174
  308. package/examples/jsm/tsl/display/TransitionNode.js +1 -0
  309. package/examples/jsm/tsl/display/hashBlur.js +28 -6
  310. package/examples/jsm/tsl/lighting/TiledLightsNode.js +5 -4
  311. package/examples/jsm/tsl/math/Bayer.js +4 -1
  312. package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
  313. package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
  314. package/examples/jsm/tsl/utils/Raymarching.js +6 -3
  315. package/examples/jsm/utils/BufferGeometryUtils.js +4 -1
  316. package/examples/jsm/utils/CameraUtils.js +4 -1
  317. package/examples/jsm/utils/GeometryCompressionUtils.js +4 -1
  318. package/examples/jsm/utils/GeometryUtils.js +4 -1
  319. package/examples/jsm/utils/LDrawUtils.js +2 -0
  320. package/examples/jsm/utils/SceneOptimizer.js +2 -0
  321. package/examples/jsm/utils/SceneUtils.js +4 -1
  322. package/examples/jsm/utils/ShadowMapViewer.js +2 -0
  323. package/examples/jsm/utils/ShadowMapViewerGPU.js +2 -0
  324. package/examples/jsm/utils/SkeletonUtils.js +4 -1
  325. package/examples/jsm/utils/SortUtils.js +4 -1
  326. package/examples/jsm/utils/UVsDebug.js +4 -1
  327. package/examples/jsm/utils/WebGLTextureUtils.js +4 -1
  328. package/examples/jsm/utils/WebGPUTextureUtils.js +4 -1
  329. package/examples/jsm/utils/WorkerPool.js +2 -0
  330. package/examples/jsm/webxr/ARButton.js +1 -0
  331. package/examples/jsm/webxr/OculusHandModel.js +1 -0
  332. package/examples/jsm/webxr/OculusHandPointerModel.js +1 -0
  333. package/examples/jsm/webxr/Text2D.js +4 -1
  334. package/examples/jsm/webxr/VRButton.js +1 -0
  335. package/examples/jsm/webxr/XRButton.js +1 -0
  336. package/examples/jsm/webxr/XRControllerModelFactory.js +2 -0
  337. package/examples/jsm/webxr/XREstimatedLight.js +1 -0
  338. package/examples/jsm/webxr/XRHandMeshModel.js +2 -0
  339. package/examples/jsm/webxr/XRHandModelFactory.js +2 -0
  340. package/examples/jsm/webxr/XRHandPrimitiveModel.js +2 -0
  341. package/examples/jsm/webxr/XRPlanes.js +1 -0
  342. package/package.json +6 -4
  343. package/src/Three.Core.js +2 -1
  344. package/src/Three.TSL.js +83 -26
  345. package/src/Three.WebGPU.Nodes.js +1 -0
  346. package/src/Three.WebGPU.js +3 -0
  347. package/src/animation/KeyframeTrack.js +1 -1
  348. package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
  349. package/src/animation/tracks/StringKeyframeTrack.js +1 -1
  350. package/src/audio/AudioListener.js +13 -10
  351. package/src/cameras/ArrayCamera.js +9 -1
  352. package/src/cameras/Camera.js +14 -0
  353. package/src/cameras/OrthographicCamera.js +1 -1
  354. package/src/cameras/PerspectiveCamera.js +1 -1
  355. package/src/constants.js +47 -20
  356. package/src/core/BufferAttribute.js +3 -3
  357. package/src/core/BufferGeometry.js +2 -5
  358. package/src/core/Clock.js +2 -8
  359. package/src/core/GLBufferAttribute.js +13 -1
  360. package/src/core/Object3D.js +23 -22
  361. package/src/core/RenderTarget.js +65 -21
  362. package/src/core/RenderTarget3D.js +1 -0
  363. package/{examples/jsm/misc → src/core}/Timer.js +4 -40
  364. package/src/extras/PMREMGenerator.js +11 -0
  365. package/src/extras/TextureUtils.js +1 -5
  366. package/src/extras/core/Curve.js +1 -1
  367. package/src/extras/core/Path.js +22 -22
  368. package/src/geometries/CapsuleGeometry.js +167 -17
  369. package/src/geometries/ExtrudeGeometry.js +39 -29
  370. package/src/helpers/ArrowHelper.js +2 -2
  371. package/src/helpers/CameraHelper.js +41 -11
  372. package/src/helpers/SkeletonHelper.js +36 -7
  373. package/src/lights/LightShadow.js +34 -7
  374. package/src/lights/PointLightShadow.js +1 -1
  375. package/src/lights/SpotLightShadow.js +9 -1
  376. package/src/lights/webgpu/ProjectorLight.js +46 -0
  377. package/src/loaders/BufferGeometryLoader.js +1 -10
  378. package/src/loaders/FileLoader.js +27 -4
  379. package/src/loaders/ImageBitmapLoader.js +48 -9
  380. package/src/loaders/ImageLoader.js +55 -8
  381. package/src/loaders/Loader.js +14 -0
  382. package/src/loaders/LoadingManager.js +23 -0
  383. package/src/loaders/ObjectLoader.js +44 -16
  384. package/src/loaders/nodes/NodeObjectLoader.js +2 -2
  385. package/src/materials/Material.js +1 -7
  386. package/src/materials/MeshBasicMaterial.js +1 -1
  387. package/src/materials/nodes/Line2NodeMaterial.js +0 -8
  388. package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
  389. package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
  390. package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
  391. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
  392. package/src/materials/nodes/MeshSSSNodeMaterial.js +2 -2
  393. package/src/materials/nodes/NodeMaterial.js +106 -20
  394. package/src/materials/nodes/PointsNodeMaterial.js +5 -0
  395. package/src/materials/nodes/manager/NodeMaterialObserver.js +107 -4
  396. package/src/math/Box3.js +28 -0
  397. package/src/math/Color.js +7 -7
  398. package/src/math/ColorManagement.js +22 -3
  399. package/src/math/Frustum.js +25 -9
  400. package/src/math/FrustumArray.js +258 -0
  401. package/src/math/Line3.js +129 -2
  402. package/src/math/Matrix4.js +48 -27
  403. package/src/math/Quaternion.js +1 -1
  404. package/src/math/Ray.js +2 -0
  405. package/src/math/Sphere.js +28 -0
  406. package/src/math/Spherical.js +2 -2
  407. package/src/nodes/Nodes.js +3 -3
  408. package/src/nodes/TSL.js +6 -3
  409. package/src/nodes/accessors/AccessorsUtils.js +7 -8
  410. package/src/nodes/accessors/Bitangent.js +54 -26
  411. package/src/nodes/accessors/Camera.js +40 -13
  412. package/src/nodes/accessors/CubeTextureNode.js +50 -2
  413. package/src/nodes/accessors/InstanceNode.js +5 -4
  414. package/src/nodes/accessors/Lights.js +2 -2
  415. package/src/nodes/accessors/MaterialNode.js +4 -0
  416. package/src/nodes/accessors/ModelNode.js +1 -1
  417. package/src/nodes/accessors/Normal.js +110 -24
  418. package/src/nodes/accessors/Object3DNode.js +7 -8
  419. package/src/nodes/accessors/Position.js +14 -4
  420. package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
  421. package/src/nodes/accessors/ReferenceNode.js +19 -4
  422. package/src/nodes/accessors/ReflectVector.js +3 -3
  423. package/src/nodes/accessors/SceneNode.js +1 -1
  424. package/src/nodes/accessors/SkinningNode.js +3 -2
  425. package/src/nodes/accessors/StorageBufferNode.js +25 -0
  426. package/src/nodes/accessors/StorageTextureNode.js +15 -4
  427. package/src/nodes/accessors/Tangent.js +25 -17
  428. package/src/nodes/accessors/TangentUtils.js +46 -0
  429. package/src/nodes/accessors/TextureBicubic.js +21 -3
  430. package/src/nodes/accessors/TextureNode.js +71 -8
  431. package/src/nodes/accessors/UniformArrayNode.js +0 -16
  432. package/src/nodes/accessors/VelocityNode.js +1 -0
  433. package/src/nodes/accessors/VertexColorNode.js +4 -4
  434. package/src/nodes/code/CodeNode.js +8 -11
  435. package/src/nodes/core/ArrayNode.js +12 -0
  436. package/src/nodes/core/AssignNode.js +30 -5
  437. package/src/nodes/core/AttributeNode.js +2 -2
  438. package/src/nodes/core/ContextNode.js +27 -4
  439. package/src/nodes/core/Node.js +83 -22
  440. package/src/nodes/core/NodeBuilder.js +273 -49
  441. package/src/nodes/core/NodeUtils.js +46 -1
  442. package/src/nodes/core/NodeVarying.js +19 -1
  443. package/src/nodes/core/PropertyNode.js +8 -12
  444. package/src/nodes/core/StackNode.js +171 -26
  445. package/src/nodes/core/StructTypeNode.js +26 -4
  446. package/src/nodes/core/SubBuildNode.js +89 -0
  447. package/src/nodes/core/UniformNode.js +63 -5
  448. package/src/nodes/core/VarNode.js +102 -4
  449. package/src/nodes/core/VaryingNode.js +45 -24
  450. package/src/nodes/display/BlendModes.js +42 -1
  451. package/src/nodes/display/ColorSpaceNode.js +4 -27
  452. package/src/nodes/display/FrontFacingNode.js +34 -2
  453. package/src/nodes/display/NormalMapNode.js +19 -50
  454. package/src/nodes/display/PassNode.js +165 -20
  455. package/src/nodes/display/ScreenNode.js +0 -26
  456. package/src/nodes/display/ViewportTextureNode.js +67 -7
  457. package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
  458. package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
  459. package/src/nodes/functions/PhongLightingModel.js +3 -3
  460. package/src/nodes/functions/PhysicalLightingModel.js +16 -16
  461. package/src/nodes/functions/ShadowMaskModel.js +5 -1
  462. package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
  463. package/src/nodes/functions/material/getParallaxCorrectNormal.js +1 -1
  464. package/src/nodes/gpgpu/AtomicFunctionNode.js +28 -10
  465. package/src/nodes/gpgpu/BarrierNode.js +3 -3
  466. package/src/nodes/gpgpu/ComputeNode.js +68 -24
  467. package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
  468. package/src/nodes/lighting/AnalyticLightNode.js +7 -13
  469. package/src/nodes/lighting/EnvironmentNode.js +5 -5
  470. package/src/nodes/lighting/HemisphereLightNode.js +2 -2
  471. package/src/nodes/lighting/IESSpotLightNode.js +2 -1
  472. package/src/nodes/lighting/LightsNode.js +29 -11
  473. package/src/nodes/lighting/ProjectorLightNode.js +91 -0
  474. package/src/nodes/lighting/ShadowBaseNode.js +1 -12
  475. package/src/nodes/lighting/ShadowFilterNode.js +274 -0
  476. package/src/nodes/lighting/ShadowNode.js +174 -242
  477. package/src/nodes/lighting/SpotLightNode.js +44 -7
  478. package/src/nodes/materialx/MaterialXNodes.js +131 -2
  479. package/src/nodes/materialx/lib/mx_noise.js +166 -2
  480. package/src/nodes/math/ConditionalNode.js +1 -20
  481. package/src/nodes/math/MathNode.js +146 -75
  482. package/src/nodes/math/OperatorNode.js +129 -119
  483. package/src/nodes/shapes/Shapes.js +5 -4
  484. package/src/nodes/tsl/TSLBase.js +1 -0
  485. package/src/nodes/tsl/TSLCore.js +222 -72
  486. package/src/nodes/utils/DebugNode.js +16 -4
  487. package/src/nodes/utils/Discard.js +2 -2
  488. package/src/nodes/utils/EquirectUV.js +27 -0
  489. package/src/nodes/utils/EventNode.js +83 -0
  490. package/src/nodes/utils/LoopNode.js +64 -34
  491. package/src/nodes/utils/MatcapUV.js +22 -0
  492. package/src/nodes/utils/RTTNode.js +22 -5
  493. package/src/nodes/utils/ReflectorNode.js +77 -7
  494. package/src/nodes/utils/SampleNode.js +81 -0
  495. package/src/nodes/utils/TriplanarTextures.js +65 -0
  496. package/src/objects/BatchedMesh.js +20 -6
  497. package/src/objects/Mesh.js +9 -0
  498. package/src/objects/Skeleton.js +1 -1
  499. package/src/objects/Sprite.js +9 -0
  500. package/src/renderers/WebGL3DRenderTarget.js +1 -0
  501. package/src/renderers/WebGLArrayRenderTarget.js +1 -0
  502. package/src/renderers/WebGLCubeRenderTarget.js +2 -4
  503. package/src/renderers/WebGLRenderer.js +45 -32
  504. package/src/renderers/common/Animation.js +2 -2
  505. package/src/renderers/common/Background.js +13 -2
  506. package/src/renderers/common/Bindings.js +19 -18
  507. package/src/renderers/common/Color4.js +2 -2
  508. package/src/renderers/common/CubeRenderTarget.js +1 -1
  509. package/src/renderers/common/PostProcessing.js +60 -5
  510. package/src/renderers/common/RenderList.js +0 -4
  511. package/src/renderers/common/RenderObject.js +80 -4
  512. package/src/renderers/common/Renderer.js +133 -22
  513. package/src/renderers/common/SampledTexture.js +3 -71
  514. package/src/renderers/common/Sampler.js +79 -0
  515. package/src/renderers/common/Storage3DTexture.js +100 -0
  516. package/src/renderers/common/StorageArrayTexture.js +84 -0
  517. package/src/renderers/common/StorageTexture.js +19 -0
  518. package/src/renderers/common/Textures.js +34 -24
  519. package/src/renderers/common/TimestampQueryPool.js +1 -0
  520. package/src/renderers/common/Uniform.js +1 -1
  521. package/src/renderers/common/UniformsGroup.js +14 -18
  522. package/src/renderers/common/XRManager.js +183 -35
  523. package/src/renderers/common/XRRenderTarget.js +21 -4
  524. package/src/renderers/common/extras/PMREMGenerator.js +30 -23
  525. package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
  526. package/src/renderers/common/nodes/Nodes.js +13 -3
  527. package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +1 -1
  528. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
  529. package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
  530. package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
  531. package/src/renderers/webgl/WebGLAttributes.js +4 -0
  532. package/src/renderers/webgl/WebGLCapabilities.js +2 -2
  533. package/src/renderers/webgl/WebGLMaterials.js +6 -6
  534. package/src/renderers/webgl/WebGLProgram.js +22 -16
  535. package/src/renderers/webgl/WebGLPrograms.js +8 -6
  536. package/src/renderers/webgl/WebGLShadowMap.js +14 -3
  537. package/src/renderers/webgl/WebGLState.js +4 -4
  538. package/src/renderers/webgl/WebGLTextures.js +163 -11
  539. package/src/renderers/webgl/WebGLUtils.js +1 -3
  540. package/src/renderers/webgl-fallback/WebGLBackend.js +261 -94
  541. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +75 -9
  542. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
  543. package/src/renderers/webgl-fallback/utils/WebGLConstants.js +1 -0
  544. package/src/renderers/webgl-fallback/utils/WebGLState.js +4 -4
  545. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +44 -29
  546. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +22 -21
  547. package/src/renderers/webgpu/WebGPUBackend.js +505 -143
  548. package/src/renderers/webgpu/WebGPURenderer.js +7 -0
  549. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +4 -1
  550. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +4 -1
  551. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +129 -96
  552. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +3 -0
  553. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +9 -1
  554. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +58 -31
  555. package/src/renderers/webgpu/utils/WebGPUConstants.js +8 -2
  556. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +39 -9
  557. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +50 -108
  558. package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
  559. package/src/renderers/webxr/WebXRController.js +1 -1
  560. package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
  561. package/src/renderers/webxr/WebXRManager.js +70 -9
  562. package/src/textures/DepthTexture.js +6 -10
  563. package/src/textures/ExternalTexture.js +45 -0
  564. package/src/textures/FramebufferTexture.js +2 -2
  565. package/src/textures/Source.js +32 -0
  566. package/src/textures/Texture.js +118 -1
  567. package/src/textures/VideoTexture.js +31 -3
  568. package/examples/jsm/effects/PeppersGhostEffect.js +0 -172
  569. package/src/core/RenderTargetArray.js +0 -40
  570. package/src/nodes/utils/EquirectUVNode.js +0 -65
  571. package/src/nodes/utils/MatcapUVNode.js +0 -49
  572. package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
@@ -3,8 +3,8 @@
3
3
  * Copyright 2010-2025 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
5
  */
6
- import { Matrix3, Vector2, Color, Matrix4, mergeUniforms, Vector3, CubeUVReflectionMapping, Mesh, BoxGeometry, ShaderMaterial, BackSide, cloneUniforms, Euler, ColorManagement, SRGBTransfer, PlaneGeometry, FrontSide, getUnlitUniformColorSpace, IntType, HalfFloatType, UnsignedByteType, FloatType, RGBAFormat, Plane, EquirectangularReflectionMapping, EquirectangularRefractionMapping, WebGLCubeRenderTarget, CubeReflectionMapping, CubeRefractionMapping, OrthographicCamera, PerspectiveCamera, NoToneMapping, MeshBasicMaterial, NoBlending, WebGLRenderTarget, BufferGeometry, BufferAttribute, LinearSRGBColorSpace, LinearFilter, warnOnce, Uint32BufferAttribute, Uint16BufferAttribute, arrayNeedsUint32, Vector4, DataArrayTexture, CubeTexture, Data3DTexture, LessEqualCompare, DepthTexture, Texture, TriPlanarMapping, CylindricalMapping, UVMapping, GLSL3, PCFShadowMap, PCFSoftShadowMap, VSMShadowMap, CustomToneMapping, NeutralToneMapping, AgXToneMapping, ACESFilmicToneMapping, CineonToneMapping, ReinhardToneMapping, LinearToneMapping, LinearTransfer, AddOperation, MixOperation, MultiplyOperation, UniformsUtils, DoubleSide, NormalBlending, TangentSpaceNormalMap, ObjectSpaceNormalMap, Layers, Frustum, MeshDepthMaterial, RGBADepthPacking, MeshDistanceMaterial, NearestFilter, LessEqualDepth, ReverseSubtractEquation, SubtractEquation, AddEquation, OneMinusConstantAlphaFactor, ConstantAlphaFactor, OneMinusConstantColorFactor, ConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, DstAlphaFactor, DstColorFactor, SrcAlphaSaturateFactor, SrcAlphaFactor, SrcColorFactor, OneFactor, ZeroFactor, NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceNone, CullFaceBack, CullFaceFront, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, MinEquation, MaxEquation, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NotEqualCompare, GreaterCompare, GreaterEqualCompare, EqualCompare, LessCompare, AlwaysCompare, NeverCompare, NoColorSpace, DepthStencilFormat, getByteLength, DepthFormat, UnsignedIntType, UnsignedInt248Type, UnsignedShortType, createElementNS, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedInt5999Type, ByteType, ShortType, AlphaFormat, RGBFormat, LuminanceFormat, LuminanceAlphaFormat, RedFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, EventDispatcher, ArrayCamera, WebXRController, RAD2DEG, createCanvasElement, SRGBColorSpace, REVISION, toNormalizedProjectionMatrix, toReversedProjectionMatrix, probeAsync, WebGLCoordinateSystem } from './three.core.js';
7
- export { AdditiveAnimationBlendMode, AlwaysStencilFunc, AmbientLight, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BasicDepthPacking, BasicShadowMap, BatchedMesh, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxHelper, BufferGeometryLoader, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CircleGeometry, Clock, ColorKeyframeTrack, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, Controls, CubeCamera, CubeTextureLoader, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceFrontBack, Curve, CurvePath, CylinderGeometry, Cylindrical, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DodecahedronGeometry, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualStencilFunc, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, Fog, FogExp2, FramebufferTexture, GLBufferAttribute, GLSL1, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HemisphereLight, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, MOUSE, Material, MaterialLoader, MathUtils, Matrix2, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NeverStencilFunc, NormalAnimationBlendMode, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, OctahedronGeometry, Path, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RGBDepthPacking, RGBIntegerFormat, RGDepthPacking, RawShaderMaterial, Ray, Raycaster, RectAreaLight, RenderTarget, RenderTarget3D, RenderTargetArray, ReplaceStencilOp, RingGeometry, Scene, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, TOUCH, TetrahedronGeometry, TextureLoader, TextureUtils, TimestampQuery, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, VectorKeyframeTrack, VideoFrameTexture, VideoTexture, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroSlopeEnding, ZeroStencilOp } from './three.core.js';
6
+ import { Matrix3, Vector2, Color, Matrix4, mergeUniforms, Vector3, CubeUVReflectionMapping, Mesh, BoxGeometry, ShaderMaterial, BackSide, cloneUniforms, Euler, ColorManagement, SRGBTransfer, PlaneGeometry, FrontSide, getUnlitUniformColorSpace, IntType, HalfFloatType, UnsignedByteType, FloatType, RGBAFormat, Plane, EquirectangularReflectionMapping, EquirectangularRefractionMapping, WebGLCubeRenderTarget, CubeReflectionMapping, CubeRefractionMapping, OrthographicCamera, PerspectiveCamera, NoToneMapping, MeshBasicMaterial, NoBlending, WebGLRenderTarget, BufferGeometry, BufferAttribute, LinearSRGBColorSpace, LinearFilter, warnOnce, Uint32BufferAttribute, Uint16BufferAttribute, arrayNeedsUint32, Vector4, DataArrayTexture, CubeTexture, Data3DTexture, LessEqualCompare, DepthTexture, Texture, TriPlanarMapping, CylindricalMapping, UVMapping, GLSL3, PCFShadowMap, PCFSoftShadowMap, VSMShadowMap, CustomToneMapping, NeutralToneMapping, AgXToneMapping, ACESFilmicToneMapping, CineonToneMapping, ReinhardToneMapping, LinearToneMapping, LinearTransfer, AddOperation, MixOperation, MultiplyOperation, UniformsUtils, DoubleSide, NormalBlending, TangentSpaceNormalMap, ObjectSpaceNormalMap, Layers, Frustum, MeshDepthMaterial, RGBADepthPacking, MeshDistanceMaterial, NearestFilter, LessEqualDepth, ReverseSubtractEquation, SubtractEquation, AddEquation, OneMinusConstantAlphaFactor, ConstantAlphaFactor, OneMinusConstantColorFactor, ConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, DstAlphaFactor, DstColorFactor, SrcAlphaSaturateFactor, SrcAlphaFactor, SrcColorFactor, OneFactor, ZeroFactor, NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceNone, CullFaceBack, CullFaceFront, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, MinEquation, MaxEquation, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NotEqualCompare, GreaterCompare, GreaterEqualCompare, EqualCompare, LessCompare, AlwaysCompare, NeverCompare, NoColorSpace, DepthStencilFormat, getByteLength, DepthFormat, UnsignedIntType, UnsignedInt248Type, UnsignedShortType, createElementNS, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedInt5999Type, ByteType, ShortType, AlphaFormat, RGBFormat, RedFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, EventDispatcher, ArrayCamera, WebXRController, RAD2DEG, createCanvasElement, SRGBColorSpace, REVISION, WebGLCoordinateSystem, probeAsync } from './three.core.js';
7
+ export { AdditiveAnimationBlendMode, AlwaysStencilFunc, AmbientLight, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BasicDepthPacking, BasicShadowMap, BatchedMesh, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxHelper, BufferGeometryLoader, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CircleGeometry, Clock, ColorKeyframeTrack, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, Controls, CubeCamera, CubeTextureLoader, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceFrontBack, Curve, CurvePath, CylinderGeometry, Cylindrical, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DodecahedronGeometry, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualStencilFunc, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, Fog, FogExp2, FramebufferTexture, FrustumArray, GLBufferAttribute, GLSL1, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HemisphereLight, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InterpolationSamplingMode, InterpolationSamplingType, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, MOUSE, Material, MaterialLoader, MathUtils, Matrix2, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NeverStencilFunc, NormalAnimationBlendMode, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, OctahedronGeometry, Path, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RGBDepthPacking, RGBIntegerFormat, RGDepthPacking, RawShaderMaterial, Ray, Raycaster, RectAreaLight, RenderTarget, RenderTarget3D, ReplaceStencilOp, RingGeometry, Scene, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, TOUCH, TetrahedronGeometry, TextureLoader, TextureUtils, Timer, TimestampQuery, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, VectorKeyframeTrack, VideoFrameTexture, VideoTexture, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroSlopeEnding, ZeroStencilOp } from './three.core.js';
8
8
 
9
9
  function WebGLAnimation() {
10
10
 
@@ -81,6 +81,10 @@ function WebGLAttributes( gl ) {
81
81
 
82
82
  type = gl.FLOAT;
83
83
 
84
+ } else if ( typeof Float16Array !== 'undefined' && array instanceof Float16Array ) {
85
+
86
+ type = gl.HALF_FLOAT;
87
+
84
88
  } else if ( array instanceof Uint16Array ) {
85
89
 
86
90
  if ( attribute.isFloat16BufferAttribute ) {
@@ -469,7 +473,7 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
469
473
 
470
474
  var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
471
475
 
472
- 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";
476
+ var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\tfloat depth = unpackRGBAToDepth( texture2D( depths, uv ) );\n\t\t#ifdef USE_REVERSEDEPTHBUF\n\t\t\treturn step( depth, compare );\n\t\t#else\n\t\t\treturn step( compare, depth );\n\t\t#endif\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\t#ifdef USE_REVERSEDEPTHBUF\n\t\t\tfloat hard_shadow = step( distribution.x, compare );\n\t\t#else\n\t\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\t#endif\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif";
473
477
 
474
478
  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";
475
479
 
@@ -519,7 +523,7 @@ const fragment$f = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform fl
519
523
 
520
524
  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}";
521
525
 
522
- 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}";
526
+ const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <triplanar_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSEDEPTHBUF\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}";
523
527
 
524
528
  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}";
525
529
 
@@ -2357,7 +2361,7 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
2357
2361
  }
2358
2362
 
2359
2363
  const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
2360
- const reverseDepthBuffer = parameters.reverseDepthBuffer === true && extensions.has( 'EXT_clip_control' );
2364
+ const reversedDepthBuffer = parameters.reversedDepthBuffer === true && extensions.has( 'EXT_clip_control' );
2361
2365
 
2362
2366
  const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
2363
2367
  const maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
@@ -2385,7 +2389,7 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
2385
2389
 
2386
2390
  precision: precision,
2387
2391
  logarithmicDepthBuffer: logarithmicDepthBuffer,
2388
- reverseDepthBuffer: reverseDepthBuffer,
2392
+ reversedDepthBuffer: reversedDepthBuffer,
2389
2393
 
2390
2394
  maxTextures: maxTextures,
2391
2395
  maxVertexTextures: maxVertexTextures,
@@ -2990,6 +2994,17 @@ class PMREMGenerator {
2990
2994
  renderer.toneMapping = NoToneMapping;
2991
2995
  renderer.autoClear = false;
2992
2996
 
2997
+ // https://github.com/mrdoob/three.js/issues/31413#issuecomment-3095966812
2998
+ const reversedDepthBuffer = renderer.state.buffers.depth.getReversed();
2999
+
3000
+ if ( reversedDepthBuffer ) {
3001
+
3002
+ renderer.setRenderTarget( cubeUVRenderTarget );
3003
+ renderer.clearDepth();
3004
+ renderer.setRenderTarget( null );
3005
+
3006
+ }
3007
+
2993
3008
  const backgroundMaterial = new MeshBasicMaterial( {
2994
3009
  name: 'PMREM.Background',
2995
3010
  side: BackSide,
@@ -5621,7 +5636,9 @@ function getEncodingComponents( colorSpace ) {
5621
5636
  function getShaderErrors( gl, shader, type ) {
5622
5637
 
5623
5638
  const status = gl.getShaderParameter( shader, gl.COMPILE_STATUS );
5624
- const errors = gl.getShaderInfoLog( shader ).trim();
5639
+
5640
+ const shaderInfoLog = gl.getShaderInfoLog( shader ) || '';
5641
+ const errors = shaderInfoLog.trim();
5625
5642
 
5626
5643
  if ( status && errors === '' ) return '';
5627
5644
 
@@ -6125,8 +6142,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
6125
6142
  parameters.bumpMap ? '#define USE_BUMPMAP' : '',
6126
6143
  parameters.normalMap ? '#define USE_NORMALMAP' : '',
6127
6144
  parameters.normalMapMode === TriPlanarMapping ? '#define USE_NORMALMAP_TRIPLANAR' : parameters.normalMapMode === CylindricalMapping ? '#define USE_NORMALMAP_CYLINDRICAL' : parameters.normalMapMode === UVMapping ? '#define USE_NORMALMAP_UV' : '',
6128
- parameters.normalMapObjectSpace && [UVMapping, CylindricalMapping].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
6129
- parameters.normalMapTangentSpace && [UVMapping, CylindricalMapping].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
6145
+ parameters.normalMapObjectSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
6146
+ parameters.normalMapTangentSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
6130
6147
  parameters.displacementMap ? '#define USE_DISPLACEMENTMAP' : '',
6131
6148
  parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
6132
6149
 
@@ -6136,9 +6153,9 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
6136
6153
  parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',
6137
6154
  parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
6138
6155
  parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',
6139
- parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
6140
- : parameters.clearcoatNormalMapMode === CylindricalMapping ? '#define USE_CLEARCOAT_NORMALMAP_CYLINDRICAL'
6141
- : parameters.clearcoatNormalMapMode === UVMapping ? '#define USE_CLEARCOAT_NORMALMAP_UV' : '',
6156
+ parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
6157
+ : parameters.clearcoatNormalMapMode === CylindricalMapping ? '#define USE_CLEARCOAT_NORMALMAP_CYLINDRICAL'
6158
+ : parameters.clearcoatNormalMapMode === UVMapping ? '#define USE_CLEARCOAT_NORMALMAP_UV' : '',
6142
6159
 
6143
6160
  parameters.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '',
6144
6161
  parameters.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '',
@@ -6226,7 +6243,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
6226
6243
  parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
6227
6244
 
6228
6245
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
6229
- parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
6246
+ parameters.reversedDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
6230
6247
 
6231
6248
  'uniform mat4 modelMatrix;',
6232
6249
  'uniform mat4 modelViewMatrix;',
@@ -6332,8 +6349,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
6332
6349
  parameters.bumpMap ? '#define USE_BUMPMAP' : '',
6333
6350
  parameters.normalMap ? '#define USE_NORMALMAP' : '',
6334
6351
  parameters.normalMapMode === TriPlanarMapping ? '#define USE_NORMALMAP_TRIPLANAR' : parameters.normalMapMode === CylindricalMapping ? '#define USE_NORMALMAP_CYLINDRICAL' : parameters.normalMapMode === UVMapping ? '#define USE_NORMALMAP_UV' : '',
6335
- parameters.normalMapObjectSpace && [UVMapping, CylindricalMapping].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
6336
- parameters.normalMapTangentSpace && [UVMapping, CylindricalMapping].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
6352
+ parameters.normalMapObjectSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
6353
+ parameters.normalMapTangentSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
6337
6354
  parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
6338
6355
 
6339
6356
  parameters.anisotropy ? '#define USE_ANISOTROPY' : '',
@@ -6343,9 +6360,9 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
6343
6360
  parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',
6344
6361
  parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
6345
6362
  parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',
6346
- parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
6347
- : parameters.clearcoatNormalMapMode === CylindricalMapping ? '#define USE_CLEARCOAT_NORMALMAP_CYLINDRICAL'
6348
- : parameters.clearcoatNormalMapMode === UVMapping ? '#define USE_CLEARCOAT_NORMALMAP_UV' : '',
6363
+ parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
6364
+ : parameters.clearcoatNormalMapMode === CylindricalMapping ? '#define USE_CLEARCOAT_NORMALMAP_CYLINDRICAL'
6365
+ : parameters.clearcoatNormalMapMode === UVMapping ? '#define USE_CLEARCOAT_NORMALMAP_UV' : '',
6349
6366
 
6350
6367
  parameters.dispersion ? '#define USE_DISPERSION' : '',
6351
6368
 
@@ -6402,7 +6419,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
6402
6419
  parameters.decodeVideoTextureEmissive ? '#define DECODE_VIDEO_TEXTURE_EMISSIVE' : '',
6403
6420
 
6404
6421
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
6405
- parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
6422
+ parameters.reversedDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
6406
6423
 
6407
6424
  'uniform mat4 modelViewMatrix;',
6408
6425
  'uniform mat4 viewMatrix;',
@@ -6503,9 +6520,13 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
6503
6520
  // check for link errors
6504
6521
  if ( renderer.debug.checkShaderErrors ) {
6505
6522
 
6506
- const programLog = gl.getProgramInfoLog( program ).trim();
6507
- const vertexLog = gl.getShaderInfoLog( glVertexShader ).trim();
6508
- const fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();
6523
+ const programInfoLog = gl.getProgramInfoLog( program ) || '';
6524
+ const vertexShaderInfoLog = gl.getShaderInfoLog( glVertexShader ) || '';
6525
+ const fragmentShaderInfoLog = gl.getShaderInfoLog( glFragmentShader ) || '';
6526
+
6527
+ const programLog = programInfoLog.trim();
6528
+ const vertexLog = vertexShaderInfoLog.trim();
6529
+ const fragmentLog = fragmentShaderInfoLog.trim();
6509
6530
 
6510
6531
  let runnable = true;
6511
6532
  let haveDiagnostics = true;
@@ -6891,7 +6912,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
6891
6912
  }
6892
6913
 
6893
6914
  const currentRenderTarget = renderer.getRenderTarget();
6894
- const reverseDepthBuffer = renderer.state.buffers.depth.getReversed();
6915
+ const reversedDepthBuffer = renderer.state.buffers.depth.getReversed();
6895
6916
 
6896
6917
  const IS_INSTANCEDMESH = object.isInstancedMesh === true;
6897
6918
  const IS_BATCHEDMESH = object.isBatchedMesh === true;
@@ -7093,11 +7114,11 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
7093
7114
  useFog: material.fog === true,
7094
7115
  fogExp2: ( !! fog && fog.isFogExp2 ),
7095
7116
 
7096
- flatShading: material.flatShading === true,
7117
+ flatShading: ( material.flatShading === true && material.wireframe === false ),
7097
7118
 
7098
7119
  sizeAttenuation: material.sizeAttenuation === true,
7099
7120
  logarithmicDepthBuffer: logarithmicDepthBuffer,
7100
- reverseDepthBuffer: reverseDepthBuffer,
7121
+ reversedDepthBuffer: reversedDepthBuffer,
7101
7122
 
7102
7123
  skinning: object.isSkinnedMesh === true,
7103
7124
 
@@ -7230,7 +7251,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
7230
7251
  array.push( parameters.anisotropyMapUv );
7231
7252
  array.push( parameters.clearcoatMapUv );
7232
7253
  array.push( parameters.clearcoatNormalMapUv );
7233
- array.push( parameters.clearcoatNormalMapMode);
7254
+ array.push( parameters.clearcoatNormalMapMode );
7234
7255
  array.push( parameters.clearcoatRoughnessMapUv );
7235
7256
  array.push( parameters.iridescenceMapUv );
7236
7257
  array.push( parameters.iridescenceThicknessMapUv );
@@ -7313,8 +7334,10 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
7313
7334
  _programLayers.enable( 20 );
7314
7335
  if ( parameters.batchingColor )
7315
7336
  _programLayers.enable( 21 );
7316
- if ( parameters.batchingMatrix )
7337
+ if ( parameters.gradientMap )
7317
7338
  _programLayers.enable( 22 );
7339
+ if ( parameters.batchingMatrix )
7340
+ _programLayers.enable( 23 );
7318
7341
 
7319
7342
  array.push( _programLayers.mask );
7320
7343
  _programLayers.disableAll();
@@ -7327,7 +7350,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
7327
7350
  _programLayers.enable( 2 );
7328
7351
  if ( parameters.logarithmicDepthBuffer )
7329
7352
  _programLayers.enable( 3 );
7330
- if ( parameters.reverseDepthBuffer )
7353
+ if ( parameters.reversedDepthBuffer )
7331
7354
  _programLayers.enable( 4 );
7332
7355
  if ( parameters.skinning )
7333
7356
  _programLayers.enable( 5 );
@@ -8494,7 +8517,17 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
8494
8517
 
8495
8518
  // Set GL state for depth map.
8496
8519
  _state.setBlending( NoBlending );
8497
- _state.buffers.color.setClear( 1, 1, 1, 1 );
8520
+
8521
+ if ( _state.buffers.depth.getReversed() ) {
8522
+
8523
+ _state.buffers.color.setClear( 0, 0, 0, 0 );
8524
+
8525
+ } else {
8526
+
8527
+ _state.buffers.color.setClear( 1, 1, 1, 1 );
8528
+
8529
+ }
8530
+
8498
8531
  _state.buffers.depth.setTest( true );
8499
8532
  _state.setScissorTest( false );
8500
8533
 
@@ -8667,7 +8700,8 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
8667
8700
  if ( ( renderer.localClippingEnabled && material.clipShadows === true && Array.isArray( material.clippingPlanes ) && material.clippingPlanes.length !== 0 ) ||
8668
8701
  ( material.displacementMap && material.displacementScale !== 0 ) ||
8669
8702
  ( material.alphaMap && material.alphaTest > 0 ) ||
8670
- ( material.map && material.alphaTest > 0 ) ) {
8703
+ ( material.map && material.alphaTest > 0 ) ||
8704
+ ( material.alphaToCoverage === true ) ) {
8671
8705
 
8672
8706
  // in this case we need a unique material instance reflecting the
8673
8707
  // appropriate state
@@ -8713,7 +8747,7 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
8713
8747
  }
8714
8748
 
8715
8749
  result.alphaMap = material.alphaMap;
8716
- result.alphaTest = material.alphaTest;
8750
+ result.alphaTest = ( material.alphaToCoverage === true ) ? 0.5 : material.alphaTest; // approximate alphaToCoverage by using a fixed alphaTest value
8717
8751
  result.map = material.map;
8718
8752
 
8719
8753
  result.clipShadows = material.clipShadows;
@@ -9495,7 +9529,7 @@ function WebGLState( gl, extensions ) {
9495
9529
  break;
9496
9530
 
9497
9531
  case MultiplyBlending:
9498
- gl.blendFuncSeparate( gl.ZERO, gl.SRC_COLOR, gl.ZERO, gl.SRC_ALPHA );
9532
+ gl.blendFuncSeparate( gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ZERO, gl.ONE );
9499
9533
  break;
9500
9534
 
9501
9535
  default:
@@ -9513,15 +9547,15 @@ function WebGLState( gl, extensions ) {
9513
9547
  break;
9514
9548
 
9515
9549
  case AdditiveBlending:
9516
- gl.blendFunc( gl.SRC_ALPHA, gl.ONE );
9550
+ gl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE, gl.ONE, gl.ONE );
9517
9551
  break;
9518
9552
 
9519
9553
  case SubtractiveBlending:
9520
- gl.blendFuncSeparate( gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
9554
+ console.error( 'THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true' );
9521
9555
  break;
9522
9556
 
9523
9557
  case MultiplyBlending:
9524
- gl.blendFunc( gl.ZERO, gl.SRC_COLOR );
9558
+ console.error( 'THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true' );
9525
9559
  break;
9526
9560
 
9527
9561
  default:
@@ -10667,7 +10701,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
10667
10701
 
10668
10702
  if ( texture.isVideoTexture ) updateVideoTexture( texture );
10669
10703
 
10670
- if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
10704
+ if ( texture.isRenderTargetTexture === false && texture.isExternalTexture !== true && texture.version > 0 && textureProperties.__version !== texture.version ) {
10671
10705
 
10672
10706
  const image = texture.image;
10673
10707
 
@@ -10686,6 +10720,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
10686
10720
 
10687
10721
  }
10688
10722
 
10723
+ } else if ( texture.isExternalTexture ) {
10724
+
10725
+ textureProperties.__webglTexture = texture.sourceTexture ? texture.sourceTexture : null;
10726
+
10689
10727
  }
10690
10728
 
10691
10729
  state.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
@@ -10696,7 +10734,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
10696
10734
 
10697
10735
  const textureProperties = properties.get( texture );
10698
10736
 
10699
- if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
10737
+ if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
10700
10738
 
10701
10739
  uploadTexture( textureProperties, texture, slot );
10702
10740
  return;
@@ -10711,7 +10749,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
10711
10749
 
10712
10750
  const textureProperties = properties.get( texture );
10713
10751
 
10714
- if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
10752
+ if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
10715
10753
 
10716
10754
  uploadTexture( textureProperties, texture, slot );
10717
10755
  return;
@@ -10891,6 +10929,115 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
10891
10929
 
10892
10930
  }
10893
10931
 
10932
+ function getRow( index, rowLength, componentStride ) {
10933
+
10934
+ return Math.floor( Math.floor( index / componentStride ) / rowLength );
10935
+
10936
+ }
10937
+
10938
+ function updateTexture( texture, image, glFormat, glType ) {
10939
+
10940
+ const componentStride = 4; // only RGBA supported
10941
+
10942
+ const updateRanges = texture.updateRanges;
10943
+
10944
+ if ( updateRanges.length === 0 ) {
10945
+
10946
+ state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, glFormat, glType, image.data );
10947
+
10948
+ } else {
10949
+
10950
+ // Before applying update ranges, we merge any adjacent / overlapping
10951
+ // ranges to reduce load on `gl.texSubImage2D`. Empirically, this has led
10952
+ // to performance improvements for applications which make heavy use of
10953
+ // update ranges. Likely due to GPU command overhead.
10954
+ //
10955
+ // Note that to reduce garbage collection between frames, we merge the
10956
+ // update ranges in-place. This is safe because this method will clear the
10957
+ // update ranges once updated.
10958
+
10959
+ updateRanges.sort( ( a, b ) => a.start - b.start );
10960
+
10961
+ // To merge the update ranges in-place, we work from left to right in the
10962
+ // existing updateRanges array, merging ranges. This may result in a final
10963
+ // array which is smaller than the original. This index tracks the last
10964
+ // index representing a merged range, any data after this index can be
10965
+ // trimmed once the merge algorithm is completed.
10966
+ let mergeIndex = 0;
10967
+
10968
+ for ( let i = 1; i < updateRanges.length; i ++ ) {
10969
+
10970
+ const previousRange = updateRanges[ mergeIndex ];
10971
+ const range = updateRanges[ i ];
10972
+
10973
+ // Only merge if in the same row and overlapping/adjacent
10974
+ const previousEnd = previousRange.start + previousRange.count;
10975
+ const currentRow = getRow( range.start, image.width, componentStride );
10976
+ const previousRow = getRow( previousRange.start, image.width, componentStride );
10977
+
10978
+ // We add one here to merge adjacent ranges. This is safe because ranges
10979
+ // operate over positive integers.
10980
+ if (
10981
+ range.start <= previousEnd + 1 &&
10982
+ currentRow === previousRow &&
10983
+ getRow( range.start + range.count - 1, image.width, componentStride ) === currentRow // ensure range doesn't spill
10984
+ ) {
10985
+
10986
+ previousRange.count = Math.max(
10987
+ previousRange.count,
10988
+ range.start + range.count - previousRange.start
10989
+ );
10990
+
10991
+ } else {
10992
+
10993
+ ++ mergeIndex;
10994
+ updateRanges[ mergeIndex ] = range;
10995
+
10996
+ }
10997
+
10998
+
10999
+ }
11000
+
11001
+ // Trim the array to only contain the merged ranges.
11002
+ updateRanges.length = mergeIndex + 1;
11003
+
11004
+ const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
11005
+ const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
11006
+ const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
11007
+
11008
+ _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
11009
+
11010
+ for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
11011
+
11012
+ const range = updateRanges[ i ];
11013
+
11014
+ const pixelStart = Math.floor( range.start / componentStride );
11015
+ const pixelCount = Math.ceil( range.count / componentStride );
11016
+
11017
+ const x = pixelStart % image.width;
11018
+ const y = Math.floor( pixelStart / image.width );
11019
+
11020
+ // Assumes update ranges refer to contiguous memory
11021
+ const width = pixelCount;
11022
+ const height = 1;
11023
+
11024
+ _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, x );
11025
+ _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, y );
11026
+
11027
+ state.texSubImage2D( _gl.TEXTURE_2D, 0, x, y, width, height, glFormat, glType, image.data );
11028
+
11029
+ }
11030
+
11031
+ texture.clearUpdateRanges();
11032
+
11033
+ _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
11034
+ _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
11035
+ _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
11036
+
11037
+ }
11038
+
11039
+ }
11040
+
10894
11041
  function uploadTexture( textureProperties, texture, slot ) {
10895
11042
 
10896
11043
  let textureType = _gl.TEXTURE_2D;
@@ -11004,7 +11151,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
11004
11151
 
11005
11152
  if ( dataReady ) {
11006
11153
 
11007
- state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, glFormat, glType, image.data );
11154
+ updateTexture( texture, image, glFormat, glType );
11008
11155
 
11009
11156
  }
11010
11157
 
@@ -11781,7 +11928,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
11781
11928
 
11782
11929
  if ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );
11783
11930
 
11784
- setupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget );
11931
+ const mipmaps = renderTarget.texture.mipmaps;
11932
+
11933
+ if ( mipmaps && mipmaps.length > 0 ) {
11934
+
11935
+ setupDepthTexture( renderTargetProperties.__webglFramebuffer[ 0 ], renderTarget );
11936
+
11937
+ } else {
11938
+
11939
+ setupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget );
11940
+
11941
+ }
11785
11942
 
11786
11943
  } else {
11787
11944
 
@@ -11812,7 +11969,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
11812
11969
 
11813
11970
  } else {
11814
11971
 
11815
- state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
11972
+ const mipmaps = renderTarget.texture.mipmaps;
11973
+
11974
+ if ( mipmaps && mipmaps.length > 0 ) {
11975
+
11976
+ state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ 0 ] );
11977
+
11978
+ } else {
11979
+
11980
+ state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
11981
+
11982
+ }
11816
11983
 
11817
11984
  if ( renderTargetProperties.__webglDepthbuffer === undefined ) {
11818
11985
 
@@ -12025,13 +12192,21 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
12025
12192
  const attachment = textures[ i ];
12026
12193
  const attachmentProperties = properties.get( attachment );
12027
12194
 
12028
- state.bindTexture( _gl.TEXTURE_2D, attachmentProperties.__webglTexture );
12029
- setTextureParameters( _gl.TEXTURE_2D, attachment );
12030
- setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, 0 );
12195
+ let glTextureType = _gl.TEXTURE_2D;
12196
+
12197
+ if ( renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
12198
+
12199
+ glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
12200
+
12201
+ }
12202
+
12203
+ state.bindTexture( glTextureType, attachmentProperties.__webglTexture );
12204
+ setTextureParameters( glTextureType, attachment );
12205
+ setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, glTextureType, 0 );
12031
12206
 
12032
12207
  if ( textureNeedsGenerateMipmaps( attachment ) ) {
12033
12208
 
12034
- generateMipmap( _gl.TEXTURE_2D );
12209
+ generateMipmap( glTextureType );
12035
12210
 
12036
12211
  }
12037
12212
 
@@ -12142,7 +12317,18 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
12142
12317
  }
12143
12318
 
12144
12319
  state.bindFramebuffer( _gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
12145
- state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
12320
+
12321
+ const mipmaps = renderTarget.texture.mipmaps;
12322
+
12323
+ if ( mipmaps && mipmaps.length > 0 ) {
12324
+
12325
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ 0 ] );
12326
+
12327
+ } else {
12328
+
12329
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
12330
+
12331
+ }
12146
12332
 
12147
12333
  for ( let i = 0; i < textures.length; i ++ ) {
12148
12334
 
@@ -12358,8 +12544,6 @@ function WebGLUtils( gl, extensions ) {
12358
12544
  if ( p === AlphaFormat ) return gl.ALPHA;
12359
12545
  if ( p === RGBFormat ) return gl.RGB;
12360
12546
  if ( p === RGBAFormat ) return gl.RGBA;
12361
- if ( p === LuminanceFormat ) return gl.LUMINANCE;
12362
- if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;
12363
12547
  if ( p === DepthFormat ) return gl.DEPTH_COMPONENT;
12364
12548
  if ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;
12365
12549
 
@@ -12543,6 +12727,48 @@ function WebGLUtils( gl, extensions ) {
12543
12727
 
12544
12728
  }
12545
12729
 
12730
+ /**
12731
+ * Represents a texture created externally from the renderer context.
12732
+ *
12733
+ * This may be a texture from a protected media stream, device camera feed,
12734
+ * or other data feeds like a depth sensor.
12735
+ *
12736
+ * Note that this class is only supported in {@link WebGLRenderer} right now.
12737
+ *
12738
+ * @augments Texture
12739
+ */
12740
+ class ExternalTexture extends Texture {
12741
+
12742
+ /**
12743
+ * Creates a new raw texture.
12744
+ *
12745
+ * @param {?WebGLTexture} [sourceTexture=null] - The external texture.
12746
+ */
12747
+ constructor( sourceTexture = null ) {
12748
+
12749
+ super();
12750
+
12751
+ /**
12752
+ * The external source texture.
12753
+ *
12754
+ * @type {?WebGLTexture}
12755
+ * @default null
12756
+ */
12757
+ this.sourceTexture = sourceTexture;
12758
+
12759
+ /**
12760
+ * This flag can be used for type testing.
12761
+ *
12762
+ * @type {boolean}
12763
+ * @readonly
12764
+ * @default true
12765
+ */
12766
+ this.isExternalTexture = true;
12767
+
12768
+ }
12769
+
12770
+ }
12771
+
12546
12772
  const _occlusion_vertex = `
12547
12773
  void main() {
12548
12774
 
@@ -12582,9 +12808,9 @@ class WebXRDepthSensing {
12582
12808
  constructor() {
12583
12809
 
12584
12810
  /**
12585
- * A texture representing the depth of the user's environment.
12811
+ * An opaque texture representing the depth of the user's environment.
12586
12812
  *
12587
- * @type {?Texture}
12813
+ * @type {?ExternalTexture}
12588
12814
  */
12589
12815
  this.texture = null;
12590
12816
 
@@ -12614,18 +12840,14 @@ class WebXRDepthSensing {
12614
12840
  /**
12615
12841
  * Inits the depth sensing module
12616
12842
  *
12617
- * @param {WebGLRenderer} renderer - The renderer.
12618
12843
  * @param {XRWebGLDepthInformation} depthData - The XR depth data.
12619
12844
  * @param {XRRenderState} renderState - The XR render state.
12620
12845
  */
12621
- init( renderer, depthData, renderState ) {
12846
+ init( depthData, renderState ) {
12622
12847
 
12623
12848
  if ( this.texture === null ) {
12624
12849
 
12625
- const texture = new Texture();
12626
-
12627
- const texProps = renderer.properties.get( texture );
12628
- texProps.__webglTexture = depthData.texture;
12850
+ const texture = new ExternalTexture( depthData.texture );
12629
12851
 
12630
12852
  if ( ( depthData.depthNear !== renderState.depthNear ) || ( depthData.depthFar !== renderState.depthFar ) ) {
12631
12853
 
@@ -12686,7 +12908,7 @@ class WebXRDepthSensing {
12686
12908
  /**
12687
12909
  * Returns a texture representing the depth of the user's environment.
12688
12910
  *
12689
- * @return {?Texture} The depth texture.
12911
+ * @return {?ExternalTexture} The depth texture.
12690
12912
  */
12691
12913
  getDepthTexture() {
12692
12914
 
@@ -12736,6 +12958,7 @@ class WebXRManager extends EventDispatcher {
12736
12958
  let xrFrame = null;
12737
12959
 
12738
12960
  const depthSensing = new WebXRDepthSensing();
12961
+ const cameraAccessTextures = {};
12739
12962
  const attributes = gl.getContextAttributes();
12740
12963
 
12741
12964
  let initialRenderTarget = null;
@@ -12916,6 +13139,11 @@ class WebXRManager extends EventDispatcher {
12916
13139
  _currentDepthFar = null;
12917
13140
 
12918
13141
  depthSensing.reset();
13142
+ for ( const key in cameraAccessTextures ) {
13143
+
13144
+ delete cameraAccessTextures[ key ];
13145
+
13146
+ }
12919
13147
 
12920
13148
  // restore framebuffer/rendering state
12921
13149
 
@@ -12962,7 +13190,8 @@ class WebXRManager extends EventDispatcher {
12962
13190
  /**
12963
13191
  * Sets the reference space type. Can be used to configure a spatial relationship with the user's physical
12964
13192
  * environment. Depending on how the user moves in 3D space, setting an appropriate reference space can
12965
- * improve tracking. Default is `local-floor`.
13193
+ * improve tracking. Default is `local-floor`. Valid values can be found here
13194
+ * https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpace#reference_space_types.
12966
13195
  *
12967
13196
  * This method can not be used during a XR session.
12968
13197
  *
@@ -13081,9 +13310,15 @@ class WebXRManager extends EventDispatcher {
13081
13310
  currentPixelRatio = renderer.getPixelRatio();
13082
13311
  renderer.getSize( currentSize );
13083
13312
 
13313
+ if ( typeof XRWebGLBinding !== 'undefined' ) {
13314
+
13315
+ glBinding = new XRWebGLBinding( session, gl );
13316
+
13317
+ }
13318
+
13084
13319
  // Check that the browser implements the necessary APIs to use an
13085
13320
  // XRProjectionLayer rather than an XRWebGLLayer
13086
- const useLayers = typeof XRWebGLBinding !== 'undefined' && 'createProjectionLayer' in XRWebGLBinding.prototype;
13321
+ const useLayers = glBinding !== null && 'createProjectionLayer' in XRWebGLBinding.prototype;
13087
13322
 
13088
13323
  if ( ! useLayers ) {
13089
13324
 
@@ -13136,8 +13371,6 @@ class WebXRManager extends EventDispatcher {
13136
13371
  scaleFactor: framebufferScaleFactor
13137
13372
  };
13138
13373
 
13139
- glBinding = new XRWebGLBinding( session, gl );
13140
-
13141
13374
  glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );
13142
13375
 
13143
13376
  session.updateRenderState( { layers: [ glProjLayer ] } );
@@ -13405,9 +13638,10 @@ class WebXRManager extends EventDispatcher {
13405
13638
 
13406
13639
  }
13407
13640
 
13408
- cameraL.layers.mask = camera.layers.mask | 0b010;
13409
- cameraR.layers.mask = camera.layers.mask | 0b100;
13410
- cameraXR.layers.mask = cameraL.layers.mask | cameraR.layers.mask;
13641
+ // inherit camera layers and enable eye layers (1 = left, 2 = right)
13642
+ cameraXR.layers.mask = camera.layers.mask | 0b110;
13643
+ cameraL.layers.mask = cameraXR.layers.mask & 0b011;
13644
+ cameraR.layers.mask = cameraXR.layers.mask & 0b101;
13411
13645
 
13412
13646
  const parent = camera.parent;
13413
13647
  const cameras = cameraXR.cameras;
@@ -13488,7 +13722,7 @@ class WebXRManager extends EventDispatcher {
13488
13722
  /**
13489
13723
  * Returns the amount of foveation used by the XR compositor for the projection layer.
13490
13724
  *
13491
- * @return {number} The amount of foveation.
13725
+ * @return {number|undefined} The amount of foveation.
13492
13726
  */
13493
13727
  this.getFoveation = function () {
13494
13728
 
@@ -13551,6 +13785,19 @@ class WebXRManager extends EventDispatcher {
13551
13785
 
13552
13786
  };
13553
13787
 
13788
+ /**
13789
+ * Retrieves an opaque texture from the view-aligned {@link XRCamera}.
13790
+ * Only available during the current animation loop.
13791
+ *
13792
+ * @param {XRCamera} xrCamera - The camera to query.
13793
+ * @return {?Texture} An opaque texture representing the current raw camera frame.
13794
+ */
13795
+ this.getCameraTexture = function ( xrCamera ) {
13796
+
13797
+ return cameraAccessTextures[ xrCamera ];
13798
+
13799
+ };
13800
+
13554
13801
  // Animation Loop
13555
13802
 
13556
13803
  let onAnimationFrameCallback = null;
@@ -13656,7 +13903,42 @@ class WebXRManager extends EventDispatcher {
13656
13903
 
13657
13904
  if ( depthData && depthData.isValid && depthData.texture ) {
13658
13905
 
13659
- depthSensing.init( renderer, depthData, session.renderState );
13906
+ depthSensing.init( depthData, session.renderState );
13907
+
13908
+ }
13909
+
13910
+ }
13911
+
13912
+ const cameraAccessEnabled = enabledFeatures &&
13913
+ enabledFeatures.includes( 'camera-access' );
13914
+
13915
+ if ( cameraAccessEnabled ) {
13916
+
13917
+ renderer.state.unbindTexture();
13918
+
13919
+ if ( glBinding ) {
13920
+
13921
+ for ( let i = 0; i < views.length; i ++ ) {
13922
+
13923
+ const camera = views[ i ].camera;
13924
+
13925
+ if ( camera ) {
13926
+
13927
+ let cameraTex = cameraAccessTextures[ camera ];
13928
+
13929
+ if ( ! cameraTex ) {
13930
+
13931
+ cameraTex = new ExternalTexture();
13932
+ cameraAccessTextures[ camera ] = cameraTex;
13933
+
13934
+ }
13935
+
13936
+ const glTexture = glBinding.getCameraImage( camera );
13937
+ cameraTex.sourceTexture = glTexture;
13938
+
13939
+ }
13940
+
13941
+ }
13660
13942
 
13661
13943
  }
13662
13944
 
@@ -13845,17 +14127,17 @@ function WebGLMaterials( renderer, properties ) {
13845
14127
 
13846
14128
  }
13847
14129
 
13848
- if ( material.texture3DMatrix ) {
14130
+ if ( material.texture3DMatrix ) {
13849
14131
 
13850
- uniforms.texture3DMatrix.value.copy( material.texture3DMatrix );
14132
+ uniforms.texture3DMatrix.value.copy( material.texture3DMatrix );
13851
14133
 
13852
- }
14134
+ }
13853
14135
 
13854
- if ( material.triplanarHardness ) {
14136
+ if ( material.triplanarHardness ) {
13855
14137
 
13856
- uniforms.triplanarHardness.value = material.triplanarHardness;
14138
+ uniforms.triplanarHardness.value = material.triplanarHardness;
13857
14139
 
13858
- }
14140
+ }
13859
14141
 
13860
14142
  if ( material.alphaMap ) {
13861
14143
 
@@ -14719,7 +15001,7 @@ class WebGLRenderer {
14719
15001
  preserveDrawingBuffer = false,
14720
15002
  powerPreference = 'default',
14721
15003
  failIfMajorPerformanceCaveat = false,
14722
- reverseDepthBuffer = false,
15004
+ reversedDepthBuffer = false,
14723
15005
  } = parameters;
14724
15006
 
14725
15007
  /**
@@ -14952,7 +15234,6 @@ class WebGLRenderer {
14952
15234
 
14953
15235
  // camera matrices cache
14954
15236
 
14955
- const _currentProjectionMatrix = new Matrix4();
14956
15237
  const _projScreenMatrix = new Matrix4();
14957
15238
 
14958
15239
  const _vector3 = new Vector3();
@@ -15048,7 +15329,7 @@ class WebGLRenderer {
15048
15329
 
15049
15330
  state = new WebGLState( _gl, extensions );
15050
15331
 
15051
- if ( capabilities.reverseDepthBuffer && reverseDepthBuffer ) {
15332
+ if ( capabilities.reversedDepthBuffer && reversedDepthBuffer ) {
15052
15333
 
15053
15334
  state.buffers.depth.setReversed( true );
15054
15335
 
@@ -15936,7 +16217,7 @@ class WebGLRenderer {
15936
16217
  * @param {Object3D} scene - The scene or another type of 3D object to precompile.
15937
16218
  * @param {Camera} camera - The camera.
15938
16219
  * @param {?Scene} [targetScene=null] - The target scene.
15939
- * @return {?Set} The precompiled materials.
16220
+ * @return {Set<Material>} The precompiled materials.
15940
16221
  */
15941
16222
  this.compile = function ( scene, camera, targetScene = null ) {
15942
16223
 
@@ -16196,7 +16477,7 @@ class WebGLRenderer {
16196
16477
  renderStateStack.push( currentRenderState );
16197
16478
 
16198
16479
  _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
16199
- _frustum.setFromProjectionMatrix( _projScreenMatrix );
16480
+ _frustum.setFromProjectionMatrix( _projScreenMatrix, WebGLCoordinateSystem, camera.reversedDepth );
16200
16481
 
16201
16482
  _localClippingEnabled = this.localClippingEnabled;
16202
16483
  _clippingEnabled = clipping.init( this.clippingPlanes, _localClippingEnabled );
@@ -16529,6 +16810,9 @@ class WebGLRenderer {
16529
16810
  //
16530
16811
 
16531
16812
  const currentRenderTarget = _this.getRenderTarget();
16813
+ const currentActiveCubeFace = _this.getActiveCubeFace();
16814
+ const currentActiveMipmapLevel = _this.getActiveMipmapLevel();
16815
+
16532
16816
  _this.setRenderTarget( transmissionRenderTarget );
16533
16817
 
16534
16818
  _this.getClearColor( _currentClearColor );
@@ -16598,7 +16882,7 @@ class WebGLRenderer {
16598
16882
 
16599
16883
  }
16600
16884
 
16601
- _this.setRenderTarget( currentRenderTarget );
16885
+ _this.setRenderTarget( currentRenderTarget, currentActiveCubeFace, currentActiveMipmapLevel );
16602
16886
 
16603
16887
  _this.setClearColor( _currentClearColor, _currentClearAlpha );
16604
16888
 
@@ -17024,23 +17308,17 @@ class WebGLRenderer {
17024
17308
 
17025
17309
  // common camera uniforms
17026
17310
 
17027
- const reverseDepthBuffer = state.buffers.depth.getReversed();
17028
-
17029
- if ( reverseDepthBuffer ) {
17030
-
17031
- _currentProjectionMatrix.copy( camera.projectionMatrix );
17032
-
17033
- toNormalizedProjectionMatrix( _currentProjectionMatrix );
17034
- toReversedProjectionMatrix( _currentProjectionMatrix );
17311
+ const reversedDepthBuffer = state.buffers.depth.getReversed();
17035
17312
 
17036
- p_uniforms.setValue( _gl, 'projectionMatrix', _currentProjectionMatrix );
17313
+ if ( reversedDepthBuffer && camera.reversedDepth !== true ) {
17037
17314
 
17038
- } else {
17039
-
17040
- p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
17315
+ camera._reversedDepth = true;
17316
+ camera.updateProjectionMatrix();
17041
17317
 
17042
17318
  }
17043
17319
 
17320
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
17321
+
17044
17322
  p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
17045
17323
 
17046
17324
  const uCamPos = p_uniforms.map.cameraPosition;
@@ -17470,9 +17748,15 @@ class WebGLRenderer {
17470
17748
 
17471
17749
  } else if ( isRenderTarget3D ) {
17472
17750
 
17473
- const textureProperties = properties.get( renderTarget.texture );
17474
17751
  const layer = activeCubeFace;
17475
- _gl.framebufferTextureLayer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, activeMipmapLevel, layer );
17752
+
17753
+ for ( let i = 0; i < renderTarget.textures.length; i ++ ) {
17754
+
17755
+ const textureProperties = properties.get( renderTarget.textures[ i ] );
17756
+
17757
+ _gl.framebufferTextureLayer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, textureProperties.__webglTexture, activeMipmapLevel, layer );
17758
+
17759
+ }
17476
17760
 
17477
17761
  } else if ( renderTarget !== null && activeMipmapLevel !== 0 ) {
17478
17762
 
@@ -17497,8 +17781,9 @@ class WebGLRenderer {
17497
17781
  * @param {number} height - The height of the copy region.
17498
17782
  * @param {TypedArray} buffer - The result buffer.
17499
17783
  * @param {number} [activeCubeFaceIndex] - The active cube face index.
17784
+ * @param {number} [textureIndex=0] - The texture index of an MRT render target.
17500
17785
  */
17501
- this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
17786
+ this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex, textureIndex = 0 ) {
17502
17787
 
17503
17788
  if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
17504
17789
 
@@ -17521,7 +17806,7 @@ class WebGLRenderer {
17521
17806
 
17522
17807
  try {
17523
17808
 
17524
- const texture = renderTarget.texture;
17809
+ const texture = renderTarget.textures[ textureIndex ];
17525
17810
  const textureFormat = texture.format;
17526
17811
  const textureType = texture.type;
17527
17812
 
@@ -17543,6 +17828,10 @@ class WebGLRenderer {
17543
17828
 
17544
17829
  if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
17545
17830
 
17831
+ // when using MRT, select the correct color buffer for the subsequent read command
17832
+
17833
+ if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
17834
+
17546
17835
  _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );
17547
17836
 
17548
17837
  }
@@ -17573,9 +17862,10 @@ class WebGLRenderer {
17573
17862
  * @param {number} height - The height of the copy region.
17574
17863
  * @param {TypedArray} buffer - The result buffer.
17575
17864
  * @param {number} [activeCubeFaceIndex] - The active cube face index.
17865
+ * @param {number} [textureIndex=0] - The texture index of an MRT render target.
17576
17866
  * @return {Promise<TypedArray>} A Promise that resolves when the read has been finished. The resolve provides the read data as a typed array.
17577
17867
  */
17578
- this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
17868
+ this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex, textureIndex = 0 ) {
17579
17869
 
17580
17870
  if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
17581
17871
 
@@ -17598,7 +17888,7 @@ class WebGLRenderer {
17598
17888
  // set the active frame buffer to the one we want to read
17599
17889
  state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
17600
17890
 
17601
- const texture = renderTarget.texture;
17891
+ const texture = renderTarget.textures[ textureIndex ];
17602
17892
  const textureFormat = texture.format;
17603
17893
  const textureType = texture.type;
17604
17894
 
@@ -17617,6 +17907,11 @@ class WebGLRenderer {
17617
17907
  const glBuffer = _gl.createBuffer();
17618
17908
  _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
17619
17909
  _gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
17910
+
17911
+ // when using MRT, select the correct color buffer for the subsequent read command
17912
+
17913
+ if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
17914
+
17620
17915
  _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
17621
17916
 
17622
17917
  // reset the frame buffer to the currently set buffer before waiting
@@ -17652,7 +17947,7 @@ class WebGLRenderer {
17652
17947
  * Copies pixels from the current bound framebuffer into the given texture.
17653
17948
  *
17654
17949
  * @param {FramebufferTexture} texture - The texture.
17655
- * @param {Vector2} position - The start position of the copy operation.
17950
+ * @param {?Vector2} [position=null] - The start position of the copy operation.
17656
17951
  * @param {number} [level=0] - The mip level. The default represents the base mip.
17657
17952
  */
17658
17953
  this.copyFramebufferToTexture = function ( texture, position = null, level = 0 ) {
@@ -17683,10 +17978,10 @@ class WebGLRenderer {
17683
17978
  *
17684
17979
  * @param {Texture} srcTexture - The source texture.
17685
17980
  * @param {Texture} dstTexture - The destination texture.
17686
- * @param {Box2|Box3} [srcRegion=null] - A bounding box which describes the source region. Can be two or three-dimensional.
17687
- * @param {Vector2|Vector3} [dstPosition=null] - A vector that represents the origin of the destination region. Can be two or three-dimensional.
17688
- * @param {number} srcLevel - The source mipmap level to copy.
17689
- * @param {number} dstLevel - The destination mipmap level.
17981
+ * @param {?(Box2|Box3)} [srcRegion=null] - A bounding box which describes the source region. Can be two or three-dimensional.
17982
+ * @param {?(Vector2|Vector3)} [dstPosition=null] - A vector that represents the origin of the destination region. Can be two or three-dimensional.
17983
+ * @param {number} [srcLevel=0] - The source mipmap level to copy.
17984
+ * @param {?number} [dstLevel=null] - The destination mipmap level.
17690
17985
  */
17691
17986
  this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel = null ) {
17692
17987
 
@@ -18059,4 +18354,4 @@ class WebGLRenderer {
18059
18354
 
18060
18355
  }
18061
18356
 
18062
- export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveBlending, AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, ArrayCamera, BackSide, BoxGeometry, BufferAttribute, BufferGeometry, ByteType, CineonToneMapping, ClampToEdgeWrapping, Color, ColorManagement, ConstantAlphaFactor, ConstantColorFactor, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeUVReflectionMapping, CullFaceBack, CullFaceFront, CullFaceNone, CustomBlending, CustomToneMapping, CylindricalMapping, Data3DTexture, DataArrayTexture, DepthFormat, DepthStencilFormat, DepthTexture, DoubleSide, DstAlphaFactor, DstColorFactor, EqualCompare, EqualDepth, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, FloatType, FrontSide, Frustum, GLSL3, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, HalfFloatType, IntType, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, LuminanceAlphaFormat, LuminanceFormat, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping, NeverCompare, NeverDepth, NoBlending, NoColorSpace, NoToneMapping, NormalBlending, NotEqualCompare, NotEqualDepth, ObjectSpaceNormalMap, OneFactor, OneMinusConstantAlphaFactor, OneMinusConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, PerspectiveCamera, Plane, PlaneGeometry, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBFormat, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RedFormat, RedIntegerFormat, ReinhardToneMapping, RepeatWrapping, ReverseSubtractEquation, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, ShaderChunk, ShaderLib, ShaderMaterial, ShortType, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, SubtractEquation, SubtractiveBlending, TangentSpaceNormalMap, Texture, TriPlanarMapping, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer, WebGLUtils, WebXRController, ZeroFactor, createCanvasElement };
18357
+ export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveBlending, AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, ArrayCamera, BackSide, BoxGeometry, BufferAttribute, BufferGeometry, ByteType, CineonToneMapping, ClampToEdgeWrapping, Color, ColorManagement, ConstantAlphaFactor, ConstantColorFactor, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeUVReflectionMapping, CullFaceBack, CullFaceFront, CullFaceNone, CustomBlending, CustomToneMapping, CylindricalMapping, Data3DTexture, DataArrayTexture, DepthFormat, DepthStencilFormat, DepthTexture, DoubleSide, DstAlphaFactor, DstColorFactor, EqualCompare, EqualDepth, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, FloatType, FrontSide, Frustum, GLSL3, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, HalfFloatType, IntType, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping, NeverCompare, NeverDepth, NoBlending, NoColorSpace, NoToneMapping, NormalBlending, NotEqualCompare, NotEqualDepth, ObjectSpaceNormalMap, OneFactor, OneMinusConstantAlphaFactor, OneMinusConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, PerspectiveCamera, Plane, PlaneGeometry, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBFormat, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RedFormat, RedIntegerFormat, ReinhardToneMapping, RepeatWrapping, ReverseSubtractEquation, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, ShaderChunk, ShaderLib, ShaderMaterial, ShortType, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, SubtractEquation, SubtractiveBlending, TangentSpaceNormalMap, Texture, TriPlanarMapping, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer, WebGLUtils, WebXRController, ZeroFactor, createCanvasElement };