super-three 0.156.0 → 0.157.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/build/three.cjs +753 -277
  2. package/build/three.js +753 -277
  3. package/build/three.min.js +2 -2
  4. package/build/three.module.js +750 -276
  5. package/build/three.module.min.js +1 -1
  6. package/examples/jsm/capabilities/WebGL.js +17 -0
  7. package/examples/jsm/controls/DragControls.js +3 -2
  8. package/examples/jsm/csm/CSMShader.js +25 -21
  9. package/examples/jsm/exporters/EXRExporter.js +102 -24
  10. package/examples/jsm/exporters/GLTFExporter.js +1 -1
  11. package/examples/jsm/libs/rhino3dm/rhino3dm.js +8726 -4
  12. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8737 -4
  13. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  14. package/examples/jsm/lights/LightProbeGenerator.js +37 -3
  15. package/examples/jsm/lines/LineMaterial.js +90 -156
  16. package/examples/jsm/loaders/3DMLoader.js +378 -104
  17. package/examples/jsm/loaders/GLTFLoader.js +1 -1
  18. package/examples/jsm/loaders/LDrawLoader.js +22 -16
  19. package/examples/jsm/loaders/RGBELoader.js +1 -1
  20. package/examples/jsm/loaders/USDZLoader.js +215 -12
  21. package/examples/jsm/materials/MeshGouraudMaterial.js +22 -18
  22. package/examples/jsm/nodes/Nodes.js +5 -1
  23. package/examples/jsm/nodes/accessors/BitangentNode.js +1 -1
  24. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +2 -2
  25. package/examples/jsm/nodes/accessors/BufferNode.js +1 -1
  26. package/examples/jsm/nodes/accessors/CameraNode.js +1 -1
  27. package/examples/jsm/nodes/accessors/CubeTextureNode.js +2 -2
  28. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +6 -5
  29. package/examples/jsm/nodes/accessors/InstanceNode.js +2 -2
  30. package/examples/jsm/nodes/accessors/LineMaterialNode.js +7 -9
  31. package/examples/jsm/nodes/accessors/MaterialNode.js +34 -46
  32. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +9 -9
  33. package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
  34. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +5 -4
  35. package/examples/jsm/nodes/accessors/MorphNode.js +4 -4
  36. package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
  37. package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
  38. package/examples/jsm/nodes/accessors/PointUVNode.js +1 -1
  39. package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
  40. package/examples/jsm/nodes/accessors/ReferenceNode.js +13 -7
  41. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -2
  42. package/examples/jsm/nodes/accessors/SceneNode.js +2 -2
  43. package/examples/jsm/nodes/accessors/SkinningNode.js +2 -2
  44. package/examples/jsm/nodes/accessors/StorageBufferNode.js +1 -1
  45. package/examples/jsm/nodes/accessors/TangentNode.js +1 -1
  46. package/examples/jsm/nodes/accessors/TextureBicubicNode.js +2 -2
  47. package/examples/jsm/nodes/accessors/TextureNode.js +12 -6
  48. package/examples/jsm/nodes/accessors/TextureSizeNode.js +2 -2
  49. package/examples/jsm/nodes/accessors/TextureStoreNode.js +1 -1
  50. package/examples/jsm/nodes/accessors/UVNode.js +1 -1
  51. package/examples/jsm/nodes/accessors/UserDataNode.js +2 -2
  52. package/examples/jsm/nodes/code/CodeNode.js +1 -1
  53. package/examples/jsm/nodes/code/ExpressionNode.js +1 -1
  54. package/examples/jsm/nodes/code/FunctionCallNode.js +1 -1
  55. package/examples/jsm/nodes/code/FunctionNode.js +18 -7
  56. package/examples/jsm/nodes/code/ScriptableNode.js +2 -2
  57. package/examples/jsm/nodes/code/ScriptableValueNode.js +2 -2
  58. package/examples/jsm/nodes/core/ArrayUniformNode.js +1 -1
  59. package/examples/jsm/nodes/core/AttributeNode.js +1 -1
  60. package/examples/jsm/nodes/core/BypassNode.js +1 -1
  61. package/examples/jsm/nodes/core/CacheNode.js +1 -1
  62. package/examples/jsm/nodes/core/ConstNode.js +1 -1
  63. package/examples/jsm/nodes/core/ContextNode.js +2 -2
  64. package/examples/jsm/nodes/core/IndexNode.js +1 -1
  65. package/examples/jsm/nodes/core/InputNode.js +1 -1
  66. package/examples/jsm/nodes/core/Node.js +28 -13
  67. package/examples/jsm/nodes/core/NodeBuilder.js +3 -17
  68. package/examples/jsm/nodes/core/NodeFrame.js +37 -14
  69. package/examples/jsm/nodes/core/OutputStructNode.js +8 -4
  70. package/examples/jsm/nodes/core/PropertyNode.js +3 -3
  71. package/examples/jsm/nodes/core/StackNode.js +1 -1
  72. package/examples/jsm/nodes/core/StructTypeNode.js +1 -1
  73. package/examples/jsm/nodes/core/TempNode.js +1 -1
  74. package/examples/jsm/nodes/core/UniformNode.js +3 -1
  75. package/examples/jsm/nodes/core/VarNode.js +1 -1
  76. package/examples/jsm/nodes/core/VaryingNode.js +1 -1
  77. package/examples/jsm/nodes/core/constants.js +1 -1
  78. package/examples/jsm/nodes/display/BlendModeNode.js +2 -2
  79. package/examples/jsm/nodes/display/BumpMapNode.js +2 -2
  80. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -2
  81. package/examples/jsm/nodes/display/ColorSpaceNode.js +2 -2
  82. package/examples/jsm/nodes/display/FrontFacingNode.js +1 -1
  83. package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
  84. package/examples/jsm/nodes/display/PosterizeNode.js +2 -2
  85. package/examples/jsm/nodes/display/ToneMappingNode.js +2 -2
  86. package/examples/jsm/nodes/display/ViewportDepthNode.js +2 -2
  87. package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -1
  88. package/examples/jsm/nodes/display/ViewportNode.js +2 -2
  89. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +1 -1
  90. package/examples/jsm/nodes/display/ViewportTextureNode.js +1 -1
  91. package/examples/jsm/nodes/fog/FogExp2Node.js +2 -2
  92. package/examples/jsm/nodes/fog/FogNode.js +2 -2
  93. package/examples/jsm/nodes/fog/FogRangeNode.js +2 -2
  94. package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
  95. package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
  96. package/examples/jsm/nodes/lighting/AONode.js +2 -2
  97. package/examples/jsm/nodes/lighting/AmbientLightNode.js +3 -3
  98. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +4 -4
  99. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +4 -4
  100. package/examples/jsm/nodes/lighting/EnvironmentNode.js +2 -2
  101. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +3 -3
  102. package/examples/jsm/nodes/lighting/IESSpotLightNode.js +2 -2
  103. package/examples/jsm/nodes/lighting/LightNode.js +2 -2
  104. package/examples/jsm/nodes/lighting/LightingContextNode.js +3 -3
  105. package/examples/jsm/nodes/lighting/LightingNode.js +1 -1
  106. package/examples/jsm/nodes/lighting/LightsNode.js +4 -4
  107. package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
  108. package/examples/jsm/nodes/lighting/SpotLightNode.js +4 -4
  109. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +449 -0
  110. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +1 -1
  111. package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +2 -2
  112. package/examples/jsm/nodes/materials/Materials.js +1 -0
  113. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -1
  114. package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +2 -2
  115. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
  116. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
  117. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
  118. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +3 -3
  119. package/examples/jsm/nodes/materials/NodeMaterial.js +27 -26
  120. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +1 -1
  121. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
  122. package/examples/jsm/nodes/math/CondNode.js +1 -1
  123. package/examples/jsm/nodes/math/HashNode.js +8 -9
  124. package/examples/jsm/nodes/math/MathNode.js +2 -2
  125. package/examples/jsm/nodes/math/OperatorNode.js +1 -1
  126. package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
  127. package/examples/jsm/nodes/shadernode/ShaderNode.js +81 -28
  128. package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
  129. package/examples/jsm/nodes/utils/ConvertNode.js +1 -1
  130. package/examples/jsm/nodes/utils/DiscardNode.js +1 -1
  131. package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -2
  132. package/examples/jsm/nodes/utils/JoinNode.js +1 -1
  133. package/examples/jsm/nodes/utils/LoopNode.js +11 -11
  134. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -2
  135. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
  136. package/examples/jsm/nodes/utils/OscNode.js +2 -2
  137. package/examples/jsm/nodes/utils/PackingNode.js +2 -2
  138. package/examples/jsm/nodes/utils/RemapNode.js +2 -2
  139. package/examples/jsm/nodes/utils/RotateUVNode.js +2 -2
  140. package/examples/jsm/nodes/utils/SetNode.js +62 -0
  141. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +2 -2
  142. package/examples/jsm/nodes/utils/SplitNode.js +1 -1
  143. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +2 -2
  144. package/examples/jsm/nodes/utils/TimerNode.js +2 -2
  145. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +2 -2
  146. package/examples/jsm/objects/Sky.js +1 -3
  147. package/examples/jsm/postprocessing/OutputPass.js +3 -2
  148. package/examples/jsm/renderers/common/Background.js +2 -2
  149. package/examples/jsm/renderers/common/Bindings.js +3 -5
  150. package/examples/jsm/renderers/common/Pipelines.js +7 -7
  151. package/examples/jsm/renderers/common/RenderContext.js +3 -0
  152. package/examples/jsm/renderers/common/RenderObject.js +40 -16
  153. package/examples/jsm/renderers/common/RenderObjects.js +8 -14
  154. package/examples/jsm/renderers/common/Renderer.js +40 -13
  155. package/examples/jsm/renderers/common/SampledTexture.js +4 -2
  156. package/examples/jsm/renderers/common/StorageTexture.js +19 -0
  157. package/examples/jsm/renderers/common/Textures.js +14 -9
  158. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +35 -0
  159. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +20 -10
  160. package/examples/jsm/renderers/common/nodes/NodeSampler.js +0 -6
  161. package/examples/jsm/renderers/common/nodes/Nodes.js +51 -24
  162. package/examples/jsm/renderers/webgl/WebGLBackend.js +100 -5
  163. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +92 -6
  164. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +13 -0
  165. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +3 -3
  166. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +14 -2
  167. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +5 -5
  168. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +6 -3
  169. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
  170. package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
  171. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +197 -167
  172. package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
  173. package/examples/jsm/shaders/MMDToonShader.js +4 -4
  174. package/examples/jsm/shaders/OutputShader.js +2 -2
  175. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +6 -6
  176. package/examples/jsm/utils/BufferGeometryUtils.js +6 -4
  177. package/package.json +1 -1
  178. package/src/Three.js +0 -2
  179. package/src/animation/AnimationUtils.js +3 -20
  180. package/src/animation/KeyframeTrack.js +8 -8
  181. package/src/cameras/Camera.js +1 -5
  182. package/src/cameras/CubeCamera.js +14 -8
  183. package/src/constants.js +7 -1
  184. package/src/core/RenderTarget.js +16 -7
  185. package/src/extras/core/CurvePath.js +4 -1
  186. package/src/loaders/MaterialLoader.js +1 -1
  187. package/src/loaders/ObjectLoader.js +6 -0
  188. package/src/materials/Material.js +8 -8
  189. package/src/math/Color.js +1 -5
  190. package/src/math/ColorManagement.js +82 -60
  191. package/src/objects/Sprite.js +2 -2
  192. package/src/renderers/WebGLMultiviewRenderTarget.js +35 -0
  193. package/src/renderers/WebGLRenderer.js +78 -22
  194. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
  195. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +1 -1
  196. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +35 -2
  197. package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -9
  198. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +19 -15
  199. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +2 -2
  200. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +4 -4
  201. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +3 -3
  202. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -6
  203. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +4 -4
  204. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +1 -1
  205. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +16 -16
  206. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +3 -3
  207. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +1 -1
  208. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
  209. package/src/renderers/shaders/UniformsUtils.js +2 -2
  210. package/src/renderers/webgl/WebGLBackground.js +5 -4
  211. package/src/renderers/webgl/WebGLLights.js +14 -3
  212. package/src/renderers/webgl/WebGLMultiview.js +100 -0
  213. package/src/renderers/webgl/WebGLProgram.js +84 -5
  214. package/src/renderers/webgl/WebGLPrograms.js +11 -2
  215. package/src/renderers/webgl/WebGLTextures.js +214 -26
  216. package/src/renderers/webgl/WebGLUtils.js +21 -23
  217. package/src/renderers/webxr/WebXRManager.js +36 -12
  218. package/src/scenes/Fog.js +1 -0
  219. package/src/scenes/FogExp2.js +1 -0
  220. package/src/textures/Source.js +2 -2
  221. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
  222. package/src/lights/AmbientLightProbe.js +0 -21
  223. package/src/lights/HemisphereLightProbe.js +0 -30
