@plastic-software/three 0.174.0 → 0.175.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 (544) hide show
  1. package/build/three.cjs +10655 -1446
  2. package/build/three.core.js +9626 -1094
  3. package/build/three.core.min.js +1 -1
  4. package/build/three.module.js +834 -157
  5. package/build/three.module.min.js +1 -1
  6. package/build/three.tsl.js +4 -2
  7. package/build/three.tsl.min.js +1 -1
  8. package/build/three.webgpu.js +2658 -1697
  9. package/build/three.webgpu.min.js +1 -1
  10. package/build/three.webgpu.nodes.js +2654 -1709
  11. package/build/three.webgpu.nodes.min.js +1 -1
  12. package/examples/jsm/Addons.js +1 -1
  13. package/examples/jsm/animation/AnimationClipCreator.js +57 -6
  14. package/examples/jsm/animation/CCDIKSolver.js +93 -39
  15. package/examples/jsm/capabilities/WebGL.js +28 -3
  16. package/examples/jsm/capabilities/WebGPU.js +16 -6
  17. package/examples/jsm/controls/ArcballControls.js +424 -154
  18. package/examples/jsm/controls/DragControls.js +93 -2
  19. package/examples/jsm/controls/FirstPersonControls.js +113 -4
  20. package/examples/jsm/controls/FlyControls.js +49 -2
  21. package/examples/jsm/controls/MapControls.js +42 -9
  22. package/examples/jsm/controls/OrbitControls.js +345 -42
  23. package/examples/jsm/controls/PointerLockControls.js +111 -9
  24. package/examples/jsm/controls/TrackballControls.js +159 -8
  25. package/examples/jsm/controls/TransformControls.js +252 -6
  26. package/examples/jsm/csm/CSM.js +226 -15
  27. package/examples/jsm/csm/CSMFrustum.js +52 -0
  28. package/examples/jsm/csm/CSMHelper.js +47 -0
  29. package/examples/jsm/csm/CSMShader.js +10 -1
  30. package/examples/jsm/csm/CSMShadowNode.js +156 -13
  31. package/examples/jsm/curves/CurveExtras.js +289 -31
  32. package/examples/jsm/curves/NURBSCurve.js +57 -14
  33. package/examples/jsm/curves/NURBSSurface.js +50 -6
  34. package/examples/jsm/curves/NURBSUtils.js +96 -112
  35. package/examples/jsm/curves/NURBSVolume.js +22 -4
  36. package/examples/jsm/effects/AnaglyphEffect.js +30 -0
  37. package/examples/jsm/effects/AsciiEffect.js +60 -15
  38. package/examples/jsm/effects/OutlineEffect.js +59 -111
  39. package/examples/jsm/effects/ParallaxBarrierEffect.js +28 -0
  40. package/examples/jsm/effects/PeppersGhostEffect.js +21 -2
  41. package/examples/jsm/effects/StereoEffect.js +29 -0
  42. package/examples/jsm/environments/DebugEnvironment.js +49 -0
  43. package/examples/jsm/environments/RoomEnvironment.js +23 -4
  44. package/examples/jsm/exporters/DRACOExporter.js +53 -13
  45. package/examples/jsm/exporters/EXRExporter.js +37 -8
  46. package/examples/jsm/exporters/GLTFExporter.js +171 -48
  47. package/examples/jsm/exporters/KTX2Exporter.js +20 -0
  48. package/examples/jsm/exporters/OBJExporter.js +18 -0
  49. package/examples/jsm/exporters/PLYExporter.js +39 -9
  50. package/examples/jsm/exporters/STLExporter.js +25 -5
  51. package/examples/jsm/exporters/USDZExporter.js +70 -3
  52. package/examples/jsm/geometries/BoxLineGeometry.js +22 -0
  53. package/examples/jsm/geometries/ConvexGeometry.js +18 -0
  54. package/examples/jsm/geometries/DecalGeometry.js +20 -9
  55. package/examples/jsm/geometries/ParametricFunctions.js +97 -0
  56. package/examples/jsm/geometries/ParametricGeometry.js +37 -5
  57. package/examples/jsm/geometries/RoundedBoxGeometry.js +21 -0
  58. package/examples/jsm/geometries/TeapotGeometry.js +22 -38
  59. package/examples/jsm/geometries/TextGeometry.js +44 -16
  60. package/examples/jsm/helpers/LightProbeHelper.js +35 -0
  61. package/examples/jsm/helpers/LightProbeHelperGPU.js +36 -0
  62. package/examples/jsm/helpers/OctreeHelper.js +35 -0
  63. package/examples/jsm/helpers/PositionalAudioHelper.js +59 -0
  64. package/examples/jsm/helpers/RectAreaLightHelper.js +35 -3
  65. package/examples/jsm/helpers/TextureHelper.js +27 -0
  66. package/examples/jsm/helpers/TextureHelperGPU.js +28 -0
  67. package/examples/jsm/helpers/VertexNormalsHelper.js +58 -2
  68. package/examples/jsm/helpers/VertexTangentsHelper.js +46 -2
  69. package/examples/jsm/helpers/ViewHelper.js +75 -1
  70. package/examples/jsm/interactive/HTMLMesh.js +25 -0
  71. package/examples/jsm/interactive/InteractiveGroup.js +65 -5
  72. package/examples/jsm/interactive/SelectionBox.js +74 -9
  73. package/examples/jsm/interactive/SelectionHelper.js +71 -29
  74. package/examples/jsm/libs/motion-controllers.module.js +1 -1
  75. package/examples/jsm/lighting/TiledLighting.js +23 -0
  76. package/examples/jsm/lights/LightProbeGenerator.js +26 -1
  77. package/examples/jsm/lights/RectAreaLightTexturesLib.js +48 -13
  78. package/examples/jsm/lights/RectAreaLightUniformsLib.js +15 -0
  79. package/examples/jsm/lines/Line2.js +36 -0
  80. package/examples/jsm/lines/LineGeometry.js +52 -0
  81. package/examples/jsm/lines/LineMaterial.js +95 -0
  82. package/examples/jsm/lines/LineSegments2.js +51 -2
  83. package/examples/jsm/lines/LineSegmentsGeometry.js +62 -8
  84. package/examples/jsm/lines/Wireframe.js +38 -2
  85. package/examples/jsm/lines/WireframeGeometry2.js +24 -0
  86. package/examples/jsm/lines/webgpu/Line2.js +25 -1
  87. package/examples/jsm/lines/webgpu/LineSegments2.js +44 -6
  88. package/examples/jsm/lines/webgpu/Wireframe.js +30 -2
  89. package/examples/jsm/loaders/3DMLoader.js +71 -2
  90. package/examples/jsm/loaders/3MFLoader.js +41 -3
  91. package/examples/jsm/loaders/AMFLoader.js +31 -12
  92. package/examples/jsm/loaders/BVHLoader.js +57 -11
  93. package/examples/jsm/loaders/ColladaLoader.js +35 -0
  94. package/examples/jsm/loaders/DDSLoader.js +24 -0
  95. package/examples/jsm/loaders/DRACOLoader.js +73 -1
  96. package/examples/jsm/loaders/EXRLoader.js +40 -8
  97. package/examples/jsm/loaders/FBXLoader.js +42 -14
  98. package/examples/jsm/loaders/FontLoader.js +60 -2
  99. package/examples/jsm/loaders/GCodeLoader.js +33 -5
  100. package/examples/jsm/loaders/GLTFLoader.js +218 -5
  101. package/examples/jsm/loaders/HDRCubeTextureLoader.js +48 -0
  102. package/examples/jsm/loaders/IESLoader.js +41 -0
  103. package/examples/jsm/loaders/KMZLoader.js +32 -0
  104. package/examples/jsm/loaders/KTX2Loader.js +86 -18
  105. package/examples/jsm/loaders/KTXLoader.js +26 -6
  106. package/examples/jsm/loaders/LDrawLoader.js +115 -5
  107. package/examples/jsm/loaders/LUT3dlLoader.js +46 -10
  108. package/examples/jsm/loaders/LUTCubeLoader.js +45 -9
  109. package/examples/jsm/loaders/LUTImageLoader.js +78 -38
  110. package/examples/jsm/loaders/LWOLoader.js +46 -7
  111. package/examples/jsm/loaders/LottieLoader.js +37 -0
  112. package/examples/jsm/loaders/MD2Loader.js +36 -1
  113. package/examples/jsm/loaders/MDDLoader.js +56 -12
  114. package/examples/jsm/loaders/MTLLoader.js +38 -33
  115. package/examples/jsm/loaders/MaterialXLoader.js +33 -0
  116. package/examples/jsm/loaders/NRRDLoader.js +36 -5
  117. package/examples/jsm/loaders/OBJLoader.js +48 -1
  118. package/examples/jsm/loaders/PCDLoader.js +47 -0
  119. package/examples/jsm/loaders/PDBLoader.js +40 -2
  120. package/examples/jsm/loaders/PLYLoader.js +62 -32
  121. package/examples/jsm/loaders/PVRLoader.js +23 -5
  122. package/examples/jsm/loaders/RGBELoader.js +38 -5
  123. package/examples/jsm/loaders/RGBMLoader.js +67 -1
  124. package/examples/jsm/loaders/STLLoader.js +47 -38
  125. package/examples/jsm/loaders/SVGLoader.js +113 -20
  126. package/examples/jsm/loaders/TDSLoader.js +81 -61
  127. package/examples/jsm/loaders/TGALoader.js +22 -0
  128. package/examples/jsm/loaders/TIFFLoader.js +22 -0
  129. package/examples/jsm/loaders/TTFLoader.js +36 -2
  130. package/examples/jsm/loaders/USDZLoader.js +34 -1
  131. package/examples/jsm/loaders/UltraHDRLoader.js +58 -12
  132. package/examples/jsm/loaders/VOXLoader.js +57 -0
  133. package/examples/jsm/loaders/VRMLLoader.js +32 -1
  134. package/examples/jsm/loaders/VTKLoader.js +38 -0
  135. package/examples/jsm/loaders/XYZLoader.js +35 -0
  136. package/examples/jsm/materials/LDrawConditionalLineMaterial.js +39 -0
  137. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +39 -0
  138. package/examples/jsm/materials/MeshPostProcessingMaterial.js +24 -2
  139. package/examples/jsm/math/Capsule.js +89 -14
  140. package/examples/jsm/math/ColorConverter.js +21 -0
  141. package/examples/jsm/math/ColorSpaces.js +53 -0
  142. package/examples/jsm/math/ConvexHull.js +514 -92
  143. package/examples/jsm/math/ImprovedNoise.js +14 -2
  144. package/examples/jsm/math/Lut.js +111 -0
  145. package/examples/jsm/math/MeshSurfaceSampler.js +76 -13
  146. package/examples/jsm/math/OBB.js +139 -46
  147. package/examples/jsm/math/Octree.js +132 -5
  148. package/examples/jsm/math/SimplexNoise.js +66 -42
  149. package/examples/jsm/misc/ConvexObjectBreaker.js +43 -25
  150. package/examples/jsm/misc/GPUComputationRenderer.js +92 -17
  151. package/examples/jsm/misc/Gyroscope.js +11 -0
  152. package/examples/jsm/misc/MD2Character.js +115 -2
  153. package/examples/jsm/misc/MD2CharacterComplex.js +170 -8
  154. package/examples/jsm/misc/MorphAnimMesh.js +43 -0
  155. package/examples/jsm/misc/MorphBlendMesh.js +102 -0
  156. package/examples/jsm/misc/ProgressiveLightMap.js +40 -15
  157. package/examples/jsm/misc/ProgressiveLightMapGPU.js +33 -13
  158. package/examples/jsm/misc/RollerCoaster.js +52 -0
  159. package/examples/jsm/misc/Timer.js +79 -2
  160. package/examples/jsm/misc/TubePainter.js +53 -0
  161. package/examples/jsm/misc/Volume.js +108 -72
  162. package/examples/jsm/misc/VolumeSlice.js +88 -45
  163. package/examples/jsm/modifiers/CurveModifier.js +57 -34
  164. package/examples/jsm/modifiers/CurveModifierGPU.js +36 -17
  165. package/examples/jsm/modifiers/EdgeSplitModifier.js +18 -0
  166. package/examples/jsm/modifiers/SimplifyModifier.js +20 -8
  167. package/examples/jsm/modifiers/TessellateModifier.js +33 -2
  168. package/examples/jsm/objects/GroundedSkybox.js +23 -5
  169. package/examples/jsm/objects/Lensflare.js +91 -2
  170. package/examples/jsm/objects/LensflareMesh.js +53 -2
  171. package/examples/jsm/objects/MarchingCubes.js +88 -5
  172. package/examples/jsm/objects/Reflector.js +70 -0
  173. package/examples/jsm/objects/ReflectorForSSRPass.js +39 -0
  174. package/examples/jsm/objects/Refractor.js +61 -0
  175. package/examples/jsm/objects/ShadowMesh.js +53 -4
  176. package/examples/jsm/objects/Sky.js +26 -9
  177. package/examples/jsm/objects/SkyMesh.js +60 -9
  178. package/examples/jsm/objects/Water.js +44 -5
  179. package/examples/jsm/objects/Water2.js +42 -3
  180. package/examples/jsm/objects/Water2Mesh.js +38 -3
  181. package/examples/jsm/objects/WaterMesh.js +94 -7
  182. package/examples/jsm/physics/AmmoPhysics.js +47 -0
  183. package/examples/jsm/physics/JoltPhysics.js +48 -0
  184. package/examples/jsm/physics/RapierPhysics.js +56 -0
  185. package/examples/jsm/postprocessing/AfterimagePass.js +90 -38
  186. package/examples/jsm/postprocessing/BloomPass.js +125 -24
  187. package/examples/jsm/postprocessing/BokehPass.js +98 -22
  188. package/examples/jsm/postprocessing/ClearPass.js +53 -3
  189. package/examples/jsm/postprocessing/CubeTexturePass.js +81 -21
  190. package/examples/jsm/postprocessing/DotScreenPass.js +58 -10
  191. package/examples/jsm/postprocessing/EffectComposer.js +131 -0
  192. package/examples/jsm/postprocessing/FilmPass.js +53 -5
  193. package/examples/jsm/postprocessing/GTAOPass.js +191 -48
  194. package/examples/jsm/postprocessing/GlitchPass.js +84 -33
  195. package/examples/jsm/postprocessing/HalftonePass.js +64 -10
  196. package/examples/jsm/postprocessing/LUTPass.js +37 -8
  197. package/examples/jsm/postprocessing/MaskPass.js +90 -0
  198. package/examples/jsm/postprocessing/OutlinePass.js +266 -133
  199. package/examples/jsm/postprocessing/OutputPass.js +53 -14
  200. package/examples/jsm/postprocessing/Pass.js +98 -4
  201. package/examples/jsm/postprocessing/RenderPass.js +83 -0
  202. package/examples/jsm/postprocessing/RenderPixelatedPass.js +123 -45
  203. package/examples/jsm/postprocessing/RenderTransitionPass.js +119 -21
  204. package/examples/jsm/postprocessing/SAOPass.js +126 -53
  205. package/examples/jsm/postprocessing/SMAAPass.js +103 -71
  206. package/examples/jsm/postprocessing/SSAARenderPass.js +117 -35
  207. package/examples/jsm/postprocessing/SSAOPass.js +160 -47
  208. package/examples/jsm/postprocessing/SSRPass.js +230 -49
  209. package/examples/jsm/postprocessing/SavePass.js +68 -16
  210. package/examples/jsm/postprocessing/ShaderPass.js +64 -7
  211. package/examples/jsm/postprocessing/TAARenderPass.js +78 -24
  212. package/examples/jsm/postprocessing/TexturePass.js +71 -8
  213. package/examples/jsm/postprocessing/UnrealBloomPass.js +113 -37
  214. package/examples/jsm/renderers/CSS2DRenderer.js +77 -1
  215. package/examples/jsm/renderers/CSS3DRenderer.js +99 -3
  216. package/examples/jsm/renderers/Projector.js +18 -2
  217. package/examples/jsm/renderers/SVGRenderer.js +124 -0
  218. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +9 -5
  219. package/examples/jsm/shaders/AfterimageShader.js +6 -4
  220. package/examples/jsm/shaders/BasicShader.js +6 -2
  221. package/examples/jsm/shaders/BleachBypassShader.js +8 -4
  222. package/examples/jsm/shaders/BlendShader.js +6 -2
  223. package/examples/jsm/shaders/BokehShader.js +7 -4
  224. package/examples/jsm/shaders/BokehShader2.js +7 -3
  225. package/examples/jsm/shaders/BrightnessContrastShader.js +8 -5
  226. package/examples/jsm/shaders/ColorCorrectionShader.js +6 -2
  227. package/examples/jsm/shaders/ColorifyShader.js +6 -2
  228. package/examples/jsm/shaders/ConvolutionShader.js +7 -39
  229. package/examples/jsm/shaders/CopyShader.js +6 -2
  230. package/examples/jsm/shaders/DOFMipMapShader.js +8 -4
  231. package/examples/jsm/shaders/DepthLimitedBlurShader.js +7 -1
  232. package/examples/jsm/shaders/DigitalGlitch.js +7 -7
  233. package/examples/jsm/shaders/DotScreenShader.js +6 -4
  234. package/examples/jsm/shaders/ExposureShader.js +6 -2
  235. package/examples/jsm/shaders/FXAAShader.js +15 -7
  236. package/examples/jsm/shaders/FilmShader.js +10 -0
  237. package/examples/jsm/shaders/FocusShader.js +6 -4
  238. package/examples/jsm/shaders/FreiChenShader.js +7 -3
  239. package/examples/jsm/shaders/GTAOShader.js +33 -39
  240. package/examples/jsm/shaders/GammaCorrectionShader.js +8 -2
  241. package/examples/jsm/shaders/GodRaysShader.js +14 -5
  242. package/examples/jsm/shaders/HalftoneShader.js +11 -5
  243. package/examples/jsm/shaders/HorizontalBlurShader.js +9 -3
  244. package/examples/jsm/shaders/HorizontalTiltShiftShader.js +6 -2
  245. package/examples/jsm/shaders/HueSaturationShader.js +7 -3
  246. package/examples/jsm/shaders/KaleidoShader.js +8 -4
  247. package/examples/jsm/shaders/LuminosityHighPassShader.js +6 -5
  248. package/examples/jsm/shaders/LuminosityShader.js +6 -3
  249. package/examples/jsm/shaders/MirrorShader.js +7 -4
  250. package/examples/jsm/shaders/NormalMapShader.js +5 -3
  251. package/examples/jsm/shaders/OutputShader.js +11 -0
  252. package/examples/jsm/shaders/PoissonDenoiseShader.js +21 -15
  253. package/examples/jsm/shaders/RGBShiftShader.js +5 -1
  254. package/examples/jsm/shaders/SAOShader.js +8 -2
  255. package/examples/jsm/shaders/SMAAShader.js +23 -1
  256. package/examples/jsm/shaders/SSAOShader.js +23 -5
  257. package/examples/jsm/shaders/SSRShader.js +25 -1
  258. package/examples/jsm/shaders/SepiaShader.js +6 -4
  259. package/examples/jsm/shaders/SobelOperatorShader.js +5 -2
  260. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +10 -8
  261. package/examples/jsm/shaders/TechnicolorShader.js +7 -4
  262. package/examples/jsm/shaders/ToonShader.js +29 -7
  263. package/examples/jsm/shaders/TriangleBlurShader.js +6 -4
  264. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +6 -3
  265. package/examples/jsm/shaders/VelocityShader.js +6 -2
  266. package/examples/jsm/shaders/VerticalBlurShader.js +6 -2
  267. package/examples/jsm/shaders/VerticalTiltShiftShader.js +5 -1
  268. package/examples/jsm/shaders/VignetteShader.js +6 -4
  269. package/examples/jsm/shaders/VolumeShader.js +7 -1
  270. package/examples/jsm/shaders/WaterRefractionShader.js +8 -0
  271. package/examples/jsm/textures/FlakesTexture.js +12 -0
  272. package/examples/jsm/transpiler/Transpiler.js +31 -0
  273. package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
  274. package/examples/jsm/tsl/display/BloomNode.js +1 -1
  275. package/examples/jsm/tsl/display/PixelationPassNode.js +4 -4
  276. package/examples/jsm/tsl/display/SSRNode.js +1 -1
  277. package/examples/jsm/tsl/lighting/TiledLightsNode.js +29 -3
  278. package/examples/jsm/tsl/math/Bayer.js +14 -1
  279. package/examples/jsm/tsl/utils/Raymarching.js +4 -2
  280. package/examples/jsm/utils/BufferGeometryUtils.js +88 -29
  281. package/examples/jsm/utils/CameraUtils.js +10 -7
  282. package/examples/jsm/utils/GeometryCompressionUtils.js +20 -30
  283. package/examples/jsm/utils/GeometryUtils.js +12 -13
  284. package/examples/jsm/utils/LDrawUtils.js +11 -4
  285. package/examples/jsm/utils/SceneOptimizer.js +66 -20
  286. package/examples/jsm/utils/SceneUtils.js +50 -3
  287. package/examples/jsm/utils/ShadowMapViewer.js +47 -24
  288. package/examples/jsm/utils/ShadowMapViewerGPU.js +47 -24
  289. package/examples/jsm/utils/SkeletonUtils.js +45 -0
  290. package/examples/jsm/utils/SortUtils.js +14 -5
  291. package/examples/jsm/utils/UVsDebug.js +9 -4
  292. package/examples/jsm/utils/WebGLTextureUtils.js +13 -0
  293. package/examples/jsm/utils/WebGPUTextureUtils.js +14 -0
  294. package/examples/jsm/utils/WorkerPool.js +65 -2
  295. package/examples/jsm/webxr/ARButton.js +18 -0
  296. package/examples/jsm/webxr/OculusHandModel.js +83 -0
  297. package/examples/jsm/webxr/OculusHandPointerModel.js +125 -0
  298. package/examples/jsm/webxr/Text2D.js +11 -0
  299. package/examples/jsm/webxr/VRButton.js +30 -0
  300. package/examples/jsm/webxr/XRButton.js +22 -0
  301. package/examples/jsm/webxr/XRControllerModelFactory.js +87 -3
  302. package/examples/jsm/webxr/XREstimatedLight.js +33 -3
  303. package/examples/jsm/webxr/XRHandMeshModel.js +35 -0
  304. package/examples/jsm/webxr/XRHandModelFactory.js +92 -0
  305. package/examples/jsm/webxr/XRHandPrimitiveModel.js +42 -0
  306. package/examples/jsm/webxr/XRPlanes.js +17 -0
  307. package/package.json +1 -1
  308. package/src/Three.TSL.js +3 -1
  309. package/src/animation/AnimationAction.js +262 -30
  310. package/src/animation/AnimationClip.js +141 -2
  311. package/src/animation/AnimationMixer.js +99 -15
  312. package/src/animation/AnimationObjectGroup.js +41 -18
  313. package/src/animation/AnimationUtils.js +168 -18
  314. package/src/animation/KeyframeTrack.js +144 -10
  315. package/src/animation/PropertyBinding.js +77 -3
  316. package/src/animation/PropertyMixer.js +72 -5
  317. package/src/animation/tracks/BooleanKeyframeTrack.js +33 -6
  318. package/src/animation/tracks/ColorKeyframeTrack.js +26 -5
  319. package/src/animation/tracks/NumberKeyframeTrack.js +26 -2
  320. package/src/animation/tracks/QuaternionKeyframeTrack.js +30 -1
  321. package/src/animation/tracks/StringKeyframeTrack.js +33 -2
  322. package/src/animation/tracks/VectorKeyframeTrack.js +26 -2
  323. package/src/audio/AudioAnalyser.js +1 -1
  324. package/src/audio/AudioListener.js +2 -2
  325. package/src/audio/PositionalAudio.js +5 -5
  326. package/src/constants.js +1429 -5
  327. package/src/core/BufferAttribute.js +413 -3
  328. package/src/core/BufferGeometry.js +337 -1
  329. package/src/core/Clock.js +60 -0
  330. package/src/core/GLBufferAttribute.js +99 -0
  331. package/src/core/InstancedBufferAttribute.js +29 -0
  332. package/src/core/InstancedBufferGeometry.js +20 -0
  333. package/src/core/InstancedInterleavedBuffer.js +26 -0
  334. package/src/core/InterleavedBuffer.js +137 -3
  335. package/src/core/InterleavedBufferAttribute.js +197 -0
  336. package/src/core/Layers.js +71 -10
  337. package/src/core/Object3D.js +23 -0
  338. package/src/core/Raycaster.js +134 -1
  339. package/src/core/RenderTarget.js +166 -7
  340. package/src/core/RenderTarget3D.js +25 -0
  341. package/src/core/RenderTargetArray.js +18 -0
  342. package/src/core/Uniform.js +29 -0
  343. package/src/core/UniformsGroup.js +84 -2
  344. package/src/extras/Controls.js +16 -1
  345. package/src/extras/Earcut.js +3 -781
  346. package/src/extras/ImageUtils.js +3 -2
  347. package/src/extras/PMREMGenerator.js +22 -17
  348. package/src/extras/core/Curve.js +1 -1
  349. package/src/extras/core/Path.js +1 -1
  350. package/src/extras/lib/earcut.js +685 -0
  351. package/src/geometries/ConeGeometry.js +2 -2
  352. package/src/geometries/CylinderGeometry.js +2 -2
  353. package/src/geometries/ExtrudeGeometry.js +71 -39
  354. package/src/geometries/LatheGeometry.js +1 -1
  355. package/src/lights/LightShadow.js +1 -1
  356. package/src/lights/webgpu/IESSpotLight.js +1 -1
  357. package/src/loaders/AnimationLoader.js +31 -0
  358. package/src/loaders/AudioLoader.js +31 -0
  359. package/src/loaders/BufferGeometryLoader.js +34 -0
  360. package/src/loaders/Cache.js +45 -0
  361. package/src/loaders/CompressedTextureLoader.js +36 -3
  362. package/src/loaders/CubeTextureLoader.js +45 -0
  363. package/src/loaders/DataTextureLoader.js +44 -3
  364. package/src/loaders/FileLoader.js +57 -1
  365. package/src/loaders/ImageBitmapLoader.js +57 -0
  366. package/src/loaders/ImageLoader.js +30 -0
  367. package/src/loaders/Loader.js +4 -6
  368. package/src/loaders/LoaderUtils.js +18 -36
  369. package/src/loaders/LoadingManager.js +142 -0
  370. package/src/loaders/MaterialLoader.js +57 -0
  371. package/src/loaders/ObjectLoader.js +53 -0
  372. package/src/loaders/TextureLoader.js +33 -0
  373. package/src/loaders/nodes/NodeLoader.js +6 -2
  374. package/src/loaders/nodes/NodeMaterialLoader.js +1 -1
  375. package/src/loaders/nodes/NodeObjectLoader.js +3 -3
  376. package/src/materials/LineBasicMaterial.js +74 -1
  377. package/src/materials/LineDashedMaterial.js +52 -0
  378. package/src/materials/Material.js +18 -3
  379. package/src/materials/MeshBasicMaterial.js +165 -0
  380. package/src/materials/MeshDepthMaterial.js +93 -0
  381. package/src/materials/MeshDistanceMaterial.js +76 -0
  382. package/src/materials/MeshLambertMaterial.js +273 -0
  383. package/src/materials/MeshMatcapMaterial.js +142 -0
  384. package/src/materials/MeshNormalMaterial.js +113 -0
  385. package/src/materials/MeshPhongMaterial.js +288 -0
  386. package/src/materials/MeshPhysicalMaterial.js +292 -1
  387. package/src/materials/MeshStandardMaterial.js +297 -0
  388. package/src/materials/MeshToonMaterial.js +218 -0
  389. package/src/materials/PointsMaterial.js +89 -0
  390. package/src/materials/RawShaderMaterial.js +25 -0
  391. package/src/materials/ShaderMaterial.js +215 -6
  392. package/src/materials/ShadowMaterial.js +54 -0
  393. package/src/materials/SpriteMaterial.js +82 -0
  394. package/src/materials/nodes/Line2NodeMaterial.js +1 -1
  395. package/src/materials/nodes/LineBasicNodeMaterial.js +2 -2
  396. package/src/materials/nodes/LineDashedNodeMaterial.js +2 -2
  397. package/src/materials/nodes/MeshBasicNodeMaterial.js +2 -2
  398. package/src/materials/nodes/MeshLambertNodeMaterial.js +2 -2
  399. package/src/materials/nodes/MeshMatcapNodeMaterial.js +2 -2
  400. package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
  401. package/src/materials/nodes/MeshPhongNodeMaterial.js +2 -2
  402. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -2
  403. package/src/materials/nodes/MeshSSSNodeMaterial.js +1 -1
  404. package/src/materials/nodes/MeshStandardNodeMaterial.js +2 -2
  405. package/src/materials/nodes/MeshToonNodeMaterial.js +2 -2
  406. package/src/materials/nodes/NodeMaterial.js +7 -3
  407. package/src/materials/nodes/PointsNodeMaterial.js +1 -1
  408. package/src/materials/nodes/ShadowNodeMaterial.js +11 -2
  409. package/src/materials/nodes/SpriteNodeMaterial.js +1 -1
  410. package/src/materials/nodes/VolumeNodeMaterial.js +10 -1
  411. package/src/math/Color.js +1 -1
  412. package/src/math/MathUtils.js +223 -0
  413. package/src/nodes/Nodes.js +1 -0
  414. package/src/nodes/accessors/BatchNode.js +8 -8
  415. package/src/nodes/accessors/BuiltinNode.js +1 -1
  416. package/src/nodes/accessors/CubeTextureNode.js +1 -1
  417. package/src/nodes/accessors/InstanceNode.js +5 -5
  418. package/src/nodes/accessors/InstancedMeshNode.js +1 -1
  419. package/src/nodes/accessors/MorphNode.js +27 -23
  420. package/src/nodes/accessors/Normal.js +1 -1
  421. package/src/nodes/accessors/Object3DNode.js +12 -12
  422. package/src/nodes/accessors/ReferenceBaseNode.js +2 -2
  423. package/src/nodes/accessors/ReferenceNode.js +1 -1
  424. package/src/nodes/accessors/SkinningNode.js +46 -37
  425. package/src/nodes/accessors/StorageBufferNode.js +1 -1
  426. package/src/nodes/accessors/StorageTextureNode.js +3 -3
  427. package/src/nodes/accessors/Texture3DNode.js +1 -1
  428. package/src/nodes/accessors/TextureNode.js +25 -5
  429. package/src/nodes/accessors/TextureSizeNode.js +1 -1
  430. package/src/nodes/accessors/UniformArrayNode.js +2 -2
  431. package/src/nodes/code/CodeNode.js +4 -4
  432. package/src/nodes/code/ExpressionNode.js +4 -4
  433. package/src/nodes/code/FunctionCallNode.js +23 -3
  434. package/src/nodes/code/ScriptableNode.js +4 -4
  435. package/src/nodes/code/ScriptableValueNode.js +2 -2
  436. package/src/nodes/core/AssignNode.js +1 -1
  437. package/src/nodes/core/AttributeNode.js +1 -1
  438. package/src/nodes/core/BypassNode.js +1 -1
  439. package/src/nodes/core/CacheNode.js +1 -1
  440. package/src/nodes/core/ContextNode.js +1 -1
  441. package/src/nodes/core/InputNode.js +2 -2
  442. package/src/nodes/core/Node.js +14 -2
  443. package/src/nodes/core/NodeBuilder.js +86 -14
  444. package/src/nodes/core/StackNode.js +5 -5
  445. package/src/nodes/core/StructNode.js +1 -1
  446. package/src/nodes/core/StructTypeNode.js +2 -2
  447. package/src/nodes/core/VarNode.js +2 -8
  448. package/src/nodes/core/VaryingNode.js +3 -3
  449. package/src/nodes/display/BlendModes.js +4 -4
  450. package/src/nodes/display/BumpMapNode.js +1 -1
  451. package/src/nodes/display/NormalMapNode.js +1 -1
  452. package/src/nodes/display/PosterizeNode.js +1 -1
  453. package/src/nodes/display/ScreenNode.js +3 -3
  454. package/src/nodes/display/ViewportDepthNode.js +2 -2
  455. package/src/nodes/display/ViewportDepthTextureNode.js +2 -2
  456. package/src/nodes/display/ViewportSharedTextureNode.js +2 -2
  457. package/src/nodes/display/ViewportTextureNode.js +4 -4
  458. package/src/nodes/functions/ShadowMaskModel.js +4 -4
  459. package/src/nodes/functions/material/getParallaxCorrectNormal.js +6 -6
  460. package/src/nodes/geometry/RangeNode.js +1 -1
  461. package/src/nodes/gpgpu/AtomicFunctionNode.js +16 -40
  462. package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
  463. package/src/nodes/gpgpu/ComputeNode.js +30 -2
  464. package/src/nodes/lighting/AnalyticLightNode.js +9 -1
  465. package/src/nodes/lighting/LightsNode.js +3 -3
  466. package/src/nodes/lighting/ShadowNode.js +1 -1
  467. package/src/nodes/math/ConditionalNode.js +20 -3
  468. package/src/nodes/math/MathNode.js +83 -78
  469. package/src/nodes/math/OperatorNode.js +171 -82
  470. package/src/nodes/pmrem/PMREMNode.js +4 -4
  471. package/src/nodes/pmrem/PMREMUtils.js +2 -2
  472. package/src/nodes/tsl/TSLBase.js +2 -1
  473. package/src/nodes/tsl/TSLCore.js +115 -12
  474. package/src/nodes/utils/ArrayElementNode.js +3 -1
  475. package/src/nodes/utils/CubeMapNode.js +3 -3
  476. package/src/nodes/utils/DebugNode.js +70 -0
  477. package/src/nodes/utils/EquirectUVNode.js +2 -2
  478. package/src/nodes/utils/JoinNode.js +27 -2
  479. package/src/nodes/utils/LoopNode.js +58 -28
  480. package/src/nodes/utils/MaxMipLevelNode.js +1 -1
  481. package/src/nodes/utils/ReflectorNode.js +2 -2
  482. package/src/nodes/utils/RemapNode.js +6 -6
  483. package/src/nodes/utils/RotateNode.js +1 -1
  484. package/src/nodes/utils/SpriteSheetUVNode.js +3 -3
  485. package/src/nodes/utils/StorageArrayElementNode.js +1 -1
  486. package/src/nodes/utils/TriplanarTexturesNode.js +3 -3
  487. package/src/objects/BatchedMesh.js +4 -4
  488. package/src/objects/InstancedMesh.js +2 -2
  489. package/src/objects/LOD.js +1 -1
  490. package/src/objects/Skeleton.js +1 -1
  491. package/src/renderers/WebGL3DRenderTarget.js +25 -0
  492. package/src/renderers/WebGLArrayRenderTarget.js +25 -0
  493. package/src/renderers/WebGLCubeRenderTarget.js +39 -1
  494. package/src/renderers/WebGLRenderTarget.js +19 -0
  495. package/src/renderers/WebGLRenderer.js +617 -79
  496. package/src/renderers/common/Animation.js +2 -2
  497. package/src/renderers/common/Attributes.js +2 -2
  498. package/src/renderers/common/Backend.js +12 -3
  499. package/src/renderers/common/Background.js +1 -0
  500. package/src/renderers/common/Color4.js +1 -1
  501. package/src/renderers/common/CubeRenderTarget.js +13 -0
  502. package/src/renderers/common/PostProcessing.js +2 -0
  503. package/src/renderers/common/QuadMesh.js +2 -0
  504. package/src/renderers/common/RenderList.js +2 -2
  505. package/src/renderers/common/RenderObject.js +1 -1
  506. package/src/renderers/common/RenderObjects.js +2 -2
  507. package/src/renderers/common/Renderer.js +52 -31
  508. package/src/renderers/common/XRManager.js +333 -10
  509. package/src/renderers/common/extras/PMREMGenerator.js +6 -0
  510. package/src/renderers/common/nodes/NodeBuilderState.js +3 -3
  511. package/src/renderers/shaders/UniformsLib.js +1 -4
  512. package/src/renderers/shaders/UniformsUtils.js +1 -3
  513. package/src/renderers/webgl/WebGLBackground.js +4 -2
  514. package/src/renderers/webgl/WebGLState.js +9 -9
  515. package/src/renderers/webgl-fallback/WebGLBackend.js +25 -26
  516. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -12
  517. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +67 -19
  518. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +1 -1
  519. package/src/renderers/webgpu/WebGPUBackend.js +128 -87
  520. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -11
  521. package/src/renderers/webgpu/WebGPURenderer.js +17 -11
  522. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +4 -4
  523. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +5 -3
  524. package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
  525. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +1 -1
  526. package/src/renderers/webxr/WebXRController.js +87 -2
  527. package/src/renderers/webxr/WebXRDepthSensing.js +49 -0
  528. package/src/renderers/webxr/WebXRManager.js +173 -1
  529. package/src/scenes/Scene.js +2 -1
  530. package/src/textures/CanvasTexture.js +28 -0
  531. package/src/textures/CompressedArrayTexture.js +57 -0
  532. package/src/textures/CompressedCubeTexture.js +29 -0
  533. package/src/textures/CompressedTexture.js +64 -6
  534. package/src/textures/CubeTexture.js +52 -4
  535. package/src/textures/Data3DTexture.js +77 -0
  536. package/src/textures/DataArrayTexture.js +93 -0
  537. package/src/textures/DataTexture.js +65 -0
  538. package/src/textures/DepthTexture.js +59 -9
  539. package/src/textures/FramebufferTexture.js +62 -0
  540. package/src/textures/Source.js +69 -0
  541. package/src/textures/Texture.js +5 -5
  542. package/src/textures/VideoFrameTexture.js +43 -6
  543. package/src/textures/VideoTexture.js +49 -4
  544. package/examples/jsm/geometries/ParametricGeometries.js +0 -254
