super-three 0.144.0 → 0.147.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +735 -387
  3. package/build/three.js +735 -387
  4. package/build/three.min.js +1 -1
  5. package/build/three.module.js +910 -408
  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 +70 -2
  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);
@@ -18883,10 +19097,7 @@ class WebXRManager extends EventDispatcher {
18883
19097
 
18884
19098
  if (index >= 0) {
18885
19099
  controllerInputSources[index] = null;
18886
- controllers[index].dispatchEvent({
18887
- type: 'disconnected',
18888
- data: inputSource
18889
- });
19100
+ controllers[index].disconnect(inputSource);
18890
19101
  }
18891
19102
  } // Notify connected
18892
19103
 
@@ -18916,10 +19127,7 @@ class WebXRManager extends EventDispatcher {
18916
19127
  const controller = controllers[controllerIndex];
18917
19128
 
18918
19129
  if (controller) {
18919
- controller.dispatchEvent({
18920
- type: 'connected',
18921
- data: inputSource
18922
- });
19130
+ controller.connect(inputSource);
18923
19131
  }
18924
19132
  }
18925
19133
  } //
@@ -19057,6 +19265,10 @@ class WebXRManager extends EventDispatcher {
19057
19265
  if (glBaseLayer !== null && glBaseLayer.fixedFoveation !== undefined) {
19058
19266
  glBaseLayer.fixedFoveation = foveation;
19059
19267
  }
19268
+ };
19269
+
19270
+ this.getPlanes = function () {
19271
+ return planes;
19060
19272
  }; // Animation Loop
19061
19273
 
19062
19274
 
@@ -19131,6 +19343,57 @@ class WebXRManager extends EventDispatcher {
19131
19343
  }
19132
19344
 
19133
19345
  if (onAnimationFrameCallback) onAnimationFrameCallback(time, frame);
19346
+
19347
+ if (frame.detectedPlanes) {
19348
+ scope.dispatchEvent({
19349
+ type: 'planesdetected',
19350
+ data: frame.detectedPlanes
19351
+ });
19352
+ let planesToRemove = null;
19353
+
19354
+ for (const plane of planes) {
19355
+ if (!frame.detectedPlanes.has(plane)) {
19356
+ if (planesToRemove === null) {
19357
+ planesToRemove = [];
19358
+ }
19359
+
19360
+ planesToRemove.push(plane);
19361
+ }
19362
+ }
19363
+
19364
+ if (planesToRemove !== null) {
19365
+ for (const plane of planesToRemove) {
19366
+ planes.delete(plane);
19367
+ planesLastChangedTimes.delete(plane);
19368
+ scope.dispatchEvent({
19369
+ type: 'planeremoved',
19370
+ data: plane
19371
+ });
19372
+ }
19373
+ }
19374
+
19375
+ for (const plane of frame.detectedPlanes) {
19376
+ if (!planes.has(plane)) {
19377
+ planes.add(plane);
19378
+ planesLastChangedTimes.set(plane, frame.lastChangedTime);
19379
+ scope.dispatchEvent({
19380
+ type: 'planeadded',
19381
+ data: plane
19382
+ });
19383
+ } else {
19384
+ const lastKnownTime = planesLastChangedTimes.get(plane);
19385
+
19386
+ if (plane.lastChangedTime > lastKnownTime) {
19387
+ planesLastChangedTimes.set(plane, plane.lastChangedTime);
19388
+ scope.dispatchEvent({
19389
+ type: 'planechanged',
19390
+ data: plane
19391
+ });
19392
+ }
19393
+ }
19394
+ }
19395
+ }
19396
+
19134
19397
  xrFrame = null;
19135
19398
  }
19136
19399
 