@@ -3,7 +3,7 @@
3
3
  * Copyright 2010-2023 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
5
  */
6
- const REVISION = '156';
6
+ const REVISION = '157';
7
7
 
8
8
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
9
9
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -163,6 +163,12 @@ const LinearSRGBColorSpace = 'srgb-linear';
163
163
  const DisplayP3ColorSpace = 'display-p3';
164
164
  const LinearDisplayP3ColorSpace = 'display-p3-linear';
165
165
 
166
+ const LinearTransfer = 'linear';
167
+ const SRGBTransfer = 'srgb';
168
+
169
+ const Rec709Primaries = 'rec709';
170
+ const P3Primaries = 'p3';
171
+
166
172
  const ZeroStencilOp = 0;
167
173
  const KeepStencilOp = 7680;
168
174
  const ReplaceStencilOp = 7681;
@@ -1551,18 +1557,6 @@ function warnOnce( message ) {
1551
1557
 
1552
1558
  }
1553
1559
 
1554
- function SRGBToLinear( c ) {
1555
-
1556
- return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
1557
-
1558
- }
1559
-
1560
- function LinearToSRGB( c ) {
1561
-
1562
- return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;
1563
-
1564
- }
1565
-
1566
1560
  /**
1567
1561
  * Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
1568
1562
  * or clipping. Based on W3C specifications for sRGB and Display P3,
@@ -1575,50 +1569,57 @@ function LinearToSRGB( c ) {
1575
1569
  * - http://www.russellcottrell.com/photo/matrixCalculator.htm
1576
1570
  */
1577
1571
 
1578
- const LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = /*@__PURE__*/ new Matrix3().fromArray( [
1579
- 0.8224621, 0.0331941, 0.0170827,
1580
- 0.1775380, 0.9668058, 0.0723974,
1581
- - 0.0000001, 0.0000001, 0.9105199
1582
- ] );
1583
-
1584
- const LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = /*@__PURE__*/ new Matrix3().fromArray( [
1585
- 1.2249401, - 0.0420569, - 0.0196376,
1586
- - 0.2249404, 1.0420571, - 0.0786361,
1587
- 0.0000001, 0.0000000, 1.0982735
1588
- ] );
1589
-
1590
- function DisplayP3ToLinearSRGB( color ) {
1591
-
1592
- // Display P3 uses the sRGB transfer functions
1593
- return color.convertSRGBToLinear().applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB );
1594
-
1595
- }
1596
-
1597
- function LinearSRGBToDisplayP3( color ) {
1598
-
1599
- // Display P3 uses the sRGB transfer functions
1600
- return color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ).convertLinearToSRGB();
1572
+ const LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = /*@__PURE__*/ new Matrix3().set(
1573
+ 0.8224621, 0.177538, 0.0,
1574
+ 0.0331941, 0.9668058, 0.0,
1575
+ 0.0170827, 0.0723974, 0.9105199,
1576
+ );
1601
1577
 
1602
- }
1578
+ const LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = /*@__PURE__*/ new Matrix3().set(
1579
+ 1.2249401, - 0.2249404, 0.0,
1580
+ - 0.0420569, 1.0420571, 0.0,
1581
+ - 0.0196376, - 0.0786361, 1.0982735
1582
+ );
1603
1583
 
1604
- // Conversions from <source> to Linear-sRGB reference space.
1605
- const TO_LINEAR = {
1606
- [ LinearSRGBColorSpace ]: ( color ) => color,
1607
- [ SRGBColorSpace ]: ( color ) => color.convertSRGBToLinear(),
1608
- [ DisplayP3ColorSpace ]: DisplayP3ToLinearSRGB,
1584
+ /**
1585
+ * Defines supported color spaces by transfer function and primaries,
1586
+ * and provides conversions to/from the Linear-sRGB reference space.
1587
+ */
1588
+ const COLOR_SPACES = {
1589
+ [ LinearSRGBColorSpace ]: {
1590
+ transfer: LinearTransfer,
1591
+ primaries: Rec709Primaries,
1592
+ toReference: ( color ) => color,
1593
+ fromReference: ( color ) => color,
1594
+ },
1595
+ [ SRGBColorSpace ]: {
1596
+ transfer: SRGBTransfer,
1597
+ primaries: Rec709Primaries,
1598
+ toReference: ( color ) => color.convertSRGBToLinear(),
1599
+ fromReference: ( color ) => color.convertLinearToSRGB(),
1600
+ },
1601
+ [ LinearDisplayP3ColorSpace ]: {
1602
+ transfer: LinearTransfer,
1603
+ primaries: P3Primaries,
1604
+ toReference: ( color ) => color.applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
1605
+ fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ),
1606
+ },
1607
+ [ DisplayP3ColorSpace ]: {
1608
+ transfer: SRGBTransfer,
1609
+ primaries: P3Primaries,
1610
+ toReference: ( color ) => color.convertSRGBToLinear().applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
1611
+ fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ).convertLinearToSRGB(),
1612
+ },
1609
1613
  };
1610
1614
 
1611
- // Conversions to <target> from Linear-sRGB reference space.
1612
- const FROM_LINEAR = {
1613
- [ LinearSRGBColorSpace ]: ( color ) => color,
1614
- [ SRGBColorSpace ]: ( color ) => color.convertLinearToSRGB(),
1615
- [ DisplayP3ColorSpace ]: LinearSRGBToDisplayP3,
1616
- };
1615
+ const SUPPORTED_WORKING_COLOR_SPACES = new Set( [ LinearSRGBColorSpace, LinearDisplayP3ColorSpace ] );
1617
1616
 
