super-three 0.167.0 → 0.169.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 (387) hide show
  1. package/build/three.cjs +532 -173
  2. package/build/three.module.js +532 -174
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +18173 -14266
  5. package/build/three.webgpu.min.js +1 -1
  6. package/build/three.webgpu.nodes.js +79941 -0
  7. package/build/three.webgpu.nodes.min.js +6 -0
  8. package/examples/jsm/Addons.js +0 -4
  9. package/examples/jsm/animation/AnimationClipCreator.js +1 -1
  10. package/examples/jsm/capabilities/WebGL.js +27 -21
  11. package/examples/jsm/controls/ArcballControls.js +174 -158
  12. package/examples/jsm/controls/DragControls.js +260 -132
  13. package/examples/jsm/controls/FirstPersonControls.js +175 -163
  14. package/examples/jsm/controls/FlyControls.js +194 -188
  15. package/examples/jsm/controls/OrbitControls.js +777 -786
  16. package/examples/jsm/controls/PointerLockControls.js +24 -15
  17. package/examples/jsm/controls/TrackballControls.js +469 -448
  18. package/examples/jsm/controls/TransformControls.js +97 -62
  19. package/examples/jsm/effects/AnaglyphEffect.js +6 -13
  20. package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
  21. package/examples/jsm/effects/StereoEffect.js +6 -1
  22. package/examples/jsm/environments/RoomEnvironment.js +1 -1
  23. package/examples/jsm/exporters/DRACOExporter.js +4 -2
  24. package/examples/jsm/exporters/EXRExporter.js +19 -11
  25. package/examples/jsm/exporters/GLTFExporter.js +6 -1
  26. package/examples/jsm/exporters/KTX2Exporter.js +21 -13
  27. package/examples/jsm/exporters/OBJExporter.js +5 -1
  28. package/examples/jsm/exporters/PLYExporter.js +9 -7
  29. package/examples/jsm/exporters/USDZExporter.js +29 -8
  30. package/examples/jsm/geometries/DecalGeometry.js +4 -1
  31. package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
  32. package/examples/jsm/helpers/LightProbeHelper.js +43 -44
  33. package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
  34. package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
  35. package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
  36. package/examples/jsm/libs/ktx-parse.module.js +1 -1
  37. package/examples/jsm/lights/LightProbeGenerator.js +24 -10
  38. package/examples/jsm/loaders/ColladaLoader.js +9 -6
  39. package/examples/jsm/loaders/DRACOLoader.js +3 -1
  40. package/examples/jsm/loaders/FBXLoader.js +30 -20
  41. package/examples/jsm/loaders/GLTFLoader.js +5 -10
  42. package/examples/jsm/loaders/KTX2Loader.js +27 -12
  43. package/examples/jsm/loaders/MTLLoader.js +4 -3
  44. package/examples/jsm/loaders/MaterialXLoader.js +40 -14
  45. package/examples/jsm/loaders/OBJLoader.js +5 -3
  46. package/examples/jsm/loaders/PCDLoader.js +14 -13
  47. package/examples/jsm/loaders/PDBLoader.js +3 -2
  48. package/examples/jsm/loaders/PLYLoader.js +8 -5
  49. package/examples/jsm/loaders/STLLoader.js +3 -2
  50. package/examples/jsm/loaders/VRMLLoader.js +10 -10
  51. package/examples/jsm/loaders/VTKLoader.js +4 -3
  52. package/examples/jsm/loaders/XYZLoader.js +3 -2
  53. package/examples/jsm/misc/Timer.js +1 -1
  54. package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
  55. package/examples/jsm/objects/LensflareMesh.js +322 -0
  56. package/examples/jsm/objects/SkyMesh.js +187 -0
  57. package/examples/jsm/objects/Water2Mesh.js +158 -0
  58. package/examples/jsm/objects/WaterMesh.js +101 -0
  59. package/examples/jsm/physics/JoltPhysics.js +1 -1
  60. package/examples/jsm/physics/RapierPhysics.js +21 -1
  61. package/examples/jsm/postprocessing/OutlinePass.js +31 -46
  62. package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
  63. package/examples/jsm/shaders/BleachBypassShader.js +1 -2
  64. package/examples/jsm/shaders/OutputShader.js +1 -1
  65. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  66. package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
  67. package/examples/jsm/transpiler/TSLEncoder.js +8 -8
  68. package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
  69. package/examples/jsm/utils/ShadowMapViewer.js +3 -8
  70. package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
  71. package/examples/jsm/utils/SkeletonUtils.js +84 -66
  72. package/examples/jsm/utils/TextureUtils.js +2 -1
  73. package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
  74. package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
  75. package/package.json +3 -2
  76. package/src/Three.WebGPU.Nodes.js +200 -0
  77. package/src/Three.WebGPU.js +7 -0
  78. package/src/Three.js +1 -0
  79. package/src/audio/Audio.js +2 -2
  80. package/src/constants.js +1 -1
  81. package/src/core/BufferAttribute.js +0 -9
  82. package/src/core/Clock.js +1 -1
  83. package/src/core/InterleavedBuffer.js +0 -9
  84. package/src/extras/Controls.js +32 -0
  85. package/src/geometries/CylinderGeometry.js +11 -4
  86. package/src/loaders/MaterialLoader.js +7 -1
  87. package/src/loaders/ObjectLoader.js +3 -3
  88. package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +25 -5
  89. package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +21 -18
  90. package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +19 -0
  91. package/src/materials/Material.js +4 -7
  92. package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
  93. package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +56 -59
  94. package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +8 -5
  95. package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +12 -10
  96. package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +16 -12
  97. package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +10 -6
  98. package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +13 -9
  99. package/src/{nodes/materials → materials/nodes}/MeshNormalNodeMaterial.js +13 -9
  100. package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +14 -9
  101. package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +22 -18
  102. package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +10 -7
  103. package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +22 -12
  104. package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +9 -5
  105. package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +71 -115
  106. package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +3 -1
  107. package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +8 -5
  108. package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +9 -5
  109. package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +47 -14
  110. package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +24 -22
  111. package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
  112. package/src/math/Triangle.js +24 -0
  113. package/src/nodes/Nodes.js +103 -159
  114. package/src/nodes/TSL.js +179 -0
  115. package/src/nodes/accessors/AccessorsUtils.js +8 -8
  116. package/src/nodes/accessors/BatchNode.js +53 -21
  117. package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
  118. package/src/nodes/accessors/BufferAttributeNode.js +8 -5
  119. package/src/nodes/accessors/BufferNode.js +7 -4
  120. package/src/nodes/accessors/Camera.js +13 -0
  121. package/src/nodes/accessors/ClippingNode.js +19 -13
  122. package/src/nodes/accessors/CubeTextureNode.js +9 -8
  123. package/src/nodes/accessors/InstanceNode.js +19 -15
  124. package/src/nodes/accessors/InstancedPointsMaterialNode.js +8 -5
  125. package/src/nodes/accessors/Lights.js +51 -0
  126. package/src/nodes/accessors/MaterialNode.js +56 -55
  127. package/src/nodes/accessors/MaterialProperties.js +3 -0
  128. package/src/nodes/accessors/MaterialReferenceNode.js +9 -4
  129. package/src/nodes/accessors/ModelNode.js +47 -12
  130. package/src/nodes/accessors/ModelViewProjectionNode.js +12 -9
  131. package/src/nodes/accessors/MorphNode.js +17 -13
  132. package/src/nodes/accessors/Normal.js +88 -0
  133. package/src/nodes/accessors/Object3DNode.js +17 -33
  134. package/src/nodes/accessors/PointUVNode.js +9 -5
  135. package/src/nodes/accessors/Position.js +10 -0
  136. package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
  137. package/src/nodes/accessors/ReferenceNode.js +50 -7
  138. package/src/nodes/accessors/ReflectVector.js +10 -0
  139. package/src/nodes/accessors/RendererReferenceNode.js +12 -6
  140. package/src/nodes/accessors/SceneNode.js +9 -6
  141. package/src/nodes/accessors/SkinningNode.js +88 -21
  142. package/src/nodes/accessors/StorageBufferNode.js +22 -5
  143. package/src/nodes/accessors/StorageTextureNode.js +9 -6
  144. package/src/nodes/accessors/Tangent.js +22 -0
  145. package/src/nodes/accessors/Texture3DNode.js +16 -13
  146. package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
  147. package/src/nodes/accessors/TextureNode.js +29 -23
  148. package/src/nodes/accessors/TextureSizeNode.js +10 -9
  149. package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +26 -14
  150. package/src/nodes/accessors/UserDataNode.js +10 -7
  151. package/src/nodes/accessors/VelocityNode.js +134 -0
  152. package/src/nodes/accessors/VertexColorNode.js +7 -4
  153. package/src/nodes/code/CodeNode.js +9 -5
  154. package/src/nodes/code/ExpressionNode.js +10 -6
  155. package/src/nodes/code/FunctionCallNode.js +8 -5
  156. package/src/nodes/code/FunctionNode.js +8 -23
  157. package/src/nodes/code/ScriptableNode.js +13 -10
  158. package/src/nodes/code/ScriptableValueNode.js +9 -7
  159. package/src/nodes/core/AssignNode.js +12 -9
  160. package/src/nodes/core/AttributeNode.js +12 -21
  161. package/src/nodes/core/BypassNode.js +11 -7
  162. package/src/nodes/core/CacheNode.js +10 -6
  163. package/src/nodes/core/ConstNode.js +6 -3
  164. package/src/nodes/core/ContextNode.js +21 -11
  165. package/src/nodes/core/IndexNode.js +35 -8
  166. package/src/nodes/core/InputNode.js +7 -3
  167. package/src/nodes/core/MRTNode.js +16 -7
  168. package/src/nodes/core/Node.js +19 -40
  169. package/src/nodes/core/NodeBuilder.js +117 -38
  170. package/src/nodes/core/NodeUtils.js +49 -6
  171. package/src/nodes/core/OutputStructNode.js +10 -6
  172. package/src/nodes/core/ParameterNode.js +7 -4
  173. package/src/nodes/core/PropertyNode.js +36 -32
  174. package/src/nodes/core/StackNode.js +31 -11
  175. package/src/nodes/core/StructTypeNode.js +7 -3
  176. package/src/nodes/core/TempNode.js +8 -4
  177. package/src/nodes/core/UniformGroupNode.js +14 -11
  178. package/src/nodes/core/UniformNode.js +7 -4
  179. package/src/nodes/core/VarNode.js +12 -8
  180. package/src/nodes/core/VaryingNode.js +10 -6
  181. package/src/nodes/display/AfterImageNode.js +15 -9
  182. package/src/nodes/display/AnaglyphPassNode.js +67 -0
  183. package/src/nodes/display/AnamorphicNode.js +17 -11
  184. package/src/nodes/display/BleachBypass.js +26 -0
  185. package/src/nodes/display/BlendMode.js +54 -0
  186. package/src/nodes/display/BloomNode.js +27 -19
  187. package/src/nodes/display/BumpMapNode.js +13 -12
  188. package/src/nodes/display/ColorAdjustment.js +46 -0
  189. package/src/nodes/display/ColorSpaceFunctions.js +38 -0
  190. package/src/nodes/display/ColorSpaceNode.js +67 -61
  191. package/src/nodes/display/DenoiseNode.js +23 -17
  192. package/src/nodes/display/DepthOfFieldNode.js +12 -7
  193. package/src/nodes/display/DotScreenNode.js +13 -22
  194. package/src/nodes/display/FXAANode.js +21 -16
  195. package/src/nodes/display/FilmNode.js +11 -7
  196. package/src/nodes/display/FrontFacingNode.js +10 -6
  197. package/src/nodes/display/GTAONode.js +22 -15
  198. package/src/nodes/display/GaussianBlurNode.js +14 -8
  199. package/src/nodes/display/Lut3DNode.js +10 -6
  200. package/src/nodes/display/MotionBlur.js +25 -0
  201. package/src/nodes/display/NormalMapNode.js +13 -13
  202. package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
  203. package/src/nodes/display/PassNode.js +95 -8
  204. package/src/nodes/display/PixelationPassNode.js +20 -8
  205. package/src/nodes/display/PosterizeNode.js +8 -7
  206. package/src/nodes/display/RGBShiftNode.js +11 -7
  207. package/src/nodes/display/RenderOutputNode.js +15 -11
  208. package/src/nodes/display/SSAAPassNode.js +287 -0
  209. package/src/nodes/display/ScreenNode.js +181 -0
  210. package/src/nodes/display/Sepia.js +17 -0
  211. package/src/nodes/display/SobelOperatorNode.js +13 -8
  212. package/src/nodes/display/StereoCompositePassNode.js +110 -0
  213. package/src/nodes/display/StereoPassNode.js +83 -0
  214. package/src/nodes/display/ToneMappingFunctions.js +190 -0
  215. package/src/nodes/display/ToneMappingNode.js +15 -175
  216. package/src/nodes/display/ToonOutlinePassNode.js +111 -0
  217. package/src/nodes/display/TransitionNode.js +12 -8
  218. package/src/nodes/display/ViewportDepthNode.js +34 -29
  219. package/src/nodes/display/ViewportDepthTextureNode.js +10 -9
  220. package/src/nodes/display/ViewportSharedTextureNode.js +10 -9
  221. package/src/nodes/display/ViewportTextureNode.js +11 -11
  222. package/src/nodes/fog/FogExp2Node.js +8 -7
  223. package/src/nodes/fog/FogNode.js +10 -8
  224. package/src/nodes/fog/FogRangeNode.js +8 -7
  225. package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
  226. package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  227. package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
  228. package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
  229. package/src/nodes/functions/BSDF/D_GGX.js +2 -2
  230. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
  231. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
  232. package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
  233. package/src/nodes/functions/BSDF/LTC.js +6 -6
  234. package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
  235. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
  236. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
  237. package/src/nodes/functions/BasicLightingModel.js +1 -1
  238. package/src/nodes/functions/PhongLightingModel.js +5 -5
  239. package/src/nodes/functions/PhysicalLightingModel.js +34 -33
  240. package/src/nodes/functions/ShadowMaskModel.js +1 -1
  241. package/src/nodes/functions/ToonLightingModel.js +3 -3
  242. package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
  243. package/src/nodes/functions/material/getRoughness.js +2 -2
  244. package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
  245. package/src/nodes/geometry/RangeNode.js +9 -5
  246. package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
  247. package/src/nodes/gpgpu/BarrierNode.js +40 -0
  248. package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
  249. package/src/nodes/gpgpu/ComputeNode.js +10 -6
  250. package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
  251. package/src/nodes/lighting/AONode.js +6 -3
  252. package/src/nodes/lighting/AmbientLightNode.js +6 -8
  253. package/src/nodes/lighting/AnalyticLightNode.js +225 -36
  254. package/src/nodes/lighting/BasicEnvironmentNode.js +8 -4
  255. package/src/nodes/lighting/BasicLightMapNode.js +7 -4
  256. package/src/nodes/lighting/DirectionalLightNode.js +7 -9
  257. package/src/nodes/lighting/EnvironmentNode.js +23 -19
  258. package/src/nodes/lighting/HemisphereLightNode.js +11 -11
  259. package/src/nodes/lighting/IESSpotLightNode.js +7 -9
  260. package/src/nodes/lighting/IrradianceNode.js +6 -3
  261. package/src/nodes/lighting/LightProbeNode.js +53 -0
  262. package/src/nodes/lighting/LightUtils.js +3 -3
  263. package/src/nodes/lighting/LightingContextNode.js +19 -18
  264. package/src/nodes/lighting/LightingNode.js +7 -3
  265. package/src/nodes/lighting/LightsNode.js +112 -75
  266. package/src/nodes/lighting/PointLightNode.js +12 -13
  267. package/src/nodes/lighting/RectAreaLightNode.js +11 -11
  268. package/src/nodes/lighting/SpotLightNode.js +14 -16
  269. package/src/nodes/materialx/MaterialXNodes.js +2 -2
  270. package/src/nodes/materialx/lib/mx_hsv.js +36 -31
  271. package/src/nodes/materialx/lib/mx_noise.js +96 -96
  272. package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
  273. package/src/nodes/math/{CondNode.js → ConditionalNode.js} +38 -10
  274. package/src/nodes/math/Hash.js +13 -0
  275. package/src/nodes/math/MathNode.js +127 -124
  276. package/src/nodes/math/MathUtils.js +0 -7
  277. package/src/nodes/math/OperatorNode.js +97 -52
  278. package/src/nodes/math/TriNoise3D.js +19 -29
  279. package/src/nodes/pmrem/PMREMNode.js +61 -15
  280. package/src/nodes/pmrem/PMREMUtils.js +46 -46
  281. package/src/nodes/procedural/Checker.js +14 -0
  282. package/src/nodes/tsl/TSLBase.js +30 -0
  283. package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
  284. package/src/nodes/utils/ArrayElementNode.js +8 -4
  285. package/src/nodes/utils/ConvertNode.js +7 -3
  286. package/src/nodes/utils/CubeMapNode.js +160 -0
  287. package/src/nodes/utils/Discard.js +8 -0
  288. package/src/nodes/utils/EquirectUVNode.js +9 -6
  289. package/src/nodes/utils/FlipNode.js +68 -0
  290. package/src/nodes/utils/FunctionOverloadingNode.js +9 -5
  291. package/src/nodes/utils/JoinNode.js +6 -3
  292. package/src/nodes/utils/LoopNode.js +16 -6
  293. package/src/nodes/utils/MatcapUVNode.js +10 -7
  294. package/src/nodes/utils/MaxMipLevelNode.js +8 -5
  295. package/src/nodes/utils/OscNode.js +12 -8
  296. package/src/nodes/utils/Packing.js +4 -0
  297. package/src/nodes/utils/RTTNode.js +11 -8
  298. package/src/nodes/utils/ReflectorNode.js +12 -4
  299. package/src/nodes/utils/RemapNode.js +12 -8
  300. package/src/nodes/utils/RotateNode.js +8 -13
  301. package/src/nodes/utils/SetNode.js +7 -4
  302. package/src/nodes/utils/SplitNode.js +7 -3
  303. package/src/nodes/utils/SpriteSheetUVNode.js +10 -6
  304. package/src/nodes/utils/SpriteUtils.js +47 -0
  305. package/src/nodes/utils/StorageArrayElementNode.js +11 -12
  306. package/src/nodes/utils/TimerNode.js +8 -5
  307. package/src/nodes/utils/TriplanarTexturesNode.js +11 -9
  308. package/src/nodes/utils/UVUtils.js +19 -0
  309. package/src/nodes/utils/ViewportUtils.js +14 -0
  310. package/src/objects/BatchedMesh.js +78 -13
  311. package/src/objects/LOD.js +21 -0
  312. package/src/objects/Line.js +1 -0
  313. package/src/objects/Mesh.js +7 -23
  314. package/src/objects/Points.js +2 -0
  315. package/src/renderers/WebGLRenderer.js +88 -41
  316. package/src/renderers/common/Backend.js +2 -2
  317. package/src/renderers/common/Background.js +3 -1
  318. package/src/renderers/common/BindGroup.js +3 -1
  319. package/src/renderers/common/Bindings.js +13 -15
  320. package/src/renderers/common/BundleGroup.js +26 -0
  321. package/src/renderers/common/ClippingContext.js +15 -5
  322. package/src/renderers/common/CubeRenderTarget.js +9 -3
  323. package/src/renderers/common/PostProcessing.js +4 -1
  324. package/src/renderers/common/QuadMesh.js +2 -0
  325. package/src/renderers/common/RenderContext.js +23 -0
  326. package/src/renderers/common/RenderList.js +1 -1
  327. package/src/renderers/common/RenderObject.js +117 -6
  328. package/src/renderers/common/RenderObjects.js +8 -1
  329. package/src/renderers/common/Renderer.js +128 -94
  330. package/src/renderers/common/SampledTexture.js +12 -3
  331. package/src/renderers/common/Textures.js +8 -12
  332. package/src/renderers/common/extras/PMREMGenerator.js +19 -22
  333. package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
  334. package/src/renderers/common/nodes/NodeLibrary.js +118 -0
  335. package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
  336. package/src/renderers/common/nodes/Nodes.js +65 -19
  337. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
  338. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
  339. package/src/renderers/webgl/WebGLAttributes.js +45 -14
  340. package/src/renderers/webgl/WebGLCapabilities.js +9 -0
  341. package/src/renderers/webgl/WebGLProgram.js +3 -1
  342. package/src/renderers/webgl/WebGLPrograms.js +21 -17
  343. package/src/renderers/webgl/WebGLProperties.js +7 -0
  344. package/src/renderers/webgl/WebGLState.js +21 -0
  345. package/src/renderers/webgl/WebGLTextures.js +83 -4
  346. package/src/renderers/webgl-fallback/WebGLBackend.js +135 -110
  347. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +60 -12
  348. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
  349. package/src/renderers/webgl-fallback/utils/WebGLState.js +20 -2
  350. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +89 -37
  351. package/src/renderers/webgpu/WebGPUBackend.js +112 -86
  352. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
  353. package/src/renderers/webgpu/WebGPURenderer.js +9 -6
  354. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
  355. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
  356. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +189 -73
  357. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
  358. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
  359. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
  360. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +7 -16
  361. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
  362. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +43 -26
  363. package/src/renderers/webgpu/utils/WebGPUUtils.js +19 -2
  364. package/src/renderers/webxr/WebXRManager.js +32 -25
  365. package/src/utils.js +33 -1
  366. package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
  367. package/examples/jsm/loaders/LogLuvLoader.js +0 -606
  368. package/examples/jsm/loaders/TiltLoader.js +0 -520
  369. package/examples/jsm/utils/GPUStatsPanel.js +0 -95
  370. package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
  371. package/src/nodes/accessors/CameraNode.js +0 -19
  372. package/src/nodes/accessors/NormalNode.js +0 -14
  373. package/src/nodes/accessors/PositionNode.js +0 -10
  374. package/src/nodes/accessors/ReflectVectorNode.js +0 -10
  375. package/src/nodes/accessors/TangentNode.js +0 -23
  376. package/src/nodes/core/NodeKeywords.js +0 -80
  377. package/src/nodes/display/BlendModeNode.js +0 -128
  378. package/src/nodes/display/ColorAdjustmentNode.js +0 -104
  379. package/src/nodes/display/ViewportNode.js +0 -137
  380. package/src/nodes/lighting/LightNode.js +0 -57
  381. package/src/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
  382. package/src/nodes/math/HashNode.js +0 -34
  383. package/src/nodes/procedural/CheckerNode.js +0 -42
  384. package/src/nodes/utils/DiscardNode.js +0 -28
  385. package/src/nodes/utils/PackingNode.js +0 -55
  386. package/src/nodes/utils/RotateUVNode.js +0 -35
  387. /package/src/nodes/accessors/{UVNode.js → UV.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 = '167';
6
+ const REVISION = '169';
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 };
@@ -1592,6 +1592,38 @@ function probeAsync( gl, sync, interval ) {
1592
1592
 
1593
1593
  }
