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
@@ -3,7 +3,7 @@
3
3
  * Copyright 2010-2024 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
5
  */
6
- const REVISION = '165';
6
+ const REVISION = '168';
7
7
 
8
8
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
9
9
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -108,6 +108,7 @@ const RedFormat = 1028;
108
108
  const RedIntegerFormat = 1029;
109
109
  const RGFormat = 1030;
110
110
  const RGIntegerFormat = 1031;
111
+ const RGBIntegerFormat = 1032;
111
112
  const RGBAIntegerFormat = 1033;
112
113
 
113
114
  const RGB_S3TC_DXT1_Format = 33776;
@@ -158,6 +159,8 @@ const TriangleStripDrawMode = 1;
158
159
  const TriangleFanDrawMode = 2;
159
160
  const BasicDepthPacking = 3200;
160
161
  const RGBADepthPacking = 3201;
162
+ const RGBDepthPacking = 3202;
163
+ const RGDepthPacking = 3203;
161
164
  const TangentSpaceNormalMap = 0;
162
165
  const ObjectSpaceNormalMap = 1;
163
166
 
@@ -1621,24 +1624,28 @@ const COLOR_SPACES = {
1621
1624
  [ LinearSRGBColorSpace ]: {
1622
1625
  transfer: LinearTransfer,
1623
1626
  primaries: Rec709Primaries,
1627
+ luminanceCoefficients: [ 0.2126, 0.7152, 0.0722 ],
1624
1628
  toReference: ( color ) => color,
1625
1629
  fromReference: ( color ) => color,
1626
1630
  },
1627
1631
  [ SRGBColorSpace ]: {
1628
1632
  transfer: SRGBTransfer,
1629
1633
  primaries: Rec709Primaries,
1634
+ luminanceCoefficients: [ 0.2126, 0.7152, 0.0722 ],
1630
1635
  toReference: ( color ) => color.convertSRGBToLinear(),
1631
1636
  fromReference: ( color ) => color.convertLinearToSRGB(),
1632
1637
  },
1633
1638
  [ LinearDisplayP3ColorSpace ]: {
1634
1639
  transfer: LinearTransfer,
1635
1640
  primaries: P3Primaries,
1641
+ luminanceCoefficients: [ 0.2289, 0.6917, 0.0793 ],
1636
1642
  toReference: ( color ) => color.applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
1637
1643
  fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ),
1638
1644
  },
1639
1645
  [ DisplayP3ColorSpace ]: {
1640
1646
  transfer: SRGBTransfer,
1641
1647
  primaries: P3Primaries,
1648
+ luminanceCoefficients: [ 0.2289, 0.6917, 0.0793 ],
1642
1649
  toReference: ( color ) => color.convertSRGBToLinear().applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
1643
1650
  fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ).convertLinearToSRGB(),
1644
1651
  },
@@ -1711,6 +1718,12 @@ const ColorManagement = {
1711
1718
 
1712
1719
  },
1713
1720
 
1721
+ getLuminanceCoefficients: function ( target, colorSpace = this._workingColorSpace ) {
1722
+
1723
+ return target.fromArray( COLOR_SPACES[ colorSpace ].luminanceCoefficients );
1724
+
1725
+ },
1726
+
1714
1727
  };
1715
1728
 
1716
1729
 
@@ -2692,6 +2705,19 @@ class Vector4 {
2692
2705
 
2693
2706
  }
2694
2707
 