1618
1617
  const ColorManagement = {
1619
1618
 
1620
1619
  enabled: true,
1621
1620
 
1621
+ _workingColorSpace: LinearSRGBColorSpace,
1622
+
1622
1623
  get legacyMode() {
1623
1624
 
1624
1625
  console.warn( 'THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150.' );
@@ -1637,13 +1638,19 @@ const ColorManagement = {
1637
1638
 
1638
1639
  get workingColorSpace() {
1639
1640
 
1640
- return LinearSRGBColorSpace;
1641
+ return this._workingColorSpace;
1641
1642
 
1642
1643
  },
1643
1644
 
1644
1645
  set workingColorSpace( colorSpace ) {
1645
1646
 
1646
- console.warn( 'THREE.ColorManagement: .workingColorSpace is readonly.' );
1647
+ if ( ! SUPPORTED_WORKING_COLOR_SPACES.has( colorSpace ) ) {
1648
+
1649
+ throw new Error( `Unsupported working color space, "${ colorSpace }".` );
1650
+
1651
+ }
1652
+
1653
+ this._workingColorSpace = colorSpace;
1647
1654
 
1648
1655
  },
1649
1656
 
@@ -1655,33 +1662,54 @@ const ColorManagement = {
1655
1662
 
1656
1663
  }
1657
1664
 
1658
- const sourceToLinear = TO_LINEAR[ sourceColorSpace ];
1659
- const targetFromLinear = FROM_LINEAR[ targetColorSpace ];
1665
+ const sourceToReference = COLOR_SPACES[ sourceColorSpace ].toReference;
1666
+ const targetFromReference = COLOR_SPACES[ targetColorSpace ].fromReference;
1660
1667
 
1661
- if ( sourceToLinear === undefined || targetFromLinear === undefined ) {
1668
+ return targetFromReference( sourceToReference( color ) );
1662
1669
 
1663
- throw new Error( `Unsupported color space conversion, "${ sourceColorSpace }" to "${ targetColorSpace }".` );
1670
+ },
1664
1671
 
1665
- }
1672
+ fromWorkingColorSpace: function ( color, targetColorSpace ) {
1666
1673
 
1667
- return targetFromLinear( sourceToLinear( color ) );
1674
+ return this.convert( color, this._workingColorSpace, targetColorSpace );
1668
1675
 
1669
1676
  },
1670
1677
 
1671
- fromWorkingColorSpace: function ( color, targetColorSpace ) {
1678
+ toWorkingColorSpace: function ( color, sourceColorSpace ) {
1672
1679
 
1673
- return this.convert( color, this.workingColorSpace, targetColorSpace );
1680
+ return this.convert( color, sourceColorSpace, this._workingColorSpace );
1674
1681
 
1675
1682
  },
1676
1683
 
1677
- toWorkingColorSpace: function ( color, sourceColorSpace ) {
1684
+ getPrimaries: function ( colorSpace ) {
1678
1685
 
1679
- return this.convert( color, sourceColorSpace, this.workingColorSpace );
1686
+ return COLOR_SPACES[ colorSpace ].primaries;
1687
+
1688
+ },
1689
+
1690
+ getTransfer: function ( colorSpace ) {
1691
+
1692
+ if ( colorSpace === NoColorSpace ) return LinearTransfer;
1693
+
1694
+ return COLOR_SPACES[ colorSpace ].transfer;
1680
1695
 
1681
1696
  },
1682
1697
 
1683
1698
  };
1684
1699
 
1700
+
1701
+ function SRGBToLinear( c ) {
1702
+
1703
+ return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
1704
+
1705
+ }
1706
+
1707
+ function LinearToSRGB( c ) {
1708
+
1709
+ return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;
1710
+
1711
+ }
1712
+
1685
1713
  let _canvas;
1686
1714
 
1687
1715
  class ImageUtils {
@@ -1807,7 +1835,7 @@ class ImageUtils {
1807
1835
 
1808
1836
  }
1809
1837
 
1810
- let sourceId = 0;
1838
+ let _sourceId = 0;
1811
1839
 
1812
1840
  class Source {
1813
1841
 
@@ -1815,7 +1843,7 @@ class Source {
1815
1843
 
1816
1844
  this.isSource = true;
1817
1845
 
1818
- Object.defineProperty( this, 'id', { value: sourceId ++ } );
1846
+ Object.defineProperty( this, 'id', { value: _sourceId ++ } );
1819
1847
 
1820
1848
  this.uuid = generateUUID();
1821
1849
 
@@ -2921,20 +2949,29 @@ class RenderTarget extends EventDispatcher {
2921
2949
 
2922
2950
  }
2923
2951
 
2952
+ options = Object.assign( {
2953
+ generateMipmaps: false,
2954
+ internalFormat: null,
2955
+ minFilter: LinearFilter,
2956
+ depthBuffer: true,
2957
+ stencilBuffer: false,
2958
+ depthTexture: null,
2959
+ samples: 0
2960
+ }, options );
2961
+
2924
2962
  this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
2925
2963
  this.texture.isRenderTargetTexture = true;
2926
2964
 
2927
2965
  this.texture.flipY = false;
2928
- this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
2929
- this.texture.internalFormat = options.internalFormat !== undefined ? options.internalFormat : null;
2930
- this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
2966
+ this.texture.generateMipmaps = options.generateMipmaps;
2967
+ this.texture.internalFormat = options.internalFormat;
2931
2968
 
2932
- this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
2933
- this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;
2969
+ this.depthBuffer = options.depthBuffer;
2970
+ this.stencilBuffer = options.stencilBuffer;
2934
2971
 
2935
- this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
2972
+ this.depthTexture = options.depthTexture;
2936
2973
 
2937
- this.samples = options.samples !== undefined ? options.samples : 0;
2974
+ this.samples = options.samples;
2938
2975
 
2939
2976
  }
2940
2977
 
@@ -8702,10 +8739,10 @@ class Material extends EventDispatcher {
8702
8739
 
8703
8740
  if ( this.blending !== NormalBlending ) data.blending = this.blending;
8704
8741
  if ( this.side !== FrontSide ) data.side = this.side;
8705
- if ( this.vertexColors ) data.vertexColors = true;
8742
+ if ( this.vertexColors === true ) data.vertexColors = true;
8706
8743
 
8707
8744
  if ( this.opacity < 1 ) data.opacity = this.opacity;
8708
- if ( this.transparent === true ) data.transparent = this.transparent;
8745
+ if ( this.transparent === true ) data.transparent = true;
8709
8746
 
8710
8747
  data.depthFunc = this.depthFunc;
8711
8748
  data.depthTest = this.depthTest;
@@ -8736,17 +8773,17 @@ class Material extends EventDispatcher {
8736
8773
  if ( this.dithering === true ) data.dithering = true;
8737
8774
 
8738
8775
  if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;
8739
- if ( this.alphaHash === true ) data.alphaHash = this.alphaHash;
8740
- if ( this.alphaToCoverage === true ) data.alphaToCoverage = this.alphaToCoverage;
8741
- if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha;
8742
- if ( this.forceSinglePass === true ) data.forceSinglePass = this.forceSinglePass;
8776
+ if ( this.alphaHash === true ) data.alphaHash = true;
8777
+ if ( this.alphaToCoverage === true ) data.alphaToCoverage = true;
8778
+ if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = true;
8779
+ if ( this.forceSinglePass === true ) data.forceSinglePass = true;
8743
8780
 
8744
- if ( this.wireframe === true ) data.wireframe = this.wireframe;
8781
+ if ( this.wireframe === true ) data.wireframe = true;
8745
8782
  if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;
8746
8783
  if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;
8747
8784
  if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;
8748
8785
 
8749
- if ( this.flatShading === true ) data.flatShading = this.flatShading;
8786
+ if ( this.flatShading === true ) data.flatShading = true;
8750
8787
 
8751
8788
  if ( this.visible === false ) data.visible = false;
8752
8789
 
@@ -9327,11 +9364,7 @@ class Color {
9327
9364
 
9328
9365
  this.getHSL( _hslA );
9329
9366
 
9330
- _hslA.h += h; _hslA.s += s; _hslA.l += l;
9331
-
9332
- this.setHSL( _hslA.h, _hslA.s, _hslA.l );
9333
-
9334
- return this;
9367
+ return this.setHSL( _hslA.h + h, _hslA.s + s, _hslA.l + l );
9335
9368
 
9336
9369
  }
9337
9370
 
@@ -12114,7 +12147,7 @@ function getUnlitUniformColorSpace( renderer ) {
12114
12147
 
12115
12148
  }
12116
12149
 
12117
- return LinearSRGBColorSpace;
12150
+ return ColorManagement.workingColorSpace;
12118
12151
 
12119
12152
  }
12120
12153
 
@@ -12342,11 +12375,7 @@ class Camera extends Object3D {
12342
12375
 
12343
12376
  getWorldDirection( target ) {
12344
12377
 
12345
- this.updateWorldMatrix( true, false );
12346
-
12347
- const e = this.matrixWorld.elements;
12348
-
12349
- return target.set( - e[ 8 ], - e[ 9 ], - e[ 10 ] ).normalize();
12378
+ return super.getWorldDirection( target ).negate();
12350
12379
 
12351
12380
  }
12352
12381
 
@@ -12616,6 +12645,7 @@ class CubeCamera extends Object3D {
12616
12645
 
12617
12646
  this.renderTarget = renderTarget;
12618
12647
  this.coordinateSystem = null;
12648
+ this.activeMipmapLevel = 0;
12619
12649
 
12620
12650
  const cameraPX = new PerspectiveCamera( fov, aspect, near, far );
12621
12651
  cameraPX.layers = this.layers;
@@ -12713,7 +12743,7 @@ class CubeCamera extends Object3D {
12713
12743
 
12714
12744
  if ( this.parent === null ) this.updateMatrixWorld();
12715
12745
 
12716
- const renderTarget = this.renderTarget;
12746
+ const { renderTarget, activeMipmapLevel } = this;
12717
12747
 
12718
12748
  if ( this.coordinateSystem !== renderer.coordinateSystem ) {
12719
12749
 
@@ -12726,6 +12756,8 @@ class CubeCamera extends Object3D {
12726
12756
  const [ cameraPX, cameraNX, cameraPY, cameraNY, cameraPZ, cameraNZ ] = this.children;
12727
12757
 
12728
12758
  const currentRenderTarget = renderer.getRenderTarget();
12759
+ const currentActiveCubeFace = renderer.getActiveCubeFace();
12760
+ const currentActiveMipmapLevel = renderer.getActiveMipmapLevel();
12729
12761
 
12730
12762
  const currentXrEnabled = renderer.xr.enabled;
12731
12763
 
@@ -12735,27 +12767,30 @@ class CubeCamera extends Object3D {
12735
12767
 
12736
12768
  renderTarget.texture.generateMipmaps = false;
12737
12769
 
12738
- renderer.setRenderTarget( renderTarget, 0 );
12770
+ renderer.setRenderTarget( renderTarget, 0, activeMipmapLevel );
12739
12771
  renderer.render( scene, cameraPX );
12740
12772
 
12741
- renderer.setRenderTarget( renderTarget, 1 );
12773
+ renderer.setRenderTarget( renderTarget, 1, activeMipmapLevel );
12742
12774
  renderer.render( scene, cameraNX );
12743
12775
 
12744
- renderer.setRenderTarget( renderTarget, 2 );
12776
+ renderer.setRenderTarget( renderTarget, 2, activeMipmapLevel );
12745
12777
  renderer.render( scene, cameraPY );
12746
12778
 
12747
- renderer.setRenderTarget( renderTarget, 3 );
12779
+ renderer.setRenderTarget( renderTarget, 3, activeMipmapLevel );
12748
12780
  renderer.render( scene, cameraNY );
12749
12781
 
12750
- renderer.setRenderTarget( renderTarget, 4 );
12782
+ renderer.setRenderTarget( renderTarget, 4, activeMipmapLevel );
12751
12783
  renderer.render( scene, cameraPZ );
12752
12784
 
12785
+ // mipmaps are generated during the last call of render()
12786
+ // at this point, all sides of the cube render target are defined
12787
+
12753
12788
  renderTarget.texture.generateMipmaps = generateMipmaps;
12754
12789
 
12755
- renderer.setRenderTarget( renderTarget, 5 );
12790
+ renderer.setRenderTarget( renderTarget, 5, activeMipmapLevel );
12756
12791
  renderer.render( scene, cameraNZ );
12757
12792
 
12758
- renderer.setRenderTarget( currentRenderTarget );
12793
+ renderer.setRenderTarget( currentRenderTarget, currentActiveCubeFace, currentActiveMipmapLevel );
12759
12794
 
12760
12795
  renderer.xr.enabled = currentXrEnabled;
12761
12796
 
@@ -13669,7 +13704,7 @@ var alphatest_fragment = "#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTes
13669
13704
 
13670
13705
  var alphatest_pars_fragment = "#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif";
13671
13706
 
13672
- var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif";
13707
+ var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif";
13673
13708
 
13674
13709
  var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
13675
13710
 
@@ -13699,7 +13734,7 @@ var color_pars_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\
13699
13734
 
13700
13735
  var color_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif";
13701
13736
 
13702
- 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; }\nvec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }\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};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\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 luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, 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}\nvec3 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 F_Schlick( const in float 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} // validated";
13737
+ 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; }\nvec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }\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};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\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 luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, 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}\nvec3 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 F_Schlick( const in float 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} // validated";
13703
13738
 
13704
13739
  var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.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\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\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\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_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 ), cubeUV_m0, CUBEUV_MAX_MIP );\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";
13705
13740
 
@@ -13715,7 +13750,7 @@ var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emi
13715
13750
 
13716
13751
  var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
13717
13752
 
13718
- var colorspace_pars_fragment = "vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}";
13753
+ var colorspace_pars_fragment = "\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( 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 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\n}";
13719
13754
 
13720
13755
  var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
13721
13756
 
@@ -13743,29 +13778,29 @@ var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;
13743
13778
 
13744
13779
  var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
13745
13780
 
13746
- var lights_lambert_pars_fragment = "varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert";
13781
+ var lights_lambert_pars_fragment = "varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert";
13747
13782
 
13748
- var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif";
13783
+ var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif";
13749
13784
 
13750
13785
  var envmap_physical_pars_fragment = "#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif";
13751
13786
 
13752
13787
  var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;";
13753
13788
 
13754
- var lights_toon_pars_fragment = "varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon";
13789
+ var lights_toon_pars_fragment = "varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon";
13755
13790
 
13756
13791
  var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
13757
13792
 
13758
- 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";
13793
+ 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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";
13759
13794
 
13760
- var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif";
13795
+ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif";
13761
13796
 
13762
- 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_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\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}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.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\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\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}\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\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}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\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#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 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_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\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 );\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\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\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}";
13797
+ 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_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\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}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.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\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\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}\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\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}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\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#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\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}";
13763
13798
 
