super-three 0.165.0 → 0.168.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 (462) hide show
  1. package/build/three.cjs +854 -410
  2. package/build/three.module.js +849 -411
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +77755 -0
  5. package/build/three.webgpu.min.js +6 -0
  6. package/examples/jsm/Addons.js +5 -2
  7. package/examples/jsm/animation/AnimationClipCreator.js +1 -1
  8. package/examples/jsm/capabilities/WebGL.js +27 -21
  9. package/examples/jsm/controls/ArcballControls.js +174 -158
  10. package/examples/jsm/controls/DragControls.js +260 -132
  11. package/examples/jsm/controls/FirstPersonControls.js +175 -163
  12. package/examples/jsm/controls/FlyControls.js +194 -188
  13. package/examples/jsm/controls/OrbitControls.js +777 -786
  14. package/examples/jsm/controls/PointerLockControls.js +24 -15
  15. package/examples/jsm/controls/TrackballControls.js +453 -452
  16. package/examples/jsm/csm/CSMShader.js +4 -4
  17. package/examples/jsm/effects/AnaglyphEffect.js +6 -13
  18. package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
  19. package/examples/jsm/effects/StereoEffect.js +6 -1
  20. package/examples/jsm/environments/RoomEnvironment.js +1 -1
  21. package/examples/jsm/exporters/GLTFExporter.js +13 -4
  22. package/examples/jsm/exporters/USDZExporter.js +29 -8
  23. package/examples/jsm/geometries/TeapotGeometry.js +1 -1
  24. package/examples/jsm/helpers/LightProbeHelper.js +42 -43
  25. package/examples/jsm/helpers/ViewHelper.js +51 -2
  26. package/examples/jsm/libs/tween.module.js +64 -75
  27. package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
  28. package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
  29. package/examples/jsm/lines/webgpu/Line2.js +20 -0
  30. package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
  31. package/examples/jsm/loaders/FBXLoader.js +23 -45
  32. package/examples/jsm/loaders/GLTFLoader.js +10 -4
  33. package/examples/jsm/loaders/KTX2Loader.js +19 -7
  34. package/examples/jsm/loaders/MaterialXLoader.js +10 -10
  35. package/examples/jsm/loaders/PCDLoader.js +9 -9
  36. package/examples/jsm/loaders/USDZLoader.js +124 -76
  37. package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
  38. package/examples/jsm/loaders/VTKLoader.js +76 -3
  39. package/examples/jsm/misc/GPUComputationRenderer.js +9 -19
  40. package/examples/jsm/modifiers/SimplifyModifier.js +2 -1
  41. package/examples/jsm/objects/InstancedPoints.js +2 -2
  42. package/examples/jsm/objects/SkyMesh.js +188 -0
  43. package/examples/jsm/objects/Water2Mesh.js +159 -0
  44. package/examples/jsm/objects/WaterMesh.js +102 -0
  45. package/examples/jsm/physics/RapierPhysics.js +20 -0
  46. package/examples/jsm/postprocessing/OutlinePass.js +31 -46
  47. package/examples/jsm/postprocessing/RenderTransitionPass.js +13 -38
  48. package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
  49. package/examples/jsm/postprocessing/SSAOPass.js +6 -9
  50. package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -4
  51. package/examples/jsm/shaders/BleachBypassShader.js +1 -2
  52. package/examples/jsm/shaders/ColorifyShader.js +1 -2
  53. package/examples/jsm/shaders/FXAAShader.js +0 -2
  54. package/examples/jsm/shaders/GTAOShader.js +1 -1
  55. package/examples/jsm/shaders/LuminosityHighPassShader.js +1 -3
  56. package/examples/jsm/shaders/OutputShader.js +1 -1
  57. package/examples/jsm/transpiler/GLSLDecoder.js +46 -4
  58. package/examples/jsm/transpiler/TSLEncoder.js +24 -22
  59. package/examples/jsm/utils/TextureUtils.js +1 -1
  60. package/package.json +8 -6
  61. package/src/Three.WebGPU.js +200 -0
  62. package/src/Three.js +3 -0
  63. package/src/constants.js +4 -1
  64. package/src/core/Object3D.js +22 -22
  65. package/src/extras/Controls.js +32 -0
  66. package/src/extras/TextureUtils.js +210 -0
  67. package/src/lights/Light.js +1 -0
  68. package/src/lights/LightShadow.js +5 -0
  69. package/{examples/jsm/lights → src/lights/webgpu}/IESSpotLight.js +1 -1
  70. package/src/loaders/ObjectLoader.js +33 -2
  71. package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeLoader.js +6 -4
  72. package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeMaterialLoader.js +2 -2
  73. package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeObjectLoader.js +2 -1
  74. package/src/materials/Material.js +7 -1
  75. package/{examples/jsm/nodes/materials → src/materials/nodes}/InstancedPointsNodeMaterial.js +36 -27
  76. package/{examples/jsm/nodes/materials → src/materials/nodes}/Line2NodeMaterial.js +37 -40
  77. package/src/materials/nodes/LineBasicNodeMaterial.js +27 -0
  78. package/{examples/jsm/nodes/materials → src/materials/nodes}/LineDashedNodeMaterial.js +10 -11
  79. package/src/materials/nodes/MeshBasicNodeMaterial.js +73 -0
  80. package/src/materials/nodes/MeshLambertNodeMaterial.js +43 -0
  81. package/src/materials/nodes/MeshMatcapNodeMaterial.js +53 -0
  82. package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
  83. package/src/materials/nodes/MeshPhongNodeMaterial.js +74 -0
  84. package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshPhysicalNodeMaterial.js +22 -20
  85. package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshSSSNodeMaterial.js +6 -6
  86. package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshStandardNodeMaterial.js +28 -11
  87. package/src/materials/nodes/MeshToonNodeMaterial.js +34 -0
  88. package/{examples/jsm/nodes/materials → src/materials/nodes}/NodeMaterial.js +142 -96
  89. package/{examples/jsm/nodes/materials/Materials.js → src/materials/nodes/NodeMaterials.js} +1 -1
  90. package/{examples/jsm/nodes/materials → src/materials/nodes}/PointsNodeMaterial.js +5 -6
  91. package/src/materials/nodes/ShadowNodeMaterial.js +34 -0
  92. package/{examples/jsm/nodes/materials → src/materials/nodes}/SpriteNodeMaterial.js +13 -13
  93. package/{examples/jsm/nodes/materials → src/materials/nodes}/VolumeNodeMaterial.js +14 -16
  94. package/src/math/Box2.js +4 -4
  95. package/src/math/Box3.js +6 -6
  96. package/src/math/ColorManagement.js +10 -0
  97. package/src/math/Matrix2.js +54 -0
  98. package/src/math/Vector4.js +13 -0
  99. package/src/nodes/Nodes.js +164 -0
  100. package/src/nodes/TSL.js +176 -0
  101. package/{examples/jsm → src}/nodes/accessors/AccessorsUtils.js +8 -8
  102. package/src/nodes/accessors/BatchNode.js +124 -0
  103. package/{examples/jsm/nodes/accessors/BitangentNode.js → src/nodes/accessors/Bitangent.js} +9 -9
  104. package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +41 -6
  105. package/{examples/jsm → src}/nodes/accessors/BufferNode.js +4 -4
  106. package/src/nodes/accessors/Camera.js +19 -0
  107. package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +16 -14
  108. package/src/nodes/accessors/CubeTextureNode.js +76 -0
  109. package/src/nodes/accessors/InstanceNode.js +144 -0
  110. package/src/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
  111. package/{examples/jsm → src}/nodes/accessors/MaterialNode.js +66 -49
  112. package/src/nodes/accessors/MaterialProperties.js +3 -0
  113. package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +6 -4
  114. package/src/nodes/accessors/ModelNode.js +37 -0
  115. package/{examples/jsm → src}/nodes/accessors/ModelViewProjectionNode.js +6 -7
  116. package/{examples/jsm → src}/nodes/accessors/MorphNode.js +35 -31
  117. package/src/nodes/accessors/Normal.js +62 -0
  118. package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +11 -11
  119. package/src/nodes/accessors/PointUVNode.js +26 -0
  120. package/src/nodes/accessors/Position.js +10 -0
  121. package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
  122. package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +14 -8
  123. package/src/nodes/accessors/ReflectVector.js +10 -0
  124. package/{examples/jsm → src}/nodes/accessors/RendererReferenceNode.js +6 -6
  125. package/{examples/jsm → src}/nodes/accessors/SceneNode.js +5 -6
  126. package/src/nodes/accessors/SkinningNode.js +187 -0
  127. package/{examples/jsm → src}/nodes/accessors/StorageBufferNode.js +54 -6
  128. package/{examples/jsm → src}/nodes/accessors/StorageTextureNode.js +16 -7
  129. package/src/nodes/accessors/Tangent.js +22 -0
  130. package/{examples/jsm → src}/nodes/accessors/Texture3DNode.js +11 -11
  131. package/{examples/jsm/nodes/accessors/TextureBicubicNode.js → src/nodes/accessors/TextureBicubic.js} +3 -32
  132. package/{examples/jsm → src}/nodes/accessors/TextureNode.js +69 -37
  133. package/{examples/jsm → src}/nodes/accessors/TextureSizeNode.js +4 -6
  134. package/{examples/jsm/nodes/accessors/UniformsNode.js → src/nodes/accessors/UniformArrayNode.js} +24 -9
  135. package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +4 -4
  136. package/src/nodes/accessors/VelocityNode.js +83 -0
  137. package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +6 -5
  138. package/{examples/jsm → src}/nodes/code/CodeNode.js +5 -5
  139. package/{examples/jsm → src}/nodes/code/ExpressionNode.js +4 -4
  140. package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +5 -5
  141. package/{examples/jsm → src}/nodes/code/FunctionNode.js +5 -23
  142. package/{examples/jsm → src}/nodes/code/ScriptableNode.js +18 -6
  143. package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +6 -7
  144. package/{examples/jsm → src}/nodes/core/AssignNode.js +5 -5
  145. package/{examples/jsm → src}/nodes/core/AttributeNode.js +22 -21
  146. package/{examples/jsm → src}/nodes/core/BypassNode.js +5 -5
  147. package/src/nodes/core/CacheNode.js +46 -0
  148. package/{examples/jsm → src}/nodes/core/ConstNode.js +2 -2
  149. package/{examples/jsm → src}/nodes/core/ContextNode.js +17 -11
  150. package/{examples/jsm → src}/nodes/core/IndexNode.js +17 -6
  151. package/{examples/jsm → src}/nodes/core/InputNode.js +2 -2
  152. package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
  153. package/src/nodes/core/MRTNode.js +82 -0
  154. package/{examples/jsm → src}/nodes/core/Node.js +57 -31
  155. package/{examples/jsm → src}/nodes/core/NodeBuilder.js +216 -65
  156. package/src/nodes/core/NodeCache.js +36 -0
  157. package/{examples/jsm → src}/nodes/core/NodeFrame.js +42 -0
  158. package/{examples/jsm → src}/nodes/core/NodeFunction.js +2 -2
  159. package/{examples/jsm → src}/nodes/core/NodeUniform.js +1 -2
  160. package/{examples/jsm → src}/nodes/core/NodeUtils.js +7 -1
  161. package/{examples/jsm → src}/nodes/core/OutputStructNode.js +4 -4
  162. package/{examples/jsm → src}/nodes/core/ParameterNode.js +4 -4
  163. package/src/nodes/core/PropertyNode.js +84 -0
  164. package/{examples/jsm → src}/nodes/core/StackNode.js +26 -10
  165. package/{examples/jsm → src}/nodes/core/StructTypeNode.js +2 -2
  166. package/{examples/jsm → src}/nodes/core/TempNode.js +4 -4
  167. package/src/nodes/core/UniformGroupNode.js +55 -0
  168. package/{examples/jsm → src}/nodes/core/UniformNode.js +14 -5
  169. package/{examples/jsm → src}/nodes/core/VarNode.js +8 -12
  170. package/{examples/jsm → src}/nodes/core/VaryingNode.js +13 -5
  171. package/{examples/jsm → src}/nodes/display/AfterImageNode.js +27 -35
  172. package/src/nodes/display/AnaglyphPassNode.js +61 -0
  173. package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +27 -30
  174. package/src/nodes/display/BleachBypass.js +26 -0
  175. package/src/nodes/display/BlendMode.js +54 -0
  176. package/src/nodes/display/BloomNode.js +335 -0
  177. package/{examples/jsm → src}/nodes/display/BumpMapNode.js +7 -12
  178. package/src/nodes/display/ColorAdjustment.js +46 -0
  179. package/src/nodes/display/ColorSpaceFunctions.js +38 -0
  180. package/src/nodes/display/ColorSpaceNode.js +85 -0
  181. package/src/nodes/display/DenoiseNode.js +201 -0
  182. package/src/nodes/display/DepthOfFieldNode.js +121 -0
  183. package/src/nodes/display/DotScreenNode.js +63 -0
  184. package/src/nodes/display/FXAANode.js +329 -0
  185. package/src/nodes/display/FilmNode.js +53 -0
  186. package/src/nodes/display/FrontFacingNode.js +41 -0
  187. package/src/nodes/display/GTAONode.js +328 -0
  188. package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +44 -24
  189. package/src/nodes/display/Lut3DNode.js +54 -0
  190. package/src/nodes/display/MotionBlur.js +25 -0
  191. package/{examples/jsm → src}/nodes/display/NormalMapNode.js +9 -11
  192. package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
  193. package/src/nodes/display/PassNode.js +367 -0
  194. package/src/nodes/display/PixelationPassNode.js +206 -0
  195. package/{examples/jsm → src}/nodes/display/PosterizeNode.js +4 -6
  196. package/src/nodes/display/RGBShiftNode.js +50 -0
  197. package/src/nodes/display/RenderOutputNode.js +56 -0
  198. package/src/nodes/display/SSAAPassNode.js +284 -0
  199. package/src/nodes/display/Sepia.js +17 -0
  200. package/src/nodes/display/SobelOperatorNode.js +123 -0
  201. package/src/nodes/display/StereoCompositePassNode.js +107 -0
  202. package/src/nodes/display/StereoPassNode.js +80 -0
  203. package/src/nodes/display/ToneMappingFunctions.js +190 -0
  204. package/src/nodes/display/ToneMappingNode.js +66 -0
  205. package/src/nodes/display/TransitionNode.js +77 -0
  206. package/src/nodes/display/ViewportDepthNode.js +121 -0
  207. package/src/nodes/display/ViewportDepthTextureNode.js +30 -0
  208. package/{examples/jsm → src}/nodes/display/ViewportNode.js +28 -26
  209. package/src/nodes/display/ViewportSharedTextureNode.js +36 -0
  210. package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +12 -12
  211. package/{examples/jsm → src}/nodes/fog/FogExp2Node.js +4 -6
  212. package/{examples/jsm → src}/nodes/fog/FogNode.js +5 -7
  213. package/{examples/jsm → src}/nodes/fog/FogRangeNode.js +4 -6
  214. package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_GGX.js +4 -4
  215. package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  216. package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
  217. package/{examples/jsm → src}/nodes/functions/BSDF/DFGApprox.js +2 -2
  218. package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX.js +2 -2
  219. package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
  220. package/{examples/jsm → src}/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
  221. package/{examples/jsm → src}/nodes/functions/BSDF/F_Schlick.js +2 -2
  222. package/src/nodes/functions/BSDF/LTC.js +131 -0
  223. package/{examples/jsm → src}/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
  224. package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
  225. package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
  226. package/src/nodes/functions/BasicLightingModel.js +78 -0
  227. package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +10 -8
  228. package/{examples/jsm → src}/nodes/functions/PhysicalLightingModel.js +73 -31
  229. package/{examples/jsm → src}/nodes/functions/ShadowMaskModel.js +1 -1
  230. package/{examples/jsm → src}/nodes/functions/ToonLightingModel.js +6 -4
  231. package/src/nodes/functions/material/getGeometryRoughness.js +13 -0
  232. package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +2 -2
  233. package/{examples/jsm → src}/nodes/geometry/RangeNode.js +23 -10
  234. package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +5 -5
  235. package/src/nodes/lighting/AONode.js +24 -0
  236. package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +2 -7
  237. package/src/nodes/lighting/AnalyticLightNode.js +354 -0
  238. package/src/nodes/lighting/BasicEnvironmentNode.js +27 -0
  239. package/src/nodes/lighting/BasicLightMapNode.js +29 -0
  240. package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +3 -9
  241. package/{examples/jsm → src}/nodes/lighting/EnvironmentNode.js +23 -21
  242. package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +4 -7
  243. package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +3 -8
  244. package/{examples/jsm → src}/nodes/lighting/IrradianceNode.js +2 -2
  245. package/{examples/jsm → src}/nodes/lighting/LightNode.js +5 -5
  246. package/src/nodes/lighting/LightProbeNode.js +76 -0
  247. package/{examples/jsm → src}/nodes/lighting/LightUtils.js +3 -3
  248. package/src/nodes/lighting/LightingContextNode.js +64 -0
  249. package/{examples/jsm → src}/nodes/lighting/LightingNode.js +4 -2
  250. package/src/nodes/lighting/LightsNode.js +231 -0
  251. package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +4 -10
  252. package/src/nodes/lighting/RectAreaLightNode.js +93 -0
  253. package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +4 -10
  254. package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +2 -2
  255. package/{examples/jsm → src}/nodes/materialx/lib/mx_hsv.js +43 -46
  256. package/{examples/jsm → src}/nodes/materialx/lib/mx_noise.js +500 -603
  257. package/{examples/jsm → src}/nodes/materialx/lib/mx_transform_color.js +3 -9
  258. package/{examples/jsm/nodes/math/CondNode.js → src/nodes/math/ConditionalNode.js} +31 -13
  259. package/src/nodes/math/Hash.js +13 -0
  260. package/src/nodes/math/MathNode.js +404 -0
  261. package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -7
  262. package/{examples/jsm → src}/nodes/math/OperatorNode.js +100 -58
  263. package/{examples/jsm → src}/nodes/math/TriNoise3D.js +19 -29
  264. package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
  265. package/{examples/jsm → src}/nodes/pmrem/PMREMNode.js +60 -16
  266. package/{examples/jsm → src}/nodes/pmrem/PMREMUtils.js +46 -46
  267. package/src/nodes/procedural/Checker.js +14 -0
  268. package/src/nodes/tsl/TSLBase.js +30 -0
  269. package/{examples/jsm/nodes/shadernode/ShaderNode.js → src/nodes/tsl/TSLCore.js} +106 -96
  270. package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +2 -2
  271. package/{examples/jsm → src}/nodes/utils/ConvertNode.js +2 -2
  272. package/src/nodes/utils/CubeMapNode.js +157 -0
  273. package/src/nodes/utils/Discard.js +8 -0
  274. package/{examples/jsm → src}/nodes/utils/EquirectUVNode.js +5 -5
  275. package/src/nodes/utils/FlipNode.js +65 -0
  276. package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +7 -5
  277. package/{examples/jsm → src}/nodes/utils/JoinNode.js +2 -2
  278. package/{examples/jsm → src}/nodes/utils/LoopNode.js +19 -12
  279. package/{examples/jsm → src}/nodes/utils/MatcapUVNode.js +6 -6
  280. package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +12 -6
  281. package/{examples/jsm → src}/nodes/utils/OscNode.js +7 -7
  282. package/src/nodes/utils/Packing.js +4 -0
  283. package/src/nodes/utils/RTTNode.js +130 -0
  284. package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +17 -4
  285. package/{examples/jsm → src}/nodes/utils/RemapNode.js +7 -7
  286. package/{examples/jsm → src}/nodes/utils/RotateNode.js +4 -12
  287. package/{examples/jsm → src}/nodes/utils/SetNode.js +2 -2
  288. package/{examples/jsm → src}/nodes/utils/SplitNode.js +2 -2
  289. package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +5 -5
  290. package/src/nodes/utils/SpriteUtils.js +47 -0
  291. package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +4 -6
  292. package/{examples/jsm → src}/nodes/utils/TimerNode.js +5 -5
  293. package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +7 -9
  294. package/src/nodes/utils/UVUtils.js +19 -0
  295. package/src/nodes/utils/ViewportUtils.js +14 -0
  296. package/src/objects/BatchedMesh.js +169 -190
  297. package/src/objects/InstancedMesh.js +1 -1
  298. package/src/renderers/WebGLRenderer.js +60 -23
  299. package/{examples/jsm → src}/renderers/common/Attributes.js +2 -1
  300. package/{examples/jsm → src}/renderers/common/Backend.js +30 -27
  301. package/{examples/jsm → src}/renderers/common/Background.js +12 -4
  302. package/src/renderers/common/BindGroup.js +18 -0
  303. package/{examples/jsm → src}/renderers/common/Bindings.js +45 -32
  304. package/{examples/jsm → src}/renderers/common/ClippingContext.js +18 -7
  305. package/{examples/jsm → src}/renderers/common/Color4.js +1 -1
  306. package/{examples/jsm → src}/renderers/common/CubeRenderTarget.js +16 -4
  307. package/{examples/jsm → src}/renderers/common/Geometries.js +37 -5
  308. package/{examples/jsm → src}/renderers/common/Info.js +34 -6
  309. package/src/renderers/common/PostProcessing.js +90 -0
  310. package/{examples/jsm/objects → src/renderers/common}/QuadMesh.js +8 -3
  311. package/{examples/jsm → src}/renderers/common/RenderContext.js +25 -1
  312. package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
  313. package/{examples/jsm → src}/renderers/common/RenderList.js +1 -1
  314. package/{examples/jsm → src}/renderers/common/RenderObject.js +45 -12
  315. package/{examples/jsm → src}/renderers/common/Renderer.js +151 -73
  316. package/{examples/jsm → src}/renderers/common/SampledTexture.js +14 -5
  317. package/src/renderers/common/StandardRenderer.js +18 -0
  318. package/{examples/jsm → src}/renderers/common/StorageBufferAttribute.js +1 -1
  319. package/{examples/jsm → src}/renderers/common/StorageInstancedBufferAttribute.js +1 -1
  320. package/{examples/jsm → src}/renderers/common/StorageTexture.js +2 -1
  321. package/{examples/jsm → src}/renderers/common/Textures.js +14 -14
  322. package/{examples/jsm → src}/renderers/common/Uniform.js +9 -4
  323. package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
  324. package/{examples/jsm → src}/renderers/common/extras/PMREMGenerator.js +25 -25
  325. package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
  326. package/src/renderers/common/nodes/NodeLibrary.js +118 -0
  327. package/{examples/jsm → src}/renderers/common/nodes/NodeSampledTexture.js +8 -7
  328. package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +2 -1
  329. package/{examples/jsm → src}/renderers/common/nodes/NodeStorageBuffer.js +5 -1
  330. package/{examples/jsm → src}/renderers/common/nodes/NodeUniform.js +3 -3
  331. package/{examples/jsm → src}/renderers/common/nodes/NodeUniformBuffer.js +2 -1
  332. package/{examples/jsm → src}/renderers/common/nodes/NodeUniformsGroup.js +2 -8
  333. package/{examples/jsm → src}/renderers/common/nodes/Nodes.js +69 -21
  334. package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
  335. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +16 -1
  336. package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
  337. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +1 -1
  338. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +0 -9
  339. package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -10
  340. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
  341. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +45 -13
  342. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -4
  343. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +3 -0
  344. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +3 -3
  345. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
  346. package/src/renderers/shaders/ShaderLib/depth.glsl.js +8 -0
  347. package/src/renderers/shaders/UniformsLib.js +3 -0
  348. package/src/renderers/webgl/WebGLAttributes.js +2 -2
  349. package/src/renderers/webgl/WebGLBufferRenderer.js +6 -19
  350. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +6 -18
  351. package/src/renderers/webgl/WebGLLights.js +6 -0
  352. package/src/renderers/webgl/WebGLProgram.js +27 -1
  353. package/src/renderers/webgl/WebGLPrograms.js +1 -1
  354. package/src/renderers/webgl/WebGLProperties.js +7 -0
  355. package/src/renderers/webgl/WebGLTextures.js +75 -57
  356. package/src/renderers/webgl/WebGLUniforms.js +12 -2
  357. package/src/renderers/webgl/WebGLUniformsGroups.js +7 -7
  358. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +242 -120
  359. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +227 -44
  360. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +2 -2
  361. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +1 -0
  362. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLExtensions.js +2 -0
  363. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLState.js +22 -1
  364. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +62 -23
  365. package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +1 -1
  366. package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +242 -136
  367. package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +9 -9
  368. package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +281 -107
  369. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
  370. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
  371. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +64 -33
  372. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +4 -1
  373. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +34 -36
  374. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
  375. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +76 -44
  376. package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +42 -4
  377. package/src/renderers/webxr/WebXRDepthSensing.js +6 -0
  378. package/src/renderers/webxr/WebXRManager.js +37 -24
  379. package/src/textures/CompressedArrayTexture.js +1 -1
  380. package/examples/jsm/loaders/LogLuvLoader.js +0 -606
  381. package/examples/jsm/nodes/Nodes.js +0 -202
  382. package/examples/jsm/nodes/accessors/BatchNode.js +0 -78
  383. package/examples/jsm/nodes/accessors/CameraNode.js +0 -12
  384. package/examples/jsm/nodes/accessors/CubeTextureNode.js +0 -61
  385. package/examples/jsm/nodes/accessors/InstanceNode.js +0 -94
  386. package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +0 -21
  387. package/examples/jsm/nodes/accessors/ModelNode.js +0 -36
  388. package/examples/jsm/nodes/accessors/NormalNode.js +0 -14
  389. package/examples/jsm/nodes/accessors/PointUVNode.js +0 -26
  390. package/examples/jsm/nodes/accessors/PositionNode.js +0 -10
  391. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -6
  392. package/examples/jsm/nodes/accessors/SkinningNode.js +0 -124
  393. package/examples/jsm/nodes/accessors/TangentNode.js +0 -23
  394. package/examples/jsm/nodes/core/CacheNode.js +0 -49
  395. package/examples/jsm/nodes/core/NodeCache.js +0 -26
  396. package/examples/jsm/nodes/core/NodeKeywords.js +0 -80
  397. package/examples/jsm/nodes/core/PropertyNode.js +0 -83
  398. package/examples/jsm/nodes/core/UniformGroupNode.js +0 -36
  399. package/examples/jsm/nodes/display/BlendModeNode.js +0 -128
  400. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +0 -99
  401. package/examples/jsm/nodes/display/ColorSpaceNode.js +0 -108
  402. package/examples/jsm/nodes/display/FrontFacingNode.js +0 -40
  403. package/examples/jsm/nodes/display/PassNode.js +0 -201
  404. package/examples/jsm/nodes/display/ToneMappingNode.js +0 -188
  405. package/examples/jsm/nodes/display/ViewportDepthNode.js +0 -97
  406. package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +0 -31
  407. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +0 -37
  408. package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +0 -13
  409. package/examples/jsm/nodes/lighting/AONode.js +0 -27
  410. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -256
  411. package/examples/jsm/nodes/lighting/LightingContextNode.js +0 -66
  412. package/examples/jsm/nodes/lighting/LightsNode.js +0 -215
  413. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -28
  414. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
  415. package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +0 -34
  416. package/examples/jsm/nodes/materials/MeshMatcapNodeMaterial.js +0 -52
  417. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -38
  418. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -65
  419. package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +0 -34
  420. package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +0 -34
  421. package/examples/jsm/nodes/math/HashNode.js +0 -34
  422. package/examples/jsm/nodes/math/MathNode.js +0 -391
  423. package/examples/jsm/nodes/procedural/CheckerNode.js +0 -42
  424. package/examples/jsm/nodes/utils/DiscardNode.js +0 -27
  425. package/examples/jsm/nodes/utils/PackingNode.js +0 -55
  426. package/examples/jsm/nodes/utils/RotateUVNode.js +0 -35
  427. package/examples/jsm/renderers/common/PostProcessing.js +0 -33
  428. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
  429. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
  430. /package/{examples/jsm/nodes/accessors/UVNode.js → src/nodes/accessors/UV.js} +0 -0
  431. /package/{examples/jsm → src}/nodes/core/NodeAttribute.js +0 -0
  432. /package/{examples/jsm → src}/nodes/core/NodeCode.js +0 -0
  433. /package/{examples/jsm → src}/nodes/core/NodeFunctionInput.js +0 -0
  434. /package/{examples/jsm → src}/nodes/core/NodeParser.js +0 -0
  435. /package/{examples/jsm → src}/nodes/core/NodeVar.js +0 -0
  436. /package/{examples/jsm → src}/nodes/core/NodeVarying.js +0 -0
  437. /package/{examples/jsm → src}/nodes/core/UniformGroup.js +0 -0
  438. /package/{examples/jsm → src}/nodes/core/constants.js +0 -0
  439. /package/{examples/jsm → src}/nodes/materialx/DISCLAIMER.md +0 -0
  440. /package/{examples/jsm → src}/nodes/parsers/GLSLNodeParser.js +0 -0
  441. /package/{examples/jsm → src}/renderers/common/Animation.js +0 -0
  442. /package/{examples/jsm → src}/renderers/common/Binding.js +0 -0
  443. /package/{examples/jsm → src}/renderers/common/Buffer.js +0 -0
  444. /package/{examples/jsm → src}/renderers/common/BufferUtils.js +0 -0
  445. /package/{examples/jsm → src}/renderers/common/ChainMap.js +0 -0
  446. /package/{examples/jsm → src}/renderers/common/ComputePipeline.js +0 -0
  447. /package/{examples/jsm → src}/renderers/common/Constants.js +0 -0
  448. /package/{examples/jsm → src}/renderers/common/DataMap.js +0 -0
  449. /package/{examples/jsm → src}/renderers/common/Pipeline.js +0 -0
  450. /package/{examples/jsm → src}/renderers/common/Pipelines.js +0 -0
  451. /package/{examples/jsm → src}/renderers/common/ProgrammableStage.js +0 -0
  452. /package/{examples/jsm → src}/renderers/common/RenderBundle.js +0 -0
  453. /package/{examples/jsm → src}/renderers/common/RenderBundles.js +0 -0
  454. /package/{examples/jsm → src}/renderers/common/RenderLists.js +0 -0
  455. /package/{examples/jsm → src}/renderers/common/RenderObjects.js +0 -0
  456. /package/{examples/jsm → src}/renderers/common/RenderPipeline.js +0 -0
  457. /package/{examples/jsm → src}/renderers/common/Sampler.js +0 -0
  458. /package/{examples/jsm → src}/renderers/common/StorageBuffer.js +0 -0
  459. /package/{examples/jsm → src}/renderers/common/UniformBuffer.js +0 -0
  460. /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBufferRenderer.js +0 -0
  461. /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLCapabilities.js +0 -0
  462. /package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeParser.js +0 -0
