super-three 0.133.5 → 0.135.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/build/three.js +617 -536
  2. package/build/three.min.js +1 -1
  3. package/build/three.module.js +760 -613
  4. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
  5. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
  6. package/examples/fonts/open-sans/open-sans.css +9 -0
  7. package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
  8. package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
  9. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
  10. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
  11. package/examples/fonts/tabler-icons/tabler-icons.min.css +4 -0
  12. package/examples/js/controls/ArcballControls.js +68 -27
  13. package/examples/js/controls/DragControls.js +7 -0
  14. package/examples/js/controls/OrbitControls.js +5 -36
  15. package/examples/js/controls/TrackballControls.js +3 -2
  16. package/examples/js/csm/CSM.js +2 -2
  17. package/examples/js/csm/CSMFrustum.js +133 -0
  18. package/examples/js/exporters/GLTFExporter.js +147 -63
  19. package/examples/js/exporters/USDZExporter.js +45 -26
  20. package/examples/js/lines/LineMaterial.js +58 -20
  21. package/examples/js/lines/LineSegments2.js +29 -24
  22. package/examples/js/loaders/3DMLoader.js +24 -11
  23. package/examples/js/loaders/3MFLoader.js +2 -2
  24. package/examples/js/loaders/ColladaLoader.js +61 -3
  25. package/examples/js/loaders/FBXLoader.js +1 -1
  26. package/examples/js/loaders/GLTFLoader.js +94 -31
  27. package/examples/js/loaders/KTX2Loader.js +12 -0
  28. package/examples/js/loaders/LWOLoader.js +8 -6
  29. package/examples/js/loaders/LogLuvLoader.js +766 -0
  30. package/examples/js/loaders/PLYLoader.js +32 -7
  31. package/examples/js/loaders/RGBELoader.js +2 -1
  32. package/examples/js/loaders/SVGLoader.js +7 -3
  33. package/examples/js/loaders/TDSLoader.js +237 -271
  34. package/examples/js/loaders/lwo/LWO2Parser.js +1 -0
  35. package/examples/js/loaders/lwo/LWO3Parser.js +4 -2
  36. package/examples/js/objects/MarchingCubes.js +42 -128
  37. package/examples/js/renderers/CSS2DRenderer.js +4 -4
  38. package/examples/js/renderers/CSS3DRenderer.js +4 -4
  39. package/examples/js/utils/RoughnessMipmapper.js +1 -0
  40. package/examples/jsm/controls/ArcballControls.js +61 -29
  41. package/examples/jsm/controls/DragControls.js +7 -0
  42. package/examples/jsm/controls/OrbitControls.js +9 -51
  43. package/examples/jsm/controls/TrackballControls.js +1 -1
  44. package/examples/jsm/csm/CSM.js +3 -3
  45. package/examples/jsm/csm/{Frustum.js → CSMFrustum.js} +3 -3
  46. package/examples/jsm/exporters/GLTFExporter.js +160 -74
  47. package/examples/jsm/exporters/USDZExporter.js +47 -26
  48. package/examples/jsm/libs/flow.module.js +3218 -0
  49. package/examples/jsm/libs/lil-gui.module.min.js +8 -0
  50. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  51. package/examples/jsm/lines/LineMaterial.js +59 -23
  52. package/examples/jsm/lines/LineSegments2.js +22 -18
  53. package/examples/jsm/loaders/3DMLoader.js +18 -12
  54. package/examples/jsm/loaders/3MFLoader.js +2 -2
  55. package/examples/jsm/loaders/ColladaLoader.js +61 -3
  56. package/examples/jsm/loaders/FBXLoader.js +1 -1
  57. package/examples/jsm/loaders/GLTFLoader.js +99 -35
  58. package/examples/jsm/loaders/KTX2Loader.js +19 -0
  59. package/examples/jsm/loaders/LWOLoader.js +8 -6
  60. package/examples/jsm/loaders/LogLuvLoader.js +606 -0
  61. package/examples/jsm/loaders/PLYLoader.js +33 -7
  62. package/examples/jsm/loaders/SVGLoader.js +7 -4
  63. package/examples/jsm/loaders/TDSLoader.js +225 -285
  64. package/examples/jsm/loaders/lwo/LWO2Parser.js +1 -0
  65. package/examples/jsm/loaders/lwo/LWO3Parser.js +2 -2
  66. package/examples/jsm/node-editor/NodeEditor.js +455 -0
  67. package/examples/jsm/node-editor/accessors/NormalEditor.js +30 -0
  68. package/examples/jsm/node-editor/accessors/PositionEditor.js +30 -0
  69. package/examples/jsm/node-editor/accessors/UVEditor.js +26 -0
  70. package/examples/jsm/node-editor/display/BlendEditor.js +43 -0
  71. package/examples/jsm/node-editor/examples/animate-uv.json +1 -0
  72. package/examples/jsm/node-editor/examples/fake-top-light.json +1 -0
  73. package/examples/jsm/node-editor/examples/oscillator-color.json +1 -0
  74. package/examples/jsm/node-editor/examples/rim.json +1 -0
  75. package/examples/jsm/node-editor/inputs/ColorEditor.js +91 -0
  76. package/examples/jsm/node-editor/inputs/FloatEditor.js +24 -0
  77. package/examples/jsm/node-editor/inputs/SliderEditor.js +68 -0
  78. package/examples/jsm/node-editor/inputs/Vector2Editor.js +28 -0
  79. package/examples/jsm/node-editor/inputs/Vector3Editor.js +30 -0
  80. package/examples/jsm/node-editor/inputs/Vector4Editor.js +37 -0
  81. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +69 -0
  82. package/examples/jsm/node-editor/math/DotEditor.js +36 -0
  83. package/examples/jsm/node-editor/math/InvertEditor.js +38 -0
  84. package/examples/jsm/node-editor/math/LimiterEditor.js +48 -0
  85. package/examples/jsm/node-editor/math/NormalizeEditor.js +26 -0
  86. package/examples/jsm/node-editor/math/OperatorEditor.js +50 -0
  87. package/examples/jsm/node-editor/math/PowerEditor.js +34 -0
  88. package/examples/jsm/node-editor/math/TrigonometryEditor.js +39 -0
  89. package/examples/jsm/node-editor/procedural/CheckerEditor.js +26 -0
  90. package/examples/jsm/node-editor/utils/OscillatorEditor.js +42 -0
  91. package/examples/jsm/node-editor/utils/TimerEditor.js +57 -0
  92. package/examples/jsm/nodes/materials/StandardNodeMaterial.js +1 -1
  93. package/examples/jsm/nodes/materials/nodes/StandardNode.js +6 -6
  94. package/examples/jsm/nodes/utils/ColorSpaceNode.js +1 -49
  95. package/examples/jsm/objects/MarchingCubes.js +46 -152
  96. package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +1 -1
  97. package/examples/jsm/postprocessing/AfterimagePass.js +1 -1
  98. package/examples/jsm/postprocessing/BloomPass.js +1 -1
  99. package/examples/jsm/postprocessing/BokehPass.js +1 -1
  100. package/examples/jsm/postprocessing/ClearPass.js +1 -1
  101. package/examples/jsm/postprocessing/CubeTexturePass.js +1 -1
  102. package/examples/jsm/postprocessing/DotScreenPass.js +1 -1
  103. package/examples/jsm/postprocessing/EffectComposer.js +3 -3
  104. package/examples/jsm/postprocessing/FilmPass.js +1 -1
  105. package/examples/jsm/postprocessing/GlitchPass.js +1 -1
  106. package/examples/jsm/postprocessing/HalftonePass.js +1 -1
  107. package/examples/jsm/postprocessing/MaskPass.js +1 -1
  108. package/examples/jsm/postprocessing/OutlinePass.js +1 -1
  109. package/examples/jsm/postprocessing/RenderPass.js +1 -1
  110. package/examples/jsm/postprocessing/SAOPass.js +1 -1
  111. package/examples/jsm/postprocessing/SMAAPass.js +1 -1
  112. package/examples/jsm/postprocessing/SSAARenderPass.js +1 -1
  113. package/examples/jsm/postprocessing/SSAOPass.js +1 -1
  114. package/examples/jsm/postprocessing/SSRPass.js +1 -1
  115. package/examples/jsm/postprocessing/SSRrPass.js +1 -1
  116. package/examples/jsm/postprocessing/SavePass.js +1 -1
  117. package/examples/jsm/postprocessing/ShaderPass.js +1 -1
  118. package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
  119. package/examples/jsm/postprocessing/TexturePass.js +1 -1
  120. package/examples/jsm/postprocessing/UnrealBloomPass.js +1 -1
  121. package/examples/jsm/renderers/CSS2DRenderer.js +5 -4
  122. package/examples/jsm/renderers/CSS3DRenderer.js +5 -4
  123. package/examples/jsm/renderers/nodes/Nodes.js +14 -13
  124. package/examples/jsm/renderers/nodes/ShaderNode.js +193 -41
  125. package/examples/jsm/renderers/nodes/accessors/MaterialNode.js +6 -6
  126. package/examples/jsm/renderers/nodes/accessors/ModelViewProjectionNode.js +5 -5
  127. package/examples/jsm/renderers/nodes/accessors/NormalNode.js +14 -3
  128. package/examples/jsm/renderers/nodes/accessors/PointUVNode.js +3 -3
  129. package/examples/jsm/renderers/nodes/accessors/PositionNode.js +15 -5
  130. package/examples/jsm/renderers/nodes/accessors/SkinningNode.js +107 -0
  131. package/examples/jsm/renderers/nodes/accessors/UVNode.js +7 -5
  132. package/examples/jsm/renderers/nodes/core/ArrayInputNode.js +3 -3
  133. package/examples/jsm/renderers/nodes/core/AttributeNode.js +6 -0
  134. package/examples/jsm/renderers/nodes/core/BypassNode.js +38 -0
  135. package/examples/jsm/renderers/nodes/core/CodeNode.js +3 -3
  136. package/examples/jsm/renderers/nodes/core/ContextNode.js +4 -19
  137. package/examples/jsm/renderers/nodes/core/ExpressionNode.js +13 -2
  138. package/examples/jsm/renderers/nodes/core/FunctionNode.js +19 -132
  139. package/examples/jsm/renderers/nodes/core/InputNode.js +13 -3
  140. package/examples/jsm/renderers/nodes/core/Node.js +32 -10
  141. package/examples/jsm/renderers/nodes/core/NodeBuilder.js +146 -128
  142. package/examples/jsm/renderers/nodes/core/NodeFunction.js +22 -0
  143. package/examples/jsm/renderers/nodes/core/NodeFunctionInput.js +4 -4
  144. package/examples/jsm/renderers/nodes/core/NodeKeywords.js +18 -179
  145. package/examples/jsm/renderers/nodes/core/NodeParser.js +11 -0
  146. package/examples/jsm/renderers/nodes/core/NodeVar.js +2 -2
  147. package/examples/jsm/renderers/nodes/core/PropertyNode.js +14 -2
  148. package/examples/jsm/renderers/nodes/core/TempNode.js +10 -13
  149. package/examples/jsm/renderers/nodes/core/VarNode.js +12 -7
  150. package/examples/jsm/renderers/nodes/core/VaryNode.js +23 -8
  151. package/examples/jsm/renderers/nodes/core/constants.js +2 -0
  152. package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +47 -25
  153. package/examples/jsm/renderers/nodes/display/NormalMapNode.js +21 -22
  154. package/examples/jsm/renderers/nodes/functions/BSDFs.js +64 -101
  155. package/examples/jsm/renderers/nodes/inputs/BufferNode.js +25 -0
  156. package/examples/jsm/renderers/nodes/inputs/IntNode.js +17 -0
  157. package/examples/jsm/renderers/nodes/inputs/TextureNode.js +10 -2
  158. package/examples/jsm/renderers/nodes/lights/LightContextNode.js +20 -14
  159. package/examples/jsm/renderers/nodes/lights/LightNode.js +32 -36
  160. package/examples/jsm/renderers/nodes/math/CondNode.js +60 -0
  161. package/examples/jsm/renderers/nodes/math/MathNode.js +87 -36
  162. package/examples/jsm/renderers/nodes/math/OperatorNode.js +124 -31
  163. package/examples/jsm/renderers/nodes/parsers/GLSLNodeFunction.js +137 -0
  164. package/examples/jsm/renderers/nodes/parsers/GLSLNodeParser.js +14 -0
  165. package/examples/jsm/renderers/nodes/parsers/WGSLNodeFunction.js +89 -0
  166. package/examples/jsm/renderers/nodes/parsers/WGSLNodeParser.js +14 -0
  167. package/examples/jsm/renderers/nodes/procedural/CheckerNode.js +7 -9
  168. package/examples/jsm/renderers/nodes/utils/ArrayElementNode.js +31 -0
  169. package/examples/jsm/renderers/nodes/utils/ConvertNode.js +33 -0
  170. package/examples/jsm/renderers/nodes/utils/JoinNode.js +7 -7
  171. package/examples/jsm/renderers/nodes/utils/OscNode.js +58 -0
  172. package/examples/jsm/renderers/nodes/utils/SplitNode.js +18 -8
  173. package/examples/jsm/renderers/nodes/utils/SpriteSheetUVNode.js +7 -7
  174. package/examples/jsm/renderers/webgl/nodes/SlotNode.js +22 -0
  175. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +191 -94
  176. package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +2 -2
  177. package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +2 -2
  178. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +1 -1
  179. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +3 -3
  180. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +2 -4
  181. package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +2 -4
  182. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +15 -23
  183. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +3 -5
  184. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +11 -27
  185. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +62 -28
  186. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +34 -27
  187. package/examples/jsm/renderers/webgpu/constants.js +2 -2
  188. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +430 -98
  189. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
  190. package/examples/jsm/utils/RoughnessMipmapper.js +1 -0
  191. package/examples/jsm/webxr/OculusHandPointerModel.js +6 -6
  192. package/package.json +10 -10
  193. package/src/Three.Legacy.js +6 -0
  194. package/src/Three.js +0 -1
  195. package/src/cameras/StereoCamera.js +8 -7
  196. package/src/constants.js +1 -2
  197. package/src/core/Layers.js +7 -1
  198. package/src/core/Object3D.js +2 -0
  199. package/src/extras/PMREMGenerator.js +11 -6
  200. package/src/loaders/FileLoader.js +89 -152
  201. package/src/loaders/ImageLoader.js +9 -4
  202. package/src/loaders/LoaderUtils.js +26 -0
  203. package/src/loaders/MaterialLoader.js +7 -4
  204. package/src/loaders/ObjectLoader.js +2 -0
  205. package/src/materials/Material.js +4 -4
  206. package/src/materials/MeshPhysicalMaterial.js +20 -14
  207. package/src/math/MathUtils.js +5 -16
  208. package/src/renderers/WebGLMultisampleRenderTarget.js +7 -1
  209. package/src/renderers/WebGLRenderer.js +83 -117
  210. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +2 -2
  211. package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -27
  212. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
  213. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +19 -6
  214. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +2 -2
  215. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
  216. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +1 -1
  217. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +13 -5
  218. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +2 -1
  219. package/src/renderers/shaders/ShaderLib.js +6 -4
  220. package/src/renderers/shaders/UniformsLib.js +1 -2
  221. package/src/renderers/webgl/WebGLExtensions.js +1 -0
  222. package/src/renderers/webgl/WebGLMaterials.js +27 -15
  223. package/src/renderers/webgl/WebGLProgram.js +10 -6
  224. package/src/renderers/webgl/WebGLPrograms.js +17 -12
  225. package/src/renderers/webgl/WebGLShadowMap.js +14 -5
  226. package/src/renderers/webgl/WebGLState.js +31 -17
  227. package/src/renderers/webgl/WebGLTextures.js +188 -51
  228. package/src/renderers/webgl/WebGLUniforms.js +45 -1
  229. package/src/renderers/webxr/WebXRManager.js +68 -107
  230. package/src/textures/Texture.js +6 -0
  231. package/src/utils.js +37 -1
  232. package/examples/js/controls/DeviceOrientationControls.js +0 -147
  233. package/examples/js/libs/dat.gui.min.js +0 -14
  234. package/examples/jsm/controls/DeviceOrientationControls.js +0 -153
  235. package/examples/jsm/libs/dat.gui.module.js +0 -3575
  236. package/examples/jsm/libs/glslang.js +0 -78
  237. package/examples/jsm/libs/glslang.wasm +0 -0
  238. package/examples/jsm/renderers/nodes/consts/MathConsts.js +0 -7
  239. package/examples/jsm/renderers/nodes/core/ConstNode.js +0 -39
  240. package/examples/jsm/renderers/nodes/core/NodeSlot.js +0 -13
  241. package/examples/jsm/renderers/nodes/core/StructNode.js +0 -80
  242. package/examples/jsm/renderers/nodes/core/StructVarNode.js +0 -75
  243. package/examples/jsm/renderers/nodes/functions/EncodingFunctions.js +0 -99
  244. package/examples/jsm/renderers/nodes/functions/MathFunctions.js +0 -47
  245. package/examples/jsm/renderers/webgpu/nodes/ShaderLib.js +0 -152
  246. package/src/extras/objects/ImmediateRenderObject.js +0 -31
