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
package/build/three.js CHANGED
@@ -9,7 +9,7 @@
9
9
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.THREE = {}));
10
10
  }(this, (function (exports) { 'use strict';
11
11
 
12
- const REVISION = '133';
12
+ const REVISION = '136';
13
13
  const MOUSE = {
14
14
  LEFT: 0,
15
15
  MIDDLE: 1,
@@ -113,7 +113,6 @@
113
113
  const RGBAFormat = 1023;
114
114
  const LuminanceFormat = 1024;
115
115
  const LuminanceAlphaFormat = 1025;
116
- const RGBEFormat = RGBAFormat;
117
116
  const DepthFormat = 1026;
118
117
  const DepthStencilFormat = 1027;
119
118
  const RedFormat = 1028;
@@ -178,12 +177,6 @@
178
177
  const TriangleFanDrawMode = 2;
179
178
  const LinearEncoding = 3000;
180
179
  const sRGBEncoding = 3001;
181
- const GammaEncoding = 3007;
182
- const RGBEEncoding = 3002;
183
- const LogLuvEncoding = 3003;
184
- const RGBM7Encoding = 3004;
185
- const RGBM16Encoding = 3005;
186
- const RGBDEncoding = 3006;
187
180
  const BasicDepthPacking = 3200;
188
181
  const RGBADepthPacking = 3201;
189
182
  const TangentSpaceNormalMap = 0;
@@ -273,25 +266,17 @@
273
266
 
274
267
  }
275
268
 
276
- let _seed = 1234567;
277
- const DEG2RAD = Math.PI / 180;
278
- const RAD2DEG = 180 / Math.PI; //
279
-
280
269
  const _lut = [];
281
270
 
282
271
  for (let i = 0; i < 256; i++) {
283
272
  _lut[i] = (i < 16 ? '0' : '') + i.toString(16);
284
273
  }
285
274
 
286
- const hasRandomUUID = typeof crypto !== 'undefined' && 'randomUUID' in crypto;
275
+ let _seed = 1234567;
276
+ const DEG2RAD = Math.PI / 180;
277
+ const RAD2DEG = 180 / Math.PI; // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
287
278
 
288
279
  function generateUUID() {
289
- if (hasRandomUUID) {
290
- return crypto.randomUUID().toUpperCase();
291
- } // TODO Remove this code when crypto.randomUUID() is available everywhere
292
- // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
293
-
294
-
295
280
  const d0 = Math.random() * 0xffffffff | 0;
296
281
  const d1 = Math.random() * 0xffffffff | 0;
297
282
  const d2 = Math.random() * 0xffffffff | 0;
@@ -1195,6 +1180,7 @@
1195
1180
  // update. You need to explicitly call Material.needsUpdate to trigger it to recompile.
1196
1181
 
1197
1182
  this.encoding = encoding;
1183
+ this.userData = {};
1198
1184
  this.version = 0;
1199
1185
  this.onUpdate = null;
1200
1186
  this.isRenderTargetTexture = false;
@@ -1232,6 +1218,7 @@
1232
1218
  this.flipY = source.flipY;
1233
1219
  this.unpackAlignment = source.unpackAlignment;
1234
1220
  this.encoding = source.encoding;
1221
+ this.userData = JSON.parse(JSON.stringify(source.userData));
1235
1222
  return this;
1236
1223
  }
1237
1224
 
@@ -1304,6 +1291,8 @@
1304
1291
  output.image = image.uuid;
1305
1292
  }
1306
1293
 
1294
+ if (JSON.stringify(this.userData) !== '{}') output.userData = this.userData;
1295
+
1307
1296
  if (!isRootObject) {
1308
1297
  meta.textures[this.uuid] = output;
1309
1298
  }
@@ -2032,14 +2021,19 @@
2032
2021
  WebGLMultipleRenderTargets.prototype.isWebGLMultipleRenderTargets = true;
2033
2022
 
2034
2023
  class WebGLMultisampleRenderTarget extends WebGLRenderTarget {
2035
- constructor(width, height, options) {
2024
+ constructor(width, height, options = {}) {
2036
2025
  super(width, height, options);
2037
2026
  this.samples = 4;
2027
+ this.ignoreDepthForMultisampleCopy = options.ignoreDepth !== undefined ? options.ignoreDepth : true;
2028
+ this.useRenderToTexture = options.useRenderToTexture !== undefined ? options.useRenderToTexture : false;
2029
+ this.useRenderbuffer = this.useRenderToTexture === false;
2038
2030
  }
2039
2031
 
2040
2032
  copy(source) {
2041
2033
  super.copy.call(this, source);
2042
2034
  this.samples = source.samples;
2035
+ this.useRenderToTexture = source.useRenderToTexture;
2036
+ this.useRenderbuffer = source.useRenderbuffer;
2043
2037
  return this;
2044
2038
  }
2045
2039
 
@@ -3646,7 +3640,11 @@
3646
3640
  // To enclose another sphere into this sphere, we only need to enclose two points:
3647
3641
  // 1) Enclose the farthest point on the other sphere into this sphere.
3648
3642
  // 2) Enclose the opposite point of the farthest point into this sphere.
3649
- _toFarthestPoint.subVectors(sphere.center, this.center).normalize().multiplyScalar(sphere.radius);
3643
+ if (this.center.equals(sphere.center) === true) {
3644
+ _toFarthestPoint.set(0, 0, 1).multiplyScalar(sphere.radius);
3645
+ } else {
3646
+ _toFarthestPoint.subVectors(sphere.center, this.center).normalize().multiplyScalar(sphere.radius);
3647
+ }
3650
3648
 
3651
3649
  this.expandByPoint(_v1$6.copy(sphere.center).add(_toFarthestPoint));
3652
3650
  this.expandByPoint(_v1$6.copy(sphere.center).sub(_toFarthestPoint));
@@ -3738,7 +3736,7 @@
3738
3736
  }
3739
3737
 
3740
3738
  distanceSqToSegment(v0, v1, optionalPointOnRay, optionalPointOnSegment) {
3741
- // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h
3739
+ // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteDistRaySegment.h
3742
3740
  // It returns the min distance between the ray and the segment
3743
3741
  // defined by v0 and v1
3744
3742
  // It can also set two optional targets :
@@ -3949,7 +3947,7 @@
3949
3947
 
3950
3948
  intersectTriangle(a, b, c, backfaceCulling, target) {
3951
3949
  // Compute the offset origin, edges, and normal.
3952
- // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
3950
+ // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
3953
3951
  _edge1.subVectors(b, a);
3954
3952
 
3955
3953
  _edge2.subVectors(c, a);
@@ -5014,7 +5012,7 @@
5014
5012
  }
5015
5013
 
5016
5014
  set(channel) {
5017
- this.mask = 1 << channel | 0;
5015
+ this.mask = (1 << channel | 0) >>> 0;
5018
5016
  }
5019
5017
 
5020
5018
  enable(channel) {
@@ -5041,6 +5039,10 @@
5041
5039
  return (this.mask & layers.mask) !== 0;
5042
5040
  }
5043
5041
 
5042
+ isEnabled(channel) {
5043
+ return (this.mask & (1 << channel | 0)) !== 0;
5044
+ }
5045
+
5044
5046
  }
5045
5047
 
5046
5048
  let _object3DId = 0;
@@ -5339,6 +5341,7 @@
5339
5341
 
5340
5342
  attach(object) {
5341
5343
  // adds object as a child of this, while maintaining the object's world transform
5344
+ // Note: This method does not support scene graphs having non-uniformly-scaled nodes(s)
5342
5345
  this.updateWorldMatrix(true, false);
5343
5346
 
5344
5347
  _m1$1.copy(this.matrixWorld).invert();
@@ -6081,13 +6084,13 @@
6081
6084
  if (this.roughness !== undefined) data.roughness = this.roughness;
6082
6085
  if (this.metalness !== undefined) data.metalness = this.metalness;
6083
6086
  if (this.sheen !== undefined) data.sheen = this.sheen;
6084
- if (this.sheenTint && this.sheenTint.isColor) data.sheenTint = this.sheenTint.getHex();
6087
+ if (this.sheenColor && this.sheenColor.isColor) data.sheenColor = this.sheenColor.getHex();
6085
6088
  if (this.sheenRoughness !== undefined) data.sheenRoughness = this.sheenRoughness;
6086
6089
  if (this.emissive && this.emissive.isColor) data.emissive = this.emissive.getHex();
6087
6090
  if (this.emissiveIntensity && this.emissiveIntensity !== 1) data.emissiveIntensity = this.emissiveIntensity;
6088
6091
  if (this.specular && this.specular.isColor) data.specular = this.specular.getHex();
6089
6092
  if (this.specularIntensity !== undefined) data.specularIntensity = this.specularIntensity;
6090
- if (this.specularTint && this.specularTint.isColor) data.specularTint = this.specularTint.getHex();
6093
+ if (this.specularColor && this.specularColor.isColor) data.specularColor = this.specularColor.getHex();
6091
6094
  if (this.shininess !== undefined) data.shininess = this.shininess;
6092
6095
  if (this.clearcoat !== undefined) data.clearcoat = this.clearcoat;
6093
6096
  if (this.clearcoatRoughness !== undefined) data.clearcoatRoughness = this.clearcoatRoughness;
@@ -6141,7 +6144,7 @@
6141
6144
  if (this.emissiveMap && this.emissiveMap.isTexture) data.emissiveMap = this.emissiveMap.toJSON(meta).uuid;
6142
6145
  if (this.specularMap && this.specularMap.isTexture) data.specularMap = this.specularMap.toJSON(meta).uuid;
6143
6146
  if (this.specularIntensityMap && this.specularIntensityMap.isTexture) data.specularIntensityMap = this.specularIntensityMap.toJSON(meta).uuid;
6144
- if (this.specularTintMap && this.specularTintMap.isTexture) data.specularTintMap = this.specularTintMap.toJSON(meta).uuid;
6147
+ if (this.specularColorMap && this.specularColorMap.isTexture) data.specularColorMap = this.specularColorMap.toJSON(meta).uuid;
6145
6148
 
6146
6149
  if (this.envMap && this.envMap.isTexture) {
6147
6150
  data.envMap = this.envMap.toJSON(meta).uuid;
@@ -6161,7 +6164,7 @@
6161
6164
  if (this.thickness !== undefined) data.thickness = this.thickness;
6162
6165
  if (this.thicknessMap && this.thicknessMap.isTexture) data.thicknessMap = this.thicknessMap.toJSON(meta).uuid;
6163
6166
  if (this.attenuationDistance !== undefined) data.attenuationDistance = this.attenuationDistance;
6164
- if (this.attenuationTint !== undefined) data.attenuationTint = this.attenuationTint.getHex();
6167
+ if (this.attenuationColor !== undefined) data.attenuationColor = this.attenuationColor.getHex();
6165
6168
  if (this.size !== undefined) data.size = this.size;
6166
6169
  if (this.shadowSide !== null) data.shadowSide = this.shadowSide;
6167
6170
  if (this.sizeAttenuation !== undefined) data.sizeAttenuation = this.sizeAttenuation;
@@ -6649,31 +6652,6 @@
6649
6652
  return this;
6650
6653
  }
6651
6654
 
6652
- copyGammaToLinear(color, gammaFactor = 2.0) {
6653
- this.r = Math.pow(color.r, gammaFactor);
6654
- this.g = Math.pow(color.g, gammaFactor);
6655
- this.b = Math.pow(color.b, gammaFactor);
6656
- return this;
6657
- }
6658
-
6659
- copyLinearToGamma(color, gammaFactor = 2.0) {
6660
- const safeInverse = gammaFactor > 0 ? 1.0 / gammaFactor : 1.0;
6661
- this.r = Math.pow(color.r, safeInverse);
6662
- this.g = Math.pow(color.g, safeInverse);
6663
- this.b = Math.pow(color.b, safeInverse);
6664
- return this;
6665
- }
6666
-
6667
- convertGammaToLinear(gammaFactor) {
6668
- this.copyGammaToLinear(this, gammaFactor);
6669
- return this;
6670
- }
6671
-
6672
- convertLinearToGamma(gammaFactor) {
6673
- this.copyLinearToGamma(this, gammaFactor);
6674
- return this;
6675
- }
6676
-
6677
6655
  copySRGBToLinear(color) {
6678
6656
  this.r = SRGBToLinear(color.r);
6679
6657
  this.g = SRGBToLinear(color.g);
@@ -7315,7 +7293,7 @@
7315
7293
 
7316
7294
  } //
7317
7295
 
7318
- let _id = 0;
7296
+ let _id$1 = 0;
7319
7297
 
7320
7298
  const _m1 = /*@__PURE__*/new Matrix4();
7321
7299
 
@@ -7333,7 +7311,7 @@
7333
7311
  constructor() {
7334
7312
  super();
7335
7313
  Object.defineProperty(this, 'id', {
7336
- value: _id++
7314
+ value: _id$1++
7337
7315
  });
7338
7316
  this.uuid = generateUUID();
7339
7317
  this.name = '';
@@ -9664,7 +9642,7 @@
9664
9642
 
9665
9643
  var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif";
9666
9644
 
9667
- 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";
9645
+ 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";
9668
9646
 
9669
9647
  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";
9670
9648
 
@@ -9686,7 +9664,7 @@
9686
9664
 
9687
9665
  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}";
9688
9666
 
9689
- 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";
9667
+ 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";
9690
9668
 
9691
9669
  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";
9692
9670
 
@@ -9700,11 +9678,11 @@
9700
9678
 
9701
9679
  var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
9702
9680
 
9703
- 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}";
9681
+ 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}";
9704
9682
 
9705
9683
  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";
9706
9684
 
9707
- 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";
9685
+ 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";
9708
9686
 
9709
9687
  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";
9710
9688
 
@@ -9720,7 +9698,7 @@
9720
9698
 
9721
9699
  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";
9722
9700
 
9723
- 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}";
9701
+ 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}";
9724
9702
 
9725
9703
  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";
9726
9704
 
@@ -9740,9 +9718,9 @@
9740
9718
 
9741
9719
  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)";
9742
9720
 
9743
- 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";
9721
+ 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";
9744
9722
 
9745
- 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}";
9723
+ 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}";
9746
9724
 
9747
9725
  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";
9748
9726
 
@@ -9834,9 +9812,9 @@
9834
9812
 
9835
9813
  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; }";
9836
9814
 
9837
- 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";
9815
+ 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";
9838
9816
 
9839
- 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";
9817
+ 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";
9840
9818
 
9841
9819
  var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif";
9842
9820
 
@@ -9886,7 +9864,7 @@
9886
9864
  const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\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 <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_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 <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_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 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\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}";
9887
9865
 
9888
9866
  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}";
9889
- 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}";
9867
+ 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}";
9890
9868
 
9891
9869
  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}";
9892
9870
  const fragment$4 = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\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 <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_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 <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_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 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\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}";
@@ -10087,9 +10065,6 @@
10087
10065
  // standard, physical
10088
10066
  refractionRatio: {
10089
10067
  value: 0.98
10090
- },
10091
- maxMipLevel: {
10092
- value: 0
10093
10068
  }
10094
10069
  },
10095
10070
  aomap: {
@@ -10521,12 +10496,18 @@
10521
10496
  sheen: {
10522
10497
  value: 0
10523
10498
  },
10524
- sheenTint: {
10499
+ sheenColor: {
10525
10500
  value: new Color(0x000000)
10526
10501
  },
10502
+ sheenColorMap: {
10503
+ value: null
10504
+ },
10527
10505
  sheenRoughness: {
10528
10506
  value: 0
10529
10507
  },
10508
+ sheenRoughnessMap: {
10509
+ value: null
10510
+ },
10530
10511
  transmission: {
10531
10512
  value: 0
10532
10513
  },
@@ -10548,7 +10529,7 @@
10548
10529
  attenuationDistance: {
10549
10530
  value: 0
10550
10531
  },
10551
- attenuationTint: {
10532
+ attenuationColor: {
10552
10533
  value: new Color(0x000000)
10553
10534
  },
10554
10535
  specularIntensity: {
@@ -10557,10 +10538,10 @@
10557
10538
  specularIntensityMap: {
10558
10539
  value: null
10559
10540
  },
10560
- specularTint: {
10541
+ specularColor: {
10561
10542
  value: new Color(1, 1, 1)
10562
10543
  },
10563
- specularTintMap: {
10544
+ specularColorMap: {
10564
10545
  value: null
10565
10546
  }
10566
10547
  }]),
@@ -11176,12 +11157,8 @@
11176
11157
 
11177
11158
  return 'lowp';
11178
11159
  }
11179
- /* eslint-disable no-undef */
11180
-
11181
11160
 
11182
11161
  const isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext || typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext;
11183
- /* eslint-enable no-undef */
11184
-
11185
11162
  let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
11186
11163
  const maxPrecision = getMaxPrecision(precision);
11187
11164
 
@@ -11524,12 +11501,7 @@
11524
11501
  const MAX_SAMPLES = 20;
11525
11502
  const ENCODINGS = {
11526
11503
  [LinearEncoding]: 0,
11527
- [sRGBEncoding]: 1,
11528
- [RGBEEncoding]: 2,
11529
- [RGBM7Encoding]: 3,
11530
- [RGBM16Encoding]: 4,
11531
- [RGBDEncoding]: 5,
11532
- [GammaEncoding]: 6
11504
+ [sRGBEncoding]: 1
11533
11505
  };
11534
11506
 
11535
11507
  const _flatCamera = /*@__PURE__*/new OrthographicCamera();
@@ -11602,7 +11574,7 @@
11602
11574
  }
11603
11575
  /**
11604
11576
  * Generates a PMREM from an equirectangular texture, which can be either LDR
11605
- * (RGBFormat) or HDR (RGBEFormat). The ideal input image size is 1k (1024 x 512),
11577
+ * or HDR. The ideal input image size is 1k (1024 x 512),
11606
11578
  * as this matches best with the 256 x 256 cubemap output.
11607
11579
  */
11608
11580
 
@@ -11612,7 +11584,7 @@
11612
11584
  }
11613
11585
  /**
11614
11586
  * Generates a PMREM from an cubemap texture, which can be either LDR
11615
- * (RGBFormat) or HDR (RGBEFormat). The ideal input cube size is 256 x 256,
11587
+ * or HDR. The ideal input cube size is 256 x 256,
11616
11588
  * as this matches best with the 256 x 256 cubemap output.
11617
11589
  */
11618
11590
 
