super-three 0.164.0 → 0.167.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 (416) hide show
  1. package/README.md +3 -3
  2. package/build/three.cjs +1273 -503
  3. package/build/three.module.js +1269 -504
  4. package/build/three.module.min.js +1 -1
  5. package/build/three.webgpu.js +76086 -0
  6. package/build/three.webgpu.min.js +6 -0
  7. package/examples/jsm/Addons.js +2 -1
  8. package/examples/jsm/controls/TransformControls.js +1 -1
  9. package/examples/jsm/csm/CSMShader.js +4 -4
  10. package/examples/jsm/environments/RoomEnvironment.js +1 -5
  11. package/examples/jsm/exporters/GLTFExporter.js +8 -4
  12. package/examples/jsm/exporters/USDZExporter.js +6 -4
  13. package/examples/jsm/geometries/TeapotGeometry.js +1 -1
  14. package/examples/jsm/helpers/ViewHelper.js +75 -61
  15. package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
  16. package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
  17. package/examples/jsm/lines/LineMaterial.js +1 -15
  18. package/examples/jsm/lines/LineSegments2.js +15 -0
  19. package/examples/jsm/lines/Wireframe.js +16 -1
  20. package/examples/jsm/lines/webgpu/Line2.js +20 -0
  21. package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
  22. package/examples/jsm/loaders/DRACOLoader.js +1 -1
  23. package/examples/jsm/loaders/FBXLoader.js +47 -58
  24. package/examples/jsm/loaders/GLTFLoader.js +12 -4
  25. package/examples/jsm/loaders/LDrawLoader.js +3 -2
  26. package/examples/jsm/loaders/MMDLoader.js +31 -12
  27. package/examples/jsm/loaders/MaterialXLoader.js +2 -9
  28. package/examples/jsm/loaders/USDZLoader.js +124 -76
  29. package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
  30. package/examples/jsm/loaders/VTKLoader.js +76 -3
  31. package/examples/jsm/misc/GPUComputationRenderer.js +9 -19
  32. package/examples/jsm/modifiers/CurveModifier.js +11 -9
  33. package/examples/jsm/modifiers/SimplifyModifier.js +2 -1
  34. package/examples/jsm/objects/InstancedPoints.js +2 -2
  35. package/examples/jsm/objects/Lensflare.js +2 -2
  36. package/examples/jsm/postprocessing/RenderPass.js +1 -1
  37. package/examples/jsm/postprocessing/RenderTransitionPass.js +13 -38
  38. package/examples/jsm/postprocessing/SSAOPass.js +6 -9
  39. package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -4
  40. package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
  41. package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
  42. package/examples/jsm/shaders/ColorifyShader.js +1 -2
  43. package/examples/jsm/shaders/FXAAShader.js +0 -2
  44. package/examples/jsm/shaders/GTAOShader.js +1 -1
  45. package/examples/jsm/shaders/LuminosityHighPassShader.js +1 -3
  46. package/examples/jsm/transpiler/GLSLDecoder.js +46 -4
  47. package/examples/jsm/transpiler/TSLEncoder.js +17 -15
  48. package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
  49. package/examples/jsm/utils/GPUStatsPanel.js +2 -0
  50. package/examples/jsm/utils/SortUtils.js +8 -5
  51. package/package.json +9 -7
  52. package/src/Three.WebGPU.js +194 -0
  53. package/src/Three.js +2 -0
  54. package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
  55. package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
  56. package/src/animation/tracks/StringKeyframeTrack.js +10 -1
  57. package/src/constants.js +4 -1
  58. package/src/core/Object3D.js +24 -22
  59. package/src/core/Raycaster.js +6 -2
  60. package/src/extras/TextureUtils.js +210 -0
  61. package/src/lights/Light.js +1 -0
  62. package/src/lights/LightShadow.js +5 -0
  63. package/{examples/jsm/lights → src/lights/webgpu}/IESSpotLight.js +1 -1
  64. package/src/loaders/FileLoader.js +4 -0
  65. package/src/loaders/LoaderUtils.js +3 -1
  66. package/src/loaders/ObjectLoader.js +34 -2
  67. package/src/materials/Material.js +13 -4
  68. package/src/math/Box2.js +4 -4
  69. package/src/math/Box3.js +6 -6
  70. package/src/math/ColorManagement.js +10 -0
  71. package/src/math/Matrix2.js +54 -0
  72. package/src/math/Vector4.js +13 -0
  73. package/{examples/jsm → src}/nodes/Nodes.js +39 -20
  74. package/{examples/jsm → src}/nodes/accessors/BatchNode.js +28 -10
  75. package/src/nodes/accessors/BitangentNode.js +13 -0
  76. package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +36 -1
  77. package/{examples/jsm → src}/nodes/accessors/BufferNode.js +6 -0
  78. package/src/nodes/accessors/CameraNode.js +19 -0
  79. package/{examples/jsm → src}/nodes/accessors/CubeTextureNode.js +22 -5
  80. package/src/nodes/accessors/InstanceNode.js +140 -0
  81. package/{examples/jsm → src}/nodes/accessors/MaterialNode.js +24 -2
  82. package/{examples/jsm → src}/nodes/accessors/ModelNode.js +4 -0
  83. package/{examples/jsm → src}/nodes/accessors/MorphNode.js +24 -20
  84. package/src/nodes/accessors/NormalNode.js +14 -0
  85. package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +1 -1
  86. package/src/nodes/accessors/PositionNode.js +10 -0
  87. package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +7 -1
  88. package/src/nodes/accessors/ReflectVectorNode.js +10 -0
  89. package/{examples/jsm → src}/nodes/accessors/StorageBufferNode.js +50 -1
  90. package/{examples/jsm/nodes/accessors/TextureStoreNode.js → src/nodes/accessors/StorageTextureNode.js} +28 -6
  91. package/src/nodes/accessors/TangentNode.js +23 -0
  92. package/src/nodes/accessors/Texture3DNode.js +100 -0
  93. package/{examples/jsm → src}/nodes/accessors/TextureNode.js +55 -18
  94. package/src/nodes/accessors/UVNode.js +3 -0
  95. package/{examples/jsm → src}/nodes/accessors/UniformsNode.js +7 -1
  96. package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +2 -1
  97. package/{examples/jsm → src}/nodes/code/ScriptableNode.js +14 -0
  98. package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +2 -1
  99. package/{examples/jsm → src}/nodes/core/AttributeNode.js +34 -8
  100. package/{examples/jsm → src}/nodes/core/CacheNode.js +7 -10
  101. package/{examples/jsm → src}/nodes/core/ContextNode.js +6 -0
  102. package/{examples/jsm → src}/nodes/core/IndexNode.js +6 -0
  103. package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
  104. package/src/nodes/core/MRTNode.js +76 -0
  105. package/{examples/jsm → src}/nodes/core/Node.js +33 -14
  106. package/{examples/jsm → src}/nodes/core/NodeBuilder.js +194 -45
  107. package/src/nodes/core/NodeCache.js +36 -0
  108. package/{examples/jsm → src}/nodes/core/NodeFrame.js +42 -0
  109. package/{examples/jsm → src}/nodes/core/NodeFunction.js +2 -2
  110. package/{examples/jsm → src}/nodes/core/NodeKeywords.js +1 -1
  111. package/{examples/jsm → src}/nodes/core/NodeUniform.js +1 -2
  112. package/{examples/jsm → src}/nodes/core/NodeUtils.js +6 -1
  113. package/{examples/jsm → src}/nodes/core/OutputStructNode.js +1 -5
  114. package/{examples/jsm → src}/nodes/core/PropertyNode.js +2 -0
  115. package/{examples/jsm → src}/nodes/core/TempNode.js +2 -2
  116. package/{examples/jsm → src}/nodes/core/UniformGroupNode.js +20 -0
  117. package/{examples/jsm → src}/nodes/core/UniformNode.js +10 -1
  118. package/{examples/jsm → src}/nodes/core/VarNode.js +2 -6
  119. package/src/nodes/core/VaryingNode.js +104 -0
  120. package/{examples/jsm → src}/nodes/display/AfterImageNode.js +24 -20
  121. package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +18 -21
  122. package/src/nodes/display/BloomNode.js +333 -0
  123. package/{examples/jsm → src}/nodes/display/ColorAdjustmentNode.js +7 -2
  124. package/{examples/jsm → src}/nodes/display/ColorSpaceNode.js +1 -1
  125. package/src/nodes/display/DenoiseNode.js +198 -0
  126. package/src/nodes/display/DepthOfFieldNode.js +119 -0
  127. package/src/nodes/display/DotScreenNode.js +75 -0
  128. package/src/nodes/display/FXAANode.js +327 -0
  129. package/src/nodes/display/FilmNode.js +52 -0
  130. package/{examples/jsm → src}/nodes/display/FrontFacingNode.js +2 -1
  131. package/src/nodes/display/GTAONode.js +324 -0
  132. package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +34 -17
  133. package/src/nodes/display/Lut3DNode.js +53 -0
  134. package/{examples/jsm → src}/nodes/display/NormalMapNode.js +1 -1
  135. package/src/nodes/display/PassNode.js +291 -0
  136. package/src/nodes/display/PixelationPassNode.js +201 -0
  137. package/src/nodes/display/RGBShiftNode.js +49 -0
  138. package/src/nodes/display/RenderOutputNode.js +56 -0
  139. package/src/nodes/display/SobelOperatorNode.js +121 -0
  140. package/{examples/jsm → src}/nodes/display/ToneMappingNode.js +44 -5
  141. package/src/nodes/display/TransitionNode.js +76 -0
  142. package/{examples/jsm → src}/nodes/display/ViewportDepthNode.js +39 -16
  143. package/{examples/jsm → src}/nodes/display/ViewportDepthTextureNode.js +2 -1
  144. package/{examples/jsm → src}/nodes/display/ViewportNode.js +3 -2
  145. package/{examples/jsm → src}/nodes/display/ViewportSharedTextureNode.js +2 -1
  146. package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +5 -2
  147. package/src/nodes/functions/BSDF/LTC.js +131 -0
  148. package/src/nodes/functions/BasicLightingModel.js +78 -0
  149. package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +5 -3
  150. package/{examples/jsm → src}/nodes/functions/PhysicalLightingModel.js +103 -18
  151. package/src/nodes/functions/ToonLightingModel.js +51 -0
  152. package/{examples/jsm → src}/nodes/geometry/RangeNode.js +19 -6
  153. package/{examples/jsm → src}/nodes/lighting/AONode.js +1 -4
  154. package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +1 -1
  155. package/src/nodes/lighting/AnalyticLightNode.js +333 -0
  156. package/src/nodes/lighting/BasicEnvironmentNode.js +26 -0
  157. package/src/nodes/lighting/BasicLightMapNode.js +29 -0
  158. package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +2 -3
  159. package/{examples/jsm → src}/nodes/lighting/EnvironmentNode.js +5 -4
  160. package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +2 -1
  161. package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +1 -1
  162. package/{examples/jsm → src}/nodes/lighting/LightingNode.js +2 -0
  163. package/{examples/jsm → src}/nodes/lighting/LightsNode.js +18 -3
  164. package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +2 -3
  165. package/src/nodes/lighting/RectAreaLightNode.js +97 -0
  166. package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +2 -3
  167. package/{examples/jsm → src}/nodes/loaders/NodeLoader.js +3 -1
  168. package/{examples/jsm → src}/nodes/loaders/NodeMaterialLoader.js +2 -1
  169. package/{examples/jsm → src}/nodes/loaders/NodeObjectLoader.js +2 -1
  170. package/{examples/jsm → src}/nodes/materials/InstancedPointsNodeMaterial.js +3 -3
  171. package/{examples/jsm → src}/nodes/materials/Line2NodeMaterial.js +4 -4
  172. package/{examples/jsm → src}/nodes/materials/LineBasicNodeMaterial.js +3 -3
  173. package/{examples/jsm → src}/nodes/materials/LineDashedNodeMaterial.js +4 -3
  174. package/{examples/jsm → src}/nodes/materials/Materials.js +3 -0
  175. package/src/nodes/materials/MeshBasicNodeMaterial.js +73 -0
  176. package/{examples/jsm → src}/nodes/materials/MeshLambertNodeMaterial.js +12 -3
  177. package/src/nodes/materials/MeshMatcapNodeMaterial.js +53 -0
  178. package/{examples/jsm → src}/nodes/materials/MeshNormalNodeMaterial.js +5 -3
  179. package/{examples/jsm → src}/nodes/materials/MeshPhongNodeMaterial.js +11 -3
  180. package/{examples/jsm → src}/nodes/materials/MeshPhysicalNodeMaterial.js +26 -8
  181. package/{examples/jsm → src}/nodes/materials/MeshStandardNodeMaterial.js +14 -3
  182. package/src/nodes/materials/MeshToonNodeMaterial.js +34 -0
  183. package/{examples/jsm → src}/nodes/materials/NodeMaterial.js +97 -24
  184. package/{examples/jsm → src}/nodes/materials/PointsNodeMaterial.js +3 -3
  185. package/{examples/jsm → src}/nodes/materials/ShadowNodeMaterial.js +3 -3
  186. package/{examples/jsm → src}/nodes/materials/SpriteNodeMaterial.js +3 -3
  187. package/src/nodes/materials/VolumeNodeMaterial.js +106 -0
  188. package/{examples/jsm → src}/nodes/materialx/lib/mx_hsv.js +9 -17
  189. package/{examples/jsm → src}/nodes/materialx/lib/mx_noise.js +474 -577
  190. package/{examples/jsm → src}/nodes/materialx/lib/mx_transform_color.js +2 -8
  191. package/{examples/jsm → src}/nodes/math/CondNode.js +13 -6
  192. package/{examples/jsm → src}/nodes/math/HashNode.js +2 -2
  193. package/{examples/jsm → src}/nodes/math/MathNode.js +14 -1
  194. package/{examples/jsm → src}/nodes/math/OperatorNode.js +6 -6
  195. package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
  196. package/{examples/jsm → src}/nodes/pmrem/PMREMNode.js +2 -1
  197. package/{examples/jsm → src}/nodes/shadernode/ShaderNode.js +57 -33
  198. package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +1 -1
  199. package/{examples/jsm → src}/nodes/utils/DiscardNode.js +1 -0
  200. package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +2 -0
  201. package/{examples/jsm → src}/nodes/utils/LoopNode.js +7 -6
  202. package/{examples/jsm → src}/nodes/utils/MatcapUVNode.js +1 -1
  203. package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +8 -2
  204. package/src/nodes/utils/RTTNode.js +130 -0
  205. package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +9 -1
  206. package/{examples/jsm → src}/nodes/utils/TimerNode.js +1 -1
  207. package/src/objects/BatchedMesh.js +232 -162
  208. package/src/objects/InstancedMesh.js +1 -1
  209. package/src/renderers/WebGLRenderer.js +312 -68
  210. package/{examples/jsm → src}/renderers/common/Attributes.js +4 -1
  211. package/{examples/jsm → src}/renderers/common/Backend.js +30 -27
  212. package/{examples/jsm → src}/renderers/common/Background.js +9 -3
  213. package/src/renderers/common/BindGroup.js +16 -0
  214. package/{examples/jsm → src}/renderers/common/Bindings.js +54 -22
  215. package/src/renderers/common/ChainMap.js +59 -0
  216. package/{examples/jsm → src}/renderers/common/ClippingContext.js +8 -6
  217. package/{examples/jsm → src}/renderers/common/Color4.js +1 -1
  218. package/{examples/jsm → src}/renderers/common/CubeRenderTarget.js +7 -1
  219. package/{examples/jsm → src}/renderers/common/Geometries.js +37 -5
  220. package/{examples/jsm → src}/renderers/common/Info.js +34 -6
  221. package/{examples/jsm → src}/renderers/common/Pipelines.js +2 -2
  222. package/src/renderers/common/PostProcessing.js +87 -0
  223. package/{examples/jsm/objects → src/renderers/common}/QuadMesh.js +6 -3
  224. package/src/renderers/common/RenderBundle.js +18 -0
  225. package/src/renderers/common/RenderBundles.js +38 -0
  226. package/{examples/jsm → src}/renderers/common/RenderContext.js +1 -1
  227. package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
  228. package/{examples/jsm → src}/renderers/common/RenderList.js +9 -0
  229. package/{examples/jsm → src}/renderers/common/RenderObject.js +50 -11
  230. package/{examples/jsm → src}/renderers/common/Renderer.js +220 -40
  231. package/{examples/jsm → src}/renderers/common/SampledTexture.js +2 -2
  232. package/{examples/jsm → src}/renderers/common/StorageBufferAttribute.js +1 -1
  233. package/{examples/jsm → src}/renderers/common/StorageInstancedBufferAttribute.js +1 -1
  234. package/{examples/jsm → src}/renderers/common/StorageTexture.js +2 -1
  235. package/{examples/jsm → src}/renderers/common/Textures.js +6 -2
  236. package/{examples/jsm → src}/renderers/common/Uniform.js +10 -5
  237. package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
  238. package/{examples/jsm → src}/renderers/common/extras/PMREMGenerator.js +13 -12
  239. package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
  240. package/{examples/jsm → src}/renderers/common/nodes/NodeSampledTexture.js +19 -4
  241. package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +8 -1
  242. package/{examples/jsm → src}/renderers/common/nodes/NodeStorageBuffer.js +5 -1
  243. package/{examples/jsm → src}/renderers/common/nodes/NodeUniform.js +3 -3
  244. package/{examples/jsm → src}/renderers/common/nodes/NodeUniformBuffer.js +2 -1
  245. package/{examples/jsm → src}/renderers/common/nodes/NodeUniformsGroup.js +2 -8
  246. package/{examples/jsm → src}/renderers/common/nodes/Nodes.js +37 -16
  247. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +31 -1
  248. package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
  249. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
  250. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
  251. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +0 -9
  252. package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -10
  253. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
  254. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
  255. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
  256. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
  257. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
  258. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
  259. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
  260. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +45 -13
  261. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -4
  262. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +3 -0
  263. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +3 -3
  264. package/src/renderers/shaders/ShaderLib/depth.glsl.js +8 -0
  265. package/src/renderers/shaders/UniformsLib.js +3 -0
  266. package/src/renderers/webgl/WebGLAttributes.js +2 -2
  267. package/src/renderers/webgl/WebGLBackground.js +6 -0
  268. package/src/renderers/webgl/WebGLBufferRenderer.js +6 -19
  269. package/src/renderers/webgl/WebGLExtensions.js +3 -1
  270. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +6 -18
  271. package/src/renderers/webgl/WebGLLights.js +15 -12
  272. package/src/renderers/webgl/WebGLMaterials.js +1 -5
  273. package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
  274. package/src/renderers/webgl/WebGLProgram.js +28 -31
  275. package/src/renderers/webgl/WebGLPrograms.js +15 -15
  276. package/src/renderers/webgl/WebGLRenderStates.js +2 -2
  277. package/src/renderers/webgl/WebGLTextures.js +100 -70
  278. package/src/renderers/webgl/WebGLUniforms.js +12 -2
  279. package/src/renderers/webgl/WebGLUniformsGroups.js +7 -7
  280. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +156 -54
  281. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +188 -41
  282. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +2 -2
  283. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +1 -0
  284. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLExtensions.js +2 -0
  285. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLState.js +1 -1
  286. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +126 -7
  287. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +1 -1
  288. package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +212 -78
  289. package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +2 -2
  290. package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +245 -49
  291. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
  292. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
  293. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +30 -14
  294. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +9 -1
  295. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +74 -24
  296. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +101 -25
  297. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +24 -3
  298. package/src/renderers/webxr/WebXRDepthSensing.js +9 -3
  299. package/src/renderers/webxr/WebXRManager.js +12 -2
  300. package/src/textures/CompressedArrayTexture.js +14 -0
  301. package/src/textures/DataArrayTexture.js +14 -0
  302. package/src/textures/DepthTexture.js +1 -3
  303. package/src/utils.js +30 -1
  304. package/examples/jsm/nodes/accessors/BitangentNode.js +0 -89
  305. package/examples/jsm/nodes/accessors/CameraNode.js +0 -119
  306. package/examples/jsm/nodes/accessors/InstanceNode.js +0 -94
  307. package/examples/jsm/nodes/accessors/NormalNode.js +0 -106
  308. package/examples/jsm/nodes/accessors/PositionNode.js +0 -104
  309. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -35
  310. package/examples/jsm/nodes/accessors/TangentNode.js +0 -109
  311. package/examples/jsm/nodes/accessors/UVNode.js +0 -47
  312. package/examples/jsm/nodes/core/NodeCache.js +0 -26
  313. package/examples/jsm/nodes/core/VaryingNode.js +0 -65
  314. package/examples/jsm/nodes/display/PassNode.js +0 -199
  315. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -255
  316. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
  317. package/examples/jsm/renderers/common/ChainMap.js +0 -89
  318. package/examples/jsm/renderers/common/PostProcessing.js +0 -33
  319. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
  320. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
  321. /package/{examples/jsm → src}/nodes/accessors/AccessorsUtils.js +0 -0
  322. /package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +0 -0
  323. /package/{examples/jsm → src}/nodes/accessors/InstancedPointsMaterialNode.js +0 -0
  324. /package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +0 -0
  325. /package/{examples/jsm → src}/nodes/accessors/ModelViewProjectionNode.js +0 -0
  326. /package/{examples/jsm → src}/nodes/accessors/PointUVNode.js +0 -0
  327. /package/{examples/jsm → src}/nodes/accessors/RendererReferenceNode.js +0 -0
  328. /package/{examples/jsm → src}/nodes/accessors/SceneNode.js +0 -0
  329. /package/{examples/jsm → src}/nodes/accessors/SkinningNode.js +0 -0
  330. /package/{examples/jsm → src}/nodes/accessors/TextureBicubicNode.js +0 -0
  331. /package/{examples/jsm → src}/nodes/accessors/TextureSizeNode.js +0 -0
  332. /package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +0 -0
  333. /package/{examples/jsm → src}/nodes/code/CodeNode.js +0 -0
  334. /package/{examples/jsm → src}/nodes/code/ExpressionNode.js +0 -0
  335. /package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +0 -0
  336. /package/{examples/jsm → src}/nodes/code/FunctionNode.js +0 -0
  337. /package/{examples/jsm → src}/nodes/core/AssignNode.js +0 -0
  338. /package/{examples/jsm → src}/nodes/core/BypassNode.js +0 -0
  339. /package/{examples/jsm → src}/nodes/core/ConstNode.js +0 -0
  340. /package/{examples/jsm → src}/nodes/core/InputNode.js +0 -0
  341. /package/{examples/jsm → src}/nodes/core/NodeAttribute.js +0 -0
  342. /package/{examples/jsm → src}/nodes/core/NodeCode.js +0 -0
  343. /package/{examples/jsm → src}/nodes/core/NodeFunctionInput.js +0 -0
  344. /package/{examples/jsm → src}/nodes/core/NodeParser.js +0 -0
  345. /package/{examples/jsm → src}/nodes/core/NodeVar.js +0 -0
  346. /package/{examples/jsm → src}/nodes/core/NodeVarying.js +0 -0
  347. /package/{examples/jsm → src}/nodes/core/ParameterNode.js +0 -0
  348. /package/{examples/jsm → src}/nodes/core/StackNode.js +0 -0
  349. /package/{examples/jsm → src}/nodes/core/StructTypeNode.js +0 -0
  350. /package/{examples/jsm → src}/nodes/core/UniformGroup.js +0 -0
  351. /package/{examples/jsm → src}/nodes/core/constants.js +0 -0
  352. /package/{examples/jsm → src}/nodes/display/BlendModeNode.js +0 -0
  353. /package/{examples/jsm → src}/nodes/display/BumpMapNode.js +0 -0
  354. /package/{examples/jsm → src}/nodes/display/PosterizeNode.js +0 -0
  355. /package/{examples/jsm → src}/nodes/fog/FogExp2Node.js +0 -0
  356. /package/{examples/jsm → src}/nodes/fog/FogNode.js +0 -0
  357. /package/{examples/jsm → src}/nodes/fog/FogRangeNode.js +0 -0
  358. /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_GGX.js +0 -0
  359. /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Lambert.js +0 -0
  360. /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Sheen.js +0 -0
  361. /package/{examples/jsm → src}/nodes/functions/BSDF/DFGApprox.js +0 -0
  362. /package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX.js +0 -0
  363. /package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX_Anisotropic.js +0 -0
  364. /package/{examples/jsm → src}/nodes/functions/BSDF/EnvironmentBRDF.js +0 -0
  365. /package/{examples/jsm → src}/nodes/functions/BSDF/F_Schlick.js +0 -0
  366. /package/{examples/jsm → src}/nodes/functions/BSDF/Schlick_to_F0.js +0 -0
  367. /package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +0 -0
  368. /package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +0 -0
  369. /package/{examples/jsm → src}/nodes/functions/ShadowMaskModel.js +0 -0
  370. /package/{examples/jsm → src}/nodes/functions/material/getGeometryRoughness.js +0 -0
  371. /package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +0 -0
  372. /package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +0 -0
  373. /package/{examples/jsm → src}/nodes/lighting/IrradianceNode.js +0 -0
  374. /package/{examples/jsm → src}/nodes/lighting/LightNode.js +0 -0
  375. /package/{examples/jsm → src}/nodes/lighting/LightUtils.js +0 -0
  376. /package/{examples/jsm → src}/nodes/lighting/LightingContextNode.js +0 -0
  377. /package/{examples/jsm → src}/nodes/materials/MeshSSSNodeMaterial.js +0 -0
  378. /package/{examples/jsm → src}/nodes/materialx/DISCLAIMER.md +0 -0
  379. /package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +0 -0
  380. /package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -0
  381. /package/{examples/jsm → src}/nodes/math/TriNoise3D.js +0 -0
  382. /package/{examples/jsm → src}/nodes/parsers/GLSLNodeParser.js +0 -0
  383. /package/{examples/jsm → src}/nodes/pmrem/PMREMUtils.js +0 -0
  384. /package/{examples/jsm → src}/nodes/procedural/CheckerNode.js +0 -0
  385. /package/{examples/jsm → src}/nodes/utils/ConvertNode.js +0 -0
  386. /package/{examples/jsm → src}/nodes/utils/EquirectUVNode.js +0 -0
  387. /package/{examples/jsm → src}/nodes/utils/JoinNode.js +0 -0
  388. /package/{examples/jsm → src}/nodes/utils/OscNode.js +0 -0
  389. /package/{examples/jsm → src}/nodes/utils/PackingNode.js +0 -0
  390. /package/{examples/jsm → src}/nodes/utils/RemapNode.js +0 -0
  391. /package/{examples/jsm → src}/nodes/utils/RotateNode.js +0 -0
  392. /package/{examples/jsm → src}/nodes/utils/RotateUVNode.js +0 -0
  393. /package/{examples/jsm → src}/nodes/utils/SetNode.js +0 -0
  394. /package/{examples/jsm → src}/nodes/utils/SplitNode.js +0 -0
  395. /package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +0 -0
  396. /package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +0 -0
  397. /package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +0 -0
  398. /package/{examples/jsm → src}/renderers/common/Animation.js +0 -0
  399. /package/{examples/jsm → src}/renderers/common/Binding.js +0 -0
  400. /package/{examples/jsm → src}/renderers/common/Buffer.js +0 -0
  401. /package/{examples/jsm → src}/renderers/common/BufferUtils.js +0 -0
  402. /package/{examples/jsm → src}/renderers/common/ComputePipeline.js +0 -0
  403. /package/{examples/jsm → src}/renderers/common/Constants.js +0 -0
  404. /package/{examples/jsm → src}/renderers/common/DataMap.js +0 -0
  405. /package/{examples/jsm → src}/renderers/common/Pipeline.js +0 -0
  406. /package/{examples/jsm → src}/renderers/common/ProgrammableStage.js +0 -0
  407. /package/{examples/jsm → src}/renderers/common/RenderLists.js +0 -0
  408. /package/{examples/jsm → src}/renderers/common/RenderObjects.js +0 -0
  409. /package/{examples/jsm → src}/renderers/common/RenderPipeline.js +0 -0
  410. /package/{examples/jsm → src}/renderers/common/Sampler.js +0 -0
  411. /package/{examples/jsm → src}/renderers/common/StorageBuffer.js +0 -0
  412. /package/{examples/jsm → src}/renderers/common/UniformBuffer.js +0 -0
  413. /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBufferRenderer.js +0 -0
  414. /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLCapabilities.js +0 -0
  415. /package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeParser.js +0 -0
  416. /package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +0 -0
