@plastic-software/three 0.179.0 → 0.181.1

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 (430) hide show
  1. package/build/three.cjs +1108 -591
  2. package/build/three.core.js +616 -345
  3. package/build/three.core.min.js +1 -1
  4. package/build/three.module.js +488 -250
  5. package/build/three.module.min.js +1 -1
  6. package/build/three.tsl.js +37 -6
  7. package/build/three.tsl.min.js +1 -1
  8. package/build/three.webgpu.js +6576 -2152
  9. package/build/three.webgpu.min.js +1 -1
  10. package/build/three.webgpu.nodes.js +6575 -2151
  11. package/build/three.webgpu.nodes.min.js +1 -1
  12. package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
  13. package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
  14. package/examples/jsm/Addons.js +1 -1
  15. package/examples/jsm/animation/CCDIKSolver.js +1 -1
  16. package/examples/jsm/controls/ArcballControls.js +8 -8
  17. package/examples/jsm/controls/DragControls.js +7 -57
  18. package/examples/jsm/controls/FirstPersonControls.js +3 -3
  19. package/examples/jsm/controls/FlyControls.js +1 -1
  20. package/examples/jsm/controls/OrbitControls.js +2 -2
  21. package/examples/jsm/controls/PointerLockControls.js +2 -10
  22. package/examples/jsm/controls/TrackballControls.js +1 -1
  23. package/examples/jsm/controls/TransformControls.js +1 -1
  24. package/examples/jsm/effects/AsciiEffect.js +8 -8
  25. package/examples/jsm/exporters/DRACOExporter.js +2 -2
  26. package/examples/jsm/exporters/EXRExporter.js +1 -1
  27. package/examples/jsm/exporters/GLTFExporter.js +33 -25
  28. package/examples/jsm/exporters/KTX2Exporter.js +4 -2
  29. package/examples/jsm/exporters/PLYExporter.js +1 -1
  30. package/examples/jsm/exporters/USDZExporter.js +9 -2
  31. package/examples/jsm/geometries/DecalGeometry.js +2 -2
  32. package/examples/jsm/geometries/ParametricGeometry.js +1 -1
  33. package/examples/jsm/geometries/TeapotGeometry.js +2 -2
  34. package/examples/jsm/geometries/TextGeometry.js +3 -2
  35. package/examples/jsm/gpgpu/BitonicSort.js +715 -0
  36. package/examples/jsm/helpers/ViewHelper.js +43 -5
  37. package/examples/jsm/inspector/Inspector.js +427 -0
  38. package/examples/jsm/inspector/RendererInspector.js +415 -0
  39. package/examples/jsm/inspector/tabs/Console.js +204 -0
  40. package/examples/jsm/inspector/tabs/Parameters.js +332 -0
  41. package/examples/jsm/inspector/tabs/Performance.js +268 -0
  42. package/examples/jsm/inspector/tabs/Viewer.js +166 -0
  43. package/examples/jsm/inspector/ui/Graph.js +95 -0
  44. package/examples/jsm/inspector/ui/Item.js +170 -0
  45. package/examples/jsm/inspector/ui/List.js +75 -0
  46. package/examples/jsm/inspector/ui/Profiler.js +170 -0
  47. package/examples/jsm/inspector/ui/Style.js +654 -0
  48. package/examples/jsm/inspector/ui/Tab.js +46 -0
  49. package/examples/jsm/inspector/ui/Values.js +423 -0
  50. package/examples/jsm/inspector/ui/utils.js +56 -0
  51. package/examples/jsm/interactive/HTMLMesh.js +6 -10
  52. package/examples/jsm/interactive/InteractiveGroup.js +1 -1
  53. package/examples/jsm/interactive/SelectionBox.js +30 -0
  54. package/examples/jsm/libs/ktx-parse.module.js +1 -1
  55. package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
  56. package/examples/jsm/lines/Line2.js +3 -3
  57. package/examples/jsm/lines/LineGeometry.js +1 -1
  58. package/examples/jsm/lines/LineSegments2.js +2 -2
  59. package/examples/jsm/lines/Wireframe.js +2 -2
  60. package/examples/jsm/lines/WireframeGeometry2.js +1 -1
  61. package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
  62. package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
  63. package/examples/jsm/loaders/3MFLoader.js +1 -1
  64. package/examples/jsm/loaders/ColladaLoader.js +3 -3
  65. package/examples/jsm/loaders/DDSLoader.js +1 -1
  66. package/examples/jsm/loaders/DRACOLoader.js +73 -22
  67. package/examples/jsm/loaders/EXRLoader.js +5 -5
  68. package/examples/jsm/loaders/FBXLoader.js +2 -2
  69. package/examples/jsm/loaders/FontLoader.js +23 -5
  70. package/examples/jsm/loaders/GLTFLoader.js +14 -8
  71. package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
  72. package/examples/jsm/loaders/HDRLoader.js +486 -0
  73. package/examples/jsm/loaders/KTX2Loader.js +136 -49
  74. package/examples/jsm/loaders/KTXLoader.js +2 -2
  75. package/examples/jsm/loaders/LDrawLoader.js +1 -1
  76. package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
  77. package/examples/jsm/loaders/LUTCubeLoader.js +1 -1
  78. package/examples/jsm/loaders/LWOLoader.js +2 -2
  79. package/examples/jsm/loaders/MaterialXLoader.js +22 -5
  80. package/examples/jsm/loaders/OBJLoader.js +1 -1
  81. package/examples/jsm/loaders/PDBLoader.js +1 -1
  82. package/examples/jsm/loaders/RGBELoader.js +7 -473
  83. package/examples/jsm/loaders/SVGLoader.js +2 -2
  84. package/examples/jsm/loaders/TTFLoader.js +4 -4
  85. package/examples/jsm/loaders/UltraHDRLoader.js +2 -2
  86. package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
  87. package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
  88. package/examples/jsm/math/ColorSpaces.js +19 -1
  89. package/examples/jsm/math/ConvexHull.js +3 -3
  90. package/examples/jsm/math/ImprovedNoise.js +1 -1
  91. package/examples/jsm/math/Lut.js +2 -2
  92. package/examples/jsm/math/SimplexNoise.js +1 -1
  93. package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
  94. package/examples/jsm/misc/ProgressiveLightMap.js +9 -3
  95. package/examples/jsm/misc/ProgressiveLightMapGPU.js +7 -1
  96. package/examples/jsm/misc/TubePainter.js +383 -40
  97. package/examples/jsm/misc/Volume.js +1 -1
  98. package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
  99. package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
  100. package/examples/jsm/objects/Sky.js +1 -1
  101. package/examples/jsm/objects/SkyMesh.js +1 -1
  102. package/examples/jsm/objects/Water.js +3 -3
  103. package/examples/jsm/objects/WaterMesh.js +6 -6
  104. package/examples/jsm/postprocessing/GlitchPass.js +2 -2
  105. package/examples/jsm/postprocessing/OutlinePass.js +1 -1
  106. package/examples/jsm/postprocessing/SSRPass.js +37 -8
  107. package/examples/jsm/postprocessing/UnrealBloomPass.js +8 -6
  108. package/examples/jsm/renderers/CSS2DRenderer.js +16 -5
  109. package/examples/jsm/renderers/CSS3DRenderer.js +7 -6
  110. package/examples/jsm/renderers/SVGRenderer.js +1 -1
  111. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +1 -1
  112. package/examples/jsm/shaders/AfterimageShader.js +1 -1
  113. package/examples/jsm/shaders/BleachBypassShader.js +1 -1
  114. package/examples/jsm/shaders/BokehShader.js +1 -1
  115. package/examples/jsm/shaders/BokehShader2.js +1 -1
  116. package/examples/jsm/shaders/DotScreenShader.js +1 -1
  117. package/examples/jsm/shaders/FocusShader.js +1 -1
  118. package/examples/jsm/shaders/GTAOShader.js +2 -2
  119. package/examples/jsm/shaders/GodRaysShader.js +1 -1
  120. package/examples/jsm/shaders/KaleidoShader.js +1 -1
  121. package/examples/jsm/shaders/PoissonDenoiseShader.js +2 -2
  122. package/examples/jsm/shaders/SSRShader.js +1 -1
  123. package/examples/jsm/shaders/SepiaShader.js +1 -1
  124. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +1 -1
  125. package/examples/jsm/shaders/TriangleBlurShader.js +1 -1
  126. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +1 -1
  127. package/examples/jsm/shaders/VignetteShader.js +1 -1
  128. package/examples/jsm/transpiler/GLSLDecoder.js +22 -19
  129. package/examples/jsm/transpiler/TSLEncoder.js +9 -10
  130. package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
  131. package/examples/jsm/tsl/display/AfterImageNode.js +26 -24
  132. package/examples/jsm/tsl/display/AnamorphicNode.js +28 -4
  133. package/examples/jsm/tsl/display/BloomNode.js +7 -3
  134. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
  135. package/examples/jsm/tsl/display/DenoiseNode.js +2 -0
  136. package/examples/jsm/tsl/display/DepthOfFieldNode.js +446 -90
  137. package/examples/jsm/tsl/display/GTAONode.js +53 -5
  138. package/examples/jsm/tsl/display/GaussianBlurNode.js +49 -35
  139. package/examples/jsm/tsl/display/OutlineNode.js +13 -2
  140. package/examples/jsm/tsl/display/SSGINode.js +654 -0
  141. package/examples/jsm/tsl/display/SSRNode.js +182 -65
  142. package/examples/jsm/tsl/display/SSSNode.js +488 -0
  143. package/examples/jsm/tsl/display/TRAANode.js +124 -7
  144. package/examples/jsm/tsl/display/boxBlur.js +65 -0
  145. package/examples/jsm/tsl/display/hashBlur.js +16 -18
  146. package/examples/jsm/tsl/lighting/TiledLightsNode.js +21 -1
  147. package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
  148. package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
  149. package/examples/jsm/webxr/OculusHandModel.js +1 -1
  150. package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
  151. package/examples/jsm/webxr/XRHandModelFactory.js +2 -6
  152. package/package.json +5 -10
  153. package/src/Three.Core.js +4 -2
  154. package/src/Three.TSL.js +36 -5
  155. package/src/Three.WebGPU.Nodes.js +2 -0
  156. package/src/Three.WebGPU.js +2 -0
  157. package/src/animation/AnimationClip.js +20 -4
  158. package/src/animation/AnimationMixer.js +3 -3
  159. package/src/animation/AnimationObjectGroup.js +2 -1
  160. package/src/animation/KeyframeTrack.js +7 -6
  161. package/src/animation/PropertyBinding.js +12 -11
  162. package/src/audio/Audio.js +10 -9
  163. package/src/audio/PositionalAudio.js +1 -1
  164. package/src/cameras/OrthographicCamera.js +1 -1
  165. package/src/cameras/PerspectiveCamera.js +1 -1
  166. package/src/cameras/StereoCamera.js +2 -2
  167. package/src/constants.js +11 -3
  168. package/src/core/BufferGeometry.js +10 -10
  169. package/src/core/EventDispatcher.js +1 -1
  170. package/src/core/InterleavedBuffer.js +1 -1
  171. package/src/core/InterleavedBufferAttribute.js +3 -2
  172. package/src/core/Object3D.js +3 -2
  173. package/src/core/Raycaster.js +2 -1
  174. package/src/core/RenderTarget.js +10 -1
  175. package/src/extras/Controls.js +5 -4
  176. package/src/extras/DataUtils.js +2 -1
  177. package/src/extras/Earcut.js +6 -0
  178. package/src/extras/ImageUtils.js +2 -2
  179. package/src/extras/PMREMGenerator.js +268 -55
  180. package/src/extras/TextureUtils.js +2 -1
  181. package/src/extras/core/Curve.js +2 -1
  182. package/src/extras/core/Interpolations.js +7 -1
  183. package/src/extras/core/ShapePath.js +4 -4
  184. package/src/extras/lib/earcut.js +8 -8
  185. package/src/geometries/BoxGeometry.js +1 -0
  186. package/src/geometries/CapsuleGeometry.js +1 -0
  187. package/src/geometries/CircleGeometry.js +1 -0
  188. package/src/geometries/ConeGeometry.js +1 -0
  189. package/src/geometries/CylinderGeometry.js +1 -0
  190. package/src/geometries/DodecahedronGeometry.js +1 -0
  191. package/src/geometries/ExtrudeGeometry.js +8 -6
  192. package/src/geometries/IcosahedronGeometry.js +1 -0
  193. package/src/geometries/LatheGeometry.js +1 -0
  194. package/src/geometries/OctahedronGeometry.js +1 -0
  195. package/src/geometries/PlaneGeometry.js +1 -0
  196. package/src/geometries/RingGeometry.js +1 -0
  197. package/src/geometries/ShapeGeometry.js +1 -0
  198. package/src/geometries/SphereGeometry.js +1 -0
  199. package/src/geometries/TetrahedronGeometry.js +1 -0
  200. package/src/geometries/TorusGeometry.js +1 -0
  201. package/src/geometries/TorusKnotGeometry.js +1 -0
  202. package/src/geometries/TubeGeometry.js +1 -0
  203. package/src/helpers/CameraHelper.js +1 -1
  204. package/src/lights/webgpu/ProjectorLight.js +1 -1
  205. package/src/loaders/AnimationLoader.js +2 -1
  206. package/src/loaders/AudioLoader.js +2 -1
  207. package/src/loaders/BufferGeometryLoader.js +2 -2
  208. package/src/loaders/Cache.js +2 -2
  209. package/src/loaders/DataTextureLoader.js +1 -1
  210. package/src/loaders/FileLoader.js +3 -2
  211. package/src/loaders/ImageBitmapLoader.js +5 -4
  212. package/src/loaders/ImageLoader.js +1 -1
  213. package/src/loaders/Loader.js +3 -3
  214. package/src/loaders/LoadingManager.js +25 -3
  215. package/src/loaders/MaterialLoader.js +3 -2
  216. package/src/loaders/ObjectLoader.js +13 -13
  217. package/src/loaders/TextureLoader.js +1 -1
  218. package/src/loaders/nodes/NodeLoader.js +3 -2
  219. package/src/materials/Material.js +16 -3
  220. package/src/materials/MeshBasicMaterial.js +1 -0
  221. package/src/materials/MeshDepthMaterial.js +1 -0
  222. package/src/materials/MeshDistanceMaterial.js +1 -1
  223. package/src/materials/MeshLambertMaterial.js +2 -1
  224. package/src/materials/MeshMatcapMaterial.js +22 -0
  225. package/src/materials/MeshNormalMaterial.js +1 -0
  226. package/src/materials/MeshPhongMaterial.js +2 -1
  227. package/src/materials/MeshPhysicalMaterial.js +2 -1
  228. package/src/materials/MeshStandardMaterial.js +8 -7
  229. package/src/materials/MeshToonMaterial.js +1 -0
  230. package/src/materials/PointsMaterial.js +1 -1
  231. package/src/materials/ShaderMaterial.js +2 -2
  232. package/src/materials/nodes/Line2NodeMaterial.js +2 -2
  233. package/src/materials/nodes/MeshSSSNodeMaterial.js +1 -1
  234. package/src/materials/nodes/NodeMaterial.js +62 -22
  235. package/src/materials/nodes/PointsNodeMaterial.js +81 -28
  236. package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
  237. package/src/materials/nodes/manager/NodeMaterialObserver.js +3 -2
  238. package/src/math/Color.js +6 -5
  239. package/src/math/ColorManagement.js +9 -3
  240. package/src/math/Cylindrical.js +1 -1
  241. package/src/math/Euler.js +2 -1
  242. package/src/math/MathUtils.js +13 -11
  243. package/src/math/Matrix2.js +1 -1
  244. package/src/math/Matrix3.js +2 -2
  245. package/src/math/Matrix4.js +7 -7
  246. package/src/math/Plane.js +1 -1
  247. package/src/math/Quaternion.js +68 -66
  248. package/src/math/Spherical.js +1 -1
  249. package/src/nodes/Nodes.js +4 -1
  250. package/src/nodes/TSL.js +4 -1
  251. package/src/nodes/accessors/BufferNode.js +1 -1
  252. package/src/nodes/accessors/Camera.js +133 -7
  253. package/src/nodes/accessors/ClippingNode.js +6 -5
  254. package/src/nodes/accessors/CubeTextureNode.js +5 -4
  255. package/src/nodes/accessors/InstanceNode.js +25 -5
  256. package/src/nodes/accessors/Lights.js +10 -0
  257. package/src/nodes/accessors/Normal.js +5 -4
  258. package/src/nodes/accessors/Object3DNode.js +1 -1
  259. package/src/nodes/accessors/Position.js +18 -2
  260. package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
  261. package/src/nodes/accessors/ReferenceNode.js +3 -2
  262. package/src/nodes/accessors/SceneNode.js +2 -1
  263. package/src/nodes/accessors/StorageBufferNode.js +2 -1
  264. package/src/nodes/accessors/StorageTextureNode.js +22 -0
  265. package/src/nodes/accessors/Texture3DNode.js +14 -1
  266. package/src/nodes/accessors/TextureNode.js +130 -44
  267. package/src/nodes/code/FunctionCallNode.js +24 -4
  268. package/src/nodes/code/FunctionNode.js +23 -0
  269. package/src/nodes/core/ArrayNode.js +1 -0
  270. package/src/nodes/core/AssignNode.js +4 -3
  271. package/src/nodes/core/AttributeNode.js +2 -1
  272. package/src/nodes/core/ContextNode.js +29 -10
  273. package/src/nodes/core/IndexNode.js +2 -2
  274. package/src/nodes/core/InputNode.js +2 -1
  275. package/src/nodes/core/InspectorNode.js +128 -0
  276. package/src/nodes/core/{CacheNode.js → IsolateNode.js} +40 -7
  277. package/src/nodes/core/Node.js +152 -31
  278. package/src/nodes/core/NodeBuilder.js +183 -35
  279. package/src/nodes/core/NodeFrame.js +21 -21
  280. package/src/nodes/core/NodeFunction.js +2 -1
  281. package/src/nodes/core/NodeParser.js +2 -1
  282. package/src/nodes/core/NodeUniform.js +1 -1
  283. package/src/nodes/core/NodeUtils.js +17 -91
  284. package/src/nodes/core/ParameterNode.js +31 -0
  285. package/src/nodes/core/PropertyNode.js +7 -0
  286. package/src/nodes/core/StackNode.js +43 -16
  287. package/src/nodes/core/StructNode.js +5 -5
  288. package/src/nodes/core/StructTypeNode.js +1 -0
  289. package/src/nodes/core/SubBuildNode.js +2 -2
  290. package/src/nodes/core/UniformNode.js +18 -10
  291. package/src/nodes/core/VarNode.js +70 -33
  292. package/src/nodes/core/VaryingNode.js +3 -2
  293. package/src/nodes/display/BlendModes.js +5 -4
  294. package/src/nodes/display/BumpMapNode.js +1 -1
  295. package/src/nodes/display/ColorAdjustment.js +1 -1
  296. package/src/nodes/display/FrontFacingNode.js +4 -8
  297. package/src/nodes/display/NormalMapNode.js +2 -1
  298. package/src/nodes/display/PassNode.js +52 -11
  299. package/src/nodes/display/RenderOutputNode.js +28 -2
  300. package/src/nodes/display/ScreenNode.js +44 -14
  301. package/src/nodes/display/ToneMappingNode.js +31 -4
  302. package/src/nodes/display/ToonOutlinePassNode.js +8 -0
  303. package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
  304. package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
  305. package/src/nodes/display/ViewportTextureNode.js +42 -12
  306. package/src/nodes/fog/Fog.js +3 -2
  307. package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
  308. package/src/nodes/functions/BSDF/DFGApprox.js +60 -19
  309. package/src/nodes/functions/BasicLightingModel.js +2 -1
  310. package/src/nodes/functions/PhysicalLightingModel.js +3 -2
  311. package/src/nodes/functions/VolumetricLightingModel.js +5 -5
  312. package/src/nodes/geometry/RangeNode.js +40 -4
  313. package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -1
  314. package/src/nodes/gpgpu/ComputeNode.js +17 -5
  315. package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
  316. package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
  317. package/src/nodes/lighting/EnvironmentNode.js +6 -6
  318. package/src/nodes/lighting/LightsNode.js +3 -4
  319. package/src/nodes/lighting/PointShadowNode.js +6 -0
  320. package/src/nodes/lighting/ShadowFilterNode.js +2 -0
  321. package/src/nodes/lighting/ShadowNode.js +75 -8
  322. package/src/nodes/math/BitcastNode.js +156 -0
  323. package/src/nodes/math/ConditionalNode.js +24 -7
  324. package/src/nodes/math/MathNode.js +25 -19
  325. package/src/nodes/math/OperatorNode.js +7 -5
  326. package/src/nodes/pmrem/PMREMUtils.js +117 -2
  327. package/src/nodes/shapes/Shapes.js +1 -1
  328. package/src/nodes/tsl/TSLBase.js +5 -2
  329. package/src/nodes/tsl/TSLCore.js +460 -159
  330. package/src/nodes/utils/DebugNode.js +2 -1
  331. package/src/nodes/utils/EventNode.js +36 -0
  332. package/src/nodes/utils/FunctionOverloadingNode.js +37 -19
  333. package/src/nodes/utils/JoinNode.js +6 -3
  334. package/src/nodes/utils/LoopNode.js +20 -24
  335. package/src/nodes/utils/MemberNode.js +59 -7
  336. package/src/nodes/utils/PostProcessingUtils.js +28 -1
  337. package/src/nodes/utils/RTTNode.js +13 -3
  338. package/src/nodes/utils/ReflectorNode.js +58 -7
  339. package/src/nodes/utils/SampleNode.js +12 -2
  340. package/src/nodes/utils/SplitNode.js +11 -0
  341. package/src/nodes/utils/Timer.js +0 -47
  342. package/src/objects/BatchedMesh.js +2 -2
  343. package/src/objects/LOD.js +1 -1
  344. package/src/objects/Line.js +2 -1
  345. package/src/objects/LineSegments.js +2 -1
  346. package/src/objects/Skeleton.js +3 -2
  347. package/src/objects/SkinnedMesh.js +3 -1
  348. package/src/objects/Sprite.js +4 -3
  349. package/src/renderers/WebGLRenderer.js +48 -41
  350. package/src/renderers/common/Animation.js +13 -1
  351. package/src/renderers/common/Attributes.js +1 -1
  352. package/src/renderers/common/Backend.js +108 -27
  353. package/src/renderers/common/Background.js +2 -1
  354. package/src/renderers/common/Bindings.js +58 -2
  355. package/src/renderers/common/CanvasTarget.js +341 -0
  356. package/src/renderers/common/ChainMap.js +1 -1
  357. package/src/renderers/common/DataMap.js +1 -1
  358. package/src/renderers/common/Geometries.js +26 -0
  359. package/src/renderers/common/Info.js +4 -2
  360. package/src/renderers/common/InspectorBase.js +146 -0
  361. package/src/renderers/common/Pipelines.js +1 -1
  362. package/src/renderers/common/PostProcessing.js +6 -25
  363. package/src/renderers/common/QuadMesh.js +7 -1
  364. package/src/renderers/common/RenderContext.js +2 -2
  365. package/src/renderers/common/RenderList.js +7 -3
  366. package/src/renderers/common/RenderObject.js +16 -2
  367. package/src/renderers/common/RenderObjects.js +1 -1
  368. package/src/renderers/common/Renderer.js +473 -245
  369. package/src/renderers/common/RendererUtils.js +9 -0
  370. package/src/renderers/common/SampledTexture.js +9 -1
  371. package/src/renderers/common/Sampler.js +50 -12
  372. package/src/renderers/common/StorageTexture.js +9 -1
  373. package/src/renderers/common/Textures.js +121 -45
  374. package/src/renderers/common/TimestampQueryPool.js +65 -3
  375. package/src/renderers/common/UniformsGroup.js +2 -1
  376. package/src/renderers/common/XRManager.js +42 -22
  377. package/src/renderers/common/extras/PMREMGenerator.js +160 -65
  378. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  379. package/src/renderers/common/nodes/NodeLibrary.js +9 -7
  380. package/src/renderers/common/nodes/NodeSampler.js +13 -1
  381. package/src/renderers/common/nodes/Nodes.js +38 -16
  382. package/src/renderers/shaders/DFGLUTData.js +64 -0
  383. package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
  384. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
  385. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
  386. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -18
  387. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
  388. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  389. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
  390. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
  391. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -15
  392. package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -1
  393. package/src/renderers/shaders/UniformsLib.js +1 -0
  394. package/src/renderers/shaders/UniformsUtils.js +25 -4
  395. package/src/renderers/webgl/WebGLCapabilities.js +2 -1
  396. package/src/renderers/webgl/WebGLExtensions.js +2 -25
  397. package/src/renderers/webgl/WebGLInfo.js +3 -1
  398. package/src/renderers/webgl/WebGLProgram.js +15 -14
  399. package/src/renderers/webgl/WebGLPrograms.js +2 -1
  400. package/src/renderers/webgl/WebGLShadowMap.js +3 -2
  401. package/src/renderers/webgl/WebGLState.js +15 -14
  402. package/src/renderers/webgl/WebGLTextures.js +19 -14
  403. package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
  404. package/src/renderers/webgl/WebGLUtils.js +3 -2
  405. package/src/renderers/webgl-fallback/WebGLBackend.js +199 -167
  406. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +181 -25
  407. package/src/renderers/webgl-fallback/utils/WebGLConstants.js +2 -3
  408. package/src/renderers/webgl-fallback/utils/WebGLState.js +7 -6
  409. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +169 -19
  410. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +51 -22
  411. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
  412. package/src/renderers/webgpu/WebGPUBackend.js +153 -123
  413. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +2 -1
  414. package/src/renderers/webgpu/WebGPURenderer.js +3 -2
  415. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +142 -50
  416. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
  417. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +5 -3
  418. package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -2
  419. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +53 -34
  420. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +6 -8
  421. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +260 -99
  422. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +32 -9
  423. package/src/renderers/webgpu/utils/WebGPUUtils.js +22 -2
  424. package/src/renderers/webxr/WebXRManager.js +42 -26
  425. package/src/textures/ExternalTexture.js +15 -4
  426. package/src/textures/Source.js +3 -2
  427. package/src/textures/Texture.js +3 -2
  428. package/src/textures/VideoTexture.js +2 -3
  429. package/src/utils.js +67 -3
  430. package/examples/jsm/loaders/RGBMLoader.js +0 -1148