@@ -11692,12 +11664,12 @@
11692
11664
  _allocateTargets(texture) {
11693
11665
  // warning: null texture is valid
11694
11666
  const params = {
11695
- magFilter: NearestFilter,
11696
- minFilter: NearestFilter,
11667
+ magFilter: LinearFilter,
11668
+ minFilter: LinearFilter,
11697
11669
  generateMipmaps: false,
11698
- type: UnsignedByteType,
11699
- format: RGBEFormat,
11700
- encoding: _isLDR(texture) ? texture.encoding : RGBEEncoding,
11670
+ type: HalfFloatType,
11671
+ format: RGBAFormat,
11672
+ encoding: LinearEncoding,
11701
11673
  depthBuffer: false
11702
11674
  };
11703
11675
 
@@ -11722,11 +11694,9 @@
11722
11694
  const forwardSign = [1, 1, 1, -1, -1, -1];
11723
11695
  const renderer = this._renderer;
11724
11696
  const originalAutoClear = renderer.autoClear;
11725
- const outputEncoding = renderer.outputEncoding;
11726
11697
  const toneMapping = renderer.toneMapping;
11727
11698
  renderer.getClearColor(_clearColor);
11728
11699
  renderer.toneMapping = NoToneMapping;
11729
- renderer.outputEncoding = LinearEncoding;
11730
11700
  renderer.autoClear = false;
11731
11701
  const backgroundMaterial = new MeshBasicMaterial({
11732
11702
  name: 'PMREM.Background',
@@ -11777,7 +11747,6 @@
11777
11747
  backgroundBox.geometry.dispose();
11778
11748
  backgroundBox.material.dispose();
11779
11749
  renderer.toneMapping = toneMapping;
11780
- renderer.outputEncoding = outputEncoding;
11781
11750
  renderer.autoClear = originalAutoClear;
11782
11751
  scene.background = background;
11783
11752
  }
@@ -11792,8 +11761,9 @@
11792
11761
 
11793
11762
  _textureToCubeUV(texture, cubeUVRenderTarget) {
11794
11763
  const renderer = this._renderer;
11764
+ const isCubeTexture = texture.mapping === CubeReflectionMapping || texture.mapping === CubeRefractionMapping;
11795
11765
 
11796
- if (texture.isCubeTexture) {
11766
+ if (isCubeTexture) {
11797
11767
  if (this._cubemapShader == null) {
11798
11768
  this._cubemapShader = _getCubemapShader();
11799
11769
  }
@@ -11803,19 +11773,17 @@
11803
11773
  }
11804
11774
  }
11805
11775
 
11806
- const material = texture.isCubeTexture ? this._cubemapShader : this._equirectShader;
11776
+ const material = isCubeTexture ? this._cubemapShader : this._equirectShader;
11807
11777
  const mesh = new Mesh(_lodPlanes[0], material);
11808
11778
  const uniforms = material.uniforms;
11809
11779
  uniforms['envMap'].value = texture;
11810
11780
 
11811
- if (!texture.isCubeTexture) {
11781
+ if (!isCubeTexture) {
11812
11782
  uniforms['texelSize'].value.set(1.0 / texture.image.width, 1.0 / texture.image.height);
11813
11783
  }
11814
11784
 
11815
11785
  this._setEncoding(uniforms['inputEncoding'], texture);
11816
11786
 
11817
- this._setEncoding(uniforms['outputEncoding'], cubeUVRenderTarget.texture);
11818
-
11819
11787
  _setViewport(cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX);
11820
11788
 
11821
11789
  renderer.setRenderTarget(cubeUVRenderTarget);
@@ -11904,11 +11872,6 @@
11904
11872
 
11905
11873
  blurUniforms['dTheta'].value = radiansPerPixel;
11906
11874
  blurUniforms['mipInt'].value = LOD_MAX - lodIn;
11907
-
11908
- this._setEncoding(blurUniforms['inputEncoding'], targetIn.texture);
11909
-
11910
- this._setEncoding(blurUniforms['outputEncoding'], targetIn.texture);
11911
-
11912
11875
  const outputSize = _sizeLods[lodOut];
11913
11876
  const x = 3 * Math.max(0, SIZE_MAX - 2 * outputSize);
11914
11877
  const y = (lodOut === 0 ? 0 : 2 * SIZE_MAX) + 2 * outputSize * (lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0);
@@ -11921,11 +11884,6 @@
11921
11884
 
11922
11885
  }
11923
11886
 
11924
- function _isLDR(texture) {
11925
- if (texture === undefined || texture.type !== UnsignedByteType) return false;
11926
- return texture.encoding === LinearEncoding || texture.encoding === sRGBEncoding || texture.encoding === GammaEncoding;
11927
- }
11928
-
11929
11887
  function _createPlanes() {
11930
11888
  const _lodPlanes = [];
11931
11889
  const _sizeLods = [];
@@ -12031,12 +11989,6 @@
12031
11989
  },
12032
11990
  'poleAxis': {
12033
11991
  value: poleAxis
12034
- },
12035
- 'inputEncoding': {
12036
- value: ENCODINGS[LinearEncoding]
12037
- },
12038
- 'outputEncoding': {
12039
- value: ENCODINGS[LinearEncoding]
12040
11992
  }
12041
11993
  },
12042
11994
  vertexShader: _getCommonVertexShader(),
@@ -12103,8 +12055,6 @@
12103
12055
 
12104
12056
  }
12105
12057
 
12106
- gl_FragColor = linearToOutputTexel( gl_FragColor );
12107
-
12108
12058
  }
12109
12059
  `,
12110
12060
  blending: NoBlending,
@@ -12127,9 +12077,6 @@
12127
12077
  },
12128
12078
  'inputEncoding': {
12129
12079
  value: ENCODINGS[LinearEncoding]
12130
- },
12131
- 'outputEncoding': {
12132
- value: ENCODINGS[LinearEncoding]
12133
12080
  }
12134
12081
  },
12135
12082
  vertexShader: _getCommonVertexShader(),
@@ -12170,8 +12117,6 @@
12170
12117
  vec3 bm = mix( bl, br, f.x );
12171
12118
  gl_FragColor.rgb = mix( tm, bm, f.y );
12172
12119
 
12173
- gl_FragColor = linearToOutputTexel( gl_FragColor );
12174
-
12175
12120
  }
12176
12121
  `,
12177
12122
  blending: NoBlending,
@@ -12190,9 +12135,6 @@
12190
12135
  },
12191
12136
  'inputEncoding': {
12192
12137
  value: ENCODINGS[LinearEncoding]
12193
- },
12194
- 'outputEncoding': {
12195
- value: ENCODINGS[LinearEncoding]
12196
12138
  }
12197
12139
  },
12198
12140
  vertexShader: _getCommonVertexShader(),
@@ -12211,9 +12153,7 @@
12211
12153
 
12212
12154
  void main() {
12213
12155
 
12214
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
12215
- gl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;
12216
- gl_FragColor = linearToOutputTexel( gl_FragColor );
12156
+ gl_FragColor = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) );
12217
12157
 
12218
12158
  }
12219
12159
  `,
@@ -12294,7 +12234,6 @@
12294
12234
  `
12295
12235
 
12296
12236
  uniform int inputEncoding;
12297
- uniform int outputEncoding;
12298
12237
 
12299
12238
  #include <encodings_pars_fragment>
12300
12239
 
@@ -12304,63 +12243,9 @@
12304
12243
 
12305
12244
  return value;
12306
12245
 
12307
- } else if ( inputEncoding == 1 ) {
12308
-
12309
- return sRGBToLinear( value );
12310
-
12311
- } else if ( inputEncoding == 2 ) {
12312
-
12313
- return RGBEToLinear( value );
12314
-
12315
- } else if ( inputEncoding == 3 ) {
12316
-
12317
- return RGBMToLinear( value, 7.0 );
12318
-
12319
- } else if ( inputEncoding == 4 ) {
12320
-
12321
- return RGBMToLinear( value, 16.0 );
12322
-
12323
- } else if ( inputEncoding == 5 ) {
12324
-
12325
- return RGBDToLinear( value, 256.0 );
12326
-
12327
12246
  } else {
12328
12247
 
12329
- return GammaToLinear( value, 2.2 );
12330
-
12331
- }
12332
-
12333
- }
12334
-
12335
- vec4 linearToOutputTexel( vec4 value ) {
12336
-
12337
- if ( outputEncoding == 0 ) {
12338
-
12339
- return value;
12340
-
12341
- } else if ( outputEncoding == 1 ) {
12342
-
12343
- return LinearTosRGB( value );
12344
-
12345
- } else if ( outputEncoding == 2 ) {
12346
-
12347
- return LinearToRGBE( value );
12348
-
12349
- } else if ( outputEncoding == 3 ) {
12350
-
12351
- return LinearToRGBM( value, 7.0 );
12352
-
12353
- } else if ( outputEncoding == 4 ) {
12354
-
12355
- return LinearToRGBM( value, 16.0 );
12356
-
12357
- } else if ( outputEncoding == 5 ) {
12358
-
12359
- return LinearToRGBD( value, 256.0 );
12360
-
12361
- } else {
12362
-
12363
- return LinearToGamma( value, 2.2 );
12248
+ return sRGBToLinear( value );
12364
12249
 
12365
12250
  }
12366
12251
 
@@ -12503,6 +12388,7 @@
12503
12388
 
12504
12389
  getExtension('OES_texture_float_linear');
12505
12390
  getExtension('EXT_color_buffer_half_float');
12391
+ getExtension('WEBGL_multisampled_render_to_texture');
12506
12392
  },
12507
12393
  get: function (name) {
12508
12394
  const extension = getExtension(name);
@@ -12765,7 +12651,6 @@
12765
12651
  this.generateMipmaps = false;
12766
12652
  this.flipY = false;
12767
12653
  this.unpackAlignment = 1;
12768
- this.needsUpdate = true;
12769
12654
  }
12770
12655
 
12771
12656
  }
@@ -12827,7 +12712,8 @@
12827
12712
  const texture = new DataTexture2DArray(buffer, width, height, numberOfMorphTargets);
12828
12713
  texture.format = RGBAFormat; // using RGBA since RGB might be emulated (and is thus slower)
12829
12714
 
12830
- texture.type = FloatType; // fill buffer
12715
+ texture.type = FloatType;
12716
+ texture.needsUpdate = true; // fill buffer
12831
12717
 
12832
12718
  const vertexDataStride = numberOfVertexData * 4;
12833
12719
 
@@ -13027,7 +12913,6 @@
13027
12913
  this.generateMipmaps = false;
13028
12914
  this.flipY = false;
13029
12915
  this.unpackAlignment = 1;
13030
- this.needsUpdate = true;
13031
12916
  }
13032
12917
 
13033
12918
  }
@@ -13554,7 +13439,7 @@
13554
13439
 
13555
13440
  function setValueV4uiArray(gl, v) {
13556
13441
  gl.uniform4uiv(this.addr, v);
13557
- } // Array of textures (2D / Cube)
13442
+ } // Array of textures (2D / 3D / Cube / 2DArray)
13558
13443
 
13559
13444
 
13560
13445
  function setValueT1Array(gl, v, textures) {
@@ -13567,6 +13452,16 @@
13567
13452
  }
13568
13453
  }
13569
13454
 
13455
+ function setValueT3DArray(gl, v, textures) {
13456
+ const n = v.length;
13457
+ const units = allocTexUnits(textures, n);
13458
+ gl.uniform1iv(this.addr, units);
13459
+
13460
+ for (let i = 0; i !== n; ++i) {
13461
+ textures.setTexture3D(v[i] || emptyTexture3d, units[i]);
13462
+ }
13463
+ }
13464
+
13570
13465
  function setValueT6Array(gl, v, textures) {
13571
13466
  const n = v.length;
13572
13467
  const units = allocTexUnits(textures, n);
@@ -13575,6 +13470,16 @@
13575
13470
  for (let i = 0; i !== n; ++i) {
13576
13471
  textures.safeSetTextureCube(v[i] || emptyCubeTexture, units[i]);
13577
13472
  }
13473
+ }
13474
+
13475
+ function setValueT2DArrayArray(gl, v, textures) {
13476
+ const n = v.length;
13477
+ const units = allocTexUnits(textures, n);
13478
+ gl.uniform1iv(this.addr, units);
13479
+
13480
+ for (let i = 0; i !== n; ++i) {
13481
+ textures.setTexture2DArray(v[i] || emptyTexture2dArray, units[i]);
13482
+ }
13578
13483
  } // Helper to pick the right setter for a pure (bottom-level) array
13579
13484
 
13580
13485
 
@@ -13656,6 +13561,14 @@
13656
13561
  // SAMPLER_2D_SHADOW
13657
13562
  return setValueT1Array;
13658
13563
 
13564
+ case 0x8b5f: // SAMPLER_3D
13565
+
13566
+ case 0x8dcb: // INT_SAMPLER_3D
13567
+
13568
+ case 0x8dd3:
13569
+ // UNSIGNED_INT_SAMPLER_3D
13570
+ return setValueT3DArray;
13571
+
13659
13572
  case 0x8b60: // SAMPLER_CUBE
13660
13573
 
13661
13574
  case 0x8dcc: // INT_SAMPLER_CUBE
@@ -13665,6 +13578,16 @@
13665
13578
  case 0x8dc5:
13666
13579
  // SAMPLER_CUBE_SHADOW
13667
13580
  return setValueT6Array;
13581
+
13582
+ case 0x8dc1: // SAMPLER_2D_ARRAY
13583
+
13584
+ case 0x8dcf: // INT_SAMPLER_2D_ARRAY
13585
+
13586
+ case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY
13587
+
13588
+ case 0x8dc4:
13589
+ // SAMPLER_2D_ARRAY_SHADOW
13590
+ return setValueT2DArrayArray;
13668
13591
  }
13669
13592
  } // --- Uniform Classes ---
13670
13593
 
@@ -13832,24 +13755,6 @@
13832
13755
  case sRGBEncoding:
13833
13756
  return ['sRGB', '( value )'];
13834
13757
 
13835
- case RGBEEncoding:
13836
- return ['RGBE', '( value )'];
13837
-
13838
- case RGBM7Encoding:
13839
- return ['RGBM', '( value, 7.0 )'];
13840
-
13841
- case RGBM16Encoding:
13842
- return ['RGBM', '( value, 16.0 )'];
13843
-
13844
- case RGBDEncoding:
13845
- return ['RGBD', '( value, 256.0 )'];
13846
-
13847
- case GammaEncoding:
13848
- return ['Gamma', '( value, float( GAMMA_FACTOR ) )'];
13849
-
13850
- case LogLuvEncoding:
13851
- return ['LogLuv', '( value )'];
13852
-
13853
13758
  default:
13854
13759
  console.warn('THREE.WebGLProgram: Unsupported encoding:', encoding);
13855
13760
  return ['Linear', '( value )'];
@@ -14095,7 +14000,6 @@
14095
14000
  const envMapTypeDefine = generateEnvMapTypeDefine(parameters);
14096
14001
  const envMapModeDefine = generateEnvMapModeDefine(parameters);
14097
14002
  const envMapBlendingDefine = generateEnvMapBlendingDefine(parameters);
14098
- const gammaFactorDefine = renderer.gammaFactor > 0 ? renderer.gammaFactor : 1.0;
14099
14003
  const customExtensions = parameters.isWebGL2 ? '' : generateExtensions(parameters);
14100
14004
  const customDefines = generateDefines(defines);
14101
14005
  const program = gl.createProgram();
@@ -14115,10 +14019,10 @@
14115
14019
  prefixFragment += '\n';
14116
14020
  }
14117
14021
  } else {
14118
- prefixVertex = [generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, parameters.instancing ? '#define USE_INSTANCING' : '', parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '', parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '', '#define GAMMA_FACTOR ' + gammaFactorDefine, '#define MAX_BONES ' + parameters.maxBones, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularTintMap ? '#define USE_SPECULARTINTMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.skinning ? '#define USE_SKINNING' : '', parameters.useVertexTexture ? '#define BONE_TEXTURE' : '', parameters.morphTargets ? '#define USE_MORPHTARGETS' : '', parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '', parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_TEXTURE' : '', parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 modelMatrix;', 'uniform mat4 modelViewMatrix;', 'uniform mat4 projectionMatrix;', 'uniform mat4 viewMatrix;', 'uniform mat3 normalMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', '#ifdef USE_INSTANCING', ' attribute mat4 instanceMatrix;', '#endif', '#ifdef USE_INSTANCING_COLOR', ' attribute vec3 instanceColor;', '#endif', 'attribute vec3 position;', 'attribute vec3 normal;', 'attribute vec2 uv;', '#ifdef USE_TANGENT', ' attribute vec4 tangent;', '#endif', '#if defined( USE_COLOR_ALPHA )', ' attribute vec4 color;', '#elif defined( USE_COLOR )', ' attribute vec3 color;', '#endif', '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )', ' attribute vec3 morphTarget0;', ' attribute vec3 morphTarget1;', ' attribute vec3 morphTarget2;', ' attribute vec3 morphTarget3;', ' #ifdef USE_MORPHNORMALS', ' attribute vec3 morphNormal0;', ' attribute vec3 morphNormal1;', ' attribute vec3 morphNormal2;', ' attribute vec3 morphNormal3;', ' #else', ' attribute vec3 morphTarget4;', ' attribute vec3 morphTarget5;', ' attribute vec3 morphTarget6;', ' attribute vec3 morphTarget7;', ' #endif', '#endif', '#ifdef USE_SKINNING', ' attribute vec4 skinIndex;', ' attribute vec4 skinWeight;', '#endif', '\n'].filter(filterEmptyLine).join('\n');
14119
- prefixFragment = [customExtensions, generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, '#define GAMMA_FACTOR ' + gammaFactorDefine, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.matcap ? '#define USE_MATCAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapTypeDefine : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.envMap ? '#define ' + envMapBlendingDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoat ? '#define USE_CLEARCOAT' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularTintMap ? '#define USE_SPECULARTINTMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.alphaTest ? '#define USE_ALPHATEST' : '', parameters.sheen ? '#define USE_SHEEN' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '', parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', (parameters.extensionShaderTextureLOD || parameters.envMap) && parameters.rendererExtensionShaderTextureLod ? '#define TEXTURE_LOD_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', parameters.toneMapping !== NoToneMapping ? '#define TONE_MAPPING' : '', parameters.toneMapping !== NoToneMapping ? ShaderChunk['tonemapping_pars_fragment'] : '', // this code is required here because it is used by the toneMapping() function defined below
14022
+ prefixVertex = [generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, parameters.instancing ? '#define USE_INSTANCING' : '', parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '', parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '', '#define MAX_BONES ' + parameters.maxBones, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.skinning ? '#define USE_SKINNING' : '', parameters.useVertexTexture ? '#define BONE_TEXTURE' : '', parameters.morphTargets ? '#define USE_MORPHTARGETS' : '', parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '', parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_TEXTURE' : '', parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 modelMatrix;', 'uniform mat4 modelViewMatrix;', 'uniform mat4 projectionMatrix;', 'uniform mat4 viewMatrix;', 'uniform mat3 normalMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', '#ifdef USE_INSTANCING', ' attribute mat4 instanceMatrix;', '#endif', '#ifdef USE_INSTANCING_COLOR', ' attribute vec3 instanceColor;', '#endif', 'attribute vec3 position;', 'attribute vec3 normal;', 'attribute vec2 uv;', '#ifdef USE_TANGENT', ' attribute vec4 tangent;', '#endif', '#if defined( USE_COLOR_ALPHA )', ' attribute vec4 color;', '#elif defined( USE_COLOR )', ' attribute vec3 color;', '#endif', '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )', ' attribute vec3 morphTarget0;', ' attribute vec3 morphTarget1;', ' attribute vec3 morphTarget2;', ' attribute vec3 morphTarget3;', ' #ifdef USE_MORPHNORMALS', ' attribute vec3 morphNormal0;', ' attribute vec3 morphNormal1;', ' attribute vec3 morphNormal2;', ' attribute vec3 morphNormal3;', ' #else', ' attribute vec3 morphTarget4;', ' attribute vec3 morphTarget5;', ' attribute vec3 morphTarget6;', ' attribute vec3 morphTarget7;', ' #endif', '#endif', '#ifdef USE_SKINNING', ' attribute vec4 skinIndex;', ' attribute vec4 skinWeight;', '#endif', '\n'].filter(filterEmptyLine).join('\n');
14023
+ prefixFragment = [customExtensions, generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.matcap ? '#define USE_MATCAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapTypeDefine : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.envMap ? '#define ' + envMapBlendingDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoat ? '#define USE_CLEARCOAT' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.alphaTest ? '#define USE_ALPHATEST' : '', parameters.sheen ? '#define USE_SHEEN' : '', parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '', parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', (parameters.extensionShaderTextureLOD || parameters.envMap) && parameters.rendererExtensionShaderTextureLod ? '#define TEXTURE_LOD_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', parameters.toneMapping !== NoToneMapping ? '#define TONE_MAPPING' : '', parameters.toneMapping !== NoToneMapping ? ShaderChunk['tonemapping_pars_fragment'] : '', // this code is required here because it is used by the toneMapping() function defined below
14120
14024
  parameters.toneMapping !== NoToneMapping ? getToneMappingFunction('toneMapping', parameters.toneMapping) : '', parameters.dithering ? '#define DITHERING' : '', parameters.format === RGBFormat ? '#define OPAQUE' : '', ShaderChunk['encodings_pars_fragment'], // this code is required here because it is used by the various encoding/decoding function defined below
14121
- parameters.map ? getTexelDecodingFunction('mapTexelToLinear', parameters.mapEncoding) : '', parameters.matcap ? getTexelDecodingFunction('matcapTexelToLinear', parameters.matcapEncoding) : '', parameters.envMap ? getTexelDecodingFunction('envMapTexelToLinear', parameters.envMapEncoding) : '', parameters.emissiveMap ? getTexelDecodingFunction('emissiveMapTexelToLinear', parameters.emissiveMapEncoding) : '', parameters.specularTintMap ? getTexelDecodingFunction('specularTintMapTexelToLinear', parameters.specularTintMapEncoding) : '', parameters.lightMap ? getTexelDecodingFunction('lightMapTexelToLinear', parameters.lightMapEncoding) : '', getTexelEncodingFunction('linearToOutputTexel', parameters.outputEncoding), parameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '', '\n'].filter(filterEmptyLine).join('\n');
14025
+ parameters.map ? getTexelDecodingFunction('mapTexelToLinear', parameters.mapEncoding) : '', parameters.matcap ? getTexelDecodingFunction('matcapTexelToLinear', parameters.matcapEncoding) : '', parameters.envMap ? getTexelDecodingFunction('envMapTexelToLinear', parameters.envMapEncoding) : '', parameters.emissiveMap ? getTexelDecodingFunction('emissiveMapTexelToLinear', parameters.emissiveMapEncoding) : '', parameters.specularColorMap ? getTexelDecodingFunction('specularColorMapTexelToLinear', parameters.specularColorMapEncoding) : '', parameters.sheenColorMap ? getTexelDecodingFunction('sheenColorMapTexelToLinear', parameters.sheenColorMapEncoding) : '', parameters.lightMap ? getTexelDecodingFunction('lightMapTexelToLinear', parameters.lightMapEncoding) : '', getTexelEncodingFunction('linearToOutputTexel', parameters.outputEncoding), parameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '', '\n'].filter(filterEmptyLine).join('\n');
14122
14026
  }
14123
14027
 
14124
14028
  vertexShader = resolveIncludes(vertexShader);
@@ -14134,7 +14038,7 @@
14134
14038
  // GLSL 3.0 conversion for built-in materials and ShaderMaterial
14135
14039
  versionString = '#version 300 es\n';
14136
14040
  prefixVertex = ['precision mediump sampler2DArray;', '#define attribute in', '#define varying out', '#define texture2D texture'].join('\n') + '\n' + prefixVertex;
14137
- prefixFragment = ['#define varying in', parameters.glslVersion === GLSL3 ? '' : 'out highp vec4 pc_fragColor;', parameters.glslVersion === GLSL3 ? '' : '#define gl_FragColor pc_fragColor', '#define gl_FragDepthEXT gl_FragDepth', '#define texture2D texture', '#define textureCube texture', '#define texture2DProj textureProj', '#define texture2DLodEXT textureLod', '#define texture2DProjLodEXT textureProjLod', '#define textureCubeLodEXT textureLod', '#define texture2DGradEXT textureGrad', '#define texture2DProjGradEXT textureProjGrad', '#define textureCubeGradEXT textureGrad'].join('\n') + '\n' + prefixFragment;
14041
+ prefixFragment = ['#define varying in', parameters.glslVersion === GLSL3 ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;', parameters.glslVersion === GLSL3 ? '' : '#define gl_FragColor pc_fragColor', '#define gl_FragDepthEXT gl_FragDepth', '#define texture2D texture', '#define textureCube texture', '#define texture2DProj textureProj', '#define texture2DLodEXT textureLod', '#define texture2DProjLodEXT textureProjLod', '#define textureCubeLodEXT textureLod', '#define texture2DGradEXT textureGrad', '#define texture2DProjGradEXT textureProjGrad', '#define textureCubeGradEXT textureGrad'].join('\n') + '\n' + prefixFragment;
14138
14042
  }
14139
14043
 
14140
14044
  const vertexGlsl = versionString + prefixVertex + vertexShader;
@@ -14235,7 +14139,98 @@
14235
14139
  return this;
14236
14140
  }