package/build/three.js CHANGED
@@ -9,7 +9,7 @@
9
9
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.THREE = {}));
10
10
  }(this, (function (exports) { 'use strict';
11
11
 
12
- const REVISION = '133';
12
+ const REVISION = '135';
13
13
  const MOUSE = {
14
14
  LEFT: 0,
15
15
  MIDDLE: 1,
@@ -180,7 +180,6 @@
180
180
  const sRGBEncoding = 3001;
181
181
  const GammaEncoding = 3007;
182
182
  const RGBEEncoding = 3002;
183
- const LogLuvEncoding = 3003;
184
183
  const RGBM7Encoding = 3004;
185
184
  const RGBM16Encoding = 3005;
186
185
  const RGBDEncoding = 3006;
@@ -273,25 +272,17 @@
273
272
 
274
273
  }
275
274
 
276
- let _seed = 1234567;
277
- const DEG2RAD = Math.PI / 180;
278
- const RAD2DEG = 180 / Math.PI; //
279
-
280
275
  const _lut = [];
281
276
 
282
277
  for (let i = 0; i < 256; i++) {
283
278
  _lut[i] = (i < 16 ? '0' : '') + i.toString(16);
284
279
  }
285
280
 
286
- const hasRandomUUID = typeof crypto !== 'undefined' && 'randomUUID' in crypto;
281
+ let _seed = 1234567;
282
+ const DEG2RAD = Math.PI / 180;
283
+ const RAD2DEG = 180 / Math.PI; // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
287
284
 
288
285
  function generateUUID() {
289
- if (hasRandomUUID) {
290
- return crypto.randomUUID().toUpperCase();
291
- } // TODO Remove this code when crypto.randomUUID() is available everywhere
292
- // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
293
-
294
-
295
286
  const d0 = Math.random() * 0xffffffff | 0;
296
287
  const d1 = Math.random() * 0xffffffff | 0;
297
288
  const d2 = Math.random() * 0xffffffff | 0;
@@ -1115,6 +1106,36 @@
1115
1106
  function createElementNS(name) {
1116
1107
  return document.createElementNS('http://www.w3.org/1999/xhtml', name);
1117
1108
  }
1109
+ /**
1110
+ * cyrb53 hash for string from: https://stackoverflow.com/a/52171480
1111
+ *
1112
+ * Public Domain, @bryc - https://stackoverflow.com/users/815680/bryc
1113
+ *
1114
+ * It is roughly similar to the well-known MurmurHash/xxHash algorithms. It uses a combination
1115
+ * of multiplication and Xorshift to generate the hash, but not as thorough. As a result it's
1116
+ * faster than either would be in JavaScript and significantly simpler to implement. Keep in
1117
+ * mind this is not a secure algorithm, if privacy/security is a concern, this is not for you.
1118
+ *
1119
+ * @param {string} str
1120
+ * @param {number} seed, default 0
1121
+ * @returns number
1122
+ */
1123
+
1124
+
1125
+ function hashString(str, seed = 0) {
1126
+ let h1 = 0xdeadbeef ^ seed,
1127
+ h2 = 0x41c6ce57 ^ seed;
1128
+
1129
+ for (let i = 0, ch; i < str.length; i++) {
1130
+ ch = str.charCodeAt(i);
1131
+ h1 = Math.imul(h1 ^ ch, 2654435761);
1132
+ h2 = Math.imul(h2 ^ ch, 1597334677);
1133
+ }
1134
+
1135
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
1136
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
1137
+ return 4294967296 * (2097151 & h2) + (h1 >>> 0);
1138
+ }
1118
1139
 
1119
1140
  let _canvas;
1120
1141
 
@@ -1195,6 +1216,7 @@
1195
1216
  // update. You need to explicitly call Material.needsUpdate to trigger it to recompile.
1196
1217
 
1197
1218
  this.encoding = encoding;
1219
+ this.userData = {};
1198
1220
  this.version = 0;
1199
1221
  this.onUpdate = null;
1200
1222
  this.isRenderTargetTexture = false;
@@ -1232,6 +1254,7 @@
1232
1254
  this.flipY = source.flipY;
1233
1255
  this.unpackAlignment = source.unpackAlignment;
1234
1256
  this.encoding = source.encoding;
1257
+ this.userData = JSON.parse(JSON.stringify(source.userData));
1235
1258
  return this;
1236
1259
  }
1237
1260
 
@@ -1304,6 +1327,8 @@
1304
1327
  output.image = image.uuid;
1305
1328
  }
1306
1329
 
1330
+ if (JSON.stringify(this.userData) !== '{}') output.userData = this.userData;
1331
+
1307
1332
  if (!isRootObject) {
1308
1333
  meta.textures[this.uuid] = output;
1309
1334
  }
@@ -2032,14 +2057,19 @@
2032
2057
  WebGLMultipleRenderTargets.prototype.isWebGLMultipleRenderTargets = true;
2033
2058
 
2034
2059
  class WebGLMultisampleRenderTarget extends WebGLRenderTarget {
2035
- constructor(width, height, options) {
2060
+ constructor(width, height, options = {}) {
2036
2061
  super(width, height, options);
2037
2062
  this.samples = 4;
2063
+ this.ignoreDepthForMultisampleCopy = options.ignoreDepth !== undefined ? options.ignoreDepth : true;
2064
+ this.useRenderToTexture = options.useRenderToTexture !== undefined ? options.useRenderToTexture : false;
2065
+ this.useRenderbuffer = this.useRenderToTexture === false;
2038
2066
  }
2039
2067
 
2040
2068
  copy(source) {
2041
2069
  super.copy.call(this, source);
2042
2070
  this.samples = source.samples;
2071
+ this.useRenderToTexture = source.useRenderToTexture;
2072
+ this.useRenderbuffer = source.useRenderbuffer;
2043
2073
  return this;
2044
2074
  }
2045
2075
 
@@ -5014,7 +5044,7 @@
5014
5044
  }
5015
5045
 
5016
5046
  set(channel) {
5017
- this.mask = 1 << channel | 0;
5047
+ this.mask = (1 << channel | 0) >>> 0;
5018
5048
  }
5019
5049
 
5020
5050
  enable(channel) {
@@ -5041,6 +5071,10 @@
5041
5071
  return (this.mask & layers.mask) !== 0;
5042
5072
  }
5043
5073
 
5074
+ isEnabled(channel) {
5075
+ return (this.mask & (1 << channel | 0)) !== 0;
5076
+ }
5077
+
5044
5078
  }
5045
5079
 
5046
5080
  let _object3DId = 0;
@@ -5339,6 +5373,7 @@
5339
5373
 
5340
5374
  attach(object) {
5341
5375
  // adds object as a child of this, while maintaining the object's world transform
5376
+ // Note: This method does not support scene graphs having non-uniformly-scaled nodes(s)
5342
5377
  this.updateWorldMatrix(true, false);
5343
5378
 
5344
5379
  _m1$1.copy(this.matrixWorld).invert();
@@ -6081,13 +6116,13 @@
6081
6116
  if (this.roughness !== undefined) data.roughness = this.roughness;
6082
6117
  if (this.metalness !== undefined) data.metalness = this.metalness;
6083
6118
  if (this.sheen !== undefined) data.sheen = this.sheen;
6084
- if (this.sheenTint && this.sheenTint.isColor) data.sheenTint = this.sheenTint.getHex();
6119
+ if (this.sheenColor && this.sheenColor.isColor) data.sheenColor = this.sheenColor.getHex();
6085
6120
  if (this.sheenRoughness !== undefined) data.sheenRoughness = this.sheenRoughness;
6086
6121
  if (this.emissive && this.emissive.isColor) data.emissive = this.emissive.getHex();
6087
6122
  if (this.emissiveIntensity && this.emissiveIntensity !== 1) data.emissiveIntensity = this.emissiveIntensity;
6088
6123
  if (this.specular && this.specular.isColor) data.specular = this.specular.getHex();
6089
6124
  if (this.specularIntensity !== undefined) data.specularIntensity = this.specularIntensity;
6090
- if (this.specularTint && this.specularTint.isColor) data.specularTint = this.specularTint.getHex();
6125
+ if (this.specularColor && this.specularColor.isColor) data.specularColor = this.specularColor.getHex();
6091
6126
  if (this.shininess !== undefined) data.shininess = this.shininess;
6092
6127
  if (this.clearcoat !== undefined) data.clearcoat = this.clearcoat;
6093
6128
  if (this.clearcoatRoughness !== undefined) data.clearcoatRoughness = this.clearcoatRoughness;
@@ -6141,7 +6176,7 @@
6141
6176
  if (this.emissiveMap && this.emissiveMap.isTexture) data.emissiveMap = this.emissiveMap.toJSON(meta).uuid;
6142
6177
  if (this.specularMap && this.specularMap.isTexture) data.specularMap = this.specularMap.toJSON(meta).uuid;
6143
6178
  if (this.specularIntensityMap && this.specularIntensityMap.isTexture) data.specularIntensityMap = this.specularIntensityMap.toJSON(meta).uuid;
6144
- if (this.specularTintMap && this.specularTintMap.isTexture) data.specularTintMap = this.specularTintMap.toJSON(meta).uuid;
6179
+ if (this.specularColorMap && this.specularColorMap.isTexture) data.specularColorMap = this.specularColorMap.toJSON(meta).uuid;
6145
6180
 
6146
6181
  if (this.envMap && this.envMap.isTexture) {
6147
6182
  data.envMap = this.envMap.toJSON(meta).uuid;
@@ -6161,7 +6196,7 @@
6161
6196
  if (this.thickness !== undefined) data.thickness = this.thickness;
6162
6197
  if (this.thicknessMap && this.thicknessMap.isTexture) data.thicknessMap = this.thicknessMap.toJSON(meta).uuid;
6163
6198
  if (this.attenuationDistance !== undefined) data.attenuationDistance = this.attenuationDistance;
6164
- if (this.attenuationTint !== undefined) data.attenuationTint = this.attenuationTint.getHex();
6199
+ if (this.attenuationColor !== undefined) data.attenuationColor = this.attenuationColor.getHex();
6165
6200
  if (this.size !== undefined) data.size = this.size;
6166
6201
  if (this.shadowSide !== null) data.shadowSide = this.shadowSide;
6167
6202
  if (this.sizeAttenuation !== undefined) data.sizeAttenuation = this.sizeAttenuation;
@@ -9664,7 +9699,7 @@
9664
9699
 
9665
9700
  var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif";
9666
9701
 
9667
- var bsdfs = "vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenTint, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenTint * ( D * V );\n}\n#endif";
9702
+ var bsdfs = "vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif";
9668
9703
 
9669
9704
  var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif";
9670
9705
 
@@ -9700,11 +9735,11 @@
9700
9735
 
9701
9736
  var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
9702
9737
 
9703
- var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}";
9738
+ var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}";
9704
9739
 
9705
9740
  var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
9706
9741
 
9707
- var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif";
9742
+ var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif";
9708
9743
 
9709
9744
  var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif";
9710
9745
 
@@ -9740,9 +9775,9 @@
9740
9775
 
9741
9776
  var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)";
9742
9777
 
9743
- var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularTintFactor = specularTint;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARTINTMAP\n\t\t\tspecularTintFactor *= specularTintMapTexelToLinear( texture2D( specularTintMap, vUv ) ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularTintFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularTintFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenTint = sheenTint;\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n#endif";
9778
+ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= specularColorMapTexelToLinear( texture2D( specularColorMap, vUv ) ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= sheenColorMapTexelToLinear( texture2D( sheenColorMap, vUv ) ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif";
9744
9779
 
9745
- var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenTint;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenTint, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
9780
+ var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
9746
9781
 
9747
9782
  var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
9748
9783
 
@@ -9834,9 +9869,9 @@
9834
9869
 
9835
9870
  var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
9836
9871
 
9837
- var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationTint, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif";
9872
+ var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif";
9838
9873
 
9839
- var transmission_pars_fragment = "#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationTint;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif";
9874
+ var transmission_pars_fragment = "#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif";
9840
9875
 
9841
9876
  var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif";
9842
9877
 
@@ -9886,7 +9921,7 @@
9886
9921
  const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
9887
9922
 
9888
9923
  const vertex$5 = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}";
9889
- const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularTint;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARTINTMAP\n\t\tuniform sampler2D specularTintMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenTint;\n\tuniform float sheenRoughness;\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - clearcoat * Fcc ) + clearcoatSpecular * clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
9924
+ const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
9890
9925
 
9891
9926
  const vertex$4 = "#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
9892
9927
  const fragment$4 = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
@@ -10087,9 +10122,6 @@
10087
10122
  // standard, physical
10088
10123
  refractionRatio: {
10089
10124
  value: 0.98
10090
- },
10091
- maxMipLevel: {
10092
- value: 0
10093
10125
  }
10094
10126
  },
10095
10127
  aomap: {
@@ -10521,12 +10553,18 @@
10521
10553
  sheen: {
10522
10554
  value: 0
10523
10555
  },
10524
- sheenTint: {
10556
+ sheenColor: {
10525
10557
  value: new Color(0x000000)
10526
10558
  },
10559
+ sheenColorMap: {
10560
+ value: null
10561
+ },
10527
10562
  sheenRoughness: {
10528
10563
  value: 0
10529
10564
  },
10565
+ sheenRoughnessMap: {
10566
+ value: null
10567
+ },
10530
10568
  transmission: {
10531
10569
  value: 0
10532
10570
  },
@@ -10548,7 +10586,7 @@
10548
10586
  attenuationDistance: {
10549
10587
  value: 0
10550
10588
  },
10551
- attenuationTint: {
10589
+ attenuationColor: {
10552
10590
  value: new Color(0x000000)
10553
10591
  },
10554
10592
  specularIntensity: {
@@ -10557,10 +10595,10 @@
10557
10595
  specularIntensityMap: {
10558
10596
  value: null
10559
10597
  },
10560
- specularTint: {
10598
+ specularColor: {
10561
10599
  value: new Color(1, 1, 1)
10562
10600
  },
10563
- specularTintMap: {
10601
+ specularColorMap: {
10564
10602
  value: null
10565
10603
  }
10566
10604
  }]),
@@ -11783,17 +11821,19 @@
11783
11821
  }
11784
11822
 
11785
11823
  _setEncoding(uniform, texture) {
11786
- if (this._renderer.capabilities.isWebGL2 === true && texture.format === RGBAFormat && texture.type === UnsignedByteType && texture.encoding === sRGBEncoding) {
11787
- uniform.value = ENCODINGS[LinearEncoding];
11788
- } else {
11789
- uniform.value = ENCODINGS[texture.encoding];
11790
- }
11824
+ /* if ( this._renderer.capabilities.isWebGL2 === true && texture.format === RGBAFormat && texture.type === UnsignedByteType && texture.encoding === sRGBEncoding ) {
11825
+ uniform.value = ENCODINGS[ LinearEncoding ];
11826
+ } else {
11827
+ uniform.value = ENCODINGS[ texture.encoding ];
11828
+ } */
11829
+ uniform.value = ENCODINGS[texture.encoding];
11791
11830
  }
11792
11831
 
11793
11832
  _textureToCubeUV(texture, cubeUVRenderTarget) {
11794
11833
  const renderer = this._renderer;
11834
+ const isCubeTexture = texture.mapping === CubeReflectionMapping || texture.mapping === CubeRefractionMapping;
11795
11835
 
11796
- if (texture.isCubeTexture) {
11836
+ if (isCubeTexture) {
11797
11837
  if (this._cubemapShader == null) {
11798
11838
  this._cubemapShader = _getCubemapShader();
11799
11839
  }
@@ -11803,12 +11843,12 @@
11803
11843
  }
11804
11844
  }
11805
11845
 
11806
- const material = texture.isCubeTexture ? this._cubemapShader : this._equirectShader;
11846
+ const material = isCubeTexture ? this._cubemapShader : this._equirectShader;
11807
11847
  const mesh = new Mesh(_lodPlanes[0], material);
11808
11848
  const uniforms = material.uniforms;
11809
11849
  uniforms['envMap'].value = texture;
11810
11850
 
11811
- if (!texture.isCubeTexture) {
11851
+ if (!isCubeTexture) {
11812
11852
  uniforms['texelSize'].value.set(1.0 / texture.image.width, 1.0 / texture.image.height);
11813
11853
  }
11814
11854
 
@@ -12503,6 +12543,7 @@
12503
12543
 
12504
12544
  getExtension('OES_texture_float_linear');
12505
12545
  getExtension('EXT_color_buffer_half_float');
12546
+ getExtension('WEBGL_multisampled_render_to_texture');
12506
12547
  },
12507
12548
  get: function (name) {
12508
12549
  const extension = getExtension(name);
@@ -13554,7 +13595,7 @@
13554
13595
 
13555
13596
  function setValueV4uiArray(gl, v) {
13556
13597
  gl.uniform4uiv(this.addr, v);
13557
- } // Array of textures (2D / Cube)
13598
+ } // Array of textures (2D / 3D / Cube / 2DArray)
13558
13599
 
13559
13600
 
13560
13601
  function setValueT1Array(gl, v, textures) {
@@ -13567,6 +13608,16 @@
13567
13608
  }
13568
13609
  }
13569
13610
 
13611
+ function setValueT3DArray(gl, v, textures) {
13612
+ const n = v.length;
13613
+ const units = allocTexUnits(textures, n);
13614
+ gl.uniform1iv(this.addr, units);
13615
+
13616
+ for (let i = 0; i !== n; ++i) {
13617
+ textures.setTexture3D(v[i] || emptyTexture3d, units[i]);
13618
+ }
13619
+ }
13620
+
13570
13621
  function setValueT6Array(gl, v, textures) {
13571
13622
  const n = v.length;
13572
13623
  const units = allocTexUnits(textures, n);
@@ -13575,6 +13626,16 @@
13575
13626
  for (let i = 0; i !== n; ++i) {
13576
13627
  textures.safeSetTextureCube(v[i] || emptyCubeTexture, units[i]);
13577
13628
  }
13629
+ }
13630
+
13631
+ function setValueT2DArrayArray(gl, v, textures) {
13632
+ const n = v.length;
13633
+ const units = allocTexUnits(textures, n);
13634
+ gl.uniform1iv(this.addr, units);
13635
+
13636
+ for (let i = 0; i !== n; ++i) {
13637
+ textures.setTexture2DArray(v[i] || emptyTexture2dArray, units[i]);
13638
+ }
13578
13639
  } // Helper to pick the right setter for a pure (bottom-level) array
13579
13640
 
13580
13641
 
@@ -13656,6 +13717,14 @@
13656
13717
  // SAMPLER_2D_SHADOW
13657
13718
  return setValueT1Array;
13658
13719
 
13720
+ case 0x8b5f: // SAMPLER_3D
13721
+
13722
+ case 0x8dcb: // INT_SAMPLER_3D
13723
+
13724
+ case 0x8dd3:
13725
+ // UNSIGNED_INT_SAMPLER_3D
13726
+ return setValueT3DArray;
13727
+
13659
13728
  case 0x8b60: // SAMPLER_CUBE
13660
13729
 
13661
13730
  case 0x8dcc: // INT_SAMPLER_CUBE
@@ -13665,6 +13734,16 @@
13665
13734
  case 0x8dc5:
13666
13735
  // SAMPLER_CUBE_SHADOW
13667
13736
  return setValueT6Array;
13737
+
13738
+ case 0x8dc1: // SAMPLER_2D_ARRAY
13739
+
13740
+ case 0x8dcf: // INT_SAMPLER_2D_ARRAY
13741
+
13742
+ case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY
13743
+
13744
+ case 0x8dc4:
13745
+ // SAMPLER_2D_ARRAY_SHADOW
13746
+ return setValueT2DArrayArray;
13668
13747
  }
13669
13748
  } // --- Uniform Classes ---
13670
13749
 
@@ -13847,9 +13926,6 @@
13847
13926
  case GammaEncoding:
13848
13927
  return ['Gamma', '( value, float( GAMMA_FACTOR ) )'];
13849
13928
 
13850
- case LogLuvEncoding:
13851
- return ['LogLuv', '( value )'];
13852
-
13853
13929
  default:
13854
13930
  console.warn('THREE.WebGLProgram: Unsupported encoding:', encoding);
13855
13931
  return ['Linear', '( value )'];
@@ -14115,10 +14191,10 @@
14115
14191
  prefixFragment += '\n';
14116
14192
  }