2708
+ setFromMatrixPosition( m ) {
2709
+
2710
+ const e = m.elements;
2711
+
2712
+ this.x = e[ 12 ];
2713
+ this.y = e[ 13 ];
2714
+ this.z = e[ 14 ];
2715
+ this.w = e[ 15 ];
2716
+
2717
+ return this;
2718
+
2719
+ }
2720
+
2695
2721
  min( v ) {
2696
2722
 
2697
2723
  this.x = Math.min( this.x, v.x );
@@ -4832,9 +4858,9 @@ class Box3 {
4832
4858
 
4833
4859
  containsPoint( point ) {
4834
4860
 
4835
- return point.x < this.min.x || point.x > this.max.x ||
4836
- point.y < this.min.y || point.y > this.max.y ||
4837
- point.z < this.min.z || point.z > this.max.z ? false : true;
4861
+ return point.x >= this.min.x && point.x <= this.max.x &&
4862
+ point.y >= this.min.y && point.y <= this.max.y &&
4863
+ point.z >= this.min.z && point.z <= this.max.z;
4838
4864
 
4839
4865
  }
4840
4866
 
@@ -4862,9 +4888,9 @@ class Box3 {
4862
4888
  intersectsBox( box ) {
4863
4889
 
4864
4890
  // using 6 splitting planes to rule out intersections.
4865
- return box.max.x < this.min.x || box.min.x > this.max.x ||
4866
- box.max.y < this.min.y || box.min.y > this.max.y ||
4867
- box.max.z < this.min.z || box.min.z > this.max.z ? false : true;
4891
+ return box.max.x >= this.min.x && box.min.x <= this.max.x &&
4892
+ box.max.y >= this.min.y && box.min.y <= this.max.y &&
4893
+ box.max.z >= this.min.z && box.min.z <= this.max.z;
4868
4894
 
4869
4895
  }
4870
4896
 
@@ -4938,14 +4964,14 @@ class Box3 {
4938
4964
  _extents.subVectors( this.max, _center );
4939
4965
 
4940
4966
  // translate triangle to aabb origin
4941
- _v0$2.subVectors( triangle.a, _center );
4967
+ _v0$3.subVectors( triangle.a, _center );
4942
4968
  _v1$7.subVectors( triangle.b, _center );
4943
4969
  _v2$4.subVectors( triangle.c, _center );
4944
4970
 
4945
4971
  // compute edge vectors for triangle
4946
- _f0.subVectors( _v1$7, _v0$2 );
4972
+ _f0.subVectors( _v1$7, _v0$3 );
4947
4973
  _f1.subVectors( _v2$4, _v1$7 );
4948
- _f2.subVectors( _v0$2, _v2$4 );
4974
+ _f2.subVectors( _v0$3, _v2$4 );
4949
4975
 
4950
4976
  // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
4951
4977
  // make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation
@@ -4955,7 +4981,7 @@ class Box3 {
4955
4981
  _f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x,
4956
4982
  - _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0
4957
4983
  ];
4958
- if ( ! satForAxes( axes, _v0$2, _v1$7, _v2$4, _extents ) ) {
4984
+ if ( ! satForAxes( axes, _v0$3, _v1$7, _v2$4, _extents ) ) {
4959
4985
 
4960
4986
  return false;
4961
4987
 
@@ -4963,7 +4989,7 @@ class Box3 {
4963
4989
 
4964
4990
  // test 3 face normals from the aabb
4965
4991
  axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];
4966
- if ( ! satForAxes( axes, _v0$2, _v1$7, _v2$4, _extents ) ) {
4992
+ if ( ! satForAxes( axes, _v0$3, _v1$7, _v2$4, _extents ) ) {
4967
4993
 
4968
4994
  return false;
4969
4995
 
@@ -4974,7 +5000,7 @@ class Box3 {
4974
5000
  _triangleNormal.crossVectors( _f0, _f1 );
4975
5001
  axes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ];
4976
5002
 
4977
- return satForAxes( axes, _v0$2, _v1$7, _v2$4, _extents );
5003
+ return satForAxes( axes, _v0$3, _v1$7, _v2$4, _extents );
4978
5004
 
4979
5005
  }
4980
5006
 
@@ -5084,7 +5110,7 @@ const _box$4 = /*@__PURE__*/ new Box3();
5084
5110
 
5085
5111
  // triangle centered vertices
5086
5112
 
5087
- const _v0$2 = /*@__PURE__*/ new Vector3();
5113
+ const _v0$3 = /*@__PURE__*/ new Vector3();
5088
5114
  const _v1$7 = /*@__PURE__*/ new Vector3();
5089
5115
  const _v2$4 = /*@__PURE__*/ new Vector3();
5090
5116
 
@@ -7717,13 +7743,17 @@ class Object3D extends EventDispatcher {
7717
7743
 
7718
7744
  if ( this.matrixWorldNeedsUpdate || force ) {
7719
7745
 
7720
- if ( this.parent === null ) {
7746
+ if ( this.matrixWorldAutoUpdate === true ) {
7721
7747
 
7722
- this.matrixWorld.copy( this.matrix );
7748
+ if ( this.parent === null ) {
7723
7749
 
7724
- } else {
7750
+ this.matrixWorld.copy( this.matrix );
7725
7751
 
7726
- this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
7752
+ } else {
7753
+
7754
+ this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
7755
+
7756
+ }
7727
7757
 
7728
7758
  }
7729
7759
 
@@ -7733,7 +7763,7 @@ class Object3D extends EventDispatcher {
7733
7763
 
7734
7764
  }
7735
7765
 
7736
- // update children
7766
+ // make sure descendants are updated if required
7737
7767
 
7738
7768
  const children = this.children;
7739
7769
 
@@ -7741,11 +7771,7 @@ class Object3D extends EventDispatcher {
7741
7771
 
7742
7772
  const child = children[ i ];
7743
7773
 
7744
- if ( child.matrixWorldAutoUpdate === true || force === true ) {
7745
-
7746
- child.updateMatrixWorld( force );
7747
-
7748
- }
7774
+ child.updateMatrixWorld( force );
7749
7775
 
7750
7776
  }
7751
7777
 
@@ -7755,7 +7781,7 @@ class Object3D extends EventDispatcher {
7755
7781
 
7756
7782
  const parent = this.parent;
7757
7783
 
7758
- if ( updateParents === true && parent !== null && parent.matrixWorldAutoUpdate === true ) {
7784
+ if ( updateParents === true && parent !== null ) {
7759
7785
 
7760
7786
  parent.updateWorldMatrix( true, false );
7761
7787
 
@@ -7763,17 +7789,21 @@ class Object3D extends EventDispatcher {
7763
7789
 
7764
7790
  if ( this.matrixAutoUpdate ) this.updateMatrix();
7765
7791
 
7766
- if ( this.parent === null ) {
7792
+ if ( this.matrixWorldAutoUpdate === true ) {
7767
7793
 
7768
- this.matrixWorld.copy( this.matrix );
7794
+ if ( this.parent === null ) {
7769
7795
 
7770
- } else {
7796
+ this.matrixWorld.copy( this.matrix );
7797
+
7798
+ } else {
7799
+
7800
+ this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
7771
7801
 
7772
- this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
7802
+ }
7773
7803
 
7774
7804
  }
7775
7805
 
7776
- // update children
7806
+ // make sure descendants are updated
7777
7807
 
7778
7808
  if ( updateChildren === true ) {
7779
7809
 
@@ -7783,11 +7813,7 @@ class Object3D extends EventDispatcher {
7783
7813
 
7784
7814
  const child = children[ i ];
7785
7815
 
7786
- if ( child.matrixWorldAutoUpdate === true ) {
7787
-
7788
- child.updateWorldMatrix( false, true );
7789
-
7790
- }
7816
+ child.updateWorldMatrix( false, true );
7791
7817
 
7792
7818
  }
7793
7819
 
@@ -7880,7 +7906,7 @@ class Object3D extends EventDispatcher {
7880
7906
  sphereCenter: bound.sphere.center.toArray()
7881
7907
  } ) );
7882
7908
 
7883
- object.maxGeometryCount = this._maxGeometryCount;
7909
+ object.maxInstanceCount = this._maxInstanceCount;
7884
7910
  object.maxVertexCount = this._maxVertexCount;
7885
7911
  object.maxIndexCount = this._maxIndexCount;
7886
7912
 
@@ -8149,7 +8175,7 @@ Object3D.DEFAULT_UP = /*@__PURE__*/ new Vector3( 0, 1, 0 );
8149
8175
  Object3D.DEFAULT_MATRIX_AUTO_UPDATE = true;
8150
8176
  Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = true;
8151
8177
 
8152
- const _v0$1 = /*@__PURE__*/ new Vector3();
8178
+ const _v0$2 = /*@__PURE__*/ new Vector3();
8153
8179
  const _v1$3 = /*@__PURE__*/ new Vector3();
8154
8180
  const _v2$2 = /*@__PURE__*/ new Vector3();
8155
8181
  const _v3$2 = /*@__PURE__*/ new Vector3();
@@ -8174,8 +8200,8 @@ class Triangle {
8174
8200
  static getNormal( a, b, c, target ) {
8175
8201
 
8176
8202
  target.subVectors( c, b );
8177
- _v0$1.subVectors( a, b );
8178
- target.cross( _v0$1 );
8203
+ _v0$2.subVectors( a, b );
8204
+ target.cross( _v0$2 );
8179
8205
 
8180
8206
  const targetLengthSq = target.lengthSq();
8181
8207
  if ( targetLengthSq > 0 ) {
@@ -8192,13 +8218,13 @@ class Triangle {
8192
8218
  // based on: http://www.blackpawn.com/texts/pointinpoly/default.html
8193
8219
  static getBarycoord( point, a, b, c, target ) {
8194
8220
 
8195
- _v0$1.subVectors( c, a );
8221
+ _v0$2.subVectors( c, a );
8196
8222
  _v1$3.subVectors( b, a );
8197
8223
  _v2$2.subVectors( point, a );
8198
8224
 
8199
- const dot00 = _v0$1.dot( _v0$1 );
8200
- const dot01 = _v0$1.dot( _v1$3 );
8201
- const dot02 = _v0$1.dot( _v2$2 );
8225
+ const dot00 = _v0$2.dot( _v0$2 );
8226
+ const dot01 = _v0$2.dot( _v1$3 );
8227
+ const dot02 = _v0$2.dot( _v2$2 );
8202
8228
  const dot11 = _v1$3.dot( _v1$3 );
8203
8229
  const dot12 = _v1$3.dot( _v2$2 );
8204
8230
 
@@ -8257,11 +8283,11 @@ class Triangle {
8257
8283
 
8258
8284
  static isFrontFacing( a, b, c, direction ) {
8259
8285
 
8260
- _v0$1.subVectors( c, b );
8286
+ _v0$2.subVectors( c, b );
8261
8287
  _v1$3.subVectors( a, b );
8262
8288
 
8263
8289
  // strictly front facing
8264
- return ( _v0$1.cross( _v1$3 ).dot( direction ) < 0 ) ? true : false;
8290
+ return ( _v0$2.cross( _v1$3 ).dot( direction ) < 0 ) ? true : false;
8265
8291
 
8266
8292
  }
8267
8293
 
@@ -8313,10 +8339,10 @@ class Triangle {
8313
8339
 
8314
8340
  getArea() {
8315
8341
 
8316
- _v0$1.subVectors( this.c, this.b );
8342
+ _v0$2.subVectors( this.c, this.b );
8317
8343
  _v1$3.subVectors( this.a, this.b );
8318
8344
 
8319
- return _v0$1.cross( _v1$3 ).length() * 0.5;
8345
+ return _v0$2.cross( _v1$3 ).length() * 0.5;
8320
8346
 
8321
8347
  }
8322
8348
 
@@ -9172,7 +9198,7 @@ class Material extends EventDispatcher {
9172
9198
 
9173
9199
  }
9174
9200
 
9175
- onBuild( /* shaderobject, renderer */ ) {}
9201
+ // onBeforeRender and onBeforeCompile only supported in WebGLRenderer
9176
9202
 
9177
9203
  onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {}
9178
9204
 
@@ -9592,6 +9618,12 @@ class Material extends EventDispatcher {
9592
9618
 
9593
9619
  }
9594
9620
 
9621
+ onBuild( /* shaderobject, renderer */ ) {
9622
+
9623
+ console.warn( 'Material: onBuild() has been removed.' ); // @deprecated, r166
9624
+
9625
+ }
9626
+
9595
9627
  }
9596
9628
 
9597
9629
  class MeshBasicMaterial extends Material {
@@ -13640,6 +13672,8 @@ function WebGLAttributes( gl ) {
13640
13672
 
13641
13673
  function update( attribute, bufferType ) {
13642
13674
 
13675
+ if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
13676
+
13643
13677
  if ( attribute.isGLBufferAttribute ) {
13644
13678
 
13645
13679
  const cached = buffers.get( attribute );
@@ -13659,8 +13693,6 @@ function WebGLAttributes( gl ) {
13659
13693
 
13660
13694
  }
13661
13695
 
13662
- if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
13663
-
13664
13696
  const data = buffers.get( attribute );
13665
13697
 
13666
13698
  if ( data === undefined ) {
@@ -13803,9 +13835,9 @@ var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D(
13803
13835
 
13804
13836
  var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
13805
13837
 
13806
- 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";
13838
+ 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";
13807
13839
 
13808
- var batching_vertex = "#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif";
13840
+ var batching_vertex = "#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif";
13809
13841
 
13810
13842
  var begin_vertex = "vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif";
13811
13843
 
@@ -13831,9 +13863,9 @@ var color_pars_fragment = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor
13831
13863
 
13832
13864
  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";
13833
13865
 
13834
- 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";
13866
+ 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";
13835
13867
 
13836
- 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";
13868
+ 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";
13837
13869
 
13838
13870
  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";
13839
13871
 
@@ -13849,7 +13881,7 @@ var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emi
13849
13881
 
13850
13882
  var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
13851
13883
 
13852
- 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}";
13884
+ 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}";
13853
13885
 
13854
13886
  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";
13855
13887
 
@@ -13893,7 +13925,7 @@ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColo
13893
13925
 
13894
13926
  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}";
13895
13927
 
13896
- 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";
13928
+ 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";
13897
13929
 
13898
13930
  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";
13899
13931
 
@@ -13951,7 +13983,7 @@ var iridescence_pars_fragment = "#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D
13951
13983
 
13952
13984
  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 );";
13953
13985
 
13954
- 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}";
13986
+ 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}";
13955
13987
 
13956
13988
  var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif";
13957
13989
 
@@ -13965,13 +13997,13 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
13965
13997
 
13966
13998
  var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
13967
13999
 
13968
- 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";
14000
+ 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";
13969
14001
 
13970
- 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";
14002
+ 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";
13971
14003
 
13972
14004
  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";
13973
14005
 
13974
- 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}";
14006
+ 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}";
13975
14007
 
13976
14008
  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";
13977
14009
 
@@ -13987,7 +14019,7 @@ var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D spe
13987
14019
 
13988
14020
  var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
13989
14021
 
13990
- 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; }";
14022
+ 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; }";
13991
14023
 
13992
14024
  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";
13993
14025
 
@@ -14015,7 +14047,7 @@ const fragment$f = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform fl
14015
14047
 
14016
14048
  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}";
14017
14049
 
14018
- 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}";
14050
+ 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}";
14019
14051
 
14020
14052
  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}";
14021
14053
 
@@ -14342,6 +14374,7 @@ const UniformsLib = {
14342
14374
  } },
14343
14375
 
14344
14376
  directionalLightShadows: { value: [], properties: {
14377
+ shadowIntensity: 1,
14345
14378
  shadowBias: {},
14346
14379
  shadowNormalBias: {},
14347
14380
  shadowRadius: {},
@@ -14362,6 +14395,7 @@ const UniformsLib = {
14362
14395
  } },
14363
14396
 
14364
14397
  spotLightShadows: { value: [], properties: {
14398
+ shadowIntensity: 1,
14365
14399
  shadowBias: {},
14366
14400
  shadowNormalBias: {},
14367
14401
  shadowRadius: {},
@@ -14380,6 +14414,7 @@ const UniformsLib = {
14380
14414
  } },
14381
14415
 
14382
14416
  pointLightShadows: { value: [], properties: {
14417
+ shadowIntensity: 1,
14383
14418
  shadowBias: {},
14384
14419
  shadowNormalBias: {},
14385
14420
  shadowRadius: {},
@@ -15678,30 +15713,17 @@ function WebGLBufferRenderer( gl, extensions, info ) {
15678
15713
  if ( drawCount === 0 ) return;
15679
15714
 
15680
15715
  const extension = extensions.get( 'WEBGL_multi_draw' );
15716
+ extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
15681
15717
 
15682
- if ( extension === null ) {
15683
-
15684
- for ( let i = 0; i < drawCount; i ++ ) {
15685
-
15686
- this.render( starts[ i ], counts[ i ] );
15687
-
15688
- }
15689
-
15690
- } else {
15691
-
15692
- extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
15693
-
15694
- let elementCount = 0;
15695
- for ( let i = 0; i < drawCount; i ++ ) {
15718
+ let elementCount = 0;
15719
+ for ( let i = 0; i < drawCount; i ++ ) {
15696
15720
 
15697
- elementCount += counts[ i ];
15698
-
15699
- }
15700
-
15701
- info.update( elementCount, mode, 1 );
15721
+ elementCount += counts[ i ];
15702
15722
 
15703
15723
  }
15704
15724
 
15725
+ info.update( elementCount, mode, 1 );
15726
+
15705
15727
  }
15706
15728
 
15707
15729
  function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
@@ -17631,29 +17653,17 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
17631
17653
  if ( drawCount === 0 ) return;
17632
17654
 
17633
17655
  const extension = extensions.get( 'WEBGL_multi_draw' );
17656
+ extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
17634
17657
 
17635
- if ( extension === null ) {
17658
+ let elementCount = 0;
17659
+ for ( let i = 0; i < drawCount; i ++ ) {
17636
17660
 
17637
- for ( let i = 0; i < drawCount; i ++ ) {
17661
+ elementCount += counts[ i ];
17638
17662
 
17639
- this.render( starts[ i ] / bytesPerElement, counts[ i ] );
17640
-
17641
- }
17642
-
17643
- } else {
17644
-
17645
- extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
17646
-
17647
- let elementCount = 0;
17648
- for ( let i = 0; i < drawCount; i ++ ) {
17649
-
17650
- elementCount += counts[ i ];
17651
-
17652
- }
17663
+ }
17653
17664
 
17654
- info.update( elementCount, mode, 1 );
17665
+ info.update( elementCount, mode, 1 );
17655
17666
 
17656
- }
17657
17667
 
17658
17668
  }
17659
17669
 
@@ -18219,7 +18229,6 @@ class DepthTexture extends Texture {
18219
18229
  const emptyTexture = /*@__PURE__*/ new Texture();
18220
18230
 
18221
18231
  const emptyShadowTexture = /*@__PURE__*/ new DepthTexture( 1, 1 );
18222
- emptyShadowTexture.compareFunction = LessEqualCompare;
18223
18232
 
18224
18233
  const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture();
18225
18234
  const empty3dTexture = /*@__PURE__*/ new Data3DTexture();
@@ -18737,7 +18746,18 @@ function setValueT1( gl, v, textures ) {
18737
18746
 
18738
18747
  }
18739
18748
 
18740
- const emptyTexture2D = ( this.type === gl.SAMPLER_2D_SHADOW ) ? emptyShadowTexture : emptyTexture;
18749
+ let emptyTexture2D;
18750
+
18751
+ if ( this.type === gl.SAMPLER_2D_SHADOW ) {
18752
+
18753
+ emptyShadowTexture.compareFunction = LessEqualCompare; // #28670
18754
+ emptyTexture2D = emptyShadowTexture;
18755
+
18756
+ } else {
18757
+
18758
+ emptyTexture2D = emptyTexture;
18759
+
18760
+ }
18741
18761
 
18742
18762
  textures.setTexture2D( v || emptyTexture2D, unit );
18743
18763
 
@@ -19441,7 +19461,7 @@ function getToneMappingFunction( functionName, toneMapping ) {
19441
19461
  break;
19442
19462
 
19443
19463
  case CineonToneMapping:
19444
- toneMappingName = 'OptimizedCineon';
19464
+ toneMappingName = 'Cineon';
19445
19465
  break;
19446
19466
 
19447
19467
  case ACESFilmicToneMapping:
@@ -19470,6 +19490,30 @@ function getToneMappingFunction( functionName, toneMapping ) {
19470
19490
 
19471
19491
  }
19472
19492
 
19493
+ const _v0$1 = /*@__PURE__*/ new Vector3();
19494
+
19495
+ function getLuminanceFunction() {
19496
+
19497
+ ColorManagement.getLuminanceCoefficients( _v0$1 );
19498
+
19499
+ const r = _v0$1.x.toFixed( 4 );
19500
+ const g = _v0$1.y.toFixed( 4 );
19501
+ const b = _v0$1.z.toFixed( 4 );
19502
+
19503
+ return [
19504
+
19505
+ 'float luminance( const in vec3 rgb ) {',
19506
+
19507
+ ` const vec3 weights = vec3( ${ r }, ${ g }, ${ b } );`,
19508
+
19509
+ ' return dot( weights, rgb );',
19510
+
19511
+ '}'
19512
+
19513
+ ].join( '\n' );
19514
+
19515
+ }
19516
+
19473
19517
  function generateVertexExtensions( parameters ) {
19474
19518
 
19475
19519
  const chunks = [
@@ -20141,6 +20185,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20141
20185
 
20142
20186
  ShaderChunk[ 'colorspace_pars_fragment' ], // this code is required here because it is used by the various encoding/decoding function defined below
20143
20187
  getTexelEncodingFunction( 'linearToOutputTexel', parameters.outputColorSpace ),
20188
+ getLuminanceFunction(),
20144
20189
 
20145
20190
  parameters.useDepthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '',
20146
20191
 
@@ -20906,7 +20951,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20906
20951
  index0AttributeName: material.index0AttributeName,
20907
20952
 
20908
20953
  extensionClipCullDistance: HAS_EXTENSIONS && material.extensions.clipCullDistance === true && extensions.has( 'WEBGL_clip_cull_distance' ),
20909
- extensionMultiDraw: HAS_EXTENSIONS && material.extensions.multiDraw === true && extensions.has( 'WEBGL_multi_draw' ),
20954
+ extensionMultiDraw: ( HAS_EXTENSIONS && material.extensions.multiDraw === true || IS_BATCHEDMESH ) && extensions.has( 'WEBGL_multi_draw' ),
20910
20955
 
20911
20956
  rendererExtensionParallelShaderCompile: extensions.has( 'KHR_parallel_shader_compile' ),
20912
20957
 
@@ -21215,6 +21260,12 @@ function WebGLProperties() {
21215
21260
 
21216
21261
  let properties = new WeakMap();
21217
21262
 
21263
+ function has( object ) {
21264
+
21265
+ return properties.has( object );
21266
+
21267
+ }
21268
+
21218
21269
  function get( object ) {
21219
21270
 
21220
21271
  let map = properties.get( object );
@@ -21249,6 +21300,7 @@ function WebGLProperties() {
21249
21300
  }
21250
21301
 
21251
21302
  return {
21303
+ has: has,
21252
21304
  get: get,
21253
21305
  remove: remove,
21254
21306
  update: update,
@@ -21588,6 +21640,7 @@ function ShadowUniformsCache() {
21588
21640
 
21589
21641
  case 'DirectionalLight':
21590
21642
  uniforms = {
21643
+ shadowIntensity: 1,
21591
21644
  shadowBias: 0,
21592
21645
  shadowNormalBias: 0,
21593
21646
  shadowRadius: 1,
@@ -21597,6 +21650,7 @@ function ShadowUniformsCache() {
21597
21650
 
21598
21651
  case 'SpotLight':
21599
21652
  uniforms = {
21653
+ shadowIntensity: 1,
21600
21654
  shadowBias: 0,
21601
21655
  shadowNormalBias: 0,
21602
21656
  shadowRadius: 1,
@@ -21606,6 +21660,7 @@ function ShadowUniformsCache() {
21606
21660
 
21607
21661
  case 'PointLight':
21608
21662
  uniforms = {
21663
+ shadowIntensity: 1,
21609
21664
  shadowBias: 0,
21610
21665
  shadowNormalBias: 0,
21611
21666
  shadowRadius: 1,
@@ -21755,6 +21810,7 @@ function WebGLLights( extensions ) {
21755
21810
 
21756
21811
  const shadowUniforms = shadowCache.get( light );
21757
21812
 
21813
+ shadowUniforms.shadowIntensity = shadow.intensity;
21758
21814
  shadowUniforms.shadowBias = shadow.bias;
21759
21815
  shadowUniforms.shadowNormalBias = shadow.normalBias;
21760
21816
  shadowUniforms.shadowRadius = shadow.radius;
@@ -21808,6 +21864,7 @@ function WebGLLights( extensions ) {
21808
21864
 
21809
21865
  const shadowUniforms = shadowCache.get( light );
21810
21866
 
21867
+ shadowUniforms.shadowIntensity = shadow.intensity;
21811
21868
  shadowUniforms.shadowBias = shadow.bias;
21812
21869
  shadowUniforms.shadowNormalBias = shadow.normalBias;
21813
21870
  shadowUniforms.shadowRadius = shadow.radius;
@@ -21849,6 +21906,7 @@ function WebGLLights( extensions ) {
21849
21906
 
21850
21907
  const shadowUniforms = shadowCache.get( light );
21851
21908
 
21909
+ shadowUniforms.shadowIntensity = shadow.intensity;
21852
21910
  shadowUniforms.shadowBias = shadow.bias;
21853
21911
  shadowUniforms.shadowNormalBias = shadow.normalBias;
21854
21912
  shadowUniforms.shadowRadius = shadow.radius;
@@ -23926,6 +23984,213 @@ function WebGLState( gl ) {
23926
23984
 
23927
23985
  }
23928
23986
 
23987
+ function contain( texture, aspect ) {
23988
+
23989
+ const imageAspect = ( texture.image && texture.image.width ) ? texture.image.width / texture.image.height : 1;
23990
+
23991
+ if ( imageAspect > aspect ) {
23992
+
23993
+ texture.repeat.x = 1;
23994
+ texture.repeat.y = imageAspect / aspect;
23995
+
23996
+ texture.offset.x = 0;
23997
+ texture.offset.y = ( 1 - texture.repeat.y ) / 2;
23998
+
23999
+ } else {
24000
+
24001
+ texture.repeat.x = aspect / imageAspect;
24002
+ texture.repeat.y = 1;
24003
+
24004
+ texture.offset.x = ( 1 - texture.repeat.x ) / 2;
24005
+ texture.offset.y = 0;
24006
+
24007
+ }
24008
+
24009
+ return texture;
24010
+
24011
+ }
24012
+
24013
+ function cover( texture, aspect ) {
24014
+
24015
+ const imageAspect = ( texture.image && texture.image.width ) ? texture.image.width / texture.image.height : 1;
24016
+
24017
+ if ( imageAspect > aspect ) {
24018
+
24019
+ texture.repeat.x = aspect / imageAspect;
24020
+ texture.repeat.y = 1;
24021
+
24022
+ texture.offset.x = ( 1 - texture.repeat.x ) / 2;
24023
+ texture.offset.y = 0;
24024
+
24025
+ } else {
24026
+
24027
+ texture.repeat.x = 1;
24028
+ texture.repeat.y = imageAspect / aspect;
24029
+
24030
+ texture.offset.x = 0;
24031
+ texture.offset.y = ( 1 - texture.repeat.y ) / 2;
24032
+
24033
+ }
24034
+
24035
+ return texture;
24036
+
24037
+ }
24038
+
24039
+ function fill( texture ) {
24040
+
24041
+ texture.repeat.x = 1;
24042
+ texture.repeat.y = 1;
24043
+
24044
+ texture.offset.x = 0;
24045
+ texture.offset.y = 0;
24046
+
24047
+ return texture;
24048
+
24049
+ }
24050
+
24051
+
24052
+
24053
+ /**
24054
+ * Given the width, height, format, and type of a texture. Determines how many
24055
+ * bytes must be used to represent the texture.
24056
+ */
24057
+ function getByteLength( width, height, format, type ) {
24058
+
24059
+ const typeByteLength = getTextureTypeByteLength( type );
24060
+
24061
+ switch ( format ) {
24062
+
24063
+ // https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml
24064
+ case AlphaFormat:
24065
+ return width * height;
24066
+ case LuminanceFormat:
24067
+ return width * height;
24068
+ case LuminanceAlphaFormat:
24069
+ return width * height * 2;
24070
+ case RedFormat:
24071
+ return ( ( width * height ) / typeByteLength.components ) * typeByteLength.byteLength;
24072
+ case RedIntegerFormat:
24073
+ return ( ( width * height ) / typeByteLength.components ) * typeByteLength.byteLength;
24074
+ case RGFormat:
24075
+ return ( ( width * height * 2 ) / typeByteLength.components ) * typeByteLength.byteLength;
24076
+ case RGIntegerFormat:
24077
+ return ( ( width * height * 2 ) / typeByteLength.components ) * typeByteLength.byteLength;
24078
+ case RGBFormat:
24079
+ return ( ( width * height * 3 ) / typeByteLength.components ) * typeByteLength.byteLength;
24080
+ case RGBAFormat:
24081
+ return ( ( width * height * 4 ) / typeByteLength.components ) * typeByteLength.byteLength;
24082
+ case RGBAIntegerFormat:
24083
+ return ( ( width * height * 4 ) / typeByteLength.components ) * typeByteLength.byteLength;
24084
+
24085
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_s3tc_srgb/
24086
+ case RGB_S3TC_DXT1_Format:
24087
+ case RGBA_S3TC_DXT1_Format:
24088
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 8;
24089
+ case RGBA_S3TC_DXT3_Format:
24090
+ case RGBA_S3TC_DXT5_Format:
24091
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
24092
+
24093
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_pvrtc/
24094
+ case RGB_PVRTC_2BPPV1_Format:
24095
+ case RGBA_PVRTC_2BPPV1_Format:
24096
+ return ( Math.max( width, 16 ) * Math.max( height, 8 ) ) / 4;
24097
+ case RGB_PVRTC_4BPPV1_Format:
24098
+ case RGBA_PVRTC_4BPPV1_Format:
24099
+ return ( Math.max( width, 8 ) * Math.max( height, 8 ) ) / 2;
24100
+
24101
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_etc/
24102
+ case RGB_ETC1_Format:
24103
+ case RGB_ETC2_Format:
24104
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 8;
24105
+ case RGBA_ETC2_EAC_Format:
24106
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
24107
+
24108
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_astc/
24109
+ case RGBA_ASTC_4x4_Format:
24110
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
24111
+ case RGBA_ASTC_5x4_Format:
24112
+ return Math.floor( ( width + 4 ) / 5 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
24113
+ case RGBA_ASTC_5x5_Format:
24114
+ return Math.floor( ( width + 4 ) / 5 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
24115
+ case RGBA_ASTC_6x5_Format:
24116
+ return Math.floor( ( width + 5 ) / 6 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
24117
+ case RGBA_ASTC_6x6_Format:
24118
+ return Math.floor( ( width + 5 ) / 6 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
24119
+ case RGBA_ASTC_8x5_Format:
24120
+ return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
24121
+ case RGBA_ASTC_8x6_Format:
24122
+ return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
24123
+ case RGBA_ASTC_8x8_Format:
24124
+ return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 7 ) / 8 ) * 16;
24125
+ case RGBA_ASTC_10x5_Format:
24126
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
24127
+ case RGBA_ASTC_10x6_Format:
24128
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
24129
+ case RGBA_ASTC_10x8_Format:
24130
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 7 ) / 8 ) * 16;
24131
+ case RGBA_ASTC_10x10_Format:
24132
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 9 ) / 10 ) * 16;
24133
+ case RGBA_ASTC_12x10_Format:
24134
+ return Math.floor( ( width + 11 ) / 12 ) * Math.floor( ( height + 9 ) / 10 ) * 16;
24135
+ case RGBA_ASTC_12x12_Format:
24136
+ return Math.floor( ( width + 11 ) / 12 ) * Math.floor( ( height + 11 ) / 12 ) * 16;
24137
+
24138
+ // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_bptc/
24139
+ case RGBA_BPTC_Format:
24140
+ case RGB_BPTC_SIGNED_Format:
24141
+ case RGB_BPTC_UNSIGNED_Format:
24142
+ return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 16;
24143
+
24144
+ // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_rgtc/
24145
+ case RED_RGTC1_Format:
24146
+ case SIGNED_RED_RGTC1_Format:
24147
+ return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 8;
24148
+ case RED_GREEN_RGTC2_Format:
24149
+ case SIGNED_RED_GREEN_RGTC2_Format:
24150
+ return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 16;
24151
+
24152
+ }
24153
+
24154
+ throw new Error(
24155
+ `Unable to determine texture byte length for ${format} format.`,
24156
+ );
24157
+
24158
+ }
24159
+
24160
+ function getTextureTypeByteLength( type ) {
24161
+
24162
+ switch ( type ) {
24163
+
24164
+ case UnsignedByteType:
24165
+ case ByteType:
24166
+ return { byteLength: 1, components: 1 };
24167
+ case UnsignedShortType:
24168
+ case ShortType:
24169
+ case HalfFloatType:
24170
+ return { byteLength: 2, components: 1 };
24171
+ case UnsignedShort4444Type:
24172
+ case UnsignedShort5551Type:
24173
+ return { byteLength: 2, components: 4 };
24174
+ case UnsignedIntType:
24175
+ case IntType:
24176
+ case FloatType:
24177
+ return { byteLength: 4, components: 1 };
24178
+ case UnsignedInt5999Type:
24179
+ return { byteLength: 4, components: 3 };
24180
+
24181
+ }
24182
+
24183
+ throw new Error( `Unknown texture type ${type}.` );
24184
+
24185
+ }
24186
+
24187
+ const TextureUtils = {
24188
+ contain,
24189
+ cover,
24190
+ fill,
24191
+ getByteLength
24192
+ };
24193
+
23929
24194
  function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
23930
24195
 
23931
24196
  const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
@@ -24821,10 +25086,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24821
25086
 
24822
25087
  if ( texture.layerUpdates.size > 0 ) {
24823
25088
 
25089
+ const layerByteLength = getByteLength( mipmap.width, mipmap.height, texture.format, texture.type );
25090
+
24824
25091
  for ( const layerIndex of texture.layerUpdates ) {
24825
25092
 
24826
- const layerSize = mipmap.width * mipmap.height;
24827
- 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 );
25093
+ const layerData = mipmap.data.subarray(
25094
+ layerIndex * layerByteLength / mipmap.data.BYTES_PER_ELEMENT,
25095
+ ( layerIndex + 1 ) * layerByteLength / mipmap.data.BYTES_PER_ELEMENT
25096
+ );
25097
+ state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, layerData, 0, 0 );
24828
25098
 
24829
25099
  }
24830
25100
 
@@ -24942,60 +25212,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24942
25212
 
24943
25213
  if ( texture.layerUpdates.size > 0 ) {
24944
25214
 
24945
- // When type is GL_UNSIGNED_BYTE, each of these bytes is
24946
- // interpreted as one color component, depending on format. When
24947
- // type is one of GL_UNSIGNED_SHORT_5_6_5,
24948
- // GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1, each
24949
- // unsigned value is interpreted as containing all the components
24950
- // for a single pixel, with the color components arranged
24951
- // according to format.
24952
- //
24953
- // See https://registry.khronos.org/OpenGL-Refpages/es1.1/xhtml/glTexImage2D.xml
24954
- let texelSize;
24955
- switch ( glType ) {
24956
-
24957
- case _gl.UNSIGNED_BYTE:
24958
- switch ( glFormat ) {
24959
-
24960
- case _gl.ALPHA:
24961
- texelSize = 1;
24962
- break;
24963
- case _gl.LUMINANCE:
24964
- texelSize = 1;
24965
- break;
24966
- case _gl.LUMINANCE_ALPHA:
24967
- texelSize = 2;
24968
- break;
24969
- case _gl.RGB:
24970
- texelSize = 3;
24971
- break;
24972
- case _gl.RGBA:
24973
- texelSize = 4;
24974
- break;
24975
-
24976
- default:
24977
- throw new Error( `Unknown texel size for format ${glFormat}.` );
24978
-
24979
- }
24980
-
24981
- break;
24982
-
24983
- case _gl.UNSIGNED_SHORT_4_4_4_4:
24984
- case _gl.UNSIGNED_SHORT_5_5_5_1:
24985
- case _gl.UNSIGNED_SHORT_5_6_5:
24986
- texelSize = 1;
24987
- break;
24988
-
24989
- default:
24990
- throw new Error( `Unknown texel size for type ${glType}.` );
24991
-
24992
- }
24993
-
24994
- const layerSize = image.width * image.height * texelSize;
25215
+ const layerByteLength = getByteLength( image.width, image.height, texture.format, texture.type );
24995
25216
 
24996
25217
  for ( const layerIndex of texture.layerUpdates ) {
24997
25218
 
24998
- 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 ) ) );
25219
+ const layerData = image.data.subarray(
25220
+ layerIndex * layerByteLength / image.data.BYTES_PER_ELEMENT,
25221
+ ( layerIndex + 1 ) * layerByteLength / image.data.BYTES_PER_ELEMENT
25222
+ );
25223
+ state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, layerIndex, image.width, image.height, 1, glFormat, glType, layerData );
24999
25224
 
25000
25225
  }
25001
25226
 
@@ -25684,6 +25909,37 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25684
25909
  const renderTargetProperties = properties.get( renderTarget );
25685
25910
  const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
25686
25911
 
25912
+ // if the bound depth texture has changed
25913
+ if ( renderTargetProperties.__boundDepthTexture !== renderTarget.depthTexture ) {
25914
+
25915
+ // fire the dispose event to get rid of stored state associated with the previously bound depth buffer
25916
+ const depthTexture = renderTarget.depthTexture;
25917
+ if ( renderTargetProperties.__depthDisposeCallback ) {
25918
+
25919
+ renderTargetProperties.__depthDisposeCallback();
25920
+
25921
+ }
25922
+
25923
+ // set up dispose listeners to track when the currently attached buffer is implicitly unbound
25924
+ if ( depthTexture ) {
25925
+
25926
+ const disposeEvent = () => {
25927
+
25928
+ delete renderTargetProperties.__boundDepthTexture;
25929
+ delete renderTargetProperties.__depthDisposeCallback;
25930
+ depthTexture.removeEventListener( 'dispose', disposeEvent );
25931
+
25932
+ };
25933
+
25934
+ depthTexture.addEventListener( 'dispose', disposeEvent );
25935
+ renderTargetProperties.__depthDisposeCallback = disposeEvent;
25936
+
25937
+ }
25938
+
25939
+ renderTargetProperties.__boundDepthTexture = depthTexture;
25940
+
25941
+ }
25942
+
25687
25943
  if ( renderTarget.depthTexture && ! renderTargetProperties.__autoAllocateDepthBuffer ) {
25688
25944
 
25689
25945
  if ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );
@@ -25699,16 +25955,42 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25699
25955
  for ( let i = 0; i < 6; i ++ ) {
25700
25956
 
25701
25957
  state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ i ] );
25702
- renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();
25703
- setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false );
25958
+
25959
+ if ( renderTargetProperties.__webglDepthbuffer[ i ] === undefined ) {
25960
+
25961
+ renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();
25962
+ setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false );
25963
+
25964
+ } else {
25965
+
25966
+ // attach buffer if it's been created already
25967
+ const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
25968
+ const renderbuffer = renderTargetProperties.__webglDepthbuffer[ i ];
25969
+ _gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
25970
+ _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
25971
+
25972
+ }
25704
25973
 
25705
25974
  }
25706
25975
 
25707
25976
  } else {
25708
25977
 
25709
25978
  state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
25710
- renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();
25711
- setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false );
25979
+
25980
+ if ( renderTargetProperties.__webglDepthbuffer === undefined ) {
25981
+
25982
+ renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();
25983
+ setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false );
25984
+
25985
+ } else {
25986
+
25987
+ // attach buffer if it's been created already
25988
+ const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
25989
+ const renderbuffer = renderTargetProperties.__webglDepthbuffer;
25990
+ _gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
25991
+ _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
25992
+
25993
+ }
25712
25994
 
25713
25995
  }
25714
25996
 
@@ -27476,6 +27758,12 @@ class WebXRDepthSensing {
27476
27758
 
27477
27759
  }
27478
27760
 
27761
+ getDepthTexture() {
27762
+
27763
+ return this.texture;
27764
+
27765
+ }
27766
+
27479
27767
  }
27480
27768
 
27481
27769
  class WebXRManager extends EventDispatcher {
@@ -27898,6 +28186,12 @@ class WebXRManager extends EventDispatcher {
27898
28186
  session.updateRenderState( { layers: layersCopy } );
27899
28187
  };
27900
28188
 
28189
+ this.getDepthTexture = function () {
28190
+
28191
+ return depthSensing.getDepthTexture();
28192
+
28193
+ };
28194
+
27901
28195
  function onInputSourcesChange( event ) {
27902
28196
 
27903
28197
  // Notify disconnected
@@ -28010,18 +28304,31 @@ class WebXRManager extends EventDispatcher {
28010
28304
  camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
28011
28305
  camera.matrixWorldInverse.copy( camera.matrixWorld ).invert();
28012
28306
 
28013
- // Find the union of the frustum values of the cameras and scale
28014
- // the values so that the near plane's position does not change in world space,
28015
- // although must now be relative to the new union camera.
28016
- const near2 = near + zOffset;
28017
- const far2 = far + zOffset;
28018
- const left2 = left - xOffset;
28019
- const right2 = right + ( ipd - xOffset );
28020
- const top2 = topFov * far / far2 * near2;
28021
- const bottom2 = bottomFov * far / far2 * near2;
28307
+ // Check if the projection uses an infinite far plane.
28308
+ if ( projL[ 10 ] === - 1.0 ) {
28309
+
28310
+ // Use the projection matrix from the left eye.
28311
+ // The camera offset is sufficient to include the view volumes
28312
+ // of both eyes (assuming symmetric projections).
28313
+ camera.projectionMatrix.copy( cameraL.projectionMatrix );
28314
+ camera.projectionMatrixInverse.copy( cameraL.projectionMatrixInverse );
28022
28315
 
28023
- camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
28024
- camera.projectionMatrixInverse.copy( camera.projectionMatrix ).invert();
28316
+ } else {
28317
+
28318
+ // Find the union of the frustum values of the cameras and scale
28319
+ // the values so that the near plane's position does not change in world space,
28320
+ // although must now be relative to the new union camera.
28321
+ const near2 = near + zOffset;
28322
+ const far2 = far + zOffset;
28323
+ const left2 = left - xOffset;
28324
+ const right2 = right + ( ipd - xOffset );
28325
+ const top2 = topFov * far / far2 * near2;
28326
+ const bottom2 = bottomFov * far / far2 * near2;
28327
+
28328
+ camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
28329
+ camera.projectionMatrixInverse.copy( camera.projectionMatrix ).invert();
28330
+
28331
+ }
28025
28332
 
28026
28333
  }
28027
28334
 
@@ -28051,15 +28358,18 @@ class WebXRManager extends EventDispatcher {
28051
28358
 
28052
28359
  if ( session === null ) return;
28053
28360
 
28361
+ let depthNear = camera.near;
28362
+ let depthFar = camera.far;
28363
+
28054
28364
  if ( depthSensing.texture !== null ) {
28055
28365
 
28056
- camera.near = depthSensing.depthNear;
28057
- camera.far = depthSensing.depthFar;
28366
+ if ( depthSensing.depthNear > 0 ) depthNear = depthSensing.depthNear;
28367
+ if ( depthSensing.depthFar > 0 ) depthFar = depthSensing.depthFar;
28058
28368
 
28059
28369
  }
28060
28370
 
28061
- cameraXR.near = cameraR.near = cameraL.near = camera.near;
28062
- cameraXR.far = cameraR.far = cameraL.far = camera.far;
28371
+ cameraXR.near = cameraR.near = cameraL.near = depthNear;
28372
+ cameraXR.far = cameraR.far = cameraL.far = depthFar;
28063
28373
 
28064
28374
  if ( _currentDepthNear !== cameraXR.near || _currentDepthFar !== cameraXR.far ) {
28065
28375
 
@@ -28073,15 +28383,6 @@ class WebXRManager extends EventDispatcher {
28073
28383
  _currentDepthNear = cameraXR.near;
28074
28384
  _currentDepthFar = cameraXR.far;
28075
28385
 
28076
- cameraL.near = _currentDepthNear;
28077
- cameraL.far = _currentDepthFar;
28078
- cameraR.near = _currentDepthNear;
28079
- cameraR.far = _currentDepthFar;
28080
-
28081
- cameraL.updateProjectionMatrix();
28082
- cameraR.updateProjectionMatrix();
28083
- camera.updateProjectionMatrix();
28084
-
28085
28386
  }
28086
28387
 
28087
28388
  const cameras = cameraXR.cameras;
@@ -29176,27 +29477,27 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
29176
29477
 
29177
29478
  const info = getUniformSize( value );
29178
29479
 
29179
- // Calculate the chunk offset
29180
- const chunkOffsetUniform = offset % chunkSize;
29480
+ const chunkOffset = offset % chunkSize; // offset in the current chunk
29481
+ const chunkPadding = chunkOffset % info.boundary; // required padding to match boundary
29482
+ const chunkStart = chunkOffset + chunkPadding; // the start position in the current chunk for the data
29483
+
29484
+ offset += chunkPadding;
29181
29485
 
29182
29486
  // Check for chunk overflow
29183
- if ( chunkOffsetUniform !== 0 && ( chunkSize - chunkOffsetUniform ) < info.boundary ) {
29487
+ if ( chunkStart !== 0 && ( chunkSize - chunkStart ) < info.storage ) {
29184
29488
 
29185
29489
  // Add padding and adjust offset
29186
- offset += ( chunkSize - chunkOffsetUniform );
29490
+ offset += ( chunkSize - chunkStart );
29187
29491
 
29188
29492
  }
29189
29493
 
29190
29494
  // the following two properties will be used for partial buffer updates
29191
-
29192
29495
  uniform.__data = new Float32Array( info.storage / Float32Array.BYTES_PER_ELEMENT );
29193
29496
  uniform.__offset = offset;
29194
29497
 
29195
-
29196
29498
  // Update the global offset
29197
29499
  offset += info.storage;
29198
29500
 
29199
-
29200
29501
  }
29201
29502
 
29202
29503
  }
@@ -29468,6 +29769,8 @@ class WebGLRenderer {
29468
29769
 
29469
29770
  const _vector3 = new Vector3();
29470
29771
 
29772
+ const _vector4 = new Vector4();
29773
+
29471
29774
  const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
29472
29775
 
29473
29776
  let _renderBackground = false;
@@ -30127,7 +30430,25 @@ class WebGLRenderer {
30127
30430
 
30128
30431
  } else {
30129
30432
 
30130
- renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
30433
+ if ( ! extensions.get( 'WEBGL_multi_draw' ) ) {
30434
+
30435
+ const starts = object._multiDrawStarts;
30436
+ const counts = object._multiDrawCounts;
30437
+ const drawCount = object._multiDrawCount;
30438
+ const bytesPerElement = index ? attributes.get( index ).bytesPerElement : 1;
30439
+ const uniforms = properties.get( material ).currentProgram.getUniforms();
30440
+ for ( let i = 0; i < drawCount; i ++ ) {
30441
+
30442
+ uniforms.setValue( _gl, '_gl_DrawID', i );
30443
+ renderer.render( starts[ i ] / bytesPerElement, counts[ i ] );
30444
+
30445
+ }
30446
+
30447
+ } else {
30448
+
30449
+ renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
30450
+
30451
+ }
30131
30452
 
30132
30453
  }
30133
30454
 
@@ -30600,7 +30921,7 @@ class WebGLRenderer {
30600
30921
 
30601
30922
  if ( sortObjects ) {
30602
30923
 
30603
- _vector3.setFromMatrixPosition( object.matrixWorld )
30924
+ _vector4.setFromMatrixPosition( object.matrixWorld )
30604
30925
  .applyMatrix4( _projScreenMatrix );
30605
30926
 
30606
30927
  }
@@ -30610,7 +30931,7 @@ class WebGLRenderer {
30610
30931
 
30611
30932
  if ( material.visible ) {
30612
30933
 
30613
- currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
30934
+ currentRenderList.push( object, geometry, material, groupOrder, _vector4.z, null );
30614
30935
 
30615
30936
  }
30616
30937
 
@@ -30628,16 +30949,16 @@ class WebGLRenderer {
30628
30949
  if ( object.boundingSphere !== undefined ) {
30629
30950
 
30630
30951
  if ( object.boundingSphere === null ) object.computeBoundingSphere();
30631
- _vector3.copy( object.boundingSphere.center );
30952
+ _vector4.copy( object.boundingSphere.center );
30632
30953
 
30633
30954
  } else {
30634
30955
 
30635
30956
  if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
30636
- _vector3.copy( geometry.boundingSphere.center );
30957
+ _vector4.copy( geometry.boundingSphere.center );
30637
30958
 
30638
30959
  }
30639
30960
 
30640
- _vector3
30961
+ _vector4
30641
30962
  .applyMatrix4( object.matrixWorld )
30642
30963
  .applyMatrix4( _projScreenMatrix );
30643
30964
 
@@ -30654,7 +30975,7 @@ class WebGLRenderer {
30654
30975
 
30655
30976
  if ( groupMaterial && groupMaterial.visible ) {
30656
30977
 
30657
- currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector3.z, group );
30978
+ currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector4.z, group );
30658
30979
 
30659
30980
  }
30660
30981
 
@@ -30662,7 +30983,7 @@ class WebGLRenderer {
30662
30983
 
30663
30984
  } else if ( material.visible ) {
30664
30985
 
30665
- currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
30986
+ currentRenderList.push( object, geometry, material, groupOrder, _vector4.z, null );
30666
30987
 
30667
30988
  }
30668
30989
 
@@ -30757,15 +31078,9 @@ class WebGLRenderer {
30757
31078
  _currentClearAlpha = _this.getClearAlpha();
30758
31079
  if ( _currentClearAlpha < 1 ) _this.setClearColor( 0xffffff, 0.5 );
30759
31080
 
30760
- if ( _renderBackground ) {
30761
-
30762
- background.render( scene );
31081
+ _this.clear();
30763
31082
 
30764
- } else {
30765
-
30766
- _this.clear();
30767
-
30768
- }
31083
+ if ( _renderBackground ) background.render( scene );
30769
31084
 
30770
31085
  // Turn off the features which can affect the frag color for opaque objects pass.
30771
31086
  // Otherwise they are applied twice in opaque objects pass and transmission objects pass.
@@ -30942,8 +31257,6 @@ class WebGLRenderer {
30942
31257
 
30943
31258
  parameters.uniforms = programCache.getUniforms( material );
30944
31259
 
30945
- material.onBuild( object, parameters, _this );
30946
-
30947
31260
  material.onBeforeCompile( parameters, _this );
30948
31261
 
30949
31262
  program = programCache.acquireProgram( parameters, programCacheKey );
@@ -31328,6 +31641,9 @@ class WebGLRenderer {
31328
31641
  p_uniforms.setOptional( _gl, object, 'batchingTexture' );
31329
31642
  p_uniforms.setValue( _gl, 'batchingTexture', object._matricesTexture, textures );
31330
31643
 
31644
+ p_uniforms.setOptional( _gl, object, 'batchingIdTexture' );
31645
+ p_uniforms.setValue( _gl, 'batchingIdTexture', object._indirectTexture, textures );
31646
+
31331
31647
  p_uniforms.setOptional( _gl, object, 'batchingColorTexture' );
31332
31648
  if ( object._colorsTexture !== null ) {
31333
31649
 
@@ -31583,6 +31899,28 @@ class WebGLRenderer {
31583
31899
  // Color and depth texture must be rebound in order for the swapchain to update.
31584
31900
  textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture );
31585
31901
 
31902
+ } else if ( renderTarget.depthBuffer ) {
31903
+
31904
+ // check if the depth texture is already bound to the frame buffer and that it's been initialized
31905
+ const depthTexture = renderTarget.depthTexture;
31906
+ if ( renderTargetProperties.__boundDepthTexture !== depthTexture ) {
31907
+
31908
+ // check if the depth texture is compatible
31909
+ if (
31910
+ depthTexture !== null &&
31911
+ properties.has( depthTexture ) &&
31912
+ ( renderTarget.width !== depthTexture.image.width || renderTarget.height !== depthTexture.image.height )
31913
+ ) {
31914
+
31915
+ throw new Error( 'WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.' );
31916
+
31917
+ }
31918
+
31919
+ // Swap the depth buffer to the currently attached one
31920
+ textures.setupDepthRenderbuffer( renderTarget );
31921
+
31922
+ }
31923
+
31586
31924
  }
31587
31925
 
31588
31926
  const texture = renderTarget.texture;
@@ -31815,7 +32153,7 @@ class WebGLRenderer {
31815
32153
  if ( texture.isTexture !== true ) {
31816
32154
 
31817
32155
  // @deprecated, r165
31818
- console.warn( 'WebGLRenderer: copyFramebufferToTexture function signature has changed.' );
32156
+ warnOnce( 'WebGLRenderer: copyFramebufferToTexture function signature has changed.' );
31819
32157
 
31820
32158
  position = arguments[ 0 ] || null;
31821
32159
  texture = arguments[ 1 ];
@@ -31843,7 +32181,7 @@ class WebGLRenderer {
31843
32181
  if ( srcTexture.isTexture !== true ) {
31844
32182
 
31845
32183
  // @deprecated, r165
31846
- console.warn( 'WebGLRenderer: copyTextureToTexture function signature has changed.' );
32184
+ warnOnce( 'WebGLRenderer: copyTextureToTexture function signature has changed.' );
31847
32185
 
31848
32186
  dstPosition = arguments[ 0 ] || null;
31849
32187
  srcTexture = arguments[ 1 ];
@@ -31919,7 +32257,7 @@ class WebGLRenderer {
31919
32257
 
31920
32258
  } else {
31921
32259
 
31922
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, glFormat, glType, image );
32260
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
31923
32261
 
31924
32262
  }
31925
32263
 
@@ -31944,7 +32282,7 @@ class WebGLRenderer {
31944
32282
  if ( srcTexture.isTexture !== true ) {
31945
32283
 
31946
32284
  // @deprecated, r165
31947
- console.warn( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
32285
+ warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
31948
32286
 
31949
32287
  srcRegion = arguments[ 0 ] || null;
31950
32288
  dstPosition = arguments[ 1 ] || null;
@@ -33994,7 +34332,7 @@ class InstancedMesh extends Mesh {
33994
34332
 
33995
34333
  if ( this.instanceColor === null ) {
33996
34334
 
33997
- this.instanceColor = new InstancedBufferAttribute( new Float32Array( this.instanceMatrix.count * 3 ), 3 );
34335
+ this.instanceColor = new InstancedBufferAttribute( new Float32Array( this.instanceMatrix.count * 3 ).fill( 1 ), 3 );
33998
34336
 
33999
34337
  }
34000
34338
 
@@ -34083,7 +34421,7 @@ class MultiDrawRenderList {
34083
34421
 
34084
34422
  }
34085
34423
 
34086
- push( drawRange, z ) {
34424
+ push( drawRange, z, index ) {
34087
34425
 
34088
34426
  const pool = this.pool;
34089
34427
  const list = this.list;
@@ -34094,6 +34432,7 @@ class MultiDrawRenderList {
34094
34432
  start: - 1,
34095
34433
  count: - 1,
34096
34434
  z: - 1,
34435
+ index: - 1,
34097
34436
 
34098
34437
  } );
34099
34438
 
@@ -34106,6 +34445,7 @@ class MultiDrawRenderList {
34106
34445
  item.start = drawRange.start;
34107
34446
  item.count = drawRange.count;
34108
34447
  item.z = z;
34448
+ item.index = index;
34109
34449
 
34110
34450
  }
34111
34451
 
@@ -34118,7 +34458,6 @@ class MultiDrawRenderList {
34118
34458
 
34119
34459
  }
34120
34460
 
34121
- const ID_ATTR_NAME = 'batchId';
34122
34461
  const _matrix$1 = /*@__PURE__*/ new Matrix4();
34123
34462
  const _invMatrixWorld = /*@__PURE__*/ new Matrix4();
34124
34463
  const _identityMatrix = /*@__PURE__*/ new Matrix4();
@@ -34173,13 +34512,13 @@ function copyAttributeData( src, target, targetOffset = 0 ) {
34173
34512
 
34174
34513
  class BatchedMesh extends Mesh {
34175
34514
 
34176
- get maxGeometryCount() {
34515
+ get maxInstanceCount() {
34177
34516
 
34178
- return this._maxGeometryCount;
34517
+ return this._maxInstanceCount;
34179
34518
 
34180
34519
  }
34181
34520
 
34182
- constructor( maxGeometryCount, maxVertexCount, maxIndexCount = maxVertexCount * 2, material ) {
34521
+ constructor( maxInstanceCount, maxVertexCount, maxIndexCount = maxVertexCount * 2, material ) {
34183
34522
 
34184
34523
  super( new BufferGeometry(), material );
34185
34524
 
@@ -34190,32 +34529,33 @@ class BatchedMesh extends Mesh {
34190
34529
  this.boundingSphere = null;
34191
34530
  this.customSort = null;
34192
34531
 
34532
+ // stores visible, active, and geometry id per object
34533
+ this._drawInfo = [];
34534
+
34535
+ // geometry information
34193
34536
  this._drawRanges = [];
34194
34537
  this._reservedRanges = [];
34195
-
34196
- this._visibility = [];
34197
- this._active = [];
34198
34538
  this._bounds = [];
34199
34539
 
34200
- this._maxGeometryCount = maxGeometryCount;
34540
+ this._maxInstanceCount = maxInstanceCount;
34201
34541
  this._maxVertexCount = maxVertexCount;
34202
34542
  this._maxIndexCount = maxIndexCount;
34203
34543
 
34204
34544
  this._geometryInitialized = false;
34205
34545
  this._geometryCount = 0;
34206
- this._multiDrawCounts = new Int32Array( maxGeometryCount );
34207
- this._multiDrawStarts = new Int32Array( maxGeometryCount );
34546
+ this._multiDrawCounts = new Int32Array( maxInstanceCount );
34547
+ this._multiDrawStarts = new Int32Array( maxInstanceCount );
34208
34548
  this._multiDrawCount = 0;
34209
34549
  this._multiDrawInstances = null;
34210
34550
  this._visibilityChanged = true;
34211
34551
 
34212
34552
  // Local matrix per geometry by using data texture
34213
34553
  this._matricesTexture = null;
34554
+ this._indirectTexture = null;
34555
+ this._colorsTexture = null;
34214
34556
 
34215
34557
  this._initMatricesTexture();
34216
-
34217
- // Local color per geometry by using data texture
34218
- this._colorsTexture = null;
34558
+ this._initIndirectTexture();
34219
34559
 
34220
34560
  }
34221
34561
 
@@ -34228,7 +34568,7 @@ class BatchedMesh extends Mesh {
34228
34568
  // 32x32 pixel texture max 256 matrices * 4 pixels = (32 * 32)
34229
34569
  // 64x64 pixel texture max 1024 matrices * 4 pixels = (64 * 64)
34230
34570
 
34231
- let size = Math.sqrt( this._maxGeometryCount * 4 ); // 4 pixels needed for 1 matrix
34571
+ let size = Math.sqrt( this._maxInstanceCount * 4 ); // 4 pixels needed for 1 matrix
34232
34572
  size = Math.ceil( size / 4 ) * 4;
34233
34573
  size = Math.max( size, 4 );
34234
34574
 
@@ -34239,9 +34579,21 @@ class BatchedMesh extends Mesh {
34239
34579
 
34240
34580
  }
34241
34581
 
34582
+ _initIndirectTexture() {
34583
+
34584
+ let size = Math.sqrt( this._maxInstanceCount );
34585
+ size = Math.ceil( size );
34586
+
34587
+ const indirectArray = new Uint32Array( size * size );
34588
+ const indirectTexture = new DataTexture( indirectArray, size, size, RedIntegerFormat, UnsignedIntType );
34589
+
34590
+ this._indirectTexture = indirectTexture;
34591
+
34592
+ }
34593
+
34242
34594
  _initColorsTexture() {
34243
34595
 
34244
- let size = Math.sqrt( this._maxGeometryCount );
34596
+ let size = Math.sqrt( this._maxInstanceCount );
34245
34597
  size = Math.ceil( size );
34246
34598
 
34247
34599
  // 4 floats per RGBA pixel initialized to white
@@ -34257,7 +34609,6 @@ class BatchedMesh extends Mesh {
34257
34609
 
34258
34610
  const geometry = this.geometry;
34259
34611
  const maxVertexCount = this._maxVertexCount;
34260
- const maxGeometryCount = this._maxGeometryCount;
34261
34612
  const maxIndexCount = this._maxIndexCount;
34262
34613
  if ( this._geometryInitialized === false ) {
34263
34614
 
@@ -34275,7 +34626,8 @@ class BatchedMesh extends Mesh {
34275
34626
 
34276
34627
  if ( reference.getIndex() !== null ) {
34277
34628
 
34278
- const indexArray = maxVertexCount > 65536
34629
+ // Reserve last u16 index for primitive restart.
34630
+ const indexArray = maxVertexCount > 65535
34279
34631
  ? new Uint32Array( maxIndexCount )
34280
34632
  : new Uint16Array( maxIndexCount );
34281
34633
 
@@ -34283,11 +34635,6 @@ class BatchedMesh extends Mesh {
34283
34635
 
34284
34636
  }
34285
34637
 
34286
- const idArray = maxGeometryCount > 65536
34287
- ? new Uint32Array( maxVertexCount )
34288
- : new Uint16Array( maxVertexCount );
34289
- geometry.setAttribute( ID_ATTR_NAME, new BufferAttribute( idArray, 1 ) );
34290
-
34291
34638
  this._geometryInitialized = true;
34292
34639
 
34293
34640
  }
@@ -34297,13 +34644,6 @@ class BatchedMesh extends Mesh {
34297
34644
  // Make sure the geometry is compatible with the existing combined geometry attributes
34298
34645
  _validateGeometry( geometry ) {
34299
34646
 
34300
- // check that the geometry doesn't have a version of our reserved id attribute
34301
- if ( geometry.getAttribute( ID_ATTR_NAME ) ) {
34302
-
34303
- throw new Error( `BatchedMesh: Geometry cannot use attribute "${ ID_ATTR_NAME }"` );
34304
-
34305
- }
34306
-
34307
34647
  // check to ensure the geometries are using consistent attributes and indices
34308
34648
  const batchGeometry = this.geometry;
34309
34649
  if ( Boolean( geometry.getIndex() ) !== Boolean( batchGeometry.getIndex() ) ) {
@@ -34314,12 +34654,6 @@ class BatchedMesh extends Mesh {
34314
34654
 
34315
34655
  for ( const attributeName in batchGeometry.attributes ) {
34316
34656
 
34317
- if ( attributeName === ID_ATTR_NAME ) {
34318
-
34319
- continue;
34320
-
34321
- }
34322
-
34323
34657
  if ( ! geometry.hasAttribute( attributeName ) ) {
34324
34658
 
34325
34659
  throw new Error( `BatchedMesh: Added geometry missing "${ attributeName }". All geometries must have consistent attributes.` );
@@ -34353,17 +34687,17 @@ class BatchedMesh extends Mesh {
34353
34687
 
34354
34688
  }
34355
34689
 
34356
- const geometryCount = this._geometryCount;
34357
34690
  const boundingBox = this.boundingBox;
34358
- const active = this._active;
34691
+ const drawInfo = this._drawInfo;
34359
34692
 
34360
34693
  boundingBox.makeEmpty();
34361
- for ( let i = 0; i < geometryCount; i ++ ) {
34694
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34362
34695
 
34363
- if ( active[ i ] === false ) continue;
34696
+ if ( drawInfo[ i ].active === false ) continue;
34364
34697
 
34698
+ const geometryId = drawInfo[ i ].geometryIndex;
34365
34699
  this.getMatrixAt( i, _matrix$1 );
34366
- this.getBoundingBoxAt( i, _box$1 ).applyMatrix4( _matrix$1 );
34700
+ this.getBoundingBoxAt( geometryId, _box$1 ).applyMatrix4( _matrix$1 );
34367
34701
  boundingBox.union( _box$1 );
34368
34702
 
34369
34703
  }
@@ -34378,23 +34712,59 @@ class BatchedMesh extends Mesh {
34378
34712
 
34379
34713
  }
34380
34714
 
34381
- const geometryCount = this._geometryCount;
34382
34715
  const boundingSphere = this.boundingSphere;
34383
- const active = this._active;
34716
+ const drawInfo = this._drawInfo;
34384
34717
 
34385
34718
  boundingSphere.makeEmpty();
34386
- for ( let i = 0; i < geometryCount; i ++ ) {
34719
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34387
34720
 
34388
- if ( active[ i ] === false ) continue;
34721
+ if ( drawInfo[ i ].active === false ) continue;
34389
34722
 
34723
+ const geometryId = drawInfo[ i ].geometryIndex;
34390
34724
  this.getMatrixAt( i, _matrix$1 );
34391
- this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix$1 );
34725
+ this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
34392
34726
  boundingSphere.union( _sphere$2 );
34393
34727
 
34394
34728
  }
34395
34729
 
34396
34730
  }
34397
34731
 
34732
+ addInstance( geometryId ) {
34733
+
34734
+ // ensure we're not over geometry
34735
+ if ( this._drawInfo.length >= this._maxInstanceCount ) {
34736
+
34737
+ throw new Error( 'BatchedMesh: Maximum item count reached.' );
34738
+
34739
+ }
34740
+
34741
+ this._drawInfo.push( {
34742
+
34743
+ visible: true,
34744
+ active: true,
34745
+ geometryIndex: geometryId,
34746
+
34747
+ } );
34748
+
34749
+ // initialize the matrix
34750
+ const drawId = this._drawInfo.length - 1;
34751
+ const matricesTexture = this._matricesTexture;
34752
+ const matricesArray = matricesTexture.image.data;
34753
+ _identityMatrix.toArray( matricesArray, drawId * 16 );
34754
+ matricesTexture.needsUpdate = true;
34755
+
34756
+ const colorsTexture = this._colorsTexture;
34757
+ if ( colorsTexture ) {
34758
+
34759
+ _whiteColor.toArray( colorsTexture.image.data, drawId * 4 );
34760
+ colorsTexture.needsUpdate = true;
34761
+
34762
+ }
34763
+
34764
+ return drawId;
34765
+
34766
+ }
34767
+
34398
34768
  addGeometry( geometry, vertexCount = - 1, indexCount = - 1 ) {
34399
34769
 
34400
34770
  this._initializeGeometry( geometry );
@@ -34402,9 +34772,9 @@ class BatchedMesh extends Mesh {
34402
34772
  this._validateGeometry( geometry );
34403
34773
 
34404
34774
  // ensure we're not over geometry
34405
- if ( this._geometryCount >= this._maxGeometryCount ) {
34775
+ if ( this._drawInfo.length >= this._maxInstanceCount ) {
34406
34776
 
34407
- throw new Error( 'BatchedMesh: Maximum geometry count reached.' );
34777
+ throw new Error( 'BatchedMesh: Maximum item count reached.' );
34408
34778
 
34409
34779
  }
34410
34780
 
@@ -34482,32 +34852,10 @@ class BatchedMesh extends Mesh {
34482
34852
 
34483
34853
  }
34484
34854
 
34485
- const visibility = this._visibility;
34486
- const active = this._active;
34487
- const matricesTexture = this._matricesTexture;
34488
- const matricesArray = this._matricesTexture.image.data;
34489
- const colorsTexture = this._colorsTexture;
34490
-
34491
- // push new visibility states
34492
- visibility.push( true );
34493
- active.push( true );
34494
-
34495
34855
  // update id
34496
34856
  const geometryId = this._geometryCount;
34497
34857
  this._geometryCount ++;
34498
34858
 
34499
- // initialize matrix information
34500
- _identityMatrix.toArray( matricesArray, geometryId * 16 );
34501
- matricesTexture.needsUpdate = true;
34502
-
34503
- // initialize the color to white
34504
- if ( colorsTexture !== null ) {
34505
-
34506
- _whiteColor.toArray( colorsTexture.image.data, geometryId * 4 );
34507
- colorsTexture.needsUpdate = true;
34508
-
34509
- }
34510
-
34511
34859
  // add the reserved range and draw range objects
34512
34860
  reservedRanges.push( reservedRange );
34513
34861
  drawRanges.push( {
@@ -34522,16 +34870,6 @@ class BatchedMesh extends Mesh {
34522
34870
  sphere: new Sphere()
34523
34871
  } );
34524
34872
 
34525
- // set the id for the geometry
34526
- const idAttribute = this.geometry.getAttribute( ID_ATTR_NAME );
34527
- for ( let i = 0; i < reservedRange.vertexCount; i ++ ) {
34528
-
34529
- idAttribute.setX( reservedRange.vertexStart + i, geometryId );
34530
-
34531
- }
34532
-
34533
- idAttribute.needsUpdate = true;
34534
-
34535
34873
  // update the geometry
34536
34874
  this.setGeometryAt( geometryId, geometry );
34537
34875
 
@@ -34539,9 +34877,9 @@ class BatchedMesh extends Mesh {
34539
34877
 
34540
34878
  }
34541
34879
 
34542
- setGeometryAt( id, geometry ) {
34880
+ setGeometryAt( geometryId, geometry ) {
34543
34881
 
34544
- if ( id >= this._geometryCount ) {
34882
+ if ( geometryId >= this._geometryCount ) {
34545
34883
 
34546
34884
  throw new Error( 'BatchedMesh: Maximum geometry count reached.' );
34547
34885
 
@@ -34553,7 +34891,7 @@ class BatchedMesh extends Mesh {
34553
34891
  const hasIndex = batchGeometry.getIndex() !== null;
34554
34892
  const dstIndex = batchGeometry.getIndex();
34555
34893
  const srcIndex = geometry.getIndex();
34556
- const reservedRange = this._reservedRanges[ id ];
34894
+ const reservedRange = this._reservedRanges[ geometryId ];
34557
34895
  if (
34558
34896
  hasIndex &&
34559
34897
  srcIndex.count > reservedRange.indexCount ||
@@ -34569,12 +34907,6 @@ class BatchedMesh extends Mesh {
34569
34907
  const vertexCount = reservedRange.vertexCount;
34570
34908
  for ( const attributeName in batchGeometry.attributes ) {
34571
34909
 
34572
- if ( attributeName === ID_ATTR_NAME ) {
34573
-
34574
- continue;
34575
-
34576
- }
34577
-
34578
34910
  // copy attribute data
34579
34911
  const srcAttribute = geometry.getAttribute( attributeName );
34580
34912
  const dstAttribute = batchGeometry.getAttribute( attributeName );
@@ -34623,7 +34955,7 @@ class BatchedMesh extends Mesh {
34623
34955
  }
34624
34956
 
34625
34957
  // store the bounding boxes
34626
- const bound = this._bounds[ id ];
34958
+ const bound = this._bounds[ geometryId ];
34627
34959
  if ( geometry.boundingBox !== null ) {
34628
34960
 
34629
34961
  bound.box.copy( geometry.boundingBox );
@@ -34647,67 +34979,54 @@ class BatchedMesh extends Mesh {
34647
34979
  }
34648
34980
 
34649
34981
  // set drawRange count
34650
- const drawRange = this._drawRanges[ id ];
34982
+ const drawRange = this._drawRanges[ geometryId ];
34651
34983
  const posAttr = geometry.getAttribute( 'position' );
34652
34984
  drawRange.count = hasIndex ? srcIndex.count : posAttr.count;
34653
34985
  this._visibilityChanged = true;
34654
34986
 
34655
- return id;
34987
+ return geometryId;
34656
34988
 
34657
34989
  }
34658
34990
 
34991
+ /*
34659
34992
  deleteGeometry( geometryId ) {
34660
34993
 
34661
- // Note: User needs to call optimize() afterward to pack the data.
34662
-
34663
- const active = this._active;
34664
- if ( geometryId >= active.length || active[ geometryId ] === false ) {
34665
-
34666
- return this;
34667
-
34668
- }
34669
-
34670
- active[ geometryId ] = false;
34671
- this._visibilityChanged = true;
34672
-
34673
- return this;
34994
+ // TODO: delete geometry and associated instances
34674
34995
 
34675
34996
  }
34997
+ */
34676
34998
 
34677
- getInstanceCountAt( id ) {
34678
-
34679
- if ( this._multiDrawInstances === null ) return null;
34680
-
34681
- return this._multiDrawInstances[ id ];
34682
-
34683
- }
34999
+ /*
35000
+ deleteInstance( instanceId ) {
34684
35001
 
34685
- setInstanceCountAt( id, instanceCount ) {
35002
+ // Note: User needs to call optimize() afterward to pack the data.
34686
35003
 
34687
- if ( this._multiDrawInstances === null ) {
35004
+ const drawInfo = this._drawInfo;
35005
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34688
35006
 
34689
- this._multiDrawInstances = new Int32Array( this._maxGeometryCount ).fill( 1 );
35007
+ return this;
34690
35008
 
34691
35009
  }
34692
35010
 
34693
- this._multiDrawInstances[ id ] = instanceCount;
35011
+ drawInfo[ instanceId ].active = false;
35012
+ this._visibilityChanged = true;
34694
35013
 
34695
- return id;
35014
+ return this;
34696
35015
 
34697
35016
  }
35017
+ */
34698
35018
 
34699
35019
  // get bounding box and compute it if it doesn't exist
34700
- getBoundingBoxAt( id, target ) {
35020
+ getBoundingBoxAt( geometryId, target ) {
34701
35021
 
34702
- const active = this._active;
34703
- if ( active[ id ] === false ) {
35022
+ if ( geometryId >= this._geometryCount ) {
34704
35023
 
34705
35024
  return null;
34706
35025
 
34707
35026
  }
34708
35027
 
34709
35028
  // compute bounding box
34710
- const bound = this._bounds[ id ];
35029
+ const bound = this._bounds[ geometryId ];
34711
35030
  const box = bound.box;
34712
35031
  const geometry = this.geometry;
34713
35032
  if ( bound.boxInitialized === false ) {
@@ -34716,7 +35035,7 @@ class BatchedMesh extends Mesh {
34716
35035
 
34717
35036
  const index = geometry.index;
34718
35037
  const position = geometry.attributes.position;
34719
- const drawRange = this._drawRanges[ id ];
35038
+ const drawRange = this._drawRanges[ geometryId ];
34720
35039
  for ( let i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
34721
35040
 
34722
35041
  let iv = i;
@@ -34740,29 +35059,28 @@ class BatchedMesh extends Mesh {
34740
35059
  }
34741
35060
 
34742
35061
  // get bounding sphere and compute it if it doesn't exist
34743
- getBoundingSphereAt( id, target ) {
35062
+ getBoundingSphereAt( geometryId, target ) {
34744
35063
 
34745
- const active = this._active;
34746
- if ( active[ id ] === false ) {
35064
+ if ( geometryId >= this._geometryCount ) {
34747
35065
 
34748
35066
  return null;
34749
35067
 
34750
35068
  }
34751
35069
 
34752
35070
  // compute bounding sphere
34753
- const bound = this._bounds[ id ];
35071
+ const bound = this._bounds[ geometryId ];
34754
35072
  const sphere = bound.sphere;
34755
35073
  const geometry = this.geometry;
34756
35074
  if ( bound.sphereInitialized === false ) {
34757
35075
 
34758
35076
  sphere.makeEmpty();
34759
35077
 
34760
- this.getBoundingBoxAt( id, _box$1 );
35078
+ this.getBoundingBoxAt( geometryId, _box$1 );
34761
35079
  _box$1.getCenter( sphere.center );
34762
35080
 
34763
35081
  const index = geometry.index;
34764
35082
  const position = geometry.attributes.position;
34765
- const drawRange = this._drawRanges[ id ];
35083
+ const drawRange = this._drawRanges[ geometryId ];
34766
35084
 
34767
35085
  let maxRadiusSq = 0;
34768
35086
  for ( let i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
@@ -34789,44 +35107,42 @@ class BatchedMesh extends Mesh {
34789
35107
 
34790
35108
  }
34791
35109
 
34792
- setMatrixAt( geometryId, matrix ) {
35110
+ setMatrixAt( instanceId, matrix ) {
34793
35111
 
34794
35112
  // @TODO: Map geometryId to index of the arrays because
34795
35113
  // optimize() can make geometryId mismatch the index
34796
35114
 
34797
- const active = this._active;
35115
+ const drawInfo = this._drawInfo;
34798
35116
  const matricesTexture = this._matricesTexture;
34799
35117
  const matricesArray = this._matricesTexture.image.data;
34800
- const geometryCount = this._geometryCount;
34801
- if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
35118
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34802
35119
 
34803
35120
  return this;
34804
35121
 
34805
35122
  }
34806
35123
 
34807
- matrix.toArray( matricesArray, geometryId * 16 );
35124
+ matrix.toArray( matricesArray, instanceId * 16 );
34808
35125
  matricesTexture.needsUpdate = true;
34809
35126
 
34810
35127
  return this;
34811
35128
 
34812
35129
  }
34813
35130
 
34814
- getMatrixAt( geometryId, matrix ) {
35131
+ getMatrixAt( instanceId, matrix ) {
34815
35132
 
34816
- const active = this._active;
35133
+ const drawInfo = this._drawInfo;
34817
35134
  const matricesArray = this._matricesTexture.image.data;
34818
- const geometryCount = this._geometryCount;
34819
- if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
35135
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34820
35136
 
34821
35137
  return null;
34822
35138
 
34823
35139
  }
34824
35140
 
34825
- return matrix.fromArray( matricesArray, geometryId * 16 );
35141
+ return matrix.fromArray( matricesArray, instanceId * 16 );
34826
35142
 
34827
35143
  }
34828
35144
 
34829
- setColorAt( geometryId, color ) {
35145
+ setColorAt( instanceId, color ) {
34830
35146
 
34831
35147
  if ( this._colorsTexture === null ) {
34832
35148
 
@@ -34834,89 +35150,79 @@ class BatchedMesh extends Mesh {
34834
35150
 
34835
35151
  }
34836
35152
 
34837
- // @TODO: Map geometryId to index of the arrays because
34838
- // optimize() can make geometryId mismatch the index
35153
+ // @TODO: Map id to index of the arrays because
35154
+ // optimize() can make id mismatch the index
34839
35155
 
34840
- const active = this._active;
34841
35156
  const colorsTexture = this._colorsTexture;
34842
35157
  const colorsArray = this._colorsTexture.image.data;
34843
- const geometryCount = this._geometryCount;
34844
- if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
35158
+ const drawInfo = this._drawInfo;
35159
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34845
35160
 
34846
35161
  return this;
34847
35162
 
34848
35163
  }
34849
35164
 
34850
- color.toArray( colorsArray, geometryId * 4 );
35165
+ color.toArray( colorsArray, instanceId * 4 );
34851
35166
  colorsTexture.needsUpdate = true;
34852
35167
 
34853
35168
  return this;
34854
35169
 
34855
35170
  }
34856
35171
 
34857
- getColorAt( geometryId, color ) {
35172
+ getColorAt( instanceId, color ) {
34858
35173
 
34859
- const active = this._active;
34860
35174
  const colorsArray = this._colorsTexture.image.data;
34861
- const geometryCount = this._geometryCount;
34862
- if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
35175
+ const drawInfo = this._drawInfo;
35176
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34863
35177
 
34864
35178
  return null;
34865
35179
 
34866
35180
  }
34867
35181
 
34868
- return color.fromArray( colorsArray, geometryId * 4 );
35182
+ return color.fromArray( colorsArray, instanceId * 4 );
34869
35183
 
34870
35184
  }
34871
35185
 
34872
- setVisibleAt( geometryId, value ) {
34873
-
34874
- const visibility = this._visibility;
34875
- const active = this._active;
34876
- const geometryCount = this._geometryCount;
35186
+ setVisibleAt( instanceId, value ) {
34877
35187
 
34878
35188
  // if the geometry is out of range, not active, or visibility state
34879
35189
  // does not change then return early
35190
+ const drawInfo = this._drawInfo;
34880
35191
  if (
34881
- geometryId >= geometryCount ||
34882
- active[ geometryId ] === false ||
34883
- visibility[ geometryId ] === value
35192
+ instanceId >= drawInfo.length ||
35193
+ drawInfo[ instanceId ].active === false ||
35194
+ drawInfo[ instanceId ].visible === value
34884
35195
  ) {
34885
35196
 
34886
35197
  return this;
34887
35198
 
34888
35199
  }
34889
35200
 
34890
- visibility[ geometryId ] = value;
35201
+ drawInfo[ instanceId ].visible = value;
34891
35202
  this._visibilityChanged = true;
34892
35203
 
34893
35204
  return this;
34894
35205
 
34895
35206
  }
34896
35207
 
34897
- getVisibleAt( geometryId ) {
34898
-
34899
- const visibility = this._visibility;
34900
- const active = this._active;
34901
- const geometryCount = this._geometryCount;
35208
+ getVisibleAt( instanceId ) {
34902
35209
 
34903
35210
  // return early if the geometry is out of range or not active
34904
- if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
35211
+ const drawInfo = this._drawInfo;
35212
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34905
35213
 
34906
35214
  return false;
34907
35215
 
34908
35216
  }
34909
35217
 
34910
- return visibility[ geometryId ];
35218
+ return drawInfo[ instanceId ].visible;
34911
35219
 
34912
35220
  }
34913
35221
 
34914
35222
  raycast( raycaster, intersects ) {
34915
35223
 
34916
- const visibility = this._visibility;
34917
- const active = this._active;
35224
+ const drawInfo = this._drawInfo;
34918
35225
  const drawRanges = this._drawRanges;
34919
- const geometryCount = this._geometryCount;
34920
35226
  const matrixWorld = this.matrixWorld;
34921
35227
  const batchGeometry = this.geometry;
34922
35228
 
@@ -34936,21 +35242,22 @@ class BatchedMesh extends Mesh {
34936
35242
 
34937
35243
  }
34938
35244
 
34939
- for ( let i = 0; i < geometryCount; i ++ ) {
35245
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34940
35246
 
34941
- if ( ! visibility[ i ] || ! active[ i ] ) {
35247
+ if ( ! drawInfo[ i ].visible || ! drawInfo[ i ].active ) {
34942
35248
 
34943
35249
  continue;
34944
35250
 
34945
35251
  }
34946
35252
 
34947
- const drawRange = drawRanges[ i ];
35253
+ const geometryId = drawInfo[ i ].geometryIndex;
35254
+ const drawRange = drawRanges[ geometryId ];
34948
35255
  _mesh.geometry.setDrawRange( drawRange.start, drawRange.count );
34949
35256
 
34950
35257
  // ge the intersects
34951
35258
  this.getMatrixAt( i, _mesh.matrixWorld ).premultiply( matrixWorld );
34952
- this.getBoundingBoxAt( i, _mesh.geometry.boundingBox );
34953
- this.getBoundingSphereAt( i, _mesh.geometry.boundingSphere );
35259
+ this.getBoundingBoxAt( geometryId, _mesh.geometry.boundingBox );
35260
+ this.getBoundingSphereAt( geometryId, _mesh.geometry.boundingSphere );
34954
35261
  _mesh.raycast( raycaster, _batchIntersects );
34955
35262
 
34956
35263
  // add batch id to the intersects
@@ -34987,8 +35294,7 @@ class BatchedMesh extends Mesh {
34987
35294
  this._drawRanges = source._drawRanges.map( range => ( { ...range } ) );
34988
35295
  this._reservedRanges = source._reservedRanges.map( range => ( { ...range } ) );
34989
35296
 
34990
- this._visibility = source._visibility.slice();
34991
- this._active = source._active.slice();
35297
+ this._drawInfo = source._drawInfo.map( inf => ( { ...inf } ) );
34992
35298
  this._bounds = source._bounds.map( bound => ( {
34993
35299
  boxInitialized: bound.boxInitialized,
34994
35300
  box: bound.box.clone(),
@@ -34997,7 +35303,7 @@ class BatchedMesh extends Mesh {
34997
35303
  sphere: bound.sphere.clone()
34998
35304
  } ) );
34999
35305
 
35000
- this._maxGeometryCount = source._maxGeometryCount;
35306
+ this._maxInstanceCount = source._maxInstanceCount;
35001
35307
  this._maxVertexCount = source._maxVertexCount;
35002
35308
  this._maxIndexCount = source._maxIndexCount;
35003
35309
 
@@ -35007,12 +35313,12 @@ class BatchedMesh extends Mesh {
35007
35313
  this._multiDrawStarts = source._multiDrawStarts.slice();
35008
35314
 
35009
35315
  this._matricesTexture = source._matricesTexture.clone();
35010
- this._matricesTexture.image.data = this._matricesTexture.image.slice();
35316
+ this._matricesTexture.image.data = this._matricesTexture.image.data.slice();
35011
35317
 
35012
35318
  if ( this._colorsTexture !== null ) {
35013
35319
 
35014
35320
  this._colorsTexture = source._colorsTexture.clone();
35015
- this._colorsTexture.image.data = this._colorsTexture.image.slice();
35321
+ this._colorsTexture.image.data = this._colorsTexture.image.data.slice();
35016
35322
 
35017
35323
  }
35018
35324
 
@@ -35028,6 +35334,9 @@ class BatchedMesh extends Mesh {
35028
35334
  this._matricesTexture.dispose();
35029
35335
  this._matricesTexture = null;
35030
35336
 
35337
+ this._indirectTexture.dispose();
35338
+ this._indirectTexture = null;
35339
+
35031
35340
  if ( this._colorsTexture !== null ) {
35032
35341
 
35033
35342
  this._colorsTexture.dispose();
@@ -35054,12 +35363,13 @@ class BatchedMesh extends Mesh {
35054
35363
  const index = geometry.getIndex();
35055
35364
  const bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;
35056
35365
 
35057
- const active = this._active;
35058
- const visibility = this._visibility;
35366
+ const drawInfo = this._drawInfo;
35059
35367
  const multiDrawStarts = this._multiDrawStarts;
35060
35368
  const multiDrawCounts = this._multiDrawCounts;
35061
35369
  const drawRanges = this._drawRanges;
35062
35370
  const perObjectFrustumCulled = this.perObjectFrustumCulled;
35371
+ const indirectTexture = this._indirectTexture;
35372
+ const indirectArray = indirectTexture.image.data;
35063
35373
 
35064
35374
  // prepare the frustum in the local frame
35065
35375
  if ( perObjectFrustumCulled ) {
@@ -35082,13 +35392,15 @@ class BatchedMesh extends Mesh {
35082
35392
  _vector$5.setFromMatrixPosition( camera.matrixWorld ).applyMatrix4( _invMatrixWorld );
35083
35393
  _forward.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ).transformDirection( _invMatrixWorld );
35084
35394
 
35085
- for ( let i = 0, l = visibility.length; i < l; i ++ ) {
35395
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
35396
+
35397
+ if ( drawInfo[ i ].visible && drawInfo[ i ].active ) {
35086
35398
 
35087
- if ( visibility[ i ] && active[ i ] ) {
35399
+ const geometryId = drawInfo[ i ].geometryIndex;
35088
35400
 
35089
35401
  // get the bounds in world space
35090
35402
  this.getMatrixAt( i, _matrix$1 );
35091
- this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix$1 );
35403
+ this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
35092
35404
 
35093
35405
  // determine whether the batched geometry is within the frustum
35094
35406
  let culled = false;
@@ -35102,7 +35414,7 @@ class BatchedMesh extends Mesh {
35102
35414
 
35103
35415
  // get the distance from camera used for sorting
35104
35416
  const z = _temp.subVectors( _sphere$2.center, _vector$5 ).dot( _forward );
35105
- _renderList.push( drawRanges[ i ], z );
35417
+ _renderList.push( drawRanges[ geometryId ], z, i );
35106
35418
 
35107
35419
  }
35108
35420
 
@@ -35128,6 +35440,7 @@ class BatchedMesh extends Mesh {
35128
35440
  const item = list[ i ];
35129
35441
  multiDrawStarts[ count ] = item.start * bytesPerElement;
35130
35442
  multiDrawCounts[ count ] = item.count;
35443
+ indirectArray[ count ] = item.index;
35131
35444
  count ++;
35132
35445
 
35133
35446
  }
@@ -35136,9 +35449,11 @@ class BatchedMesh extends Mesh {
35136
35449
 
35137
35450
  } else {
35138
35451
 
35139
- for ( let i = 0, l = visibility.length; i < l; i ++ ) {
35452
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
35140
35453
 
35141
- if ( visibility[ i ] && active[ i ] ) {
35454
+ if ( drawInfo[ i ].visible && drawInfo[ i ].active ) {
35455
+
35456
+ const geometryId = drawInfo[ i ].geometryIndex;
35142
35457
 
35143
35458
  // determine whether the batched geometry is within the frustum
35144
35459
  let culled = false;
@@ -35146,16 +35461,17 @@ class BatchedMesh extends Mesh {
35146
35461
 
35147
35462
  // get the bounds in world space
35148
35463
  this.getMatrixAt( i, _matrix$1 );
35149
- this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix$1 );
35464
+ this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
35150
35465
  culled = ! _frustum.intersectsSphere( _sphere$2 );
35151
35466
 
35152
35467
  }
35153
35468
 
35154
35469
  if ( ! culled ) {
35155
35470
 
35156
- const range = drawRanges[ i ];
35471
+ const range = drawRanges[ geometryId ];
35157
35472
  multiDrawStarts[ count ] = range.start * bytesPerElement;
35158
35473
  multiDrawCounts[ count ] = range.count;
35474
+ indirectArray[ count ] = i;
35159
35475
  count ++;
35160
35476
 
35161
35477
  }
@@ -35166,6 +35482,7 @@ class BatchedMesh extends Mesh {
35166
35482
 
35167
35483
  }
35168
35484
 
35485
+ indirectTexture.needsUpdate = true;
35169
35486
  this._multiDrawCount = count;
35170
35487
  this._visibilityChanged = false;
35171
35488
 
@@ -35835,7 +36152,7 @@ class CompressedArrayTexture extends CompressedTexture {
35835
36152
 
35836
36153
  }
35837
36154
 
35838
- addLayerUpdates( layerIndex ) {
36155
+ addLayerUpdate( layerIndex ) {
35839
36156
 
35840
36157
  this.layerUpdates.add( layerIndex );
35841
36158
 
@@ -45642,6 +45959,7 @@ class Light extends Object3D {
45642
45959
  if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;
45643
45960
 
45644
45961
  if ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();
45962
+ if ( this.target !== undefined ) data.object.target = this.target.uuid;
45645
45963
 
45646
45964
  return data;
45647
45965
 
@@ -45688,6 +46006,8 @@ class LightShadow {
45688
46006
 
45689
46007
  this.camera = camera;
45690
46008
 
46009
+ this.intensity = 1;
46010
+
45691
46011
  this.bias = 0;
45692
46012
  this.normalBias = 0;
45693
46013
  this.radius = 1;
@@ -45785,6 +46105,8 @@ class LightShadow {
45785
46105
 
45786
46106
  this.camera = source.camera.clone();
45787
46107
 
46108
+ this.intensity = source.intensity;
46109
+
45788
46110
  this.bias = source.bias;
45789
46111
  this.radius = source.radius;
45790
46112
 
@@ -45804,6 +46126,7 @@ class LightShadow {
45804
46126
 
45805
46127
  const object = {};
45806
46128
 
46129
+ if ( this.intensity !== 1 ) object.intensity = this.intensity;
45807
46130
  if ( this.bias !== 0 ) object.bias = this.bias;
45808
46131
  if ( this.normalBias !== 0 ) object.normalBias = this.normalBias;
45809
46132
  if ( this.radius !== 1 ) object.radius = this.radius;
@@ -47232,6 +47555,7 @@ class ObjectLoader extends Loader {
47232
47555
  const skeletons = this.parseSkeletons( json.skeletons, object );
47233
47556
 
47234
47557
  this.bindSkeletons( object, skeletons );
47558
+ this.bindLightTargets( object );
47235
47559
 
47236
47560
  //
47237
47561
 
@@ -47273,6 +47597,7 @@ class ObjectLoader extends Loader {
47273
47597
  const skeletons = this.parseSkeletons( json.skeletons, object );
47274
47598
 
47275
47599
  this.bindSkeletons( object, skeletons );
47600
+ this.bindLightTargets( object );
47276
47601
 
47277
47602
  return object;
47278
47603
 
@@ -47917,6 +48242,7 @@ class ObjectLoader extends Loader {
47917
48242
  case 'DirectionalLight':
47918
48243
 
47919
48244
  object = new DirectionalLight( data.color, data.intensity );
48245
+ object.target = data.target || '';
47920
48246
 
47921
48247
  break;
47922
48248
 
@@ -47935,6 +48261,7 @@ class ObjectLoader extends Loader {
47935
48261
  case 'SpotLight':
47936
48262
 
47937
48263
  object = new SpotLight( data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay );
48264
+ object.target = data.target || '';
47938
48265
 
47939
48266
  break;
47940
48267
 
@@ -47991,7 +48318,7 @@ class ObjectLoader extends Loader {
47991
48318
  geometry = getGeometry( data.geometry );
47992
48319
  material = getMaterial( data.material );
47993
48320
 
47994
- object = new BatchedMesh( data.maxGeometryCount, data.maxVertexCount, data.maxIndexCount, material );
48321
+ object = new BatchedMesh( data.maxInstanceCount, data.maxVertexCount, data.maxIndexCount, material );
47995
48322
  object.geometry = geometry;
47996
48323
  object.perObjectFrustumCulled = data.perObjectFrustumCulled;
47997
48324
  object.sortObjects = data.sortObjects;
@@ -48021,7 +48348,7 @@ class ObjectLoader extends Loader {
48021
48348
 
48022
48349
  } );
48023
48350
 
48024
- object._maxGeometryCount = data.maxGeometryCount;
48351
+ object._maxInstanceCount = data.maxInstanceCount;
48025
48352
  object._maxVertexCount = data.maxVertexCount;
48026
48353
  object._maxIndexCount = data.maxIndexCount;
48027
48354
 
@@ -48115,6 +48442,7 @@ class ObjectLoader extends Loader {
48115
48442
 
48116
48443
  if ( data.shadow ) {
48117
48444
 
48445
+ if ( data.shadow.intensity !== undefined ) object.shadow.intensity = data.shadow.intensity;
48118
48446
  if ( data.shadow.bias !== undefined ) object.shadow.bias = data.shadow.bias;
48119
48447
  if ( data.shadow.normalBias !== undefined ) object.shadow.normalBias = data.shadow.normalBias;
48120
48448
  if ( data.shadow.radius !== undefined ) object.shadow.radius = data.shadow.radius;
@@ -48206,6 +48534,32 @@ class ObjectLoader extends Loader {
48206
48534
 
48207
48535
  }
48208
48536
 
48537
+ bindLightTargets( object ) {
48538
+
48539
+ object.traverse( function ( child ) {
48540
+
48541
+ if ( child.isDirectionalLight || child.isSpotLight ) {
48542
+
48543
+ const uuid = child.target;
48544
+
48545
+ const target = object.getObjectByProperty( 'uuid', uuid );
48546
+
48547
+ if ( target !== undefined ) {
48548
+
48549
+ child.target = target;
48550
+
48551
+ } else {
48552
+
48553
+ child.target = new Object3D();
48554
+
48555
+ }
48556
+
48557
+ }
48558
+
48559
+ } );
48560
+
48561
+ }
48562
+
48209
48563
  }
48210
48564
 
48211
48565
  const TEXTURE_MAPPING = {
@@ -52658,6 +53012,61 @@ class Cylindrical {
52658
53012
 
52659
53013
  }
52660
53014
 
53015
+ class Matrix2 {
53016
+
53017
+ constructor( n11, n12, n21, n22 ) {
53018
+
53019
+ Matrix2.prototype.isMatrix2 = true;
53020
+
53021
+ this.elements = [
53022
+ 1, 0,
53023
+ 0, 1,
53024
+ ];
53025
+
53026
+ if ( n11 !== undefined ) {
53027
+
53028
+ this.set( n11, n12, n21, n22 );
53029
+
53030
+ }
53031
+
53032
+ }
53033
+
53034
+ identity() {
53035
+
53036
+ this.set(
53037
+ 1, 0,
53038
+ 0, 1,
53039
+ );
53040
+
53041
+ return this;
53042
+
53043
+ }
53044
+
53045
+ fromArray( array, offset = 0 ) {
53046
+
53047
+ for ( let i = 0; i < 4; i ++ ) {
53048
+
53049
+ this.elements[ i ] = array[ i + offset ];
53050
+
53051
+ }
53052
+
53053
+ return this;
53054
+
53055
+ }
53056
+
53057
+ set( n11, n12, n21, n22 ) {
53058
+
53059
+ const te = this.elements;
53060
+
53061
+ te[ 0 ] = n11; te[ 2 ] = n12;
53062
+ te[ 1 ] = n21; te[ 3 ] = n22;
53063
+
53064
+ return this;
53065
+
53066
+ }
53067
+
53068
+ }
53069
+
52661
53070
  const _vector$4 = /*@__PURE__*/ new Vector2();
52662
53071
 
52663
53072
  class Box2 {
@@ -52777,8 +53186,8 @@ class Box2 {
52777
53186
 
52778
53187
  containsPoint( point ) {
52779
53188
 
52780
- return point.x < this.min.x || point.x > this.max.x ||
52781
- point.y < this.min.y || point.y > this.max.y ? false : true;
53189
+ return point.x >= this.min.x && point.x <= this.max.x &&
53190
+ point.y >= this.min.y && point.y <= this.max.y;
52782
53191
 
52783
53192
  }
52784
53193
 
@@ -52805,8 +53214,8 @@ class Box2 {
52805
53214
 
52806
53215
  // using 4 splitting planes to rule out intersections
52807
53216
 
52808
- return box.max.x < this.min.x || box.min.x > this.max.x ||
52809
- box.max.y < this.min.y || box.min.y > this.max.y ? false : true;
53217
+ return box.max.x >= this.min.x && box.min.x <= this.max.x &&
53218
+ box.max.y >= this.min.y && box.min.y <= this.max.y;
52810
53219
 
52811
53220
  }
52812
53221
 
@@ -54489,6 +54898,35 @@ class ShapePath {
54489
54898
 
54490
54899
  }
54491
54900
 
54901
+ class Controls extends EventDispatcher {
54902
+
54903
+ constructor( object, domElement ) {
54904
+
54905
+ super();
54906
+
54907
+ this.object = object;
54908
+ this.domElement = domElement;
54909
+
54910
+ this.enabled = true;
54911
+
54912
+ this.state = - 1;
54913
+
54914
+ this.keys = {};
54915
+ this.mouseButtons = { LEFT: null, MIDDLE: null, RIGHT: null };
54916
+ this.touches = { ONE: null, TWO: null };
54917
+
54918
+ }
54919
+
54920
+ connect() {}
54921
+
54922
+ disconnect() {}
54923
+
54924
+ dispose() {}
54925
+
54926
+ update( /* delta */ ) {}
54927
+
54928
+ }
54929
+
54492
54930
  class WebGLMultipleRenderTargets extends WebGLRenderTarget { // @deprecated, r162
54493
54931
 
54494
54932
  constructor( width = 1, height = 1, count = 1, options = {} ) {
@@ -54531,4 +54969,4 @@ if ( typeof window !== 'undefined' ) {
54531
54969
 
54532
54970
  }
54533
54971
 
54534
- export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BackSide, BasicDepthPacking, BasicShadowMap, BatchedMesh, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CineonToneMapping, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, ColorManagement, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, ConstantAlphaFactor, ConstantColorFactor, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry, Cylindrical, Data3DTexture, DataArrayTexture, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DisplayP3ColorSpace, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualCompare, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, FloatType, Fog, FogExp2, FramebufferTexture, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearDisplayP3ColorSpace, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry, OneFactor, OneMinusConstantAlphaFactor, OneMinusConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, P3Primaries, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, Path, PerspectiveCamera, Plane, PlaneGeometry, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBFormat, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, Rec709Primaries, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RenderTarget, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, Scene, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry, Texture, TextureLoader, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, VideoTexture, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLRenderTarget, WebGLRenderer, WebGLUtils, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, createCanvasElement };
54972
+ export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BackSide, BasicDepthPacking, BasicShadowMap, BatchedMesh, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CineonToneMapping, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, ColorManagement, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, ConstantAlphaFactor, ConstantColorFactor, Controls, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry, Cylindrical, Data3DTexture, DataArrayTexture, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DisplayP3ColorSpace, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualCompare, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, FloatType, Fog, FogExp2, FramebufferTexture, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearDisplayP3ColorSpace, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils, Matrix2, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry, OneFactor, OneMinusConstantAlphaFactor, OneMinusConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, P3Primaries, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, Path, PerspectiveCamera, Plane, PlaneGeometry, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBDepthPacking, RGBFormat, RGBIntegerFormat, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGDepthPacking, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, Rec709Primaries, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RenderTarget, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, Scene, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry, Texture, TextureLoader, TextureUtils, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, VideoTexture, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLRenderTarget, WebGLRenderer, WebGLUtils, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, createCanvasElement };