13764
- 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\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\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 *= ( 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\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\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 ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ 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 *= ( 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";
13799
+ var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal;\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\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, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( 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, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\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, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( 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, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, 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\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\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 ], geometryNormal );\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";
13765
13800
 
13766
- var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif";
13801
+ var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif";
13767
13802
 
13768
- var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif";
13803
+ var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif";
13769
13804
 
13770
13805
  var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
13771
13806
 
@@ -13795,7 +13830,7 @@ var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\tuniform float morphTar
13795
13830
 
13796
13831
  var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif";
13797
13832
 
13798
- var normal_fragment_begin = "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;";
13833
+ var normal_fragment_begin = "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;";
13799
13834
 
13800
13835
  var normal_fragment_maps = "#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif";
13801
13836
 
@@ -13807,7 +13842,7 @@ var normal_vertex = "#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNorm
13807
13842
 
13808
13843
  var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif";
13809
13844
 
13810
- var clearcoat_normal_fragment_begin = "#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif";
13845
+ var clearcoat_normal_fragment_begin = "#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif";
13811
13846
 
13812
13847
  var clearcoat_normal_fragment_maps = "#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif";
13813
13848
 
@@ -13917,7 +13952,7 @@ const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;
13917
13952
 
13918
13953
  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 <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 <color_vertex>\n\t#include <morphcolor_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}";
13919
13954
 
13920
- const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_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 USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\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 <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\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 <iridescence_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 <alphahash_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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13955
+ const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_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 USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\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 <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\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 <iridescence_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 <alphahash_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( geometryClearcoatNormal, geometryViewDir ) );\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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13921
13956
 
13922
13957
  const vertex$4 = "#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_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 <color_vertex>\n\t#include <morphcolor_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}";
13923
13958
 
@@ -14712,7 +14747,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
14712
14747
  if ( boxMesh === undefined ) {
14713
14748
 
14714
14749
  boxMesh = new Mesh(
14715
- new BoxGeometry( 1, 1, 1 ),
14750
+ new BoxGeometry( 10000, 10000, 10000 ),
14716
14751
  new ShaderMaterial( {
14717
14752
  name: 'BackgroundCubeMaterial',
14718
14753
  uniforms: cloneUniforms( ShaderLib.backgroundCube.uniforms ),
@@ -14753,7 +14788,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
14753
14788
  boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
14754
14789
  boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
14755
14790
  boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
14756
- boxMesh.material.toneMapped = ( background.colorSpace === SRGBColorSpace ) ? false : true;
14791
+ boxMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;
14757
14792
 
14758
14793
  if ( currentBackground !== background ||
14759
14794
  currentBackgroundVersion !== background.version ||
@@ -14809,7 +14844,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
14809
14844
 
14810
14845
  planeMesh.material.uniforms.t2D.value = background;
14811
14846
  planeMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
14812
- planeMesh.material.toneMapped = ( background.colorSpace === SRGBColorSpace ) ? false : true;
14847
+ planeMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;
14813
14848
 
14814
14849
  if ( background.matrixAutoUpdate === true ) {
14815
14850
 
@@ -17808,6 +17843,103 @@ function WebGLMorphtargets( gl, capabilities, textures ) {
17808
17843
 
17809
17844
  }
17810
17845
 
17846
+ /**
17847
+ * @author fernandojsg / http://fernandojsg.com
17848
+ * @author Takahiro https://github.com/takahirox
17849
+ */
17850
+
17851
+ class WebGLMultiview {
17852
+
17853
+ constructor( renderer, extensions, gl ) {
17854
+
17855
+ this.renderer = renderer;
17856
+
17857
+ this.DEFAULT_NUMVIEWS = 2;
17858
+ this.maxNumViews = 0;
17859
+ this.gl = gl;
17860
+
17861
+ this.extensions = extensions;
17862
+
17863
+ this.available = this.extensions.has( 'OCULUS_multiview' );
17864
+
17865
+ if ( this.available ) {
17866
+
17867
+ const extension = this.extensions.get( 'OCULUS_multiview' );
17868
+
17869
+ this.maxNumViews = this.gl.getParameter( extension.MAX_VIEWS_OVR );
17870
+
17871
+ this.mat4 = [];
17872
+ this.mat3 = [];
17873
+ this.cameraArray = [];
17874
+
17875
+ for ( var i = 0; i < this.maxNumViews; i ++ ) {
17876
+
17877
+ this.mat4[ i ] = new Matrix4();
17878
+ this.mat3[ i ] = new Matrix3();
17879
+
17880
+ }
17881
+
17882
+ }
17883
+
17884
+ }
17885
+
17886
+ //
17887
+ getCameraArray( camera ) {
17888
+
17889
+ if ( camera.isArrayCamera ) return camera.cameras;
17890
+
17891
+ this.cameraArray[ 0 ] = camera;
17892
+
17893
+ return this.cameraArray;
17894
+
17895
+ }
17896
+
17897
+ updateCameraProjectionMatricesUniform( camera, uniforms ) {
17898
+
17899
+ var cameras = this.getCameraArray( camera );
17900
+
17901
+ for ( var i = 0; i < cameras.length; i ++ ) {
17902
+
17903
+ this.mat4[ i ].copy( cameras[ i ].projectionMatrix );
17904
+
17905
+ }
17906
+
17907
+ uniforms.setValue( this.gl, 'projectionMatrices', this.mat4 );
17908
+
17909
+ }
17910
+
17911
+ updateCameraViewMatricesUniform( camera, uniforms ) {
17912
+
17913
+ var cameras = this.getCameraArray( camera );
17914
+
17915
+ for ( var i = 0; i < cameras.length; i ++ ) {
17916
+
17917
+ this.mat4[ i ].copy( cameras[ i ].matrixWorldInverse );
17918
+
17919
+ }
17920
+
17921
+ uniforms.setValue( this.gl, 'viewMatrices', this.mat4 );
17922
+
17923
+ }
17924
+
17925
+ updateObjectMatricesUniforms( object, camera, uniforms ) {
17926
+
17927
+ var cameras = this.getCameraArray( camera );
17928
+
17929
+ for ( var i = 0; i < cameras.length; i ++ ) {
17930
+
17931
+ this.mat4[ i ].multiplyMatrices( cameras[ i ].matrixWorldInverse, object.matrixWorld );
17932
+ this.mat3[ i ].getNormalMatrix( this.mat4[ i ] );
17933
+
17934
+ }
17935
+
17936
+ uniforms.setValue( this.gl, 'modelViewMatrices', this.mat4 );
17937
+ uniforms.setValue( this.gl, 'normalMatrices', this.mat3 );
17938
+
17939
+ }
17940
+
17941
+ }
17942
+
17811
17943
  function WebGLObjects( gl, geometries, attributes, info ) {
17812
17944
 
17813
17945
  let updateMap = new WeakMap();
@@ -19073,15 +19205,38 @@ function handleSource( string, errorLine ) {
19073
19205
 
19074
19206
  function getEncodingComponents( colorSpace ) {
19075
19207
 
19208
+ const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
19209
+ const encodingPrimaries = ColorManagement.getPrimaries( colorSpace );
19210
+
19211
+ let gamutMapping;
19212
+
19213
+ if ( workingPrimaries === encodingPrimaries ) {
19214
+
19215
+ gamutMapping = '';
19216
+
19217
+ } else if ( workingPrimaries === P3Primaries && encodingPrimaries === Rec709Primaries ) {
19218
+
19219
+ gamutMapping = 'LinearDisplayP3ToLinearSRGB';
19220
+
19221
+ } else if ( workingPrimaries === Rec709Primaries && encodingPrimaries === P3Primaries ) {
19222
+
19223
+ gamutMapping = 'LinearSRGBToLinearDisplayP3';
19224
+
19225
+ }
19226
+
19076
19227
  switch ( colorSpace ) {
19077
19228
 
19078
19229
  case LinearSRGBColorSpace:
19079
- return [ 'Linear', '( value )' ];
19230
+ case LinearDisplayP3ColorSpace:
19231
+ return [ gamutMapping, 'LinearTransferOETF' ];
19232
+
19080
19233
  case SRGBColorSpace:
19081
- return [ 'sRGB', '( value )' ];
19234
+ case DisplayP3ColorSpace:
19235
+ return [ gamutMapping, 'sRGBTransferOETF' ];
19236
+
19082
19237
  default:
19083
19238
  console.warn( 'THREE.WebGLProgram: Unsupported color space:', colorSpace );
19084
- return [ 'Linear', '( value )' ];
19239
+ return [ gamutMapping, 'LinearTransferOETF' ];
19085
19240
 
19086
19241
  }
19087
19242
 
@@ -19114,7 +19269,7 @@ function getShaderErrors( gl, shader, type ) {
19114
19269
  function getTexelEncodingFunction( functionName, colorSpace ) {
19115
19270
 
19116
19271
  const components = getEncodingComponents( colorSpace );
19117
- return 'vec4 ' + functionName + '( vec4 value ) { return LinearTo' + components[ 0 ] + components[ 1 ] + '; }';
19272
+ return `vec4 ${functionName}( vec4 value ) { return ${components[ 0 ]}( ${components[ 1 ]}( value ) ); }`;
19118
19273
 
19119
19274
  }
19120
19275
 
@@ -19478,6 +19633,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19478
19633
  let prefixVertex, prefixFragment;
19479
19634
  let versionString = parameters.glslVersion ? '#version ' + parameters.glslVersion + '\n' : '';
19480
19635
 
19636
+ const numMultiviewViews = parameters.numMultiviewViews;
19637
+
19481
19638
  if ( parameters.isRawShaderMaterial ) {
19482
19639
 
19483
19640
  prefixVertex = [
@@ -19541,6 +19698,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19541
19698
  parameters.displacementMap ? '#define USE_DISPLACEMENTMAP' : '',
19542
19699
  parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
19543
19700
 
19701
+ parameters.anisotropy ? '#define USE_ANISOTROPY' : '',
19544
19702
  parameters.anisotropyMap ? '#define USE_ANISOTROPYMAP' : '',
19545
19703
 
19546
19704
  parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',
@@ -19628,6 +19786,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19628
19786
 
19629
19787
  parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '',
19630
19788
 
19789
+ parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
19790
+
19631
19791
  parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
19632
19792
 
19633
19793
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
@@ -19810,6 +19970,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19810
19970
 
19811
19971
  parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '',
19812
19972
 
19973
+ parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
19974
+
19813
19975
  parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
19814
19976
 
19815
19977
  parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
@@ -19879,6 +20041,53 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19879
20041
  '#define textureCubeGradEXT textureGrad'
19880
20042
  ].join( '\n' ) + '\n' + prefixFragment;
19881
20043
 
20044
+ // Multiview
20045
+
20046
+ if ( numMultiviewViews > 0 ) {
20047
+
20048
+ // TODO: fix light transforms here?
20049
+
20050
+ prefixVertex = [
20051
+ '#extension GL_OVR_multiview : require',
20052
+ 'layout(num_views = ' + numMultiviewViews + ') in;',
20053
+ '#define VIEW_ID gl_ViewID_OVR'
20054
+ ].join( '\n' ) + '\n' + prefixVertex;
20055
+
20056
+ prefixVertex = prefixVertex.replace(
20057
+ [
20058
+ 'uniform mat4 modelViewMatrix;',
20059
+ 'uniform mat4 projectionMatrix;',
20060
+ 'uniform mat4 viewMatrix;',
20061
+ 'uniform mat3 normalMatrix;'
20062
+ ].join( '\n' ),
20063
+ [
20064
+ 'uniform mat4 modelViewMatrices[' + numMultiviewViews + '];',
20065
+ 'uniform mat4 projectionMatrices[' + numMultiviewViews + '];',
20066
+ 'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
20067
+ 'uniform mat3 normalMatrices[' + numMultiviewViews + '];',
20068
+
20069
+ '#define modelViewMatrix modelViewMatrices[VIEW_ID]',
20070
+ '#define projectionMatrix projectionMatrices[VIEW_ID]',
20071
+ '#define viewMatrix viewMatrices[VIEW_ID]',
20072
+ '#define normalMatrix normalMatrices[VIEW_ID]'
20073
+ ].join( '\n' )
20074
+ );
20075
+
20076
+ prefixFragment = [
20077
+ '#extension GL_OVR_multiview : require',
20078
+ '#define VIEW_ID gl_ViewID_OVR'
20079
+ ].join( '\n' ) + '\n' + prefixFragment;
20080
+
20081
+ prefixFragment = prefixFragment.replace(
20082
+ 'uniform mat4 viewMatrix;',
20083
+ [
20084
+ 'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
20085
+ '#define viewMatrix viewMatrices[VIEW_ID]'
20086
+ ].join( '\n' )
20087
+ );
20088
+
20089
+ }
20090
+
19882
20091
  }
19883
20092
 
19884
20093
  const vertexGlsl = versionString + prefixVertex + vertexShader;
@@ -20043,6 +20252,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20043
20252
  this.program = program;
20044
20253
  this.vertexShader = glVertexShader;
20045
20254
  this.fragmentShader = glFragmentShader;
20255
+ this.numMultiviewViews = numMultiviewViews;
20046
20256
 
20047
20257
  return this;
20048
20258
 
@@ -20272,6 +20482,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20272
20482
 
20273
20483
  const currentRenderTarget = renderer.getRenderTarget();
20274
20484
 
20485
+ const numMultiviewViews = currentRenderTarget && currentRenderTarget.isWebGLMultiviewRenderTarget ? currentRenderTarget.numViews : 0;
20486
+
20275
20487
  const IS_INSTANCEDMESH = object.isInstancedMesh === true;
20276
20488
 
20277
20489
  const HAS_MAP = !! material.map;
@@ -20362,6 +20574,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20362
20574
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
20363
20575
 
20364
20576
  supportsVertexTextures: SUPPORTS_VERTEX_TEXTURES,
20577
+ numMultiviewViews: numMultiviewViews,
20365
20578
  outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace ),
20366
20579
 
20367
20580
  map: HAS_MAP,
@@ -20490,6 +20703,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20490
20703
  numSpotLightShadows: lights.spotShadowMap.length,
20491
20704
  numSpotLightShadowsWithMaps: lights.numSpotLightShadowsWithMaps,
20492
20705
 
20706
+ numLightProbes: lights.numLightProbes,
20707
+
20493
20708
  numClippingPlanes: clipping.numPlanes,
20494
20709
  numClipIntersection: clipping.numIntersection,
20495
20710
 
@@ -20501,7 +20716,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20501
20716
  toneMapping: toneMapping,
20502
20717
  useLegacyLights: renderer._useLegacyLights,
20503
20718
 
20504
- decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( material.map.colorSpace === SRGBColorSpace ),
20719
+ decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( ColorManagement.getTransfer( material.map.colorSpace ) === SRGBTransfer ),
20505
20720
 
20506
20721
  premultipliedAlpha: material.premultipliedAlpha,
20507
20722
 
@@ -20614,6 +20829,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20614
20829
  array.push( parameters.numPointLightShadows );
20615
20830
  array.push( parameters.numSpotLightShadows );
20616
20831
  array.push( parameters.numSpotLightShadowsWithMaps );
20832
+ array.push( parameters.numLightProbes );
20617
20833
  array.push( parameters.shadowMapType );
20618
20834
  array.push( parameters.toneMapping );
20619
20835
  array.push( parameters.numClippingPlanes );
@@ -20706,6 +20922,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20706
20922
  _programLayers.enable( 18 );
20707
20923
  if ( parameters.decodeVideoTexture )
20708
20924
  _programLayers.enable( 19 );
20925
+ if ( parameters.numMultiviewViews )
20926
+ _programLayers.enable( 20 );
20709
20927
 
20710
20928
  array.push( _programLayers.mask );
20711
20929
 
@@ -21252,7 +21470,9 @@ function WebGLLights( extensions, capabilities ) {
21252
21470
  numDirectionalShadows: - 1,
21253
21471
  numPointShadows: - 1,
21254
21472
  numSpotShadows: - 1,
21255
- numSpotMaps: - 1
21473
+ numSpotMaps: - 1,
21474
+
21475
+ numLightProbes: - 1
21256
21476
  },
21257
21477
 
21258
21478
  ambient: [ 0, 0, 0 ],
@@ -21274,7 +21494,8 @@ function WebGLLights( extensions, capabilities ) {
21274
21494
  pointShadowMap: [],
21275
21495
  pointShadowMatrix: [],
21276
21496
  hemi: [],
21277
- numSpotLightShadowsWithMaps: 0
21497
+ numSpotLightShadowsWithMaps: 0,
21498
+ numLightProbes: 0
21278
21499
 
21279
21500
  };
21280
21501
 
@@ -21302,6 +21523,8 @@ function WebGLLights( extensions, capabilities ) {
21302
21523
  let numSpotMaps = 0;
21303
21524
  let numSpotShadowsWithMaps = 0;
21304
21525
 
21526
+ let numLightProbes = 0;
21527
+
21305
21528
  // ordering : [shadow casting + map texturing, map texturing, shadow casting, none ]
21306
21529
  lights.sort( shadowCastingAndTexturingLightsFirst );
21307
21530
 
@@ -21332,6 +21555,8 @@ function WebGLLights( extensions, capabilities ) {
21332
21555
 
21333
21556
  }
21334
21557
 
21558
+ numLightProbes ++;
21559
+
21335
21560
  } else if ( light.isDirectionalLight ) {
21336
21561
 
21337
21562
  const uniforms = cache.get( light );
@@ -21519,7 +21744,8 @@ function WebGLLights( extensions, capabilities ) {
21519
21744
  hash.numDirectionalShadows !== numDirectionalShadows ||
21520
21745
  hash.numPointShadows !== numPointShadows ||
21521
21746
  hash.numSpotShadows !== numSpotShadows ||
21522
- hash.numSpotMaps !== numSpotMaps ) {
21747
+ hash.numSpotMaps !== numSpotMaps ||
21748
+ hash.numLightProbes !== numLightProbes ) {
21523
21749
 
21524
21750
  state.directional.length = directionalLength;
21525
21751
  state.spot.length = spotLength;
@@ -21538,6 +21764,7 @@ function WebGLLights( extensions, capabilities ) {
21538
21764
  state.spotLightMatrix.length = numSpotShadows + numSpotMaps - numSpotShadowsWithMaps;
21539
21765
  state.spotLightMap.length = numSpotMaps;
21540
21766
  state.numSpotLightShadowsWithMaps = numSpotShadowsWithMaps;
21767
+ state.numLightProbes = numLightProbes;
21541
21768
 
21542
21769
  hash.directionalLength = directionalLength;
21543
21770
  hash.pointLength = pointLength;
@@ -21550,6 +21777,8 @@ function WebGLLights( extensions, capabilities ) {
21550
21777
  hash.numSpotShadows = numSpotShadows;
21551
21778
  hash.numSpotMaps = numSpotMaps;
21552
21779
 
21780
+ hash.numLightProbes = numLightProbes;
21781
+
21553
21782
  state.version = nextVersion ++;
21554
21783
 
21555
21784
  }
@@ -23530,12 +23759,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
23530
23759
  const maxSamples = capabilities.maxSamples;
23531
23760
  const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
23532
23761
  const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
23762
+ const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
23533
23763
 
23534
23764
  const _videoTextures = new WeakMap();
23535
23765
  let _canvas;
23536
23766
 
23537
23767
  const _sources = new WeakMap(); // maps WebglTexture objects to instances of Source
23538
23768
 
23769
+ let _deferredUploads = [];
23770
+ let _deferTextureUploads = false;
23771
+
23539
23772
  // cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,
23540
23773
  // also OffscreenCanvas.getContext("webgl"), but not OffscreenCanvas.getContext("2d")!
23541
23774
  // Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d).
@@ -23696,9 +23929,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
23696
23929
 
23697
23930
  if ( glFormat === _gl.RGBA ) {
23698
23931
 
23932
+ const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
23933
+
23699
23934
  if ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;
23700
23935
  if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;
23701
- if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( colorSpace === SRGBColorSpace && forceLinearTransfer === false ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
23936
+ if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( transfer === SRGBTransfer ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
23702
23937
  if ( glType === _gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = _gl.RGBA4;
23703
23938
  if ( glType === _gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = _gl.RGB5_A1;
23704
23939
 
@@ -24001,8 +24236,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24001
24236
 
24002
24237
  } else {
24003
24238
 
24004
- uploadTexture( textureProperties, texture, slot );
24005
- return;
24239
+ if ( uploadTexture( textureProperties, texture, slot ) ) {
24240
+
24241
+ return;
24242
+
24243
+ }
24006
24244
 
24007
24245
  }
24008
24246
 
@@ -24235,8 +24473,45 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24235
24473
 
24236
24474
  }
24237
24475
 
24476
+ function setDeferTextureUploads( deferFlag ) {
24477
+
24478
+ _deferTextureUploads = deferFlag;
24479
+
24480
+ }
24481
+
24482
+ function runDeferredUploads() {
24483
+
24484
+ const previousDeferSetting = _deferTextureUploads;
24485
+ _deferTextureUploads = false;
24486
+
24487
+ for ( const upload of _deferredUploads ) {
24488
+
24489
+ uploadTexture( upload.textureProperties, upload.texture, upload.slot );
24490
+ upload.texture.isPendingDeferredUpload = false;
24491
+
24492
+ }
24493
+
24494
+ _deferredUploads = [];
24495
+
24496
+ _deferTextureUploads = previousDeferSetting;
24497
+
24498
+ }
24499
+
24238
24500
  function uploadTexture( textureProperties, texture, slot ) {
24239
24501
 
24502
+ if ( _deferTextureUploads ) {
24503
+
24504
+ if ( ! texture.isPendingDeferredUpload ) {
24505
+
24506
+ texture.isPendingDeferredUpload = true;
24507
+ _deferredUploads.push( { textureProperties: textureProperties, texture: texture, slot: slot } );
24508
+
24509
+ }
24510
+
24511
+ return false;
24512
+
24513
+ }
24514
+
24240
24515
  let textureType = _gl.TEXTURE_2D;
24241
24516
 
24242
24517
  if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) textureType = _gl.TEXTURE_2D_ARRAY;
@@ -24253,10 +24528,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24253
24528
 
24254
24529
  state.activeTexture( _gl.TEXTURE0 + slot );
24255
24530
 
24531
+ const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
24532
+ const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries( texture.colorSpace );
24533
+ const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
24534
+
24256
24535
  _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
24257
24536
  _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
24258
24537
  _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
24259
- _gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, _gl.NONE );
24538
+ _gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
24260
24539
 
24261
24540
  const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo$1( texture.image ) === false;
24262
24541
  let image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );
@@ -24649,6 +24928,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24649
24928
  }
24650
24929
 
24651
24930
  textureProperties.__version = texture.version;
24931
+ return true;
24652
24932
 
24653
24933
  }
24654
24934
 
@@ -24667,10 +24947,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24667
24947
 
24668
24948
  state.activeTexture( _gl.TEXTURE0 + slot );
24669
24949
 
24950
+ const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
24951
+ const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries( texture.colorSpace );
24952
+ const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
24953
+
24670
24954
  _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
24671
24955
  _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
24672
24956
  _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
24673
- _gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, _gl.NONE );
24957
+ _gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
24674
24958
 
24675
24959
  const isCompressed = ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture );
24676
24960
  const isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );
@@ -24874,7 +25158,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24874
25158
  const width = Math.max( 1, renderTarget.width >> level );
24875
25159
  const height = Math.max( 1, renderTarget.height >> level );
24876
25160
 
24877
- if ( textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY ) {
25161
+ if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
25162
+
25163
+ state.texStorage3D( _gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.numViews );
25164
+
25165
+ } else if ( textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY ) {
24878
25166
 
24879
25167
  state.texImage3D( textureTarget, level, glInternalFormat, width, height, renderTarget.depth, 0, glFormat, glType, null );
24880
25168
 
@@ -24888,13 +25176,31 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24888
25176
 
24889
25177
  state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
24890
25178
 
24891
- if ( useMultisampledRTT( renderTarget ) ) {
25179
+ const multisampled = useMultisampledRTT( renderTarget );
24892
25180
 
24893
- multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
25181
+ if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
25182
+
25183
+ if ( multisampled ) {
25184
+
25185
+ multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ), 0, renderTarget.numViews );
25186
+
25187
+ } else {
25188
+
25189
+ multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( texture ).__webglTexture, 0, 0, renderTarget.numViews );
25190
+
25191
+ }
24894
25192
 
24895
25193
  } else if ( textureTarget === _gl.TEXTURE_2D || ( textureTarget >= _gl.TEXTURE_CUBE_MAP_POSITIVE_X && textureTarget <= _gl.TEXTURE_CUBE_MAP_NEGATIVE_Z ) ) { // see #24753
24896
25194
 
24897
- _gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, level );
25195
+ if ( multisampled ) {
25196
+
25197
+ multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
25198
+
25199
+ } else {
25200
+
25201
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, level );
25202
+
25203
+ }
24898
25204
 
24899
25205
  }
24900
25206
 
@@ -24908,9 +25214,61 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24908
25214
 
24909
25215
  _gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
24910
25216
 
24911
- if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
25217
+ if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
25218
+
25219
+ const useMultisample = useMultisampledRTT( renderTarget );
25220
+ const numViews = renderTarget.numViews;
25221
+
25222
+ const depthTexture = renderTarget.depthTexture;
25223
+ let glInternalFormat = _gl.DEPTH_COMPONENT24;
25224
+ let glDepthAttachment = _gl.DEPTH_ATTACHMENT;
25225
+
25226
+ if ( depthTexture && depthTexture.isDepthTexture ) {
25227
+
25228
+ if ( depthTexture.type === FloatType ) {
25229
+
25230
+ glInternalFormat = _gl.DEPTH_COMPONENT32F;
25231
+
25232
+ } else if ( depthTexture.type === UnsignedInt248Type ) {
25233
+
25234
+ glInternalFormat = _gl.DEPTH24_STENCIL8;
25235
+ glDepthAttachment = _gl.DEPTH_STENCIL_ATTACHMENT;
25236
+
25237
+ }
25238
+
25239
+ // we're defaulting to _gl.DEPTH_COMPONENT24 so don't assign here
25240
+ // or else DeepScan will complain
25241
+
25242
+ // else if ( depthTexture.type === UnsignedIntType ) {
25243
+
25244
+ // glInternalFormat = _gl.DEPTH_COMPONENT24;
24912
25245
 
24913
- let glInternalFormat = _gl.DEPTH_COMPONENT16;
25246
+ // }
25247
+
25248
+ }
25249
+
25250
+ let depthStencilTexture = properties.get( renderTarget.depthTexture ).__webglTexture;
25251
+ if ( depthStencilTexture === undefined ) {
25252
+
25253
+ depthStencilTexture = _gl.createTexture();
25254
+ _gl.bindTexture( _gl.TEXTURE_2D_ARRAY, depthStencilTexture );
25255
+ _gl.texStorage3D( _gl.TEXTURE_2D_ARRAY, 1, glInternalFormat, renderTarget.width, renderTarget.height, numViews );
25256
+
25257
+ }
25258
+
25259
+ if ( useMultisample ) {
25260
+
25261
+ multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, glDepthAttachment, depthStencilTexture, 0, getRenderTargetSamples( renderTarget ), 0, numViews );
25262
+
25263
+ } else {
25264
+
25265
+ multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, glDepthAttachment, depthStencilTexture, 0, 0, numViews );
25266
+
25267
+ }
25268
+
25269
+ } else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
25270
+
25271
+ let glInternalFormat = ( isWebGL2 === true ) ? _gl.DEPTH_COMPONENT24 : _gl.DEPTH_COMPONENT16;
24914
25272
 
24915
25273
  if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
24916
25274
 
@@ -25032,37 +25390,85 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25032
25390
  }
25033
25391
 
25034
25392
  setTexture2D( renderTarget.depthTexture, 0 );
25393
+ if ( renderTarget.depthTexture.image.depth != 1 ) {
25394
+
25395
+ setTexture2DArray( renderTarget.depthTexture, 0 );
25396
+
25397
+ } else {
25398
+
25399
+ setTexture2D( renderTarget.depthTexture, 0 );
25400
+
25401
+ }
25035
25402
 
25036
25403
  const webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture;
25037
25404
  const samples = getRenderTargetSamples( renderTarget );
25038
25405
 
25039
- if ( renderTarget.depthTexture.format === DepthFormat ) {
25406
+ if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
25040
25407
 
25041
- if ( useMultisampledRTT( renderTarget ) ) {
25408
+ const useMultisample = useMultisampledRTT( renderTarget );
25409
+ const numViews = renderTarget.numViews;
25042
25410
 
25043
- multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
25411
+ if ( renderTarget.depthTexture.format === DepthFormat ) {
25044
25412
 
25045
- } else {
25413
+ if ( useMultisample ) {
25046
25414
 
25047
- _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
25415
+ multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, webglDepthTexture, 0, samples, 0, numViews );
25048
25416
 
25049
- }
25417
+ } else {
25050
25418
 
25051
- } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
25419
+ multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, webglDepthTexture, 0, 0, numViews );
25052
25420
 
25053
- if ( useMultisampledRTT( renderTarget ) ) {
25421
+ }
25422
+
25423
+ } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
25424
+
25425
+ if ( useMultisample ) {
25426
+
25427
+ multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, webglDepthTexture, 0, samples, 0, numViews );
25428
+
25429
+ } else {
25054
25430
 
25055
- multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
25431
+ multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, webglDepthTexture, 0, 0, numViews );
25432
+
25433
+ }
25056
25434
 
