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
package/build/three.js CHANGED
@@ -10,7 +10,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
10
10
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.THREE = {}));
11
11
  })(this, (function (exports) { 'use strict';
12
12
 
13
- const REVISION = '156';
13
+ const REVISION = '157';
14
14
 
15
15
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
16
16
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -170,6 +170,12 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
170
170
  const DisplayP3ColorSpace = 'display-p3';
171
171
  const LinearDisplayP3ColorSpace = 'display-p3-linear';
172
172
 
173
+ const LinearTransfer = 'linear';
174
+ const SRGBTransfer = 'srgb';
175
+
176
+ const Rec709Primaries = 'rec709';
177
+ const P3Primaries = 'p3';
178
+
173
179
  const ZeroStencilOp = 0;
174
180
  const KeepStencilOp = 7680;
175
181
  const ReplaceStencilOp = 7681;
@@ -1558,18 +1564,6 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
1558
1564
 
1559
1565
  }
1560
1566
 
1561
- function SRGBToLinear( c ) {
1562
-
1563
- return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
1564
-
1565
- }
1566
-
1567
- function LinearToSRGB( c ) {
1568
-
1569
- return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;
1570
-
1571
- }
1572
-
1573
1567
  /**
1574
1568
  * Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
1575
1569
  * or clipping. Based on W3C specifications for sRGB and Display P3,
@@ -1582,50 +1576,57 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
1582
1576
  * - http://www.russellcottrell.com/photo/matrixCalculator.htm
1583
1577
  */
1584
1578
 
1585
- const LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = /*@__PURE__*/ new Matrix3().fromArray( [
1586
- 0.8224621, 0.0331941, 0.0170827,
1587
- 0.1775380, 0.9668058, 0.0723974,
1588
- - 0.0000001, 0.0000001, 0.9105199
1589
- ] );
1590
-
1591
- const LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = /*@__PURE__*/ new Matrix3().fromArray( [
1592
- 1.2249401, - 0.0420569, - 0.0196376,
1593
- - 0.2249404, 1.0420571, - 0.0786361,
1594
- 0.0000001, 0.0000000, 1.0982735
1595
- ] );
1596
-
1597
- function DisplayP3ToLinearSRGB( color ) {
1598
-
1599
- // Display P3 uses the sRGB transfer functions
1600
- return color.convertSRGBToLinear().applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB );
1601
-
1602
- }
1603
-
1604
- function LinearSRGBToDisplayP3( color ) {
1605
-
1606
- // Display P3 uses the sRGB transfer functions
1607
- return color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ).convertLinearToSRGB();
1579
+ const LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = /*@__PURE__*/ new Matrix3().set(
1580
+ 0.8224621, 0.177538, 0.0,
1581
+ 0.0331941, 0.9668058, 0.0,
1582
+ 0.0170827, 0.0723974, 0.9105199,
1583
+ );
1608
1584
 
1609
- }
1585
+ const LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = /*@__PURE__*/ new Matrix3().set(
1586
+ 1.2249401, - 0.2249404, 0.0,
1587
+ - 0.0420569, 1.0420571, 0.0,
1588
+ - 0.0196376, - 0.0786361, 1.0982735
1589
+ );
1610
1590
 
1611
- // Conversions from <source> to Linear-sRGB reference space.
1612
- const TO_LINEAR = {
1613
- [ LinearSRGBColorSpace ]: ( color ) => color,
1614
- [ SRGBColorSpace ]: ( color ) => color.convertSRGBToLinear(),
1615
- [ DisplayP3ColorSpace ]: DisplayP3ToLinearSRGB,
1591
+ /**
1592
+ * Defines supported color spaces by transfer function and primaries,
1593
+ * and provides conversions to/from the Linear-sRGB reference space.
1594
+ */
1595
+ const COLOR_SPACES = {
1596
+ [ LinearSRGBColorSpace ]: {
1597
+ transfer: LinearTransfer,
1598
+ primaries: Rec709Primaries,
1599
+ toReference: ( color ) => color,
1600
+ fromReference: ( color ) => color,
1601
+ },
1602
+ [ SRGBColorSpace ]: {
1603
+ transfer: SRGBTransfer,
1604
+ primaries: Rec709Primaries,
1605
+ toReference: ( color ) => color.convertSRGBToLinear(),
1606
+ fromReference: ( color ) => color.convertLinearToSRGB(),
1607
+ },
1608
+ [ LinearDisplayP3ColorSpace ]: {
1609
+ transfer: LinearTransfer,
1610
+ primaries: P3Primaries,
1611
+ toReference: ( color ) => color.applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
1612
+ fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ),
1613
+ },
1614
+ [ DisplayP3ColorSpace ]: {
1615
+ transfer: SRGBTransfer,
1616
+ primaries: P3Primaries,
1617
+ toReference: ( color ) => color.convertSRGBToLinear().applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
1618
+ fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ).convertLinearToSRGB(),
1619
+ },
1616
1620
  };
1617
1621
 
1618
- // Conversions to <target> from Linear-sRGB reference space.
1619
- const FROM_LINEAR = {
1620
- [ LinearSRGBColorSpace ]: ( color ) => color,
1621
- [ SRGBColorSpace ]: ( color ) => color.convertLinearToSRGB(),
1622
- [ DisplayP3ColorSpace ]: LinearSRGBToDisplayP3,
1623
- };
1622
+ const SUPPORTED_WORKING_COLOR_SPACES = new Set( [ LinearSRGBColorSpace, LinearDisplayP3ColorSpace ] );
1624
1623
 
1625
1624
  const ColorManagement = {
1626
1625
 
1627
1626
  enabled: true,
1628
1627
 
1628
+ _workingColorSpace: LinearSRGBColorSpace,
1629
+
1629
1630
  get legacyMode() {
1630
1631
 
1631
1632
  console.warn( 'THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150.' );
@@ -1644,13 +1645,19 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
1644
1645
 
1645
1646
  get workingColorSpace() {
1646
1647
 
1647
- return LinearSRGBColorSpace;
1648
+ return this._workingColorSpace;
1648
1649
 
1649
1650
  },
1650
1651
 
1651
1652
  set workingColorSpace( colorSpace ) {
1652
1653
 
1653
- console.warn( 'THREE.ColorManagement: .workingColorSpace is readonly.' );
1654
+ if ( ! SUPPORTED_WORKING_COLOR_SPACES.has( colorSpace ) ) {
1655
+
1656
+ throw new Error( `Unsupported working color space, "${ colorSpace }".` );
1657
+
1658
+ }
1659
+
1660
+ this._workingColorSpace = colorSpace;
1654
1661
 
1655
1662
  },
1656
1663
 
@@ -1662,33 +1669,54 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
1662
1669
 
1663
1670
  }
1664
1671
 
1665
- const sourceToLinear = TO_LINEAR[ sourceColorSpace ];
1666
- const targetFromLinear = FROM_LINEAR[ targetColorSpace ];
1672
+ const sourceToReference = COLOR_SPACES[ sourceColorSpace ].toReference;
1673
+ const targetFromReference = COLOR_SPACES[ targetColorSpace ].fromReference;
1667
1674
 
1668
- if ( sourceToLinear === undefined || targetFromLinear === undefined ) {
1675
+ return targetFromReference( sourceToReference( color ) );
1669
1676
 
1670
- throw new Error( `Unsupported color space conversion, "${ sourceColorSpace }" to "${ targetColorSpace }".` );
1677
+ },
1671
1678
 
1672
- }
1679
+ fromWorkingColorSpace: function ( color, targetColorSpace ) {
1673
1680
 
1674
- return targetFromLinear( sourceToLinear( color ) );
1681
+ return this.convert( color, this._workingColorSpace, targetColorSpace );
1675
1682
 
1676
1683
  },
1677
1684
 
1678
- fromWorkingColorSpace: function ( color, targetColorSpace ) {
1685
+ toWorkingColorSpace: function ( color, sourceColorSpace ) {
1679
1686
 
1680
- return this.convert( color, this.workingColorSpace, targetColorSpace );
1687
+ return this.convert( color, sourceColorSpace, this._workingColorSpace );
1681
1688
 
1682
1689
  },
1683
1690
 
1684
- toWorkingColorSpace: function ( color, sourceColorSpace ) {
1691
+ getPrimaries: function ( colorSpace ) {
1685
1692
 
1686
- return this.convert( color, sourceColorSpace, this.workingColorSpace );
1693
+ return COLOR_SPACES[ colorSpace ].primaries;
1694
+
1695
+ },
1696
+
1697
+ getTransfer: function ( colorSpace ) {
1698
+
1699
+ if ( colorSpace === NoColorSpace ) return LinearTransfer;
1700
+
1701
+ return COLOR_SPACES[ colorSpace ].transfer;
1687
1702
 
1688
1703
  },
1689
1704
 
1690
1705
  };
1691
1706
 
1707
+
1708
+ function SRGBToLinear( c ) {
1709
+
1710
+ return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
1711
+
1712
+ }
1713
+
1714
+ function LinearToSRGB( c ) {
1715
+
1716
+ return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;
1717
+
1718
+ }
1719
+
1692
1720
  let _canvas;
1693
1721
 
1694
1722
  class ImageUtils {
@@ -1814,7 +1842,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
1814
1842
 
1815
1843
  }
1816
1844
 
1817
- let sourceId = 0;
1845
+ let _sourceId = 0;
1818
1846
 
1819
1847
  class Source {
1820
1848
 
@@ -1822,7 +1850,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
1822
1850
 
1823
1851
  this.isSource = true;
1824
1852
 
1825
- Object.defineProperty( this, 'id', { value: sourceId ++ } );
1853
+ Object.defineProperty( this, 'id', { value: _sourceId ++ } );
1826
1854
 
1827
1855
  this.uuid = generateUUID();
1828
1856
 
@@ -2928,20 +2956,29 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
2928
2956
 
2929
2957
  }
2930
2958
 
2959
+ options = Object.assign( {
2960
+ generateMipmaps: false,
2961
+ internalFormat: null,
2962
+ minFilter: LinearFilter,
2963
+ depthBuffer: true,
2964
+ stencilBuffer: false,
2965
+ depthTexture: null,
2966
+ samples: 0
2967
+ }, options );
2968
+
2931
2969
  this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
2932
2970
  this.texture.isRenderTargetTexture = true;
2933
2971
 
2934
2972
  this.texture.flipY = false;
2935
- this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
2936
- this.texture.internalFormat = options.internalFormat !== undefined ? options.internalFormat : null;
2937
- this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
2973
+ this.texture.generateMipmaps = options.generateMipmaps;
2974
+ this.texture.internalFormat = options.internalFormat;
2938
2975
 
2939
- this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
2940
- this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;
2976
+ this.depthBuffer = options.depthBuffer;
2977
+ this.stencilBuffer = options.stencilBuffer;
2941
2978
 
2942
- this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
2979
+ this.depthTexture = options.depthTexture;
2943
2980
 
2944
- this.samples = options.samples !== undefined ? options.samples : 0;
2981
+ this.samples = options.samples;
2945
2982
 
2946
2983
  }