@@ -17,6 +17,8 @@ import RenderBundles from './RenderBundles.js';
17
17
  import NodeLibrary from './nodes/NodeLibrary.js';
18
18
  import Lighting from './Lighting.js';
19
19
  import XRManager from './XRManager.js';
20
+ import InspectorBase from './InspectorBase.js';
21
+ import CanvasTarget from './CanvasTarget.js';
20
22
 
21
23
  import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
22
24
 
@@ -30,7 +32,10 @@ import { Vector4 } from '../../math/Vector4.js';
30
32
  import { RenderTarget } from '../../core/RenderTarget.js';
31
33
  import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearFilter, HalfFloatType, RGBAFormat, PCFShadowMap } from '../../constants.js';
32
34
 
35
+ import { float, vec3, vec4 } from '../../nodes/tsl/TSLCore.js';
36
+ import { reference } from '../../nodes/accessors/ReferenceNode.js';
33
37
  import { highpModelNormalViewMatrix, highpModelViewMatrix } from '../../nodes/accessors/ModelNode.js';
38
+ import { error, warn, warnOnce } from '../../utils.js';
34
39
 
35
40
  const _scene = /*@__PURE__*/ new Scene();
36
41
  const _drawingBufferSize = /*@__PURE__*/ new Vector2();
@@ -95,15 +100,6 @@ class Renderer {
95
100
  multiview = false
96
101
  } = parameters;