25057
25435
  } else {
25058
25436
 
25059
- _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
25437
+ throw new Error( 'Unknown depthTexture format' );
25060
25438
 
25061
25439
  }
25062
25440
 
25063
25441
  } else {
25064
25442
 
25065
- throw new Error( 'Unknown depthTexture format' );
25443
+ if ( renderTarget.depthTexture.format === DepthFormat ) {
25444
+
25445
+ if ( useMultisampledRTT( renderTarget ) ) {
25446
+
25447
+ multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
25448
+
25449
+ } else {
25450
+
25451
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
25452
+
25453
+ }
25454
+
25455
+ } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
25456
+
25457
+ if ( useMultisampledRTT( renderTarget ) ) {
25458
+
25459
+ multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
25460
+
25461
+ } else {
25462
+
25463
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
25464
+
25465
+ }
25466
+
25467
+ } else {
25468
+
25469
+ throw new Error( 'Unknown depthTexture format' );
25470
+
25471
+ }
25066
25472
 
25067
25473
  }
25068
25474
 
@@ -25341,6 +25747,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25341
25747
 
25342
25748
  }
25343
25749
 
25750
+ if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
25751
+
25752
+ glTextureType = _gl.TEXTURE_2D_ARRAY;
25753
+
25754
+ }
25755
+
25344
25756
  state.bindTexture( glTextureType, textureProperties.__webglTexture );