1594
1594
 
1595
+ function toNormalizedProjectionMatrix( projectionMatrix ) {
1596
+
1597
+ const m = projectionMatrix.elements;
1598
+
1599
+ // Convert [-1, 1] to [0, 1] projection matrix
1600
+ m[ 2 ] = 0.5 * m[ 2 ] + 0.5 * m[ 3 ];
1601
+ m[ 6 ] = 0.5 * m[ 6 ] + 0.5 * m[ 7 ];
1602
+ m[ 10 ] = 0.5 * m[ 10 ] + 0.5 * m[ 11 ];
1603
+ m[ 14 ] = 0.5 * m[ 14 ] + 0.5 * m[ 15 ];
1604
+
1605
+ }
1606
+
1607
+ function toReversedProjectionMatrix( projectionMatrix ) {
1608
+
1609
+ const m = projectionMatrix.elements;
1610
+ const isPerspectiveMatrix = m[ 11 ] === - 1;
1611
+
1612
+ // Reverse [0, 1] projection matrix
1613
+ if ( isPerspectiveMatrix ) {
1614
+
1615
+ m[ 10 ] = - m[ 10 ] - 1;
1616
+ m[ 14 ] = - m[ 14 ];
1617
+
1618
+ } else {
1619
+
1620
+ m[ 10 ] = - m[ 10 ];
1621
+ m[ 14 ] = - m[ 14 ] + 1;
1622
+
1623
+ }
1624
+
1625
+ }
1626
+
1595
1627
  /**
1596
1628
  * Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
1597
1629
  * or clipping. Based on W3C specifications for sRGB and Display P3,
@@ -8187,6 +8219,10 @@ const _vap = /*@__PURE__*/ new Vector3();
8187
8219
  const _vbp = /*@__PURE__*/ new Vector3();