@@ -3,7 +3,7 @@
3
3
  * Copyright 2010-2024 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
5
  */
6
- const REVISION = '164';
6
+ const REVISION = '167';
7
7
 
8
8
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
9
9
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -108,6 +108,7 @@ const RedFormat = 1028;
108
108
  const RedIntegerFormat = 1029;
109
109
  const RGFormat = 1030;
110
110
  const RGIntegerFormat = 1031;
111
+ const RGBIntegerFormat = 1032;
111
112
  const RGBAIntegerFormat = 1033;
112
113
 
113
114
  const RGB_S3TC_DXT1_Format = 33776;
@@ -158,6 +159,8 @@ const TriangleStripDrawMode = 1;
158
159
  const TriangleFanDrawMode = 2;
159
160
  const BasicDepthPacking = 3200;
160
161
  const RGBADepthPacking = 3201;
162
+ const RGBDepthPacking = 3202;
163
+ const RGDepthPacking = 3203;
161
164
  const TangentSpaceNormalMap = 0;
162
165
  const ObjectSpaceNormalMap = 1;
163
166
 
@@ -1560,6 +1563,35 @@ function warnOnce( message ) {
1560
1563
 
1561
1564
  }
1562
1565
 
1566
+ function probeAsync( gl, sync, interval ) {
1567
+
1568
+ return new Promise( function ( resolve, reject ) {
1569
+
1570
+ function probe() {
1571
+
1572
+ switch ( gl.clientWaitSync( sync, gl.SYNC_FLUSH_COMMANDS_BIT, 0 ) ) {
1573
+
1574
+ case gl.WAIT_FAILED:
1575
+ reject();
1576
+ break;
1577
+
1578
+ case gl.TIMEOUT_EXPIRED:
1579
+ setTimeout( probe, interval );
1580
+ break;
1581
+
1582
+ default:
1583
+ resolve();
1584
+
1585
+ }
1586
+
1587
+ }
1588
+
1589
+ setTimeout( probe, interval );
1590
+
1591
+ } );
1592
+
1593
+ }
1594
+
1563
1595
  /**
1564
1596
  * Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
1565
1597
  * or clipping. Based on W3C specifications for sRGB and Display P3,
@@ -1592,24 +1624,28 @@ const COLOR_SPACES = {
1592
1624
  [ LinearSRGBColorSpace ]: {
1593
1625
  transfer: LinearTransfer,
1594
1626
  primaries: Rec709Primaries,
1627
+ luminanceCoefficients: [ 0.2126, 0.7152, 0.0722 ],
1595
1628
  toReference: ( color ) => color,
1596
1629
  fromReference: ( color ) => color,
1597
1630
  },
1598
1631
  [ SRGBColorSpace ]: {
1599
1632
  transfer: SRGBTransfer,
1600
1633
  primaries: Rec709Primaries,
1634
+ luminanceCoefficients: [ 0.2126, 0.7152, 0.0722 ],
1601
1635
  toReference: ( color ) => color.convertSRGBToLinear(),
1602
1636
  fromReference: ( color ) => color.convertLinearToSRGB(),
1603
1637
  },
1604
1638
  [ LinearDisplayP3ColorSpace ]: {
1605
1639
  transfer: LinearTransfer,
1606
1640
  primaries: P3Primaries,
1641
+ luminanceCoefficients: [ 0.2289, 0.6917, 0.0793 ],
1607
1642
  toReference: ( color ) => color.applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
1608
1643
  fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ),
1609
1644
  },
1610
1645
  [ DisplayP3ColorSpace ]: {
1611
1646
  transfer: SRGBTransfer,
1612
1647
  primaries: P3Primaries,
1648
+ luminanceCoefficients: [ 0.2289, 0.6917, 0.0793 ],
1613
1649
  toReference: ( color ) => color.convertSRGBToLinear().applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
1614
1650
  fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ).convertLinearToSRGB(),
1615
1651
  },
@@ -1682,6 +1718,12 @@ const ColorManagement = {
1682
1718
 
1683
1719
  },
1684
1720
 
1721
+ getLuminanceCoefficients: function ( target, colorSpace = this._workingColorSpace ) {
1722
+
1723
+ return target.fromArray( COLOR_SPACES[ colorSpace ].luminanceCoefficients );
1724
+
1725
+ },
1726
+
1685
1727
  };
1686
1728
 
1687
1729
 
@@ -2663,6 +2705,19 @@ class Vector4 {
2663
2705
 
2664
2706
  }
2665
2707
 
2708
+ setFromMatrixPosition( m ) {
2709
+
2710
+ const e = m.elements;
2711
+
2712
+ this.x = e[ 12 ];
2713
+ this.y = e[ 13 ];
2714
+ this.z = e[ 14 ];
2715
+ this.w = e[ 15 ];
2716
+
2717
+ return this;
2718
+
2719
+ }
2720
+
2666
2721
  min( v ) {
2667
2722
 
2668
2723
  this.x = Math.min( this.x, v.x );
@@ -3077,6 +3132,20 @@ class DataArrayTexture extends Texture {
3077
3132
  this.flipY = false;
3078
3133
  this.unpackAlignment = 1;
3079
3134
 
3135
+ this.layerUpdates = new Set();
3136
+
3137
+ }
3138
+
3139
+ addLayerUpdate( layerIndex ) {
3140
+
3141
+ this.layerUpdates.add( layerIndex );
3142
+
3143
+ }
3144
+
3145
+ clearLayerUpdates() {
3146
+
3147
+ this.layerUpdates.clear();
3148
+
3080
3149
  }
3081
3150
 
3082
3151
  }
@@ -4789,9 +4858,9 @@ class Box3 {
4789
4858
 
4790
4859
  containsPoint( point ) {
4791
4860
 
4792
- return point.x < this.min.x || point.x > this.max.x ||
4793
- point.y < this.min.y || point.y > this.max.y ||
4794
- point.z < this.min.z || point.z > this.max.z ? false : true;
4861
+ return point.x >= this.min.x && point.x <= this.max.x &&
4862
+ point.y >= this.min.y && point.y <= this.max.y &&
4863
+ point.z >= this.min.z && point.z <= this.max.z;
4795
4864
 
4796
4865
  }
4797
4866
 
@@ -4819,9 +4888,9 @@ class Box3 {
4819
4888
  intersectsBox( box ) {
4820
4889
 
4821
4890
  // using 6 splitting planes to rule out intersections.
4822
- return box.max.x < this.min.x || box.min.x > this.max.x ||
4823
- box.max.y < this.min.y || box.min.y > this.max.y ||
4824
- box.max.z < this.min.z || box.min.z > this.max.z ? false : true;
4891
+ return box.max.x >= this.min.x && box.min.x <= this.max.x &&
4892
+ box.max.y >= this.min.y && box.min.y <= this.max.y &&
4893
+ box.max.z >= this.min.z && box.min.z <= this.max.z;
4825
4894
 
4826
4895
  }
4827
4896
 
@@ -4895,14 +4964,14 @@ class Box3 {
4895
4964
  _extents.subVectors( this.max, _center );
4896
4965
 
4897
4966
  // translate triangle to aabb origin
4898
- _v0$2.subVectors( triangle.a, _center );
4967
+ _v0$3.subVectors( triangle.a, _center );
4899
4968
  _v1$7.subVectors( triangle.b, _center );
4900
4969
  _v2$4.subVectors( triangle.c, _center );
4901
4970
 
4902
4971
  // compute edge vectors for triangle
4903
- _f0.subVectors( _v1$7, _v0$2 );
4972
+ _f0.subVectors( _v1$7, _v0$3 );
4904
4973
  _f1.subVectors( _v2$4, _v1$7 );
4905
- _f2.subVectors( _v0$2, _v2$4 );
4974
+ _f2.subVectors( _v0$3, _v2$4 );
4906
4975
 
4907
4976
  // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
4908
4977
  // make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation
@@ -4912,7 +4981,7 @@ class Box3 {
4912
4981
  _f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x,
4913
4982
  - _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0
4914
4983
  ];
4915
- if ( ! satForAxes( axes, _v0$2, _v1$7, _v2$4, _extents ) ) {
4984
+ if ( ! satForAxes( axes, _v0$3, _v1$7, _v2$4, _extents ) ) {
4916
4985
 
4917
4986
  return false;
4918
4987
 
@@ -4920,7 +4989,7 @@ class Box3 {
4920
4989
 
4921
4990
  // test 3 face normals from the aabb
4922
4991
  axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];
4923
- if ( ! satForAxes( axes, _v0$2, _v1$7, _v2$4, _extents ) ) {
4992
+ if ( ! satForAxes( axes, _v0$3, _v1$7, _v2$4, _extents ) ) {
4924
4993
 
4925
4994
  return false;
4926
4995
 
@@ -4931,7 +5000,7 @@ class Box3 {
4931
5000
  _triangleNormal.crossVectors( _f0, _f1 );
4932
5001
  axes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ];
4933
5002
 
4934
- return satForAxes( axes, _v0$2, _v1$7, _v2$4, _extents );
5003
+ return satForAxes( axes, _v0$3, _v1$7, _v2$4, _extents );
4935
5004
 
4936
5005
  }
4937
5006
 
@@ -5041,7 +5110,7 @@ const _box$4 = /*@__PURE__*/ new Box3();
5041
5110
 
5042
5111
  // triangle centered vertices
5043
5112
 
5044
- const _v0$2 = /*@__PURE__*/ new Vector3();
5113
+ const _v0$3 = /*@__PURE__*/ new Vector3();
5045
5114
  const _v1$7 = /*@__PURE__*/ new Vector3();
5046
5115
  const _v2$4 = /*@__PURE__*/ new Vector3();
5047
5116
 