14237
14141
 
14142
+ let _id = 0;
14143
+
14144
+ class WebGLShaderCache {
14145
+ constructor() {
14146
+ this.shaderCache = new Map();
14147
+ this.materialCache = new Map();
14148
+ }
14149
+
14150
+ update(material) {
14151
+ const vertexShader = material.vertexShader;
14152
+ const fragmentShader = material.fragmentShader;
14153
+
14154
+ const vertexShaderStage = this._getShaderStage(vertexShader);
14155
+
14156
+ const fragmentShaderStage = this._getShaderStage(fragmentShader);
14157
+
14158
+ const materialShaders = this._getShaderCacheForMaterial(material);
14159
+
14160
+ if (materialShaders.has(vertexShaderStage) === false) {
14161
+ materialShaders.add(vertexShaderStage);
14162
+ vertexShaderStage.usedTimes++;
14163
+ }
14164
+
14165
+ if (materialShaders.has(fragmentShaderStage) === false) {
14166
+ materialShaders.add(fragmentShaderStage);
14167
+ fragmentShaderStage.usedTimes++;
14168
+ }
14169
+
14170
+ return this;
14171
+ }
14172
+
14173
+ remove(material) {
14174
+ const materialShaders = this.materialCache.get(material);
14175
+
14176
+ for (const shaderStage of materialShaders) {
14177
+ shaderStage.usedTimes--;
14178
+ if (shaderStage.usedTimes === 0) this.shaderCache.delete(shaderStage);
14179
+ }
14180
+
14181
+ this.materialCache.delete(material);
14182
+ return this;
14183
+ }
14184
+
14185
+ getVertexShaderID(material) {
14186
+ return this._getShaderStage(material.vertexShader).id;
14187
+ }
14188
+
14189
+ getFragmentShaderID(material) {
14190
+ return this._getShaderStage(material.fragmentShader).id;
14191
+ }
14192
+
14193
+ dispose() {
14194
+ this.shaderCache.clear();
14195
+ this.materialCache.clear();
14196
+ }
14197
+
14198
+ _getShaderCacheForMaterial(material) {
14199
+ const cache = this.materialCache;
14200
+
14201
+ if (cache.has(material) === false) {
14202
+ cache.set(material, new Set());
14203
+ }
14204
+
14205
+ return cache.get(material);
14206
+ }
14207
+
14208
+ _getShaderStage(code) {
14209
+ const cache = this.shaderCache;
14210
+
14211
+ if (cache.has(code) === false) {
14212
+ const stage = new WebGLShaderStage();
14213
+ cache.set(code, stage);
14214
+ }
14215
+
14216
+ return cache.get(code);
14217
+ }
14218
+
14219
+ }
14220
+
14221
+ class WebGLShaderStage {
14222
+ constructor() {
14223
+ this.id = _id++;
14224
+ this.usedTimes = 0;
14225
+ }
14226
+
14227
+ }
14228
+
14238
14229
  function WebGLPrograms(renderer, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping) {
14230
+ const _programLayers = new Layers();
14231
+
14232
+ const _customShaders = new WebGLShaderCache();
14233
+
14239
14234
  const programs = [];
14240
14235
  const isWebGL2 = capabilities.isWebGL2;
14241
14236
  const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
@@ -14260,7 +14255,6 @@
14260
14255
  ShadowMaterial: 'shadow',
14261
14256
  SpriteMaterial: 'sprite'
14262
14257
  };
14263
- const parameterNames = ['precision', 'isWebGL2', 'supportsVertexTextures', 'outputEncoding', 'instancing', 'instancingColor', 'map', 'mapEncoding', 'matcap', 'matcapEncoding', 'envMap', 'envMapMode', 'envMapEncoding', 'envMapCubeUV', 'lightMap', 'lightMapEncoding', 'aoMap', 'emissiveMap', 'emissiveMapEncoding', 'bumpMap', 'normalMap', 'objectSpaceNormalMap', 'tangentSpaceNormalMap', 'clearcoat', 'clearcoatMap', 'clearcoatRoughnessMap', 'clearcoatNormalMap', 'displacementMap', 'specularMap', 'specularIntensityMap', 'specularTintMap', 'specularTintMapEncoding', 'roughnessMap', 'metalnessMap', 'gradientMap', 'alphaMap', 'alphaTest', 'combine', 'vertexColors', 'vertexAlphas', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2', 'flatShading', 'sizeAttenuation', 'logarithmicDepthBuffer', 'skinning', 'maxBones', 'useVertexTexture', 'morphTargets', 'morphNormals', 'morphTargetsCount', 'premultipliedAlpha', 'numDirLights', 'numPointLights', 'numSpotLights', 'numHemiLights', 'numRectAreaLights', 'numDirLightShadows', 'numPointLightShadows', 'numSpotLightShadows', 'shadowMapEnabled', 'shadowMapType', 'toneMapping', 'physicallyCorrectLights', 'doubleSided', 'flipSided', 'numClippingPlanes', 'numClipIntersection', 'depthPacking', 'dithering', 'format', 'sheen', 'transmission', 'transmissionMap', 'thicknessMap'];
14264
14258
 
14265
14259
  function getMaxBones(object) {
14266
14260
  const skeleton = object.skeleton;
@@ -14325,6 +14319,7 @@
14325
14319
  }
14326
14320
 
14327
14321
  let vertexShader, fragmentShader;
14322
+ let customVertexShaderID, customFragmentShaderID;
14328
14323
 
14329
14324
  if (shaderID) {
14330
14325
  const shader = ShaderLib[shaderID];
@@ -14333,6 +14328,11 @@
14333
14328
  } else {
14334
14329
  vertexShader = material.vertexShader;
14335
14330
  fragmentShader = material.fragmentShader;
14331
+
14332
+ _customShaders.update(material);
14333
+
14334
+ customVertexShaderID = _customShaders.getVertexShaderID(material);
14335
+ customFragmentShaderID = _customShaders.getFragmentShaderID(material);
14336
14336
  }
14337
14337
 
14338
14338
  const currentRenderTarget = renderer.getRenderTarget();
@@ -14345,6 +14345,8 @@
14345
14345
  vertexShader: vertexShader,
14346
14346
  fragmentShader: fragmentShader,
14347
14347
  defines: material.defines,
14348
+ customVertexShaderID: customVertexShaderID,
14349
+ customFragmentShaderID: customFragmentShaderID,
14348
14350
  isRawShaderMaterial: material.isRawShaderMaterial === true,
14349
14351
  glslVersion: material.glslVersion,
14350
14352
  precision: precision,
@@ -14378,12 +14380,15 @@
14378
14380
  metalnessMap: !!material.metalnessMap,
14379
14381
  specularMap: !!material.specularMap,
14380
14382
  specularIntensityMap: !!material.specularIntensityMap,
14381
- specularTintMap: !!material.specularTintMap,
14382
- specularTintMapEncoding: getTextureEncodingFromMap(material.specularTintMap),
14383
+ specularColorMap: !!material.specularColorMap,
14384
+ specularColorMapEncoding: getTextureEncodingFromMap(material.specularColorMap),
14383
14385
  alphaMap: !!material.alphaMap,
14384
14386
  alphaTest: useAlphaTest,
14385
14387
  gradientMap: !!material.gradientMap,
14386
14388
  sheen: material.sheen > 0,
14389
+ sheenColorMap: !!material.sheenColorMap,
14390
+ sheenColorMapEncoding: getTextureEncodingFromMap(material.sheenColorMap),
14391
+ sheenRoughnessMap: !!material.sheenRoughnessMap,
14387
14392
  transmission: material.transmission > 0,
14388
14393
  transmissionMap: !!material.transmissionMap,
14389
14394
  thicknessMap: !!material.thicknessMap,
@@ -14391,8 +14396,8 @@
14391
14396
  vertexTangents: !!material.normalMap && !!object.geometry && !!object.geometry.attributes.tangent,
14392
14397
  vertexColors: material.vertexColors,
14393
14398
  vertexAlphas: material.vertexColors === true && !!object.geometry && !!object.geometry.attributes.color && object.geometry.attributes.color.itemSize === 4,
14394
- 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,
14395
- 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,
14399
+ 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,
14400
+ 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,
14396
14401
  fog: !!fog,
14397
14402
  useFog: material.fog,
14398
14403
  fogExp2: fog && fog.isFogExp2,
@@ -14444,8 +14449,8 @@
14444
14449
  if (parameters.shaderID) {
14445
14450
  array.push(parameters.shaderID);
14446
14451
  } else {
14447
- array.push(parameters.fragmentShader);
14448
- array.push(parameters.vertexShader);
14452
+ array.push(parameters.customVertexShaderID);
14453
+ array.push(parameters.customFragmentShaderID);
14449
14454
  }
14450
14455
 
14451
14456
  if (parameters.defines !== undefined) {
@@ -14456,18 +14461,111 @@
14456
14461
  }
14457
14462
 
14458
14463
  if (parameters.isRawShaderMaterial === false) {
14459
- for (let i = 0; i < parameterNames.length; i++) {
14460
- array.push(parameters[parameterNames[i]]);
14461
- }
14462
-
14464
+ getProgramCacheKeyParameters(array, parameters);
14465
+ getProgramCacheKeyBooleans(array, parameters);
14463
14466
  array.push(renderer.outputEncoding);
14464
- array.push(renderer.gammaFactor);
14465
14467
  }
14466
14468
 
14467
14469
  array.push(parameters.customProgramCacheKey);
14468
14470
  return array.join();
14469
14471
  }
14470
14472
 
14473
+ function getProgramCacheKeyParameters(array, parameters) {
14474
+ array.push(parameters.precision);
14475
+ array.push(parameters.outputEncoding);
14476
+ array.push(parameters.mapEncoding);
14477
+ array.push(parameters.matcapEncoding);
14478
+ array.push(parameters.envMapMode);
14479
+ array.push(parameters.envMapEncoding);
14480
+ array.push(parameters.lightMapEncoding);
14481
+ array.push(parameters.emissiveMapEncoding);
14482
+ array.push(parameters.combine);
14483
+ array.push(parameters.vertexUvs);
14484
+ array.push(parameters.fogExp2);
14485
+ array.push(parameters.sizeAttenuation);
14486
+ array.push(parameters.maxBones);
14487
+ array.push(parameters.morphTargetsCount);
14488
+ array.push(parameters.numDirLights);
14489
+ array.push(parameters.numPointLights);
14490
+ array.push(parameters.numSpotLights);
14491
+ array.push(parameters.numHemiLights);
14492
+ array.push(parameters.numRectAreaLights);
14493
+ array.push(parameters.numDirLightShadows);
14494
+ array.push(parameters.numPointLightShadows);
14495
+ array.push(parameters.numSpotLightShadows);
14496
+ array.push(parameters.shadowMapType);
14497
+ array.push(parameters.toneMapping);
14498
+ array.push(parameters.numClippingPlanes);
14499
+ array.push(parameters.numClipIntersection);
14500
+ array.push(parameters.format);
14501
+ array.push(parameters.specularColorMapEncoding);
14502
+ array.push(parameters.sheenColorMapEncoding);
14503
+ }
14504
+
14505
+ function getProgramCacheKeyBooleans(array, parameters) {
14506
+ _programLayers.disableAll();
14507
+
14508
+ if (parameters.isWebGL2) _programLayers.enable(0);
14509
+ if (parameters.supportsVertexTextures) _programLayers.enable(1);
14510
+ if (parameters.instancing) _programLayers.enable(2);
14511
+ if (parameters.instancingColor) _programLayers.enable(3);
14512
+ if (parameters.map) _programLayers.enable(4);
14513
+ if (parameters.matcap) _programLayers.enable(5);
14514
+ if (parameters.envMap) _programLayers.enable(6);
14515
+ if (parameters.envMapCubeUV) _programLayers.enable(7);
14516
+ if (parameters.lightMap) _programLayers.enable(8);
14517
+ if (parameters.aoMap) _programLayers.enable(9);
14518
+ if (parameters.emissiveMap) _programLayers.enable(10);
14519
+ if (parameters.bumpMap) _programLayers.enable(11);
14520
+ if (parameters.normalMap) _programLayers.enable(12);
14521
+ if (parameters.objectSpaceNormalMap) _programLayers.enable(13);
14522
+ if (parameters.tangentSpaceNormalMap) _programLayers.enable(14);
14523
+ if (parameters.clearcoat) _programLayers.enable(15);
14524
+ if (parameters.clearcoatMap) _programLayers.enable(16);
14525
+ if (parameters.clearcoatRoughnessMap) _programLayers.enable(17);
14526
+ if (parameters.clearcoatNormalMap) _programLayers.enable(18);
14527
+ if (parameters.displacementMap) _programLayers.enable(19);
14528
+ if (parameters.specularMap) _programLayers.enable(20);
14529
+ if (parameters.roughnessMap) _programLayers.enable(21);
14530
+ if (parameters.metalnessMap) _programLayers.enable(22);
14531
+ if (parameters.gradientMap) _programLayers.enable(23);
14532
+ if (parameters.alphaMap) _programLayers.enable(24);
14533
+ if (parameters.alphaTest) _programLayers.enable(25);
14534
+ if (parameters.vertexColors) _programLayers.enable(26);
14535
+ if (parameters.vertexAlphas) _programLayers.enable(27);
14536
+ if (parameters.vertexUvs) _programLayers.enable(28);
14537
+ if (parameters.vertexTangents) _programLayers.enable(29);
14538
+ if (parameters.uvsVertexOnly) _programLayers.enable(30);
14539
+ if (parameters.fog) _programLayers.enable(31);
14540
+ array.push(_programLayers.mask);
14541
+
14542
+ _programLayers.disableAll();
14543
+
14544
+ if (parameters.useFog) _programLayers.enable(0);
14545
+ if (parameters.flatShading) _programLayers.enable(1);
14546
+ if (parameters.logarithmicDepthBuffer) _programLayers.enable(2);
14547
+ if (parameters.skinning) _programLayers.enable(3);
14548
+ if (parameters.useVertexTexture) _programLayers.enable(4);
14549
+ if (parameters.morphTargets) _programLayers.enable(5);
14550
+ if (parameters.morphNormals) _programLayers.enable(6);
14551
+ if (parameters.premultipliedAlpha) _programLayers.enable(7);
14552
+ if (parameters.shadowMapEnabled) _programLayers.enable(8);
14553
+ if (parameters.physicallyCorrectLights) _programLayers.enable(9);
14554
+ if (parameters.doubleSided) _programLayers.enable(10);
14555
+ if (parameters.flipSided) _programLayers.enable(11);
14556
+ if (parameters.depthPacking) _programLayers.enable(12);
14557
+ if (parameters.dithering) _programLayers.enable(13);
14558
+ if (parameters.specularIntensityMap) _programLayers.enable(14);
14559
+ if (parameters.specularColorMap) _programLayers.enable(15);
14560
+ if (parameters.transmission) _programLayers.enable(16);
14561
+ if (parameters.transmissionMap) _programLayers.enable(17);
14562
+ if (parameters.thicknessMap) _programLayers.enable(18);
14563
+ if (parameters.sheen) _programLayers.enable(19);
14564
+ if (parameters.sheenColorMap) _programLayers.enable(20);
14565
+ if (parameters.sheenRoughnessMap) _programLayers.enable(21);
14566
+ array.push(_programLayers.mask);
14567
+ }
14568
+
14471
14569
  function getUniforms(material) {
14472
14570
  const shaderID = shaderIDs[material.type];
14473
14571
  let uniforms;
@@ -14514,14 +14612,24 @@
14514
14612
  }
14515
14613
  }
14516
14614
 
14615
+ function releaseShaderCache(material) {
14616
+ _customShaders.remove(material);
14617
+ }
14618
+
14619
+ function dispose() {
14620
+ _customShaders.dispose();
14621
+ }
14622
+
14517
14623
  return {
14518
14624
  getParameters: getParameters,
14519
14625
  getProgramCacheKey: getProgramCacheKey,
14520
14626
  getUniforms: getUniforms,
14521
14627
  acquireProgram: acquireProgram,
14522
14628
  releaseProgram: releaseProgram,
14629
+ releaseShaderCache: releaseShaderCache,
14523
14630
  // Exposed for resource monitoring & error feedback via renderer.info:
14524
- programs: programs
14631
+ programs: programs,
14632
+ dispose: dispose
14525
14633
  };
14526
14634
  }
14527
14635
 
@@ -14564,8 +14672,6 @@
14564
14672
  return a.groupOrder - b.groupOrder;
14565
14673
  } else if (a.renderOrder !== b.renderOrder) {
14566
14674
  return a.renderOrder - b.renderOrder;
14567
- } else if (a.program !== b.program) {
14568
- return a.program.id - b.program.id;
14569
14675
  } else if (a.material.id !== b.material.id) {
14570
14676
  return a.material.id - b.material.id;
14571
14677
  } else if (a.z !== b.z) {
@@ -14587,15 +14693,12 @@
14587
14693
  }
14588
14694
  }
14589
14695
 
