super-three 0.144.0 → 0.147.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +737 -388
  3. package/build/three.js +737 -388
  4. package/build/three.min.js +1 -1
  5. package/build/three.module.js +911 -409
  6. package/examples/js/animation/AnimationClipCreator.js +0 -8
  7. package/examples/js/animation/CCDIKSolver.js +50 -67
  8. package/examples/js/animation/MMDAnimationHelper.js +66 -137
  9. package/examples/js/animation/MMDPhysics.js +70 -134
  10. package/examples/js/cameras/CinematicCamera.js +33 -22
  11. package/examples/js/controls/ArcballControls.js +138 -405
  12. package/examples/js/controls/DragControls.js +8 -33
  13. package/examples/js/controls/FirstPersonControls.js +32 -54
  14. package/examples/js/controls/FlyControls.js +29 -55
  15. package/examples/js/controls/OrbitControls.js +125 -99
  16. package/examples/js/controls/PointerLockControls.js +5 -14
  17. package/examples/js/controls/TrackballControls.js +33 -86
  18. package/examples/js/controls/TransformControls.js +85 -170
  19. package/examples/js/csm/CSM.js +4 -39
  20. package/examples/js/csm/CSMFrustum.js +3 -9
  21. package/examples/js/csm/CSMHelper.js +24 -4
  22. package/examples/js/csm/CSMShader.js +2 -6
  23. package/examples/js/curves/CurveExtras.js +27 -27
  24. package/examples/js/curves/NURBSCurve.js +4 -16
  25. package/examples/js/curves/NURBSSurface.js +3 -9
  26. package/examples/js/curves/NURBSUtils.js +8 -45
  27. package/examples/js/effects/AnaglyphEffect.js +4 -18
  28. package/examples/js/effects/AsciiEffect.js +32 -31
  29. package/examples/js/effects/OutlineEffect.js +26 -30
  30. package/examples/js/effects/ParallaxBarrierEffect.js +0 -13
  31. package/examples/js/effects/PeppersGhostEffect.js +12 -39
  32. package/examples/js/effects/StereoEffect.js +0 -4
  33. package/examples/js/environments/RoomEnvironment.js +12 -10
  34. package/examples/js/exporters/ColladaExporter.js +48 -65
  35. package/examples/js/exporters/DRACOExporter.js +22 -22
  36. package/examples/js/exporters/EXRExporter.js +15 -18
  37. package/examples/js/exporters/GLTFExporter.js +141 -317
  38. package/examples/js/exporters/MMDExporter.js +5 -12
  39. package/examples/js/exporters/OBJExporter.js +42 -33
  40. package/examples/js/exporters/PLYExporter.js +38 -33
  41. package/examples/js/exporters/STLExporter.js +5 -7
  42. package/examples/js/exporters/USDZExporter.js +113 -27
  43. package/examples/js/geometries/BoxLineGeometry.js +0 -1
  44. package/examples/js/geometries/ConvexGeometry.js +11 -6
  45. package/examples/js/geometries/DecalGeometry.js +53 -20
  46. package/examples/js/geometries/LightningStrike.js +54 -67
  47. package/examples/js/geometries/ParametricGeometries.js +8 -7
  48. package/examples/js/geometries/ParametricGeometry.js +25 -12
  49. package/examples/js/geometries/RoundedBoxGeometry.js +21 -19
  50. package/examples/js/geometries/TeapotGeometry.js +54 -50
  51. package/examples/js/geometries/TextGeometry.js +6 -4
  52. package/examples/js/helpers/LightProbeHelper.js +1 -2
  53. package/examples/js/helpers/OctreeHelper.js +22 -20
  54. package/examples/js/helpers/PositionalAudioHelper.js +8 -6
  55. package/examples/js/helpers/RectAreaLightHelper.js +6 -7
  56. package/examples/js/helpers/VertexNormalsHelper.js +15 -13
  57. package/examples/js/helpers/VertexTangentsHelper.js +15 -9
  58. package/examples/js/helpers/ViewHelper.js +31 -16
  59. package/examples/js/interactive/HTMLMesh.js +25 -39
  60. package/examples/js/interactive/InteractiveGroup.js +9 -14
  61. package/examples/js/interactive/SelectionBox.js +3 -70
  62. package/examples/js/interactive/SelectionHelper.js +0 -8
  63. package/examples/js/lights/LightProbeGenerator.js +32 -39
  64. package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
  65. package/examples/js/lines/LineGeometry.js +3 -5
  66. package/examples/js/lines/LineMaterial.js +4 -11
  67. package/examples/js/lines/LineSegments2.js +40 -89
  68. package/examples/js/lines/LineSegmentsGeometry.js +7 -28
  69. package/examples/js/lines/Wireframe.js +2 -7
  70. package/examples/js/lines/WireframeGeometry2.js +3 -1
  71. package/examples/js/loaders/3DMLoader.js +58 -155
  72. package/examples/js/loaders/3MFLoader.js +72 -106
  73. package/examples/js/loaders/AMFLoader.js +0 -25
  74. package/examples/js/loaders/BVHLoader.js +44 -43
  75. package/examples/js/loaders/BasisTextureLoader.js +16 -46
  76. package/examples/js/loaders/ColladaLoader.js +228 -359
  77. package/examples/js/loaders/DDSLoader.js +24 -25
  78. package/examples/js/loaders/DRACOLoader.js +29 -66
  79. package/examples/js/loaders/EXRLoader.js +67 -164
  80. package/examples/js/loaders/FBXLoader.js +287 -441
  81. package/examples/js/loaders/FontLoader.js +6 -15
  82. package/examples/js/loaders/GCodeLoader.js +15 -16
  83. package/examples/js/loaders/GLTFLoader.js +409 -706
  84. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -6
  85. package/examples/js/loaders/KMZLoader.js +3 -7
  86. package/examples/js/loaders/KTXLoader.js +12 -30
  87. package/examples/js/loaders/LDrawLoader.js +178 -289
  88. package/examples/js/loaders/LUT3dlLoader.js +7 -11
  89. package/examples/js/loaders/LUTCubeLoader.js +0 -8
  90. package/examples/js/loaders/LWOLoader.js +59 -124
  91. package/examples/js/loaders/LogLuvLoader.js +27 -77
  92. package/examples/js/loaders/LottieLoader.js +4 -4
  93. package/examples/js/loaders/MD2Loader.js +26 -27
  94. package/examples/js/loaders/MDDLoader.js +6 -10
  95. package/examples/js/loaders/MMDLoader.js +180 -189
  96. package/examples/js/loaders/MTLLoader.js +18 -47
  97. package/examples/js/loaders/NRRDLoader.js +44 -84
  98. package/examples/js/loaders/OBJLoader.js +50 -65
  99. package/examples/js/loaders/PCDLoader.js +34 -29
  100. package/examples/js/loaders/PDBLoader.js +17 -13
  101. package/examples/js/loaders/PLYLoader.js +62 -48
  102. package/examples/js/loaders/PRWMLoader.js +11 -22
  103. package/examples/js/loaders/PVRLoader.js +7 -16
  104. package/examples/js/loaders/RGBELoader.js +36 -61
  105. package/examples/js/loaders/RGBMLoader.js +26 -87
  106. package/examples/js/loaders/STLLoader.js +20 -27
  107. package/examples/js/loaders/SVGLoader.js +361 -233
  108. package/examples/js/loaders/TDSLoader.js +81 -118
  109. package/examples/js/loaders/TGALoader.js +39 -41
  110. package/examples/js/loaders/TIFFLoader.js +0 -1
  111. package/examples/js/loaders/TTFLoader.js +0 -8
  112. package/examples/js/loaders/TiltLoader.js +14 -15
  113. package/examples/js/loaders/VOXLoader.js +8 -16
  114. package/examples/js/loaders/VRMLLoader.js +243 -340
  115. package/examples/js/loaders/VTKLoader.js +101 -118
  116. package/examples/js/loaders/XYZLoader.js +2 -4
  117. package/examples/js/loaders/lwo/IFFParser.js +55 -136
  118. package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
  119. package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
  120. package/examples/js/materials/MeshGouraudMaterial.js +15 -13
  121. package/examples/js/math/Capsule.js +0 -17
  122. package/examples/js/math/ColorConverter.js +3 -3
  123. package/examples/js/math/ConvexHull.js +185 -141
  124. package/examples/js/math/ImprovedNoise.js +1 -1
  125. package/examples/js/math/Lut.js +8 -15
  126. package/examples/js/math/MeshSurfaceSampler.js +6 -28
  127. package/examples/js/math/OBB.js +90 -49
  128. package/examples/js/math/Octree.js +2 -57
  129. package/examples/js/math/SimplexNoise.js +74 -88
  130. package/examples/js/misc/ConvexObjectBreaker.js +37 -48
  131. package/examples/js/misc/GPUComputationRenderer.js +26 -16
  132. package/examples/js/misc/Gyroscope.js +5 -9
  133. package/examples/js/misc/MD2Character.js +14 -23
  134. package/examples/js/misc/MD2CharacterComplex.js +73 -54
  135. package/examples/js/misc/MorphAnimMesh.js +0 -6
  136. package/examples/js/misc/MorphBlendMesh.js +3 -30
  137. package/examples/js/misc/ProgressiveLightMap.js +47 -43
  138. package/examples/js/misc/RollerCoaster.js +17 -24
  139. package/examples/js/misc/TubePainter.js +18 -12
  140. package/examples/js/misc/Volume.js +16 -45
  141. package/examples/js/misc/VolumeSlice.js +14 -24
  142. package/examples/js/modifiers/CurveModifier.js +19 -21
  143. package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
  144. package/examples/js/modifiers/SimplifyModifier.js +56 -59
  145. package/examples/js/modifiers/TessellateModifier.js +2 -9
  146. package/examples/js/objects/GroundProjectedEnv.js +2 -14
  147. package/examples/js/objects/Lensflare.js +47 -38
  148. package/examples/js/objects/LightningStorm.js +10 -13
  149. package/examples/js/objects/MarchingCubes.js +80 -59
  150. package/examples/js/objects/Reflector.js +22 -20
  151. package/examples/js/objects/ReflectorForSSRPass.js +19 -23
  152. package/examples/js/objects/Refractor.js +52 -30
  153. package/examples/js/objects/ShadowMesh.js +1 -2
  154. package/examples/js/objects/Sky.js +2 -7
  155. package/examples/js/objects/Water.js +23 -18
  156. package/examples/js/objects/Water2.js +20 -19
  157. package/examples/js/physics/AmmoPhysics.js +23 -20
  158. package/examples/js/physics/OimoPhysics.js +19 -17
  159. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
  160. package/examples/js/postprocessing/AfterimagePass.js +19 -12
  161. package/examples/js/postprocessing/BloomPass.js +38 -17
  162. package/examples/js/postprocessing/BokehPass.js +29 -12
  163. package/examples/js/postprocessing/ClearPass.js +1 -6
  164. package/examples/js/postprocessing/CubeTexturePass.js +12 -9
  165. package/examples/js/postprocessing/DotScreenPass.js +7 -5
  166. package/examples/js/postprocessing/EffectComposer.js +25 -32
  167. package/examples/js/postprocessing/FilmPass.js +7 -5
  168. package/examples/js/postprocessing/GlitchPass.js +10 -11
  169. package/examples/js/postprocessing/HalftonePass.js +9 -9
  170. package/examples/js/postprocessing/LUTPass.js +2 -15
  171. package/examples/js/postprocessing/MaskPass.js +20 -17
  172. package/examples/js/postprocessing/OutlinePass.js +45 -36
  173. package/examples/js/postprocessing/Pass.js +11 -14
  174. package/examples/js/postprocessing/RenderPass.js +3 -7
  175. package/examples/js/postprocessing/RenderPixelatedPass.js +215 -0
  176. package/examples/js/postprocessing/SAOPass.js +40 -32
  177. package/examples/js/postprocessing/SMAAPass.js +34 -17
  178. package/examples/js/postprocessing/SSAARenderPass.js +14 -14
  179. package/examples/js/postprocessing/SSAOPass.js +56 -42
  180. package/examples/js/postprocessing/SSRPass.js +78 -61
  181. package/examples/js/postprocessing/SavePass.js +14 -6
  182. package/examples/js/postprocessing/ShaderPass.js +9 -8
  183. package/examples/js/postprocessing/TAARenderPass.js +11 -9
  184. package/examples/js/postprocessing/TexturePass.js +7 -4
  185. package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
  186. package/examples/js/renderers/CSS2DRenderer.js +2 -21
  187. package/examples/js/renderers/CSS3DRenderer.js +3 -24
  188. package/examples/js/renderers/Projector.js +29 -85
  189. package/examples/js/renderers/SVGRenderer.js +4 -50
  190. package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
  191. package/examples/js/shaders/AfterimageShader.js +3 -6
  192. package/examples/js/shaders/BasicShader.js +3 -6
  193. package/examples/js/shaders/BleachBypassShader.js +3 -6
  194. package/examples/js/shaders/BlendShader.js +3 -6
  195. package/examples/js/shaders/BokehShader.js +3 -6
  196. package/examples/js/shaders/BokehShader2.js +4 -13
  197. package/examples/js/shaders/BrightnessContrastShader.js +3 -6
  198. package/examples/js/shaders/ColorCorrectionShader.js +2 -6
  199. package/examples/js/shaders/ColorifyShader.js +2 -6
  200. package/examples/js/shaders/ConvolutionShader.js +5 -10
  201. package/examples/js/shaders/CopyShader.js +3 -6
  202. package/examples/js/shaders/DOFMipMapShader.js +3 -6
  203. package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
  204. package/examples/js/shaders/DigitalGlitch.js +3 -6
  205. package/examples/js/shaders/DotScreenShader.js +2 -6
  206. package/examples/js/shaders/FXAAShader.js +1 -3
  207. package/examples/js/shaders/FilmShader.js +3 -6
  208. package/examples/js/shaders/FocusShader.js +3 -6
  209. package/examples/js/shaders/FreiChenShader.js +2 -6
  210. package/examples/js/shaders/GammaCorrectionShader.js +3 -6
  211. package/examples/js/shaders/GodRaysShader.js +11 -24
  212. package/examples/js/shaders/HalftoneShader.js +3 -6
  213. package/examples/js/shaders/HorizontalBlurShader.js +3 -6
  214. package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
  215. package/examples/js/shaders/HueSaturationShader.js +3 -6
  216. package/examples/js/shaders/KaleidoShader.js +3 -6
  217. package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
  218. package/examples/js/shaders/LuminosityShader.js +3 -6
  219. package/examples/js/shaders/MMDToonShader.js +2 -8
  220. package/examples/js/shaders/MirrorShader.js +3 -6
  221. package/examples/js/shaders/NormalMapShader.js +2 -6
  222. package/examples/js/shaders/RGBShiftShader.js +3 -6
  223. package/examples/js/shaders/SAOShader.js +2 -6
  224. package/examples/js/shaders/SMAAShader.js +6 -18
  225. package/examples/js/shaders/SSAOShader.js +2 -6
  226. package/examples/js/shaders/SSRShader.js +6 -18
  227. package/examples/js/shaders/SepiaShader.js +3 -6
  228. package/examples/js/shaders/SobelOperatorShader.js +2 -6
  229. package/examples/js/shaders/TechnicolorShader.js +3 -6
  230. package/examples/js/shaders/ToneMapShader.js +3 -6
  231. package/examples/js/shaders/ToonShader.js +8 -24
  232. package/examples/js/shaders/TriangleBlurShader.js +2 -6
  233. package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
  234. package/examples/js/shaders/VelocityShader.js +126 -0
  235. package/examples/js/shaders/VerticalBlurShader.js +3 -6
  236. package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
  237. package/examples/js/shaders/VignetteShader.js +3 -6
  238. package/examples/js/shaders/VolumeShader.js +2 -6
  239. package/examples/js/shaders/WaterRefractionShader.js +2 -6
  240. package/examples/js/textures/FlakesTexture.js +0 -1
  241. package/examples/js/utils/BufferGeometryUtils.js +236 -170
  242. package/examples/js/utils/CameraUtils.js +5 -20
  243. package/examples/js/utils/GPUStatsPanel.js +3 -12
  244. package/examples/js/utils/GeometryCompressionUtils.js +19 -44
  245. package/examples/js/utils/GeometryUtils.js +13 -18
  246. package/examples/js/utils/LDrawUtils.js +8 -11
  247. package/examples/js/utils/PackedPhongMaterial.js +6 -4
  248. package/examples/js/utils/SceneUtils.js +117 -6
  249. package/examples/js/utils/ShadowMapViewer.js +17 -14
  250. package/examples/js/utils/SkeletonUtils.js +13 -27
  251. package/examples/js/utils/UVsDebug.js +20 -12
  252. package/examples/js/utils/WorkerPool.js +1 -11
  253. package/examples/jsm/animation/CCDIKSolver.js +27 -3
  254. package/examples/jsm/animation/MMDPhysics.js +25 -0
  255. package/examples/jsm/capabilities/WebGPU.js +3 -1
  256. package/examples/jsm/controls/FirstPersonControls.js +20 -20
  257. package/examples/jsm/controls/FlyControls.js +16 -17
  258. package/examples/jsm/controls/OrbitControls.js +44 -4
  259. package/examples/jsm/controls/TrackballControls.js +14 -2
  260. package/examples/jsm/controls/TransformControls.js +1 -1
  261. package/examples/jsm/csm/CSM.js +1 -0
  262. package/examples/jsm/csm/CSMHelper.js +30 -0
  263. package/examples/jsm/exporters/GLTFExporter.js +0 -79
  264. package/examples/jsm/exporters/USDZExporter.js +93 -1
  265. package/examples/jsm/helpers/OctreeHelper.js +22 -8
  266. package/examples/jsm/helpers/VertexNormalsHelper.js +7 -1
  267. package/examples/jsm/helpers/VertexTangentsHelper.js +7 -0
  268. package/examples/jsm/helpers/ViewHelper.js +24 -0
  269. package/examples/jsm/interactive/HTMLMesh.js +5 -6
  270. package/examples/jsm/interactive/InteractiveGroup.js +4 -2
  271. package/examples/jsm/libs/flow.module.js +610 -160
  272. package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
  273. package/examples/jsm/lines/LineSegments2.js +4 -0
  274. package/examples/jsm/loaders/3DMLoader.js +1 -2
  275. package/examples/jsm/loaders/ColladaLoader.js +28 -0
  276. package/examples/jsm/loaders/FBXLoader.js +18 -2
  277. package/examples/jsm/loaders/GLTFLoader.js +269 -428
  278. package/examples/jsm/loaders/KTX2Loader.js +68 -29
  279. package/examples/jsm/loaders/LDrawLoader.js +14 -13
  280. package/examples/jsm/loaders/LottieLoader.js +4 -2
  281. package/examples/jsm/loaders/MaterialXLoader.js +728 -0
  282. package/examples/jsm/loaders/PCDLoader.js +1 -1
  283. package/examples/jsm/loaders/PLYLoader.js +68 -16
  284. package/examples/jsm/loaders/SVGLoader.js +227 -14
  285. package/examples/jsm/loaders/USDZLoader.js +351 -111
  286. package/examples/jsm/loaders/VRMLLoader.js +13 -1
  287. package/examples/jsm/math/ConvexHull.js +4 -4
  288. package/examples/jsm/math/Octree.js +1 -1
  289. package/examples/jsm/node-editor/NodeEditor.js +91 -12
  290. package/examples/jsm/node-editor/core/BaseNode.js +10 -3
  291. package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +6 -9
  292. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +6 -9
  293. package/examples/jsm/node-editor/math/AngleEditor.js +3 -3
  294. package/examples/jsm/node-editor/math/InvertEditor.js +2 -2
  295. package/examples/jsm/node-editor/scene/MeshEditor.js +11 -8
  296. package/examples/jsm/node-editor/utils/PreviewEditor.js +4 -0
  297. package/examples/jsm/nodes/Nodes.js +30 -3
  298. package/examples/jsm/nodes/accessors/BitangentNode.js +62 -0
  299. package/examples/jsm/nodes/accessors/NormalNode.js +6 -6
  300. package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
  301. package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
  302. package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
  303. package/examples/jsm/nodes/accessors/SkinningNode.js +8 -1
  304. package/examples/jsm/nodes/accessors/TangentNode.js +95 -0
  305. package/examples/jsm/nodes/core/AttributeNode.js +31 -8
  306. package/examples/jsm/nodes/core/Node.js +1 -1
  307. package/examples/jsm/nodes/core/NodeBuilder.js +55 -6
  308. package/examples/jsm/nodes/core/NodeFrame.js +2 -2
  309. package/examples/jsm/nodes/core/NodeVarying.js +7 -4
  310. package/examples/jsm/nodes/core/VaryingNode.js +6 -4
  311. package/examples/jsm/nodes/core/constants.js +13 -13
  312. package/examples/jsm/nodes/display/BlendModeNode.js +85 -0
  313. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -12
  314. package/examples/jsm/nodes/display/NormalMapNode.js +19 -12
  315. package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
  316. package/examples/jsm/nodes/display/ViewportNode.js +106 -0
  317. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +5 -5
  318. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +3 -3
  319. package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +2 -2
  320. package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
  321. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  322. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
  323. package/examples/jsm/nodes/materials/Materials.js +9 -7
  324. package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
  325. package/examples/jsm/nodes/materialx/{Disclaimer.md → DISCLAIMER.md} +1 -1
  326. package/examples/jsm/nodes/materialx/MaterialXNodes.js +59 -0
  327. package/examples/jsm/nodes/materialx/{functions/lib → lib}/mx_hsv.js +1 -1
  328. package/examples/jsm/nodes/materialx/{functions/lib → lib}/mx_noise.js +13 -3
  329. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
  330. package/examples/jsm/nodes/math/MathNode.js +5 -5
  331. package/examples/jsm/nodes/math/OperatorNode.js +16 -3
  332. package/examples/jsm/nodes/shadernode/ShaderNode.js +35 -20
  333. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +87 -63
  334. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +29 -0
  335. package/examples/jsm/nodes/utils/ConvertNode.js +15 -14
  336. package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
  337. package/examples/jsm/nodes/utils/JoinNode.js +8 -2
  338. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
  339. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
  340. package/examples/jsm/nodes/utils/OscNode.js +2 -2
  341. package/examples/jsm/nodes/utils/RemapNode.js +34 -0
  342. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
  343. package/examples/jsm/nodes/utils/TimerNode.js +21 -1
  344. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
  345. package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
  346. package/examples/jsm/postprocessing/BloomPass.js +22 -3
  347. package/examples/jsm/postprocessing/BokehPass.js +18 -4
  348. package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
  349. package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
  350. package/examples/jsm/postprocessing/EffectComposer.js +9 -0
  351. package/examples/jsm/postprocessing/FilmPass.js +8 -0
  352. package/examples/jsm/postprocessing/GlitchPass.js +13 -1
  353. package/examples/jsm/postprocessing/HalftonePass.js +8 -0
  354. package/examples/jsm/postprocessing/OutlinePass.js +21 -1
  355. package/examples/jsm/postprocessing/Pass.js +2 -0
  356. package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
  357. package/examples/jsm/postprocessing/SAOPass.js +20 -0
  358. package/examples/jsm/postprocessing/SMAAPass.js +16 -0
  359. package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
  360. package/examples/jsm/postprocessing/SavePass.js +17 -1
  361. package/examples/jsm/postprocessing/ShaderPass.js +8 -0
  362. package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
  363. package/examples/jsm/postprocessing/TexturePass.js +8 -0
  364. package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
  365. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +56 -35
  366. package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
  367. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
  368. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
  369. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
  370. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +41 -9
  371. package/examples/jsm/shaders/MMDToonShader.js +0 -2
  372. package/examples/jsm/shaders/VelocityShader.js +128 -0
  373. package/examples/jsm/utils/BufferGeometryUtils.js +174 -42
  374. package/examples/jsm/utils/SceneUtils.js +129 -4
  375. package/examples/jsm/webxr/OculusHandModel.js +3 -2
  376. package/examples/jsm/webxr/XRHandMeshModel.js +8 -3
  377. package/package.json +13 -13
  378. package/src/Three.js +1 -0
  379. package/src/animation/PropertyBinding.js +7 -0
  380. package/src/audio/AudioContext.js +5 -5
  381. package/src/cameras/CubeCamera.js +14 -14
  382. package/src/constants.js +1 -1
  383. package/src/core/InstancedBufferGeometry.js +1 -7
  384. package/src/core/InterleavedBufferAttribute.js +4 -4
  385. package/src/extras/Earcut.js +67 -67
  386. package/src/geometries/PolyhedronGeometry.js +1 -1
  387. package/src/geometries/ShapeGeometry.js +1 -1
  388. package/src/helpers/ArrowHelper.js +9 -0
  389. package/src/helpers/Box3Helper.js +7 -0
  390. package/src/helpers/BoxHelper.js +7 -1
  391. package/src/helpers/DirectionalLightHelper.js +5 -1
  392. package/src/helpers/GridHelper.js +7 -0
  393. package/src/helpers/HemisphereLightHelper.js +4 -1
  394. package/src/helpers/PlaneHelper.js +9 -0
  395. package/src/helpers/PointLightHelper.js +2 -1
  396. package/src/helpers/PolarGridHelper.js +7 -0
  397. package/src/helpers/SkeletonHelper.js +7 -0
  398. package/src/helpers/SpotLightHelper.js +4 -2
  399. package/src/lights/LightShadow.js +1 -2
  400. package/src/lights/PointLight.js +2 -2
  401. package/src/lights/SpotLight.js +2 -2
  402. package/src/loaders/FileLoader.js +4 -1
  403. package/src/loaders/ObjectLoader.js +5 -1
  404. package/src/materials/Material.js +1 -1
  405. package/src/materials/MeshPhysicalMaterial.js +1 -1
  406. package/src/math/Color.js +5 -5
  407. package/src/math/Matrix3.js +53 -18
  408. package/src/math/Ray.js +2 -5
  409. package/src/math/Sphere.js +36 -21
  410. package/src/objects/InstancedMesh.js +7 -0
  411. package/src/objects/LOD.js +25 -6
  412. package/src/renderers/WebGL3DRenderTarget.js +1 -1
  413. package/src/renderers/WebGLArrayRenderTarget.js +1 -1
  414. package/src/renderers/WebGLCubeRenderTarget.js +1 -1
  415. package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
  416. package/src/renderers/WebGLRenderTarget.js +1 -1
  417. package/src/renderers/WebGLRenderer.js +36 -62
  418. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
  419. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
  420. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
  421. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
  422. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
  423. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +2 -4
  424. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
  425. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +2 -2
  426. package/src/renderers/shaders/ShaderChunk.js +3 -0
  427. package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
  428. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
  429. package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
  430. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +0 -3
  431. package/src/renderers/shaders/ShaderLib.js +20 -6
  432. package/src/renderers/shaders/UniformsLib.js +1 -1
  433. package/src/renderers/shaders/UniformsUtils.js +15 -0
  434. package/src/renderers/webgl/WebGLAttributes.js +2 -0
  435. package/src/renderers/webgl/WebGLBackground.js +15 -7
  436. package/src/renderers/webgl/WebGLLights.js +0 -4
  437. package/src/renderers/webgl/WebGLMaterials.js +2 -1
  438. package/src/renderers/webgl/WebGLShadowMap.js +3 -1
  439. package/src/renderers/webgl/WebGLState.js +78 -41
  440. package/src/renderers/webgl/WebGLTextures.js +94 -39
  441. package/src/renderers/webgl/WebGLUniforms.js +152 -24
  442. package/src/renderers/webgl/WebGLUtils.js +1 -1
  443. package/src/renderers/webxr/WebXRController.js +46 -13
  444. package/src/renderers/webxr/WebXRManager.js +71 -3
  445. package/src/scenes/Scene.js +8 -0
  446. package/src/textures/CompressedArrayTexture.js +18 -0
  447. package/src/textures/Texture.js +2 -1
  448. package/examples/js/libs/lottie_canvas.js +0 -12751
  449. package/examples/js/shaders/PixelShader.js +0 -51
  450. package/examples/jsm/shaders/PixelShader.js +0 -44