2947
2984
 
@@ -8709,10 +8746,10 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
8709
8746
 
8710
8747
  if ( this.blending !== NormalBlending ) data.blending = this.blending;
8711
8748
  if ( this.side !== FrontSide ) data.side = this.side;
8712
- if ( this.vertexColors ) data.vertexColors = true;
8749
+ if ( this.vertexColors === true ) data.vertexColors = true;
8713
8750
 
8714
8751
  if ( this.opacity < 1 ) data.opacity = this.opacity;
8715
- if ( this.transparent === true ) data.transparent = this.transparent;
8752
+ if ( this.transparent === true ) data.transparent = true;
8716
8753
 
8717
8754
  data.depthFunc = this.depthFunc;
8718
8755
  data.depthTest = this.depthTest;
@@ -8743,17 +8780,17 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
8743
8780
  if ( this.dithering === true ) data.dithering = true;
8744
8781
 
8745
8782
  if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;
8746
- if ( this.alphaHash === true ) data.alphaHash = this.alphaHash;
8747
- if ( this.alphaToCoverage === true ) data.alphaToCoverage = this.alphaToCoverage;
8748
- if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha;
8749
- if ( this.forceSinglePass === true ) data.forceSinglePass = this.forceSinglePass;
8783
+ if ( this.alphaHash === true ) data.alphaHash = true;
8784
+ if ( this.alphaToCoverage === true ) data.alphaToCoverage = true;
8785
+ if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = true;
8786
+ if ( this.forceSinglePass === true ) data.forceSinglePass = true;
8750
8787
 
8751
- if ( this.wireframe === true ) data.wireframe = this.wireframe;
8788
+ if ( this.wireframe === true ) data.wireframe = true;
8752
8789
  if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;
8753
8790
  if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;
8754
8791
  if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;
8755
8792
 
8756
- if ( this.flatShading === true ) data.flatShading = this.flatShading;
8793
+ if ( this.flatShading === true ) data.flatShading = true;
8757
8794
 
8758
8795
  if ( this.visible === false ) data.visible = false;
8759
8796
 
@@ -9334,11 +9371,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
9334
9371
 
9335
9372
  this.getHSL( _hslA );
9336
9373
 
9337
- _hslA.h += h; _hslA.s += s; _hslA.l += l;
9338
-
9339
- this.setHSL( _hslA.h, _hslA.s, _hslA.l );
9340
-
9341
- return this;
9374
+ return this.setHSL( _hslA.h + h, _hslA.s + s, _hslA.l + l );
9342
9375
 
9343
9376
  }
9344
9377
 
@@ -12121,7 +12154,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
12121
12154
 
12122
12155
  }
12123
12156
 
12124
- return LinearSRGBColorSpace;
12157
+ return ColorManagement.workingColorSpace;
12125
12158
 
12126
12159
  }
12127
12160
 
@@ -12349,11 +12382,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
12349
12382
 
12350
12383
  getWorldDirection( target ) {
12351
12384
 
12352
- this.updateWorldMatrix( true, false );
12353
-
12354
- const e = this.matrixWorld.elements;
12355
-
12356
- return target.set( - e[ 8 ], - e[ 9 ], - e[ 10 ] ).normalize();
12385
+ return super.getWorldDirection( target ).negate();
12357
12386
 
12358
12387
  }
12359
12388
 
@@ -12623,6 +12652,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
12623
12652
 
12624
12653
  this.renderTarget = renderTarget;
12625
12654
  this.coordinateSystem = null;
12655
+ this.activeMipmapLevel = 0;
12626
12656
 
12627
12657
  const cameraPX = new PerspectiveCamera( fov, aspect, near, far );
12628
12658
  cameraPX.layers = this.layers;
@@ -12720,7 +12750,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
12720
12750
 
12721
12751
  if ( this.parent === null ) this.updateMatrixWorld();
12722
12752
 
12723
- const renderTarget = this.renderTarget;
12753
+ const { renderTarget, activeMipmapLevel } = this;
12724
12754
 
12725
12755
  if ( this.coordinateSystem !== renderer.coordinateSystem ) {
12726
12756
 
@@ -12733,6 +12763,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
12733
12763
  const [ cameraPX, cameraNX, cameraPY, cameraNY, cameraPZ, cameraNZ ] = this.children;
12734
12764
 
12735
12765
  const currentRenderTarget = renderer.getRenderTarget();
12766
+ const currentActiveCubeFace = renderer.getActiveCubeFace();
12767
+ const currentActiveMipmapLevel = renderer.getActiveMipmapLevel();
12736
12768
 
12737
12769
  const currentXrEnabled = renderer.xr.enabled;
12738
12770
 
@@ -12742,27 +12774,30 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
12742
12774
 
12743
12775
  renderTarget.texture.generateMipmaps = false;
12744
12776
 
12745
- renderer.setRenderTarget( renderTarget, 0 );
12777
+ renderer.setRenderTarget( renderTarget, 0, activeMipmapLevel );
12746
12778
  renderer.render( scene, cameraPX );
12747
12779
 
12748
- renderer.setRenderTarget( renderTarget, 1 );
12780
+ renderer.setRenderTarget( renderTarget, 1, activeMipmapLevel );
12749
12781
  renderer.render( scene, cameraNX );
12750
12782
 
12751
- renderer.setRenderTarget( renderTarget, 2 );
12783
+ renderer.setRenderTarget( renderTarget, 2, activeMipmapLevel );
12752
12784
  renderer.render( scene, cameraPY );
12753
12785
 
12754
- renderer.setRenderTarget( renderTarget, 3 );
12786
+ renderer.setRenderTarget( renderTarget, 3, activeMipmapLevel );
12755
12787
  renderer.render( scene, cameraNY );
12756
12788
 
12757
- renderer.setRenderTarget( renderTarget, 4 );
12789
+ renderer.setRenderTarget( renderTarget, 4, activeMipmapLevel );
12758
12790
  renderer.render( scene, cameraPZ );
12759
12791
 
12792
+ // mipmaps are generated during the last call of render()
12793
+ // at this point, all sides of the cube render target are defined
12794
+
12760
12795
  renderTarget.texture.generateMipmaps = generateMipmaps;
12761
12796
 
12762
- renderer.setRenderTarget( renderTarget, 5 );
12797
+ renderer.setRenderTarget( renderTarget, 5, activeMipmapLevel );
12763
12798
  renderer.render( scene, cameraNZ );
12764
12799
 
12765
- renderer.setRenderTarget( currentRenderTarget );
12800
+ renderer.setRenderTarget( currentRenderTarget, currentActiveCubeFace, currentActiveMipmapLevel );
12766
12801
 
12767
12802
  renderer.xr.enabled = currentXrEnabled;
12768
12803
 
@@ -13676,7 +13711,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
13676
13711
 
13677
13712
  var alphatest_pars_fragment = "#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif";
13678
13713
 
13679
- 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";
13714
+ 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";
13680
13715
 
13681
13716
  var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
13682
13717
 
@@ -13706,7 +13741,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
13706
13741
 
13707
13742
  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";
13708
13743
 
13709
- 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";
13744
+ 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";
13710
13745
 
13711
13746
  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";
13712
13747
 
@@ -13722,7 +13757,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
13722
13757
 
13723
13758
  var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
13724
13759
 
13725
- 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}";
13760
+ 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}";
13726
13761
 
13727
13762
  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";
13728
13763
 
@@ -13750,29 +13785,29 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
13750
13785
 
13751
13786
  var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
13752
13787
 
13753
- 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";
13788
+ 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";
13754
13789
 
13755
- 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";
13790
+ 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";
13756
13791
 
13757
13792
  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";
13758
13793
 
13759
13794
  var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;";
13760
13795
 
13761
- 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";
13796
+ 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";
13762
13797
 
13763
13798
  var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
13764
13799
 
13765
- 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";
13800
+ 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";
13766
13801
 
13767
- 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";
13802
+ 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";
13768
13803
 
13769
- 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}";
13804
+ 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}";
13770
13805
 
13771
- 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";
13806
+ 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";
13772
13807
 
13773
- 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";
13808
+ 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";
13774
13809
 
13775
- 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";
13810
+ 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";
13776
13811
 
13777
13812
  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";
13778
13813
 
@@ -13802,7 +13837,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
13802
13837
 
13803
13838
  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";
13804
13839
 
13805
- 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;";
13840
+ 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;";
13806
13841
 
13807
13842
  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";
13808
13843
 
@@ -13814,7 +13849,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
13814
13849
 
13815
13850
  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";
13816
13851
 
13817
- var clearcoat_normal_fragment_begin = "#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif";
13852
+ var clearcoat_normal_fragment_begin = "#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif";
13818
13853
 
13819
13854
  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";
13820
13855
 
@@ -13924,7 +13959,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
13924
13959
 
13925
13960
  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}";
13926
13961
 
