super-three 0.133.3 → 0.136.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 (354) hide show
  1. package/build/three.js +1059 -783
  2. package/build/three.min.js +1 -1
  3. package/build/three.module.js +1424 -895
  4. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
  5. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
  6. package/examples/fonts/open-sans/open-sans.css +9 -0
  7. package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
  8. package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +3966 -0
  9. package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
  10. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
  11. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
  12. package/examples/fonts/tabler-icons/tabler-icons.min.css +4 -0
  13. package/examples/js/animation/CCDIKSolver.js +0 -1
  14. package/examples/js/animation/MMDPhysics.js +1 -3
  15. package/examples/js/controls/ArcballControls.js +99 -72
  16. package/examples/js/controls/DragControls.js +7 -0
  17. package/examples/js/controls/OrbitControls.js +5 -36
  18. package/examples/js/controls/TrackballControls.js +3 -2
  19. package/examples/js/controls/TransformControls.js +24 -1
  20. package/examples/js/csm/CSM.js +2 -2
  21. package/examples/js/csm/CSMFrustum.js +133 -0
  22. package/examples/js/curves/CurveExtras.js +0 -2
  23. package/examples/js/effects/AsciiEffect.js +2 -9
  24. package/examples/js/exporters/GLTFExporter.js +148 -64
  25. package/examples/js/exporters/USDZExporter.js +45 -26
  26. package/examples/js/geometries/TeapotGeometry.js +0 -1
  27. package/examples/js/interactive/SelectionBox.js +2 -0
  28. package/examples/js/interactive/SelectionHelper.js +22 -7
  29. package/examples/js/lights/RectAreaLightUniformsLib.js +4 -0
  30. package/examples/js/lines/LineMaterial.js +58 -20
  31. package/examples/js/lines/LineSegments2.js +29 -24
  32. package/examples/js/loaders/3DMLoader.js +24 -11
  33. package/examples/js/loaders/3MFLoader.js +2 -2
  34. package/examples/js/loaders/AMFLoader.js +0 -2
  35. package/examples/js/loaders/ColladaLoader.js +61 -4
  36. package/examples/js/loaders/EXRLoader.js +185 -262
  37. package/examples/js/loaders/FBXLoader.js +4 -5
  38. package/examples/js/loaders/GLTFLoader.js +96 -33
  39. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -8
  40. package/examples/js/loaders/KTX2Loader.js +23 -2
  41. package/examples/js/loaders/KTXLoader.js +1 -1
  42. package/examples/js/loaders/LDrawLoader.js +26 -30
  43. package/examples/js/loaders/LUT3dlLoader.js +2 -0
  44. package/examples/js/loaders/LUTCubeLoader.js +2 -0
  45. package/examples/js/loaders/LWOLoader.js +8 -6
  46. package/examples/js/loaders/LogLuvLoader.js +766 -0
  47. package/examples/js/loaders/MMDLoader.js +0 -1
  48. package/examples/js/loaders/NRRDLoader.js +9 -2
  49. package/examples/js/loaders/OBJLoader.js +0 -2
  50. package/examples/js/loaders/PLYLoader.js +33 -8
  51. package/examples/js/loaders/RGBELoader.js +2 -16
  52. package/examples/js/loaders/RGBMLoader.js +55 -5
  53. package/examples/js/loaders/SVGLoader.js +9 -5
  54. package/examples/js/loaders/TDSLoader.js +237 -271
  55. package/examples/js/loaders/VOXLoader.js +1 -0
  56. package/examples/js/loaders/VRMLLoader.js +2 -1
  57. package/examples/js/loaders/lwo/LWO2Parser.js +1 -0
  58. package/examples/js/loaders/lwo/LWO3Parser.js +4 -2
  59. package/examples/js/math/ImprovedNoise.js +1 -1
  60. package/examples/js/misc/GPUComputationRenderer.js +3 -1
  61. package/examples/js/objects/Lensflare.js +2 -10
  62. package/examples/js/objects/MarchingCubes.js +42 -128
  63. package/examples/js/objects/Reflector.js +7 -0
  64. package/examples/js/objects/Refractor.js +7 -0
  65. package/examples/js/objects/Sky.js +1 -1
  66. package/examples/js/objects/Water.js +2 -2
  67. package/examples/js/objects/Water2.js +4 -7
  68. package/examples/js/postprocessing/GlitchPass.js +3 -1
  69. package/examples/js/postprocessing/SSAOPass.js +1 -0
  70. package/examples/js/renderers/CSS2DRenderer.js +4 -4
  71. package/examples/js/renderers/CSS3DRenderer.js +4 -4
  72. package/examples/js/shaders/ConvolutionShader.js +0 -1
  73. package/examples/js/shaders/FXAAShader.js +1 -1
  74. package/examples/js/shaders/FilmShader.js +1 -1
  75. package/examples/js/shaders/GammaCorrectionShader.js +1 -1
  76. package/examples/js/shaders/HorizontalBlurShader.js +1 -2
  77. package/examples/js/shaders/SSRShader.js +1 -1
  78. package/examples/js/shaders/SSRrShader.js +1 -1
  79. package/examples/js/shaders/VerticalBlurShader.js +1 -2
  80. package/examples/js/utils/GeometryUtils.js +1 -1
  81. package/examples/js/utils/RoughnessMipmapper.js +18 -28
  82. package/examples/jsm/animation/CCDIKSolver.js +0 -1
  83. package/examples/jsm/animation/MMDPhysics.js +0 -2
  84. package/examples/jsm/controls/ArcballControls.js +80 -77
  85. package/examples/jsm/controls/DragControls.js +7 -0
  86. package/examples/jsm/controls/OrbitControls.js +9 -51
  87. package/examples/jsm/controls/TrackballControls.js +1 -1
  88. package/examples/jsm/controls/TransformControls.js +24 -1
  89. package/examples/jsm/csm/CSM.js +3 -3
  90. package/examples/jsm/csm/{Frustum.js → CSMFrustum.js} +3 -3
  91. package/examples/jsm/curves/CurveExtras.js +0 -2
  92. package/examples/jsm/effects/AsciiEffect.js +2 -9
  93. package/examples/jsm/exporters/GLTFExporter.js +161 -75
  94. package/examples/jsm/exporters/USDZExporter.js +47 -26
  95. package/examples/jsm/geometries/TeapotGeometry.js +0 -1
  96. package/examples/jsm/interactive/SelectionBox.js +1 -0
  97. package/examples/jsm/interactive/SelectionHelper.js +19 -7
  98. package/examples/jsm/libs/flow.module.js +3338 -0
  99. package/examples/jsm/libs/lil-gui.module.min.js +8 -0
  100. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  101. package/examples/jsm/lights/RectAreaLightUniformsLib.js +7 -0
  102. package/examples/jsm/lines/LineMaterial.js +59 -23
  103. package/examples/jsm/lines/LineSegments2.js +22 -18
  104. package/examples/jsm/loaders/3DMLoader.js +18 -12
  105. package/examples/jsm/loaders/3MFLoader.js +2 -2
  106. package/examples/jsm/loaders/AMFLoader.js +0 -2
  107. package/examples/jsm/loaders/ColladaLoader.js +61 -4
  108. package/examples/jsm/loaders/EXRLoader.js +184 -293
  109. package/examples/jsm/loaders/FBXLoader.js +4 -5
  110. package/examples/jsm/loaders/GLTFLoader.js +101 -37
  111. package/examples/jsm/loaders/HDRCubeTextureLoader.js +1 -14
  112. package/examples/jsm/loaders/KTX2Loader.js +30 -2
  113. package/examples/jsm/loaders/KTXLoader.js +1 -1
  114. package/examples/jsm/loaders/LDrawLoader.js +23 -24
  115. package/examples/jsm/loaders/LUT3dlLoader.js +2 -0
  116. package/examples/jsm/loaders/LUTCubeLoader.js +2 -0
  117. package/examples/jsm/loaders/LWOLoader.js +8 -6
  118. package/examples/jsm/loaders/LogLuvLoader.js +606 -0
  119. package/examples/jsm/loaders/MMDLoader.js +0 -1
  120. package/examples/jsm/loaders/NRRDLoader.js +10 -2
  121. package/examples/jsm/loaders/OBJLoader.js +0 -2
  122. package/examples/jsm/loaders/PLYLoader.js +34 -8
  123. package/examples/jsm/loaders/RGBELoader.js +0 -20
  124. package/examples/jsm/loaders/RGBMLoader.js +61 -7
  125. package/examples/jsm/loaders/SVGLoader.js +9 -6
  126. package/examples/jsm/loaders/TDSLoader.js +236 -275
  127. package/examples/jsm/loaders/VOXLoader.js +1 -0
  128. package/examples/jsm/loaders/VRMLLoader.js +2 -1
  129. package/examples/jsm/loaders/lwo/LWO2Parser.js +1 -0
  130. package/examples/jsm/loaders/lwo/LWO3Parser.js +2 -2
  131. package/examples/jsm/math/ImprovedNoise.js +1 -1
  132. package/examples/jsm/misc/GPUComputationRenderer.js +3 -1
  133. package/examples/jsm/node-editor/NodeEditor.js +456 -0
  134. package/examples/jsm/node-editor/accessors/NormalEditor.js +30 -0
  135. package/examples/jsm/node-editor/accessors/PositionEditor.js +30 -0
  136. package/examples/jsm/node-editor/accessors/UVEditor.js +26 -0
  137. package/examples/jsm/node-editor/display/BlendEditor.js +43 -0
  138. package/examples/jsm/node-editor/examples/animate-uv.json +1 -0
  139. package/examples/jsm/node-editor/examples/fake-top-light.json +1 -0
  140. package/examples/jsm/node-editor/examples/oscillator-color.json +1 -0
  141. package/examples/jsm/node-editor/examples/rim.json +1 -0
  142. package/examples/jsm/node-editor/inputs/ColorEditor.js +91 -0
  143. package/examples/jsm/node-editor/inputs/FloatEditor.js +24 -0
  144. package/examples/jsm/node-editor/inputs/SliderEditor.js +68 -0
  145. package/examples/jsm/node-editor/inputs/Vector2Editor.js +28 -0
  146. package/examples/jsm/node-editor/inputs/Vector3Editor.js +30 -0
  147. package/examples/jsm/node-editor/inputs/Vector4Editor.js +37 -0
  148. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +108 -0
  149. package/examples/jsm/node-editor/math/DotEditor.js +36 -0
  150. package/examples/jsm/node-editor/math/InvertEditor.js +38 -0
  151. package/examples/jsm/node-editor/math/LimiterEditor.js +48 -0
  152. package/examples/jsm/node-editor/math/NormalizeEditor.js +26 -0
  153. package/examples/jsm/node-editor/math/OperatorEditor.js +50 -0
  154. package/examples/jsm/node-editor/math/PowerEditor.js +34 -0
  155. package/examples/jsm/node-editor/math/TrigonometryEditor.js +39 -0
  156. package/examples/jsm/node-editor/procedural/CheckerEditor.js +26 -0
  157. package/examples/jsm/node-editor/utils/OscillatorEditor.js +42 -0
  158. package/examples/jsm/node-editor/utils/TimerEditor.js +57 -0
  159. package/examples/jsm/nodes/core/NodeBuilder.js +2 -2
  160. package/examples/jsm/nodes/materials/StandardNodeMaterial.js +1 -1
  161. package/examples/jsm/nodes/materials/nodes/StandardNode.js +7 -6
  162. package/examples/jsm/nodes/math/MathNode.js +12 -0
  163. package/examples/jsm/nodes/misc/BumpMapNode.js +1 -1
  164. package/examples/jsm/nodes/misc/TextureCubeUVNode.js +1 -4
  165. package/examples/jsm/nodes/utils/ColorSpaceNode.js +1 -164
  166. package/examples/jsm/objects/Lensflare.js +3 -14
  167. package/examples/jsm/objects/MarchingCubes.js +46 -152
  168. package/examples/jsm/objects/Reflector.js +7 -0
  169. package/examples/jsm/objects/Refractor.js +7 -0
  170. package/examples/jsm/objects/Sky.js +1 -1
  171. package/examples/jsm/objects/Water.js +2 -2
  172. package/examples/jsm/objects/Water2.js +4 -8
  173. package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +1 -1
  174. package/examples/jsm/postprocessing/AfterimagePass.js +1 -1
  175. package/examples/jsm/postprocessing/BloomPass.js +1 -1
  176. package/examples/jsm/postprocessing/BokehPass.js +1 -1
  177. package/examples/jsm/postprocessing/ClearPass.js +1 -1
  178. package/examples/jsm/postprocessing/CubeTexturePass.js +1 -1
  179. package/examples/jsm/postprocessing/DotScreenPass.js +1 -1
  180. package/examples/jsm/postprocessing/EffectComposer.js +3 -3
  181. package/examples/jsm/postprocessing/FilmPass.js +1 -1
  182. package/examples/jsm/postprocessing/GlitchPass.js +4 -2
  183. package/examples/jsm/postprocessing/HalftonePass.js +1 -1
  184. package/examples/jsm/postprocessing/MaskPass.js +1 -1
  185. package/examples/jsm/postprocessing/OutlinePass.js +1 -1
  186. package/examples/jsm/postprocessing/RenderPass.js +1 -1
  187. package/examples/jsm/postprocessing/SAOPass.js +2 -2
  188. package/examples/jsm/postprocessing/SMAAPass.js +1 -1
  189. package/examples/jsm/postprocessing/SSAARenderPass.js +1 -1
  190. package/examples/jsm/postprocessing/SSAOPass.js +2 -1
  191. package/examples/jsm/postprocessing/SSRPass.js +1 -1
  192. package/examples/jsm/postprocessing/SSRrPass.js +1 -1
  193. package/examples/jsm/postprocessing/SavePass.js +1 -1
  194. package/examples/jsm/postprocessing/ShaderPass.js +1 -1
  195. package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
  196. package/examples/jsm/postprocessing/TexturePass.js +1 -1
  197. package/examples/jsm/postprocessing/UnrealBloomPass.js +1 -1
  198. package/examples/jsm/renderers/CSS2DRenderer.js +5 -4
  199. package/examples/jsm/renderers/CSS3DRenderer.js +5 -4
  200. package/examples/jsm/renderers/nodes/Nodes.js +15 -13
  201. package/examples/jsm/renderers/nodes/ShaderNode.js +194 -41
  202. package/examples/jsm/renderers/nodes/accessors/MaterialNode.js +6 -6
  203. package/examples/jsm/renderers/nodes/accessors/ModelViewProjectionNode.js +5 -5
  204. package/examples/jsm/renderers/nodes/accessors/NormalNode.js +14 -3
  205. package/examples/jsm/renderers/nodes/accessors/PointUVNode.js +3 -3
  206. package/examples/jsm/renderers/nodes/accessors/PositionNode.js +15 -5
  207. package/examples/jsm/renderers/nodes/accessors/SkinningNode.js +107 -0
  208. package/examples/jsm/renderers/nodes/accessors/UVNode.js +7 -5
  209. package/examples/jsm/renderers/nodes/core/ArrayInputNode.js +3 -3
  210. package/examples/jsm/renderers/nodes/core/AttributeNode.js +6 -0
  211. package/examples/jsm/renderers/nodes/core/BypassNode.js +38 -0
  212. package/examples/jsm/renderers/nodes/core/CodeNode.js +3 -3
  213. package/examples/jsm/renderers/nodes/core/ContextNode.js +4 -19
  214. package/examples/jsm/renderers/nodes/core/ExpressionNode.js +13 -2
  215. package/examples/jsm/renderers/nodes/core/FunctionNode.js +19 -132
  216. package/examples/jsm/renderers/nodes/core/InputNode.js +13 -3
  217. package/examples/jsm/renderers/nodes/core/Node.js +32 -10
  218. package/examples/jsm/renderers/nodes/core/NodeBuilder.js +146 -128
  219. package/examples/jsm/renderers/nodes/core/NodeFunction.js +22 -0
  220. package/examples/jsm/renderers/nodes/core/NodeFunctionInput.js +4 -4
  221. package/examples/jsm/renderers/nodes/core/NodeKeywords.js +18 -179
  222. package/examples/jsm/renderers/nodes/core/NodeParser.js +11 -0
  223. package/examples/jsm/renderers/nodes/core/NodeVar.js +2 -2
  224. package/examples/jsm/renderers/nodes/core/PropertyNode.js +14 -2
  225. package/examples/jsm/renderers/nodes/core/TempNode.js +10 -13
  226. package/examples/jsm/renderers/nodes/core/VarNode.js +12 -7
  227. package/examples/jsm/renderers/nodes/core/VaryNode.js +23 -8
  228. package/examples/jsm/renderers/nodes/core/constants.js +2 -0
  229. package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +60 -43
  230. package/examples/jsm/renderers/nodes/display/NormalMapNode.js +21 -22
  231. package/examples/jsm/renderers/nodes/functions/BSDFs.js +64 -101
  232. package/examples/jsm/renderers/nodes/functions/PhysicalMaterialFunctions.js +27 -0
  233. package/examples/jsm/renderers/nodes/inputs/BufferNode.js +25 -0
  234. package/examples/jsm/renderers/nodes/inputs/IntNode.js +17 -0
  235. package/examples/jsm/renderers/nodes/inputs/TextureNode.js +10 -2
  236. package/examples/jsm/renderers/nodes/lights/LightContextNode.js +20 -14
  237. package/examples/jsm/renderers/nodes/lights/LightNode.js +32 -36
  238. package/examples/jsm/renderers/nodes/math/CondNode.js +60 -0
  239. package/examples/jsm/renderers/nodes/math/MathNode.js +90 -37
  240. package/examples/jsm/renderers/nodes/math/OperatorNode.js +124 -31
  241. package/examples/jsm/renderers/nodes/parsers/GLSLNodeFunction.js +137 -0
  242. package/examples/jsm/renderers/nodes/parsers/GLSLNodeParser.js +14 -0
  243. package/examples/jsm/renderers/nodes/parsers/WGSLNodeFunction.js +89 -0
  244. package/examples/jsm/renderers/nodes/parsers/WGSLNodeParser.js +14 -0
  245. package/examples/jsm/renderers/nodes/procedural/CheckerNode.js +7 -9
  246. package/examples/jsm/renderers/nodes/utils/ArrayElementNode.js +31 -0
  247. package/examples/jsm/renderers/nodes/utils/ConvertNode.js +33 -0
  248. package/examples/jsm/renderers/nodes/utils/JoinNode.js +7 -7
  249. package/examples/jsm/renderers/nodes/utils/OscNode.js +58 -0
  250. package/examples/jsm/renderers/nodes/utils/SplitNode.js +18 -8
  251. package/examples/jsm/renderers/nodes/utils/SpriteSheetUVNode.js +7 -7
  252. package/examples/jsm/renderers/nodes/utils/TimerNode.js +1 -1
  253. package/examples/jsm/renderers/webgl/nodes/SlotNode.js +22 -0
  254. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +192 -95
  255. package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +2 -2
  256. package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +2 -2
  257. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +1 -1
  258. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +10 -9
  259. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +2 -4
  260. package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +2 -4
  261. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +15 -23
  262. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +44 -65
  263. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +12 -28
  264. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +61 -28
  265. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +34 -27
  266. package/examples/jsm/renderers/webgpu/constants.js +2 -2
  267. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +453 -95
  268. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
  269. package/examples/jsm/shaders/ConvolutionShader.js +0 -1
  270. package/examples/jsm/shaders/FXAAShader.js +1 -1
  271. package/examples/jsm/shaders/FilmShader.js +1 -1
  272. package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
  273. package/examples/jsm/shaders/HorizontalBlurShader.js +1 -2
  274. package/examples/jsm/shaders/SSRShader.js +1 -1
  275. package/examples/jsm/shaders/SSRrShader.js +1 -1
  276. package/examples/jsm/shaders/VerticalBlurShader.js +1 -2
  277. package/examples/jsm/utils/GeometryUtils.js +1 -1
  278. package/examples/jsm/utils/RoughnessMipmapper.js +19 -31
  279. package/examples/jsm/utils/WorkerPool.js +11 -11
  280. package/examples/jsm/webxr/OculusHandPointerModel.js +6 -6
  281. package/package.json +24 -18
  282. package/src/Three.Legacy.js +18 -0
  283. package/src/Three.js +1 -3
  284. package/src/cameras/StereoCamera.js +8 -7
  285. package/src/constants.js +1 -8
  286. package/src/core/Layers.js +7 -1
  287. package/src/core/Object3D.js +3 -1
  288. package/src/extras/PMREMGenerator.js +23 -109
  289. package/src/extras/core/Interpolations.js +1 -1
  290. package/src/geometries/LatheGeometry.js +70 -47
  291. package/src/helpers/CameraHelper.js +1 -1
  292. package/src/loaders/FileLoader.js +98 -144
  293. package/src/loaders/ImageLoader.js +9 -4
  294. package/src/loaders/LoaderUtils.js +26 -0
  295. package/src/loaders/MaterialLoader.js +7 -4
  296. package/src/loaders/ObjectLoader.js +2 -0
  297. package/src/materials/Material.js +4 -4
  298. package/src/materials/MeshPhysicalMaterial.js +20 -14
  299. package/src/math/Color.js +0 -38
  300. package/src/math/MathUtils.js +5 -16
  301. package/src/math/Ray.js +2 -2
  302. package/src/math/Sphere.js +10 -1
  303. package/src/objects/Skeleton.js +1 -0
  304. package/src/renderers/WebGLMultisampleRenderTarget.js +7 -1
  305. package/src/renderers/WebGLRenderer.js +105 -132
  306. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +2 -2
  307. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +1 -1
  308. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +2 -24
  309. package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -74
  310. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
  311. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +1 -1
  312. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +19 -6
  313. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +28 -2
  314. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
  315. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
  316. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +1 -1
  317. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +23 -5
  318. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +2 -1
  319. package/src/renderers/shaders/ShaderLib.js +6 -4
  320. package/src/renderers/shaders/UniformsLib.js +1 -2
  321. package/src/renderers/webgl/WebGLCapabilities.js +0 -2
  322. package/src/renderers/webgl/WebGLExtensions.js +1 -0
  323. package/src/renderers/webgl/WebGLMaterials.js +27 -15
  324. package/src/renderers/webgl/WebGLMorphtargets.js +1 -0
  325. package/src/renderers/webgl/WebGLProgram.js +11 -24
  326. package/src/renderers/webgl/WebGLPrograms.js +194 -33
  327. package/src/renderers/webgl/WebGLRenderLists.js +4 -14
  328. package/src/renderers/webgl/WebGLShaderCache.js +120 -0
  329. package/src/renderers/webgl/WebGLShadowMap.js +14 -5
  330. package/src/renderers/webgl/WebGLState.js +76 -17
  331. package/src/renderers/webgl/WebGLTextures.js +367 -61
  332. package/src/renderers/webgl/WebGLUniforms.js +45 -1
  333. package/src/renderers/webxr/WebXRManager.js +77 -109
  334. package/src/scenes/Scene.js +1 -1
  335. package/src/textures/DataTexture.js +0 -2
  336. package/src/textures/DataTexture2DArray.js +0 -2
  337. package/src/textures/DataTexture3D.js +0 -2
  338. package/src/textures/FramebufferTexture.js +25 -0
  339. package/src/textures/Texture.js +6 -0
  340. package/examples/js/controls/DeviceOrientationControls.js +0 -147
  341. package/examples/js/libs/dat.gui.min.js +0 -14
  342. package/examples/jsm/controls/DeviceOrientationControls.js +0 -153
  343. package/examples/jsm/libs/dat.gui.module.js +0 -3575
  344. package/examples/jsm/libs/glslang.js +0 -78
  345. package/examples/jsm/libs/glslang.wasm +0 -0
  346. package/examples/jsm/renderers/nodes/consts/MathConsts.js +0 -7
  347. package/examples/jsm/renderers/nodes/core/ConstNode.js +0 -39
  348. package/examples/jsm/renderers/nodes/core/NodeSlot.js +0 -13
  349. package/examples/jsm/renderers/nodes/core/StructNode.js +0 -80
  350. package/examples/jsm/renderers/nodes/core/StructVarNode.js +0 -75
  351. package/examples/jsm/renderers/nodes/functions/EncodingFunctions.js +0 -99
  352. package/examples/jsm/renderers/nodes/functions/MathFunctions.js +0 -47
  353. package/examples/jsm/renderers/webgpu/nodes/ShaderLib.js +0 -152
  354. package/src/extras/objects/ImmediateRenderObject.js +0 -31
@@ -3,7 +3,7 @@
3
3
  * Copyright 2010-2021 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
5
  */
6
- const REVISION = '133';
6
+ const REVISION = '136';
7
7
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
8
8
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
9
9
  const CullFaceNone = 0;
@@ -96,7 +96,6 @@ const RGBFormat = 1022;
96
96
  const RGBAFormat = 1023;
97
97
  const LuminanceFormat = 1024;
98
98
  const LuminanceAlphaFormat = 1025;
99
- const RGBEFormat = RGBAFormat;
100
99
  const DepthFormat = 1026;
101
100
  const DepthStencilFormat = 1027;
102
101
  const RedFormat = 1028;
@@ -162,12 +161,6 @@ const TriangleStripDrawMode = 1;
162
161
  const TriangleFanDrawMode = 2;
163
162
  const LinearEncoding = 3000;
164
163
  const sRGBEncoding = 3001;
165
- const GammaEncoding = 3007;
166
- const RGBEEncoding = 3002;
167
- const LogLuvEncoding = 3003;
168
- const RGBM7Encoding = 3004;
169
- const RGBM16Encoding = 3005;
170
- const RGBDEncoding = 3006;
171
164
  const BasicDepthPacking = 3200;