package/build/three.cjs CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  'use strict';
7
7
 
8
- const REVISION = '165';
8
+ const REVISION = '168';
9
9
 
10
10
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
11
11
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -110,6 +110,7 @@ const RedFormat = 1028;
110
110
  const RedIntegerFormat = 1029;
111
111
  const RGFormat = 1030;
112
112
  const RGIntegerFormat = 1031;
113
+ const RGBIntegerFormat = 1032;
113
114
  const RGBAIntegerFormat = 1033;
114
115
 
115
116
  const RGB_S3TC_DXT1_Format = 33776;
@@ -160,6 +161,8 @@ const TriangleStripDrawMode = 1;
160
161
  const TriangleFanDrawMode = 2;
161
162
  const BasicDepthPacking = 3200;
162
163
  const RGBADepthPacking = 3201;
164
+ const RGBDepthPacking = 3202;
165
+ const RGDepthPacking = 3203;
163
166
  const TangentSpaceNormalMap = 0;
164
167
  const ObjectSpaceNormalMap = 1;
165
168
 
@@ -1623,24 +1626,28 @@ const COLOR_SPACES = {
1623
1626
  [ LinearSRGBColorSpace ]: {
1624
1627
  transfer: LinearTransfer,
1625
1628
  primaries: Rec709Primaries,
1629
+ luminanceCoefficients: [ 0.2126, 0.7152, 0.0722 ],
1626
1630
  toReference: ( color ) => color,
1627
1631
  fromReference: ( color ) => color,
1628
1632
  },
1629
1633
  [ SRGBColorSpace ]: {
1630
1634
  transfer: SRGBTransfer,
1631
1635
  primaries: Rec709Primaries,
1636
+ luminanceCoefficients: [ 0.2126, 0.7152, 0.0722 ],
1632
1637
  toReference: ( color ) => color.convertSRGBToLinear(),
1633
1638
  fromReference: ( color ) => color.convertLinearToSRGB(),
1634
1639
  },
1635
1640
  [ LinearDisplayP3ColorSpace ]: {
1636
1641
  transfer: LinearTransfer,
1637
1642
  primaries: P3Primaries,
1643
+ luminanceCoefficients: [ 0.2289, 0.6917, 0.0793 ],
1638
1644
  toReference: ( color ) => color.applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
1639
1645
  fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ),
1640
1646
  },
1641
1647
  [ DisplayP3ColorSpace ]: {
1642
1648
  transfer: SRGBTransfer,
1643
1649
  primaries: P3Primaries,
1650
+ luminanceCoefficients: [ 0.2289, 0.6917, 0.0793 ],
1644
1651
  toReference: ( color ) => color.convertSRGBToLinear().applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
1645
1652
  fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ).convertLinearToSRGB(),
1646
1653
  },
@@ -1713,6 +1720,12 @@ const ColorManagement = {
1713
1720
 
1714
1721
  },
1715
1722
 
1723
+ getLuminanceCoefficients: function ( target, colorSpace = this._workingColorSpace ) {
1724
+
1725
+ return target.fromArray( COLOR_SPACES[ colorSpace ].luminanceCoefficients );
1726
+
1727
+ },
1728
+
1716
1729
  };
1717
1730
 
1718
1731
 
@@ -2694,6 +2707,19 @@ class Vector4 {
2694
2707
 
2695
2708
  }
2696
2709
 