97
102
 
98
- /**
99
- * A reference to the canvas element the renderer is drawing to.
100
- * This value of this property will automatically be created by
101
- * the renderer.
102
- *
103
- * @type {HTMLCanvasElement|OffscreenCanvas}
104
- */
105
- this.domElement = backend.getDomElement();
106
-
107
103
  /**
108
104
  * A reference to the current backend.
109
105
  *
@@ -111,14 +107,6 @@ class Renderer {
111
107
  */
112
108
  this.backend = backend;
113
109
 
114
- /**
115
- * The number of MSAA samples.
116
- *
117
- * @type {number}
118
- * @default 0
119
- */
120
- this.samples = samples || ( antialias === true ) ? 4 : 0;
121
-
122
110
  /**
123
111
  * Whether the renderer should automatically clear the current rendering target
124
112
  * before execute a `render()` call. The target can be the canvas (default framebuffer)
@@ -267,61 +255,48 @@ class Renderer {
267
255
  // internals
268
256
 
269
257
  /**
270
- * This callback function can be used to provide a fallback backend, if the primary backend can't be targeted.
271
- *
272
- * @private
273
- * @type {?Function}
274
- */
275
- this._getFallback = getFallback;
276
-
277
- /**
278
- * The renderer's pixel ratio.
279
- *
280
- * @private
281
- * @type {number}
282
- * @default 1
283
- */
284
- this._pixelRatio = 1;
285
-
286
- /**
287
- * The width of the renderer's default framebuffer in logical pixel unit.
258
+ * The number of MSAA samples.
288
259
  *
289
260
  * @private
290
261
  * @type {number}
262
+ * @default 0
291
263
  */