@@ -55,8 +55,18 @@ import { WebGLUniformsGroups } from './webgl/WebGLUniformsGroups.js';
55
55
  import { createCanvasElement, probeAsync, toNormalizedProjectionMatrix, toReversedProjectionMatrix, warnOnce } from '../utils.js';
56
56
  import { ColorManagement } from '../math/ColorManagement.js';
57
57
 
58
+ /**
59
+ * This renderer uses WebGL 2 to display scenes.
60
+ *
61
+ * WebGL 1 is not supported since `r163`.
62
+ */
58
63
  class WebGLRenderer {
59
64
 
65
+ /**
66
+ * Constructs a new WebGL renderer.
67
+ *
68
+ * @param {WebGLRenderer~Options} [parameters] - The configuration parameter.
69
+ */
60
70
  constructor( parameters = {} ) {
61
71
 
62
72
  const {
@@ -73,6 +83,13 @@ class WebGLRenderer {
73
83
  reverseDepthBuffer = false,
74
84
  } = parameters;
75
85
 
86
+ /**
87
+ * This flag can be used for type testing.
88
+ *
89
+ * @type {boolean}
90
+ * @readonly
91
+ * @default true
92
+ */
76
93
  this.isWebGLRenderer = true;
77
94
 
78
95
  let _alpha;
@@ -107,13 +124,36 @@ class WebGLRenderer {
107
124
 
108
125
  // public properties
109
126
 
127
+ /**
128
+ * A canvas where the renderer draws its output.This is automatically created by the renderer
129
+ * in the constructor (if not provided already); you just need to add it to your page like so:
130
+ * ```js
131
+ * document.body.appendChild( renderer.domElement );
132
+ * ```
133
+ *
134
+ * @type {DOMElement}
135
+ */
110
136
  this.domElement = canvas;
111
137
 
112
- // Debug configuration container
138
+ /**
139
+ * A object with debug configuration settings.
140
+ *
141
+ * - `checkShaderErrors`: If it is `true`, defines whether material shader programs are
142
+ * checked for errors during compilation and linkage process. It may be useful to disable
143
+ * this check in production for performance gain. It is strongly recommended to keep these
144
+ * checks enabled during development. If the shader does not compile and link - it will not
145
+ * work and associated material will not render.
146
+ * - `onShaderError(gl, program, glVertexShader,glFragmentShader)`: A callback function that
147
+ * can be used for custom error reporting. The callback receives the WebGL context, an instance
148
+ * of WebGLProgram as well two instances of WebGLShader representing the vertex and fragment shader.
149
+ * Assigning a custom function disables the default error reporting.
150
+ *
151
+ * @type {Object}
152
+ */
113
153
  this.debug = {
114
154
 
115
155
  /**
116
- * Enables error checking and reporting when shader programs are being compiled
156
+ * Enables error checking and reporting when shader programs are being compiled.
117
157
  * @type {boolean}
118
158
  */
119
159
  checkShaderErrors: true,
@@ -126,29 +166,105 @@ class WebGLRenderer {
126
166
 
127
167
  // clearing
128
168
 
169
+ /**
170
+ * Whether the renderer should automatically clear its output before rendering a frame or not.
171
+ *
172
+ * @type {boolean}
173
+ * @default true
174
+ */
129
175
  this.autoClear = true;
176
+
177
+ /**
178
+ * If {@link WebGLRenderer#autoClear} set to `true`, whether the renderer should clear
179
+ * the color buffer or not.
180
+ *
181
+ * @type {boolean}
182
+ * @default true
183
+ */
130
184
  this.autoClearColor = true;
185
+
186
+ /**
187
+ * If {@link WebGLRenderer#autoClear} set to `true`, whether the renderer should clear
188
+ * the depth buffer or not.
189
+ *
190
+ * @type {boolean}
191
+ * @default true
192
+ */
131
193
  this.autoClearDepth = true;
194
+
195
+ /**
196
+ * If {@link WebGLRenderer#autoClear} set to `true`, whether the renderer should clear
197
+ * the stencil buffer or not.
198
+ *
199
+ * @type {boolean}
200
+ * @default true
201
+ */
132
202
  this.autoClearStencil = true;
133
203
 
134
204
  // scene graph
135
205
 
206
+ /**
207
+ * Whether the renderer should sort objects or not.
208
+ *
209
+ * Note: Sorting is used to attempt to properly render objects that have some
210
+ * degree of transparency. By definition, sorting objects may not work in all
211
+ * cases. Depending on the needs of application, it may be necessary to turn
212
+ * off sorting and use other methods to deal with transparency rendering e.g.
213
+ * manually determining each object's rendering order.
214
+ *
215
+ * @type {boolean}
216
+ * @default true
217
+ */
136
218
  this.sortObjects = true;
137
219
 
138
220
  // user-defined clipping
139
221
 
222
+ /**
223
+ * User-defined clipping planes specified in world space. These planes apply globally.
224
+ * Points in space whose dot product with the plane is negative are cut away.
225
+ *
226
+ * @type {Array<Plane>}
227
+ */
140
228
  this.clippingPlanes = [];
141
- this.localClippingEnabled = false;
142
-
143
- // physically based shading
144
229
 
145
- this._outputColorSpace = SRGBColorSpace;
230
+ /**
231
+ * Whether the renderer respects object-level clipping planes or not.
232
+ *
233
+ * @type {boolean}
234
+ * @default false
235
+ */
236
+ this.localClippingEnabled = false;
146
237
 
147
238
  // tone mapping
148
239
 
240
+ /**
241
+ * The tone mapping technique of the renderer.
242
+ *
243
+ * @type {(NoToneMapping|LinearToneMapping|ReinhardToneMapping|CineonToneMapping|ACESFilmicToneMapping|CustomToneMapping|AgXToneMapping|NeutralToneMapping)}
244
+ * @default NoToneMapping
245
+ */
149
246
  this.toneMapping = NoToneMapping;
247
+
248
+ /**
249
+ * Exposure level of tone mapping.
250
+ *
251
+ * @type {number}
252
+ * @default 1
253
+ */
150
254
  this.toneMappingExposure = 1.0;
151
255
 
256
+ // transmission
257
+
258
+ /**
259
+ * The normalized resolution scale for the transmission render target, measured in percentage
260
+ * of viewport dimensions. Lowering this value can result in significant performance improvements
261
+ * when using {@link MeshPhysicalMaterial#transmission}.
262
+ *
263
+ * @type {number}
264
+ * @default 1
265
+ */
266
+ this.transmissionResolutionScale = 1.0;
267
+
152
268
  // internal properties
153
269
 
154
270
  const _this = this;
@@ -157,6 +273,8 @@ class WebGLRenderer {
157
273
 
158
274
  // internal state cache
159
275
 
276
+ this._outputColorSpace = SRGBColorSpace;
277
+
160
278
  let _currentActiveCubeFace = 0;
161
279
  let _currentActiveMipmapLevel = 0;
162
280
  let _currentRenderTarget = null;
@@ -193,9 +311,6 @@ class WebGLRenderer {
193
311
  let _clippingEnabled = false;
194
312
  let _localClippingEnabled = false;
195
313
 
196
- // transmission render target scale
197
- this.transmissionResolutionScale = 1.0;
198
-
199
314
  // camera matrices cache
200
315
 
201
316
  const _currentProjectionMatrix = new Matrix4();
@@ -324,12 +439,79 @@ class WebGLRenderer {
324
439
 
325
440
  info.programs = programCache.programs;
326
441
 
442
+ /**
443
+ * Holds details about the capabilities of the current rendering context.
444
+ *
445
+ * @name WebGLRenderer#capabilities
446
+ * @type {WebGLRenderer~Capabilities}
447
+ */
327
448
  _this.capabilities = capabilities;
449
+
450
+ /**
451
+ * Provides methods for retrieving and testing WebGL extensions.
452
+ *
453
+ * - `get(extensionName:string)`: Used to check whether a WebGL extension is supported
454
+ * and return the extension object if available.
455
+ * - `has(extensionName:string)`: returns `true` if the extension is supported.
456
+ *
457
+ * @name WebGLRenderer#extensions
458
+ * @type {Object}
459
+ */
328
460
  _this.extensions = extensions;
461
+
462
+ /**
463
+ * Used to track properties of other objects like native WebGL objects.
464
+ *
465
+ * @name WebGLRenderer#properties
466
+ * @type {Object}
467
+ */
329
468
  _this.properties = properties;
469
+
470
+ /**
471
+ * Manages the render lists of the renderer.
472
+ *
473
+ * @name WebGLRenderer#renderLists
474
+ * @type {Object}
475
+ */
330
476
  _this.renderLists = renderLists;
477
+
478
+
479
+
480
+ /**
481
+ * Interface for managing shadows.
482
+ *
483
+ * @name WebGLRenderer#shadowMap
484
+ * @type {WebGLRenderer~ShadowMap}
485
+ */
331
486
  _this.shadowMap = shadowMap;
487
+
488
+ /**
489
+ * Interface for managing the WebGL state.
490
+ *
491
+ * @name WebGLRenderer#state
492
+ * @type {Object}
493
+ */
332
494
  _this.state = state;
495
+
496
+ /**
497
+ * Holds a series of statistical information about the GPU memory
498
+ * and the rendering process. Useful for debugging and monitoring.
499
+ *
500
+ * By default these data are reset at each render call but when having
501
+ * multiple render passes per frame (e.g. when using post processing) it can
502
+ * be preferred to reset with a custom pattern. First, set `autoReset` to
503
+ * `false`.
504
+ * ```js
505
+ * renderer.info.autoReset = false;
506
+ * ```
507
+ * Call `reset()` whenever you have finished to render a single frame.
508
+ * ```js
509
+ * renderer.info.reset();
510
+ * ```
511
+ *
512
+ * @name WebGLRenderer#info
513
+ * @type {WebGLRenderer~Info}
514
+ */
333
515
  _this.info = info;
334
516
 
335
517
  }
@@ -340,22 +522,38 @@ class WebGLRenderer {
340
522
 
341
523
  const xr = new WebXRManager( _this, _gl );
342
524
 
525
+ /**
526
+ * A reference to the XR manager.
527
+ *
528
+ * @type {WebXRManager}
529
+ */
343
530
  this.xr = xr;
344
531
 
345
- // API
346
-
532
+ /**
533
+ * Returns the rendering context.
534
+ *
535
+ * @return {WebGL2RenderingContext} The rendering context.
536
+ */
347
537
  this.getContext = function () {
348
538
 
349
539
  return _gl;
350
540
 
351
541
  };
352
542
 
543
+ /**
544
+ * Returns the rendering context attributes.
545
+ *
546
+ * @return {WebGLContextAttributes} The rendering context attributes.
547
+ */
353
548
  this.getContextAttributes = function () {
354
549
 
355
550
  return _gl.getContextAttributes();
356
551
 
357
552
  };
358
553
 
554
+ /**
555
+ * Simulates a loss of the WebGL context. This requires support for the `WEBGL_lose_context` extension.
556
+ */
359
557
  this.forceContextLoss = function () {
360
558
 
361
559
  const extension = extensions.get( 'WEBGL_lose_context' );
@@ -363,6 +561,9 @@ class WebGLRenderer {
363
561
 
364
562
  };
365
563
 
564
+ /**
565
+ * Simulates a restore of the WebGL context. This requires support for the `WEBGL_lose_context` extension.
566
+ */
366
567
  this.forceContextRestore = function () {
367
568
 
368
569
  const extension = extensions.get( 'WEBGL_lose_context' );
@@ -370,12 +571,22 @@ class WebGLRenderer {
370
571
 
371
572
  };
372
573
 
574
+ /**
575
+ * Returns the pixel ratio.
576
+ *
577
+ * @return {number} The pixel ratio.
578
+ */
373
579
  this.getPixelRatio = function () {
374
580
 
375
581
  return _pixelRatio;
376
582
 
377
583
  };
378
584
 
585
+ /**
586
+ * Sets the given pixel ratio and resizes the canvas if necessary.
587
+ *
588
+ * @param {number} value - The pixel ratio.
589
+ */
379
590
  this.setPixelRatio = function ( value ) {
380
591
 
381
592
  if ( value === undefined ) return;
@@ -386,12 +597,27 @@ class WebGLRenderer {
386
597
 
387
598
  };
388
599
 
600
+ /**
601
+ * Returns the renderer's size in logical pixels. This method does not honor the pixel ratio.
602
+ *
603
+ * @param {Vector2} target - The method writes the result in this target object.
604
+ * @return {Vector2} The renderer's size in logical pixels.
605
+ */
389
606
  this.getSize = function ( target ) {
390
607
 
391
608
  return target.set( _width, _height );
392
609
 
393
610
  };
394
611
 
612
+ /**
613
+ * Resizes the output canvas to (width, height) with device pixel ratio taken
614
+ * into account, and also sets the viewport to fit that size, starting in (0,
615
+ * 0). Setting `updateStyle` to false prevents any style changes to the output canvas.
616
+ *
617
+ * @param {number} width - The width in logical pixels.
618
+ * @param {number} height - The height in logical pixels.
619
+ * @param {boolean} [updateStyle=true] - Whether to update the `style` attribute of the canvas or not.
620
+ */
395
621
  this.setSize = function ( width, height, updateStyle = true ) {
396
622
 
397
623
  if ( xr.isPresenting ) {
@@ -418,12 +644,31 @@ class WebGLRenderer {
418
644
 
419
645
  };
420
646
 
647
+ /**
648
+ * Returns the drawing buffer size in physical pixels. This method honors the pixel ratio.
649
+ *
650
+ * @param {Vector2} target - The method writes the result in this target object.
651
+ * @return {Vector2} The drawing buffer size.
652
+ */
421
653
  this.getDrawingBufferSize = function ( target ) {
422
654
 
423
655
  return target.set( _width * _pixelRatio, _height * _pixelRatio ).floor();
424
656
 
425
657
  };
426
658
 
659
+ /**
660
+ * This method allows to define the drawing buffer size by specifying
661
+ * width, height and pixel ratio all at once. The size of the drawing
662
+ * buffer is computed with this formula:
663
+ * ```js
664
+ * size.x = width * pixelRatio;
665
+ * size.y = height * pixelRatio;
666
+ * ```
667
+ *
668
+ * @param {number} width - The width in logical pixels.
669
+ * @param {number} height - The height in logical pixels.
670
+ * @param {number} pixelRatio - The pixel ratio.
671
+ */
427
672
  this.setDrawingBufferSize = function ( width, height, pixelRatio ) {
428
673
 
429
674
  _width = width;
@@ -438,18 +683,39 @@ class WebGLRenderer {
438
683
 
439
684
  };
440
685
 
686
+ /**
687
+ * Returns the current viewport definition.
688
+ *
689
+ * @param {Vector2} target - The method writes the result in this target object.
690
+ * @return {Vector2} The current viewport definition.
691
+ */
441
692
  this.getCurrentViewport = function ( target ) {
442
693
 
443
694
  return target.copy( _currentViewport );
444
695
 
445
696
  };
446
697
 
698
+ /**
699
+ * Returns the viewport definition.
700
+ *
701
+ * @param {Vector4} target - The method writes the result in this target object.
702
+ * @return {Vector4} The viewport definition.
703
+ */
447
704
  this.getViewport = function ( target ) {
448
705
 
449
706
  return target.copy( _viewport );
450
707
 
451
708
  };
452
709
 
710
+ /**
711
+ * Sets the viewport to render from `(x, y)` to `(x + width, y + height)`.
712
+ *
713
+ * @param {number | Vector4} x - The horizontal coordinate for the lower left corner of the viewport origin in logical pixel unit.
714
+ * Or alternatively a four-component vector specifying all the parameters of the viewport.
715
+ * @param {number} y - The vertical coordinate for the lower left corner of the viewport origin in logical pixel unit.
716
+ * @param {number} width - The width of the viewport in logical pixel unit.
717
+ * @param {number} height - The height of the viewport in logical pixel unit.
718
+ */
453
719
  this.setViewport = function ( x, y, width, height ) {
454
720
 
455
721
  if ( x.isVector4 ) {
@@ -466,12 +732,27 @@ class WebGLRenderer {
466
732
 
467
733
  };
468
734
 
735
+ /**
736
+ * Returns the scissor region.
737
+ *
738
+ * @param {Vector4} target - The method writes the result in this target object.
739
+ * @return {Vector4} The scissor region.
740
+ */
469
741
  this.getScissor = function ( target ) {
470
742
 
471
743
  return target.copy( _scissor );
472
744
 
473
745
  };
474
746
 
747
+ /**
748
+ * Sets the scissor region to render from `(x, y)` to `(x + width, y + height)`.
749
+ *
750
+ * @param {number | Vector4} x - The horizontal coordinate for the lower left corner of the scissor region origin in logical pixel unit.
751
+ * Or alternatively a four-component vector specifying all the parameters of the scissor region.
752
+ * @param {number} y - The vertical coordinate for the lower left corner of the scissor region origin in logical pixel unit.
753
+ * @param {number} width - The width of the scissor region in logical pixel unit.
754
+ * @param {number} height - The height of the scissor region in logical pixel unit.
755
+ */
475
756
  this.setScissor = function ( x, y, width, height ) {
476
757
 
477
758
  if ( x.isVector4 ) {
@@ -488,24 +769,48 @@ class WebGLRenderer {
488
769
 
489
770
  };
490
771
 
772
+ /**
773
+ * Returns `true` if the scissor test is enabled.
774
+ *
775
+ * @return {boolean} Whether the scissor test is enabled or not.
776
+ */
491
777
  this.getScissorTest = function () {
492
778
 
493
779
  return _scissorTest;
494
780
 
495
781
  };
496
782
 
783
+ /**
784
+ * Enable or disable the scissor test. When this is enabled, only the pixels
785
+ * within the defined scissor area will be affected by further renderer
786
+ * actions.
787
+ *
788
+ * @param {boolean} boolean - Whether the scissor test is enabled or not.
789
+ */
497
790
  this.setScissorTest = function ( boolean ) {
498
791
 
499
792
  state.setScissorTest( _scissorTest = boolean );
500
793
 
501
794
  };
502
795
 
796
+ /**
797
+ * Sets a custom opaque sort function for the render lists. Pass `null`
798
+ * to use the default `painterSortStable` function.
799
+ *
800
+ * @param {?Function} method - The opaque sort function.
801
+ */
503
802
  this.setOpaqueSort = function ( method ) {
504
803
 
505
804
  _opaqueSort = method;
506
805
 
507
806
  };
508
807
 
808
+ /**
809
+ * Sets a custom transparent sort function for the render lists. Pass `null`
810
+ * to use the default `reversePainterSortStable` function.
811
+ *
812
+ * @param {?Function} method - The opaque sort function.
813
+ */
509
814
  this.setTransparentSort = function ( method ) {
510
815
 
511
816
  _transparentSort = method;
@@ -514,30 +819,60 @@ class WebGLRenderer {
514
819
 
515
820
  // Clearing
516
821
 
822
+ /**
823
+ * Returns the clear color.
824
+ *
825
+ * @param {Color} target - The method writes the result in this target object.
826
+ * @return {Color} The clear color.
827
+ */
517
828
  this.getClearColor = function ( target ) {
518
829
 
519
830
  return target.copy( background.getClearColor() );
520
831
 
521
832
  };
522
833
 
834
+ /**
835
+ * Sets the clear color and alpha.
836
+ *
837
+ * @param {Color} color - The clear color.
838
+ * @param {number} [alpha=1] - The clear alpha.
839
+ */
523
840
  this.setClearColor = function () {
524
841
 
525
842
  background.setClearColor( ...arguments );
526
843
 
527
844
  };
528
845
 
846
+ /**
847
+ * Returns the clear alpha. Ranges within `[0,1]`.
848
+ *
849
+ * @return {number} The clear alpha.
850
+ */
529
851
  this.getClearAlpha = function () {
530
852
 
531
853
  return background.getClearAlpha();
532
854
 
533
855
  };
534
856
 
857
+ /**
858
+ * Sets the clear alpha.
859
+ *
860
+ * @param {number} alpha - The clear alpha.
861
+ */
535
862
  this.setClearAlpha = function () {
536
863
 
537
864
  background.setClearAlpha( ...arguments );
538
865
 
539
866
  };
540
867
 
868
+ /**
869
+ * Tells the renderer to clear its color, depth or stencil drawing buffer(s).
870
+ * This method initializes the buffers to the current clear color values.
871
+ *
872
+ * @param {boolean} [color=true] - Whether the color buffer should be cleared or not.
873
+ * @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not.
874
+ * @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not.
875
+ */
541
876
  this.clear = function ( color = true, depth = true, stencil = true ) {
542
877
 
543
878
  let bits = 0;
@@ -616,26 +951,37 @@ class WebGLRenderer {
616
951
 
617
952
  };
618
953
 
954
+ /**
955
+ * Clears the color buffer. Equivalent to calling `renderer.clear( true, false, false )`.
956
+ */
619
957
  this.clearColor = function () {
620
958
 
621
959
  this.clear( true, false, false );
622
960
 
623
961
  };
624
962
 
963
+ /**
964
+ * Clears the depth buffer. Equivalent to calling `renderer.clear( false, true, false )`.
965
+ */
625
966
  this.clearDepth = function () {
626
967
 
627
968
  this.clear( false, true, false );
628
969
 
629
970
  };
630
971
 
972
+ /**
973
+ * Clears the stencil buffer. Equivalent to calling `renderer.clear( false, false, true )`.
974
+ */
631
975
  this.clearStencil = function () {
632
976
 
633
977
  this.clear( false, false, true );
634
978
 
635
979
  };
636
980
 
637
- //
638
-
981
+ /**
982
+ * Frees the GPU-related resources allocated by this instance. Call this
983
+ * method whenever this instance is no longer used in your app.
984
+ */
639
985
  this.dispose = function () {
640
986
 
641
987
  canvas.removeEventListener( 'webglcontextlost', onContextLost, false );
@@ -941,6 +1287,18 @@ class WebGLRenderer {
941
1287
 
942
1288
  }
943
1289
 
1290
+ /**
1291
+ * Compiles all materials in the scene with the camera. This is useful to precompile shaders
1292
+ * before the first rendering. If you want to add a 3D object to an existing scene, use the third
1293
+ * optional parameter for applying the target scene.
1294
+ *
1295
+ * Note that the (target) scene's lighting and environment must be configured before calling this method.
1296
+ *
1297
+ * @param {Object3D} scene - The scene or another type of 3D object to precompile.
1298
+ * @param {Camera} camera - The camera.
1299
+ * @param {?Scene} [targetScene=null] - The target scene.
1300
+ * @return {?Set} The precompiled materials.
1301
+ */
944
1302
  this.compile = function ( scene, camera, targetScene = null ) {
945
1303
 
946
1304
  if ( targetScene === null ) targetScene = scene;
@@ -1036,6 +1394,18 @@ class WebGLRenderer {
1036
1394
 
1037
1395
  // compileAsync
1038
1396
 
1397
+ /**
1398
+ * Asynchronous version of {@link WebGLRenderer#compile}.
1399
+ *
1400
+ * This method makes use of the `KHR_parallel_shader_compile` WebGL extension. Hence,
1401
+ * it is recommended to use this version of `compile()` whenever possible.
1402
+ *
1403
+ * @async
1404
+ * @param {Object3D} scene - The scene or another type of 3D object to precompile.
1405
+ * @param {Camera} camera - The camera.
1406
+ * @param {?Scene} [targetScene=null] - The target scene.
1407
+ * @return {Promise} A Promise that resolves when the given scene can be rendered without unnecessary stalling due to shader compilation.
1408
+ */
1039
1409
  this.compileAsync = function ( scene, camera, targetScene = null ) {
1040
1410
 
1041
1411
  const materials = this.compile( scene, camera, targetScene );
@@ -1137,6 +1507,20 @@ class WebGLRenderer {
1137
1507
 
1138
1508
  // Rendering
1139
1509
 
1510
+ /**
1511
+ * Renders the given scene (or other type of 3D object) using the given camera.
1512
+ *
1513
+ * The render is done to a previously specified render target set by calling {@link WebGLRenderer#setRenderTarget}
1514
+ * or to the canvas as usual.
1515
+ *
1516
+ * By default render buffers are cleared before rendering but you can prevent
1517
+ * this by setting the property `autoClear` to `false`. If you want to prevent
1518
+ * only certain buffers being cleared you can `autoClearColor`, `autoClearDepth`
1519
+ * or `autoClearStencil` to `false`. To force a clear, use {@link WebGLRenderer#clear}.
1520
+ *
1521
+ * @param {Object3D} scene - The scene to render.
1522
+ * @param {Camera} camera - The camera.
1523
+ */
1140
1524
  this.render = function ( scene, camera ) {
1141
1525
 
1142
1526
  if ( camera !== undefined && camera.isCamera !== true ) {
@@ -1595,8 +1979,14 @@ class WebGLRenderer {
1595
1979
 
1596
1980
  const object = renderItem.object;
1597
1981
  const geometry = renderItem.geometry;
1598
- const material = overrideMaterial === null ? renderItem.material : overrideMaterial;
1599
1982
  const group = renderItem.group;
1983
+ let material = renderItem.material;
1984
+
1985
+ if ( material.allowOverride === true && overrideMaterial !== null ) {
1986
+
1987
+ material = overrideMaterial;
1988
+
1989
+ }
1600
1990
 
1601
1991
  if ( object.layers.test( camera.layers ) ) {
1602
1992
 
@@ -2233,18 +2623,34 @@ class WebGLRenderer {
2233
2623
 
2234
2624
  }
2235
2625
 
2626
+ /**
2627
+ * Returns the active cube face.
2628
+ *
2629
+ * @return {number} The active cube face.
2630
+ */
2236
2631
  this.getActiveCubeFace = function () {
2237
2632
 
2238
2633
  return _currentActiveCubeFace;
2239
2634
 
2240
2635
  };
2241
2636
 
2637
+ /**
2638
+ * Returns the active mipmap level.
2639
+ *
2640
+ * @return {number} The active mipmap level.
2641
+ */
2242
2642
  this.getActiveMipmapLevel = function () {
2243
2643
 
2244
2644
  return _currentActiveMipmapLevel;
2245
2645
 
2246
2646
  };
2247
2647
 
2648
+ /**
2649
+ * Returns the active render target.
2650
+ *
2651
+ * @return {?WebGLRenderTarget} The active render target. Returns `null` if no render target
2652
+ * is currently set.
2653
+ */
2248
2654
  this.getRenderTarget = function () {
2249
2655
 
2250
2656
  return _currentRenderTarget;
@@ -2253,26 +2659,21 @@ class WebGLRenderer {
2253
2659
 
2254
2660
  this.setRenderTargetTextures = function ( renderTarget, colorTexture, depthTexture ) {
2255
2661
 
2256
- properties.get( renderTarget.texture ).__webglTexture = colorTexture;
2257
- properties.get( renderTarget.depthTexture ).__webglTexture = depthTexture;
2258
-
2259
2662
  const renderTargetProperties = properties.get( renderTarget );
2260
- renderTargetProperties.__hasExternalTextures = true;
2261
2663
 
2262
- renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
2263
-
2264
- if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
2664
+ renderTargetProperties.__autoAllocateDepthBuffer = renderTarget.resolveDepthBuffer === false;
2665
+ if ( renderTargetProperties.__autoAllocateDepthBuffer === false ) {
2265
2666
 
2266
2667
  // The multisample_render_to_texture extension doesn't work properly if there
2267
2668
  // are midframe flushes and an external depth buffer. Disable use of the extension.
2268
- if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
2669
+ renderTargetProperties.__useRenderToTexture = false;
2269
2670
 
2270
- console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
2271
- renderTargetProperties.__useRenderToTexture = false;
2671
+ }
2272
2672
 
2273
- }
2673
+ properties.get( renderTarget.texture ).__webglTexture = colorTexture;
2674
+ properties.get( renderTarget.depthTexture ).__webglTexture = renderTargetProperties.__autoAllocateDepthBuffer ? undefined : depthTexture;
2274
2675
 
2275
- }
2676
+ renderTargetProperties.__hasExternalTextures = true;
2276
2677
 
2277
2678
  };
2278
2679
 
@@ -2285,6 +2686,16 @@ class WebGLRenderer {
2285
2686
  };
2286
2687
 
2287
2688
  const _scratchFrameBuffer = _gl.createFramebuffer();
2689
+
2690
+ /**
2691
+ * Sets the active rendertarget.
2692
+ *
2693
+ * @param {?WebGLRenderTarget} renderTarget - The render target to set. When `null` is given,
2694
+ * the canvas is set as the active render target instead.
2695
+ * @param {number} [activeCubeFace=0] - The active cube face when using a cube render target.
2696
+ * Indicates the z layer to render in to when using 3D or array render targets.
2697
+ * @param {number} [activeMipmapLevel=0] - The active mipmap level.
2698
+ */
2288
2699
  this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {
2289
2700
 
2290
2701
  _currentRenderTarget = renderTarget;
@@ -2437,6 +2848,17 @@ class WebGLRenderer {
2437
2848
 
2438
2849
  };
2439
2850
 
2851
+ /**
2852
+ * Reads the pixel data from the given render target into the given buffer.
2853
+ *
2854
+ * @param {WebGLRenderTarget} renderTarget - The render target to read from.
2855
+ * @param {number} x - The `x` coordinate of the copy region's origin.
2856
+ * @param {number} y - The `y` coordinate of the copy region's origin.
2857
+ * @param {number} width - The width of the copy region.
2858
+ * @param {number} height - The height of the copy region.
2859
+ * @param {TypedArray} buffer - The result buffer.
2860
+ * @param {number} [activeCubeFaceIndex] - The active cube face index.
2861
+ */
2440
2862
  this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
2441
2863
 
2442
2864
  if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
@@ -2499,6 +2921,21 @@ class WebGLRenderer {
2499
2921
 
2500
2922
  };
2501
2923
 
2924
+ /**
2925
+ * Asynchronous, non-blocking version of {@link WebGLRenderer#readRenderTargetPixels}.
2926
+ *
2927
+ * It is recommended to use this version of `readRenderTargetPixels()` whenever possible.
2928
+ *
2929
+ * @async
2930
+ * @param {WebGLRenderTarget} renderTarget - The render target to read from.
2931
+ * @param {number} x - The `x` coordinate of the copy region's origin.
2932
+ * @param {number} y - The `y` coordinate of the copy region's origin.
2933
+ * @param {number} width - The width of the copy region.
2934
+ * @param {number} height - The height of the copy region.
2935
+ * @param {TypedArray} buffer - The result buffer.
2936
+ * @param {number} [activeCubeFaceIndex] - The active cube face index.
2937
+ * @return {Promise<TypedArray>} A Promise that resolves when the read has been finished. The resolve provides the read data as a typed array.
2938
+ */
2502
2939
  this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
2503
2940
 
2504
2941
  if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
@@ -2516,27 +2953,27 @@ class WebGLRenderer {
2516
2953
 
2517
2954
  if ( framebuffer ) {
2518
2955
 
2519
- const texture = renderTarget.texture;
2520
- const textureFormat = texture.format;
2521
- const textureType = texture.type;
2956
+ // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
2957
+ if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
2522
2958
 
2523
- if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
2959
+ // set the active frame buffer to the one we want to read
2960
+ state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
2524
2961
 
2525
- throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
2962
+ const texture = renderTarget.texture;
2963
+ const textureFormat = texture.format;
2964
+ const textureType = texture.type;
2526
2965
 
2527
- }
2966
+ if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
2528
2967
 
2529
- if ( ! capabilities.textureTypeReadable( textureType ) ) {
2968
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
2530
2969
 
2531
- throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
2970
+ }
2532
2971
 
2533
- }
2972
+ if ( ! capabilities.textureTypeReadable( textureType ) ) {
2534
2973
 
2535
- // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
2536
- if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
2974
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
2537
2975
 
2538
- // set the active frame buffer to the one we want to read
2539
- state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
2976
+ }
2540
2977
 
2541
2978
  const glBuffer = _gl.createBuffer();
2542
2979
  _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
@@ -2572,19 +3009,15 @@ class WebGLRenderer {
2572
3009
 
2573
3010
  };
2574
3011
 
3012
+ /**
3013
+ * Copies pixels from the current bound framebuffer into the given texture.
3014
+ *
3015
+ * @param {FramebufferTexture} texture - The texture.
3016
+ * @param {Vector2} position - The start position of the copy operation.
3017
+ * @param {number} [level=0] - The mip level. The default represents the base mip.
3018
+ */
2575
3019
  this.copyFramebufferToTexture = function ( texture, position = null, level = 0 ) {
2576
3020
 
2577
- // support previous signature with position first
2578
- if ( texture.isTexture !== true ) {
2579
-
2580
- // @deprecated, r165
2581
- warnOnce( 'WebGLRenderer: copyFramebufferToTexture function signature has changed.' );
2582
-
2583
- position = arguments[ 0 ] || null;
2584
- texture = arguments[ 1 ];
2585
-
2586
- }
2587
-
2588
3021
  const levelScale = Math.pow( 2, - level );
2589
3022
  const width = Math.floor( texture.image.width * levelScale );
2590
3023
  const height = Math.floor( texture.image.height * levelScale );
@@ -2602,21 +3035,21 @@ class WebGLRenderer {
2602
3035
 
2603
3036
  const _srcFramebuffer = _gl.createFramebuffer();
2604
3037
  const _dstFramebuffer = _gl.createFramebuffer();
2605
- this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel = null ) {
2606
-
2607
- // support previous signature with dstPosition first
2608
- if ( srcTexture.isTexture !== true ) {
2609
-
2610
- // @deprecated, r165
2611
- warnOnce( 'WebGLRenderer: copyTextureToTexture function signature has changed.' );
2612
3038
 
2613
- dstPosition = arguments[ 0 ] || null;
2614
- srcTexture = arguments[ 1 ];
2615
- dstTexture = arguments[ 2 ];
2616
- dstLevel = arguments[ 3 ] || 0;
2617
- srcRegion = null;
2618
-
2619
- }
3039
+ /**
3040
+ * Copies data of the given source texture into a destination texture.
3041
+ *
3042
+ * When using render target textures as `srcTexture` and `dstTexture`, you must make sure both render targets are initialized
3043
+ * {@link WebGLRenderer#initRenderTarget}.
3044
+ *
3045
+ * @param {Texture} srcTexture - The source texture.
3046
+ * @param {Texture} dstTexture - The destination texture.
3047
+ * @param {Box2|Box3} [srcRegion=null] - A bounding box which describes the source region. Can be two or three-dimensional.
3048
+ * @param {Vector2|Vector3} [dstPosition=null] - A vector that represents the origin of the destination region. Can be two or three-dimensional.
3049
+ * @param {number} srcLevel - The source mipmap level to copy.
3050
+ * @param {number} dstLevel - The destination mipmap level.
3051
+ */
3052
+ this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel = null ) {
2620
3053
 
2621
3054
  // support the previous signature with just a single dst mipmap level
2622
3055
  if ( dstLevel === null ) {
@@ -2870,20 +3303,6 @@ class WebGLRenderer {
2870
3303
 
2871
3304
  this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
2872
3305
 
2873
- // support previous signature with source box first
2874
- if ( srcTexture.isTexture !== true ) {
2875
-
2876
- // @deprecated, r165
2877
- warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
2878
-
2879
- srcRegion = arguments[ 0 ] || null;
2880
- dstPosition = arguments[ 1 ] || null;
2881
- srcTexture = arguments[ 2 ];
2882
- dstTexture = arguments[ 3 ];
2883
- level = arguments[ 4 ] || 0;
2884
-
2885
- }
2886
-
2887
3306
  // @deprecated, r170
2888
3307
  warnOnce( 'WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.' );
2889
3308
 
@@ -2891,6 +3310,13 @@ class WebGLRenderer {
2891
3310
 
2892
3311
  };
2893
3312
 
3313
+ /**
3314
+ * Initializes the given WebGLRenderTarget memory. Useful for initializing a render target so data
3315
+ * can be copied into it using {@link WebGLRenderer#copyTextureToTexture} before it has been
3316
+ * rendered to.
3317
+ *
3318
+ * @param {WebGLRenderTarget} target - The render target.
3319
+ */
2894
3320
  this.initRenderTarget = function ( target ) {
2895
3321
 
2896
3322
  if ( properties.get( target ).__webglFramebuffer === undefined ) {
@@ -2901,6 +3327,12 @@ class WebGLRenderer {
2901
3327
 
2902
3328
  };
2903
3329
 
3330
+ /**
3331
+ * Initializes the given texture. Useful for preloading a texture rather than waiting until first
3332
+ * render (which can cause noticeable lags due to decode and GPU upload overhead).
3333
+ *
3334
+ * @param {Texture} texture - The texture.
3335
+ */
2904
3336
  this.initTexture = function ( texture ) {
2905
3337
 
2906
3338
  if ( texture.isCubeTexture ) {
@@ -2925,6 +3357,11 @@ class WebGLRenderer {
2925
3357
 
2926
3358
  };
2927
3359
 
3360
+ /**
3361
+ * Can be used to reset the internal WebGL state. This method is mostly
3362
+ * relevant for applications which share a single WebGL context across
3363
+ * multiple WebGL libraries.
3364
+ */
2928
3365
  this.resetState = function () {
2929
3366
 
2930
3367
  _currentActiveCubeFace = 0;
@@ -2944,12 +3381,27 @@ class WebGLRenderer {
2944
3381
 
2945
3382
  }
2946
3383
 
3384
+ /**
3385
+ * Defines the coordinate system of the renderer.
3386
+ *
3387
+ * In `WebGLRenderer`, the value is always `WebGLCoordinateSystem`.
3388
+ *
3389
+ * @type {WebGLCoordinateSystem|WebGPUCoordinateSystem}
3390
+ * @default WebGLCoordinateSystem
3391
+ * @readonly
3392
+ */
2947
3393
  get coordinateSystem() {
2948
3394
 
2949
3395
  return WebGLCoordinateSystem;
2950
3396
 
2951
3397
  }
2952
3398
 
3399
+ /**
3400
+ * Defines the output color space of the renderer.
3401
+ *
3402
+ * @type {SRGBColorSpace|LinearSRGBColorSpace}
3403
+ * @default SRGBColorSpace
3404
+ */
2953
3405
  get outputColorSpace() {
2954
3406
 
2955
3407
  return this._outputColorSpace;
@@ -2961,12 +3413,98 @@ class WebGLRenderer {
2961
3413
  this._outputColorSpace = colorSpace;
2962
3414
 
2963
3415
  const gl = this.getContext();
2964
- gl.drawingBufferColorspace = ColorManagement._getDrawingBufferColorSpace( colorSpace );
3416
+ gl.drawingBufferColorSpace = ColorManagement._getDrawingBufferColorSpace( colorSpace );
2965
3417
  gl.unpackColorSpace = ColorManagement._getUnpackColorSpace();
2966
3418
 
2967
3419
  }
2968
3420
 
2969
3421
  }
2970
3422
 
3423
+ // JSDoc
3424
+
3425
+ /**
3426
+ * WebGLRenderer options.
3427
+ *
3428
+ * @typedef {Object} WebGLRenderer~Options
3429
+ * @property {DOMElement} [canvas=null] - A canvas element where the renderer draws its output. If not passed in here, a new canvas element will be created by the renderer.
3430
+ * @property {WebGL2RenderingContext} [context=null] - Can be used to attach an existing rendering context to this renderer.
3431
+ * @property {('highp'|'mediump'|'lowp')} [precision='highp'] - The default shader precision. Uses `highp` if supported by the device.
3432
+ * @property {boolean} [alpha=false] - Controls the default clear alpha value. When set to`true`, the value is `0`. Otherwise it's `1`.
3433
+ * @property {boolean} [premultipliedAlpha=true] Whether the renderer will assume colors have premultiplied alpha or not.
3434
+ * @property {boolean} [antialias=false] Whether to use the default MSAA or not.
3435
+ * @property {boolean} [stencil=false] Whether the drawing buffer has a stencil buffer of at least 8 bits or not.
3436
+ * @property {boolean} [preserveDrawingBuffer=false] Whether to preserve the buffer until manually cleared or overwritten.
3437
+ * @property {('default'|'low-power'|'high-performance')} [powerPreference='default'] Provides a hint to the user agent indicating what configuration of GPU is suitable for this WebGL context.
3438
+ * @property {boolean} [failIfMajorPerformanceCaveat=false] Whether the renderer creation will fail upon low performance is detected.
3439
+ * @property {boolean} [depth=true] Whether the drawing buffer has a depth buffer of at least 16 bits.
3440
+ * @property {boolean} [logarithmicDepthBuffer=false] Whether to use a logarithmic depth buffer. It may be necessary to use this if dealing with huge differences in scale in a single scene.
3441
+ * Note that this setting uses `gl_FragDepth` if available which disables the Early Fragment Test optimization and can cause a decrease in performance.
3442
+ * @property {boolean} [reverseDepthBuffer=false] Whether to use a reverse depth buffer. Requires the `EXT_clip_control` extension.
3443
+ * This is a more faster and accurate version than logarithmic depth buffer.
3444
+ **/
3445
+
3446
+ /**
3447
+ * WebGLRenderer Capabilities.
3448
+ *
3449
+ * @typedef {Object} WebGLRenderer~Capabilities
3450
+ * @property {Function} getMaxAnisotropy - Returns the maximum available anisotropy.
3451
+ * @property {Function} getMaxPrecision - Returns the maximum available precision for vertex and fragment shaders.
3452
+ * @property {boolean} logarithmicDepthBuffer - `true` if `logarithmicDepthBuffer` was set to `true` in the constructor.
3453
+ * @property {number} maxAttributes - The number of shader attributes that can be used by the vertex shader.
3454
+ * @property {number} maxCubemapSize - Maximum height * width of cube map textures that a shader can use.
3455
+ * @property {number} maxFragmentUniforms - The number of uniforms that can be used by a fragment shader.
3456
+ * @property {number} maxSamples - Maximum number of samples in context of Multisample anti-aliasing (MSAA).
3457
+ * @property {number} maxTextures - The maximum number of textures that can be used by a shader.
3458
+ * @property {number} maxTextureSize - Maximum height * width of a texture that a shader use.
3459
+ * @property {number} maxVaryings - The number of varying vectors that can used by shaders.
3460
+ * @property {number} maxVertexTextures - The number of textures that can be used in a vertex shader.
3461
+ * @property {number} maxVertexUniforms - The maximum number of uniforms that can be used in a vertex shader.
3462
+ * @property {string} precision - The shader precision currently being used by the renderer.
3463
+ * @property {boolean} reverseDepthBuffer - `true` if `reverseDepthBuffer` was set to `true` in the constructor
3464
+ * and the rendering context supports `EXT_clip_control`.
3465
+ * @property {boolean} vertexTextures - `true` if vertex textures can be used.
3466
+ **/
3467
+
3468
+ /**
3469
+ * WebGLRenderer Info Memory
3470
+ *
3471
+ * @typedef {Object} WebGLRenderer~InfoMemory
3472
+ * @property {number} geometries - The number of active geometries.
3473
+ * @property {number} textures - The number of active textures.
3474
+ **/
3475
+
3476
+ /**
3477
+ * WebGLRenderer Info Render
3478
+ *
3479
+ * @typedef {Object} WebGLRenderer~InfoRender
3480
+ * @property {number} frame - The frame ID.
3481
+ * @property {number} calls - The number of draw calls per frame.
3482
+ * @property {number} triangles - The number of rendered triangles primitives per frame.
3483
+ * @property {number} points - The number of rendered points primitives per frame.
3484
+ * @property {number} lines - The number of rendered lines primitives per frame.
3485
+ **/
3486
+
3487
+ /**
3488
+ * WebGLRenderer Info
3489
+ *
3490
+ * @typedef {Object} WebGLRenderer~Info
3491
+ * @property {boolean} [autoReset=true] - Whether to automatically reset the info by the renderer or not.
3492
+ * @property {WebGLRenderer~InfoMemory} memory - Information about allocated objects.
3493
+ * @property {WebGLRenderer~InfoRender} render - Information about rendered objects.
3494
+ * @property {?Array<WebGLProgram>} programs - An array `WebGLProgram`s used for rendering.
3495
+ * @property {Function} reset - Resets the info object for the next frame.
3496
+ **/
3497
+
3498
+ /**
3499
+ * WebGLRenderer Shadow Map.
3500
+ *
3501
+ * @typedef {Object} WebGLRenderer~ShadowMap
3502
+ * @property {boolean} [enabled=false] - If set to `true`, use shadow maps in the scene.
3503
+ * @property {boolean} [autoUpdate=true] - Enables automatic updates to the shadows in the scene.
3504
+ * If you do not require dynamic lighting / shadows, you may set this to `false`.
3505
+ * @property {boolean} [needsUpdate=false] - When set to `true`, shadow maps in the scene
3506
+ * will be updated in the next `render` call.
3507
+ * @property {(BasicShadowMap|PCFShadowMap|PCFSoftShadowMap|VSMShadowMap)} [type=PCFShadowMap] - Defines the shadow map type.
3508
+ **/
2971
3509
 
2972
3510
  export { WebGLRenderer };