14117
14193
  } else {
14118
- prefixVertex = [generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, parameters.instancing ? '#define USE_INSTANCING' : '', parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '', parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '', '#define GAMMA_FACTOR ' + gammaFactorDefine, '#define MAX_BONES ' + parameters.maxBones, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularTintMap ? '#define USE_SPECULARTINTMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.skinning ? '#define USE_SKINNING' : '', parameters.useVertexTexture ? '#define BONE_TEXTURE' : '', parameters.morphTargets ? '#define USE_MORPHTARGETS' : '', parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '', parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_TEXTURE' : '', parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 modelMatrix;', 'uniform mat4 modelViewMatrix;', 'uniform mat4 projectionMatrix;', 'uniform mat4 viewMatrix;', 'uniform mat3 normalMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', '#ifdef USE_INSTANCING', ' attribute mat4 instanceMatrix;', '#endif', '#ifdef USE_INSTANCING_COLOR', ' attribute vec3 instanceColor;', '#endif', 'attribute vec3 position;', 'attribute vec3 normal;', 'attribute vec2 uv;', '#ifdef USE_TANGENT', ' attribute vec4 tangent;', '#endif', '#if defined( USE_COLOR_ALPHA )', ' attribute vec4 color;', '#elif defined( USE_COLOR )', ' attribute vec3 color;', '#endif', '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )', ' attribute vec3 morphTarget0;', ' attribute vec3 morphTarget1;', ' attribute vec3 morphTarget2;', ' attribute vec3 morphTarget3;', ' #ifdef USE_MORPHNORMALS', ' attribute vec3 morphNormal0;', ' attribute vec3 morphNormal1;', ' attribute vec3 morphNormal2;', ' attribute vec3 morphNormal3;', ' #else', ' attribute vec3 morphTarget4;', ' attribute vec3 morphTarget5;', ' attribute vec3 morphTarget6;', ' attribute vec3 morphTarget7;', ' #endif', '#endif', '#ifdef USE_SKINNING', ' attribute vec4 skinIndex;', ' attribute vec4 skinWeight;', '#endif', '\n'].filter(filterEmptyLine).join('\n');
14119
- prefixFragment = [customExtensions, generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, '#define GAMMA_FACTOR ' + gammaFactorDefine, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.matcap ? '#define USE_MATCAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapTypeDefine : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.envMap ? '#define ' + envMapBlendingDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoat ? '#define USE_CLEARCOAT' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularTintMap ? '#define USE_SPECULARTINTMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.alphaTest ? '#define USE_ALPHATEST' : '', parameters.sheen ? '#define USE_SHEEN' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '', parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', (parameters.extensionShaderTextureLOD || parameters.envMap) && parameters.rendererExtensionShaderTextureLod ? '#define TEXTURE_LOD_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', parameters.toneMapping !== NoToneMapping ? '#define TONE_MAPPING' : '', parameters.toneMapping !== NoToneMapping ? ShaderChunk['tonemapping_pars_fragment'] : '', // this code is required here because it is used by the toneMapping() function defined below
14194
+ prefixVertex = [generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, parameters.instancing ? '#define USE_INSTANCING' : '', parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '', parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '', '#define GAMMA_FACTOR ' + gammaFactorDefine, '#define MAX_BONES ' + parameters.maxBones, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.skinning ? '#define USE_SKINNING' : '', parameters.useVertexTexture ? '#define BONE_TEXTURE' : '', parameters.morphTargets ? '#define USE_MORPHTARGETS' : '', parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '', parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_TEXTURE' : '', parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 modelMatrix;', 'uniform mat4 modelViewMatrix;', 'uniform mat4 projectionMatrix;', 'uniform mat4 viewMatrix;', 'uniform mat3 normalMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', '#ifdef USE_INSTANCING', ' attribute mat4 instanceMatrix;', '#endif', '#ifdef USE_INSTANCING_COLOR', ' attribute vec3 instanceColor;', '#endif', 'attribute vec3 position;', 'attribute vec3 normal;', 'attribute vec2 uv;', '#ifdef USE_TANGENT', ' attribute vec4 tangent;', '#endif', '#if defined( USE_COLOR_ALPHA )', ' attribute vec4 color;', '#elif defined( USE_COLOR )', ' attribute vec3 color;', '#endif', '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )', ' attribute vec3 morphTarget0;', ' attribute vec3 morphTarget1;', ' attribute vec3 morphTarget2;', ' attribute vec3 morphTarget3;', ' #ifdef USE_MORPHNORMALS', ' attribute vec3 morphNormal0;', ' attribute vec3 morphNormal1;', ' attribute vec3 morphNormal2;', ' attribute vec3 morphNormal3;', ' #else', ' attribute vec3 morphTarget4;', ' attribute vec3 morphTarget5;', ' attribute vec3 morphTarget6;', ' attribute vec3 morphTarget7;', ' #endif', '#endif', '#ifdef USE_SKINNING', ' attribute vec4 skinIndex;', ' attribute vec4 skinWeight;', '#endif', '\n'].filter(filterEmptyLine).join('\n');
14195
+ prefixFragment = [customExtensions, generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, '#define GAMMA_FACTOR ' + gammaFactorDefine, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.matcap ? '#define USE_MATCAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapTypeDefine : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.envMap ? '#define ' + envMapBlendingDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoat ? '#define USE_CLEARCOAT' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.alphaTest ? '#define USE_ALPHATEST' : '', parameters.sheen ? '#define USE_SHEEN' : '', parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '', parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', (parameters.extensionShaderTextureLOD || parameters.envMap) && parameters.rendererExtensionShaderTextureLod ? '#define TEXTURE_LOD_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', parameters.toneMapping !== NoToneMapping ? '#define TONE_MAPPING' : '', parameters.toneMapping !== NoToneMapping ? ShaderChunk['tonemapping_pars_fragment'] : '', // this code is required here because it is used by the toneMapping() function defined below
14120
14196
  parameters.toneMapping !== NoToneMapping ? getToneMappingFunction('toneMapping', parameters.toneMapping) : '', parameters.dithering ? '#define DITHERING' : '', parameters.format === RGBFormat ? '#define OPAQUE' : '', ShaderChunk['encodings_pars_fragment'], // this code is required here because it is used by the various encoding/decoding function defined below
14121
- parameters.map ? getTexelDecodingFunction('mapTexelToLinear', parameters.mapEncoding) : '', parameters.matcap ? getTexelDecodingFunction('matcapTexelToLinear', parameters.matcapEncoding) : '', parameters.envMap ? getTexelDecodingFunction('envMapTexelToLinear', parameters.envMapEncoding) : '', parameters.emissiveMap ? getTexelDecodingFunction('emissiveMapTexelToLinear', parameters.emissiveMapEncoding) : '', parameters.specularTintMap ? getTexelDecodingFunction('specularTintMapTexelToLinear', parameters.specularTintMapEncoding) : '', parameters.lightMap ? getTexelDecodingFunction('lightMapTexelToLinear', parameters.lightMapEncoding) : '', getTexelEncodingFunction('linearToOutputTexel', parameters.outputEncoding), parameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '', '\n'].filter(filterEmptyLine).join('\n');
14197
+ parameters.map ? getTexelDecodingFunction('mapTexelToLinear', parameters.mapEncoding) : '', parameters.matcap ? getTexelDecodingFunction('matcapTexelToLinear', parameters.matcapEncoding) : '', parameters.envMap ? getTexelDecodingFunction('envMapTexelToLinear', parameters.envMapEncoding) : '', parameters.emissiveMap ? getTexelDecodingFunction('emissiveMapTexelToLinear', parameters.emissiveMapEncoding) : '', parameters.specularColorMap ? getTexelDecodingFunction('specularColorMapTexelToLinear', parameters.specularColorMapEncoding) : '', parameters.sheenColorMap ? getTexelDecodingFunction('sheenColorMapTexelToLinear', parameters.sheenColorMapEncoding) : '', parameters.lightMap ? getTexelDecodingFunction('lightMapTexelToLinear', parameters.lightMapEncoding) : '', getTexelEncodingFunction('linearToOutputTexel', parameters.outputEncoding), parameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '', '\n'].filter(filterEmptyLine).join('\n');
14122
14198
  }
14123
14199
 
14124
14200
  vertexShader = resolveIncludes(vertexShader);
@@ -14260,7 +14336,7 @@
14260
14336
  ShadowMaterial: 'shadow',
14261
14337
  SpriteMaterial: 'sprite'
14262
14338
  };