14590
- function WebGLRenderList(properties) {
14696
+ function WebGLRenderList() {
14591
14697
  const renderItems = [];
14592
14698
  let renderItemsIndex = 0;
14593
14699
  const opaque = [];
14594
14700
  const transmissive = [];
14595
14701
  const transparent = [];
14596
- const defaultProgram = {
14597
- id: -1
14598
- };
14599
14702
 
14600
14703
  function init() {
14601
14704
  renderItemsIndex = 0;
@@ -14606,7 +14709,6 @@
14606
14709
 
14607
14710
  function getNextRenderItem(object, geometry, material, groupOrder, z, group) {
14608
14711
  let renderItem = renderItems[renderItemsIndex];
14609
- const materialProperties = properties.get(material);
14610
14712
 
14611
14713
  if (renderItem === undefined) {
14612
14714
  renderItem = {
@@ -14614,7 +14716,6 @@
14614
14716
  object: object,
14615
14717
  geometry: geometry,
14616
14718
  material: material,
14617
- program: materialProperties.program || defaultProgram,
14618
14719
  groupOrder: groupOrder,
14619
14720
  renderOrder: object.renderOrder,
14620
14721
  z: z,
@@ -14626,7 +14727,6 @@
14626
14727
  renderItem.object = object;
14627
14728
  renderItem.geometry = geometry;
14628
14729
  renderItem.material = material;
14629
- renderItem.program = materialProperties.program || defaultProgram;
14630
14730
  renderItem.groupOrder = groupOrder;
14631
14731
  renderItem.renderOrder = object.renderOrder;
14632
14732
  renderItem.z = z;
@@ -14676,7 +14776,6 @@
14676
14776
  renderItem.object = null;
14677
14777
  renderItem.geometry = null;
14678
14778
  renderItem.material = null;
14679
- renderItem.program = null;
14680
14779
  renderItem.group = null;
14681
14780
  }
14682
14781
  }
@@ -14693,18 +14792,18 @@
14693
14792
  };
14694
14793
  }
14695
14794
 
14696
- function WebGLRenderLists(properties) {
14795
+ function WebGLRenderLists() {
14697
14796
  let lists = new WeakMap();
14698
14797
 
14699
14798
  function get(scene, renderCallDepth) {
14700
14799
  let list;
14701
14800
 
14702
14801
  if (lists.has(scene) === false) {
14703
- list = new WebGLRenderList(properties);
14802
+ list = new WebGLRenderList();
14704
14803
  lists.set(scene, [list]);
14705
14804
  } else {
14706
14805
  if (renderCallDepth >= lists.get(scene).length) {
14707
- list = new WebGLRenderList(properties);
14806
+ list = new WebGLRenderList();
14708
14807
  lists.get(scene).push(list);
14709
14808
  } else {
14710
14809
  list = lists.get(scene)[renderCallDepth];
@@ -15290,7 +15389,7 @@
15290
15389
  MeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;
15291
15390
 
15292
15391
  const vertex = "void main() {\n\tgl_Position = vec4( position, 1.0 );\n}";
15293
- 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}";
15392
+ 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}";
15294
15393
 
15295
15394
  function WebGLShadowMap(_renderer, _objects, _capabilities) {
15296
15395
  let _frustum = new Frustum();
@@ -15311,6 +15410,9 @@
15311
15410
  2: DoubleSide
15312
15411
  };
15313
15412
  const shadowMaterialVertical = new ShaderMaterial({
15413
+ defines: {
15414
+ VSM_SAMPLES: 8
15415
+ },
15314
15416
  uniforms: {
15315
15417
  shadow_pass: {
15316
15418
  value: null
@@ -15320,9 +15422,6 @@
15320
15422
  },
15321
15423
  radius: {
15322
15424
  value: 4.0
15323
- },
15324
- samples: {
15325
- value: 8.0
15326
15425
  }
15327
15426
  },
15328
15427
  vertexShader: vertex,
@@ -15449,13 +15548,19 @@
15449
15548
  };
15450
15549
 
15451
15550
  function VSMPass(shadow, camera) {
15452
- const geometry = _objects.update(fullScreenMesh); // vertical pass
15551
+ const geometry = _objects.update(fullScreenMesh);
15552
+
15553
+ if (shadowMaterialVertical.defines.VSM_SAMPLES !== shadow.blurSamples) {
15554
+ shadowMaterialVertical.defines.VSM_SAMPLES = shadow.blurSamples;
15555
+ shadowMaterialHorizontal.defines.VSM_SAMPLES = shadow.blurSamples;
15556
+ shadowMaterialVertical.needsUpdate = true;
15557
+ shadowMaterialHorizontal.needsUpdate = true;
15558
+ } // vertical pass
15453
15559
 
15454
15560
 
15455
15561
  shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;
15456
15562
  shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;
15457
15563
  shadowMaterialVertical.uniforms.radius.value = shadow.radius;
15458
- shadowMaterialVertical.uniforms.samples.value = shadow.blurSamples;
15459
15564
 
15460
15565
  _renderer.setRenderTarget(shadow.mapPass);
15461
15566
 
@@ -15467,7 +15572,6 @@
15467
15572
  shadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture;
15468
15573
  shadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize;
15469
15574
  shadowMaterialHorizontal.uniforms.radius.value = shadow.radius;
15470
- shadowMaterialHorizontal.uniforms.samples.value = shadow.blurSamples;
15471
15575
 
15472
15576
  _renderer.setRenderTarget(shadow.map);
15473
15577
 
@@ -15771,7 +15875,6 @@
15771
15875
  const depthBuffer = new DepthBuffer();
15772
15876
  const stencilBuffer = new StencilBuffer();
15773
15877
  let enabledCapabilities = {};
15774
- let xrFramebuffer = null;
15775
15878
  let currentBoundFramebuffers = {};
15776
15879
  let currentProgram = null;
15777
15880
  let currentBlendingEnabled = false;
@@ -15851,16 +15954,7 @@
15851
15954
  }
15852
15955
  }
15853
15956
 
15854
- function bindXRFramebuffer(framebuffer) {
15855
- if (framebuffer !== xrFramebuffer) {
15856
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
15857
- xrFramebuffer = framebuffer;
15858
- }
15859
- }
15860
-
15861
15957
  function bindFramebuffer(target, framebuffer) {
15862
- if (framebuffer === null && xrFramebuffer !== null) framebuffer = xrFramebuffer; // use active XR framebuffer if available
15863
-
15864
15958
  if (currentBoundFramebuffers[target] !== framebuffer) {
15865
15959
  gl.bindFramebuffer(target, framebuffer);
15866
15960
  currentBoundFramebuffers[target] = framebuffer;
@@ -16162,6 +16256,46 @@
16162
16256
  }
16163
16257
  }
16164
16258
 
16259
+ function texSubImage2D() {
16260
+ try {
16261
+ gl.texSubImage2D.apply(gl, arguments);
16262
+ } catch (error) {
16263
+ console.error('THREE.WebGLState:', error);
16264
+ }
16265
+ }
16266
+
16267
+ function texSubImage3D() {
16268
+ try {
16269
+ gl.texSubImage3D.apply(gl, arguments);
16270
+ } catch (error) {
16271
+ console.error('THREE.WebGLState:', error);
16272
+ }
16273
+ }
16274
+
16275
+ function compressedTexSubImage2D() {
16276
+ try {
16277
+ gl.compressedTexSubImage2D.apply(gl, arguments);
16278
+ } catch (error) {
16279
+ console.error('THREE.WebGLState:', error);
16280
+ }
16281
+ }
16282
+
16283
+ function texStorage2D() {
16284
+ try {
16285
+ gl.texStorage2D.apply(gl, arguments);
16286
+ } catch (error) {
16287
+ console.error('THREE.WebGLState:', error);
16288
+ }
16289
+ }
16290
+
16291
+ function texStorage3D() {
16292
+ try {
16293
+ gl.texStorage3D.apply(gl, arguments);
16294
+ } catch (error) {
16295
+ console.error('THREE.WebGLState:', error);
16296
+ }
16297
+ }
16298
+
16165
16299
  function texImage2D() {
16166
16300
  try {
16167
16301
  gl.texImage2D.apply(gl, arguments);
@@ -16234,7 +16368,6 @@
16234
16368
  enabledCapabilities = {};
16235
16369
  currentTextureSlot = null;
16236
16370
  currentBoundTextures = {};
16237
- xrFramebuffer = null;
16238
16371
  currentBoundFramebuffers = {};
16239
16372
  currentProgram = null;
16240
16373
  currentBlendingEnabled = false;
@@ -16267,7 +16400,6 @@
16267
16400
  enable: enable,
16268
16401
  disable: disable,
16269
16402
  bindFramebuffer: bindFramebuffer,
16270
- bindXRFramebuffer: bindXRFramebuffer,
16271
16403
  useProgram: useProgram,
16272
16404
  setBlending: setBlending,
16273
16405
  setMaterial: setMaterial,
@@ -16282,6 +16414,11 @@
16282
16414
  compressedTexImage2D: compressedTexImage2D,
16283
16415
  texImage2D: texImage2D,
16284
16416
  texImage3D: texImage3D,
16417
+ texStorage2D: texStorage2D,
16418
+ texStorage3D: texStorage3D,
16419
+ texSubImage2D: texSubImage2D,
16420
+ texSubImage3D: texSubImage3D,
16421
+ compressedTexSubImage2D: compressedTexSubImage2D,
16285
16422
  scissor: scissor,
16286
16423
  viewport: viewport,
16287
16424
  reset: reset
@@ -16294,6 +16431,8 @@
16294
16431
  const maxCubemapSize = capabilities.maxCubemapSize;
16295
16432
  const maxTextureSize = capabilities.maxTextureSize;
16296
16433
  const maxSamples = capabilities.maxSamples;
16434
+ const hasMultisampledRenderToTexture = extensions.has('WEBGL_multisampled_render_to_texture');
16435
+ const MultisampledRenderToTextureExtension = hasMultisampledRenderToTexture ? extensions.get('WEBGL_multisampled_render_to_texture') : undefined;
16297
16436
 
16298
16437
  const _videoTextures = new WeakMap();
16299
16438
 
@@ -16362,11 +16501,8 @@
16362
16501
  return texture.generateMipmaps && supportsMips && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
16363
16502
  }
16364
16503
 
16365
- function generateMipmap(target, texture, width, height, depth = 1) {
16504
+ function generateMipmap(target) {
16366
16505
  _gl.generateMipmap(target);
16367
-
16368
- const textureProperties = properties.get(texture);
16369
- textureProperties.__maxMipLevel = Math.log2(Math.max(width, height, depth));
16370
16506
  }
16371
16507
 
16372
16508
  function getInternalFormat(internalFormatName, glFormat, glType, encoding) {
@@ -16402,6 +16538,20 @@
16402
16538
  }
16403
16539
 
16404
16540
  return internalFormat;
16541
+ }
16542
+
16543
+ function getMipLevels(texture, image, supportsMips) {
16544
+ if (textureNeedsGenerateMipmaps(texture, supportsMips) === true || texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter) {
16545
+ return Math.log2(Math.max(image.width, image.height)) + 1;
16546
+ } else if (texture.mipmaps !== undefined && texture.mipmaps.length > 0) {
16547
+ // user-defined mipmaps
16548
+ return texture.mipmaps.length;
16549
+ } else if (texture.isCompressedTexture && Array.isArray(texture.image)) {
16550
+ return image.mipmaps.length;
16551
+ } else {
16552
+ // texture without mipmaps (only base level)
16553
+ return 1;
16554
+ }
16405
16555
  } // Fallback filters for non-power-of-2 textures
16406
16556
 
16407
16557
 
@@ -16664,6 +16814,9 @@
16664
16814
  setTextureParameters(textureType, texture, supportsMips);
16665
16815
  let mipmap;
16666
16816
  const mipmaps = texture.mipmaps;
16817
+ const useTexStorage = isWebGL2 && texture.isVideoTexture !== true;
16818
+ const allocateMemory = textureProperties.__version === undefined;
16819
+ const levels = getMipLevels(texture, image, supportsMips);
16667
16820
 
16668
16821
  if (texture.isDepthTexture) {
16669
16822
  // populate depth texture with dummy data
@@ -16712,66 +16865,130 @@
16712
16865
  } //
16713
16866
 
16714
16867
 
16715
- state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
16868
+ if (useTexStorage && allocateMemory) {
16869
+ state.texStorage2D(_gl.TEXTURE_2D, 1, glInternalFormat, image.width, image.height);
16870
+ } else {
16871
+ state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
16872
+ }
16716
16873
  } else if (texture.isDataTexture) {
16717
16874
  // use manually created mipmaps if available
16718
16875
  // if there are no manual mipmaps
16719
16876
  // set 0 level mipmap and then use GL to generate other mipmap levels
16720
16877
  if (mipmaps.length > 0 && supportsMips) {
16878
+ if (useTexStorage && allocateMemory) {
16879
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
16880
+ }
16881
+
16721
16882
  for (let i = 0, il = mipmaps.length; i < il; i++) {
16722
16883
  mipmap = mipmaps[i];
16723
- state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
16884
+
16885
+ if (useTexStorage) {
16886
+ state.texSubImage2D(_gl.TEXTURE_2D, 0, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);
16887
+ } else {
16888
+ state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
16889
+ }
16724
16890
  }
16725
16891
 
16726
16892
  texture.generateMipmaps = false;
16727
- textureProperties.__maxMipLevel = mipmaps.length - 1;
16728
16893
  } else {
16729
- state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data);
16730
- textureProperties.__maxMipLevel = 0;
16894
+ if (useTexStorage) {
16895
+ if (allocateMemory) {
16896
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);
16897
+ }
16898
+
16899
+ state.texSubImage2D(_gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, glFormat, glType, image.data);
16900
+ } else {
16901
+ state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data);
16902
+ }
16731
16903
  }
16732
16904
  } else if (texture.isCompressedTexture) {
16905
+ if (useTexStorage && allocateMemory) {
16906
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
16907
+ }
16908
+
16733
16909
  for (let i = 0, il = mipmaps.length; i < il; i++) {
16734
16910
  mipmap = mipmaps[i];
16735
16911
 
16736
16912
  if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
16737
16913
  if (glFormat !== null) {
16738
- state.compressedTexImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
16914
+ if (useTexStorage) {
16915
+ state.compressedTexSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data);
16916
+ } else {
16917
+ state.compressedTexImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
16918
+ }
16739
16919
  } else {
16740
16920
  console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()');
16741
16921
  }
16742
16922
  } else {
16743
- state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
16923
+ if (useTexStorage) {
16924
+ state.texSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);
16925
+ } else {
16926
+ state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
16927
+ }
16744
16928
  }
16745
16929
  }
16746
-
16747
- textureProperties.__maxMipLevel = mipmaps.length - 1;
16748
16930
  } else if (texture.isDataTexture2DArray) {
16749
- state.texImage3D(_gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
16750
- textureProperties.__maxMipLevel = 0;
16931
+ if (useTexStorage) {
16932
+ if (allocateMemory) {
16933
+ state.texStorage3D(_gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, image.width, image.height, image.depth);
16934
+ }
16935
+
16936
+ state.texSubImage3D(_gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data);
16937
+ } else {
16938
+ state.texImage3D(_gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
16939
+ }
16751
16940
  } else if (texture.isDataTexture3D) {
16752
- state.texImage3D(_gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
16753
- textureProperties.__maxMipLevel = 0;
16941
+ if (useTexStorage) {
16942
+ if (allocateMemory) {
16943
+ state.texStorage3D(_gl.TEXTURE_3D, levels, glInternalFormat, image.width, image.height, image.depth);
16944
+ }
16945
+
16946
+ state.texSubImage3D(_gl.TEXTURE_3D, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data);
16947
+ } else {
16948
+ state.texImage3D(_gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
16949
+ }
16950
+ } else if (texture.isFramebufferTexture) {
16951
+ if (useTexStorage && allocateMemory) {
16952
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);
16953
+ } else {
16954
+ state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
16955
+ }
16754
16956
  } else {
16755
16957
  // regular Texture (image, video, canvas)
16756
16958
  // use manually created mipmaps if available
16757
16959
  // if there are no manual mipmaps
16758
16960
  // set 0 level mipmap and then use GL to generate other mipmap levels
16759
16961
  if (mipmaps.length > 0 && supportsMips) {
16962
+ if (useTexStorage && allocateMemory) {
16963
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
16964
+ }
16965
+
16760
16966
  for (let i = 0, il = mipmaps.length; i < il; i++) {
16761
16967
  mipmap = mipmaps[i];
16762
- state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, glFormat, glType, mipmap);
16968
+
16969
+ if (useTexStorage) {
16970
+ state.texSubImage2D(_gl.TEXTURE_2D, i, 0, 0, glFormat, glType, mipmap);
16971
+ } else {
16972
+ state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, glFormat, glType, mipmap);
16973
+ }
16763
16974
  }
16764
16975
 
16765
16976
  texture.generateMipmaps = false;
16766
- textureProperties.__maxMipLevel = mipmaps.length - 1;
16767
16977
  } else {
16768
- state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, glFormat, glType, image);
16769
- textureProperties.__maxMipLevel = 0;
16978
+ if (useTexStorage) {
16979
+ if (allocateMemory) {
16980
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);
16981
+ }
16982
+
16983
+ state.texSubImage2D(_gl.TEXTURE_2D, 0, 0, 0, glFormat, glType, image);
16984
+ } else {
16985
+ state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, glFormat, glType, image);
16986
+ }
16770
16987
  }
16771
16988
  }
16772
16989
 
16773
16990
  if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
16774
- generateMipmap(textureType, texture, image.width, image.height);
16991
+ generateMipmap(textureType);
16775
16992
  }
16776
16993
 
16777
16994
  textureProperties.__version = texture.version;
@@ -16809,10 +17026,17 @@
16809
17026
  glFormat = utils.convert(texture.format),
16810
17027
  glType = utils.convert(texture.type),
16811
17028
  glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
17029
+ const useTexStorage = isWebGL2 && texture.isVideoTexture !== true;
17030
+ const allocateMemory = textureProperties.__version === undefined;
17031
+ let levels = getMipLevels(texture, image, supportsMips);
16812
17032
  setTextureParameters(_gl.TEXTURE_CUBE_MAP, texture, supportsMips);
16813
17033
  let mipmaps;
16814
17034
 
16815
17035
  if (isCompressed) {
17036
+ if (useTexStorage && allocateMemory) {
17037
+ state.texStorage2D(_gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, image.width, image.height);
17038
+ }
17039
+
16816
17040
  for (let i = 0; i < 6; i++) {
16817
17041
  mipmaps = cubeImage[i].mipmaps;
16818
17042
 
@@ -16821,45 +17045,75 @@
16821
17045
 
16822
17046
  if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
16823
17047
  if (glFormat !== null) {
16824
- state.compressedTexImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
17048
+ if (useTexStorage) {
17049
+ state.compressedTexSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data);
17050
+ } else {
17051
+ state.compressedTexImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
17052
+ }
16825
17053
  } else {
16826
17054
  console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()');
16827
17055
  }
16828
17056
  } else {
16829
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
17057
+ if (useTexStorage) {
17058
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);
17059
+ } else {
17060
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
17061
+ }
16830
17062
  }
16831
17063
  }
16832
17064
  }
16833
-
16834
- textureProperties.__maxMipLevel = mipmaps.length - 1;
16835
17065
  } else {
16836
17066
  mipmaps = texture.mipmaps;
16837
17067
 
17068
+ if (useTexStorage && allocateMemory) {
17069
+ // TODO: Uniformly handle mipmap definitions
17070
+ // Normal textures and compressed cube textures define base level + mips with their mipmap array
17071
+ // Uncompressed cube textures use their mipmap array only for mips (no base level)
17072
+ if (mipmaps.length > 0) levels++;
17073
+ state.texStorage2D(_gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, cubeImage[0].width, cubeImage[0].height);
17074
+ }
17075
+
16838
17076
  for (let i = 0; i < 6; i++) {
16839
17077
  if (isDataTexture) {
16840
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[i].width, cubeImage[i].height, 0, glFormat, glType, cubeImage[i].data);
17078
+ if (useTexStorage) {
17079
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, cubeImage[i].width, cubeImage[i].height, glFormat, glType, cubeImage[i].data);
17080
+ } else {
17081
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[i].width, cubeImage[i].height, 0, glFormat, glType, cubeImage[i].data);
17082
+ }
16841
17083
 
16842
17084
  for (let j = 0; j < mipmaps.length; j++) {
16843
17085
  const mipmap = mipmaps[j];
16844
17086
  const mipmapImage = mipmap.image[i].image;
16845
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data);
17087
+
17088
+ if (useTexStorage) {
17089
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, mipmapImage.width, mipmapImage.height, glFormat, glType, mipmapImage.data);
17090
+ } else {
17091
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data);
17092
+ }
16846
17093
  }
16847
17094
  } else {
16848
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[i]);
17095
+ if (useTexStorage) {
17096
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, glFormat, glType, cubeImage[i]);
17097
+ } else {
17098
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[i]);
17099
+ }
16849
17100
 
16850
17101
  for (let j = 0; j < mipmaps.length; j++) {
16851
17102
  const mipmap = mipmaps[j];
16852
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[i]);
17103
+
17104
+ if (useTexStorage) {
17105
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, glFormat, glType, mipmap.image[i]);
17106
+ } else {
17107
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[i]);
17108
+ }
16853
17109
  }
16854
17110
  }
16855
17111
  }
16856
-
16857
- textureProperties.__maxMipLevel = mipmaps.length;
16858
17112
  }
16859
17113
 
16860
17114
  if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
16861
17115
  // We assume images for cube map have the same size.
16862
- generateMipmap(_gl.TEXTURE_CUBE_MAP, texture, image.width, image.height);
17116
+ generateMipmap(_gl.TEXTURE_CUBE_MAP);
16863
17117
  }
16864
17118
 
16865
17119
  textureProperties.__version = texture.version;
@@ -16872,16 +17126,23 @@
16872
17126
  const glFormat = utils.convert(texture.format);
16873
17127
  const glType = utils.convert(texture.type);
16874
17128
  const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
17129
+ const renderTargetProperties = properties.get(renderTarget);
16875
17130
 
16876
- if (textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY) {
16877
- state.texImage3D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.depth, 0, glFormat, glType, null);
16878
- } else {
16879
- state.texImage2D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null);
17131
+ if (!renderTargetProperties.__hasExternalTextures) {
17132
+ if (textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY) {
17133
+ state.texImage3D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.depth, 0, glFormat, glType, null);
17134
+ } else {
17135
+ state.texImage2D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null);
17136
+ }
16880
17137
  }
16881
17138
 
16882
17139
  state.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer);
16883
17140
 