292
- this._width = this.domElement.width;
264
+ this._samples = samples || ( antialias === true ) ? 4 : 0;
293
265
 
294
266
  /**
295
- * The height of the renderer's default framebuffer in logical pixel unit.
267
+ * OnCanvasTargetResize callback function.
296
268
  *
297
269
  * @private
298
- * @type {number}
270
+ * @type {Function}
299
271
  */
300
- this._height = this.domElement.height;
272
+ this._onCanvasTargetResize = this._onCanvasTargetResize.bind( this );
301
273
 
302
274
  /**
303
- * The viewport of the renderer in logical pixel unit.
275
+ * The canvas target for rendering.
304
276
  *
305
277
  * @private
306
- * @type {Vector4}
278
+ * @type {CanvasTarget}
307
279
  */
308
- this._viewport = new Vector4( 0, 0, this._width, this._height );
280
+ this._canvasTarget = new CanvasTarget( backend.getDomElement() );
281
+ this._canvasTarget.addEventListener( 'resize', this._onCanvasTargetResize );
282
+ this._canvasTarget.isDefaultCanvasTarget = true;
309
283
 
310
284
  /**
311
- * The scissor rectangle of the renderer in logical pixel unit.
285
+ * The inspector provides information about the internal renderer state.
312
286
  *
313
287
  * @private
314
- * @type {Vector4}
288
+ * @type {InspectorBase}
315
289
  */
316
- this._scissor = new Vector4( 0, 0, this._width, this._height );
290
+ this._inspector = new InspectorBase();
291
+ this._inspector.setRenderer( this );
317
292
 
318
293
  /**
319
- * Whether the scissor test should be enabled or not.
294
+ * This callback function can be used to provide a fallback backend, if the primary backend can't be targeted.
320
295
  *
321
296
  * @private
322
- * @type {boolean}
297
+ * @type {?Function}
323
298
  */
324
- this._scissorTest = false;
299
+ this._getFallback = getFallback;
325
300
 
326
301
  /**
327
302
  * A reference to a renderer module for managing shader attributes.
@@ -439,7 +414,8 @@ class Renderer {
439
414
  * @type {QuadMesh}
440
415
  */
441
416
  this._quad = new QuadMesh( new NodeMaterial() );
442
- this._quad.material.name = 'Renderer_output';
417
+ this._quad.name = 'Output Color Transform';
418
+ this._quad.material.name = 'outputColorTransform';
443
419
 
444
420
  /**
445
421
  * A reference to the current render context.
@@ -621,6 +597,14 @@ class Renderer {
621
597
  */
622
598
  this._colorBufferType = colorBufferType;
623
599
 
600
+ /**
601
+ * A cache for shadow nodes per material
602
+ *
603
+ * @private
604
+ * @type {WeakMap<Material, Object>}
605
+ */
606
+ this._cacheShadowNodes = new WeakMap();
607
+
624
608
  /**
625
609
  * Whether the renderer has been initialized or not.
626
610
  *
@@ -738,12 +722,6 @@ class Renderer {
738
722
  */