13927
- 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}";
13962
+ 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}";
13928
13963
 
13929
13964
  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}";
13930
13965
 
@@ -14719,7 +14754,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
14719
14754
  if ( boxMesh === undefined ) {
14720
14755
 
14721
14756
  boxMesh = new Mesh(
14722
- new BoxGeometry( 1, 1, 1 ),
14757
+ new BoxGeometry( 10000, 10000, 10000 ),
14723
14758
  new ShaderMaterial( {
14724
14759
  name: 'BackgroundCubeMaterial',
14725
14760
  uniforms: cloneUniforms( ShaderLib.backgroundCube.uniforms ),
@@ -14760,7 +14795,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
14760
14795
  boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
14761
14796
  boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
14762
14797
  boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
14763
- boxMesh.material.toneMapped = ( background.colorSpace === SRGBColorSpace ) ? false : true;
14798
+ boxMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;
14764
14799
 
14765
14800
  if ( currentBackground !== background ||
14766
14801
  currentBackgroundVersion !== background.version ||
@@ -14816,7 +14851,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
14816
14851
 
14817
14852
  planeMesh.material.uniforms.t2D.value = background;
14818
14853
  planeMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
14819
- planeMesh.material.toneMapped = ( background.colorSpace === SRGBColorSpace ) ? false : true;
14854
+ planeMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;
14820
14855
 
14821
14856
  if ( background.matrixAutoUpdate === true ) {
14822
14857
 
@@ -17815,6 +17850,103 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
17815
17850
 
17816
17851
  }
17817
17852
 
17853
+ /**
17854
+ * @author fernandojsg / http://fernandojsg.com
17855
+ * @author Takahiro https://github.com/takahirox
17856
+ */
17857
+
17858
+ class WebGLMultiview {
17859
+
17860
+ constructor( renderer, extensions, gl ) {
17861
+
17862
+ this.renderer = renderer;
17863
+
17864
+ this.DEFAULT_NUMVIEWS = 2;
17865
+ this.maxNumViews = 0;
17866
+ this.gl = gl;
17867
+
17868
+ this.extensions = extensions;
17869
+
17870
+ this.available = this.extensions.has( 'OCULUS_multiview' );
17871
+
17872
+ if ( this.available ) {
17873
+
17874
+ const extension = this.extensions.get( 'OCULUS_multiview' );
17875
+
17876
+ this.maxNumViews = this.gl.getParameter( extension.MAX_VIEWS_OVR );
17877
+
17878
+ this.mat4 = [];
17879
+ this.mat3 = [];
17880
+ this.cameraArray = [];
17881
+
17882
+ for ( var i = 0; i < this.maxNumViews; i ++ ) {
17883
+
17884
+ this.mat4[ i ] = new Matrix4();
17885
+ this.mat3[ i ] = new Matrix3();
17886
+
17887
+ }
17888
+
17889
+ }
17890
+
17891
+ }
17892
+
17893
+ //
17894
+ getCameraArray( camera ) {
17895
+
17896
+ if ( camera.isArrayCamera ) return camera.cameras;
17897
+
17898
+ this.cameraArray[ 0 ] = camera;
17899
+
17900
+ return this.cameraArray;
17901
+
17902
+ }
17903
+
17904
+ updateCameraProjectionMatricesUniform( camera, uniforms ) {
17905
+
17906
+ var cameras = this.getCameraArray( camera );
17907
+
17908
+ for ( var i = 0; i < cameras.length; i ++ ) {
17909
+
17910
+ this.mat4[ i ].copy( cameras[ i ].projectionMatrix );
17911
+
17912
+ }
17913
+
17914
+ uniforms.setValue( this.gl, 'projectionMatrices', this.mat4 );
17915
+
17916
+ }
17917
+
17918
+ updateCameraViewMatricesUniform( camera, uniforms ) {
17919
+
17920
+ var cameras = this.getCameraArray( camera );
17921
+
17922
+ for ( var i = 0; i < cameras.length; i ++ ) {
17923
+
17924
+ this.mat4[ i ].copy( cameras[ i ].matrixWorldInverse );
17925
+
17926
+ }
17927
+
17928
+ uniforms.setValue( this.gl, 'viewMatrices', this.mat4 );
17929
+
17930
+ }
17931
+
17932
+ updateObjectMatricesUniforms( object, camera, uniforms ) {
17933
+
17934
+ var cameras = this.getCameraArray( camera );
17935
+
17936
+ for ( var i = 0; i < cameras.length; i ++ ) {
17937
+
17938
+ this.mat4[ i ].multiplyMatrices( cameras[ i ].matrixWorldInverse, object.matrixWorld );
17939
+ this.mat3[ i ].getNormalMatrix( this.mat4[ i ] );
17940
+
17941
+ }
17942
+
17943
+ uniforms.setValue( this.gl, 'modelViewMatrices', this.mat4 );
17944
+ uniforms.setValue( this.gl, 'normalMatrices', this.mat3 );
17945
+
17946
+ }
17947
+
17948
+ }
17949
+
17818
17950
  function WebGLObjects( gl, geometries, attributes, info ) {
17819
17951
 
17820
17952
  let updateMap = new WeakMap();
@@ -19080,15 +19212,38 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
19080
19212
 
19081
19213
  function getEncodingComponents( colorSpace ) {
19082
19214
 
19215
+ const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
19216
+ const encodingPrimaries = ColorManagement.getPrimaries( colorSpace );
19217
+
19218
+ let gamutMapping;
19219
+
19220
+ if ( workingPrimaries === encodingPrimaries ) {
19221
+
19222
+ gamutMapping = '';
19223
+
19224
+ } else if ( workingPrimaries === P3Primaries && encodingPrimaries === Rec709Primaries ) {
19225
+
19226
+ gamutMapping = 'LinearDisplayP3ToLinearSRGB';
19227
+
19228
+ } else if ( workingPrimaries === Rec709Primaries && encodingPrimaries === P3Primaries ) {
19229
+
19230
+ gamutMapping = 'LinearSRGBToLinearDisplayP3';
19231
+
19232
+ }
19233
+
19083
19234
  switch ( colorSpace ) {
19084
19235
 
19085
19236
  case LinearSRGBColorSpace:
19086
- return [ 'Linear', '( value )' ];
19237
+ case LinearDisplayP3ColorSpace:
19238
+ return [ gamutMapping, 'LinearTransferOETF' ];
19239
+
19087
19240
  case SRGBColorSpace:
19088
- return [ 'sRGB', '( value )' ];
19241
+ case DisplayP3ColorSpace:
19242
+ return [ gamutMapping, 'sRGBTransferOETF' ];
19243
+
19089
19244
  default:
19090
19245
  console.warn( 'THREE.WebGLProgram: Unsupported color space:', colorSpace );
19091
- return [ 'Linear', '( value )' ];
19246
+ return [ gamutMapping, 'LinearTransferOETF' ];
19092
19247
 
19093
19248
  }
19094
19249
 
@@ -19121,7 +19276,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
19121
19276
  function getTexelEncodingFunction( functionName, colorSpace ) {
19122
19277
 
19123
19278
  const components = getEncodingComponents( colorSpace );
19124
- return 'vec4 ' + functionName + '( vec4 value ) { return LinearTo' + components[ 0 ] + components[ 1 ] + '; }';
19279
+ return `vec4 ${functionName}( vec4 value ) { return ${components[ 0 ]}( ${components[ 1 ]}( value ) ); }`;
19125
19280
 
19126
19281
  }
19127
19282
 
@@ -19485,6 +19640,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
19485
19640
  let prefixVertex, prefixFragment;
19486
19641
  let versionString = parameters.glslVersion ? '#version ' + parameters.glslVersion + '\n' : '';
19487
19642
 
19643
+ const numMultiviewViews = parameters.numMultiviewViews;
19644
+
19488
19645
  if ( parameters.isRawShaderMaterial ) {
19489
19646
 
19490
19647
  prefixVertex = [
@@ -19548,6 +19705,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
19548
19705
  parameters.displacementMap ? '#define USE_DISPLACEMENTMAP' : '',
19549
19706
  parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
19550
19707
 
19708
+ parameters.anisotropy ? '#define USE_ANISOTROPY' : '',
19551
19709
  parameters.anisotropyMap ? '#define USE_ANISOTROPYMAP' : '',
19552
19710
 
19553
19711
  parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',
@@ -19635,6 +19793,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
19635
19793
 
19636
19794
  parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '',
19637
19795
 
19796
+ parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
19797
+
19638
19798
  parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
19639
19799
 
19640
19800
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
@@ -19817,6 +19977,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
19817
19977
 
19818
19978
  parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '',
19819
19979
 
19980
+ parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
19981
+
19820
19982
  parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
19821
19983
 
19822
19984
  parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
@@ -19886,6 +20048,53 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
19886
20048
  '#define textureCubeGradEXT textureGrad'
19887
20049
  ].join( '\n' ) + '\n' + prefixFragment;
19888
20050
 
20051
+ // Multiview
20052
+
20053
+ if ( numMultiviewViews > 0 ) {
20054
+
20055
+ // TODO: fix light transforms here?
20056
+
20057
+ prefixVertex = [
20058
+ '#extension GL_OVR_multiview : require',
20059
+ 'layout(num_views = ' + numMultiviewViews + ') in;',
20060
+ '#define VIEW_ID gl_ViewID_OVR'
20061
+ ].join( '\n' ) + '\n' + prefixVertex;
20062
+
20063
+ prefixVertex = prefixVertex.replace(
20064
+ [
20065
+ 'uniform mat4 modelViewMatrix;',
20066
+ 'uniform mat4 projectionMatrix;',
20067
+ 'uniform mat4 viewMatrix;',
20068
+ 'uniform mat3 normalMatrix;'
20069
+ ].join( '\n' ),
20070
+ [
20071
+ 'uniform mat4 modelViewMatrices[' + numMultiviewViews + '];',
20072
+ 'uniform mat4 projectionMatrices[' + numMultiviewViews + '];',
20073
+ 'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
20074
+ 'uniform mat3 normalMatrices[' + numMultiviewViews + '];',
20075
+
20076
+ '#define modelViewMatrix modelViewMatrices[VIEW_ID]',
20077
+ '#define projectionMatrix projectionMatrices[VIEW_ID]',
20078
+ '#define viewMatrix viewMatrices[VIEW_ID]',
20079
+ '#define normalMatrix normalMatrices[VIEW_ID]'
20080
+ ].join( '\n' )
20081
+ );
20082
+
20083
+ prefixFragment = [
20084
+ '#extension GL_OVR_multiview : require',
20085
+ '#define VIEW_ID gl_ViewID_OVR'
20086
+ ].join( '\n' ) + '\n' + prefixFragment;
20087
+
20088
+ prefixFragment = prefixFragment.replace(
20089
+ 'uniform mat4 viewMatrix;',
20090
+ [
20091
+ 'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
20092
+ '#define viewMatrix viewMatrices[VIEW_ID]'
20093
+ ].join( '\n' )
20094
+ );
20095
+
20096
+ }
20097
+
19889
20098
  }
19890
20099
 
19891
20100
  const vertexGlsl = versionString + prefixVertex + vertexShader;
@@ -20050,6 +20259,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
20050
20259
  this.program = program;
20051
20260
  this.vertexShader = glVertexShader;
20052
20261
  this.fragmentShader = glFragmentShader;
20262
+ this.numMultiviewViews = numMultiviewViews;
20053
20263
 
20054
20264
  return this;
20055
20265
 
@@ -20279,6 +20489,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
20279
20489
 
20280
20490
  const currentRenderTarget = renderer.getRenderTarget();
20281
20491
 
20492
+ const numMultiviewViews = currentRenderTarget && currentRenderTarget.isWebGLMultiviewRenderTarget ? currentRenderTarget.numViews : 0;
20493
+
20282
20494
  const IS_INSTANCEDMESH = object.isInstancedMesh === true;
20283
20495
 
20284
20496
  const HAS_MAP = !! material.map;
@@ -20369,6 +20581,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
20369
20581
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
20370
20582
 
20371
20583
  supportsVertexTextures: SUPPORTS_VERTEX_TEXTURES,
20584
+ numMultiviewViews: numMultiviewViews,
20372
20585
  outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace ),
20373
20586
 
20374
20587
  map: HAS_MAP,
@@ -20497,6 +20710,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
20497
20710
  numSpotLightShadows: lights.spotShadowMap.length,
20498
20711
  numSpotLightShadowsWithMaps: lights.numSpotLightShadowsWithMaps,
20499
20712
 
20713
+ numLightProbes: lights.numLightProbes,
20714
+
20500
20715
  numClippingPlanes: clipping.numPlanes,
20501
20716
  numClipIntersection: clipping.numIntersection,
20502
20717
 
@@ -20508,7 +20723,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
20508
20723
  toneMapping: toneMapping,
20509
20724
  useLegacyLights: renderer._useLegacyLights,
20510
20725
 
20511
- decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( material.map.colorSpace === SRGBColorSpace ),
20726
+ decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( ColorManagement.getTransfer( material.map.colorSpace ) === SRGBTransfer ),
20512
20727
 
20513
20728
  premultipliedAlpha: material.premultipliedAlpha,
20514
20729
 
@@ -20621,6 +20836,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
20621
20836
  array.push( parameters.numPointLightShadows );
20622
20837
  array.push( parameters.numSpotLightShadows );
20623
20838
  array.push( parameters.numSpotLightShadowsWithMaps );
20839
+ array.push( parameters.numLightProbes );
20624
20840
  array.push( parameters.shadowMapType );
20625
20841
  array.push( parameters.toneMapping );
20626
20842
  array.push( parameters.numClippingPlanes );
@@ -20713,6 +20929,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
20713
20929
  _programLayers.enable( 18 );
20714
20930
  if ( parameters.decodeVideoTexture )
20715
20931
  _programLayers.enable( 19 );
20932
+ if ( parameters.numMultiviewViews )
20933
+ _programLayers.enable( 20 );
20716
20934
 
20717
20935
  array.push( _programLayers.mask );
20718
20936
 
@@ -21259,7 +21477,9 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
21259
21477
  numDirectionalShadows: - 1,
21260
21478
  numPointShadows: - 1,
21261
21479
  numSpotShadows: - 1,
21262
- numSpotMaps: - 1
21480
+ numSpotMaps: - 1,
21481
+
21482
+ numLightProbes: - 1
21263
21483
  },
21264
21484
 
21265
21485
  ambient: [ 0, 0, 0 ],
@@ -21281,7 +21501,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
21281
21501
  pointShadowMap: [],
21282
21502
  pointShadowMatrix: [],
21283
21503
  hemi: [],
21284
- numSpotLightShadowsWithMaps: 0
21504
+ numSpotLightShadowsWithMaps: 0,
21505
+ numLightProbes: 0
21285
21506
 
21286
21507
  };
21287
21508
 
@@ -21309,6 +21530,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
21309
21530
  let numSpotMaps = 0;
21310
21531
  let numSpotShadowsWithMaps = 0;
21311
21532
 
21533
+ let numLightProbes = 0;
21534
+
21312
21535
  // ordering : [shadow casting + map texturing, map texturing, shadow casting, none ]
21313
21536
  lights.sort( shadowCastingAndTexturingLightsFirst );
21314
21537
 
@@ -21339,6 +21562,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
21339
21562
 
21340
21563
  }
21341
21564
 
21565
+ numLightProbes ++;
21566
+
21342
21567
  } else if ( light.isDirectionalLight ) {
21343
21568
 
21344
21569
  const uniforms = cache.get( light );
@@ -21526,7 +21751,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
21526
21751
  hash.numDirectionalShadows !== numDirectionalShadows ||
21527
21752
  hash.numPointShadows !== numPointShadows ||
21528
21753
  hash.numSpotShadows !== numSpotShadows ||
21529
- hash.numSpotMaps !== numSpotMaps ) {
21754
+ hash.numSpotMaps !== numSpotMaps ||
21755
+ hash.numLightProbes !== numLightProbes ) {
21530
21756
 
21531
21757
  state.directional.length = directionalLength;
21532
21758
  state.spot.length = spotLength;
@@ -21545,6 +21771,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
21545
21771
  state.spotLightMatrix.length = numSpotShadows + numSpotMaps - numSpotShadowsWithMaps;
21546
21772
  state.spotLightMap.length = numSpotMaps;
21547
21773
  state.numSpotLightShadowsWithMaps = numSpotShadowsWithMaps;
21774
+ state.numLightProbes = numLightProbes;
21548
21775
 
21549
21776
  hash.directionalLength = directionalLength;
21550
21777
  hash.pointLength = pointLength;
@@ -21557,6 +21784,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
21557
21784
  hash.numSpotShadows = numSpotShadows;
21558
21785
  hash.numSpotMaps = numSpotMaps;
21559
21786
 
21787
+ hash.numLightProbes = numLightProbes;
21788
+
21560
21789
  state.version = nextVersion ++;
21561
21790
 
21562
21791
  }
@@ -23537,12 +23766,16 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
23537
23766
  const maxSamples = capabilities.maxSamples;
23538
23767
  const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
23539
23768
  const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
23769
+ const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
23540
23770
 
23541
23771
  const _videoTextures = new WeakMap();
23542
23772
  let _canvas;
23543
23773
 
23544
23774
  const _sources = new WeakMap(); // maps WebglTexture objects to instances of Source
23545
23775
 
23776
+ let _deferredUploads = [];
23777
+ let _deferTextureUploads = false;
23778
+
23546
23779
  // cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,
23547
23780
  // also OffscreenCanvas.getContext("webgl"), but not OffscreenCanvas.getContext("2d")!
23548
23781
  // Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d).
@@ -23703,9 +23936,11 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
23703
23936
 
23704
23937
  if ( glFormat === _gl.RGBA ) {
23705
23938
 
23939
+ const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
23940
+
23706
23941
  if ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;
23707
23942
  if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;
23708
- if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( colorSpace === SRGBColorSpace && forceLinearTransfer === false ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
23943
+ if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( transfer === SRGBTransfer ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
23709
23944
  if ( glType === _gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = _gl.RGBA4;
23710
23945
  if ( glType === _gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = _gl.RGB5_A1;
23711
23946
 
@@ -24008,8 +24243,11 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
24008
24243
 
24009
24244
  } else {
24010
24245
 
24011
- uploadTexture( textureProperties, texture, slot );
24012
- return;
24246
+ if ( uploadTexture( textureProperties, texture, slot ) ) {
24247
+
24248
+ return;
24249
+
24250
+ }
24013
24251
 
24014
24252
  }
24015
24253
 
@@ -24242,8 +24480,45 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
24242
24480
 
24243
24481
  }
24244
24482
 
24483
+ function setDeferTextureUploads( deferFlag ) {
24484
+
24485
+ _deferTextureUploads = deferFlag;
24486
+
24487
+ }
24488
+
24489
+ function runDeferredUploads() {
24490
+
24491
+ const previousDeferSetting = _deferTextureUploads;
24492
+ _deferTextureUploads = false;
24493
+
24494
+ for ( const upload of _deferredUploads ) {
24495
+
24496
+ uploadTexture( upload.textureProperties, upload.texture, upload.slot );
24497
+ upload.texture.isPendingDeferredUpload = false;
24498
+
24499
+ }
24500
+
24501
+ _deferredUploads = [];
24502
+
24503
+ _deferTextureUploads = previousDeferSetting;
24504
+
24505
+ }
24506
+
24245
24507
  function uploadTexture( textureProperties, texture, slot ) {
24246
24508
 
24509
+ if ( _deferTextureUploads ) {
24510
+
24511
+ if ( ! texture.isPendingDeferredUpload ) {
24512
+
24513
+ texture.isPendingDeferredUpload = true;
24514
+ _deferredUploads.push( { textureProperties: textureProperties, texture: texture, slot: slot } );
24515
+
24516
+ }
24517
+
24518
+ return false;
24519
+
24520
+ }
24521
+
24247
24522
  let textureType = _gl.TEXTURE_2D;
24248
24523
 
24249
24524
  if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) textureType = _gl.TEXTURE_2D_ARRAY;
@@ -24260,10 +24535,14 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
24260
24535
 
24261
24536
  state.activeTexture( _gl.TEXTURE0 + slot );
24262
24537
 
24538
+ const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
24539
+ const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries( texture.colorSpace );
24540
+ const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
24541
+
24263
24542
  _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
24264
24543
  _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
24265
24544
  _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
24266
- _gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, _gl.NONE );
24545
+ _gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
24267
24546
 
24268
24547
  const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo$1( texture.image ) === false;
24269
24548
  let image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );
@@ -24656,6 +24935,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
24656
24935
  }
24657
24936
 
24658
24937
  textureProperties.__version = texture.version;
24938
+ return true;
24659
24939
 
24660
24940
  }
24661
24941
 
@@ -24674,10 +24954,14 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
24674
24954
 
24675
24955
  state.activeTexture( _gl.TEXTURE0 + slot );
24676
24956
 
24957
+ const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
24958
+ const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries( texture.colorSpace );
24959
+ const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
24960
+
24677
24961
  _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
24678
24962
  _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
24679
24963
  _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
24680
- _gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, _gl.NONE );
24964
+ _gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
24681
24965
 