16884
- _gl.framebufferTexture2D(_gl.FRAMEBUFFER, attachment, textureTarget, properties.get(texture).__webglTexture, 0);
17141
+ if (renderTarget.useRenderToTexture) {
17142
+ MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT(_gl.FRAMEBUFFER, attachment, textureTarget, properties.get(texture).__webglTexture, 0, getRenderTargetSamples(renderTarget));
17143
+ } else {
17144
+ _gl.framebufferTexture2D(_gl.FRAMEBUFFER, attachment, textureTarget, properties.get(texture).__webglTexture, 0);
17145
+ }
16885
17146
 
16886
17147
  state.bindFramebuffer(_gl.FRAMEBUFFER, null);
16887
17148
  } // Setup storage for internal depth/stencil buffers and bind to correct framebuffer
@@ -16893,7 +17154,7 @@
16893
17154
  if (renderTarget.depthBuffer && !renderTarget.stencilBuffer) {
16894
17155
  let glInternalFormat = _gl.DEPTH_COMPONENT16;
16895
17156
 
16896
- if (isMultisample) {
17157
+ if (isMultisample || renderTarget.useRenderToTexture) {
16897
17158
  const depthTexture = renderTarget.depthTexture;
16898
17159
 
16899
17160
  if (depthTexture && depthTexture.isDepthTexture) {
@@ -16906,17 +17167,23 @@
16906
17167
 
16907
17168
  const samples = getRenderTargetSamples(renderTarget);
16908
17169
 
16909
- _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
17170
+ if (renderTarget.useRenderToTexture) {
17171
+ MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
17172
+ } else {
17173
+ _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
17174
+ }
16910
17175
  } else {
16911
17176
  _gl.renderbufferStorage(_gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height);
16912
17177
  }
16913
17178
 
16914
17179
  _gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer);
16915
17180
  } else if (renderTarget.depthBuffer && renderTarget.stencilBuffer) {
16916
- if (isMultisample) {
16917
- const samples = getRenderTargetSamples(renderTarget);
17181
+ const samples = getRenderTargetSamples(renderTarget);
16918
17182
 
17183
+ if (isMultisample && renderTarget.useRenderbuffer) {
16919
17184
  _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height);
17185
+ } else if (renderTarget.useRenderToTexture) {
17186
+ MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height);
16920
17187
  } else {
16921
17188
  _gl.renderbufferStorage(_gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTarget.width, renderTarget.height);
16922
17189
  }
@@ -16928,11 +17195,12 @@
16928
17195
  const glFormat = utils.convert(texture.format);
16929
17196
  const glType = utils.convert(texture.type);
16930
17197
  const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
17198
+ const samples = getRenderTargetSamples(renderTarget);
16931
17199
 
16932
- if (isMultisample) {
16933
- const samples = getRenderTargetSamples(renderTarget);
16934
-
17200
+ if (isMultisample && renderTarget.useRenderbuffer) {
16935
17201
  _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
17202
+ } else if (renderTarget.useRenderToTexture) {
17203
+ MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
16936
17204
  } else {
16937
17205
  _gl.renderbufferStorage(_gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height);
16938
17206
  }
@@ -16962,10 +17230,20 @@
16962
17230
 
16963
17231
  const webglDepthTexture = properties.get(renderTarget.depthTexture).__webglTexture;
16964
17232
 
17233
+ const samples = getRenderTargetSamples(renderTarget);
17234
+
16965
17235
  if (renderTarget.depthTexture.format === DepthFormat) {
16966
- _gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0);
17236
+ if (renderTarget.useRenderToTexture) {
17237
+ MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples);
17238
+ } else {
17239
+ _gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0);
17240
+ }
16967
17241
  } else if (renderTarget.depthTexture.format === DepthStencilFormat) {
16968
- _gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0);
17242
+ if (renderTarget.useRenderToTexture) {
17243
+ MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT(_gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples);
17244
+ } else {
17245
+ _gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0);
17246
+ }
16969
17247
  } else {
16970
17248
  throw new Error('Unknown depthTexture format');
16971
17249
  }
@@ -16976,7 +17254,7 @@
16976
17254
  const renderTargetProperties = properties.get(renderTarget);
16977
17255
  const isCube = renderTarget.isWebGLCubeRenderTarget === true;
16978
17256
 
16979
- if (renderTarget.depthTexture) {
17257
+ if (renderTarget.depthTexture && !renderTargetProperties.__autoAllocateDepthBuffer) {
16980
17258
  if (isCube) throw new Error('target.depthTexture not supported in Cube render targets');
16981
17259
  setupDepthTexture(renderTargetProperties.__webglFramebuffer, renderTarget);
16982
17260
  } else {
@@ -16996,6 +17274,19 @@
16996
17274
  }
16997
17275
 
16998
17276
  state.bindFramebuffer(_gl.FRAMEBUFFER, null);
17277
+ } // rebind framebuffer with external textures
17278
+
17279
+
17280
+ function rebindTextures(renderTarget, colorTexture, depthTexture) {
17281
+ const renderTargetProperties = properties.get(renderTarget);
17282
+
17283
+ if (colorTexture !== undefined) {
17284
+ setupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, renderTarget.texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D);
17285
+ }
17286
+
17287
+ if (depthTexture !== undefined) {
17288
+ setupDepthRenderbuffer(renderTarget);
17289
+ }
16999
17290
  } // Set up GL resources for the render target
17000
17291
 
17001
17292
 
@@ -17006,14 +17297,16 @@
17006
17297
  renderTarget.addEventListener('dispose', onRenderTargetDispose);
17007
17298
 
17008
17299
  if (renderTarget.isWebGLMultipleRenderTargets !== true) {
17009
- textureProperties.__webglTexture = _gl.createTexture();
17300
+ if (textureProperties.__webglTexture === undefined) {
17301
+ textureProperties.__webglTexture = _gl.createTexture();
17302
+ }
17303
+
17010
17304
  textureProperties.__version = texture.version;
17011
17305
  info.memory.textures++;
17012
17306
  }
17013
17307
 
17014
17308
  const isCube = renderTarget.isWebGLCubeRenderTarget === true;
17015
17309
  const isMultipleRenderTargets = renderTarget.isWebGLMultipleRenderTargets === true;
17016
- const isMultisample = renderTarget.isWebGLMultisampleRenderTarget === true;
17017
17310
  const isRenderTarget3D = texture.isDataTexture3D || texture.isDataTexture2DArray;
17018
17311
  const supportsMips = isPowerOfTwo$1(renderTarget) || isWebGL2; // Handles WebGL2 RGBFormat fallback - #18858
17019
17312
 
@@ -17047,7 +17340,7 @@
17047
17340
  } else {
17048
17341
  console.warn('THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.');
17049
17342
  }
17050
- } else if (isMultisample) {
17343
+ } else if (renderTarget.useRenderbuffer) {
17051
17344
  if (isWebGL2) {
17052
17345
  renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
17053
17346
  renderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer();
@@ -17089,7 +17382,7 @@
17089
17382
  }
17090
17383
 
17091
17384
  if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
17092
- generateMipmap(_gl.TEXTURE_CUBE_MAP, texture, renderTarget.width, renderTarget.height);
17385
+ generateMipmap(_gl.TEXTURE_CUBE_MAP);
17093
17386
  }
17094
17387
 
17095
17388
  state.unbindTexture();
@@ -17104,7 +17397,7 @@
17104
17397
  setupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D);
17105
17398
 
17106
17399
  if (textureNeedsGenerateMipmaps(attachment, supportsMips)) {
17107
- generateMipmap(_gl.TEXTURE_2D, attachment, renderTarget.width, renderTarget.height);
17400
+ generateMipmap(_gl.TEXTURE_2D);
17108
17401
  }
17109
17402
  }
17110
17403
 
@@ -17127,7 +17420,7 @@
17127
17420
  setupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, texture, _gl.COLOR_ATTACHMENT0, glTextureType);
17128
17421
 
17129
17422
  if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
17130
- generateMipmap(glTextureType, texture, renderTarget.width, renderTarget.height, renderTarget.depth);
17423
+ generateMipmap(glTextureType);
17131
17424
  }
17132
17425
 
17133
17426
  state.unbindTexture();
@@ -17152,26 +17445,44 @@
17152
17445
  const webglTexture = properties.get(texture).__webglTexture;
17153
17446
 
17154
17447
  state.bindTexture(target, webglTexture);
17155
- generateMipmap(target, texture, renderTarget.width, renderTarget.height);
17448
+ generateMipmap(target);
17156
17449
  state.unbindTexture();
17157
17450
  }
17158
17451
  }
17159
17452
  }
17160
17453
 
17161
17454
  function updateMultisampleRenderTarget(renderTarget) {
17162
- if (renderTarget.isWebGLMultisampleRenderTarget) {
17455
+ if (renderTarget.useRenderbuffer) {
17163
17456
  if (isWebGL2) {
17164
17457
  const width = renderTarget.width;
17165
17458
  const height = renderTarget.height;
17166
17459
  let mask = _gl.COLOR_BUFFER_BIT;
17167
- if (renderTarget.depthBuffer) mask |= _gl.DEPTH_BUFFER_BIT;
17168
- if (renderTarget.stencilBuffer) mask |= _gl.STENCIL_BUFFER_BIT;
17460
+ const invalidationArray = [_gl.COLOR_ATTACHMENT0];
17461
+ const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
17462
+
17463
+ if (renderTarget.depthBuffer) {
17464
+ invalidationArray.push(depthStyle);
17465
+ }
17466
+
17467
+ if (!renderTarget.ignoreDepthForMultisampleCopy) {
17468
+ if (renderTarget.depthBuffer) mask |= _gl.DEPTH_BUFFER_BIT;
17469
+ if (renderTarget.stencilBuffer) mask |= _gl.STENCIL_BUFFER_BIT;
17470
+ }
17471
+
17169
17472
  const renderTargetProperties = properties.get(renderTarget);
17170
17473
  state.bindFramebuffer(_gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer);
17171
17474
  state.bindFramebuffer(_gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer);
17172
17475
 
17476
+ if (renderTarget.ignoreDepthForMultisampleCopy) {
17477
+ _gl.invalidateFramebuffer(_gl.READ_FRAMEBUFFER, [depthStyle]);
17478
+
17479
+ _gl.invalidateFramebuffer(_gl.DRAW_FRAMEBUFFER, [depthStyle]);
17480
+ }
17481
+
17173
17482
  _gl.blitFramebuffer(0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST);
17174
17483
 
17484
+ _gl.invalidateFramebuffer(_gl.READ_FRAMEBUFFER, invalidationArray);
17485
+
17175
17486
  state.bindFramebuffer(_gl.READ_FRAMEBUFFER, null);
17176
17487
  state.bindFramebuffer(_gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer);
17177
17488
  } else {
@@ -17181,7 +17492,7 @@
17181
17492
  }
17182
17493
 
17183
17494
  function getRenderTargetSamples(renderTarget) {
17184
- return isWebGL2 && renderTarget.isWebGLMultisampleRenderTarget ? Math.min(maxSamples, renderTarget.samples) : 0;
17495
+ return isWebGL2 && (renderTarget.useRenderbuffer || renderTarget.useRenderToTexture) ? Math.min(maxSamples, renderTarget.samples) : 0;
17185
17496
  }
17186
17497
 
17187
17498
  function updateVideoTexture(texture) {
@@ -17231,9 +17542,12 @@
17231
17542
  this.setTexture2DArray = setTexture2DArray;
17232
17543
  this.setTexture3D = setTexture3D;
17233
17544
  this.setTextureCube = setTextureCube;
17545
+ this.rebindTextures = rebindTextures;
17234
17546
  this.setupRenderTarget = setupRenderTarget;
17235
17547
  this.updateRenderTargetMipmap = updateRenderTargetMipmap;
17236
17548
  this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
17549
+ this.setupDepthRenderbuffer = setupDepthRenderbuffer;
17550
+ this.setupFrameBufferTexture = setupFrameBufferTexture;
17237
17551
  this.safeSetTexture2D = safeSetTexture2D;
17238
17552
  this.safeSetTextureCube = safeSetTextureCube;
17239
17553
  }
@@ -17963,29 +18277,51 @@
17963
18277
 
17964
18278
  }
17965
18279
 
18280
+ class DepthTexture extends Texture {
18281
+ constructor(width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format) {
18282
+ format = format !== undefined ? format : DepthFormat;
18283
+
18284
+ if (format !== DepthFormat && format !== DepthStencilFormat) {
18285
+ throw new Error('DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat');
18286
+ }
18287
+
18288
+ if (type === undefined && format === DepthFormat) type = UnsignedShortType;
18289
+ if (type === undefined && format === DepthStencilFormat) type = UnsignedInt248Type;
18290
+ super(null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);
18291
+ this.image = {
18292
+ width: width,
18293
+ height: height
18294
+ };
18295
+ this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
18296
+ this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
18297
+ this.flipY = false;
18298
+ this.generateMipmaps = false;
18299
+ }
18300
+
18301
+ }
18302
+
18303
+ DepthTexture.prototype.isDepthTexture = true;
18304
+
17966
18305
  class WebXRManager extends EventDispatcher {
17967
18306
  constructor(renderer, gl) {
17968
18307
  super();
17969
18308
  const scope = this;
17970
- const state = renderer.state;
17971
18309
  let session = null;
17972
18310
  let framebufferScaleFactor = 1.0;
17973
18311
  var poseTarget = null;
17974
18312
  let referenceSpace = null;
17975
18313
  let referenceSpaceType = 'local-floor';
18314
+ const hasMultisampledRenderToTexture = renderer.extensions.has('WEBGL_multisampled_render_to_texture');
17976
18315
  let pose = null;
17977
18316
  var layers = [];
17978
18317
  let glBinding = null;
17979
- let glFramebuffer = null;
17980
18318
  let glProjLayer = null;
17981
18319
  let glBaseLayer = null;
17982
18320
  let isMultisample = false;
17983
- let glMultisampledFramebuffer = null;
17984
- let glColorRenderbuffer = null;
17985
- let glDepthRenderbuffer = null;
17986
18321
  let xrFrame = null;
17987
- let depthStyle = null;
17988
- let clearStyle = null;
18322
+ const attributes = gl.getContextAttributes();
18323
+ let initialRenderTarget = null;
18324
+ let newRenderTarget = null;
17989
18325
  const controllers = [];
17990
18326
  const inputSourcesMap = new Map(); //
17991
18327
 
@@ -18064,20 +18400,12 @@
18064
18400
  _currentDepthNear = null;
18065
18401
  _currentDepthFar = null; // restore framebuffer/rendering state
18066
18402
 
18067
- state.bindXRFramebuffer(null);
18068
- renderer.setRenderTarget(renderer.getRenderTarget());
18069
- if (glFramebuffer) gl.deleteFramebuffer(glFramebuffer);
18070
- if (glMultisampledFramebuffer) gl.deleteFramebuffer(glMultisampledFramebuffer);
18071
- if (glColorRenderbuffer) gl.deleteRenderbuffer(glColorRenderbuffer);
18072
- if (glDepthRenderbuffer) gl.deleteRenderbuffer(glDepthRenderbuffer);
18073
- glFramebuffer = null;
18074
- glMultisampledFramebuffer = null;
18075
- glColorRenderbuffer = null;
18076
- glDepthRenderbuffer = null;
18403
+ renderer.setRenderTarget(initialRenderTarget);
18077
18404
  glBaseLayer = null;
18078
18405
  glProjLayer = null;
18079
18406
  glBinding = null;
18080
- session = null; //
18407
+ session = null;
18408
+ newRenderTarget = null; //
18081
18409
 
18082
18410
  animation.stop();
18083
18411
  scope.isPresenting = false;
@@ -18126,6 +18454,7 @@
18126
18454
  session = value;
18127
18455
 
18128
18456
  if (session !== null) {
18457
+ initialRenderTarget = renderer.getRenderTarget();
18129
18458
  session.addEventListener('select', onSessionEvent);
18130
18459
  session.addEventListener('selectstart', onSessionEvent);
18131
18460
  session.addEventListener('selectend', onSessionEvent);
@@ -18134,15 +18463,14 @@
18134
18463
  session.addEventListener('squeezeend', onSessionEvent);
18135
18464
  session.addEventListener('end', onSessionEnd);
18136
18465
  session.addEventListener('inputsourceschange', onInputSourcesChange);
18137
- const attributes = gl.getContextAttributes();
18138
18466
 
18139
18467
  if (attributes.xrCompatible !== true) {
18140
18468
  await gl.makeXRCompatible();
18141
18469
  }
18142
18470
 
18143
- if (session.renderState.layers === undefined) {
18471
+ if (session.renderState.layers === undefined || renderer.capabilities.isWebGL2 === false) {
18144
18472
  const layerInit = {
18145
- antialias: attributes.antialias,
18473
+ antialias: session.renderState.layers === undefined ? attributes.antialias : true,
18146
18474
  alpha: attributes.alpha,
18147
18475
  depth: attributes.depth,
18148
18476
  stencil: attributes.stencil,
@@ -18152,64 +18480,58 @@
18152
18480
  session.updateRenderState({
18153
18481
  baseLayer: glBaseLayer
18154
18482
  });
18155
- } else if (gl instanceof WebGLRenderingContext) {
18156
- // Use old style webgl layer because we can't use MSAA
18157
- // WebGL2 support.
18158
- const layerInit = {
18159
- antialias: true,
18160
- alpha: attributes.alpha,
18161
- depth: attributes.depth,
18162
- stencil: attributes.stencil,
18163
- framebufferScaleFactor: framebufferScaleFactor
18164
- };
18165
- glBaseLayer = new XRWebGLLayer(session, gl, layerInit);
18166
- session.updateRenderState({
18167
- layers: [glBaseLayer]
18483
+ newRenderTarget = new WebGLRenderTarget(glBaseLayer.framebufferWidth, glBaseLayer.framebufferHeight, {
18484
+ format: RGBAFormat,
18485
+ type: UnsignedByteType,
18486
+ encoding: renderer.outputEncoding
18168
18487
  });
18169
18488
  } else {
18170
18489
  isMultisample = attributes.antialias;
18171
18490
  let depthFormat = null;
18491
+ let depthType = null;
18492
+ let glDepthFormat = null;
18172
18493
 
18173
18494
  if (attributes.depth) {
18174
- clearStyle = gl.DEPTH_BUFFER_BIT;
18175
- if (attributes.stencil) clearStyle |= gl.STENCIL_BUFFER_BIT;
18176
- depthStyle = attributes.stencil ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;
18177
- depthFormat = attributes.stencil ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT24;
18495
+ glDepthFormat = attributes.stencil ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT24;
18496
+ depthFormat = attributes.stencil ? DepthStencilFormat : DepthFormat;
18497
+ depthType = attributes.stencil ? UnsignedInt248Type : UnsignedShortType;
18178
18498
  }
18179
18499
 
18180
18500
  const projectionlayerInit = {
18181
- colorFormat: attributes.alpha ? gl.RGBA8 : gl.RGB8,
18182
- depthFormat: depthFormat,
18501
+ colorFormat: attributes.alpha || isMultisample ? gl.RGBA8 : gl.RGB8,
18502
+ depthFormat: glDepthFormat,
18183
18503
  scaleFactor: framebufferScaleFactor
18184
18504
  };
18185
18505
  glBinding = new XRWebGLBinding(session, gl);
18186
18506
  glProjLayer = glBinding.createProjectionLayer(projectionlayerInit);
18187
- glFramebuffer = gl.createFramebuffer();
18188
18507
  session.updateRenderState({
18189
18508
  layers: [glProjLayer]
18190
18509
  });
18191
18510
 
18192
18511
  if (isMultisample) {
18193
- glMultisampledFramebuffer = gl.createFramebuffer();
18194
- glColorRenderbuffer = gl.createRenderbuffer();
18195
- gl.bindRenderbuffer(gl.RENDERBUFFER, glColorRenderbuffer);
18196
- gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.RGBA8, glProjLayer.textureWidth, glProjLayer.textureHeight);
18197
- state.bindFramebuffer(gl.FRAMEBUFFER, glMultisampledFramebuffer);
18198
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, glColorRenderbuffer);
18199
- gl.bindRenderbuffer(gl.RENDERBUFFER, null);
18200
-
18201
- if (depthFormat !== null) {
18202
- glDepthRenderbuffer = gl.createRenderbuffer();
18203
- gl.bindRenderbuffer(gl.RENDERBUFFER, glDepthRenderbuffer);
18204
- gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, depthFormat, glProjLayer.textureWidth, glProjLayer.textureHeight);
18205
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, depthStyle, gl.RENDERBUFFER, glDepthRenderbuffer);
18206
- gl.bindRenderbuffer(gl.RENDERBUFFER, null);
18207
- }
18208
-
18209
- state.bindFramebuffer(gl.FRAMEBUFFER, null);
18512
+ newRenderTarget = new WebGLMultisampleRenderTarget(glProjLayer.textureWidth, glProjLayer.textureHeight, {
18513
+ format: RGBAFormat,
18514
+ type: UnsignedByteType,
18515
+ depthTexture: new DepthTexture(glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat),
18516
+ stencilBuffer: attributes.stencil,
18517
+ ignoreDepth: glProjLayer.ignoreDepthValues,
18518
+ useRenderToTexture: hasMultisampledRenderToTexture,
18519
+ encoding: renderer.outputEncoding
18520
+ });
18521
+ } else {
18522
+ newRenderTarget = new WebGLRenderTarget(glProjLayer.textureWidth, glProjLayer.textureHeight, {
18523
+ format: attributes.alpha ? RGBAFormat : RGBFormat,
18524
+ type: UnsignedByteType,
18525
+ depthTexture: new DepthTexture(glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat),
18526
+ stencilBuffer: attributes.stencil,
18527
+ ignoreDepth: glProjLayer.ignoreDepthValues,
18528
+ encoding: renderer.outputEncoding
18529
+ });
18210
18530
  }
18211
- }
18531
+ } // Set foveation to maximum.
18532
+
18212
18533
 
18534
+ this.setFoveation(1.0);
18213
18535
  referenceSpace = await session.requestReferenceSpace(referenceSpaceType);
18214
18536
  animation.setContext(session);
18215
18537
  animation.start();
@@ -18242,7 +18564,7 @@
18242
18564
  var layersCopy = layers.map(function (x) {
18243
18565
  return x;
18244
18566
  });
18245
- layersCopy.push(layersCopy);
18567
+ layersCopy.unshift(session.renderState.layers[0]);
18246
18568
  session.updateRenderState({
18247
18569
  layers: layersCopy
18248
18570
  });
@@ -18429,7 +18751,8 @@
18429
18751
  const views = pose.views;
18430
18752
 
18431
18753
  if (glBaseLayer !== null) {
18432
- state.bindXRFramebuffer(glBaseLayer.framebuffer);
18754
+ renderer.setRenderTargetFramebuffer(newRenderTarget, glBaseLayer.framebuffer);
18755
+ renderer.setRenderTarget(newRenderTarget);
18433
18756
  }
18434
18757
 
18435
18758
  let cameraVRNeedsUpdate = false; // check if it's necessary to rebuild cameraVR's camera list
@@ -18447,14 +18770,12 @@
18447
18770
  viewport = glBaseLayer.getViewport(view);
18448
18771
  } else {
18449
18772
  const glSubImage = glBinding.getViewSubImage(glProjLayer, view);
18450
- state.bindXRFramebuffer(glFramebuffer);
18773
+ viewport = glSubImage.viewport; // For side-by-side projection, we only produce a single texture for both eyes.
18451
18774
 
18452
- if (glSubImage.depthStencilTexture !== undefined) {
18453
- gl.framebufferTexture2D(gl.FRAMEBUFFER, depthStyle, gl.TEXTURE_2D, glSubImage.depthStencilTexture, 0);
18775
+ if (i === 0) {
18776
+ renderer.setRenderTargetTextures(newRenderTarget, glSubImage.colorTexture, glProjLayer.ignoreDepthValues ? undefined : glSubImage.depthStencilTexture);
18777
+ renderer.setRenderTarget(newRenderTarget);
18454
18778
  }
18455
-
18456
- gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, glSubImage.colorTexture, 0);
18457
- viewport = glSubImage.viewport;
18458
18779
  }
18459
18780
 
18460
18781
  const camera = cameras[i];
@@ -18470,11 +18791,6 @@
18470
18791
  cameraVR.cameras.push(camera);
18471
18792
  }
18472
18793
  }
18473
-
18474
- if (isMultisample) {
18475
- state.bindXRFramebuffer(glMultisampledFramebuffer);
18476
- if (clearStyle !== null) gl.clear(clearStyle);
18477
- }
18478
18794
  } //