package/build/three.cjs CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  Object.defineProperty(exports, '__esModule', { value: true });
9
9
 
10
- const REVISION = '144';
10
+ const REVISION = '147';
11
11
  const MOUSE = {
12
12
  LEFT: 0,
13
13
  MIDDLE: 1,
@@ -996,49 +996,44 @@ class Matrix3 {
996
996
  const s = Math.sin(rotation);
997
997
  this.set(sx * c, sx * s, -sx * (c * cx + s * cy) + cx + tx, -sy * s, sy * c, -sy * (-s * cx + c * cy) + cy + ty, 0, 0, 1);
998
998
  return this;
999
- }
999
+ } //
1000
+
1000
1001
 
1001
1002
  scale(sx, sy) {
1002
- const te = this.elements;
1003
- te[0] *= sx;
1004
- te[3] *= sx;
1005
- te[6] *= sx;
1006
- te[1] *= sy;
1007
- te[4] *= sy;
1008
- te[7] *= sy;
1003
+ this.premultiply(_m3.makeScale(sx, sy));
1009
1004
  return this;
1010
1005
  }
1011
1006
 
1012
1007
  rotate(theta) {
1013
- const c = Math.cos(theta);
1014
- const s = Math.sin(theta);
1015
- const te = this.elements;
1016
- const a11 = te[0],
1017
- a12 = te[3],
1018
- a13 = te[6];
1019
- const a21 = te[1],
1020
- a22 = te[4],
1021
- a23 = te[7];
1022
- te[0] = c * a11 + s * a21;
1023
- te[3] = c * a12 + s * a22;
1024
- te[6] = c * a13 + s * a23;
1025
- te[1] = -s * a11 + c * a21;
1026
- te[4] = -s * a12 + c * a22;
1027
- te[7] = -s * a13 + c * a23;
1008
+ this.premultiply(_m3.makeRotation(-theta));
1028
1009
  return this;
1029
1010
  }
1030
1011
 
1031
1012
  translate(tx, ty) {
1032
- const te = this.elements;
1033
- te[0] += tx * te[2];
1034
- te[3] += tx * te[5];
1035
- te[6] += tx * te[8];
1036
- te[1] += ty * te[2];
1037
- te[4] += ty * te[5];
1038
- te[7] += ty * te[8];
1013
+ this.premultiply(_m3.makeTranslation(tx, ty));
1014
+ return this;
1015
+ } // for 2D Transforms
1016
+
1017
+
1018
+ makeTranslation(x, y) {
1019
+ this.set(1, 0, x, 0, 1, y, 0, 0, 1);
1039
1020
  return this;
1040
1021
  }
1041
1022
 