25345
25757
  setTextureParameters( glTextureType, texture, supportsMips );
25346
25758
 
@@ -25370,9 +25782,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25370
25782
 
25371
25783
  // Setup depth and stencil buffers
25372
25784
 
25373
- if ( renderTarget.depthBuffer ) {
25785
+ if ( renderTarget.depthBuffer || renderTarget.isWebGLMultiviewRenderTarget === true ) {
25374
25786
 
25375
- setupDepthRenderbuffer( renderTarget );
25787
+ this.setupDepthRenderbuffer( renderTarget );
25376
25788
 
25377
25789
  }
25378
25790
 
@@ -25551,7 +25963,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25551
25963
 
25552
25964
  // sRGB
25553
25965
 
25554
- if ( colorSpace === SRGBColorSpace || colorSpace === DisplayP3ColorSpace ) {
25966
+ if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
25555
25967
 
25556
25968
  if ( isWebGL2 === false ) {
25557
25969
 
@@ -25608,18 +26020,19 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25608
26020
  this.setTexture3D = setTexture3D;
25609
26021
  this.setTextureCube = setTextureCube;
25610
26022
  this.rebindTextures = rebindTextures;
26023
+ this.uploadTexture = uploadTexture;
25611
26024
  this.setupRenderTarget = setupRenderTarget;
25612
26025
  this.updateRenderTargetMipmap = updateRenderTargetMipmap;
25613
26026
  this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
26027
+ this.setupDepthTexture = setupDepthTexture;
25614
26028
  this.setupDepthRenderbuffer = setupDepthRenderbuffer;
25615
26029
  this.setupFrameBufferTexture = setupFrameBufferTexture;
25616
26030
  this.useMultisampledRTT = useMultisampledRTT;
26031
+ this.runDeferredUploads = runDeferredUploads;
26032
+ this.setDeferTextureUploads = setDeferTextureUploads;
25617
26033
 
25618
26034
  }
25619
26035
 
25620
- const LinearTransferFunction = 0;
25621
- const SRGBTransferFunction = 1;
25622
-
25623
26036
  function WebGLUtils( gl, extensions, capabilities ) {
25624
26037
 
25625
26038
  const isWebGL2 = capabilities.isWebGL2;
@@ -25628,7 +26041,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
25628
26041
 
25629
26042
  let extension;
25630
26043
 
25631
- const transferFunction = ( colorSpace === SRGBColorSpace || colorSpace === DisplayP3ColorSpace ) ? SRGBTransferFunction : LinearTransferFunction;
26044
+ const transfer = ColorManagement.getTransfer( colorSpace );
25632
26045
 
25633
26046
  if ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;
25634
26047
  if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
@@ -25696,7 +26109,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
25696
26109
 
25697
26110
  if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
25698
26111
 
25699
- if ( transferFunction === SRGBTransferFunction ) {
26112
+ if ( transfer === SRGBTransfer ) {
25700
26113
 
25701
26114
  extension = extensions.get( 'WEBGL_compressed_texture_s3tc_srgb' );
25702
26115
 
@@ -25781,8 +26194,8 @@ function WebGLUtils( gl, extensions, capabilities ) {
25781
26194
 
25782
26195
  if ( extension !== null ) {
25783
26196
 
25784
- if ( p === RGB_ETC2_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
25785
- if ( p === RGBA_ETC2_EAC_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
26197
+ if ( p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
26198
+ if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
25786
26199
 
25787
26200
  } else {
25788
26201
 
@@ -25804,20 +26217,20 @@ function WebGLUtils( gl, extensions, capabilities ) {
25804
26217
 
25805
26218
  if ( extension !== null ) {
25806
26219
 
25807
- if ( p === RGBA_ASTC_4x4_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;
25808
- if ( p === RGBA_ASTC_5x4_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;
25809
- if ( p === RGBA_ASTC_5x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;
25810
- if ( p === RGBA_ASTC_6x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;
25811
- if ( p === RGBA_ASTC_6x6_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;
25812
- if ( p === RGBA_ASTC_8x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;
25813
- if ( p === RGBA_ASTC_8x6_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;
25814
- if ( p === RGBA_ASTC_8x8_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;
25815
- if ( p === RGBA_ASTC_10x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;
25816
- if ( p === RGBA_ASTC_10x6_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;
25817
- if ( p === RGBA_ASTC_10x8_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;
25818
- if ( p === RGBA_ASTC_10x10_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;
25819
- if ( p === RGBA_ASTC_12x10_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;
25820
- if ( p === RGBA_ASTC_12x12_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;
26220
+ if ( p === RGBA_ASTC_4x4_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;
26221
+ if ( p === RGBA_ASTC_5x4_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;
26222
+ if ( p === RGBA_ASTC_5x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;
26223
+ if ( p === RGBA_ASTC_6x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;
26224
+ if ( p === RGBA_ASTC_6x6_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;
26225
+ if ( p === RGBA_ASTC_8x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;
26226
+ if ( p === RGBA_ASTC_8x6_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;
26227
+ if ( p === RGBA_ASTC_8x8_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;
26228
+ if ( p === RGBA_ASTC_10x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;
26229
+ if ( p === RGBA_ASTC_10x6_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;
26230
+ if ( p === RGBA_ASTC_10x8_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;
26231
+ if ( p === RGBA_ASTC_10x10_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;
26232
+ if ( p === RGBA_ASTC_12x10_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;
26233
+ if ( p === RGBA_ASTC_12x12_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;
25821
26234
 
25822
26235
  } else {
25823
26236
 
@@ -25835,7 +26248,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
25835
26248
 
25836
26249
  if ( extension !== null ) {
25837
26250
 
25838
- if ( p === RGBA_BPTC_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;
26251
+ if ( p === RGBA_BPTC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;
25839
26252
  if ( p === RGB_BPTC_SIGNED_Format ) return extension.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
25840
26253
  if ( p === RGB_BPTC_UNSIGNED_Format ) return extension.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
25841
26254
 
@@ -26473,6 +26886,39 @@ Object.assign( WebVRManager.prototype, {
26473
26886
  dispatchEvent: EventDispatcher.prototype.dispatchEvent
26474
26887
  } );
26475
26888
 
26889
+ /**
26890
+ * @author fernandojsg / http://fernandojsg.com
26891
+ * @author Takahiro https://github.com/takahirox
26892
+ */
26893
+
26894
+
26895
+ class WebGLMultiviewRenderTarget extends WebGLRenderTarget {
26896
+
26897
+ constructor( width, height, numViews, options = {} ) {
26898
+
26899
+ super( width, height, options );
26900
+
26901
+ this.depthBuffer = false;
26902
+ this.stencilBuffer = false;
26903
+
26904
+ this.numViews = numViews;
26905
+
26906
+ }
26907
+
26908
+ copy( source ) {
26909
+
26910
+ super.copy( source );
26911
+
26912
+ this.numViews = source.numViews;
26913
+
26914
+ return this;
26915
+
26916
+ }
26917
+
26918
+ }
26919
+
26920
+ WebGLMultiviewRenderTarget.prototype.isWebGLMultiviewRenderTarget = true;
26921
+
26476
26922
  const _moveEvent = { type: 'move' };
26477
26923
 
26478
26924
  class WebXRController {
@@ -26867,7 +27313,7 @@ class DepthTexture extends Texture {
26867
27313
 
26868
27314
  class WebXRManager extends EventDispatcher {
26869
27315
 
26870
- constructor( renderer, gl ) {
27316
+ constructor( renderer, gl, extensions, useMultiview ) {
26871
27317
 
26872
27318
  super();
26873
27319
 
@@ -26923,6 +27369,7 @@ class WebXRManager extends EventDispatcher {
26923
27369
  this.enabled = false;
26924
27370
 
26925
27371
  this.isPresenting = false;
27372
+ this.isMultiview = false;
26926
27373
 
26927
27374
  this.getCameraPose = function ( ) {
26928
27375
 
@@ -27166,29 +27613,51 @@ class WebXRManager extends EventDispatcher {
27166
27613
 
27167
27614
  }
27168
27615
 
27616
+ scope.isMultiview = useMultiview && extensions.has( 'OCULUS_multiview' );
27617
+
27169
27618
  const projectionlayerInit = {
27170
27619
  colorFormat: gl.RGBA8,
27171
27620
  depthFormat: glDepthFormat,
27172
27621
  scaleFactor: framebufferScaleFactor
27173
27622
  };
27174
27623
 
27624
+ if ( scope.isMultiview ) {
27625
+
27626
+ projectionlayerInit.textureType = 'texture-array';
27627
+
27628
+ }
27629
+
27175
27630
  glBinding = new XRWebGLBinding( session, gl );
27176
27631
 
27177
27632
  glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );
27178
27633
 
27179
27634
  session.updateRenderState( { layers: [ glProjLayer ] } );
27180
27635
 
27181
- newRenderTarget = new WebGLRenderTarget(
27182
- glProjLayer.textureWidth,
27183
- glProjLayer.textureHeight,
27184
- {
27185
- format: RGBAFormat,
27186
- type: UnsignedByteType,
27187
- depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
27188
- stencilBuffer: attributes.stencil,
27189
- colorSpace: renderer.outputColorSpace,
27190
- samples: attributes.antialias ? 4 : 0
27191
- } );
27636
+ const renderTargetOptions = {
27637
+ format: RGBAFormat,
27638
+ type: UnsignedByteType,
27639
+ depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
27640
+ stencilBuffer: attributes.stencil,
27641
+ colorSpace: renderer.outputColorSpace,
27642
+ samples: attributes.antialias ? 4 : 0
27643
+ };
27644
+
27645
+ if ( scope.isMultiview ) {
27646
+
27647
+ const extension = extensions.get( 'OCULUS_multiview' );
27648
+
27649
+ this.maxNumViews = gl.getParameter( extension.MAX_VIEWS_OVR );
27650
+
27651
+ newRenderTarget = new WebGLMultiviewRenderTarget( glProjLayer.textureWidth, glProjLayer.textureHeight, 2, renderTargetOptions );
27652
+
27653
+ } else {
27654
+
27655
+ newRenderTarget = new WebGLRenderTarget(
27656
+ glProjLayer.textureWidth,
27657
+ glProjLayer.textureHeight,
27658
+ renderTargetOptions );
27659
+
27660
+ }
27192
27661
 
27193
27662
  const renderTargetProperties = renderer.properties.get( newRenderTarget );
27194
27663
  renderTargetProperties.__ignoreDepthValues = glProjLayer.ignoreDepthValues;
@@ -28640,6 +29109,7 @@ class WebGLRenderer {
28640
29109
  preserveDrawingBuffer = false,
28641
29110
  powerPreference = 'default',
28642
29111
  failIfMajorPerformanceCaveat = false,
29112
+ multiviewStereo = false,
28643
29113
  } = parameters;
28644
29114
 
28645
29115
  this.isWebGLRenderer = true;
@@ -28705,7 +29175,7 @@ class WebGLRenderer {
28705
29175
 
28706
29176
  // physically based shading
28707
29177
 
28708
- this.outputColorSpace = SRGBColorSpace;
29178
+ this._outputColorSpace = SRGBColorSpace;
28709
29179
 
28710
29180
  // physical lights
28711
29181
 
@@ -28874,6 +29344,7 @@ class WebGLRenderer {
28874
29344
  let extensions, capabilities, state, info;
28875
29345
  let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;
28876
29346
  let programCache, materials, renderLists, renderStates, clipping, shadowMap;
29347
+ let multiview;
28877
29348
 
28878
29349
  let background, morphtargets, bufferRenderer, indexedBufferRenderer;
28879
29350
 
@@ -28907,6 +29378,7 @@ class WebGLRenderer {
28907
29378
  renderLists = new WebGLRenderLists();
28908
29379
  renderStates = new WebGLRenderStates( extensions, capabilities );
28909
29380
  background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
29381
+ multiview = new WebGLMultiview( _this, extensions, _gl );
28910
29382
  shadowMap = new WebGLShadowMap( _this, objects, capabilities );
28911
29383
  uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
28912
29384
 
@@ -28929,7 +29401,7 @@ class WebGLRenderer {
28929
29401
 
28930
29402
  // xr
28931
29403
 
28932
- const xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl ) : new WebVRManager( _this );
29404
+ const xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl, extensions, multiviewStereo ) : new WebVRManager( _this );
28933
29405
 
28934
29406
  this.xr = xr;
28935
29407
 
@@ -29676,13 +30148,23 @@ class WebGLRenderer {
29676
30148
 
29677
30149
  if ( camera.isArrayCamera ) {
29678
30150
 
29679
- const cameras = camera.cameras;
30151
+ if ( xr.enabled && xr.isMultiview ) {
29680
30152
 
29681
- for ( let i = 0, l = cameras.length; i < l; i ++ ) {
30153
+ textures.setDeferTextureUploads( true );
29682
30154
 
29683
- const camera2 = cameras[ i ];
30155
+ renderScene( currentRenderList, scene, camera, camera.cameras[ 0 ].viewport );
29684
30156
 
29685
- renderScene( currentRenderList, scene, camera2, camera2.viewport );
30157
+ } else {
30158
+
30159
+ const cameras = camera.cameras;
30160
+
30161
+ for ( let i = 0, l = cameras.length; i < l; i ++ ) {
30162
+
30163
+ const camera2 = cameras[ i ];
30164
+
30165
+ renderScene( currentRenderList, scene, camera2, camera2.viewport );
30166
+
30167
+ }
29686
30168
 
29687
30169
  }
29688
30170
 
@@ -29710,6 +30192,8 @@ class WebGLRenderer {
29710
30192
 
29711
30193
  if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
29712
30194
 
30195
+ textures.runDeferredUploads();
30196
+
29713
30197
  if ( xr.enabled && xr.submitFrame ) {
29714
30198
 
29715
30199
  xr.submitFrame();
@@ -30177,6 +30661,7 @@ class WebGLRenderer {
30177
30661
  materialProperties.vertexAlphas = parameters.vertexAlphas;
30178
30662
  materialProperties.vertexTangents = parameters.vertexTangents;
30179
30663
  materialProperties.toneMapping = parameters.toneMapping;
30664
+ materialProperties.numMultiviewViews = parameters.numMultiviewViews;
30180
30665
 
30181
30666
  }
30182
30667
 
@@ -30208,6 +30693,8 @@ class WebGLRenderer {
30208
30693
 
30209
30694
  }
30210
30695
 
30696
+ const numMultiviewViews = _currentRenderTarget && _currentRenderTarget.isWebGLMultiviewRenderTarget ? _currentRenderTarget.numViews : 0;
30697
+
30211
30698
  const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
30212
30699
  const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
30213
30700
 
@@ -30311,6 +30798,10 @@ class WebGLRenderer {
30311
30798
 
30312
30799
  needsProgramChange = true;
30313
30800
 
30801
+ } else if ( materialProperties.numMultiviewViews !== numMultiviewViews ) {
30802
+
30803
+ needsProgramChange = true;
30804
+
30314
30805
  }
30315
30806
 
30316
30807
  } else {
@@ -30357,8 +30848,17 @@ class WebGLRenderer {
30357
30848
 
30358
30849
  // common camera uniforms
30359
30850
 
30360
- p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
30361
- p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
30851
+ if ( program.numMultiviewViews > 0 ) {
30852
+
30853
+ multiview.updateCameraProjectionMatricesUniform( camera, p_uniforms );
30854
+ multiview.updateCameraViewMatricesUniform( camera, p_uniforms );
30855
+
30856
+ } else {
30857
+
30858
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
30859
+ p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
30860
+
30861
+ }
30362
30862
 
30363
30863
  const uCamPos = p_uniforms.map.cameraPosition;
30364
30864
 
@@ -30506,8 +31006,17 @@ class WebGLRenderer {
30506
31006
 
30507
31007
  // common matrices
30508
31008
 
30509
- p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
30510
- p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
31009
+ if ( program.numMultiviewViews > 0 ) {
31010
+
31011
+ multiview.updateObjectMatricesUniforms( object, camera, p_uniforms );
31012
+
31013
+ } else {
31014
+
31015
+ p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
31016
+ p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
31017
+
31018
+ }
31019
+
30511
31020
  p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );
30512
31021
 
30513
31022
  // UBOs
@@ -30617,20 +31126,16 @@ class WebGLRenderer {
30617
31126
  const renderTargetProperties = properties.get( renderTarget );
30618
31127
  renderTargetProperties.__hasExternalTextures = true;
30619
31128
 
30620
- if ( renderTargetProperties.__hasExternalTextures ) {
30621
-
30622
- renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
30623
-
30624
- if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
31129
+ renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
30625
31130
 
30626
- // The multisample_render_to_texture extension doesn't work properly if there
30627
- // are midframe flushes and an external depth buffer. Disable use of the extension.
30628
- if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
31131
+ if ( ! renderTargetProperties.__autoAllocateDepthBuffer && ! _currentRenderTarget.isWebGLMultiviewRenderTarget ) {
30629
31132
 
30630
- console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
30631
- renderTargetProperties.__useRenderToTexture = false;
31133
+ // The multisample_render_to_texture extension doesn't work properly if there
31134
+ // are midframe flushes and an external depth buffer. Disable use of the extension.
31135
+ if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
30632
31136
 
30633
- }
31137
+ console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
31138
+ renderTargetProperties.__useRenderToTexture = false;
30634
31139
 
30635
31140
  }
30636
31141
 
@@ -31013,6 +31518,22 @@ class WebGLRenderer {
31013
31518
 
31014
31519
  }
31015
31520
 
31521
+ get outputColorSpace() {
31522
+
31523
+ return this._outputColorSpace;
31524
+
31525
+ }
31526
+
31527
+ set outputColorSpace( colorSpace ) {
31528
+
31529
+ this._outputColorSpace = colorSpace;
31530
+
31531
+ const gl = this.getContext();
31532
+ gl.drawingBufferColorSpace = colorSpace === DisplayP3ColorSpace ? 'display-p3' : 'srgb';
31533
+ gl.unpackColorSpace = ColorManagement.workingColorSpace === LinearDisplayP3ColorSpace ? 'display-p3' : 'srgb';
31534
+
31535
+ }
31536
+
31016
31537
  get physicallyCorrectLights() { // @deprecated, r150
31017
31538
 
31018
31539
  console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
@@ -31084,6 +31605,7 @@ class FogExp2 {
31084
31605
 
31085
31606
  return {
31086
31607
  type: 'FogExp2',
31608
+ name: this.name,
31087
31609
  color: this.color.getHex(),
31088
31610
  density: this.density
31089
31611
  };
@@ -31117,6 +31639,7 @@ class Fog {
31117
31639
 
31118
31640
  return {
31119
31641
  type: 'Fog',
31642
+ name: this.name,
31120
31643
  color: this.color.getHex(),
31121
31644
  near: this.near,
31122
31645
  far: this.far
@@ -31722,7 +32245,7 @@ const _uvC = /*@__PURE__*/ new Vector2();
31722
32245
 
31723
32246
  class Sprite extends Object3D {
31724
32247
 
31725
- constructor( material ) {
32248
+ constructor( material = new SpriteMaterial() ) {
31726
32249
 
31727
32250
  super();
31728
32251
 
@@ -31750,7 +32273,7 @@ class Sprite extends Object3D {
31750
32273
  }
31751
32274
 
31752
32275
  this.geometry = _geometry;
31753
- this.material = ( material !== undefined ) ? material : new SpriteMaterial();
32276
+ this.material = material;
31754
32277
 
31755
32278
  this.center = new Vector2( 0.5, 0.5 );
31756
32279
 
@@ -35044,10 +35567,13 @@ class CurvePath extends Curve {
35044
35567
 
35045
35568
  if ( ! startPoint.equals( endPoint ) ) {
35046
35569
 
35047
- this.curves.push( new LineCurve( endPoint, startPoint ) );
35570
+ const lineType = ( startPoint.isVector2 === true ) ? 'LineCurve' : 'LineCurve3';
35571
+ this.curves.push( new Curves[ lineType ]( endPoint, startPoint ) );
35048
35572
 
35049
35573
  }
35050
35574
 
35575
+ return this;
35576
+
35051
35577
  }
35052
35578
 
35053
35579
  // To get accurate point with reference to
@@ -40403,21 +40929,6 @@ class LineDashedMaterial extends LineBasicMaterial {
40403
40929
 
40404
40930
  }
40405
40931
 
40406
- // same as Array.prototype.slice, but also works on typed arrays
40407
- function arraySlice( array, from, to ) {
40408
-
40409
- if ( isTypedArray( array ) ) {
40410
-
40411
- // in ios9 array.subarray(from, undefined) will return empty array
40412
- // but array.subarray(from) or array.subarray(from, len) is correct
40413
- return new array.constructor( array.subarray( from, to !== undefined ? to : array.length ) );
40414
-
40415
- }
40416
-
40417
- return array.slice( from, to );
40418
-
40419
- }
40420
-
40421
40932
  // converts an array to a specific type
40422
40933
  function convertArray( array, type, forceClone ) {
40423
40934
 
@@ -40681,14 +41192,14 @@ function makeClipAdditive( targetClip, referenceFrame = 0, referenceClip = targe
40681
41192
  // Reference frame is earlier than the first keyframe, so just use the first keyframe
40682
41193
  const startIndex = referenceOffset;
40683
41194
  const endIndex = referenceValueSize - referenceOffset;
40684
- referenceValue = arraySlice( referenceTrack.values, startIndex, endIndex );
41195
+ referenceValue = referenceTrack.values.slice( startIndex, endIndex );
40685
41196
 
40686
41197
  } else if ( referenceTime >= referenceTrack.times[ lastIndex ] ) {
40687
41198
 
40688
41199
  // Reference frame is after the last keyframe, so just use the last keyframe
40689
41200
  const startIndex = lastIndex * referenceValueSize + referenceOffset;
40690
41201
  const endIndex = startIndex + referenceValueSize - referenceOffset;
40691
- referenceValue = arraySlice( referenceTrack.values, startIndex, endIndex );
41202
+ referenceValue = referenceTrack.values.slice( startIndex, endIndex );
40692
41203
 
40693
41204
  } else {
40694
41205
 
@@ -40697,7 +41208,7 @@ function makeClipAdditive( targetClip, referenceFrame = 0, referenceClip = targe
40697
41208
  const startIndex = referenceOffset;
40698
41209
  const endIndex = referenceValueSize - referenceOffset;
40699
41210
  interpolant.evaluate( referenceTime );
40700
- referenceValue = arraySlice( interpolant.resultBuffer, startIndex, endIndex );
41211
+ referenceValue = interpolant.resultBuffer.slice( startIndex, endIndex );
40701
41212
 
40702
41213
  }
40703
41214
 
@@ -40752,7 +41263,6 @@ function makeClipAdditive( targetClip, referenceFrame = 0, referenceClip = targe
40752
41263
  }
40753
41264
 
40754
41265
  const AnimationUtils = {
40755
- arraySlice: arraySlice,
40756
41266
  convertArray: convertArray,
40757
41267
  isTypedArray: isTypedArray,
40758
41268
  getKeyframeOrder: getKeyframeOrder,
@@ -41435,8 +41945,8 @@ class KeyframeTrack {
41435
41945
  }
41436
41946
 
41437
41947
  const stride = this.getValueSize();
41438
- this.times = arraySlice( times, from, to );
41439
- this.values = arraySlice( this.values, from * stride, to * stride );
41948
+ this.times = times.slice( from, to );
41949
+ this.values = this.values.slice( from * stride, to * stride );
41440
41950
 
41441
41951
  }
41442
41952
 
@@ -41526,8 +42036,8 @@ class KeyframeTrack {
41526
42036
  optimize() {
41527
42037
 
41528
42038
  // times or values may be shared with other tracks, so overwriting is unsafe
41529
- const times = arraySlice( this.times ),
41530
- values = arraySlice( this.values ),
42039
+ const times = this.times.slice(),
42040
+ values = this.values.slice(),
41531
42041
  stride = this.getValueSize(),
41532
42042
 
41533
42043
  smoothInterpolation = this.getInterpolation() === InterpolateSmooth,
@@ -41620,8 +42130,8 @@ class KeyframeTrack {
41620
42130
 
41621
42131
  if ( writeIndex !== times.length ) {
41622
42132
 
41623
- this.times = arraySlice( times, 0, writeIndex );
41624
- this.values = arraySlice( values, 0, writeIndex * stride );
42133
+ this.times = times.slice( 0, writeIndex );
42134
+ this.values = values.slice( 0, writeIndex * stride );
41625
42135
 
41626
42136
  } else {
41627
42137
 
@@ -41636,8 +42146,8 @@ class KeyframeTrack {
41636
42146
 
41637
42147
  clone() {
41638
42148
 
41639
- const times = arraySlice( this.times, 0 );
41640
- const values = arraySlice( this.values, 0 );
42149
+ const times = this.times.slice();
42150
+ const values = this.values.slice();
41641
42151
 
41642
42152
  const TypedKeyframeTrack = this.constructor;
41643
42153
  const track = new TypedKeyframeTrack( this.name, times, values );
@@ -44216,7 +44726,7 @@ class MaterialLoader extends Loader {
44216
44726
 
44217
44727
  if ( json.rotation !== undefined ) material.rotation = json.rotation;
44218
44728
 
44219
- if ( json.linewidth !== 1 ) material.linewidth = json.linewidth;
44729
+ if ( json.linewidth !== undefined ) material.linewidth = json.linewidth;
44220
44730
  if ( json.dashSize !== undefined ) material.dashSize = json.dashSize;
44221
44731
  if ( json.gapSize !== undefined ) material.gapSize = json.gapSize;
44222
44732
  if ( json.scale !== undefined ) material.scale = json.scale;
@@ -45497,6 +46007,12 @@ class ObjectLoader extends Loader {
45497
46007
 
45498
46008
  }
45499
46009
 
46010
+ if ( data.fog.name !== '' ) {
46011
+
46012
+ object.fog.name = data.fog.name;
46013
+
46014
+ }
46015
+
45500
46016
  }
45501
46017
 
45502
46018
  if ( data.backgroundBlurriness !== undefined ) object.backgroundBlurriness = data.backgroundBlurriness;
@@ -45981,48 +46497,6 @@ class AudioLoader extends Loader {
45981
46497
 
45982
46498
  }
45983
46499
 
45984
- class HemisphereLightProbe extends LightProbe {
45985
-
45986
- constructor( skyColor, groundColor, intensity = 1 ) {
45987
-
45988
- super( undefined, intensity );
45989
-
45990
- this.isHemisphereLightProbe = true;
45991
-
45992
- const color1 = new Color().set( skyColor );
45993
- const color2 = new Color().set( groundColor );
45994
-
45995
- const sky = new Vector3( color1.r, color1.g, color1.b );
45996
- const ground = new Vector3( color2.r, color2.g, color2.b );
45997
-
45998
- // without extra factor of PI in the shader, should = 1 / Math.sqrt( Math.PI );
45999
- const c0 = Math.sqrt( Math.PI );
46000
- const c1 = c0 * Math.sqrt( 0.75 );
46001
-
46002
- this.sh.coefficients[ 0 ].copy( sky ).add( ground ).multiplyScalar( c0 );
46003
- this.sh.coefficients[ 1 ].copy( sky ).sub( ground ).multiplyScalar( c1 );
46004
-
46005
- }
46006
-
46007
- }
46008
-
46009
- class AmbientLightProbe extends LightProbe {
46010
-
46011
- constructor( color, intensity = 1 ) {
46012
-
46013
- super( undefined, intensity );
46014
-
46015
- this.isAmbientLightProbe = true;
46016
-
46017
- const color1 = new Color().set( color );
46018
-
46019
- // without extra factor of PI in the shader, would be 2 / Math.sqrt( Math.PI );
46020
- this.sh.coefficients[ 0 ].set( color1.r, color1.g, color1.b ).multiplyScalar( 2 * Math.sqrt( Math.PI ) );
46021
-
46022
- }
46023
-
46024
- }
46025
-
46026
46500
  const _eyeRight = /*@__PURE__*/ new Matrix4();
46027
46501
  const _eyeLeft = /*@__PURE__*/ new Matrix4();
46028
46502
  const _projectionMatrix = /*@__PURE__*/ new Matrix4();
@@ -52063,4 +52537,4 @@ if ( typeof window !== 'undefined' ) {
52063
52537
 
52064
52538
  }
52065
52539
 
52066
- export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AmbientLightProbe, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BackSide, BasicDepthPacking, BasicShadowMap, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CineonToneMapping, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, ColorManagement, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry, Cylindrical, Data3DTexture, DataArrayTexture, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DisplayP3ColorSpace, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualCompare, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, Float64BufferAttribute, FloatType, Fog, FogExp2, FramebufferTexture, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, HemisphereLightProbe, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearDisplayP3ColorSpace, LinearEncoding, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry, OneFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, Path, PerspectiveCamera, Plane, PlaneGeometry, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RenderTarget, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, Scene, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry, Texture, TextureLoader, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, TwoPassDoubleSide, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, VideoTexture, WebGL1Renderer, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLRenderTarget, WebGLRenderer, WebGLUtils, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, _SRGBAFormat, createCanvasElement, sRGBEncoding };
52540
+ export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BackSide, BasicDepthPacking, BasicShadowMap, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CineonToneMapping, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, ColorManagement, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry, Cylindrical, Data3DTexture, DataArrayTexture, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DisplayP3ColorSpace, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualCompare, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, Float64BufferAttribute, FloatType, Fog, FogExp2, FramebufferTexture, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearDisplayP3ColorSpace, LinearEncoding, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry, OneFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, P3Primaries, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, Path, PerspectiveCamera, Plane, PlaneGeometry, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, Rec709Primaries, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RenderTarget, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, Scene, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry, Texture, TextureLoader, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, TwoPassDoubleSide, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, VideoTexture, WebGL1Renderer, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLRenderTarget, WebGLRenderer, WebGLUtils, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, _SRGBAFormat, createCanvasElement, sRGBEncoding };