18479
18795
 
18480
18796
 
@@ -18487,23 +18803,6 @@
18487
18803
  }
18488
18804
 
18489
18805
  if (onAnimationFrameCallback) onAnimationFrameCallback(time, frame);
18490
-
18491
- if (isMultisample) {
18492
- const width = glProjLayer.textureWidth;
18493
- const height = glProjLayer.textureHeight;
18494
- state.bindFramebuffer(gl.READ_FRAMEBUFFER, glMultisampledFramebuffer);
18495
- state.bindFramebuffer(gl.DRAW_FRAMEBUFFER, glFramebuffer); // Invalidate the depth here to avoid flush of the depth data to main memory.
18496
-
18497
- gl.invalidateFramebuffer(gl.READ_FRAMEBUFFER, [depthStyle]);
18498
- gl.invalidateFramebuffer(gl.DRAW_FRAMEBUFFER, [depthStyle]);
18499
- gl.blitFramebuffer(0, 0, width, height, 0, 0, width, height, gl.COLOR_BUFFER_BIT, gl.NEAREST); // Invalidate the MSAA buffer because it's not needed anymore.
18500
-
18501
- gl.invalidateFramebuffer(gl.READ_FRAMEBUFFER, [gl.COLOR_ATTACHMENT0]);
18502
- state.bindFramebuffer(gl.READ_FRAMEBUFFER, null);
18503
- state.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null);
18504
- state.bindFramebuffer(gl.FRAMEBUFFER, glMultisampledFramebuffer);
18505
- }
18506
-
18507
18806
  xrFrame = null;
18508
18807
  }
18509
18808
 
@@ -18616,12 +18915,6 @@
18616
18915
  uniforms.reflectivity.value = material.reflectivity;
18617
18916
  uniforms.ior.value = material.ior;
18618
18917
  uniforms.refractionRatio.value = material.refractionRatio;
18619
-
18620
- const maxMipLevel = properties.get(envMap).__maxMipLevel;
18621
-
18622
- if (maxMipLevel !== undefined) {
18623
- uniforms.maxMipLevel.value = maxMipLevel;
18624
- }
18625
18918
  }
18626
18919
 
18627
18920
  if (material.lightMap) {
@@ -18679,12 +18972,16 @@
18679
18972
  uvScaleMap = material.clearcoatRoughnessMap;
18680
18973
  } else if (material.specularIntensityMap) {
18681
18974
  uvScaleMap = material.specularIntensityMap;
18682
- } else if (material.specularTintMap) {
18683
- uvScaleMap = material.specularTintMap;
18975
+ } else if (material.specularColorMap) {
18976
+ uvScaleMap = material.specularColorMap;
18684
18977
  } else if (material.transmissionMap) {
18685
18978
  uvScaleMap = material.transmissionMap;
18686
18979
  } else if (material.thicknessMap) {
18687
18980
  uvScaleMap = material.thicknessMap;
18981
+ } else if (material.sheenColorMap) {
18982
+ uvScaleMap = material.sheenColorMap;
18983
+ } else if (material.sheenRoughnessMap) {
18984
+ uvScaleMap = material.sheenRoughnessMap;
18688
18985
  }
18689
18986
 
18690
18987
  if (uvScaleMap !== undefined) {
@@ -18919,8 +19216,16 @@
18919
19216
  uniforms.ior.value = material.ior; // also part of uniforms common
18920
19217
 
18921
19218
  if (material.sheen > 0) {
18922
- uniforms.sheenTint.value.copy(material.sheenTint).multiplyScalar(material.sheen);
19219
+ uniforms.sheenColor.value.copy(material.sheenColor).multiplyScalar(material.sheen);
18923
19220
  uniforms.sheenRoughness.value = material.sheenRoughness;
19221
+
19222
+ if (material.sheenColorMap) {
19223
+ uniforms.sheenColorMap.value = material.sheenColorMap;
19224
+ }
19225
+
19226
+ if (material.sheenRoughnessMap) {
19227
+ uniforms.sheenRoughnessMap.value = material.sheenRoughnessMap;
19228
+ }
18924
19229
  }
18925
19230
 
18926
19231
  if (material.clearcoat > 0) {
@@ -18961,18 +19266,18 @@
18961
19266
  }
18962
19267
 
18963
19268
  uniforms.attenuationDistance.value = material.attenuationDistance;
18964
- uniforms.attenuationTint.value.copy(material.attenuationTint);
19269
+ uniforms.attenuationColor.value.copy(material.attenuationColor);
18965
19270
  }
18966
19271
 
18967
19272
  uniforms.specularIntensity.value = material.specularIntensity;
18968
- uniforms.specularTint.value.copy(material.specularTint);
19273
+ uniforms.specularColor.value.copy(material.specularColor);
18969
19274
 
18970
19275
  if (material.specularIntensityMap) {
18971
19276
  uniforms.specularIntensityMap.value = material.specularIntensityMap;
18972
19277
  }
18973
19278
 
18974
- if (material.specularTintMap) {
18975
- uniforms.specularTintMap.value = material.specularTintMap;
19279
+ if (material.specularColorMap) {
19280
+ uniforms.specularColorMap.value = material.specularColorMap;
18976
19281
  }
18977
19282
  }
18978
19283
 
@@ -19091,8 +19396,6 @@
19091
19396
  this.clippingPlanes = [];
19092
19397
  this.localClippingEnabled = false; // physically based shading
19093
19398
 
19094
- this.gammaFactor = 2.0; // for backwards compatibility
19095
-
19096
19399
  this.outputEncoding = LinearEncoding; // physical lights
19097
19400
 
19098
19401
  this.physicallyCorrectLights = false; // tone mapping
@@ -19181,7 +19484,9 @@
19181
19484
  preserveDrawingBuffer: _preserveDrawingBuffer,
19182
19485
  powerPreference: _powerPreference,
19183
19486
  failIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat
19184
- }; // event listeners must be registered before WebGL context is created, see #12753
19487
+ }; // OffscreenCanvas does not have setAttribute, see #22811
19488
+
19489
+ if ('setAttribute' in _canvas) _canvas.setAttribute('data-engine', `three.js r${REVISION}`); // event listeners must be registered before WebGL context is created, see #12753
19185
19490
 
19186
19491
  _canvas.addEventListener('webglcontextlost', onContextLost, false);
19187
19492
 
@@ -19246,7 +19551,7 @@
19246
19551
  clipping = new WebGLClipping(properties);
19247
19552
  programCache = new WebGLPrograms(_this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping);
19248
19553
  materials = new WebGLMaterials(properties);
19249
- renderLists = new WebGLRenderLists(properties);
19554
+ renderLists = new WebGLRenderLists();
19250
19555
  renderStates = new WebGLRenderStates(extensions, capabilities);
19251
19556
  background = new WebGLBackground(_this, cubemaps, state, objects, _premultipliedAlpha);
19252
19557
  shadowMap = new WebGLShadowMap(_this, objects, capabilities);
@@ -19429,6 +19734,7 @@
19429
19734
  cubeuvmaps.dispose();
19430
19735
  objects.dispose();
19431
19736
  bindingStates.dispose();
19737
+ programCache.dispose();
19432
19738
  xr.dispose();
19433
19739
  xr.removeEventListener('sessionstart', onXRSessionStart);
19434
19740
  xr.removeEventListener('sessionend', onXRSessionEnd);
@@ -19484,71 +19790,13 @@
19484
19790
  programs.forEach(function (program) {
19485
19791
  programCache.releaseProgram(program);
19486
19792
  });
19487
- }
19488
- } // Buffer rendering
19489
-
19490
-
19491
- function renderObjectImmediate(object, program) {
19492
- object.render(function (object) {
19493
- _this.renderBufferImmediate(object, program);
19494
- });
19495
- }
19496
-
19497
- this.renderBufferImmediate = function (object, program) {
19498
- bindingStates.initAttributes();
19499
- const buffers = properties.get(object);
19500
- if (object.hasPositions && !buffers.position) buffers.position = _gl.createBuffer();
19501
- if (object.hasNormals && !buffers.normal) buffers.normal = _gl.createBuffer();
19502
- if (object.hasUvs && !buffers.uv) buffers.uv = _gl.createBuffer();
19503
- if (object.hasColors && !buffers.color) buffers.color = _gl.createBuffer();
19504
- const programAttributes = program.getAttributes();
19505
-
19506
- if (object.hasPositions) {
19507
- _gl.bindBuffer(_gl.ARRAY_BUFFER, buffers.position);
19508
19793
 
19509
- _gl.bufferData(_gl.ARRAY_BUFFER, object.positionArray, _gl.DYNAMIC_DRAW);
19510
-
19511
- bindingStates.enableAttribute(programAttributes.position.location);
19512
-
19513
- _gl.vertexAttribPointer(programAttributes.position.location, 3, _gl.FLOAT, false, 0, 0);
19514
- }
19515
-
19516
- if (object.hasNormals) {
19517
- _gl.bindBuffer(_gl.ARRAY_BUFFER, buffers.normal);
19518
-
19519
- _gl.bufferData(_gl.ARRAY_BUFFER, object.normalArray, _gl.DYNAMIC_DRAW);
19520
-
19521
- bindingStates.enableAttribute(programAttributes.normal.location);
19522
-
19523
- _gl.vertexAttribPointer(programAttributes.normal.location, 3, _gl.FLOAT, false, 0, 0);
19524
- }
19525
-
19526
- if (object.hasUvs) {
19527
- _gl.bindBuffer(_gl.ARRAY_BUFFER, buffers.uv);
19528
-
19529
- _gl.bufferData(_gl.ARRAY_BUFFER, object.uvArray, _gl.DYNAMIC_DRAW);
19530
-
19531
- bindingStates.enableAttribute(programAttributes.uv.location);
19532
-
19533
- _gl.vertexAttribPointer(programAttributes.uv.location, 2, _gl.FLOAT, false, 0, 0);
19534
- }
19535
-
19536
- if (object.hasColors) {
19537
- _gl.bindBuffer(_gl.ARRAY_BUFFER, buffers.color);
19538
-
19539
- _gl.bufferData(_gl.ARRAY_BUFFER, object.colorArray, _gl.DYNAMIC_DRAW);
19540
-
19541
- bindingStates.enableAttribute(programAttributes.color.location);
19542
-
19543
- _gl.vertexAttribPointer(programAttributes.color.location, 3, _gl.FLOAT, false, 0, 0);
19794
+ if (material.isShaderMaterial) {
19795
+ programCache.releaseShaderCache(material);
19796
+ }
19544
19797
  }
19798
+ } // Buffer rendering
19545
19799
 
19546
- bindingStates.disableUnusedAttributes();
19547
-
19548
- _gl.drawArrays(_gl.TRIANGLES, 0, object.count);
19549
-
19550
- object.count = 0;
19551
- };
19552
19800
 
19553
19801
  this.renderBufferDirect = function (camera, scene, geometry, material, object, group) {
19554
19802
  if (scene === null) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)
@@ -19823,12 +20071,6 @@
19823
20071
  currentRenderList.push(object, geometry, material, groupOrder, _vector3.z, null);
19824
20072
  }
19825
20073
  }
19826
- } else if (object.isImmediateRenderObject) {
19827
- if (sortObjects) {
19828
- _vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix);
19829
- }
19830
-
19831
- currentRenderList.push(object, null, object.material, groupOrder, _vector3.z, null);
19832
20074
  } else if (object.isMesh || object.isLine || object.isPoints) {
19833
20075
  if (object.isSkinnedMesh) {
19834
20076
  // update skeleton only once in a frame
@@ -19893,7 +20135,8 @@
19893
20135
  minFilter: LinearMipmapLinearFilter,
19894
20136
  magFilter: NearestFilter,
19895
20137
  wrapS: ClampToEdgeWrapping,
19896
- wrapT: ClampToEdgeWrapping
20138
+ wrapT: ClampToEdgeWrapping,
20139
+ useRenderToTexture: extensions.has('WEBGL_multisampled_render_to_texture')
19897
20140
  });
19898
20141
  }
19899
20142
 
@@ -19937,27 +20180,20 @@
19937
20180
  object.normalMatrix.getNormalMatrix(object.modelViewMatrix);
19938
20181
  material.onBeforeRender(_this, scene, camera, geometry, object, group);
19939
20182
 
19940
- if (object.isImmediateRenderObject) {
19941
- const program = setProgram(camera, scene, geometry, material, object);
19942
- state.setMaterial(material);
19943
- bindingStates.reset();
19944
- renderObjectImmediate(object, program);
19945
- } else {
19946
- if (material.transparent === true && material.side === DoubleSide) {
19947
- material.side = BackSide;
19948
- material.needsUpdate = true;
20183
+ if (material.transparent === true && material.side === DoubleSide) {
20184
+ material.side = BackSide;
20185
+ material.needsUpdate = true;
19949
20186
 
19950
- _this.renderBufferDirect(camera, scene, geometry, material, object, group);
20187
+ _this.renderBufferDirect(camera, scene, geometry, material, object, group);
19951
20188
 
19952
- material.side = FrontSide;
19953
- material.needsUpdate = true;
20189
+ material.side = FrontSide;
20190
+ material.needsUpdate = true;
19954
20191
 
19955
- _this.renderBufferDirect(camera, scene, geometry, material, object, group);
20192
+ _this.renderBufferDirect(camera, scene, geometry, material, object, group);
19956
20193
 
19957
- material.side = DoubleSide;
19958
- } else {
19959
- _this.renderBufferDirect(camera, scene, geometry, material, object, group);
19960
- }
20194
+ material.side = DoubleSide;
20195
+ } else {
20196
+ _this.renderBufferDirect(camera, scene, geometry, material, object, group);
19961
20197
  }
19962
20198
 
19963
20199
  object.onAfterRender(_this, scene, camera, geometry, material, group);
@@ -19995,7 +20231,7 @@
19995
20231
  }
19996
20232
  } else {
19997
20233
  parameters.uniforms = programCache.getUniforms(material);
19998
- material.onBuild(parameters, _this);
20234
+ material.onBuild(object, parameters, _this);
19999
20235
  material.onBeforeCompile(parameters, _this);
20000
20236
  program = programCache.acquireProgram(parameters, programCacheKey);
20001
20237
  programs.set(programCacheKey, program);
@@ -20054,6 +20290,7 @@
20054
20290
  materialProperties.numIntersection = parameters.numClipIntersection;
20055
20291
  materialProperties.vertexAlphas = parameters.vertexAlphas;
20056
20292
  materialProperties.vertexTangents = parameters.vertexTangents;
20293
+ materialProperties.toneMapping = parameters.toneMapping;
20057
20294
  }
20058
20295
 
20059
20296
  function setProgram(camera, scene, geometry, material, object) {
@@ -20064,11 +20301,12 @@
20064
20301
  const environment = material.isMeshStandardMaterial ? scene.environment : null;
20065
20302
  const encoding = _currentRenderTarget === null ? _this.outputEncoding : _currentRenderTarget.texture.encoding;
20066
20303
  const envMap = (material.isMeshStandardMaterial ? cubeuvmaps : cubemaps).get(material.envMap || environment);
20067
- const vertexAlphas = material.vertexColors === true && !!geometry && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4;
20068
- const vertexTangents = !!material.normalMap && !!geometry && !!geometry.attributes.tangent;
20069
- const morphTargets = !!geometry && !!geometry.morphAttributes.position;
20070
- const morphNormals = !!geometry && !!geometry.morphAttributes.normal;
20071
- const morphTargetsCount = !!geometry && !!geometry.morphAttributes.position ? geometry.morphAttributes.position.length : 0;
20304
+ const vertexAlphas = material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4;
20305
+ const vertexTangents = !!material.normalMap && !!geometry.attributes.tangent;
20306
+ const morphTargets = !!geometry.morphAttributes.position;
20307
+ const morphNormals = !!geometry.morphAttributes.normal;
20308
+ const morphTargetsCount = !!geometry.morphAttributes.position ? geometry.morphAttributes.position.length : 0;
20309
+ const toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping;
20072
20310
  const materialProperties = properties.get(material);
20073
20311
  const lights = currentRenderState.state.lights;
20074
20312
 
@@ -20112,6 +20350,8 @@
20112
20350
  needsProgramChange = true;
20113
20351
  } else if (materialProperties.morphNormals !== morphNormals) {
20114
20352
  needsProgramChange = true;
20353
+ } else if (materialProperties.toneMapping !== toneMapping) {
20354
+ needsProgramChange = true;
20115
20355
  } else if (capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount) {
20116
20356
  needsProgramChange = true;
20117
20357
  }
@@ -20294,13 +20534,52 @@
20294
20534
  return _currentRenderTarget;
20295
20535
  };
20296
20536
 