14263
- const parameterNames = ['precision', 'isWebGL2', 'supportsVertexTextures', 'outputEncoding', 'instancing', 'instancingColor', 'map', 'mapEncoding', 'matcap', 'matcapEncoding', 'envMap', 'envMapMode', 'envMapEncoding', 'envMapCubeUV', 'lightMap', 'lightMapEncoding', 'aoMap', 'emissiveMap', 'emissiveMapEncoding', 'bumpMap', 'normalMap', 'objectSpaceNormalMap', 'tangentSpaceNormalMap', 'clearcoat', 'clearcoatMap', 'clearcoatRoughnessMap', 'clearcoatNormalMap', 'displacementMap', 'specularMap', 'specularIntensityMap', 'specularTintMap', 'specularTintMapEncoding', 'roughnessMap', 'metalnessMap', 'gradientMap', 'alphaMap', 'alphaTest', 'combine', 'vertexColors', 'vertexAlphas', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2', 'flatShading', 'sizeAttenuation', 'logarithmicDepthBuffer', 'skinning', 'maxBones', 'useVertexTexture', 'morphTargets', 'morphNormals', 'morphTargetsCount', 'premultipliedAlpha', 'numDirLights', 'numPointLights', 'numSpotLights', 'numHemiLights', 'numRectAreaLights', 'numDirLightShadows', 'numPointLightShadows', 'numSpotLightShadows', 'shadowMapEnabled', 'shadowMapType', 'toneMapping', 'physicallyCorrectLights', 'doubleSided', 'flipSided', 'numClippingPlanes', 'numClipIntersection', 'depthPacking', 'dithering', 'format', 'sheen', 'transmission', 'transmissionMap', 'thicknessMap'];
14339
+ const parameterNames = ['precision', 'isWebGL2', 'supportsVertexTextures', 'outputEncoding', 'instancing', 'instancingColor', 'map', 'mapEncoding', 'matcap', 'matcapEncoding', 'envMap', 'envMapMode', 'envMapEncoding', 'envMapCubeUV', 'lightMap', 'lightMapEncoding', 'aoMap', 'emissiveMap', 'emissiveMapEncoding', 'bumpMap', 'normalMap', 'objectSpaceNormalMap', 'tangentSpaceNormalMap', 'clearcoat', 'clearcoatMap', 'clearcoatRoughnessMap', 'clearcoatNormalMap', 'displacementMap', 'specularMap',, 'roughnessMap', 'metalnessMap', 'gradientMap', 'alphaMap', 'alphaTest', 'combine', 'vertexColors', 'vertexAlphas', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2', 'flatShading', 'sizeAttenuation', 'logarithmicDepthBuffer', 'skinning', 'maxBones', 'useVertexTexture', 'morphTargets', 'morphNormals', 'morphTargetsCount', 'premultipliedAlpha', 'numDirLights', 'numPointLights', 'numSpotLights', 'numHemiLights', 'numRectAreaLights', 'numDirLightShadows', 'numPointLightShadows', 'numSpotLightShadows', 'shadowMapEnabled', 'shadowMapType', 'toneMapping', 'physicallyCorrectLights', 'doubleSided', 'flipSided', 'numClippingPlanes', 'numClipIntersection', 'depthPacking', 'dithering', 'format', 'specularIntensityMap', 'specularColorMap', 'specularColorMapEncoding', 'transmission', 'transmissionMap', 'thicknessMap', 'sheen', 'sheenColorMap', 'sheenColorMapEncoding', 'sheenRoughnessMap'];
14264
14340
 
14265
14341
  function getMaxBones(object) {
14266
14342
  const skeleton = object.skeleton;
@@ -14299,10 +14375,10 @@
14299
14375
  } else {
14300
14376
  encoding = LinearEncoding;
14301
14377
  }
14378
+ /* if ( isWebGL2 && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding ) {
14379
+ encoding = LinearEncoding; // disable inline decode for sRGB textures in WebGL 2
14380
+ } */
14302
14381
 
14303
- if (isWebGL2 && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding) {
14304
- encoding = LinearEncoding; // disable inline decode for sRGB textures in WebGL 2
14305
- }
14306
14382
 
14307
14383
  return encoding;
14308
14384
  }
@@ -14378,12 +14454,15 @@
14378
14454
  metalnessMap: !!material.metalnessMap,
14379
14455
  specularMap: !!material.specularMap,
14380
14456
  specularIntensityMap: !!material.specularIntensityMap,
14381
- specularTintMap: !!material.specularTintMap,
14382
- specularTintMapEncoding: getTextureEncodingFromMap(material.specularTintMap),
14457
+ specularColorMap: !!material.specularColorMap,
14458
+ specularColorMapEncoding: getTextureEncodingFromMap(material.specularColorMap),
14383
14459
  alphaMap: !!material.alphaMap,
14384
14460
  alphaTest: useAlphaTest,
14385
14461
  gradientMap: !!material.gradientMap,
14386
14462
  sheen: material.sheen > 0,
14463
+ sheenColorMap: !!material.sheenColorMap,
14464
+ sheenColorMapEncoding: getTextureEncodingFromMap(material.sheenColorMap),
14465
+ sheenRoughnessMap: !!material.sheenRoughnessMap,
14387
14466
  transmission: material.transmission > 0,
14388
14467
  transmissionMap: !!material.transmissionMap,
14389
14468
  thicknessMap: !!material.thicknessMap,
@@ -14391,8 +14470,8 @@
14391
14470
  vertexTangents: !!material.normalMap && !!object.geometry && !!object.geometry.attributes.tangent,
14392
14471
  vertexColors: material.vertexColors,
14393
14472
  vertexAlphas: material.vertexColors === true && !!object.geometry && !!object.geometry.attributes.color && object.geometry.attributes.color.itemSize === 4,
14394
- vertexUvs: !!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatMap || !!material.clearcoatRoughnessMap || !!material.clearcoatNormalMap || !!material.displacementMap || !!material.transmissionMap || !!material.thicknessMap || !!material.specularIntensityMap || !!material.specularTintMap,
14395
- uvsVertexOnly: !(!!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatNormalMap || material.transmission > 0 || !!material.transmissionMap || !!material.thicknessMap || !!material.specularIntensityMap || !!material.specularTintMap) && !!material.displacementMap,
14473
+ vertexUvs: !!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatMap || !!material.clearcoatRoughnessMap || !!material.clearcoatNormalMap || !!material.displacementMap || !!material.transmissionMap || !!material.thicknessMap || !!material.specularIntensityMap || !!material.specularColorMap || !!material.sheenColorMap || material.sheenRoughnessMap,
14474
+ uvsVertexOnly: !(!!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatNormalMap || material.transmission > 0 || !!material.transmissionMap || !!material.thicknessMap || !!material.specularIntensityMap || !!material.specularColorMap || material.sheen > 0 || !!material.sheenColorMap || !!material.sheenRoughnessMap) && !!material.displacementMap,
14396
14475
  fog: !!fog,
14397
14476
  useFog: material.fog,
14398
14477
  fogExp2: fog && fog.isFogExp2,
@@ -14444,8 +14523,8 @@
14444
14523
  if (parameters.shaderID) {
14445
14524
  array.push(parameters.shaderID);
14446
14525
  } else {
14447
- array.push(parameters.fragmentShader);
14448
- array.push(parameters.vertexShader);
14526
+ array.push(hashString(parameters.fragmentShader));
14527
+ array.push(hashString(parameters.vertexShader));
14449
14528
  }
14450
14529
 
14451
14530
  if (parameters.defines !== undefined) {
@@ -15290,7 +15369,7 @@
15290
15369
  MeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;
15291
15370
 
15292
15371
  const vertex = "void main() {\n\tgl_Position = vec4( position, 1.0 );\n}";
15293
- const fragment = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nuniform float samples;\n#include <packing>\nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";
15372
+ const fragment = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";
15294
15373
 
15295
15374
  function WebGLShadowMap(_renderer, _objects, _capabilities) {
15296
15375
  let _frustum = new Frustum();
@@ -15311,6 +15390,9 @@
15311
15390
  2: DoubleSide
15312
15391
  };
15313
15392
  const shadowMaterialVertical = new ShaderMaterial({
15393
+ defines: {
15394
+ VSM_SAMPLES: 8
15395
+ },
15314
15396
  uniforms: {
15315
15397
  shadow_pass: {
15316
15398
  value: null
@@ -15320,9 +15402,6 @@
15320
15402
  },
15321
15403
  radius: {
15322
15404
  value: 4.0
15323
- },
15324
- samples: {
15325
- value: 8.0
15326
15405
  }
15327
15406
  },
15328
15407
  vertexShader: vertex,
@@ -15449,13 +15528,19 @@
15449
15528
  };
15450
15529
 
15451
15530
  function VSMPass(shadow, camera) {
15452
- const geometry = _objects.update(fullScreenMesh); // vertical pass
15531
+ const geometry = _objects.update(fullScreenMesh);
15532
+
15533
+ if (shadowMaterialVertical.defines.VSM_SAMPLES !== shadow.blurSamples) {
15534
+ shadowMaterialVertical.defines.VSM_SAMPLES = shadow.blurSamples;
15535
+ shadowMaterialHorizontal.defines.VSM_SAMPLES = shadow.blurSamples;
15536
+ shadowMaterialVertical.needsUpdate = true;
15537
+ shadowMaterialHorizontal.needsUpdate = true;
15538
+ } // vertical pass
15453
15539
 
15454
15540
 
15455
15541
  shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;
15456
15542
  shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;
15457
15543
  shadowMaterialVertical.uniforms.radius.value = shadow.radius;
15458
- shadowMaterialVertical.uniforms.samples.value = shadow.blurSamples;
15459
15544
 
15460
15545
  _renderer.setRenderTarget(shadow.mapPass);
15461
15546
 
@@ -15467,7 +15552,6 @@
15467
15552
  shadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture;
15468
15553
  shadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize;
15469
15554
  shadowMaterialHorizontal.uniforms.radius.value = shadow.radius;
15470
- shadowMaterialHorizontal.uniforms.samples.value = shadow.blurSamples;
15471
15555
 
15472
15556
  _renderer.setRenderTarget(shadow.map);
15473
15557
 
@@ -15771,7 +15855,6 @@
15771
15855
  const depthBuffer = new DepthBuffer();
15772
15856
  const stencilBuffer = new StencilBuffer();
15773
15857
  let enabledCapabilities = {};
15774
- let xrFramebuffer = null;
15775
15858
  let currentBoundFramebuffers = {};
15776
15859
  let currentProgram = null;
15777
15860
  let currentBlendingEnabled = false;
@@ -15851,16 +15934,7 @@
15851
15934
  }
15852
15935
  }
15853
15936
 
15854
- function bindXRFramebuffer(framebuffer) {
15855
- if (framebuffer !== xrFramebuffer) {
15856
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
15857
- xrFramebuffer = framebuffer;
15858
- }
15859
- }
15860
-
15861
15937
  function bindFramebuffer(target, framebuffer) {
15862
- if (framebuffer === null && xrFramebuffer !== null) framebuffer = xrFramebuffer; // use active XR framebuffer if available
15863
-
15864
15938
  if (currentBoundFramebuffers[target] !== framebuffer) {
15865
15939
  gl.bindFramebuffer(target, framebuffer);
15866
15940
  currentBoundFramebuffers[target] = framebuffer;
@@ -16162,6 +16236,22 @@
16162
16236
  }
16163
16237
  }
16164
16238
 
16239
+ function texSubImage2D() {
16240
+ try {
16241
+ gl.texSubImage2D.apply(gl, arguments);
16242
+ } catch (error) {
16243
+ console.error('THREE.WebGLState:', error);
16244
+ }
16245
+ }
16246
+
16247
+ function texStorage2D() {
16248
+ try {
16249
+ gl.texStorage2D.apply(gl, arguments);
16250
+ } catch (error) {
16251
+ console.error('THREE.WebGLState:', error);
16252
+ }
16253
+ }
16254
+
16165
16255
  function texImage2D() {
16166
16256
  try {
16167
16257
  gl.texImage2D.apply(gl, arguments);
@@ -16234,7 +16324,6 @@
16234
16324
  enabledCapabilities = {};
16235
16325
  currentTextureSlot = null;
16236
16326
  currentBoundTextures = {};
16237
- xrFramebuffer = null;
16238
16327
  currentBoundFramebuffers = {};
16239
16328
  currentProgram = null;
16240
16329
  currentBlendingEnabled = false;
@@ -16267,7 +16356,6 @@
16267
16356
  enable: enable,
16268
16357
  disable: disable,
16269
16358
  bindFramebuffer: bindFramebuffer,
16270
- bindXRFramebuffer: bindXRFramebuffer,
16271
16359
  useProgram: useProgram,
16272
16360
  setBlending: setBlending,
16273
16361
  setMaterial: setMaterial,
@@ -16282,6 +16370,8 @@
16282
16370
  compressedTexImage2D: compressedTexImage2D,
16283
16371
  texImage2D: texImage2D,
16284
16372
  texImage3D: texImage3D,
16373
+ texStorage2D: texStorage2D,
16374
+ texSubImage2D: texSubImage2D,
16285
16375
  scissor: scissor,
16286
16376
  viewport: viewport,
16287
16377
  reset: reset
@@ -16294,6 +16384,8 @@
16294
16384
  const maxCubemapSize = capabilities.maxCubemapSize;
16295
16385
  const maxTextureSize = capabilities.maxTextureSize;
16296
16386
  const maxSamples = capabilities.maxSamples;
16387
+ const hasMultisampledRenderToTexture = extensions.has('WEBGL_multisampled_render_to_texture');
16388
+ const MultisampledRenderToTextureExtension = hasMultisampledRenderToTexture ? extensions.get('WEBGL_multisampled_render_to_texture') : undefined;
16297
16389
 
16298
16390
  const _videoTextures = new WeakMap();
16299
16391
 
@@ -16362,14 +16454,13 @@
16362
16454
  return texture.generateMipmaps && supportsMips && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
16363
16455
  }
16364
16456
 
16365
- function generateMipmap(target, texture, width, height, depth = 1) {
16457
+ function generateMipmap(target) {
16366
16458
  _gl.generateMipmap(target);
16367
-
16368
- const textureProperties = properties.get(texture);
16369
- textureProperties.__maxMipLevel = Math.log2(Math.max(width, height, depth));
16370
16459
  }
16371
16460
 
16372
- function getInternalFormat(internalFormatName, glFormat, glType, encoding) {
16461
+ function getInternalFormat(internalFormatName, glFormat, glType
16462
+ /*, encoding*/
16463
+ ) {
16373
16464
  if (isWebGL2 === false) return glFormat;
16374
16465
 
16375
16466
  if (internalFormatName !== null) {
@@ -16393,8 +16484,9 @@
16393
16484
 
16394
16485
  if (glFormat === _gl.RGBA) {
16395
16486
  if (glType === _gl.FLOAT) internalFormat = _gl.RGBA32F;
16396
- if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F;
16397
- if (glType === _gl.UNSIGNED_BYTE) internalFormat = encoding === sRGBEncoding ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
16487
+ if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F; //if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( encoding === sRGBEncoding ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
16488
+
16489
+ if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RGBA8;
16398
16490
  }
16399
16491
 
16400
16492
  if (internalFormat === _gl.R16F || internalFormat === _gl.R32F || internalFormat === _gl.RGBA16F || internalFormat === _gl.RGBA32F) {
@@ -16402,6 +16494,19 @@
16402
16494
  }
16403
16495
 
16404
16496
  return internalFormat;
16497
+ }
16498
+
16499
+ function getMipLevels(texture, image, supportsMips) {
16500
+ if (textureNeedsGenerateMipmaps(texture, supportsMips) === true) {
16501
+ // generated mipmaps via gl.generateMipmap()
16502
+ return Math.log2(Math.max(image.width, image.height)) + 1;
16503
+ } else if (texture.mipmaps.length > 0) {
16504
+ // user-defined mipmaps
16505
+ return texture.mipmaps.length;
16506
+ } else {
16507
+ // texture without mipmaps (only base level)
16508
+ return 1;
16509
+ }
16405
16510
  } // Fallback filters for non-power-of-2 textures
16406
16511
 
16407
16512
 
@@ -16724,10 +16829,8 @@
16724
16829
  }
16725
16830
 
16726
16831
  texture.generateMipmaps = false;
16727
- textureProperties.__maxMipLevel = mipmaps.length - 1;
16728
16832
  } else {
16729
16833
  state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data);
16730
- textureProperties.__maxMipLevel = 0;
16731
16834
  }
16732
16835
  } else if (texture.isCompressedTexture) {
16733
16836
  for (let i = 0, il = mipmaps.length; i < il; i++) {
@@ -16743,35 +16846,50 @@
16743
16846
  state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
16744
16847
  }
16745
16848
  }
16746
-
16747
- textureProperties.__maxMipLevel = mipmaps.length - 1;
16748
16849
  } else if (texture.isDataTexture2DArray) {
16749
16850
  state.texImage3D(_gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
16750
- textureProperties.__maxMipLevel = 0;
16751
16851
  } else if (texture.isDataTexture3D) {
16752
16852
  state.texImage3D(_gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
16753
- textureProperties.__maxMipLevel = 0;
16754
16853
  } else {
16755
16854
  // regular Texture (image, video, canvas)
16756
16855
  // use manually created mipmaps if available
16757
16856
  // if there are no manual mipmaps
16758
16857
  // set 0 level mipmap and then use GL to generate other mipmap levels
16858
+ const levels = getMipLevels(texture, image, supportsMips);
16859
+ const useTexStorage = isWebGL2 && texture.isVideoTexture !== true;
16860
+ const allocateMemory = textureProperties.__version === undefined;
16861
+
16759
16862
  if (mipmaps.length > 0 && supportsMips) {
16863
+ if (useTexStorage && allocateMemory) {
16864
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
16865
+ }
16866
+
16760
16867
  for (let i = 0, il = mipmaps.length; i < il; i++) {
16761
16868
  mipmap = mipmaps[i];
16762
- state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, glFormat, glType, mipmap);
16869
+
16870
+ if (useTexStorage) {
16871
+ state.texSubImage2D(_gl.TEXTURE_2D, i, 0, 0, glFormat, glType, mipmap);
16872
+ } else {
16873
+ state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, glFormat, glType, mipmap);
16874
+ }
16763
16875
  }
16764
16876
 
16765
16877
  texture.generateMipmaps = false;
16766
- textureProperties.__maxMipLevel = mipmaps.length - 1;
16767
16878
  } else {
16768
- state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, glFormat, glType, image);
16769
- textureProperties.__maxMipLevel = 0;
16879
+ if (useTexStorage) {
16880
+ if (allocateMemory) {
16881
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);
16882
+ }
16883
+
16884
+ state.texSubImage2D(_gl.TEXTURE_2D, 0, 0, 0, glFormat, glType, image);
16885
+ } else {
16886
+ state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, glFormat, glType, image);
16887
+ }
16770
16888
  }
16771
16889
  }
16772
16890
 
16773
16891
  if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
16774
- generateMipmap(textureType, texture, image.width, image.height);
16892
+ generateMipmap(textureType);
16775
16893
  }
16776
16894
 
16777
16895
  textureProperties.__version = texture.version;
@@ -16830,8 +16948,6 @@
16830
16948
  }
16831
16949
  }
16832
16950
  }
16833
-
16834
- textureProperties.__maxMipLevel = mipmaps.length - 1;
16835
16951
  } else {
16836
16952
  mipmaps = texture.mipmaps;
16837
16953
 
@@ -16853,13 +16969,11 @@
16853
16969
  }
16854
16970
  }
16855
16971
  }
16856
-
16857
- textureProperties.__maxMipLevel = mipmaps.length;
16858
16972
  }
16859
16973
 
16860
16974
  if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
16861
16975
  // We assume images for cube map have the same size.
16862
- generateMipmap(_gl.TEXTURE_CUBE_MAP, texture, image.width, image.height);
16976
+ generateMipmap(_gl.TEXTURE_CUBE_MAP);
16863
16977
  }
16864
16978
 
16865
16979
  textureProperties.__version = texture.version;
@@ -16872,16 +16986,23 @@
16872
16986
  const glFormat = utils.convert(texture.format);
16873
16987
  const glType = utils.convert(texture.type);
16874
16988
  const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
16989
+ const renderTargetProperties = properties.get(renderTarget);
16875
16990
 
16876
- if (textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY) {
16877
- state.texImage3D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.depth, 0, glFormat, glType, null);
16878
- } else {
16879
- state.texImage2D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null);
16991
+ if (!renderTargetProperties.__hasExternalTextures) {
16992
+ if (textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY) {
16993
+ state.texImage3D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.depth, 0, glFormat, glType, null);
16994
+ } else {
16995
+ state.texImage2D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null);
16996
+ }
16880
16997
  }
16881
16998
 
16882
16999
  state.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer);
16883
17000
 
16884
- _gl.framebufferTexture2D(_gl.FRAMEBUFFER, attachment, textureTarget, properties.get(texture).__webglTexture, 0);
17001
+ if (renderTarget.useRenderToTexture) {
17002
+ MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT(_gl.FRAMEBUFFER, attachment, textureTarget, properties.get(texture).__webglTexture, 0, getRenderTargetSamples(renderTarget));
17003
+ } else {
17004
+ _gl.framebufferTexture2D(_gl.FRAMEBUFFER, attachment, textureTarget, properties.get(texture).__webglTexture, 0);
17005
+ }
16885
17006
 
16886
17007
  state.bindFramebuffer(_gl.FRAMEBUFFER, null);