24682
24966
  const isCompressed = ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture );
24683
24967
  const isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );
@@ -24881,7 +25165,11 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
24881
25165
  const width = Math.max( 1, renderTarget.width >> level );
24882
25166
  const height = Math.max( 1, renderTarget.height >> level );
24883
25167
 
24884
- if ( textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY ) {
25168
+ if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
25169
+
25170
+ state.texStorage3D( _gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.numViews );
25171
+
25172
+ } else if ( textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY ) {
24885
25173
 
24886
25174
  state.texImage3D( textureTarget, level, glInternalFormat, width, height, renderTarget.depth, 0, glFormat, glType, null );
24887
25175
 
@@ -24895,13 +25183,31 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
24895
25183
 
24896
25184
  state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
24897
25185
 
24898
- if ( useMultisampledRTT( renderTarget ) ) {
25186
+ const multisampled = useMultisampledRTT( renderTarget );
24899
25187
 
24900
- multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
25188
+ if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
25189
+
25190
+ if ( multisampled ) {
25191
+
25192
+ multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ), 0, renderTarget.numViews );
25193
+
25194
+ } else {
25195
+
25196
+ multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( texture ).__webglTexture, 0, 0, renderTarget.numViews );
25197
+
25198
+ }
24901
25199
 