1023
+ makeRotation(theta) {
1024
+ // counterclockwise
1025
+ const c = Math.cos(theta);
1026
+ const s = Math.sin(theta);
1027
+ this.set(c, -s, 0, s, c, 0, 0, 0, 1);
1028
+ return this;
1029
+ }
1030
+
1031
+ makeScale(x, y) {
1032
+ this.set(x, 0, 0, 0, y, 0, 0, 0, 1);
1033
+ return this;
1034
+ } //
1035
+
1036
+
1042
1037
  equals(matrix) {
1043
1038
  const te = this.elements;
1044
1039
  const me = matrix.elements;
@@ -1078,6 +1073,8 @@ class Matrix3 {
1078
1073
 
1079
1074
  }
1080
1075
 
1076
+ const _m3 = /*@__PURE__*/new Matrix3();
1077
+
1081
1078
  function arrayNeedsUint32(array) {
1082
1079
  // assumes larger values usually on last
1083
1080
  for (let i = array.length - 1; i >= 0; --i) {
@@ -1307,7 +1304,7 @@ const _colorKeywords = {
1307
1304
  'yellow': 0xFFFF00,
1308
1305
  'yellowgreen': 0x9ACD32
1309
1306
  };
1310
- const _rgb = {
1307
+ const _rgb$1 = {
1311
1308
  r: 0,
1312
1309
  g: 0,
1313
1310
  b: 0
@@ -1382,7 +1379,7 @@ class Color {
1382
1379
  return this;
1383
1380
  }
1384
1381
 
1385
- setRGB(r, g, b, colorSpace = LinearSRGBColorSpace) {
1382
+ setRGB(r, g, b, colorSpace = ColorManagement.workingColorSpace) {
1386
1383
  this.r = r;
1387
1384
  this.g = g;
1388
1385
  this.b = b;
@@ -1390,7 +1387,7 @@ class Color {
1390
1387
  return this;
1391
1388
  }
1392
1389
 
1393
- setHSL(h, s, l, colorSpace = LinearSRGBColorSpace) {
1390
+ setHSL(h, s, l, colorSpace = ColorManagement.workingColorSpace) {
1394
1391
  // h,s,l ranges are in 0.0 - 1.0
1395
1392
  h = euclideanModulo(h, 1);
1396
1393
  s = clamp(s, 0, 1);
@@ -1545,20 +1542,20 @@ class Color {
1545
1542
  }
1546
1543
 
1547
1544
  getHex(colorSpace = SRGBColorSpace) {
1548
- ColorManagement.fromWorkingColorSpace(toComponents(this, _rgb), colorSpace);
1549
- return clamp(_rgb.r * 255, 0, 255) << 16 ^ clamp(_rgb.g * 255, 0, 255) << 8 ^ clamp(_rgb.b * 255, 0, 255) << 0;
1545
+ ColorManagement.fromWorkingColorSpace(toComponents(this, _rgb$1), colorSpace);
1546
+ return clamp(_rgb$1.r * 255, 0, 255) << 16 ^ clamp(_rgb$1.g * 255, 0, 255) << 8 ^ clamp(_rgb$1.b * 255, 0, 255) << 0;
1550
1547
  }
1551
1548
 
1552
1549
  getHexString(colorSpace = SRGBColorSpace) {
1553
1550
  return ('000000' + this.getHex(colorSpace).toString(16)).slice(-6);
1554
1551
  }
1555
1552
 
1556
- getHSL(target, colorSpace = LinearSRGBColorSpace) {
1553
+ getHSL(target, colorSpace = ColorManagement.workingColorSpace) {
1557
1554
  // h,s,l ranges are in 0.0 - 1.0
1558
- ColorManagement.fromWorkingColorSpace(toComponents(this, _rgb), colorSpace);
1559
- const r = _rgb.r,
1560
- g = _rgb.g,
1561
- b = _rgb.b;
1555
+ ColorManagement.fromWorkingColorSpace(toComponents(this, _rgb$1), colorSpace);
1556
+ const r = _rgb$1.r,
1557
+ g = _rgb$1.g,
1558
+ b = _rgb$1.b;
1562
1559
  const max = Math.max(r, g, b);
1563
1560
  const min = Math.min(r, g, b);
1564
1561
  let hue, saturation;
@@ -1594,23 +1591,23 @@ class Color {
1594
1591
  return target;
1595
1592
  }
1596
1593
 
1597
- getRGB(target, colorSpace = LinearSRGBColorSpace) {
1598
- ColorManagement.fromWorkingColorSpace(toComponents(this, _rgb), colorSpace);
1599
- target.r = _rgb.r;
1600
- target.g = _rgb.g;
1601
- target.b = _rgb.b;
1594
+ getRGB(target, colorSpace = ColorManagement.workingColorSpace) {
1595
+ ColorManagement.fromWorkingColorSpace(toComponents(this, _rgb$1), colorSpace);
1596
+ target.r = _rgb$1.r;
1597
+ target.g = _rgb$1.g;
1598
+ target.b = _rgb$1.b;
1602
1599
  return target;
1603
1600
  }
1604
1601
 
1605
1602
  getStyle(colorSpace = SRGBColorSpace) {
1606
- ColorManagement.fromWorkingColorSpace(toComponents(this, _rgb), colorSpace);
1603
+ ColorManagement.fromWorkingColorSpace(toComponents(this, _rgb$1), colorSpace);
1607
1604
 
1608
1605
  if (colorSpace !== SRGBColorSpace) {
1609
1606
  // Requires CSS Color Module Level 4 (https://www.w3.org/TR/css-color-4/).
1610
- return `color(${colorSpace} ${_rgb.r} ${_rgb.g} ${_rgb.b})`;
1607
+ return `color(${colorSpace} ${_rgb$1.r} ${_rgb$1.g} ${_rgb$1.b})`;
1611
1608
  }
1612
1609
 
1613
- return `rgb(${_rgb.r * 255 | 0},${_rgb.g * 255 | 0},${_rgb.b * 255 | 0})`;
1610
+ return `rgb(${_rgb$1.r * 255 | 0},${_rgb$1.g * 255 | 0},${_rgb$1.b * 255 | 0})`;
1614
1611
  }
1615
1612
 
1616
1613
  offsetHSL(h, s, l) {
@@ -1887,7 +1884,7 @@ function serializeImage(image) {
1887
1884
  let textureId = 0;
1888
1885
 
1889
1886
  class Texture extends EventDispatcher {
1890
- constructor(image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = 1, encoding = LinearEncoding) {
1887
+ constructor(image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = Texture.DEFAULT_ANISOTROPY, encoding = LinearEncoding) {
1891
1888
  super();
1892
1889
  this.isTexture = true;
1893
1890
  Object.defineProperty(this, 'id', {
@@ -2086,6 +2083,7 @@ class Texture extends EventDispatcher {
2086
2083
 
2087
2084
  Texture.DEFAULT_IMAGE = null;
2088
2085
  Texture.DEFAULT_MAPPING = UVMapping;
2086
+ Texture.DEFAULT_ANISOTROPY = 1;
2089
2087
 
2090
2088
  class Vector4 {
2091
2089
  constructor(x = 0, y = 0, z = 0, w = 1) {
@@ -2573,7 +2571,7 @@ class Vector4 {
2573
2571
  */
2574
2572
 
2575
2573
  class WebGLRenderTarget extends EventDispatcher {
2576
- constructor(width, height, options = {}) {
2574
+ constructor(width = 1, height = 1, options = {}) {
2577
2575
  super();
2578
2576
  this.isWebGLRenderTarget = true;
2579
2577
  this.width = width;
@@ -2664,7 +2662,7 @@ class DataArrayTexture extends Texture {
2664
2662
  }
2665
2663
 
2666
2664
  class WebGLArrayRenderTarget extends WebGLRenderTarget {
2667
- constructor(width, height, depth) {
2665
+ constructor(width = 1, height = 1, depth = 1) {
2668
2666
  super(width, height);
2669
2667
  this.isWebGLArrayRenderTarget = true;
2670
2668
  this.depth = depth;
@@ -2702,7 +2700,7 @@ class Data3DTexture extends Texture {
2702
2700
  }
2703
2701
 
2704
2702
  class WebGL3DRenderTarget extends WebGLRenderTarget {
2705
- constructor(width, height, depth) {
2703
+ constructor(width = 1, height = 1, depth = 1) {
2706
2704
  super(width, height);
2707
2705
  this.isWebGL3DRenderTarget = true;
2708
2706
  this.depth = depth;
@@ -2713,7 +2711,7 @@ class WebGL3DRenderTarget extends WebGLRenderTarget {
2713
2711
  }
2714
2712
 
2715
2713
  class WebGLMultipleRenderTargets extends WebGLRenderTarget {
2716
- constructor(width, height, count, options = {}) {
2714
+ constructor(width = 1, height = 1, count = 1, options = {}) {
2717
2715
  super(width, height, options);
2718
2716
  this.isWebGLMultipleRenderTargets = true;
2719
2717
  const texture = this.texture;
@@ -4055,28 +4053,28 @@ class Box3 {
4055
4053
 
4056
4054
  _v1$7.subVectors(triangle.b, _center);
4057
4055
 
4058
- _v2$3.subVectors(triangle.c, _center); // compute edge vectors for triangle
4056
+ _v2$4.subVectors(triangle.c, _center); // compute edge vectors for triangle
4059
4057
 
4060
4058
 
4061
4059
  _f0.subVectors(_v1$7, _v0$2);
4062
4060
 
4063
- _f1.subVectors(_v2$3, _v1$7);
4061
+ _f1.subVectors(_v2$4, _v1$7);
4064
4062
 
4065
- _f2.subVectors(_v0$2, _v2$3); // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
4063
+ _f2.subVectors(_v0$2, _v2$4); // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
4066
4064
  // make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation
4067
4065
  // axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)
4068
4066
 
4069
4067
 
4070
4068
  let axes = [0, -_f0.z, _f0.y, 0, -_f1.z, _f1.y, 0, -_f2.z, _f2.y, _f0.z, 0, -_f0.x, _f1.z, 0, -_f1.x, _f2.z, 0, -_f2.x, -_f0.y, _f0.x, 0, -_f1.y, _f1.x, 0, -_f2.y, _f2.x, 0];
4071
4069
 
4072
- if (!satForAxes(axes, _v0$2, _v1$7, _v2$3, _extents)) {
4070
+ if (!satForAxes(axes, _v0$2, _v1$7, _v2$4, _extents)) {
4073
4071
  return false;
4074
4072
  } // test 3 face normals from the aabb
4075
4073
 
4076
4074
 
4077
4075
  axes = [1, 0, 0, 0, 1, 0, 0, 0, 1];
4078
4076
 
4079
- if (!satForAxes(axes, _v0$2, _v1$7, _v2$3, _extents)) {
4077
+ if (!satForAxes(axes, _v0$2, _v1$7, _v2$4, _extents)) {
4080
4078
  return false;
4081
4079
  } // finally testing the face normal of the triangle
4082
4080
  // use already existing triangle edge vectors here
@@ -4085,7 +4083,7 @@ class Box3 {
4085
4083
  _triangleNormal.crossVectors(_f0, _f1);
4086
4084
 
4087
4085
  axes = [_triangleNormal.x, _triangleNormal.y, _triangleNormal.z];
4088
- return satForAxes(axes, _v0$2, _v1$7, _v2$3, _extents);
4086
+ return satForAxes(axes, _v0$2, _v1$7, _v2$4, _extents);
4089
4087
  }
4090
4088
 
4091
4089
  clampPoint(point, target) {
@@ -4173,7 +4171,7 @@ const _v0$2 = /*@__PURE__*/new Vector3();
4173
4171
 
4174
4172
  const _v1$7 = /*@__PURE__*/new Vector3();
4175
4173
 
4176
- const _v2$3 = /*@__PURE__*/new Vector3(); // triangle edge vectors
4174
+ const _v2$4 = /*@__PURE__*/new Vector3(); // triangle edge vectors
4177
4175
 
4178
4176
 
4179
4177
  const _f0 = /*@__PURE__*/new Vector3();
@@ -4215,9 +4213,7 @@ const _box$2 = /*@__PURE__*/new Box3();
4215
4213
 
4216
4214
  const _v1$6 = /*@__PURE__*/new Vector3();
4217
4215
 
4218
- const _toFarthestPoint = /*@__PURE__*/new Vector3();
4219
-
4220
- const _toPoint = /*@__PURE__*/new Vector3();
4216
+ const _v2$3 = /*@__PURE__*/new Vector3();
4221
4217
 
4222
4218
  class Sphere {
4223
4219
  constructor(center = new Vector3(), radius = -1) {
@@ -4323,37 +4319,46 @@ class Sphere {
4323
4319
  }
4324
4320
 
4325
4321
  expandByPoint(point) {
4326
- // from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L649-L671
4327
- _toPoint.subVectors(point, this.center);
4322
+ if (this.isEmpty()) {
4323
+ this.center.copy(point);
4324
+ this.radius = 0;
4325
+ return this;
4326
+ }
4327
+
4328
+ _v1$6.subVectors(point, this.center);
4328
4329
 
4329
- const lengthSq = _toPoint.lengthSq();
4330
+ const lengthSq = _v1$6.lengthSq();
4330
4331
 
4331
4332
  if (lengthSq > this.radius * this.radius) {
4333
+ // calculate the minimal sphere
4332
4334
  const length = Math.sqrt(lengthSq);
4333
- const missingRadiusHalf = (length - this.radius) * 0.5; // Nudge this sphere towards the target point. Add half the missing distance to radius,
4334
- // and the other half to position. This gives a tighter enclosure, instead of if
4335
- // the whole missing distance were just added to radius.
4336
-
4337
- this.center.add(_toPoint.multiplyScalar(missingRadiusHalf / length));
4338
- this.radius += missingRadiusHalf;
4335
+ const delta = (length - this.radius) * 0.5;
4336
+ this.center.addScaledVector(_v1$6, delta / length);
4337
+ this.radius += delta;
4339
4338
  }
4340
4339
 
4341
4340
  return this;
4342
4341
  }
4343
4342
 
4344
4343
  union(sphere) {
4345
- // from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L759-L769
4346
- // To enclose another sphere into this sphere, we only need to enclose two points:
4347
- // 1) Enclose the farthest point on the other sphere into this sphere.
4348
- // 2) Enclose the opposite point of the farthest point into this sphere.
4344
+ if (sphere.isEmpty()) {
4345
+ return this;
4346
+ }
4347
+
4348
+ if (this.isEmpty()) {
4349
+ this.copy(sphere);
4350
+ return this;
4351
+ }
4352
+
4349
4353
  if (this.center.equals(sphere.center) === true) {
4350
- _toFarthestPoint.set(0, 0, 1).multiplyScalar(sphere.radius);
4354
+ this.radius = Math.max(this.radius, sphere.radius);
4351
4355
  } else {
4352
- _toFarthestPoint.subVectors(sphere.center, this.center).normalize().multiplyScalar(sphere.radius);
4356
+ _v2$3.subVectors(sphere.center, this.center).setLength(sphere.radius);
4357
+
4358
+ this.expandByPoint(_v1$6.copy(sphere.center).add(_v2$3));
4359
+ this.expandByPoint(_v1$6.copy(sphere.center).sub(_v2$3));
4353
4360
  }
4354
4361
 
4355
- this.expandByPoint(_v1$6.copy(sphere.center).add(_toFarthestPoint));
4356
- this.expandByPoint(_v1$6.copy(sphere.center).sub(_toFarthestPoint));
4357
4362
  return this;
4358
4363
  }
4359
4364
 
@@ -4625,11 +4630,9 @@ class Ray {
4625
4630
  tymax = (box.min.y - origin.y) * invdiry;
4626
4631
  }
4627
4632
 
4628
- if (tmin > tymax || tymin > tmax) return null; // These lines also handle the case where tmin or tmax is NaN
4629
- // (result of 0 * Infinity). x !== x returns true if x is NaN
4630
-
4631
- if (tymin > tmin || tmin !== tmin) tmin = tymin;
4632
- if (tymax < tmax || tmax !== tmax) tmax = tymax;
4633
+ if (tmin > tymax || tymin > tmax) return null;
4634
+ if (tymin > tmin || isNaN(tmin)) tmin = tymin;
4635
+ if (tymax < tmax || isNaN(tmax)) tmax = tymax;
4633
4636
 
4634
4637
  if (invdirz >= 0) {
4635
4638
  tzmin = (box.min.z - origin.z) * invdirz;
@@ -6874,7 +6877,7 @@ class Material extends EventDispatcher {
6874
6877
  if (this.transmissionMap && this.transmissionMap.isTexture) data.transmissionMap = this.transmissionMap.toJSON(meta).uuid;
6875
6878
  if (this.thickness !== undefined) data.thickness = this.thickness;
6876
6879
  if (this.thicknessMap && this.thicknessMap.isTexture) data.thicknessMap = this.thicknessMap.toJSON(meta).uuid;
6877
- if (this.attenuationDistance !== undefined) data.attenuationDistance = this.attenuationDistance;
6880
+ if (this.attenuationDistance !== undefined && this.attenuationDistance !== Infinity) data.attenuationDistance = this.attenuationDistance;
6878
6881
  if (this.attenuationColor !== undefined) data.attenuationColor = this.attenuationColor.getHex();
6879
6882
  if (this.size !== undefined) data.size = this.size;
6880
6883
  if (this.shadowSide !== null) data.shadowSide = this.shadowSide;
@@ -8590,6 +8593,7 @@ class BoxGeometry extends BufferGeometry {
8590
8593
  /**
8591
8594
  * Uniform Utilities
8592
8595
  */
8596
+
8593
8597
  function cloneUniforms(src) {
8594
8598
  const dst = {};
8595
8599
 
@@ -8632,6 +8636,14 @@ function cloneUniformsGroups(src) {
8632
8636
  }
8633
8637
 
8634
8638
  return dst;
8639
+ }
8640
+ function getUnlitUniformColorSpace(renderer) {
8641
+ if (renderer.getRenderTarget() === null) {
8642
+ // https://github.com/mrdoob/three.js/pull/23937#issuecomment-1111067398
8643
+ return renderer.outputEncoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
8644
+ }
8645
+
8646
+ return LinearSRGBColorSpace;
8635
8647
  } // Legacy
8636
8648
 
8637
8649
  const UniformsUtils = {
@@ -8991,8 +9003,9 @@ class PerspectiveCamera extends Camera {
8991
9003
 
8992
9004
  }
8993
9005
 
8994
- const fov = 90,
8995
- aspect = 1;
9006
+ const fov = -90; // negative fov is not an error
9007
+
9008
+ const aspect = 1;
8996
9009
 
8997
9010
  class CubeCamera extends Object3D {
8998
9011
  constructor(near, far, renderTarget) {
@@ -9001,33 +9014,33 @@ class CubeCamera extends Object3D {
9001
9014
  this.renderTarget = renderTarget;
9002
9015
  const cameraPX = new PerspectiveCamera(fov, aspect, near, far);
9003
9016
  cameraPX.layers = this.layers;
9004
- cameraPX.up.set(0, -1, 0);
9005
- cameraPX.lookAt(new Vector3(1, 0, 0));
9017
+ cameraPX.up.set(0, 1, 0);
9018
+ cameraPX.lookAt(1, 0, 0);
9006
9019
  this.add(cameraPX);
9007
9020
  const cameraNX = new PerspectiveCamera(fov, aspect, near, far);
9008
9021
  cameraNX.layers = this.layers;
9009
- cameraNX.up.set(0, -1, 0);
9010
- cameraNX.lookAt(new Vector3(-1, 0, 0));
9022
+ cameraNX.up.set(0, 1, 0);
9023
+ cameraNX.lookAt(-1, 0, 0);
9011
9024
  this.add(cameraNX);
9012
9025
  const cameraPY = new PerspectiveCamera(fov, aspect, near, far);
9013
9026
  cameraPY.layers = this.layers;
9014
- cameraPY.up.set(0, 0, 1);
9015
- cameraPY.lookAt(new Vector3(0, 1, 0));
9027
+ cameraPY.up.set(0, 0, -1);
9028
+ cameraPY.lookAt(0, 1, 0);
9016
9029
  this.add(cameraPY);
9017
9030
  const cameraNY = new PerspectiveCamera(fov, aspect, near, far);
9018
9031
  cameraNY.layers = this.layers;
9019
- cameraNY.up.set(0, 0, -1);
9020
- cameraNY.lookAt(new Vector3(0, -1, 0));
9032
+ cameraNY.up.set(0, 0, 1);
9033
+ cameraNY.lookAt(0, -1, 0);
9021
9034
  this.add(cameraNY);
9022
9035
  const cameraPZ = new PerspectiveCamera(fov, aspect, near, far);
9023
9036
  cameraPZ.layers = this.layers;
9024
- cameraPZ.up.set(0, -1, 0);
9025
- cameraPZ.lookAt(new Vector3(0, 0, 1));
9037
+ cameraPZ.up.set(0, 1, 0);
9038
+ cameraPZ.lookAt(0, 0, 1);
9026
9039
  this.add(cameraPZ);
9027
9040
  const cameraNZ = new PerspectiveCamera(fov, aspect, near, far);
9028
9041
  cameraNZ.layers = this.layers;
9029
- cameraNZ.up.set(0, -1, 0);
9030
- cameraNZ.lookAt(new Vector3(0, 0, -1));
9042
+ cameraNZ.up.set(0, 1, 0);
9043
+ cameraNZ.lookAt(0, 0, -1);
9031
9044
  this.add(cameraNZ);
9032
9045
  }
9033
9046
 
@@ -9083,7 +9096,7 @@ class CubeTexture extends Texture {
9083
9096
  }
9084
9097
 
9085
9098
  class WebGLCubeRenderTarget extends WebGLRenderTarget {
9086
- constructor(size, options = {}) {
9099
+ constructor(size = 1, options = {}) {
9087
9100
  super(size, size, options);
9088
9101
  this.isWebGLCubeRenderTarget = true;
9089
9102
  const image = {
@@ -9557,6 +9570,8 @@ function WebGLAttributes(gl, capabilities) {
9557
9570
 
9558
9571
  updateRange.count = -1; // reset range
9559
9572
  }
9573
+
9574
+ attribute.onUploadCallback();
9560
9575
  } //
9561
9576
 
9562
9577
 
@@ -9724,7 +9739,7 @@ var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
9724
9739
 
9725
9740
  var encodings_pars_fragment = "vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}";
9726
9741
 
9727
- var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
9742
+ var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
9728
9743
 
9729
9744
  var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif";
9730
9745
 
@@ -9750,7 +9765,7 @@ var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;
9750
9765
 
9751
9766
  var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
9752
9767
 
9753
- var lights_lambert_pars_fragment = "varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert\n#define Material_LightProbeLOD( material )\t(0)";
9768
+ var lights_lambert_pars_fragment = "varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert";
9754
9769
 
9755
9770
  var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif";
9756
9771
 
@@ -9758,11 +9773,11 @@ var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP )\n\tvec3 getIBLIrr
9758
9773
 
9759
9774
  var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;";
9760
9775
 
9761
- var lights_toon_pars_fragment = "varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)";
9776
+ var lights_toon_pars_fragment = "varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon";
9762
9777
 
9763
9778
  var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
9764
9779
 
9765
- var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)";
9780
+ var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong";
9766
9781
 
9767
9782
  var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif";
9768
9783
 
@@ -9802,7 +9817,7 @@ var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\tuniform float morphTar
9802
9817
 
9803
9818
  var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif";
9804
9819
 
9805
- var normal_fragment_begin = "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;";
9820
+ var normal_fragment_begin = "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;";
9806
9821
 
9807
9822
  var normal_fragment_maps = "#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif";
9808
9823
 
@@ -9824,7 +9839,7 @@ var iridescence_pars_fragment = "#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D
9824
9839
 
9825
9840
  var output_fragment = "#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );";
9826
9841
 
9827
- var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}";
9842
+ var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}";
9828
9843
 
9829
9844
  var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif";
9830
9845
 
@@ -9864,7 +9879,7 @@ var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp(
9864
9879
 
9865
9880
  var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );\n#endif";
9866
9881
 
9867
- var transmission_pars_fragment = "#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef texture2DLodEXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif";
9882
+ var transmission_pars_fragment = "#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef texture2DLodEXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif";
9868
9883
 
9869
9884
  var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif";
9870
9885
 
@@ -9880,11 +9895,14 @@ var uv2_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 =
9880
9895
 
9881
9896
  var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif";
9882
9897
 
9883
- const vertex$g = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}";
9884
- const fragment$g = "uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tgl_FragColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tgl_FragColor = vec4( mix( pow( gl_FragColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), gl_FragColor.rgb * 0.0773993808, vec3( lessThanEqual( gl_FragColor.rgb, vec3( 0.04045 ) ) ) ), gl_FragColor.w );\n\t#endif\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}";
9898
+ const vertex$h = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}";
9899
+ const fragment$h = "uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}";
9900
+
9901
+ const vertex$g = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}";
9902
+ const fragment$g = "#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}";
9885
9903
 
9886
9904
  const vertex$f = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}";
9887
- const fragment$f = "#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}";
9905
+ const fragment$f = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}";
9888
9906
 
9889
9907
  const vertex$e = "#include <common>\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 <uv_vertex>\n\t#include <skinbase_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}";
9890
9908
  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 <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_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#endif\n}";
@@ -10035,8 +10053,10 @@ const ShaderChunk = {
10035
10053
  uv2_pars_vertex: uv2_pars_vertex,
10036
10054
  uv2_vertex: uv2_vertex,
10037
10055
  worldpos_vertex: worldpos_vertex,
10038
- background_vert: vertex$g,
10039
- background_frag: fragment$g,
10056
+ background_vert: vertex$h,
10057
+ background_frag: fragment$h,
10058
+ backgroundCube_vert: vertex$g,
10059
+ backgroundCube_frag: fragment$g,
10040
10060
  cube_vert: vertex$f,
10041
10061
  cube_frag: fragment$f,
10042
10062
  depth_vert: vertex$e,
@@ -10476,17 +10496,44 @@ const ShaderLib = {
10476
10496
  },
10477
10497
  t2D: {
10478
10498
  value: null
10499
+ },
10500
+ backgroundIntensity: {
10501
+ value: 1
10479
10502
  }
10480
10503
  },
10481
10504
  vertexShader: ShaderChunk.background_vert,
10482
10505
  fragmentShader: ShaderChunk.background_frag
10483
10506
  },
10507
+ backgroundCube: {
10508
+ uniforms: {
10509
+ envMap: {
10510
+ value: null
10511
+ },
10512
+ flipEnvMap: {
10513
+ value: -1
10514
+ },
10515
+ backgroundBlurriness: {
10516
+ value: 0
10517
+ },
10518
+ backgroundIntensity: {
10519
+ value: 1
10520
+ }
10521
+ },
10522
+ vertexShader: ShaderChunk.backgroundCube_vert,
10523
+ fragmentShader: ShaderChunk.backgroundCube_frag
10524
+ },
10484
10525
  cube: {
10485
- uniforms: /*@__PURE__*/mergeUniforms([UniformsLib.envmap, {
10526
+ uniforms: {
10527
+ tCube: {
10528
+ value: null
10529
+ },
10530
+ tFlip: {
10531
+ value: -1
10532
+ },
10486
10533
  opacity: {
10487
10534
  value: 1.0
10488
10535
  }
10489
- }]),
10536
+ },
10490
10537
  vertexShader: ShaderChunk.cube_vert,
10491
10538
  fragmentShader: ShaderChunk.cube_frag
10492
10539
  },
@@ -10621,7 +10668,13 @@ ShaderLib.physical = {
10621
10668
  fragmentShader: ShaderChunk.meshphysical_frag
10622
10669
  };
10623
10670
 
10624
- function WebGLBackground(renderer, cubemaps, state, objects, alpha, premultipliedAlpha) {
10671
+ const _rgb = {
10672
+ r: 0,
10673
+ b: 0,
10674
+ g: 0
10675
+ };
10676
+
10677
+ function WebGLBackground(renderer, cubemaps, cubeuvmaps, state, objects, alpha, premultipliedAlpha) {
10625
10678
  const clearColor = new Color(0x000000);
10626
10679
  let clearAlpha = alpha === true ? 0 : 1;
10627
10680
  let planeMesh;
@@ -10635,7 +10688,9 @@ function WebGLBackground(renderer, cubemaps, state, objects, alpha, premultiplie
10635
10688
  let background = scene.isScene === true ? scene.background : null;
10636
10689
 
10637
10690
  if (background && background.isTexture) {
10638
- background = cubemaps.get(background);
10691
+ const usePMREM = scene.backgroundBlurriness > 0; // use PMREM if the user wants to blur the background
10692
+
10693
+ background = (usePMREM ? cubeuvmaps : cubemaps).get(background);
10639
10694
  } // Ignore background in AR
10640
10695
  // TODO: Reconsider this.
10641
10696
 
@@ -10662,9 +10717,9 @@ function WebGLBackground(renderer, cubemaps, state, objects, alpha, premultiplie
10662
10717
  if (boxMesh === undefined) {
10663
10718
  boxMesh = new Mesh(new BoxGeometry(1, 1, 1), new ShaderMaterial({
10664
10719
  name: 'BackgroundCubeMaterial',
10665
- uniforms: cloneUniforms(ShaderLib.cube.uniforms),
10666
- vertexShader: ShaderLib.cube.vertexShader,
10667
- fragmentShader: ShaderLib.cube.fragmentShader,
10720
+ uniforms: cloneUniforms(ShaderLib.backgroundCube.uniforms),
10721
+ vertexShader: ShaderLib.backgroundCube.vertexShader,
10722
+ fragmentShader: ShaderLib.backgroundCube.fragmentShader,
10668
10723
  side: BackSide,
10669
10724
  depthTest: false,
10670
10725
  depthWrite: false,
@@ -10688,6 +10743,8 @@ function WebGLBackground(renderer, cubemaps, state, objects, alpha, premultiplie
10688
10743
 
10689
10744
  boxMesh.material.uniforms.envMap.value = background;
10690
10745
  boxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture && background.isRenderTargetTexture === false ? -1 : 1;
10746
+ boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
10747
+ boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
10691
10748
 
10692
10749
  if (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {
10693
10750
  boxMesh.material.needsUpdate = true;
@@ -10722,6 +10779,7 @@ function WebGLBackground(renderer, cubemaps, state, objects, alpha, premultiplie
10722
10779
  }
10723
10780
 
10724
10781
  planeMesh.material.uniforms.t2D.value = background;
10782
+ planeMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
10725
10783
 
10726
10784
  if (background.matrixAutoUpdate === true) {
10727
10785
  background.updateMatrix();
@@ -10743,7 +10801,8 @@ function WebGLBackground(renderer, cubemaps, state, objects, alpha, premultiplie
10743
10801
  }
10744
10802
 
10745
10803
  function setClear(color, alpha) {
10746
- state.buffers.color.setClear(color.r, color.g, color.b, alpha, premultipliedAlpha);
10804
+ color.getRGB(_rgb, getUnlitUniformColorSpace(renderer));
10805
+ state.buffers.color.setClear(_rgb.r, _rgb.g, _rgb.b, alpha, premultipliedAlpha);
10747
10806
  }
10748
10807
 
10749
10808
  return {
@@ -13168,28 +13227,58 @@ function setValueV1i(gl, v) {
13168
13227
  if (cache[0] === v) return;
13169
13228
  gl.uniform1i(this.addr, v);
13170
13229
  cache[0] = v;
13171
- } // Single integer / boolean vector (from flat array)
13230
+ } // Single integer / boolean vector (from flat array or THREE.VectorN)
13172
13231
 
13173
13232
 
13174
13233
  function setValueV2i(gl, v) {
13175
13234
  const cache = this.cache;
13176
- if (arraysEqual(cache, v)) return;
13177
- gl.uniform2iv(this.addr, v);
13178
- copyArray(cache, v);
13235
+
13236
+ if (v.x !== undefined) {
13237
+ if (cache[0] !== v.x || cache[1] !== v.y) {
13238
+ gl.uniform2i(this.addr, v.x, v.y);
13239
+ cache[0] = v.x;
13240
+ cache[1] = v.y;
13241
+ }
13242
+ } else {
13243
+ if (arraysEqual(cache, v)) return;
13244
+ gl.uniform2iv(this.addr, v);
13245
+ copyArray(cache, v);
13246
+ }
13179
13247
  }
13180
13248
 
13181
13249
  function setValueV3i(gl, v) {
13182
13250
  const cache = this.cache;
13183
- if (arraysEqual(cache, v)) return;
13184
- gl.uniform3iv(this.addr, v);
13185
- copyArray(cache, v);
13251
+
13252
+ if (v.x !== undefined) {
13253
+ if (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z) {
13254
+ gl.uniform3i(this.addr, v.x, v.y, v.z);
13255
+ cache[0] = v.x;
13256
+ cache[1] = v.y;
13257
+ cache[2] = v.z;
13258
+ }
13259
+ } else {
13260
+ if (arraysEqual(cache, v)) return;
13261
+ gl.uniform3iv(this.addr, v);
13262
+ copyArray(cache, v);
13263
+ }
13186
13264
  }
13187
13265
 
13188
13266
  function setValueV4i(gl, v) {
13189
13267
  const cache = this.cache;
13190
- if (arraysEqual(cache, v)) return;
13191
- gl.uniform4iv(this.addr, v);
13192
- copyArray(cache, v);
13268
+
13269
+ if (v.x !== undefined) {
13270
+ if (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z || cache[3] !== v.w) {
13271
+ gl.uniform4i(this.addr, v.x, v.y, v.z, v.w);
13272
+ cache[0] = v.x;
13273
+ cache[1] = v.y;
13274
+ cache[2] = v.z;
13275
+ cache[3] = v.w;
13276
+ }
13277
+ } else {
13278
+ if (arraysEqual(cache, v)) return;
13279
+ gl.uniform4iv(this.addr, v);
13280
+ copyArray(cache, v);
13281
+ }
13193
13282
  } // Single unsigned integer
13194
13283
 
13195
13284
 
@@ -13198,28 +13287,58 @@ function setValueV1ui(gl, v) {
13198
13287
  if (cache[0] === v) return;
13199
13288
  gl.uniform1ui(this.addr, v);
13200
13289
  cache[0] = v;
13201
- } // Single unsigned integer vector (from flat array)
13290
+ } // Single unsigned integer vector (from flat array or THREE.VectorN)
13202
13291
 
13203
13292
 
13204
13293
  function setValueV2ui(gl, v) {
13205
13294
  const cache = this.cache;
13206
- if (arraysEqual(cache, v)) return;
13207
- gl.uniform2uiv(this.addr, v);
13208
- copyArray(cache, v);
13295
+
13296
+ if (v.x !== undefined) {
13297
+ if (cache[0] !== v.x || cache[1] !== v.y) {
13298
+ gl.uniform2ui(this.addr, v.x, v.y);
13299
+ cache[0] = v.x;
13300
+ cache[1] = v.y;
13301
+ }
13302
+ } else {
13303
+ if (arraysEqual(cache, v)) return;
13304
+ gl.uniform2uiv(this.addr, v);
13305
+ copyArray(cache, v);
13306
+ }
13209
13307
  }
13210
13308
 
13211
13309
  function setValueV3ui(gl, v) {
13212
13310
  const cache = this.cache;
13213
- if (arraysEqual(cache, v)) return;
13214
- gl.uniform3uiv(this.addr, v);
13215
- copyArray(cache, v);
13311
+
13312
+ if (v.x !== undefined) {
13313
+ if (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z) {
13314
+ gl.uniform3ui(this.addr, v.x, v.y, v.z);
13315
+ cache[0] = v.x;
13316
+ cache[1] = v.y;
13317
+ cache[2] = v.z;
13318
+ }
13319
+ } else {
13320
+ if (arraysEqual(cache, v)) return;
13321
+ gl.uniform3uiv(this.addr, v);
13322
+ copyArray(cache, v);
13323
+ }
13216
13324
  }
13217
13325
 
13218
13326
  function setValueV4ui(gl, v) {
13219
13327
  const cache = this.cache;
13220
- if (arraysEqual(cache, v)) return;
13221
- gl.uniform4uiv(this.addr, v);
13222
- copyArray(cache, v);
13328
+
13329
+ if (v.x !== undefined) {
13330
+ if (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z || cache[3] !== v.w) {
13331
+ gl.uniform4ui(this.addr, v.x, v.y, v.z, v.w);
13332
+ cache[0] = v.x;
13333
+ cache[1] = v.y;
13334
+ cache[2] = v.z;
13335
+ cache[3] = v.w;
13336
+ }
13337
+ } else {
13338
+ if (arraysEqual(cache, v)) return;
13339
+ gl.uniform4uiv(this.addr, v);
13340
+ copyArray(cache, v);
13341
+ }
13223
13342
  } // Single texture (2D / Cube)
13224
13343
 
13225
13344
 
@@ -13455,9 +13574,14 @@ function setValueV4uiArray(gl, v) {
13455
13574
 
13456
13575
 
13457
13576
  function setValueT1Array(gl, v, textures) {
13577
+ const cache = this.cache;
13458
13578
  const n = v.length;
13459
13579
  const units = allocTexUnits(textures, n);
13460
- gl.uniform1iv(this.addr, units);
13580
+
13581
+ if (!arraysEqual(cache, units)) {
13582
+ gl.uniform1iv(this.addr, units);
13583
+ copyArray(cache, units);
13584
+ }
13461
13585
 
13462
13586
  for (let i = 0; i !== n; ++i) {
13463
13587
  textures.setTexture2D(v[i] || emptyTexture, units[i]);
@@ -13465,9 +13589,14 @@ function setValueT1Array(gl, v, textures) {
13465
13589
  }
13466
13590
 
13467
13591
  function setValueT3DArray(gl, v, textures) {
13592
+ const cache = this.cache;
13468
13593
  const n = v.length;
13469
13594
  const units = allocTexUnits(textures, n);
13470
- gl.uniform1iv(this.addr, units);
13595
+
13596
+ if (!arraysEqual(cache, units)) {
13597
+ gl.uniform1iv(this.addr, units);
13598
+ copyArray(cache, units);
13599
+ }
13471
13600
 
13472
13601
  for (let i = 0; i !== n; ++i) {
13473
13602
  textures.setTexture3D(v[i] || empty3dTexture, units[i]);
@@ -13475,9 +13604,14 @@ function setValueT3DArray(gl, v, textures) {
13475
13604
  }
13476
13605
 
13477
13606
  function setValueT6Array(gl, v, textures) {
13607
+ const cache = this.cache;
13478
13608
  const n = v.length;
13479
13609
  const units = allocTexUnits(textures, n);
13480
- gl.uniform1iv(this.addr, units);
13610
+
13611
+ if (!arraysEqual(cache, units)) {
13612
+ gl.uniform1iv(this.addr, units);
13613
+ copyArray(cache, units);
13614
+ }
13481
13615
 
13482
13616
  for (let i = 0; i !== n; ++i) {
13483
13617
  textures.setTextureCube(v[i] || emptyCubeTexture, units[i]);
@@ -13485,9 +13619,14 @@ function setValueT6Array(gl, v, textures) {
13485
13619
  }
13486
13620
 
13487
13621
  function setValueT2DArrayArray(gl, v, textures) {
13622
+ const cache = this.cache;
13488
13623
  const n = v.length;
13489
13624
  const units = allocTexUnits(textures, n);
13490
- gl.uniform1iv(this.addr, units);
13625
+
13626
+ if (!arraysEqual(cache, units)) {
13627
+ gl.uniform1iv(this.addr, units);
13628
+ copyArray(cache, units);
13629
+ }
13491
13630
 
13492
13631
  for (let i = 0; i !== n; ++i) {
13493
13632
  textures.setTexture2DArray(v[i] || emptyArrayTexture, units[i]);
@@ -15068,10 +15207,7 @@ function WebGLLights(extensions, capabilities) {
15068
15207
 
15069
15208
  spotLength++;
15070
15209
  } else if (light.isRectAreaLight) {
15071
- const uniforms = cache.get(light); // (a) intensity is the total visible light emitted
15072
- //uniforms.color.copy( color ).multiplyScalar( intensity / ( light.width * light.height * Math.PI ) );
15073
- // (b) intensity is the brightness of the light
15074
-
15210
+ const uniforms = cache.get(light);
15075
15211
  uniforms.color.copy(color).multiplyScalar(intensity);
15076
15212
  uniforms.halfWidth.set(light.width * 0.5, 0.0, 0.0);
15077
15213
  uniforms.halfHeight.set(0.0, light.height * 0.5, 0.0);
@@ -15553,7 +15689,7 @@ function WebGLShadowMap(_renderer, _objects, _capabilities) {
15553
15689
  result = light.isPointLight === true ? _distanceMaterial : _depthMaterial;
15554
15690
  }
15555
15691
 
15556
- if (_renderer.localClippingEnabled && material.clipShadows === true && Array.isArray(material.clippingPlanes) && material.clippingPlanes.length !== 0 || material.displacementMap && material.displacementScale !== 0 || material.alphaMap && material.alphaTest > 0) {
15692
+ if (_renderer.localClippingEnabled && material.clipShadows === true && Array.isArray(material.clippingPlanes) && material.clippingPlanes.length !== 0 || material.displacementMap && material.displacementScale !== 0 || material.alphaMap && material.alphaTest > 0 || material.map && material.alphaTest > 0) {
15557
15693
  // in this case we need a unique material instance reflecting the
15558
15694
  // appropriate state
15559
15695
  const keyA = result.uuid,
@@ -15586,6 +15722,7 @@ function WebGLShadowMap(_renderer, _objects, _capabilities) {
15586
15722
 
15587
15723
  result.alphaMap = material.alphaMap;
15588
15724
  result.alphaTest = material.alphaTest;
15725
+ result.map = material.map;
15589
15726
  result.clipShadows = material.clipShadows;
15590
15727
  result.clippingPlanes = material.clippingPlanes;
15591
15728
  result.clipIntersection = material.clipIntersection;
@@ -15706,45 +15843,41 @@ function WebGLState(gl, extensions, capabilities) {
15706
15843
  },
15707
15844
  setFunc: function (depthFunc) {
15708
15845
  if (currentDepthFunc !== depthFunc) {
15709
- if (depthFunc) {
15710
- switch (depthFunc) {
15711
- case NeverDepth:
15712
- gl.depthFunc(gl.NEVER);
15713
- break;
15846
+ switch (depthFunc) {
15847
+ case NeverDepth:
15848
+ gl.depthFunc(gl.NEVER);
15849
+ break;
15714
15850
 
15715
- case AlwaysDepth:
15716
- gl.depthFunc(gl.ALWAYS);
15717
- break;
15851
+ case AlwaysDepth:
15852
+ gl.depthFunc(gl.ALWAYS);
15853
+ break;
15718
15854
 
15719
- case LessDepth:
15720
- gl.depthFunc(gl.LESS);
15721
- break;
15855
+ case LessDepth:
15856
+ gl.depthFunc(gl.LESS);
15857
+ break;
15722
15858
 
15723
- case LessEqualDepth:
15724
- gl.depthFunc(gl.LEQUAL);
15725
- break;
15859
+ case LessEqualDepth:
15860
+ gl.depthFunc(gl.LEQUAL);
15861
+ break;
15726
15862
 
15727
- case EqualDepth:
15728
- gl.depthFunc(gl.EQUAL);
15729
- break;
15863
+ case EqualDepth:
15864
+ gl.depthFunc(gl.EQUAL);
15865
+ break;
15730
15866
 
15731
- case GreaterEqualDepth:
15732
- gl.depthFunc(gl.GEQUAL);
15733
- break;
15867
+ case GreaterEqualDepth:
15868
+ gl.depthFunc(gl.GEQUAL);
15869
+ break;
15734
15870
 
15735
- case GreaterDepth:
15736
- gl.depthFunc(gl.GREATER);
15737
- break;
15871
+ case GreaterDepth:
15872
+ gl.depthFunc(gl.GREATER);
15873
+ break;
15738
15874
 
15739
- case NotEqualDepth:
15740
- gl.depthFunc(gl.NOTEQUAL);
15741
- break;
15875
+ case NotEqualDepth:
15876
+ gl.depthFunc(gl.NOTEQUAL);
15877
+ break;
15742
15878
 
15743
- default:
15744
- gl.depthFunc(gl.LEQUAL);
15745
- }
15746
- } else {
15747
- gl.depthFunc(gl.LEQUAL);
15879
+ default:
15880
+ gl.depthFunc(gl.LEQUAL);
15748
15881
  }
15749
15882
 
15750
15883
  currentDepthFunc = depthFunc;
@@ -16130,7 +16263,7 @@ function WebGLState(gl, extensions, capabilities) {
16130
16263
  }
16131
16264
 
16132
16265
  currentBlending = blending;
16133
- currentPremultipledAlpha = null;
16266
+ currentPremultipledAlpha = false;
16134
16267
  }
16135
16268
 
16136
16269
  function setMaterial(material, frontFaceCW) {
@@ -16228,22 +16361,31 @@ function WebGLState(gl, extensions, capabilities) {
16228
16361
  }
16229
16362
  }
16230
16363
 
16231
- function bindTexture(webglType, webglTexture) {
16232
- if (currentTextureSlot === null) {
16233
- activeTexture();
16364
+ function bindTexture(webglType, webglTexture, webglSlot) {
16365
+ if (webglSlot === undefined) {
16366
+ if (currentTextureSlot === null) {
16367
+ webglSlot = gl.TEXTURE0 + maxTextures - 1;
16368
+ } else {
16369
+ webglSlot = currentTextureSlot;
16370
+ }
16234
16371
  }
16235
16372
 
16236
- let boundTexture = currentBoundTextures[currentTextureSlot];
16373
+ let boundTexture = currentBoundTextures[webglSlot];
16237
16374
 
16238
16375
  if (boundTexture === undefined) {
16239
16376
  boundTexture = {
16240
16377
  type: undefined,
16241
16378
  texture: undefined
16242
16379
  };
16243
- currentBoundTextures[currentTextureSlot] = boundTexture;
16380
+ currentBoundTextures[webglSlot] = boundTexture;
16244
16381
  }
16245
16382
 
16246
16383
  if (boundTexture.type !== webglType || boundTexture.texture !== webglTexture) {
16384
+ if (currentTextureSlot !== webglSlot) {
16385
+ gl.activeTexture(webglSlot);
16386
+ currentTextureSlot = webglSlot;
16387
+ }
16388
+
16247
16389
  gl.bindTexture(webglType, webglTexture || emptyTextures[webglType]);
16248
16390
  boundTexture.type = webglType;
16249
16391
  boundTexture.texture = webglTexture;
@@ -16268,6 +16410,14 @@ function WebGLState(gl, extensions, capabilities) {
16268
16410
  }
16269
16411
  }
16270
16412
 
16413
+ function compressedTexImage3D() {
16414
+ try {
16415
+ gl.compressedTexImage3D.apply(gl, arguments);
16416
+ } catch (error) {
16417
+ console.error('THREE.WebGLState:', error);
16418
+ }
16419
+ }
16420
+
16271
16421
  function texSubImage2D() {
16272
16422
  try {
16273
16423
  gl.texSubImage2D.apply(gl, arguments);
@@ -16292,6 +16442,14 @@ function WebGLState(gl, extensions, capabilities) {
16292
16442
  }
16293
16443
  }
16294
16444
 
16445
+ function compressedTexSubImage3D() {
16446
+ try {
16447
+ gl.compressedTexSubImage3D.apply(gl, arguments);
16448
+ } catch (error) {
16449
+ console.error('THREE.WebGLState:', error);
16450
+ }
16451
+ }
16452
+
16295
16453
  function texStorage2D() {
16296
16454
  try {
16297
16455
  gl.texStorage2D.apply(gl, arguments);
@@ -16454,6 +16612,7 @@ function WebGLState(gl, extensions, capabilities) {
16454
16612
  bindTexture: bindTexture,
16455
16613
  unbindTexture: unbindTexture,
16456
16614
  compressedTexImage2D: compressedTexImage2D,
16615
+ compressedTexImage3D: compressedTexImage3D,
16457
16616
  texImage2D: texImage2D,
16458
16617
  texImage3D: texImage3D,
16459
16618
  updateUBOMapping: updateUBOMapping,
@@ -16463,6 +16622,7 @@ function WebGLState(gl, extensions, capabilities) {
16463
16622
  texSubImage2D: texSubImage2D,
16464
16623
  texSubImage3D: texSubImage3D,
16465
16624
  compressedTexSubImage2D: compressedTexSubImage2D,
16625
+ compressedTexSubImage3D: compressedTexSubImage3D,
16466
16626
  scissor: scissor,
16467
16627
  viewport: viewport,
16468
16628
  reset: reset
@@ -16476,7 +16636,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
16476
16636
  const maxTextureSize = capabilities.maxTextureSize;
16477
16637
  const maxSamples = capabilities.maxSamples;
16478
16638
  const multisampledRTTExt = extensions.has('WEBGL_multisampled_render_to_texture') ? extensions.get('WEBGL_multisampled_render_to_texture') : null;
16479
- const supportsInvalidateFramebuffer = /OculusBrowser/g.test(navigator.userAgent);
16639
+ const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test(navigator.userAgent);
16480
16640
 
16481
16641
  const _videoTextures = new WeakMap();
16482
16642
 
@@ -16554,7 +16714,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
16554
16714
  _gl.generateMipmap(target);
16555
16715
  }
16556
16716
 
16557
- function getInternalFormat(internalFormatName, glFormat, glType, encoding, isVideoTexture = false) {
16717
+ function getInternalFormat(internalFormatName, glFormat, glType, encoding, forceLinearEncoding = false) {
16558
16718
  if (isWebGL2 === false) return glFormat;
16559
16719
 
16560
16720
  if (internalFormatName !== null) {
@@ -16579,7 +16739,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
16579
16739
  if (glFormat === _gl.RGBA) {
16580
16740
  if (glType === _gl.FLOAT) internalFormat = _gl.RGBA32F;
16581
16741
  if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F;
16582
- if (glType === _gl.UNSIGNED_BYTE) internalFormat = encoding === sRGBEncoding && isVideoTexture === false ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
16742
+ if (glType === _gl.UNSIGNED_BYTE) internalFormat = encoding === sRGBEncoding && forceLinearEncoding === false ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
16583
16743
  if (glType === _gl.UNSIGNED_SHORT_4_4_4_4) internalFormat = _gl.RGBA4;
16584
16744
  if (glType === _gl.UNSIGNED_SHORT_5_5_5_1) internalFormat = _gl.RGB5_A1;
16585
16745
  }
@@ -16746,6 +16906,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
16746
16906
  const array = [];
16747
16907
  array.push(texture.wrapS);
16748
16908
  array.push(texture.wrapT);
16909
+ array.push(texture.wrapR || 0);
16749
16910
  array.push(texture.magFilter);
16750
16911
  array.push(texture.minFilter);
16751
16912
  array.push(texture.anisotropy);
@@ -16778,8 +16939,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
16778
16939
  }
16779
16940
  }
16780
16941
 
16781
- state.activeTexture(_gl.TEXTURE0 + slot);
16782
- state.bindTexture(_gl.TEXTURE_2D, textureProperties.__webglTexture);
16942
+ state.bindTexture(_gl.TEXTURE_2D, textureProperties.__webglTexture, _gl.TEXTURE0 + slot);
16783
16943
  }
16784
16944
 
16785
16945
  function setTexture2DArray(texture, slot) {
@@ -16790,8 +16950,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
16790
16950
  return;
16791
16951
  }
16792
16952
 
16793
- state.activeTexture(_gl.TEXTURE0 + slot);
16794
- state.bindTexture(_gl.TEXTURE_2D_ARRAY, textureProperties.__webglTexture);
16953
+ state.bindTexture(_gl.TEXTURE_2D_ARRAY, textureProperties.__webglTexture, _gl.TEXTURE0 + slot);
16795
16954
  }
16796
16955
 
16797
16956
  function setTexture3D(texture, slot) {
@@ -16802,8 +16961,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
16802
16961
  return;
16803
16962
  }
16804
16963
 
16805
- state.activeTexture(_gl.TEXTURE0 + slot);
16806
- state.bindTexture(_gl.TEXTURE_3D, textureProperties.__webglTexture);
16964
+ state.bindTexture(_gl.TEXTURE_3D, textureProperties.__webglTexture, _gl.TEXTURE0 + slot);
16807
16965
  }
16808
16966
 
16809
16967
  function setTextureCube(texture, slot) {
@@ -16814,8 +16972,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
16814
16972
  return;
16815
16973
  }
16816
16974
 
16817
- state.activeTexture(_gl.TEXTURE0 + slot);
16818
- state.bindTexture(_gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture);
16975
+ state.bindTexture(_gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture, _gl.TEXTURE0 + slot);
16819
16976
  }
16820
16977
 
16821
16978
  const wrappingToGL = {
@@ -16940,14 +17097,16 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
16940
17097
 
16941
17098
  function uploadTexture(textureProperties, texture, slot) {
16942
17099
  let textureType = _gl.TEXTURE_2D;
16943
- if (texture.isDataArrayTexture) textureType = _gl.TEXTURE_2D_ARRAY;
17100
+ if (texture.isDataArrayTexture || texture.isCompressedArrayTexture) textureType = _gl.TEXTURE_2D_ARRAY;
16944
17101
  if (texture.isData3DTexture) textureType = _gl.TEXTURE_3D;
16945
17102
  const forceUpload = initTexture(textureProperties, texture);
16946
17103
  const source = texture.source;
16947
- state.activeTexture(_gl.TEXTURE0 + slot);
16948
- state.bindTexture(textureType, textureProperties.__webglTexture);
17104
+ state.bindTexture(textureType, textureProperties.__webglTexture, _gl.TEXTURE0 + slot);
17105
+ const sourceProperties = properties.get(source);
17106
+
17107
+ if (source.version !== sourceProperties.__version || forceUpload === true) {
17108
+ state.activeTexture(_gl.TEXTURE0 + slot);
16949
17109
 
16950
- if (source.version !== source.__currentVersion || forceUpload === true) {
16951
17110
  _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
16952
17111
 
16953
17112
  _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
@@ -16967,7 +17126,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
16967
17126
  let mipmap;
16968
17127
  const mipmaps = texture.mipmaps;
16969
17128
  const useTexStorage = isWebGL2 && texture.isVideoTexture !== true;
16970
- const allocateMemory = source.__currentVersion === undefined || forceUpload === true;
17129
+ const allocateMemory = sourceProperties.__version === undefined || forceUpload === true;
16971
17130
  const levels = getMipLevels(texture, image, supportsMips);
16972
17131
 
16973
17132
  if (texture.isDepthTexture) {
@@ -17056,28 +17215,56 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
17056
17215
  }
17057
17216
  }
17058
17217
  } else if (texture.isCompressedTexture) {
17059
- if (useTexStorage && allocateMemory) {
17060
- state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
17061
- }
17218
+ if (texture.isCompressedArrayTexture) {
17219
+ if (useTexStorage && allocateMemory) {
17220
+ state.texStorage3D(_gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height, image.depth);
17221
+ }
17062
17222
 
17063
- for (let i = 0, il = mipmaps.length; i < il; i++) {
17064
- mipmap = mipmaps[i];
17223
+ for (let i = 0, il = mipmaps.length; i < il; i++) {
17224
+ mipmap = mipmaps[i];
17065
17225
 
17066
- if (texture.format !== RGBAFormat) {
17067
- if (glFormat !== null) {
17068
- if (useTexStorage) {
17069
- state.compressedTexSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data);
17226
+ if (texture.format !== RGBAFormat) {
17227
+ if (glFormat !== null) {
17228
+ if (useTexStorage) {
17229
+ state.compressedTexSubImage3D(_gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0);
17230
+ } else {
17231
+ state.compressedTexImage3D(_gl.TEXTURE_2D_ARRAY, i, glInternalFormat, mipmap.width, mipmap.height, image.depth, 0, mipmap.data, 0, 0);
17232
+ }
17070
17233
  } else {
17071
- state.compressedTexImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
17234
+ console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()');
17072
17235
  }
17073
17236
  } else {
17074
- console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()');
17237
+ if (useTexStorage) {
17238
+ state.texSubImage3D(_gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, glType, mipmap.data);
17239
+ } else {
17240
+ state.texImage3D(_gl.TEXTURE_2D_ARRAY, i, glInternalFormat, mipmap.width, mipmap.height, image.depth, 0, glFormat, glType, mipmap.data);
17241
+ }
17075
17242
  }
17076
- } else {
17077
- if (useTexStorage) {
17078
- state.texSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);
17243
+ }
17244
+ } else {
17245
+ if (useTexStorage && allocateMemory) {
17246
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
17247
+ }
17248
+
17249
+ for (let i = 0, il = mipmaps.length; i < il; i++) {
17250
+ mipmap = mipmaps[i];
17251
+
17252
+ if (texture.format !== RGBAFormat) {
17253
+ if (glFormat !== null) {
17254
+ if (useTexStorage) {
17255
+ state.compressedTexSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data);
17256
+ } else {
17257
+ state.compressedTexImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
17258
+ }
17259
+ } else {
17260
+ console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()');
17261
+ }
17079
17262
  } else {
17080
- state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
17263
+ if (useTexStorage) {
17264
+ state.texSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);
17265
+ } else {
17266
+ state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
17267
+ }
17081
17268
  }
17082
17269
  }
17083
17270
  }
@@ -17154,7 +17341,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
17154
17341
  generateMipmap(textureType);
17155
17342
  }
17156
17343
 
17157
- source.__currentVersion = source.version;
17344
+ sourceProperties.__version = source.version;
17158
17345
  if (texture.onUpdate) texture.onUpdate(texture);
17159
17346
  }
17160
17347
 
@@ -17165,10 +17352,12 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
17165
17352
  if (texture.image.length !== 6) return;
17166
17353
  const forceUpload = initTexture(textureProperties, texture);
17167
17354
  const source = texture.source;
17168
- state.activeTexture(_gl.TEXTURE0 + slot);
17169
- state.bindTexture(_gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture);
17355
+ state.bindTexture(_gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture, _gl.TEXTURE0 + slot);
17356
+ const sourceProperties = properties.get(source);
17357
+
17358
+ if (source.version !== sourceProperties.__version || forceUpload === true) {
17359
+ state.activeTexture(_gl.TEXTURE0 + slot);
17170
17360
 
17171
- if (source.version !== source.__currentVersion || forceUpload === true) {
17172
17361
  _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
17173
17362
 
17174
17363
  _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
@@ -17197,7 +17386,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
17197
17386
  glType = utils.convert(texture.type),
17198
17387
  glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
17199
17388
  const useTexStorage = isWebGL2 && texture.isVideoTexture !== true;
17200
- const allocateMemory = source.__currentVersion === undefined || forceUpload === true;
17389
+ const allocateMemory = sourceProperties.__version === undefined || forceUpload === true;
17201
17390
  let levels = getMipLevels(texture, image, supportsMips);
17202
17391
  setTextureParameters(_gl.TEXTURE_CUBE_MAP, texture, supportsMips);
17203
17392
  let mipmaps;
@@ -17286,7 +17475,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
17286
17475
  generateMipmap(_gl.TEXTURE_CUBE_MAP);
17287
17476
  }
17288
17477
 
17289
- source.__currentVersion = source.version;
17478
+ sourceProperties.__version = source.version;
17290
17479
  if (texture.onUpdate) texture.onUpdate(texture);
17291
17480
  }
17292
17481
 
@@ -17313,7 +17502,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
17313
17502
 
17314
17503
  if (useMultisampledRTT(renderTarget)) {
17315
17504
  multisampledRTTExt.framebufferTexture2DMultisampleEXT(_gl.FRAMEBUFFER, attachment, textureTarget, properties.get(texture).__webglTexture, 0, getRenderTargetSamples(renderTarget));
17316
- } else {
17505
+ } else if (textureTarget === _gl.TEXTURE_2D || textureTarget >= _gl.TEXTURE_CUBE_MAP_POSITIVE_X && textureTarget <= _gl.TEXTURE_CUBE_MAP_NEGATIVE_Z) {
17506
+ // see #24753
17317
17507
  _gl.framebufferTexture2D(_gl.FRAMEBUFFER, attachment, textureTarget, properties.get(texture).__webglTexture, 0);
17318
17508
  }
17319
17509
 
@@ -17525,7 +17715,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
17525
17715
 
17526
17716
  const glFormat = utils.convert(texture.format, texture.encoding);
17527
17717
  const glType = utils.convert(texture.type);
17528
- const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
17718
+ const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, renderTarget.isXRRenderTarget === true);
17529
17719
  const samples = getRenderTargetSamples(renderTarget);
17530
17720
 
17531
17721
  _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
@@ -17805,8 +17995,7 @@ function WebGLUtils(gl, extensions, capabilities) {
17805
17995
  if (p === LuminanceFormat) return gl.LUMINANCE;
17806
17996
  if (p === LuminanceAlphaFormat) return gl.LUMINANCE_ALPHA;
17807
17997
  if (p === DepthFormat) return gl.DEPTH_COMPONENT;
17808
- if (p === DepthStencilFormat) return gl.DEPTH_STENCIL;
17809
- if (p === RedFormat) return gl.RED; // @deprecated since r137
17998
+ if (p === DepthStencilFormat) return gl.DEPTH_STENCIL; // @deprecated since r137
17810
17999
 
17811
18000
  if (p === RGBFormat) {
17812
18001
  console.warn('THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228');
@@ -17825,6 +18014,7 @@ function WebGLUtils(gl, extensions, capabilities) {
17825
18014
  } // WebGL2 formats.
17826
18015
 
17827
18016
 
18017
+ if (p === RedFormat) return gl.RED;
17828
18018
  if (p === RedIntegerFormat) return gl.RED_INTEGER;
17829
18019
  if (p === RGFormat) return gl.RG;
17830
18020
  if (p === RGIntegerFormat) return gl.RG_INTEGER;
@@ -18417,6 +18607,25 @@ class WebXRController {
18417
18607
  return this;
18418
18608
  }
18419
18609
 
18610
+ connect(inputSource) {
18611
+ if (inputSource && inputSource.hand) {
18612
+ const hand = this._hand;
18613
+
18614
+ if (hand) {
18615
+ for (const inputjoint of inputSource.hand.values()) {
18616
+ // Initialize hand with joints when connected
18617
+ this._getHandJoint(hand, inputjoint);
18618
+ }
18619
+ }
18620
+ }
18621
+
18622
+ this.dispatchEvent({
18623
+ type: 'connected',
18624
+ data: inputSource
18625
+ });
18626
+ return this;
18627
+ }
18628
+
18420
18629
  disconnect(inputSource) {
18421
18630
  this.dispatchEvent({
18422
18631
  type: 'disconnected',
@@ -18452,19 +18661,9 @@ class WebXRController {
18452
18661
 
18453
18662
  for (const inputjoint of inputSource.hand.values()) {
18454
18663
  // Update the joints groups with the XRJoint poses
18455
- const jointPose = frame.getJointPose(inputjoint, referenceSpace);
18664
+ const jointPose = frame.getJointPose(inputjoint, referenceSpace); // The transform of this joint will be updated with the joint pose on each frame
18456
18665
 
18457
- if (hand.joints[inputjoint.jointName] === undefined) {
18458
- // The transform of this joint will be updated with the joint pose on each frame
18459
- const joint = new Group();
18460
- joint.matrixAutoUpdate = false;
18461
- joint.visible = false;
18462
- hand.joints[inputjoint.jointName] = joint; // ??
18463
-
18464
- hand.add(joint);
18465
- }
18466
-
18467
- const joint = hand.joints[inputjoint.jointName];
18666
+ const joint = this._getHandJoint(hand, inputjoint);
18468
18667
 
18469
18668
  if (jointPose !== null) {
18470
18669
  joint.matrix.fromArray(jointPose.transform.matrix);
@@ -18566,6 +18765,19 @@ class WebXRController {
18566
18765
  }
18567
18766
 
18568
18767
  return this;
18768
+ } // private method
18769
+
18770
+
18771
+ _getHandJoint(hand, inputjoint) {
18772
+ if (hand.joints[inputjoint.jointName] === undefined) {
18773
+ const joint = new Group();
18774
+ joint.matrixAutoUpdate = false;
18775
+ joint.visible = false;
18776
+ hand.joints[inputjoint.jointName] = joint;
18777
+ hand.add(joint);
18778
+ }
18779
+
18780
+ return hand.joints[inputjoint.jointName];
18569
18781
  }
18570
18782
 
18571
18783
  }
@@ -18614,7 +18826,9 @@ class WebXRManager extends EventDispatcher {
18614
18826
  let initialRenderTarget = null;
18615
18827
  let newRenderTarget = null;
18616
18828
  const controllers = [];
18617
- const controllerInputSources = []; //
18829
+ const controllerInputSources = [];
18830
+ const planes = new Set();
18831
+ const planesLastChangedTimes = new Map(); //
18618
18832
 
18619
18833
  const cameraL = new PerspectiveCamera();
18620
18834
  cameraL.layers.enable(1);
@@ -18857,11 +19071,12 @@ class WebXRManager extends EventDispatcher {
18857
19071
  };
18858
19072
 
18859
19073
  this.removeLayer = function (layer) {
19074
+ layers.splice(layers.indexOf(layer), 1);
19075
+
18860
19076
  if (!window.XRWebGLBinding || !this.layersEnabled || !session) {
18861
19077
  return;
18862
19078
  }
18863
19079
 
18864
- layers.splice(layers.indexOf(layer), 1);
18865
19080
  this.updateLayers();
18866
19081
  };
18867
19082
 
@@ -18883,10 +19098,7 @@ class WebXRManager extends EventDispatcher {
18883
19098
 
18884
19099
  if (index >= 0) {
18885
19100
  controllerInputSources[index] = null;
18886
- controllers[index].dispatchEvent({
18887
- type: 'disconnected',
18888
- data: inputSource
18889
- });
19101
+ controllers[index].disconnect(inputSource);
18890
19102
  }
18891
19103
  } // Notify connected
18892
19104
 
@@ -18916,10 +19128,7 @@ class WebXRManager extends EventDispatcher {
18916
19128
  const controller = controllers[controllerIndex];
18917
19129
 
18918
19130
  if (controller) {
18919
- controller.dispatchEvent({
18920
- type: 'connected',
18921
- data: inputSource
18922
- });
19131
+ controller.connect(inputSource);
18923
19132
  }
18924
19133
  }
18925
19134
  } //
@@ -19057,6 +19266,10 @@ class WebXRManager extends EventDispatcher {
19057
19266
  if (glBaseLayer !== null && glBaseLayer.fixedFoveation !== undefined) {
19058
19267
  glBaseLayer.fixedFoveation = foveation;
19059
19268
  }
19269
+ };
19270
+
19271
+ this.getPlanes = function () {
19272
+ return planes;
19060
19273
  }; // Animation Loop
19061
19274
 
19062
19275
 
@@ -19131,6 +19344,57 @@ class WebXRManager extends EventDispatcher {
19131
19344
  }
19132
19345
 
19133
19346
  if (onAnimationFrameCallback) onAnimationFrameCallback(time, frame);
19347
+
19348
+ if (frame.detectedPlanes) {
19349
+ scope.dispatchEvent({
19350
+ type: 'planesdetected',
19351
+ data: frame.detectedPlanes
19352
+ });
19353
+ let planesToRemove = null;
19354
+
19355
+ for (const plane of planes) {
19356
+ if (!frame.detectedPlanes.has(plane)) {
19357
+ if (planesToRemove === null) {
19358
+ planesToRemove = [];
19359
+ }
19360
+
19361
+ planesToRemove.push(plane);
19362
+ }
19363
+ }
19364
+
19365
+ if (planesToRemove !== null) {
19366
+ for (const plane of planesToRemove) {
19367
+ planes.delete(plane);
19368
+ planesLastChangedTimes.delete(plane);
19369
+ scope.dispatchEvent({
19370
+ type: 'planeremoved',
19371
+ data: plane
19372
+ });
19373
+ }
19374
+ }
19375
+
19376
+ for (const plane of frame.detectedPlanes) {
19377
+ if (!planes.has(plane)) {
19378
+ planes.add(plane);
19379
+ planesLastChangedTimes.set(plane, frame.lastChangedTime);
19380
+ scope.dispatchEvent({
19381
+ type: 'planeadded',
19382
+ data: plane
19383
+ });
19384
+ } else {
19385
+ const lastKnownTime = planesLastChangedTimes.get(plane);
19386
+
19387
+ if (plane.lastChangedTime > lastKnownTime) {
19388
+ planesLastChangedTimes.set(plane, plane.lastChangedTime);
19389
+ scope.dispatchEvent({
19390
+ type: 'planechanged',
19391
+ data: plane
19392
+ });
19393
+ }
19394
+ }
19395
+ }
19396
+ }
19397
+
19134
19398
  xrFrame = null;
19135
19399
  }
19136
19400
 
@@ -19148,7 +19412,7 @@ class WebXRManager extends EventDispatcher {
19148
19412
 
19149
19413
  function WebGLMaterials(renderer, properties) {
19150
19414
  function refreshFogUniforms(uniforms, fog) {
19151
- uniforms.fogColor.value.copy(fog.color);
19415
+ fog.color.getRGB(uniforms.fogColor.value, getUnlitUniformColorSpace(renderer));
19152
19416
 
19153
19417
  if (fog.isFog) {
19154
19418
  uniforms.fogNear.value = fog.near;
@@ -19897,20 +20161,7 @@ function WebGLRenderer(parameters = {}) {
19897
20161
  this.physicallyCorrectLights = false; // tone mapping
19898
20162
 
19899
20163
  this.toneMapping = NoToneMapping;
19900
- this.toneMappingExposure = 1.0; //
19901
-
19902
- Object.defineProperties(this, {
19903
- // @deprecated since r136, 0e21088102b4de7e0a0a33140620b7a3424b9e6d
19904
- gammaFactor: {
19905
- get: function () {
19906
- console.warn('THREE.WebGLRenderer: .gammaFactor has been removed.');
19907
- return 2;
19908
- },
19909
- set: function () {
19910
- console.warn('THREE.WebGLRenderer: .gammaFactor has been removed.');
19911
- }
19912
- }
19913
- }); // internal properties
20164
+ this.toneMappingExposure = 1.0; // internal properties
19914
20165
 
19915
20166
  const _this = this;
19916
20167
 
@@ -20063,7 +20314,7 @@ function WebGLRenderer(parameters = {}) {
20063
20314
  materials = new WebGLMaterials(_this, properties);
20064
20315
  renderLists = new WebGLRenderLists();
20065
20316
  renderStates = new WebGLRenderStates(extensions, capabilities);
20066
- background = new WebGLBackground(_this, cubemaps, state, objects, _alpha, _premultipliedAlpha);
20317
+ background = new WebGLBackground(_this, cubemaps, cubeuvmaps, state, objects, _alpha, _premultipliedAlpha);
20067
20318
  shadowMap = new WebGLShadowMap(_this, objects, capabilities);
20068
20319
  uniformsGroups = new WebGLUniformsGroups(_gl, info, capabilities, state);
20069
20320
  bufferRenderer = new WebGLBufferRenderer(_gl, extensions, info, capabilities);
@@ -20326,22 +20577,35 @@ function WebGLRenderer(parameters = {}) {
20326
20577
  state.setMaterial(material, frontFaceCW); //
20327
20578
 
20328
20579
  let index = geometry.index;
20329
- const position = geometry.attributes.position; //
20330
-
20331
- if (index === null) {
20332
- if (position === undefined || position.count === 0) return;
20333
- } else if (index.count === 0) {
20334
- return;
20335
- } //
20336
-
20337
-
20338
20580
  let rangeFactor = 1;
20339
20581
 
20340
20582
  if (material.wireframe === true) {
20341
20583
  index = geometries.getWireframeAttribute(geometry);
20342
20584
  rangeFactor = 2;
20585
+ } //
20586
+
20587
+
20588
+ const drawRange = geometry.drawRange;
20589
+ const position = geometry.attributes.position;
20590
+ let drawStart = drawRange.start * rangeFactor;
20591
+ let drawEnd = (drawRange.start + drawRange.count) * rangeFactor;
20592
+
20593
+ if (group !== null) {
20594
+ drawStart = Math.max(drawStart, group.start * rangeFactor);
20595
+ drawEnd = Math.min(drawEnd, (group.start + group.count) * rangeFactor);
20343
20596
  }
20344
20597
 
20598
+ if (index !== null) {
20599
+ drawStart = Math.max(drawStart, 0);
20600
+ drawEnd = Math.min(drawEnd, index.count);
20601
+ } else if (position !== undefined && position !== null) {
20602
+ drawStart = Math.max(drawStart, 0);
20603
+ drawEnd = Math.min(drawEnd, position.count);
20604
+ }
20605
+
20606
+ const drawCount = drawEnd - drawStart;
20607
+ if (drawCount < 0 || drawCount === Infinity) return; //
20608
+
20345
20609
  bindingStates.setup(object, material, program, geometry, index);
20346
20610
  let attribute;
20347
20611
  let renderer = bufferRenderer;
@@ -20353,16 +20617,6 @@ function WebGLRenderer(parameters = {}) {
20353
20617
  } //
20354
20618
 
20355
20619
 
20356
- const dataCount = index !== null ? index.count : position.count;
20357
- const rangeStart = geometry.drawRange.start * rangeFactor;
20358
- const rangeCount = geometry.drawRange.count * rangeFactor;
20359
- const groupStart = group !== null ? group.start * rangeFactor : 0;
20360
- const groupCount = group !== null ? group.count * rangeFactor : Infinity;
20361
- const drawStart = Math.max(rangeStart, groupStart);
20362
- const drawEnd = Math.min(dataCount, rangeStart + rangeCount, groupStart + groupCount) - 1;
20363
- const drawCount = Math.max(0, drawEnd - drawStart + 1);
20364
- if (drawCount === 0) return; //
20365
-
20366
20620
  if (object.isMesh) {
20367
20621
  if (material.wireframe === true) {
20368
20622
  state.setLineWidth(material.wireframeLinewidth * getTargetPixelRatio());
@@ -20392,7 +20646,8 @@ function WebGLRenderer(parameters = {}) {
20392
20646
  if (object.isInstancedMesh) {
20393
20647
  renderer.renderInstances(drawStart, drawCount, object.count);
20394
20648
  } else if (geometry.isInstancedBufferGeometry) {
20395
- const instanceCount = Math.min(geometry.instanceCount, geometry._maxInstanceCount);
20649
+ const maxInstanceCount = geometry._maxInstanceCount !== undefined ? geometry._maxInstanceCount : Infinity;
20650
+ const instanceCount = Math.min(geometry.instanceCount, maxInstanceCount);
20396
20651
  renderer.renderInstances(drawStart, drawCount, instanceCount);
20397
20652
  } else {
20398
20653
  renderer.render(drawStart, drawCount);
@@ -21134,6 +21389,9 @@ function WebGLRenderer(parameters = {}) {
21134
21389
  _currentActiveCubeFace = activeCubeFace;
21135
21390
  _currentActiveMipmapLevel = activeMipmapLevel;
21136
21391
  let useDefaultFramebuffer = true;
21392
+ let framebuffer = null;
21393
+ let isCube = false;
21394
+ let isRenderTarget3D = false;
21137
21395
 
21138
21396
  if (renderTarget) {
21139
21397
  const renderTargetProperties = properties.get(renderTarget);
@@ -21148,16 +21406,10 @@ function WebGLRenderer(parameters = {}) {
21148
21406
  // Color and depth texture must be rebound in order for the swapchain to update.
21149
21407
  textures.rebindTextures(renderTarget, properties.get(renderTarget.texture).__webglTexture, properties.get(renderTarget.depthTexture).__webglTexture);
21150
21408
  }
21151
- }
21152
21409
 
21153
- let framebuffer = null;
21154
- let isCube = false;
21155
- let isRenderTarget3D = false;
21156
-
21157
- if (renderTarget) {
21158
21410
  const texture = renderTarget.texture;
21159
21411
 
21160
- if (texture.isData3DTexture || texture.isDataArrayTexture) {
21412
+ if (texture.isData3DTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture) {
21161
21413
  isRenderTarget3D = true;
21162
21414
  }
21163
21415
 
@@ -21350,7 +21602,7 @@ function WebGLRenderer(parameters = {}) {
21350
21602
  if (srcTexture.isDataTexture || srcTexture.isData3DTexture) {
21351
21603
  _gl.texSubImage3D(glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image.data);
21352
21604
  } else {
21353
- if (srcTexture.isCompressedTexture) {
21605
+ if (srcTexture.isCompressedArrayTexture) {
21354
21606
  console.warn('THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.');
21355
21607
 
21356
21608
  _gl.compressedTexSubImage3D(glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data);
@@ -21379,7 +21631,7 @@ function WebGLRenderer(parameters = {}) {
21379
21631
  textures.setTextureCube(texture, 0);
21380
21632
  } else if (texture.isData3DTexture) {
21381
21633
  textures.setTexture3D(texture, 0);
21382
- } else if (texture.isDataArrayTexture) {
21634
+ } else if (texture.isDataArrayTexture || texture.isCompressedArrayTexture) {
21383
21635
  textures.setTexture2DArray(texture, 0);
21384
21636
  } else {
21385
21637
  textures.setTexture2D(texture, 0);
@@ -21461,6 +21713,8 @@ class Scene extends Object3D {
21461
21713
  this.background = null;
21462
21714
  this.environment = null;
21463
21715
  this.fog = null;
21716
+ this.backgroundBlurriness = 0;
21717
+ this.backgroundIntensity = 1;
21464
21718
  this.overrideMaterial = null;
21465
21719
 
21466
21720
  if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
@@ -21475,6 +21729,8 @@ class Scene extends Object3D {
21475
21729
  if (source.background !== null) this.background = source.background.clone();
21476
21730
  if (source.environment !== null) this.environment = source.environment.clone();
21477
21731
  if (source.fog !== null) this.fog = source.fog.clone();
21732
+ this.backgroundBlurriness = source.backgroundBlurriness;
21733
+ this.backgroundIntensity = source.backgroundIntensity;
21478
21734
  if (source.overrideMaterial !== null) this.overrideMaterial = source.overrideMaterial.clone();
21479
21735
  this.matrixAutoUpdate = source.matrixAutoUpdate;
21480
21736
  return this;
@@ -21483,6 +21739,8 @@ class Scene extends Object3D {
21483
21739
  toJSON(meta) {
21484
21740
  const data = super.toJSON(meta);
21485
21741
  if (this.fog !== null) data.object.fog = this.fog.toJSON();
21742
+ if (this.backgroundBlurriness > 0) data.backgroundBlurriness = this.backgroundBlurriness;
21743
+ if (this.backgroundIntensity !== 1) data.backgroundIntensity = this.backgroundIntensity;
21486
21744
  return data;
21487
21745
  } // @deprecated
21488
21746
 
@@ -21753,7 +22011,7 @@ class InterleavedBufferAttribute {
21753
22011
 
21754
22012
  clone(data) {
21755
22013
  if (data === undefined) {
21756
- console.log('THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will deinterleave buffer data.');
22014
+ console.log('THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.');
21757
22015
  const array = [];
21758
22016
 
21759
22017
  for (let i = 0; i < this.count; i++) {
@@ -21780,7 +22038,7 @@ class InterleavedBufferAttribute {
21780
22038
 
21781
22039
  toJSON(data) {
21782
22040
  if (data === undefined) {
21783
- console.log('THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will deinterleave buffer data.');
22041
+ console.log('THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.');
21784
22042
  const array = [];
21785
22043
 
21786
22044
  for (let i = 0; i < this.count; i++) {
@@ -21789,7 +22047,7 @@ class InterleavedBufferAttribute {
21789
22047
  for (let j = 0; j < this.itemSize; j++) {
21790
22048
  array.push(this.data.array[index + j]);
21791
22049
  }
21792
- } // deinterleave data and save it as an ordinary buffer attribute for now
22050
+ } // de-interleave data and save it as an ordinary buffer attribute for now
21793
22051
 
21794
22052
 
21795
22053
  return {
@@ -21799,7 +22057,7 @@ class InterleavedBufferAttribute {
21799
22057
  normalized: this.normalized
21800
22058
  };
21801
22059
  } else {
21802
- // save as true interleaved attribtue
22060
+ // save as true interleaved attribute
21803
22061
  if (data.interleavedBuffers === undefined) {
21804
22062
  data.interleavedBuffers = {};
21805
22063
  }
@@ -22015,14 +22273,14 @@ class LOD extends Object3D {
22015
22273
 
22016
22274
  for (let i = 0, l = levels.length; i < l; i++) {
22017
22275
  const level = levels[i];
22018
- this.addLevel(level.object.clone(), level.distance);
22276
+ this.addLevel(level.object.clone(), level.distance, level.hysteresis);
22019
22277
  }
22020
22278
 
22021
22279
  this.autoUpdate = source.autoUpdate;
22022
22280
  return this;
22023
22281
  }
22024
22282
 
22025
- addLevel(object, distance = 0) {
22283
+ addLevel(object, distance = 0, hysteresis = 0) {
22026
22284
  distance = Math.abs(distance);
22027
22285
  const levels = this.levels;
22028
22286
  let l;
@@ -22035,6 +22293,7 @@ class LOD extends Object3D {
22035
22293
 
22036
22294
  levels.splice(l, 0, {
22037
22295
  distance: distance,
22296
+ hysteresis: hysteresis,
22038
22297
  object: object
22039
22298
  });
22040
22299
  this.add(object);
@@ -22052,7 +22311,13 @@ class LOD extends Object3D {
22052
22311
  let i, l;
22053
22312
 
22054
22313
  for (i = 1, l = levels.length; i < l; i++) {
22055
- if (distance < levels[i].distance) {
22314
+ let levelDistance = levels[i].distance;
22315
+
22316
+ if (levels[i].object.visible) {
22317
+ levelDistance -= levelDistance * levels[i].hysteresis;
22318
+ }
22319
+
22320
+ if (distance < levelDistance) {
22056
22321
  break;
22057
22322
  }
22058
22323
  }
@@ -22087,7 +22352,13 @@ class LOD extends Object3D {
22087
22352
  let i, l;
22088
22353
 
22089
22354
  for (i = 1, l = levels.length; i < l; i++) {
22090
- if (distance >= levels[i].distance) {
22355
+ let levelDistance = levels[i].distance;
22356
+
22357
+ if (levels[i].object.visible) {
22358
+ levelDistance -= levelDistance * levels[i].hysteresis;
22359
+ }
22360
+
22361
+ if (distance >= levelDistance) {
22091
22362
  levels[i - 1].object.visible = false;
22092
22363
  levels[i].object.visible = true;
22093
22364
  } else {
@@ -22113,7 +22384,8 @@ class LOD extends Object3D {
22113
22384
  const level = levels[i];
22114
22385
  data.object.levels.push({
22115
22386
  object: level.object.uuid,
22116
- distance: level.distance
22387
+ distance: level.distance,
22388
+ hysteresis: level.hysteresis
22117
22389
  });
22118
22390
  }
22119
22391
 
@@ -22469,6 +22741,8 @@ const _instanceWorldMatrix = /*@__PURE__*/new Matrix4();
22469
22741
 
22470
22742
  const _instanceIntersects = [];
22471
22743
 
22744
+ const _identity = /*@__PURE__*/new Matrix4();
22745
+
22472
22746
  const _mesh = /*@__PURE__*/new Mesh();
22473
22747
 
22474
22748
  class InstancedMesh extends Mesh {
@@ -22479,6 +22753,10 @@ class InstancedMesh extends Mesh {
22479
22753
  this.instanceColor = null;
22480
22754
  this.count = count;
22481
22755
  this.frustumCulled = false;
22756
+
22757
+ for (let i = 0; i < count; i++) {
22758
+ this.setMatrixAt(i, _identity);
22759
+ }
22482
22760
  }
22483
22761
 
22484
22762
  copy(source, recursive) {
@@ -22995,6 +23273,16 @@ class CompressedTexture extends Texture {
22995
23273
 
22996
23274
  }
22997
23275
 
23276
+ class CompressedArrayTexture extends CompressedTexture {
23277
+ constructor(mipmaps, width, height, depth, format, type) {
23278
+ super(mipmaps, width, height, format, type);
23279
+ this.isCompressedArrayTexture = true;
23280
+ this.image.depth = depth;
23281
+ this.wrapR = ClampToEdgeWrapping;
23282
+ }
23283
+
23284
+ }
23285
+
22998
23286
  class CanvasTexture extends Texture {
22999
23287
  constructor(canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy) {
23000
23288
  super(canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);
@@ -24714,7 +25002,7 @@ class PolyhedronGeometry extends BufferGeometry {
24714
25002
  function subdivide(detail) {
24715
25003
  const a = new Vector3();
24716
25004
  const b = new Vector3();
24717
- const c = new Vector3(); // iterate over all faces and apply a subdivison with the given detail value
25005
+ const c = new Vector3(); // iterate over all faces and apply a subdivision with the given detail value
24718
25006
 
24719
25007
  for (let i = 0; i < indices.length; i += 3) {
24720
25008
  // get the vertices of the face
@@ -25080,7 +25368,7 @@ class Shape extends Path {
25080
25368
  }
25081
25369
 
25082
25370
  /**
25083
- * Port from https://github.com/mapbox/earcut (v2.2.2)
25371
+ * Port from https://github.com/mapbox/earcut (v2.2.4)
25084
25372
  */
25085
25373
  const Earcut = {
25086
25374
  triangulate: function (data, holeIndices, dim = 2) {
@@ -25107,10 +25395,10 @@ const Earcut = {
25107
25395
 
25108
25396
 
25109
25397
  invSize = Math.max(maxX - minX, maxY - minY);
25110
- invSize = invSize !== 0 ? 1 / invSize : 0;
25398
+ invSize = invSize !== 0 ? 32767 / invSize : 0;
25111
25399
  }
25112
25400
 
25113
- earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
25401
+ earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
25114
25402
  return triangles;
25115
25403
  }
25116
25404
  }; // create a circular doubly linked list from polygon points in the specified winding order
@@ -25170,9 +25458,9 @@ function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
25170
25458
 
25171
25459
  if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
25172
25460
  // cut off the triangle
25173
- triangles.push(prev.i / dim);
25174
- triangles.push(ear.i / dim);
25175
- triangles.push(next.i / dim);
25461
+ triangles.push(prev.i / dim | 0);
25462
+ triangles.push(ear.i / dim | 0);
25463
+ triangles.push(next.i / dim | 0);
25176
25464
  removeNode(ear); // skipping the next vertex leads to less sliver triangles
25177
25465
 
25178
25466
  ear = next.next;
@@ -25206,10 +25494,21 @@ function isEar(ear) {
25206
25494
  if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
25207
25495
  // now make sure we don't have other points inside the potential ear
25208
25496
 
25209
- let p = ear.next.next;
25210
-
25211
- while (p !== ear.prev) {
25212
- if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
25497
+ const ax = a.x,
25498
+ bx = b.x,
25499
+ cx = c.x,
25500
+ ay = a.y,
25501
+ by = b.y,
25502
+ cy = c.y; // triangle bbox; min & max are calculated like this for speed
25503
+
25504
+ const x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx,
25505
+ y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy,
25506
+ x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx,
25507
+ y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
25508
+ let p = c.next;
25509
+
25510
+ while (p !== a) {
25511
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
25213
25512
  p = p.next;
25214
25513
  }
25215
25514
 
@@ -25221,34 +25520,40 @@ function isEarHashed(ear, minX, minY, invSize) {
25221
25520
  b = ear,
25222
25521
  c = ear.next;
25223
25522
  if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
25224
- // triangle bbox; min & max are calculated like this for speed
25225
25523
 
25226
- const minTX = a.x < b.x ? a.x < c.x ? a.x : c.x : b.x < c.x ? b.x : c.x,
25227
- minTY = a.y < b.y ? a.y < c.y ? a.y : c.y : b.y < c.y ? b.y : c.y,
25228
- maxTX = a.x > b.x ? a.x > c.x ? a.x : c.x : b.x > c.x ? b.x : c.x,
25229
- maxTY = a.y > b.y ? a.y > c.y ? a.y : c.y : b.y > c.y ? b.y : c.y; // z-order range for the current triangle bbox;
25524
+ const ax = a.x,
25525
+ bx = b.x,
25526
+ cx = c.x,
25527
+ ay = a.y,
25528
+ by = b.y,
25529
+ cy = c.y; // triangle bbox; min & max are calculated like this for speed
25230
25530
 
25231
- const minZ = zOrder(minTX, minTY, minX, minY, invSize),
25232
- maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
25531
+ const x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx,
25532
+ y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy,
25533
+ x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx,
25534
+ y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy; // z-order range for the current triangle bbox;
25535
+
25536
+ const minZ = zOrder(x0, y0, minX, minY, invSize),
25537
+ maxZ = zOrder(x1, y1, minX, minY, invSize);
25233
25538
  let p = ear.prevZ,
25234
25539
  n = ear.nextZ; // look for points inside the triangle in both directions
25235
25540
 
25236
25541
  while (p && p.z >= minZ && n && n.z <= maxZ) {
25237
- if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
25542
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
25238
25543
  p = p.prevZ;
25239
- if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
25544
+ if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
25240
25545
  n = n.nextZ;
25241
25546
  } // look for remaining points in decreasing z-order
25242
25547
 
25243
25548
 
25244
25549
  while (p && p.z >= minZ) {
25245
- if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
25550
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
25246
25551
  p = p.prevZ;
25247
25552
  } // look for remaining points in increasing z-order
25248
25553
 
25249
25554
 
25250
25555
  while (n && n.z <= maxZ) {
25251
- if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
25556
+ if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
25252
25557
  n = n.nextZ;
25253
25558
  }
25254
25559
 
@@ -25264,9 +25569,9 @@ function cureLocalIntersections(start, triangles, dim) {
25264
25569
  b = p.next.next;
25265
25570
 
25266
25571
  if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
25267
- triangles.push(a.i / dim);
25268
- triangles.push(p.i / dim);
25269
- triangles.push(b.i / dim); // remove two nodes involved
25572
+ triangles.push(a.i / dim | 0);
25573
+ triangles.push(p.i / dim | 0);
25574
+ triangles.push(b.i / dim | 0); // remove two nodes involved
25270
25575
 
25271
25576
  removeNode(p);
25272
25577
  removeNode(p.next);
@@ -25295,8 +25600,8 @@ function splitEarcut(start, triangles, dim, minX, minY, invSize) {
25295
25600
  a = filterPoints(a, a.next);
25296
25601
  c = filterPoints(c, c.next); // run earcut on each half
25297
25602
 
25298
- earcutLinked(a, triangles, dim, minX, minY, invSize);
25299
- earcutLinked(c, triangles, dim, minX, minY, invSize);
25603
+ earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
25604
+ earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
25300
25605
  return;
25301
25606
  }
25302
25607
 
@@ -25323,8 +25628,7 @@ function eliminateHoles(data, holeIndices, outerNode, dim) {
25323
25628
  queue.sort(compareX); // process holes from left to right
25324
25629
 
25325
25630
  for (i = 0; i < queue.length; i++) {
25326
- eliminateHole(queue[i], outerNode);
25327
- outerNode = filterPoints(outerNode, outerNode.next);
25631
+ outerNode = eliminateHole(queue[i], outerNode);
25328
25632
  }
25329
25633
 
25330
25634
  return outerNode;
@@ -25336,23 +25640,25 @@ function compareX(a, b) {
25336
25640
 
25337
25641
 
25338
25642
  function eliminateHole(hole, outerNode) {
25339
- outerNode = findHoleBridge(hole, outerNode);
25340
-
25341
- if (outerNode) {
25342
- const b = splitPolygon(outerNode, hole); // filter collinear points around the cuts
25643
+ const bridge = findHoleBridge(hole, outerNode);
25343
25644
 
25344
- filterPoints(outerNode, outerNode.next);
25345
- filterPoints(b, b.next);
25645
+ if (!bridge) {
25646
+ return outerNode;
25346
25647
  }
25648
+
25649
+ const bridgeReverse = splitPolygon(bridge, hole); // filter collinear points around the cuts
25650
+
25651
+ filterPoints(bridgeReverse, bridgeReverse.next);
25652
+ return filterPoints(bridge, bridge.next);
25347
25653
  } // David Eberly's algorithm for finding a bridge between hole and outer polygon
25348
25654
 
25349
25655
 
25350
25656
  function findHoleBridge(hole, outerNode) {
25351
- let p = outerNode;
25352
- const hx = hole.x;
25353
- const hy = hole.y;
25354
- let qx = -Infinity,
25355
- m; // find a segment intersected by a ray from the hole's leftmost point to the left;
25657
+ let p = outerNode,
25658
+ qx = -Infinity,
25659
+ m;
25660
+ const hx = hole.x,
25661
+ hy = hole.y; // find a segment intersected by a ray from the hole's leftmost point to the left;
25356
25662
  // segment's endpoint with lesser x will be potential connection point
25357
25663
 
25358
25664
  do {
@@ -25361,22 +25667,15 @@ function findHoleBridge(hole, outerNode) {
25361
25667
 
25362
25668
  if (x <= hx && x > qx) {
25363
25669
  qx = x;
25364
-
25365
- if (x === hx) {
25366
- if (hy === p.y) return p;
25367
- if (hy === p.next.y) return p.next;
25368
- }
25369
-
25370
25670
  m = p.x < p.next.x ? p : p.next;
25671
+ if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint
25371
25672
  }
25372
25673
  }
25373
25674
 
25374
25675
  p = p.next;
25375
25676
  } while (p !== outerNode);
25376
25677
 
25377
- if (!m) return null;
25378
- if (hx === qx) return m; // hole touches outer segment; pick leftmost endpoint
25379
- // look for points inside the triangle of hole point, segment intersection and endpoint;
25678
+ if (!m) return null; // look for points inside the triangle of hole point, segment intersection and endpoint;
25380
25679
  // if there are no points found, we have a valid connection;
25381
25680
  // otherwise choose the point of the minimum angle with the ray as connection point
25382
25681
 
@@ -25413,7 +25712,7 @@ function indexCurve(start, minX, minY, invSize) {
25413
25712
  let p = start;
25414
25713
 
25415
25714
  do {
25416
- if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, invSize);
25715
+ if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);
25417
25716
  p.prevZ = p.prev;
25418
25717
  p.nextZ = p.next;
25419
25718
  p = p.next;
@@ -25485,8 +25784,8 @@ function sortLinked(list) {
25485
25784
 
25486
25785
  function zOrder(x, y, minX, minY, invSize) {
25487
25786
  // coords are transformed into non-negative 15-bit integer range
25488
- x = 32767 * (x - minX) * invSize;
25489
- y = 32767 * (y - minY) * invSize;
25787
+ x = (x - minX) * invSize | 0;
25788
+ y = (y - minY) * invSize | 0;
25490
25789
  x = (x | x << 8) & 0x00FF00FF;
25491
25790
  x = (x | x << 4) & 0x0F0F0F0F;
25492
25791
  x = (x | x << 2) & 0x33333333;
@@ -25513,12 +25812,12 @@ function getLeftmost(start) {
25513
25812
 
25514
25813
 
25515
25814
  function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
25516
- return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
25815
+ return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
25517
25816
  } // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
25518
25817
 
25519
25818
 
25520
25819
  function isValidDiagonal(a, b) {
25521
- return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && ( // doesn't intersect other edges
25820
+ return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && ( // dones't intersect other edges
25522
25821
  locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && ( // locally visible
25523
25822
  area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
25524
25823
  equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
@@ -25646,7 +25945,7 @@ function Node(i, x, y) {
25646
25945
  this.prev = null;
25647
25946
  this.next = null; // z-order curve value
25648
25947
 
25649
- this.z = null; // previous and next nodes in z-order
25948
+ this.z = 0; // previous and next nodes in z-order
25650
25949
 
25651
25950
  this.prevZ = null;
25652
25951
  this.nextZ = null; // indicates whether this is a steiner point
@@ -26424,7 +26723,7 @@ class ShapeGeometry extends BufferGeometry {
26424
26723
  vertices.push(vertex.x, vertex.y, 0);
26425
26724
  normals.push(0, 0, 1);
26426
26725
  uvs.push(vertex.x, vertex.y); // world uvs
26427
- } // incides
26726
+ } // indices
26428
26727
 
26429
26728
 
26430
26729
  for (let i = 0, l = faces.length; i < l; i++) {
@@ -27119,7 +27418,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
27119
27418
  this.transmissionMap = null;
27120
27419
  this.thickness = 0;
27121
27420
  this.thicknessMap = null;
27122
- this.attenuationDistance = 0.0;
27421
+ this.attenuationDistance = Infinity;
27123
27422
  this.attenuationColor = new Color(1, 1, 1);
27124
27423
  this.specularIntensity = 1.0;
27125
27424
  this.specularIntensityMap = null;
@@ -29061,8 +29360,10 @@ class FileLoader extends Loader {
29061
29360
  }
29062
29361
 
29063
29362
  const callbacks = loading[url];
29064
- const reader = response.body.getReader();
29065
- const contentLength = response.headers.get('Content-Length');
29363
+ const reader = response.body.getReader(); // Nginx needs X-File-Size check
29364
+ // https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
29365
+
29366
+ const contentLength = response.headers.get('Content-Length') || response.headers.get('X-File-Size');
29066
29367
  const total = contentLength ? parseInt(contentLength) : 0;
29067
29368
  const lengthComputable = total !== 0;
29068
29369
  let loaded = 0; // periodically read data into the new stream tracking while download progress
@@ -29597,8 +29898,7 @@ class LightShadow {
29597
29898
  this._frustum.setFromProjectionMatrix(_projScreenMatrix$1);
29598
29899
 
29599
29900
  shadowMatrix.set(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);
29600
- shadowMatrix.multiply(shadowCamera.projectionMatrix);
29601
- shadowMatrix.multiply(shadowCamera.matrixWorldInverse);
29901
+ shadowMatrix.multiply(_projScreenMatrix$1);
29602
29902
  }
29603
29903
 
29604
29904
  getViewport(viewportIndex) {
@@ -29676,7 +29976,7 @@ class SpotLightShadow extends LightShadow {
29676
29976
  }
29677
29977
 
29678
29978
  class SpotLight extends Light {
29679
- constructor(color, intensity, distance = 0, angle = Math.PI / 3, penumbra = 0, decay = 1) {
29979
+ constructor(color, intensity, distance = 0, angle = Math.PI / 3, penumbra = 0, decay = 2) {
29680
29980
  super(color, intensity);
29681
29981
  this.isSpotLight = true;
29682
29982
  this.type = 'SpotLight';
@@ -29686,8 +29986,7 @@ class SpotLight extends Light {
29686
29986
  this.distance = distance;
29687
29987
  this.angle = angle;
29688
29988
  this.penumbra = penumbra;
29689
- this.decay = decay; // for physically correct lights, should be 2.
29690
-
29989
+ this.decay = decay;
29691
29990
  this.map = null;
29692
29991
  this.shadow = new SpotLightShadow();
29693
29992
  }
@@ -29786,13 +30085,12 @@ class PointLightShadow extends LightShadow {
29786
30085
  }
29787
30086
 
29788
30087
  class PointLight extends Light {
29789
- constructor(color, intensity, distance = 0, decay = 1) {
30088
+ constructor(color, intensity, distance = 0, decay = 2) {
29790
30089
  super(color, intensity);
29791
30090
  this.isPointLight = true;
29792
30091
  this.type = 'PointLight';
29793
30092
  this.distance = distance;
29794
- this.decay = decay; // for physically correct lights, should be 2.
29795
-
30093
+ this.decay = decay;
29796
30094
  this.shadow = new PointLightShadow();
29797
30095
  }
29798
30096
 
@@ -30415,12 +30713,8 @@ class InstancedBufferGeometry extends BufferGeometry {
30415
30713
  return this;
30416
30714
  }
30417
30715
 
30418
- clone() {
30419
- return new this.constructor().copy(this);
30420
- }
30421
-
30422
30716
  toJSON() {
30423
- const data = super.toJSON(this);
30717
+ const data = super.toJSON();
30424
30718
  data.instanceCount = this.instanceCount;
30425
30719
  data.isInstancedBufferGeometry = true;
30426
30720
  return data;
@@ -30601,6 +30895,7 @@ class ObjectLoader extends Loader {
30601
30895
  const metadata = json.metadata;
30602
30896
 
30603
30897
  if (metadata === undefined || metadata.type === undefined || metadata.type.toLowerCase() === 'geometry') {
30898
+ if (onError !== undefined) onError(new Error('THREE.ObjectLoader: Can\'t load ' + url));
30604
30899
  console.error('THREE.ObjectLoader: Can\'t load ' + url);
30605
30900
  return;
30606
30901
  }
@@ -31056,6 +31351,7 @@ class ObjectLoader extends Loader {
31056
31351
  }
31057
31352
  }
31058
31353
 
31354
+ if (data.backgroundBlurriness !== undefined) object.backgroundBlurriness = data.backgroundBlurriness;
31059
31355
  break;
31060
31356
 
31061
31357
  case 'PerspectiveCamera':
@@ -31221,7 +31517,7 @@ class ObjectLoader extends Loader {
31221
31517
  const child = object.getObjectByProperty('uuid', level.object);
31222
31518
 
31223
31519
  if (child !== undefined) {
31224
- object.addLevel(child, level.distance);
31520
+ object.addLevel(child, level.distance, level.hysteresis);
31225
31521
  }
31226
31522
  }
31227
31523
  }
@@ -31332,18 +31628,20 @@ class ImageBitmapLoader extends Loader {
31332
31628
 
31333
31629
  let _context;
31334
31630
 
31335
- const AudioContext = {
31336
- getContext: function () {
31631
+ class AudioContext {
31632
+ static getContext() {
31337
31633
  if (_context === undefined) {
31338
31634
  _context = new (window.AudioContext || window.webkitAudioContext)();
31339
31635
  }
31340
31636
 
31341
31637
  return _context;
31342
- },
31343
- setContext: function (value) {
31638
+ }
31639
+
31640
+ static setContext(value) {
31344
31641
  _context = value;
31345
31642
  }
31346
- };
31643
+
31644
+ }
31347
31645
 
31348
31646
  class AudioLoader extends Loader {
31349
31647
  constructor(manager) {
@@ -32587,6 +32885,11 @@ class PropertyBinding {
32587
32885
  break;
32588
32886
 
32589
32887
  case 'map':
32888
+ if ('map' in targetObject) {
32889
+ targetObject = targetObject.map;
32890
+ break;
32891
+ }
32892
+
32590
32893
  if (!targetObject.material) {
32591
32894
  console.error('THREE.PropertyBinding: Can not bind to material as node does not have a material.', this);
32592
32895
  return;
@@ -34575,10 +34878,10 @@ class SpotLightHelper extends Object3D {
34575
34878
  constructor(light, color) {
34576
34879
  super();
34577
34880
  this.light = light;
34578
- this.light.updateMatrixWorld();
34579
34881
  this.matrix = light.matrixWorld;
34580
34882
  this.matrixAutoUpdate = false;
34581
34883
  this.color = color;
34884
+ this.type = 'SpotLightHelper';
34582
34885
  const geometry = new BufferGeometry();
34583
34886
  const positions = [0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, -1, 1];
34584
34887
 
@@ -34604,7 +34907,8 @@ class SpotLightHelper extends Object3D {
34604
34907
  }
34605
34908
 
34606
34909
  update() {
34607
- this.light.updateMatrixWorld();
34910
+ this.light.updateWorldMatrix(true, false);
34911
+ this.light.target.updateWorldMatrix(true, false);
34608
34912
  const coneLength = this.light.distance ? this.light.distance : 1000;
34609
34913
  const coneWidth = coneLength * Math.tan(this.light.angle);
34610
34914
  this.cone.scale.set(coneWidth, coneWidth, coneLength);
@@ -34696,6 +35000,11 @@ class SkeletonHelper extends LineSegments {
34696
35000
  super.updateMatrixWorld(force);
34697
35001
  }
34698
35002
 
35003
+ dispose() {
35004
+ this.geometry.dispose();
35005
+ this.material.dispose();
35006
+ }
35007
+
34699
35008
  }
34700
35009
 
34701
35010
  function getBoneList(object) {
@@ -34722,7 +35031,6 @@ class PointLightHelper extends Mesh {
34722
35031
  });
34723
35032
  super(geometry, material);
34724
35033
  this.light = light;
34725
- this.light.updateMatrixWorld();
34726
35034
  this.color = color;
34727
35035
  this.type = 'PointLightHelper';
34728
35036
  this.matrix = this.light.matrixWorld;
@@ -34750,6 +35058,8 @@ class PointLightHelper extends Mesh {
34750
35058
  }
34751
35059
 
34752
35060
  update() {
35061
+ this.light.updateWorldMatrix(true, false);
35062
+
34753
35063
  if (this.color !== undefined) {
34754
35064
  this.material.color.set(this.color);
34755
35065
  } else {
@@ -34779,10 +35089,10 @@ class HemisphereLightHelper extends Object3D {
34779
35089
  constructor(light, size, color) {
34780
35090
  super();
34781
35091
  this.light = light;
34782
- this.light.updateMatrixWorld();
34783
35092
  this.matrix = light.matrixWorld;
34784
35093
  this.matrixAutoUpdate = false;
34785
35094
  this.color = color;
35095
+ this.type = 'HemisphereLightHelper';
34786
35096
  const geometry = new OctahedronGeometry(size);
34787
35097
  geometry.rotateY(Math.PI * 0.5);
34788
35098
  this.material = new MeshBasicMaterial({
@@ -34823,6 +35133,7 @@ class HemisphereLightHelper extends Object3D {
34823
35133
  colors.needsUpdate = true;
34824
35134
  }
34825
35135
 
35136
+ this.light.updateWorldMatrix(true, false);
34826
35137
  mesh.lookAt(_vector$1.setFromMatrixPosition(this.light.matrixWorld).negate());
34827
35138
  }
34828
35139
 
@@ -34863,6 +35174,11 @@ class GridHelper extends LineSegments {
34863
35174
  this.type = 'GridHelper';
34864
35175
  }
34865
35176
 
35177
+ dispose() {
35178
+ this.geometry.dispose();
35179
+ this.material.dispose();
35180
+ }
35181
+
34866
35182
  }
34867
35183
 
34868
35184
  class PolarGridHelper extends LineSegments {
@@ -34917,6 +35233,11 @@ class PolarGridHelper extends LineSegments {
34917
35233
  this.type = 'PolarGridHelper';
34918
35234
  }
34919
35235
 
35236
+ dispose() {
35237
+ this.geometry.dispose();
35238
+ this.material.dispose();
35239
+ }
35240
+
34920
35241
  }
34921
35242
 
34922
35243
  const _v1 = /*@__PURE__*/new Vector3();
@@ -34929,10 +35250,10 @@ class DirectionalLightHelper extends Object3D {
34929
35250
  constructor(light, size, color) {
34930
35251
  super();
34931
35252
  this.light = light;
34932
- this.light.updateMatrixWorld();
34933
35253
  this.matrix = light.matrixWorld;
34934
35254
  this.matrixAutoUpdate = false;
34935
35255
  this.color = color;
35256
+ this.type = 'DirectionalLightHelper';
34936
35257
  if (size === undefined) size = 1;
34937
35258
  let geometry = new BufferGeometry();
34938
35259
  geometry.setAttribute('position', new Float32BufferAttribute([-size, size, 0, size, size, 0, size, -size, 0, -size, -size, 0, -size, size, 0], 3));
@@ -34957,6 +35278,9 @@ class DirectionalLightHelper extends Object3D {
34957
35278
  }
34958
35279
 
34959
35280
  update() {
35281
+ this.light.updateWorldMatrix(true, false);
35282
+ this.light.target.updateWorldMatrix(true, false);
35283
+
34960
35284
  _v1.setFromMatrixPosition(this.light.matrixWorld);
34961
35285
 
34962
35286
  _v2.setFromMatrixPosition(this.light.target.matrixWorld);
@@ -35304,6 +35628,11 @@ class BoxHelper extends LineSegments {
35304
35628
  return this;
35305
35629
  }
35306
35630
 
35631
+ dispose() {
35632
+ this.geometry.dispose();
35633
+ this.material.dispose();
35634
+ }
35635
+
35307
35636
  }
35308
35637
 
35309
35638
  class Box3Helper extends LineSegments {
@@ -35331,6 +35660,11 @@ class Box3Helper extends LineSegments {
35331
35660
  super.updateMatrixWorld(force);
35332
35661
  }
35333
35662
 
35663
+ dispose() {
35664
+ this.geometry.dispose();
35665
+ this.material.dispose();
35666
+ }
35667
+
35334
35668
  }
35335
35669
 
35336
35670
  class PlaneHelper extends Line {
@@ -35368,6 +35702,13 @@ class PlaneHelper extends Line {
35368
35702
  super.updateMatrixWorld(force);
35369
35703
  }
35370
35704
 
35705
+ dispose() {
35706
+ this.geometry.dispose();
35707
+ this.material.dispose();
35708
+ this.children[0].geometry.dispose();
35709
+ this.children[0].material.dispose();
35710
+ }
35711
+
35371
35712
  }
35372
35713
 
35373
35714
  const _axis = /*@__PURE__*/new Vector3();
@@ -35442,6 +35783,13 @@ class ArrowHelper extends Object3D {
35442
35783
  return this;
35443
35784
  }
35444
35785
 
35786
+ dispose() {
35787
+ this.line.geometry.dispose();
35788
+ this.line.material.dispose();
35789
+ this.cone.geometry.dispose();
35790
+ this.cone.material.dispose();
35791
+ }
35792
+
35445
35793
  }
35446
35794
 
35447
35795
  class AxesHelper extends LineSegments {
@@ -36059,6 +36407,7 @@ exports.Clock = Clock;
36059
36407
  exports.Color = Color;
36060
36408
  exports.ColorKeyframeTrack = ColorKeyframeTrack;
36061
36409
  exports.ColorManagement = ColorManagement;
36410
+ exports.CompressedArrayTexture = CompressedArrayTexture;
36062
36411
  exports.CompressedTexture = CompressedTexture;
36063
36412
  exports.CompressedTextureLoader = CompressedTextureLoader;
36064
36413
  exports.ConeBufferGeometry = ConeBufferGeometry;