20537
+ this.setRenderTargetTextures = function (renderTarget, colorTexture, depthTexture) {
20538
+ properties.get(renderTarget.texture).__webglTexture = colorTexture;
20539
+ properties.get(renderTarget.depthTexture).__webglTexture = depthTexture;
20540
+ const renderTargetProperties = properties.get(renderTarget);
20541
+ renderTargetProperties.__hasExternalTextures = true;
20542
+
20543
+ if (renderTargetProperties.__hasExternalTextures) {
20544
+ renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
20545
+
20546
+ if (!renderTargetProperties.__autoAllocateDepthBuffer) {
20547
+ // The multisample_render_to_texture extension doesn't work properly if there
20548
+ // are midframe flushes and an external depth buffer. Disable use of the extension.
20549
+ if (renderTarget.useRenderToTexture) {
20550
+ console.warn('render-to-texture extension was disabled because an external texture was provided');
20551
+ renderTarget.useRenderToTexture = false;
20552
+ renderTarget.useRenderbuffer = true;
20553
+ }
20554
+ }
20555
+ }
20556
+ };
20557
+
20558
+ this.setRenderTargetFramebuffer = function (renderTarget, defaultFramebuffer) {
20559
+ const renderTargetProperties = properties.get(renderTarget);
20560
+ renderTargetProperties.__webglFramebuffer = defaultFramebuffer;
20561
+ renderTargetProperties.__useDefaultFramebuffer = defaultFramebuffer === undefined;
20562
+ };
20563
+
20297
20564
  this.setRenderTarget = function (renderTarget, activeCubeFace = 0, activeMipmapLevel = 0) {
20298
20565
  _currentRenderTarget = renderTarget;
20299
20566
  _currentActiveCubeFace = activeCubeFace;
20300
20567
  _currentActiveMipmapLevel = activeMipmapLevel;
20568
+ let useDefaultFramebuffer = true;
20301
20569
 
20302
- if (renderTarget && properties.get(renderTarget).__webglFramebuffer === undefined) {
20303
- textures.setupRenderTarget(renderTarget);
20570
+ if (renderTarget) {
20571
+ const renderTargetProperties = properties.get(renderTarget);
20572
+
20573
+ if (renderTargetProperties.__useDefaultFramebuffer !== undefined) {
20574
+ // We need to make sure to rebind the framebuffer.
20575
+ state.bindFramebuffer(_gl.FRAMEBUFFER, null);
20576
+ useDefaultFramebuffer = false;
20577
+ } else if (renderTargetProperties.__webglFramebuffer === undefined) {
20578
+ textures.setupRenderTarget(renderTarget);
20579
+ } else if (renderTargetProperties.__hasExternalTextures) {
20580
+ // Color and depth texture must be rebound in order for the swapchain to update.
20581
+ textures.rebindTextures(renderTarget, properties.get(renderTarget.texture).__webglTexture, properties.get(renderTarget.depthTexture).__webglTexture);
20582
+ }
20304
20583
  }
20305
20584
 
20306
20585
  let framebuffer = null;
@@ -20319,7 +20598,7 @@
20319
20598
  if (renderTarget.isWebGLCubeRenderTarget) {
20320
20599
  framebuffer = __webglFramebuffer[activeCubeFace];
20321
20600
  isCube = true;
20322
- } else if (renderTarget.isWebGLMultisampleRenderTarget) {
20601
+ } else if (renderTarget.useRenderbuffer) {
20323
20602
  framebuffer = properties.get(renderTarget).__webglMultisampledFramebuffer;
20324
20603
  } else {
20325
20604
  framebuffer = __webglFramebuffer;
@@ -20340,7 +20619,7 @@
20340
20619
 
20341
20620
  const framebufferBound = state.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer);
20342
20621
 
20343
- if (framebufferBound && capabilities.drawBuffers) {
20622
+ if (framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer) {
20344
20623
  let needsUpdate = false;
20345
20624
 
20346
20625
  if (renderTarget) {
@@ -20448,21 +20727,17 @@
20448
20727
  };
20449
20728
 
20450
20729
  this.copyFramebufferToTexture = function (position, texture, level = 0) {
20730
+ if (texture.isFramebufferTexture !== true) {
20731
+ console.error('THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.');
20732
+ return;
20733
+ }
20734
+
20451
20735
  const levelScale = Math.pow(2, -level);
20452
20736
  const width = Math.floor(texture.image.width * levelScale);
20453
20737
  const height = Math.floor(texture.image.height * levelScale);
20454
- let glFormat = utils.convert(texture.format);
20455
-
20456
- if (capabilities.isWebGL2) {
20457
- // Workaround for https://bugs.chromium.org/p/chromium/issues/detail?id=1120100
20458
- // Not needed in Chrome 93+
20459
- if (glFormat === _gl.RGB) glFormat = _gl.RGB8;
20460
- if (glFormat === _gl.RGBA) glFormat = _gl.RGBA8;
20461
- }
20462
-
20463
20738
  textures.setTexture2D(texture, 0);
20464
20739
 
20465
- _gl.copyTexImage2D(_gl.TEXTURE_2D, level, glFormat, position.x, position.y, width, height, 0);
20740
+ _gl.copyTexSubImage2D(_gl.TEXTURE_2D, level, 0, 0, position.x, position.y, width, height);
20466
20741
 
20467
20742
  state.unbindTexture();
20468
20743
  };
@@ -20591,11 +20866,12 @@
20591
20866
  if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
20592
20867
  __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', {
20593
20868
  detail: this
20594
- })); // eslint-disable-line no-undef
20595
-
20869
+ }));
20596
20870
  }
20597
20871
  }
20598
20872
 
20873
+ WebGLRenderer.prototype.isWebGLRenderer = true;
20874
+
20599
20875
  class WebGL1Renderer extends WebGLRenderer {}
20600
20876
 
20601
20877
  WebGL1Renderer.prototype.isWebGL1Renderer = true;
@@ -20661,8 +20937,7 @@
20661
20937
  if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
20662
20938
  __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', {
20663
20939
  detail: this
20664
- })); // eslint-disable-line no-undef
20665
-
20940
+ }));
20666
20941
  }
20667
20942
  }
20668
20943
 
@@ -21427,7 +21702,6 @@
21427
21702
  this.generateMipmaps = false;
21428
21703
  this.flipY = false;
21429
21704
  this.unpackAlignment = 1;
21430
- this.needsUpdate = true;
21431
21705
  }
21432
21706
 
21433
21707
  }
@@ -21551,6 +21825,7 @@
21551
21825
  boneMatrices.set(this.boneMatrices); // copy current values
21552
21826
 
21553
21827
  const boneTexture = new DataTexture(boneMatrices, size, size, RGBAFormat, FloatType);
21828
+ boneTexture.needsUpdate = true;
21554
21829
  this.boneMatrices = boneMatrices;
21555
21830
  this.boneTexture = boneTexture;
21556
21831
  this.boneTextureSize = size;
@@ -22215,6 +22490,23 @@
22215
22490
 
22216
22491
  VideoTexture.prototype.isVideoTexture = true;
22217
22492
 
22493
+ class FramebufferTexture extends Texture {
22494
+ constructor(width, height, format) {
22495
+ super({
22496
+ width,
22497
+ height
22498
+ });
22499
+ this.format = format;
22500
+ this.magFilter = NearestFilter;
22501
+ this.minFilter = NearestFilter;
22502
+ this.generateMipmaps = false;
22503
+ this.needsUpdate = true;
22504
+ }
22505
+
22506
+ }
22507
+
22508
+ FramebufferTexture.prototype.isFramebufferTexture = true;
22509
+
22218
22510
  class CompressedTexture extends Texture {
22219
22511
  constructor(mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding) {
22220
22512
  super(null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);
@@ -22245,31 +22537,6 @@
22245
22537
 
22246
22538
  CanvasTexture.prototype.isCanvasTexture = true;
22247
22539
 
22248
- class DepthTexture extends Texture {
22249
- constructor(width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format) {
22250
- format = format !== undefined ? format : DepthFormat;
22251
-
22252
- if (format !== DepthFormat && format !== DepthStencilFormat) {
22253
- throw new Error('DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat');
22254
- }
22255
-
22256
- if (type === undefined && format === DepthFormat) type = UnsignedShortType;
22257
- if (type === undefined && format === DepthStencilFormat) type = UnsignedInt248Type;
22258
- super(null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);
22259
- this.image = {
22260
- width: width,
22261
- height: height
22262
- };
22263
- this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
22264
- this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
22265
- this.flipY = false;
22266
- this.generateMipmaps = false;
22267
- }
22268
-
22269
- }
22270
-
22271
- DepthTexture.prototype.isDepthTexture = true;
22272
-
22273
22540
  class CircleGeometry extends BufferGeometry {
22274
22541
  constructor(radius = 1, segments = 8, thetaStart = 0, thetaLength = Math.PI * 2) {
22275
22542
  super();
@@ -23438,7 +23705,7 @@
23438
23705
 
23439
23706
  /**
23440
23707
  * Bezier Curves formulas obtained from
23441
- * http://en.wikipedia.org/wiki/Bézier_curve
23708
+ * https://en.wikipedia.org/wiki/B%C3%A9zier_curve
23442
23709
  */
23443
23710
  function CatmullRom(t, p0, p1, p2, p3) {
23444
23711
  const v0 = (p2 - p0) * 0.5;
@@ -25423,11 +25690,55 @@
25423
25690
 
25424
25691
  const indices = [];
25425
25692
  const vertices = [];
25426
- const uvs = []; // helper variables
25693
+ const uvs = [];
25694
+ const initNormals = [];
25695
+ const normals = []; // helper variables
25427
25696
 
25428
25697
  const inverseSegments = 1.0 / segments;
25429
25698
  const vertex = new Vector3();
25430
- const uv = new Vector2(); // generate vertices and uvs
25699
+ const uv = new Vector2();
25700
+ const normal = new Vector3();
25701
+ const curNormal = new Vector3();
25702
+ const prevNormal = new Vector3();
25703
+ let dx = 0;
25704
+ let dy = 0; // pre-compute normals for initial "meridian"
25705
+
25706
+ for (let j = 0; j <= points.length - 1; j++) {
25707
+ switch (j) {
25708
+ case 0:
25709
+ // special handling for 1st vertex on path
25710
+ dx = points[j + 1].x - points[j].x;
25711
+ dy = points[j + 1].y - points[j].y;
25712
+ normal.x = dy * 1.0;
25713
+ normal.y = -dx;
25714
+ normal.z = dy * 0.0;
25715
+ prevNormal.copy(normal);
25716
+ normal.normalize();
25717
+ initNormals.push(normal.x, normal.y, normal.z);
25718
+ break;
25719
+
25720
+ case points.length - 1:
25721
+ // special handling for last Vertex on path
25722
+ initNormals.push(prevNormal.x, prevNormal.y, prevNormal.z);
25723
+ break;
25724
+
25725
+ default:
25726
+ // default handling for all vertices in between
25727
+ dx = points[j + 1].x - points[j].x;
25728
+ dy = points[j + 1].y - points[j].y;
25729
+ normal.x = dy * 1.0;
25730
+ normal.y = -dx;
25731
+ normal.z = dy * 0.0;
25732
+ curNormal.copy(normal);
25733
+ normal.x += prevNormal.x;
25734
+ normal.y += prevNormal.y;
25735
+ normal.z += prevNormal.z;
25736
+ normal.normalize();
25737
+ initNormals.push(normal.x, normal.y, normal.z);
25738
+ prevNormal.copy(curNormal);
25739
+ }
25740
+ } // generate vertices, uvs and normals
25741
+
25431
25742
 
25432
25743
  for (let i = 0; i <= segments; i++) {
25433
25744
  const phi = phiStart + i * inverseSegments * phiLength;
@@ -25443,7 +25754,12 @@
25443
25754
 
25444
25755
  uv.x = i / segments;
25445
25756
  uv.y = j / (points.length - 1);
25446
- uvs.push(uv.x, uv.y);
25757
+ uvs.push(uv.x, uv.y); // normal
25758
+
25759
+ const x = initNormals[3 * j + 0] * sin;
25760
+ const y = initNormals[3 * j + 1];
25761
+ const z = initNormals[3 * j + 0] * cos;
25762
+ normals.push(x, y, z);
25447
25763
  }
25448
25764
  } // indices
25449
25765
 
@@ -25464,36 +25780,8 @@
25464
25780
 
25465
25781
  this.setIndex(indices);
25466
25782
  this.setAttribute('position', new Float32BufferAttribute(vertices, 3));
25467
- this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); // generate normals
25468
-
25469
- this.computeVertexNormals(); // if the geometry is closed, we need to average the normals along the seam.
25470
- // because the corresponding vertices are identical (but still have different UVs).
25471
-
25472
- if (phiLength === Math.PI * 2) {
25473
- const normals = this.attributes.normal.array;
25474
- const n1 = new Vector3();
25475
- const n2 = new Vector3();
25476
- const n = new Vector3(); // this is the buffer offset for the last line of vertices
25477
-
25478
- const base = segments * points.length * 3;
25479
-
25480
- for (let i = 0, j = 0; i < points.length; i++, j += 3) {
25481
- // select the normal of the vertex in the first line
25482
- n1.x = normals[j + 0];
25483
- n1.y = normals[j + 1];
25484
- n1.z = normals[j + 2]; // select the normal of the vertex in the last line
25485
-
25486
- n2.x = normals[base + j + 0];
25487
- n2.y = normals[base + j + 1];
25488
- n2.z = normals[base + j + 2]; // average normals
25489
-
25490
- n.addVectors(n1, n2).normalize(); // assign the new values to both normals
25491
-
25492
- normals[j + 0] = normals[base + j + 0] = n.x;
25493
- normals[j + 1] = normals[base + j + 1] = n.y;
25494
- normals[j + 2] = normals[base + j + 2] = n.z;
25495
- }
25496
- }
25783
+ this.setAttribute('uv', new Float32BufferAttribute(uvs, 2));
25784
+ this.setAttribute('normal', new Float32BufferAttribute(normals, 3));
25497
25785
  }
25498
25786
 
25499
25787
  static fromJSON(data) {
@@ -26395,8 +26683,10 @@
26395
26683
  * reflectivity: <float>,
26396
26684
  *
26397
26685
  * sheen: <float>,
26398
- * sheenTint: <Color>,
26686
+ * sheenColor: <Color>,
26687
+ * sheenColorMap: new THREE.Texture( <Image> ),
26399
26688
  * sheenRoughness: <float>,
26689
+ * sheenRoughnessMap: new THREE.Texture( <Image> ),
26400
26690
  *
26401
26691
  * transmission: <float>,
26402
26692
  * transmissionMap: new THREE.Texture( <Image> ),
@@ -26404,12 +26694,12 @@
26404
26694
  * thickness: <float>,
26405
26695
  * thicknessMap: new THREE.Texture( <Image> ),
26406
26696
  * attenuationDistance: <float>,
26407
- * attenuationTint: <Color>,
26697
+ * attenuationColor: <Color>,
26408
26698
  *
26409
26699
  * specularIntensity: <float>,
26410
- * specularIntensityhMap: new THREE.Texture( <Image> ),
26411
- * specularTint: <Color>,
26412
- * specularTintMap: new THREE.Texture( <Image> )
26700
+ * specularIntensityMap: new THREE.Texture( <Image> ),
26701
+ * specularColor: <Color>,
26702
+ * specularColorMap: new THREE.Texture( <Image> )
26413
26703
  * }
26414
26704
  */
26415
26705
 
@@ -26435,17 +26725,19 @@
26435
26725
  this.ior = (1 + 0.4 * reflectivity) / (1 - 0.4 * reflectivity);
26436
26726
  }
26437
26727
  });
26438
- this.sheenTint = new Color(0x000000);
26728
+ this.sheenColor = new Color(0x000000);
26729
+ this.sheenColorMap = null;
26439
26730
  this.sheenRoughness = 1.0;
26731
+ this.sheenRoughnessMap = null;
26440
26732
  this.transmissionMap = null;
26441
- this.thickness = 0.01;
26733
+ this.thickness = 0;
26442
26734
  this.thicknessMap = null;
26443
26735
  this.attenuationDistance = 0.0;
26444
- this.attenuationTint = new Color(1, 1, 1);
26736
+ this.attenuationColor = new Color(1, 1, 1);
26445
26737
  this.specularIntensity = 1.0;
26446
26738
  this.specularIntensityMap = null;
26447
- this.specularTint = new Color(1, 1, 1);
26448
- this.specularTintMap = null;
26739
+ this.specularColor = new Color(1, 1, 1);
26740
+ this.specularColorMap = null;
26449
26741
  this._sheen = 0.0;
26450
26742
  this._clearcoat = 0;
26451
26743
  this._transmission = 0;
@@ -26502,18 +26794,20 @@
26502
26794
  this.clearcoatNormalScale.copy(source.clearcoatNormalScale);
26503
26795
  this.ior = source.ior;
26504
26796
  this.sheen = source.sheen;
26505
- this.sheenTint.copy(source.sheenTint);
26797
+ this.sheenColor.copy(source.sheenColor);
26798
+ this.sheenColorMap = source.sheenColorMap;
26506
26799
  this.sheenRoughness = source.sheenRoughness;
26800
+ this.sheenRoughnessMap = source.sheenRoughnessMap;
26507
26801
  this.transmission = source.transmission;
26508
26802
  this.transmissionMap = source.transmissionMap;
26509
26803
  this.thickness = source.thickness;
26510
26804
  this.thicknessMap = source.thicknessMap;
26511
26805
  this.attenuationDistance = source.attenuationDistance;
26512
- this.attenuationTint.copy(source.attenuationTint);
26806
+ this.attenuationColor.copy(source.attenuationColor);
26513
26807
  this.specularIntensity = source.specularIntensity;
26514
26808
  this.specularIntensityMap = source.specularIntensityMap;
26515
- this.specularTint.copy(source.specularTint);
26516
- this.specularTintMap = source.specularTintMap;
26809
+ this.specularColor.copy(source.specularColor);
26810
+ this.specularColorMap = source.specularColorMap;
26517
26811
  return this;
26518
26812
  }
26519
26813
 
@@ -28470,14 +28764,13 @@
28470
28764
  if (url === undefined) url = '';
28471
28765
  if (this.path !== undefined) url = this.path + url;
28472
28766
  url = this.manager.resolveURL(url);
28473
- const scope = this;
28474
28767
  const cached = Cache.get(url);
28475
28768
 
28476
28769
  if (cached !== undefined) {
28477
- scope.manager.itemStart(url);
28478
- setTimeout(function () {
28770
+ this.manager.itemStart(url);
28771
+ setTimeout(() => {
28479
28772
  if (onLoad) onLoad(cached);
28480
- scope.manager.itemEnd(url);
28773
+ this.manager.itemEnd(url);
28481
28774
  }, 0);
28482
28775
  return cached;
28483
28776
  } // Check if request is duplicate
@@ -28490,155 +28783,130 @@
28490
28783
  onError: onError
28491
28784
  });
28492
28785
  return;
28493
- } // Check for data: URI
28786
+ } // Initialise array for duplicate requests
28494
28787
 
28495
28788
 
28496
- const dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/;
28497
- const dataUriRegexResult = url.match(dataUriRegex);
28498
- let request; // Safari can not handle Data URIs through XMLHttpRequest so process manually
28789
+ loading[url] = [];
28790
+ loading[url].push({
28791
+ onLoad: onLoad,
28792
+ onProgress: onProgress,
28793
+ onError: onError
28794
+ }); // create request
28499
28795
 