16887
17008
  } // Setup storage for internal depth/stencil buffers and bind to correct framebuffer
@@ -16893,7 +17014,7 @@
16893
17014
  if (renderTarget.depthBuffer && !renderTarget.stencilBuffer) {
16894
17015
  let glInternalFormat = _gl.DEPTH_COMPONENT16;
16895
17016
 
16896
- if (isMultisample) {
17017
+ if (isMultisample || renderTarget.useRenderToTexture) {
16897
17018
  const depthTexture = renderTarget.depthTexture;
16898
17019
 
16899
17020
  if (depthTexture && depthTexture.isDepthTexture) {
@@ -16906,17 +17027,23 @@
16906
17027
 
16907
17028
  const samples = getRenderTargetSamples(renderTarget);
16908
17029
 
16909
- _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
17030
+ if (renderTarget.useRenderToTexture) {
17031
+ MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
17032
+ } else {
17033
+ _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
17034
+ }
16910
17035
  } else {
16911
17036
  _gl.renderbufferStorage(_gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height);
16912
17037
  }
16913
17038
 
16914
17039
  _gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer);
16915
17040
  } else if (renderTarget.depthBuffer && renderTarget.stencilBuffer) {
16916
- if (isMultisample) {
16917
- const samples = getRenderTargetSamples(renderTarget);
17041
+ const samples = getRenderTargetSamples(renderTarget);
16918
17042
 
17043
+ if (isMultisample && renderTarget.useRenderbuffer) {
16919
17044
  _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height);
17045
+ } else if (renderTarget.useRenderToTexture) {
17046
+ MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height);
16920
17047
  } else {
16921
17048
  _gl.renderbufferStorage(_gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTarget.width, renderTarget.height);
16922
17049
  }
@@ -16928,11 +17055,12 @@
16928
17055
  const glFormat = utils.convert(texture.format);
16929
17056
  const glType = utils.convert(texture.type);
16930
17057
  const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
17058
+ const samples = getRenderTargetSamples(renderTarget);
16931
17059
 
16932
- if (isMultisample) {
16933
- const samples = getRenderTargetSamples(renderTarget);
16934
-
17060
+ if (isMultisample && renderTarget.useRenderbuffer) {
16935
17061
  _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
17062
+ } else if (renderTarget.useRenderToTexture) {
17063
+ MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
16936
17064
  } else {
16937
17065
  _gl.renderbufferStorage(_gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height);
16938
17066
  }
@@ -16962,10 +17090,20 @@
16962
17090
 
16963
17091
  const webglDepthTexture = properties.get(renderTarget.depthTexture).__webglTexture;
16964
17092
 
17093
+ const samples = getRenderTargetSamples(renderTarget);
17094
+
16965
17095
  if (renderTarget.depthTexture.format === DepthFormat) {
16966
- _gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0);
17096
+ if (renderTarget.useRenderToTexture) {
17097
+ MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples);
17098
+ } else {
17099
+ _gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0);
17100
+ }
16967
17101
  } else if (renderTarget.depthTexture.format === DepthStencilFormat) {
16968
- _gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0);
17102
+ if (renderTarget.useRenderToTexture) {
17103
+ MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT(_gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples);
17104
+ } else {
17105
+ _gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0);
17106
+ }
16969
17107
  } else {
16970
17108
  throw new Error('Unknown depthTexture format');
16971
17109
  }
@@ -16976,7 +17114,7 @@
16976
17114
  const renderTargetProperties = properties.get(renderTarget);
16977
17115
  const isCube = renderTarget.isWebGLCubeRenderTarget === true;
16978
17116
 
16979
- if (renderTarget.depthTexture) {
17117
+ if (renderTarget.depthTexture && !renderTargetProperties.__autoAllocateDepthBuffer) {
16980
17118
  if (isCube) throw new Error('target.depthTexture not supported in Cube render targets');
16981
17119
  setupDepthTexture(renderTargetProperties.__webglFramebuffer, renderTarget);
16982
17120
  } else {
@@ -16996,6 +17134,19 @@
16996
17134
  }
16997
17135
 
16998
17136
  state.bindFramebuffer(_gl.FRAMEBUFFER, null);
17137
+ } // rebind framebuffer with external textures
17138
+
17139
+
17140
+ function rebindTextures(renderTarget, colorTexture, depthTexture) {
17141
+ const renderTargetProperties = properties.get(renderTarget);
17142
+
17143
+ if (colorTexture !== undefined) {
17144
+ setupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, renderTarget.texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D);
17145
+ }
17146
+
17147
+ if (depthTexture !== undefined) {
17148
+ setupDepthRenderbuffer(renderTarget);
17149
+ }
16999
17150
  } // Set up GL resources for the render target
17000
17151
 
17001
17152
 
@@ -17006,14 +17157,16 @@
17006
17157
  renderTarget.addEventListener('dispose', onRenderTargetDispose);
17007
17158
 
17008
17159
  if (renderTarget.isWebGLMultipleRenderTargets !== true) {
17009
- textureProperties.__webglTexture = _gl.createTexture();
17160
+ if (textureProperties.__webglTexture === undefined) {
17161
+ textureProperties.__webglTexture = _gl.createTexture();
17162
+ }
17163
+
17010
17164
  textureProperties.__version = texture.version;
17011
17165
  info.memory.textures++;
17012
17166
  }
17013
17167
 
17014
17168
  const isCube = renderTarget.isWebGLCubeRenderTarget === true;
17015
17169
  const isMultipleRenderTargets = renderTarget.isWebGLMultipleRenderTargets === true;
17016
- const isMultisample = renderTarget.isWebGLMultisampleRenderTarget === true;
17017
17170
  const isRenderTarget3D = texture.isDataTexture3D || texture.isDataTexture2DArray;
17018
17171
  const supportsMips = isPowerOfTwo$1(renderTarget) || isWebGL2; // Handles WebGL2 RGBFormat fallback - #18858
17019
17172
 
@@ -17047,7 +17200,7 @@
17047
17200
  } else {
17048
17201
  console.warn('THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.');
17049
17202
  }
17050
- } else if (isMultisample) {
17203
+ } else if (renderTarget.useRenderbuffer) {
17051
17204
  if (isWebGL2) {
17052
17205
  renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
17053
17206
  renderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer();
@@ -17089,7 +17242,7 @@
17089
17242
  }
17090
17243
 
17091
17244
  if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
17092
- generateMipmap(_gl.TEXTURE_CUBE_MAP, texture, renderTarget.width, renderTarget.height);
17245
+ generateMipmap(_gl.TEXTURE_CUBE_MAP);
17093
17246
  }
17094
17247
 
17095
17248
  state.unbindTexture();
@@ -17104,7 +17257,7 @@
17104
17257
  setupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D);
17105
17258
 
17106
17259
  if (textureNeedsGenerateMipmaps(attachment, supportsMips)) {
17107
- generateMipmap(_gl.TEXTURE_2D, attachment, renderTarget.width, renderTarget.height);
17260
+ generateMipmap(_gl.TEXTURE_2D);
17108
17261
  }
17109
17262
  }
17110
17263
 
@@ -17127,7 +17280,7 @@
17127
17280
  setupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, texture, _gl.COLOR_ATTACHMENT0, glTextureType);
17128
17281
 
17129
17282
  if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
17130
- generateMipmap(glTextureType, texture, renderTarget.width, renderTarget.height, renderTarget.depth);
17283
+ generateMipmap(glTextureType);
17131
17284
  }
17132
17285
 
17133
17286
  state.unbindTexture();
@@ -17152,26 +17305,44 @@
17152
17305
  const webglTexture = properties.get(texture).__webglTexture;
17153
17306
 
17154
17307
  state.bindTexture(target, webglTexture);
17155
- generateMipmap(target, texture, renderTarget.width, renderTarget.height);
17308
+ generateMipmap(target);
17156
17309
  state.unbindTexture();
17157
17310
  }
17158
17311
  }
17159
17312
  }
17160
17313
 
17161
17314
  function updateMultisampleRenderTarget(renderTarget) {
17162
- if (renderTarget.isWebGLMultisampleRenderTarget) {
17315
+ if (renderTarget.useRenderbuffer) {
17163
17316
  if (isWebGL2) {
17164
17317
  const width = renderTarget.width;
17165
17318
  const height = renderTarget.height;
17166
17319
  let mask = _gl.COLOR_BUFFER_BIT;
17167
- if (renderTarget.depthBuffer) mask |= _gl.DEPTH_BUFFER_BIT;
17168
- if (renderTarget.stencilBuffer) mask |= _gl.STENCIL_BUFFER_BIT;
17320
+ const invalidationArray = [_gl.COLOR_ATTACHMENT0];
17321
+ const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
17322
+
17323
+ if (renderTarget.depthBuffer) {
17324
+ invalidationArray.push(depthStyle);
17325
+ }
17326
+
17327
+ if (!renderTarget.ignoreDepthForMultisampleCopy) {
17328
+ if (renderTarget.depthBuffer) mask |= _gl.DEPTH_BUFFER_BIT;
17329
+ if (renderTarget.stencilBuffer) mask |= _gl.STENCIL_BUFFER_BIT;
17330
+ }
17331
+
17169
17332
  const renderTargetProperties = properties.get(renderTarget);
17170
17333
  state.bindFramebuffer(_gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer);
17171
17334
  state.bindFramebuffer(_gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer);
17172
17335
 
17336
+ if (renderTarget.ignoreDepthForMultisampleCopy) {
17337
+ _gl.invalidateFramebuffer(_gl.READ_FRAMEBUFFER, [depthStyle]);
17338
+
17339
+ _gl.invalidateFramebuffer(_gl.DRAW_FRAMEBUFFER, [depthStyle]);
17340
+ }
17341
+
17173
17342
  _gl.blitFramebuffer(0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST);
17174
17343
 
17344
+ _gl.invalidateFramebuffer(_gl.READ_FRAMEBUFFER, invalidationArray);
17345
+
17175
17346
  state.bindFramebuffer(_gl.READ_FRAMEBUFFER, null);
17176
17347
  state.bindFramebuffer(_gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer);
17177
17348
  } else {
@@ -17181,7 +17352,7 @@
17181
17352
  }
17182
17353
 
17183
17354
  function getRenderTargetSamples(renderTarget) {
17184
- return isWebGL2 && renderTarget.isWebGLMultisampleRenderTarget ? Math.min(maxSamples, renderTarget.samples) : 0;
17355
+ return isWebGL2 && (renderTarget.useRenderbuffer || renderTarget.useRenderToTexture) ? Math.min(maxSamples, renderTarget.samples) : 0;
17185
17356
  }
17186
17357
 
17187
17358
  function updateVideoTexture(texture) {
@@ -17231,9 +17402,12 @@
17231
17402
  this.setTexture2DArray = setTexture2DArray;
17232
17403
  this.setTexture3D = setTexture3D;
17233
17404
  this.setTextureCube = setTextureCube;
17405
+ this.rebindTextures = rebindTextures;
17234
17406
  this.setupRenderTarget = setupRenderTarget;
17235
17407
  this.updateRenderTargetMipmap = updateRenderTargetMipmap;
17236
17408
  this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
17409
+ this.setupDepthRenderbuffer = setupDepthRenderbuffer;
17410
+ this.setupFrameBufferTexture = setupFrameBufferTexture;
17237
17411
  this.safeSetTexture2D = safeSetTexture2D;
17238
17412
  this.safeSetTextureCube = safeSetTextureCube;
17239
17413
  }
@@ -17963,29 +18137,51 @@
17963
18137
 
17964
18138
  }
17965
18139
 
18140
+ class DepthTexture extends Texture {
18141
+ constructor(width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format) {
18142
+ format = format !== undefined ? format : DepthFormat;
18143
+
18144
+ if (format !== DepthFormat && format !== DepthStencilFormat) {
18145
+ throw new Error('DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat');
18146
+ }
18147
+
18148
+ if (type === undefined && format === DepthFormat) type = UnsignedShortType;
18149
+ if (type === undefined && format === DepthStencilFormat) type = UnsignedInt248Type;
18150
+ super(null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);
18151
+ this.image = {
18152
+ width: width,
18153
+ height: height
18154
+ };
18155
+ this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
18156
+ this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
18157
+ this.flipY = false;
18158
+ this.generateMipmaps = false;
18159
+ }
18160
+
18161
+ }
18162
+
18163
+ DepthTexture.prototype.isDepthTexture = true;
18164
+
17966
18165
  class WebXRManager extends EventDispatcher {
17967
18166
  constructor(renderer, gl) {
17968
18167
  super();
17969
18168
  const scope = this;
17970
- const state = renderer.state;
17971
18169
  let session = null;
17972
18170
  let framebufferScaleFactor = 1.0;
17973
18171
  var poseTarget = null;
17974
18172
  let referenceSpace = null;
17975
18173
  let referenceSpaceType = 'local-floor';
18174
+ const hasMultisampledRenderToTexture = renderer.extensions.has('WEBGL_multisampled_render_to_texture');
17976
18175
  let pose = null;
17977
18176
  var layers = [];
17978
18177
  let glBinding = null;
17979
- let glFramebuffer = null;
17980
18178
  let glProjLayer = null;
17981
18179
  let glBaseLayer = null;
17982
18180
  let isMultisample = false;
17983
- let glMultisampledFramebuffer = null;
17984
- let glColorRenderbuffer = null;
17985
- let glDepthRenderbuffer = null;
17986
18181
  let xrFrame = null;
17987
- let depthStyle = null;
17988
- let clearStyle = null;
18182
+ const attributes = gl.getContextAttributes();
18183
+ let initialRenderTarget = null;
18184
+ let newRenderTarget = null;
17989
18185
  const controllers = [];
17990
18186
  const inputSourcesMap = new Map(); //
17991
18187
 
@@ -18064,20 +18260,12 @@
18064
18260
  _currentDepthNear = null;
18065
18261
  _currentDepthFar = null; // restore framebuffer/rendering state
18066
18262
 
18067
- state.bindXRFramebuffer(null);
18068
- renderer.setRenderTarget(renderer.getRenderTarget());
18069
- if (glFramebuffer) gl.deleteFramebuffer(glFramebuffer);
18070
- if (glMultisampledFramebuffer) gl.deleteFramebuffer(glMultisampledFramebuffer);
18071
- if (glColorRenderbuffer) gl.deleteRenderbuffer(glColorRenderbuffer);
18072
- if (glDepthRenderbuffer) gl.deleteRenderbuffer(glDepthRenderbuffer);
18073
- glFramebuffer = null;
18074
- glMultisampledFramebuffer = null;
18075
- glColorRenderbuffer = null;
18076
- glDepthRenderbuffer = null;
18263
+ renderer.setRenderTarget(initialRenderTarget);
18077
18264
  glBaseLayer = null;
18078
18265
  glProjLayer = null;
18079
18266
  glBinding = null;
18080
- session = null; //
18267
+ session = null;
18268
+ newRenderTarget = null; //
18081
18269
 
18082
18270
  animation.stop();
18083
18271
  scope.isPresenting = false;
@@ -18126,6 +18314,7 @@
18126
18314
  session = value;
18127
18315
 
18128
18316
  if (session !== null) {
18317
+ initialRenderTarget = renderer.getRenderTarget();
18129
18318
  session.addEventListener('select', onSessionEvent);
18130
18319
  session.addEventListener('selectstart', onSessionEvent);
18131
18320
  session.addEventListener('selectend', onSessionEvent);
@@ -18134,15 +18323,14 @@
18134
18323
  session.addEventListener('squeezeend', onSessionEvent);
18135
18324
  session.addEventListener('end', onSessionEnd);
18136
18325
  session.addEventListener('inputsourceschange', onInputSourcesChange);
18137
- const attributes = gl.getContextAttributes();
18138
18326
 
18139
18327
  if (attributes.xrCompatible !== true) {
18140
18328
  await gl.makeXRCompatible();
18141
18329
  }
18142
18330
 
18143
- if (session.renderState.layers === undefined) {
18331
+ if (session.renderState.layers === undefined || renderer.capabilities.isWebGL2 === false) {
18144
18332
  const layerInit = {
18145
- antialias: attributes.antialias,
18333
+ antialias: session.renderState.layers === undefined ? attributes.antialias : true,
18146
18334
  alpha: attributes.alpha,
18147
18335
  depth: attributes.depth,
18148
18336
  stencil: attributes.stencil,
@@ -18152,64 +18340,52 @@
18152
18340
  session.updateRenderState({
18153
18341
  baseLayer: glBaseLayer
18154
18342
  });
18155
- } else if (gl instanceof WebGLRenderingContext) {
18156
- // Use old style webgl layer because we can't use MSAA
18157
- // WebGL2 support.
18158
- const layerInit = {
18159
- antialias: true,
18160
- alpha: attributes.alpha,
18161
- depth: attributes.depth,
18162
- stencil: attributes.stencil,
18163
- framebufferScaleFactor: framebufferScaleFactor
18164
- };
18165
- glBaseLayer = new XRWebGLLayer(session, gl, layerInit);
18166
- session.updateRenderState({
18167
- layers: [glBaseLayer]
18168
- });
18343
+ newRenderTarget = new WebGLRenderTarget(glBaseLayer.framebufferWidth, glBaseLayer.framebufferHeight);
18169
18344
  } else {
18170
18345
  isMultisample = attributes.antialias;
18171
18346
  let depthFormat = null;
18347
+ let depthType = null;
18348
+ let glDepthFormat = null;
18172
18349
 
18173
18350
  if (attributes.depth) {
18174
- clearStyle = gl.DEPTH_BUFFER_BIT;
18175
- if (attributes.stencil) clearStyle |= gl.STENCIL_BUFFER_BIT;
18176
- depthStyle = attributes.stencil ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;
18177
- depthFormat = attributes.stencil ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT24;
18351
+ glDepthFormat = attributes.stencil ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT16;
18352
+ depthFormat = attributes.stencil ? DepthStencilFormat : DepthFormat;
18353
+ depthType = attributes.stencil ? UnsignedInt248Type : UnsignedShortType;
18178
18354
  }
18179
18355
 
18180
18356
  const projectionlayerInit = {
18181
- colorFormat: attributes.alpha ? gl.RGBA8 : gl.RGB8,
18182
- depthFormat: depthFormat,
18357
+ colorFormat: attributes.alpha || isMultisample ? gl.RGBA8 : gl.RGB8,
18358
+ depthFormat: glDepthFormat,
18183
18359
  scaleFactor: framebufferScaleFactor
18184
18360
  };
18185
18361
  glBinding = new XRWebGLBinding(session, gl);
18186
18362
  glProjLayer = glBinding.createProjectionLayer(projectionlayerInit);
18187
- glFramebuffer = gl.createFramebuffer();
18188
18363
  session.updateRenderState({
18189
18364
  layers: [glProjLayer]
18190
18365
  });
18191
18366
 
18192
18367
  if (isMultisample) {
18193
- glMultisampledFramebuffer = gl.createFramebuffer();
18194
- glColorRenderbuffer = gl.createRenderbuffer();
18195
- gl.bindRenderbuffer(gl.RENDERBUFFER, glColorRenderbuffer);
18196
- gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.RGBA8, glProjLayer.textureWidth, glProjLayer.textureHeight);
18197
- state.bindFramebuffer(gl.FRAMEBUFFER, glMultisampledFramebuffer);
18198
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, glColorRenderbuffer);
18199
- gl.bindRenderbuffer(gl.RENDERBUFFER, null);
18200
-
18201
- if (depthFormat !== null) {
18202
- glDepthRenderbuffer = gl.createRenderbuffer();
18203
- gl.bindRenderbuffer(gl.RENDERBUFFER, glDepthRenderbuffer);
18204
- gl.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, depthFormat, glProjLayer.textureWidth, glProjLayer.textureHeight);
18205
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, depthStyle, gl.RENDERBUFFER, glDepthRenderbuffer);
18206
- gl.bindRenderbuffer(gl.RENDERBUFFER, null);
18207
- }
18208
-
18209
- state.bindFramebuffer(gl.FRAMEBUFFER, null);
18368
+ newRenderTarget = new WebGLMultisampleRenderTarget(glProjLayer.textureWidth, glProjLayer.textureHeight, {
18369
+ format: RGBAFormat,
18370
+ type: UnsignedByteType,
18371
+ depthTexture: new DepthTexture(glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat),
18372
+ stencilBuffer: attributes.stencil,
18373
+ ignoreDepth: glProjLayer.ignoreDepthValues,
18374
+ useRenderToTexture: hasMultisampledRenderToTexture
18375
+ });
18376
+ } else {
18377
+ newRenderTarget = new WebGLRenderTarget(glProjLayer.textureWidth, glProjLayer.textureHeight, {
18378
+ format: attributes.alpha ? RGBAFormat : RGBFormat,
18379
+ type: UnsignedByteType,
18380
+ depthTexture: new DepthTexture(glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat),
18381
+ stencilBuffer: attributes.stencil,
18382
+ ignoreDepth: glProjLayer.ignoreDepthValues
18383
+ });
18210
18384
  }
18211
- }
18385
+ } // Set foveation to maximum.
18212
18386
 
18387
+
18388
+ this.setFoveation(0);
18213
18389
  referenceSpace = await session.requestReferenceSpace(referenceSpaceType);
18214
18390
  animation.setContext(session);
18215
18391
  animation.start();
@@ -18429,7 +18605,8 @@
18429
18605
  const views = pose.views;
18430
18606
 
18431
18607
  if (glBaseLayer !== null) {
18432
- state.bindXRFramebuffer(glBaseLayer.framebuffer);
18608
+ renderer.setRenderTargetFramebuffer(newRenderTarget, glBaseLayer.framebuffer);
18609
+ renderer.setRenderTarget(newRenderTarget);
18433
18610
  }
18434
18611
 
18435
18612
  let cameraVRNeedsUpdate = false; // check if it's necessary to rebuild cameraVR's camera list
@@ -18447,14 +18624,12 @@
18447
18624
  viewport = glBaseLayer.getViewport(view);
18448
18625
  } else {
18449
18626
  const glSubImage = glBinding.getViewSubImage(glProjLayer, view);
18450
- state.bindXRFramebuffer(glFramebuffer);
18627
+ viewport = glSubImage.viewport; // For side-by-side projection, we only produce a single texture for both eyes.
18451
18628
 
18452
- if (glSubImage.depthStencilTexture !== undefined) {
18453
- gl.framebufferTexture2D(gl.FRAMEBUFFER, depthStyle, gl.TEXTURE_2D, glSubImage.depthStencilTexture, 0);
18629
+ if (i === 0) {
18630
+ renderer.setRenderTargetTextures(newRenderTarget, glSubImage.colorTexture, glProjLayer.ignoreDepthValues ? undefined : glSubImage.depthStencilTexture);
18631
+ renderer.setRenderTarget(newRenderTarget);
18454
18632
  }
18455
-
18456
- gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, glSubImage.colorTexture, 0);
18457
- viewport = glSubImage.viewport;
18458
18633
  }
18459
18634
 
18460
18635
  const camera = cameras[i];
@@ -18470,11 +18645,6 @@
18470
18645
  cameraVR.cameras.push(camera);
18471
18646
  }