172
165
  const RGBADepthPacking = 3201;
173
166
  const TangentSpaceNormalMap = 0;
@@ -289,13 +282,6 @@ class EventDispatcher {
289
282
 
290
283
  }
291
284
 
292
- let _seed = 1234567;
293
-
294
- const DEG2RAD = Math.PI / 180;
295
- const RAD2DEG = 180 / Math.PI;
296
-
297
- //
298
-
299
285
  const _lut = [];
300
286
 
301
287
  for ( let i = 0; i < 256; i ++ ) {
@@ -304,18 +290,14 @@ for ( let i = 0; i < 256; i ++ ) {
304
290
 
305
291
  }
306
292
 
307
- const hasRandomUUID = typeof crypto !== 'undefined' && 'randomUUID' in crypto;
308
-
309
- function generateUUID() {
310
-
311
- if ( hasRandomUUID ) {
293
+ let _seed = 1234567;
312
294
 
313
- return crypto.randomUUID().toUpperCase();
314
295
 
315
- }
296
+ const DEG2RAD = Math.PI / 180;
297
+ const RAD2DEG = 180 / Math.PI;
316
298
 
317
- // TODO Remove this code when crypto.randomUUID() is available everywhere
318
- // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
299
+ // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
300
+ function generateUUID() {
319
301
 
320
302
  const d0 = Math.random() * 0xffffffff | 0;
321
303
  const d1 = Math.random() * 0xffffffff | 0;
@@ -1531,6 +1513,8 @@ class Texture extends EventDispatcher {
1531
1513
  // update. You need to explicitly call Material.needsUpdate to trigger it to recompile.
1532
1514
  this.encoding = encoding;
1533
1515
 
1516
+ this.userData = {};
1517
+
1534
1518
  this.version = 0;
1535
1519
  this.onUpdate = null;
1536
1520
 
@@ -1585,6 +1569,8 @@ class Texture extends EventDispatcher {
1585
1569
  this.unpackAlignment = source.unpackAlignment;
1586
1570
  this.encoding = source.encoding;
1587
1571
 
1572
+ this.userData = JSON.parse( JSON.stringify( source.userData ) );
1573
+
1588
1574
  return this;
1589
1575
 
1590
1576
  }
@@ -1691,6 +1677,8 @@ class Texture extends EventDispatcher {
1691
1677
 
1692
1678
  }
1693
1679
 
1680
+ if ( JSON.stringify( this.userData ) !== '{}' ) output.userData = this.userData;
1681
+
1694
1682
  if ( ! isRootObject ) {
1695
1683
 
1696
1684
  meta.textures[ this.uuid ] = output;
@@ -2678,12 +2666,16 @@ WebGLMultipleRenderTargets.prototype.isWebGLMultipleRenderTargets = true;
2678
2666
 
2679
2667
  class WebGLMultisampleRenderTarget extends WebGLRenderTarget {
2680
2668
 
2681
- constructor( width, height, options ) {
2669
+ constructor( width, height, options = {} ) {
2682
2670
 
2683
2671
  super( width, height, options );
2684
2672
 
2685
2673
  this.samples = 4;
2686
2674
 
2675
+ this.ignoreDepthForMultisampleCopy = options.ignoreDepth !== undefined ? options.ignoreDepth : true;
2676
+ this.useRenderToTexture = ( options.useRenderToTexture !== undefined ) ? options.useRenderToTexture : false;
2677
+ this.useRenderbuffer = this.useRenderToTexture === false;
2678
+
2687
2679
  }
2688
2680
 
2689
2681
  copy( source ) {
@@ -2691,6 +2683,8 @@ class WebGLMultisampleRenderTarget extends WebGLRenderTarget {
2691
2683
  super.copy.call( this, source );
2692
2684
 
2693
2685
  this.samples = source.samples;
2686
+ this.useRenderToTexture = source.useRenderToTexture;
2687
+ this.useRenderbuffer = source.useRenderbuffer;
2694
2688
 
2695
2689
  return this;
2696
2690
 
@@ -4834,7 +4828,16 @@ class Sphere {
4834
4828
  // 1) Enclose the farthest point on the other sphere into this sphere.
4835
4829
  // 2) Enclose the opposite point of the farthest point into this sphere.
4836
4830
 
4837
- _toFarthestPoint.subVectors( sphere.center, this.center ).normalize().multiplyScalar( sphere.radius );
4831
+ if ( this.center.equals( sphere.center ) === true ) {
4832
+
4833
+ _toFarthestPoint.set( 0, 0, 1 ).multiplyScalar( sphere.radius );
4834
+
4835
+
4836
+ } else {
4837
+
4838
+ _toFarthestPoint.subVectors( sphere.center, this.center ).normalize().multiplyScalar( sphere.radius );
4839
+
4840
+ }
4838
4841
 
4839
4842
  this.expandByPoint( _v1$6.copy( sphere.center ).add( _toFarthestPoint ) );
4840
4843
  this.expandByPoint( _v1$6.copy( sphere.center ).sub( _toFarthestPoint ) );
@@ -4957,7 +4960,7 @@ class Ray {
4957
4960
 
4958
4961
  distanceSqToSegment( v0, v1, optionalPointOnRay, optionalPointOnSegment ) {
4959
4962
 
4960
- // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h
4963
+ // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteDistRaySegment.h
4961
4964
  // It returns the min distance between the ray and the segment
4962
4965
  // defined by v0 and v1
4963
4966
  // It can also set two optional targets :
@@ -5256,7 +5259,7 @@ class Ray {
5256
5259
 
5257
5260
  // Compute the offset origin, edges, and normal.
5258
5261
 
5259
- // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
5262
+ // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
5260
5263
 
5261
5264
  _edge1.subVectors( b, a );
5262
5265
  _edge2.subVectors( c, a );
@@ -6558,7 +6561,7 @@ class Layers {
6558
6561
 
6559
6562
  set( channel ) {
6560
6563
 
6561
- this.mask = 1 << channel | 0;
6564
+ this.mask = ( 1 << channel | 0 ) >>> 0;
6562
6565
 
6563
6566
  }
6564
6567
 
@@ -6598,6 +6601,12 @@ class Layers {
6598
6601
 
6599
6602
  }
6600
6603
 
6604
+ isEnabled( channel ) {
6605
+
6606
+ return ( this.mask & ( 1 << channel | 0 ) ) !== 0;
6607
+
6608
+ }
6609
+
6601
6610
  }
6602
6611
 
6603
6612
  let _object3DId = 0;
@@ -6998,6 +7007,8 @@ class Object3D extends EventDispatcher {
6998
7007
 
6999
7008
  // adds object as a child of this, while maintaining the object's world transform
7000
7009
 
7010
+ // Note: This method does not support scene graphs having non-uniformly-scaled nodes(s)
7011
+
7001
7012
  this.updateWorldMatrix( true, false );
7002
7013
 
7003
7014
  _m1$1.copy( this.matrixWorld ).invert();
@@ -7091,7 +7102,7 @@ class Object3D extends EventDispatcher {
7091
7102
 
7092
7103
  }
7093
7104
 
7094
- raycast() {}
7105
+ raycast( /* raycaster, intersects */ ) {}
7095
7106
 
7096
7107
  traverse( callback ) {
7097
7108
 
@@ -7998,14 +8009,14 @@ class Material extends EventDispatcher {
7998
8009
  if ( this.metalness !== undefined ) data.metalness = this.metalness;
7999
8010
 
8000
8011
  if ( this.sheen !== undefined ) data.sheen = this.sheen;
8001
- if ( this.sheenTint && this.sheenTint.isColor ) data.sheenTint = this.sheenTint.getHex();
8012
+ if ( this.sheenColor && this.sheenColor.isColor ) data.sheenColor = this.sheenColor.getHex();
8002
8013
  if ( this.sheenRoughness !== undefined ) data.sheenRoughness = this.sheenRoughness;
8003
8014
  if ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();
8004
8015
  if ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;
8005
8016
 
8006
8017
  if ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();
8007
8018
  if ( this.specularIntensity !== undefined ) data.specularIntensity = this.specularIntensity;
8008
- if ( this.specularTint && this.specularTint.isColor ) data.specularTint = this.specularTint.getHex();
8019
+ if ( this.specularColor && this.specularColor.isColor ) data.specularColor = this.specularColor.getHex();
8009
8020
  if ( this.shininess !== undefined ) data.shininess = this.shininess;
8010
8021
  if ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat;
8011
8022
  if ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness;
@@ -8076,7 +8087,7 @@ class Material extends EventDispatcher {
8076
8087
  if ( this.emissiveMap && this.emissiveMap.isTexture ) data.emissiveMap = this.emissiveMap.toJSON( meta ).uuid;
8077
8088
  if ( this.specularMap && this.specularMap.isTexture ) data.specularMap = this.specularMap.toJSON( meta ).uuid;
8078
8089
  if ( this.specularIntensityMap && this.specularIntensityMap.isTexture ) data.specularIntensityMap = this.specularIntensityMap.toJSON( meta ).uuid;
8079
- if ( this.specularTintMap && this.specularTintMap.isTexture ) data.specularTintMap = this.specularTintMap.toJSON( meta ).uuid;
8090
+ if ( this.specularColorMap && this.specularColorMap.isTexture ) data.specularColorMap = this.specularColorMap.toJSON( meta ).uuid;
8080
8091
 
8081
8092
  if ( this.envMap && this.envMap.isTexture ) {
8082
8093
 
@@ -8101,7 +8112,7 @@ class Material extends EventDispatcher {
8101
8112
  if ( this.thickness !== undefined ) data.thickness = this.thickness;
8102
8113
  if ( this.thicknessMap && this.thicknessMap.isTexture ) data.thicknessMap = this.thicknessMap.toJSON( meta ).uuid;
8103
8114
  if ( this.attenuationDistance !== undefined ) data.attenuationDistance = this.attenuationDistance;
8104
- if ( this.attenuationTint !== undefined ) data.attenuationTint = this.attenuationTint.getHex();
8115
+ if ( this.attenuationColor !== undefined ) data.attenuationColor = this.attenuationColor.getHex();
8105
8116
 
8106
8117
  if ( this.size !== undefined ) data.size = this.size;
8107
8118
  if ( this.shadowSide !== null ) data.shadowSide = this.shadowSide;
@@ -8592,44 +8603,6 @@ class Color {
8592
8603
 
8593
8604
  }
8594
8605
 
8595
- copyGammaToLinear( color, gammaFactor = 2.0 ) {
8596
-
8597
- this.r = Math.pow( color.r, gammaFactor );
8598
- this.g = Math.pow( color.g, gammaFactor );
8599
- this.b = Math.pow( color.b, gammaFactor );
8600
-
8601
- return this;
8602
-
8603
- }
8604
-
8605
- copyLinearToGamma( color, gammaFactor = 2.0 ) {
8606
-
8607
- const safeInverse = ( gammaFactor > 0 ) ? ( 1.0 / gammaFactor ) : 1.0;
8608
-
8609
- this.r = Math.pow( color.r, safeInverse );
8610
- this.g = Math.pow( color.g, safeInverse );
8611
- this.b = Math.pow( color.b, safeInverse );
8612
-
8613
- return this;
8614
-
8615
- }
8616
-
8617
- convertGammaToLinear( gammaFactor ) {
8618
-
8619
- this.copyGammaToLinear( this, gammaFactor );
8620
-
8621
- return this;
8622
-
8623
- }
8624
-
8625
- convertLinearToGamma( gammaFactor ) {
8626
-
8627
- this.copyLinearToGamma( this, gammaFactor );
8628
-
8629
- return this;
8630
-
8631
- }
8632
-
8633
8606
  copySRGBToLinear( color ) {
8634
8607
 
8635
8608
  this.r = SRGBToLinear( color.r );
@@ -9503,7 +9476,7 @@ class Float64BufferAttribute extends BufferAttribute {
9503
9476
 
9504
9477
  }
9505
9478
 
9506
- let _id = 0;
9479
+ let _id$1 = 0;
9507
9480
 
9508
9481
  const _m1 = /*@__PURE__*/ new Matrix4();
9509
9482
  const _obj = /*@__PURE__*/ new Object3D();
@@ -9518,7 +9491,7 @@ class BufferGeometry extends EventDispatcher {
9518
9491
 
9519
9492
  super();
9520
9493
 
9521
- Object.defineProperty( this, 'id', { value: _id ++ } );
9494
+ Object.defineProperty( this, 'id', { value: _id$1 ++ } );
9522
9495
 
9523
9496
  this.uuid = generateUUID();
9524
9497
 
@@ -12722,7 +12695,7 @@ var begin_vertex = "vec3 transformed = vec3( position );";
12722
12695
 
12723
12696
  var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif";
12724
12697
 
12725
- var bsdfs = "vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenTint, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenTint * ( D * V );\n}\n#endif";
12698
+ var bsdfs = "vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif";
12726
12699
 
12727
12700
  var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif";
12728
12701
 
@@ -12744,7 +12717,7 @@ var color_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#el
12744
12717
 
12745
12718
  var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}";
12746
12719
 
12747
- var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif";
12720
+ var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\treturn texture2D( envMap, uv ).rgb;\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif";
12748
12721
 
12749
12722
  var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif";
12750
12723
 
@@ -12758,11 +12731,11 @@ var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emi
12758
12731
 
12759
12732
  var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
12760
12733
 
12761
- var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\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}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}";
12734
+ var encodings_pars_fragment = "vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\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}";
12762
12735
 
12763
12736
  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\tenvColor = envMapTexelToLinear( envColor );\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";
12764
12737
 
12765
- var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\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";
12738
+ 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";
12766
12739
 
12767
12740
  var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif";
12768
12741
 
@@ -12778,7 +12751,7 @@ var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0
12778
12751
 
12779
12752
  var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif";
12780
12753
 
12781
- var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}";
12754
+ var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}";
12782
12755
 
12783
12756
  var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif";
12784
12757
 
@@ -12798,9 +12771,9 @@ var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor
12798
12771
 
12799
12772
  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)";
12800
12773
 
12801
- 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\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularTintFactor = specularTint;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARTINTMAP\n\t\t\tspecularTintFactor *= specularTintMapTexelToLinear( texture2D( specularTintMap, 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 specularTintFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularTintFactor, 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_SHEEN\n\tmaterial.sheenTint = sheenTint;\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n#endif";
12774
+ 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\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 *= specularColorMapTexelToLinear( 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( ( ior - 1.0 ) / ( 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_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= sheenColorMapTexelToLinear( 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";
12802
12775
 
12803
- var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenTint;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenTint, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
12776
+ var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
12804
12777
 
12805
12778
  var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
12806
12779
 
@@ -12892,9 +12865,9 @@ var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = to
12892
12865
 
12893
12866
  var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
12894
12867
 
12895
- var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= 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, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationTint, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif";
12868
+ var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= 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, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif";
12896
12869
 
12897
- var transmission_pars_fragment = "#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationTint;\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( vec3 n, vec3 v, float thickness, float ior, 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( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\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( vec3 radiance, float transmissionDistance, vec3 attenuationColor, 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( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, 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";
12870
+ 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( vec3 n, vec3 v, float thickness, float ior, 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( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\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( vec3 radiance, float transmissionDistance, vec3 attenuationColor, 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( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, 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";
12898
12871
 
12899
12872
  var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif";
12900
12873
 
@@ -12956,7 +12929,7 @@ const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;
12956
12929
 
12957
12930
  const vertex$5 = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\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\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}";
12958
12931
 
12959
- const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularTint;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARTINTMAP\n\t\tuniform sampler2D specularTintMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenTint;\n\tuniform float sheenRoughness;\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - clearcoat * Fcc ) + clearcoatSpecular * clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
12932
+ const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
12960
12933
 
12961
12934
  const vertex$4 = "#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\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\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
12962
12935
 
@@ -13144,8 +13117,7 @@ const UniformsLib = {
13144
13117
  flipEnvMap: { value: - 1 },
13145
13118
  reflectivity: { value: 1.0 }, // basic, lambert, phong
13146
13119
  ior: { value: 1.5 }, // standard, physical
13147
- refractionRatio: { value: 0.98 },
13148
- maxMipLevel: { value: 0 }
13120
+ refractionRatio: { value: 0.98 }
13149
13121
 
13150
13122
  },
13151
13123
 
@@ -13616,8 +13588,10 @@ ShaderLib.physical = {
13616
13588
  clearcoatNormalScale: { value: new Vector2( 1, 1 ) },
13617
13589
  clearcoatNormalMap: { value: null },
13618
13590
  sheen: { value: 0 },
13619
- sheenTint: { value: new Color( 0x000000 ) },
13591
+ sheenColor: { value: new Color( 0x000000 ) },
13592
+ sheenColorMap: { value: null },
13620
13593
  sheenRoughness: { value: 0 },
13594
+ sheenRoughnessMap: { value: null },
13621
13595
  transmission: { value: 0 },
13622
13596
  transmissionMap: { value: null },
13623
13597
  transmissionSamplerSize: { value: new Vector2() },
@@ -13625,11 +13599,11 @@ ShaderLib.physical = {
13625
13599
  thickness: { value: 0 },
13626
13600
  thicknessMap: { value: null },
13627
13601
  attenuationDistance: { value: 0 },
13628
- attenuationTint: { value: new Color( 0x000000 ) },
13602
+ attenuationColor: { value: new Color( 0x000000 ) },
13629
13603
  specularIntensity: { value: 0 },
13630
13604
  specularIntensityMap: { value: null },
13631
- specularTint: { value: new Color( 1, 1, 1 ) },
13632
- specularTintMap: { value: null },
13605
+ specularColor: { value: new Color( 1, 1, 1 ) },
13606
+ specularColorMap: { value: null },
13633
13607
  }
13634
13608
  ] ),
13635
13609
 
@@ -14558,10 +14532,8 @@ function WebGLCapabilities( gl, extensions, parameters ) {
14558
14532
 
14559
14533
  }
14560
14534
 
14561
- /* eslint-disable no-undef */
14562
14535
  const isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext ) ||
14563
14536
  ( typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext );
14564
- /* eslint-enable no-undef */
14565
14537
 
14566
14538
  let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
14567
14539
  const maxPrecision = getMaxPrecision( precision );
@@ -15051,12 +15023,7 @@ const MAX_SAMPLES = 20;
15051
15023
 
15052
15024
  const ENCODINGS = {
15053
15025
  [ LinearEncoding ]: 0,
15054
- [ sRGBEncoding ]: 1,
15055
- [ RGBEEncoding ]: 2,
15056
- [ RGBM7Encoding ]: 3,
15057
- [ RGBM16Encoding ]: 4,
15058
- [ RGBDEncoding ]: 5,
15059
- [ GammaEncoding ]: 6
15026
+ [ sRGBEncoding ]: 1
15060
15027
  };
15061
15028
 
15062
15029
  const _flatCamera = /*@__PURE__*/ new OrthographicCamera();
@@ -15140,7 +15107,7 @@ class PMREMGenerator {
15140
15107
 
15141
15108
  /**
15142
15109
  * Generates a PMREM from an equirectangular texture, which can be either LDR
15143
- * (RGBFormat) or HDR (RGBEFormat). The ideal input image size is 1k (1024 x 512),
15110
+ * or HDR. The ideal input image size is 1k (1024 x 512),
15144
15111
  * as this matches best with the 256 x 256 cubemap output.
15145
15112
  */
15146
15113
  fromEquirectangular( equirectangular ) {
@@ -15151,7 +15118,7 @@ class PMREMGenerator {
15151
15118
 
15152
15119
  /**
15153
15120
  * Generates a PMREM from an cubemap texture, which can be either LDR
15154
- * (RGBFormat) or HDR (RGBEFormat). The ideal input cube size is 256 x 256,
15121
+ * or HDR. The ideal input cube size is 256 x 256,
15155
15122
  * as this matches best with the 256 x 256 cubemap output.
15156
15123
  */
15157
15124
  fromCubemap( cubemap ) {
@@ -15236,12 +15203,12 @@ class PMREMGenerator {
15236
15203
  _allocateTargets( texture ) { // warning: null texture is valid
15237
15204
 
15238
15205
  const params = {
15239
- magFilter: NearestFilter,
15240
- minFilter: NearestFilter,
15206
+ magFilter: LinearFilter,
15207
+ minFilter: LinearFilter,
15241
15208
  generateMipmaps: false,
15242
- type: UnsignedByteType,
15243
- format: RGBEFormat,
15244
- encoding: _isLDR( texture ) ? texture.encoding : RGBEEncoding,
15209
+ type: HalfFloatType,
15210
+ format: RGBAFormat,
15211
+ encoding: LinearEncoding,
15245
15212
  depthBuffer: false
15246
15213
  };
15247
15214
 
@@ -15269,12 +15236,10 @@ class PMREMGenerator {
15269
15236
  const renderer = this._renderer;
15270
15237
 
15271
15238
  const originalAutoClear = renderer.autoClear;
15272
- const outputEncoding = renderer.outputEncoding;
15273
15239
  const toneMapping = renderer.toneMapping;
15274
15240
  renderer.getClearColor( _clearColor );
15275
15241
 
15276
15242
  renderer.toneMapping = NoToneMapping;
15277
- renderer.outputEncoding = LinearEncoding;
15278
15243
  renderer.autoClear = false;
15279
15244
 
15280
15245
  const backgroundMaterial = new MeshBasicMaterial( {
@@ -15344,7 +15309,6 @@ class PMREMGenerator {
15344
15309
  backgroundBox.material.dispose();
15345
15310
 
15346
15311
  renderer.toneMapping = toneMapping;
15347
- renderer.outputEncoding = outputEncoding;
15348
15312
  renderer.autoClear = originalAutoClear;
15349
15313
  scene.background = background;
15350
15314
 
@@ -15368,7 +15332,9 @@ class PMREMGenerator {
15368
15332
 
15369
15333
  const renderer = this._renderer;
15370
15334
 
15371
- if ( texture.isCubeTexture ) {
15335
+ const isCubeTexture = ( texture.mapping === CubeReflectionMapping || texture.mapping === CubeRefractionMapping );
15336
+
15337
+ if ( isCubeTexture ) {
15372
15338
 
15373
15339
  if ( this._cubemapShader == null ) {
15374
15340
 
@@ -15386,21 +15352,20 @@ class PMREMGenerator {
15386
15352
 
15387
15353
  }
15388
15354
 
15389
- const material = texture.isCubeTexture ? this._cubemapShader : this._equirectShader;
15355
+ const material = isCubeTexture ? this._cubemapShader : this._equirectShader;
15390
15356
  const mesh = new Mesh( _lodPlanes[ 0 ], material );
15391
15357
 
15392
15358
  const uniforms = material.uniforms;
15393
15359
 
15394
15360
  uniforms[ 'envMap' ].value = texture;
15395
15361
 
15396
- if ( ! texture.isCubeTexture ) {
15362
+ if ( ! isCubeTexture ) {
15397
15363
 
15398
15364
  uniforms[ 'texelSize' ].value.set( 1.0 / texture.image.width, 1.0 / texture.image.height );
15399
15365
 
15400
15366
  }
15401
15367
 
15402
15368
  this._setEncoding( uniforms[ 'inputEncoding' ], texture );
15403
- this._setEncoding( uniforms[ 'outputEncoding' ], cubeUVRenderTarget.texture );
15404
15369
 
15405
15370
  _setViewport( cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX );
15406
15371
 
@@ -15532,9 +15497,6 @@ class PMREMGenerator {
15532
15497
  blurUniforms[ 'dTheta' ].value = radiansPerPixel;
15533
15498
  blurUniforms[ 'mipInt' ].value = LOD_MAX - lodIn;
15534
15499
 
15535
- this._setEncoding( blurUniforms[ 'inputEncoding' ], targetIn.texture );
15536
- this._setEncoding( blurUniforms[ 'outputEncoding' ], targetIn.texture );
15537
-
15538
15500
  const outputSize = _sizeLods[ lodOut ];
15539
15501
  const x = 3 * Math.max( 0, SIZE_MAX - 2 * outputSize );
15540
15502
  const y = ( lodOut === 0 ? 0 : 2 * SIZE_MAX ) + 2 * outputSize * ( lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0 );
@@ -15547,14 +15509,6 @@ class PMREMGenerator {
15547
15509
 
15548
15510
  }
15549
15511
 
15550
- function _isLDR( texture ) {
15551
-
15552
- if ( texture === undefined || texture.type !== UnsignedByteType ) return false;
15553
-
15554
- return texture.encoding === LinearEncoding || texture.encoding === sRGBEncoding || texture.encoding === GammaEncoding;
15555
-
15556
- }
15557
-
15558
15512
  function _createPlanes() {
15559
15513
 
15560
15514
  const _lodPlanes = [];
@@ -15667,9 +15621,7 @@ function _getBlurShader( maxSamples ) {
15667
15621
  'latitudinal': { value: false },
15668
15622
  'dTheta': { value: 0 },
15669
15623
  'mipInt': { value: 0 },
15670
- 'poleAxis': { value: poleAxis },
15671
- 'inputEncoding': { value: ENCODINGS[ LinearEncoding ] },
15672
- 'outputEncoding': { value: ENCODINGS[ LinearEncoding ] }
15624
+ 'poleAxis': { value: poleAxis }
15673
15625
  },
15674
15626
 
15675
15627
  vertexShader: _getCommonVertexShader(),
@@ -15735,8 +15687,6 @@ function _getBlurShader( maxSamples ) {
15735
15687
 
15736
15688
  }
15737
15689
 
15738
- gl_FragColor = linearToOutputTexel( gl_FragColor );
15739
-
15740
15690
  }
15741
15691
  `,
15742
15692
 
@@ -15760,8 +15710,7 @@ function _getEquirectShader() {
15760
15710
  uniforms: {
15761
15711
  'envMap': { value: null },
15762
15712
  'texelSize': { value: texelSize },
15763
- 'inputEncoding': { value: ENCODINGS[ LinearEncoding ] },
15764
- 'outputEncoding': { value: ENCODINGS[ LinearEncoding ] }
15713
+ 'inputEncoding': { value: ENCODINGS[ LinearEncoding ] }
15765
15714
  },
15766
15715
 
15767
15716
  vertexShader: _getCommonVertexShader(),
@@ -15801,8 +15750,6 @@ function _getEquirectShader() {
15801
15750
  vec3 bm = mix( bl, br, f.x );
15802
15751
  gl_FragColor.rgb = mix( tm, bm, f.y );
15803
15752
 
15804
- gl_FragColor = linearToOutputTexel( gl_FragColor );
15805
-
15806
15753
  }
15807
15754
  `,
15808
15755
 
@@ -15824,8 +15771,7 @@ function _getCubemapShader() {
15824
15771
 
15825
15772
  uniforms: {
15826
15773
  'envMap': { value: null },
15827
- 'inputEncoding': { value: ENCODINGS[ LinearEncoding ] },
15828
- 'outputEncoding': { value: ENCODINGS[ LinearEncoding ] }
15774
+ 'inputEncoding': { value: ENCODINGS[ LinearEncoding ] }
15829
15775
  },
15830
15776
 
15831
15777
  vertexShader: _getCommonVertexShader(),
@@ -15843,9 +15789,7 @@ function _getCubemapShader() {
15843
15789
 
15844
15790
  void main() {
15845
15791
 
15846
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
15847
- gl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;
15848
- gl_FragColor = linearToOutputTexel( gl_FragColor );
15792
+ gl_FragColor = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) );
15849
15793
 
15850
15794
  }
15851
15795
  `,
@@ -15928,7 +15872,6 @@ function _getEncodings() {
15928
15872
  return /* glsl */`
15929
15873
 
15930
15874
  uniform int inputEncoding;
15931
- uniform int outputEncoding;
15932
15875
 
15933
15876
  #include <encodings_pars_fragment>
15934
15877
 
@@ -15938,63 +15881,9 @@ function _getEncodings() {
15938
15881
 
15939
15882
  return value;
15940
15883
 
15941
- } else if ( inputEncoding == 1 ) {
15942
-
15943
- return sRGBToLinear( value );
15944
-
15945
- } else if ( inputEncoding == 2 ) {
15946
-
15947
- return RGBEToLinear( value );
15948
-
15949
- } else if ( inputEncoding == 3 ) {
15950
-
15951
- return RGBMToLinear( value, 7.0 );
15952
-
15953
- } else if ( inputEncoding == 4 ) {
15954
-
15955
- return RGBMToLinear( value, 16.0 );
15956
-
15957
- } else if ( inputEncoding == 5 ) {
15958
-
15959
- return RGBDToLinear( value, 256.0 );
15960
-
15961
- } else {
15962
-
15963
- return GammaToLinear( value, 2.2 );
15964
-
15965
- }
15966
-
15967
- }
15968
-
15969
- vec4 linearToOutputTexel( vec4 value ) {
15970
-
15971
- if ( outputEncoding == 0 ) {
15972
-
15973
- return value;
15974
-
15975
- } else if ( outputEncoding == 1 ) {
15976
-
15977
- return LinearTosRGB( value );
15978
-
15979
- } else if ( outputEncoding == 2 ) {
15980
-
15981
- return LinearToRGBE( value );
15982
-
15983
- } else if ( outputEncoding == 3 ) {
15984
-
15985
- return LinearToRGBM( value, 7.0 );
15986
-
15987
- } else if ( outputEncoding == 4 ) {
15988
-
15989
- return LinearToRGBM( value, 16.0 );
15990
-
15991
- } else if ( outputEncoding == 5 ) {
15992
-
15993
- return LinearToRGBD( value, 256.0 );
15994
-
15995
15884
  } else {
15996
15885
 
15997
- return LinearToGamma( value, 2.2 );
15886
+ return sRGBToLinear( value );
15998
15887
 
15999
15888
  }
16000
15889
 
@@ -16194,6 +16083,7 @@ function WebGLExtensions( gl ) {
16194
16083
 
16195
16084
  getExtension( 'OES_texture_float_linear' );
16196
16085
  getExtension( 'EXT_color_buffer_half_float' );
16086
+ getExtension( 'WEBGL_multisampled_render_to_texture' );
16197
16087
 
16198
16088
  },
16199
16089
 
@@ -16561,8 +16451,6 @@ class DataTexture2DArray extends Texture {
16561
16451
  this.flipY = false;
16562
16452
  this.unpackAlignment = 1;
16563
16453
 
16564
- this.needsUpdate = true;
16565
-
16566
16454
  }
16567
16455
 
16568
16456
  }
@@ -16650,6 +16538,7 @@ function WebGLMorphtargets( gl, capabilities, textures ) {
16650
16538
  const texture = new DataTexture2DArray( buffer, width, height, numberOfMorphTargets );
16651
16539
  texture.format = RGBAFormat; // using RGBA since RGB might be emulated (and is thus slower)
16652
16540
  texture.type = FloatType;
16541
+ texture.needsUpdate = true;
16653
16542
 
16654
16543
  // fill buffer
16655
16544
 
@@ -16940,8 +16829,6 @@ class DataTexture3D extends Texture {
16940
16829
  this.flipY = false;
16941
16830
  this.unpackAlignment = 1;
16942
16831
 
16943
- this.needsUpdate = true;
16944
-
16945
16832
  }
16946
16833
 
16947
16834
  }
@@ -17635,7 +17522,7 @@ function setValueV4uiArray( gl, v ) {
17635
17522
  }
17636
17523
 
17637
17524
 
17638
- // Array of textures (2D / Cube)
17525
+ // Array of textures (2D / 3D / Cube / 2DArray)
17639
17526
 
17640
17527
  function setValueT1Array( gl, v, textures ) {
17641
17528
 
@@ -17653,6 +17540,22 @@ function setValueT1Array( gl, v, textures ) {
17653
17540
 
17654
17541
  }
17655
17542
 
17543
+ function setValueT3DArray( gl, v, textures ) {
17544
+
17545
+ const n = v.length;
17546
+
17547
+ const units = allocTexUnits( textures, n );
17548
+
17549
+ gl.uniform1iv( this.addr, units );
17550
+
17551
+ for ( let i = 0; i !== n; ++ i ) {
17552
+
17553
+ textures.setTexture3D( v[ i ] || emptyTexture3d, units[ i ] );
17554
+
17555
+ }
17556
+
17557
+ }
17558
+
17656
17559
  function setValueT6Array( gl, v, textures ) {
17657
17560
 
17658
17561
  const n = v.length;
@@ -17669,6 +17572,23 @@ function setValueT6Array( gl, v, textures ) {
17669
17572
 
17670
17573
  }
17671
17574
 
17575
+ function setValueT2DArrayArray( gl, v, textures ) {
17576
+
17577
+ const n = v.length;
17578
+
17579
+ const units = allocTexUnits( textures, n );
17580
+
17581
+ gl.uniform1iv( this.addr, units );
17582
+
17583
+ for ( let i = 0; i !== n; ++ i ) {
17584
+
17585
+ textures.setTexture2DArray( v[ i ] || emptyTexture2dArray, units[ i ] );
17586
+
17587
+ }
17588
+
17589
+ }
17590
+
17591
+
17672
17592
  // Helper to pick the right setter for a pure (bottom-level) array
17673
17593
 
17674
17594
  function getPureArraySetter( type ) {
@@ -17701,12 +17621,23 @@ function getPureArraySetter( type ) {
17701
17621
  case 0x8b62: // SAMPLER_2D_SHADOW
17702
17622
  return setValueT1Array;
17703
17623
 
17624
+ case 0x8b5f: // SAMPLER_3D
17625
+ case 0x8dcb: // INT_SAMPLER_3D
17626
+ case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D
17627
+ return setValueT3DArray;
17628
+
17704
17629
  case 0x8b60: // SAMPLER_CUBE
17705
17630
  case 0x8dcc: // INT_SAMPLER_CUBE
17706
17631
  case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE
17707
17632
  case 0x8dc5: // SAMPLER_CUBE_SHADOW
17708
17633
  return setValueT6Array;
17709
17634
 
17635
+ case 0x8dc1: // SAMPLER_2D_ARRAY
17636
+ case 0x8dcf: // INT_SAMPLER_2D_ARRAY
17637
+ case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY
17638
+ case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW
17639
+ return setValueT2DArrayArray;
17640
+
17710
17641
  }
17711
17642
 
17712
17643
  }
@@ -17952,18 +17883,6 @@ function getEncodingComponents( encoding ) {
17952
17883
  return [ 'Linear', '( value )' ];
17953
17884
  case sRGBEncoding:
17954
17885
  return [ 'sRGB', '( value )' ];
17955
- case RGBEEncoding:
17956
- return [ 'RGBE', '( value )' ];
17957
- case RGBM7Encoding:
17958
- return [ 'RGBM', '( value, 7.0 )' ];
17959
- case RGBM16Encoding:
17960
- return [ 'RGBM', '( value, 16.0 )' ];
17961
- case RGBDEncoding:
17962
- return [ 'RGBD', '( value, 256.0 )' ];
17963
- case GammaEncoding:
17964
- return [ 'Gamma', '( value, float( GAMMA_FACTOR ) )' ];
17965
- case LogLuvEncoding:
17966
- return [ 'LogLuv', '( value )' ];
17967
17886
  default:
17968
17887
  console.warn( 'THREE.WebGLProgram: Unsupported encoding:', encoding );
17969
17888
  return [ 'Linear', '( value )' ];
@@ -18324,9 +18243,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
18324
18243
  const envMapModeDefine = generateEnvMapModeDefine( parameters );
18325
18244
  const envMapBlendingDefine = generateEnvMapBlendingDefine( parameters );
18326
18245
 
18327
-
18328
- const gammaFactorDefine = ( renderer.gammaFactor > 0 ) ? renderer.gammaFactor : 1.0;
18329
-
18330
18246
  const customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters );
18331
18247
 
18332
18248
  const customDefines = generateDefines( defines );
@@ -18378,8 +18294,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
18378
18294
 
18379
18295
  parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '',
18380
18296
 
18381
- '#define GAMMA_FACTOR ' + gammaFactorDefine,
18382
-
18383
18297
  '#define MAX_BONES ' + parameters.maxBones,
18384
18298
  ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',
18385
18299
  ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '',
@@ -18403,7 +18317,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
18403
18317
 
18404
18318
  parameters.specularMap ? '#define USE_SPECULARMAP' : '',
18405
18319
  parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '',
18406
- parameters.specularTintMap ? '#define USE_SPECULARTINTMAP' : '',
18320
+ parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '',
18407
18321
 
18408
18322
  parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',
18409
18323
  parameters.metalnessMap ? '#define USE_METALNESSMAP' : '',
@@ -18413,6 +18327,9 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
18413
18327
  parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '',
18414
18328
  parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '',
18415
18329
 
18330
+ parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '',
18331
+ parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '',
18332
+
18416
18333
  parameters.vertexTangents ? '#define USE_TANGENT' : '',
18417
18334
  parameters.vertexColors ? '#define USE_COLOR' : '',
18418
18335
  parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',
@@ -18525,8 +18442,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
18525
18442
 
18526
18443
  customDefines,
18527
18444
 
18528
- '#define GAMMA_FACTOR ' + gammaFactorDefine,
18529
-
18530
18445
  ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',
18531
18446
  ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '',
18532
18447
 
@@ -18551,7 +18466,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
18551
18466
 
18552
18467
  parameters.specularMap ? '#define USE_SPECULARMAP' : '',
18553
18468
  parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '',
18554
- parameters.specularTintMap ? '#define USE_SPECULARTINTMAP' : '',
18469
+ parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '',
18555
18470
  parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',
18556
18471
  parameters.metalnessMap ? '#define USE_METALNESSMAP' : '',
18557
18472
 
@@ -18559,6 +18474,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
18559
18474
  parameters.alphaTest ? '#define USE_ALPHATEST' : '',
18560
18475
 
18561
18476
  parameters.sheen ? '#define USE_SHEEN' : '',
18477
+ parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '',
18478
+ parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '',
18562
18479
 
18563
18480
  parameters.transmission ? '#define USE_TRANSMISSION' : '',
18564
18481
  parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '',
@@ -18605,7 +18522,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
18605
18522
  parameters.matcap ? getTexelDecodingFunction( 'matcapTexelToLinear', parameters.matcapEncoding ) : '',
18606
18523
  parameters.envMap ? getTexelDecodingFunction( 'envMapTexelToLinear', parameters.envMapEncoding ) : '',
18607
18524
  parameters.emissiveMap ? getTexelDecodingFunction( 'emissiveMapTexelToLinear', parameters.emissiveMapEncoding ) : '',
18608
- parameters.specularTintMap ? getTexelDecodingFunction( 'specularTintMapTexelToLinear', parameters.specularTintMapEncoding ) : '',
18525
+ parameters.specularColorMap ? getTexelDecodingFunction( 'specularColorMapTexelToLinear', parameters.specularColorMapEncoding ) : '',
18526
+ parameters.sheenColorMap ? getTexelDecodingFunction( 'sheenColorMapTexelToLinear', parameters.sheenColorMapEncoding ) : '',
18609
18527
  parameters.lightMap ? getTexelDecodingFunction( 'lightMapTexelToLinear', parameters.lightMapEncoding ) : '',
18610
18528
  getTexelEncodingFunction( 'linearToOutputTexel', parameters.outputEncoding ),
18611
18529
 
@@ -18643,7 +18561,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
18643
18561
 
18644
18562
  prefixFragment = [
18645
18563
  '#define varying in',
18646
- ( parameters.glslVersion === GLSL3 ) ? '' : 'out highp vec4 pc_fragColor;',
18564
+ ( parameters.glslVersion === GLSL3 ) ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;',
18647
18565
  ( parameters.glslVersion === GLSL3 ) ? '' : '#define gl_FragColor pc_fragColor',
18648
18566
  '#define gl_FragDepthEXT gl_FragDepth',
18649
18567
  '#define texture2D texture',
@@ -18815,8 +18733,129 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
18815
18733
 
18816
18734
  }
18817
18735
 
18736
+ let _id = 0;
18737
+
18738
+ class WebGLShaderCache {
18739
+
18740
+ constructor() {
18741
+
18742
+ this.shaderCache = new Map();
18743
+ this.materialCache = new Map();
18744
+
18745
+ }
18746
+
18747
+ update( material ) {
18748
+
18749
+ const vertexShader = material.vertexShader;
18750
+ const fragmentShader = material.fragmentShader;
18751
+
18752
+ const vertexShaderStage = this._getShaderStage( vertexShader );
18753
+ const fragmentShaderStage = this._getShaderStage( fragmentShader );
18754
+
18755
+ const materialShaders = this._getShaderCacheForMaterial( material );
18756
+
18757
+ if ( materialShaders.has( vertexShaderStage ) === false ) {
18758
+
18759
+ materialShaders.add( vertexShaderStage );
18760
+ vertexShaderStage.usedTimes ++;
18761
+
18762
+ }
18763
+
18764
+ if ( materialShaders.has( fragmentShaderStage ) === false ) {
18765
+
18766
+ materialShaders.add( fragmentShaderStage );
18767
+ fragmentShaderStage.usedTimes ++;
18768
+
18769
+ }
18770
+
18771
+ return this;
18772
+
18773
+ }
18774
+
18775
+ remove( material ) {
18776
+
18777
+ const materialShaders = this.materialCache.get( material );
18778
+
18779
+ for ( const shaderStage of materialShaders ) {
18780
+
18781
+ shaderStage.usedTimes --;
18782
+
18783
+ if ( shaderStage.usedTimes === 0 ) this.shaderCache.delete( shaderStage );
18784
+
18785
+ }
18786
+
18787
+ this.materialCache.delete( material );
18788
+
18789
+ return this;
18790
+
18791
+ }
18792
+
18793
+ getVertexShaderID( material ) {
18794
+
18795
+ return this._getShaderStage( material.vertexShader ).id;
18796
+
18797
+ }
18798
+
18799
+ getFragmentShaderID( material ) {
18800
+
18801
+ return this._getShaderStage( material.fragmentShader ).id;
18802
+
18803
+ }
18804
+
18805
+ dispose() {
18806
+
18807
+ this.shaderCache.clear();
18808
+ this.materialCache.clear();
18809
+
18810
+ }
18811
+
18812
+ _getShaderCacheForMaterial( material ) {
18813
+
18814
+ const cache = this.materialCache;
18815
+
18816
+ if ( cache.has( material ) === false ) {
18817
+
18818
+ cache.set( material, new Set() );
18819
+
18820
+ }
18821
+
18822
+ return cache.get( material );
18823
+
18824
+ }
18825
+
18826
+ _getShaderStage( code ) {
18827
+
18828
+ const cache = this.shaderCache;
18829
+
18830
+ if ( cache.has( code ) === false ) {
18831
+
18832
+ const stage = new WebGLShaderStage();
18833
+ cache.set( code, stage );
18834
+
18835
+ }
18836
+
18837
+ return cache.get( code );
18838
+
18839
+ }
18840
+
18841
+ }
18842
+
18843
+ class WebGLShaderStage {
18844
+
18845
+ constructor() {
18846
+
18847
+ this.id = _id ++;
18848
+
18849
+ this.usedTimes = 0;
18850
+
18851
+ }
18852
+
18853
+ }
18854
+
18818
18855
  function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping ) {
18819
18856
 
18857
+ const _programLayers = new Layers();
18858
+ const _customShaders = new WebGLShaderCache();
18820
18859
  const programs = [];
18821
18860
 
18822
18861
  const isWebGL2 = capabilities.isWebGL2;
@@ -18824,7 +18863,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
18824
18863
  const floatVertexTextures = capabilities.floatVertexTextures;
18825
18864
  const maxVertexUniforms = capabilities.maxVertexUniforms;
18826
18865
  const vertexTextures = capabilities.vertexTextures;
18827
-
18828
18866
  let precision = capabilities.precision;
18829
18867
 
18830
18868
  const shaderIDs = {
@@ -18845,24 +18883,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
18845
18883
  SpriteMaterial: 'sprite'
18846
18884
  };
18847
18885
 
18848
- const parameterNames = [
18849
- 'precision', 'isWebGL2', 'supportsVertexTextures', 'outputEncoding', 'instancing', 'instancingColor',
18850
- 'map', 'mapEncoding', 'matcap', 'matcapEncoding', 'envMap', 'envMapMode', 'envMapEncoding', 'envMapCubeUV',
18851
- 'lightMap', 'lightMapEncoding', 'aoMap', 'emissiveMap', 'emissiveMapEncoding', 'bumpMap', 'normalMap',
18852
- 'objectSpaceNormalMap', 'tangentSpaceNormalMap',
18853
- 'clearcoat', 'clearcoatMap', 'clearcoatRoughnessMap', 'clearcoatNormalMap',
18854
- 'displacementMap',
18855
- 'specularMap', 'specularIntensityMap', 'specularTintMap', 'specularTintMapEncoding', 'roughnessMap', 'metalnessMap', 'gradientMap',
18856
- 'alphaMap', 'alphaTest', 'combine', 'vertexColors', 'vertexAlphas', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2',
18857
- 'flatShading', 'sizeAttenuation', 'logarithmicDepthBuffer', 'skinning',
18858
- 'maxBones', 'useVertexTexture', 'morphTargets', 'morphNormals', 'morphTargetsCount', 'premultipliedAlpha',
18859
- 'numDirLights', 'numPointLights', 'numSpotLights', 'numHemiLights', 'numRectAreaLights',
18860
- 'numDirLightShadows', 'numPointLightShadows', 'numSpotLightShadows',
18861
- 'shadowMapEnabled', 'shadowMapType', 'toneMapping', 'physicallyCorrectLights',
18862
- 'doubleSided', 'flipSided', 'numClippingPlanes', 'numClipIntersection', 'depthPacking', 'dithering', 'format',
18863
- 'sheen', 'transmission', 'transmissionMap', 'thicknessMap'
18864
- ];
18865
-
18866
18886
  function getMaxBones( object ) {
18867
18887
 
18868
18888
  const skeleton = object.skeleton;
@@ -18955,6 +18975,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
18955
18975
  }
18956
18976
 
18957
18977
  let vertexShader, fragmentShader;
18978
+ let customVertexShaderID, customFragmentShaderID;
18958
18979
 
18959
18980
  if ( shaderID ) {
18960
18981
 
@@ -18968,6 +18989,11 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
18968
18989
  vertexShader = material.vertexShader;
18969
18990
  fragmentShader = material.fragmentShader;
18970
18991
 
18992
+ _customShaders.update( material );
18993
+
18994
+ customVertexShaderID = _customShaders.getVertexShaderID( material );
18995
+ customFragmentShaderID = _customShaders.getFragmentShaderID( material );
18996
+
18971
18997
  }
18972
18998
 
18973
18999
  const currentRenderTarget = renderer.getRenderTarget();
@@ -18986,6 +19012,9 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
18986
19012
  fragmentShader: fragmentShader,
18987
19013
  defines: material.defines,
18988
19014
 
19015
+ customVertexShaderID: customVertexShaderID,
19016
+ customFragmentShaderID: customFragmentShaderID,
19017
+
18989
19018
  isRawShaderMaterial: material.isRawShaderMaterial === true,
18990
19019
  glslVersion: material.glslVersion,
18991
19020
 
@@ -19024,8 +19053,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
19024
19053
  metalnessMap: !! material.metalnessMap,
19025
19054
  specularMap: !! material.specularMap,
19026
19055
  specularIntensityMap: !! material.specularIntensityMap,
19027
- specularTintMap: !! material.specularTintMap,
19028
- specularTintMapEncoding: getTextureEncodingFromMap( material.specularTintMap ),
19056
+ specularColorMap: !! material.specularColorMap,
19057
+ specularColorMapEncoding: getTextureEncodingFromMap( material.specularColorMap ),
19029
19058
 
19030
19059
  alphaMap: !! material.alphaMap,
19031
19060
  alphaTest: useAlphaTest,
@@ -19033,6 +19062,9 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
19033
19062
  gradientMap: !! material.gradientMap,
19034
19063
 
19035
19064
  sheen: material.sheen > 0,
19065
+ sheenColorMap: !! material.sheenColorMap,
19066
+ sheenColorMapEncoding: getTextureEncodingFromMap( material.sheenColorMap ),
19067
+ sheenRoughnessMap: !! material.sheenRoughnessMap,
19036
19068
 
19037
19069
  transmission: material.transmission > 0,
19038
19070
  transmissionMap: !! material.transmissionMap,
@@ -19043,8 +19075,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
19043
19075
  vertexTangents: ( !! material.normalMap && !! object.geometry && !! object.geometry.attributes.tangent ),
19044
19076
  vertexColors: material.vertexColors,
19045
19077
  vertexAlphas: material.vertexColors === true && !! object.geometry && !! object.geometry.attributes.color && object.geometry.attributes.color.itemSize === 4,
19046
- vertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatMap || !! material.clearcoatRoughnessMap || !! material.clearcoatNormalMap || !! material.displacementMap || !! material.transmissionMap || !! material.thicknessMap || !! material.specularIntensityMap || !! material.specularTintMap,
19047
- uvsVertexOnly: ! ( !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap || material.transmission > 0 || !! material.transmissionMap || !! material.thicknessMap || !! material.specularIntensityMap || !! material.specularTintMap ) && !! material.displacementMap,
19078
+ vertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatMap || !! material.clearcoatRoughnessMap || !! material.clearcoatNormalMap || !! material.displacementMap || !! material.transmissionMap || !! material.thicknessMap || !! material.specularIntensityMap || !! material.specularColorMap || !! material.sheenColorMap || !! material.sheenRoughnessMap,
19079
+ uvsVertexOnly: ! ( !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap || material.transmission > 0 || !! material.transmissionMap || !! material.thicknessMap || !! material.specularIntensityMap || !! material.specularColorMap || material.sheen > 0 || !! material.sheenColorMap || !! material.sheenRoughnessMap ) && !! material.displacementMap,
19048
19080
 
19049
19081
  fog: !! fog,
19050
19082
  useFog: material.fog,
@@ -19121,8 +19153,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
19121
19153
 
19122
19154
  } else {
19123
19155
 
19124
- array.push( parameters.fragmentShader );
19125
- array.push( parameters.vertexShader );
19156
+ array.push( parameters.customVertexShaderID );
19157
+ array.push( parameters.customFragmentShaderID );
19126
19158
 
19127
19159
  }
19128
19160
 
@@ -19139,14 +19171,9 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
19139
19171
 
19140
19172
  if ( parameters.isRawShaderMaterial === false ) {
19141
19173
 
19142
- for ( let i = 0; i < parameterNames.length; i ++ ) {
19143
-
19144
- array.push( parameters[ parameterNames[ i ] ] );
19145
-
19146
- }
19147
-
19174
+ getProgramCacheKeyParameters( array, parameters );
19175
+ getProgramCacheKeyBooleans( array, parameters );
19148
19176
  array.push( renderer.outputEncoding );
19149
- array.push( renderer.gammaFactor );
19150
19177
 
19151
19178
  }
19152
19179
 
@@ -19156,6 +19183,161 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
19156
19183
 
19157
19184
  }
19158
19185
 
19186
+ function getProgramCacheKeyParameters( array, parameters ) {
19187
+
19188
+ array.push( parameters.precision );
19189
+ array.push( parameters.outputEncoding );
19190
+ array.push( parameters.mapEncoding );
19191
+ array.push( parameters.matcapEncoding );
19192
+ array.push( parameters.envMapMode );
19193
+ array.push( parameters.envMapEncoding );
19194
+ array.push( parameters.lightMapEncoding );
19195
+ array.push( parameters.emissiveMapEncoding );
19196
+ array.push( parameters.combine );
19197
+ array.push( parameters.vertexUvs );
19198
+ array.push( parameters.fogExp2 );
19199
+ array.push( parameters.sizeAttenuation );
19200
+ array.push( parameters.maxBones );
19201
+ array.push( parameters.morphTargetsCount );
19202
+ array.push( parameters.numDirLights );
19203
+ array.push( parameters.numPointLights );
19204
+ array.push( parameters.numSpotLights );
19205
+ array.push( parameters.numHemiLights );
19206
+ array.push( parameters.numRectAreaLights );
19207
+ array.push( parameters.numDirLightShadows );
19208
+ array.push( parameters.numPointLightShadows );
19209
+ array.push( parameters.numSpotLightShadows );
19210
+ array.push( parameters.shadowMapType );
19211
+ array.push( parameters.toneMapping );
19212
+ array.push( parameters.numClippingPlanes );
19213
+ array.push( parameters.numClipIntersection );
19214
+ array.push( parameters.format );
19215
+ array.push( parameters.specularColorMapEncoding );
19216
+ array.push( parameters.sheenColorMapEncoding );
19217
+
19218
+ }
19219
+
19220
+ function getProgramCacheKeyBooleans( array, parameters ) {
19221
+
19222
+ _programLayers.disableAll();
19223
+
19224
+ if ( parameters.isWebGL2 )
19225
+ _programLayers.enable( 0 );
19226
+ if ( parameters.supportsVertexTextures )
19227
+ _programLayers.enable( 1 );
19228
+ if ( parameters.instancing )
19229
+ _programLayers.enable( 2 );
19230
+ if ( parameters.instancingColor )
19231
+ _programLayers.enable( 3 );
19232
+ if ( parameters.map )
19233
+ _programLayers.enable( 4 );
19234
+ if ( parameters.matcap )
19235
+ _programLayers.enable( 5 );
19236
+ if ( parameters.envMap )
19237
+ _programLayers.enable( 6 );
19238
+ if ( parameters.envMapCubeUV )
19239
+ _programLayers.enable( 7 );
19240
+ if ( parameters.lightMap )
19241
+ _programLayers.enable( 8 );
19242
+ if ( parameters.aoMap )
19243
+ _programLayers.enable( 9 );
19244
+ if ( parameters.emissiveMap )
19245
+ _programLayers.enable( 10 );
19246
+ if ( parameters.bumpMap )
19247
+ _programLayers.enable( 11 );
19248
+ if ( parameters.normalMap )
19249
+ _programLayers.enable( 12 );
19250
+ if ( parameters.objectSpaceNormalMap )
19251
+ _programLayers.enable( 13 );
19252
+ if ( parameters.tangentSpaceNormalMap )
19253
+ _programLayers.enable( 14 );
19254
+ if ( parameters.clearcoat )
19255
+ _programLayers.enable( 15 );
19256
+ if ( parameters.clearcoatMap )
19257
+ _programLayers.enable( 16 );
19258
+ if ( parameters.clearcoatRoughnessMap )
19259
+ _programLayers.enable( 17 );
19260
+ if ( parameters.clearcoatNormalMap )
19261
+ _programLayers.enable( 18 );
19262
+ if ( parameters.displacementMap )
19263
+ _programLayers.enable( 19 );
19264
+ if ( parameters.specularMap )
19265
+ _programLayers.enable( 20 );
19266
+ if ( parameters.roughnessMap )
19267
+ _programLayers.enable( 21 );
19268
+ if ( parameters.metalnessMap )
19269
+ _programLayers.enable( 22 );
19270
+ if ( parameters.gradientMap )
19271
+ _programLayers.enable( 23 );
19272
+ if ( parameters.alphaMap )
19273
+ _programLayers.enable( 24 );
19274
+ if ( parameters.alphaTest )
19275
+ _programLayers.enable( 25 );
19276
+ if ( parameters.vertexColors )
19277
+ _programLayers.enable( 26 );
19278
+ if ( parameters.vertexAlphas )
19279
+ _programLayers.enable( 27 );
19280
+ if ( parameters.vertexUvs )
19281
+ _programLayers.enable( 28 );
19282
+ if ( parameters.vertexTangents )
19283
+ _programLayers.enable( 29 );
19284
+ if ( parameters.uvsVertexOnly )
19285
+ _programLayers.enable( 30 );
19286
+ if ( parameters.fog )
19287
+ _programLayers.enable( 31 );
19288
+
19289
+ array.push( _programLayers.mask );
19290
+ _programLayers.disableAll();
19291
+
19292
+ if ( parameters.useFog )
19293
+ _programLayers.enable( 0 );
19294
+ if ( parameters.flatShading )
19295
+ _programLayers.enable( 1 );
19296
+ if ( parameters.logarithmicDepthBuffer )
19297
+ _programLayers.enable( 2 );
19298
+ if ( parameters.skinning )
19299
+ _programLayers.enable( 3 );
19300
+ if ( parameters.useVertexTexture )
19301
+ _programLayers.enable( 4 );
19302
+ if ( parameters.morphTargets )
19303
+ _programLayers.enable( 5 );
19304
+ if ( parameters.morphNormals )
19305
+ _programLayers.enable( 6 );
19306
+ if ( parameters.premultipliedAlpha )
19307
+ _programLayers.enable( 7 );
19308
+ if ( parameters.shadowMapEnabled )
19309
+ _programLayers.enable( 8 );
19310
+ if ( parameters.physicallyCorrectLights )
19311
+ _programLayers.enable( 9 );
19312
+ if ( parameters.doubleSided )
19313
+ _programLayers.enable( 10 );
19314
+ if ( parameters.flipSided )
19315
+ _programLayers.enable( 11 );
19316
+ if ( parameters.depthPacking )
19317
+ _programLayers.enable( 12 );
19318
+ if ( parameters.dithering )
19319
+ _programLayers.enable( 13 );
19320
+ if ( parameters.specularIntensityMap )
19321
+ _programLayers.enable( 14 );
19322
+ if ( parameters.specularColorMap )
19323
+ _programLayers.enable( 15 );
19324
+ if ( parameters.transmission )
19325
+ _programLayers.enable( 16 );
19326
+ if ( parameters.transmissionMap )
19327
+ _programLayers.enable( 17 );
19328
+ if ( parameters.thicknessMap )
19329
+ _programLayers.enable( 18 );
19330
+ if ( parameters.sheen )
19331
+ _programLayers.enable( 19 );
19332
+ if ( parameters.sheenColorMap )
19333
+ _programLayers.enable( 20 );
19334
+ if ( parameters.sheenRoughnessMap )
19335
+ _programLayers.enable( 21 );
19336
+
19337
+ array.push( _programLayers.mask );
19338
+
19339
+ }
19340
+
19159
19341
  function getUniforms( material ) {
19160
19342
 
19161
19343
  const shaderID = shaderIDs[ material.type ];
@@ -19223,14 +19405,28 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
19223
19405
 
19224
19406
  }
19225
19407
 
19408
+ function releaseShaderCache( material ) {
19409
+
19410
+ _customShaders.remove( material );
19411
+
19412
+ }
19413
+
19414
+ function dispose() {
19415
+
19416
+ _customShaders.dispose();
19417
+
19418
+ }
19419
+
19226
19420
  return {
19227
19421
  getParameters: getParameters,
19228
19422
  getProgramCacheKey: getProgramCacheKey,
19229
19423
  getUniforms: getUniforms,
19230
19424
  acquireProgram: acquireProgram,
19231
19425
  releaseProgram: releaseProgram,
19426
+ releaseShaderCache: releaseShaderCache,
19232
19427
  // Exposed for resource monitoring & error feedback via renderer.info:
19233
- programs: programs
19428
+ programs: programs,
19429
+ dispose: dispose
19234
19430
  };
19235
19431
 
19236
19432
  }
@@ -19291,10 +19487,6 @@ function painterSortStable( a, b ) {
19291
19487
 
19292
19488
  return a.renderOrder - b.renderOrder;
19293
19489
 
19294
- } else if ( a.program !== b.program ) {
19295
-
19296
- return a.program.id - b.program.id;
19297
-
19298
19490
  } else if ( a.material.id !== b.material.id ) {
19299
19491
 
19300
19492
  return a.material.id - b.material.id;
@@ -19334,7 +19526,7 @@ function reversePainterSortStable( a, b ) {
19334
19526
  }
19335
19527
 
19336
19528
 
19337
- function WebGLRenderList( properties ) {
19529
+ function WebGLRenderList() {
19338
19530
 
19339
19531
  const renderItems = [];
19340
19532
  let renderItemsIndex = 0;
@@ -19343,8 +19535,6 @@ function WebGLRenderList( properties ) {
19343
19535
  const transmissive = [];
19344
19536
  const transparent = [];
19345
19537
 
19346
- const defaultProgram = { id: - 1 };
19347
-
19348
19538
  function init() {
19349
19539
 
19350
19540
  renderItemsIndex = 0;
@@ -19358,7 +19548,6 @@ function WebGLRenderList( properties ) {
19358
19548
  function getNextRenderItem( object, geometry, material, groupOrder, z, group ) {
19359
19549
 
19360
19550
  let renderItem = renderItems[ renderItemsIndex ];
19361
- const materialProperties = properties.get( material );
19362
19551
 
19363
19552
  if ( renderItem === undefined ) {
19364
19553
 
@@ -19367,7 +19556,6 @@ function WebGLRenderList( properties ) {
19367
19556
  object: object,
19368
19557
  geometry: geometry,
19369
19558
  material: material,
19370
- program: materialProperties.program || defaultProgram,
19371
19559
  groupOrder: groupOrder,
19372
19560
  renderOrder: object.renderOrder,
19373
19561
  z: z,
@@ -19382,7 +19570,6 @@ function WebGLRenderList( properties ) {
19382
19570
  renderItem.object = object;
19383
19571
  renderItem.geometry = geometry;
19384
19572
  renderItem.material = material;
19385
- renderItem.program = materialProperties.program || defaultProgram;
19386
19573
  renderItem.groupOrder = groupOrder;
19387
19574
  renderItem.renderOrder = object.renderOrder;
19388
19575
  renderItem.z = z;
@@ -19458,7 +19645,6 @@ function WebGLRenderList( properties ) {
19458
19645
  renderItem.object = null;
19459
19646
  renderItem.geometry = null;
19460
19647
  renderItem.material = null;
19461
- renderItem.program = null;
19462
19648
  renderItem.group = null;
19463
19649
 
19464
19650
  }
@@ -19481,7 +19667,7 @@ function WebGLRenderList( properties ) {
19481
19667
 
19482
19668
  }
19483
19669
 
19484
- function WebGLRenderLists( properties ) {
19670
+ function WebGLRenderLists() {
19485
19671
 
19486
19672
  let lists = new WeakMap();
19487
19673
 
@@ -19491,14 +19677,14 @@ function WebGLRenderLists( properties ) {
19491
19677
 
19492
19678
  if ( lists.has( scene ) === false ) {
19493
19679
 
19494
- list = new WebGLRenderList( properties );
19680
+ list = new WebGLRenderList();
19495
19681
  lists.set( scene, [ list ] );
19496
19682
 
19497
19683
  } else {
19498
19684
 
19499
19685
  if ( renderCallDepth >= lists.get( scene ).length ) {
19500
19686
 
19501
- list = new WebGLRenderList( properties );
19687
+ list = new WebGLRenderList();
19502
19688
  lists.get( scene ).push( list );
19503
19689
 
19504
19690
  } else {
@@ -20311,7 +20497,7 @@ MeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;
20311
20497
 
20312
20498
  const vertex = "void main() {\n\tgl_Position = vec4( position, 1.0 );\n}";
20313
20499
 
20314
- const fragment = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nuniform float samples;\n#include <packing>\nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";
20500
+ const fragment = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";
20315
20501
 
20316
20502
  function WebGLShadowMap( _renderer, _objects, _capabilities ) {
20317
20503
 
@@ -20332,12 +20518,13 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
20332
20518
  const shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide };
20333
20519
 
20334
20520
  const shadowMaterialVertical = new ShaderMaterial( {
20335
-
20521
+ defines: {
20522
+ VSM_SAMPLES: 8
20523
+ },
20336
20524
  uniforms: {
20337
20525
  shadow_pass: { value: null },
20338
20526
  resolution: { value: new Vector2() },
20339
- radius: { value: 4.0 },
20340
- samples: { value: 8.0 }
20527
+ radius: { value: 4.0 }
20341
20528
  },
20342
20529
 
20343
20530
  vertexShader: vertex,
@@ -20503,12 +20690,21 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
20503
20690
 
20504
20691
  const geometry = _objects.update( fullScreenMesh );
20505
20692
 
20693
+ if ( shadowMaterialVertical.defines.VSM_SAMPLES !== shadow.blurSamples ) {
20694
+
20695
+ shadowMaterialVertical.defines.VSM_SAMPLES = shadow.blurSamples;
20696
+ shadowMaterialHorizontal.defines.VSM_SAMPLES = shadow.blurSamples;
20697
+
20698
+ shadowMaterialVertical.needsUpdate = true;
20699
+ shadowMaterialHorizontal.needsUpdate = true;
20700
+
20701
+ }
20702
+
20506
20703
  // vertical pass
20507
20704
 
20508
20705
  shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;
20509
20706
  shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;
20510
20707
  shadowMaterialVertical.uniforms.radius.value = shadow.radius;
20511
- shadowMaterialVertical.uniforms.samples.value = shadow.blurSamples;
20512
20708
  _renderer.setRenderTarget( shadow.mapPass );
20513
20709
  _renderer.clear();
20514
20710
  _renderer.renderBufferDirect( camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null );
@@ -20518,7 +20714,6 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
20518
20714
  shadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture;
20519
20715
  shadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize;
20520
20716
  shadowMaterialHorizontal.uniforms.radius.value = shadow.radius;
20521
- shadowMaterialHorizontal.uniforms.samples.value = shadow.blurSamples;
20522
20717
  _renderer.setRenderTarget( shadow.map );
20523
20718
  _renderer.clear();
20524
20719
  _renderer.renderBufferDirect( camera, null, geometry, shadowMaterialHorizontal, fullScreenMesh, null );
@@ -20984,7 +21179,6 @@ function WebGLState( gl, extensions, capabilities ) {
20984
21179
 
20985
21180
  let enabledCapabilities = {};
20986
21181
 
20987
- let xrFramebuffer = null;
20988
21182
  let currentBoundFramebuffers = {};
20989
21183
 
20990
21184
  let currentProgram = null;
@@ -21096,22 +21290,8 @@ function WebGLState( gl, extensions, capabilities ) {
21096
21290
 
21097
21291
  }
21098
21292
 
21099
- function bindXRFramebuffer( framebuffer ) {
21100
-
21101
- if ( framebuffer !== xrFramebuffer ) {
21102
-
21103
- gl.bindFramebuffer( 36160, framebuffer );
21104
-
21105
- xrFramebuffer = framebuffer;
21106
-
21107
- }
21108
-
21109
- }
21110
-
21111
21293
  function bindFramebuffer( target, framebuffer ) {
21112
21294
 
21113
- if ( framebuffer === null && xrFramebuffer !== null ) framebuffer = xrFramebuffer; // use active XR framebuffer if available
21114
-
21115
21295
  if ( currentBoundFramebuffers[ target ] !== framebuffer ) {
21116
21296
 
21117
21297
  gl.bindFramebuffer( target, framebuffer );
@@ -21547,6 +21727,76 @@ function WebGLState( gl, extensions, capabilities ) {
21547
21727
 
21548
21728
  }
21549
21729
 
21730
+ function texSubImage2D() {
21731
+
21732
+ try {
21733
+
21734
+ gl.texSubImage2D.apply( gl, arguments );
21735
+
21736
+ } catch ( error ) {
21737
+
21738
+ console.error( 'THREE.WebGLState:', error );
21739
+
21740
+ }
21741
+
21742
+ }
21743
+
21744
+ function texSubImage3D() {
21745
+
21746
+ try {
21747
+
21748
+ gl.texSubImage3D.apply( gl, arguments );
21749
+
21750
+ } catch ( error ) {
21751
+
21752
+ console.error( 'THREE.WebGLState:', error );
21753
+
21754
+ }
21755
+
21756
+ }
21757
+
21758
+ function compressedTexSubImage2D() {
21759
+
21760
+ try {
21761
+
21762
+ gl.compressedTexSubImage2D.apply( gl, arguments );
21763
+
21764
+ } catch ( error ) {
21765
+
21766
+ console.error( 'THREE.WebGLState:', error );
21767
+
21768
+ }
21769
+
21770
+ }
21771
+
21772
+ function texStorage2D() {
21773
+
21774
+ try {
21775
+
21776
+ gl.texStorage2D.apply( gl, arguments );
21777
+
21778
+ } catch ( error ) {
21779
+
21780
+ console.error( 'THREE.WebGLState:', error );
21781
+
21782
+ }
21783
+
21784
+ }
21785
+
21786
+ function texStorage3D() {
21787
+
21788
+ try {
21789
+
21790
+ gl.texStorage3D.apply( gl, arguments );
21791
+
21792
+ } catch ( error ) {
21793
+
21794
+ console.error( 'THREE.WebGLState:', error );
21795
+
21796
+ }
21797
+
21798
+ }
21799
+
21550
21800
  function texImage2D() {
21551
21801
 
21552
21802
  try {
@@ -21659,7 +21909,6 @@ function WebGLState( gl, extensions, capabilities ) {
21659
21909
  currentTextureSlot = null;
21660
21910
  currentBoundTextures = {};
21661
21911
 
21662
- xrFramebuffer = null;
21663
21912
  currentBoundFramebuffers = {};
21664
21913
 
21665
21914
  currentProgram = null;
@@ -21703,7 +21952,6 @@ function WebGLState( gl, extensions, capabilities ) {
21703
21952
  disable: disable,
21704
21953
 
21705
21954
  bindFramebuffer: bindFramebuffer,
21706
- bindXRFramebuffer: bindXRFramebuffer,
21707
21955
 
21708
21956
  useProgram: useProgram,
21709
21957
 
@@ -21725,6 +21973,12 @@ function WebGLState( gl, extensions, capabilities ) {
21725
21973
  texImage2D: texImage2D,
21726
21974
  texImage3D: texImage3D,
21727
21975
 
21976
+ texStorage2D: texStorage2D,
21977
+ texStorage3D: texStorage3D,
21978
+ texSubImage2D: texSubImage2D,
21979
+ texSubImage3D: texSubImage3D,
21980
+ compressedTexSubImage2D: compressedTexSubImage2D,
21981
+
21728
21982
  scissor: scissor,
21729
21983
  viewport: viewport,
21730
21984
 
@@ -21741,6 +21995,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
21741
21995
  const maxCubemapSize = capabilities.maxCubemapSize;
21742
21996
  const maxTextureSize = capabilities.maxTextureSize;
21743
21997
  const maxSamples = capabilities.maxSamples;
21998
+ const hasMultisampledRenderToTexture = extensions.has( 'WEBGL_multisampled_render_to_texture' );
21999
+ const MultisampledRenderToTextureExtension = hasMultisampledRenderToTexture ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : undefined;
21744
22000
 
21745
22001
  const _videoTextures = new WeakMap();
21746
22002
  let _canvas;
@@ -21854,14 +22110,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
21854
22110
 
21855
22111
  }
21856
22112
 
21857
- function generateMipmap( target, texture, width, height, depth = 1 ) {
22113
+ function generateMipmap( target ) {
21858
22114
 
21859
22115
  _gl.generateMipmap( target );
21860
22116
 
21861
- const textureProperties = properties.get( texture );
21862
-
21863
- textureProperties.__maxMipLevel = Math.log2( Math.max( width, height, depth ) );
21864
-
21865
22117
  }
21866
22118
 
21867
22119
  function getInternalFormat( internalFormatName, glFormat, glType, encoding ) {
@@ -21913,6 +22165,32 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
21913
22165
 
21914
22166
  }
21915
22167
 
22168
+ function getMipLevels( texture, image, supportsMips ) {
22169
+
22170
+ if ( textureNeedsGenerateMipmaps( texture, supportsMips ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
22171
+
22172
+ return Math.log2( Math.max( image.width, image.height ) ) + 1;
22173
+
22174
+ } else if ( texture.mipmaps !== undefined && texture.mipmaps.length > 0 ) {
22175
+
22176
+ // user-defined mipmaps
22177
+
22178
+ return texture.mipmaps.length;
22179
+
22180
+ } else if ( texture.isCompressedTexture && Array.isArray( texture.image ) ) {
22181
+
22182
+ return image.mipmaps.length;
22183
+
22184
+ } else {
22185
+
22186
+ // texture without mipmaps (only base level)
22187
+
22188
+ return 1;
22189
+
22190
+ }
22191
+
22192
+ }
22193
+
21916
22194
  // Fallback filters for non-power-of-2 textures
21917
22195
 
21918
22196
  function filterFallback( f ) {
@@ -22271,6 +22549,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22271
22549
  let mipmap;
22272
22550
  const mipmaps = texture.mipmaps;
22273
22551
 
22552
+ const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
22553
+ const allocateMemory = ( textureProperties.__version === undefined );
22554
+ const levels = getMipLevels( texture, image, supportsMips );
22555
+
22274
22556
  if ( texture.isDepthTexture ) {
22275
22557
 
22276
22558
  // populate depth texture with dummy data
@@ -22347,7 +22629,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22347
22629
 
22348
22630
  //
22349
22631
 
22350
- state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
22632
+ if ( useTexStorage && allocateMemory ) {
22633
+
22634
+ state.texStorage2D( 3553, 1, glInternalFormat, image.width, image.height );
22635
+
22636
+ } else {
22637
+
22638
+ state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
22639
+
22640
+ }
22351
22641
 
22352
22642
  } else if ( texture.isDataTexture ) {
22353
22643
 
@@ -22357,25 +22647,58 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22357
22647
 
22358
22648
  if ( mipmaps.length > 0 && supportsMips ) {
22359
22649
 
22650
+ if ( useTexStorage && allocateMemory ) {
22651
+
22652
+ state.texStorage2D( 3553, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
22653
+
22654
+ }
22655
+
22360
22656
  for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
22361
22657
 
22362
22658
  mipmap = mipmaps[ i ];
22363
- state.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
22659
+
22660
+ if ( useTexStorage ) {
22661
+
22662
+ state.texSubImage2D( 3553, 0, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
22663
+
22664
+ } else {
22665
+
22666
+ state.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
22667
+
22668
+ }
22364
22669
 
22365
22670
  }
22366
22671
 
22367
22672
  texture.generateMipmaps = false;
22368
- textureProperties.__maxMipLevel = mipmaps.length - 1;
22369
22673
 
22370
22674
  } else {
22371
22675
 
22372
- state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data );
22373
- textureProperties.__maxMipLevel = 0;
22676
+ if ( useTexStorage ) {
22677
+
22678
+ if ( allocateMemory ) {
22679
+
22680
+ state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height );
22681
+
22682
+ }
22683
+
22684
+ state.texSubImage2D( 3553, 0, 0, 0, image.width, image.height, glFormat, glType, image.data );
22685
+
22686
+ } else {
22687
+
22688
+ state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data );
22689
+
22690
+ }
22374
22691
 
22375
22692
  }
22376
22693
 
22377
22694
  } else if ( texture.isCompressedTexture ) {
22378
22695
 
22696
+ if ( useTexStorage && allocateMemory ) {
22697
+
22698
+ state.texStorage2D( 3553, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
22699
+
22700
+ }
22701
+
22379
22702
  for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
22380
22703
 
22381
22704
  mipmap = mipmaps[ i ];
@@ -22384,7 +22707,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22384
22707
 
22385
22708
  if ( glFormat !== null ) {
22386
22709
 
22387
- state.compressedTexImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
22710
+ if ( useTexStorage ) {
22711
+
22712
+ state.compressedTexSubImage2D( 3553, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
22713
+
22714
+ } else {
22715
+
22716
+ state.compressedTexImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
22717
+
22718
+ }
22388
22719
 
22389
22720
  } else {
22390
22721
 
@@ -22394,23 +22725,67 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22394
22725
 
22395
22726
  } else {
22396
22727
 
22397
- state.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
22728
+ if ( useTexStorage ) {
22729
+
22730
+ state.texSubImage2D( 3553, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
22731
+
22732
+ } else {
22733
+
22734
+ state.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
22735
+
22736
+ }
22398
22737
 
22399
22738
  }
22400
22739
 
22401
22740
  }
22402
22741
 
22403
- textureProperties.__maxMipLevel = mipmaps.length - 1;
22404
-
22405
22742
  } else if ( texture.isDataTexture2DArray ) {
22406
22743
 
22407
- state.texImage3D( 35866, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
22408
- textureProperties.__maxMipLevel = 0;
22744
+ if ( useTexStorage ) {
22745
+
22746
+ if ( allocateMemory ) {
22747
+
22748
+ state.texStorage3D( 35866, levels, glInternalFormat, image.width, image.height, image.depth );
22749
+
22750
+ }
22751
+
22752
+ state.texSubImage3D( 35866, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
22753
+
22754
+ } else {
22755
+
22756
+ state.texImage3D( 35866, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
22757
+
22758
+ }
22409
22759
 
22410
22760
  } else if ( texture.isDataTexture3D ) {
22411
22761
 
22412
- state.texImage3D( 32879, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
22413
- textureProperties.__maxMipLevel = 0;
22762
+ if ( useTexStorage ) {
22763
+
22764
+ if ( allocateMemory ) {
22765
+
22766
+ state.texStorage3D( 32879, levels, glInternalFormat, image.width, image.height, image.depth );
22767
+
22768
+ }
22769
+
22770
+ state.texSubImage3D( 32879, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
22771
+
22772
+ } else {
22773
+
22774
+ state.texImage3D( 32879, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
22775
+
22776
+ }
22777
+
22778
+ } else if ( texture.isFramebufferTexture ) {
22779
+
22780
+ if ( useTexStorage && allocateMemory ) {
22781
+
22782
+ state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height );
22783
+
22784
+ } else {
22785
+
22786
+ state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
22787
+
22788
+ }
22414
22789
 
22415
22790
  } else {
22416
22791
 
@@ -22422,20 +22797,47 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22422
22797
 
22423
22798
  if ( mipmaps.length > 0 && supportsMips ) {
22424
22799
 
22800
+ if ( useTexStorage && allocateMemory ) {
22801
+
22802
+ state.texStorage2D( 3553, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
22803
+
22804
+ }
22805
+
22425
22806
  for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
22426
22807
 
22427
22808
  mipmap = mipmaps[ i ];
22428
- state.texImage2D( 3553, i, glInternalFormat, glFormat, glType, mipmap );
22809
+
22810
+ if ( useTexStorage ) {
22811
+
22812
+ state.texSubImage2D( 3553, i, 0, 0, glFormat, glType, mipmap );
22813
+
22814
+ } else {
22815
+
22816
+ state.texImage2D( 3553, i, glInternalFormat, glFormat, glType, mipmap );
22817
+
22818
+ }
22429
22819
 
22430
22820
  }
22431
22821
 
22432
22822
  texture.generateMipmaps = false;
22433
- textureProperties.__maxMipLevel = mipmaps.length - 1;
22434
22823
 
22435
22824
  } else {
22436
22825
 
22437
- state.texImage2D( 3553, 0, glInternalFormat, glFormat, glType, image );
22438
- textureProperties.__maxMipLevel = 0;
22826
+ if ( useTexStorage ) {
22827
+
22828
+ if ( allocateMemory ) {
22829
+
22830
+ state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height );
22831
+
22832
+ }
22833
+
22834
+ state.texSubImage2D( 3553, 0, 0, 0, glFormat, glType, image );
22835
+
22836
+ } else {
22837
+
22838
+ state.texImage2D( 3553, 0, glInternalFormat, glFormat, glType, image );
22839
+
22840
+ }
22439
22841
 
22440
22842
  }
22441
22843
 
@@ -22443,7 +22845,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22443
22845
 
22444
22846
  if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
22445
22847
 
22446
- generateMipmap( textureType, texture, image.width, image.height );
22848
+ generateMipmap( textureType );
22447
22849
 
22448
22850
  }
22449
22851
 
@@ -22492,12 +22894,22 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22492
22894
  glType = utils.convert( texture.type ),
22493
22895
  glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
22494
22896
 
22897
+ const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
22898
+ const allocateMemory = ( textureProperties.__version === undefined );
22899
+ let levels = getMipLevels( texture, image, supportsMips );
22900
+
22495
22901
  setTextureParameters( 34067, texture, supportsMips );
22496
22902
 
22497
22903
  let mipmaps;
22498
22904
 
22499
22905
  if ( isCompressed ) {
22500
22906
 
22907
+ if ( useTexStorage && allocateMemory ) {
22908
+
22909
+ state.texStorage2D( 34067, levels, glInternalFormat, image.width, image.height );
22910
+
22911
+ }
22912
+
22501
22913
  for ( let i = 0; i < 6; i ++ ) {
22502
22914
 
22503
22915
  mipmaps = cubeImage[ i ].mipmaps;
@@ -22510,7 +22922,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22510
22922
 
22511
22923
  if ( glFormat !== null ) {
22512
22924
 
22513
- state.compressedTexImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
22925
+ if ( useTexStorage ) {
22926
+
22927
+ state.compressedTexSubImage2D( 34069 + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
22928
+
22929
+ } else {
22930
+
22931
+ state.compressedTexImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
22932
+
22933
+ }
22514
22934
 
22515
22935
  } else {
22516
22936
 
@@ -22520,7 +22940,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22520
22940
 
22521
22941
  } else {
22522
22942
 
22523
- state.texImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
22943
+ if ( useTexStorage ) {
22944
+
22945
+ state.texSubImage2D( 34069 + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
22946
+
22947
+ } else {
22948
+
22949
+ state.texImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
22950
+
22951
+ }
22524
22952
 
22525
22953
  }
22526
22954
 
@@ -22528,36 +22956,78 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22528
22956
 
22529
22957
  }
22530
22958
 
22531
- textureProperties.__maxMipLevel = mipmaps.length - 1;
22532
-
22533
22959
  } else {
22534
22960
 
22535
22961
  mipmaps = texture.mipmaps;
22536
22962
 
22963
+ if ( useTexStorage && allocateMemory ) {
22964
+
22965
+ // TODO: Uniformly handle mipmap definitions
22966
+ // Normal textures and compressed cube textures define base level + mips with their mipmap array
22967
+ // Uncompressed cube textures use their mipmap array only for mips (no base level)
22968
+
22969
+ if ( mipmaps.length > 0 ) levels ++;
22970
+
22971
+ state.texStorage2D( 34067, levels, glInternalFormat, cubeImage[ 0 ].width, cubeImage[ 0 ].height );
22972
+
22973
+ }
22974
+
22537
22975
  for ( let i = 0; i < 6; i ++ ) {
22538
22976
 
22539
22977
  if ( isDataTexture ) {
22540
22978
 
22541
- state.texImage2D( 34069 + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data );
22979
+ if ( useTexStorage ) {
22980
+
22981
+ state.texSubImage2D( 34069 + i, 0, 0, 0, cubeImage[ i ].width, cubeImage[ i ].height, glFormat, glType, cubeImage[ i ].data );
22982
+
22983
+ } else {
22984
+
22985
+ state.texImage2D( 34069 + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data );
22986
+
22987
+ }
22542
22988
 
22543
22989
  for ( let j = 0; j < mipmaps.length; j ++ ) {
22544
22990
 
22545
22991
  const mipmap = mipmaps[ j ];
22546
22992
  const mipmapImage = mipmap.image[ i ].image;
22547
22993
 
22548
- state.texImage2D( 34069 + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data );
22994
+ if ( useTexStorage ) {
22995
+
22996
+ state.texSubImage2D( 34069 + i, j + 1, 0, 0, mipmapImage.width, mipmapImage.height, glFormat, glType, mipmapImage.data );
22997
+
22998
+ } else {
22999
+
23000
+ state.texImage2D( 34069 + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data );
23001
+
23002
+ }
22549
23003
 
22550
23004
  }
22551
23005
 
22552
23006
  } else {
22553
23007
 
22554
- state.texImage2D( 34069 + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );
23008
+ if ( useTexStorage ) {
23009
+
23010
+ state.texSubImage2D( 34069 + i, 0, 0, 0, glFormat, glType, cubeImage[ i ] );
23011
+
23012
+ } else {
23013
+
23014
+ state.texImage2D( 34069 + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );
23015
+
23016
+ }
22555
23017
 
22556
23018
  for ( let j = 0; j < mipmaps.length; j ++ ) {
22557
23019
 
22558
23020
  const mipmap = mipmaps[ j ];
22559
23021
 
22560
- state.texImage2D( 34069 + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] );
23022
+ if ( useTexStorage ) {
23023
+
23024
+ state.texSubImage2D( 34069 + i, j + 1, 0, 0, glFormat, glType, mipmap.image[ i ] );
23025
+
23026
+ } else {
23027
+
23028
+ state.texImage2D( 34069 + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] );
23029
+
23030
+ }
22561
23031
 
22562
23032
  }
22563
23033
 
@@ -22565,14 +23035,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22565
23035
 
22566
23036
  }
22567
23037
 
22568
- textureProperties.__maxMipLevel = mipmaps.length;
22569
-
22570
23038
  }
22571
23039
 
22572
23040
  if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
22573
23041
 
22574
23042
  // We assume images for cube map have the same size.
22575
- generateMipmap( 34067, texture, image.width, image.height );
23043
+ generateMipmap( 34067 );
22576
23044
 
22577
23045
  }
22578
23046
 
@@ -22590,23 +23058,38 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22590
23058
  const glFormat = utils.convert( texture.format );
22591
23059
  const glType = utils.convert( texture.type );
22592
23060
  const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
23061
+ const renderTargetProperties = properties.get( renderTarget );
22593
23062
 
22594
- if ( textureTarget === 32879 || textureTarget === 35866 ) {
23063
+ if ( ! renderTargetProperties.__hasExternalTextures ) {
22595
23064
 
22596
- state.texImage3D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.depth, 0, glFormat, glType, null );
23065
+ if ( textureTarget === 32879 || textureTarget === 35866 ) {
22597
23066
 
22598
- } else {
23067
+ state.texImage3D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.depth, 0, glFormat, glType, null );
22599
23068
 
22600
- state.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );
23069
+ } else {
23070
+
23071
+ state.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );
23072
+
23073
+ }
22601
23074
 
22602
23075
  }
22603
23076
 
22604
23077
  state.bindFramebuffer( 36160, framebuffer );
22605
- _gl.framebufferTexture2D( 36160, attachment, textureTarget, properties.get( texture ).__webglTexture, 0 );
23078
+ if ( renderTarget.useRenderToTexture ) {
23079
+
23080
+ MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( 36160, attachment, textureTarget, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
23081
+
23082
+ } else {
23083
+
23084
+ _gl.framebufferTexture2D( 36160, attachment, textureTarget, properties.get( texture ).__webglTexture, 0 );
23085
+
23086
+ }
23087
+
22606
23088
  state.bindFramebuffer( 36160, null );
22607
23089
 
22608
23090
  }
22609
23091
 
23092
+
22610
23093
  // Setup storage for internal depth/stencil buffers and bind to correct framebuffer
22611
23094
  function setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {
22612
23095
 
@@ -22616,7 +23099,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22616
23099
 
22617
23100
  let glInternalFormat = 33189;
22618
23101
 
22619
- if ( isMultisample ) {
23102
+ if ( isMultisample || renderTarget.useRenderToTexture ) {
22620
23103
 
22621
23104
  const depthTexture = renderTarget.depthTexture;
22622
23105
 
@@ -22636,7 +23119,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22636
23119
 
22637
23120
  const samples = getRenderTargetSamples( renderTarget );
22638
23121
 
22639
- _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height );
23122
+ if ( renderTarget.useRenderToTexture ) {
23123
+
23124
+ MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height );
23125
+
23126
+ } else {
23127
+
23128
+ _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height );
23129
+
23130
+ }
22640
23131
 
22641
23132
  } else {
22642
23133
 
@@ -22648,12 +23139,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22648
23139
 
22649
23140
  } else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) {
22650
23141
 
22651
- if ( isMultisample ) {
23142
+ const samples = getRenderTargetSamples( renderTarget );
22652
23143
 
22653
- const samples = getRenderTargetSamples( renderTarget );
23144
+ if ( isMultisample && renderTarget.useRenderbuffer ) {
22654
23145
 
22655
23146
  _gl.renderbufferStorageMultisample( 36161, samples, 35056, renderTarget.width, renderTarget.height );
22656
23147
 
23148
+ } else if ( renderTarget.useRenderToTexture ) {
23149
+
23150
+ MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( 36161, samples, 35056, renderTarget.width, renderTarget.height );
23151
+
22657
23152
  } else {
22658
23153
 
22659
23154
  _gl.renderbufferStorage( 36161, 34041, renderTarget.width, renderTarget.height );
@@ -22671,13 +23166,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22671
23166
  const glFormat = utils.convert( texture.format );
22672
23167
  const glType = utils.convert( texture.type );
22673
23168
  const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
23169
+ const samples = getRenderTargetSamples( renderTarget );
22674
23170
 
22675
- if ( isMultisample ) {
22676
-
22677
- const samples = getRenderTargetSamples( renderTarget );
23171
+ if ( isMultisample && renderTarget.useRenderbuffer ) {
22678
23172
 
22679
23173
  _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height );
22680
23174
 
23175
+ } else if ( renderTarget.useRenderToTexture ) {
23176
+
23177
+ MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height );
23178
+
22681
23179
  } else {
22682
23180
 
22683
23181
  _gl.renderbufferStorage( 36161, glInternalFormat, renderTarget.width, renderTarget.height );
@@ -22718,14 +23216,31 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22718
23216
  setTexture2D( renderTarget.depthTexture, 0 );
22719
23217
 
22720
23218
  const webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture;
23219
+ const samples = getRenderTargetSamples( renderTarget );
22721
23220
 
22722
23221
  if ( renderTarget.depthTexture.format === DepthFormat ) {
22723
23222
 
22724
- _gl.framebufferTexture2D( 36160, 36096, 3553, webglDepthTexture, 0 );
23223
+ if ( renderTarget.useRenderToTexture ) {
23224
+
23225
+ MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( 36160, 36096, 3553, webglDepthTexture, 0, samples );
23226
+
23227
+ } else {
23228
+
23229
+ _gl.framebufferTexture2D( 36160, 36096, 3553, webglDepthTexture, 0 );
23230
+
23231
+ }
22725
23232
 
22726
23233
  } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
22727
23234
 
22728
- _gl.framebufferTexture2D( 36160, 33306, 3553, webglDepthTexture, 0 );
23235
+ if ( renderTarget.useRenderToTexture ) {
23236
+
23237
+ MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( 36160, 33306, 3553, webglDepthTexture, 0, samples );
23238
+
23239
+ } else {
23240
+
23241
+ _gl.framebufferTexture2D( 36160, 33306, 3553, webglDepthTexture, 0 );
23242
+
23243
+ }
22729
23244
 
22730
23245
  } else {
22731
23246
 
@@ -22739,10 +23254,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22739
23254
  function setupDepthRenderbuffer( renderTarget ) {
22740
23255
 
22741
23256
  const renderTargetProperties = properties.get( renderTarget );
22742
-
22743
23257
  const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
22744
23258
 
22745
- if ( renderTarget.depthTexture ) {
23259
+ if ( renderTarget.depthTexture && ! renderTargetProperties.__autoAllocateDepthBuffer ) {
22746
23260
 
22747
23261
  if ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );
22748
23262
 
@@ -22776,6 +23290,25 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22776
23290
 
22777
23291
  }
22778
23292
 
23293
+ // rebind framebuffer with external textures
23294
+ function rebindTextures( renderTarget, colorTexture, depthTexture ) {
23295
+
23296
+ const renderTargetProperties = properties.get( renderTarget );
23297
+
23298
+ if ( colorTexture !== undefined ) {
23299
+
23300
+ setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, renderTarget.texture, 36064, 3553 );
23301
+
23302
+ }
23303
+
23304
+ if ( depthTexture !== undefined ) {
23305
+
23306
+ setupDepthRenderbuffer( renderTarget );
23307
+
23308
+ }
23309
+
23310
+ }
23311
+
22779
23312
  // Set up GL resources for the render target
22780
23313
  function setupRenderTarget( renderTarget ) {
22781
23314
 
@@ -22788,7 +23321,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22788
23321
 
22789
23322
  if ( renderTarget.isWebGLMultipleRenderTargets !== true ) {
22790
23323
 
22791
- textureProperties.__webglTexture = _gl.createTexture();
23324
+ if ( textureProperties.__webglTexture === undefined ) {
23325
+
23326
+ textureProperties.__webglTexture = _gl.createTexture();
23327
+
23328
+ }
23329
+
22792
23330
  textureProperties.__version = texture.version;
22793
23331
  info.memory.textures ++;
22794
23332
 
@@ -22796,7 +23334,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22796
23334
 
22797
23335
  const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
22798
23336
  const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true );
22799
- const isMultisample = ( renderTarget.isWebGLMultisampleRenderTarget === true );
22800
23337
  const isRenderTarget3D = texture.isDataTexture3D || texture.isDataTexture2DArray;
22801
23338
  const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
22802
23339
 
@@ -22852,7 +23389,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22852
23389
 
22853
23390
  }
22854
23391
 
22855
- } else if ( isMultisample ) {
23392
+ } else if ( renderTarget.useRenderbuffer ) {
22856
23393
 
22857
23394
  if ( isWebGL2 ) {
22858
23395
 
@@ -22906,7 +23443,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22906
23443
 
22907
23444
  if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
22908
23445
 
22909
- generateMipmap( 34067, texture, renderTarget.width, renderTarget.height );
23446
+ generateMipmap( 34067 );
22910
23447
 
22911
23448
  }
22912
23449
 
@@ -22927,7 +23464,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22927
23464
 
22928
23465
  if ( textureNeedsGenerateMipmaps( attachment, supportsMips ) ) {
22929
23466
 
22930
- generateMipmap( 3553, attachment, renderTarget.width, renderTarget.height );
23467
+ generateMipmap( 3553 );
22931
23468
 
22932
23469
  }
22933
23470
 
@@ -22962,7 +23499,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22962
23499
 
22963
23500
  if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
22964
23501
 
22965
- generateMipmap( glTextureType, texture, renderTarget.width, renderTarget.height, renderTarget.depth );
23502
+ generateMipmap( glTextureType );
22966
23503
 
22967
23504
  }
22968
23505
 
@@ -22996,7 +23533,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
22996
23533
  const webglTexture = properties.get( texture ).__webglTexture;
22997
23534
 
22998
23535
  state.bindTexture( target, webglTexture );
22999
- generateMipmap( target, texture, renderTarget.width, renderTarget.height );
23536
+ generateMipmap( target );
23000
23537
  state.unbindTexture();
23001
23538
 
23002
23539
  }
@@ -23007,23 +23544,43 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
23007
23544
 
23008
23545
  function updateMultisampleRenderTarget( renderTarget ) {
23009
23546
 
23010
- if ( renderTarget.isWebGLMultisampleRenderTarget ) {
23547
+ if ( renderTarget.useRenderbuffer ) {
23011
23548
 
23012
23549
  if ( isWebGL2 ) {
23013
23550
 
23014
23551
  const width = renderTarget.width;
23015
23552
  const height = renderTarget.height;
23016
23553
  let mask = 16384;
23554
+ const invalidationArray = [ 36064 ];
23555
+ const depthStyle = renderTarget.stencilBuffer ? 33306 : 36096;
23556
+
23557
+ if ( renderTarget.depthBuffer ) {
23017
23558
 
23018
- if ( renderTarget.depthBuffer ) mask |= 256;
23019
- if ( renderTarget.stencilBuffer ) mask |= 1024;
23559
+ invalidationArray.push( depthStyle );
23560
+
23561
+ }
23562
+
23563
+ if ( ! renderTarget.ignoreDepthForMultisampleCopy ) {
23564
+
23565
+ if ( renderTarget.depthBuffer ) mask |= 256;
23566
+ if ( renderTarget.stencilBuffer ) mask |= 1024;
23567
+
23568
+ }
23020
23569
 
23021
23570
  const renderTargetProperties = properties.get( renderTarget );
23022
23571
 
23023
23572
  state.bindFramebuffer( 36008, renderTargetProperties.__webglMultisampledFramebuffer );
23024
23573
  state.bindFramebuffer( 36009, renderTargetProperties.__webglFramebuffer );
23025
23574
 
23575
+ if ( renderTarget.ignoreDepthForMultisampleCopy ) {
23576
+
23577
+ _gl.invalidateFramebuffer( 36008, [ depthStyle ] );
23578
+ _gl.invalidateFramebuffer( 36009, [ depthStyle ] );
23579
+
23580
+ }
23581
+
23026
23582
  _gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, 9728 );
23583
+ _gl.invalidateFramebuffer( 36008, invalidationArray );
23027
23584
 
23028
23585
  state.bindFramebuffer( 36008, null );
23029
23586
  state.bindFramebuffer( 36009, renderTargetProperties.__webglMultisampledFramebuffer );
@@ -23040,7 +23597,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
23040
23597
 
23041
23598
  function getRenderTargetSamples( renderTarget ) {
23042
23599
 
23043
- return ( isWebGL2 && renderTarget.isWebGLMultisampleRenderTarget ) ?
23600
+ return ( isWebGL2 && ( renderTarget.useRenderbuffer || renderTarget.useRenderToTexture ) ) ?
23044
23601
  Math.min( maxSamples, renderTarget.samples ) : 0;
23045
23602
 
23046
23603
  }
@@ -23113,9 +23670,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
23113
23670
  this.setTexture2DArray = setTexture2DArray;
23114
23671
  this.setTexture3D = setTexture3D;
23115
23672
  this.setTextureCube = setTextureCube;
23673
+ this.rebindTextures = rebindTextures;
23116
23674
  this.setupRenderTarget = setupRenderTarget;
23117
23675
  this.updateRenderTargetMipmap = updateRenderTargetMipmap;
23118
23676
  this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
23677
+ this.setupDepthRenderbuffer = setupDepthRenderbuffer;
23678
+ this.setupFrameBufferTexture = setupFrameBufferTexture;
23119
23679
 
23120
23680
  this.safeSetTexture2D = safeSetTexture2D;
23121
23681
  this.safeSetTextureCube = safeSetTextureCube;
@@ -24137,6 +24697,38 @@ class WebXRController {
24137
24697
 
24138
24698
  }
24139
24699
 
24700
+ class DepthTexture extends Texture {
24701
+
24702
+ constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
24703
+
24704
+ format = format !== undefined ? format : DepthFormat;
24705
+
24706
+ if ( format !== DepthFormat && format !== DepthStencilFormat ) {
24707
+
24708
+ throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' );
24709
+
24710
+ }
24711
+
24712
+ if ( type === undefined && format === DepthFormat ) type = UnsignedShortType;
24713
+ if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type;
24714
+
24715
+ super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
24716
+
24717
+ this.image = { width: width, height: height };
24718
+
24719
+ this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
24720
+ this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
24721
+
24722
+ this.flipY = false;
24723
+ this.generateMipmaps = false;
24724
+
24725
+ }
24726
+
24727
+
24728
+ }
24729
+
24730
+ DepthTexture.prototype.isDepthTexture = true;
24731
+
24140
24732
  class WebXRManager extends EventDispatcher {
24141
24733
 
24142
24734
  constructor( renderer, gl ) {
@@ -24144,7 +24736,6 @@ class WebXRManager extends EventDispatcher {
24144
24736
  super();
24145
24737
 
24146
24738
  const scope = this;
24147
- const state = renderer.state;
24148
24739
 
24149
24740
  let session = null;
24150
24741
  let framebufferScaleFactor = 1.0;
@@ -24152,21 +24743,19 @@ class WebXRManager extends EventDispatcher {
24152
24743
 
24153
24744
  let referenceSpace = null;
24154
24745
  let referenceSpaceType = 'local-floor';
24746
+ const hasMultisampledRenderToTexture = renderer.extensions.has( 'WEBGL_multisampled_render_to_texture' );
24155
24747
 
24156
24748
  let pose = null;
24157
24749
  var layers = [];
24158
24750
 
24159
24751
  let glBinding = null;
24160
- let glFramebuffer = null;
24161
24752
  let glProjLayer = null;
24162
24753
  let glBaseLayer = null;
24163
24754
  let isMultisample = false;
24164
- let glMultisampledFramebuffer = null;
24165
- let glColorRenderbuffer = null;
24166
- let glDepthRenderbuffer = null;
24167
24755
  let xrFrame = null;
24168
- let depthStyle = null;
24169
- let clearStyle = null;
24756
+ const attributes = gl.getContextAttributes();
24757
+ let initialRenderTarget = null;
24758
+ let newRenderTarget = null;
24170
24759
 
24171
24760
  const controllers = [];
24172
24761
  const inputSourcesMap = new Map();
@@ -24277,21 +24866,13 @@ class WebXRManager extends EventDispatcher {
24277
24866
 
24278
24867
  // restore framebuffer/rendering state
24279
24868
 
24280
- state.bindXRFramebuffer( null );
24281
- renderer.setRenderTarget( renderer.getRenderTarget() );
24282
-
24283
- if ( glFramebuffer ) gl.deleteFramebuffer( glFramebuffer );
24284
- if ( glMultisampledFramebuffer ) gl.deleteFramebuffer( glMultisampledFramebuffer );
24285
- if ( glColorRenderbuffer ) gl.deleteRenderbuffer( glColorRenderbuffer );
24286
- if ( glDepthRenderbuffer ) gl.deleteRenderbuffer( glDepthRenderbuffer );
24287
- glFramebuffer = null;
24288
- glMultisampledFramebuffer = null;
24289
- glColorRenderbuffer = null;
24290
- glDepthRenderbuffer = null;
24869
+ renderer.setRenderTarget( initialRenderTarget );
24870
+
24291
24871
  glBaseLayer = null;
24292
24872
  glProjLayer = null;
24293
24873
  glBinding = null;
24294
24874
  session = null;
24875
+ newRenderTarget = null;
24295
24876
 
24296
24877
  //
24297
24878
 
@@ -24363,6 +24944,8 @@ class WebXRManager extends EventDispatcher {
24363
24944
 
24364
24945
  if ( session !== null ) {
24365
24946
 
24947
+ initialRenderTarget = renderer.getRenderTarget();
24948
+
24366
24949
  session.addEventListener( 'select', onSessionEvent );
24367
24950
  session.addEventListener( 'selectstart', onSessionEvent );
24368
24951
  session.addEventListener( 'selectend', onSessionEvent );
@@ -24372,18 +24955,16 @@ class WebXRManager extends EventDispatcher {
24372
24955
  session.addEventListener( 'end', onSessionEnd );
24373
24956
  session.addEventListener( 'inputsourceschange', onInputSourcesChange );
24374
24957
 
24375
- const attributes = gl.getContextAttributes();
24376
-
24377
24958
  if ( attributes.xrCompatible !== true ) {
24378
24959
 
24379
24960
  await gl.makeXRCompatible();
24380
24961
 
24381
24962
  }
24382
24963
 
24383
- if ( session.renderState.layers === undefined) {
24964
+ if ( ( session.renderState.layers === undefined ) || ( renderer.capabilities.isWebGL2 === false ) ) {
24384
24965
 
24385
24966
  const layerInit = {
24386
- antialias: attributes.antialias,
24967
+ antialias: ( session.renderState.layers === undefined ) ? attributes.antialias : true,
24387
24968
  alpha: attributes.alpha,
24388
24969
  depth: attributes.depth,
24389
24970
  stencil: attributes.stencil,
@@ -24394,43 +24975,34 @@ class WebXRManager extends EventDispatcher {
24394
24975
 
24395
24976
  session.updateRenderState( { baseLayer: glBaseLayer } );
24396
24977
 
24397
- } else if ( gl instanceof WebGLRenderingContext ) {
24398
-
24399
- // Use old style webgl layer because we can't use MSAA
24400
- // WebGL2 support.
24401
-
24402
- const layerInit = {
24403
- antialias: true,
24404
- alpha: attributes.alpha,
24405
- depth: attributes.depth,
24406
- stencil: attributes.stencil,
24407
- framebufferScaleFactor: framebufferScaleFactor
24408
- };
24409
-
24410
- glBaseLayer = new XRWebGLLayer( session, gl, layerInit );
24411
-
24412
- session.updateRenderState( { layers: [ glBaseLayer ] } );
24978
+ newRenderTarget = new WebGLRenderTarget(
24979
+ glBaseLayer.framebufferWidth,
24980
+ glBaseLayer.framebufferHeight,
24981
+ {
24982
+ format: RGBAFormat,
24983
+ type: UnsignedByteType,
24984
+ encoding: renderer.outputEncoding
24985
+ }
24986
+ );
24413
24987
 
24414
24988
  } else {
24415
24989
 
24416
24990
  isMultisample = attributes.antialias;
24417
24991
  let depthFormat = null;
24418
-
24992
+ let depthType = null;
24993
+ let glDepthFormat = null;
24419
24994
 
24420
24995
  if ( attributes.depth ) {
24421
24996
 
24422
- clearStyle = 256;
24423
-
24424
- if ( attributes.stencil ) clearStyle |= 1024;
24425
-
24426
- depthStyle = attributes.stencil ? 33306 : 36096;
24427
- depthFormat = attributes.stencil ? 35056 : 33190;
24997
+ glDepthFormat = attributes.stencil ? 35056 : 33190;
24998
+ depthFormat = attributes.stencil ? DepthStencilFormat : DepthFormat;
24999
+ depthType = attributes.stencil ? UnsignedInt248Type : UnsignedShortType;
24428
25000
 
24429
25001
  }
24430
25002
 
24431
25003
  const projectionlayerInit = {
24432
- colorFormat: attributes.alpha ? 32856 : 32849,
24433
- depthFormat: depthFormat,
25004
+ colorFormat: ( attributes.alpha || isMultisample ) ? 32856 : 32849,
25005
+ depthFormat: glDepthFormat,
24434
25006
  scaleFactor: framebufferScaleFactor
24435
25007
  };
24436
25008
 
@@ -24438,41 +25010,44 @@ class WebXRManager extends EventDispatcher {
24438
25010
 
24439
25011
  glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );
24440
25012
 
24441
- glFramebuffer = gl.createFramebuffer();
24442
-
24443
25013
  session.updateRenderState( { layers: [ glProjLayer ] } );
24444
25014
 
24445
25015
  if ( isMultisample ) {
24446
25016
 
24447
- glMultisampledFramebuffer = gl.createFramebuffer();
24448
- glColorRenderbuffer = gl.createRenderbuffer();
24449
- gl.bindRenderbuffer( 36161, glColorRenderbuffer );
24450
- gl.renderbufferStorageMultisample(
24451
- 36161,
24452
- 4,
24453
- 32856,
25017
+ newRenderTarget = new WebGLMultisampleRenderTarget(
24454
25018
  glProjLayer.textureWidth,
24455
- glProjLayer.textureHeight );
24456
- state.bindFramebuffer( 36160, glMultisampledFramebuffer );
24457
- gl.framebufferRenderbuffer( 36160, 36064, 36161, glColorRenderbuffer );
24458
- gl.bindRenderbuffer( 36161, null );
25019
+ glProjLayer.textureHeight,
25020
+ {
25021
+ format: RGBAFormat,
25022
+ type: UnsignedByteType,
25023
+ depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
25024
+ stencilBuffer: attributes.stencil,
25025
+ ignoreDepth: glProjLayer.ignoreDepthValues,
25026
+ useRenderToTexture: hasMultisampledRenderToTexture,
25027
+ encoding: renderer.outputEncoding
25028
+ } );
24459
25029
 
24460
- if ( depthFormat !== null ) {
24461
-
24462
- glDepthRenderbuffer = gl.createRenderbuffer();
24463
- gl.bindRenderbuffer( 36161, glDepthRenderbuffer );
24464
- gl.renderbufferStorageMultisample( 36161, 4, depthFormat, glProjLayer.textureWidth, glProjLayer.textureHeight );
24465
- gl.framebufferRenderbuffer( 36160, depthStyle, 36161, glDepthRenderbuffer );
24466
- gl.bindRenderbuffer( 36161, null );
24467
-
24468
- }
25030
+ } else {
24469
25031
 
24470
- state.bindFramebuffer( 36160, null );
25032
+ newRenderTarget = new WebGLRenderTarget(
25033
+ glProjLayer.textureWidth,
25034
+ glProjLayer.textureHeight,
25035
+ {
25036
+ format: attributes.alpha ? RGBAFormat : RGBFormat,
25037
+ type: UnsignedByteType,
25038
+ depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
25039
+ stencilBuffer: attributes.stencil,
25040
+ ignoreDepth: glProjLayer.ignoreDepthValues,
25041
+ encoding: renderer.outputEncoding
25042
+ } );
24471
25043
 
24472
25044
  }
24473
25045
 
24474
25046
  }
24475
25047
 
25048
+ // Set foveation to maximum.
25049
+ this.setFoveation( 1.0 );
25050
+
24476
25051
  referenceSpace = await session.requestReferenceSpace( referenceSpaceType );
24477
25052
 
24478
25053
  animation.setContext( session );
@@ -24503,8 +25078,8 @@ class WebXRManager extends EventDispatcher {
24503
25078
 
24504
25079
  this.updateLayers = function() {
24505
25080
  var layersCopy = layers.map(function (x) { return x; });
24506
- layersCopy.push(layersCopy);
24507
-
25081
+
25082
+ layersCopy.unshift( session.renderState.layers[0] );
24508
25083
  session.updateRenderState( { layers: layersCopy } );
24509
25084
  };
24510
25085
 
@@ -24758,7 +25333,8 @@ class WebXRManager extends EventDispatcher {
24758
25333
 
24759
25334
  if ( glBaseLayer !== null ) {
24760
25335
 
24761
- state.bindXRFramebuffer( glBaseLayer.framebuffer );
25336
+ renderer.setRenderTargetFramebuffer( newRenderTarget, glBaseLayer.framebuffer );
25337
+ renderer.setRenderTarget( newRenderTarget );
24762
25338
 
24763
25339
  }
24764
25340
 
@@ -24769,7 +25345,6 @@ class WebXRManager extends EventDispatcher {
24769
25345
  if ( views.length !== cameraVR.cameras.length ) {
24770
25346
 
24771
25347
  cameraVR.cameras.length = 0;
24772
-
24773
25348
  cameraVRNeedsUpdate = true;
24774
25349
 
24775
25350
  }
@@ -24787,19 +25362,20 @@ class WebXRManager extends EventDispatcher {
24787
25362
  } else {
24788
25363
 
24789
25364
  const glSubImage = glBinding.getViewSubImage( glProjLayer, view );
25365
+ viewport = glSubImage.viewport;
24790
25366
 
24791
- state.bindXRFramebuffer( glFramebuffer );
25367
+ // For side-by-side projection, we only produce a single texture for both eyes.
25368
+ if ( i === 0 ) {
24792
25369
 
24793
- if ( glSubImage.depthStencilTexture !== undefined ) {
25370
+ renderer.setRenderTargetTextures(
25371
+ newRenderTarget,
25372
+ glSubImage.colorTexture,
25373
+ glProjLayer.ignoreDepthValues ? undefined : glSubImage.depthStencilTexture );
24794
25374
 
24795
- gl.framebufferTexture2D( 36160, depthStyle, 3553, glSubImage.depthStencilTexture, 0 );
25375
+ renderer.setRenderTarget( newRenderTarget );
24796
25376
 
24797
25377
  }
24798
25378
 
24799
- gl.framebufferTexture2D( 36160, 36064, 3553, glSubImage.colorTexture, 0 );
24800
-
24801
- viewport = glSubImage.viewport;
24802
-
24803
25379
  }
24804
25380
 
24805
25381
  const camera = cameras[ i ];
@@ -24822,14 +25398,6 @@ class WebXRManager extends EventDispatcher {
24822
25398
 
24823
25399
  }
24824
25400
 
24825
- if ( isMultisample ) {
24826
-
24827
- state.bindXRFramebuffer( glMultisampledFramebuffer );
24828
-
24829
- if ( clearStyle !== null ) gl.clear( clearStyle );
24830
-
24831
- }
24832
-
24833
25401
  }
24834
25402
 
24835
25403
  //
@@ -24847,26 +25415,6 @@ class WebXRManager extends EventDispatcher {
24847
25415
 
24848
25416
  if ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );
24849
25417
 
24850
- if ( isMultisample ) {
24851
-
24852
- const width = glProjLayer.textureWidth;
24853
- const height = glProjLayer.textureHeight;
24854
-
24855
- state.bindFramebuffer( 36008, glMultisampledFramebuffer );
24856
- state.bindFramebuffer( 36009, glFramebuffer );
24857
- // Invalidate the depth here to avoid flush of the depth data to main memory.
24858
- gl.invalidateFramebuffer( 36008, [ depthStyle ] );
24859
- gl.invalidateFramebuffer( 36009, [ depthStyle ] );
24860
- gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, 16384, 9728 );
24861
- // Invalidate the MSAA buffer because it's not needed anymore.
24862
- gl.invalidateFramebuffer( 36008, [ 36064 ] );
24863
- state.bindFramebuffer( 36008, null );
24864
- state.bindFramebuffer( 36009, null );
24865
-
24866
- state.bindFramebuffer( 36160, glMultisampledFramebuffer );
24867
-
24868
- }
24869
-
24870
25418
  xrFrame = null;
24871
25419
 
24872
25420
  }
@@ -25044,14 +25592,6 @@ function WebGLMaterials( properties ) {
25044
25592
  uniforms.ior.value = material.ior;
25045
25593
  uniforms.refractionRatio.value = material.refractionRatio;
25046
25594
 
25047
- const maxMipLevel = properties.get( envMap ).__maxMipLevel;
25048
-
25049
- if ( maxMipLevel !== undefined ) {
25050
-
25051
- uniforms.maxMipLevel.value = maxMipLevel;
25052
-
25053
- }
25054
-
25055
25595
  }
25056
25596
 
25057
25597
  if ( material.lightMap ) {
@@ -25140,9 +25680,9 @@ function WebGLMaterials( properties ) {
25140
25680
 
25141
25681
  uvScaleMap = material.specularIntensityMap;
25142
25682
 
25143
- } else if ( material.specularTintMap ) {
25683
+ } else if ( material.specularColorMap ) {
25144
25684
 
25145
- uvScaleMap = material.specularTintMap;
25685
+ uvScaleMap = material.specularColorMap;
25146
25686
 
25147
25687
  } else if ( material.transmissionMap ) {
25148
25688
 
@@ -25152,6 +25692,14 @@ function WebGLMaterials( properties ) {
25152
25692
 
25153
25693
  uvScaleMap = material.thicknessMap;
25154
25694
 
25695
+ } else if ( material.sheenColorMap ) {
25696
+
25697
+ uvScaleMap = material.sheenColorMap;
25698
+
25699
+ } else if ( material.sheenRoughnessMap ) {
25700
+
25701
+ uvScaleMap = material.sheenRoughnessMap;
25702
+
25155
25703
  }
25156
25704
 
25157
25705
  if ( uvScaleMap !== undefined ) {
@@ -25487,10 +26035,22 @@ function WebGLMaterials( properties ) {
25487
26035
 
25488
26036
  if ( material.sheen > 0 ) {
25489
26037
 
25490
- uniforms.sheenTint.value.copy( material.sheenTint ).multiplyScalar( material.sheen );
26038
+ uniforms.sheenColor.value.copy( material.sheenColor ).multiplyScalar( material.sheen );
25491
26039
 
25492
26040
  uniforms.sheenRoughness.value = material.sheenRoughness;
25493
26041
 
26042
+ if ( material.sheenColorMap ) {
26043
+
26044
+ uniforms.sheenColorMap.value = material.sheenColorMap;
26045
+
26046
+ }
26047
+
26048
+ if ( material.sheenRoughnessMap ) {
26049
+
26050
+ uniforms.sheenRoughnessMap.value = material.sheenRoughnessMap;
26051
+
26052
+ }
26053
+
25494
26054
  }
25495
26055
 
25496
26056
  if ( material.clearcoat > 0 ) {
@@ -25546,12 +26106,12 @@ function WebGLMaterials( properties ) {
25546
26106
  }
25547
26107
 
25548
26108
  uniforms.attenuationDistance.value = material.attenuationDistance;
25549
- uniforms.attenuationTint.value.copy( material.attenuationTint );
26109
+ uniforms.attenuationColor.value.copy( material.attenuationColor );
25550
26110
 
25551
26111
  }
25552
26112
 
25553
26113
  uniforms.specularIntensity.value = material.specularIntensity;
25554
- uniforms.specularTint.value.copy( material.specularTint );
26114
+ uniforms.specularColor.value.copy( material.specularColor );
25555
26115
 
25556
26116
  if ( material.specularIntensityMap ) {
25557
26117
 
@@ -25559,9 +26119,9 @@ function WebGLMaterials( properties ) {
25559
26119
 
25560
26120
  }
25561
26121
 
25562
- if ( material.specularTintMap ) {
26122
+ if ( material.specularColorMap ) {
25563
26123
 
25564
- uniforms.specularTintMap.value = material.specularTintMap;
26124
+ uniforms.specularColorMap.value = material.specularColorMap;
25565
26125
 
25566
26126
  }
25567
26127
 
@@ -25727,7 +26287,6 @@ function WebGLRenderer( parameters = {} ) {
25727
26287
 
25728
26288
  // physically based shading
25729
26289
 
25730
- this.gammaFactor = 2.0; // for backwards compatibility
25731
26290
  this.outputEncoding = LinearEncoding;
25732
26291
 
25733
26292
  // physical lights
@@ -25833,8 +26392,10 @@ function WebGLRenderer( parameters = {} ) {
25833
26392
  failIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat
25834
26393
  };
25835
26394
 
25836
- // event listeners must be registered before WebGL context is created, see #12753
26395
+ // OffscreenCanvas does not have setAttribute, see #22811
26396
+ if ( 'setAttribute' in _canvas ) _canvas.setAttribute( 'data-engine', `three.js r${REVISION}` );
25837
26397
 
26398
+ // event listeners must be registered before WebGL context is created, see #12753
25838
26399
  _canvas.addEventListener( 'webglcontextlost', onContextLost, false );
25839
26400
  _canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );
25840
26401
 
@@ -25920,7 +26481,7 @@ function WebGLRenderer( parameters = {} ) {
25920
26481
  clipping = new WebGLClipping( properties );
25921
26482
  programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
25922
26483
  materials = new WebGLMaterials( properties );
25923
- renderLists = new WebGLRenderLists( properties );
26484
+ renderLists = new WebGLRenderLists();
25924
26485
  renderStates = new WebGLRenderStates( extensions, capabilities );
25925
26486
  background = new WebGLBackground( _this, cubemaps, state, objects, _premultipliedAlpha );
25926
26487
  shadowMap = new WebGLShadowMap( _this, objects, capabilities );
@@ -26186,6 +26747,7 @@ function WebGLRenderer( parameters = {} ) {
26186
26747
  cubeuvmaps.dispose();
26187
26748
  objects.dispose();
26188
26749
  bindingStates.dispose();
26750
+ programCache.dispose();
26189
26751
 
26190
26752
  xr.dispose();
26191
26753
 
@@ -26270,82 +26832,17 @@ function WebGLRenderer( parameters = {} ) {
26270
26832
 
26271
26833
  } );
26272
26834
 
26273
- }
26274
-
26275
- }
26276
-
26277
- // Buffer rendering
26278
-
26279
- function renderObjectImmediate( object, program ) {
26280
-
26281
- object.render( function ( object ) {
26282
-
26283
- _this.renderBufferImmediate( object, program );
26284
-
26285
- } );
26286
-
26287
- }
26288
-
26289
- this.renderBufferImmediate = function ( object, program ) {
26290
-
26291
- bindingStates.initAttributes();
26292
-
26293
- const buffers = properties.get( object );
26294
-
26295
- if ( object.hasPositions && ! buffers.position ) buffers.position = _gl.createBuffer();
26296
- if ( object.hasNormals && ! buffers.normal ) buffers.normal = _gl.createBuffer();
26297
- if ( object.hasUvs && ! buffers.uv ) buffers.uv = _gl.createBuffer();
26298
- if ( object.hasColors && ! buffers.color ) buffers.color = _gl.createBuffer();
26299
-
26300
- const programAttributes = program.getAttributes();
26301
-
26302
- if ( object.hasPositions ) {
26303
-
26304
- _gl.bindBuffer( 34962, buffers.position );
26305
- _gl.bufferData( 34962, object.positionArray, 35048 );
26306
-
26307
- bindingStates.enableAttribute( programAttributes.position.location );
26308
- _gl.vertexAttribPointer( programAttributes.position.location, 3, 5126, false, 0, 0 );
26309
-
26310
- }
26311
-
26312
- if ( object.hasNormals ) {
26313
-
26314
- _gl.bindBuffer( 34962, buffers.normal );
26315
- _gl.bufferData( 34962, object.normalArray, 35048 );
26835
+ if ( material.isShaderMaterial ) {
26316
26836
 
26317
- bindingStates.enableAttribute( programAttributes.normal.location );
26318
- _gl.vertexAttribPointer( programAttributes.normal.location, 3, 5126, false, 0, 0 );
26837
+ programCache.releaseShaderCache( material );
26319
26838
 
26320
- }
26321
-
26322
- if ( object.hasUvs ) {
26323
-
26324
- _gl.bindBuffer( 34962, buffers.uv );
26325
- _gl.bufferData( 34962, object.uvArray, 35048 );
26326
-
26327
- bindingStates.enableAttribute( programAttributes.uv.location );
26328
- _gl.vertexAttribPointer( programAttributes.uv.location, 2, 5126, false, 0, 0 );
26329
-
26330
- }
26331
-
26332
- if ( object.hasColors ) {
26333
-
26334
- _gl.bindBuffer( 34962, buffers.color );
26335
- _gl.bufferData( 34962, object.colorArray, 35048 );
26336
-
26337
- bindingStates.enableAttribute( programAttributes.color.location );
26338
- _gl.vertexAttribPointer( programAttributes.color.location, 3, 5126, false, 0, 0 );
26839
+ }
26339
26840
 
26340
26841
  }
26341
26842
 
26342
- bindingStates.disableUnusedAttributes();
26343
-
26344
- _gl.drawArrays( 4, 0, object.count );
26345
-
26346
- object.count = 0;
26843
+ }
26347
26844
 
26348
- };
26845
+ // Buffer rendering
26349
26846
 
26350
26847
  this.renderBufferDirect = function ( camera, scene, geometry, material, object, group ) {
26351
26848
 
@@ -26788,17 +27285,6 @@ function WebGLRenderer( parameters = {} ) {
26788
27285
 
26789
27286
  }
26790
27287
 
26791
- } else if ( object.isImmediateRenderObject ) {
26792
-
26793
- if ( sortObjects ) {
26794
-
26795
- _vector3.setFromMatrixPosition( object.matrixWorld )
26796
- .applyMatrix4( _projScreenMatrix );
26797
-
26798
- }
26799
-
26800
- currentRenderList.push( object, null, object.material, groupOrder, _vector3.z, null );
26801
-
26802
27288
  } else if ( object.isMesh || object.isLine || object.isPoints ) {
26803
27289
 
26804
27290
  if ( object.isSkinnedMesh ) {
@@ -26896,7 +27382,8 @@ function WebGLRenderer( parameters = {} ) {
26896
27382
  minFilter: LinearMipmapLinearFilter,
26897
27383
  magFilter: NearestFilter,
26898
27384
  wrapS: ClampToEdgeWrapping,
26899
- wrapT: ClampToEdgeWrapping
27385
+ wrapT: ClampToEdgeWrapping,
27386
+ useRenderToTexture: extensions.has( 'WEBGL_multisampled_render_to_texture' )
26900
27387
  } );
26901
27388
 
26902
27389
  }
@@ -26953,35 +27440,21 @@ function WebGLRenderer( parameters = {} ) {
26953
27440
 
26954
27441
  material.onBeforeRender( _this, scene, camera, geometry, object, group );
26955
27442
 
26956
- if ( object.isImmediateRenderObject ) {
26957
-
26958
- const program = setProgram( camera, scene, geometry, material, object );
27443
+ if ( material.transparent === true && material.side === DoubleSide ) {
26959
27444
 
26960
- state.setMaterial( material );
27445
+ material.side = BackSide;
27446
+ material.needsUpdate = true;
27447
+ _this.renderBufferDirect( camera, scene, geometry, material, object, group );
26961
27448
 
26962
- bindingStates.reset();
27449
+ material.side = FrontSide;
27450
+ material.needsUpdate = true;
27451
+ _this.renderBufferDirect( camera, scene, geometry, material, object, group );
26963
27452
 
26964
- renderObjectImmediate( object, program );
27453
+ material.side = DoubleSide;
26965
27454
 
26966
27455
  } else {
26967
27456
 
26968
- if ( material.transparent === true && material.side === DoubleSide ) {
26969
-
26970
- material.side = BackSide;
26971
- material.needsUpdate = true;
26972
- _this.renderBufferDirect( camera, scene, geometry, material, object, group );
26973
-
26974
- material.side = FrontSide;
26975
- material.needsUpdate = true;
26976
- _this.renderBufferDirect( camera, scene, geometry, material, object, group );
26977
-
26978
- material.side = DoubleSide;
26979
-
26980
- } else {
26981
-
26982
- _this.renderBufferDirect( camera, scene, geometry, material, object, group );
26983
-
26984
- }
27457
+ _this.renderBufferDirect( camera, scene, geometry, material, object, group );
26985
27458
 
26986
27459
  }
26987
27460
 
@@ -27040,7 +27513,7 @@ function WebGLRenderer( parameters = {} ) {
27040
27513
 
27041
27514
  parameters.uniforms = programCache.getUniforms( material );
27042
27515
 
27043
- material.onBuild( parameters, _this );
27516
+ material.onBuild( object, parameters, _this );
27044
27517
 
27045
27518
  material.onBeforeCompile( parameters, _this );
27046
27519
 
@@ -27117,6 +27590,7 @@ function WebGLRenderer( parameters = {} ) {
27117
27590
  materialProperties.numIntersection = parameters.numClipIntersection;
27118
27591
  materialProperties.vertexAlphas = parameters.vertexAlphas;
27119
27592
  materialProperties.vertexTangents = parameters.vertexTangents;
27593
+ materialProperties.toneMapping = parameters.toneMapping;
27120
27594
 
27121
27595
  }
27122
27596
 
@@ -27130,11 +27604,12 @@ function WebGLRenderer( parameters = {} ) {
27130
27604
  const environment = material.isMeshStandardMaterial ? scene.environment : null;
27131
27605
  const encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : _currentRenderTarget.texture.encoding;
27132
27606
  const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment );
27133
- const vertexAlphas = material.vertexColors === true && !! geometry && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
27134
- const vertexTangents = !! material.normalMap && !! geometry && !! geometry.attributes.tangent;
27135
- const morphTargets = !! geometry && !! geometry.morphAttributes.position;
27136
- const morphNormals = !! geometry && !! geometry.morphAttributes.normal;
27137
- const morphTargetsCount = ( !! geometry && !! geometry.morphAttributes.position ) ? geometry.morphAttributes.position.length : 0;
27607
+ const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
27608
+ const vertexTangents = !! material.normalMap && !! geometry.attributes.tangent;
27609
+ const morphTargets = !! geometry.morphAttributes.position;
27610
+ const morphNormals = !! geometry.morphAttributes.normal;
27611
+ const morphTargetsCount = !! geometry.morphAttributes.position ? geometry.morphAttributes.position.length : 0;
27612
+ const toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping;
27138
27613
 
27139
27614
  const materialProperties = properties.get( material );
27140
27615
  const lights = currentRenderState.state.lights;
@@ -27216,6 +27691,10 @@ function WebGLRenderer( parameters = {} ) {
27216
27691
 
27217
27692
  needsProgramChange = true;
27218
27693
 
27694
+ } else if ( materialProperties.toneMapping !== toneMapping ) {
27695
+
27696
+ needsProgramChange = true;
27697
+
27219
27698
  } else if ( capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount ) {
27220
27699
 
27221
27700
  needsProgramChange = true;
@@ -27502,15 +27981,71 @@ function WebGLRenderer( parameters = {} ) {
27502
27981
 
27503
27982
  };
27504
27983
 
27984
+ this.setRenderTargetTextures = function ( renderTarget, colorTexture, depthTexture ) {
27985
+
27986
+ properties.get( renderTarget.texture ).__webglTexture = colorTexture;
27987
+ properties.get( renderTarget.depthTexture ).__webglTexture = depthTexture;
27988
+
27989
+ const renderTargetProperties = properties.get( renderTarget );
27990
+ renderTargetProperties.__hasExternalTextures = true;
27991
+
27992
+ if ( renderTargetProperties.__hasExternalTextures ) {
27993
+
27994
+ renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
27995
+
27996
+ if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
27997
+
27998
+ // The multisample_render_to_texture extension doesn't work properly if there
27999
+ // are midframe flushes and an external depth buffer. Disable use of the extension.
28000
+ if ( renderTarget.useRenderToTexture ) {
28001
+
28002
+ console.warn( 'render-to-texture extension was disabled because an external texture was provided' );
28003
+ renderTarget.useRenderToTexture = false;
28004
+ renderTarget.useRenderbuffer = true;
28005
+
28006
+ }
28007
+
28008
+ }
28009
+
28010
+ }
28011
+
28012
+ };
28013
+
28014
+ this.setRenderTargetFramebuffer = function ( renderTarget, defaultFramebuffer ) {
28015
+
28016
+ const renderTargetProperties = properties.get( renderTarget );
28017
+ renderTargetProperties.__webglFramebuffer = defaultFramebuffer;
28018
+ renderTargetProperties.__useDefaultFramebuffer = defaultFramebuffer === undefined;
28019
+
28020
+ };
28021
+
27505
28022
  this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {
27506
28023
 
27507
28024
  _currentRenderTarget = renderTarget;
27508
28025
  _currentActiveCubeFace = activeCubeFace;
27509
28026
  _currentActiveMipmapLevel = activeMipmapLevel;
28027
+ let useDefaultFramebuffer = true;
28028
+
28029
+ if ( renderTarget ) {
28030
+
28031
+ const renderTargetProperties = properties.get( renderTarget );
28032
+
28033
+ if ( renderTargetProperties.__useDefaultFramebuffer !== undefined ) {
28034
+
28035
+ // We need to make sure to rebind the framebuffer.
28036
+ state.bindFramebuffer( 36160, null );
28037
+ useDefaultFramebuffer = false;
27510
28038
 
27511
- if ( renderTarget && properties.get( renderTarget ).__webglFramebuffer === undefined ) {
28039
+ } else if ( renderTargetProperties.__webglFramebuffer === undefined ) {
27512
28040
 
27513
- textures.setupRenderTarget( renderTarget );
28041
+ textures.setupRenderTarget( renderTarget );
28042
+
28043
+ } else if ( renderTargetProperties.__hasExternalTextures ) {
28044
+
28045
+ // Color and depth texture must be rebound in order for the swapchain to update.
28046
+ textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture );
28047
+
28048
+ }
27514
28049
 
27515
28050
  }
27516
28051
 
@@ -27535,7 +28070,7 @@ function WebGLRenderer( parameters = {} ) {
27535
28070
  framebuffer = __webglFramebuffer[ activeCubeFace ];
27536
28071
  isCube = true;
27537
28072
 
27538
- } else if ( renderTarget.isWebGLMultisampleRenderTarget ) {
28073
+ } else if ( renderTarget.useRenderbuffer ) {
27539
28074
 
27540
28075
  framebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;
27541
28076
 
@@ -27559,7 +28094,7 @@ function WebGLRenderer( parameters = {} ) {
27559
28094
 
27560
28095
  const framebufferBound = state.bindFramebuffer( 36160, framebuffer );
27561
28096
 
27562
- if ( framebufferBound && capabilities.drawBuffers ) {
28097
+ if ( framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer ) {
27563
28098
 
27564
28099
  let needsUpdate = false;
27565
28100
 
@@ -27722,25 +28257,20 @@ function WebGLRenderer( parameters = {} ) {
27722
28257
 
27723
28258
  this.copyFramebufferToTexture = function ( position, texture, level = 0 ) {
27724
28259
 
27725
- const levelScale = Math.pow( 2, - level );
27726
- const width = Math.floor( texture.image.width * levelScale );
27727
- const height = Math.floor( texture.image.height * levelScale );
27728
-
27729
- let glFormat = utils.convert( texture.format );
27730
-
27731
- if ( capabilities.isWebGL2 ) {
28260
+ if ( texture.isFramebufferTexture !== true ) {
27732
28261
 
27733
- // Workaround for https://bugs.chromium.org/p/chromium/issues/detail?id=1120100
27734
- // Not needed in Chrome 93+
27735
-
27736
- if ( glFormat === 6407 ) glFormat = 32849;
27737
- if ( glFormat === 6408 ) glFormat = 32856;
28262
+ console.error( 'THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.' );
28263
+ return;
27738
28264
 
27739
28265
  }
27740
28266
 
28267
+ const levelScale = Math.pow( 2, - level );
28268
+ const width = Math.floor( texture.image.width * levelScale );
28269
+ const height = Math.floor( texture.image.height * levelScale );
28270
+
27741
28271
  textures.setTexture2D( texture, 0 );
27742
28272
 
27743
- _gl.copyTexImage2D( 3553, level, glFormat, position.x, position.y, width, height, 0 );
28273
+ _gl.copyTexSubImage2D( 3553, level, 0, 0, position.x, position.y, width, height );
27744
28274
 
27745
28275
  state.unbindTexture();
27746
28276
 
@@ -27890,12 +28420,14 @@ function WebGLRenderer( parameters = {} ) {
27890
28420
 
27891
28421
  if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
27892
28422
 
27893
- __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef
28423
+ __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
27894
28424
 
27895
28425
  }
27896
28426
 
27897
28427
  }
27898
28428
 
28429
+ WebGLRenderer.prototype.isWebGLRenderer = true;
28430
+
27899
28431
  class WebGL1Renderer extends WebGLRenderer {}
27900
28432
 
27901
28433
  WebGL1Renderer.prototype.isWebGL1Renderer = true;
@@ -27983,7 +28515,7 @@ class Scene extends Object3D {
27983
28515
 
27984
28516
  if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
27985
28517
 
27986
- __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef
28518
+ __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
27987
28519
 
27988
28520
  }
27989
28521
 
@@ -29037,8 +29569,6 @@ class DataTexture extends Texture {
29037
29569
  this.flipY = false;
29038
29570
  this.unpackAlignment = 1;
29039
29571
 
29040
- this.needsUpdate = true;
29041
-
29042
29572
  }
29043
29573
 
29044
29574
  }
@@ -29216,6 +29746,7 @@ class Skeleton {
29216
29746
  boneMatrices.set( this.boneMatrices ); // copy current values
29217
29747
 
29218
29748
  const boneTexture = new DataTexture( boneMatrices, size, size, RGBAFormat, FloatType );
29749
+ boneTexture.needsUpdate = true;
29219
29750
 
29220
29751
  this.boneMatrices = boneMatrices;
29221
29752
  this.boneTexture = boneTexture;
@@ -30131,6 +30662,27 @@ class VideoTexture extends Texture {
30131
30662
 
30132
30663
  VideoTexture.prototype.isVideoTexture = true;
30133
30664
 
30665
+ class FramebufferTexture extends Texture {
30666
+
30667
+ constructor( width, height, format ) {
30668
+
30669
+ super( { width, height } );
30670
+
30671
+ this.format = format;
30672
+
30673
+ this.magFilter = NearestFilter;
30674
+ this.minFilter = NearestFilter;
30675
+
30676
+ this.generateMipmaps = false;
30677
+
30678
+ this.needsUpdate = true;
30679
+
30680
+ }
30681
+
30682
+ }
30683
+
30684
+ FramebufferTexture.prototype.isFramebufferTexture = true;
30685
+
30134
30686
  class CompressedTexture extends Texture {
30135
30687
 
30136
30688
  constructor( mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
@@ -30170,38 +30722,6 @@ class CanvasTexture extends Texture {
30170
30722
 
30171
30723
  CanvasTexture.prototype.isCanvasTexture = true;
30172
30724
 
30173
- class DepthTexture extends Texture {
30174
-
30175
- constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
30176
-
30177
- format = format !== undefined ? format : DepthFormat;
30178
-
30179
- if ( format !== DepthFormat && format !== DepthStencilFormat ) {
30180
-
30181
- throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' );
30182
-
30183
- }
30184
-
30185
- if ( type === undefined && format === DepthFormat ) type = UnsignedShortType;
30186
- if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type;
30187
-
30188
- super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
30189
-
30190
- this.image = { width: width, height: height };
30191
-
30192
- this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
30193
- this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
30194
-
30195
- this.flipY = false;
30196
- this.generateMipmaps = false;
30197
-
30198
- }
30199
-
30200
-
30201
- }
30202
-
30203
- DepthTexture.prototype.isDepthTexture = true;
30204
-
30205
30725
  class CircleGeometry extends BufferGeometry {
30206
30726
 
30207
30727
  constructor( radius = 1, segments = 8, thetaStart = 0, thetaLength = Math.PI * 2 ) {
@@ -31907,7 +32427,7 @@ CatmullRomCurve3.prototype.isCatmullRomCurve3 = true;
31907
32427
 
31908
32428
  /**
31909
32429
  * Bezier Curves formulas obtained from
31910
- * http://en.wikipedia.org/wiki/Bézier_curve
32430
+ * https://en.wikipedia.org/wiki/B%C3%A9zier_curve
31911
32431
  */
31912
32432
 
31913
32433
  function CatmullRom( t, p0, p1, p2, p3 ) {
@@ -34802,14 +35322,75 @@ class LatheGeometry extends BufferGeometry {
34802
35322
  const indices = [];
34803
35323
  const vertices = [];
34804
35324
  const uvs = [];
35325
+ const initNormals = [];
35326
+ const normals = [];
34805
35327
 
34806
35328
  // helper variables
34807
35329
 
34808
35330
  const inverseSegments = 1.0 / segments;
34809
35331
  const vertex = new Vector3();
34810
35332
  const uv = new Vector2();
35333
+ const normal = new Vector3();
35334
+ const curNormal = new Vector3();
35335
+ const prevNormal = new Vector3();
35336
+ let dx = 0;
35337
+ let dy = 0;
34811
35338
 
34812
- // generate vertices and uvs
35339
+ // pre-compute normals for initial "meridian"
35340
+
35341
+ for ( let j = 0; j <= ( points.length - 1 ); j ++ ) {
35342
+
35343
+ switch ( j ) {
35344
+
35345
+ case 0: // special handling for 1st vertex on path
35346
+
35347
+ dx = points[ j + 1 ].x - points[ j ].x;
35348
+ dy = points[ j + 1 ].y - points[ j ].y;
35349
+
35350
+ normal.x = dy * 1.0;
35351
+ normal.y = - dx;
35352
+ normal.z = dy * 0.0;
35353
+
35354
+ prevNormal.copy( normal );
35355
+
35356
+ normal.normalize();
35357
+
35358
+ initNormals.push( normal.x, normal.y, normal.z );
35359
+
35360
+ break;
35361
+
35362
+ case ( points.length - 1 ): // special handling for last Vertex on path
35363
+
35364
+ initNormals.push( prevNormal.x, prevNormal.y, prevNormal.z );
35365
+
35366
+ break;
35367
+
35368
+ default: // default handling for all vertices in between
35369
+
35370
+ dx = points[ j + 1 ].x - points[ j ].x;
35371
+ dy = points[ j + 1 ].y - points[ j ].y;
35372
+
35373
+ normal.x = dy * 1.0;
35374
+ normal.y = - dx;
35375
+ normal.z = dy * 0.0;
35376
+
35377
+ curNormal.copy( normal );
35378
+
35379
+ normal.x += prevNormal.x;
35380
+ normal.y += prevNormal.y;
35381
+ normal.z += prevNormal.z;
35382
+
35383
+ normal.normalize();
35384
+
35385
+ initNormals.push( normal.x, normal.y, normal.z );
35386
+
35387
+ prevNormal.copy( curNormal );
35388
+
35389
+ }
35390
+
35391
+ }
35392
+
35393
+ // generate vertices, uvs and normals
34813
35394
 
34814
35395
  for ( let i = 0; i <= segments; i ++ ) {
34815
35396
 
@@ -34835,6 +35416,13 @@ class LatheGeometry extends BufferGeometry {
34835
35416
 
34836
35417
  uvs.push( uv.x, uv.y );
34837
35418
 
35419
+ // normal
35420
+
35421
+ const x = initNormals[ 3 * j + 0 ] * sin;
35422
+ const y = initNormals[ 3 * j + 1 ];
35423
+ const z = initNormals[ 3 * j + 0 ] * cos;
35424
+
35425
+ normals.push( x, y, z );
34838
35426
 
34839
35427
  }
34840
35428
 
@@ -34867,52 +35455,7 @@ class LatheGeometry extends BufferGeometry {
34867
35455
  this.setIndex( indices );
34868
35456
  this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
34869
35457
  this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
34870
-
34871
- // generate normals
34872
-
34873
- this.computeVertexNormals();
34874
-
34875
- // if the geometry is closed, we need to average the normals along the seam.
34876
- // because the corresponding vertices are identical (but still have different UVs).
34877
-
34878
- if ( phiLength === Math.PI * 2 ) {
34879
-
34880
- const normals = this.attributes.normal.array;
34881
- const n1 = new Vector3();
34882
- const n2 = new Vector3();
34883
- const n = new Vector3();
34884
-
34885
- // this is the buffer offset for the last line of vertices
34886
-
34887
- const base = segments * points.length * 3;
34888
-
34889
- for ( let i = 0, j = 0; i < points.length; i ++, j += 3 ) {
34890
-
34891
- // select the normal of the vertex in the first line
34892
-
34893
- n1.x = normals[ j + 0 ];
34894
- n1.y = normals[ j + 1 ];
34895
- n1.z = normals[ j + 2 ];
34896
-
34897
- // select the normal of the vertex in the last line
34898
-
34899
- n2.x = normals[ base + j + 0 ];
34900
- n2.y = normals[ base + j + 1 ];
34901
- n2.z = normals[ base + j + 2 ];
34902
-
34903
- // average normals
34904
-
34905
- n.addVectors( n1, n2 ).normalize();
34906
-
34907
- // assign the new values to both normals
34908
-
34909
- normals[ j + 0 ] = normals[ base + j + 0 ] = n.x;
34910
- normals[ j + 1 ] = normals[ base + j + 1 ] = n.y;
34911
- normals[ j + 2 ] = normals[ base + j + 2 ] = n.z;
34912
-
34913
- }
34914
-
34915
- }
35458
+ this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
34916
35459
 
34917
35460
  }
34918
35461
 
@@ -36222,8 +36765,10 @@ MeshStandardMaterial.prototype.isMeshStandardMaterial = true;
36222
36765
  * reflectivity: <float>,
36223
36766
  *
36224
36767
  * sheen: <float>,
36225
- * sheenTint: <Color>,
36768
+ * sheenColor: <Color>,
36769
+ * sheenColorMap: new THREE.Texture( <Image> ),
36226
36770
  * sheenRoughness: <float>,
36771
+ * sheenRoughnessMap: new THREE.Texture( <Image> ),
36227
36772
  *
36228
36773
  * transmission: <float>,
36229
36774
  * transmissionMap: new THREE.Texture( <Image> ),
@@ -36231,12 +36776,12 @@ MeshStandardMaterial.prototype.isMeshStandardMaterial = true;
36231
36776
  * thickness: <float>,
36232
36777
  * thicknessMap: new THREE.Texture( <Image> ),
36233
36778
  * attenuationDistance: <float>,
36234
- * attenuationTint: <Color>,
36779
+ * attenuationColor: <Color>,
36235
36780
  *
36236
36781
  * specularIntensity: <float>,
36237
- * specularIntensityhMap: new THREE.Texture( <Image> ),
36238
- * specularTint: <Color>,
36239
- * specularTintMap: new THREE.Texture( <Image> )
36782
+ * specularIntensityMap: new THREE.Texture( <Image> ),
36783
+ * specularColor: <Color>,
36784
+ * specularColorMap: new THREE.Texture( <Image> )
36240
36785
  * }
36241
36786
  */
36242
36787
 
@@ -36276,20 +36821,22 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
36276
36821
  }
36277
36822
  } );
36278
36823
 
36279
- this.sheenTint = new Color( 0x000000 );
36824
+ this.sheenColor = new Color( 0x000000 );
36825
+ this.sheenColorMap = null;
36280
36826
  this.sheenRoughness = 1.0;
36827
+ this.sheenRoughnessMap = null;
36281
36828
 
36282
36829
  this.transmissionMap = null;
36283
36830
 
36284
- this.thickness = 0.01;
36831
+ this.thickness = 0;
36285
36832
  this.thicknessMap = null;
36286
36833
  this.attenuationDistance = 0.0;
36287
- this.attenuationTint = new Color( 1, 1, 1 );
36834
+ this.attenuationColor = new Color( 1, 1, 1 );
36288
36835
 
36289
36836
  this.specularIntensity = 1.0;
36290
36837
  this.specularIntensityMap = null;
36291
- this.specularTint = new Color( 1, 1, 1 );
36292
- this.specularTintMap = null;
36838
+ this.specularColor = new Color( 1, 1, 1 );
36839
+ this.specularColorMap = null;
36293
36840
 
36294
36841
  this._sheen = 0.0;
36295
36842
  this._clearcoat = 0;
@@ -36374,8 +36921,10 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
36374
36921
  this.ior = source.ior;
36375
36922
 
36376
36923
  this.sheen = source.sheen;
36377
- this.sheenTint.copy( source.sheenTint );
36924
+ this.sheenColor.copy( source.sheenColor );
36925
+ this.sheenColorMap = source.sheenColorMap;
36378
36926
  this.sheenRoughness = source.sheenRoughness;
36927
+ this.sheenRoughnessMap = source.sheenRoughnessMap;
36379
36928
 
36380
36929
  this.transmission = source.transmission;
36381
36930
  this.transmissionMap = source.transmissionMap;
@@ -36383,12 +36932,12 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
36383
36932
  this.thickness = source.thickness;
36384
36933
  this.thicknessMap = source.thicknessMap;
36385
36934
  this.attenuationDistance = source.attenuationDistance;
36386
- this.attenuationTint.copy( source.attenuationTint );
36935
+ this.attenuationColor.copy( source.attenuationColor );
36387
36936
 
36388
36937
  this.specularIntensity = source.specularIntensity;
36389
36938
  this.specularIntensityMap = source.specularIntensityMap;
36390
- this.specularTint.copy( source.specularTint );
36391
- this.specularTintMap = source.specularTintMap;
36939
+ this.specularColor.copy( source.specularColor );
36940
+ this.specularColorMap = source.specularColorMap;
36392
36941
 
36393
36942
  return this;
36394
36943
 
@@ -39110,19 +39659,17 @@ class FileLoader extends Loader {
39110
39659
 
39111
39660
  url = this.manager.resolveURL( url );
39112
39661
 
39113
- const scope = this;
39114
-
39115
39662
  const cached = Cache.get( url );
39116
39663
 
39117
39664
  if ( cached !== undefined ) {
39118
39665
 
39119
- scope.manager.itemStart( url );
39666
+ this.manager.itemStart( url );
39120
39667
 
39121
- setTimeout( function () {
39668
+ setTimeout( () => {
39122
39669
 
39123
39670
  if ( onLoad ) onLoad( cached );
39124
39671
 
39125
- scope.manager.itemEnd( url );
39672
+ this.manager.itemEnd( url );
39126
39673
 
39127
39674
  }, 0 );
39128
39675
 
@@ -39146,225 +39693,181 @@ class FileLoader extends Loader {
39146
39693
 
39147
39694
  }
39148
39695
 
39149
- // Check for data: URI
39150
- const dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/;
39151
- const dataUriRegexResult = url.match( dataUriRegex );
39152
- let request;
39153
-
39154
- // Safari can not handle Data URIs through XMLHttpRequest so process manually
39155
- if ( dataUriRegexResult ) {
39156
-
39157
- const mimeType = dataUriRegexResult[ 1 ];
39158
- const isBase64 = !! dataUriRegexResult[ 2 ];
39159
-
39160
- let data = dataUriRegexResult[ 3 ];
39161
- data = decodeURIComponent( data );
39162
-
39163
- if ( isBase64 ) data = atob( data );
39164
-
39165
- try {
39166
-
39167
- let response;
39168
- const responseType = ( this.responseType || '' ).toLowerCase();
39696
+ // Initialise array for duplicate requests
39697
+ loading[ url ] = [];
39169
39698
 
39170
- switch ( responseType ) {
39171
-
39172
- case 'arraybuffer':
39173
- case 'blob':
39174
-
39175
- const view = new Uint8Array( data.length );
39176
-
39177
- for ( let i = 0; i < data.length; i ++ ) {
39178
-
39179
- view[ i ] = data.charCodeAt( i );
39180
-
39181
- }
39182
-
39183
- if ( responseType === 'blob' ) {
39184
-
39185
- response = new Blob( [ view.buffer ], { type: mimeType } );
39186
-
39187
- } else {
39188
-
39189
- response = view.buffer;
39190
-
39191
- }
39699
+ loading[ url ].push( {
39700
+ onLoad: onLoad,
39701
+ onProgress: onProgress,
39702
+ onError: onError,
39703
+ } );
39192
39704
 
39193
- break;
39705
+ // create request
39706
+ const req = new Request( url, {
39707
+ headers: new Headers( this.requestHeader ),
39708
+ credentials: this.withCredentials ? 'include' : 'same-origin',
39709
+ // An abort controller could be added within a future PR
39710
+ } );
39194
39711
 
39195
- case 'document':
39712
+ // start the fetch
39713
+ fetch( req )
39714
+ .then( response => {
39196
39715
 
39197
- const parser = new DOMParser();
39198
- response = parser.parseFromString( data, mimeType );
39716
+ if ( response.status === 200 || response.status === 0 ) {
39199
39717
 
39200
- break;
39718
+ // Some browsers return HTTP Status 0 when using non-http protocol
39719
+ // e.g. 'file://' or 'data://'. Handle as success.
39201
39720
 
39202
- case 'json':
39721
+ if ( response.status === 0 ) {
39203
39722
 
39204
- response = JSON.parse( data );
39723
+ console.warn( 'THREE.FileLoader: HTTP Status 0 received.' );
39205
39724
 
39206
- break;
39725
+ }
39207
39726
 
39208
- default: // 'text' or other
39727
+ if ( typeof ReadableStream === 'undefined' || response.body.getReader === undefined ) {
39209
39728
 
39210
- response = data;
39729
+ return response;
39211
39730
 
39212
- break;
39731
+ }
39213
39732
 
39214
- }
39733
+ const callbacks = loading[ url ];
39734
+ const reader = response.body.getReader();
39735
+ const contentLength = response.headers.get( 'Content-Length' );
39736
+ const total = contentLength ? parseInt( contentLength ) : 0;
39737
+ const lengthComputable = total !== 0;
39738
+ let loaded = 0;
39215
39739
 
39216
- // Wait for next browser tick like standard XMLHttpRequest event dispatching does
39217
- setTimeout( function () {
39740
+ // periodically read data into the new stream tracking while download progress
39741
+ const stream = new ReadableStream( {
39742
+ start( controller ) {
39218
39743
 
39219
- if ( onLoad ) onLoad( response );
39744
+ readData();
39220
39745
 
39221
- scope.manager.itemEnd( url );
39746
+ function readData() {
39222
39747
 
39223
- }, 0 );
39748
+ reader.read().then( ( { done, value } ) => {
39224
39749
 
39225
- } catch ( error ) {
39750
+ if ( done ) {
39226
39751
 
39227
- // Wait for next browser tick like standard XMLHttpRequest event dispatching does
39228
- setTimeout( function () {
39752
+ controller.close();
39229
39753
 
39230
- if ( onError ) onError( error );
39754
+ } else {
39231
39755
 
39232
- scope.manager.itemError( url );
39233
- scope.manager.itemEnd( url );
39756
+ loaded += value.byteLength;
39234
39757
 
39235
- }, 0 );
39758
+ const event = new ProgressEvent( 'progress', { lengthComputable, loaded, total } );
39759
+ for ( let i = 0, il = callbacks.length; i < il; i ++ ) {
39236
39760
 
39237
- }
39761
+ const callback = callbacks[ i ];
39762
+ if ( callback.onProgress ) callback.onProgress( event );
39238
39763
 
39239
- } else {
39764
+ }
39240
39765
 
39241
- // Initialise array for duplicate requests
39766
+ controller.enqueue( value );
39767
+ readData();
39242
39768
 
39243
- loading[ url ] = [];
39769
+ }
39244
39770
 
39245
- loading[ url ].push( {
39771
+ } );
39246
39772
 
39247
- onLoad: onLoad,
39248
- onProgress: onProgress,
39249
- onError: onError
39773
+ }
39250
39774
 
39251
- } );
39775
+ }
39252
39776
 
39253
- request = new XMLHttpRequest();
39777
+ } );
39254
39778
 
39255
- request.open( 'GET', url, true );
39779
+ return new Response( stream );
39256
39780
 
39257
- request.addEventListener( 'load', function ( event ) {
39781
+ } else {
39258
39782
 
39259
- const response = this.response;
39783
+ throw Error( `fetch for "${response.url}" responded with ${response.status}: ${response.statusText}` );
39260
39784
 
39261
- const callbacks = loading[ url ];
39785
+ }
39262
39786
 
39263
- delete loading[ url ];
39787
+ } )
39788
+ .then( response => {
39264
39789
 
39265
- if ( this.status === 200 || this.status === 0 ) {
39790
+ switch ( this.responseType ) {
39266
39791
 
39267
- // Some browsers return HTTP Status 0 when using non-http protocol
39268
- // e.g. 'file://' or 'data://'. Handle as success.
39792
+ case 'arraybuffer':
39269
39793
 
39270
- if ( this.status === 0 ) console.warn( 'THREE.FileLoader: HTTP Status 0 received.' );
39794
+ return response.arrayBuffer();
39271
39795
 
39272
- // Add to cache only on HTTP success, so that we do not cache
39273
- // error response bodies as proper responses to requests.
39274
- Cache.add( url, response );
39796
+ case 'blob':
39275
39797
 
39276
- for ( let i = 0, il = callbacks.length; i < il; i ++ ) {
39798
+ return response.blob();
39277
39799
 
39278
- const callback = callbacks[ i ];
39279
- if ( callback.onLoad ) callback.onLoad( response );
39800
+ case 'document':
39280
39801
 
39281
- }
39802
+ return response.text()
39803
+ .then( text => {
39282
39804
 
39283
- scope.manager.itemEnd( url );
39805
+ const parser = new DOMParser();
39806
+ return parser.parseFromString( text, this.mimeType );
39284
39807
 
39285
- } else {
39808
+ } );
39286
39809
 
39287
- for ( let i = 0, il = callbacks.length; i < il; i ++ ) {
39810
+ case 'json':
39288
39811
 
39289
- const callback = callbacks[ i ];
39290
- if ( callback.onError ) callback.onError( event );
39812
+ return response.json();
39291
39813
 
39292
- }
39814
+ default:
39293
39815
 
39294
- scope.manager.itemError( url );
39295
- scope.manager.itemEnd( url );
39816
+ return response.text();
39296
39817
 
39297
39818
  }
39298
39819
 
39299
- }, false );
39820
+ } )
39821
+ .then( data => {
39300
39822
 
39301
- request.addEventListener( 'progress', function ( event ) {
39823
+ // Add to cache only on HTTP success, so that we do not cache
39824
+ // error response bodies as proper responses to requests.
39825
+ Cache.add( url, data );
39302
39826
 
39303
39827
  const callbacks = loading[ url ];
39828
+ delete loading[ url ];
39304
39829
 
39305
39830
  for ( let i = 0, il = callbacks.length; i < il; i ++ ) {
39306
39831
 
39307
39832
  const callback = callbacks[ i ];
39308
- if ( callback.onProgress ) callback.onProgress( event );
39833
+ if ( callback.onLoad ) callback.onLoad( data );
39309
39834
 
39310
39835
  }
39311
39836
 
39312
- }, false );
39837
+ } )
39838
+ .catch( err => {
39313
39839
 
39314
- request.addEventListener( 'error', function ( event ) {
39840
+ // Abort errors and other errors are handled the same
39315
39841
 
39316
39842
  const callbacks = loading[ url ];
39317
39843
 
39318
- delete loading[ url ];
39319
-
39320
- for ( let i = 0, il = callbacks.length; i < il; i ++ ) {
39844
+ if ( callbacks === undefined ) {
39321
39845
 
39322
- const callback = callbacks[ i ];
39323
- if ( callback.onError ) callback.onError( event );
39846
+ // When onLoad was called and url was deleted in `loading`
39847
+ this.manager.itemError( url );
39848
+ throw err;
39324
39849
 
39325
39850
  }
39326
39851
 
39327
- scope.manager.itemError( url );
39328
- scope.manager.itemEnd( url );
39329
-
39330
- }, false );
39331
-
39332
- request.addEventListener( 'abort', function ( event ) {
39333
-
39334
- const callbacks = loading[ url ];
39335
-
39336
39852
  delete loading[ url ];
39337
39853
 
39338
39854
  for ( let i = 0, il = callbacks.length; i < il; i ++ ) {
39339
39855
 
39340
39856
  const callback = callbacks[ i ];
39341
- if ( callback.onError ) callback.onError( event );
39857
+ if ( callback.onError ) callback.onError( err );
39342
39858
 
39343
39859
  }
39344
39860
 
39345
- scope.manager.itemError( url );
39346
- scope.manager.itemEnd( url );
39347
-
39348
- }, false );
39349
-
39350
- if ( this.responseType !== undefined ) request.responseType = this.responseType;
39351
- if ( this.withCredentials !== undefined ) request.withCredentials = this.withCredentials;
39352
-
39353
- if ( request.overrideMimeType ) request.overrideMimeType( this.mimeType !== undefined ? this.mimeType : 'text/plain' );
39354
-
39355
- for ( const header in this.requestHeader ) {
39356
-
39357
- request.setRequestHeader( header, this.requestHeader[ header ] );
39861
+ this.manager.itemError( url );
39358
39862
 
39359
- }
39360
-
39361
- request.send( null );
39863
+ } )
39864
+ .finally( () => {
39362
39865
 
39363
- }
39866
+ this.manager.itemEnd( url );
39364
39867
 
39365
- scope.manager.itemStart( url );
39868
+ } );
39366
39869
 
39367
- return request;
39870
+ this.manager.itemStart( url );
39368
39871
 
39369
39872
  }
39370
39873
 
@@ -39609,8 +40112,7 @@ class ImageLoader extends Loader {
39609
40112
 
39610
40113
  function onImageLoad() {
39611
40114
 
39612
- image.removeEventListener( 'load', onImageLoad, false );
39613
- image.removeEventListener( 'error', onImageError, false );
40115
+ removeEventListeners();
39614
40116
 
39615
40117
  Cache.add( url, this );
39616
40118
 
@@ -39622,8 +40124,7 @@ class ImageLoader extends Loader {
39622
40124
 
39623
40125
  function onImageError( event ) {
39624
40126
 
39625
- image.removeEventListener( 'load', onImageLoad, false );
39626
- image.removeEventListener( 'error', onImageError, false );
40127
+ removeEventListeners();
39627
40128
 
39628
40129
  if ( onError ) onError( event );
39629
40130
 
@@ -39632,6 +40133,13 @@ class ImageLoader extends Loader {
39632
40133
 
39633
40134
  }
39634
40135
 
40136
+ function removeEventListeners() {
40137
+
40138
+ image.removeEventListener( 'load', onImageLoad, false );
40139
+ image.removeEventListener( 'error', onImageError, false );
40140
+
40141
+ }
40142
+
39635
40143
  image.addEventListener( 'load', onImageLoad, false );
39636
40144
  image.addEventListener( 'error', onImageError, false );
39637
40145
 
@@ -40784,19 +41292,19 @@ class MaterialLoader extends Loader {
40784
41292
  if ( json.roughness !== undefined ) material.roughness = json.roughness;
40785
41293
  if ( json.metalness !== undefined ) material.metalness = json.metalness;
40786
41294
  if ( json.sheen !== undefined ) material.sheen = json.sheen;
40787
- if ( json.sheenTint !== undefined ) material.sheenTint = new Color().setHex( json.sheenTint );
41295
+ if ( json.sheenColor !== undefined ) material.sheenColor = new Color().setHex( json.sheenColor );
40788
41296
  if ( json.sheenRoughness !== undefined ) material.sheenRoughness = json.sheenRoughness;
40789
41297
  if ( json.emissive !== undefined && material.emissive !== undefined ) material.emissive.setHex( json.emissive );
40790
41298
  if ( json.specular !== undefined && material.specular !== undefined ) material.specular.setHex( json.specular );
40791
41299
  if ( json.specularIntensity !== undefined ) material.specularIntensity = json.specularIntensity;
40792
- if ( json.specularTint !== undefined && material.specularTint !== undefined ) material.specularTint.setHex( json.specularTint );
41300
+ if ( json.specularColor !== undefined && material.specularColor !== undefined ) material.specularColor.setHex( json.specularColor );
40793
41301
  if ( json.shininess !== undefined ) material.shininess = json.shininess;
40794
41302
  if ( json.clearcoat !== undefined ) material.clearcoat = json.clearcoat;
40795
41303
  if ( json.clearcoatRoughness !== undefined ) material.clearcoatRoughness = json.clearcoatRoughness;
40796
41304
  if ( json.transmission !== undefined ) material.transmission = json.transmission;
40797
41305
  if ( json.thickness !== undefined ) material.thickness = json.thickness;
40798
41306
  if ( json.attenuationDistance !== undefined ) material.attenuationDistance = json.attenuationDistance;
40799
- if ( json.attenuationTint !== undefined && material.attenuationTint !== undefined ) material.attenuationTint.setHex( json.attenuationTint );
41307
+ if ( json.attenuationColor !== undefined && material.attenuationColor !== undefined ) material.attenuationColor.setHex( json.attenuationColor );
40800
41308
  if ( json.fog !== undefined ) material.fog = json.fog;
40801
41309
  if ( json.flatShading !== undefined ) material.flatShading = json.flatShading;
40802
41310
  if ( json.blending !== undefined ) material.blending = json.blending;
@@ -40973,7 +41481,7 @@ class MaterialLoader extends Loader {
40973
41481
 
40974
41482
  if ( json.specularMap !== undefined ) material.specularMap = getTexture( json.specularMap );
40975
41483
  if ( json.specularIntensityMap !== undefined ) material.specularIntensityMap = getTexture( json.specularIntensityMap );
40976
- if ( json.specularTintMap !== undefined ) material.specularTintMap = getTexture( json.specularTintMap );
41484
+ if ( json.specularColorMap !== undefined ) material.specularColorMap = getTexture( json.specularColorMap );
40977
41485
 
40978
41486
  if ( json.envMap !== undefined ) material.envMap = getTexture( json.envMap );
40979
41487
  if ( json.envMapIntensity !== undefined ) material.envMapIntensity = json.envMapIntensity;
@@ -40997,6 +41505,9 @@ class MaterialLoader extends Loader {
40997
41505
  if ( json.transmissionMap !== undefined ) material.transmissionMap = getTexture( json.transmissionMap );
40998
41506
  if ( json.thicknessMap !== undefined ) material.thicknessMap = getTexture( json.thicknessMap );
40999
41507
 
41508
+ if ( json.sheenColorMap !== undefined ) material.sheenColorMap = getTexture( json.sheenColorMap );
41509
+ if ( json.sheenRoughnessMap !== undefined ) material.sheenRoughnessMap = getTexture( json.sheenRoughnessMap );
41510
+
41000
41511
  return material;
41001
41512
 
41002
41513
  }
@@ -41056,6 +41567,32 @@ class LoaderUtils {
41056
41567
 
41057
41568
  }
41058
41569
 
41570
+ static resolveURL( url, path ) {
41571
+
41572
+ // Invalid URL
41573
+ if ( typeof url !== 'string' || url === '' ) return '';
41574
+
41575
+ // Host Relative URL
41576
+ if ( /^https?:\/\//i.test( path ) && /^\//.test( url ) ) {
41577
+
41578
+ path = path.replace( /(^https?:\/\/[^\/]+).*/i, '$1' );
41579
+
41580
+ }
41581
+
41582
+ // Absolute URL http://,https://,//
41583
+ if ( /^(https?:)?\/\//i.test( url ) ) return url;
41584
+
41585
+ // Data URI
41586
+ if ( /^data:.*,.*$/i.test( url ) ) return url;
41587
+
41588
+ // Blob URL
41589
+ if ( /^blob:.*$/i.test( url ) ) return url;
41590
+
41591
+ // Relative URL
41592
+ return path + url;
41593
+
41594
+ }
41595
+
41059
41596
  }
41060
41597
 
41061
41598
  class InstancedBufferGeometry extends BufferGeometry {
@@ -41958,6 +42495,8 @@ class ObjectLoader extends Loader {
41958
42495
  if ( data.premultiplyAlpha !== undefined ) texture.premultiplyAlpha = data.premultiplyAlpha;
41959
42496
  if ( data.unpackAlignment !== undefined ) texture.unpackAlignment = data.unpackAlignment;
41960
42497
 
42498
+ if ( data.userData !== undefined ) texture.userData = data.userData;
42499
+
41961
42500
  textures[ data.uuid ] = texture;
41962
42501
 
41963
42502
  }
@@ -42599,6 +43138,7 @@ AmbientLightProbe.prototype.isAmbientLightProbe = true;
42599
43138
 
42600
43139
  const _eyeRight = /*@__PURE__*/ new Matrix4();
42601
43140
  const _eyeLeft = /*@__PURE__*/ new Matrix4();
43141
+ const _projectionMatrix = /*@__PURE__*/ new Matrix4();
42602
43142
 
42603
43143
  class StereoCamera {
42604
43144
 
@@ -42651,7 +43191,7 @@ class StereoCamera {
42651
43191
  // Off-axis stereoscopic effect based on
42652
43192
  // http://paulbourke.net/stereographics/stereorender/
42653
43193
 
42654
- const projectionMatrix = camera.projectionMatrix.clone();
43194
+ _projectionMatrix.copy( camera.projectionMatrix );
42655
43195
  const eyeSepHalf = cache.eyeSep / 2;
42656
43196
  const eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;
42657
43197
  const ymax = ( cache.near * Math.tan( DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom;
@@ -42667,20 +43207,20 @@ class StereoCamera {
42667
43207
  xmin = - ymax * cache.aspect + eyeSepOnProjection;
42668
43208
  xmax = ymax * cache.aspect + eyeSepOnProjection;
42669
43209
 
42670
- projectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin );
42671
- projectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );
43210
+ _projectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin );
43211
+ _projectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );
42672
43212
 
42673
- this.cameraL.projectionMatrix.copy( projectionMatrix );
43213
+ this.cameraL.projectionMatrix.copy( _projectionMatrix );
42674
43214
 
42675
43215
  // for right eye
42676
43216
 
42677
43217
  xmin = - ymax * cache.aspect - eyeSepOnProjection;
42678
43218
  xmax = ymax * cache.aspect - eyeSepOnProjection;
42679
43219
 
42680
- projectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin );
42681
- projectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );
43220
+ _projectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin );
43221
+ _projectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );
42682
43222
 
42683
- this.cameraR.projectionMatrix.copy( projectionMatrix );
43223
+ this.cameraR.projectionMatrix.copy( _projectionMatrix );
42684
43224
 
42685
43225
  }
42686
43226
 
@@ -46981,33 +47521,6 @@ class Line3 {
46981
47521
 
46982
47522
  }
46983
47523
 
46984
- class ImmediateRenderObject extends Object3D {
46985
-
46986
- constructor( material ) {
46987
-
46988
- super();
46989
-
46990
- this.material = material;
46991
- this.render = function ( /* renderCallback */ ) {};
46992
-
46993
- this.hasPositions = false;
46994
- this.hasNormals = false;
46995
- this.hasColors = false;
46996
- this.hasUvs = false;
46997
-
46998
- this.positionArray = null;
46999
- this.normalArray = null;
47000
- this.colorArray = null;
47001
- this.uvArray = null;
47002
-
47003
- this.count = 0;
47004
-
47005
- }
47006
-
47007
- }
47008
-
47009
- ImmediateRenderObject.prototype.isImmediateRenderObject = true;
47010
-
47011
47524
  const _vector$3 = /*@__PURE__*/ new Vector3();
47012
47525
 
47013
47526
  class SpotLightHelper extends Object3D {
@@ -47563,7 +48076,7 @@ const _camera = /*@__PURE__*/ new Camera();
47563
48076
  * - shows frustum, line of sight and up of the camera
47564
48077
  * - suitable for fast updates
47565
48078
  * - based on frustum visualization in lightgl.js shadowmap example
47566
- * http://evanw.github.com/lightgl.js/tests/shadowmap.html
48079
+ * https://github.com/evanw/lightgl.js/blob/master/tests/shadowmap.html
47567
48080
  */
47568
48081
 
47569
48082
  class CameraHelper extends LineSegments {
@@ -49959,7 +50472,19 @@ Object.defineProperties( WebGLRenderer.prototype, {
49959
50472
 
49960
50473
  }
49961
50474
  },
50475
+ gammaFactor: {
50476
+ get: function () {
50477
+
50478
+ console.warn( 'THREE.WebGLRenderer: .gammaFactor has been removed.' );
50479
+ return 2;
50480
+
50481
+ },
50482
+ set: function () {
50483
+
50484
+ console.warn( 'THREE.WebGLRenderer: .gammaFactor has been removed.' );
49962
50485
 
50486
+ }
50487
+ }
49963
50488
  } );
49964
50489
 
49965
50490
  Object.defineProperties( WebGLShadowMap.prototype, {
@@ -50320,13 +50845,17 @@ function Font() {
50320
50845
 
50321
50846
  }
50322
50847
 
50848
+ function ImmediateRenderObject() {
50849
+
50850
+ console.error( 'THREE.ImmediateRenderObject has been removed.' );
50851
+
50852
+ }
50853
+
50323
50854
  if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
50324
50855
 
50325
- /* eslint-disable no-undef */
50326
50856
  __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: {
50327
50857
  revision: REVISION,
50328
50858
  } } ) );
50329
- /* eslint-enable no-undef */
50330
50859
 
50331
50860
  }
50332
50861
 
@@ -50344,4 +50873,4 @@ if ( typeof window !== 'undefined' ) {
50344
50873
 
50345
50874
  }
50346
50875
 
50347
- export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AlphaFormat, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AmbientLightProbe, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, AxisHelper, BackSide, BasicDepthPacking, BasicShadowMap, BinaryTextureLoader, Bone, BooleanKeyframeTrack, BoundingBoxHelper, Box2, Box3, Box3Helper, BoxGeometry as BoxBufferGeometry, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasRenderer, CanvasTexture, CatmullRomCurve3, CineonToneMapping, CircleGeometry as CircleBufferGeometry, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, CompressedTexture, CompressedTextureLoader, ConeGeometry as ConeBufferGeometry, ConeGeometry, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubeUVRefractionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry as CylinderBufferGeometry, CylinderGeometry, Cylindrical, DataTexture, DataTexture2DArray, DataTexture3D, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DodecahedronGeometry as DodecahedronBufferGeometry, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicBufferAttribute, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EdgesHelper, EllipseCurve, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry as ExtrudeBufferGeometry, ExtrudeGeometry, FaceColors, FileLoader, FlatShading, Float16BufferAttribute, Float32Attribute, Float32BufferAttribute, Float64Attribute, Float64BufferAttribute, FloatType, Fog, FogExp2, Font, FontLoader, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GammaEncoding, GreaterDepth, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, HemisphereLightProbe, IcosahedronGeometry as IcosahedronBufferGeometry, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, ImmediateRenderObject, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16Attribute, Int16BufferAttribute, Int32Attribute, Int32BufferAttribute, Int8Attribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, JSONLoader, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry as LatheBufferGeometry, LatheGeometry, Layers, LensFlare, LessDepth, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LinePieces, LineSegments, LineStrip, LinearEncoding, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearToneMapping, Loader, LoaderUtils, LoadingManager, LogLuvEncoding, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils as Math, MathUtils, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshFaceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiMaterial, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeverDepth, NeverStencilFunc, NoBlending, NoColors, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry as OctahedronBufferGeometry, OctahedronGeometry, OneFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, ParametricGeometry, Particle, ParticleBasicMaterial, ParticleSystem, ParticleSystemMaterial, Path, PerspectiveCamera, Plane, PlaneGeometry as PlaneBufferGeometry, PlaneGeometry, PlaneHelper, PointCloud, PointCloudMaterial, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry as PolyhedronBufferGeometry, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBDEncoding, RGBEEncoding, RGBEFormat, RGBFormat, RGBIntegerFormat, RGBM16Encoding, RGBM7Encoding, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry as RingBufferGeometry, RingGeometry, SRGB8_ALPHA8_ASTC_10x10_Format, SRGB8_ALPHA8_ASTC_10x5_Format, SRGB8_ALPHA8_ASTC_10x6_Format, SRGB8_ALPHA8_ASTC_10x8_Format, SRGB8_ALPHA8_ASTC_12x10_Format, SRGB8_ALPHA8_ASTC_12x12_Format, SRGB8_ALPHA8_ASTC_4x4_Format, SRGB8_ALPHA8_ASTC_5x4_Format, SRGB8_ALPHA8_ASTC_5x5_Format, SRGB8_ALPHA8_ASTC_6x5_Format, SRGB8_ALPHA8_ASTC_6x6_Format, SRGB8_ALPHA8_ASTC_8x5_Format, SRGB8_ALPHA8_ASTC_8x6_Format, SRGB8_ALPHA8_ASTC_8x8_Format, Scene, SceneUtils, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry as ShapeBufferGeometry, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, SmoothShading, Sphere, SphereGeometry as SphereBufferGeometry, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry as TetrahedronBufferGeometry, TetrahedronGeometry, TextGeometry, Texture, TextureLoader, TorusGeometry as TorusBufferGeometry, TorusGeometry, TorusKnotGeometry as TorusKnotBufferGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry as TubeBufferGeometry, TubeGeometry, UVMapping, Uint16Attribute, Uint16BufferAttribute, Uint32Attribute, Uint32BufferAttribute, Uint8Attribute, Uint8BufferAttribute, Uint8ClampedAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShort565Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, Vertex, VertexColors, VideoTexture, WebGL1Renderer, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLMultisampleRenderTarget, WebGLRenderTarget, WebGLRenderTargetCube, WebGLRenderer, WebGLUtils, WireframeGeometry, WireframeHelper, WrapAroundEnding, XHRLoader, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, sRGBEncoding };
50876
+ export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AlphaFormat, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AmbientLightProbe, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, AxisHelper, BackSide, BasicDepthPacking, BasicShadowMap, BinaryTextureLoader, Bone, BooleanKeyframeTrack, BoundingBoxHelper, Box2, Box3, Box3Helper, BoxGeometry as BoxBufferGeometry, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasRenderer, CanvasTexture, CatmullRomCurve3, CineonToneMapping, CircleGeometry as CircleBufferGeometry, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, CompressedTexture, CompressedTextureLoader, ConeGeometry as ConeBufferGeometry, ConeGeometry, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubeUVRefractionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry as CylinderBufferGeometry, CylinderGeometry, Cylindrical, DataTexture, DataTexture2DArray, DataTexture3D, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DodecahedronGeometry as DodecahedronBufferGeometry, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicBufferAttribute, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EdgesHelper, EllipseCurve, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry as ExtrudeBufferGeometry, ExtrudeGeometry, FaceColors, FileLoader, FlatShading, Float16BufferAttribute, Float32Attribute, Float32BufferAttribute, Float64Attribute, Float64BufferAttribute, FloatType, Fog, FogExp2, Font, FontLoader, FramebufferTexture, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GreaterDepth, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, HemisphereLightProbe, IcosahedronGeometry as IcosahedronBufferGeometry, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, ImmediateRenderObject, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16Attribute, Int16BufferAttribute, Int32Attribute, Int32BufferAttribute, Int8Attribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, JSONLoader, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry as LatheBufferGeometry, LatheGeometry, Layers, LensFlare, LessDepth, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LinePieces, LineSegments, LineStrip, LinearEncoding, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearToneMapping, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils as Math, MathUtils, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshFaceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiMaterial, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeverDepth, NeverStencilFunc, NoBlending, NoColors, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry as OctahedronBufferGeometry, OctahedronGeometry, OneFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, ParametricGeometry, Particle, ParticleBasicMaterial, ParticleSystem, ParticleSystemMaterial, Path, PerspectiveCamera, Plane, PlaneGeometry as PlaneBufferGeometry, PlaneGeometry, PlaneHelper, PointCloud, PointCloudMaterial, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry as PolyhedronBufferGeometry, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBFormat, RGBIntegerFormat, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry as RingBufferGeometry, RingGeometry, SRGB8_ALPHA8_ASTC_10x10_Format, SRGB8_ALPHA8_ASTC_10x5_Format, SRGB8_ALPHA8_ASTC_10x6_Format, SRGB8_ALPHA8_ASTC_10x8_Format, SRGB8_ALPHA8_ASTC_12x10_Format, SRGB8_ALPHA8_ASTC_12x12_Format, SRGB8_ALPHA8_ASTC_4x4_Format, SRGB8_ALPHA8_ASTC_5x4_Format, SRGB8_ALPHA8_ASTC_5x5_Format, SRGB8_ALPHA8_ASTC_6x5_Format, SRGB8_ALPHA8_ASTC_6x6_Format, SRGB8_ALPHA8_ASTC_8x5_Format, SRGB8_ALPHA8_ASTC_8x6_Format, SRGB8_ALPHA8_ASTC_8x8_Format, Scene, SceneUtils, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry as ShapeBufferGeometry, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, SmoothShading, Sphere, SphereGeometry as SphereBufferGeometry, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry as TetrahedronBufferGeometry, TetrahedronGeometry, TextGeometry, Texture, TextureLoader, TorusGeometry as TorusBufferGeometry, TorusGeometry, TorusKnotGeometry as TorusKnotBufferGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry as TubeBufferGeometry, TubeGeometry, UVMapping, Uint16Attribute, Uint16BufferAttribute, Uint32Attribute, Uint32BufferAttribute, Uint8Attribute, Uint8BufferAttribute, Uint8ClampedAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShort565Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, Vertex, VertexColors, VideoTexture, WebGL1Renderer, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLMultisampleRenderTarget, WebGLRenderTarget, WebGLRenderTargetCube, WebGLRenderer, WebGLUtils, WireframeGeometry, WireframeHelper, WrapAroundEnding, XHRLoader, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, sRGBEncoding };