2710
+ setFromMatrixPosition( m ) {
2711
+
2712
+ const e = m.elements;
2713
+
2714
+ this.x = e[ 12 ];
2715
+ this.y = e[ 13 ];
2716
+ this.z = e[ 14 ];
2717
+ this.w = e[ 15 ];
2718
+
2719
+ return this;
2720
+
2721
+ }
2722
+
2697
2723
  min( v ) {
2698
2724
 
2699
2725
  this.x = Math.min( this.x, v.x );
@@ -4834,9 +4860,9 @@ class Box3 {
4834
4860
 
4835
4861
  containsPoint( point ) {
4836
4862
 
4837
- return point.x < this.min.x || point.x > this.max.x ||
4838
- point.y < this.min.y || point.y > this.max.y ||
4839
- point.z < this.min.z || point.z > this.max.z ? false : true;
4863
+ return point.x >= this.min.x && point.x <= this.max.x &&
4864
+ point.y >= this.min.y && point.y <= this.max.y &&
4865
+ point.z >= this.min.z && point.z <= this.max.z;
4840
4866
 
4841
4867
  }
4842
4868
 
@@ -4864,9 +4890,9 @@ class Box3 {
4864
4890
  intersectsBox( box ) {
4865
4891
 
4866
4892
  // using 6 splitting planes to rule out intersections.
4867
- return box.max.x < this.min.x || box.min.x > this.max.x ||
4868
- box.max.y < this.min.y || box.min.y > this.max.y ||
4869
- box.max.z < this.min.z || box.min.z > this.max.z ? false : true;
4893
+ return box.max.x >= this.min.x && box.min.x <= this.max.x &&
4894
+ box.max.y >= this.min.y && box.min.y <= this.max.y &&
4895
+ box.max.z >= this.min.z && box.min.z <= this.max.z;
4870
4896
 
4871
4897
  }
4872
4898
 
@@ -4940,14 +4966,14 @@ class Box3 {
4940
4966
  _extents.subVectors( this.max, _center );
4941
4967
 
4942
4968
  // translate triangle to aabb origin
4943
- _v0$2.subVectors( triangle.a, _center );
4969
+ _v0$3.subVectors( triangle.a, _center );
4944
4970
  _v1$7.subVectors( triangle.b, _center );
4945
4971
  _v2$4.subVectors( triangle.c, _center );
4946
4972
 
4947
4973
  // compute edge vectors for triangle
4948
- _f0.subVectors( _v1$7, _v0$2 );
4974
+ _f0.subVectors( _v1$7, _v0$3 );
4949
4975
  _f1.subVectors( _v2$4, _v1$7 );
4950
- _f2.subVectors( _v0$2, _v2$4 );
4976
+ _f2.subVectors( _v0$3, _v2$4 );
4951
4977
 
4952
4978
  // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
4953
4979
  // 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
@@ -4957,7 +4983,7 @@ class Box3 {
4957
4983
  _f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x,
4958
4984
  - _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0
4959
4985
  ];
4960
- if ( ! satForAxes( axes, _v0$2, _v1$7, _v2$4, _extents ) ) {
4986
+ if ( ! satForAxes( axes, _v0$3, _v1$7, _v2$4, _extents ) ) {
4961
4987
 
4962
4988
  return false;
4963
4989
 
@@ -4965,7 +4991,7 @@ class Box3 {
4965
4991
 
4966
4992
  // test 3 face normals from the aabb
4967
4993
  axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];
4968
- if ( ! satForAxes( axes, _v0$2, _v1$7, _v2$4, _extents ) ) {
4994
+ if ( ! satForAxes( axes, _v0$3, _v1$7, _v2$4, _extents ) ) {
4969
4995
 
4970
4996
  return false;
4971
4997
 
@@ -4976,7 +5002,7 @@ class Box3 {
4976
5002
  _triangleNormal.crossVectors( _f0, _f1 );
4977
5003
  axes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ];
4978
5004
 
4979
- return satForAxes( axes, _v0$2, _v1$7, _v2$4, _extents );
5005
+ return satForAxes( axes, _v0$3, _v1$7, _v2$4, _extents );
4980
5006
 
4981
5007
  }
4982
5008
 
@@ -5086,7 +5112,7 @@ const _box$4 = /*@__PURE__*/ new Box3();
5086
5112
 
5087
5113
  // triangle centered vertices
5088
5114
 
5089
- const _v0$2 = /*@__PURE__*/ new Vector3();
5115
+ const _v0$3 = /*@__PURE__*/ new Vector3();
5090
5116
  const _v1$7 = /*@__PURE__*/ new Vector3();
5091
5117
  const _v2$4 = /*@__PURE__*/ new Vector3();
5092
5118
 
@@ -7719,13 +7745,17 @@ class Object3D extends EventDispatcher {
7719
7745
 
7720
7746
  if ( this.matrixWorldNeedsUpdate || force ) {
7721
7747
 
7722
- if ( this.parent === null ) {
7748
+ if ( this.matrixWorldAutoUpdate === true ) {
7723
7749
 
7724
- this.matrixWorld.copy( this.matrix );
7750
+ if ( this.parent === null ) {
7725
7751
 
7726
- } else {
7752
+ this.matrixWorld.copy( this.matrix );
7727
7753
 
7728
- this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
7754
+ } else {
7755
+
7756
+ this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
7757
+
7758
+ }
7729
7759
 
7730
7760
  }
7731
7761
 
@@ -7735,7 +7765,7 @@ class Object3D extends EventDispatcher {
7735
7765
 
7736
7766
  }
7737
7767
 
7738
- // update children
7768
+ // make sure descendants are updated if required
7739
7769
 
7740
7770
  const children = this.children;
7741
7771
 
@@ -7743,11 +7773,7 @@ class Object3D extends EventDispatcher {
7743
7773
 
7744
7774
  const child = children[ i ];
7745
7775
 
7746
- if ( child.matrixWorldAutoUpdate === true || force === true ) {
7747
-
7748
- child.updateMatrixWorld( force );
7749
-
7750
- }
7776
+ child.updateMatrixWorld( force );
7751
7777
 
7752
7778
  }
7753
7779
 
@@ -7757,7 +7783,7 @@ class Object3D extends EventDispatcher {
7757
7783
 
7758
7784
  const parent = this.parent;
7759
7785
 
7760
- if ( updateParents === true && parent !== null && parent.matrixWorldAutoUpdate === true ) {
7786
+ if ( updateParents === true && parent !== null ) {
7761
7787
 
7762
7788
  parent.updateWorldMatrix( true, false );
7763
7789
 
@@ -7765,17 +7791,21 @@ class Object3D extends EventDispatcher {
7765
7791
 
7766
7792
  if ( this.matrixAutoUpdate ) this.updateMatrix();
7767
7793
 
7768
- if ( this.parent === null ) {
7794
+ if ( this.matrixWorldAutoUpdate === true ) {
7769
7795
 
7770
- this.matrixWorld.copy( this.matrix );
7796
+ if ( this.parent === null ) {
7771
7797
 
7772
- } else {
7798
+ this.matrixWorld.copy( this.matrix );
7799
+
7800
+ } else {
7801
+
7802
+ this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
7773
7803
 
7774
- this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
7804
+ }
7775
7805
 
7776
7806
  }
7777
7807
 
7778
- // update children
7808
+ // make sure descendants are updated
7779
7809
 
7780
7810
  if ( updateChildren === true ) {
7781
7811
 
@@ -7785,11 +7815,7 @@ class Object3D extends EventDispatcher {
7785
7815
 
7786
7816
  const child = children[ i ];
7787
7817
 
7788
- if ( child.matrixWorldAutoUpdate === true ) {
7789
-
7790
- child.updateWorldMatrix( false, true );
7791
-
7792
- }
7818
+ child.updateWorldMatrix( false, true );
7793
7819
 
7794
7820
  }
7795
7821
 
@@ -7882,7 +7908,7 @@ class Object3D extends EventDispatcher {
7882
7908
  sphereCenter: bound.sphere.center.toArray()
7883
7909
  } ) );
7884
7910
 
7885
- object.maxGeometryCount = this._maxGeometryCount;
7911
+ object.maxInstanceCount = this._maxInstanceCount;
7886
7912
  object.maxVertexCount = this._maxVertexCount;
7887
7913
  object.maxIndexCount = this._maxIndexCount;
7888
7914
 
@@ -8151,7 +8177,7 @@ Object3D.DEFAULT_UP = /*@__PURE__*/ new Vector3( 0, 1, 0 );
8151
8177
  Object3D.DEFAULT_MATRIX_AUTO_UPDATE = true;
8152
8178
  Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = true;
8153
8179
 
8154
- const _v0$1 = /*@__PURE__*/ new Vector3();
8180
+ const _v0$2 = /*@__PURE__*/ new Vector3();
8155
8181
  const _v1$3 = /*@__PURE__*/ new Vector3();
8156
8182
  const _v2$2 = /*@__PURE__*/ new Vector3();
8157
8183
  const _v3$2 = /*@__PURE__*/ new Vector3();
@@ -8176,8 +8202,8 @@ class Triangle {
8176
8202
  static getNormal( a, b, c, target ) {
8177
8203
 
8178
8204
  target.subVectors( c, b );
8179
- _v0$1.subVectors( a, b );
8180
- target.cross( _v0$1 );
8205
+ _v0$2.subVectors( a, b );
8206
+ target.cross( _v0$2 );
8181
8207
 
8182
8208
  const targetLengthSq = target.lengthSq();
8183
8209
  if ( targetLengthSq > 0 ) {
@@ -8194,13 +8220,13 @@ class Triangle {
8194
8220
  // based on: http://www.blackpawn.com/texts/pointinpoly/default.html
8195
8221
  static getBarycoord( point, a, b, c, target ) {
8196
8222
 
8197
- _v0$1.subVectors( c, a );
8223
+ _v0$2.subVectors( c, a );
8198
8224
  _v1$3.subVectors( b, a );
8199
8225
  _v2$2.subVectors( point, a );
8200
8226
 
8201
- const dot00 = _v0$1.dot( _v0$1 );
8202
- const dot01 = _v0$1.dot( _v1$3 );
8203
- const dot02 = _v0$1.dot( _v2$2 );
8227
+ const dot00 = _v0$2.dot( _v0$2 );
8228
+ const dot01 = _v0$2.dot( _v1$3 );
8229
+ const dot02 = _v0$2.dot( _v2$2 );
8204
8230
  const dot11 = _v1$3.dot( _v1$3 );
8205
8231
  const dot12 = _v1$3.dot( _v2$2 );
8206
8232
 
@@ -8259,11 +8285,11 @@ class Triangle {
8259
8285
 
8260
8286
  static isFrontFacing( a, b, c, direction ) {
8261
8287
 
8262
- _v0$1.subVectors( c, b );
8288
+ _v0$2.subVectors( c, b );
8263
8289
  _v1$3.subVectors( a, b );
8264
8290
 
8265
8291
  // strictly front facing
8266
- return ( _v0$1.cross( _v1$3 ).dot( direction ) < 0 ) ? true : false;
8292
+ return ( _v0$2.cross( _v1$3 ).dot( direction ) < 0 ) ? true : false;
8267
8293
 
8268
8294
  }
8269
8295
 
@@ -8315,10 +8341,10 @@ class Triangle {
8315
8341
 
8316
8342
  getArea() {
8317
8343
 
8318
- _v0$1.subVectors( this.c, this.b );
8344
+ _v0$2.subVectors( this.c, this.b );
8319
8345
  _v1$3.subVectors( this.a, this.b );
8320
8346
 
8321
- return _v0$1.cross( _v1$3 ).length() * 0.5;
8347
+ return _v0$2.cross( _v1$3 ).length() * 0.5;
8322
8348
 
8323
8349
  }
8324
8350
 
@@ -9174,7 +9200,7 @@ class Material extends EventDispatcher {
9174
9200
 
9175
9201
  }
9176
9202
 
9177
- onBuild( /* shaderobject, renderer */ ) {}
9203
+ // onBeforeRender and onBeforeCompile only supported in WebGLRenderer
9178
9204
 
9179
9205
  onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {}
9180
9206
 
@@ -9594,6 +9620,12 @@ class Material extends EventDispatcher {
9594
9620
 
9595
9621
  }
9596
9622
 
9623
+ onBuild( /* shaderobject, renderer */ ) {
9624
+
9625
+ console.warn( 'Material: onBuild() has been removed.' ); // @deprecated, r166
9626
+
9627
+ }
9628
+
9597
9629
  }
9598
9630
 
9599
9631
  class MeshBasicMaterial extends Material {
@@ -13642,6 +13674,8 @@ function WebGLAttributes( gl ) {
13642
13674
 
13643
13675
  function update( attribute, bufferType ) {
13644
13676
 
13677
+ if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
13678
+
13645
13679
  if ( attribute.isGLBufferAttribute ) {
13646
13680
 
13647
13681
  const cached = buffers.get( attribute );
@@ -13661,8 +13695,6 @@ function WebGLAttributes( gl ) {
13661
13695
 
13662
13696
  }
13663
13697
 
13664
- if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
13665
-
13666
13698
  const data = buffers.get( attribute );
13667
13699
 
13668
13700
  if ( data === undefined ) {
@@ -13805,9 +13837,9 @@ var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D(
13805
13837
 
13806
13838
  var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
13807
13839
 
13808
- 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\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";
13840
+ 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";
13809
13841
 
13810
- var batching_vertex = "#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif";
13842
+ var batching_vertex = "#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif";
13811
13843
 
13812
13844
  var begin_vertex = "vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif";
13813
13845
 
@@ -13833,9 +13865,9 @@ var color_pars_fragment = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor
13833
13865
 
13834
13866
  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";
13835
13867
 
13836
- 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( batchId );\n\tvColor.xyz *= batchingColor.xyz;\n#endif";
13868
+ 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";
13837
13869
 
13838
- 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";
13870
+ 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";
13839
13871
 
13840
13872
  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";
13841
13873
 
@@ -13851,7 +13883,7 @@ var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emi
13851
13883
 
13852
13884
  var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
13853
13885
 
13854
- 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}";
13886
+ 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}";
13855
13887
 
13856
13888
  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";
13857
13889
 
@@ -13895,7 +13927,7 @@ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColo
13895
13927
 
13896
13928
  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}";
13897
13929
 
13898
- 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";
13930
+ 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";
13899
13931
 
13900
13932
  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";
13901
13933
 
@@ -13953,7 +13985,7 @@ var iridescence_pars_fragment = "#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D
13953
13985
 
13954
13986
  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 );";
13955
13987
 
13956
- 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}";
13988
+ 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}";
13957
13989
 
13958
13990
  var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif";
13959
13991
 
@@ -13967,13 +13999,13 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
13967
13999
 
13968
14000
  var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
13969
14001
 
13970
- 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";
14002
+ 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";
13971
14003
 
13972
- 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";
14004
+ 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";
13973
14005
 
13974
14006
  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";
13975
14007
 
13976
- 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}";
14008
+ 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}";
13977
14009
 
13978
14010
  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";
13979
14011
 
@@ -13989,7 +14021,7 @@ var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D spe
13989
14021
 
13990
14022
  var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
13991
14023
 
13992
- var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
14024
+ var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
13993
14025
 
13994
14026
  var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif";
13995
14027
 
@@ -14017,7 +14049,7 @@ const fragment$f = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform fl
14017
14049
 
14018
14050
  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}";
14019
14051
 
14020
- 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}";
14052
+ 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}";
14021
14053
 
14022
14054
  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}";
14023
14055
 
@@ -14344,6 +14376,7 @@ const UniformsLib = {
14344
14376
  } },
14345
14377
 
14346
14378
  directionalLightShadows: { value: [], properties: {
14379
+ shadowIntensity: 1,
14347
14380
  shadowBias: {},
14348
14381
  shadowNormalBias: {},
14349
14382
  shadowRadius: {},
@@ -14364,6 +14397,7 @@ const UniformsLib = {
14364
14397
  } },
14365
14398
 
14366
14399
  spotLightShadows: { value: [], properties: {
14400
+ shadowIntensity: 1,
14367
14401
  shadowBias: {},
14368
14402
  shadowNormalBias: {},
14369
14403
  shadowRadius: {},
@@ -14382,6 +14416,7 @@ const UniformsLib = {
14382
14416
  } },
14383
14417
 
14384
14418
  pointLightShadows: { value: [], properties: {
14419
+ shadowIntensity: 1,
14385
14420
  shadowBias: {},
14386
14421
  shadowNormalBias: {},
14387
14422
  shadowRadius: {},
@@ -15680,30 +15715,17 @@ function WebGLBufferRenderer( gl, extensions, info ) {
15680
15715
  if ( drawCount === 0 ) return;
15681
15716
 
15682
15717
  const extension = extensions.get( 'WEBGL_multi_draw' );
15718
+ extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
15683
15719
 
15684
- if ( extension === null ) {
15685
-
15686
- for ( let i = 0; i < drawCount; i ++ ) {
15687
-
15688
- this.render( starts[ i ], counts[ i ] );
15689
-
15690
- }
15691
-
15692
- } else {
15693
-
15694
- extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
15695
-
15696
- let elementCount = 0;
15697
- for ( let i = 0; i < drawCount; i ++ ) {
15720
+ let elementCount = 0;
15721
+ for ( let i = 0; i < drawCount; i ++ ) {
15698
15722
 
15699
- elementCount += counts[ i ];
15700
-
15701
- }
15702
-
15703
- info.update( elementCount, mode, 1 );
15723
+ elementCount += counts[ i ];
15704
15724
 
15705
15725
  }
15706
15726
 
15727
+ info.update( elementCount, mode, 1 );
15728
+
15707
15729
  }
15708
15730
 
15709
15731
  function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
@@ -17633,29 +17655,17 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
17633
17655
  if ( drawCount === 0 ) return;
17634
17656
 
17635
17657
  const extension = extensions.get( 'WEBGL_multi_draw' );
17658
+ extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
17636
17659
 
17637
- if ( extension === null ) {
17660
+ let elementCount = 0;
17661
+ for ( let i = 0; i < drawCount; i ++ ) {
17638
17662
 
17639
- for ( let i = 0; i < drawCount; i ++ ) {
17663
+ elementCount += counts[ i ];
17640
17664
 
17641
- this.render( starts[ i ] / bytesPerElement, counts[ i ] );
17642
-
17643
- }
17644
-
17645
- } else {
17646
-
17647
- extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
17648
-
17649
- let elementCount = 0;
17650
- for ( let i = 0; i < drawCount; i ++ ) {
17651
-
17652
- elementCount += counts[ i ];
17653
-
17654
- }
17665
+ }
17655
17666
 
17656
- info.update( elementCount, mode, 1 );
17667
+ info.update( elementCount, mode, 1 );
17657
17668
 
17658
- }
17659
17669
 
17660
17670
  }
17661
17671
 
@@ -18221,7 +18231,6 @@ class DepthTexture extends Texture {
18221
18231
  const emptyTexture = /*@__PURE__*/ new Texture();
18222
18232
 
18223
18233
  const emptyShadowTexture = /*@__PURE__*/ new DepthTexture( 1, 1 );
18224
- emptyShadowTexture.compareFunction = LessEqualCompare;
18225
18234
 
18226
18235
  const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture();
18227
18236
  const empty3dTexture = /*@__PURE__*/ new Data3DTexture();
@@ -18739,7 +18748,18 @@ function setValueT1( gl, v, textures ) {
18739
18748
 
18740
18749
  }
18741
18750
 
18742
- const emptyTexture2D = ( this.type === gl.SAMPLER_2D_SHADOW ) ? emptyShadowTexture : emptyTexture;
18751
+ let emptyTexture2D;
18752
+
18753
+ if ( this.type === gl.SAMPLER_2D_SHADOW ) {
18754
+
18755
+ emptyShadowTexture.compareFunction = LessEqualCompare; // #28670
18756
+ emptyTexture2D = emptyShadowTexture;
18757
+
18758
+ } else {
18759
+
18760
+ emptyTexture2D = emptyTexture;
18761
+
18762
+ }
18743
18763
 
18744
18764
  textures.setTexture2D( v || emptyTexture2D, unit );
18745
18765
 
@@ -19443,7 +19463,7 @@ function getToneMappingFunction( functionName, toneMapping ) {
19443
19463
  break;
19444
19464
 
19445
19465
  case CineonToneMapping:
19446
- toneMappingName = 'OptimizedCineon';
19466
+ toneMappingName = 'Cineon';
19447
19467
  break;
19448
19468
 
19449
19469
  case ACESFilmicToneMapping:
@@ -19472,6 +19492,30 @@ function getToneMappingFunction( functionName, toneMapping ) {
19472
19492
 
19473
19493
  }
19474
19494
 
19495
+ const _v0$1 = /*@__PURE__*/ new Vector3();
19496
+
19497
+ function getLuminanceFunction() {
19498
+
19499
+ ColorManagement.getLuminanceCoefficients( _v0$1 );
19500
+
19501
+ const r = _v0$1.x.toFixed( 4 );
19502
+ const g = _v0$1.y.toFixed( 4 );
19503
+ const b = _v0$1.z.toFixed( 4 );
19504
+
19505
+ return [
19506
+
19507
+ 'float luminance( const in vec3 rgb ) {',
19508
+
19509
+ ` const vec3 weights = vec3( ${ r }, ${ g }, ${ b } );`,
19510
+
19511
+ ' return dot( weights, rgb );',
19512
+
19513
+ '}'
19514
+
19515
+ ].join( '\n' );
19516
+
19517
+ }
19518
+
19475
19519
  function generateVertexExtensions( parameters ) {
19476
19520
 
19477
19521
  const chunks = [
@@ -20143,6 +20187,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20143
20187
 
20144
20188
  ShaderChunk[ 'colorspace_pars_fragment' ], // this code is required here because it is used by the various encoding/decoding function defined below
20145
20189
  getTexelEncodingFunction( 'linearToOutputTexel', parameters.outputColorSpace ),
20190
+ getLuminanceFunction(),
20146
20191
 
20147
20192
  parameters.useDepthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '',
20148
20193
 
@@ -20908,7 +20953,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20908
20953
  index0AttributeName: material.index0AttributeName,
20909
20954
 
20910
20955
  extensionClipCullDistance: HAS_EXTENSIONS && material.extensions.clipCullDistance === true && extensions.has( 'WEBGL_clip_cull_distance' ),
20911
- extensionMultiDraw: HAS_EXTENSIONS && material.extensions.multiDraw === true && extensions.has( 'WEBGL_multi_draw' ),
20956
+ extensionMultiDraw: ( HAS_EXTENSIONS && material.extensions.multiDraw === true || IS_BATCHEDMESH ) && extensions.has( 'WEBGL_multi_draw' ),
20912
20957
 
20913
20958
  rendererExtensionParallelShaderCompile: extensions.has( 'KHR_parallel_shader_compile' ),
20914
20959
 
@@ -21217,6 +21262,12 @@ function WebGLProperties() {
21217
21262
 
21218
21263
  let properties = new WeakMap();
21219
21264
 
21265
+ function has( object ) {
21266
+
21267
+ return properties.has( object );
21268
+
21269
+ }
21270
+
21220
21271
  function get( object ) {
21221
21272
 
21222
21273
  let map = properties.get( object );
@@ -21251,6 +21302,7 @@ function WebGLProperties() {
21251
21302
  }
21252
21303
 
21253
21304
  return {
21305
+ has: has,
21254
21306
  get: get,
21255
21307
  remove: remove,
21256
21308
  update: update,
@@ -21590,6 +21642,7 @@ function ShadowUniformsCache() {
21590
21642
 
21591
21643
  case 'DirectionalLight':
21592
21644
  uniforms = {
21645
+ shadowIntensity: 1,
21593
21646
  shadowBias: 0,
21594
21647
  shadowNormalBias: 0,
21595
21648
  shadowRadius: 1,
@@ -21599,6 +21652,7 @@ function ShadowUniformsCache() {
21599
21652
 
21600
21653
  case 'SpotLight':
21601
21654
  uniforms = {
21655
+ shadowIntensity: 1,
21602
21656
  shadowBias: 0,
21603
21657
  shadowNormalBias: 0,
21604
21658
  shadowRadius: 1,
@@ -21608,6 +21662,7 @@ function ShadowUniformsCache() {
21608
21662
 
21609
21663
  case 'PointLight':
21610
21664
  uniforms = {
21665
+ shadowIntensity: 1,
21611
21666
  shadowBias: 0,
21612
21667
  shadowNormalBias: 0,
21613
21668
  shadowRadius: 1,
@@ -21757,6 +21812,7 @@ function WebGLLights( extensions ) {
21757
21812
 
21758
21813
  const shadowUniforms = shadowCache.get( light );
21759
21814
 
21815
+ shadowUniforms.shadowIntensity = shadow.intensity;
21760
21816
  shadowUniforms.shadowBias = shadow.bias;
21761
21817
  shadowUniforms.shadowNormalBias = shadow.normalBias;
21762
21818
  shadowUniforms.shadowRadius = shadow.radius;
@@ -21810,6 +21866,7 @@ function WebGLLights( extensions ) {
21810
21866
 
21811
21867
  const shadowUniforms = shadowCache.get( light );
21812
21868
 
21869
+ shadowUniforms.shadowIntensity = shadow.intensity;
21813
21870
  shadowUniforms.shadowBias = shadow.bias;
21814
21871
  shadowUniforms.shadowNormalBias = shadow.normalBias;
21815
21872
  shadowUniforms.shadowRadius = shadow.radius;
@@ -21851,6 +21908,7 @@ function WebGLLights( extensions ) {
21851
21908
 
21852
21909
  const shadowUniforms = shadowCache.get( light );
21853
21910
 
21911
+ shadowUniforms.shadowIntensity = shadow.intensity;
21854
21912
  shadowUniforms.shadowBias = shadow.bias;
21855
21913
  shadowUniforms.shadowNormalBias = shadow.normalBias;
21856
21914
  shadowUniforms.shadowRadius = shadow.radius;
@@ -23928,6 +23986,213 @@ function WebGLState( gl ) {
23928
23986
 
23929
23987
  }
23930
23988
 
23989
+ function contain( texture, aspect ) {
23990
+
23991
+ const imageAspect = ( texture.image && texture.image.width ) ? texture.image.width / texture.image.height : 1;
23992
+
23993
+ if ( imageAspect > aspect ) {
23994
+
23995
+ texture.repeat.x = 1;
23996
+ texture.repeat.y = imageAspect / aspect;
23997
+
23998
+ texture.offset.x = 0;
23999
+ texture.offset.y = ( 1 - texture.repeat.y ) / 2;
24000
+
24001
+ } else {
24002
+
24003
+ texture.repeat.x = aspect / imageAspect;
24004
+ texture.repeat.y = 1;
24005
+
24006
+ texture.offset.x = ( 1 - texture.repeat.x ) / 2;
24007
+ texture.offset.y = 0;
24008
+
24009
+ }
24010
+
24011
+ return texture;
24012
+
24013
+ }
24014
+
24015
+ function cover( texture, aspect ) {
24016
+
24017
+ const imageAspect = ( texture.image && texture.image.width ) ? texture.image.width / texture.image.height : 1;
24018
+
24019
+ if ( imageAspect > aspect ) {
24020
+
24021
+ texture.repeat.x = aspect / imageAspect;
24022
+ texture.repeat.y = 1;
24023
+
24024
+ texture.offset.x = ( 1 - texture.repeat.x ) / 2;
24025
+ texture.offset.y = 0;
24026
+
24027
+ } else {
24028
+
24029
+ texture.repeat.x = 1;
24030
+ texture.repeat.y = imageAspect / aspect;
24031
+
24032
+ texture.offset.x = 0;
24033
+ texture.offset.y = ( 1 - texture.repeat.y ) / 2;
24034
+
24035
+ }
24036
+
24037
+ return texture;
24038
+
24039
+ }
24040
+
24041
+ function fill( texture ) {
24042
+
24043
+ texture.repeat.x = 1;
24044
+ texture.repeat.y = 1;
24045
+
24046
+ texture.offset.x = 0;
24047
+ texture.offset.y = 0;
24048
+
24049
+ return texture;
24050
+
24051
+ }
24052
+
24053
+
24054
+
24055
+ /**
24056
+ * Given the width, height, format, and type of a texture. Determines how many
24057
+ * bytes must be used to represent the texture.
24058
+ */
24059
+ function getByteLength( width, height, format, type ) {
24060
+
24061
+ const typeByteLength = getTextureTypeByteLength( type );
24062
+
24063
+ switch ( format ) {
24064
+
24065
+ // https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml
24066
+ case AlphaFormat:
24067
+ return width * height;
24068
+ case LuminanceFormat:
24069
+ return width * height;
24070
+ case LuminanceAlphaFormat:
24071
+ return width * height * 2;
24072
+ case RedFormat:
24073
+ return ( ( width * height ) / typeByteLength.components ) * typeByteLength.byteLength;
24074
+ case RedIntegerFormat:
24075
+ return ( ( width * height ) / typeByteLength.components ) * typeByteLength.byteLength;
24076
+ case RGFormat:
24077
+ return ( ( width * height * 2 ) / typeByteLength.components ) * typeByteLength.byteLength;
24078
+ case RGIntegerFormat:
24079
+ return ( ( width * height * 2 ) / typeByteLength.components ) * typeByteLength.byteLength;
24080
+ case RGBFormat:
24081
+ return ( ( width * height * 3 ) / typeByteLength.components ) * typeByteLength.byteLength;
24082
+ case RGBAFormat:
24083
+ return ( ( width * height * 4 ) / typeByteLength.components ) * typeByteLength.byteLength;
24084
+ case RGBAIntegerFormat:
24085
+ return ( ( width * height * 4 ) / typeByteLength.components ) * typeByteLength.byteLength;
24086
+
24087
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_s3tc_srgb/
24088
+ case RGB_S3TC_DXT1_Format:
24089
+ case RGBA_S3TC_DXT1_Format:
24090
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 8;
24091
+ case RGBA_S3TC_DXT3_Format:
24092
+ case RGBA_S3TC_DXT5_Format:
24093
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
24094
+
24095
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_pvrtc/
24096
+ case RGB_PVRTC_2BPPV1_Format:
24097
+ case RGBA_PVRTC_2BPPV1_Format:
24098
+ return ( Math.max( width, 16 ) * Math.max( height, 8 ) ) / 4;
24099
+ case RGB_PVRTC_4BPPV1_Format:
24100
+ case RGBA_PVRTC_4BPPV1_Format:
24101
+ return ( Math.max( width, 8 ) * Math.max( height, 8 ) ) / 2;
24102
+
24103
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_etc/
24104
+ case RGB_ETC1_Format:
24105
+ case RGB_ETC2_Format:
24106
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 8;
24107
+ case RGBA_ETC2_EAC_Format:
24108
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
24109
+
24110
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_astc/
24111
+ case RGBA_ASTC_4x4_Format:
24112
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
24113
+ case RGBA_ASTC_5x4_Format:
24114
+ return Math.floor( ( width + 4 ) / 5 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
24115
+ case RGBA_ASTC_5x5_Format:
24116
+ return Math.floor( ( width + 4 ) / 5 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
24117
+ case RGBA_ASTC_6x5_Format:
24118
+ return Math.floor( ( width + 5 ) / 6 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
24119
+ case RGBA_ASTC_6x6_Format:
24120
+ return Math.floor( ( width + 5 ) / 6 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
24121
+ case RGBA_ASTC_8x5_Format:
24122
+ return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
24123
+ case RGBA_ASTC_8x6_Format:
24124
+ return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
24125
+ case RGBA_ASTC_8x8_Format:
24126
+ return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 7 ) / 8 ) * 16;
24127
+ case RGBA_ASTC_10x5_Format:
24128
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
24129
+ case RGBA_ASTC_10x6_Format:
24130
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
24131
+ case RGBA_ASTC_10x8_Format:
24132
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 7 ) / 8 ) * 16;
24133
+ case RGBA_ASTC_10x10_Format:
24134
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 9 ) / 10 ) * 16;
24135
+ case RGBA_ASTC_12x10_Format:
24136
+ return Math.floor( ( width + 11 ) / 12 ) * Math.floor( ( height + 9 ) / 10 ) * 16;
24137
+ case RGBA_ASTC_12x12_Format:
24138
+ return Math.floor( ( width + 11 ) / 12 ) * Math.floor( ( height + 11 ) / 12 ) * 16;
24139
+
24140
+ // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_bptc/
24141
+ case RGBA_BPTC_Format:
24142
+ case RGB_BPTC_SIGNED_Format:
24143
+ case RGB_BPTC_UNSIGNED_Format:
24144
+ return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 16;
24145
+
24146
+ // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_rgtc/
24147
+ case RED_RGTC1_Format:
24148
+ case SIGNED_RED_RGTC1_Format:
24149
+ return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 8;
24150
+ case RED_GREEN_RGTC2_Format:
24151
+ case SIGNED_RED_GREEN_RGTC2_Format:
24152
+ return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 16;
24153
+
24154
+ }
24155
+
24156
+ throw new Error(
24157
+ `Unable to determine texture byte length for ${format} format.`,
24158
+ );
24159
+
24160
+ }
24161
+
24162
+ function getTextureTypeByteLength( type ) {
24163
+
24164
+ switch ( type ) {
24165
+
24166
+ case UnsignedByteType:
24167
+ case ByteType:
24168
+ return { byteLength: 1, components: 1 };
24169
+ case UnsignedShortType:
24170
+ case ShortType:
24171
+ case HalfFloatType:
24172
+ return { byteLength: 2, components: 1 };
24173
+ case UnsignedShort4444Type:
24174
+ case UnsignedShort5551Type:
24175
+ return { byteLength: 2, components: 4 };
24176
+ case UnsignedIntType:
24177
+ case IntType:
24178
+ case FloatType:
24179
+ return { byteLength: 4, components: 1 };
24180
+ case UnsignedInt5999Type:
24181
+ return { byteLength: 4, components: 3 };
24182
+
24183
+ }
24184
+
24185
+ throw new Error( `Unknown texture type ${type}.` );
24186
+
24187
+ }
24188
+
24189
+ const TextureUtils = {
24190
+ contain,
24191
+ cover,
24192
+ fill,
24193
+ getByteLength
24194
+ };
24195
+
23931
24196
  function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
23932
24197
 
23933
24198
  const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
@@ -24823,10 +25088,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24823
25088
 
24824
25089
  if ( texture.layerUpdates.size > 0 ) {
24825
25090
 
25091
+ const layerByteLength = getByteLength( mipmap.width, mipmap.height, texture.format, texture.type );
25092
+
24826
25093
  for ( const layerIndex of texture.layerUpdates ) {
24827
25094
 
24828
- const layerSize = mipmap.width * mipmap.height;
24829
- state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, mipmap.data.slice( layerSize * layerIndex, layerSize * ( layerIndex + 1 ) ), 0, 0 );
25095
+ const layerData = mipmap.data.subarray(
25096
+ layerIndex * layerByteLength / mipmap.data.BYTES_PER_ELEMENT,
25097
+ ( layerIndex + 1 ) * layerByteLength / mipmap.data.BYTES_PER_ELEMENT
25098
+ );
25099
+ state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, layerData, 0, 0 );
24830
25100
 
24831
25101
  }
24832
25102
 
@@ -24944,60 +25214,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24944
25214
 
24945
25215
  if ( texture.layerUpdates.size > 0 ) {
24946
25216
 
24947
- // When type is GL_UNSIGNED_BYTE, each of these bytes is
24948
- // interpreted as one color component, depending on format. When
24949
- // type is one of GL_UNSIGNED_SHORT_5_6_5,
24950
- // GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1, each
24951
- // unsigned value is interpreted as containing all the components
24952
- // for a single pixel, with the color components arranged
24953
- // according to format.
24954
- //
24955
- // See https://registry.khronos.org/OpenGL-Refpages/es1.1/xhtml/glTexImage2D.xml
24956
- let texelSize;
24957
- switch ( glType ) {
24958
-
24959
- case _gl.UNSIGNED_BYTE:
24960
- switch ( glFormat ) {
24961
-
24962
- case _gl.ALPHA:
24963
- texelSize = 1;
24964
- break;
24965
- case _gl.LUMINANCE:
24966
- texelSize = 1;
24967
- break;
24968
- case _gl.LUMINANCE_ALPHA:
24969
- texelSize = 2;
24970
- break;
24971
- case _gl.RGB:
24972
- texelSize = 3;
24973
- break;
24974
- case _gl.RGBA:
24975
- texelSize = 4;
24976
- break;
24977
-
24978
- default:
24979
- throw new Error( `Unknown texel size for format ${glFormat}.` );
24980
-
24981
- }
24982
-
24983
- break;
24984
-
24985
- case _gl.UNSIGNED_SHORT_4_4_4_4:
24986
- case _gl.UNSIGNED_SHORT_5_5_5_1:
24987
- case _gl.UNSIGNED_SHORT_5_6_5:
24988
- texelSize = 1;
24989
- break;
24990
-
24991
- default:
24992
- throw new Error( `Unknown texel size for type ${glType}.` );
24993
-
24994
- }
24995
-
24996
- const layerSize = image.width * image.height * texelSize;
25217
+ const layerByteLength = getByteLength( image.width, image.height, texture.format, texture.type );
24997
25218
 
24998
25219
  for ( const layerIndex of texture.layerUpdates ) {
24999
25220
 
25000
- state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, layerIndex, image.width, image.height, 1, glFormat, glType, image.data.slice( layerSize * layerIndex, layerSize * ( layerIndex + 1 ) ) );
25221
+ const layerData = image.data.subarray(
25222
+ layerIndex * layerByteLength / image.data.BYTES_PER_ELEMENT,
25223
+ ( layerIndex + 1 ) * layerByteLength / image.data.BYTES_PER_ELEMENT
25224
+ );
25225
+ state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, layerIndex, image.width, image.height, 1, glFormat, glType, layerData );
25001
25226
 
25002
25227
  }
25003
25228
 
@@ -25686,6 +25911,37 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25686
25911
  const renderTargetProperties = properties.get( renderTarget );
25687
25912
  const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
25688
25913
 
25914
+ // if the bound depth texture has changed
25915
+ if ( renderTargetProperties.__boundDepthTexture !== renderTarget.depthTexture ) {
25916
+
25917
+ // fire the dispose event to get rid of stored state associated with the previously bound depth buffer
25918
+ const depthTexture = renderTarget.depthTexture;
25919
+ if ( renderTargetProperties.__depthDisposeCallback ) {
25920
+
25921
+ renderTargetProperties.__depthDisposeCallback();
25922
+
25923
+ }
25924
+
25925
+ // set up dispose listeners to track when the currently attached buffer is implicitly unbound
25926
+ if ( depthTexture ) {
25927
+
25928
+ const disposeEvent = () => {
25929
+
25930
+ delete renderTargetProperties.__boundDepthTexture;
25931
+ delete renderTargetProperties.__depthDisposeCallback;
25932
+ depthTexture.removeEventListener( 'dispose', disposeEvent );
25933
+
25934
+ };
25935
+
25936
+ depthTexture.addEventListener( 'dispose', disposeEvent );
25937
+ renderTargetProperties.__depthDisposeCallback = disposeEvent;
25938
+
25939
+ }
25940
+
25941
+ renderTargetProperties.__boundDepthTexture = depthTexture;
25942
+
25943
+ }
25944
+
25689
25945
  if ( renderTarget.depthTexture && ! renderTargetProperties.__autoAllocateDepthBuffer ) {
25690
25946
 
25691
25947
  if ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );
@@ -25701,16 +25957,42 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25701
25957
  for ( let i = 0; i < 6; i ++ ) {
25702
25958
 
25703
25959
  state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ i ] );
25704
- renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();
25705
- setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false );
25960
+
25961
+ if ( renderTargetProperties.__webglDepthbuffer[ i ] === undefined ) {
25962
+
25963
+ renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();
25964
+ setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false );
25965
+
25966
+ } else {
25967
+
25968
+ // attach buffer if it's been created already
25969
+ const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
25970
+ const renderbuffer = renderTargetProperties.__webglDepthbuffer[ i ];
25971
+ _gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
25972
+ _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
25973
+
25974
+ }
25706
25975
 
25707
25976
  }
25708
25977
 
25709
25978
  } else {
25710
25979
 
25711
25980
  state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
25712
- renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();
25713
- setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false );
25981
+
25982
+ if ( renderTargetProperties.__webglDepthbuffer === undefined ) {
25983
+
25984
+ renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();
25985
+ setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false );
25986
+
25987
+ } else {
25988
+
25989
+ // attach buffer if it's been created already
25990
+ const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
25991
+ const renderbuffer = renderTargetProperties.__webglDepthbuffer;
25992
+ _gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
25993
+ _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
25994
+
25995
+ }
25714
25996
 
25715
25997
  }
25716
25998
 
@@ -27478,6 +27760,12 @@ class WebXRDepthSensing {
27478
27760
 
27479
27761
  }
27480
27762
 
27763
+ getDepthTexture() {
27764
+
27765
+ return this.texture;
27766
+
27767
+ }
27768
+
27481
27769
  }
27482
27770
 
27483
27771
  class WebXRManager extends EventDispatcher {
@@ -27900,6 +28188,12 @@ class WebXRManager extends EventDispatcher {
27900
28188
  session.updateRenderState( { layers: layersCopy } );
27901
28189
  };
27902
28190
 
28191
+ this.getDepthTexture = function () {
28192
+
28193
+ return depthSensing.getDepthTexture();
28194
+
28195
+ };
28196
+
27903
28197
  function onInputSourcesChange( event ) {
27904
28198
 
27905
28199
  // Notify disconnected
@@ -28012,18 +28306,31 @@ class WebXRManager extends EventDispatcher {
28012
28306
  camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
28013
28307
  camera.matrixWorldInverse.copy( camera.matrixWorld ).invert();
28014
28308
 
28015
- // Find the union of the frustum values of the cameras and scale
28016
- // the values so that the near plane's position does not change in world space,
28017
- // although must now be relative to the new union camera.
28018
- const near2 = near + zOffset;
28019
- const far2 = far + zOffset;
28020
- const left2 = left - xOffset;
28021
- const right2 = right + ( ipd - xOffset );
28022
- const top2 = topFov * far / far2 * near2;
28023
- const bottom2 = bottomFov * far / far2 * near2;
28309
+ // Check if the projection uses an infinite far plane.
28310
+ if ( projL[ 10 ] === - 1.0 ) {
28311
+
28312
+ // Use the projection matrix from the left eye.
28313
+ // The camera offset is sufficient to include the view volumes
28314
+ // of both eyes (assuming symmetric projections).
28315
+ camera.projectionMatrix.copy( cameraL.projectionMatrix );
28316
+ camera.projectionMatrixInverse.copy( cameraL.projectionMatrixInverse );
28024
28317
 
28025
- camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
28026
- camera.projectionMatrixInverse.copy( camera.projectionMatrix ).invert();
28318
+ } else {
28319
+
28320
+ // Find the union of the frustum values of the cameras and scale
28321
+ // the values so that the near plane's position does not change in world space,
28322
+ // although must now be relative to the new union camera.
28323
+ const near2 = near + zOffset;
28324
+ const far2 = far + zOffset;
28325
+ const left2 = left - xOffset;
28326
+ const right2 = right + ( ipd - xOffset );
28327
+ const top2 = topFov * far / far2 * near2;
28328
+ const bottom2 = bottomFov * far / far2 * near2;
28329
+
28330
+ camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
28331
+ camera.projectionMatrixInverse.copy( camera.projectionMatrix ).invert();
28332
+
28333
+ }
28027
28334
 
28028
28335
  }
28029
28336
 
@@ -28053,15 +28360,18 @@ class WebXRManager extends EventDispatcher {
28053
28360
 
28054
28361
  if ( session === null ) return;
28055
28362
 
28363
+ let depthNear = camera.near;
28364
+ let depthFar = camera.far;
28365
+
28056
28366
  if ( depthSensing.texture !== null ) {
28057
28367
 
28058
- camera.near = depthSensing.depthNear;
28059
- camera.far = depthSensing.depthFar;
28368
+ if ( depthSensing.depthNear > 0 ) depthNear = depthSensing.depthNear;
28369
+ if ( depthSensing.depthFar > 0 ) depthFar = depthSensing.depthFar;
28060
28370
 
28061
28371
  }
28062
28372
 
28063
- cameraXR.near = cameraR.near = cameraL.near = camera.near;
28064
- cameraXR.far = cameraR.far = cameraL.far = camera.far;
28373
+ cameraXR.near = cameraR.near = cameraL.near = depthNear;
28374
+ cameraXR.far = cameraR.far = cameraL.far = depthFar;
28065
28375
 
28066
28376
  if ( _currentDepthNear !== cameraXR.near || _currentDepthFar !== cameraXR.far ) {
28067
28377
 
@@ -28075,15 +28385,6 @@ class WebXRManager extends EventDispatcher {
28075
28385
  _currentDepthNear = cameraXR.near;
28076
28386
  _currentDepthFar = cameraXR.far;
28077
28387
 
28078
- cameraL.near = _currentDepthNear;
28079
- cameraL.far = _currentDepthFar;
28080
- cameraR.near = _currentDepthNear;
28081
- cameraR.far = _currentDepthFar;
28082
-
28083
- cameraL.updateProjectionMatrix();
28084
- cameraR.updateProjectionMatrix();
28085
- camera.updateProjectionMatrix();
28086
-
28087
28388
  }
28088
28389
 
28089
28390
  const cameras = cameraXR.cameras;
@@ -29178,27 +29479,27 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
29178
29479
 
29179
29480
  const info = getUniformSize( value );
29180
29481
 
29181
- // Calculate the chunk offset
29182
- const chunkOffsetUniform = offset % chunkSize;
29482
+ const chunkOffset = offset % chunkSize; // offset in the current chunk
29483
+ const chunkPadding = chunkOffset % info.boundary; // required padding to match boundary
29484
+ const chunkStart = chunkOffset + chunkPadding; // the start position in the current chunk for the data
29485
+
29486
+ offset += chunkPadding;
29183
29487
 
29184
29488
  // Check for chunk overflow
29185
- if ( chunkOffsetUniform !== 0 && ( chunkSize - chunkOffsetUniform ) < info.boundary ) {
29489
+ if ( chunkStart !== 0 && ( chunkSize - chunkStart ) < info.storage ) {
29186
29490
 
29187
29491
  // Add padding and adjust offset
29188
- offset += ( chunkSize - chunkOffsetUniform );
29492
+ offset += ( chunkSize - chunkStart );
29189
29493
 
29190
29494
  }
29191
29495
 
29192
29496
  // the following two properties will be used for partial buffer updates
29193
-
29194
29497
  uniform.__data = new Float32Array( info.storage / Float32Array.BYTES_PER_ELEMENT );
29195
29498
  uniform.__offset = offset;
29196
29499
 
29197
-
29198
29500
  // Update the global offset
29199
29501
  offset += info.storage;
29200
29502
 
29201
-
29202
29503
  }
29203
29504
 
29204
29505
  }
@@ -29470,6 +29771,8 @@ class WebGLRenderer {
29470
29771
 
29471
29772
  const _vector3 = new Vector3();
29472
29773
 
29774
+ const _vector4 = new Vector4();
29775
+
29473
29776
  const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
29474
29777
 
29475
29778
  let _renderBackground = false;
@@ -30129,7 +30432,25 @@ class WebGLRenderer {
30129
30432
 
30130
30433
  } else {
30131
30434
 
30132
- renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
30435
+ if ( ! extensions.get( 'WEBGL_multi_draw' ) ) {
30436
+
30437
+ const starts = object._multiDrawStarts;
30438
+ const counts = object._multiDrawCounts;
30439
+ const drawCount = object._multiDrawCount;
30440
+ const bytesPerElement = index ? attributes.get( index ).bytesPerElement : 1;
30441
+ const uniforms = properties.get( material ).currentProgram.getUniforms();
30442
+ for ( let i = 0; i < drawCount; i ++ ) {
30443
+
30444
+ uniforms.setValue( _gl, '_gl_DrawID', i );
30445
+ renderer.render( starts[ i ] / bytesPerElement, counts[ i ] );
30446
+
30447
+ }
30448
+
30449
+ } else {
30450
+
30451
+ renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
30452
+
30453
+ }
30133
30454
 
30134
30455
  }
30135
30456
 
@@ -30602,7 +30923,7 @@ class WebGLRenderer {
30602
30923
 
30603
30924
  if ( sortObjects ) {
30604
30925
 
30605
- _vector3.setFromMatrixPosition( object.matrixWorld )
30926
+ _vector4.setFromMatrixPosition( object.matrixWorld )
30606
30927
  .applyMatrix4( _projScreenMatrix );
30607
30928
 
30608
30929
  }
@@ -30612,7 +30933,7 @@ class WebGLRenderer {
30612
30933
 
30613
30934
  if ( material.visible ) {
30614
30935
 
30615
- currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
30936
+ currentRenderList.push( object, geometry, material, groupOrder, _vector4.z, null );
30616
30937
 
30617
30938
  }
30618
30939
 
@@ -30630,16 +30951,16 @@ class WebGLRenderer {
30630
30951
  if ( object.boundingSphere !== undefined ) {
30631
30952
 
30632
30953
  if ( object.boundingSphere === null ) object.computeBoundingSphere();
30633
- _vector3.copy( object.boundingSphere.center );
30954
+ _vector4.copy( object.boundingSphere.center );
30634
30955
 
30635
30956
  } else {
30636
30957
 
30637
30958
  if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
30638
- _vector3.copy( geometry.boundingSphere.center );
30959
+ _vector4.copy( geometry.boundingSphere.center );
30639
30960
 
30640
30961
  }
30641
30962
 
30642
- _vector3
30963
+ _vector4
30643
30964
  .applyMatrix4( object.matrixWorld )
30644
30965
  .applyMatrix4( _projScreenMatrix );
30645
30966
 
@@ -30656,7 +30977,7 @@ class WebGLRenderer {
30656
30977
 
30657
30978
  if ( groupMaterial && groupMaterial.visible ) {
30658
30979
 
30659
- currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector3.z, group );
30980
+ currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector4.z, group );
30660
30981
 
30661
30982
  }
30662
30983
 
@@ -30664,7 +30985,7 @@ class WebGLRenderer {
30664
30985
 
30665
30986
  } else if ( material.visible ) {
30666
30987
 
30667
- currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
30988
+ currentRenderList.push( object, geometry, material, groupOrder, _vector4.z, null );
30668
30989
 
30669
30990
  }
30670
30991
 
@@ -30759,15 +31080,9 @@ class WebGLRenderer {
30759
31080
  _currentClearAlpha = _this.getClearAlpha();
30760
31081
  if ( _currentClearAlpha < 1 ) _this.setClearColor( 0xffffff, 0.5 );
30761
31082
 
30762
- if ( _renderBackground ) {
30763
-
30764
- background.render( scene );
31083
+ _this.clear();
30765
31084
 
30766
- } else {
30767
-
30768
- _this.clear();
30769
-
30770
- }
31085
+ if ( _renderBackground ) background.render( scene );
30771
31086
 
30772
31087
  // Turn off the features which can affect the frag color for opaque objects pass.
30773
31088
  // Otherwise they are applied twice in opaque objects pass and transmission objects pass.
@@ -30944,8 +31259,6 @@ class WebGLRenderer {
30944
31259
 
30945
31260
  parameters.uniforms = programCache.getUniforms( material );
30946
31261
 
30947
- material.onBuild( object, parameters, _this );
30948
-
30949
31262
  material.onBeforeCompile( parameters, _this );
30950
31263
 
30951
31264
  program = programCache.acquireProgram( parameters, programCacheKey );
@@ -31330,6 +31643,9 @@ class WebGLRenderer {
31330
31643
  p_uniforms.setOptional( _gl, object, 'batchingTexture' );
31331
31644
  p_uniforms.setValue( _gl, 'batchingTexture', object._matricesTexture, textures );
31332
31645
 
31646
+ p_uniforms.setOptional( _gl, object, 'batchingIdTexture' );
31647
+ p_uniforms.setValue( _gl, 'batchingIdTexture', object._indirectTexture, textures );
31648
+
31333
31649
  p_uniforms.setOptional( _gl, object, 'batchingColorTexture' );
31334
31650
  if ( object._colorsTexture !== null ) {
31335
31651
 
@@ -31585,6 +31901,28 @@ class WebGLRenderer {
31585
31901
  // Color and depth texture must be rebound in order for the swapchain to update.
31586
31902
  textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture );
31587
31903
 
31904
+ } else if ( renderTarget.depthBuffer ) {
31905
+
31906
+ // check if the depth texture is already bound to the frame buffer and that it's been initialized
31907
+ const depthTexture = renderTarget.depthTexture;
31908
+ if ( renderTargetProperties.__boundDepthTexture !== depthTexture ) {
31909
+
31910
+ // check if the depth texture is compatible
31911
+ if (
31912
+ depthTexture !== null &&
31913
+ properties.has( depthTexture ) &&
31914
+ ( renderTarget.width !== depthTexture.image.width || renderTarget.height !== depthTexture.image.height )
31915
+ ) {
31916
+
31917
+ throw new Error( 'WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.' );
31918
+
31919
+ }
31920
+
31921
+ // Swap the depth buffer to the currently attached one
31922
+ textures.setupDepthRenderbuffer( renderTarget );
31923
+
31924
+ }
31925
+
31588
31926
  }
31589
31927
 
31590
31928
  const texture = renderTarget.texture;
@@ -31817,7 +32155,7 @@ class WebGLRenderer {
31817
32155
  if ( texture.isTexture !== true ) {
31818
32156
 
31819
32157
  // @deprecated, r165
31820
- console.warn( 'WebGLRenderer: copyFramebufferToTexture function signature has changed.' );
32158
+ warnOnce( 'WebGLRenderer: copyFramebufferToTexture function signature has changed.' );
31821
32159
 
31822
32160
  position = arguments[ 0 ] || null;
31823
32161
  texture = arguments[ 1 ];
@@ -31845,7 +32183,7 @@ class WebGLRenderer {
31845
32183
  if ( srcTexture.isTexture !== true ) {
31846
32184
 
31847
32185
  // @deprecated, r165
31848
- console.warn( 'WebGLRenderer: copyTextureToTexture function signature has changed.' );
32186
+ warnOnce( 'WebGLRenderer: copyTextureToTexture function signature has changed.' );
31849
32187
 
31850
32188
  dstPosition = arguments[ 0 ] || null;
31851
32189
  srcTexture = arguments[ 1 ];
@@ -31921,7 +32259,7 @@ class WebGLRenderer {
31921
32259
 
31922
32260
  } else {
31923
32261
 
31924
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, glFormat, glType, image );
32262
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
31925
32263
 
31926
32264
  }
31927
32265
 
@@ -31946,7 +32284,7 @@ class WebGLRenderer {
31946
32284
  if ( srcTexture.isTexture !== true ) {
31947
32285
 
31948
32286
  // @deprecated, r165
31949
- console.warn( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
32287
+ warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
31950
32288
 
31951
32289
  srcRegion = arguments[ 0 ] || null;
31952
32290
  dstPosition = arguments[ 1 ] || null;
@@ -33996,7 +34334,7 @@ class InstancedMesh extends Mesh {
33996
34334
 
33997
34335
  if ( this.instanceColor === null ) {
33998
34336
 
33999
- this.instanceColor = new InstancedBufferAttribute( new Float32Array( this.instanceMatrix.count * 3 ), 3 );
34337
+ this.instanceColor = new InstancedBufferAttribute( new Float32Array( this.instanceMatrix.count * 3 ).fill( 1 ), 3 );
34000
34338
 
34001
34339
  }
34002
34340
 
@@ -34085,7 +34423,7 @@ class MultiDrawRenderList {
34085
34423
 
34086
34424
  }
34087
34425
 
34088
- push( drawRange, z ) {
34426
+ push( drawRange, z, index ) {
34089
34427
 
34090
34428
  const pool = this.pool;
34091
34429
  const list = this.list;
@@ -34096,6 +34434,7 @@ class MultiDrawRenderList {
34096
34434
  start: - 1,
34097
34435
  count: - 1,
34098
34436
  z: - 1,
34437
+ index: - 1,
34099
34438
 
34100
34439
  } );
34101
34440
 
@@ -34108,6 +34447,7 @@ class MultiDrawRenderList {
34108
34447
  item.start = drawRange.start;
34109
34448
  item.count = drawRange.count;
34110
34449
  item.z = z;
34450
+ item.index = index;
34111
34451
 
34112
34452
  }
34113
34453
 
@@ -34120,7 +34460,6 @@ class MultiDrawRenderList {
34120
34460
 
34121
34461
  }
34122
34462
 
34123
- const ID_ATTR_NAME = 'batchId';
34124
34463
  const _matrix$1 = /*@__PURE__*/ new Matrix4();
34125
34464
  const _invMatrixWorld = /*@__PURE__*/ new Matrix4();
34126
34465
  const _identityMatrix = /*@__PURE__*/ new Matrix4();
@@ -34175,13 +34514,13 @@ function copyAttributeData( src, target, targetOffset = 0 ) {
34175
34514
 
34176
34515
  class BatchedMesh extends Mesh {
34177
34516
 
34178
- get maxGeometryCount() {
34517
+ get maxInstanceCount() {
34179
34518
 
34180
- return this._maxGeometryCount;
34519
+ return this._maxInstanceCount;
34181
34520
 
34182
34521
  }
34183
34522
 
34184
- constructor( maxGeometryCount, maxVertexCount, maxIndexCount = maxVertexCount * 2, material ) {
34523
+ constructor( maxInstanceCount, maxVertexCount, maxIndexCount = maxVertexCount * 2, material ) {
34185
34524
 
34186
34525
  super( new BufferGeometry(), material );
34187
34526
 
@@ -34192,32 +34531,33 @@ class BatchedMesh extends Mesh {
34192
34531
  this.boundingSphere = null;
34193
34532
  this.customSort = null;
34194
34533
 
34534
+ // stores visible, active, and geometry id per object
34535
+ this._drawInfo = [];
34536
+
34537
+ // geometry information
34195
34538
  this._drawRanges = [];
34196
34539
  this._reservedRanges = [];
34197
-
34198
- this._visibility = [];
34199
- this._active = [];
34200
34540
  this._bounds = [];
34201
34541
 
34202
- this._maxGeometryCount = maxGeometryCount;
34542
+ this._maxInstanceCount = maxInstanceCount;
34203
34543
  this._maxVertexCount = maxVertexCount;
34204
34544
  this._maxIndexCount = maxIndexCount;
34205
34545
 
34206
34546
  this._geometryInitialized = false;
34207
34547
  this._geometryCount = 0;
34208
- this._multiDrawCounts = new Int32Array( maxGeometryCount );
34209
- this._multiDrawStarts = new Int32Array( maxGeometryCount );
34548
+ this._multiDrawCounts = new Int32Array( maxInstanceCount );
34549
+ this._multiDrawStarts = new Int32Array( maxInstanceCount );
34210
34550
  this._multiDrawCount = 0;
34211
34551
  this._multiDrawInstances = null;
34212
34552
  this._visibilityChanged = true;
34213
34553
 
34214
34554
  // Local matrix per geometry by using data texture
34215
34555
  this._matricesTexture = null;
34556
+ this._indirectTexture = null;
34557
+ this._colorsTexture = null;
34216
34558
 
34217
34559
  this._initMatricesTexture();
34218
-
34219
- // Local color per geometry by using data texture
34220
- this._colorsTexture = null;
34560
+ this._initIndirectTexture();
34221
34561
 
34222
34562
  }
34223
34563
 
@@ -34230,7 +34570,7 @@ class BatchedMesh extends Mesh {
34230
34570
  // 32x32 pixel texture max 256 matrices * 4 pixels = (32 * 32)
34231
34571
  // 64x64 pixel texture max 1024 matrices * 4 pixels = (64 * 64)
34232
34572
 
34233
- let size = Math.sqrt( this._maxGeometryCount * 4 ); // 4 pixels needed for 1 matrix
34573
+ let size = Math.sqrt( this._maxInstanceCount * 4 ); // 4 pixels needed for 1 matrix
34234
34574
  size = Math.ceil( size / 4 ) * 4;
34235
34575
  size = Math.max( size, 4 );
34236
34576
 
@@ -34241,9 +34581,21 @@ class BatchedMesh extends Mesh {
34241
34581
 
34242
34582
  }
34243
34583
 
34584
+ _initIndirectTexture() {
34585
+
34586
+ let size = Math.sqrt( this._maxInstanceCount );
34587
+ size = Math.ceil( size );
34588
+
34589
+ const indirectArray = new Uint32Array( size * size );
34590
+ const indirectTexture = new DataTexture( indirectArray, size, size, RedIntegerFormat, UnsignedIntType );
34591
+
34592
+ this._indirectTexture = indirectTexture;
34593
+
34594
+ }
34595
+
34244
34596
  _initColorsTexture() {
34245
34597
 
34246
- let size = Math.sqrt( this._maxGeometryCount );
34598
+ let size = Math.sqrt( this._maxInstanceCount );
34247
34599
  size = Math.ceil( size );
34248
34600
 
34249
34601
  // 4 floats per RGBA pixel initialized to white
@@ -34259,7 +34611,6 @@ class BatchedMesh extends Mesh {
34259
34611
 
34260
34612
  const geometry = this.geometry;
34261
34613
  const maxVertexCount = this._maxVertexCount;
34262
- const maxGeometryCount = this._maxGeometryCount;
34263
34614
  const maxIndexCount = this._maxIndexCount;
34264
34615
  if ( this._geometryInitialized === false ) {
34265
34616
 
@@ -34277,7 +34628,8 @@ class BatchedMesh extends Mesh {
34277
34628
 
34278
34629
  if ( reference.getIndex() !== null ) {
34279
34630
 
34280
- const indexArray = maxVertexCount > 65536
34631
+ // Reserve last u16 index for primitive restart.
34632
+ const indexArray = maxVertexCount > 65535
34281
34633
  ? new Uint32Array( maxIndexCount )
34282
34634
  : new Uint16Array( maxIndexCount );
34283
34635
 
@@ -34285,11 +34637,6 @@ class BatchedMesh extends Mesh {
34285
34637
 
34286
34638
  }
34287
34639
 
34288
- const idArray = maxGeometryCount > 65536
34289
- ? new Uint32Array( maxVertexCount )
34290
- : new Uint16Array( maxVertexCount );
34291
- geometry.setAttribute( ID_ATTR_NAME, new BufferAttribute( idArray, 1 ) );
34292
-
34293
34640
  this._geometryInitialized = true;
34294
34641
 
34295
34642
  }
@@ -34299,13 +34646,6 @@ class BatchedMesh extends Mesh {
34299
34646
  // Make sure the geometry is compatible with the existing combined geometry attributes
34300
34647
  _validateGeometry( geometry ) {
34301
34648
 
34302
- // check that the geometry doesn't have a version of our reserved id attribute
34303
- if ( geometry.getAttribute( ID_ATTR_NAME ) ) {
34304
-
34305
- throw new Error( `BatchedMesh: Geometry cannot use attribute "${ ID_ATTR_NAME }"` );
34306
-
34307
- }
34308
-
34309
34649
  // check to ensure the geometries are using consistent attributes and indices
34310
34650
  const batchGeometry = this.geometry;
34311
34651
  if ( Boolean( geometry.getIndex() ) !== Boolean( batchGeometry.getIndex() ) ) {
@@ -34316,12 +34656,6 @@ class BatchedMesh extends Mesh {
34316
34656
 
34317
34657
  for ( const attributeName in batchGeometry.attributes ) {
34318
34658
 
34319
- if ( attributeName === ID_ATTR_NAME ) {
34320
-
34321
- continue;
34322
-
34323
- }
34324
-
34325
34659
  if ( ! geometry.hasAttribute( attributeName ) ) {
34326
34660
 
34327
34661
  throw new Error( `BatchedMesh: Added geometry missing "${ attributeName }". All geometries must have consistent attributes.` );
@@ -34355,17 +34689,17 @@ class BatchedMesh extends Mesh {
34355
34689
 
34356
34690
  }
34357
34691
 
34358
- const geometryCount = this._geometryCount;
34359
34692
  const boundingBox = this.boundingBox;
34360
- const active = this._active;
34693
+ const drawInfo = this._drawInfo;
34361
34694
 
34362
34695
  boundingBox.makeEmpty();
34363
- for ( let i = 0; i < geometryCount; i ++ ) {
34696
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34364
34697
 
34365
- if ( active[ i ] === false ) continue;
34698
+ if ( drawInfo[ i ].active === false ) continue;
34366
34699
 
34700
+ const geometryId = drawInfo[ i ].geometryIndex;
34367
34701
  this.getMatrixAt( i, _matrix$1 );
34368
- this.getBoundingBoxAt( i, _box$1 ).applyMatrix4( _matrix$1 );
34702
+ this.getBoundingBoxAt( geometryId, _box$1 ).applyMatrix4( _matrix$1 );
34369
34703
  boundingBox.union( _box$1 );
34370
34704
 
34371
34705
  }
@@ -34380,23 +34714,59 @@ class BatchedMesh extends Mesh {
34380
34714
 
34381
34715
  }
34382
34716
 
34383
- const geometryCount = this._geometryCount;
34384
34717
  const boundingSphere = this.boundingSphere;
34385
- const active = this._active;
34718
+ const drawInfo = this._drawInfo;
34386
34719
 
34387
34720
  boundingSphere.makeEmpty();
34388
- for ( let i = 0; i < geometryCount; i ++ ) {
34721
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34389
34722
 
34390
- if ( active[ i ] === false ) continue;
34723
+ if ( drawInfo[ i ].active === false ) continue;
34391
34724
 
34725
+ const geometryId = drawInfo[ i ].geometryIndex;
34392
34726
  this.getMatrixAt( i, _matrix$1 );
34393
- this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix$1 );
34727
+ this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
34394
34728
  boundingSphere.union( _sphere$2 );
34395
34729
 
34396
34730
  }
34397
34731
 
34398
34732
  }
34399
34733
 
34734
+ addInstance( geometryId ) {
34735
+
34736
+ // ensure we're not over geometry
34737
+ if ( this._drawInfo.length >= this._maxInstanceCount ) {
34738
+
34739
+ throw new Error( 'BatchedMesh: Maximum item count reached.' );
34740
+
34741
+ }
34742
+
34743
+ this._drawInfo.push( {
34744
+
34745
+ visible: true,
34746
+ active: true,
34747
+ geometryIndex: geometryId,
34748
+
34749
+ } );
34750
+
34751
+ // initialize the matrix
34752
+ const drawId = this._drawInfo.length - 1;
34753
+ const matricesTexture = this._matricesTexture;
34754
+ const matricesArray = matricesTexture.image.data;
34755
+ _identityMatrix.toArray( matricesArray, drawId * 16 );
34756
+ matricesTexture.needsUpdate = true;
34757
+
34758
+ const colorsTexture = this._colorsTexture;
34759
+ if ( colorsTexture ) {
34760
+
34761
+ _whiteColor.toArray( colorsTexture.image.data, drawId * 4 );
34762
+ colorsTexture.needsUpdate = true;
34763
+
34764
+ }
34765
+
34766
+ return drawId;
34767
+
34768
+ }
34769
+
34400
34770
  addGeometry( geometry, vertexCount = - 1, indexCount = - 1 ) {
34401
34771
 
34402
34772
  this._initializeGeometry( geometry );
@@ -34404,9 +34774,9 @@ class BatchedMesh extends Mesh {
34404
34774
  this._validateGeometry( geometry );
34405
34775
 
34406
34776
  // ensure we're not over geometry
34407
- if ( this._geometryCount >= this._maxGeometryCount ) {
34777
+ if ( this._drawInfo.length >= this._maxInstanceCount ) {
34408
34778
 
34409
- throw new Error( 'BatchedMesh: Maximum geometry count reached.' );
34779
+ throw new Error( 'BatchedMesh: Maximum item count reached.' );
34410
34780
 
34411
34781
  }
34412
34782
 
@@ -34484,32 +34854,10 @@ class BatchedMesh extends Mesh {
34484
34854
 
34485
34855
  }
34486
34856
 
34487
- const visibility = this._visibility;
34488
- const active = this._active;
34489
- const matricesTexture = this._matricesTexture;
34490
- const matricesArray = this._matricesTexture.image.data;
34491
- const colorsTexture = this._colorsTexture;
34492
-
34493
- // push new visibility states
34494
- visibility.push( true );
34495
- active.push( true );
34496
-
34497
34857
  // update id
34498
34858
  const geometryId = this._geometryCount;
34499
34859
  this._geometryCount ++;
34500
34860
 
34501
- // initialize matrix information
34502
- _identityMatrix.toArray( matricesArray, geometryId * 16 );
34503
- matricesTexture.needsUpdate = true;
34504
-
34505
- // initialize the color to white
34506
- if ( colorsTexture !== null ) {
34507
-
34508
- _whiteColor.toArray( colorsTexture.image.data, geometryId * 4 );
34509
- colorsTexture.needsUpdate = true;
34510
-
34511
- }
34512
-
34513
34861
  // add the reserved range and draw range objects
34514
34862
  reservedRanges.push( reservedRange );
34515
34863
  drawRanges.push( {
@@ -34524,16 +34872,6 @@ class BatchedMesh extends Mesh {
34524
34872
  sphere: new Sphere()
34525
34873
  } );
34526
34874
 
34527
- // set the id for the geometry
34528
- const idAttribute = this.geometry.getAttribute( ID_ATTR_NAME );
34529
- for ( let i = 0; i < reservedRange.vertexCount; i ++ ) {
34530
-
34531
- idAttribute.setX( reservedRange.vertexStart + i, geometryId );
34532
-
34533
- }
34534
-
34535
- idAttribute.needsUpdate = true;
34536
-
34537
34875
  // update the geometry
34538
34876
  this.setGeometryAt( geometryId, geometry );
34539
34877
 
@@ -34541,9 +34879,9 @@ class BatchedMesh extends Mesh {
34541
34879
 
34542
34880
  }
34543
34881
 
34544
- setGeometryAt( id, geometry ) {
34882
+ setGeometryAt( geometryId, geometry ) {
34545
34883
 
34546
- if ( id >= this._geometryCount ) {
34884
+ if ( geometryId >= this._geometryCount ) {
34547
34885
 
34548
34886
  throw new Error( 'BatchedMesh: Maximum geometry count reached.' );
34549
34887
 
@@ -34555,7 +34893,7 @@ class BatchedMesh extends Mesh {
34555
34893
  const hasIndex = batchGeometry.getIndex() !== null;
34556
34894
  const dstIndex = batchGeometry.getIndex();
34557
34895
  const srcIndex = geometry.getIndex();
34558
- const reservedRange = this._reservedRanges[ id ];
34896
+ const reservedRange = this._reservedRanges[ geometryId ];
34559
34897
  if (
34560
34898
  hasIndex &&
34561
34899
  srcIndex.count > reservedRange.indexCount ||
@@ -34571,12 +34909,6 @@ class BatchedMesh extends Mesh {
34571
34909
  const vertexCount = reservedRange.vertexCount;
34572
34910
  for ( const attributeName in batchGeometry.attributes ) {
34573
34911
 
34574
- if ( attributeName === ID_ATTR_NAME ) {
34575
-
34576
- continue;
34577
-
34578
- }
34579
-
34580
34912
  // copy attribute data
34581
34913
  const srcAttribute = geometry.getAttribute( attributeName );
34582
34914
  const dstAttribute = batchGeometry.getAttribute( attributeName );
@@ -34625,7 +34957,7 @@ class BatchedMesh extends Mesh {
34625
34957
  }
34626
34958
 
34627
34959
  // store the bounding boxes
34628
- const bound = this._bounds[ id ];
34960
+ const bound = this._bounds[ geometryId ];
34629
34961
  if ( geometry.boundingBox !== null ) {
34630
34962
 
34631
34963
  bound.box.copy( geometry.boundingBox );
@@ -34649,67 +34981,54 @@ class BatchedMesh extends Mesh {
34649
34981
  }
34650
34982
 
34651
34983
  // set drawRange count
34652
- const drawRange = this._drawRanges[ id ];
34984
+ const drawRange = this._drawRanges[ geometryId ];
34653
34985
  const posAttr = geometry.getAttribute( 'position' );
34654
34986
  drawRange.count = hasIndex ? srcIndex.count : posAttr.count;
34655
34987
  this._visibilityChanged = true;
34656
34988
 
34657
- return id;
34989
+ return geometryId;
34658
34990
 
34659
34991
  }
34660
34992
 
34993
+ /*
34661
34994
  deleteGeometry( geometryId ) {
34662
34995
 
34663
- // Note: User needs to call optimize() afterward to pack the data.
34664
-
34665
- const active = this._active;
34666
- if ( geometryId >= active.length || active[ geometryId ] === false ) {
34667
-
34668
- return this;
34669
-
34670
- }
34671
-
34672
- active[ geometryId ] = false;
34673
- this._visibilityChanged = true;
34674
-
34675
- return this;
34996
+ // TODO: delete geometry and associated instances
34676
34997
 
34677
34998
  }
34999
+ */
34678
35000
 
34679
- getInstanceCountAt( id ) {
34680
-
34681
- if ( this._multiDrawInstances === null ) return null;
34682
-
34683
- return this._multiDrawInstances[ id ];
34684
-
34685
- }
35001
+ /*
35002
+ deleteInstance( instanceId ) {
34686
35003
 
34687
- setInstanceCountAt( id, instanceCount ) {
35004
+ // Note: User needs to call optimize() afterward to pack the data.
34688
35005
 
34689
- if ( this._multiDrawInstances === null ) {
35006
+ const drawInfo = this._drawInfo;
35007
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34690
35008
 
34691
- this._multiDrawInstances = new Int32Array( this._maxGeometryCount ).fill( 1 );
35009
+ return this;
34692
35010
 
34693
35011
  }
34694
35012
 
34695
- this._multiDrawInstances[ id ] = instanceCount;
35013
+ drawInfo[ instanceId ].active = false;
35014
+ this._visibilityChanged = true;
34696
35015
 
34697
- return id;
35016
+ return this;
34698
35017
 
34699
35018
  }
35019
+ */
34700
35020
 
34701
35021
  // get bounding box and compute it if it doesn't exist
34702
- getBoundingBoxAt( id, target ) {
35022
+ getBoundingBoxAt( geometryId, target ) {
34703
35023
 
34704
- const active = this._active;
34705
- if ( active[ id ] === false ) {
35024
+ if ( geometryId >= this._geometryCount ) {
34706
35025
 
34707
35026
  return null;
34708
35027
 
34709
35028
  }
34710
35029
 
34711
35030
  // compute bounding box
34712
- const bound = this._bounds[ id ];
35031
+ const bound = this._bounds[ geometryId ];
34713
35032
  const box = bound.box;
34714
35033
  const geometry = this.geometry;
34715
35034
  if ( bound.boxInitialized === false ) {
@@ -34718,7 +35037,7 @@ class BatchedMesh extends Mesh {
34718
35037
 
34719
35038
  const index = geometry.index;
34720
35039
  const position = geometry.attributes.position;
34721
- const drawRange = this._drawRanges[ id ];
35040
+ const drawRange = this._drawRanges[ geometryId ];
34722
35041
  for ( let i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
34723
35042
 
34724
35043
  let iv = i;
@@ -34742,29 +35061,28 @@ class BatchedMesh extends Mesh {
34742
35061
  }
34743
35062
 
34744
35063
  // get bounding sphere and compute it if it doesn't exist
34745
- getBoundingSphereAt( id, target ) {
35064
+ getBoundingSphereAt( geometryId, target ) {
34746
35065
 
34747
- const active = this._active;
34748
- if ( active[ id ] === false ) {
35066
+ if ( geometryId >= this._geometryCount ) {
34749
35067
 
34750
35068
  return null;
34751
35069
 
34752
35070
  }
34753
35071
 
34754
35072
  // compute bounding sphere
34755
- const bound = this._bounds[ id ];
35073
+ const bound = this._bounds[ geometryId ];
34756
35074
  const sphere = bound.sphere;
34757
35075
  const geometry = this.geometry;
34758
35076
  if ( bound.sphereInitialized === false ) {
34759
35077
 
34760
35078
  sphere.makeEmpty();
34761
35079
 
34762
- this.getBoundingBoxAt( id, _box$1 );
35080
+ this.getBoundingBoxAt( geometryId, _box$1 );
34763
35081
  _box$1.getCenter( sphere.center );
34764
35082
 
34765
35083
  const index = geometry.index;
34766
35084
  const position = geometry.attributes.position;
34767
- const drawRange = this._drawRanges[ id ];
35085
+ const drawRange = this._drawRanges[ geometryId ];
34768
35086
 
34769
35087
  let maxRadiusSq = 0;
34770
35088
  for ( let i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
@@ -34791,44 +35109,42 @@ class BatchedMesh extends Mesh {
34791
35109
 
34792
35110
  }
34793
35111
 
34794
- setMatrixAt( geometryId, matrix ) {
35112
+ setMatrixAt( instanceId, matrix ) {
34795
35113
 
34796
35114
  // @TODO: Map geometryId to index of the arrays because
34797
35115
  // optimize() can make geometryId mismatch the index
34798
35116
 
34799
- const active = this._active;
35117
+ const drawInfo = this._drawInfo;
34800
35118
  const matricesTexture = this._matricesTexture;
34801
35119
  const matricesArray = this._matricesTexture.image.data;
34802
- const geometryCount = this._geometryCount;
34803
- if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
35120
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34804
35121
 
34805
35122
  return this;
34806
35123
 
34807
35124
  }
34808
35125
 
34809
- matrix.toArray( matricesArray, geometryId * 16 );
35126
+ matrix.toArray( matricesArray, instanceId * 16 );
34810
35127
  matricesTexture.needsUpdate = true;
34811
35128
 
34812
35129
  return this;
34813
35130
 
34814
35131
  }
34815
35132
 
34816
- getMatrixAt( geometryId, matrix ) {
35133
+ getMatrixAt( instanceId, matrix ) {
34817
35134
 
34818
- const active = this._active;
35135
+ const drawInfo = this._drawInfo;
34819
35136
  const matricesArray = this._matricesTexture.image.data;
34820
- const geometryCount = this._geometryCount;
34821
- if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
35137
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34822
35138
 
34823
35139
  return null;
34824
35140
 
34825
35141
  }
34826
35142
 
34827
- return matrix.fromArray( matricesArray, geometryId * 16 );
35143
+ return matrix.fromArray( matricesArray, instanceId * 16 );
34828
35144
 
34829
35145
  }
34830
35146
 
34831
- setColorAt( geometryId, color ) {
35147
+ setColorAt( instanceId, color ) {
34832
35148
 
34833
35149
  if ( this._colorsTexture === null ) {
34834
35150
 
@@ -34836,89 +35152,79 @@ class BatchedMesh extends Mesh {
34836
35152
 
34837
35153
  }
34838
35154
 
34839
- // @TODO: Map geometryId to index of the arrays because
34840
- // optimize() can make geometryId mismatch the index
35155
+ // @TODO: Map id to index of the arrays because
35156
+ // optimize() can make id mismatch the index
34841
35157
 
34842
- const active = this._active;
34843
35158
  const colorsTexture = this._colorsTexture;
34844
35159
  const colorsArray = this._colorsTexture.image.data;
34845
- const geometryCount = this._geometryCount;
34846
- if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
35160
+ const drawInfo = this._drawInfo;
35161
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34847
35162
 
34848
35163
  return this;
34849
35164
 
34850
35165
  }
34851
35166
 
34852
- color.toArray( colorsArray, geometryId * 4 );
35167
+ color.toArray( colorsArray, instanceId * 4 );
34853
35168
  colorsTexture.needsUpdate = true;
34854
35169
 
34855
35170
  return this;
34856
35171
 
34857
35172
  }
34858
35173
 
34859
- getColorAt( geometryId, color ) {
35174
+ getColorAt( instanceId, color ) {
34860
35175
 
34861
- const active = this._active;
34862
35176
  const colorsArray = this._colorsTexture.image.data;
34863
- const geometryCount = this._geometryCount;
34864
- if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
35177
+ const drawInfo = this._drawInfo;
35178
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34865
35179
 
34866
35180
  return null;
34867
35181
 
34868
35182
  }
34869
35183
 
34870
- return color.fromArray( colorsArray, geometryId * 4 );
35184
+ return color.fromArray( colorsArray, instanceId * 4 );
34871
35185
 
34872
35186
  }
34873
35187
 
34874
- setVisibleAt( geometryId, value ) {
34875
-
34876
- const visibility = this._visibility;
34877
- const active = this._active;
34878
- const geometryCount = this._geometryCount;
35188
+ setVisibleAt( instanceId, value ) {
34879
35189
 
34880
35190
  // if the geometry is out of range, not active, or visibility state
34881
35191
  // does not change then return early
35192
+ const drawInfo = this._drawInfo;
34882
35193
  if (
34883
- geometryId >= geometryCount ||
34884
- active[ geometryId ] === false ||
34885
- visibility[ geometryId ] === value
35194
+ instanceId >= drawInfo.length ||
35195
+ drawInfo[ instanceId ].active === false ||
35196
+ drawInfo[ instanceId ].visible === value
34886
35197
  ) {
34887
35198
 
34888
35199
  return this;
34889
35200
 
34890
35201
  }
34891
35202
 
34892
- visibility[ geometryId ] = value;
35203
+ drawInfo[ instanceId ].visible = value;
34893
35204
  this._visibilityChanged = true;
34894
35205
 
34895
35206
  return this;
34896
35207
 
34897
35208
  }
34898
35209
 
34899
- getVisibleAt( geometryId ) {
34900
-
34901
- const visibility = this._visibility;
34902
- const active = this._active;
34903
- const geometryCount = this._geometryCount;
35210
+ getVisibleAt( instanceId ) {
34904
35211
 
34905
35212
  // return early if the geometry is out of range or not active
34906
- if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
35213
+ const drawInfo = this._drawInfo;
35214
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34907
35215
 
34908
35216
  return false;
34909
35217
 
34910
35218
  }
34911
35219
 
34912
- return visibility[ geometryId ];
35220
+ return drawInfo[ instanceId ].visible;
34913
35221
 
34914
35222
  }
34915
35223
 
34916
35224
  raycast( raycaster, intersects ) {
34917
35225
 
34918
- const visibility = this._visibility;
34919
- const active = this._active;
35226
+ const drawInfo = this._drawInfo;
34920
35227
  const drawRanges = this._drawRanges;
34921
- const geometryCount = this._geometryCount;
34922
35228
  const matrixWorld = this.matrixWorld;
34923
35229
  const batchGeometry = this.geometry;
34924
35230
 
@@ -34938,21 +35244,22 @@ class BatchedMesh extends Mesh {
34938
35244
 
34939
35245
  }
34940
35246
 
34941
- for ( let i = 0; i < geometryCount; i ++ ) {
35247
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34942
35248
 
34943
- if ( ! visibility[ i ] || ! active[ i ] ) {
35249
+ if ( ! drawInfo[ i ].visible || ! drawInfo[ i ].active ) {
34944
35250
 
34945
35251
  continue;
34946
35252
 
34947
35253
  }
34948
35254
 
34949
- const drawRange = drawRanges[ i ];
35255
+ const geometryId = drawInfo[ i ].geometryIndex;
35256
+ const drawRange = drawRanges[ geometryId ];
34950
35257
  _mesh.geometry.setDrawRange( drawRange.start, drawRange.count );
34951
35258
 
34952
35259
  // ge the intersects
34953
35260
  this.getMatrixAt( i, _mesh.matrixWorld ).premultiply( matrixWorld );
34954
- this.getBoundingBoxAt( i, _mesh.geometry.boundingBox );
34955
- this.getBoundingSphereAt( i, _mesh.geometry.boundingSphere );
35261
+ this.getBoundingBoxAt( geometryId, _mesh.geometry.boundingBox );
35262
+ this.getBoundingSphereAt( geometryId, _mesh.geometry.boundingSphere );
34956
35263
  _mesh.raycast( raycaster, _batchIntersects );
34957
35264
 
34958
35265
  // add batch id to the intersects
@@ -34989,8 +35296,7 @@ class BatchedMesh extends Mesh {
34989
35296
  this._drawRanges = source._drawRanges.map( range => ( { ...range } ) );
34990
35297
  this._reservedRanges = source._reservedRanges.map( range => ( { ...range } ) );
34991
35298
 
34992
- this._visibility = source._visibility.slice();
34993
- this._active = source._active.slice();
35299
+ this._drawInfo = source._drawInfo.map( inf => ( { ...inf } ) );
34994
35300
  this._bounds = source._bounds.map( bound => ( {
34995
35301
  boxInitialized: bound.boxInitialized,
34996
35302
  box: bound.box.clone(),
@@ -34999,7 +35305,7 @@ class BatchedMesh extends Mesh {
34999
35305
  sphere: bound.sphere.clone()
35000
35306
  } ) );
35001
35307
 
35002
- this._maxGeometryCount = source._maxGeometryCount;
35308
+ this._maxInstanceCount = source._maxInstanceCount;
35003
35309
  this._maxVertexCount = source._maxVertexCount;
35004
35310
  this._maxIndexCount = source._maxIndexCount;
35005
35311
 
@@ -35009,12 +35315,12 @@ class BatchedMesh extends Mesh {
35009
35315
  this._multiDrawStarts = source._multiDrawStarts.slice();
35010
35316
 
35011
35317
  this._matricesTexture = source._matricesTexture.clone();
35012
- this._matricesTexture.image.data = this._matricesTexture.image.slice();
35318
+ this._matricesTexture.image.data = this._matricesTexture.image.data.slice();
35013
35319
 
35014
35320
  if ( this._colorsTexture !== null ) {
35015
35321
 
35016
35322
  this._colorsTexture = source._colorsTexture.clone();
35017
- this._colorsTexture.image.data = this._colorsTexture.image.slice();
35323
+ this._colorsTexture.image.data = this._colorsTexture.image.data.slice();
35018
35324
 
35019
35325
  }
35020
35326
 
@@ -35030,6 +35336,9 @@ class BatchedMesh extends Mesh {
35030
35336
  this._matricesTexture.dispose();
35031
35337
  this._matricesTexture = null;
35032
35338
 
35339
+ this._indirectTexture.dispose();
35340
+ this._indirectTexture = null;
35341
+
35033
35342
  if ( this._colorsTexture !== null ) {
35034
35343
 
35035
35344
  this._colorsTexture.dispose();
@@ -35056,12 +35365,13 @@ class BatchedMesh extends Mesh {
35056
35365
  const index = geometry.getIndex();
35057
35366
  const bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;
35058
35367
 
35059
- const active = this._active;
35060
- const visibility = this._visibility;
35368
+ const drawInfo = this._drawInfo;
35061
35369
  const multiDrawStarts = this._multiDrawStarts;
35062
35370
  const multiDrawCounts = this._multiDrawCounts;
35063
35371
  const drawRanges = this._drawRanges;
35064
35372
  const perObjectFrustumCulled = this.perObjectFrustumCulled;
35373
+ const indirectTexture = this._indirectTexture;
35374
+ const indirectArray = indirectTexture.image.data;
35065
35375
 
35066
35376
  // prepare the frustum in the local frame
35067
35377
  if ( perObjectFrustumCulled ) {
@@ -35084,13 +35394,15 @@ class BatchedMesh extends Mesh {
35084
35394
  _vector$5.setFromMatrixPosition( camera.matrixWorld ).applyMatrix4( _invMatrixWorld );
35085
35395
  _forward.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ).transformDirection( _invMatrixWorld );
35086
35396
 
35087
- for ( let i = 0, l = visibility.length; i < l; i ++ ) {
35397
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
35398
+
35399
+ if ( drawInfo[ i ].visible && drawInfo[ i ].active ) {
35088
35400
 
35089
- if ( visibility[ i ] && active[ i ] ) {
35401
+ const geometryId = drawInfo[ i ].geometryIndex;
35090
35402
 
35091
35403
  // get the bounds in world space
35092
35404
  this.getMatrixAt( i, _matrix$1 );
35093
- this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix$1 );
35405
+ this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
35094
35406
 
35095
35407
  // determine whether the batched geometry is within the frustum
35096
35408
  let culled = false;
@@ -35104,7 +35416,7 @@ class BatchedMesh extends Mesh {
35104
35416
 
35105
35417
  // get the distance from camera used for sorting
35106
35418
  const z = _temp.subVectors( _sphere$2.center, _vector$5 ).dot( _forward );
35107
- _renderList.push( drawRanges[ i ], z );
35419
+ _renderList.push( drawRanges[ geometryId ], z, i );
35108
35420
 
35109
35421
  }
35110
35422
 
@@ -35130,6 +35442,7 @@ class BatchedMesh extends Mesh {
35130
35442
  const item = list[ i ];
35131
35443
  multiDrawStarts[ count ] = item.start * bytesPerElement;
35132
35444
  multiDrawCounts[ count ] = item.count;
35445
+ indirectArray[ count ] = item.index;
35133
35446
  count ++;
35134
35447
 
35135
35448
  }
@@ -35138,9 +35451,11 @@ class BatchedMesh extends Mesh {
35138
35451
 
35139
35452
  } else {
35140
35453
 
35141
- for ( let i = 0, l = visibility.length; i < l; i ++ ) {
35454
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
35142
35455
 
35143
- if ( visibility[ i ] && active[ i ] ) {
35456
+ if ( drawInfo[ i ].visible && drawInfo[ i ].active ) {
35457
+
35458
+ const geometryId = drawInfo[ i ].geometryIndex;
35144
35459
 
35145
35460
  // determine whether the batched geometry is within the frustum
35146
35461
  let culled = false;
@@ -35148,16 +35463,17 @@ class BatchedMesh extends Mesh {
35148
35463
 
35149
35464
  // get the bounds in world space
35150
35465
  this.getMatrixAt( i, _matrix$1 );
35151
- this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix$1 );
35466
+ this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
35152
35467
  culled = ! _frustum.intersectsSphere( _sphere$2 );
35153
35468
 
35154
35469
  }
35155
35470
 
35156
35471
  if ( ! culled ) {
35157
35472
 
35158
- const range = drawRanges[ i ];
35473
+ const range = drawRanges[ geometryId ];
35159
35474
  multiDrawStarts[ count ] = range.start * bytesPerElement;
35160
35475
  multiDrawCounts[ count ] = range.count;
35476
+ indirectArray[ count ] = i;
35161
35477
  count ++;
35162
35478
 
35163
35479
  }
@@ -35168,6 +35484,7 @@ class BatchedMesh extends Mesh {
35168
35484
 
35169
35485
  }
35170
35486
 
35487
+ indirectTexture.needsUpdate = true;
35171
35488
  this._multiDrawCount = count;
35172
35489
  this._visibilityChanged = false;
35173
35490
 
@@ -35837,7 +36154,7 @@ class CompressedArrayTexture extends CompressedTexture {
35837
36154
 
35838
36155
  }
35839
36156
 
35840
- addLayerUpdates( layerIndex ) {
36157
+ addLayerUpdate( layerIndex ) {
35841
36158
 
35842
36159
  this.layerUpdates.add( layerIndex );
35843
36160
 
@@ -45644,6 +45961,7 @@ class Light extends Object3D {
45644
45961
  if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;
45645
45962
 
45646
45963
  if ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();
45964
+ if ( this.target !== undefined ) data.object.target = this.target.uuid;
45647
45965
 
45648
45966
  return data;
45649
45967
 
@@ -45690,6 +46008,8 @@ class LightShadow {
45690
46008
 
45691
46009
  this.camera = camera;
45692
46010
 
46011
+ this.intensity = 1;
46012
+
45693
46013
  this.bias = 0;
45694
46014
  this.normalBias = 0;
45695
46015
  this.radius = 1;
@@ -45787,6 +46107,8 @@ class LightShadow {
45787
46107
 
45788
46108
  this.camera = source.camera.clone();
45789
46109
 
46110
+ this.intensity = source.intensity;
46111
+
45790
46112
  this.bias = source.bias;
45791
46113
  this.radius = source.radius;
45792
46114
 
@@ -45806,6 +46128,7 @@ class LightShadow {
45806
46128
 
45807
46129
  const object = {};
45808
46130
 
46131
+ if ( this.intensity !== 1 ) object.intensity = this.intensity;
45809
46132
  if ( this.bias !== 0 ) object.bias = this.bias;
45810
46133
  if ( this.normalBias !== 0 ) object.normalBias = this.normalBias;
45811
46134
  if ( this.radius !== 1 ) object.radius = this.radius;
@@ -47234,6 +47557,7 @@ class ObjectLoader extends Loader {
47234
47557
  const skeletons = this.parseSkeletons( json.skeletons, object );
47235
47558
 
47236
47559
  this.bindSkeletons( object, skeletons );
47560
+ this.bindLightTargets( object );
47237
47561
 
47238
47562
  //
47239
47563
 
@@ -47275,6 +47599,7 @@ class ObjectLoader extends Loader {
47275
47599
  const skeletons = this.parseSkeletons( json.skeletons, object );
47276
47600
 
47277
47601
  this.bindSkeletons( object, skeletons );
47602
+ this.bindLightTargets( object );
47278
47603
 
47279
47604
  return object;
47280
47605
 
@@ -47919,6 +48244,7 @@ class ObjectLoader extends Loader {
47919
48244
  case 'DirectionalLight':
47920
48245
 
47921
48246
  object = new DirectionalLight( data.color, data.intensity );
48247
+ object.target = data.target || '';
47922
48248
 
47923
48249
  break;
47924
48250
 
@@ -47937,6 +48263,7 @@ class ObjectLoader extends Loader {
47937
48263
  case 'SpotLight':
47938
48264
 
47939
48265
  object = new SpotLight( data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay );
48266
+ object.target = data.target || '';
47940
48267
 
47941
48268
  break;
47942
48269
 
@@ -47993,7 +48320,7 @@ class ObjectLoader extends Loader {
47993
48320
  geometry = getGeometry( data.geometry );
47994
48321
  material = getMaterial( data.material );
47995
48322
 
47996
- object = new BatchedMesh( data.maxGeometryCount, data.maxVertexCount, data.maxIndexCount, material );
48323
+ object = new BatchedMesh( data.maxInstanceCount, data.maxVertexCount, data.maxIndexCount, material );
47997
48324
  object.geometry = geometry;
47998
48325
  object.perObjectFrustumCulled = data.perObjectFrustumCulled;
47999
48326
  object.sortObjects = data.sortObjects;
@@ -48023,7 +48350,7 @@ class ObjectLoader extends Loader {
48023
48350
 
48024
48351
  } );
48025
48352
 
48026
- object._maxGeometryCount = data.maxGeometryCount;
48353
+ object._maxInstanceCount = data.maxInstanceCount;
48027
48354
  object._maxVertexCount = data.maxVertexCount;
48028
48355
  object._maxIndexCount = data.maxIndexCount;
48029
48356
 
@@ -48117,6 +48444,7 @@ class ObjectLoader extends Loader {
48117
48444
 
48118
48445
  if ( data.shadow ) {
48119
48446
 
48447
+ if ( data.shadow.intensity !== undefined ) object.shadow.intensity = data.shadow.intensity;
48120
48448
  if ( data.shadow.bias !== undefined ) object.shadow.bias = data.shadow.bias;
48121
48449
  if ( data.shadow.normalBias !== undefined ) object.shadow.normalBias = data.shadow.normalBias;
48122
48450
  if ( data.shadow.radius !== undefined ) object.shadow.radius = data.shadow.radius;
@@ -48208,6 +48536,32 @@ class ObjectLoader extends Loader {
48208
48536
 
48209
48537
  }
48210
48538
 
48539
+ bindLightTargets( object ) {
48540
+
48541
+ object.traverse( function ( child ) {
48542
+
48543
+ if ( child.isDirectionalLight || child.isSpotLight ) {
48544
+
48545
+ const uuid = child.target;
48546
+
48547
+ const target = object.getObjectByProperty( 'uuid', uuid );
48548
+
48549
+ if ( target !== undefined ) {
48550
+
48551
+ child.target = target;
48552
+
48553
+ } else {
48554
+
48555
+ child.target = new Object3D();
48556
+
48557
+ }
48558
+
48559
+ }
48560
+
48561
+ } );
48562
+
48563
+ }
48564
+
48211
48565
  }
48212
48566
 
48213
48567
  const TEXTURE_MAPPING = {
@@ -52660,6 +53014,61 @@ class Cylindrical {
52660
53014
 
52661
53015
  }
52662
53016
 
53017
+ class Matrix2 {
53018
+
53019
+ constructor( n11, n12, n21, n22 ) {
53020
+
53021
+ Matrix2.prototype.isMatrix2 = true;
53022
+
53023
+ this.elements = [
53024
+ 1, 0,
53025
+ 0, 1,
53026
+ ];
53027
+
53028
+ if ( n11 !== undefined ) {
53029
+
53030
+ this.set( n11, n12, n21, n22 );
53031
+
53032
+ }
53033
+
53034
+ }
53035
+
53036
+ identity() {
53037
+
53038
+ this.set(
53039
+ 1, 0,
53040
+ 0, 1,
53041
+ );
53042
+
53043
+ return this;
53044
+
53045
+ }
53046
+
53047
+ fromArray( array, offset = 0 ) {
53048
+
53049
+ for ( let i = 0; i < 4; i ++ ) {
53050
+
53051
+ this.elements[ i ] = array[ i + offset ];
53052
+
53053
+ }
53054
+
53055
+ return this;
53056
+
53057
+ }
53058
+
53059
+ set( n11, n12, n21, n22 ) {
53060
+
53061
+ const te = this.elements;
53062
+
53063
+ te[ 0 ] = n11; te[ 2 ] = n12;
53064
+ te[ 1 ] = n21; te[ 3 ] = n22;
53065
+
53066
+ return this;
53067
+
53068
+ }
53069
+
53070
+ }
53071
+
52663
53072
  const _vector$4 = /*@__PURE__*/ new Vector2();
52664
53073
 
52665
53074
  class Box2 {
@@ -52779,8 +53188,8 @@ class Box2 {
52779
53188
 
52780
53189
  containsPoint( point ) {
52781
53190
 
52782
- return point.x < this.min.x || point.x > this.max.x ||
52783
- point.y < this.min.y || point.y > this.max.y ? false : true;
53191
+ return point.x >= this.min.x && point.x <= this.max.x &&
53192
+ point.y >= this.min.y && point.y <= this.max.y;
52784
53193
 
52785
53194
  }
52786
53195
 
@@ -52807,8 +53216,8 @@ class Box2 {
52807
53216
 
52808
53217
  // using 4 splitting planes to rule out intersections
52809
53218
 
52810
- return box.max.x < this.min.x || box.min.x > this.max.x ||
52811
- box.max.y < this.min.y || box.min.y > this.max.y ? false : true;
53219
+ return box.max.x >= this.min.x && box.min.x <= this.max.x &&
53220
+ box.max.y >= this.min.y && box.min.y <= this.max.y;
52812
53221
 
52813
53222
  }
52814
53223
 
@@ -54491,6 +54900,35 @@ class ShapePath {
54491
54900
 
54492
54901
  }
54493
54902
 
54903
+ class Controls extends EventDispatcher {
54904
+
54905
+ constructor( object, domElement ) {
54906
+
54907
+ super();
54908
+
54909
+ this.object = object;
54910
+ this.domElement = domElement;
54911
+
54912
+ this.enabled = true;
54913
+
54914
+ this.state = - 1;
54915
+
54916
+ this.keys = {};
54917
+ this.mouseButtons = { LEFT: null, MIDDLE: null, RIGHT: null };
54918
+ this.touches = { ONE: null, TWO: null };
54919
+
54920
+ }
54921
+
54922
+ connect() {}
54923
+
54924
+ disconnect() {}
54925
+
54926
+ dispose() {}
54927
+
54928
+ update( /* delta */ ) {}
54929
+
54930
+ }
54931
+
54494
54932
  class WebGLMultipleRenderTargets extends WebGLRenderTarget { // @deprecated, r162
54495
54933
 
54496
54934
  constructor( width = 1, height = 1, count = 1, options = {} ) {
@@ -54595,6 +55033,7 @@ exports.CompressedTextureLoader = CompressedTextureLoader;
54595
55033
  exports.ConeGeometry = ConeGeometry;
54596
55034
  exports.ConstantAlphaFactor = ConstantAlphaFactor;
54597
55035
  exports.ConstantColorFactor = ConstantColorFactor;
55036
+ exports.Controls = Controls;
54598
55037
  exports.CubeCamera = CubeCamera;
54599
55038
  exports.CubeReflectionMapping = CubeReflectionMapping;
54600
55039
  exports.CubeRefractionMapping = CubeRefractionMapping;
@@ -54734,6 +55173,7 @@ exports.MOUSE = MOUSE;
54734
55173
  exports.Material = Material;
54735
55174
  exports.MaterialLoader = MaterialLoader;
54736
55175
  exports.MathUtils = MathUtils;
55176
+ exports.Matrix2 = Matrix2;
54737
55177
  exports.Matrix3 = Matrix3;
54738
55178
  exports.Matrix4 = Matrix4;
54739
55179
  exports.MaxEquation = MaxEquation;
@@ -54833,7 +55273,9 @@ exports.RGBA_PVRTC_4BPPV1_Format = RGBA_PVRTC_4BPPV1_Format;
54833
55273
  exports.RGBA_S3TC_DXT1_Format = RGBA_S3TC_DXT1_Format;
54834
55274
  exports.RGBA_S3TC_DXT3_Format = RGBA_S3TC_DXT3_Format;
54835
55275
  exports.RGBA_S3TC_DXT5_Format = RGBA_S3TC_DXT5_Format;
55276
+ exports.RGBDepthPacking = RGBDepthPacking;
54836
55277
  exports.RGBFormat = RGBFormat;
55278
+ exports.RGBIntegerFormat = RGBIntegerFormat;
54837
55279
  exports.RGB_BPTC_SIGNED_Format = RGB_BPTC_SIGNED_Format;
54838
55280
  exports.RGB_BPTC_UNSIGNED_Format = RGB_BPTC_UNSIGNED_Format;
54839
55281
  exports.RGB_ETC1_Format = RGB_ETC1_Format;
@@ -54841,6 +55283,7 @@ exports.RGB_ETC2_Format = RGB_ETC2_Format;
54841
55283
  exports.RGB_PVRTC_2BPPV1_Format = RGB_PVRTC_2BPPV1_Format;
54842
55284
  exports.RGB_PVRTC_4BPPV1_Format = RGB_PVRTC_4BPPV1_Format;
54843
55285
  exports.RGB_S3TC_DXT1_Format = RGB_S3TC_DXT1_Format;
55286
+ exports.RGDepthPacking = RGDepthPacking;
54844
55287
  exports.RGFormat = RGFormat;
54845
55288
  exports.RGIntegerFormat = RGIntegerFormat;
54846
55289
  exports.RawShaderMaterial = RawShaderMaterial;
@@ -54901,6 +55344,7 @@ exports.TangentSpaceNormalMap = TangentSpaceNormalMap;
54901
55344
  exports.TetrahedronGeometry = TetrahedronGeometry;
54902
55345
  exports.Texture = Texture;
54903
55346
  exports.TextureLoader = TextureLoader;
55347
+ exports.TextureUtils = TextureUtils;
54904
55348
  exports.TorusGeometry = TorusGeometry;
54905
55349
  exports.TorusKnotGeometry = TorusKnotGeometry;
54906
55350
  exports.Triangle = Triangle;