18472
18647
  }
18473
-
18474
- if (isMultisample) {
18475
- state.bindXRFramebuffer(glMultisampledFramebuffer);
18476
- if (clearStyle !== null) gl.clear(clearStyle);
18477
- }
18478
18648
  } //
18479
18649
 
18480
18650
 
@@ -18487,23 +18657,6 @@
18487
18657
  }
18488
18658
 
18489
18659
  if (onAnimationFrameCallback) onAnimationFrameCallback(time, frame);
18490
-
18491
- if (isMultisample) {
18492
- const width = glProjLayer.textureWidth;
18493
- const height = glProjLayer.textureHeight;
18494
- state.bindFramebuffer(gl.READ_FRAMEBUFFER, glMultisampledFramebuffer);
18495
- state.bindFramebuffer(gl.DRAW_FRAMEBUFFER, glFramebuffer); // Invalidate the depth here to avoid flush of the depth data to main memory.
18496
-
18497
- gl.invalidateFramebuffer(gl.READ_FRAMEBUFFER, [depthStyle]);
18498
- gl.invalidateFramebuffer(gl.DRAW_FRAMEBUFFER, [depthStyle]);
18499
- gl.blitFramebuffer(0, 0, width, height, 0, 0, width, height, gl.COLOR_BUFFER_BIT, gl.NEAREST); // Invalidate the MSAA buffer because it's not needed anymore.
18500
-
18501
- gl.invalidateFramebuffer(gl.READ_FRAMEBUFFER, [gl.COLOR_ATTACHMENT0]);
18502
- state.bindFramebuffer(gl.READ_FRAMEBUFFER, null);
18503
- state.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null);
18504
- state.bindFramebuffer(gl.FRAMEBUFFER, glMultisampledFramebuffer);
18505
- }
18506
-
18507
18660
  xrFrame = null;
18508
18661
  }
18509
18662
 
@@ -18616,12 +18769,6 @@
18616
18769
  uniforms.reflectivity.value = material.reflectivity;
18617
18770
  uniforms.ior.value = material.ior;
18618
18771
  uniforms.refractionRatio.value = material.refractionRatio;
18619
-
18620
- const maxMipLevel = properties.get(envMap).__maxMipLevel;
18621
-
18622
- if (maxMipLevel !== undefined) {
18623
- uniforms.maxMipLevel.value = maxMipLevel;
18624
- }
18625
18772
  }
18626
18773
 
18627
18774
  if (material.lightMap) {
@@ -18679,12 +18826,16 @@
18679
18826
  uvScaleMap = material.clearcoatRoughnessMap;
18680
18827
  } else if (material.specularIntensityMap) {
18681
18828
  uvScaleMap = material.specularIntensityMap;
18682
- } else if (material.specularTintMap) {
18683
- uvScaleMap = material.specularTintMap;
18829
+ } else if (material.specularColorMap) {
18830
+ uvScaleMap = material.specularColorMap;
18684
18831
  } else if (material.transmissionMap) {
18685
18832
  uvScaleMap = material.transmissionMap;
18686
18833
  } else if (material.thicknessMap) {
18687
18834
  uvScaleMap = material.thicknessMap;
18835
+ } else if (material.sheenColorMap) {
18836
+ uvScaleMap = material.sheenColorMap;
18837
+ } else if (material.sheenRoughnessMap) {
18838
+ uvScaleMap = material.sheenRoughnessMap;
18688
18839
  }
18689
18840
 
18690
18841
  if (uvScaleMap !== undefined) {
@@ -18919,8 +19070,16 @@
18919
19070
  uniforms.ior.value = material.ior; // also part of uniforms common
18920
19071
 
18921
19072
  if (material.sheen > 0) {
18922
- uniforms.sheenTint.value.copy(material.sheenTint).multiplyScalar(material.sheen);
19073
+ uniforms.sheenColor.value.copy(material.sheenColor).multiplyScalar(material.sheen);
18923
19074
  uniforms.sheenRoughness.value = material.sheenRoughness;
19075
+
19076
+ if (material.sheenColorMap) {
19077
+ uniforms.sheenColorMap.value = material.sheenColorMap;
19078
+ }
19079
+
19080
+ if (material.sheenRoughnessMap) {
19081
+ uniforms.sheenRoughnessMap.value = material.sheenRoughnessMap;
19082
+ }
18924
19083
  }
18925
19084
 
18926
19085
  if (material.clearcoat > 0) {
@@ -18961,18 +19120,18 @@
18961
19120
  }
18962
19121
 
18963
19122
  uniforms.attenuationDistance.value = material.attenuationDistance;
18964
- uniforms.attenuationTint.value.copy(material.attenuationTint);
19123
+ uniforms.attenuationColor.value.copy(material.attenuationColor);
18965
19124
  }
18966
19125
 
18967
19126
  uniforms.specularIntensity.value = material.specularIntensity;
18968
- uniforms.specularTint.value.copy(material.specularTint);
19127
+ uniforms.specularColor.value.copy(material.specularColor);
18969
19128
 
18970
19129
  if (material.specularIntensityMap) {
18971
19130
  uniforms.specularIntensityMap.value = material.specularIntensityMap;
18972
19131
  }
18973
19132
 
18974
- if (material.specularTintMap) {
18975
- uniforms.specularTintMap.value = material.specularTintMap;
19133
+ if (material.specularColorMap) {
19134
+ uniforms.specularColorMap.value = material.specularColorMap;
18976
19135
  }
18977
19136
  }
18978
19137
 
@@ -19181,7 +19340,9 @@
19181
19340
  preserveDrawingBuffer: _preserveDrawingBuffer,
19182
19341
  powerPreference: _powerPreference,
19183
19342
  failIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat
19184
- }; // event listeners must be registered before WebGL context is created, see #12753
19343
+ }; // OffscreenCanvas does not have setAttribute, see #22811
19344
+
19345
+ if ('setAttribute' in _canvas) _canvas.setAttribute('data-engine', `three.js r${REVISION}`); // event listeners must be registered before WebGL context is created, see #12753
19185
19346
 
19186
19347
  _canvas.addEventListener('webglcontextlost', onContextLost, false);
19187
19348
 
@@ -19488,68 +19649,6 @@
19488
19649
  } // Buffer rendering
19489
19650
 
19490
19651
 
19491
- function renderObjectImmediate(object, program) {
19492
- object.render(function (object) {
19493
- _this.renderBufferImmediate(object, program);
19494
- });
19495
- }
19496
-
19497
- this.renderBufferImmediate = function (object, program) {
19498
- bindingStates.initAttributes();
19499
- const buffers = properties.get(object);
19500
- if (object.hasPositions && !buffers.position) buffers.position = _gl.createBuffer();
19501
- if (object.hasNormals && !buffers.normal) buffers.normal = _gl.createBuffer();
19502
- if (object.hasUvs && !buffers.uv) buffers.uv = _gl.createBuffer();
19503
- if (object.hasColors && !buffers.color) buffers.color = _gl.createBuffer();
19504
- const programAttributes = program.getAttributes();
19505
-
19506
- if (object.hasPositions) {
19507
- _gl.bindBuffer(_gl.ARRAY_BUFFER, buffers.position);
19508
-
19509
- _gl.bufferData(_gl.ARRAY_BUFFER, object.positionArray, _gl.DYNAMIC_DRAW);
19510
-
19511
- bindingStates.enableAttribute(programAttributes.position.location);
19512
-
19513
- _gl.vertexAttribPointer(programAttributes.position.location, 3, _gl.FLOAT, false, 0, 0);
19514
- }
19515
-
19516
- if (object.hasNormals) {
19517
- _gl.bindBuffer(_gl.ARRAY_BUFFER, buffers.normal);
19518
-
19519
- _gl.bufferData(_gl.ARRAY_BUFFER, object.normalArray, _gl.DYNAMIC_DRAW);
19520
-
19521
- bindingStates.enableAttribute(programAttributes.normal.location);
19522
-
19523
- _gl.vertexAttribPointer(programAttributes.normal.location, 3, _gl.FLOAT, false, 0, 0);
19524
- }
19525
-
19526
- if (object.hasUvs) {
19527
- _gl.bindBuffer(_gl.ARRAY_BUFFER, buffers.uv);
19528
-
19529
- _gl.bufferData(_gl.ARRAY_BUFFER, object.uvArray, _gl.DYNAMIC_DRAW);
19530
-
19531
- bindingStates.enableAttribute(programAttributes.uv.location);
19532
-
19533
- _gl.vertexAttribPointer(programAttributes.uv.location, 2, _gl.FLOAT, false, 0, 0);
19534
- }
19535
-
19536
- if (object.hasColors) {
19537
- _gl.bindBuffer(_gl.ARRAY_BUFFER, buffers.color);
19538
-
19539
- _gl.bufferData(_gl.ARRAY_BUFFER, object.colorArray, _gl.DYNAMIC_DRAW);
19540
-
19541
- bindingStates.enableAttribute(programAttributes.color.location);
19542
-
19543
- _gl.vertexAttribPointer(programAttributes.color.location, 3, _gl.FLOAT, false, 0, 0);
19544
- }
19545
-
19546
- bindingStates.disableUnusedAttributes();
19547
-
19548
- _gl.drawArrays(_gl.TRIANGLES, 0, object.count);
19549
-
19550
- object.count = 0;
19551
- };
19552
-
19553
19652
  this.renderBufferDirect = function (camera, scene, geometry, material, object, group) {
19554
19653
  if (scene === null) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)
19555
19654
 
@@ -19823,12 +19922,6 @@
19823
19922
  currentRenderList.push(object, geometry, material, groupOrder, _vector3.z, null);
19824
19923
  }
19825
19924
  }
19826
- } else if (object.isImmediateRenderObject) {
19827
- if (sortObjects) {
19828
- _vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix);
19829
- }
19830
-
19831
- currentRenderList.push(object, null, object.material, groupOrder, _vector3.z, null);
19832
19925
  } else if (object.isMesh || object.isLine || object.isPoints) {
19833
19926
  if (object.isSkinnedMesh) {
19834
19927
  // update skeleton only once in a frame
@@ -19893,7 +19986,8 @@
19893
19986
  minFilter: LinearMipmapLinearFilter,
19894
19987
  magFilter: NearestFilter,
19895
19988
  wrapS: ClampToEdgeWrapping,
19896
- wrapT: ClampToEdgeWrapping
19989
+ wrapT: ClampToEdgeWrapping,
19990
+ useRenderToTexture: extensions.has('WEBGL_multisampled_render_to_texture')
19897
19991
  });
19898
19992
  }
19899
19993
 
@@ -19937,27 +20031,20 @@
19937
20031
  object.normalMatrix.getNormalMatrix(object.modelViewMatrix);
19938
20032
  material.onBeforeRender(_this, scene, camera, geometry, object, group);