@@ -7674,13 +7743,17 @@ class Object3D extends EventDispatcher {
7674
7743
 
7675
7744
  if ( this.matrixWorldNeedsUpdate || force ) {
7676
7745
 
7677
- if ( this.parent === null ) {
7746
+ if ( this.matrixWorldAutoUpdate === true ) {
7678
7747
 
7679
- this.matrixWorld.copy( this.matrix );
7748
+ if ( this.parent === null ) {
7680
7749
 
7681
- } else {
7750
+ this.matrixWorld.copy( this.matrix );
7682
7751
 
7683
- this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
7752
+ } else {
7753
+
7754
+ this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
7755
+
7756
+ }
7684
7757
 
7685
7758
  }
7686
7759
 
@@ -7690,7 +7763,7 @@ class Object3D extends EventDispatcher {
7690
7763
 
7691
7764
  }
7692
7765
 
7693
- // update children
7766
+ // make sure descendants are updated if required
7694
7767
 
7695
7768
  const children = this.children;
7696
7769
 
@@ -7698,11 +7771,7 @@ class Object3D extends EventDispatcher {
7698
7771
 
7699
7772
  const child = children[ i ];
7700
7773
 
7701
- if ( child.matrixWorldAutoUpdate === true || force === true ) {
7702
-
7703
- child.updateMatrixWorld( force );
7704
-
7705
- }
7774
+ child.updateMatrixWorld( force );
7706
7775
 
7707
7776
  }
7708
7777
 
@@ -7712,7 +7781,7 @@ class Object3D extends EventDispatcher {
7712
7781
 
7713
7782
  const parent = this.parent;
7714
7783
 
7715
- if ( updateParents === true && parent !== null && parent.matrixWorldAutoUpdate === true ) {
7784
+ if ( updateParents === true && parent !== null ) {
7716
7785
 
7717
7786
  parent.updateWorldMatrix( true, false );
7718
7787
 
@@ -7720,17 +7789,21 @@ class Object3D extends EventDispatcher {
7720
7789
 
7721
7790
  if ( this.matrixAutoUpdate ) this.updateMatrix();
7722
7791
 
7723
- if ( this.parent === null ) {
7792
+ if ( this.matrixWorldAutoUpdate === true ) {
7793
+
7794
+ if ( this.parent === null ) {
7724
7795
 
7725
- this.matrixWorld.copy( this.matrix );
7796
+ this.matrixWorld.copy( this.matrix );
7726
7797
 
7727
- } else {
7798
+ } else {
7728
7799
 
7729
- this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
7800
+ this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
7801
+
7802
+ }
7730
7803
 
7731
7804
  }
7732
7805
 
7733
- // update children
7806
+ // make sure descendants are updated
7734
7807
 
7735
7808
  if ( updateChildren === true ) {
7736
7809
 
@@ -7740,11 +7813,7 @@ class Object3D extends EventDispatcher {
7740
7813
 
7741
7814
  const child = children[ i ];
7742
7815
 
7743
- if ( child.matrixWorldAutoUpdate === true ) {
7744
-
7745
- child.updateWorldMatrix( false, true );
7746
-
7747
- }
7816
+ child.updateWorldMatrix( false, true );
7748
7817
 
7749
7818
  }
7750
7819
 
@@ -7837,7 +7906,7 @@ class Object3D extends EventDispatcher {
7837
7906
  sphereCenter: bound.sphere.center.toArray()
7838
7907
  } ) );
7839
7908
 
7840
- object.maxGeometryCount = this._maxGeometryCount;
7909
+ object.maxInstanceCount = this._maxInstanceCount;
7841
7910
  object.maxVertexCount = this._maxVertexCount;
7842
7911
  object.maxIndexCount = this._maxIndexCount;
7843
7912
 
@@ -7846,6 +7915,8 @@ class Object3D extends EventDispatcher {
7846
7915
 
7847
7916
  object.matricesTexture = this._matricesTexture.toJSON( meta );
7848
7917
 
7918
+ if ( this._colorsTexture !== null ) object.colorsTexture = this._colorsTexture.toJSON( meta );
7919
+
7849
7920
  if ( this.boundingSphere !== null ) {
7850
7921
 
7851
7922
  object.boundingSphere = {
@@ -8104,7 +8175,7 @@ Object3D.DEFAULT_UP = /*@__PURE__*/ new Vector3( 0, 1, 0 );
8104
8175
  Object3D.DEFAULT_MATRIX_AUTO_UPDATE = true;
8105
8176
  Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = true;
8106
8177
 
8107
- const _v0$1 = /*@__PURE__*/ new Vector3();
8178
+ const _v0$2 = /*@__PURE__*/ new Vector3();
8108
8179
  const _v1$3 = /*@__PURE__*/ new Vector3();
8109
8180
  const _v2$2 = /*@__PURE__*/ new Vector3();
8110
8181
  const _v3$2 = /*@__PURE__*/ new Vector3();
@@ -8129,8 +8200,8 @@ class Triangle {
8129
8200
  static getNormal( a, b, c, target ) {
8130
8201
 
8131
8202
  target.subVectors( c, b );
8132
- _v0$1.subVectors( a, b );
8133
- target.cross( _v0$1 );
8203
+ _v0$2.subVectors( a, b );
8204
+ target.cross( _v0$2 );
8134
8205
 
8135
8206
  const targetLengthSq = target.lengthSq();
8136
8207
  if ( targetLengthSq > 0 ) {
@@ -8147,13 +8218,13 @@ class Triangle {
8147
8218
  // based on: http://www.blackpawn.com/texts/pointinpoly/default.html
8148
8219
  static getBarycoord( point, a, b, c, target ) {
8149
8220
 
8150
- _v0$1.subVectors( c, a );
8221
+ _v0$2.subVectors( c, a );
8151
8222
  _v1$3.subVectors( b, a );
8152
8223
  _v2$2.subVectors( point, a );
8153
8224
 
8154
- const dot00 = _v0$1.dot( _v0$1 );
8155
- const dot01 = _v0$1.dot( _v1$3 );
8156
- const dot02 = _v0$1.dot( _v2$2 );
8225
+ const dot00 = _v0$2.dot( _v0$2 );
8226
+ const dot01 = _v0$2.dot( _v1$3 );
8227
+ const dot02 = _v0$2.dot( _v2$2 );
8157
8228
  const dot11 = _v1$3.dot( _v1$3 );
8158
8229
  const dot12 = _v1$3.dot( _v2$2 );
8159
8230
 
@@ -8212,11 +8283,11 @@ class Triangle {
8212
8283
 
8213
8284
  static isFrontFacing( a, b, c, direction ) {
8214
8285
 
8215
- _v0$1.subVectors( c, b );
8286
+ _v0$2.subVectors( c, b );
8216
8287
  _v1$3.subVectors( a, b );
8217
8288
 
8218
8289
  // strictly front facing
8219
- return ( _v0$1.cross( _v1$3 ).dot( direction ) < 0 ) ? true : false;
8290
+ return ( _v0$2.cross( _v1$3 ).dot( direction ) < 0 ) ? true : false;
8220
8291
 
8221
8292
  }
8222
8293
 
@@ -8268,10 +8339,10 @@ class Triangle {
8268
8339
 
8269
8340
  getArea() {
8270
8341
 
8271
- _v0$1.subVectors( this.c, this.b );
8342
+ _v0$2.subVectors( this.c, this.b );
8272
8343
  _v1$3.subVectors( this.a, this.b );
8273
8344
 
8274
- return _v0$1.cross( _v1$3 ).length() * 0.5;
8345
+ return _v0$2.cross( _v1$3 ).length() * 0.5;
8275
8346
 
8276
8347
  }
8277
8348
 
@@ -9127,10 +9198,6 @@ class Material extends EventDispatcher {
9127
9198
 
9128
9199
  }
9129
9200
 
9130
- onBuild( /* shaderobject, renderer */ ) {}
9131
-
9132
- onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {}
9133
-
9134
9201
  onBeforeCompile( /* shaderobject, renderer */ ) {}
9135
9202
 
9136
9203
  customProgramCacheKey() {
@@ -9547,6 +9614,19 @@ class Material extends EventDispatcher {
9547
9614
 
9548
9615
  }
9549
9616
 
9617
+ onBuild( /* shaderobject, renderer */ ) {
9618
+
9619
+ console.warn( 'Material: onBuild() has been removed.' ); // @deprecated, r166
9620
+
9621
+ }
9622
+
9623
+ onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {
9624
+
9625
+ console.warn( 'Material: onBeforeRender() has been removed.' ); // @deprecated, r166
9626
+
9627
+ }
9628
+
9629
+
9550
9630
  }
9551
9631
 
9552
9632
  class MeshBasicMaterial extends Material {
@@ -13595,6 +13675,8 @@ function WebGLAttributes( gl ) {
13595
13675
 
13596
13676
  function update( attribute, bufferType ) {
13597
13677
 
13678
+ if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
13679
+
13598
13680
  if ( attribute.isGLBufferAttribute ) {
13599
13681
 
13600
13682
  const cached = buffers.get( attribute );
@@ -13614,8 +13696,6 @@ function WebGLAttributes( gl ) {
13614
13696
 
13615
13697
  }
13616
13698
 
13617
- if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
13618
-
13619
13699
  const data = buffers.get( attribute );
13620
13700
 
13621
13701
  if ( data === undefined ) {
@@ -13758,9 +13838,9 @@ var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D(
13758
13838
 
13759
13839
  var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
13760
13840
 
13761
- var batching_pars_vertex = "#ifdef USE_BATCHING\n\tattribute float batchId;\n\tuniform highp sampler2D batchingTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif";
13841
+ var batching_pars_vertex = "#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif";
13762
13842
 
13763
- var batching_vertex = "#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif";
13843
+ var batching_vertex = "#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif";
13764
13844
 
13765
13845
  var begin_vertex = "vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif";
13766
13846
 
@@ -13784,11 +13864,11 @@ var color_fragment = "#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\
13784
13864
 
13785
13865
  var color_pars_fragment = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif";
13786
13866
 
13787
- var color_pars_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif";
13867
+ var color_pars_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif";
13788
13868
 
13789
- var color_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif";
13869
+ var color_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif";
13790
13870
 
13791
- var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated";
13871
+ var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated";
13792
13872
 
13793
13873
  var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif";
13794
13874
 
@@ -13804,7 +13884,7 @@ var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emi
13804
13884
 
13805
13885
  var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
13806
13886
 
13807
- var colorspace_pars_fragment = "\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\n}";
13887
+ var colorspace_pars_fragment = "\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}";
13808
13888
 
13809
13889
  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, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
13810
13890
 
@@ -13832,7 +13912,7 @@ var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor
13832
13912
 
13833
13913
  var lights_lambert_pars_fragment = "varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert";
13834
13914
 
13835
- var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif";
13915
+ var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif";
13836
13916
 
13837
13917
  var envmap_physical_pars_fragment = "#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif";
13838
13918
 
@@ -13848,7 +13928,7 @@ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColo
13848
13928
 
13849
13929
  var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
13850
13930
 
13851
- var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
13931
+ var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
13852
13932
 
13853
13933
  var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif";
13854
13934
 
@@ -13874,15 +13954,15 @@ var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_META
13874
13954
 
13875
13955
  var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif";
13876
13956
 
13877
- var morphinstance_vertex = "#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[MORPHTARGETS_COUNT];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif";
13957
+ var morphinstance_vertex = "#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif";
13878
13958
 
13879
- var morphcolor_vertex = "#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif";
13959
+ var morphcolor_vertex = "#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif";
13880
13960
 
13881
- var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif";
13961
+ var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif";
13882
13962
 
13883
- var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t#endif\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\t#ifndef USE_INSTANCING_MORPH\n\t\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\t#endif\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif";
13963
+ var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif";
13884
13964
 
13885
- var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif";
13965
+ var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif";
13886
13966
 
13887
13967
  var normal_fragment_begin = "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;";
13888
13968
 
@@ -13906,7 +13986,7 @@ var iridescence_pars_fragment = "#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D
13906
13986
 
13907
13987
  var opaque_fragment = "#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );";
13908
13988
 
13909
- var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}";
13989
+ var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}";
13910
13990
 
13911
13991
  var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif";
13912
13992
 
@@ -13920,13 +14000,13 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
13920
14000
 
13921
14001
  var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
13922
14002
 
13923
- var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n#endif";
14003
+ var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif";
13924
14004
 
13925
- var shadowmap_pars_vertex = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif";
14005
+ var shadowmap_pars_vertex = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif";
13926
14006
 
13927
14007
  var shadowmap_vertex = "#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif";
13928
14008
 
13929
- var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}";
14009
+ var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}";
13930
14010
 
13931
14011
  var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
13932
14012
 
@@ -13970,7 +14050,7 @@ const fragment$f = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform fl
13970
14050
 
13971
14051
  const vertex$e = "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\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\tvHighPrecisionZW = gl_Position.zw;\n}";
13972
14052
 
13973
- const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}";
14053
+ const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}";
13974
14054
 
13975
14055
  const vertex$d = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\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 <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}";
13976
14056
 
@@ -14297,6 +14377,7 @@ const UniformsLib = {
14297
14377
  } },
14298
14378
 
14299
14379
  directionalLightShadows: { value: [], properties: {
14380
+ shadowIntensity: 1,
14300
14381
  shadowBias: {},
14301
14382
  shadowNormalBias: {},
14302
14383
  shadowRadius: {},
@@ -14317,6 +14398,7 @@ const UniformsLib = {
14317
14398
  } },
14318
14399
 
14319
14400
  spotLightShadows: { value: [], properties: {
14401
+ shadowIntensity: 1,
14320
14402
  shadowBias: {},
14321
14403
  shadowNormalBias: {},
14322
14404
  shadowRadius: {},
@@ -14335,6 +14417,7 @@ const UniformsLib = {
14335
14417
  } },
14336
14418
 
14337
14419
  pointLightShadows: { value: [], properties: {
14420
+ shadowIntensity: 1,
14338
14421
  shadowBias: {},
14339
14422
  shadowNormalBias: {},
14340
14423
  shadowRadius: {},
@@ -14807,6 +14890,12 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
14807
14890
 
14808
14891
  if ( renderer.autoClear || forceClear ) {
14809
14892
 
14893
+ // buffers might not be writable which is required to ensure a correct clear
14894
+
14895
+ state.buffers.depth.setTest( true );
14896
+ state.buffers.depth.setMask( true );
14897
+ state.buffers.color.setMask( true );
14898
+
14810
14899
  renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
14811
14900
 
14812
14901
  }
@@ -15627,30 +15716,17 @@ function WebGLBufferRenderer( gl, extensions, info ) {
15627
15716
  if ( drawCount === 0 ) return;
15628
15717
 
15629
15718
  const extension = extensions.get( 'WEBGL_multi_draw' );
15719
+ extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
15630
15720
 
15631
- if ( extension === null ) {
15632
-
15633
- for ( let i = 0; i < drawCount; i ++ ) {
15634
-
15635
- this.render( starts[ i ], counts[ i ] );
15636
-
15637
- }
15638
-
15639
- } else {
15721
+ let elementCount = 0;
15722
+ for ( let i = 0; i < drawCount; i ++ ) {
15640
15723
 
15641
- extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
15642
-
15643
- let elementCount = 0;
15644
- for ( let i = 0; i < drawCount; i ++ ) {
15645
-
15646
- elementCount += counts[ i ];
15647
-
15648
- }
15649
-
15650
- info.update( elementCount, mode, 1 );
15724
+ elementCount += counts[ i ];
15651
15725
 
15652
15726
  }
15653
15727
 
15728
+ info.update( elementCount, mode, 1 );
15729
+
15654
15730
  }
15655
15731
 
15656
15732
  function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
@@ -17320,7 +17396,7 @@ function WebGLExtensions( gl ) {
17320
17396
 
17321
17397
  if ( extension === null ) {
17322
17398
 
17323
- console.warn( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );
17399
+ warnOnce( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );
17324
17400
 
17325
17401
  }
17326
17402
 
@@ -17580,29 +17656,17 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
17580
17656
  if ( drawCount === 0 ) return;
17581
17657
 
17582
17658
  const extension = extensions.get( 'WEBGL_multi_draw' );
17659
+ extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
17583
17660
 
17584
- if ( extension === null ) {
17585
-
17586
- for ( let i = 0; i < drawCount; i ++ ) {
17587
-
17588
- this.render( starts[ i ] / bytesPerElement, counts[ i ] );
17589
-
17590
- }
17591
-
17592
- } else {
17593
-
17594
- extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
17595
-
17596
- let elementCount = 0;
17597
- for ( let i = 0; i < drawCount; i ++ ) {
17661
+ let elementCount = 0;
17662
+ for ( let i = 0; i < drawCount; i ++ ) {
17598
17663
 
17599
- elementCount += counts[ i ];
17664
+ elementCount += counts[ i ];
17600
17665
 
17601
- }
17666
+ }
17602
17667
 
17603
- info.update( elementCount, mode, 1 );
17668
+ info.update( elementCount, mode, 1 );
17604
17669
 
17605
- }
17606
17670
 
17607
17671
  }
17608
17672
 
@@ -17730,8 +17794,7 @@ function WebGLMorphtargets( gl, capabilities, textures ) {
17730
17794
 
17731
17795
  const objectInfluences = object.morphTargetInfluences;
17732
17796
 
17733
- // instead of using attributes, the WebGL 2 code path encodes morph targets
17734
- // into an array of data textures. Each layer represents a single morph target.
17797
+ // the following encodes morph targets into an array of data textures. Each layer represents a single morph target.
17735
17798
 
17736
17799
  const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
17737
17800
  const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
@@ -18072,9 +18135,7 @@ function WebGLObjects( gl, geometries, attributes, info ) {
18072
18135
 
18073
18136
  class DepthTexture extends Texture {
18074
18137
 
18075
- constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
18076
-
18077
- format = format !== undefined ? format : DepthFormat;
18138
+ constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format = DepthFormat ) {
18078
18139
 
18079
18140
  if ( format !== DepthFormat && format !== DepthStencilFormat ) {
18080
18141
 
@@ -18171,7 +18232,6 @@ class DepthTexture extends Texture {
18171
18232
  const emptyTexture = /*@__PURE__*/ new Texture();
18172
18233
 
18173
18234
  const emptyShadowTexture = /*@__PURE__*/ new DepthTexture( 1, 1 );
18174
- emptyShadowTexture.compareFunction = LessEqualCompare;
18175
18235
 
18176
18236
  const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture();
18177
18237
  const empty3dTexture = /*@__PURE__*/ new Data3DTexture();
@@ -18689,7 +18749,18 @@ function setValueT1( gl, v, textures ) {
18689
18749
 
18690
18750
  }
18691
18751
 
18692
- const emptyTexture2D = ( this.type === gl.SAMPLER_2D_SHADOW ) ? emptyShadowTexture : emptyTexture;
18752
+ let emptyTexture2D;
18753
+
18754
+ if ( this.type === gl.SAMPLER_2D_SHADOW ) {
18755
+
18756
+ emptyShadowTexture.compareFunction = LessEqualCompare; // #28670
18757
+ emptyTexture2D = emptyShadowTexture;
18758
+
18759
+ } else {
18760
+
18761
+ emptyTexture2D = emptyTexture;
18762
+
18763
+ }
18693
18764
 
18694
18765
  textures.setTexture2D( v || emptyTexture2D, unit );
18695
18766
 
@@ -19422,6 +19493,30 @@ function getToneMappingFunction( functionName, toneMapping ) {
19422
19493
 
19423
19494
  }
19424
19495
 
19496
+ const _v0$1 = /*@__PURE__*/ new Vector3();
19497
+
19498
+ function getLuminanceFunction() {
19499
+
19500
+ ColorManagement.getLuminanceCoefficients( _v0$1 );
19501
+
19502
+ const r = _v0$1.x.toFixed( 4 );
19503
+ const g = _v0$1.y.toFixed( 4 );
19504
+ const b = _v0$1.z.toFixed( 4 );
19505
+
19506
+ return [
19507
+
19508
+ 'float luminance( const in vec3 rgb ) {',
19509
+
19510
+ ` const vec3 weights = vec3( ${ r }, ${ g }, ${ b } );`,
19511
+
19512
+ ' return dot( weights, rgb );',
19513
+
19514
+ '}'
19515
+
19516
+ ].join( '\n' );
19517
+
19518
+ }
19519
+
19425
19520
  function generateVertexExtensions( parameters ) {
19426
19521
 
19427
19522
  const chunks = [
@@ -19804,6 +19899,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19804
19899
 
19805
19900
  parameters.extensionClipCullDistance ? '#define USE_CLIP_DISTANCE' : '',
19806
19901
  parameters.batching ? '#define USE_BATCHING' : '',
19902
+ parameters.batchingColor ? '#define USE_BATCHING_COLOR' : '',
19807
19903
  parameters.instancing ? '#define USE_INSTANCING' : '',
19808
19904
  parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '',
19809
19905
  parameters.instancingMorph ? '#define USE_INSTANCING_MORPH' : '',
@@ -19900,7 +19996,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19900
19996
  parameters.morphTargets ? '#define USE_MORPHTARGETS' : '',
19901
19997
  parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',
19902
19998
  ( parameters.morphColors ) ? '#define USE_MORPHCOLORS' : '',
19903
- ( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE' : '',
19904
19999
  ( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + parameters.morphTextureStride : '',
19905
20000
  ( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '',
19906
20001
  parameters.doubleSided ? '#define DOUBLE_SIDED' : '',
@@ -19913,8 +20008,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19913
20008
 
19914
20009
  parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
19915
20010
 
19916
- parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
19917
-
19918
20011
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
19919
20012
 
19920
20013
  'uniform mat4 modelMatrix;',
@@ -19981,31 +20074,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19981
20074
 
19982
20075
  '#endif',
19983
20076
 
19984
- '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )',
19985
-
19986
- ' attribute vec3 morphTarget0;',
19987
- ' attribute vec3 morphTarget1;',
19988
- ' attribute vec3 morphTarget2;',
19989
- ' attribute vec3 morphTarget3;',
19990
-
19991
- ' #ifdef USE_MORPHNORMALS',
19992
-
19993
- ' attribute vec3 morphNormal0;',
19994
- ' attribute vec3 morphNormal1;',
19995
- ' attribute vec3 morphNormal2;',
19996
- ' attribute vec3 morphNormal3;',
19997
-
19998
- ' #else',
19999
-
20000
- ' attribute vec3 morphTarget4;',
20001
- ' attribute vec3 morphTarget5;',
20002
- ' attribute vec3 morphTarget6;',
20003
- ' attribute vec3 morphTarget7;',
20004
-
20005
- ' #endif',
20006
-
20007
- '#endif',
20008
-
20009
20077
  '#ifdef USE_SKINNING',
20010
20078
 
20011
20079
  ' attribute vec4 skinIndex;',
@@ -20081,7 +20149,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20081
20149
  parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '',
20082
20150
 
20083
20151
  parameters.vertexTangents && parameters.flatShading === false ? '#define USE_TANGENT' : '',
20084
- parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '',
20152
+ parameters.vertexColors || parameters.instancingColor || parameters.batchingColor ? '#define USE_COLOR' : '',
20085
20153
  parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',
20086
20154
  parameters.vertexUv1s ? '#define USE_UV1' : '',
20087
20155
  parameters.vertexUv2s ? '#define USE_UV2' : '',
@@ -20103,8 +20171,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20103
20171
 
20104
20172
  parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
20105
20173
 
20106
- parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
20107
-
20108
20174
  parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
20109
20175
 
20110
20176
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
@@ -20122,6 +20188,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20122
20188
 
20123
20189
  ShaderChunk[ 'colorspace_pars_fragment' ], // this code is required here because it is used by the various encoding/decoding function defined below
20124
20190
  getTexelEncodingFunction( 'linearToOutputTexel', parameters.outputColorSpace ),
20191
+ getLuminanceFunction(),
20125
20192
 
20126
20193
  parameters.useDepthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '',
20127
20194
 
@@ -20727,6 +20794,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20727
20794
  precision: precision,
20728
20795
 
20729
20796
  batching: IS_BATCHEDMESH,
20797
+ batchingColor: IS_BATCHEDMESH && object._colorsTexture !== null,
20730
20798
  instancing: IS_INSTANCEDMESH,
20731
20799
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
20732
20800
  instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
@@ -20872,7 +20940,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20872
20940
  shadowMapType: renderer.shadowMap.type,
20873
20941
 
20874
20942
  toneMapping: toneMapping,
20875
- useLegacyLights: renderer._useLegacyLights,
20876
20943
 
20877
20944
  decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( ColorManagement.getTransfer( material.map.colorSpace ) === SRGBTransfer ),
20878
20945
 
@@ -20887,7 +20954,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20887
20954
  index0AttributeName: material.index0AttributeName,
20888
20955
 
20889
20956
  extensionClipCullDistance: HAS_EXTENSIONS && material.extensions.clipCullDistance === true && extensions.has( 'WEBGL_clip_cull_distance' ),
20890
- extensionMultiDraw: HAS_EXTENSIONS && material.extensions.multiDraw === true && extensions.has( 'WEBGL_multi_draw' ),
20957
+ extensionMultiDraw: ( HAS_EXTENSIONS && material.extensions.multiDraw === true || IS_BATCHEDMESH ) && extensions.has( 'WEBGL_multi_draw' ),
20891
20958
 
20892
20959
  rendererExtensionParallelShaderCompile: extensions.has( 'KHR_parallel_shader_compile' ),
20893
20960
 
@@ -21046,6 +21113,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
21046
21113
  _programLayers.enable( 19 );
21047
21114
  if ( parameters.dispersion )
21048
21115
  _programLayers.enable( 20 );
21116
+ if ( parameters.batchingColor )
21117
+ _programLayers.enable( 21 );
21049
21118
 
21050
21119
  array.push( _programLayers.mask );
21051
21120
  _programLayers.disableAll();
@@ -21070,30 +21139,28 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
21070
21139
  _programLayers.enable( 8 );
21071
21140
  if ( parameters.shadowMapEnabled )
21072
21141
  _programLayers.enable( 9 );
21073
- if ( parameters.useLegacyLights )
21074
- _programLayers.enable( 10 );
21075
21142
  if ( parameters.doubleSided )
21076
- _programLayers.enable( 11 );
21143
+ _programLayers.enable( 10 );
21077
21144
  if ( parameters.flipSided )
21078
- _programLayers.enable( 12 );
21145
+ _programLayers.enable( 11 );
21079
21146
  if ( parameters.useDepthPacking )
21080
- _programLayers.enable( 13 );
21147
+ _programLayers.enable( 12 );
21081
21148
  if ( parameters.dithering )
21082
- _programLayers.enable( 14 );
21149
+ _programLayers.enable( 13 );
21083
21150
  if ( parameters.transmission )
21084
- _programLayers.enable( 15 );
21151
+ _programLayers.enable( 14 );
21085
21152
  if ( parameters.sheen )
21086
- _programLayers.enable( 16 );
21153
+ _programLayers.enable( 15 );
21087
21154
  if ( parameters.opaque )
21088
- _programLayers.enable( 17 );
21155
+ _programLayers.enable( 16 );
21089
21156
  if ( parameters.pointsUvs )
21090
- _programLayers.enable( 18 );
21157
+ _programLayers.enable( 17 );
21091
21158
  if ( parameters.decodeVideoTexture )
21092
- _programLayers.enable( 19 );
21159
+ _programLayers.enable( 18 );
21093
21160
  if ( parameters.alphaToCoverage )
21094
- _programLayers.enable( 20 );
21161
+ _programLayers.enable( 19 );
21095
21162
  if ( parameters.numMultiviewViews )
21096
- _programLayers.enable( 21 );
21163
+ _programLayers.enable( 20 );
21097
21164
 
21098
21165
  array.push( _programLayers.mask );
21099
21166
 
@@ -21569,6 +21636,7 @@ function ShadowUniformsCache() {
21569
21636
 
21570
21637
  case 'DirectionalLight':
21571
21638
  uniforms = {
21639
+ shadowIntensity: 1,
21572
21640
  shadowBias: 0,
21573
21641
  shadowNormalBias: 0,
21574
21642
  shadowRadius: 1,
@@ -21578,6 +21646,7 @@ function ShadowUniformsCache() {
21578
21646
 
21579
21647
  case 'SpotLight':
21580
21648
  uniforms = {
21649
+ shadowIntensity: 1,
21581
21650
  shadowBias: 0,
21582
21651
  shadowNormalBias: 0,
21583
21652
  shadowRadius: 1,
@@ -21587,6 +21656,7 @@ function ShadowUniformsCache() {
21587
21656
 
21588
21657
  case 'PointLight':
21589
21658
  uniforms = {
21659
+ shadowIntensity: 1,
21590
21660
  shadowBias: 0,
21591
21661
  shadowNormalBias: 0,
21592
21662
  shadowRadius: 1,
@@ -21675,7 +21745,7 @@ function WebGLLights( extensions ) {
21675
21745
  const matrix4 = new Matrix4();
21676
21746
  const matrix42 = new Matrix4();
21677
21747
 
21678
- function setup( lights, useLegacyLights ) {
21748
+ function setup( lights ) {
21679
21749
 
21680
21750
  let r = 0, g = 0, b = 0;
21681
21751
 
@@ -21698,9 +21768,6 @@ function WebGLLights( extensions ) {
21698
21768
  // ordering : [shadow casting + map texturing, map texturing, shadow casting, none ]
21699
21769
  lights.sort( shadowCastingAndTexturingLightsFirst );
21700
21770
 
21701
- // artist-friendly light intensity scaling factor
21702
- const scaleFactor = ( useLegacyLights === true ) ? Math.PI : 1;
21703
-
21704
21771
  for ( let i = 0, l = lights.length; i < l; i ++ ) {
21705
21772
 
21706
21773
  const light = lights[ i ];
@@ -21713,9 +21780,9 @@ function WebGLLights( extensions ) {
21713
21780
 
21714
21781
  if ( light.isAmbientLight ) {
21715
21782
 
21716
- r += color.r * intensity * scaleFactor;
21717
- g += color.g * intensity * scaleFactor;
21718
- b += color.b * intensity * scaleFactor;
21783
+ r += color.r * intensity;
21784
+ g += color.g * intensity;
21785
+ b += color.b * intensity;
21719
21786
 
21720
21787
  } else if ( light.isLightProbe ) {
21721
21788
 
@@ -21731,7 +21798,7 @@ function WebGLLights( extensions ) {
21731
21798
 
21732
21799
  const uniforms = cache.get( light );
21733
21800
 
21734
- uniforms.color.copy( light.color ).multiplyScalar( light.intensity * scaleFactor );
21801
+ uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
21735
21802
 
21736
21803
  if ( light.castShadow ) {
21737
21804
 
@@ -21739,6 +21806,7 @@ function WebGLLights( extensions ) {
21739
21806
 
21740
21807
  const shadowUniforms = shadowCache.get( light );
21741
21808
 
21809
+ shadowUniforms.shadowIntensity = shadow.intensity;
21742
21810
  shadowUniforms.shadowBias = shadow.bias;
21743
21811
  shadowUniforms.shadowNormalBias = shadow.normalBias;
21744
21812
  shadowUniforms.shadowRadius = shadow.radius;
@@ -21762,7 +21830,7 @@ function WebGLLights( extensions ) {
21762
21830
 
21763
21831
  uniforms.position.setFromMatrixPosition( light.matrixWorld );
21764
21832
 
21765
- uniforms.color.copy( color ).multiplyScalar( intensity * scaleFactor );
21833
+ uniforms.color.copy( color ).multiplyScalar( intensity );
21766
21834
  uniforms.distance = distance;
21767
21835
 
21768
21836
  uniforms.coneCos = Math.cos( light.angle );
@@ -21792,6 +21860,7 @@ function WebGLLights( extensions ) {
21792
21860
 
21793
21861
  const shadowUniforms = shadowCache.get( light );
21794
21862
 
21863
+ shadowUniforms.shadowIntensity = shadow.intensity;
21795
21864
  shadowUniforms.shadowBias = shadow.bias;
21796
21865
  shadowUniforms.shadowNormalBias = shadow.normalBias;
21797
21866
  shadowUniforms.shadowRadius = shadow.radius;
@@ -21823,7 +21892,7 @@ function WebGLLights( extensions ) {
21823
21892
 
21824
21893
  const uniforms = cache.get( light );
21825
21894
 
21826
- uniforms.color.copy( light.color ).multiplyScalar( light.intensity * scaleFactor );
21895
+ uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
21827
21896
  uniforms.distance = light.distance;
21828
21897
  uniforms.decay = light.decay;
21829
21898
 
@@ -21833,6 +21902,7 @@ function WebGLLights( extensions ) {
21833
21902
 
21834
21903
  const shadowUniforms = shadowCache.get( light );
21835
21904
 
21905
+ shadowUniforms.shadowIntensity = shadow.intensity;
21836
21906
  shadowUniforms.shadowBias = shadow.bias;
21837
21907
  shadowUniforms.shadowNormalBias = shadow.normalBias;
21838
21908
  shadowUniforms.shadowRadius = shadow.radius;
@@ -21856,8 +21926,8 @@ function WebGLLights( extensions ) {
21856
21926
 
21857
21927
  const uniforms = cache.get( light );
21858
21928
 
21859
- uniforms.skyColor.copy( light.color ).multiplyScalar( intensity * scaleFactor );
21860
- uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity * scaleFactor );
21929
+ uniforms.skyColor.copy( light.color ).multiplyScalar( intensity );
21930
+ uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity );
21861
21931
 
21862
21932
  state.hemi[ hemiLength ] = uniforms;
21863
21933
 
@@ -22058,9 +22128,9 @@ function WebGLRenderState( extensions ) {
22058
22128
 
22059
22129
  }
22060
22130
 
22061
- function setupLights( useLegacyLights ) {
22131
+ function setupLights() {
22062
22132
 
22063
- lights.setup( lightsArray, useLegacyLights );
22133
+ lights.setup( lightsArray );
22064
22134
 
22065
22135
  }
22066
22136
 
@@ -23910,6 +23980,213 @@ function WebGLState( gl ) {
23910
23980
 
23911
23981
  }
23912
23982
 
23983
+ function contain( texture, aspect ) {
23984
+
23985
+ const imageAspect = ( texture.image && texture.image.width ) ? texture.image.width / texture.image.height : 1;
23986
+
23987
+ if ( imageAspect > aspect ) {
23988
+
23989
+ texture.repeat.x = 1;
23990
+ texture.repeat.y = imageAspect / aspect;
23991
+
23992
+ texture.offset.x = 0;
23993
+ texture.offset.y = ( 1 - texture.repeat.y ) / 2;
23994
+
23995
+ } else {
23996
+
23997
+ texture.repeat.x = aspect / imageAspect;
23998
+ texture.repeat.y = 1;
23999
+
24000
+ texture.offset.x = ( 1 - texture.repeat.x ) / 2;
24001
+ texture.offset.y = 0;
24002
+
24003
+ }
24004
+
24005
+ return texture;
24006
+
24007
+ }
24008
+
24009
+ function cover( texture, aspect ) {
24010
+
24011
+ const imageAspect = ( texture.image && texture.image.width ) ? texture.image.width / texture.image.height : 1;
24012
+
24013
+ if ( imageAspect > aspect ) {
24014
+
24015
+ texture.repeat.x = aspect / imageAspect;
24016
+ texture.repeat.y = 1;
24017
+
24018
+ texture.offset.x = ( 1 - texture.repeat.x ) / 2;
24019
+ texture.offset.y = 0;
24020
+
24021
+ } else {
24022
+
24023
+ texture.repeat.x = 1;
24024
+ texture.repeat.y = imageAspect / aspect;
24025
+
24026
+ texture.offset.x = 0;
24027
+ texture.offset.y = ( 1 - texture.repeat.y ) / 2;
24028
+
24029
+ }
24030
+
24031
+ return texture;
24032
+
24033
+ }
24034
+
24035
+ function fill( texture ) {
24036
+
24037
+ texture.repeat.x = 1;
24038
+ texture.repeat.y = 1;
24039
+
24040
+ texture.offset.x = 0;
24041
+ texture.offset.y = 0;
24042
+
24043
+ return texture;
24044
+
24045
+ }
24046
+
24047
+
24048
+
24049
+ /**
24050
+ * Given the width, height, format, and type of a texture. Determines how many
24051
+ * bytes must be used to represent the texture.
24052
+ */
24053
+ function getByteLength( width, height, format, type ) {
24054
+
24055
+ const typeByteLength = getTextureTypeByteLength( type );
24056
+
24057
+ switch ( format ) {
24058
+
24059
+ // https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml
24060
+ case AlphaFormat:
24061
+ return width * height;
24062
+ case LuminanceFormat:
24063
+ return width * height;
24064
+ case LuminanceAlphaFormat:
24065
+ return width * height * 2;
24066
+ case RedFormat:
24067
+ return ( ( width * height ) / typeByteLength.components ) * typeByteLength.byteLength;
24068
+ case RedIntegerFormat:
24069
+ return ( ( width * height ) / typeByteLength.components ) * typeByteLength.byteLength;
24070
+ case RGFormat:
24071
+ return ( ( width * height * 2 ) / typeByteLength.components ) * typeByteLength.byteLength;
24072
+ case RGIntegerFormat:
24073
+ return ( ( width * height * 2 ) / typeByteLength.components ) * typeByteLength.byteLength;
24074
+ case RGBFormat:
24075
+ return ( ( width * height * 3 ) / typeByteLength.components ) * typeByteLength.byteLength;
24076
+ case RGBAFormat:
24077
+ return ( ( width * height * 4 ) / typeByteLength.components ) * typeByteLength.byteLength;
24078
+ case RGBAIntegerFormat:
24079
+ return ( ( width * height * 4 ) / typeByteLength.components ) * typeByteLength.byteLength;
24080
+
24081
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_s3tc_srgb/
24082
+ case RGB_S3TC_DXT1_Format:
24083
+ case RGBA_S3TC_DXT1_Format:
24084
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 8;
24085
+ case RGBA_S3TC_DXT3_Format:
24086
+ case RGBA_S3TC_DXT5_Format:
24087
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
24088
+
24089
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_pvrtc/
24090
+ case RGB_PVRTC_2BPPV1_Format:
24091
+ case RGBA_PVRTC_2BPPV1_Format:
24092
+ return ( Math.max( width, 16 ) * Math.max( height, 8 ) ) / 4;
24093
+ case RGB_PVRTC_4BPPV1_Format:
24094
+ case RGBA_PVRTC_4BPPV1_Format:
24095
+ return ( Math.max( width, 8 ) * Math.max( height, 8 ) ) / 2;
24096
+
24097
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_etc/
24098
+ case RGB_ETC1_Format:
24099
+ case RGB_ETC2_Format:
24100
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 8;
24101
+ case RGBA_ETC2_EAC_Format:
24102
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
24103
+
24104
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_astc/
24105
+ case RGBA_ASTC_4x4_Format:
24106
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
24107
+ case RGBA_ASTC_5x4_Format:
24108
+ return Math.floor( ( width + 4 ) / 5 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
24109
+ case RGBA_ASTC_5x5_Format:
24110
+ return Math.floor( ( width + 4 ) / 5 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
24111
+ case RGBA_ASTC_6x5_Format:
24112
+ return Math.floor( ( width + 5 ) / 6 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
24113
+ case RGBA_ASTC_6x6_Format:
24114
+ return Math.floor( ( width + 5 ) / 6 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
24115
+ case RGBA_ASTC_8x5_Format:
24116
+ return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
24117
+ case RGBA_ASTC_8x6_Format:
24118
+ return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
24119
+ case RGBA_ASTC_8x8_Format:
24120
+ return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 7 ) / 8 ) * 16;
24121
+ case RGBA_ASTC_10x5_Format:
24122
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
24123
+ case RGBA_ASTC_10x6_Format:
24124
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
24125
+ case RGBA_ASTC_10x8_Format:
24126
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 7 ) / 8 ) * 16;
24127
+ case RGBA_ASTC_10x10_Format:
24128
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 9 ) / 10 ) * 16;
24129
+ case RGBA_ASTC_12x10_Format:
24130
+ return Math.floor( ( width + 11 ) / 12 ) * Math.floor( ( height + 9 ) / 10 ) * 16;
24131
+ case RGBA_ASTC_12x12_Format:
24132
+ return Math.floor( ( width + 11 ) / 12 ) * Math.floor( ( height + 11 ) / 12 ) * 16;
24133
+
24134
+ // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_bptc/
24135
+ case RGBA_BPTC_Format:
24136
+ case RGB_BPTC_SIGNED_Format:
24137
+ case RGB_BPTC_UNSIGNED_Format:
24138
+ return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 16;
24139
+
24140
+ // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_rgtc/
24141
+ case RED_RGTC1_Format:
24142
+ case SIGNED_RED_RGTC1_Format:
24143
+ return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 8;
24144
+ case RED_GREEN_RGTC2_Format:
24145
+ case SIGNED_RED_GREEN_RGTC2_Format:
24146
+ return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 16;
24147
+
24148
+ }
24149
+
24150
+ throw new Error(
24151
+ `Unable to determine texture byte length for ${format} format.`,
24152
+ );
24153
+
24154
+ }
24155
+
24156
+ function getTextureTypeByteLength( type ) {
24157
+
24158
+ switch ( type ) {
24159
+
24160
+ case UnsignedByteType:
24161
+ case ByteType:
24162
+ return { byteLength: 1, components: 1 };
24163
+ case UnsignedShortType:
24164
+ case ShortType:
24165
+ case HalfFloatType:
24166
+ return { byteLength: 2, components: 1 };
24167
+ case UnsignedShort4444Type:
24168
+ case UnsignedShort5551Type:
24169
+ return { byteLength: 2, components: 4 };
24170
+ case UnsignedIntType:
24171
+ case IntType:
24172
+ case FloatType:
24173
+ return { byteLength: 4, components: 1 };
24174
+ case UnsignedInt5999Type:
24175
+ return { byteLength: 4, components: 3 };
24176
+
24177
+ }
24178
+
24179
+ throw new Error( `Unknown texture type ${type}.` );
24180
+
24181
+ }
24182
+
24183
+ const TextureUtils = {
24184
+ contain,
24185
+ cover,
24186
+ fill,
24187
+ getByteLength
24188
+ };
24189
+
23913
24190
  function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
23914
24191
 
23915
24192
  const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
@@ -24107,6 +24384,48 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24107
24384
 
24108
24385
  }
24109
24386
 
24387
+ function getInternalDepthFormat( useStencil, depthType ) {
24388
+
24389
+ let glInternalFormat;
24390
+ if ( useStencil ) {
24391
+
24392
+ if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
24393
+
24394
+ glInternalFormat = _gl.DEPTH24_STENCIL8;
24395
+
24396
+ } else if ( depthType === FloatType ) {
24397
+
24398
+ glInternalFormat = _gl.DEPTH32F_STENCIL8;
24399
+
24400
+ } else if ( depthType === UnsignedShortType ) {
24401
+
24402
+ glInternalFormat = _gl.DEPTH24_STENCIL8;
24403
+ console.warn( 'DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.' );
24404
+
24405
+ }
24406
+
24407
+ } else {
24408
+
24409
+ if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
24410
+
24411
+ glInternalFormat = _gl.DEPTH_COMPONENT24;
24412
+
24413
+ } else if ( depthType === FloatType ) {
24414
+
24415
+ glInternalFormat = _gl.DEPTH_COMPONENT32F;
24416
+
24417
+ } else if ( depthType === UnsignedShortType ) {
24418
+
24419
+ glInternalFormat = _gl.DEPTH_COMPONENT16;
24420
+
24421
+ }
24422
+
24423
+ }
24424
+
24425
+ return glInternalFormat;
24426
+
24427
+ }
24428
+
24110
24429
  function getMipLevels( texture, image ) {
24111
24430
 
24112
24431
  if ( textureNeedsGenerateMipmaps( texture ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
@@ -24661,23 +24980,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24661
24980
 
24662
24981
  if ( texture.isDepthTexture ) {
24663
24982
 
24664
- // populate depth texture with dummy data
24665
-
24666
- glInternalFormat = _gl.DEPTH_COMPONENT16;
24667
-
24668
- if ( texture.type === FloatType ) {
24669
-
24670
- glInternalFormat = _gl.DEPTH_COMPONENT32F;
24671
-
24672
- } else if ( texture.type === UnsignedIntType ) {
24673
-
24674
- glInternalFormat = _gl.DEPTH_COMPONENT24;
24675
-
24676
- } else if ( texture.type === UnsignedInt248Type ) {
24677
-
24678
- glInternalFormat = _gl.DEPTH24_STENCIL8;
24679
-
24680
- }
24983
+ glInternalFormat = getInternalDepthFormat( texture.format === DepthStencilFormat, texture.type );
24681
24984
 
24682
24985
  //
24683
24986
 
@@ -24777,7 +25080,27 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24777
25080
 
24778
25081
  if ( dataReady ) {
24779
25082
 
24780
- state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
25083
+ if ( texture.layerUpdates.size > 0 ) {
25084
+
25085
+ const layerByteLength = getByteLength( mipmap.width, mipmap.height, texture.format, texture.type );
25086
+
25087
+ for ( const layerIndex of texture.layerUpdates ) {
25088
+
25089
+ const layerData = mipmap.data.subarray(
25090
+ layerIndex * layerByteLength / mipmap.data.BYTES_PER_ELEMENT,
25091
+ ( layerIndex + 1 ) * layerByteLength / mipmap.data.BYTES_PER_ELEMENT
25092
+ );
25093
+ state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, layerData, 0, 0 );
25094
+
25095
+ }
25096
+
25097
+ texture.clearLayerUpdates();
25098
+
25099
+ } else {
25100
+
25101
+ state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
25102
+
25103
+ }
24781
25104
 
24782
25105
  }
24783
25106
 
@@ -24883,7 +25206,27 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24883
25206
 
24884
25207
  if ( dataReady ) {
24885
25208
 
24886
- state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
25209
+ if ( texture.layerUpdates.size > 0 ) {
25210
+
25211
+ const layerByteLength = getByteLength( image.width, image.height, texture.format, texture.type );
25212
+
25213
+ for ( const layerIndex of texture.layerUpdates ) {
25214
+
25215
+ const layerData = image.data.subarray(
25216
+ layerIndex * layerByteLength / image.data.BYTES_PER_ELEMENT,
25217
+ ( layerIndex + 1 ) * layerByteLength / image.data.BYTES_PER_ELEMENT
25218
+ );
25219
+ state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, layerIndex, image.width, image.height, 1, glFormat, glType, layerData );
25220
+
25221
+ }
25222
+
25223
+ texture.clearLayerUpdates();
25224
+
25225
+ } else {
25226
+
25227
+ state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
25228
+
25229
+ }
24887
25230
 
24888
25231
  }
24889
25232
 
@@ -25327,7 +25670,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25327
25670
 
25328
25671
  }
25329
25672
 
25330
-
25331
25673
  // Setup storage for internal depth/stencil buffers and bind to correct framebuffer
25332
25674
  function setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {
25333
25675
 
@@ -25387,66 +25729,30 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25387
25729
 
25388
25730
  } else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
25389
25731
 
25390
- let glInternalFormat = _gl.DEPTH_COMPONENT24;
25391
-
25392
- if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
25393
-
25394
- const depthTexture = renderTarget.depthTexture;
25395
-
25396
- if ( depthTexture && depthTexture.isDepthTexture ) {
25397
-
25398
- if ( depthTexture.type === FloatType ) {
25399
-
25400
- glInternalFormat = _gl.DEPTH_COMPONENT32F;
25401
-
25402
- } else if ( depthTexture.type === UnsignedIntType ) {
25403
-
25404
- glInternalFormat = _gl.DEPTH_COMPONENT24;
25405
-
25406
- }
25407
-
25408
- }
25409
-
25410
- const samples = getRenderTargetSamples( renderTarget );
25411
-
25412
- if ( useMultisampledRTT( renderTarget ) ) {
25413
-
25414
- multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
25415
-
25416
- } else {
25417
-
25418
- _gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
25419
-
25420
- }
25421
-
25422
- } else {
25423
-
25424
- _gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
25425
-
25426
- }
25427
-
25428
- _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
25429
-
25430
- } else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) {
25732
+ // retrieve the depth attachment types
25733
+ const depthTexture = renderTarget.depthTexture;
25734
+ const depthType = depthTexture && depthTexture.isDepthTexture ? depthTexture.type : null;
25735
+ const glInternalFormat = getInternalDepthFormat( renderTarget.stencilBuffer, depthType );
25736
+ const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
25431
25737
 
25738
+ // set up the attachment
25432
25739
  const samples = getRenderTargetSamples( renderTarget );
25740
+ const isUseMultisampledRTT = useMultisampledRTT( renderTarget );
25741
+ if ( isUseMultisampledRTT ) {
25433
25742
 
25434
- if ( isMultisample && useMultisampledRTT( renderTarget ) === false ) {
25743
+ multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
25435
25744
 
25436
- _gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height );
25745
+ } else if ( isMultisample ) {
25437
25746
 
25438
- } else if ( useMultisampledRTT( renderTarget ) ) {
25439
-
25440
- multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height );
25747
+ _gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
25441
25748
 
25442
25749
  } else {
25443
25750
 
25444
- _gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTarget.width, renderTarget.height );
25751
+ _gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
25445
25752
 
25446
25753
  }
25447
25754
 
25448
-
25449
- _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
25755
+ _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
25450
25756
 
25451
25757
  } else {
25452
25758
 
@@ -27357,7 +27663,7 @@ class WebXRDepthSensing {
27357
27663
 
27358
27664
  }
27359
27665
 
27360
- render( renderer, cameraXR ) {
27666
+ getMesh( cameraXR ) {
27361
27667
 
27362
27668
  if ( this.texture !== null ) {
27363
27669
 
@@ -27378,10 +27684,10 @@ class WebXRDepthSensing {
27378
27684
 
27379
27685
  }
27380
27686
 
27381
- renderer.render( this.mesh, cameraXR );
27382
-
27383
27687
  }
27384
27688
 
27689
+ return this.mesh;
27690
+
27385
27691
  }
27386
27692
 
27387
27693
  reset() {
@@ -27391,6 +27697,12 @@ class WebXRDepthSensing {
27391
27697
 
27392
27698
  }
27393
27699
 
27700
+ getDepthTexture() {
27701
+
27702
+ return this.texture;
27703
+
27704
+ }
27705
+
27394
27706
  }
27395
27707
 
27396
27708
  class WebXRManager extends EventDispatcher {
@@ -27813,6 +28125,12 @@ class WebXRManager extends EventDispatcher {
27813
28125
  session.updateRenderState( { layers: layersCopy } );
27814
28126
  };
27815
28127
 
28128
+ this.getDepthTexture = function () {
28129
+
28130
+ return depthSensing.getDepthTexture();
28131
+
28132
+ };
28133
+
27816
28134
  function onInputSourcesChange( event ) {
27817
28135
 
27818
28136
  // Notify disconnected
@@ -28105,6 +28423,12 @@ class WebXRManager extends EventDispatcher {
28105
28423
 
28106
28424
  };
28107
28425
 
28426
+ this.getDepthSensingMesh = function () {
28427
+
28428
+ return depthSensing.getMesh( cameraXR );
28429
+
28430
+ };
28431
+
28108
28432
  // Animation Loop
28109
28433
 
28110
28434
  let onAnimationFrameCallback = null;
@@ -28230,8 +28554,6 @@ class WebXRManager extends EventDispatcher {
28230
28554
 
28231
28555
  }
28232
28556
 
28233
- depthSensing.render( renderer, cameraXR );
28234
-
28235
28557
  if ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );
28236
28558
 
28237
28559
  if ( frame.detectedPlanes ) {
@@ -28506,11 +28828,7 @@ function WebGLMaterials( renderer, properties ) {
28506
28828
  if ( material.lightMap ) {
28507
28829
 
28508
28830
  uniforms.lightMap.value = material.lightMap;
28509
-
28510
- // artist-friendly light intensity scaling factor
28511
- const scaleFactor = ( renderer._useLegacyLights === true ) ? Math.PI : 1;
28512
-
28513
- uniforms.lightMapIntensity.value = material.lightMapIntensity * scaleFactor;
28831
+ uniforms.lightMapIntensity.value = material.lightMapIntensity;
28514
28832
 
28515
28833
  refreshTransformUniform( material.lightMap, uniforms.lightMapTransform );
28516
28834
 
@@ -29091,27 +29409,27 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
29091
29409
 
29092
29410
  const info = getUniformSize( value );
29093
29411
 
29094
- // Calculate the chunk offset
29095
- const chunkOffsetUniform = offset % chunkSize;
29412
+ const chunkOffset = offset % chunkSize; // offset in the current chunk
29413
+ const chunkPadding = chunkOffset % info.boundary; // required padding to match boundary
29414
+ const chunkStart = chunkOffset + chunkPadding; // the start position in the current chunk for the data
29415
+
29416
+ offset += chunkPadding;
29096
29417
 
29097
29418
  // Check for chunk overflow
29098
- if ( chunkOffsetUniform !== 0 && ( chunkSize - chunkOffsetUniform ) < info.boundary ) {
29419
+ if ( chunkStart !== 0 && ( chunkSize - chunkStart ) < info.storage ) {
29099
29420
 
29100
29421
  // Add padding and adjust offset
29101
- offset += ( chunkSize - chunkOffsetUniform );
29422
+ offset += ( chunkSize - chunkStart );
29102
29423
 
29103
29424
  }
29104
29425
 
29105
29426
  // the following two properties will be used for partial buffer updates
29106
-
29107
29427
  uniform.__data = new Float32Array( info.storage / Float32Array.BYTES_PER_ELEMENT );
29108
29428
  uniform.__offset = offset;
29109
29429
 
29110
-
29111
29430
  // Update the global offset
29112
29431
  offset += info.storage;
29113
29432
 
29114
-
29115
29433
  }
29116
29434
 
29117
29435
  }
@@ -29328,10 +29646,6 @@ class WebGLRenderer {
29328
29646
 
29329
29647
  this._outputColorSpace = SRGBColorSpace;
29330
29648
 
29331
- // physical lights
29332
-
29333
- this._useLegacyLights = false;
29334
-
29335
29649
  // tone mapping
29336
29650
 
29337
29651
  this.toneMapping = NoToneMapping;
@@ -29387,8 +29701,12 @@ class WebGLRenderer {
29387
29701
 
29388
29702
  const _vector3 = new Vector3();
29389
29703
 
29704
+ const _vector4 = new Vector4();
29705
+
29390
29706
  const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
29391
29707
 
29708
+ let _renderBackground = false;
29709
+
29392
29710
  function getTargetPixelRatio() {
29393
29711
 
29394
29712
  return _currentRenderTarget === null ? _pixelRatio : 1;
@@ -30044,7 +30362,25 @@ class WebGLRenderer {
30044
30362
 
30045
30363
  } else {
30046
30364
 
30047
- renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
30365
+ if ( ! extensions.get( 'WEBGL_multi_draw' ) ) {
30366
+
30367
+ const starts = object._multiDrawStarts;
30368
+ const counts = object._multiDrawCounts;
30369
+ const drawCount = object._multiDrawCount;
30370
+ const bytesPerElement = index ? attributes.get( index ).bytesPerElement : 1;
30371
+ const uniforms = properties.get( material ).currentProgram.getUniforms();
30372
+ for ( let i = 0; i < drawCount; i ++ ) {
30373
+
30374
+ uniforms.setValue( _gl, '_gl_DrawID', i );
30375
+ renderer.render( starts[ i ] / bytesPerElement, counts[ i ] );
30376
+
30377
+ }
30378
+
30379
+ } else {
30380
+
30381
+ renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
30382
+
30383
+ }
30048
30384
 
30049
30385
  }
30050
30386
 
@@ -30138,7 +30474,7 @@ class WebGLRenderer {
30138
30474
 
30139
30475
  }
30140
30476
 
30141
- currentRenderState.setupLights( _this._useLegacyLights );
30477
+ currentRenderState.setupLights();
30142
30478
 
30143
30479
  // Only initialize materials in the new scene, not the targetScene.
30144
30480
 
@@ -30328,6 +30664,18 @@ class WebGLRenderer {
30328
30664
 
30329
30665
  renderListStack.push( currentRenderList );
30330
30666
 
30667
+ if ( xr.enabled === true && xr.isPresenting === true ) {
30668
+
30669
+ const depthSensingMesh = _this.xr.getDepthSensingMesh();
30670
+
30671
+ if ( depthSensingMesh !== null ) {
30672
+
30673
+ projectObject( depthSensingMesh, camera, - Infinity, _this.sortObjects );
30674
+
30675
+ }
30676
+
30677
+ }
30678
+
30331
30679
  projectObject( scene, camera, 0, _this.sortObjects );
30332
30680
 
30333
30681
  currentRenderList.finish();
@@ -30338,8 +30686,8 @@ class WebGLRenderer {
30338
30686
 
30339
30687
  }
30340
30688
 
30341
- const renderBackground = xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false;
30342
- if ( renderBackground ) {
30689
+ _renderBackground = xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false;
30690
+ if ( _renderBackground ) {
30343
30691
 
30344
30692
  background.addToRenderList( currentRenderList, scene );
30345
30693
 
@@ -30366,7 +30714,7 @@ class WebGLRenderer {
30366
30714
  const opaqueObjects = currentRenderList.opaque;
30367
30715
  const transmissiveObjects = currentRenderList.transmissive;
30368
30716
 
30369
- currentRenderState.setupLights( _this._useLegacyLights );
30717
+ currentRenderState.setupLights();
30370
30718
 
30371
30719
  if ( camera.isArrayCamera ) {
30372
30720
 
@@ -30384,7 +30732,7 @@ class WebGLRenderer {
30384
30732
 
30385
30733
  }
30386
30734
 
30387
- if ( renderBackground ) background.render( scene );
30735
+ if ( _renderBackground ) background.render( scene );
30388
30736
 
30389
30737
  if ( xr.enabled && xr.isMultiview ) {
30390
30738
 
@@ -30408,7 +30756,7 @@ class WebGLRenderer {
30408
30756
 
30409
30757
  if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
30410
30758
 
30411
- if ( renderBackground ) background.render( scene );
30759
+ if ( _renderBackground ) background.render( scene );
30412
30760
 
30413
30761
  renderScene( currentRenderList, scene, camera );
30414
30762
 
@@ -30505,7 +30853,7 @@ class WebGLRenderer {
30505
30853
 
30506
30854
  if ( sortObjects ) {
30507
30855
 
30508
- _vector3.setFromMatrixPosition( object.matrixWorld )
30856
+ _vector4.setFromMatrixPosition( object.matrixWorld )
30509
30857
  .applyMatrix4( _projScreenMatrix );
30510
30858
 
30511
30859
  }
@@ -30515,7 +30863,7 @@ class WebGLRenderer {
30515
30863
 
30516
30864
  if ( material.visible ) {
30517
30865
 
30518
- currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
30866
+ currentRenderList.push( object, geometry, material, groupOrder, _vector4.z, null );
30519
30867
 
30520
30868
  }
30521
30869
 
@@ -30533,16 +30881,16 @@ class WebGLRenderer {
30533
30881
  if ( object.boundingSphere !== undefined ) {
30534
30882
 
30535
30883
  if ( object.boundingSphere === null ) object.computeBoundingSphere();
30536
- _vector3.copy( object.boundingSphere.center );
30884
+ _vector4.copy( object.boundingSphere.center );
30537
30885
 
30538
30886
  } else {
30539
30887
 
30540
30888
  if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
30541
- _vector3.copy( geometry.boundingSphere.center );
30889
+ _vector4.copy( geometry.boundingSphere.center );
30542
30890
 
30543
30891
  }
30544
30892
 
30545
- _vector3
30893
+ _vector4
30546
30894
  .applyMatrix4( object.matrixWorld )
30547
30895
  .applyMatrix4( _projScreenMatrix );
30548
30896
 
@@ -30559,7 +30907,7 @@ class WebGLRenderer {
30559
30907
 
30560
30908
  if ( groupMaterial && groupMaterial.visible ) {
30561
30909
 
30562
- currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector3.z, group );
30910
+ currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector4.z, group );
30563
30911
 
30564
30912
  }
30565
30913
 
@@ -30567,7 +30915,7 @@ class WebGLRenderer {
30567
30915
 
30568
30916
  } else if ( material.visible ) {
30569
30917
 
30570
- currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
30918
+ currentRenderList.push( object, geometry, material, groupOrder, _vector4.z, null );
30571
30919
 
30572
30920
  }
30573
30921
 
@@ -30632,7 +30980,8 @@ class WebGLRenderer {
30632
30980
  samples: 4,
30633
30981
  stencilBuffer: stencil,
30634
30982
  resolveDepthBuffer: false,
30635
- resolveStencilBuffer: false
30983
+ resolveStencilBuffer: false,
30984
+ colorSpace: ColorManagement.workingColorSpace,
30636
30985
  } );
30637
30986
 
30638
30987
  // debug
@@ -30663,6 +31012,8 @@ class WebGLRenderer {
30663
31012
 
30664
31013
  _this.clear();
30665
31014
 
31015
+ if ( _renderBackground ) background.render( scene );
31016
+
30666
31017
  // Turn off the features which can affect the frag color for opaque objects pass.
30667
31018
  // Otherwise they are applied twice in opaque objects pass and transmission objects pass.
30668
31019
  const currentToneMapping = _this.toneMapping;
@@ -30762,8 +31113,6 @@ class WebGLRenderer {
30762
31113
  object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
30763
31114
  object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
30764
31115
 
30765
- material.onBeforeRender( _this, scene, camera, geometry, object, group );
30766
-
30767
31116
  if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
30768
31117
 
30769
31118
  material.side = BackSide;
@@ -30838,8 +31187,6 @@ class WebGLRenderer {
30838
31187
 
30839
31188
  parameters.uniforms = programCache.getUniforms( material );
30840
31189
 
30841
- material.onBuild( object, parameters, _this );
30842
-
30843
31190
  material.onBeforeCompile( parameters, _this );
30844
31191
 
30845
31192
  program = programCache.acquireProgram( parameters, programCacheKey );
@@ -30918,6 +31265,7 @@ class WebGLRenderer {
30918
31265
 
30919
31266
  materialProperties.outputColorSpace = parameters.outputColorSpace;
30920
31267
  materialProperties.batching = parameters.batching;
31268
+ materialProperties.batchingColor = parameters.batchingColor;
30921
31269
  materialProperties.instancing = parameters.instancing;
30922
31270
  materialProperties.instancingColor = parameters.instancingColor;
30923
31271
  materialProperties.instancingMorph = parameters.instancingMorph;
@@ -31010,6 +31358,14 @@ class WebGLRenderer {
31010
31358
 
31011
31359
  needsProgramChange = true;
31012
31360
 
31361
+ } else if ( object.isBatchedMesh && materialProperties.batchingColor === true && object.colorTexture === null ) {
31362
+
31363
+ needsProgramChange = true;
31364
+
31365
+ } else if ( object.isBatchedMesh && materialProperties.batchingColor === false && object.colorTexture !== null ) {
31366
+
31367
+ needsProgramChange = true;
31368
+
31013
31369
  } else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
31014
31370
 
31015
31371
  needsProgramChange = true;
@@ -31215,6 +31571,16 @@ class WebGLRenderer {
31215
31571
  p_uniforms.setOptional( _gl, object, 'batchingTexture' );
31216
31572
  p_uniforms.setValue( _gl, 'batchingTexture', object._matricesTexture, textures );
31217
31573
 
31574
+ p_uniforms.setOptional( _gl, object, 'batchingIdTexture' );
31575
+ p_uniforms.setValue( _gl, 'batchingIdTexture', object._indirectTexture, textures );
31576
+
31577
+ p_uniforms.setOptional( _gl, object, 'batchingColorTexture' );
31578
+ if ( object._colorsTexture !== null ) {
31579
+
31580
+ p_uniforms.setValue( _gl, 'batchingColorTexture', object._colorsTexture, textures );
31581
+
31582
+ }
31583
+
31218
31584
  }
31219
31585
 
31220
31586
  const morphAttributes = geometry.morphAttributes;
@@ -31610,24 +31976,159 @@ class WebGLRenderer {
31610
31976
 
31611
31977
  };
31612
31978
 
31613
- this.copyFramebufferToTexture = function ( position, texture, level = 0 ) {
31979
+ this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
31980
+
31981
+ if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
31982
+
31983
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
31984
+
31985
+ }
31986
+
31987
+ let framebuffer = properties.get( renderTarget ).__webglFramebuffer;
31988
+ if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {
31989
+
31990
+ framebuffer = framebuffer[ activeCubeFaceIndex ];
31991
+
31992
+ }
31993
+
31994
+ if ( framebuffer ) {
31995
+
31996
+ state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
31997
+
31998
+ try {
31999
+
32000
+ const texture = renderTarget.texture;
32001
+ const textureFormat = texture.format;
32002
+ const textureType = texture.type;
32003
+
32004
+ if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
32005
+
32006
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
32007
+
32008
+ }
32009
+
32010
+ if ( ! capabilities.textureTypeReadable( textureType ) ) {
32011
+
32012
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
32013
+
32014
+ }
32015
+
32016
+ // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
32017
+ if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
32018
+
32019
+ const glBuffer = _gl.createBuffer();
32020
+ _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
32021
+ _gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
32022
+ _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
32023
+ _gl.flush();
32024
+
32025
+ // check if the commands have finished every 8 ms
32026
+ const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
32027
+ await probeAsync( _gl, sync, 4 );
32028
+
32029
+ try {
32030
+
32031
+ _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
32032
+ _gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
32033
+
32034
+ } finally {
32035
+
32036
+ _gl.deleteBuffer( glBuffer );
32037
+ _gl.deleteSync( sync );
32038
+
32039
+ }
32040
+
32041
+ return buffer;
32042
+
32043
+ }
32044
+
32045
+ } finally {
32046
+
32047
+ // restore framebuffer of current render target if necessary
32048
+
32049
+ const framebuffer = ( _currentRenderTarget !== null ) ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
32050
+ state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
32051
+
32052
+ }
32053
+
32054
+ }
32055
+
32056
+ };
32057
+
32058
+ this.copyFramebufferToTexture = function ( texture, position = null, level = 0 ) {
32059
+
32060
+ // support previous signature with position first
32061
+ if ( texture.isTexture !== true ) {
32062
+
32063
+ // @deprecated, r165
32064
+ warnOnce( 'WebGLRenderer: copyFramebufferToTexture function signature has changed.' );
32065
+
32066
+ position = arguments[ 0 ] || null;
32067
+ texture = arguments[ 1 ];
32068
+
32069
+ }
31614
32070
 
31615
32071
  const levelScale = Math.pow( 2, - level );
31616
32072
  const width = Math.floor( texture.image.width * levelScale );
31617
32073
  const height = Math.floor( texture.image.height * levelScale );
31618
32074
 
32075
+ const x = position !== null ? position.x : 0;
32076
+ const y = position !== null ? position.y : 0;
32077
+
31619
32078
  textures.setTexture2D( texture, 0 );
31620
32079
 
31621
- _gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0, position.x, position.y, width, height );
32080
+ _gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0, x, y, width, height );
31622
32081
 
31623
32082
  state.unbindTexture();
31624
32083
 
31625
32084
  };
31626
32085
 
31627
- this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level = 0 ) {
32086
+ this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
32087
+
32088
+ // support previous signature with dstPosition first
32089
+ if ( srcTexture.isTexture !== true ) {
32090
+
32091
+ // @deprecated, r165
32092
+ warnOnce( 'WebGLRenderer: copyTextureToTexture function signature has changed.' );
32093
+
32094
+ dstPosition = arguments[ 0 ] || null;
32095
+ srcTexture = arguments[ 1 ];
32096
+ dstTexture = arguments[ 2 ];
32097
+ level = arguments[ 3 ] || 0;
32098
+ srcRegion = null;
32099
+
32100
+ }
32101
+
32102
+ let width, height, minX, minY;
32103
+ let dstX, dstY;
32104
+ if ( srcRegion !== null ) {
32105
+
32106
+ width = srcRegion.max.x - srcRegion.min.x;
32107
+ height = srcRegion.max.y - srcRegion.min.y;
32108
+ minX = srcRegion.min.x;
32109
+ minY = srcRegion.min.y;
32110
+
32111
+ } else {
32112
+
32113
+ width = srcTexture.image.width;
32114
+ height = srcTexture.image.height;
32115
+ minX = 0;
32116
+ minY = 0;
32117
+
32118
+ }
32119
+
32120
+ if ( dstPosition !== null ) {
32121
+
32122
+ dstX = dstPosition.x;
32123
+ dstY = dstPosition.y;
32124
+
32125
+ } else {
32126
+
32127
+ dstX = 0;
32128
+ dstY = 0;
32129
+
32130
+ }
31628
32131
 
31629
- const width = srcTexture.image.width;
31630
- const height = srcTexture.image.height;
31631
32132
  const glFormat = utils.convert( dstTexture.format );
31632
32133
  const glType = utils.convert( dstTexture.type );
31633
32134
 
@@ -31639,24 +32140,43 @@ class WebGLRenderer {
31639
32140
  _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
31640
32141
  _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
31641
32142
 
32143
+ const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
32144
+ const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
32145
+ const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
32146
+ const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
32147
+ const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
32148
+
32149
+ const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
32150
+
32151
+ _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
32152
+ _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
32153
+ _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
32154
+ _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
32155
+
31642
32156
  if ( srcTexture.isDataTexture ) {
31643
32157
 
31644
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );
32158
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
31645
32159
 
31646
32160
  } else {
31647
32161
 
31648
32162
  if ( srcTexture.isCompressedTexture ) {
31649
32163
 
31650
- _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data );
32164
+ _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
31651
32165
 
31652
32166
  } else {
31653
32167
 
31654
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image );
32168
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
31655
32169
 
31656
32170
  }
31657
32171
 
31658
32172
  }
31659
32173
 
32174
+ _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
32175
+ _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
32176
+ _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
32177
+ _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
32178
+ _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
32179
+
31660
32180
  // Generate mipmaps only when copying level 0
31661
32181
  if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
31662
32182
 
@@ -31664,11 +32184,59 @@ class WebGLRenderer {
31664
32184
 
31665
32185
  };
31666
32186
 
31667
- this.copyTextureToTexture3D = function ( sourceBox, position, srcTexture, dstTexture, level = 0 ) {
32187
+ this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
32188
+
32189
+ // support previous signature with source box first
32190
+ if ( srcTexture.isTexture !== true ) {
32191
+
32192
+ // @deprecated, r165
32193
+ warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
32194
+
32195
+ srcRegion = arguments[ 0 ] || null;
32196
+ dstPosition = arguments[ 1 ] || null;
32197
+ srcTexture = arguments[ 2 ];
32198
+ dstTexture = arguments[ 3 ];
32199
+ level = arguments[ 4 ] || 0;
32200
+
32201
+ }
32202
+
32203
+ let width, height, depth, minX, minY, minZ;
32204
+ let dstX, dstY, dstZ;
32205
+ const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
32206
+ if ( srcRegion !== null ) {
32207
+
32208
+ width = srcRegion.max.x - srcRegion.min.x;
32209
+ height = srcRegion.max.y - srcRegion.min.y;
32210
+ depth = srcRegion.max.z - srcRegion.min.z;
32211
+ minX = srcRegion.min.x;
32212
+ minY = srcRegion.min.y;
32213
+ minZ = srcRegion.min.z;
32214
+
32215
+ } else {
32216
+
32217
+ width = image.width;
32218
+ height = image.height;
32219
+ depth = image.depth;
32220
+ minX = 0;
32221
+ minY = 0;
32222
+ minZ = 0;
32223
+
32224
+ }
32225
+
32226
+ if ( dstPosition !== null ) {
32227
+
32228
+ dstX = dstPosition.x;
32229
+ dstY = dstPosition.y;
32230
+ dstZ = dstPosition.z;
32231
+
32232
+ } else {
32233
+
32234
+ dstX = 0;
32235
+ dstY = 0;
32236
+ dstZ = 0;
32237
+
32238
+ }
31668
32239
 
31669
- const width = sourceBox.max.x - sourceBox.min.x;
31670
- const height = sourceBox.max.y - sourceBox.min.y;
31671
- const depth = sourceBox.max.z - sourceBox.min.z;
31672
32240
  const glFormat = utils.convert( dstTexture.format );
31673
32241
  const glType = utils.convert( dstTexture.type );
31674
32242
  let glTarget;
@@ -31694,43 +32262,41 @@ class WebGLRenderer {
31694
32262
  _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
31695
32263
  _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
31696
32264
 
31697
- const unpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
31698
- const unpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
31699
- const unpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
31700
- const unpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
31701
- const unpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
31702
-
31703
- const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
32265
+ const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
32266
+ const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
32267
+ const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
32268
+ const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
32269
+ const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
31704
32270
 
31705
32271
  _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
31706
32272
  _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
31707
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, sourceBox.min.x );
31708
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, sourceBox.min.y );
31709
- _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, sourceBox.min.z );
32273
+ _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
32274
+ _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
32275
+ _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
31710
32276
 
31711
32277
  if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
31712
32278
 
31713
- _gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image.data );
32279
+ _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
31714
32280
 
31715
32281
  } else {
31716
32282
 
31717
32283
  if ( dstTexture.isCompressedArrayTexture ) {
31718
32284
 
31719
- _gl.compressedTexSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data );
32285
+ _gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
31720
32286
 
31721
32287
  } else {
31722
32288
 
31723
- _gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image );
32289
+ _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
31724
32290
 
31725
32291
  }
31726
32292
 
31727
32293
  }
31728
32294
 
31729
- _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, unpackRowLen );
31730
- _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, unpackImageHeight );
31731
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, unpackSkipPixels );
31732
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, unpackSkipRows );
31733
- _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, unpackSkipImages );
32295
+ _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
32296
+ _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
32297
+ _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
32298
+ _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
32299
+ _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
31734
32300
 
31735
32301
  // Generate mipmaps only when copying level 0
31736
32302
  if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget );
@@ -31739,6 +32305,16 @@ class WebGLRenderer {
31739
32305
 
31740
32306
  };
31741
32307
 
32308
+ this.initRenderTarget = function ( target ) {
32309
+
32310
+ if ( properties.get( target ).__webglFramebuffer === undefined ) {
32311
+
32312
+ textures.setupRenderTarget( target );
32313
+
32314
+ }
32315
+
32316
+ };
32317
+
31742
32318
  this.initTexture = function ( texture ) {
31743
32319
 
31744
32320
  if ( texture.isCubeTexture ) {
@@ -31804,20 +32380,6 @@ class WebGLRenderer {
31804
32380
 
31805
32381
  }
31806
32382
 
31807
- get useLegacyLights() { // @deprecated, r155
31808
-
31809
- console.warn( 'THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.' );
31810
- return this._useLegacyLights;
31811
-
31812
- }
31813
-
31814
- set useLegacyLights( value ) { // @deprecated, r155
31815
-
31816
- console.warn( 'THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.' );
31817
- this._useLegacyLights = value;
31818
-
31819
- }
31820
-
31821
32383
  }
31822
32384
 
31823
32385
  class FogExp2 {
@@ -33678,7 +34240,7 @@ class InstancedMesh extends Mesh {
33678
34240
 
33679
34241
  if ( this.instanceColor === null ) {
33680
34242
 
33681
- this.instanceColor = new InstancedBufferAttribute( new Float32Array( this.instanceMatrix.count * 3 ), 3 );
34243
+ this.instanceColor = new InstancedBufferAttribute( new Float32Array( this.instanceMatrix.count * 3 ).fill( 1 ), 3 );
33682
34244
 
33683
34245
  }
33684
34246
 
@@ -33767,7 +34329,7 @@ class MultiDrawRenderList {
33767
34329
 
33768
34330
  }
33769
34331
 
33770
- push( drawRange, z ) {
34332
+ push( drawRange, z, index ) {
33771
34333
 
33772
34334
  const pool = this.pool;
33773
34335
  const list = this.list;
@@ -33778,6 +34340,7 @@ class MultiDrawRenderList {
33778
34340
  start: - 1,
33779
34341
  count: - 1,
33780
34342
  z: - 1,
34343
+ index: - 1,
33781
34344
 
33782
34345
  } );
33783
34346
 
@@ -33790,6 +34353,7 @@ class MultiDrawRenderList {
33790
34353
  item.start = drawRange.start;
33791
34354
  item.count = drawRange.count;
33792
34355
  item.z = z;
34356
+ item.index = index;
33793
34357
 
33794
34358
  }
33795
34359
 
@@ -33802,15 +34366,17 @@ class MultiDrawRenderList {
33802
34366
 
33803
34367
  }
33804
34368
 
33805
- const ID_ATTR_NAME = 'batchId';
33806
34369
  const _matrix$1 = /*@__PURE__*/ new Matrix4();
33807
34370
  const _invMatrixWorld = /*@__PURE__*/ new Matrix4();
33808
34371
  const _identityMatrix = /*@__PURE__*/ new Matrix4();
34372
+ const _whiteColor = /*@__PURE__*/ new Color( 1, 1, 1 );
33809
34373
  const _projScreenMatrix$2 = /*@__PURE__*/ new Matrix4();
33810
34374
  const _frustum = /*@__PURE__*/ new Frustum();
33811
34375
  const _box$1 = /*@__PURE__*/ new Box3();
33812
34376
  const _sphere$2 = /*@__PURE__*/ new Sphere();
33813
34377
  const _vector$5 = /*@__PURE__*/ new Vector3();
34378
+ const _forward = /*@__PURE__*/ new Vector3();
34379
+ const _temp = /*@__PURE__*/ new Vector3();
33814
34380
  const _renderList = /*@__PURE__*/ new MultiDrawRenderList();
33815
34381
  const _mesh = /*@__PURE__*/ new Mesh();
33816
34382
  const _batchIntersects = [];
@@ -33854,13 +34420,13 @@ function copyAttributeData( src, target, targetOffset = 0 ) {
33854
34420
 
33855
34421
  class BatchedMesh extends Mesh {
33856
34422
 
33857
- get maxGeometryCount() {
34423
+ get maxInstanceCount() {
33858
34424
 
33859
- return this._maxGeometryCount;
34425
+ return this._maxInstanceCount;
33860
34426
 
33861
34427
  }
33862
34428
 
33863
- constructor( maxGeometryCount, maxVertexCount, maxIndexCount = maxVertexCount * 2, material ) {
34429
+ constructor( maxInstanceCount, maxVertexCount, maxIndexCount = maxVertexCount * 2, material ) {
33864
34430
 
33865
34431
  super( new BufferGeometry(), material );
33866
34432
 
@@ -33871,29 +34437,33 @@ class BatchedMesh extends Mesh {
33871
34437
  this.boundingSphere = null;
33872
34438
  this.customSort = null;
33873
34439
 
34440
+ // stores visible, active, and geometry id per object
34441
+ this._drawInfo = [];
34442
+
34443
+ // geometry information
33874
34444
  this._drawRanges = [];
33875
34445
  this._reservedRanges = [];
33876
-
33877
- this._visibility = [];
33878
- this._active = [];
33879
34446
  this._bounds = [];
33880
34447
 
33881
- this._maxGeometryCount = maxGeometryCount;
34448
+ this._maxInstanceCount = maxInstanceCount;
33882
34449
  this._maxVertexCount = maxVertexCount;
33883
34450
  this._maxIndexCount = maxIndexCount;
33884
34451
 
33885
34452
  this._geometryInitialized = false;
33886
34453
  this._geometryCount = 0;
33887
- this._multiDrawCounts = new Int32Array( maxGeometryCount );
33888
- this._multiDrawStarts = new Int32Array( maxGeometryCount );
34454
+ this._multiDrawCounts = new Int32Array( maxInstanceCount );
34455
+ this._multiDrawStarts = new Int32Array( maxInstanceCount );
33889
34456
  this._multiDrawCount = 0;
33890
34457
  this._multiDrawInstances = null;
33891
34458
  this._visibilityChanged = true;
33892
34459
 
33893
34460
  // Local matrix per geometry by using data texture
33894
34461
  this._matricesTexture = null;
34462
+ this._indirectTexture = null;
34463
+ this._colorsTexture = null;
33895
34464
 
33896
34465
  this._initMatricesTexture();
34466
+ this._initIndirectTexture();
33897
34467
 
33898
34468
  }
33899
34469
 
@@ -33906,7 +34476,7 @@ class BatchedMesh extends Mesh {
33906
34476
  // 32x32 pixel texture max 256 matrices * 4 pixels = (32 * 32)
33907
34477
  // 64x64 pixel texture max 1024 matrices * 4 pixels = (64 * 64)
33908
34478
 
33909
- let size = Math.sqrt( this._maxGeometryCount * 4 ); // 4 pixels needed for 1 matrix
34479
+ let size = Math.sqrt( this._maxInstanceCount * 4 ); // 4 pixels needed for 1 matrix
33910
34480
  size = Math.ceil( size / 4 ) * 4;
33911
34481
  size = Math.max( size, 4 );
33912
34482
 
@@ -33917,11 +34487,36 @@ class BatchedMesh extends Mesh {
33917
34487
 
33918
34488
  }
33919
34489
 
34490
+ _initIndirectTexture() {
34491
+
34492
+ let size = Math.sqrt( this._maxInstanceCount );
34493
+ size = Math.ceil( size );
34494
+
34495
+ const indirectArray = new Uint32Array( size * size );
34496
+ const indirectTexture = new DataTexture( indirectArray, size, size, RedIntegerFormat, UnsignedIntType );
34497
+
34498
+ this._indirectTexture = indirectTexture;
34499
+
34500
+ }
34501
+
34502
+ _initColorsTexture() {
34503
+
34504
+ let size = Math.sqrt( this._maxIndexCount );
34505
+ size = Math.ceil( size );
34506
+
34507
+ // 4 floats per RGBA pixel initialized to white
34508
+ const colorsArray = new Float32Array( size * size * 4 ).fill( 1 );
34509
+ const colorsTexture = new DataTexture( colorsArray, size, size, RGBAFormat, FloatType );
34510
+ colorsTexture.colorSpace = ColorManagement.workingColorSpace;
34511
+
34512
+ this._colorsTexture = colorsTexture;
34513
+
34514
+ }
34515
+
33920
34516
  _initializeGeometry( reference ) {
33921
34517
 
33922
34518
  const geometry = this.geometry;
33923
34519
  const maxVertexCount = this._maxVertexCount;
33924
- const maxGeometryCount = this._maxGeometryCount;
33925
34520
  const maxIndexCount = this._maxIndexCount;
33926
34521
  if ( this._geometryInitialized === false ) {
33927
34522
 
@@ -33939,7 +34534,8 @@ class BatchedMesh extends Mesh {
33939
34534
 
33940
34535
  if ( reference.getIndex() !== null ) {
33941
34536
 
33942
- const indexArray = maxVertexCount > 65536
34537
+ // Reserve last u16 index for primitive restart.
34538
+ const indexArray = maxVertexCount > 65535
33943
34539
  ? new Uint32Array( maxIndexCount )
33944
34540
  : new Uint16Array( maxIndexCount );
33945
34541
 
@@ -33947,11 +34543,6 @@ class BatchedMesh extends Mesh {
33947
34543
 
33948
34544
  }
33949
34545
 
33950
- const idArray = maxGeometryCount > 65536
33951
- ? new Uint32Array( maxVertexCount )
33952
- : new Uint16Array( maxVertexCount );
33953
- geometry.setAttribute( ID_ATTR_NAME, new BufferAttribute( idArray, 1 ) );
33954
-
33955
34546
  this._geometryInitialized = true;
33956
34547
 
33957
34548
  }
@@ -33961,13 +34552,6 @@ class BatchedMesh extends Mesh {
33961
34552
  // Make sure the geometry is compatible with the existing combined geometry attributes
33962
34553
  _validateGeometry( geometry ) {
33963
34554
 
33964
- // check that the geometry doesn't have a version of our reserved id attribute
33965
- if ( geometry.getAttribute( ID_ATTR_NAME ) ) {
33966
-
33967
- throw new Error( `BatchedMesh: Geometry cannot use attribute "${ ID_ATTR_NAME }"` );
33968
-
33969
- }
33970
-
33971
34555
  // check to ensure the geometries are using consistent attributes and indices
33972
34556
  const batchGeometry = this.geometry;
33973
34557
  if ( Boolean( geometry.getIndex() ) !== Boolean( batchGeometry.getIndex() ) ) {
@@ -33978,12 +34562,6 @@ class BatchedMesh extends Mesh {
33978
34562
 
33979
34563
  for ( const attributeName in batchGeometry.attributes ) {
33980
34564
 
33981
- if ( attributeName === ID_ATTR_NAME ) {
33982
-
33983
- continue;
33984
-
33985
- }
33986
-
33987
34565
  if ( ! geometry.hasAttribute( attributeName ) ) {
33988
34566
 
33989
34567
  throw new Error( `BatchedMesh: Added geometry missing "${ attributeName }". All geometries must have consistent attributes.` );
@@ -34019,15 +34597,16 @@ class BatchedMesh extends Mesh {
34019
34597
 
34020
34598
  const geometryCount = this._geometryCount;
34021
34599
  const boundingBox = this.boundingBox;
34022
- const active = this._active;
34600
+ const drawInfo = this._drawInfo;
34023
34601
 
34024
34602
  boundingBox.makeEmpty();
34025
34603
  for ( let i = 0; i < geometryCount; i ++ ) {
34026
34604
 
34027
- if ( active[ i ] === false ) continue;
34605
+ if ( drawInfo[ i ].active === false ) continue;
34028
34606
 
34607
+ const geometryId = drawInfo[ i ].geometryIndex;
34029
34608
  this.getMatrixAt( i, _matrix$1 );
34030
- this.getBoundingBoxAt( i, _box$1 ).applyMatrix4( _matrix$1 );
34609
+ this.getBoundingBoxAt( geometryId, _box$1 ).applyMatrix4( _matrix$1 );
34031
34610
  boundingBox.union( _box$1 );
34032
34611
 
34033
34612
  }
@@ -34042,23 +34621,59 @@ class BatchedMesh extends Mesh {
34042
34621
 
34043
34622
  }
34044
34623
 
34045
- const geometryCount = this._geometryCount;
34046
34624
  const boundingSphere = this.boundingSphere;
34047
- const active = this._active;
34625
+ const drawInfo = this._drawInfo;
34048
34626
 
34049
34627
  boundingSphere.makeEmpty();
34050
- for ( let i = 0; i < geometryCount; i ++ ) {
34628
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34051
34629
 
34052
- if ( active[ i ] === false ) continue;
34630
+ if ( drawInfo[ i ].active === false ) continue;
34053
34631
 
34632
+ const geometryId = drawInfo[ i ].geometryIndex;
34054
34633
  this.getMatrixAt( i, _matrix$1 );
34055
- this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix$1 );
34634
+ this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
34056
34635
  boundingSphere.union( _sphere$2 );
34057
34636
 
34058
34637
  }
34059
34638
 
34060
34639
  }
34061
34640
 
34641
+ addInstance( geometryId ) {
34642
+
34643
+ // ensure we're not over geometry
34644
+ if ( this._drawInfo.length >= this._maxInstanceCount ) {
34645
+
34646
+ throw new Error( 'BatchedMesh: Maximum item count reached.' );
34647
+
34648
+ }
34649
+
34650
+ this._drawInfo.push( {
34651
+
34652
+ visible: true,
34653
+ active: true,
34654
+ geometryIndex: geometryId,
34655
+
34656
+ } );
34657
+
34658
+ // initialize the matrix
34659
+ const drawId = this._drawInfo.length - 1;
34660
+ const matricesTexture = this._matricesTexture;
34661
+ const matricesArray = matricesTexture.image.data;
34662
+ _identityMatrix.toArray( matricesArray, drawId * 16 );
34663
+ matricesTexture.needsUpdate = true;
34664
+
34665
+ const colorsTexture = this._colorsTexture;
34666
+ if ( colorsTexture ) {
34667
+
34668
+ _whiteColor.toArray( colorsTexture.image.data, drawId * 4 );
34669
+ colorsTexture.needsUpdate = true;
34670
+
34671
+ }
34672
+
34673
+ return drawId;
34674
+
34675
+ }
34676
+
34062
34677
  addGeometry( geometry, vertexCount = - 1, indexCount = - 1 ) {
34063
34678
 
34064
34679
  this._initializeGeometry( geometry );
@@ -34066,9 +34681,9 @@ class BatchedMesh extends Mesh {
34066
34681
  this._validateGeometry( geometry );
34067
34682
 
34068
34683
  // ensure we're not over geometry
34069
- if ( this._geometryCount >= this._maxGeometryCount ) {
34684
+ if ( this._drawInfo.length >= this._maxInstanceCount ) {
34070
34685
 
34071
- throw new Error( 'BatchedMesh: Maximum geometry count reached.' );
34686
+ throw new Error( 'BatchedMesh: Maximum item count reached.' );
34072
34687
 
34073
34688
  }
34074
34689
 
@@ -34146,23 +34761,10 @@ class BatchedMesh extends Mesh {
34146
34761
 
34147
34762
  }
34148
34763
 
34149
- const visibility = this._visibility;
34150
- const active = this._active;
34151
- const matricesTexture = this._matricesTexture;
34152
- const matricesArray = this._matricesTexture.image.data;
34153
-
34154
- // push new visibility states
34155
- visibility.push( true );
34156
- active.push( true );
34157
-
34158
34764
  // update id
34159
34765
  const geometryId = this._geometryCount;
34160
34766
  this._geometryCount ++;
34161
34767
 
34162
- // initialize matrix information
34163
- _identityMatrix.toArray( matricesArray, geometryId * 16 );
34164
- matricesTexture.needsUpdate = true;
34165
-
34166
34768
  // add the reserved range and draw range objects
34167
34769
  reservedRanges.push( reservedRange );
34168
34770
  drawRanges.push( {
@@ -34177,16 +34779,6 @@ class BatchedMesh extends Mesh {
34177
34779
  sphere: new Sphere()
34178
34780
  } );
34179
34781
 
34180
- // set the id for the geometry
34181
- const idAttribute = this.geometry.getAttribute( ID_ATTR_NAME );
34182
- for ( let i = 0; i < reservedRange.vertexCount; i ++ ) {
34183
-
34184
- idAttribute.setX( reservedRange.vertexStart + i, geometryId );
34185
-
34186
- }
34187
-
34188
- idAttribute.needsUpdate = true;
34189
-
34190
34782
  // update the geometry
34191
34783
  this.setGeometryAt( geometryId, geometry );
34192
34784
 
@@ -34194,9 +34786,9 @@ class BatchedMesh extends Mesh {
34194
34786
 
34195
34787
  }
34196
34788
 
34197
- setGeometryAt( id, geometry ) {
34789
+ setGeometryAt( geometryId, geometry ) {
34198
34790
 
34199
- if ( id >= this._geometryCount ) {
34791
+ if ( geometryId >= this._geometryCount ) {
34200
34792
 
34201
34793
  throw new Error( 'BatchedMesh: Maximum geometry count reached.' );
34202
34794
 
@@ -34208,7 +34800,7 @@ class BatchedMesh extends Mesh {
34208
34800
  const hasIndex = batchGeometry.getIndex() !== null;
34209
34801
  const dstIndex = batchGeometry.getIndex();
34210
34802
  const srcIndex = geometry.getIndex();
34211
- const reservedRange = this._reservedRanges[ id ];
34803
+ const reservedRange = this._reservedRanges[ geometryId ];
34212
34804
  if (
34213
34805
  hasIndex &&
34214
34806
  srcIndex.count > reservedRange.indexCount ||
@@ -34224,12 +34816,6 @@ class BatchedMesh extends Mesh {
34224
34816
  const vertexCount = reservedRange.vertexCount;
34225
34817
  for ( const attributeName in batchGeometry.attributes ) {
34226
34818
 
34227
- if ( attributeName === ID_ATTR_NAME ) {
34228
-
34229
- continue;
34230
-
34231
- }
34232
-
34233
34819
  // copy attribute data
34234
34820
  const srcAttribute = geometry.getAttribute( attributeName );
34235
34821
  const dstAttribute = batchGeometry.getAttribute( attributeName );
@@ -34278,7 +34864,7 @@ class BatchedMesh extends Mesh {
34278
34864
  }
34279
34865
 
34280
34866
  // store the bounding boxes
34281
- const bound = this._bounds[ id ];
34867
+ const bound = this._bounds[ geometryId ];
34282
34868
  if ( geometry.boundingBox !== null ) {
34283
34869
 
34284
34870
  bound.box.copy( geometry.boundingBox );
@@ -34302,67 +34888,54 @@ class BatchedMesh extends Mesh {
34302
34888
  }
34303
34889
 
34304
34890
  // set drawRange count
34305
- const drawRange = this._drawRanges[ id ];
34891
+ const drawRange = this._drawRanges[ geometryId ];
34306
34892
  const posAttr = geometry.getAttribute( 'position' );
34307
34893
  drawRange.count = hasIndex ? srcIndex.count : posAttr.count;
34308
34894
  this._visibilityChanged = true;
34309
34895
 
34310
- return id;
34896
+ return geometryId;
34311
34897
 
34312
34898
  }
34313
34899
 
34900
+ /*
34314
34901
  deleteGeometry( geometryId ) {
34315
34902
 
34316
- // Note: User needs to call optimize() afterward to pack the data.
34317
-
34318
- const active = this._active;
34319
- if ( geometryId >= active.length || active[ geometryId ] === false ) {
34320
-
34321
- return this;
34322
-
34323
- }
34324
-
34325
- active[ geometryId ] = false;
34326
- this._visibilityChanged = true;
34327
-
34328
- return this;
34903
+ // TODO: delete geometry and associated instances
34329
34904
 
34330
34905
  }
34906
+ */
34331
34907
 
34332
- getInstanceCountAt( id ) {
34333
-
34334
- if ( this._multiDrawInstances === null ) return null;
34335
-
34336
- return this._multiDrawInstances[ id ];
34337
-
34338
- }
34908
+ /*
34909
+ deleteInstance( instanceId ) {
34339
34910
 
34340
- setInstanceCountAt( id, instanceCount ) {
34911
+ // Note: User needs to call optimize() afterward to pack the data.
34341
34912
 
34342
- if ( this._multiDrawInstances === null ) {
34913
+ const drawInfo = this._drawInfo;
34914
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34343
34915
 
34344
- this._multiDrawInstances = new Int32Array( this._maxGeometryCount ).fill( 1 );
34916
+ return this;
34345
34917
 
34346
34918
  }
34347
34919
 
34348
- this._multiDrawInstances[ id ] = instanceCount;
34920
+ drawInfo[ instanceId ].active = false;
34921
+ this._visibilityChanged = true;
34349
34922
 
34350
- return id;
34923
+ return this;
34351
34924
 
34352
34925
  }
34926
+ */
34353
34927
 
34354
34928
  // get bounding box and compute it if it doesn't exist
34355
- getBoundingBoxAt( id, target ) {
34929
+ getBoundingBoxAt( geometryId, target ) {
34356
34930
 
34357
- const active = this._active;
34358
- if ( active[ id ] === false ) {
34931
+ if ( geometryId >= this._geometryCount ) {
34359
34932
 
34360
34933
  return null;
34361
34934
 
34362
34935
  }
34363
34936
 
34364
34937
  // compute bounding box
34365
- const bound = this._bounds[ id ];
34938
+ const bound = this._bounds[ geometryId ];
34366
34939
  const box = bound.box;
34367
34940
  const geometry = this.geometry;
34368
34941
  if ( bound.boxInitialized === false ) {
@@ -34371,7 +34944,7 @@ class BatchedMesh extends Mesh {
34371
34944
 
34372
34945
  const index = geometry.index;
34373
34946
  const position = geometry.attributes.position;
34374
- const drawRange = this._drawRanges[ id ];
34947
+ const drawRange = this._drawRanges[ geometryId ];
34375
34948
  for ( let i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
34376
34949
 
34377
34950
  let iv = i;
@@ -34395,29 +34968,28 @@ class BatchedMesh extends Mesh {
34395
34968
  }
34396
34969
 
34397
34970
  // get bounding sphere and compute it if it doesn't exist
34398
- getBoundingSphereAt( id, target ) {
34971
+ getBoundingSphereAt( geometryId, target ) {
34399
34972
 
34400
- const active = this._active;
34401
- if ( active[ id ] === false ) {
34973
+ if ( geometryId >= this._geometryCount ) {
34402
34974
 
34403
34975
  return null;
34404
34976
 
34405
34977
  }
34406
34978
 
34407
34979
  // compute bounding sphere
34408
- const bound = this._bounds[ id ];
34980
+ const bound = this._bounds[ geometryId ];
34409
34981
  const sphere = bound.sphere;
34410
34982
  const geometry = this.geometry;
34411
34983
  if ( bound.sphereInitialized === false ) {
34412
34984
 
34413
34985
  sphere.makeEmpty();
34414
34986
 
34415
- this.getBoundingBoxAt( id, _box$1 );
34987
+ this.getBoundingBoxAt( geometryId, _box$1 );
34416
34988
  _box$1.getCenter( sphere.center );
34417
34989
 
34418
34990
  const index = geometry.index;
34419
34991
  const position = geometry.attributes.position;
34420
- const drawRange = this._drawRanges[ id ];
34992
+ const drawRange = this._drawRanges[ geometryId ];
34421
34993
 
34422
34994
  let maxRadiusSq = 0;
34423
34995
  for ( let i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
@@ -34444,91 +35016,122 @@ class BatchedMesh extends Mesh {
34444
35016
 
34445
35017
  }
34446
35018
 
34447
- setMatrixAt( geometryId, matrix ) {
35019
+ setMatrixAt( instanceId, matrix ) {
34448
35020
 
34449
35021
  // @TODO: Map geometryId to index of the arrays because
34450
35022
  // optimize() can make geometryId mismatch the index
34451
35023
 
34452
- const active = this._active;
35024
+ const drawInfo = this._drawInfo;
34453
35025
  const matricesTexture = this._matricesTexture;
34454
35026
  const matricesArray = this._matricesTexture.image.data;
34455
- const geometryCount = this._geometryCount;
34456
- if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
35027
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34457
35028
 
34458
35029
  return this;
34459
35030
 
34460
35031
  }
34461
35032
 
34462
- matrix.toArray( matricesArray, geometryId * 16 );
35033
+ matrix.toArray( matricesArray, instanceId * 16 );
34463
35034
  matricesTexture.needsUpdate = true;
34464
35035
 
34465
35036
  return this;
34466
35037
 
34467
35038
  }
34468
35039
 
34469
- getMatrixAt( geometryId, matrix ) {
35040
+ getMatrixAt( instanceId, matrix ) {
34470
35041
 
34471
- const active = this._active;
35042
+ const drawInfo = this._drawInfo;
34472
35043
  const matricesArray = this._matricesTexture.image.data;
34473
- const geometryCount = this._geometryCount;
34474
- if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
35044
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34475
35045
 
34476
35046
  return null;
34477
35047
 
34478
35048
  }
34479
35049
 
34480
- return matrix.fromArray( matricesArray, geometryId * 16 );
35050
+ return matrix.fromArray( matricesArray, instanceId * 16 );
34481
35051
 
34482
35052
  }
34483
35053
 
34484
- setVisibleAt( geometryId, value ) {
35054
+ setColorAt( instanceId, color ) {
34485
35055
 
34486
- const visibility = this._visibility;
34487
- const active = this._active;
34488
- const geometryCount = this._geometryCount;
35056
+ if ( this._colorsTexture === null ) {
35057
+
35058
+ this._initColorsTexture();
35059
+
35060
+ }
35061
+
35062
+ // @TODO: Map id to index of the arrays because
35063
+ // optimize() can make id mismatch the index
35064
+
35065
+ const colorsTexture = this._colorsTexture;
35066
+ const colorsArray = this._colorsTexture.image.data;
35067
+ const drawInfo = this._drawInfo;
35068
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35069
+
35070
+ return this;
35071
+
35072
+ }
35073
+
35074
+ color.toArray( colorsArray, instanceId * 4 );
35075
+ colorsTexture.needsUpdate = true;
35076
+
35077
+ return this;
35078
+
35079
+ }
35080
+
35081
+ getColorAt( instanceId, color ) {
35082
+
35083
+ const colorsArray = this._colorsTexture.image.data;
35084
+ const drawInfo = this._drawInfo;
35085
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35086
+
35087
+ return null;
35088
+
35089
+ }
35090
+
35091
+ return color.fromArray( colorsArray, instanceId * 4 );
35092
+
35093
+ }
35094
+
35095
+ setVisibleAt( instanceId, value ) {
34489
35096
 
34490
35097
  // if the geometry is out of range, not active, or visibility state
34491
35098
  // does not change then return early
35099
+ const drawInfo = this._drawInfo;
34492
35100
  if (
34493
- geometryId >= geometryCount ||
34494
- active[ geometryId ] === false ||
34495
- visibility[ geometryId ] === value
35101
+ instanceId >= drawInfo.length ||
35102
+ drawInfo[ instanceId ].active === false ||
35103
+ drawInfo[ instanceId ].visible === value
34496
35104
  ) {
34497
35105
 
34498
35106
  return this;
34499
35107
 
34500
35108
  }
34501
35109
 
34502
- visibility[ geometryId ] = value;
35110
+ drawInfo[ instanceId ].visible = value;
34503
35111
  this._visibilityChanged = true;
34504
35112
 
34505
35113
  return this;
34506
35114
 
34507
35115
  }
34508
35116
 
34509
- getVisibleAt( geometryId ) {
34510
-
34511
- const visibility = this._visibility;
34512
- const active = this._active;
34513
- const geometryCount = this._geometryCount;
35117
+ getVisibleAt( instanceId ) {
34514
35118
 
34515
35119
  // return early if the geometry is out of range or not active
34516
- if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
35120
+ const drawInfo = this._drawInfo;
35121
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34517
35122
 
34518
35123
  return false;
34519
35124
 
34520
35125
  }
34521
35126
 
34522
- return visibility[ geometryId ];
35127
+ return drawInfo[ instanceId ].visible;
34523
35128
 
34524
35129
  }
34525
35130
 
34526
35131
  raycast( raycaster, intersects ) {
34527
35132
 
34528
- const visibility = this._visibility;
34529
- const active = this._active;
35133
+ const drawInfo = this._drawInfo;
34530
35134
  const drawRanges = this._drawRanges;
34531
- const geometryCount = this._geometryCount;
34532
35135
  const matrixWorld = this.matrixWorld;
34533
35136
  const batchGeometry = this.geometry;
34534
35137
 
@@ -34548,21 +35151,22 @@ class BatchedMesh extends Mesh {
34548
35151
 
34549
35152
  }
34550
35153
 
34551
- for ( let i = 0; i < geometryCount; i ++ ) {
35154
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34552
35155
 
34553
- if ( ! visibility[ i ] || ! active[ i ] ) {
35156
+ if ( ! drawInfo[ i ].visible || ! drawInfo[ i ].active ) {
34554
35157
 
34555
35158
  continue;
34556
35159
 
34557
35160
  }
34558
35161
 
34559
- const drawRange = drawRanges[ i ];
35162
+ const geometryId = drawInfo[ i ].geometryIndex;
35163
+ const drawRange = drawRanges[ geometryId ];
34560
35164
  _mesh.geometry.setDrawRange( drawRange.start, drawRange.count );
34561
35165
 
34562
35166
  // ge the intersects
34563
35167
  this.getMatrixAt( i, _mesh.matrixWorld ).premultiply( matrixWorld );
34564
- this.getBoundingBoxAt( i, _mesh.geometry.boundingBox );
34565
- this.getBoundingSphereAt( i, _mesh.geometry.boundingSphere );
35168
+ this.getBoundingBoxAt( geometryId, _mesh.geometry.boundingBox );
35169
+ this.getBoundingSphereAt( geometryId, _mesh.geometry.boundingSphere );
34566
35170
  _mesh.raycast( raycaster, _batchIntersects );
34567
35171
 
34568
35172
  // add batch id to the intersects
@@ -34599,8 +35203,7 @@ class BatchedMesh extends Mesh {
34599
35203
  this._drawRanges = source._drawRanges.map( range => ( { ...range } ) );
34600
35204
  this._reservedRanges = source._reservedRanges.map( range => ( { ...range } ) );
34601
35205
 
34602
- this._visibility = source._visibility.slice();
34603
- this._active = source._active.slice();
35206
+ this._drawInfo = source._drawInfo.map( inf => ( { ...inf } ) );
34604
35207
  this._bounds = source._bounds.map( bound => ( {
34605
35208
  boxInitialized: bound.boxInitialized,
34606
35209
  box: bound.box.clone(),
@@ -34609,7 +35212,7 @@ class BatchedMesh extends Mesh {
34609
35212
  sphere: bound.sphere.clone()
34610
35213
  } ) );
34611
35214
 
34612
- this._maxGeometryCount = source._maxGeometryCount;
35215
+ this._maxInstanceCount = source._maxInstanceCount;
34613
35216
  this._maxVertexCount = source._maxVertexCount;
34614
35217
  this._maxIndexCount = source._maxIndexCount;
34615
35218
 
@@ -34619,7 +35222,14 @@ class BatchedMesh extends Mesh {
34619
35222
  this._multiDrawStarts = source._multiDrawStarts.slice();
34620
35223
 
34621
35224
  this._matricesTexture = source._matricesTexture.clone();
34622
- this._matricesTexture.image.data = this._matricesTexture.image.slice();
35225
+ this._matricesTexture.image.data = this._matricesTexture.image.data.slice();
35226
+
35227
+ if ( this._colorsTexture !== null ) {
35228
+
35229
+ this._colorsTexture = source._colorsTexture.clone();
35230
+ this._colorsTexture.image.data = this._colorsTexture.image.data.slice();
35231
+
35232
+ }
34623
35233
 
34624
35234
  return this;
34625
35235
 
@@ -34632,6 +35242,17 @@ class BatchedMesh extends Mesh {
34632
35242
 
34633
35243
  this._matricesTexture.dispose();
34634
35244
  this._matricesTexture = null;
35245
+
35246
+ this._indirectTexture.dispose();
35247
+ this._indirectTexture = null;
35248
+
35249
+ if ( this._colorsTexture !== null ) {
35250
+
35251
+ this._colorsTexture.dispose();
35252
+ this._colorsTexture = null;
35253
+
35254
+ }
35255
+
34635
35256
  return this;
34636
35257
 
34637
35258
  }
@@ -34651,12 +35272,13 @@ class BatchedMesh extends Mesh {
34651
35272
  const index = geometry.getIndex();
34652
35273
  const bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;
34653
35274
 
34654
- const active = this._active;
34655
- const visibility = this._visibility;
35275
+ const drawInfo = this._drawInfo;
34656
35276
  const multiDrawStarts = this._multiDrawStarts;
34657
35277
  const multiDrawCounts = this._multiDrawCounts;
34658
35278
  const drawRanges = this._drawRanges;
34659
35279
  const perObjectFrustumCulled = this.perObjectFrustumCulled;
35280
+ const indirectTexture = this._indirectTexture;
35281
+ const indirectArray = indirectTexture.image.data;
34660
35282
 
34661
35283
  // prepare the frustum in the local frame
34662
35284
  if ( perObjectFrustumCulled ) {
@@ -34677,14 +35299,17 @@ class BatchedMesh extends Mesh {
34677
35299
  // get the camera position in the local frame
34678
35300
  _invMatrixWorld.copy( this.matrixWorld ).invert();
34679
35301
  _vector$5.setFromMatrixPosition( camera.matrixWorld ).applyMatrix4( _invMatrixWorld );
35302
+ _forward.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ).transformDirection( _invMatrixWorld );
34680
35303
 
34681
- for ( let i = 0, l = visibility.length; i < l; i ++ ) {
35304
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34682
35305
 
34683
- if ( visibility[ i ] && active[ i ] ) {
35306
+ if ( drawInfo[ i ].visible && drawInfo[ i ].active ) {
35307
+
35308
+ const geometryId = drawInfo[ i ].geometryIndex;
34684
35309
 
34685
35310
  // get the bounds in world space
34686
35311
  this.getMatrixAt( i, _matrix$1 );
34687
- this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix$1 );
35312
+ this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
34688
35313
 
34689
35314
  // determine whether the batched geometry is within the frustum
34690
35315
  let culled = false;
@@ -34697,8 +35322,8 @@ class BatchedMesh extends Mesh {
34697
35322
  if ( ! culled ) {
34698
35323
 
34699
35324
  // get the distance from camera used for sorting
34700
- const z = _vector$5.distanceTo( _sphere$2.center );
34701
- _renderList.push( drawRanges[ i ], z );
35325
+ const z = _temp.subVectors( _sphere$2.center, _vector$5 ).dot( _forward );
35326
+ _renderList.push( drawRanges[ geometryId ], z, i );
34702
35327
 
34703
35328
  }
34704
35329
 
@@ -34724,6 +35349,7 @@ class BatchedMesh extends Mesh {
34724
35349
  const item = list[ i ];
34725
35350
  multiDrawStarts[ count ] = item.start * bytesPerElement;
34726
35351
  multiDrawCounts[ count ] = item.count;
35352
+ indirectArray[ count ] = item.index;
34727
35353
  count ++;
34728
35354
 
34729
35355
  }
@@ -34732,9 +35358,11 @@ class BatchedMesh extends Mesh {
34732
35358
 
34733
35359
  } else {
34734
35360
 
34735
- for ( let i = 0, l = visibility.length; i < l; i ++ ) {
35361
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
35362
+
35363
+ if ( drawInfo[ i ].visible && drawInfo[ i ].active ) {
34736
35364
 
34737
- if ( visibility[ i ] && active[ i ] ) {
35365
+ const geometryId = drawInfo[ i ].geometryIndex;
34738
35366
 
34739
35367
  // determine whether the batched geometry is within the frustum
34740
35368
  let culled = false;
@@ -34742,16 +35370,17 @@ class BatchedMesh extends Mesh {
34742
35370
 
34743
35371
  // get the bounds in world space
34744
35372
  this.getMatrixAt( i, _matrix$1 );
34745
- this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix$1 );
35373
+ this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
34746
35374
  culled = ! _frustum.intersectsSphere( _sphere$2 );
34747
35375
 
34748
35376
  }
34749
35377
 
34750
35378
  if ( ! culled ) {
34751
35379
 
34752
- const range = drawRanges[ i ];
35380
+ const range = drawRanges[ geometryId ];
34753
35381
  multiDrawStarts[ count ] = range.start * bytesPerElement;
34754
35382
  multiDrawCounts[ count ] = range.count;
35383
+ indirectArray[ count ] = i;
34755
35384
  count ++;
34756
35385
 
34757
35386
  }
@@ -34762,6 +35391,7 @@ class BatchedMesh extends Mesh {
34762
35391
 
34763
35392
  }
34764
35393
 
35394
+ indirectTexture.needsUpdate = true;
34765
35395
  this._multiDrawCount = count;
34766
35396
  this._visibilityChanged = false;
34767
35397
 
@@ -35427,6 +36057,20 @@ class CompressedArrayTexture extends CompressedTexture {
35427
36057
  this.image.depth = depth;
35428
36058
  this.wrapR = ClampToEdgeWrapping;
35429
36059
 
36060
+ this.layerUpdates = new Set();
36061
+
36062
+ }
36063
+
36064
+ addLayerUpdate( layerIndex ) {
36065
+
36066
+ this.layerUpdates.add( layerIndex );
36067
+
36068
+ }
36069
+
36070
+ clearLayerUpdates() {
36071
+
36072
+ this.layerUpdates.clear();
36073
+
35430
36074
  }
35431
36075
 
35432
36076
  }
@@ -43591,7 +44235,16 @@ KeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear;
43591
44235
  /**
43592
44236
  * A Track of Boolean keyframe values.
43593
44237
  */
43594
- class BooleanKeyframeTrack extends KeyframeTrack {}
44238
+ class BooleanKeyframeTrack extends KeyframeTrack {
44239
+
44240
+ // No interpolation parameter because only InterpolateDiscrete is valid.
44241
+ constructor( name, times, values ) {
44242
+
44243
+ super( name, times, values );
44244
+
44245
+ }
44246
+
44247
+ }
43595
44248
 
43596
44249
  BooleanKeyframeTrack.prototype.ValueTypeName = 'bool';
43597
44250
  BooleanKeyframeTrack.prototype.ValueBufferType = Array;
@@ -43662,13 +44315,22 @@ class QuaternionKeyframeTrack extends KeyframeTrack {
43662
44315
 
43663
44316
  QuaternionKeyframeTrack.prototype.ValueTypeName = 'quaternion';
43664
44317
  // ValueBufferType is inherited
43665
- QuaternionKeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear;
44318
+ // DefaultInterpolation is inherited;
43666
44319
  QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined;
43667
44320
 
43668
44321
  /**
43669
44322
  * A Track that interpolates Strings
43670
44323
  */
43671
- class StringKeyframeTrack extends KeyframeTrack {}
44324
+ class StringKeyframeTrack extends KeyframeTrack {
44325
+
44326
+ // No interpolation parameter because only InterpolateDiscrete is valid.
44327
+ constructor( name, times, values ) {
44328
+
44329
+ super( name, times, values );
44330
+
44331
+ }
44332
+
44333
+ }
43672
44334
 
43673
44335
  StringKeyframeTrack.prototype.ValueTypeName = 'string';
43674
44336
  StringKeyframeTrack.prototype.ValueBufferType = Array;
@@ -44541,6 +45203,10 @@ class FileLoader extends Loader {
44541
45203
 
44542
45204
  }
44543
45205
 
45206
+ }, ( e ) => {
45207
+
45208
+ controller.error( e );
45209
+
44544
45210
  } );
44545
45211
 
44546
45212
  }
@@ -45202,6 +45868,7 @@ class Light extends Object3D {
45202
45868
  if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;
45203
45869
 
45204
45870
  if ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();
45871
+ if ( this.target !== undefined ) data.object.target = this.target.uuid;
45205
45872
 
45206
45873
  return data;
45207
45874
 
@@ -45248,6 +45915,8 @@ class LightShadow {
45248
45915
 
45249
45916
  this.camera = camera;
45250
45917
 
45918
+ this.intensity = 1;
45919
+
45251
45920
  this.bias = 0;
45252
45921
  this.normalBias = 0;
45253
45922
  this.radius = 1;
@@ -45345,6 +46014,8 @@ class LightShadow {
45345
46014
 
45346
46015
  this.camera = source.camera.clone();
45347
46016
 
46017
+ this.intensity = source.intensity;
46018
+
45348
46019
  this.bias = source.bias;
45349
46020
  this.radius = source.radius;
45350
46021
 
@@ -45364,6 +46035,7 @@ class LightShadow {
45364
46035
 
45365
46036
  const object = {};
45366
46037
 
46038
+ if ( this.intensity !== 1 ) object.intensity = this.intensity;
45367
46039
  if ( this.bias !== 0 ) object.bias = this.bias;
45368
46040
  if ( this.normalBias !== 0 ) object.normalBias = this.normalBias;
45369
46041
  if ( this.radius !== 1 ) object.radius = this.radius;
@@ -46376,7 +47048,9 @@ class MaterialLoader extends Loader {
46376
47048
 
46377
47049
  class LoaderUtils {
46378
47050
 
46379
- static decodeText( array ) {
47051
+ static decodeText( array ) { // @deprecated, r165
47052
+
47053
+ console.warn( 'THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead.' );
46380
47054
 
46381
47055
  if ( typeof TextDecoder !== 'undefined' ) {
46382
47056
 
@@ -46790,6 +47464,7 @@ class ObjectLoader extends Loader {
46790
47464
  const skeletons = this.parseSkeletons( json.skeletons, object );
46791
47465
 
46792
47466
  this.bindSkeletons( object, skeletons );
47467
+ this.bindLightTargets( object );
46793
47468
 
46794
47469
  //
46795
47470
 
@@ -46831,6 +47506,7 @@ class ObjectLoader extends Loader {
46831
47506
  const skeletons = this.parseSkeletons( json.skeletons, object );
46832
47507
 
46833
47508
  this.bindSkeletons( object, skeletons );
47509
+ this.bindLightTargets( object );
46834
47510
 
46835
47511
  return object;
46836
47512
 
@@ -47475,6 +48151,7 @@ class ObjectLoader extends Loader {
47475
48151
  case 'DirectionalLight':
47476
48152
 
47477
48153
  object = new DirectionalLight( data.color, data.intensity );
48154
+ object.target = data.target || '';
47478
48155
 
47479
48156
  break;
47480
48157
 
@@ -47493,6 +48170,7 @@ class ObjectLoader extends Loader {
47493
48170
  case 'SpotLight':
47494
48171
 
47495
48172
  object = new SpotLight( data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay );
48173
+ object.target = data.target || '';
47496
48174
 
47497
48175
  break;
47498
48176
 
@@ -47549,7 +48227,7 @@ class ObjectLoader extends Loader {
47549
48227
  geometry = getGeometry( data.geometry );
47550
48228
  material = getMaterial( data.material );
47551
48229
 
47552
- object = new BatchedMesh( data.maxGeometryCount, data.maxVertexCount, data.maxIndexCount, material );
48230
+ object = new BatchedMesh( data.maxInstanceCount, data.maxVertexCount, data.maxIndexCount, material );
47553
48231
  object.geometry = geometry;
47554
48232
  object.perObjectFrustumCulled = data.perObjectFrustumCulled;
47555
48233
  object.sortObjects = data.sortObjects;
@@ -47579,7 +48257,7 @@ class ObjectLoader extends Loader {
47579
48257
 
47580
48258
  } );
47581
48259
 
47582
- object._maxGeometryCount = data.maxGeometryCount;
48260
+ object._maxInstanceCount = data.maxInstanceCount;
47583
48261
  object._maxVertexCount = data.maxVertexCount;
47584
48262
  object._maxIndexCount = data.maxIndexCount;
47585
48263
 
@@ -47587,6 +48265,7 @@ class ObjectLoader extends Loader {
47587
48265
  object._geometryCount = data.geometryCount;
47588
48266
 
47589
48267
  object._matricesTexture = getTexture( data.matricesTexture.uuid );
48268
+ if ( data.colorsTexture !== undefined ) object._colorsTexture = getTexture( data.colorsTexture.uuid );
47590
48269
 
47591
48270
  break;
47592
48271
 
@@ -47672,6 +48351,7 @@ class ObjectLoader extends Loader {
47672
48351
 
47673
48352
  if ( data.shadow ) {
47674
48353
 
48354
+ if ( data.shadow.intensity !== undefined ) object.shadow.intensity = data.shadow.intensity;
47675
48355
  if ( data.shadow.bias !== undefined ) object.shadow.bias = data.shadow.bias;
47676
48356
  if ( data.shadow.normalBias !== undefined ) object.shadow.normalBias = data.shadow.normalBias;
47677
48357
  if ( data.shadow.radius !== undefined ) object.shadow.radius = data.shadow.radius;
@@ -47763,6 +48443,32 @@ class ObjectLoader extends Loader {
47763
48443
 
47764
48444
  }
47765
48445
 
48446
+ bindLightTargets( object ) {
48447
+
48448
+ object.traverse( function ( child ) {
48449
+
48450
+ if ( child.isDirectionalLight || child.isSpotLight ) {
48451
+
48452
+ const uuid = child.target;
48453
+
48454
+ const target = object.getObjectByProperty( 'uuid', uuid );
48455
+
48456
+ if ( target !== undefined ) {
48457
+
48458
+ child.target = target;
48459
+
48460
+ } else {
48461
+
48462
+ child.target = new Object3D();
48463
+
48464
+ }
48465
+
48466
+ }
48467
+
48468
+ } );
48469
+
48470
+ }
48471
+
47766
48472
  }
47767
48473
 
47768
48474
  const TEXTURE_MAPPING = {
@@ -52049,13 +52755,17 @@ function ascSort( a, b ) {
52049
52755
 
52050
52756
  function intersect( object, raycaster, intersects, recursive ) {
52051
52757
 
52758
+ let propagate = true;
52759
+
52052
52760
  if ( object.layers.test( raycaster.layers ) ) {
52053
52761
 
52054
- object.raycast( raycaster, intersects );
52762
+ const result = object.raycast( raycaster, intersects );
52763
+
52764
+ if ( result === false ) propagate = false;
52055
52765
 
52056
52766
  }
52057
52767
 
52058
- if ( recursive === true ) {
52768
+ if ( propagate === true && recursive === true ) {
52059
52769
 
52060
52770
  const children = object.children;
52061
52771
 
@@ -52211,6 +52921,61 @@ class Cylindrical {
52211
52921
 
52212
52922
  }
52213
52923
 
52924
+ class Matrix2 {
52925
+
52926
+ constructor( n11, n12, n21, n22 ) {
52927
+
52928
+ Matrix2.prototype.isMatrix2 = true;
52929
+
52930
+ this.elements = [
52931
+ 1, 0,
52932
+ 0, 1,
52933
+ ];
52934
+
52935
+ if ( n11 !== undefined ) {
52936
+
52937
+ this.set( n11, n12, n21, n22 );
52938
+
52939
+ }
52940
+
52941
+ }
52942
+
52943
+ identity() {
52944
+
52945
+ this.set(
52946
+ 1, 0,
52947
+ 0, 1,
52948
+ );
52949
+
52950
+ return this;
52951
+
52952
+ }
52953
+
52954
+ fromArray( array, offset = 0 ) {
52955
+
52956
+ for ( let i = 0; i < 4; i ++ ) {
52957
+
52958
+ this.elements[ i ] = array[ i + offset ];
52959
+
52960
+ }
52961
+
52962
+ return this;
52963
+
52964
+ }
52965
+
52966
+ set( n11, n12, n21, n22 ) {
52967
+
52968
+ const te = this.elements;
52969
+
52970
+ te[ 0 ] = n11; te[ 2 ] = n12;
52971
+ te[ 1 ] = n21; te[ 3 ] = n22;
52972
+
52973
+ return this;
52974
+
52975
+ }
52976
+
52977
+ }
52978
+
52214
52979
  const _vector$4 = /*@__PURE__*/ new Vector2();
52215
52980
 
52216
52981
  class Box2 {
@@ -52330,8 +53095,8 @@ class Box2 {
52330
53095
 
52331
53096
  containsPoint( point ) {
52332
53097
 
52333
- return point.x < this.min.x || point.x > this.max.x ||
52334
- point.y < this.min.y || point.y > this.max.y ? false : true;
53098
+ return point.x >= this.min.x && point.x <= this.max.x &&
53099
+ point.y >= this.min.y && point.y <= this.max.y;
52335
53100
 
52336
53101
  }
52337
53102
 
@@ -52358,8 +53123,8 @@ class Box2 {
52358
53123
 
52359
53124
  // using 4 splitting planes to rule out intersections
52360
53125
 
52361
- return box.max.x < this.min.x || box.min.x > this.max.x ||
52362
- box.max.y < this.min.y || box.min.y > this.max.y ? false : true;
53126
+ return box.max.x >= this.min.x && box.min.x <= this.max.x &&
53127
+ box.max.y >= this.min.y && box.min.y <= this.max.y;
52363
53128
 
52364
53129
  }
52365
53130
 
@@ -54084,4 +54849,4 @@ if ( typeof window !== 'undefined' ) {
54084
54849
 
54085
54850
  }
54086
54851
 
54087
- export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BackSide, BasicDepthPacking, BasicShadowMap, BatchedMesh, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CineonToneMapping, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, ColorManagement, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, ConstantAlphaFactor, ConstantColorFactor, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry, Cylindrical, Data3DTexture, DataArrayTexture, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DisplayP3ColorSpace, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualCompare, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, FloatType, Fog, FogExp2, FramebufferTexture, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearDisplayP3ColorSpace, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry, OneFactor, OneMinusConstantAlphaFactor, OneMinusConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, P3Primaries, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, Path, PerspectiveCamera, Plane, PlaneGeometry, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBFormat, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, Rec709Primaries, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RenderTarget, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, Scene, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry, Texture, TextureLoader, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, VideoTexture, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLRenderTarget, WebGLRenderer, WebGLUtils, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, createCanvasElement };
54852
+ export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BackSide, BasicDepthPacking, BasicShadowMap, BatchedMesh, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CineonToneMapping, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, ColorManagement, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, ConstantAlphaFactor, ConstantColorFactor, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry, Cylindrical, Data3DTexture, DataArrayTexture, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DisplayP3ColorSpace, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualCompare, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, FloatType, Fog, FogExp2, FramebufferTexture, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearDisplayP3ColorSpace, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils, Matrix2, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry, OneFactor, OneMinusConstantAlphaFactor, OneMinusConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, P3Primaries, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, Path, PerspectiveCamera, Plane, PlaneGeometry, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBDepthPacking, RGBFormat, RGBIntegerFormat, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGDepthPacking, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, Rec709Primaries, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RenderTarget, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, Scene, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry, Texture, TextureLoader, TextureUtils, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, VideoTexture, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLRenderTarget, WebGLRenderer, WebGLUtils, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, createCanvasElement };