@@ -19148,7 +19411,7 @@ class WebXRManager extends EventDispatcher {
19148
19411
 
19149
19412
  function WebGLMaterials(renderer, properties) {
19150
19413
  function refreshFogUniforms(uniforms, fog) {
19151
- uniforms.fogColor.value.copy(fog.color);
19414
+ fog.color.getRGB(uniforms.fogColor.value, getUnlitUniformColorSpace(renderer));
19152
19415
 
19153
19416
  if (fog.isFog) {
19154
19417
  uniforms.fogNear.value = fog.near;
@@ -19897,20 +20160,7 @@ function WebGLRenderer(parameters = {}) {
19897
20160
  this.physicallyCorrectLights = false; // tone mapping
19898
20161
 
19899
20162
  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
20163
+ this.toneMappingExposure = 1.0; // internal properties
19914
20164
 
19915
20165
  const _this = this;
19916
20166
 
@@ -20063,7 +20313,7 @@ function WebGLRenderer(parameters = {}) {
20063
20313
  materials = new WebGLMaterials(_this, properties);
20064
20314
  renderLists = new WebGLRenderLists();
20065
20315
  renderStates = new WebGLRenderStates(extensions, capabilities);
20066
- background = new WebGLBackground(_this, cubemaps, state, objects, _alpha, _premultipliedAlpha);
20316
+ background = new WebGLBackground(_this, cubemaps, cubeuvmaps, state, objects, _alpha, _premultipliedAlpha);
20067
20317
  shadowMap = new WebGLShadowMap(_this, objects, capabilities);
20068
20318
  uniformsGroups = new WebGLUniformsGroups(_gl, info, capabilities, state);
20069
20319
  bufferRenderer = new WebGLBufferRenderer(_gl, extensions, info, capabilities);
@@ -20326,22 +20576,35 @@ function WebGLRenderer(parameters = {}) {
20326
20576
  state.setMaterial(material, frontFaceCW); //
20327
20577
 
20328
20578
  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
20579
  let rangeFactor = 1;
20339
20580
 
20340
20581
  if (material.wireframe === true) {
20341
20582
  index = geometries.getWireframeAttribute(geometry);
20342
20583
  rangeFactor = 2;
20584
+ } //
20585
+
20586
+
20587
+ const drawRange = geometry.drawRange;
20588
+ const position = geometry.attributes.position;
20589
+ let drawStart = drawRange.start * rangeFactor;
20590
+ let drawEnd = (drawRange.start + drawRange.count) * rangeFactor;
20591
+
20592
+ if (group !== null) {
20593
+ drawStart = Math.max(drawStart, group.start * rangeFactor);
20594
+ drawEnd = Math.min(drawEnd, (group.start + group.count) * rangeFactor);
20343
20595
  }
20344
20596
 
20597
+ if (index !== null) {
20598
+ drawStart = Math.max(drawStart, 0);
20599
+ drawEnd = Math.min(drawEnd, index.count);
20600
+ } else if (position !== undefined && position !== null) {
20601
+ drawStart = Math.max(drawStart, 0);
20602
+ drawEnd = Math.min(drawEnd, position.count);
20603
+ }
20604
+
20605
+ const drawCount = drawEnd - drawStart;
20606
+ if (drawCount < 0 || drawCount === Infinity) return; //
20607
+
20345
20608
  bindingStates.setup(object, material, program, geometry, index);
20346
20609
  let attribute;
20347
20610
  let renderer = bufferRenderer;
@@ -20353,16 +20616,6 @@ function WebGLRenderer(parameters = {}) {
20353
20616
  } //
20354
20617
 
20355
20618
 
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
20619
  if (object.isMesh) {
20367
20620
  if (material.wireframe === true) {
20368
20621
  state.setLineWidth(material.wireframeLinewidth * getTargetPixelRatio());
@@ -20392,7 +20645,8 @@ function WebGLRenderer(parameters = {}) {
20392
20645
  if (object.isInstancedMesh) {
20393
20646
  renderer.renderInstances(drawStart, drawCount, object.count);
20394
20647
  } else if (geometry.isInstancedBufferGeometry) {
20395
- const instanceCount = Math.min(geometry.instanceCount, geometry._maxInstanceCount);
20648
+ const maxInstanceCount = geometry._maxInstanceCount !== undefined ? geometry._maxInstanceCount : Infinity;
20649
+ const instanceCount = Math.min(geometry.instanceCount, maxInstanceCount);
20396
20650
  renderer.renderInstances(drawStart, drawCount, instanceCount);
20397
20651
  } else {
20398
20652
  renderer.render(drawStart, drawCount);
@@ -21134,6 +21388,9 @@ function WebGLRenderer(parameters = {}) {
21134
21388
  _currentActiveCubeFace = activeCubeFace;
21135
21389
  _currentActiveMipmapLevel = activeMipmapLevel;
21136
21390
  let useDefaultFramebuffer = true;
21391
+ let framebuffer = null;
21392
+ let isCube = false;
21393
+ let isRenderTarget3D = false;
21137
21394
 
21138
21395
  if (renderTarget) {
21139
21396
  const renderTargetProperties = properties.get(renderTarget);
@@ -21148,16 +21405,10 @@ function WebGLRenderer(parameters = {}) {
21148
21405
  // Color and depth texture must be rebound in order for the swapchain to update.
21149
21406
  textures.rebindTextures(renderTarget, properties.get(renderTarget.texture).__webglTexture, properties.get(renderTarget.depthTexture).__webglTexture);
21150
21407
  }
21151
- }
21152
21408
 
21153
- let framebuffer = null;
21154
- let isCube = false;
21155
- let isRenderTarget3D = false;
21156
-
21157
- if (renderTarget) {
21158
21409
  const texture = renderTarget.texture;
21159
21410
 
21160
- if (texture.isData3DTexture || texture.isDataArrayTexture) {
21411
+ if (texture.isData3DTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture) {
21161
21412
  isRenderTarget3D = true;
21162
21413
  }
21163
21414
 
@@ -21350,7 +21601,7 @@ function WebGLRenderer(parameters = {}) {
21350
21601
  if (srcTexture.isDataTexture || srcTexture.isData3DTexture) {
21351
21602
  _gl.texSubImage3D(glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image.data);
21352
21603
  } else {
21353
- if (srcTexture.isCompressedTexture) {
21604
+ if (srcTexture.isCompressedArrayTexture) {
21354
21605
  console.warn('THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.');
21355
21606
 
21356
21607
  _gl.compressedTexSubImage3D(glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data);
@@ -21379,7 +21630,7 @@ function WebGLRenderer(parameters = {}) {
21379
21630
  textures.setTextureCube(texture, 0);
21380
21631
  } else if (texture.isData3DTexture) {
21381
21632
  textures.setTexture3D(texture, 0);
21382
- } else if (texture.isDataArrayTexture) {
21633
+ } else if (texture.isDataArrayTexture || texture.isCompressedArrayTexture) {
21383
21634
  textures.setTexture2DArray(texture, 0);
21384
21635
  } else {
21385
21636
  textures.setTexture2D(texture, 0);
@@ -21461,6 +21712,8 @@ class Scene extends Object3D {
21461
21712
  this.background = null;
21462
21713
  this.environment = null;
21463
21714
  this.fog = null;
21715
+ this.backgroundBlurriness = 0;
21716
+ this.backgroundIntensity = 1;
21464
21717
  this.overrideMaterial = null;
21465
21718
 
21466
21719
  if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
@@ -21475,6 +21728,8 @@ class Scene extends Object3D {
21475
21728
  if (source.background !== null) this.background = source.background.clone();
21476
21729
  if (source.environment !== null) this.environment = source.environment.clone();
21477
21730
  if (source.fog !== null) this.fog = source.fog.clone();
21731
+ this.backgroundBlurriness = source.backgroundBlurriness;
21732
+ this.backgroundIntensity = source.backgroundIntensity;
21478
21733
  if (source.overrideMaterial !== null) this.overrideMaterial = source.overrideMaterial.clone();
21479
21734
  this.matrixAutoUpdate = source.matrixAutoUpdate;
21480
21735
  return this;
@@ -21483,6 +21738,8 @@ class Scene extends Object3D {
21483
21738
  toJSON(meta) {
21484
21739
  const data = super.toJSON(meta);
21485
21740
  if (this.fog !== null) data.object.fog = this.fog.toJSON();
21741
+ if (this.backgroundBlurriness > 0) data.backgroundBlurriness = this.backgroundBlurriness;
21742
+ if (this.backgroundIntensity !== 1) data.backgroundIntensity = this.backgroundIntensity;
21486
21743
  return data;
21487
21744
  } // @deprecated
21488
21745
 
@@ -21753,7 +22010,7 @@ class InterleavedBufferAttribute {
21753
22010
 
21754
22011
  clone(data) {
21755
22012
  if (data === undefined) {
21756
- console.log('THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will deinterleave buffer data.');
22013
+ console.log('THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.');
21757
22014
  const array = [];
21758
22015
 
21759
22016
  for (let i = 0; i < this.count; i++) {
@@ -21780,7 +22037,7 @@ class InterleavedBufferAttribute {
21780
22037
 
21781
22038
  toJSON(data) {
21782
22039
  if (data === undefined) {
21783
- console.log('THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will deinterleave buffer data.');
22040
+ console.log('THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.');
21784
22041
  const array = [];
21785
22042
 
21786
22043
  for (let i = 0; i < this.count; i++) {
@@ -21789,7 +22046,7 @@ class InterleavedBufferAttribute {
21789
22046
  for (let j = 0; j < this.itemSize; j++) {
21790
22047
  array.push(this.data.array[index + j]);
21791
22048
  }
21792
- } // deinterleave data and save it as an ordinary buffer attribute for now
22049
+ } // de-interleave data and save it as an ordinary buffer attribute for now
21793
22050
 
21794
22051
 
21795
22052
  return {
@@ -21799,7 +22056,7 @@ class InterleavedBufferAttribute {
21799
22056
  normalized: this.normalized
21800
22057
  };
21801
22058
  } else {
21802
- // save as true interleaved attribtue
22059
+ // save as true interleaved attribute
21803
22060
  if (data.interleavedBuffers === undefined) {
21804
22061
  data.interleavedBuffers = {};
21805
22062
  }
@@ -22015,14 +22272,14 @@ class LOD extends Object3D {
22015
22272
 
22016
22273
  for (let i = 0, l = levels.length; i < l; i++) {
22017
22274
  const level = levels[i];
22018
- this.addLevel(level.object.clone(), level.distance);
22275
+ this.addLevel(level.object.clone(), level.distance, level.hysteresis);
22019
22276
  }
22020
22277
 
22021
22278
  this.autoUpdate = source.autoUpdate;
22022
22279
  return this;
22023
22280
  }
22024
22281
 
22025
- addLevel(object, distance = 0) {
22282
+ addLevel(object, distance = 0, hysteresis = 0) {
22026
22283
  distance = Math.abs(distance);
22027
22284
  const levels = this.levels;
22028
22285
  let l;
@@ -22035,6 +22292,7 @@ class LOD extends Object3D {
22035
22292
 
22036
22293
  levels.splice(l, 0, {
22037
22294
  distance: distance,
22295
+ hysteresis: hysteresis,
22038
22296
  object: object
22039
22297
  });
22040
22298
  this.add(object);
@@ -22052,7 +22310,13 @@ class LOD extends Object3D {
22052
22310
  let i, l;
22053
22311
 
22054
22312
  for (i = 1, l = levels.length; i < l; i++) {
22055
- if (distance < levels[i].distance) {
22313
+ let levelDistance = levels[i].distance;
22314
+
22315
+ if (levels[i].object.visible) {
22316
+ levelDistance -= levelDistance * levels[i].hysteresis;
22317
+ }
22318
+
22319
+ if (distance < levelDistance) {
22056
22320
  break;
22057
22321
  }
22058
22322
  }
@@ -22087,7 +22351,13 @@ class LOD extends Object3D {
22087
22351
  let i, l;
22088
22352
 
22089
22353
  for (i = 1, l = levels.length; i < l; i++) {
22090
- if (distance >= levels[i].distance) {
22354
+ let levelDistance = levels[i].distance;
22355
+
22356
+ if (levels[i].object.visible) {
22357
+ levelDistance -= levelDistance * levels[i].hysteresis;
22358
+ }
22359
+
22360
+ if (distance >= levelDistance) {
22091
22361
  levels[i - 1].object.visible = false;
22092
22362
  levels[i].object.visible = true;
22093
22363
  } else {
@@ -22113,7 +22383,8 @@ class LOD extends Object3D {
22113
22383
  const level = levels[i];
22114
22384
  data.object.levels.push({
22115
22385
  object: level.object.uuid,
22116
- distance: level.distance
22386
+ distance: level.distance,
22387
+ hysteresis: level.hysteresis
22117
22388
  });
22118
22389
  }
22119
22390
 
@@ -22469,6 +22740,8 @@ const _instanceWorldMatrix = /*@__PURE__*/new Matrix4();
22469
22740
 
22470
22741
  const _instanceIntersects = [];
22471
22742
 
22743
+ const _identity = /*@__PURE__*/new Matrix4();
22744
+
22472
22745
  const _mesh = /*@__PURE__*/new Mesh();
22473
22746
 
22474
22747
  class InstancedMesh extends Mesh {
@@ -22479,6 +22752,10 @@ class InstancedMesh extends Mesh {
22479
22752
  this.instanceColor = null;
22480
22753
  this.count = count;
22481
22754
  this.frustumCulled = false;
22755
+
22756
+ for (let i = 0; i < count; i++) {
22757
+ this.setMatrixAt(i, _identity);
22758
+ }
22482
22759
  }
22483
22760
 
22484
22761
  copy(source, recursive) {
@@ -22995,6 +23272,16 @@ class CompressedTexture extends Texture {
22995
23272
 
22996
23273
  }
22997
23274
 
23275
+ class CompressedArrayTexture extends CompressedTexture {
23276
+ constructor(mipmaps, width, height, depth, format, type) {
23277
+ super(mipmaps, width, height, format, type);
23278
+ this.isCompressedArrayTexture = true;
23279
+ this.image.depth = depth;
23280
+ this.wrapR = ClampToEdgeWrapping;
23281
+ }
23282
+
23283
+ }
23284
+
22998
23285
  class CanvasTexture extends Texture {
22999
23286
  constructor(canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy) {
23000
23287
  super(canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);
@@ -24714,7 +25001,7 @@ class PolyhedronGeometry extends BufferGeometry {
24714
25001
  function subdivide(detail) {
24715
25002
  const a = new Vector3();
24716
25003
  const b = new Vector3();
24717
- const c = new Vector3(); // iterate over all faces and apply a subdivison with the given detail value
25004
+ const c = new Vector3(); // iterate over all faces and apply a subdivision with the given detail value
24718
25005
 
24719
25006
  for (let i = 0; i < indices.length; i += 3) {
24720
25007
  // get the vertices of the face
@@ -25080,7 +25367,7 @@ class Shape extends Path {
25080
25367
  }
25081
25368
 
25082
25369
  /**
25083
- * Port from https://github.com/mapbox/earcut (v2.2.2)
25370
+ * Port from https://github.com/mapbox/earcut (v2.2.4)
25084
25371
  */
25085
25372
  const Earcut = {
25086
25373
  triangulate: function (data, holeIndices, dim = 2) {
@@ -25107,10 +25394,10 @@ const Earcut = {
25107
25394
 
25108
25395
 
25109
25396
  invSize = Math.max(maxX - minX, maxY - minY);
25110
- invSize = invSize !== 0 ? 1 / invSize : 0;
25397
+ invSize = invSize !== 0 ? 32767 / invSize : 0;
25111
25398
  }
25112
25399
 
25113
- earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
25400
+ earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
25114
25401
  return triangles;
25115
25402
  }
25116
25403
  }; // create a circular doubly linked list from polygon points in the specified winding order
@@ -25170,9 +25457,9 @@ function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
25170
25457
 
25171
25458
  if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
25172
25459
  // cut off the triangle
25173
- triangles.push(prev.i / dim);
25174
- triangles.push(ear.i / dim);
25175
- triangles.push(next.i / dim);
25460
+ triangles.push(prev.i / dim | 0);
25461
+ triangles.push(ear.i / dim | 0);
25462
+ triangles.push(next.i / dim | 0);
25176
25463
  removeNode(ear); // skipping the next vertex leads to less sliver triangles
25177
25464
 
25178
25465
  ear = next.next;
@@ -25206,10 +25493,21 @@ function isEar(ear) {
25206
25493
  if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
25207
25494
  // now make sure we don't have other points inside the potential ear
25208
25495
 
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;
25496
+ const ax = a.x,
25497
+ bx = b.x,
25498
+ cx = c.x,
25499
+ ay = a.y,
25500
+ by = b.y,
25501
+ cy = c.y; // triangle bbox; min & max are calculated like this for speed
25502
+
25503
+ const x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx,
25504
+ y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy,
25505
+ x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx,
25506
+ y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
25507
+ let p = c.next;
25508
+
25509
+ while (p !== a) {
25510
+ 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
25511
  p = p.next;
25214
25512
  }
25215
25513
 
@@ -25221,34 +25519,40 @@ function isEarHashed(ear, minX, minY, invSize) {
25221
25519
  b = ear,
25222
25520
  c = ear.next;
25223
25521
  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
25522
 
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;
25523
+ const ax = a.x,
25524
+ bx = b.x,
25525
+ cx = c.x,
25526
+ ay = a.y,
25527
+ by = b.y,
25528
+ cy = c.y; // triangle bbox; min & max are calculated like this for speed
25529
+
25530
+ const x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx,
25531
+ y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy,
25532
+ x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx,
25533
+ y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy; // z-order range for the current triangle bbox;
25230
25534
 
25231
- const minZ = zOrder(minTX, minTY, minX, minY, invSize),
25232
- maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
25535
+ const minZ = zOrder(x0, y0, minX, minY, invSize),
25536
+ maxZ = zOrder(x1, y1, minX, minY, invSize);
25233
25537
  let p = ear.prevZ,
25234
25538
  n = ear.nextZ; // look for points inside the triangle in both directions
25235
25539
 
25236
25540
  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;
25541
+ 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
25542
  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;
25543
+ 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
25544
  n = n.nextZ;
25241
25545
  } // look for remaining points in decreasing z-order
25242
25546
 
25243
25547
 
25244
25548
  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;
25549
+ 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
25550
  p = p.prevZ;
25247
25551
  } // look for remaining points in increasing z-order
25248
25552
 
25249
25553
 
25250
25554
  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;
25555
+ 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
25556
  n = n.nextZ;
25253
25557
  }
25254
25558
 
@@ -25264,9 +25568,9 @@ function cureLocalIntersections(start, triangles, dim) {
25264
25568
  b = p.next.next;
25265
25569
 
25266
25570
  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
25571
+ triangles.push(a.i / dim | 0);
25572
+ triangles.push(p.i / dim | 0);
25573
+ triangles.push(b.i / dim | 0); // remove two nodes involved
25270
25574
 
25271
25575
  removeNode(p);
25272
25576
  removeNode(p.next);
@@ -25295,8 +25599,8 @@ function splitEarcut(start, triangles, dim, minX, minY, invSize) {
25295
25599
  a = filterPoints(a, a.next);
25296
25600
  c = filterPoints(c, c.next); // run earcut on each half
25297
25601
 
25298
- earcutLinked(a, triangles, dim, minX, minY, invSize);
25299
- earcutLinked(c, triangles, dim, minX, minY, invSize);
25602
+ earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
25603
+ earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
25300
25604
  return;
25301
25605
  }
25302
25606
 
@@ -25323,8 +25627,7 @@ function eliminateHoles(data, holeIndices, outerNode, dim) {
25323
25627
  queue.sort(compareX); // process holes from left to right
25324
25628
 
25325
25629
  for (i = 0; i < queue.length; i++) {
25326
- eliminateHole(queue[i], outerNode);
25327
- outerNode = filterPoints(outerNode, outerNode.next);
25630
+ outerNode = eliminateHole(queue[i], outerNode);
25328
25631
  }
25329
25632
 
25330
25633
  return outerNode;
@@ -25336,23 +25639,25 @@ function compareX(a, b) {
25336
25639
 
25337
25640
 
25338
25641
  function eliminateHole(hole, outerNode) {
25339
- outerNode = findHoleBridge(hole, outerNode);
25642
+ const bridge = findHoleBridge(hole, outerNode);
25340
25643
 
25341
- if (outerNode) {
25342
- const b = splitPolygon(outerNode, hole); // filter collinear points around the cuts
25343
-
25344
- filterPoints(outerNode, outerNode.next);
25345
- filterPoints(b, b.next);
25644
+ if (!bridge) {
25645
+ return outerNode;
25346
25646
  }
25647
+
25648
+ const bridgeReverse = splitPolygon(bridge, hole); // filter collinear points around the cuts
25649
+
25650
+ filterPoints(bridgeReverse, bridgeReverse.next);
25651
+ return filterPoints(bridge, bridge.next);
25347
25652
  } // David Eberly's algorithm for finding a bridge between hole and outer polygon
25348
25653
 
25349
25654
 
25350
25655
  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;
25656
+ let p = outerNode,
25657
+ qx = -Infinity,
25658
+ m;
25659
+ const hx = hole.x,
25660
+ hy = hole.y; // find a segment intersected by a ray from the hole's leftmost point to the left;
25356
25661
  // segment's endpoint with lesser x will be potential connection point
25357
25662
 
25358
25663
  do {
@@ -25361,22 +25666,15 @@ function findHoleBridge(hole, outerNode) {
25361
25666
 
25362
25667
  if (x <= hx && x > qx) {
25363
25668
  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
25669
  m = p.x < p.next.x ? p : p.next;
25670
+ if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint
25371
25671
  }
25372
25672
  }
25373
25673
 
25374
25674
  p = p.next;
25375
25675
  } while (p !== outerNode);
25376
25676
 
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;
25677
+ if (!m) return null; // look for points inside the triangle of hole point, segment intersection and endpoint;
25380
25678
  // if there are no points found, we have a valid connection;
25381
25679
  // otherwise choose the point of the minimum angle with the ray as connection point
25382
25680
 
@@ -25413,7 +25711,7 @@ function indexCurve(start, minX, minY, invSize) {
25413
25711
  let p = start;
25414
25712
 
25415
25713
  do {
25416
- if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, invSize);
25714
+ if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);
25417
25715
  p.prevZ = p.prev;
25418
25716
  p.nextZ = p.next;
25419
25717
  p = p.next;
@@ -25485,8 +25783,8 @@ function sortLinked(list) {
25485
25783
 
25486
25784
  function zOrder(x, y, minX, minY, invSize) {
25487
25785
  // coords are transformed into non-negative 15-bit integer range
25488
- x = 32767 * (x - minX) * invSize;
25489
- y = 32767 * (y - minY) * invSize;
25786
+ x = (x - minX) * invSize | 0;
25787
+ y = (y - minY) * invSize | 0;
25490
25788
  x = (x | x << 8) & 0x00FF00FF;
25491
25789
  x = (x | x << 4) & 0x0F0F0F0F;
25492
25790
  x = (x | x << 2) & 0x33333333;
@@ -25513,12 +25811,12 @@ function getLeftmost(start) {
25513
25811
 
25514
25812
 
25515
25813
  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;
25814
+ 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
25815
  } // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
25518
25816
 
25519
25817
 
25520
25818
  function isValidDiagonal(a, b) {
25521
- return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && ( // doesn't intersect other edges
25819
+ return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && ( // dones't intersect other edges
25522
25820
  locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && ( // locally visible
25523
25821
  area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
25524
25822
  equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
@@ -25646,7 +25944,7 @@ function Node(i, x, y) {
25646
25944
  this.prev = null;
25647
25945
  this.next = null; // z-order curve value
25648
25946
 
25649
- this.z = null; // previous and next nodes in z-order
25947
+ this.z = 0; // previous and next nodes in z-order
25650
25948
 
25651
25949
  this.prevZ = null;
25652
25950
  this.nextZ = null; // indicates whether this is a steiner point
@@ -26424,7 +26722,7 @@ class ShapeGeometry extends BufferGeometry {
26424
26722
  vertices.push(vertex.x, vertex.y, 0);
26425
26723
  normals.push(0, 0, 1);
26426
26724
  uvs.push(vertex.x, vertex.y); // world uvs
26427
- } // incides
26725
+ } // indices
26428
26726
 
26429
26727
 
26430
26728
  for (let i = 0, l = faces.length; i < l; i++) {
@@ -27119,7 +27417,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
27119
27417
  this.transmissionMap = null;
27120
27418
  this.thickness = 0;
27121
27419
  this.thicknessMap = null;
27122
- this.attenuationDistance = 0.0;
27420
+ this.attenuationDistance = Infinity;
27123
27421
  this.attenuationColor = new Color(1, 1, 1);
27124
27422
  this.specularIntensity = 1.0;
27125
27423
  this.specularIntensityMap = null;
@@ -29061,8 +29359,10 @@ class FileLoader extends Loader {
29061
29359
  }
29062
29360
 
29063
29361
  const callbacks = loading[url];
29064
- const reader = response.body.getReader();
29065
- const contentLength = response.headers.get('Content-Length');
29362
+ const reader = response.body.getReader(); // Nginx needs X-File-Size check
29363
+ // https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
29364
+
29365
+ const contentLength = response.headers.get('Content-Length') || response.headers.get('X-File-Size');
29066
29366
  const total = contentLength ? parseInt(contentLength) : 0;
29067
29367
  const lengthComputable = total !== 0;
29068
29368
  let loaded = 0; // periodically read data into the new stream tracking while download progress
@@ -29597,8 +29897,7 @@ class LightShadow {
29597
29897
  this._frustum.setFromProjectionMatrix(_projScreenMatrix$1);
29598
29898
 
29599
29899
  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);
29900
+ shadowMatrix.multiply(_projScreenMatrix$1);
29602
29901
  }
29603
29902
 
29604
29903
  getViewport(viewportIndex) {
@@ -29676,7 +29975,7 @@ class SpotLightShadow extends LightShadow {
29676
29975
  }
29677
29976
 
29678
29977
  class SpotLight extends Light {
29679
- constructor(color, intensity, distance = 0, angle = Math.PI / 3, penumbra = 0, decay = 1) {
29978
+ constructor(color, intensity, distance = 0, angle = Math.PI / 3, penumbra = 0, decay = 2) {
29680
29979
  super(color, intensity);
29681
29980
  this.isSpotLight = true;
29682
29981
  this.type = 'SpotLight';
@@ -29686,8 +29985,7 @@ class SpotLight extends Light {
29686
29985
  this.distance = distance;
29687
29986
  this.angle = angle;
29688
29987
  this.penumbra = penumbra;
29689
- this.decay = decay; // for physically correct lights, should be 2.
29690
-
29988
+ this.decay = decay;
29691
29989
  this.map = null;
29692
29990
  this.shadow = new SpotLightShadow();
29693
29991
  }
@@ -29786,13 +30084,12 @@ class PointLightShadow extends LightShadow {
29786
30084
  }
29787
30085
 
29788
30086
  class PointLight extends Light {
29789
- constructor(color, intensity, distance = 0, decay = 1) {
30087
+ constructor(color, intensity, distance = 0, decay = 2) {
29790
30088
  super(color, intensity);
29791
30089
  this.isPointLight = true;
29792
30090
  this.type = 'PointLight';
29793
30091
  this.distance = distance;
29794
- this.decay = decay; // for physically correct lights, should be 2.
29795
-
30092
+ this.decay = decay;
29796
30093
  this.shadow = new PointLightShadow();
29797
30094
  }
29798
30095
 
@@ -30415,12 +30712,8 @@ class InstancedBufferGeometry extends BufferGeometry {
30415
30712
  return this;
30416
30713
  }
30417
30714
 
30418
- clone() {
30419
- return new this.constructor().copy(this);
30420
- }
30421
-
30422
30715
  toJSON() {
30423
- const data = super.toJSON(this);
30716
+ const data = super.toJSON();
30424
30717
  data.instanceCount = this.instanceCount;
30425
30718
  data.isInstancedBufferGeometry = true;
30426
30719
  return data;
@@ -30601,6 +30894,7 @@ class ObjectLoader extends Loader {
30601
30894
  const metadata = json.metadata;
30602
30895
 
30603
30896
  if (metadata === undefined || metadata.type === undefined || metadata.type.toLowerCase() === 'geometry') {
30897
+ if (onError !== undefined) onError(new Error('THREE.ObjectLoader: Can\'t load ' + url));
30604
30898
  console.error('THREE.ObjectLoader: Can\'t load ' + url);
30605
30899
  return;
30606
30900
  }
@@ -31056,6 +31350,7 @@ class ObjectLoader extends Loader {
31056
31350
  }
31057
31351
  }
31058
31352
 
31353
+ if (data.backgroundBlurriness !== undefined) object.backgroundBlurriness = data.backgroundBlurriness;
31059
31354
  break;
31060
31355
 
31061
31356
  case 'PerspectiveCamera':
@@ -31221,7 +31516,7 @@ class ObjectLoader extends Loader {
31221
31516
  const child = object.getObjectByProperty('uuid', level.object);
31222
31517
 
31223
31518
  if (child !== undefined) {
31224
- object.addLevel(child, level.distance);
31519
+ object.addLevel(child, level.distance, level.hysteresis);
31225
31520
  }
31226
31521
  }
31227
31522
  }
@@ -31332,18 +31627,20 @@ class ImageBitmapLoader extends Loader {
31332
31627
 
31333
31628
  let _context;
31334
31629
 
31335
- const AudioContext = {
31336
- getContext: function () {
31630
+ class AudioContext {
31631
+ static getContext() {
31337
31632
  if (_context === undefined) {
31338
31633
  _context = new (window.AudioContext || window.webkitAudioContext)();
31339
31634
  }
31340
31635
 
31341
31636
  return _context;
31342
- },
31343
- setContext: function (value) {
31637
+ }
31638
+
31639
+ static setContext(value) {
31344
31640
  _context = value;
31345
31641
  }
31346
- };
31642
+
31643
+ }
31347
31644
 
31348
31645
  class AudioLoader extends Loader {
31349
31646
  constructor(manager) {
@@ -32587,6 +32884,11 @@ class PropertyBinding {
32587
32884
  break;
32588
32885
 
32589
32886
  case 'map':
32887
+ if ('map' in targetObject) {
32888
+ targetObject = targetObject.map;
32889
+ break;
32890
+ }
32891
+
32590
32892
  if (!targetObject.material) {
32591
32893
  console.error('THREE.PropertyBinding: Can not bind to material as node does not have a material.', this);
32592
32894
  return;
@@ -34575,10 +34877,10 @@ class SpotLightHelper extends Object3D {
34575
34877
  constructor(light, color) {
34576
34878
  super();
34577
34879
  this.light = light;
34578
- this.light.updateMatrixWorld();
34579
34880
  this.matrix = light.matrixWorld;
34580
34881
  this.matrixAutoUpdate = false;
34581
34882
  this.color = color;
34883
+ this.type = 'SpotLightHelper';
34582
34884
  const geometry = new BufferGeometry();
34583
34885
  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
34886
 
@@ -34604,7 +34906,8 @@ class SpotLightHelper extends Object3D {
34604
34906
  }
34605
34907
 
34606
34908
  update() {
34607
- this.light.updateMatrixWorld();
34909
+ this.light.updateWorldMatrix(true, false);
34910
+ this.light.target.updateWorldMatrix(true, false);
34608
34911
  const coneLength = this.light.distance ? this.light.distance : 1000;
34609
34912
  const coneWidth = coneLength * Math.tan(this.light.angle);
34610
34913
  this.cone.scale.set(coneWidth, coneWidth, coneLength);
@@ -34696,6 +34999,11 @@ class SkeletonHelper extends LineSegments {
34696
34999
  super.updateMatrixWorld(force);
34697
35000
  }
34698
35001
 
35002
+ dispose() {
35003
+ this.geometry.dispose();
35004
+ this.material.dispose();
35005
+ }
35006
+
34699
35007
  }
34700
35008
 
34701
35009
  function getBoneList(object) {
@@ -34722,7 +35030,6 @@ class PointLightHelper extends Mesh {
34722
35030
  });
34723
35031
  super(geometry, material);
34724
35032
  this.light = light;
34725
- this.light.updateMatrixWorld();
34726
35033
  this.color = color;
34727
35034
  this.type = 'PointLightHelper';
34728
35035
  this.matrix = this.light.matrixWorld;
@@ -34750,6 +35057,8 @@ class PointLightHelper extends Mesh {
34750
35057
  }
34751
35058
 
34752
35059
  update() {
35060
+ this.light.updateWorldMatrix(true, false);
35061
+
34753
35062
  if (this.color !== undefined) {
34754
35063
  this.material.color.set(this.color);
34755
35064
  } else {
@@ -34779,10 +35088,10 @@ class HemisphereLightHelper extends Object3D {
34779
35088
  constructor(light, size, color) {
34780
35089
  super();
34781
35090
  this.light = light;
34782
- this.light.updateMatrixWorld();
34783
35091
  this.matrix = light.matrixWorld;
34784
35092
  this.matrixAutoUpdate = false;
34785
35093
  this.color = color;
35094
+ this.type = 'HemisphereLightHelper';
34786
35095
  const geometry = new OctahedronGeometry(size);
34787
35096
  geometry.rotateY(Math.PI * 0.5);
34788
35097
  this.material = new MeshBasicMaterial({
@@ -34823,6 +35132,7 @@ class HemisphereLightHelper extends Object3D {
34823
35132
  colors.needsUpdate = true;
34824
35133
  }
34825
35134
 
35135
+ this.light.updateWorldMatrix(true, false);
34826
35136
  mesh.lookAt(_vector$1.setFromMatrixPosition(this.light.matrixWorld).negate());
34827
35137
  }
34828
35138
 
@@ -34863,6 +35173,11 @@ class GridHelper extends LineSegments {
34863
35173
  this.type = 'GridHelper';
34864
35174
  }
34865
35175
 
35176
+ dispose() {
35177
+ this.geometry.dispose();
35178
+ this.material.dispose();
35179
+ }
35180
+
34866
35181
  }
34867
35182
 
34868
35183
  class PolarGridHelper extends LineSegments {
@@ -34917,6 +35232,11 @@ class PolarGridHelper extends LineSegments {
34917
35232
  this.type = 'PolarGridHelper';
34918
35233
  }
34919
35234
 
35235
+ dispose() {
35236
+ this.geometry.dispose();
35237
+ this.material.dispose();
35238
+ }
35239
+
34920
35240
  }
34921
35241
 
34922
35242
  const _v1 = /*@__PURE__*/new Vector3();
@@ -34929,10 +35249,10 @@ class DirectionalLightHelper extends Object3D {
34929
35249
  constructor(light, size, color) {
34930
35250
  super();
34931
35251
  this.light = light;
34932
- this.light.updateMatrixWorld();
34933
35252
  this.matrix = light.matrixWorld;
34934
35253
  this.matrixAutoUpdate = false;
34935
35254
  this.color = color;
35255
+ this.type = 'DirectionalLightHelper';
34936
35256
  if (size === undefined) size = 1;
34937
35257
  let geometry = new BufferGeometry();
34938
35258
  geometry.setAttribute('position', new Float32BufferAttribute([-size, size, 0, size, size, 0, size, -size, 0, -size, -size, 0, -size, size, 0], 3));
@@ -34957,6 +35277,9 @@ class DirectionalLightHelper extends Object3D {
34957
35277
  }
34958
35278
 
34959
35279
  update() {
35280
+ this.light.updateWorldMatrix(true, false);
35281
+ this.light.target.updateWorldMatrix(true, false);
35282
+
34960
35283
  _v1.setFromMatrixPosition(this.light.matrixWorld);
34961
35284
 
34962
35285
  _v2.setFromMatrixPosition(this.light.target.matrixWorld);
@@ -35304,6 +35627,11 @@ class BoxHelper extends LineSegments {
35304
35627
  return this;
35305
35628
  }
35306
35629
 
35630
+ dispose() {
35631
+ this.geometry.dispose();
35632
+ this.material.dispose();
35633
+ }
35634
+
35307
35635
  }
35308
35636
 
35309
35637
  class Box3Helper extends LineSegments {
@@ -35331,6 +35659,11 @@ class Box3Helper extends LineSegments {
35331
35659
  super.updateMatrixWorld(force);
35332
35660
  }
35333
35661
 
35662
+ dispose() {
35663
+ this.geometry.dispose();
35664
+ this.material.dispose();
35665
+ }
35666
+
35334
35667
  }
35335
35668
 
35336
35669
  class PlaneHelper extends Line {
@@ -35368,6 +35701,13 @@ class PlaneHelper extends Line {
35368
35701
  super.updateMatrixWorld(force);
35369
35702
  }
35370
35703
 
35704
+ dispose() {
35705
+ this.geometry.dispose();
35706
+ this.material.dispose();
35707
+ this.children[0].geometry.dispose();
35708
+ this.children[0].material.dispose();
35709
+ }
35710
+
35371
35711
  }
35372
35712
 
35373
35713
  const _axis = /*@__PURE__*/new Vector3();
@@ -35442,6 +35782,13 @@ class ArrowHelper extends Object3D {
35442
35782
  return this;
35443
35783
  }
35444
35784
 
35785
+ dispose() {
35786
+ this.line.geometry.dispose();
35787
+ this.line.material.dispose();
35788
+ this.cone.geometry.dispose();
35789
+ this.cone.material.dispose();
35790
+ }
35791
+
35445
35792
  }
35446
35793
 
35447
35794
  class AxesHelper extends LineSegments {
@@ -36059,6 +36406,7 @@ exports.Clock = Clock;
36059
36406
  exports.Color = Color;
36060
36407
  exports.ColorKeyframeTrack = ColorKeyframeTrack;
36061
36408
  exports.ColorManagement = ColorManagement;
36409
+ exports.CompressedArrayTexture = CompressedArrayTexture;
36062
36410
  exports.CompressedTexture = CompressedTexture;
36063
36411
  exports.CompressedTextureLoader = CompressedTextureLoader;
36064
36412
  exports.ConeBufferGeometry = ConeBufferGeometry;