19939
20033
 
19940
- if (object.isImmediateRenderObject) {
19941
- const program = setProgram(camera, scene, geometry, material, object);
19942
- state.setMaterial(material);
19943
- bindingStates.reset();
19944
- renderObjectImmediate(object, program);
19945
- } else {
19946
- if (material.transparent === true && material.side === DoubleSide) {
19947
- material.side = BackSide;
19948
- material.needsUpdate = true;
20034
+ if (material.transparent === true && material.side === DoubleSide) {
20035
+ material.side = BackSide;
20036
+ material.needsUpdate = true;
19949
20037
 
19950
- _this.renderBufferDirect(camera, scene, geometry, material, object, group);
20038
+ _this.renderBufferDirect(camera, scene, geometry, material, object, group);
19951
20039
 
19952
- material.side = FrontSide;
19953
- material.needsUpdate = true;
20040
+ material.side = FrontSide;
20041
+ material.needsUpdate = true;
19954
20042
 
19955
- _this.renderBufferDirect(camera, scene, geometry, material, object, group);
20043
+ _this.renderBufferDirect(camera, scene, geometry, material, object, group);
19956
20044
 
19957
- material.side = DoubleSide;
19958
- } else {
19959
- _this.renderBufferDirect(camera, scene, geometry, material, object, group);
19960
- }
20045
+ material.side = DoubleSide;
20046
+ } else {
20047
+ _this.renderBufferDirect(camera, scene, geometry, material, object, group);
19961
20048
  }
19962
20049
 
19963
20050
  object.onAfterRender(_this, scene, camera, geometry, material, group);
@@ -19995,7 +20082,7 @@
19995
20082
  }
19996
20083
  } else {
19997
20084
  parameters.uniforms = programCache.getUniforms(material);
19998
- material.onBuild(parameters, _this);
20085
+ material.onBuild(object, parameters, _this);
19999
20086
  material.onBeforeCompile(parameters, _this);
20000
20087
  program = programCache.acquireProgram(parameters, programCacheKey);
20001
20088
  programs.set(programCacheKey, program);
@@ -20064,11 +20151,11 @@
20064
20151
  const environment = material.isMeshStandardMaterial ? scene.environment : null;
20065
20152
  const encoding = _currentRenderTarget === null ? _this.outputEncoding : _currentRenderTarget.texture.encoding;
20066
20153
  const envMap = (material.isMeshStandardMaterial ? cubeuvmaps : cubemaps).get(material.envMap || environment);
20067
- const vertexAlphas = material.vertexColors === true && !!geometry && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4;
20068
- const vertexTangents = !!material.normalMap && !!geometry && !!geometry.attributes.tangent;
20069
- const morphTargets = !!geometry && !!geometry.morphAttributes.position;
20070
- const morphNormals = !!geometry && !!geometry.morphAttributes.normal;
20071
- const morphTargetsCount = !!geometry && !!geometry.morphAttributes.position ? geometry.morphAttributes.position.length : 0;
20154
+ const vertexAlphas = material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4;
20155
+ const vertexTangents = !!material.normalMap && !!geometry.attributes.tangent;
20156
+ const morphTargets = !!geometry.morphAttributes.position;
20157
+ const morphNormals = !!geometry.morphAttributes.normal;
20158
+ const morphTargetsCount = !!geometry.morphAttributes.position ? geometry.morphAttributes.position.length : 0;
20072
20159
  const materialProperties = properties.get(material);
20073
20160
  const lights = currentRenderState.state.lights;
20074
20161
 
@@ -20294,13 +20381,52 @@
20294
20381
  return _currentRenderTarget;
20295
20382
  };
20296
20383
 
20384
+ this.setRenderTargetTextures = function (renderTarget, colorTexture, depthTexture) {
20385
+ properties.get(renderTarget.texture).__webglTexture = colorTexture;
20386
+ properties.get(renderTarget.depthTexture).__webglTexture = depthTexture;
20387
+ const renderTargetProperties = properties.get(renderTarget);
20388
+ renderTargetProperties.__hasExternalTextures = true;
20389
+
20390
+ if (renderTargetProperties.__hasExternalTextures) {
20391
+ renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
20392
+
20393
+ if (!renderTargetProperties.__autoAllocateDepthBuffer) {
20394
+ // The multisample_render_to_texture extension doesn't work properly if there
20395
+ // are midframe flushes and an external depth buffer. Disable use of the extension.
20396
+ if (renderTarget.useRenderToTexture) {
20397
+ console.warn('render-to-texture extension was disabled because an external texture was provided');
20398
+ renderTarget.useRenderToTexture = false;
20399
+ renderTarget.useRenderbuffer = true;
20400
+ }
20401
+ }
20402
+ }
20403
+ };
20404
+
20405
+ this.setRenderTargetFramebuffer = function (renderTarget, defaultFramebuffer) {
20406
+ const renderTargetProperties = properties.get(renderTarget);
20407
+ renderTargetProperties.__webglFramebuffer = defaultFramebuffer;
20408
+ renderTargetProperties.__useDefaultFramebuffer = defaultFramebuffer === undefined;
20409
+ };
20410
+
20297
20411
  this.setRenderTarget = function (renderTarget, activeCubeFace = 0, activeMipmapLevel = 0) {
20298
20412
  _currentRenderTarget = renderTarget;
20299
20413
  _currentActiveCubeFace = activeCubeFace;
20300
20414
  _currentActiveMipmapLevel = activeMipmapLevel;
20415
+ let useDefaultFramebuffer = true;
20416
+
20417
+ if (renderTarget) {
20418
+ const renderTargetProperties = properties.get(renderTarget);
20301
20419
 
20302
- if (renderTarget && properties.get(renderTarget).__webglFramebuffer === undefined) {
20303
- textures.setupRenderTarget(renderTarget);
20420
+ if (renderTargetProperties.__useDefaultFramebuffer !== undefined) {
20421
+ // We need to make sure to rebind the framebuffer.
20422
+ state.bindFramebuffer(_gl.FRAMEBUFFER, null);
20423
+ useDefaultFramebuffer = false;
20424
+ } else if (renderTargetProperties.__webglFramebuffer === undefined) {
20425
+ textures.setupRenderTarget(renderTarget);
20426
+ } else if (renderTargetProperties.__hasExternalTextures) {
20427
+ // Color and depth texture must be rebound in order for the swapchain to update.
20428
+ textures.rebindTextures(renderTarget, properties.get(renderTarget.texture).__webglTexture, properties.get(renderTarget.depthTexture).__webglTexture);
20429
+ }
20304
20430
  }
20305
20431
 
20306
20432
  let framebuffer = null;
@@ -20319,7 +20445,7 @@
20319
20445
  if (renderTarget.isWebGLCubeRenderTarget) {
20320
20446
  framebuffer = __webglFramebuffer[activeCubeFace];
20321
20447
  isCube = true;
20322
- } else if (renderTarget.isWebGLMultisampleRenderTarget) {
20448
+ } else if (renderTarget.useRenderbuffer) {
20323
20449
  framebuffer = properties.get(renderTarget).__webglMultisampledFramebuffer;
20324
20450
  } else {
20325
20451
  framebuffer = __webglFramebuffer;
@@ -20340,7 +20466,7 @@
20340
20466
 
20341
20467
  const framebufferBound = state.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer);
20342
20468
 
20343
- if (framebufferBound && capabilities.drawBuffers) {
20469
+ if (framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer) {
20344
20470
  let needsUpdate = false;
20345
20471
 
20346
20472
  if (renderTarget) {
@@ -20596,6 +20722,8 @@
20596
20722
  }
20597
20723
  }
20598
20724
 
20725
+ WebGLRenderer.prototype.isWebGLRenderer = true;
20726
+
20599
20727
  class WebGL1Renderer extends WebGLRenderer {}
20600
20728
 
20601
20729
  WebGL1Renderer.prototype.isWebGL1Renderer = true;
@@ -22245,31 +22373,6 @@
22245
22373
 
22246
22374
  CanvasTexture.prototype.isCanvasTexture = true;
22247
22375
 
22248
- class DepthTexture extends Texture {
22249
- constructor(width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format) {
22250
- format = format !== undefined ? format : DepthFormat;
22251
-
22252
- if (format !== DepthFormat && format !== DepthStencilFormat) {
22253
- throw new Error('DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat');
22254
- }
22255
-
22256
- if (type === undefined && format === DepthFormat) type = UnsignedShortType;
22257
- if (type === undefined && format === DepthStencilFormat) type = UnsignedInt248Type;
22258
- super(null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);
22259
- this.image = {
22260
- width: width,
22261
- height: height
22262
- };
22263
- this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
22264
- this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
22265
- this.flipY = false;
22266
- this.generateMipmaps = false;
22267
- }
22268
-
22269
- }
22270
-
22271
- DepthTexture.prototype.isDepthTexture = true;
22272
-
22273
22376
  class CircleGeometry extends BufferGeometry {
22274
22377
  constructor(radius = 1, segments = 8, thetaStart = 0, thetaLength = Math.PI * 2) {
22275
22378
  super();
@@ -26395,8 +26498,10 @@
26395
26498
  * reflectivity: <float>,
26396
26499
  *
26397
26500
  * sheen: <float>,
26398
- * sheenTint: <Color>,
26501
+ * sheenColor: <Color>,
26502
+ * sheenColorMap: new THREE.Texture( <Image> ),
26399
26503
  * sheenRoughness: <float>,
26504
+ * sheenRoughnessMap: new THREE.Texture( <Image> ),
26400
26505
  *
26401
26506
  * transmission: <float>,
26402
26507
  * transmissionMap: new THREE.Texture( <Image> ),
@@ -26404,12 +26509,12 @@
26404
26509
  * thickness: <float>,
26405
26510
  * thicknessMap: new THREE.Texture( <Image> ),
26406
26511
  * attenuationDistance: <float>,
26407
- * attenuationTint: <Color>,
26512
+ * attenuationColor: <Color>,
26408
26513
  *
26409
26514
  * specularIntensity: <float>,
26410
- * specularIntensityhMap: new THREE.Texture( <Image> ),
26411
- * specularTint: <Color>,
26412
- * specularTintMap: new THREE.Texture( <Image> )
26515
+ * specularIntensityMap: new THREE.Texture( <Image> ),
26516
+ * specularColor: <Color>,
26517
+ * specularColorMap: new THREE.Texture( <Image> )
26413
26518
  * }
26414
26519
  */
26415
26520
 
@@ -26435,17 +26540,19 @@
26435
26540
  this.ior = (1 + 0.4 * reflectivity) / (1 - 0.4 * reflectivity);
26436
26541
  }
26437
26542
  });
26438
- this.sheenTint = new Color(0x000000);
26543
+ this.sheenColor = new Color(0x000000);
26544
+ this.sheenColorMap = null;
26439
26545
  this.sheenRoughness = 1.0;
26546
+ this.sheenRoughnessMap = null;
26440
26547
  this.transmissionMap = null;
26441
- this.thickness = 0.01;
26548
+ this.thickness = 0;
26442
26549
  this.thicknessMap = null;
26443
26550
  this.attenuationDistance = 0.0;
26444
- this.attenuationTint = new Color(1, 1, 1);
26551
+ this.attenuationColor = new Color(1, 1, 1);
26445
26552
  this.specularIntensity = 1.0;
26446
26553
  this.specularIntensityMap = null;
26447
- this.specularTint = new Color(1, 1, 1);
26448
- this.specularTintMap = null;
26554
+ this.specularColor = new Color(1, 1, 1);
26555
+ this.specularColorMap = null;
26449
26556
  this._sheen = 0.0;
26450
26557
  this._clearcoat = 0;
26451
26558
  this._transmission = 0;
@@ -26502,18 +26609,20 @@
26502
26609
  this.clearcoatNormalScale.copy(source.clearcoatNormalScale);
26503
26610
  this.ior = source.ior;
26504
26611
  this.sheen = source.sheen;
26505
- this.sheenTint.copy(source.sheenTint);
26612
+ this.sheenColor.copy(source.sheenColor);
26613
+ this.sheenColorMap = source.sheenColorMap;
26506
26614
  this.sheenRoughness = source.sheenRoughness;
26615
+ this.sheenRoughnessMap = source.sheenRoughnessMap;
26507
26616
  this.transmission = source.transmission;
26508
26617
  this.transmissionMap = source.transmissionMap;
26509
26618
  this.thickness = source.thickness;
26510
26619
  this.thicknessMap = source.thicknessMap;
26511
26620
  this.attenuationDistance = source.attenuationDistance;
26512
- this.attenuationTint.copy(source.attenuationTint);
26621
+ this.attenuationColor.copy(source.attenuationColor);
26513
26622
  this.specularIntensity = source.specularIntensity;
26514
26623
  this.specularIntensityMap = source.specularIntensityMap;
26515
- this.specularTint.copy(source.specularTint);
26516
- this.specularTintMap = source.specularTintMap;
26624
+ this.specularColor.copy(source.specularColor);
26625
+ this.specularColorMap = source.specularColorMap;
26517
26626
  return this;
26518
26627
  }
26519
26628
 
@@ -28470,14 +28579,13 @@
28470
28579
  if (url === undefined) url = '';
28471
28580
  if (this.path !== undefined) url = this.path + url;
28472
28581
  url = this.manager.resolveURL(url);
28473
- const scope = this;
28474
28582
  const cached = Cache.get(url);
28475
28583
 
28476
28584
  if (cached !== undefined) {
28477
- scope.manager.itemStart(url);
28478
- setTimeout(function () {
28585
+ this.manager.itemStart(url);
28586
+ setTimeout(() => {
28479
28587
  if (onLoad) onLoad(cached);
28480
- scope.manager.itemEnd(url);
28588
+ this.manager.itemEnd(url);
28481
28589
  }, 0);
28482
28590
  return cached;
28483
28591
  } // Check if request is duplicate
@@ -28490,155 +28598,121 @@
28490
28598
  onError: onError
28491
28599
  });
28492
28600
  return;
28493
- } // Check for data: URI
28494
-
28601
+ } // Initialise array for duplicate requests
28495
28602
 
28496
- const dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/;
28497
- const dataUriRegexResult = url.match(dataUriRegex);
28498
- let request; // Safari can not handle Data URIs through XMLHttpRequest so process manually
28499
28603
 