739
723
  async init() {
740
724
 
741
- if ( this._initialized ) {
742
-
743
- throw new Error( 'Renderer: Backend has already been initialized.' );
744
-
745
- }
746
-
747
725
  if ( this._initPromise !== null ) {
748
726
 
749
727
  return this._initPromise;
@@ -786,7 +764,7 @@ class Renderer {
786
764
  }
787
765
 
788
766
  this._nodes = new Nodes( this, backend );
789
- this._animation = new Animation( this._nodes, this.info );
767
+ this._animation = new Animation( this, this._nodes, this.info );
790
768
  this._attributes = new Attributes( backend );
791
769
  this._background = new Background( this, this._nodes );
792
770
  this._geometries = new Geometries( this._attributes, this.info );
@@ -803,6 +781,12 @@ class Renderer {
803
781
  this._animation.start();
804
782
  this._initialized = true;
805
783
 
784
+ //
785
+
786
+ this._inspector.init();
787
+
788
+ //
789
+
806
790
  resolve( this );
807
791
 
808
792
  } );
@@ -811,6 +795,19 @@ class Renderer {
811
795
 
812
796
  }
813
797
 
798
+ /**
799
+ * A reference to the canvas element the renderer is drawing to.
800
+ * This value of this property will automatically be created by
801
+ * the renderer.
802
+ *
803
+ * @type {HTMLCanvasElement|OffscreenCanvas}
804
+ */
805
+ get domElement() {
806
+
807
+ return this._canvasTarget.domElement;
808
+
809
+ }
810
+
814
811
  /**
815
812
  * The coordinate system of the renderer. The value of this property
816
813
  * depends on the selected backend. Either `THREE.WebGLCoordinateSystem` or
@@ -968,15 +965,18 @@ class Renderer {
968
965
  * Renders the scene in an async fashion.
969
966
  *
970
967
  * @async
968
+ * @deprecated
971
969
  * @param {Object3D} scene - The scene or 3D object to render.
972
970
  * @param {Camera} camera - The camera.
973
971
  * @return {Promise} A Promise that resolves when the render has been finished.
974
972
  */
975
973
  async renderAsync( scene, camera ) {
976
974
 
977
- if ( this._initialized === false ) await this.init();
975
+ warnOnce( 'Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
978
976
 
979
- this._renderScene( scene, camera );
977
+ await this.init();
978
+
979
+ this.render( scene, camera );
980
980
 
981
981
  }
982
982
 
@@ -985,11 +985,38 @@ class Renderer {
985
985
  * the CPU waits for the GPU to complete its operation (e.g. a compute task).
986
986
  *
987
987
  * @async
988
+ * @deprecated
988
989
  * @return {Promise} A Promise that resolves when synchronization has been finished.
989
990
  */
990
991
  async waitForGPU() {
991
992
 
992
- await this.backend.waitForGPU();
993
+ error( 'Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.' );
994
+
995
+ }
996
+
997
+ //
998
+
999
+ /**
1000
+ * Sets the inspector instance. The inspector can be any class that extends from `InspectorBase`.
1001
+ *
1002
+ * @param {InspectorBase} value - The new inspector.
1003
+ */
1004
+ set inspector( value ) {
1005
+
1006
+ if ( this._inspector !== null ) {
1007
+
1008
+ this._inspector.setRenderer( null );
1009
+
1010
+ }
1011
+
1012
+ this._inspector = value;
1013
+ this._inspector.setRenderer( this );
1014
+
1015
+ }
1016
+
1017
+ get inspector() {
1018
+
1019
+ return this._inspector;
993
1020
 
994
1021
  }
995
1022
 
@@ -1082,7 +1109,7 @@ class Renderer {
1082
1109
 
1083
1110
  }
1084
1111
 
1085
- console.error( errorMessage );
1112
+ error( errorMessage );
1086
1113
 
1087
1114
  this._isDeviceLost = true;
1088
1115
 
@@ -1174,23 +1201,24 @@ class Renderer {
1174
1201
 
1175
1202
  /**
1176
1203
  * Renders the scene or 3D object with the given camera. This method can only be called
1177
- * if the renderer has been initialized.
1204
+ * if the renderer has been initialized. When using `render()` inside an animation loop,
1205
+ * it's guaranteed the renderer will be initialized. The animation loop must be defined
1206
+ * with {@link Renderer#setAnimationLoop} though.
1207
+ *
1208
+ * For all other use cases (like when using on-demand rendering), you must call
1209
+ * {@link Renderer#init} before rendering.
1178
1210
  *
1179
1211
  * The target of the method is the default framebuffer (meaning the canvas)
1180
1212
  * or alternatively a render target when specified via `setRenderTarget()`.
1181
1213
  *
1182
1214
  * @param {Object3D} scene - The scene or 3D object to render.
1183
1215
  * @param {Camera} camera - The camera to render the scene with.
1184
- * @return {?Promise} A Promise that resolve when the scene has been rendered.
1185
- * Only returned when the renderer has not been initialized.
1186
1216
  */
1187
1217
  render( scene, camera ) {
1188
1218
 
1189
1219
  if ( this._initialized === false ) {
1190
1220
 
1191
- console.warn( 'THREE.Renderer: .render() called before the backend is initialized. Try using .renderAsync() instead.' );
1192
-
1193
- return this.renderAsync( scene, camera );
1221
+ throw new Error( 'Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.' );
1194
1222
 
1195
1223
  }
1196
1224
 
@@ -1198,6 +1226,18 @@ class Renderer {
1198
1226
 
1199
1227
  }
1200
1228
 
1229
+ /**
1230
+ * Returns whether the renderer has been initialized or not.
1231
+ *
1232
+ * @readonly
1233
+ * @return {boolean} Whether the renderer has been initialized or not.
1234
+ */
1235
+ get initialized() {
1236
+
1237
+ return this._initialized;
1238
+
1239
+ }
1240
+
1201
1241
  /**
1202
1242
  * Returns an internal render target which is used when computing the output tone mapping
1203
1243
  * and color space conversion. Unlike in `WebGLRenderer`, this is done in a separate render
@@ -1254,11 +1294,13 @@ class Renderer {
1254
1294
 
1255
1295
  }
1256
1296
 
1257
- frameBufferTarget.viewport.copy( this._viewport );
1258
- frameBufferTarget.scissor.copy( this._scissor );
1259
- frameBufferTarget.viewport.multiplyScalar( this._pixelRatio );
1260
- frameBufferTarget.scissor.multiplyScalar( this._pixelRatio );
1261
- frameBufferTarget.scissorTest = this._scissorTest;
1297
+ const canvasTarget = this._canvasTarget;
1298
+
1299
+ frameBufferTarget.viewport.copy( canvasTarget._viewport );
1300
+ frameBufferTarget.scissor.copy( canvasTarget._scissor );
1301
+ frameBufferTarget.viewport.multiplyScalar( canvasTarget._pixelRatio );
1302
+ frameBufferTarget.scissor.multiplyScalar( canvasTarget._pixelRatio );
1303
+ frameBufferTarget.scissorTest = canvasTarget._scissorTest;
1262
1304
  frameBufferTarget.multiview = outputRenderTarget !== null ? outputRenderTarget.multiview : false;
1263
1305
  frameBufferTarget.resolveDepthBuffer = outputRenderTarget !== null ? outputRenderTarget.resolveDepthBuffer : true;
1264
1306
  frameBufferTarget._autoAllocateDepthBuffer = outputRenderTarget !== null ? outputRenderTarget._autoAllocateDepthBuffer : false;
@@ -1280,6 +1322,8 @@ class Renderer {
1280
1322
 
1281
1323
  if ( this._isDeviceLost === true ) return;
1282
1324
 
1325
+ //
1326
+
1283
1327
  const frameBufferTarget = useFrameBufferTarget ? this._getFrameBufferTarget() : null;
1284
1328
 
1285
1329
  // preserve render tree
@@ -1332,6 +1376,12 @@ class Renderer {
1332
1376
 
1333
1377
  //
1334
1378
 
1379
+ this.backend.updateTimeStampUID( renderContext );
1380
+
1381
+ this.inspector.beginRender( this.backend.getTimestampUID( renderContext ), scene, camera, renderTarget );
1382
+
1383
+ //
1384
+
1335
1385
  const coordinateSystem = this.coordinateSystem;
1336
1386
  const xr = this.xr;
1337
1387
 
@@ -1368,9 +1418,11 @@ class Renderer {
1368
1418
 
1369
1419
  //
1370
1420
 
1371
- let viewport = this._viewport;
1372
- let scissor = this._scissor;
1373
- let pixelRatio = this._pixelRatio;
1421
+ const canvasTarget = this._canvasTarget;
1422
+
1423
+ let viewport = canvasTarget._viewport;
1424
+ let scissor = canvasTarget._scissor;
1425
+ let pixelRatio = canvasTarget._pixelRatio;
1374
1426
 
1375
1427
  if ( renderTarget !== null ) {
1376
1428
 
@@ -1395,7 +1447,7 @@ class Renderer {
1395
1447
  renderContext.viewport = renderContext.viewportValue.equals( _screen ) === false;
1396
1448
 
1397
1449
  renderContext.scissorValue.copy( scissor ).multiplyScalar( pixelRatio ).floor();
1398
- renderContext.scissor = this._scissorTest && renderContext.scissorValue.equals( _screen ) === false;
1450
+ renderContext.scissor = canvasTarget._scissorTest && renderContext.scissorValue.equals( _screen ) === false;
1399
1451
  renderContext.scissorValue.width >>= activeMipmapLevel;
1400
1452
  renderContext.scissorValue.height >>= activeMipmapLevel;
1401
1453
 
@@ -1450,8 +1502,8 @@ class Renderer {
1450
1502
 
1451
1503
  renderContext.textures = null;
1452
1504
  renderContext.depthTexture = null;
1453
- renderContext.width = this.domElement.width;
1454
- renderContext.height = this.domElement.height;
1505
+ renderContext.width = _drawingBufferSize.width;
1506
+ renderContext.height = _drawingBufferSize.height;
1455
1507
  renderContext.depth = this.depth;
1456
1508
  renderContext.stencil = this.stencil;
1457
1509
 
@@ -1465,6 +1517,22 @@ class Renderer {
1465
1517
 
1466
1518
  //
1467
1519
 
1520
+ renderContext.scissorValue.max( _vector4.set( 0, 0, 0, 0 ) );
1521
+
1522
+ if ( renderContext.scissorValue.x + renderContext.scissorValue.width > renderContext.width ) {
1523
+
1524
+ renderContext.scissorValue.width = Math.max( renderContext.width - renderContext.scissorValue.x, 0 );
1525
+
1526
+ }
1527
+
1528
+ if ( renderContext.scissorValue.y + renderContext.scissorValue.height > renderContext.height ) {
1529
+
1530
+ renderContext.scissorValue.height = Math.max( renderContext.height - renderContext.scissorValue.y, 0 );
1531
+
1532
+ }
1533
+
1534
+ //
1535
+
1468
1536
  this._background.update( sceneRef, renderList, renderContext );
1469
1537
 
1470
1538
  //
@@ -1513,14 +1581,20 @@ class Renderer {
1513
1581
 
1514
1582
  //
1515
1583
 
1584
+ this.inspector.finishRender( this.backend.getTimestampUID( renderContext ) );
1585
+
1586
+ //
1587
+
1516
1588
  return renderContext;
1517
1589
 
1518
1590
  }
1519
1591
 
1520
1592
  _setXRLayerSize( width, height ) {
1521
1593
 
1522
- this._width = width;
1523
- this._height = height;
1594
+ // TODO: Find a better solution to resize the canvas when in XR.
1595
+
1596
+ this._canvasTarget._width = width;
1597
+ this._canvasTarget._height = height;
1524
1598
 
1525
1599
  this.setViewport( 0, 0, width, height );
1526
1600
 
@@ -1598,7 +1672,7 @@ class Renderer {
1598
1672
  * for best compatibility.
1599
1673
  *
1600
1674
  * @async
1601
- * @param {?Function} callback - The application's animation loop.
1675
+ * @param {?onAnimationCallback} callback - The application's animation loop.
1602
1676
  * @return {Promise} A Promise that resolves when the set has been executed.
1603
1677
  */
1604
1678
  async setAnimationLoop( callback ) {
@@ -1609,6 +1683,17 @@ class Renderer {
1609
1683
 
1610
1684
  }
1611
1685
 
1686
+ /**
1687
+ * Returns the current animation loop callback.
1688
+ *
1689
+ * @return {?Function} The current animation loop callback.
1690
+ */
1691
+ getAnimationLoop() {
1692
+
1693
+ return this._animation.getAnimationLoop();
1694
+
1695
+ }
1696
+
1612
1697
  /**
1613
1698
  * Can be used to transfer buffer data from a storage buffer attribute
1614
1699
  * from the GPU to the CPU in context of compute shaders.
@@ -1641,7 +1726,7 @@ class Renderer {
1641
1726
  */
1642
1727
  getPixelRatio() {
1643
1728
 
1644
- return this._pixelRatio;
1729
+ return this._canvasTarget.getPixelRatio();
1645
1730
 
1646
1731
  }
1647
1732
 
@@ -1653,7 +1738,7 @@ class Renderer {
1653
1738
  */
1654
1739
  getDrawingBufferSize( target ) {
1655
1740
 
1656
- return target.set( this._width * this._pixelRatio, this._height * this._pixelRatio ).floor();
1741
+ return this._canvasTarget.getDrawingBufferSize( target );
1657
1742
 
1658
1743
  }
1659
1744
 
@@ -1665,7 +1750,7 @@ class Renderer {
1665
1750
  */
1666
1751
  getSize( target ) {
1667
1752
 
1668
- return target.set( this._width, this._height );
1753
+ return this._canvasTarget.getSize( target );
1669
1754
 
1670
1755
  }
1671
1756
 
@@ -1676,11 +1761,7 @@ class Renderer {
1676
1761
  */
1677
1762
  setPixelRatio( value = 1 ) {
1678
1763
 
1679
- if ( this._pixelRatio === value ) return;
1680
-
1681
- this._pixelRatio = value;
1682
-
1683
- this.setSize( this._width, this._height, false );
1764
+ this._canvasTarget.setPixelRatio( value );
1684
1765
 
1685
1766
  }
1686
1767
 
@@ -1702,17 +1783,7 @@ class Renderer {
1702
1783
  // Renderer can't be resized while presenting in XR.
1703
1784
  if ( this.xr && this.xr.isPresenting ) return;
1704
1785
 
1705
- this._width = width;
1706
- this._height = height;
1707
-
1708
- this._pixelRatio = pixelRatio;
1709
-
1710
- this.domElement.width = Math.floor( width * pixelRatio );
1711
- this.domElement.height = Math.floor( height * pixelRatio );
1712
-
1713
- this.setViewport( 0, 0, width, height );
1714
-
1715
- if ( this._initialized ) this.backend.updateSize();
1786
+ this._canvasTarget.setDrawingBufferSize( width, height, pixelRatio );
1716
1787
 
1717
1788
  }
1718
1789
 
@@ -1728,22 +1799,7 @@ class Renderer {
1728
1799
  // Renderer can't be resized while presenting in XR.
1729
1800
  if ( this.xr && this.xr.isPresenting ) return;
1730
1801
 
1731
- this._width = width;
1732
- this._height = height;
1733
-
1734
- this.domElement.width = Math.floor( width * this._pixelRatio );
1735
- this.domElement.height = Math.floor( height * this._pixelRatio );
1736
-
1737
- if ( updateStyle === true ) {
1738
-
1739
- this.domElement.style.width = width + 'px';
1740
- this.domElement.style.height = height + 'px';
1741
-
1742
- }
1743
-
1744
- this.setViewport( 0, 0, width, height );
1745
-
1746
- if ( this._initialized ) this.backend.updateSize();
1802
+ this._canvasTarget.setSize( width, height, updateStyle );
1747
1803
 
1748
1804
  }
1749
1805
 
@@ -1779,14 +1835,7 @@ class Renderer {
1779
1835
  */
1780
1836
  getScissor( target ) {
1781
1837
 
1782
- const scissor = this._scissor;
1783
-
1784
- target.x = scissor.x;
1785
- target.y = scissor.y;
1786
- target.width = scissor.width;
1787
- target.height = scissor.height;
1788
-
1789
- return target;
1838
+ return this._canvasTarget.getScissor( target );
1790
1839
 
1791
1840
  }
1792
1841
 
@@ -1801,17 +1850,7 @@ class Renderer {
1801
1850
  */
1802
1851
  setScissor( x, y, width, height ) {
1803
1852
 
1804
- const scissor = this._scissor;
1805
-
1806
- if ( x.isVector4 ) {
1807
-
1808
- scissor.copy( x );
1809
-
1810
- } else {
1811
-
1812
- scissor.set( x, y, width, height );
1813
-
1814
- }
1853
+ this._canvasTarget.setScissor( x, y, width, height );
1815
1854
 
1816
1855
  }
1817
1856
 
@@ -1822,7 +1861,7 @@ class Renderer {
1822
1861
  */
1823
1862
  getScissorTest() {
1824
1863
 
1825
- return this._scissorTest;
1864
+ return this._canvasTarget.getScissorTest();
1826
1865
 
1827
1866
  }
1828
1867
 
@@ -1833,7 +1872,9 @@ class Renderer {
1833
1872
  */
1834
1873
  setScissorTest( boolean ) {
1835
1874
 
1836
- this._scissorTest = boolean;
1875
+ this._canvasTarget.setScissorTest( boolean );
1876
+
1877
+ // TODO: Move it to CanvasTarget event listener.
1837
1878
 
1838
1879
  this.backend.setScissorTest( boolean );
1839
1880
 
@@ -1847,7 +1888,7 @@ class Renderer {
1847
1888
  */
1848
1889
  getViewport( target ) {
1849
1890
 
1850
- return target.copy( this._viewport );
1891
+ return this._canvasTarget.getViewport( target );
1851
1892
 
1852
1893
  }
1853
1894
 
@@ -1863,20 +1904,7 @@ class Renderer {
1863
1904
  */
1864
1905
  setViewport( x, y, width, height, minDepth = 0, maxDepth = 1 ) {
1865
1906
 
1866
- const viewport = this._viewport;
1867
-
1868
- if ( x.isVector4 ) {
1869
-
1870
- viewport.copy( x );
1871
-
1872
- } else {
1873
-
1874
- viewport.set( x, y, width, height );
1875
-
1876
- }
1877
-
1878
- viewport.minDepth = minDepth;
1879
- viewport.maxDepth = maxDepth;
1907
+ this._canvasTarget.setViewport( x, y, width, height, minDepth, maxDepth );
1880
1908
 
1881
1909
  }
1882
1910
 
@@ -1993,16 +2021,12 @@ class Renderer {
1993
2021
  * @param {boolean} [color=true] - Whether the color buffer should be cleared or not.
1994
2022
  * @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not.
1995
2023
  * @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not.
1996
- * @return {Promise} A Promise that resolves when the clear operation has been executed.
1997
- * Only returned when the renderer has not been initialized.
1998
2024
  */
1999
2025
  clear( color = true, depth = true, stencil = true ) {
2000
2026
 
2001
2027
  if ( this._initialized === false ) {
2002
2028
 
2003
- console.warn( 'THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead.' );
2004
-
2005
- return this.clearAsync( color, depth, stencil );
2029
+ throw new Error( 'Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before before using this method.' );
2006
2030
 
2007
2031
  }
2008
2032
 
@@ -2043,37 +2067,28 @@ class Renderer {
2043
2067
 
2044
2068
  /**
2045
2069
  * Performs a manual clear operation of the color buffer. This method ignores `autoClear` properties.
2046
- *
2047
- * @return {Promise} A Promise that resolves when the clear operation has been executed.
2048
- * Only returned when the renderer has not been initialized.
2049
2070
  */
2050
2071
  clearColor() {
2051
2072
 
2052
- return this.clear( true, false, false );
2073
+ this.clear( true, false, false );
2053
2074
 
2054
2075
  }
2055
2076
 
2056
2077
  /**
2057
2078
  * Performs a manual clear operation of the depth buffer. This method ignores `autoClear` properties.
2058
- *
2059
- * @return {Promise} A Promise that resolves when the clear operation has been executed.
2060
- * Only returned when the renderer has not been initialized.
2061
2079
  */
2062
2080
  clearDepth() {
2063
2081
 
2064
- return this.clear( false, true, false );
2082
+ this.clear( false, true, false );
2065
2083
 
2066
2084
  }
2067
2085
 
2068
2086
  /**
2069
2087
  * Performs a manual clear operation of the stencil buffer. This method ignores `autoClear` properties.
2070
- *
2071
- * @return {Promise} A Promise that resolves when the clear operation has been executed.
2072
- * Only returned when the renderer has not been initialized.
2073
2088
  */
2074
2089
  clearStencil() {
2075
2090
 
2076
- return this.clear( false, false, true );
2091
+ this.clear( false, false, true );
2077
2092
 
2078
2093
  }
2079
2094
 
@@ -2081,6 +2096,7 @@ class Renderer {
2081
2096
  * Async version of {@link Renderer#clear}.
2082
2097
  *
2083
2098
  * @async
2099
+ * @deprecated
2084
2100
  * @param {boolean} [color=true] - Whether the color buffer should be cleared or not.
2085
2101
  * @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not.
2086
2102
  * @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not.
@@ -2088,7 +2104,9 @@ class Renderer {
2088
2104
  */
2089
2105
  async clearAsync( color = true, depth = true, stencil = true ) {
2090
2106
 
2091
- if ( this._initialized === false ) await this.init();
2107
+ warnOnce( 'Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
2108
+
2109
+ await this.init();
2092
2110
 
2093
2111
  this.clear( color, depth, stencil );
2094
2112
 
@@ -2098,11 +2116,14 @@ class Renderer {
2098
2116
  * Async version of {@link Renderer#clearColor}.
2099
2117
  *
2100
2118
  * @async
2119
+ * @deprecated
2101
2120
  * @return {Promise} A Promise that resolves when the clear operation has been executed.
2102
2121
  */
2103
2122
  async clearColorAsync() {
2104
2123
 
2105
- this.clearAsync( true, false, false );
2124
+ warnOnce( 'Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
2125
+
2126
+ this.clear( true, false, false );
2106
2127
 
2107
2128
  }
2108
2129
 
@@ -2110,11 +2131,14 @@ class Renderer {
2110
2131
  * Async version of {@link Renderer#clearDepth}.
2111
2132
  *
2112
2133
  * @async
2134
+ * @deprecated
2113
2135
  * @return {Promise} A Promise that resolves when the clear operation has been executed.
2114
2136
  */
2115
2137
  async clearDepthAsync() {
2116
2138
 
2117
- this.clearAsync( false, true, false );
2139
+ warnOnce( 'Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
2140
+
2141
+ this.clear( false, true, false );
2118
2142
 
2119
2143
  }
2120
2144
 
@@ -2122,11 +2146,67 @@ class Renderer {
2122
2146
  * Async version of {@link Renderer#clearStencil}.
2123
2147
  *
2124
2148
  * @async
2149
+ * @deprecated
2125
2150
  * @return {Promise} A Promise that resolves when the clear operation has been executed.
2126
2151
  */
2127
2152
  async clearStencilAsync() {
2128
2153
 
2129
- this.clearAsync( false, false, true );
2154
+ warnOnce( 'Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
2155
+
2156
+ this.clear( false, false, true );
2157
+
2158
+ }
2159
+
2160
+ /**
2161
+ * Returns `true` if a framebuffer target is needed to perform tone mapping or color space conversion.
2162
+ * If this is the case, the renderer allocates an internal render target for that purpose.
2163
+ *
2164
+ */
2165
+ get needsFrameBufferTarget() {
2166
+
2167
+ const useToneMapping = this.currentToneMapping !== NoToneMapping;
2168
+ const useColorSpace = this.currentColorSpace !== ColorManagement.workingColorSpace;
2169
+
2170
+ return useToneMapping || useColorSpace;
2171
+
2172
+ }
2173
+
2174
+ /**
2175
+ * The number of samples used for multi-sample anti-aliasing (MSAA).
2176
+ *
2177
+ * @type {number}
2178
+ * @default 0
2179
+ */
2180
+ get samples() {
2181
+
2182
+ return this._samples;
2183
+
2184
+ }
2185
+
2186
+ /**
2187
+ * The current number of samples used for multi-sample anti-aliasing (MSAA).
2188
+ *
2189
+ * When rendering to a custom render target, the number of samples of that render target is used.
2190
+ * If the renderer needs an internal framebuffer target for tone mapping or color space conversion,
2191
+ * the number of samples is set to 0.
2192
+ *
2193
+ * @type {number}
2194
+ */
2195
+ get currentSamples() {
2196
+
2197
+ let samples = this._samples;
2198
+
2199
+ if ( this._renderTarget !== null ) {
2200
+
2201
+ samples = this._renderTarget.samples;
2202
+
2203
+ } else if ( this.needsFrameBufferTarget ) {
2204
+
2205
+ samples = 0;
2206
+
2207
+ }
2208
+
2209
+ return samples;
2130
2210
 
2131
2211
  }
2132
2212
 
@@ -2171,25 +2251,30 @@ class Renderer {
2171
2251
  */
2172
2252
  dispose() {
2173
2253
 
2174
- this.info.dispose();
2175
- this.backend.dispose();
2254
+ if ( this._initialized === true ) {
2176
2255
 
2177
- this._animation.dispose();
2178
- this._objects.dispose();
2179
- this._pipelines.dispose();
2180
- this._nodes.dispose();
2181
- this._bindings.dispose();
2182
- this._renderLists.dispose();
2183
- this._renderContexts.dispose();
2184
- this._textures.dispose();
2256
+ this.info.dispose();
2257
+ this.backend.dispose();
2185
2258
 
2186
- if ( this._frameBufferTarget !== null ) this._frameBufferTarget.dispose();
2259
+ this._animation.dispose();
2260
+ this._objects.dispose();
2261
+ this._geometries.dispose();
2262
+ this._pipelines.dispose();
2263
+ this._nodes.dispose();
2264
+ this._bindings.dispose();
2265
+ this._renderLists.dispose();
2266
+ this._renderContexts.dispose();
2267
+ this._textures.dispose();
2187
2268
 
2188
- Object.values( this.backend.timestampQueryPool ).forEach( queryPool => {
2269
+ if ( this._frameBufferTarget !== null ) this._frameBufferTarget.dispose();
2189
2270
 
2190
- if ( queryPool !== null ) queryPool.dispose();
2271
+ Object.values( this.backend.timestampQueryPool ).forEach( queryPool => {
2191
2272
 
2192
- } );
2273
+ if ( queryPool !== null ) queryPool.dispose();
2274
+
2275
+ } );
2276
+
2277
+ }
2193
2278
 
2194
2279
  this.setRenderTarget( null );
2195
2280
  this.setAnimationLoop( null );
@@ -2246,6 +2331,32 @@ class Renderer {
2246
2331
 
2247
2332
  }
2248
2333
 
2334
+ /**
2335
+ * Sets the canvas target. The canvas target manages the HTML canvas
2336
+ * or the offscreen canvas the renderer draws into.
2337
+ *
2338
+ * @param {CanvasTarget} canvasTarget - The canvas target.
2339
+ */
2340
+ setCanvasTarget( canvasTarget ) {
2341
+
2342
+ this._canvasTarget.removeEventListener( 'resize', this._onCanvasTargetResize );
2343
+
2344
+ this._canvasTarget = canvasTarget;
2345
+ this._canvasTarget.addEventListener( 'resize', this._onCanvasTargetResize );
2346
+
2347
+ }
2348
+
2349
+ /**
2350
+ * Returns the current canvas target.
2351
+ *
2352
+ * @return {CanvasTarget} The current canvas target.
2353
+ */
2354
+ getCanvasTarget() {
2355
+
2356
+ return this._canvasTarget;
2357
+
2358
+ }
2359
+
2249
2360
  /**
2250
2361
  * Resets the renderer to the initial state before WebXR started.
2251
2362
  *
@@ -2309,18 +2420,21 @@ class Renderer {
2309
2420
  * if the renderer has been initialized.
2310
2421
  *
2311
2422
  * @param {Node|Array<Node>} computeNodes - The compute node(s).
2312
- * @param {Array<number>|number} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
2423
+ * @param {number|Array<number>|IndirectStorageBufferAttribute} [dispatchSize=null]
2424
+ * - A single number representing count, or
2425
+ * - An array [x, y, z] representing dispatch size, or
2426
+ * - A IndirectStorageBufferAttribute for indirect dispatch size.
2313
2427
  * @return {Promise|undefined} A Promise that resolve when the compute has finished. Only returned when the renderer has not been initialized.
2314
2428
  */
2315
- compute( computeNodes, dispatchSizeOrCount = null ) {
2429
+ compute( computeNodes, dispatchSize = null ) {
2316
2430
 
2317
2431
  if ( this._isDeviceLost === true ) return;
2318
2432
 
2319
2433
  if ( this._initialized === false ) {
2320
2434
 
2321
- console.warn( 'THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead.' );
2435
+ warn( 'Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead.' );
2322
2436
 
2323
- return this.computeAsync( computeNodes );
2437
+ return this.computeAsync( computeNodes, dispatchSize );
2324
2438
 
2325
2439
  }
2326
2440
 
@@ -2340,6 +2454,12 @@ class Renderer {
2340
2454
 
2341
2455
  //
2342
2456
 
2457
+ this.backend.updateTimeStampUID( computeNodes );
2458
+
2459
+ this.inspector.beginCompute( this.backend.getTimestampUID( computeNodes ), computeNodes );
2460
+
2461
+ //
2462
+
2343
2463
  const backend = this.backend;
2344
2464
  const pipelines = this._pipelines;
2345
2465
  const bindings = this._bindings;
@@ -2366,7 +2486,7 @@ class Renderer {
2366
2486
  computeNode.removeEventListener( 'dispose', dispose );
2367
2487
 
2368
2488
  pipelines.delete( computeNode );
2369
- bindings.delete( computeNode );
2489
+ bindings.deleteForCompute( computeNode );
2370
2490
  nodes.delete( computeNode );
2371
2491
 
2372
2492
  };
@@ -2391,7 +2511,7 @@ class Renderer {
2391
2511
  const computeBindings = bindings.getForCompute( computeNode );
2392
2512
  const computePipeline = pipelines.getForCompute( computeNode, computeBindings );
2393
2513
 
2394
- backend.compute( computeNodes, computeNode, computeBindings, computePipeline, dispatchSizeOrCount );
2514
+ backend.compute( computeNodes, computeNode, computeBindings, computePipeline, dispatchSize );
2395
2515
 
2396
2516
  }
2397
2517
 
@@ -2401,6 +2521,10 @@ class Renderer {
2401
2521
 
2402
2522
  nodeFrame.renderId = previousRenderId;
2403
2523
 
2524
+ //
2525
+
2526
+ this.inspector.finishCompute( this.backend.getTimestampUID( computeNodes ) );
2527
+
2404
2528
  }
2405
2529
 
2406
2530
  /**
@@ -2408,14 +2532,17 @@ class Renderer {
2408
2532
  *
2409
2533
  * @async
2410
2534
  * @param {Node|Array<Node>} computeNodes - The compute node(s).
2411
- * @param {Array<number>|number} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
2535
+ * @param {number|Array<number>|IndirectStorageBufferAttribute} [dispatchSize=null]
2536
+ * - A single number representing count, or
2537
+ * - An array [x, y, z] representing dispatch size, or
2538
+ * - A IndirectStorageBufferAttribute for indirect dispatch size.
2412
2539
  * @return {Promise} A Promise that resolve when the compute has finished.
2413
2540
  */
2414
- async computeAsync( computeNodes, dispatchSizeOrCount = null ) {
2541
+ async computeAsync( computeNodes, dispatchSize = null ) {
2415
2542
 
2416
2543
  if ( this._initialized === false ) await this.init();
2417
2544
 
2418
- this.compute( computeNodes, dispatchSizeOrCount );
2545
+ this.compute( computeNodes, dispatchSize );
2419
2546
 
2420
2547
  }
2421
2548
 
@@ -2423,14 +2550,17 @@ class Renderer {
2423
2550
  * Checks if the given feature is supported by the selected backend.
2424
2551
  *
2425
2552
  * @async
2553
+ * @deprecated
2426
2554
  * @param {string} name - The feature's name.
2427
2555
  * @return {Promise<boolean>} A Promise that resolves with a bool that indicates whether the feature is supported or not.
2428
2556
  */
2429
2557
  async hasFeatureAsync( name ) {
2430
2558
 
2431
- if ( this._initialized === false ) await this.init();
2559
+ warnOnce( 'Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
2432
2560
 
2433
- return this.backend.hasFeature( name );
2561
+ await this.init();
2562
+
2563
+ return this.hasFeature( name );
2434
2564
 
2435
2565
  }
2436
2566
 
@@ -2453,9 +2583,7 @@ class Renderer {
2453
2583
 
2454
2584
  if ( this._initialized === false ) {
2455
2585
 
2456
- console.warn( 'THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead.' );
2457
-
2458
- return false;
2586
+ throw new Error( 'Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before before using this method.' );
2459
2587
 
2460
2588
  }
2461
2589
 
@@ -2479,14 +2607,17 @@ class Renderer {
2479
2607
  * (which can cause noticeable lags due to decode and GPU upload overhead).
2480
2608
  *
2481
2609
  * @async
2610
+ * @deprecated
2482
2611
  * @param {Texture} texture - The texture.
2483
2612
  * @return {Promise} A Promise that resolves when the texture has been initialized.
2484
2613
  */
2485
2614
  async initTextureAsync( texture ) {
2486
2615
 
2487
- if ( this._initialized === false ) await this.init();
2616
+ warnOnce( 'Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.' ); // @deprecated r181
2488
2617
 
2489
- this._textures.updateTexture( texture );
2618
+ await this.init();
2619
+
2620
+ this.initTexture( texture );
2490
2621
 
2491
2622
  }
2492
2623
 
@@ -2502,7 +2633,7 @@ class Renderer {
2502
2633
 
2503
2634
  if ( this._initialized === false ) {
2504
2635
 
2505
- console.warn( 'THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead.' );
2636
+ throw new Error( 'Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before before using this method.' );
2506
2637
 
2507
2638
  }
2508
2639
 
@@ -2514,7 +2645,7 @@ class Renderer {
2514
2645
  * Copies the current bound framebuffer into the given texture.
2515
2646
  *
2516
2647
  * @param {FramebufferTexture} framebufferTexture - The texture.
2517
- * @param {?Vector2|Vector4} [rectangle=null] - A two or four dimensional vector that defines the rectangular portion of the framebuffer that should be copied.
2648
+ * @param {?(Vector2|Vector4)} [rectangle=null] - A two or four dimensional vector that defines the rectangular portion of the framebuffer that should be copied.
2518
2649
  */
2519
2650
  copyFramebufferToTexture( framebufferTexture, rectangle = null ) {
2520
2651
 
@@ -2530,7 +2661,7 @@ class Renderer {
2530
2661
 
2531
2662
  } else {
2532
2663
 
2533
- console.error( 'THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.' );
2664
+ error( 'Renderer.copyFramebufferToTexture: Invalid rectangle.' );
2534
2665
 
2535
2666
  return;
2536
2667
 
@@ -2571,6 +2702,8 @@ class Renderer {
2571
2702
 
2572
2703
  this.backend.copyFramebufferToTexture( framebufferTexture, renderContext, rectangle );
2573
2704
 
2705
+ this._inspector.copyFramebufferToTexture( framebufferTexture );
2706
+
2574
2707
  }
2575
2708
 
2576
2709
  /**
@@ -2590,6 +2723,8 @@ class Renderer {
2590
2723
 
2591
2724
  this.backend.copyTextureToTexture( srcTexture, dstTexture, srcRegion, dstPosition, srcLevel, dstLevel );
2592
2725
 
2726
+ this._inspector.copyTextureToTexture( srcTexture, dstTexture );
2727
+
2593
2728
  }
2594
2729
 
2595
2730
  /**
@@ -2667,7 +2802,7 @@ class Renderer {
2667
2802
 
2668
2803
  } else if ( object.isLineLoop ) {
2669
2804
 
2670
- console.error( 'THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.' );
2805
+ error( 'Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.' );
2671
2806
 
2672
2807
  } else if ( object.isMesh || object.isLine || object.isPoints ) {
2673
2808
 
@@ -2836,6 +2971,93 @@ class Renderer {
2836
2971
 
2837
2972
  }
2838
2973
 
2974
+ /**
2975
+ * Retrieves shadow nodes for the given material. This is used to setup shadow passes.
2976
+ * The result is cached per material and updated when the material's version changes.
2977
+ *
2978
+ * @param {Material} material
2979
+ * @returns {Object} - The shadow nodes for the material.
2980
+ */
2981
+ _getShadowNodes( material ) {
2982
+
2983
+ const version = material.version;
2984
+
2985
+ let cache = this._cacheShadowNodes.get( material );
2986
+
2987
+ if ( cache === undefined || cache.version !== version ) {
2988
+
2989
+ const hasMap = material.map !== null;
2990
+ const hasColorNode = material.colorNode && material.colorNode.isNode;
2991
+ const hasCastShadowNode = material.castShadowNode && material.castShadowNode.isNode;
2992
+
2993
+ let positionNode = null;
2994
+ let colorNode = null;
2995
+ let depthNode = null;
2996
+
2997
+ if ( hasMap || hasColorNode || hasCastShadowNode ) {
2998
+
2999
+ let shadowRGB;
3000
+ let shadowAlpha;
3001
+
3002
+ if ( hasCastShadowNode ) {
3003
+
3004
+ shadowRGB = material.castShadowNode.rgb;
3005
+ shadowAlpha = material.castShadowNode.a;
3006
+
3007
+ } else {
3008
+
3009
+ shadowRGB = vec3( 0 );
3010
+ shadowAlpha = float( 1 );
3011
+
3012
+ }
3013
+
3014
+ if ( hasMap ) {
3015
+
3016
+ shadowAlpha = shadowAlpha.mul( reference( 'map', 'texture', material ).a );
3017
+
3018
+ }
3019
+
3020
+ if ( hasColorNode ) {
3021
+
3022
+ shadowAlpha = shadowAlpha.mul( material.colorNode.a );
3023
+
3024
+ }
3025
+
3026
+ colorNode = vec4( shadowRGB, shadowAlpha );
3027
+
3028
+ }
3029
+
3030
+ if ( material.depthNode && material.depthNode.isNode ) {
3031
+
3032
+ depthNode = material.depthNode;
3033
+
3034
+ }
3035
+
3036
+ if ( material.castShadowPositionNode && material.castShadowPositionNode.isNode ) {
3037
+
3038
+ positionNode = material.castShadowPositionNode;
3039
+
3040
+ } else if ( material.positionNode && material.positionNode.isNode ) {
3041
+
3042
+ positionNode = material.positionNode;
3043
+
3044
+ }
3045
+
3046
+ cache = {
3047
+ version,
3048
+ colorNode,
3049
+ depthNode,
3050
+ positionNode
3051
+ };
3052
+
3053
+ this._cacheShadowNodes.set( material, cache );
3054
+
3055
+ }
3056
+
3057
+ return cache;
3058
+
3059
+ }
3060
+
2839
3061
  /**
2840
3062
  * This method represents the default render object function that manages the render lifecycle
2841
3063
  * of the object.
@@ -2852,9 +3074,11 @@ class Renderer {
2852
3074
  */
2853
3075
  renderObject( object, scene, camera, geometry, material, group, lightsNode, clippingContext = null, passId = null ) {
2854
3076
 
2855
- let overridePositionNode;
2856
- let overrideColorNode;
2857
- let overrideDepthNode;
3077
+ let materialOverride = false;
3078
+ let materialColorNode;
3079
+ let materialDepthNode;
3080
+ let materialPositionNode;
3081
+ let materialSide;
2858
3082
 
2859
3083
  //
2860
3084
 
@@ -2866,41 +3090,35 @@ class Renderer {
2866
3090
 
2867
3091
  const overrideMaterial = scene.overrideMaterial;
2868
3092
 
3093
+ materialOverride = true;
3094
+
3095
+ // store original nodes
3096
+ materialColorNode = scene.overrideMaterial.colorNode;
3097
+ materialDepthNode = scene.overrideMaterial.depthNode;
3098
+ materialPositionNode = scene.overrideMaterial.positionNode;
3099
+ materialSide = scene.overrideMaterial.side;
3100
+
2869
3101
  if ( material.positionNode && material.positionNode.isNode ) {
2870
3102
 
2871
- overridePositionNode = overrideMaterial.positionNode;
2872
3103
  overrideMaterial.positionNode = material.positionNode;
2873
3104
 
2874
3105
  }
2875
3106
 
2876
3107
  overrideMaterial.alphaTest = material.alphaTest;
2877
3108
  overrideMaterial.alphaMap = material.alphaMap;
2878
- overrideMaterial.transparent = material.transparent || material.transmission > 0;
3109
+ overrideMaterial.transparent = material.transparent || material.transmission > 0 ||
3110
+ ( material.transmissionNode && material.transmissionNode.isNode ) ||
3111
+ ( material.backdropNode && material.backdropNode.isNode );
2879
3112
 
2880
3113
  if ( overrideMaterial.isShadowPassMaterial ) {
2881
3114
 
2882
- overrideMaterial.side = material.shadowSide === null ? material.side : material.shadowSide;
2883
-
2884
- if ( material.depthNode && material.depthNode.isNode ) {
2885
-
2886
- overrideDepthNode = overrideMaterial.depthNode;
2887
- overrideMaterial.depthNode = material.depthNode;
3115
+ const { colorNode, depthNode, positionNode } = this._getShadowNodes( material );
2888
3116
 
2889
- }
2890
-
2891
- if ( material.castShadowNode && material.castShadowNode.isNode ) {
2892
-
2893
- overrideColorNode = overrideMaterial.colorNode;
2894
- overrideMaterial.colorNode = material.castShadowNode;
2895
-
2896
- }
2897
-
2898
- if ( material.castShadowPositionNode && material.castShadowPositionNode.isNode ) {
3117
+ overrideMaterial.side = material.shadowSide === null ? material.side : material.shadowSide;
2899
3118
 
2900
- overridePositionNode = overrideMaterial.positionNode;
2901
- overrideMaterial.positionNode = material.castShadowPositionNode;
2902
-
2903
- }
3119
+ if ( colorNode !== null ) overrideMaterial.colorNode = colorNode;
3120
+ if ( depthNode !== null ) overrideMaterial.depthNode = depthNode;
3121
+ if ( positionNode !== null ) overrideMaterial.positionNode = positionNode;
2904
3122
 
2905
3123
  }
2906
3124
 
@@ -2928,21 +3146,12 @@ class Renderer {
2928
3146
 
2929
3147
  //
2930
3148
 
2931
- if ( overridePositionNode !== undefined ) {
3149
+ if ( materialOverride ) {
2932
3150
 
2933
- scene.overrideMaterial.positionNode = overridePositionNode;
2934
-
2935
- }
2936
-
2937
- if ( overrideDepthNode !== undefined ) {
2938
-
2939
- scene.overrideMaterial.depthNode = overrideDepthNode;
2940
-
2941
- }
2942
-
2943
- if ( overrideColorNode !== undefined ) {
2944
-
2945
- scene.overrideMaterial.colorNode = overrideColorNode;
3151
+ scene.overrideMaterial.colorNode = materialColorNode;
3152
+ scene.overrideMaterial.depthNode = materialDepthNode;
3153
+ scene.overrideMaterial.positionNode = materialPositionNode;
3154
+ scene.overrideMaterial.side = materialSide;
2946
3155
 
2947
3156
  }
2948
3157
 
@@ -3042,6 +3251,17 @@ class Renderer {
3042
3251
 
3043
3252
  }
3044
3253
 
3254
+ /**
3255
+ * Callback when the canvas has been resized.
3256
+ *
3257
+ * @private
3258
+ */
3259
+ _onCanvasTargetResize() {
3260
+
3261
+ if ( this._initialized ) this.backend.updateSize();
3262
+
3263
+ }
3264
+
3045
3265
  /**
3046
3266
  * Alias for `compileAsync()`.
3047
3267
  *
@@ -3059,4 +3279,12 @@ class Renderer {
3059
3279
 
3060
3280
  }
3061
3281
 
3282
+ /**
3283
+ * Animation loop parameter of `renderer.setAnimationLoop()`.
3284
+ *
3285
+ * @callback onAnimationCallback
3286
+ * @param {DOMHighResTimeStamp} time - A timestamp indicating the end time of the previous frame's rendering.
3287
+ * @param {XRFrame} [frame] - A reference to the current XR frame. Only relevant when using XR rendering.
3288
+ */
3289
+
3062
3290
  export default Renderer;