28500
- if (dataUriRegexResult) {
28501
- const mimeType = dataUriRegexResult[1];
28502
- const isBase64 = !!dataUriRegexResult[2];
28503
- let data = dataUriRegexResult[3];
28504
- data = decodeURIComponent(data);
28505
- if (isBase64) data = atob(data);
28796
+ const req = new Request(url, {
28797
+ headers: new Headers(this.requestHeader),
28798
+ credentials: this.withCredentials ? 'include' : 'same-origin' // An abort controller could be added within a future PR
28506
28799
 
28507
- try {
28508
- let response;
28509
- const responseType = (this.responseType || '').toLowerCase();
28800
+ }); // start the fetch
28510
28801
 
28511
- switch (responseType) {
28512
- case 'arraybuffer':
28513
- case 'blob':
28514
- const view = new Uint8Array(data.length);
28802
+ fetch(req).then(response => {
28803
+ if (response.status === 200 || response.status === 0) {
28804
+ // Some browsers return HTTP Status 0 when using non-http protocol
28805
+ // e.g. 'file://' or 'data://'. Handle as success.
28806
+ if (response.status === 0) {
28807
+ console.warn('THREE.FileLoader: HTTP Status 0 received.');
28808
+ }
28515
28809
 
28516
- for (let i = 0; i < data.length; i++) {
28517
- view[i] = data.charCodeAt(i);
28518
- }
28810
+ if (typeof ReadableStream === 'undefined' || response.body.getReader === undefined) {
28811
+ return response;
28812
+ }
28519
28813
 
28520
- if (responseType === 'blob') {
28521
- response = new Blob([view.buffer], {
28522
- type: mimeType
28814
+ const callbacks = loading[url];
28815
+ const reader = response.body.getReader();
28816
+ const contentLength = response.headers.get('Content-Length');
28817
+ const total = contentLength ? parseInt(contentLength) : 0;
28818
+ const lengthComputable = total !== 0;
28819
+ let loaded = 0; // periodically read data into the new stream tracking while download progress
28820
+
28821
+ const stream = new ReadableStream({
28822
+ start(controller) {
28823
+ readData();
28824
+
28825
+ function readData() {
28826
+ reader.read().then(({
28827
+ done,
28828
+ value
28829
+ }) => {
28830
+ if (done) {
28831
+ controller.close();
28832
+ } else {
28833
+ loaded += value.byteLength;
28834
+ const event = new ProgressEvent('progress', {
28835
+ lengthComputable,
28836
+ loaded,
28837
+ total
28838
+ });
28839
+
28840
+ for (let i = 0, il = callbacks.length; i < il; i++) {
28841
+ const callback = callbacks[i];
28842
+ if (callback.onProgress) callback.onProgress(event);
28843
+ }
28844
+
28845
+ controller.enqueue(value);
28846
+ readData();
28847
+ }
28523
28848
  });
28524
- } else {
28525
- response = view.buffer;
28526
28849
  }
28850
+ }
28527
28851
 
28528
- break;
28529
-
28530
- case 'document':
28531
- const parser = new DOMParser();
28532
- response = parser.parseFromString(data, mimeType);
28533
- break;
28534
-
28535
- case 'json':
28536
- response = JSON.parse(data);
28537
- break;
28538
-
28539
- default:
28540
- // 'text' or other
28541
- response = data;
28542
- break;
28543
- } // Wait for next browser tick like standard XMLHttpRequest event dispatching does
28544
-
28545
-
28546
- setTimeout(function () {
28547
- if (onLoad) onLoad(response);
28548
- scope.manager.itemEnd(url);
28549
- }, 0);
28550
- } catch (error) {
28551
- // Wait for next browser tick like standard XMLHttpRequest event dispatching does
28552
- setTimeout(function () {
28553
- if (onError) onError(error);
28554
- scope.manager.itemError(url);
28555
- scope.manager.itemEnd(url);
28556
- }, 0);
28852
+ });
28853
+ return new Response(stream);
28854
+ } else {
28855
+ throw Error(`fetch for "${response.url}" responded with ${response.status}: ${response.statusText}`);
28557
28856
  }
28558
- } else {
28559
- // Initialise array for duplicate requests
28560
- loading[url] = [];
28561
- loading[url].push({
28562
- onLoad: onLoad,
28563
- onProgress: onProgress,
28564
- onError: onError
28565
- });
28566
- request = new XMLHttpRequest();
28567
- request.open('GET', url, true);
28568
- request.addEventListener('load', function (event) {
28569
- const response = this.response;
28570
- const callbacks = loading[url];
28571
- delete loading[url];
28857
+ }).then(response => {
28858
+ switch (this.responseType) {
28859
+ case 'arraybuffer':
28860
+ return response.arrayBuffer();
28572
28861
 
28573
- if (this.status === 200 || this.status === 0) {
28574
- // Some browsers return HTTP Status 0 when using non-http protocol
28575
- // e.g. 'file://' or 'data://'. Handle as success.
28576
- if (this.status === 0) console.warn('THREE.FileLoader: HTTP Status 0 received.'); // Add to cache only on HTTP success, so that we do not cache
28577
- // error response bodies as proper responses to requests.
28862
+ case 'blob':
28863
+ return response.blob();
28578
28864
 
28579
- Cache.add(url, response);
28580
-
28581
- for (let i = 0, il = callbacks.length; i < il; i++) {
28582
- const callback = callbacks[i];
28583
- if (callback.onLoad) callback.onLoad(response);
28584
- }
28585
-
28586
- scope.manager.itemEnd(url);
28587
- } else {
28588
- for (let i = 0, il = callbacks.length; i < il; i++) {
28589
- const callback = callbacks[i];
28590
- if (callback.onError) callback.onError(event);
28591
- }
28865
+ case 'document':
28866
+ return response.text().then(text => {
28867
+ const parser = new DOMParser();
28868
+ return parser.parseFromString(text, this.mimeType);
28869
+ });
28592
28870
 
28593
- scope.manager.itemError(url);
28594
- scope.manager.itemEnd(url);
28595
- }
28596
- }, false);
28597
- request.addEventListener('progress', function (event) {
28598
- const callbacks = loading[url];
28871
+ case 'json':
28872
+ return response.json();
28599
28873
 
28600
- for (let i = 0, il = callbacks.length; i < il; i++) {
28601
- const callback = callbacks[i];
28602
- if (callback.onProgress) callback.onProgress(event);
28603
- }
28604
- }, false);
28605
- request.addEventListener('error', function (event) {
28606
- const callbacks = loading[url];
28607
- delete loading[url];
28874
+ default:
28875
+ return response.text();
28876
+ }
28877
+ }).then(data => {
28878
+ // Add to cache only on HTTP success, so that we do not cache
28879
+ // error response bodies as proper responses to requests.
28880
+ Cache.add(url, data);
28881
+ const callbacks = loading[url];
28882
+ delete loading[url];
28608
28883
 
28609
- for (let i = 0, il = callbacks.length; i < il; i++) {
28610
- const callback = callbacks[i];
28611
- if (callback.onError) callback.onError(event);
28612
- }
28884
+ for (let i = 0, il = callbacks.length; i < il; i++) {
28885
+ const callback = callbacks[i];
28886
+ if (callback.onLoad) callback.onLoad(data);
28887
+ }
28888
+ }).catch(err => {
28889
+ // Abort errors and other errors are handled the same
28890
+ const callbacks = loading[url];
28613
28891
 
28614
- scope.manager.itemError(url);
28615
- scope.manager.itemEnd(url);
28616
- }, false);
28617
- request.addEventListener('abort', function (event) {
28618
- const callbacks = loading[url];
28619
- delete loading[url];
28892
+ if (callbacks === undefined) {
28893
+ // When onLoad was called and url was deleted in `loading`
28894
+ this.manager.itemError(url);
28895
+ throw err;
28896
+ }
28620
28897
 
28621
- for (let i = 0, il = callbacks.length; i < il; i++) {
28622
- const callback = callbacks[i];
28623
- if (callback.onError) callback.onError(event);
28624
- }
28898
+ delete loading[url];
28625
28899
 
28626
- scope.manager.itemError(url);
28627
- scope.manager.itemEnd(url);
28628
- }, false);
28629
- if (this.responseType !== undefined) request.responseType = this.responseType;
28630
- if (this.withCredentials !== undefined) request.withCredentials = this.withCredentials;
28631
- if (request.overrideMimeType) request.overrideMimeType(this.mimeType !== undefined ? this.mimeType : 'text/plain');
28632
-
28633
- for (const header in this.requestHeader) {
28634
- request.setRequestHeader(header, this.requestHeader[header]);
28900
+ for (let i = 0, il = callbacks.length; i < il; i++) {
28901
+ const callback = callbacks[i];
28902
+ if (callback.onError) callback.onError(err);
28635
28903
  }
28636
28904
 
28637
- request.send(null);
28638
- }
28639
-
28640
- scope.manager.itemStart(url);
28641
- return request;
28905
+ this.manager.itemError(url);
28906
+ }).finally(() => {
28907
+ this.manager.itemEnd(url);
28908
+ });
28909
+ this.manager.itemStart(url);
28642
28910
  }
28643
28911
 
28644
28912
  setResponseType(value) {
@@ -28805,21 +29073,24 @@
28805
29073
  const image = createElementNS('img');
28806
29074
 
28807
29075
  function onImageLoad() {
28808
- image.removeEventListener('load', onImageLoad, false);
28809
- image.removeEventListener('error', onImageError, false);
29076
+ removeEventListeners();
28810
29077
  Cache.add(url, this);
28811
29078
  if (onLoad) onLoad(this);
28812
29079
  scope.manager.itemEnd(url);
28813
29080
  }
28814
29081
 
28815
29082
  function onImageError(event) {
28816
- image.removeEventListener('load', onImageLoad, false);
28817
- image.removeEventListener('error', onImageError, false);
29083
+ removeEventListeners();
28818
29084
  if (onError) onError(event);
28819
29085
  scope.manager.itemError(url);
28820
29086
  scope.manager.itemEnd(url);
28821
29087
  }
28822
29088
 
29089
+ function removeEventListeners() {
29090
+ image.removeEventListener('load', onImageLoad, false);
29091
+ image.removeEventListener('error', onImageError, false);
29092
+ }
29093
+
28823
29094
  image.addEventListener('load', onImageLoad, false);
28824
29095
  image.addEventListener('error', onImageError, false);
28825
29096
 
@@ -29631,19 +29902,19 @@
29631
29902
  if (json.roughness !== undefined) material.roughness = json.roughness;
29632
29903
  if (json.metalness !== undefined) material.metalness = json.metalness;
29633
29904
  if (json.sheen !== undefined) material.sheen = json.sheen;
29634
- if (json.sheenTint !== undefined) material.sheenTint = new Color().setHex(json.sheenTint);
29905
+ if (json.sheenColor !== undefined) material.sheenColor = new Color().setHex(json.sheenColor);
29635
29906
  if (json.sheenRoughness !== undefined) material.sheenRoughness = json.sheenRoughness;
29636
29907
  if (json.emissive !== undefined && material.emissive !== undefined) material.emissive.setHex(json.emissive);
29637
29908
  if (json.specular !== undefined && material.specular !== undefined) material.specular.setHex(json.specular);
29638
29909
  if (json.specularIntensity !== undefined) material.specularIntensity = json.specularIntensity;
29639
- if (json.specularTint !== undefined && material.specularTint !== undefined) material.specularTint.setHex(json.specularTint);
29910
+ if (json.specularColor !== undefined && material.specularColor !== undefined) material.specularColor.setHex(json.specularColor);
29640
29911
  if (json.shininess !== undefined) material.shininess = json.shininess;
29641
29912
  if (json.clearcoat !== undefined) material.clearcoat = json.clearcoat;
29642
29913
  if (json.clearcoatRoughness !== undefined) material.clearcoatRoughness = json.clearcoatRoughness;
29643
29914
  if (json.transmission !== undefined) material.transmission = json.transmission;
29644
29915
  if (json.thickness !== undefined) material.thickness = json.thickness;
29645
29916
  if (json.attenuationDistance !== undefined) material.attenuationDistance = json.attenuationDistance;
29646
- if (json.attenuationTint !== undefined && material.attenuationTint !== undefined) material.attenuationTint.setHex(json.attenuationTint);
29917
+ if (json.attenuationColor !== undefined && material.attenuationColor !== undefined) material.attenuationColor.setHex(json.attenuationColor);
29647
29918
  if (json.fog !== undefined) material.fog = json.fog;
29648
29919
  if (json.flatShading !== undefined) material.flatShading = json.flatShading;
29649
29920
  if (json.blending !== undefined) material.blending = json.blending;
@@ -29778,7 +30049,7 @@
29778
30049
  if (json.emissiveIntensity !== undefined) material.emissiveIntensity = json.emissiveIntensity;
29779
30050
  if (json.specularMap !== undefined) material.specularMap = getTexture(json.specularMap);
29780
30051
  if (json.specularIntensityMap !== undefined) material.specularIntensityMap = getTexture(json.specularIntensityMap);
29781
- if (json.specularTintMap !== undefined) material.specularTintMap = getTexture(json.specularTintMap);
30052
+ if (json.specularColorMap !== undefined) material.specularColorMap = getTexture(json.specularColorMap);
29782
30053
  if (json.envMap !== undefined) material.envMap = getTexture(json.envMap);
29783
30054
  if (json.envMapIntensity !== undefined) material.envMapIntensity = json.envMapIntensity;
29784
30055
  if (json.reflectivity !== undefined) material.reflectivity = json.reflectivity;
@@ -29794,6 +30065,8 @@
29794
30065
  if (json.clearcoatNormalScale !== undefined) material.clearcoatNormalScale = new Vector2().fromArray(json.clearcoatNormalScale);
29795
30066
  if (json.transmissionMap !== undefined) material.transmissionMap = getTexture(json.transmissionMap);
29796
30067
  if (json.thicknessMap !== undefined) material.thicknessMap = getTexture(json.thicknessMap);
30068
+ if (json.sheenColorMap !== undefined) material.sheenColorMap = getTexture(json.sheenColorMap);
30069
+ if (json.sheenRoughnessMap !== undefined) material.sheenRoughnessMap = getTexture(json.sheenRoughnessMap);
29797
30070
  return material;
29798
30071
  }
29799
30072
 
@@ -29834,6 +30107,24 @@
29834
30107
  return url.substr(0, index + 1);
29835
30108
  }
29836
30109
 
30110
+ static resolveURL(url, path) {
30111
+ // Invalid URL
30112
+ if (typeof url !== 'string' || url === '') return ''; // Host Relative URL
30113
+
30114
+ if (/^https?:\/\//i.test(path) && /^\//.test(url)) {
30115
+ path = path.replace(/(^https?:\/\/[^\/]+).*/i, '$1');
30116
+ } // Absolute URL http://,https://,//
30117
+
30118
+
30119
+ if (/^(https?:)?\/\//i.test(url)) return url; // Data URI
30120
+
30121
+ if (/^data:.*,.*$/i.test(url)) return url; // Blob URL
30122
+
30123
+ if (/^blob:.*$/i.test(url)) return url; // Relative URL
30124
+
30125
+ return path + url;
30126
+ }
30127
+
29837
30128
  }
29838
30129
 
29839
30130
  class InstancedBufferGeometry extends BufferGeometry {
@@ -30430,6 +30721,7 @@
30430
30721
  if (data.flipY !== undefined) texture.flipY = data.flipY;
30431
30722
  if (data.premultiplyAlpha !== undefined) texture.premultiplyAlpha = data.premultiplyAlpha;
30432
30723
  if (data.unpackAlignment !== undefined) texture.unpackAlignment = data.unpackAlignment;
30724
+ if (data.userData !== undefined) texture.userData = data.userData;
30433
30725
  textures[data.uuid] = texture;
30434
30726
  }
30435
30727
  }
@@ -30875,6 +31167,8 @@
30875
31167
 
30876
31168
  const _eyeLeft = /*@__PURE__*/new Matrix4();
30877
31169
 
31170
+ const _projectionMatrix = /*@__PURE__*/new Matrix4();
31171
+
30878
31172
  class StereoCamera {
30879
31173
  constructor() {
30880
31174
  this.type = 'StereoCamera';
@@ -30911,7 +31205,8 @@
30911
31205
  cache.eyeSep = this.eyeSep; // Off-axis stereoscopic effect based on
30912
31206
  // http://paulbourke.net/stereographics/stereorender/
30913
31207
 
30914
- const projectionMatrix = camera.projectionMatrix.clone();
31208
+ _projectionMatrix.copy(camera.projectionMatrix);
31209
+
30915
31210
  const eyeSepHalf = cache.eyeSep / 2;
30916
31211
  const eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;
30917
31212
  const ymax = cache.near * Math.tan(DEG2RAD * cache.fov * 0.5) / cache.zoom;
@@ -30922,15 +31217,15 @@
30922
31217
 
30923
31218
  xmin = -ymax * cache.aspect + eyeSepOnProjection;
30924
31219
  xmax = ymax * cache.aspect + eyeSepOnProjection;
30925
- projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);
30926
- projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);
30927
- this.cameraL.projectionMatrix.copy(projectionMatrix); // for right eye
31220
+ _projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);
31221
+ _projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);
31222
+ this.cameraL.projectionMatrix.copy(_projectionMatrix); // for right eye
30928
31223
 
30929
31224
  xmin = -ymax * cache.aspect - eyeSepOnProjection;
30930
31225
  xmax = ymax * cache.aspect - eyeSepOnProjection;
30931
- projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);
30932
- projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);
30933
- this.cameraR.projectionMatrix.copy(projectionMatrix);
31226
+ _projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);
31227
+ _projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);
31228
+ this.cameraR.projectionMatrix.copy(_projectionMatrix);
30934
31229
  }
30935
31230
 
30936
31231
  this.cameraL.matrixWorld.copy(camera.matrixWorld).multiply(_eyeLeft);
@@ -33963,28 +34258,6 @@
33963
34258
 
33964
34259
  }
33965
34260
 
33966
- class ImmediateRenderObject extends Object3D {
33967
- constructor(material) {
33968
- super();
33969
- this.material = material;
33970
-
33971
- this.render = function () {};
33972
-
33973
- this.hasPositions = false;
33974
- this.hasNormals = false;
33975
- this.hasColors = false;
33976
- this.hasUvs = false;
33977
- this.positionArray = null;
33978
- this.normalArray = null;
33979
- this.colorArray = null;
33980
- this.uvArray = null;
33981
- this.count = 0;
33982
- }
33983
-
33984
- }
33985
-
33986
- ImmediateRenderObject.prototype.isImmediateRenderObject = true;
33987
-
33988
34261
  const _vector$3 = /*@__PURE__*/new Vector3();
33989
34262
 
33990
34263
  class SpotLightHelper extends Object3D {
@@ -34400,7 +34673,7 @@
34400
34673
  * - shows frustum, line of sight and up of the camera
34401
34674
  * - suitable for fast updates
34402
34675
  * - based on frustum visualization in lightgl.js shadowmap example
34403
- * http://evanw.github.com/lightgl.js/tests/shadowmap.html
34676
+ * https://github.com/evanw/lightgl.js/blob/master/tests/shadowmap.html
34404
34677
  */
34405
34678
 
34406
34679
 
@@ -36102,6 +36375,15 @@
36102
36375
  set: function () {
36103
36376
  console.warn('THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.');
36104
36377
  }
36378
+ },
36379
+ gammaFactor: {
36380
+ get: function () {
36381
+ console.warn('THREE.WebGLRenderer: .gammaFactor has been removed.');
36382
+ return 2;
36383
+ },
36384
+ set: function () {
36385
+ console.warn('THREE.WebGLRenderer: .gammaFactor has been removed.');
36386
+ }
36105
36387
  }
36106
36388
  });
36107
36389
  Object.defineProperties(WebGLShadowMap.prototype, {
@@ -36334,16 +36616,16 @@
36334
36616
  function Font() {
36335
36617
  console.error('THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js');
36336
36618
  }
36619
+ function ImmediateRenderObject() {
36620
+ console.error('THREE.ImmediateRenderObject has been removed.');
36621
+ }
36337
36622
 
36338
36623
  if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
36339
- /* eslint-disable no-undef */
36340
36624
  __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('register', {
36341
36625
  detail: {
36342
36626
  revision: REVISION
36343
36627
  }
36344
36628
  }));
36345
- /* eslint-enable no-undef */
36346
-
36347
36629
  }
36348
36630
 
36349
36631
  if (typeof window !== 'undefined') {
@@ -36481,12 +36763,12 @@
36481
36763
  exports.FogExp2 = FogExp2;
36482
36764
  exports.Font = Font;
36483
36765
  exports.FontLoader = FontLoader;
36766
+ exports.FramebufferTexture = FramebufferTexture;
36484
36767
  exports.FrontSide = FrontSide;
36485
36768
  exports.Frustum = Frustum;
36486
36769
  exports.GLBufferAttribute = GLBufferAttribute;
36487
36770
  exports.GLSL1 = GLSL1;
36488
36771
  exports.GLSL3 = GLSL3;
36489
- exports.GammaEncoding = GammaEncoding;
36490
36772
  exports.GreaterDepth = GreaterDepth;
36491
36773
  exports.GreaterEqualDepth = GreaterEqualDepth;
36492
36774
  exports.GreaterEqualStencilFunc = GreaterEqualStencilFunc;
@@ -36558,7 +36840,6 @@
36558
36840
  exports.Loader = Loader;
36559
36841
  exports.LoaderUtils = LoaderUtils;
36560
36842
  exports.LoadingManager = LoadingManager;
36561
- exports.LogLuvEncoding = LogLuvEncoding;
36562
36843
  exports.LoopOnce = LoopOnce;
36563
36844
  exports.LoopPingPong = LoopPingPong;
36564
36845
  exports.LoopRepeat = LoopRepeat;
@@ -36672,13 +36953,8 @@
36672
36953
  exports.RGBA_S3TC_DXT1_Format = RGBA_S3TC_DXT1_Format;
36673
36954
  exports.RGBA_S3TC_DXT3_Format = RGBA_S3TC_DXT3_Format;
36674
36955
  exports.RGBA_S3TC_DXT5_Format = RGBA_S3TC_DXT5_Format;
36675
- exports.RGBDEncoding = RGBDEncoding;
36676
- exports.RGBEEncoding = RGBEEncoding;
36677
- exports.RGBEFormat = RGBEFormat;
36678
36956
  exports.RGBFormat = RGBFormat;
36679
36957
  exports.RGBIntegerFormat = RGBIntegerFormat;
36680
- exports.RGBM16Encoding = RGBM16Encoding;
36681
- exports.RGBM7Encoding = RGBM7Encoding;
36682
36958
  exports.RGB_ETC1_Format = RGB_ETC1_Format;
36683
36959
  exports.RGB_ETC2_Format = RGB_ETC2_Format;
36684
36960
  exports.RGB_PVRTC_2BPPV1_Format = RGB_PVRTC_2BPPV1_Format;