28500
- if (dataUriRegexResult) {
28501
- const mimeType = dataUriRegexResult[1];
28502
- const isBase64 = !!dataUriRegexResult[2];
28503
- let data = dataUriRegexResult[3];
28504
- data = decodeURIComponent(data);
28505
- if (isBase64) data = atob(data);
28604
+ loading[url] = [];
28605
+ loading[url].push({
28606
+ onLoad: onLoad,
28607
+ onProgress: onProgress,
28608
+ onError: onError
28609
+ }); // create request
28506
28610
 
28507
- try {
28508
- let response;
28509
- const responseType = (this.responseType || '').toLowerCase();
28611
+ const req = new Request(url, {
28612
+ headers: new Headers(this.requestHeader),
28613
+ credentials: this.withCredentials ? 'include' : 'same-origin' // An abort controller could be added within a future PR
28510
28614
 
28511
- switch (responseType) {
28512
- case 'arraybuffer':
28513
- case 'blob':
28514
- const view = new Uint8Array(data.length);
28615
+ }); // start the fetch
28515
28616
 
28516
- for (let i = 0; i < data.length; i++) {
28517
- view[i] = data.charCodeAt(i);
28518
- }
28617
+ fetch(req).then(response => {
28618
+ if (response.status === 200 || response.status === 0) {
28619
+ // Some browsers return HTTP Status 0 when using non-http protocol
28620
+ // e.g. 'file://' or 'data://'. Handle as success.
28621
+ if (response.status === 0) {
28622
+ console.warn('THREE.FileLoader: HTTP Status 0 received.');
28623
+ }
28519
28624
 
28520
- if (responseType === 'blob') {
28521
- response = new Blob([view.buffer], {
28522
- type: mimeType
28625
+ const callbacks = loading[url];
28626
+ const reader = response.body.getReader();
28627
+ const contentLength = response.headers.get('Content-Length');
28628
+ const total = contentLength ? parseInt(contentLength) : 0;
28629
+ const lengthComputable = total !== 0;
28630
+ let loaded = 0; // periodically read data into the new stream tracking while download progress
28631
+
28632
+ return new ReadableStream({
28633
+ start(controller) {
28634
+ readData();
28635
+
28636
+ function readData() {
28637
+ reader.read().then(({
28638
+ done,
28639
+ value
28640
+ }) => {
28641
+ if (done) {
28642
+ controller.close();
28643
+ } else {
28644
+ loaded += value.byteLength;
28645
+ const event = new ProgressEvent('progress', {
28646
+ lengthComputable,
28647
+ loaded,
28648
+ total
28649
+ });
28650
+
28651
+ for (let i = 0, il = callbacks.length; i < il; i++) {
28652
+ const callback = callbacks[i];
28653
+ if (callback.onProgress) callback.onProgress(event);
28654
+ }
28655
+
28656
+ controller.enqueue(value);
28657
+ readData();
28658
+ }
28523
28659
  });
28524
- } else {
28525
- response = view.buffer;
28526
28660
  }
28661
+ }
28527
28662
 
28528
- break;
28529
-
28530
- case 'document':
28531
- const parser = new DOMParser();
28532
- response = parser.parseFromString(data, mimeType);
28533
- break;
28534
-
28535
- case 'json':
28536
- response = JSON.parse(data);
28537
- break;
28538
-
28539
- default:
28540
- // 'text' or other
28541
- response = data;
28542
- break;
28543
- } // Wait for next browser tick like standard XMLHttpRequest event dispatching does
28544
-
28545
-
28546
- setTimeout(function () {
28547
- if (onLoad) onLoad(response);
28548
- scope.manager.itemEnd(url);
28549
- }, 0);
28550
- } catch (error) {
28551
- // Wait for next browser tick like standard XMLHttpRequest event dispatching does
28552
- setTimeout(function () {
28553
- if (onError) onError(error);
28554
- scope.manager.itemError(url);
28555
- scope.manager.itemEnd(url);
28556
- }, 0);
28663
+ });
28664
+ } else {
28665
+ throw Error(`fetch for "${response.url}" responded with ${response.status}: ${response.statusText}`);
28557
28666
  }
28558
- } else {
28559
- // Initialise array for duplicate requests
28560
- loading[url] = [];
28561
- loading[url].push({
28562
- onLoad: onLoad,
28563
- onProgress: onProgress,
28564
- onError: onError
28565
- });
28566
- request = new XMLHttpRequest();
28567
- request.open('GET', url, true);
28568
- request.addEventListener('load', function (event) {
28569
- const response = this.response;
28570
- const callbacks = loading[url];
28571
- delete loading[url];
28572
-
28573
- if (this.status === 200 || this.status === 0) {
28574
- // Some browsers return HTTP Status 0 when using non-http protocol
28575
- // e.g. 'file://' or 'data://'. Handle as success.
28576
- if (this.status === 0) console.warn('THREE.FileLoader: HTTP Status 0 received.'); // Add to cache only on HTTP success, so that we do not cache
28577
- // error response bodies as proper responses to requests.
28578
-
28579
- Cache.add(url, response);
28667
+ }).then(stream => {
28668
+ const response = new Response(stream);
28580
28669
 
28581
- for (let i = 0, il = callbacks.length; i < il; i++) {
28582
- const callback = callbacks[i];
28583
- if (callback.onLoad) callback.onLoad(response);
28584
- }
28670
+ switch (this.responseType) {
28671
+ case 'arraybuffer':
28672
+ return response.arrayBuffer();
28585
28673
 
28586
- scope.manager.itemEnd(url);
28587
- } else {
28588
- for (let i = 0, il = callbacks.length; i < il; i++) {
28589
- const callback = callbacks[i];
28590
- if (callback.onError) callback.onError(event);
28591
- }
28674
+ case 'blob':
28675
+ return response.blob();
28592
28676
 
28593
- scope.manager.itemError(url);
28594
- scope.manager.itemEnd(url);
28595
- }
28596
- }, false);
28597
- request.addEventListener('progress', function (event) {
28598
- const callbacks = loading[url];
28599
-
28600
- for (let i = 0, il = callbacks.length; i < il; i++) {
28601
- const callback = callbacks[i];
28602
- if (callback.onProgress) callback.onProgress(event);
28603
- }
28604
- }, false);
28605
- request.addEventListener('error', function (event) {
28606
- const callbacks = loading[url];
28607
- delete loading[url];
28677
+ case 'document':
28678
+ return response.text().then(text => {
28679
+ const parser = new DOMParser();
28680
+ return parser.parseFromString(text, this.mimeType);
28681
+ });
28608
28682
 
28609
- for (let i = 0, il = callbacks.length; i < il; i++) {
28610
- const callback = callbacks[i];
28611
- if (callback.onError) callback.onError(event);
28612
- }
28683
+ case 'json':
28684
+ return response.json();
28613
28685
 
28614
- scope.manager.itemError(url);
28615
- scope.manager.itemEnd(url);
28616
- }, false);
28617
- request.addEventListener('abort', function (event) {
28618
- const callbacks = loading[url];
28619
- delete loading[url];
28686
+ default:
28687
+ return response.text();
28688
+ }
28689
+ }).then(data => {
28690
+ // Add to cache only on HTTP success, so that we do not cache
28691
+ // error response bodies as proper responses to requests.
28692
+ Cache.add(url, data);
28693
+ const callbacks = loading[url];
28694
+ delete loading[url];
28620
28695
 
28621
- for (let i = 0, il = callbacks.length; i < il; i++) {
28622
- const callback = callbacks[i];
28623
- if (callback.onError) callback.onError(event);
28624
- }
28696
+ for (let i = 0, il = callbacks.length; i < il; i++) {
28697
+ const callback = callbacks[i];
28698
+ if (callback.onLoad) callback.onLoad(data);
28699
+ }
28625
28700
 
28626
- scope.manager.itemError(url);
28627
- scope.manager.itemEnd(url);
28628
- }, false);
28629
- if (this.responseType !== undefined) request.responseType = this.responseType;
28630
- if (this.withCredentials !== undefined) request.withCredentials = this.withCredentials;
28631
- if (request.overrideMimeType) request.overrideMimeType(this.mimeType !== undefined ? this.mimeType : 'text/plain');
28701
+ this.manager.itemEnd(url);
28702
+ }).catch(err => {
28703
+ // Abort errors and other errors are handled the same
28704
+ const callbacks = loading[url];
28705
+ delete loading[url];
28632
28706
 
28633
- for (const header in this.requestHeader) {
28634
- request.setRequestHeader(header, this.requestHeader[header]);
28707
+ for (let i = 0, il = callbacks.length; i < il; i++) {
28708
+ const callback = callbacks[i];
28709
+ if (callback.onError) callback.onError(err);
28635
28710
  }
28636
28711
 
28637
- request.send(null);
28638
- }
28639
-
28640
- scope.manager.itemStart(url);
28641
- return request;
28712
+ this.manager.itemError(url);
28713
+ this.manager.itemEnd(url);
28714
+ });
28715
+ this.manager.itemStart(url);
28642
28716
  }
28643
28717
 
28644
28718
  setResponseType(value) {
@@ -28805,21 +28879,24 @@
28805
28879
  const image = createElementNS('img');
28806
28880
 
28807
28881
  function onImageLoad() {
28808
- image.removeEventListener('load', onImageLoad, false);
28809
- image.removeEventListener('error', onImageError, false);
28882
+ removeEventListeners();
28810
28883
  Cache.add(url, this);
28811
28884
  if (onLoad) onLoad(this);
28812
28885
  scope.manager.itemEnd(url);
28813
28886
  }
28814
28887
 
28815
28888
  function onImageError(event) {
28816
- image.removeEventListener('load', onImageLoad, false);
28817
- image.removeEventListener('error', onImageError, false);
28889
+ removeEventListeners();
28818
28890
  if (onError) onError(event);
28819
28891
  scope.manager.itemError(url);
28820
28892
  scope.manager.itemEnd(url);
28821
28893
  }
28822
28894
 
28895
+ function removeEventListeners() {
28896
+ image.removeEventListener('load', onImageLoad, false);
28897
+ image.removeEventListener('error', onImageError, false);
28898
+ }
28899
+
28823
28900
  image.addEventListener('load', onImageLoad, false);
28824
28901
  image.addEventListener('error', onImageError, false);
28825
28902
 
@@ -29631,19 +29708,19 @@
29631
29708
  if (json.roughness !== undefined) material.roughness = json.roughness;
29632
29709
  if (json.metalness !== undefined) material.metalness = json.metalness;
29633
29710
  if (json.sheen !== undefined) material.sheen = json.sheen;
29634
- if (json.sheenTint !== undefined) material.sheenTint = new Color().setHex(json.sheenTint);
29711
+ if (json.sheenColor !== undefined) material.sheenColor = new Color().setHex(json.sheenColor);
29635
29712
  if (json.sheenRoughness !== undefined) material.sheenRoughness = json.sheenRoughness;
29636
29713
  if (json.emissive !== undefined && material.emissive !== undefined) material.emissive.setHex(json.emissive);
29637
29714
  if (json.specular !== undefined && material.specular !== undefined) material.specular.setHex(json.specular);
29638
29715
  if (json.specularIntensity !== undefined) material.specularIntensity = json.specularIntensity;
29639
- if (json.specularTint !== undefined && material.specularTint !== undefined) material.specularTint.setHex(json.specularTint);
29716
+ if (json.specularColor !== undefined && material.specularColor !== undefined) material.specularColor.setHex(json.specularColor);
29640
29717
  if (json.shininess !== undefined) material.shininess = json.shininess;
29641
29718
  if (json.clearcoat !== undefined) material.clearcoat = json.clearcoat;
29642
29719
  if (json.clearcoatRoughness !== undefined) material.clearcoatRoughness = json.clearcoatRoughness;
29643
29720
  if (json.transmission !== undefined) material.transmission = json.transmission;
29644
29721
  if (json.thickness !== undefined) material.thickness = json.thickness;
29645
29722
  if (json.attenuationDistance !== undefined) material.attenuationDistance = json.attenuationDistance;
29646
- if (json.attenuationTint !== undefined && material.attenuationTint !== undefined) material.attenuationTint.setHex(json.attenuationTint);
29723
+ if (json.attenuationColor !== undefined && material.attenuationColor !== undefined) material.attenuationColor.setHex(json.attenuationColor);
29647
29724
  if (json.fog !== undefined) material.fog = json.fog;
29648
29725
  if (json.flatShading !== undefined) material.flatShading = json.flatShading;
29649
29726
  if (json.blending !== undefined) material.blending = json.blending;
@@ -29778,7 +29855,7 @@
29778
29855
  if (json.emissiveIntensity !== undefined) material.emissiveIntensity = json.emissiveIntensity;
29779
29856
  if (json.specularMap !== undefined) material.specularMap = getTexture(json.specularMap);
29780
29857
  if (json.specularIntensityMap !== undefined) material.specularIntensityMap = getTexture(json.specularIntensityMap);
29781
- if (json.specularTintMap !== undefined) material.specularTintMap = getTexture(json.specularTintMap);
29858
+ if (json.specularColorMap !== undefined) material.specularColorMap = getTexture(json.specularColorMap);
29782
29859
  if (json.envMap !== undefined) material.envMap = getTexture(json.envMap);
29783
29860
  if (json.envMapIntensity !== undefined) material.envMapIntensity = json.envMapIntensity;
29784
29861
  if (json.reflectivity !== undefined) material.reflectivity = json.reflectivity;
@@ -29794,6 +29871,8 @@
29794
29871
  if (json.clearcoatNormalScale !== undefined) material.clearcoatNormalScale = new Vector2().fromArray(json.clearcoatNormalScale);
29795
29872
  if (json.transmissionMap !== undefined) material.transmissionMap = getTexture(json.transmissionMap);
29796
29873
  if (json.thicknessMap !== undefined) material.thicknessMap = getTexture(json.thicknessMap);
29874
+ if (json.sheenColorMap !== undefined) material.sheenColorMap = getTexture(json.sheenColorMap);
29875
+ if (json.sheenRoughnessMap !== undefined) material.sheenRoughnessMap = getTexture(json.sheenRoughnessMap);
29797
29876
  return material;
29798
29877
  }
29799
29878
 
@@ -29834,6 +29913,24 @@
29834
29913
  return url.substr(0, index + 1);
29835
29914
  }
29836
29915
 
29916
+ static resolveURL(url, path) {
29917
+ // Invalid URL
29918
+ if (typeof url !== 'string' || url === '') return ''; // Host Relative URL
29919
+
29920
+ if (/^https?:\/\//i.test(path) && /^\//.test(url)) {
29921
+ path = path.replace(/(^https?:\/\/[^\/]+).*/i, '$1');
29922
+ } // Absolute URL http://,https://,//
29923
+
29924
+
29925
+ if (/^(https?:)?\/\//i.test(url)) return url; // Data URI
29926
+
29927
+ if (/^data:.*,.*$/i.test(url)) return url; // Blob URL
29928
+
29929
+ if (/^blob:.*$/i.test(url)) return url; // Relative URL
29930
+
29931
+ return path + url;
29932
+ }
29933
+
29837
29934
  }
29838
29935
 
29839
29936
  class InstancedBufferGeometry extends BufferGeometry {
@@ -30430,6 +30527,7 @@
30430
30527
  if (data.flipY !== undefined) texture.flipY = data.flipY;
30431
30528
  if (data.premultiplyAlpha !== undefined) texture.premultiplyAlpha = data.premultiplyAlpha;
30432
30529
  if (data.unpackAlignment !== undefined) texture.unpackAlignment = data.unpackAlignment;
30530
+ if (data.userData !== undefined) texture.userData = data.userData;
30433
30531
  textures[data.uuid] = texture;
30434
30532
  }
30435
30533
  }
@@ -30875,6 +30973,8 @@
30875
30973
 
30876
30974
  const _eyeLeft = /*@__PURE__*/new Matrix4();
30877
30975
 
30976
+ const _projectionMatrix = /*@__PURE__*/new Matrix4();
30977
+
30878
30978
  class StereoCamera {
30879
30979
  constructor() {
30880
30980
  this.type = 'StereoCamera';
@@ -30911,7 +31011,8 @@
30911
31011
  cache.eyeSep = this.eyeSep; // Off-axis stereoscopic effect based on
30912
31012
  // http://paulbourke.net/stereographics/stereorender/
30913
31013
 
30914
- const projectionMatrix = camera.projectionMatrix.clone();
31014
+ _projectionMatrix.copy(camera.projectionMatrix);
31015
+
30915
31016
  const eyeSepHalf = cache.eyeSep / 2;
30916
31017
  const eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;
30917
31018
  const ymax = cache.near * Math.tan(DEG2RAD * cache.fov * 0.5) / cache.zoom;
@@ -30922,15 +31023,15 @@
30922
31023
 
30923
31024
  xmin = -ymax * cache.aspect + eyeSepOnProjection;
30924
31025
  xmax = ymax * cache.aspect + eyeSepOnProjection;
30925
- projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);
30926
- projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);
30927
- this.cameraL.projectionMatrix.copy(projectionMatrix); // for right eye
31026
+ _projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);
31027
+ _projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);
31028
+ this.cameraL.projectionMatrix.copy(_projectionMatrix); // for right eye
30928
31029
 
30929
31030
  xmin = -ymax * cache.aspect - eyeSepOnProjection;
30930
31031
  xmax = ymax * cache.aspect - eyeSepOnProjection;
30931
- projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);
30932
- projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);
30933
- this.cameraR.projectionMatrix.copy(projectionMatrix);
31032
+ _projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);
31033
+ _projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);
31034
+ this.cameraR.projectionMatrix.copy(_projectionMatrix);
30934
31035
  }
30935
31036
 
30936
31037
  this.cameraL.matrixWorld.copy(camera.matrixWorld).multiply(_eyeLeft);
@@ -33963,28 +34064,6 @@
33963
34064
 
33964
34065
  }
33965
34066
 
33966
- class ImmediateRenderObject extends Object3D {
33967
- constructor(material) {
33968
- super();
33969
- this.material = material;
33970
-
33971
- this.render = function () {};
33972
-
33973
- this.hasPositions = false;
33974
- this.hasNormals = false;
33975
- this.hasColors = false;
33976
- this.hasUvs = false;
33977
- this.positionArray = null;
33978
- this.normalArray = null;
33979
- this.colorArray = null;
33980
- this.uvArray = null;
33981
- this.count = 0;
33982
- }
33983
-
33984
- }
33985
-
33986
- ImmediateRenderObject.prototype.isImmediateRenderObject = true;
33987
-
33988
34067
  const _vector$3 = /*@__PURE__*/new Vector3();
33989
34068
 
33990
34069
  class SpotLightHelper extends Object3D {
@@ -36334,6 +36413,9 @@
36334
36413
  function Font() {
36335
36414
  console.error('THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js');
36336
36415
  }
36416
+ function ImmediateRenderObject() {
36417
+ console.error('THREE.ImmediateRenderObject has been removed.');
36418
+ }
36337
36419
 
36338
36420
  if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
36339
36421
  /* eslint-disable no-undef */
@@ -36558,7 +36640,6 @@
36558
36640
  exports.Loader = Loader;
36559
36641
  exports.LoaderUtils = LoaderUtils;
36560
36642
  exports.LoadingManager = LoadingManager;
36561
- exports.LogLuvEncoding = LogLuvEncoding;
36562
36643
  exports.LoopOnce = LoopOnce;
36563
36644
  exports.LoopPingPong = LoopPingPong;
36564
36645
  exports.LoopRepeat = LoopRepeat;