24902
25200
  } else if ( textureTarget === _gl.TEXTURE_2D || ( textureTarget >= _gl.TEXTURE_CUBE_MAP_POSITIVE_X && textureTarget <= _gl.TEXTURE_CUBE_MAP_NEGATIVE_Z ) ) { // see #24753
24903
25201
 
24904
- _gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, level );
25202
+ if ( multisampled ) {
25203
+
25204
+ multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
25205
+
25206
+ } else {
25207
+
25208
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, level );
25209
+
25210
+ }
24905
25211
 
24906
25212
  }
24907
25213
 
@@ -24915,9 +25221,61 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
24915
25221
 
24916
25222
  _gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
24917
25223
 
24918
- if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
25224
+ if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
25225
+
25226
+ const useMultisample = useMultisampledRTT( renderTarget );
25227
+ const numViews = renderTarget.numViews;
25228
+
25229
+ const depthTexture = renderTarget.depthTexture;
25230
+ let glInternalFormat = _gl.DEPTH_COMPONENT24;
25231
+ let glDepthAttachment = _gl.DEPTH_ATTACHMENT;
25232
+
25233
+ if ( depthTexture && depthTexture.isDepthTexture ) {
25234
+
25235
+ if ( depthTexture.type === FloatType ) {
25236
+
25237
+ glInternalFormat = _gl.DEPTH_COMPONENT32F;
25238
+
25239
+ } else if ( depthTexture.type === UnsignedInt248Type ) {
25240
+
25241
+ glInternalFormat = _gl.DEPTH24_STENCIL8;
25242
+ glDepthAttachment = _gl.DEPTH_STENCIL_ATTACHMENT;
25243
+
25244
+ }
25245
+
25246
+ // we're defaulting to _gl.DEPTH_COMPONENT24 so don't assign here
25247
+ // or else DeepScan will complain
25248
+
25249
+ // else if ( depthTexture.type === UnsignedIntType ) {
25250
+
25251
+ // glInternalFormat = _gl.DEPTH_COMPONENT24;
24919
25252
 
24920
- let glInternalFormat = _gl.DEPTH_COMPONENT16;
25253
+ // }
25254
+
25255
+ }
25256
+
25257
+ let depthStencilTexture = properties.get( renderTarget.depthTexture ).__webglTexture;
25258
+ if ( depthStencilTexture === undefined ) {
25259
+
25260
+ depthStencilTexture = _gl.createTexture();
25261
+ _gl.bindTexture( _gl.TEXTURE_2D_ARRAY, depthStencilTexture );
25262
+ _gl.texStorage3D( _gl.TEXTURE_2D_ARRAY, 1, glInternalFormat, renderTarget.width, renderTarget.height, numViews );
25263
+
25264
+ }
25265
+
25266
+ if ( useMultisample ) {
25267
+
25268
+ multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, glDepthAttachment, depthStencilTexture, 0, getRenderTargetSamples( renderTarget ), 0, numViews );
25269
+
25270
+ } else {
25271
+
25272
+ multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, glDepthAttachment, depthStencilTexture, 0, 0, numViews );
25273
+
25274
+ }
25275
+
25276
+ } else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
25277
+
25278
+ let glInternalFormat = ( isWebGL2 === true ) ? _gl.DEPTH_COMPONENT24 : _gl.DEPTH_COMPONENT16;
24921
25279
 
24922
25280
  if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
24923
25281
 
@@ -25039,37 +25397,85 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
25039
25397
  }
25040
25398
 
25041
25399
  setTexture2D( renderTarget.depthTexture, 0 );
25400
+ if ( renderTarget.depthTexture.image.depth != 1 ) {
25401
+
25402
+ setTexture2DArray( renderTarget.depthTexture, 0 );
25403
+
25404
+ } else {
25405
+
25406
+ setTexture2D( renderTarget.depthTexture, 0 );
25407
+
25408
+ }
25042
25409
 
25043
25410
  const webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture;
25044
25411
  const samples = getRenderTargetSamples( renderTarget );
25045
25412
 
25046
- if ( renderTarget.depthTexture.format === DepthFormat ) {
25413
+ if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
25047
25414
 
25048
- if ( useMultisampledRTT( renderTarget ) ) {
25415
+ const useMultisample = useMultisampledRTT( renderTarget );
25416
+ const numViews = renderTarget.numViews;
25049
25417
 
25050
- multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
25418
+ if ( renderTarget.depthTexture.format === DepthFormat ) {
25051
25419
 
25052
- } else {
25420
+ if ( useMultisample ) {
25053
25421
 
25054
- _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
25422
+ multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, webglDepthTexture, 0, samples, 0, numViews );
25055
25423
 
25056
- }
25424
+ } else {
25057
25425
 
25058
- } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
25426
+ multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, webglDepthTexture, 0, 0, numViews );
25059
25427
 
25060
- if ( useMultisampledRTT( renderTarget ) ) {
25428
+ }
25429
+
25430
+ } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
25431
+
25432
+ if ( useMultisample ) {
25433
+
25434
+ multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, webglDepthTexture, 0, samples, 0, numViews );
25435
+
25436
+ } else {
25061
25437
 
25062
- multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
25438
+ multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, webglDepthTexture, 0, 0, numViews );
25439
+
25440
+ }
25063
25441
 
25064
25442
  } else {
25065
25443
 
25066
- _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
25444
+ throw new Error( 'Unknown depthTexture format' );
25067
25445
 
25068
25446
  }
25069
25447
 
25070
25448
  } else {
25071
25449
 
25072
- throw new Error( 'Unknown depthTexture format' );
25450
+ if ( renderTarget.depthTexture.format === DepthFormat ) {
25451
+
25452
+ if ( useMultisampledRTT( renderTarget ) ) {
25453
+
25454
+ multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
25455
+
25456
+ } else {
25457
+
25458
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
25459
+
25460
+ }
25461
+
25462
+ } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
25463
+
25464
+ if ( useMultisampledRTT( renderTarget ) ) {
25465
+
25466
+ multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
25467
+
25468
+ } else {
25469
+
25470
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
25471
+
25472
+ }
25473
+
25474
+ } else {
25475
+
25476
+ throw new Error( 'Unknown depthTexture format' );
25477
+
25478
+ }
25073
25479
 
25074
25480
  }
25075
25481
 
@@ -25348,6 +25754,12 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
25348
25754
 
25349
25755
  }
25350
25756
 
25757
+ if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
25758
+
25759
+ glTextureType = _gl.TEXTURE_2D_ARRAY;
25760
+
25761
+ }
25762
+
25351
25763
  state.bindTexture( glTextureType, textureProperties.__webglTexture );
25352
25764
  setTextureParameters( glTextureType, texture, supportsMips );
25353
25765
 
@@ -25377,9 +25789,9 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
25377
25789
 
25378
25790
  // Setup depth and stencil buffers
25379
25791
 