8188
8220
  const _vcp = /*@__PURE__*/ new Vector3();
8189
8221
 
8222
+ const _v40 = /*@__PURE__*/ new Vector4();
8223
+ const _v41 = /*@__PURE__*/ new Vector4();
8224
+ const _v42 = /*@__PURE__*/ new Vector4();
8225
+
8190
8226
  class Triangle {
8191
8227
 
8192
8228
  constructor( a = new Vector3(), b = new Vector3(), c = new Vector3() ) {
@@ -8281,6 +8317,25 @@ class Triangle {
8281
8317
 
8282
8318
  }
8283
8319
 
8320
+ static getInterpolatedAttribute( attr, i1, i2, i3, barycoord, target ) {
8321
+
8322
+ _v40.setScalar( 0 );
8323
+ _v41.setScalar( 0 );
8324
+ _v42.setScalar( 0 );
8325
+
8326
+ _v40.fromBufferAttribute( attr, i1 );
8327
+ _v41.fromBufferAttribute( attr, i2 );
8328
+ _v42.fromBufferAttribute( attr, i3 );
8329
+
8330
+ target.setScalar( 0 );
8331
+ target.addScaledVector( _v40, barycoord.x );
8332
+ target.addScaledVector( _v41, barycoord.y );
8333
+ target.addScaledVector( _v42, barycoord.z );
8334
+
8335
+ return target;
8336
+
8337
+ }
8338
+
8284
8339
  static isFrontFacing( a, b, c, direction ) {
8285
8340
 
8286
8341
  _v0$2.subVectors( c, b );
@@ -9198,6 +9253,10 @@ class Material extends EventDispatcher {
9198
9253
 
9199
9254
  }
9200
9255
 
9256
+ // onBeforeRender and onBeforeCompile only supported in WebGLRenderer
9257
+
9258
+ onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {}
9259
+
9201
9260
  onBeforeCompile( /* shaderobject, renderer */ ) {}
9202
9261
 
9203
9262
  customProgramCacheKey() {
@@ -9620,13 +9679,6 @@ class Material extends EventDispatcher {
9620
9679
 
9621
9680
  }
9622
9681
 
9623
- onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {
9624
-
9625
- console.warn( 'Material: onBeforeRender() has been removed.' ); // @deprecated, r166
9626
-
9627
- }
9628
-
9629
-
9630
9682
  }
9631
9683
 
9632
9684
  class MeshBasicMaterial extends Material {
@@ -9899,7 +9951,6 @@ class BufferAttribute {
9899
9951
  this.normalized = normalized;
9900
9952
 
9901
9953
  this.usage = StaticDrawUsage;
9902
- this._updateRange = { offset: 0, count: - 1 };
9903
9954
  this.updateRanges = [];
9904
9955
  this.gpuType = FloatType;
9905
9956
 
@@ -9915,13 +9966,6 @@ class BufferAttribute {
9915
9966
 
9916
9967
  }
9917
9968
 
9918
- get updateRange() {
9919
-
9920
- warnOnce( 'THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.' ); // @deprecated, r159
9921
- return this._updateRange;
9922
-
9923
- }
9924
-
9925
9969
  setUsage( value ) {
9926
9970
 
9927
9971
  this.usage = value;
@@ -11566,14 +11610,6 @@ const _vC$1 = /*@__PURE__*/ new Vector3();
11566
11610
  const _tempA = /*@__PURE__*/ new Vector3();
11567
11611
  const _morphA = /*@__PURE__*/ new Vector3();
11568
11612
 
11569
- const _uvA$1 = /*@__PURE__*/ new Vector2();
11570
- const _uvB$1 = /*@__PURE__*/ new Vector2();
11571
- const _uvC$1 = /*@__PURE__*/ new Vector2();
11572
-
11573
- const _normalA = /*@__PURE__*/ new Vector3();
11574
- const _normalB = /*@__PURE__*/ new Vector3();
11575
- const _normalC = /*@__PURE__*/ new Vector3();
11576
-
11577
11613
  const _intersectionPoint = /*@__PURE__*/ new Vector3();
11578
11614
  const _intersectionPointWorld = /*@__PURE__*/ new Vector3();
11579
11615
 
@@ -11916,33 +11952,24 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
11916
11952
 
11917
11953
  if ( intersection ) {
11918
11954
 
11919
- if ( uv ) {
11955
+ const barycoord = new Vector3();
11956
+ Triangle.getBarycoord( _intersectionPoint, _vA$1, _vB$1, _vC$1, barycoord );
11920
11957
 
11921
- _uvA$1.fromBufferAttribute( uv, a );
11922
- _uvB$1.fromBufferAttribute( uv, b );
11923
- _uvC$1.fromBufferAttribute( uv, c );
11958
+ if ( uv ) {
11924
11959
 
11925
- intersection.uv = Triangle.getInterpolation( _intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() );
11960
+ intersection.uv = Triangle.getInterpolatedAttribute( uv, a, b, c, barycoord, new Vector2() );
11926
11961
 
11927
11962
  }
11928
11963
 
11929
11964
  if ( uv1 ) {
11930
11965
 
11931
- _uvA$1.fromBufferAttribute( uv1, a );
11932
- _uvB$1.fromBufferAttribute( uv1, b );
11933
- _uvC$1.fromBufferAttribute( uv1, c );
11934
-
11935
- intersection.uv1 = Triangle.getInterpolation( _intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() );
11966
+ intersection.uv1 = Triangle.getInterpolatedAttribute( uv1, a, b, c, barycoord, new Vector2() );
11936
11967
 
11937
11968
  }
11938
11969
 
11939
11970
  if ( normal ) {
11940
11971
 
11941
- _normalA.fromBufferAttribute( normal, a );
11942
- _normalB.fromBufferAttribute( normal, b );
11943
- _normalC.fromBufferAttribute( normal, c );
11944
-
11945
- intersection.normal = Triangle.getInterpolation( _intersectionPoint, _vA$1, _vB$1, _vC$1, _normalA, _normalB, _normalC, new Vector3() );
11972
+ intersection.normal = Triangle.getInterpolatedAttribute( normal, a, b, c, barycoord, new Vector3() );
11946
11973
 
11947
11974
  if ( intersection.normal.dot( ray.direction ) > 0 ) {
11948
11975
 
@@ -11963,6 +11990,7 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
11963
11990
  Triangle.getNormal( _vA$1, _vB$1, _vC$1, face.normal );
11964
11991
 
11965
11992
  intersection.face = face;
11993
+ intersection.barycoord = barycoord;
11966
11994
 
11967
11995
  }
11968
11996
 
@@ -13606,40 +13634,71 @@ function WebGLAttributes( gl ) {
13606
13634
  function updateBuffer( buffer, attribute, bufferType ) {
13607
13635
 
13608
13636
  const array = attribute.array;
13609
- const updateRange = attribute._updateRange; // @deprecated, r159
13610
13637
  const updateRanges = attribute.updateRanges;
13611
13638
 
13612
13639
  gl.bindBuffer( bufferType, buffer );
13613
13640
 
13614
- if ( updateRange.count === - 1 && updateRanges.length === 0 ) {
13641
+ if ( updateRanges.length === 0 ) {
13615
13642
 
13616
13643
  // Not using update ranges
13617
13644
  gl.bufferSubData( bufferType, 0, array );
13618
13645
 
13619
- }
13646
+ } else {
13620
13647
 
13621
- if ( updateRanges.length !== 0 ) {
13648
+ // Before applying update ranges, we merge any adjacent / overlapping
13649
+ // ranges to reduce load on `gl.bufferSubData`. Empirically, this has led
13650
+ // to performance improvements for applications which make heavy use of
13651
+ // update ranges. Likely due to GPU command overhead.
13652
+ //
13653
+ // Note that to reduce garbage collection between frames, we merge the
13654
+ // update ranges in-place. This is safe because this method will clear the
13655
+ // update ranges once updated.
13622
13656
 
13623
- for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
13657
+ updateRanges.sort( ( a, b ) => a.start - b.start );
13658
+
13659
+ // To merge the update ranges in-place, we work from left to right in the
13660
+ // existing updateRanges array, merging ranges. This may result in a final
13661
+ // array which is smaller than the original. This index tracks the last
13662
+ // index representing a merged range, any data after this index can be
13663
+ // trimmed once the merge algorithm is completed.
13664
+ let mergeIndex = 0;
13624
13665
 
13666
+ for ( let i = 1; i < updateRanges.length; i ++ ) {
13667
+
13668
+ const previousRange = updateRanges[ mergeIndex ];
13625
13669
  const range = updateRanges[ i ];
13626
13670
 
13627
- gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13628
- array, range.start, range.count );
13671
+ // We add one here to merge adjacent ranges. This is safe because ranges
13672
+ // operate over positive integers.
13673
+ if ( range.start <= previousRange.start + previousRange.count + 1 ) {
13674
+
13675
+ previousRange.count = Math.max(
13676
+ previousRange.count,
13677
+ range.start + range.count - previousRange.start
13678
+ );
13679
+
13680
+ } else {
13681
+
13682
+ ++ mergeIndex;
13683
+ updateRanges[ mergeIndex ] = range;
13684
+
13685
+ }
13629
13686
 
13630
13687
  }
13631
13688
 
13632
- attribute.clearUpdateRanges();
13689
+ // Trim the array to only contain the merged ranges.
13690
+ updateRanges.length = mergeIndex + 1;
13633
13691
 
13634
- }
13692
+ for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
13635
13693
 
13636
- // @deprecated, r159
13637
- if ( updateRange.count !== - 1 ) {
13694
+ const range = updateRanges[ i ];
13638
13695
 
13639
- gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
13640
- array, updateRange.offset, updateRange.count );
13696
+ gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13697
+ array, range.start, range.count );
13641
13698
 
13642
- updateRange.count = - 1; // reset range
13699
+ }
13700
+
13701
+ attribute.clearUpdateRanges();
13643
13702
 
13644
13703
  }
13645
13704
 
@@ -14022,7 +14081,7 @@ var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D spe
14022
14081
 
14023
14082
  var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
14024
14083
 
14025
- 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; }";
14084
+ 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; }";
14026
14085
 
14027
14086
  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";
14028
14087
 
@@ -14100,7 +14159,7 @@ const vertex$2 = "#include <common>\n#include <batching_pars_vertex>\n#include <
14100
14159
 
14101
14160
  const fragment$2 = "uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}";
14102
14161
 
14103
- const vertex$1 = "uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}";
14162
+ const vertex$1 = "uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}";
14104
14163
 
14105
14164
  const fragment$1 = "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\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 <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}";
14106
14165
 
@@ -15866,6 +15925,14 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
15866
15925
  }
15867
15926
 
15868
15927
  const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
15928
+ const reverseDepthBuffer = parameters.reverseDepthBuffer === true && extensions.has( 'EXT_clip_control' );
15929
+
15930
+ if ( reverseDepthBuffer === true ) {
15931
+
15932
+ const ext = extensions.get( 'EXT_clip_control' );
15933
+ ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.ZERO_TO_ONE_EXT );
15934
+
15935
+ }
15869
15936
 
15870
15937
  const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
15871
15938
  const maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
@@ -15893,6 +15960,7 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
15893
15960
 
15894
15961
  precision: precision,
15895
15962
  logarithmicDepthBuffer: logarithmicDepthBuffer,
15963
+ reverseDepthBuffer: reverseDepthBuffer,
15896
15964
 
15897
15965
  maxTextures: maxTextures,
15898
15966
  maxVertexTextures: maxVertexTextures,
@@ -19464,7 +19532,7 @@ function getToneMappingFunction( functionName, toneMapping ) {
19464
19532
  break;
19465
19533
 
19466
19534
  case CineonToneMapping:
19467
- toneMappingName = 'OptimizedCineon';
19535
+ toneMappingName = 'Cineon';
19468
19536
  break;
19469
19537
 
19470
19538
  case ACESFilmicToneMapping:
@@ -20009,6 +20077,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20009
20077
  parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
20010
20078
 
20011
20079
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
20080
+ parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
20012
20081
 
20013
20082
  'uniform mat4 modelMatrix;',
20014
20083
  'uniform mat4 modelViewMatrix;',
@@ -20174,6 +20243,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20174
20243
  parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
20175
20244
 
20176
20245
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
20246
+ parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
20177
20247
 
20178
20248
  'uniform mat4 viewMatrix;',
20179
20249
  'uniform vec3 cameraPosition;',
@@ -20614,6 +20684,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20614
20684
  const programs = [];
20615
20685
 
20616
20686
  const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
20687
+ const reverseDepthBuffer = capabilities.reverseDepthBuffer;
20617
20688
  const SUPPORTS_VERTEX_TEXTURES = capabilities.vertexTextures;
20618
20689
 
20619
20690
  let precision = capabilities.precision;
@@ -20908,6 +20979,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20908
20979
 
20909
20980
  sizeAttenuation: material.sizeAttenuation === true,
20910
20981
  logarithmicDepthBuffer: logarithmicDepthBuffer,
20982
+ reverseDepthBuffer: reverseDepthBuffer,
20911
20983
 
20912
20984
  skinning: object.isSkinnedMesh === true,
20913
20985
 
@@ -21127,40 +21199,42 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
21127
21199
  _programLayers.enable( 2 );
21128
21200
  if ( parameters.logarithmicDepthBuffer )
21129
21201
  _programLayers.enable( 3 );
21130
- if ( parameters.skinning )
21202
+ if ( parameters.reverseDepthBuffer )
21131
21203
  _programLayers.enable( 4 );
21132
- if ( parameters.morphTargets )
21204
+ if ( parameters.skinning )
21133
21205
  _programLayers.enable( 5 );
21134
- if ( parameters.morphNormals )
21206
+ if ( parameters.morphTargets )
21135
21207
  _programLayers.enable( 6 );
21136
- if ( parameters.morphColors )
21208
+ if ( parameters.morphNormals )
21137
21209
  _programLayers.enable( 7 );
21138
- if ( parameters.premultipliedAlpha )
21210
+ if ( parameters.morphColors )
21139
21211
  _programLayers.enable( 8 );
21140
- if ( parameters.shadowMapEnabled )
21212
+ if ( parameters.premultipliedAlpha )
21141
21213
  _programLayers.enable( 9 );
21142
- if ( parameters.doubleSided )
21214
+ if ( parameters.shadowMapEnabled )
21143
21215
  _programLayers.enable( 10 );
21144
- if ( parameters.flipSided )
21216
+ if ( parameters.doubleSided )
21145
21217
  _programLayers.enable( 11 );
21146
- if ( parameters.useDepthPacking )
21218
+ if ( parameters.flipSided )
21147
21219
  _programLayers.enable( 12 );
21148
- if ( parameters.dithering )
21220
+ if ( parameters.useDepthPacking )
21149
21221
  _programLayers.enable( 13 );
21150
- if ( parameters.transmission )
21222
+ if ( parameters.dithering )
21151
21223
  _programLayers.enable( 14 );
21152
- if ( parameters.sheen )
21224
+ if ( parameters.transmission )
21153
21225
  _programLayers.enable( 15 );
21154
- if ( parameters.opaque )
21226
+ if ( parameters.sheen )
21155
21227
  _programLayers.enable( 16 );
21156
- if ( parameters.pointsUvs )
21228
+ if ( parameters.opaque )
21157
21229
  _programLayers.enable( 17 );
21158
- if ( parameters.decodeVideoTexture )
21230
+ if ( parameters.pointsUvs )
21159
21231
  _programLayers.enable( 18 );
21160
- if ( parameters.alphaToCoverage )
21232
+ if ( parameters.decodeVideoTexture )
21161
21233
  _programLayers.enable( 19 );
21162
- if ( parameters.numMultiviewViews )
21234
+ if ( parameters.alphaToCoverage )
21163
21235
  _programLayers.enable( 20 );
21236
+ if ( parameters.numMultiviewViews )
21237
+ _programLayers.enable( 21 );
21164
21238
 
21165
21239
  array.push( _programLayers.mask );
21166
21240
 
@@ -21263,6 +21337,12 @@ function WebGLProperties() {
21263
21337
 
21264
21338
  let properties = new WeakMap();
21265
21339
 
21340
+ function has( object ) {
21341
+
21342
+ return properties.has( object );
21343
+
21344
+ }
21345
+
21266
21346
  function get( object ) {
21267
21347
 
21268
21348
  let map = properties.get( object );
@@ -21297,6 +21377,7 @@ function WebGLProperties() {
21297
21377
  }
21298
21378
 
21299
21379
  return {
21380
+ has: has,
21300
21381
  get: get,
21301
21382
  remove: remove,
21302
21383
  update: update,
@@ -22711,6 +22792,18 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
22711
22792
 
22712
22793
  }
22713
22794
 
22795
+ const reversedFuncs = {
22796
+ [ NeverDepth ]: AlwaysDepth,
22797
+ [ LessDepth ]: GreaterDepth,
22798
+ [ EqualDepth ]: NotEqualDepth,
22799
+ [ LessEqualDepth ]: GreaterEqualDepth,
22800
+
22801
+ [ AlwaysDepth ]: NeverDepth,
22802
+ [ GreaterDepth ]: LessDepth,
22803
+ [ NotEqualDepth ]: EqualDepth,
22804
+ [ GreaterEqualDepth ]: LessEqualDepth,
22805
+ };
22806
+
22714
22807
  function WebGLState( gl ) {
22715
22808
 
22716
22809
  function ColorBuffer() {
@@ -22775,6 +22868,7 @@ function WebGLState( gl ) {
22775
22868
  function DepthBuffer() {
22776
22869
 
22777
22870
  let locked = false;
22871
+ let reversed = false;
22778
22872
 
22779
22873
  let currentDepthMask = null;
22780
22874
  let currentDepthFunc = null;
@@ -22782,6 +22876,12 @@ function WebGLState( gl ) {
22782
22876
 
22783
22877
  return {
22784
22878
 
22879
+ setReversed: function ( value ) {
22880
+
22881
+ reversed = value;
22882
+
22883
+ },
22884
+
22785
22885
  setTest: function ( depthTest ) {
22786
22886
 
22787
22887
  if ( depthTest ) {
@@ -22809,6 +22909,8 @@ function WebGLState( gl ) {
22809
22909
 
22810
22910
  setFunc: function ( depthFunc ) {
22811
22911
 
22912
+ if ( reversed ) depthFunc = reversedFuncs[ depthFunc ];
22913
+
22812
22914
  if ( currentDepthFunc !== depthFunc ) {
22813
22915
 
22814
22916
  switch ( depthFunc ) {
@@ -24354,6 +24456,28 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24354
24456
 
24355
24457
  }
24356
24458
 
24459
+ if ( glFormat === _gl.RGB_INTEGER ) {
24460
+
24461
+ if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGB8UI;
24462
+ if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RGB16UI;
24463
+ if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RGB32UI;
24464
+ if ( glType === _gl.BYTE ) internalFormat = _gl.RGB8I;
24465
+ if ( glType === _gl.SHORT ) internalFormat = _gl.RGB16I;
24466
+ if ( glType === _gl.INT ) internalFormat = _gl.RGB32I;
24467
+
24468
+ }
24469
+
24470
+ if ( glFormat === _gl.RGBA_INTEGER ) {
24471
+
24472
+ if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGBA8UI;
24473
+ if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RGBA16UI;
24474
+ if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RGBA32UI;
24475
+ if ( glType === _gl.BYTE ) internalFormat = _gl.RGBA8I;
24476
+ if ( glType === _gl.SHORT ) internalFormat = _gl.RGBA16I;
24477
+ if ( glType === _gl.INT ) internalFormat = _gl.RGBA32I;
24478
+
24479
+ }
24480
+
24357
24481
  if ( glFormat === _gl.RGB ) {
24358
24482
 
24359
24483
  if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
@@ -25905,6 +26029,37 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25905
26029
  const renderTargetProperties = properties.get( renderTarget );
25906
26030
  const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
25907
26031
 
26032
+ // if the bound depth texture has changed
26033
+ if ( renderTargetProperties.__boundDepthTexture !== renderTarget.depthTexture ) {
26034
+
26035
+ // fire the dispose event to get rid of stored state associated with the previously bound depth buffer
26036
+ const depthTexture = renderTarget.depthTexture;
26037
+ if ( renderTargetProperties.__depthDisposeCallback ) {
26038
+
26039
+ renderTargetProperties.__depthDisposeCallback();
26040
+
26041
+ }
26042
+
26043
+ // set up dispose listeners to track when the currently attached buffer is implicitly unbound
26044
+ if ( depthTexture ) {
26045
+
26046
+ const disposeEvent = () => {
26047
+
26048
+ delete renderTargetProperties.__boundDepthTexture;
26049
+ delete renderTargetProperties.__depthDisposeCallback;
26050
+ depthTexture.removeEventListener( 'dispose', disposeEvent );
26051
+
26052
+ };
26053
+
26054
+ depthTexture.addEventListener( 'dispose', disposeEvent );
26055
+ renderTargetProperties.__depthDisposeCallback = disposeEvent;
26056
+
26057
+ }
26058
+
26059
+ renderTargetProperties.__boundDepthTexture = depthTexture;
26060
+
26061
+ }
26062
+
25908
26063
  if ( renderTarget.depthTexture && ! renderTargetProperties.__autoAllocateDepthBuffer ) {
25909
26064
 
25910
26065
  if ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );
@@ -25920,16 +26075,42 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25920
26075
  for ( let i = 0; i < 6; i ++ ) {
25921
26076
 
25922
26077
  state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ i ] );
25923
- renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();
25924
- setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false );
26078
+
26079
+ if ( renderTargetProperties.__webglDepthbuffer[ i ] === undefined ) {
26080
+
26081
+ renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();
26082
+ setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false );
26083
+
26084
+ } else {
26085
+
26086
+ // attach buffer if it's been created already
26087
+ const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
26088
+ const renderbuffer = renderTargetProperties.__webglDepthbuffer[ i ];
26089
+ _gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
26090
+ _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
26091
+
26092
+ }
25925
26093
 
25926
26094
  }
25927
26095
 
25928
26096
  } else {
25929
26097
 
25930
26098
  state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
25931
- renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();
25932
- setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false );
26099
+
26100
+ if ( renderTargetProperties.__webglDepthbuffer === undefined ) {
26101
+
26102
+ renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();
26103
+ setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false );
26104
+
26105
+ } else {
26106
+
26107
+ // attach buffer if it's been created already
26108
+ const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
26109
+ const renderbuffer = renderTargetProperties.__webglDepthbuffer;
26110
+ _gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
26111
+ _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, glAttachmentType, _gl.RENDERBUFFER, renderbuffer );
26112
+
26113
+ }
25933
26114
 
25934
26115
  }
25935
26116
 
@@ -28243,18 +28424,31 @@ class WebXRManager extends EventDispatcher {
28243
28424
  camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
28244
28425
  camera.matrixWorldInverse.copy( camera.matrixWorld ).invert();
28245
28426
 
28246
- // Find the union of the frustum values of the cameras and scale
28247
- // the values so that the near plane's position does not change in world space,
28248
- // although must now be relative to the new union camera.
28249
- const near2 = near + zOffset;
28250
- const far2 = far + zOffset;
28251
- const left2 = left - xOffset;
28252
- const right2 = right + ( ipd - xOffset );
28253
- const top2 = topFov * far / far2 * near2;
28254
- const bottom2 = bottomFov * far / far2 * near2;
28427
+ // Check if the projection uses an infinite far plane.
28428
+ if ( projL[ 10 ] === - 1.0 ) {
28429
+
28430
+ // Use the projection matrix from the left eye.
28431
+ // The camera offset is sufficient to include the view volumes
28432
+ // of both eyes (assuming symmetric projections).
28433
+ camera.projectionMatrix.copy( cameraL.projectionMatrix );
28434
+ camera.projectionMatrixInverse.copy( cameraL.projectionMatrixInverse );
28435
+
28436
+ } else {
28437
+
28438
+ // Find the union of the frustum values of the cameras and scale
28439
+ // the values so that the near plane's position does not change in world space,
28440
+ // although must now be relative to the new union camera.
28441
+ const near2 = near + zOffset;
28442
+ const far2 = far + zOffset;
28443
+ const left2 = left - xOffset;
28444
+ const right2 = right + ( ipd - xOffset );
28445
+ const top2 = topFov * far / far2 * near2;
28446
+ const bottom2 = bottomFov * far / far2 * near2;
28255
28447
 
28256
- camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
28257
- camera.projectionMatrixInverse.copy( camera.projectionMatrix ).invert();
28448
+ camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
28449
+ camera.projectionMatrixInverse.copy( camera.projectionMatrix ).invert();
28450
+
28451
+ }
28258
28452
 
28259
28453
  }
28260
28454
 
@@ -28284,15 +28478,18 @@ class WebXRManager extends EventDispatcher {
28284
28478
 
28285
28479
  if ( session === null ) return;
28286
28480
 
28481
+ let depthNear = camera.near;
28482
+ let depthFar = camera.far;
28483
+
28287
28484
  if ( depthSensing.texture !== null ) {
28288
28485
 
28289
- camera.near = depthSensing.depthNear;
28290
- camera.far = depthSensing.depthFar;
28486
+ if ( depthSensing.depthNear > 0 ) depthNear = depthSensing.depthNear;
28487
+ if ( depthSensing.depthFar > 0 ) depthFar = depthSensing.depthFar;
28291
28488
 
28292
28489
  }
28293
28490
 
28294
- cameraXR.near = cameraR.near = cameraL.near = camera.near;
28295
- cameraXR.far = cameraR.far = cameraL.far = camera.far;
28491
+ cameraXR.near = cameraR.near = cameraL.near = depthNear;
28492
+ cameraXR.far = cameraR.far = cameraL.far = depthFar;
28296
28493
 
28297
28494
  if ( _currentDepthNear !== cameraXR.near || _currentDepthFar !== cameraXR.far ) {
28298
28495
 
@@ -28306,15 +28503,6 @@ class WebXRManager extends EventDispatcher {
28306
28503
  _currentDepthNear = cameraXR.near;
28307
28504
  _currentDepthFar = cameraXR.far;
28308
28505
 
28309
- cameraL.near = _currentDepthNear;
28310
- cameraL.far = _currentDepthFar;
28311
- cameraR.near = _currentDepthNear;
28312
- cameraR.far = _currentDepthFar;
28313
-
28314
- cameraL.updateProjectionMatrix();
28315
- cameraR.updateProjectionMatrix();
28316
- camera.updateProjectionMatrix();
28317
-
28318
28506
  }
28319
28507
 
28320
28508
  const cameras = cameraXR.cameras;
@@ -29697,6 +29885,7 @@ class WebGLRenderer {
29697
29885
 
29698
29886
  // camera matrices cache
29699
29887
 
29888
+ const _currentProjectionMatrix = new Matrix4();
29700
29889
  const _projScreenMatrix = new Matrix4();
29701
29890
 
29702
29891
  const _vector3 = new Vector3();
@@ -29793,6 +29982,8 @@ class WebGLRenderer {
29793
29982
 
29794
29983
  state = new WebGLState( _gl );
29795
29984
 
29985
+ if ( capabilities.reverseDepthBuffer ) state.buffers.depth.setReversed( true );
29986
+
29796
29987
  info = new WebGLInfo( _gl );
29797
29988
  properties = new WebGLProperties();
29798
29989
  textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
@@ -30093,7 +30284,13 @@ class WebGLRenderer {
30093
30284
 
30094
30285
  }
30095
30286
 
30096
- if ( depth ) bits |= _gl.DEPTH_BUFFER_BIT;
30287
+ if ( depth ) {
30288
+
30289
+ bits |= _gl.DEPTH_BUFFER_BIT;
30290
+ _gl.clearDepth( this.capabilities.reverseDepthBuffer ? 0 : 1 );
30291
+
30292
+ }
30293
+
30097
30294
  if ( stencil ) {
30098
30295
 
30099
30296
  bits |= _gl.STENCIL_BUFFER_BIT;
@@ -30482,6 +30679,12 @@ class WebGLRenderer {
30482
30679
 
30483
30680
  scene.traverse( function ( object ) {
30484
30681
 
30682
+ if ( ! ( object.isMesh || object.isPoints || object.isLine || object.isSprite ) ) {
30683
+
30684
+ return;
30685
+
30686
+ }
30687
+
30485
30688
  const material = object.material;
30486
30689
 
30487
30690
  if ( material ) {
@@ -31113,6 +31316,8 @@ class WebGLRenderer {
31113
31316
  object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
31114
31317
  object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
31115
31318
 
31319
+ material.onBeforeRender( _this, scene, camera, geometry, object, group );
31320
+
31116
31321
  if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
31117
31322
 
31118
31323
  material.side = BackSide;
@@ -31497,7 +31702,21 @@ class WebGLRenderer {
31497
31702
 
31498
31703
  } else {
31499
31704
 
31500
- p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
31705
+ if ( capabilities.reverseDepthBuffer ) {
31706
+
31707
+ _currentProjectionMatrix.copy( camera.projectionMatrix );
31708
+
31709
+ toNormalizedProjectionMatrix( _currentProjectionMatrix );
31710
+ toReversedProjectionMatrix( _currentProjectionMatrix );
31711
+
31712
+ p_uniforms.setValue( _gl, 'projectionMatrix', _currentProjectionMatrix );
31713
+
31714
+ } else {
31715
+
31716
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
31717
+
31718
+ }
31719
+
31501
31720
  p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
31502
31721
 
31503
31722
  }
@@ -31829,6 +32048,28 @@ class WebGLRenderer {
31829
32048
  // Color and depth texture must be rebound in order for the swapchain to update.
31830
32049
  textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture );
31831
32050
 
32051
+ } else if ( renderTarget.depthBuffer ) {
32052
+
32053
+ // check if the depth texture is already bound to the frame buffer and that it's been initialized
32054
+ const depthTexture = renderTarget.depthTexture;
32055
+ if ( renderTargetProperties.__boundDepthTexture !== depthTexture ) {
32056
+
32057
+ // check if the depth texture is compatible
32058
+ if (
32059
+ depthTexture !== null &&
32060
+ properties.has( depthTexture ) &&
32061
+ ( renderTarget.width !== depthTexture.image.width || renderTarget.height !== depthTexture.image.height )
32062
+ ) {
32063
+
32064
+ throw new Error( 'WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.' );
32065
+
32066
+ }
32067
+
32068
+ // Swap the depth buffer to the currently attached one
32069
+ textures.setupDepthRenderbuffer( renderTarget );
32070
+
32071
+ }
32072
+
31832
32073
  }
31833
32074
 
31834
32075
  const texture = renderTarget.texture;
@@ -31993,61 +32234,55 @@ class WebGLRenderer {
31993
32234
 
31994
32235
  if ( framebuffer ) {
31995
32236
 
31996
- state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
31997
-
31998
- try {
31999
-
32000
- const texture = renderTarget.texture;
32001
- const textureFormat = texture.format;
32002
- const textureType = texture.type;
32003
-
32004
- if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
32237
+ const texture = renderTarget.texture;
32238
+ const textureFormat = texture.format;
32239
+ const textureType = texture.type;
32005
32240
 
32006
- throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
32241
+ if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
32007
32242
 
32008
- }
32009
-
32010
- if ( ! capabilities.textureTypeReadable( textureType ) ) {
32243
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
32011
32244
 
32012
- throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
32245
+ }
32013
32246
 
32014
- }
32247
+ if ( ! capabilities.textureTypeReadable( textureType ) ) {
32015
32248
 
32016
- // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
32017
- if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
32249
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
32018
32250
 
32019
- const glBuffer = _gl.createBuffer();
32020
- _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
32021
- _gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
32022
- _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
32023
- _gl.flush();
32251
+ }
32024
32252
 
32025
- // check if the commands have finished every 8 ms
32026
- const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
32027
- await probeAsync( _gl, sync, 4 );
32253
+ // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
32254
+ if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
32028
32255
 
32029
- try {
32256
+ // set the active frame buffer to the one we want to read
32257
+ state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
32030
32258
 
32031
- _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
32032
- _gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
32259
+ const glBuffer = _gl.createBuffer();
32260
+ _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
32261
+ _gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
32262
+ _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
32033
32263
 
32034
- } finally {
32264
+ // reset the frame buffer to the currently set buffer before waiting
32265
+ const currFramebuffer = _currentRenderTarget !== null ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
32266
+ state.bindFramebuffer( _gl.FRAMEBUFFER, currFramebuffer );
32035
32267
 
32036
- _gl.deleteBuffer( glBuffer );
32037
- _gl.deleteSync( sync );
32268
+ // check if the commands have finished every 8 ms
32269
+ const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
32038
32270
 
32039
- }
32271
+ _gl.flush();
32040
32272
 
32041
- return buffer;
32273
+ await probeAsync( _gl, sync, 4 );
32042
32274
 
32043
- }
32275
+ // read the data and delete the buffer
32276
+ _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
32277
+ _gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
32278
+ _gl.deleteBuffer( glBuffer );
32279
+ _gl.deleteSync( sync );
32044
32280
 
32045
- } finally {
32281
+ return buffer;
32046
32282
 
32047
- // restore framebuffer of current render target if necessary
32283
+ } else {
32048
32284
 
32049
- const framebuffer = ( _currentRenderTarget !== null ) ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
32050
- state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
32285
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.' );
32051
32286
 
32052
32287
  }
32053
32288
 
@@ -32533,7 +32768,6 @@ class InterleavedBuffer {
32533
32768
  this.count = array !== undefined ? array.length / stride : 0;
32534
32769
 
32535
32770
  this.usage = StaticDrawUsage;
32536
- this._updateRange = { offset: 0, count: - 1 };
32537
32771
  this.updateRanges = [];
32538
32772
 
32539
32773
  this.version = 0;
@@ -32550,13 +32784,6 @@ class InterleavedBuffer {
32550
32784
 
32551
32785
  }
32552
32786
 
32553
- get updateRange() {
32554
-
32555
- warnOnce( 'THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.' ); // @deprecated, r159
32556
- return this._updateRange;
32557
-
32558
- }
32559
-
32560
32787
  setUsage( value ) {
32561
32788
 
32562
32789
  this.usage = value;
@@ -33321,6 +33548,27 @@ class LOD extends Object3D {
33321
33548
 
33322
33549
  }
33323
33550
 
33551
+ removeLevel( distance ) {
33552
+
33553
+ const levels = this.levels;
33554
+
33555
+ for ( let i = 0; i < levels.length; i ++ ) {
33556
+
33557
+ if ( levels[ i ].distance === distance ) {
33558
+
33559
+ const removedElements = levels.splice( i, 1 );
33560
+ this.remove( removedElements[ 0 ].object );
33561
+
33562
+ return true;
33563
+
33564
+ }
33565
+
33566
+ }
33567
+
33568
+ return false;
33569
+
33570
+ }
33571
+
33324
33572
  getCurrentLevel() {
33325
33573
 
33326
33574
  return this._currentLevel;
@@ -34440,6 +34688,9 @@ class BatchedMesh extends Mesh {
34440
34688
  // stores visible, active, and geometry id per object
34441
34689
  this._drawInfo = [];
34442
34690
 
34691
+ // instance ids that have been set as inactive, and are available to be overwritten
34692
+ this._availableInstanceIds = [];
34693
+
34443
34694
  // geometry information
34444
34695
  this._drawRanges = [];
34445
34696
  this._reservedRanges = [];
@@ -34501,7 +34752,7 @@ class BatchedMesh extends Mesh {
34501
34752
 
34502
34753
  _initColorsTexture() {
34503
34754
 
34504
- let size = Math.sqrt( this._maxIndexCount );
34755
+ let size = Math.sqrt( this._maxInstanceCount );
34505
34756
  size = Math.ceil( size );
34506
34757
 
34507
34758
  // 4 floats per RGBA pixel initialized to white
@@ -34595,12 +34846,11 @@ class BatchedMesh extends Mesh {
34595
34846
 
34596
34847
  }
34597
34848
 
34598
- const geometryCount = this._geometryCount;
34599
34849
  const boundingBox = this.boundingBox;
34600
34850
  const drawInfo = this._drawInfo;
34601
34851
 
34602
34852
  boundingBox.makeEmpty();
34603
- for ( let i = 0; i < geometryCount; i ++ ) {
34853
+ for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34604
34854
 
34605
34855
  if ( drawInfo[ i ].active === false ) continue;
34606
34856
 
@@ -34640,23 +34890,36 @@ class BatchedMesh extends Mesh {
34640
34890
 
34641
34891
  addInstance( geometryId ) {
34642
34892
 
34893
+ const atCapacity = this._drawInfo.length >= this.maxInstanceCount;
34894
+
34643
34895
  // ensure we're not over geometry
34644
- if ( this._drawInfo.length >= this._maxInstanceCount ) {
34896
+ if ( atCapacity && this._availableInstanceIds.length === 0 ) {
34645
34897
 
34646
34898
  throw new Error( 'BatchedMesh: Maximum item count reached.' );
34647
34899
 
34648
34900
  }
34649
34901
 
34650
- this._drawInfo.push( {
34651
-
34902
+ const instanceDrawInfo = {
34652
34903
  visible: true,
34653
34904
  active: true,
34654
34905
  geometryIndex: geometryId,
34906
+ };
34655
34907
 
34656
- } );
34908
+ let drawId = null;
34909
+
34910
+ // Prioritize using previously freed instance ids
34911
+ if ( this._availableInstanceIds.length > 0 ) {
34912
+
34913
+ drawId = this._availableInstanceIds.pop();
34914
+ this._drawInfo[ drawId ] = instanceDrawInfo;
34915
+
34916
+ } else {
34917
+
34918
+ drawId = this._drawInfo.length;
34919
+ this._drawInfo.push( instanceDrawInfo );
34920
+
34921
+ }
34657
34922
 
34658
- // initialize the matrix
34659
- const drawId = this._drawInfo.length - 1;
34660
34923
  const matricesTexture = this._matricesTexture;
34661
34924
  const matricesArray = matricesTexture.image.data;
34662
34925
  _identityMatrix.toArray( matricesArray, drawId * 16 );
@@ -34905,11 +35168,8 @@ class BatchedMesh extends Mesh {
34905
35168
  }
34906
35169
  */
34907
35170
 
34908
- /*
34909
35171
  deleteInstance( instanceId ) {
34910
35172
 
34911
- // Note: User needs to call optimize() afterward to pack the data.
34912
-
34913
35173
  const drawInfo = this._drawInfo;
34914
35174
  if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34915
35175
 
@@ -34918,12 +35178,12 @@ class BatchedMesh extends Mesh {
34918
35178
  }
34919
35179
 
34920
35180
  drawInfo[ instanceId ].active = false;
35181
+ this._availableInstanceIds.push( instanceId );
34921
35182
  this._visibilityChanged = true;
34922
35183
 
34923
35184
  return this;
34924
35185
 
34925
35186
  }
34926
- */
34927
35187
 
34928
35188
  // get bounding box and compute it if it doesn't exist
34929
35189
  getBoundingBoxAt( geometryId, target ) {
@@ -35128,6 +35388,59 @@ class BatchedMesh extends Mesh {
35128
35388
 
35129
35389
  }
35130
35390
 
35391
+ setGeometryIdAt( instanceId, geometryId ) {
35392
+
35393
+ // return early if the geometry is out of range or not active
35394
+ const drawInfo = this._drawInfo;
35395
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35396
+
35397
+ return null;
35398
+
35399
+ }
35400
+
35401
+ // check if the provided geometryId is within the valid range
35402
+ if ( geometryId < 0 || geometryId >= this._geometryCount ) {
35403
+
35404
+ return null;
35405
+
35406
+ }
35407
+
35408
+ drawInfo[ instanceId ].geometryIndex = geometryId;
35409
+
35410
+ return this;
35411
+
35412
+ }
35413
+
35414
+ getGeometryIdAt( instanceId ) {
35415
+
35416
+ const drawInfo = this._drawInfo;
35417
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35418
+
35419
+ return - 1;
35420
+
35421
+ }
35422
+
35423
+ return drawInfo[ instanceId ].geometryIndex;
35424
+
35425
+ }
35426
+
35427
+ getGeometryRangeAt( geometryId, target = {} ) {
35428
+
35429
+ if ( geometryId < 0 || geometryId >= this._geometryCount ) {
35430
+
35431
+ return null;
35432
+
35433
+ }
35434
+
35435
+ const drawRange = this._drawRanges[ geometryId ];
35436
+
35437
+ target.start = drawRange.start;
35438
+ target.count = drawRange.count;
35439
+
35440
+ return target;
35441
+
35442
+ }
35443
+
35131
35444
  raycast( raycaster, intersects ) {
35132
35445
 
35133
35446
  const drawInfo = this._drawInfo;
@@ -35679,6 +35992,7 @@ function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
35679
35992
  index: a,
35680
35993
  face: null,
35681
35994
  faceIndex: null,
35995
+ barycoord: null,
35682
35996
  object: object
35683
35997
 
35684
35998
  };
@@ -35944,6 +36258,8 @@ function testPoint( point, index, localThresholdSq, matrixWorld, raycaster, inte
35944
36258
  point: intersectPoint,
35945
36259
  index: index,
35946
36260
  face: null,
36261
+ faceIndex: null,
36262
+ barycoord: null,
35947
36263
  object: object
35948
36264
 
35949
36265
  } );
@@ -38446,12 +38762,19 @@ class CylinderGeometry extends BufferGeometry {
38446
38762
 
38447
38763
  // faces
38448
38764
 
38449
- indices.push( a, b, d );
38450
- indices.push( b, c, d );
38765
+ if ( radiusTop > 0 ) {
38451
38766
 
38452
- // update group counter
38767
+ indices.push( a, b, d );
38768
+ groupCount += 3;
38453
38769
 
38454
- groupCount += 6;
38770
+ }
38771
+
38772
+ if ( radiusBottom > 0 ) {
38773
+
38774
+ indices.push( b, c, d );
38775
+ groupCount += 3;
38776
+
38777
+ }
38455
38778
 
38456
38779
  }
38457
38780
 
@@ -46761,7 +47084,7 @@ class MaterialLoader extends Loader {
46761
47084
 
46762
47085
  }
46763
47086
 
46764
- const material = MaterialLoader.createMaterialFromType( json.type );
47087
+ const material = this.createMaterialFromType( json.type );
46765
47088
 
46766
47089
  if ( json.uuid !== undefined ) material.uuid = json.uuid;
46767
47090
  if ( json.name !== undefined ) material.name = json.name;
@@ -47017,6 +47340,12 @@ class MaterialLoader extends Loader {
47017
47340
 
47018
47341
  }
47019
47342
 
47343
+ createMaterialFromType( type ) {
47344
+
47345
+ return MaterialLoader.createMaterialFromType( type );
47346
+
47347
+ }
47348
+
47020
47349
  static createMaterialFromType( type ) {
47021
47350
 
47022
47351
  const materialLib = {
@@ -48151,7 +48480,7 @@ class ObjectLoader extends Loader {
48151
48480
  case 'DirectionalLight':
48152
48481
 
48153
48482
  object = new DirectionalLight( data.color, data.intensity );
48154
- object.target = data.target || '';
48483
+ object.target = data.target || '';
48155
48484
 
48156
48485
  break;
48157
48486
 
@@ -48170,7 +48499,7 @@ class ObjectLoader extends Loader {
48170
48499
  case 'SpotLight':
48171
48500
 
48172
48501
  object = new SpotLight( data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay );
48173
- object.target = data.target || '';
48502
+ object.target = data.target || '';
48174
48503
 
48175
48504
  break;
48176
48505
 
@@ -48447,7 +48776,7 @@ class ObjectLoader extends Loader {
48447
48776
 
48448
48777
  object.traverse( function ( child ) {
48449
48778
 
48450
- if ( child.isDirectionalLight || child.isSpotLight ) {
48779
+ if ( child.isDirectionalLight || child.isSpotLight ) {
48451
48780
 
48452
48781
  const uuid = child.target;
48453
48782
 
@@ -48862,7 +49191,7 @@ class Clock {
48862
49191
 
48863
49192
  function now() {
48864
49193
 
48865
- return ( typeof performance === 'undefined' ? Date : performance ).now(); // see #10732
49194
+ return performance.now();
48866
49195
 
48867
49196
  }
48868
49197
 
@@ -49154,7 +49483,7 @@ class Audio extends Object3D {
49154
49483
 
49155
49484
  }
49156
49485
 
49157
- stop() {
49486
+ stop( delay = 0 ) {
49158
49487
 
49159
49488
  if ( this.hasPlaybackControl === false ) {
49160
49489
 
@@ -49167,7 +49496,7 @@ class Audio extends Object3D {
49167
49496
 
49168
49497
  if ( this.source !== null ) {
49169
49498
 
49170
- this.source.stop();
49499
+ this.source.stop( this.context.currentTime + delay );
49171
49500
  this.source.onended = null;
49172
49501
 
49173
49502
  }
@@ -54807,6 +55136,35 @@ class ShapePath {
54807
55136
 
54808
55137
  }
54809
55138
 
55139
+ class Controls extends EventDispatcher {
55140
+
55141
+ constructor( object, domElement = null ) {
55142
+
55143
+ super();
55144
+
55145
+ this.object = object;
55146
+ this.domElement = domElement;
55147
+
55148
+ this.enabled = true;
55149
+
55150
+ this.state = - 1;
55151
+
55152
+ this.keys = {};
55153
+ this.mouseButtons = { LEFT: null, MIDDLE: null, RIGHT: null };
55154
+ this.touches = { ONE: null, TWO: null };
55155
+
55156
+ }
55157
+
55158
+ connect() {}
55159
+
55160
+ disconnect() {}
55161
+
55162
+ dispose() {}
55163
+
55164
+ update( /* delta */ ) {}
55165
+
55166
+ }
55167
+
54810
55168
  class WebGLMultipleRenderTargets extends WebGLRenderTarget { // @deprecated, r162
54811
55169
 
54812
55170
  constructor( width = 1, height = 1, count = 1, options = {} ) {
@@ -54849,4 +55207,4 @@ if ( typeof window !== 'undefined' ) {
54849
55207
 
54850
55208
  }
54851
55209
 
54852
- export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BackSide, BasicDepthPacking, BasicShadowMap, BatchedMesh, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CineonToneMapping, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, ColorManagement, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, ConstantAlphaFactor, ConstantColorFactor, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry, Cylindrical, Data3DTexture, DataArrayTexture, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DisplayP3ColorSpace, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualCompare, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, FloatType, Fog, FogExp2, FramebufferTexture, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearDisplayP3ColorSpace, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils, Matrix2, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry, OneFactor, OneMinusConstantAlphaFactor, OneMinusConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, P3Primaries, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, Path, PerspectiveCamera, Plane, PlaneGeometry, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBDepthPacking, RGBFormat, RGBIntegerFormat, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGDepthPacking, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, Rec709Primaries, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RenderTarget, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, Scene, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry, Texture, TextureLoader, TextureUtils, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, VideoTexture, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLRenderTarget, WebGLRenderer, WebGLUtils, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, createCanvasElement };
55210
+ 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 };