25380
- if ( renderTarget.depthBuffer ) {
25792
+ if ( renderTarget.depthBuffer || renderTarget.isWebGLMultiviewRenderTarget === true ) {
25381
25793
 
25382
- setupDepthRenderbuffer( renderTarget );
25794
+ this.setupDepthRenderbuffer( renderTarget );
25383
25795
 
25384
25796
  }
25385
25797
 
@@ -25558,7 +25970,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
25558
25970
 
25559
25971
  // sRGB
25560
25972
 
25561
- if ( colorSpace === SRGBColorSpace || colorSpace === DisplayP3ColorSpace ) {
25973
+ if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
25562
25974
 
25563
25975
  if ( isWebGL2 === false ) {
25564
25976
 
@@ -25615,18 +26027,19 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
25615
26027
  this.setTexture3D = setTexture3D;
25616
26028
  this.setTextureCube = setTextureCube;
25617
26029
  this.rebindTextures = rebindTextures;
26030
+ this.uploadTexture = uploadTexture;
25618
26031
  this.setupRenderTarget = setupRenderTarget;
25619
26032
  this.updateRenderTargetMipmap = updateRenderTargetMipmap;
25620
26033
  this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
26034
+ this.setupDepthTexture = setupDepthTexture;
25621
26035
  this.setupDepthRenderbuffer = setupDepthRenderbuffer;
25622
26036
  this.setupFrameBufferTexture = setupFrameBufferTexture;
25623
26037
  this.useMultisampledRTT = useMultisampledRTT;
26038
+ this.runDeferredUploads = runDeferredUploads;
26039
+ this.setDeferTextureUploads = setDeferTextureUploads;
25624
26040
 
25625
26041
  }
25626
26042
 
25627
- const LinearTransferFunction = 0;
25628
- const SRGBTransferFunction = 1;
25629
-
25630
26043
  function WebGLUtils( gl, extensions, capabilities ) {
25631
26044
 
25632
26045
  const isWebGL2 = capabilities.isWebGL2;
@@ -25635,7 +26048,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
25635
26048
 
25636
26049
  let extension;
25637
26050
 
25638
- const transferFunction = ( colorSpace === SRGBColorSpace || colorSpace === DisplayP3ColorSpace ) ? SRGBTransferFunction : LinearTransferFunction;
26051
+ const transfer = ColorManagement.getTransfer( colorSpace );
25639
26052
 
25640
26053
  if ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;
25641
26054
  if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
@@ -25703,7 +26116,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
25703
26116
 
25704
26117
  if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
25705
26118
 
25706
- if ( transferFunction === SRGBTransferFunction ) {
26119
+ if ( transfer === SRGBTransfer ) {
25707
26120
 
25708
26121
  extension = extensions.get( 'WEBGL_compressed_texture_s3tc_srgb' );
25709
26122
 
@@ -25788,8 +26201,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
25788
26201
 
25789
26202
  if ( extension !== null ) {
25790
26203
 
25791
- if ( p === RGB_ETC2_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
25792
- if ( p === RGBA_ETC2_EAC_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
26204
+ if ( p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
26205
+ if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
25793
26206
 
25794
26207
  } else {
25795
26208
 
@@ -25811,20 +26224,20 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
25811
26224
 
25812
26225
  if ( extension !== null ) {
25813
26226
 
25814
- if ( p === RGBA_ASTC_4x4_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;
25815
- if ( p === RGBA_ASTC_5x4_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;
25816
- if ( p === RGBA_ASTC_5x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;
25817
- if ( p === RGBA_ASTC_6x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;
25818
- if ( p === RGBA_ASTC_6x6_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;
25819
- if ( p === RGBA_ASTC_8x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;
25820
- if ( p === RGBA_ASTC_8x6_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;
25821
- if ( p === RGBA_ASTC_8x8_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;
25822
- if ( p === RGBA_ASTC_10x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;
25823
- if ( p === RGBA_ASTC_10x6_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;
25824
- if ( p === RGBA_ASTC_10x8_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;
25825
- if ( p === RGBA_ASTC_10x10_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;
25826
- if ( p === RGBA_ASTC_12x10_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;
25827
- if ( p === RGBA_ASTC_12x12_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;
26227
+ if ( p === RGBA_ASTC_4x4_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;
26228
+ if ( p === RGBA_ASTC_5x4_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;
26229
+ if ( p === RGBA_ASTC_5x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;
26230
+ if ( p === RGBA_ASTC_6x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;
26231
+ if ( p === RGBA_ASTC_6x6_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;
26232
+ if ( p === RGBA_ASTC_8x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;
26233
+ if ( p === RGBA_ASTC_8x6_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;
26234
+ if ( p === RGBA_ASTC_8x8_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;
26235
+ if ( p === RGBA_ASTC_10x5_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;
26236
+ if ( p === RGBA_ASTC_10x6_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;
26237
+ if ( p === RGBA_ASTC_10x8_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;
26238
+ if ( p === RGBA_ASTC_10x10_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;
26239
+ if ( p === RGBA_ASTC_12x10_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;
26240
+ if ( p === RGBA_ASTC_12x12_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;
25828
26241
 
25829
26242
  } else {
25830
26243
 
@@ -25842,7 +26255,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
25842
26255
 
25843
26256
  if ( extension !== null ) {
25844
26257
 
25845
- if ( p === RGBA_BPTC_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;
26258
+ if ( p === RGBA_BPTC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;
25846
26259
  if ( p === RGB_BPTC_SIGNED_Format ) return extension.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
25847
26260
  if ( p === RGB_BPTC_UNSIGNED_Format ) return extension.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
25848
26261
 
@@ -26480,6 +26893,39 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
26480
26893
  dispatchEvent: EventDispatcher.prototype.dispatchEvent
26481
26894
  } );
26482
26895
 
26896
+ /**
26897
+ * @author fernandojsg / http://fernandojsg.com
26898
+ * @author Takahiro https://github.com/takahirox
26899
+ */
26900
+
26901
+
26902
+ class WebGLMultiviewRenderTarget extends WebGLRenderTarget {
26903
+
26904
+ constructor( width, height, numViews, options = {} ) {
26905
+
26906
+ super( width, height, options );
26907
+
26908
+ this.depthBuffer = false;
26909
+ this.stencilBuffer = false;
26910
+
26911
+ this.numViews = numViews;
26912
+
26913
+ }
26914
+
26915
+ copy( source ) {
26916
+
26917
+ super.copy( source );
26918
+
26919
+ this.numViews = source.numViews;
26920
+
26921
+ return this;
26922
+
26923
+ }
26924
+
26925
+ }
26926
+
26927
+ WebGLMultiviewRenderTarget.prototype.isWebGLMultiviewRenderTarget = true;
26928
+
26483
26929
  const _moveEvent = { type: 'move' };
26484
26930
 
26485
26931
  class WebXRController {
@@ -26874,7 +27320,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
26874
27320
 
26875
27321
  class WebXRManager extends EventDispatcher {
26876
27322
 
26877
- constructor( renderer, gl ) {
27323
+ constructor( renderer, gl, extensions, useMultiview ) {
26878
27324
 
26879
27325
  super();
26880
27326
 
@@ -26930,6 +27376,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
26930
27376
  this.enabled = false;
26931
27377
 
26932
27378
  this.isPresenting = false;
27379
+ this.isMultiview = false;
26933
27380
 
26934
27381
  this.getCameraPose = function ( ) {
26935
27382
 
@@ -27173,29 +27620,51 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
27173
27620
 
27174
27621
  }
27175
27622
 
27623
+ scope.isMultiview = useMultiview && extensions.has( 'OCULUS_multiview' );
27624
+
27176
27625
  const projectionlayerInit = {
27177
27626
  colorFormat: gl.RGBA8,
27178
27627
  depthFormat: glDepthFormat,
27179
27628
  scaleFactor: framebufferScaleFactor
27180
27629
  };
27181
27630
 
27631
+ if ( scope.isMultiview ) {
27632
+
27633
+ projectionlayerInit.textureType = 'texture-array';
27634
+
27635
+ }
27636
+
27182
27637
  glBinding = new XRWebGLBinding( session, gl );
27183
27638
 
27184
27639
  glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );
27185
27640
 
27186
27641
  session.updateRenderState( { layers: [ glProjLayer ] } );
27187
27642
 
27188
- newRenderTarget = new WebGLRenderTarget(
27189
- glProjLayer.textureWidth,
27190
- glProjLayer.textureHeight,
27191
- {
27192
- format: RGBAFormat,
27193
- type: UnsignedByteType,
27194
- depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
27195
- stencilBuffer: attributes.stencil,
27196
- colorSpace: renderer.outputColorSpace,
27197
- samples: attributes.antialias ? 4 : 0
27198
- } );
27643
+ const renderTargetOptions = {
27644
+ format: RGBAFormat,
27645
+ type: UnsignedByteType,
27646
+ depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
27647
+ stencilBuffer: attributes.stencil,
27648
+ colorSpace: renderer.outputColorSpace,
27649
+ samples: attributes.antialias ? 4 : 0
27650
+ };
27651
+
27652
+ if ( scope.isMultiview ) {
27653
+
27654
+ const extension = extensions.get( 'OCULUS_multiview' );
27655
+
27656
+ this.maxNumViews = gl.getParameter( extension.MAX_VIEWS_OVR );
27657
+
27658
+ newRenderTarget = new WebGLMultiviewRenderTarget( glProjLayer.textureWidth, glProjLayer.textureHeight, 2, renderTargetOptions );
27659
+
27660
+ } else {
27661
+
27662
+ newRenderTarget = new WebGLRenderTarget(
27663
+ glProjLayer.textureWidth,
27664
+ glProjLayer.textureHeight,
27665
+ renderTargetOptions );
27666
+
27667
+ }
27199
27668
 
27200
27669
  const renderTargetProperties = renderer.properties.get( newRenderTarget );
27201
27670
  renderTargetProperties.__ignoreDepthValues = glProjLayer.ignoreDepthValues;
@@ -28647,6 +29116,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
28647
29116
  preserveDrawingBuffer = false,
28648
29117
  powerPreference = 'default',
28649
29118
  failIfMajorPerformanceCaveat = false,
29119
+ multiviewStereo = false,
28650
29120
  } = parameters;
28651
29121
 
28652
29122
  this.isWebGLRenderer = true;
@@ -28712,7 +29182,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
28712
29182
 
28713
29183
  // physically based shading
28714
29184
 
28715
- this.outputColorSpace = SRGBColorSpace;
29185
+ this._outputColorSpace = SRGBColorSpace;
28716
29186
 
28717
29187
  // physical lights
28718
29188
 
@@ -28881,6 +29351,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
28881
29351
  let extensions, capabilities, state, info;
28882
29352
  let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;
28883
29353
  let programCache, materials, renderLists, renderStates, clipping, shadowMap;
29354
+ let multiview;
28884
29355
 
28885
29356
  let background, morphtargets, bufferRenderer, indexedBufferRenderer;
28886
29357
 
@@ -28914,6 +29385,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
28914
29385
  renderLists = new WebGLRenderLists();
28915
29386
  renderStates = new WebGLRenderStates( extensions, capabilities );
28916
29387
  background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
29388
+ multiview = new WebGLMultiview( _this, extensions, _gl );
28917
29389
  shadowMap = new WebGLShadowMap( _this, objects, capabilities );
28918
29390
  uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
28919
29391
 
@@ -28936,7 +29408,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
28936
29408
 
28937
29409
  // xr
28938
29410
 
28939
- const xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl ) : new WebVRManager( _this );
29411
+ const xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl, extensions, multiviewStereo ) : new WebVRManager( _this );
28940
29412
 
28941
29413
  this.xr = xr;
28942
29414
 
@@ -29683,13 +30155,23 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
29683
30155
 
29684
30156
  if ( camera.isArrayCamera ) {
29685
30157
 
29686
- const cameras = camera.cameras;
30158
+ if ( xr.enabled && xr.isMultiview ) {
29687
30159
 
29688
- for ( let i = 0, l = cameras.length; i < l; i ++ ) {
30160
+ textures.setDeferTextureUploads( true );
29689
30161
 
29690
- const camera2 = cameras[ i ];
30162
+ renderScene( currentRenderList, scene, camera, camera.cameras[ 0 ].viewport );
29691
30163
 
29692
- renderScene( currentRenderList, scene, camera2, camera2.viewport );
30164
+ } else {
30165
+
30166
+ const cameras = camera.cameras;
30167
+
30168
+ for ( let i = 0, l = cameras.length; i < l; i ++ ) {
30169
+
30170
+ const camera2 = cameras[ i ];
30171
+
30172
+ renderScene( currentRenderList, scene, camera2, camera2.viewport );
30173
+
30174
+ }
29693
30175
 
29694
30176
  }
29695
30177
 
@@ -29717,6 +30199,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
29717
30199
 
29718
30200
  if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
29719
30201
 
30202
+ textures.runDeferredUploads();
30203
+
29720
30204
  if ( xr.enabled && xr.submitFrame ) {
29721
30205
 
29722
30206
  xr.submitFrame();
@@ -30184,6 +30668,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
30184
30668
  materialProperties.vertexAlphas = parameters.vertexAlphas;
30185
30669
  materialProperties.vertexTangents = parameters.vertexTangents;
30186
30670
  materialProperties.toneMapping = parameters.toneMapping;
30671
+ materialProperties.numMultiviewViews = parameters.numMultiviewViews;
30187
30672
 
30188
30673
  }
30189
30674
 
@@ -30215,6 +30700,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
30215
30700
 
30216
30701
  }
30217
30702
 
30703
+ const numMultiviewViews = _currentRenderTarget && _currentRenderTarget.isWebGLMultiviewRenderTarget ? _currentRenderTarget.numViews : 0;
30704
+
30218
30705
  const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
30219
30706
  const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
30220
30707
 
@@ -30318,6 +30805,10 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
30318
30805
 
30319
30806
  needsProgramChange = true;
30320
30807
 
30808
+ } else if ( materialProperties.numMultiviewViews !== numMultiviewViews ) {
30809
+
30810
+ needsProgramChange = true;
30811
+
30321
30812
  }
30322
30813
 
30323
30814
  } else {
@@ -30364,8 +30855,17 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
30364
30855
 
30365
30856
  // common camera uniforms
30366
30857
 
30367
- p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
30368
- p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
30858
+ if ( program.numMultiviewViews > 0 ) {
30859
+
30860
+ multiview.updateCameraProjectionMatricesUniform( camera, p_uniforms );
30861
+ multiview.updateCameraViewMatricesUniform( camera, p_uniforms );
30862
+
30863
+ } else {
30864
+
30865
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
30866
+ p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
30867
+
30868
+ }
30369
30869
 
30370
30870
  const uCamPos = p_uniforms.map.cameraPosition;
30371
30871
 
@@ -30513,8 +31013,17 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
30513
31013
 
30514
31014
  // common matrices
30515
31015
 
30516
- p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
30517
- p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
31016
+ if ( program.numMultiviewViews > 0 ) {
31017
+
31018
+ multiview.updateObjectMatricesUniforms( object, camera, p_uniforms );
31019
+
31020
+ } else {
31021
+
31022
+ p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
31023
+ p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
31024
+
31025
+ }
31026
+
30518
31027
  p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );
30519
31028
 
30520
31029
  // UBOs
@@ -30624,20 +31133,16 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
30624
31133
  const renderTargetProperties = properties.get( renderTarget );
30625
31134
  renderTargetProperties.__hasExternalTextures = true;
30626
31135
 
30627
- if ( renderTargetProperties.__hasExternalTextures ) {
30628
-
30629
- renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
30630
-
30631
- if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
31136
+ renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
30632
31137
 
30633
- // The multisample_render_to_texture extension doesn't work properly if there
30634
- // are midframe flushes and an external depth buffer. Disable use of the extension.
30635
- if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
31138
+ if ( ! renderTargetProperties.__autoAllocateDepthBuffer && ! _currentRenderTarget.isWebGLMultiviewRenderTarget ) {
30636
31139
 
30637
- console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
30638
- renderTargetProperties.__useRenderToTexture = false;
31140
+ // The multisample_render_to_texture extension doesn't work properly if there
31141
+ // are midframe flushes and an external depth buffer. Disable use of the extension.
31142
+ if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
30639
31143
 
30640
- }
31144
+ console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
31145
+ renderTargetProperties.__useRenderToTexture = false;
30641
31146
 
30642
31147
  }
30643
31148
 
@@ -31020,6 +31525,22 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
31020
31525
 
31021
31526
  }
31022
31527
 
31528
+ get outputColorSpace() {
31529
+
31530
+ return this._outputColorSpace;
31531
+
31532
+ }
31533
+
31534
+ set outputColorSpace( colorSpace ) {
31535
+
31536
+ this._outputColorSpace = colorSpace;
31537
+
31538
+ const gl = this.getContext();
31539
+ gl.drawingBufferColorSpace = colorSpace === DisplayP3ColorSpace ? 'display-p3' : 'srgb';
31540
+ gl.unpackColorSpace = ColorManagement.workingColorSpace === LinearDisplayP3ColorSpace ? 'display-p3' : 'srgb';
31541
+
31542
+ }
31543
+
31023
31544
  get physicallyCorrectLights() { // @deprecated, r150
31024
31545
 
31025
31546
  console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
@@ -31091,6 +31612,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
31091
31612
 
31092
31613
  return {
31093
31614
  type: 'FogExp2',
31615
+ name: this.name,
31094
31616
  color: this.color.getHex(),
31095
31617
  density: this.density
31096
31618
  };
@@ -31124,6 +31646,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
31124
31646
 
31125
31647
  return {
31126
31648
  type: 'Fog',
31649
+ name: this.name,
31127
31650
  color: this.color.getHex(),
31128
31651
  near: this.near,
31129
31652
  far: this.far
@@ -31729,7 +32252,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
31729
32252
 
31730
32253
  class Sprite extends Object3D {
31731
32254
 
31732
- constructor( material ) {
32255
+ constructor( material = new SpriteMaterial() ) {
31733
32256
 
31734
32257
  super();
31735
32258
 
@@ -31757,7 +32280,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
31757
32280
  }
31758
32281
 
31759
32282
  this.geometry = _geometry;
31760
- this.material = ( material !== undefined ) ? material : new SpriteMaterial();
32283
+ this.material = material;
31761
32284
 
31762
32285
  this.center = new Vector2( 0.5, 0.5 );
31763
32286
 
@@ -35051,10 +35574,13 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
35051
35574
 
35052
35575
  if ( ! startPoint.equals( endPoint ) ) {
35053
35576
 
35054
- this.curves.push( new LineCurve( endPoint, startPoint ) );
35577
+ const lineType = ( startPoint.isVector2 === true ) ? 'LineCurve' : 'LineCurve3';
35578
+ this.curves.push( new Curves[ lineType ]( endPoint, startPoint ) );
35055
35579
 
35056
35580
  }
35057
35581
 
35582
+ return this;
35583
+
35058
35584
  }
35059
35585
 
35060
35586
  // To get accurate point with reference to
@@ -40410,21 +40936,6 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
40410
40936
 
40411
40937
  }
40412
40938
 
40413
- // same as Array.prototype.slice, but also works on typed arrays
40414
- function arraySlice( array, from, to ) {
40415
-
40416
- if ( isTypedArray( array ) ) {
40417
-
40418
- // in ios9 array.subarray(from, undefined) will return empty array
40419
- // but array.subarray(from) or array.subarray(from, len) is correct
40420
- return new array.constructor( array.subarray( from, to !== undefined ? to : array.length ) );
40421
-
40422
- }
40423
-
40424
- return array.slice( from, to );
40425
-
40426
- }
40427
-
40428
40939
  // converts an array to a specific type
40429
40940
  function convertArray( array, type, forceClone ) {
40430
40941
 
@@ -40688,14 +41199,14 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
40688
41199
  // Reference frame is earlier than the first keyframe, so just use the first keyframe
40689
41200
  const startIndex = referenceOffset;
40690
41201
  const endIndex = referenceValueSize - referenceOffset;
40691
- referenceValue = arraySlice( referenceTrack.values, startIndex, endIndex );
41202
+ referenceValue = referenceTrack.values.slice( startIndex, endIndex );
40692
41203
 
40693
41204
  } else if ( referenceTime >= referenceTrack.times[ lastIndex ] ) {
40694
41205
 
40695
41206
  // Reference frame is after the last keyframe, so just use the last keyframe
40696
41207
  const startIndex = lastIndex * referenceValueSize + referenceOffset;
40697
41208
  const endIndex = startIndex + referenceValueSize - referenceOffset;
40698
- referenceValue = arraySlice( referenceTrack.values, startIndex, endIndex );
41209
+ referenceValue = referenceTrack.values.slice( startIndex, endIndex );
40699
41210
 
40700
41211
  } else {
40701
41212
 
@@ -40704,7 +41215,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
40704
41215
  const startIndex = referenceOffset;
40705
41216
  const endIndex = referenceValueSize - referenceOffset;
40706
41217
  interpolant.evaluate( referenceTime );
40707
- referenceValue = arraySlice( interpolant.resultBuffer, startIndex, endIndex );
41218
+ referenceValue = interpolant.resultBuffer.slice( startIndex, endIndex );
40708
41219
 
40709
41220
  }
40710
41221
 
@@ -40759,7 +41270,6 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
40759
41270
  }
40760
41271
 
40761
41272
  const AnimationUtils = {
40762
- arraySlice: arraySlice,
40763
41273
  convertArray: convertArray,
40764
41274
  isTypedArray: isTypedArray,
40765
41275
  getKeyframeOrder: getKeyframeOrder,
@@ -41442,8 +41952,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
41442
41952
  }
41443
41953
 
41444
41954
  const stride = this.getValueSize();
41445
- this.times = arraySlice( times, from, to );
41446
- this.values = arraySlice( this.values, from * stride, to * stride );
41955
+ this.times = times.slice( from, to );
41956
+ this.values = this.values.slice( from * stride, to * stride );
41447
41957
 
41448
41958
  }
41449
41959
 
@@ -41533,8 +42043,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
41533
42043
  optimize() {
41534
42044
 
41535
42045
  // times or values may be shared with other tracks, so overwriting is unsafe
41536
- const times = arraySlice( this.times ),
41537
- values = arraySlice( this.values ),
42046
+ const times = this.times.slice(),
42047
+ values = this.values.slice(),
41538
42048
  stride = this.getValueSize(),
41539
42049
 
41540
42050
  smoothInterpolation = this.getInterpolation() === InterpolateSmooth,
@@ -41627,8 +42137,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
41627
42137
 
41628
42138
  if ( writeIndex !== times.length ) {
41629
42139
 
41630
- this.times = arraySlice( times, 0, writeIndex );
41631
- this.values = arraySlice( values, 0, writeIndex * stride );
42140
+ this.times = times.slice( 0, writeIndex );
42141
+ this.values = values.slice( 0, writeIndex * stride );
41632
42142
 
41633
42143
  } else {
41634
42144
 
@@ -41643,8 +42153,8 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
41643
42153
 
41644
42154
  clone() {
41645
42155
 
41646
- const times = arraySlice( this.times, 0 );
41647
- const values = arraySlice( this.values, 0 );
42156
+ const times = this.times.slice();
42157
+ const values = this.values.slice();
41648
42158
 
41649
42159
  const TypedKeyframeTrack = this.constructor;
41650
42160
  const track = new TypedKeyframeTrack( this.name, times, values );
@@ -44223,7 +44733,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
44223
44733
 
44224
44734
  if ( json.rotation !== undefined ) material.rotation = json.rotation;
44225
44735
 
44226
- if ( json.linewidth !== 1 ) material.linewidth = json.linewidth;
44736
+ if ( json.linewidth !== undefined ) material.linewidth = json.linewidth;
44227
44737
  if ( json.dashSize !== undefined ) material.dashSize = json.dashSize;
44228
44738
  if ( json.gapSize !== undefined ) material.gapSize = json.gapSize;
44229
44739
  if ( json.scale !== undefined ) material.scale = json.scale;
@@ -45504,6 +46014,12 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
45504
46014
 
45505
46015
  }
45506
46016
 
46017
+ if ( data.fog.name !== '' ) {
46018
+
46019
+ object.fog.name = data.fog.name;
46020
+
46021
+ }
46022
+
45507
46023
  }
45508
46024
 
45509
46025
  if ( data.backgroundBlurriness !== undefined ) object.backgroundBlurriness = data.backgroundBlurriness;
@@ -45988,48 +46504,6 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
45988
46504
 
45989
46505
  }
45990
46506
 
45991
- class HemisphereLightProbe extends LightProbe {
45992
-
45993
- constructor( skyColor, groundColor, intensity = 1 ) {
45994
-
45995
- super( undefined, intensity );
45996
-
45997
- this.isHemisphereLightProbe = true;
45998
-
45999
- const color1 = new Color().set( skyColor );
46000
- const color2 = new Color().set( groundColor );
46001
-
46002
- const sky = new Vector3( color1.r, color1.g, color1.b );
46003
- const ground = new Vector3( color2.r, color2.g, color2.b );
46004
-
46005
- // without extra factor of PI in the shader, should = 1 / Math.sqrt( Math.PI );
46006
- const c0 = Math.sqrt( Math.PI );
46007
- const c1 = c0 * Math.sqrt( 0.75 );
46008
-
46009
- this.sh.coefficients[ 0 ].copy( sky ).add( ground ).multiplyScalar( c0 );
46010
- this.sh.coefficients[ 1 ].copy( sky ).sub( ground ).multiplyScalar( c1 );
46011
-
46012
- }
46013
-
46014
- }
46015
-
46016
- class AmbientLightProbe extends LightProbe {
46017
-
46018
- constructor( color, intensity = 1 ) {
46019
-
46020
- super( undefined, intensity );
46021
-
46022
- this.isAmbientLightProbe = true;
46023
-
46024
- const color1 = new Color().set( color );
46025
-
46026
- // without extra factor of PI in the shader, would be 2 / Math.sqrt( Math.PI );
46027
- this.sh.coefficients[ 0 ].set( color1.r, color1.g, color1.b ).multiplyScalar( 2 * Math.sqrt( Math.PI ) );
46028
-
46029
- }
46030
-
46031
- }
46032
-
46033
46507
  const _eyeRight = /*@__PURE__*/ new Matrix4();
46034
46508
  const _eyeLeft = /*@__PURE__*/ new Matrix4();
46035
46509
  const _projectionMatrix = /*@__PURE__*/ new Matrix4();
@@ -52080,7 +52554,6 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
52080
52554
  exports.AlwaysDepth = AlwaysDepth;
52081
52555
  exports.AlwaysStencilFunc = AlwaysStencilFunc;
52082
52556
  exports.AmbientLight = AmbientLight;
52083
- exports.AmbientLightProbe = AmbientLightProbe;
52084
52557
  exports.AnimationAction = AnimationAction;
52085
52558
  exports.AnimationClip = AnimationClip;
52086
52559
  exports.AnimationLoader = AnimationLoader;
@@ -52203,7 +52676,6 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
52203
52676
  exports.HalfFloatType = HalfFloatType;
52204
52677
  exports.HemisphereLight = HemisphereLight;
52205
52678
  exports.HemisphereLightHelper = HemisphereLightHelper;
52206
- exports.HemisphereLightProbe = HemisphereLightProbe;
52207
52679
  exports.IcosahedronGeometry = IcosahedronGeometry;
52208
52680
  exports.ImageBitmapLoader = ImageBitmapLoader;
52209
52681
  exports.ImageLoader = ImageLoader;
@@ -52256,6 +52728,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
52256
52728
  exports.LinearMipmapNearestFilter = LinearMipmapNearestFilter;
52257
52729
  exports.LinearSRGBColorSpace = LinearSRGBColorSpace;
52258
52730
  exports.LinearToneMapping = LinearToneMapping;
52731
+ exports.LinearTransfer = LinearTransfer;
52259
52732
  exports.Loader = Loader;
52260
52733
  exports.LoaderUtils = LoaderUtils;
52261
52734
  exports.LoadingManager = LoadingManager;
@@ -52314,6 +52787,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
52314
52787
  exports.OneMinusSrcAlphaFactor = OneMinusSrcAlphaFactor;
52315
52788
  exports.OneMinusSrcColorFactor = OneMinusSrcColorFactor;
52316
52789
  exports.OrthographicCamera = OrthographicCamera;
52790
+ exports.P3Primaries = P3Primaries;
52317
52791
  exports.PCFShadowMap = PCFShadowMap;
52318
52792
  exports.PCFSoftShadowMap = PCFSoftShadowMap;
52319
52793
  exports.PMREMGenerator = PMREMGenerator;
@@ -52375,6 +52849,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
52375
52849
  exports.RawShaderMaterial = RawShaderMaterial;
52376
52850
  exports.Ray = Ray;
52377
52851
  exports.Raycaster = Raycaster;
52852
+ exports.Rec709Primaries = Rec709Primaries;
52378
52853
  exports.RectAreaLight = RectAreaLight;
52379
52854
  exports.RedFormat = RedFormat;
52380
52855
  exports.RedIntegerFormat = RedIntegerFormat;
@@ -52387,6 +52862,7 @@ console.warn( 'Scripts "build/three.js" and "build/three.min.js" are deprecated
52387
52862
  exports.SIGNED_RED_GREEN_RGTC2_Format = SIGNED_RED_GREEN_RGTC2_Format;
52388
52863
  exports.SIGNED_RED_RGTC1_Format = SIGNED_RED_RGTC1_Format;
52389
52864
  exports.SRGBColorSpace = SRGBColorSpace;
52865
+ exports.SRGBTransfer = SRGBTransfer;
52390
52866
  exports.Scene = Scene;
52391
52867
  exports.ShaderChunk = ShaderChunk;
52392
52868
  exports.ShaderLib = ShaderLib;