@plastic-software/three 0.182.0 → 0.183.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 (298) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +11520 -10877
  3. package/build/three.core.js +11732 -11340
  4. package/build/three.core.min.js +2 -2
  5. package/build/three.module.js +509 -262
  6. package/build/three.module.min.js +2 -2
  7. package/build/three.tsl.js +7 -11
  8. package/build/three.tsl.min.js +2 -2
  9. package/build/three.webgpu.js +3072 -2607
  10. package/build/three.webgpu.min.js +2 -2
  11. package/build/three.webgpu.nodes.js +3071 -2607
  12. package/build/three.webgpu.nodes.min.js +2 -2
  13. package/examples/jsm/Addons.js +0 -3
  14. package/examples/jsm/animation/CCDIKSolver.js +2 -2
  15. package/examples/jsm/controls/ArcballControls.js +3 -3
  16. package/examples/jsm/controls/OrbitControls.js +103 -0
  17. package/examples/jsm/effects/AnaglyphEffect.js +102 -7
  18. package/examples/jsm/environments/ColorEnvironment.js +59 -0
  19. package/examples/jsm/environments/RoomEnvironment.js +1 -0
  20. package/examples/jsm/exporters/EXRExporter.js +1 -1
  21. package/examples/jsm/exporters/GLTFExporter.js +131 -4
  22. package/examples/jsm/exporters/USDZExporter.js +22 -3
  23. package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
  24. package/examples/jsm/helpers/ViewHelper.js +67 -8
  25. package/examples/jsm/inspector/Inspector.js +21 -5
  26. package/examples/jsm/inspector/tabs/Console.js +39 -5
  27. package/examples/jsm/inspector/tabs/Parameters.js +16 -0
  28. package/examples/jsm/inspector/ui/Style.js +25 -1
  29. package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
  30. package/examples/jsm/lines/LineMaterial.js +6 -0
  31. package/examples/jsm/loaders/3MFLoader.js +2 -2
  32. package/examples/jsm/loaders/AMFLoader.js +2 -2
  33. package/examples/jsm/loaders/ColladaLoader.js +24 -4026
  34. package/examples/jsm/loaders/EXRLoader.js +5 -5
  35. package/examples/jsm/loaders/FBXLoader.js +2 -2
  36. package/examples/jsm/loaders/GCodeLoader.js +34 -8
  37. package/examples/jsm/loaders/GLTFLoader.js +122 -171
  38. package/examples/jsm/loaders/KMZLoader.js +5 -5
  39. package/examples/jsm/loaders/KTX2Loader.js +5 -5
  40. package/examples/jsm/loaders/LWOLoader.js +7 -39
  41. package/examples/jsm/loaders/NRRDLoader.js +2 -2
  42. package/examples/jsm/loaders/PCDLoader.js +3 -2
  43. package/examples/jsm/loaders/USDLoader.js +100 -40
  44. package/examples/jsm/loaders/UltraHDRLoader.js +182 -30
  45. package/examples/jsm/loaders/VRMLLoader.js +77 -0
  46. package/examples/jsm/loaders/VTKLoader.js +37 -24
  47. package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
  48. package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
  49. package/examples/jsm/loaders/usd/USDAParser.js +447 -366
  50. package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
  51. package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
  52. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
  53. package/examples/jsm/objects/LensflareMesh.js +1 -1
  54. package/examples/jsm/objects/Sky.js +76 -4
  55. package/examples/jsm/objects/SkyMesh.js +114 -7
  56. package/examples/jsm/objects/Water.js +4 -3
  57. package/examples/jsm/objects/Water2.js +5 -3
  58. package/examples/jsm/objects/WaterMesh.js +5 -7
  59. package/examples/jsm/physics/JoltPhysics.js +7 -5
  60. package/examples/jsm/physics/RapierPhysics.js +6 -4
  61. package/examples/jsm/postprocessing/EffectComposer.js +7 -5
  62. package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
  63. package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
  64. package/examples/jsm/renderers/SVGRenderer.js +2 -2
  65. package/examples/jsm/shaders/GTAOShader.js +19 -6
  66. package/examples/jsm/shaders/HalftoneShader.js +12 -1
  67. package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
  68. package/examples/jsm/shaders/SAOShader.js +17 -4
  69. package/examples/jsm/shaders/SSAOShader.js +11 -1
  70. package/examples/jsm/shaders/SSRShader.js +6 -5
  71. package/examples/jsm/shaders/VignetteShader.js +1 -1
  72. package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
  73. package/examples/jsm/tsl/display/AnaglyphPassNode.js +456 -16
  74. package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
  75. package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
  76. package/examples/jsm/tsl/display/BloomNode.js +5 -5
  77. package/examples/jsm/tsl/display/CRT.js +150 -0
  78. package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
  79. package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
  80. package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
  81. package/examples/jsm/tsl/display/FXAANode.js +2 -2
  82. package/examples/jsm/tsl/display/GTAONode.js +2 -2
  83. package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
  84. package/examples/jsm/tsl/display/GodraysNode.js +624 -0
  85. package/examples/jsm/tsl/display/LensflareNode.js +1 -1
  86. package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
  87. package/examples/jsm/tsl/display/OutlineNode.js +3 -3
  88. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
  89. package/examples/jsm/tsl/display/PixelationPassNode.js +5 -5
  90. package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
  91. package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
  92. package/examples/jsm/tsl/display/SMAANode.js +2 -2
  93. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
  94. package/examples/jsm/tsl/display/SSGINode.js +2 -2
  95. package/examples/jsm/tsl/display/SSRNode.js +7 -7
  96. package/examples/jsm/tsl/display/SSSNode.js +2 -2
  97. package/examples/jsm/tsl/display/Shape.js +29 -0
  98. package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
  99. package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
  100. package/examples/jsm/tsl/display/TRAANode.js +9 -12
  101. package/examples/jsm/tsl/display/TransitionNode.js +1 -1
  102. package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
  103. package/examples/jsm/tsl/math/Bayer.js +40 -1
  104. package/examples/jsm/utils/LDrawUtils.js +1 -1
  105. package/package.json +11 -19
  106. package/src/Three.Core.js +1 -1
  107. package/src/Three.TSL.js +5 -9
  108. package/src/Three.WebGPU.Nodes.js +2 -0
  109. package/src/Three.WebGPU.js +3 -0
  110. package/src/Three.js +1 -0
  111. package/src/animation/AnimationAction.js +1 -1
  112. package/src/animation/AnimationClip.js +1 -1
  113. package/src/animation/AnimationMixer.js +6 -0
  114. package/src/animation/KeyframeTrack.js +46 -7
  115. package/src/animation/PropertyMixer.js +4 -4
  116. package/src/audio/Audio.js +1 -1
  117. package/src/audio/AudioListener.js +5 -3
  118. package/src/cameras/Camera.js +32 -2
  119. package/src/cameras/CubeCamera.js +20 -0
  120. package/src/constants.js +30 -1
  121. package/src/core/Clock.js +7 -0
  122. package/src/core/Object3D.js +56 -4
  123. package/src/core/RenderTarget.js +3 -4
  124. package/src/extras/PMREMGenerator.js +4 -8
  125. package/src/geometries/TorusGeometry.js +8 -3
  126. package/src/helpers/CameraHelper.js +3 -0
  127. package/src/helpers/DirectionalLightHelper.js +4 -1
  128. package/src/helpers/HemisphereLightHelper.js +3 -0
  129. package/src/helpers/PointLightHelper.js +0 -24
  130. package/src/helpers/SpotLightHelper.js +3 -0
  131. package/src/lights/LightShadow.js +15 -3
  132. package/src/lights/webgpu/IESSpotLight.js +2 -1
  133. package/src/loaders/Cache.js +28 -0
  134. package/src/loaders/FileLoader.js +1 -1
  135. package/src/loaders/ImageBitmapLoader.js +8 -3
  136. package/src/loaders/Loader.js +6 -0
  137. package/src/loaders/ObjectLoader.js +18 -1
  138. package/src/materials/MeshLambertMaterial.js +9 -0
  139. package/src/materials/MeshPhongMaterial.js +9 -0
  140. package/src/materials/nodes/Line2NodeMaterial.js +5 -5
  141. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -0
  142. package/src/materials/nodes/NodeMaterial.js +15 -24
  143. package/src/materials/nodes/manager/NodeMaterialObserver.js +9 -3
  144. package/src/math/Line3.js +3 -5
  145. package/src/math/MathUtils.js +10 -10
  146. package/src/math/Matrix4.js +35 -26
  147. package/src/math/Quaternion.js +3 -29
  148. package/src/math/Vector3.js +3 -3
  149. package/src/math/interpolants/BezierInterpolant.js +108 -0
  150. package/src/nodes/Nodes.js +87 -68
  151. package/src/nodes/TSL.js +2 -5
  152. package/src/nodes/accessors/Arrays.js +1 -1
  153. package/src/nodes/accessors/Bitangent.js +5 -5
  154. package/src/nodes/accessors/BufferAttributeNode.js +1 -1
  155. package/src/nodes/accessors/Camera.js +149 -28
  156. package/src/nodes/accessors/InstanceNode.js +105 -40
  157. package/src/nodes/accessors/Normal.js +9 -9
  158. package/src/nodes/accessors/Position.js +34 -2
  159. package/src/nodes/accessors/SceneProperties.js +53 -0
  160. package/src/nodes/accessors/SkinningNode.js +12 -24
  161. package/src/nodes/accessors/StorageBufferNode.js +0 -19
  162. package/src/nodes/accessors/StorageTextureNode.js +37 -1
  163. package/src/nodes/accessors/Tangent.js +3 -3
  164. package/src/nodes/accessors/Texture3DNode.js +6 -34
  165. package/src/nodes/accessors/TextureNode.js +58 -22
  166. package/src/nodes/accessors/UniformArrayNode.js +2 -0
  167. package/src/nodes/core/MRTNode.js +48 -2
  168. package/src/nodes/core/Node.js +29 -3
  169. package/src/nodes/core/NodeBuilder.js +115 -40
  170. package/src/nodes/core/NodeError.js +28 -0
  171. package/src/nodes/core/NodeUtils.js +5 -3
  172. package/src/nodes/core/OutputStructNode.js +12 -10
  173. package/src/nodes/core/ParameterNode.js +2 -1
  174. package/src/nodes/core/StackNode.js +9 -8
  175. package/src/nodes/core/StackTrace.js +139 -0
  176. package/src/nodes/core/StructNode.js +15 -0
  177. package/src/nodes/core/SubBuildNode.js +1 -1
  178. package/src/nodes/core/UniformNode.js +2 -1
  179. package/src/nodes/core/VarNode.js +1 -1
  180. package/src/nodes/core/VaryingNode.js +1 -18
  181. package/src/nodes/display/BlendModes.js +0 -64
  182. package/src/nodes/display/ColorAdjustment.js +17 -0
  183. package/src/nodes/display/ColorSpaceNode.js +3 -3
  184. package/src/nodes/display/NormalMapNode.js +2 -2
  185. package/src/nodes/display/PassNode.js +21 -2
  186. package/src/nodes/display/RenderOutputNode.js +3 -3
  187. package/src/nodes/display/ScreenNode.js +2 -1
  188. package/src/nodes/display/ToneMappingNode.js +1 -1
  189. package/src/nodes/display/ToonOutlinePassNode.js +2 -2
  190. package/src/nodes/display/ViewportDepthNode.js +52 -4
  191. package/src/nodes/display/ViewportTextureNode.js +21 -4
  192. package/src/nodes/fog/Fog.js +18 -35
  193. package/src/nodes/functions/PhysicalLightingModel.js +25 -3
  194. package/src/nodes/geometry/RangeNode.js +4 -2
  195. package/src/nodes/gpgpu/ComputeNode.js +5 -4
  196. package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
  197. package/src/nodes/lighting/EnvironmentNode.js +28 -3
  198. package/src/nodes/lighting/PointShadowNode.js +24 -12
  199. package/src/nodes/lighting/ShadowFilterNode.js +15 -43
  200. package/src/nodes/lighting/ShadowNode.js +54 -32
  201. package/src/nodes/math/ConditionalNode.js +2 -2
  202. package/src/nodes/math/MathNode.js +3 -40
  203. package/src/nodes/math/OperatorNode.js +2 -1
  204. package/src/nodes/pmrem/PMREMUtils.js +9 -15
  205. package/src/nodes/tsl/TSLCore.js +13 -10
  206. package/src/nodes/utils/DebugNode.js +11 -11
  207. package/src/nodes/utils/JoinNode.js +2 -2
  208. package/src/nodes/utils/LoopNode.js +1 -1
  209. package/src/nodes/utils/MemberNode.js +1 -1
  210. package/src/nodes/utils/RTTNode.js +1 -1
  211. package/src/nodes/utils/ReflectorNode.js +2 -3
  212. package/src/nodes/utils/SpriteSheetUV.js +35 -0
  213. package/src/nodes/utils/UVUtils.js +4 -2
  214. package/src/objects/BatchedMesh.js +22 -12
  215. package/src/objects/InstancedMesh.js +11 -0
  216. package/src/renderers/WebGLRenderer.js +34 -60
  217. package/src/renderers/common/Backend.js +21 -0
  218. package/src/renderers/common/Background.js +7 -4
  219. package/src/renderers/common/BindGroup.js +1 -9
  220. package/src/renderers/common/Bindings.js +20 -5
  221. package/src/renderers/common/BlendMode.js +143 -0
  222. package/src/renderers/common/BundleGroup.js +1 -1
  223. package/src/renderers/common/CubeRenderTarget.js +50 -6
  224. package/src/renderers/common/Geometries.js +17 -3
  225. package/src/renderers/common/Lighting.js +5 -21
  226. package/src/renderers/common/Pipelines.js +4 -4
  227. package/src/renderers/common/PostProcessing.js +8 -206
  228. package/src/renderers/common/RenderBundles.js +2 -1
  229. package/src/renderers/common/RenderContext.js +16 -0
  230. package/src/renderers/common/RenderContexts.js +33 -56
  231. package/src/renderers/common/RenderLists.js +2 -1
  232. package/src/renderers/common/RenderObject.js +2 -3
  233. package/src/renderers/common/RenderObjectPipeline.js +40 -0
  234. package/src/renderers/common/RenderObjects.js +18 -2
  235. package/src/renderers/common/RenderPipeline.js +203 -17
  236. package/src/renderers/common/Renderer.js +207 -40
  237. package/src/renderers/common/Sampler.js +4 -4
  238. package/src/renderers/common/StorageBuffer.js +13 -1
  239. package/src/renderers/common/Textures.js +16 -0
  240. package/src/renderers/common/TimestampQueryPool.js +5 -3
  241. package/src/renderers/common/Uniform.js +8 -0
  242. package/src/renderers/common/UniformsGroup.js +60 -0
  243. package/src/renderers/common/XRManager.js +2 -2
  244. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  245. package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
  246. package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
  247. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
  248. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
  249. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
  250. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
  251. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
  252. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
  253. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
  254. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
  255. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +23 -1
  256. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
  257. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +55 -24
  258. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
  259. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
  260. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  261. package/src/renderers/shaders/ShaderLib.js +4 -2
  262. package/src/renderers/shaders/UniformsLib.js +0 -3
  263. package/src/renderers/webgl/WebGLBackground.js +2 -2
  264. package/src/renderers/webgl/WebGLBindingStates.js +99 -27
  265. package/src/renderers/webgl/WebGLEnvironments.js +228 -0
  266. package/src/renderers/webgl/WebGLGeometries.js +10 -7
  267. package/src/renderers/webgl/WebGLMaterials.js +12 -0
  268. package/src/renderers/webgl/WebGLObjects.js +3 -1
  269. package/src/renderers/webgl/WebGLProgram.js +2 -2
  270. package/src/renderers/webgl/WebGLPrograms.js +10 -4
  271. package/src/renderers/webgl/WebGLRenderLists.js +15 -0
  272. package/src/renderers/webgl/WebGLShadowMap.js +5 -4
  273. package/src/renderers/webgl/WebGLState.js +12 -17
  274. package/src/renderers/webgl-fallback/WebGLBackend.js +71 -7
  275. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +98 -29
  276. package/src/renderers/webgl-fallback/utils/WebGLState.js +168 -7
  277. package/src/renderers/webgpu/WebGPUBackend.js +58 -9
  278. package/src/renderers/webgpu/WebGPURenderer.js +1 -0
  279. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +257 -45
  280. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +8 -19
  281. package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
  282. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -31
  283. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
  284. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +25 -25
  285. package/src/renderers/webgpu/utils/WebGPUUtils.js +10 -6
  286. package/src/renderers/webxr/WebXRManager.js +2 -2
  287. package/src/textures/Texture.js +2 -2
  288. package/src/utils.js +246 -3
  289. package/examples/jsm/materials/MeshGouraudMaterial.js +0 -433
  290. package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
  291. package/examples/jsm/shaders/GodRaysShader.js +0 -333
  292. package/src/nodes/accessors/SceneNode.js +0 -145
  293. package/src/nodes/code/ScriptableNode.js +0 -726
  294. package/src/nodes/code/ScriptableValueNode.js +0 -253
  295. package/src/nodes/display/PosterizeNode.js +0 -65
  296. package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
  297. package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
  298. package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
@@ -9,7 +9,7 @@ import RenderLists from './RenderLists.js';
9
9
  import RenderContexts from './RenderContexts.js';
10
10
  import Textures from './Textures.js';
11
11
  import Background from './Background.js';
12
- import Nodes from './nodes/Nodes.js';
12
+ import NodeManager from './nodes/NodeManager.js';
13
13
  import Color4 from './Color4.js';
14
14
  import ClippingContext from './ClippingContext.js';
15
15
  import QuadMesh from './QuadMesh.js';
@@ -30,9 +30,9 @@ import { Matrix4 } from '../../math/Matrix4.js';
30
30
  import { Vector2 } from '../../math/Vector2.js';
31
31
  import { Vector4 } from '../../math/Vector4.js';
32
32
  import { RenderTarget } from '../../core/RenderTarget.js';
33
- import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearFilter, HalfFloatType, RGBAFormat, PCFShadowMap } from '../../constants.js';
33
+ import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearFilter, HalfFloatType, RGBAFormat, PCFShadowMap, VSMShadowMap } from '../../constants.js';
34
34
 
35
- import { float, vec3, vec4 } from '../../nodes/tsl/TSLCore.js';
35
+ import { float, vec3, vec4, Fn } from '../../nodes/tsl/TSLCore.js';
36
36
  import { reference } from '../../nodes/accessors/ReferenceNode.js';
37
37
  import { highpModelNormalViewMatrix, highpModelViewMatrix } from '../../nodes/accessors/ModelNode.js';
38
38
  import { context } from '../../nodes/core/ContextNode.js';
@@ -47,6 +47,8 @@ const _frustumArray = /*@__PURE__*/ new FrustumArray();
47
47
  const _projScreenMatrix = /*@__PURE__*/ new Matrix4();
48
48
  const _vector4 = /*@__PURE__*/ new Vector4();
49
49
 
50
+ const _shadowSide = { [ FrontSide ]: BackSide, [ BackSide ]: FrontSide, [ DoubleSide ]: DoubleSide };
51
+
50
52
  /**
51
53
  * Base class for renderers.
52
54
  */
@@ -57,6 +59,7 @@ class Renderer {
57
59
  *
58
60
  * @typedef {Object} Renderer~Options
59
61
  * @property {boolean} [logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
62
+ * @property {boolean} [reversedDepthBuffer=false] - Whether reversed depth buffer is enabled or not.
60
63
  * @property {boolean} [alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
61
64
  * @property {boolean} [depth=true] - Whether the default framebuffer should have a depth buffer or not.
62
65
  * @property {boolean} [stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
@@ -91,6 +94,7 @@ class Renderer {
91
94
 
92
95
  const {
93
96
  logarithmicDepthBuffer = false,
97
+ reversedDepthBuffer = false,
94
98
  alpha = true,
95
99
  depth = true,
96
100
  stencil = false,
@@ -158,9 +162,19 @@ class Renderer {
158
162
  *
159
163
  * @type {boolean}
160
164
  * @default false
165
+ * @readonly
161
166
  */
162
167
  this.logarithmicDepthBuffer = logarithmicDepthBuffer;
163
168
 
169
+ /**
170
+ * Whether reversed depth buffer is enabled or not.
171
+ *
172
+ * @type {boolean}
173
+ * @default false
174
+ * @readonly
175
+ */
176
+ this.reversedDepthBuffer = reversedDepthBuffer;
177
+
164
178
  /**
165
179
  * Defines the output color space of the renderer.
166
180
  *
@@ -317,7 +331,7 @@ class Renderer {
317
331
  * A reference to a renderer module for managing node related logic.
318
332
  *
319
333
  * @private
320
- * @type {?Nodes}
334
+ * @type {?NodeManager}
321
335
  * @default null
322
336
  */
323
337
  this._nodes = null;
@@ -560,8 +574,7 @@ class Renderer {
560
574
  * and pipeline updates.
561
575
  *
562
576
  * @private
563
- * @type {?Function}
564
- * @default null
577
+ * @type {Function}
565
578
  */
566
579
  this._handleObjectFunction = this._renderObjectDirect;
567
580
 
@@ -611,6 +624,16 @@ class Renderer {
611
624
  */
612
625
  this._initialized = false;
613
626
 
627
+ /**
628
+ * The call depth of the renderer. Counts the number of
629
+ * nested render calls.
630
+ *
631
+ * @private
632
+ * @type {number}
633
+ * @default - 1
634
+ */
635
+ this._callDepth = - 1;
636
+
614
637
  /**
615
638
  * A reference to the promise which initializes the renderer.
616
639
  *
@@ -649,6 +672,7 @@ class Renderer {
649
672
  * Shadow map configuration
650
673
  * @typedef {Object} ShadowMapConfig
651
674
  * @property {boolean} enabled - Whether to globally enable shadows or not.
675
+ * @property {boolean} transmitted - Whether to enable light transmission through non-opaque materials.
652
676
  * @property {number} type - The shadow map type.
653
677
  */
654
678
 
@@ -659,6 +683,7 @@ class Renderer {
659
683
  */
660
684
  this.shadowMap = {
661
685
  enabled: false,
686
+ transmitted: false,
662
687
  type: PCFShadowMap
663
688
  };
664
689
 
@@ -696,7 +721,7 @@ class Renderer {
696
721
  await this.compileAsync( scene, camera );
697
722
 
698
723
  const renderList = this._renderLists.get( scene, camera );
699
- const renderContext = this._renderContexts.get( scene, camera, this._renderTarget, this._mrt );
724
+ const renderContext = this._renderContexts.get( this._renderTarget, this._mrt );
700
725
 
701
726
  const material = scene.overrideMaterial || object.material;
702
727
 
@@ -760,7 +785,7 @@ class Renderer {
760
785
 
761
786
  }
762
787
 
763
- this._nodes = new Nodes( this, backend );
788
+ this._nodes = new NodeManager( this, backend );
764
789
  this._animation = new Animation( this, this._nodes, this.info );
765
790
  this._attributes = new Attributes( backend );
766
791
  this._background = new Background( this, this._nodes );
@@ -771,7 +796,7 @@ class Renderer {
771
796
  this._objects = new RenderObjects( this, this._nodes, this._geometries, this._pipelines, this._bindings, this.info );
772
797
  this._renderLists = new RenderLists( this.lighting );
773
798
  this._bundles = new RenderBundles();
774
- this._renderContexts = new RenderContexts();
799
+ this._renderContexts = new RenderContexts( this );
775
800
 
776
801
  //
777
802
 
@@ -847,6 +872,7 @@ class Renderer {
847
872
  const previousRenderId = nodeFrame.renderId;
848
873
  const previousRenderContext = this._currentRenderContext;
849
874
  const previousRenderObjectFunction = this._currentRenderObjectFunction;
875
+ const previousHandleObjectFunction = this._handleObjectFunction;
850
876
  const previousCompilationPromises = this._compilationPromises;
851
877
 
852
878
  //
@@ -856,7 +882,7 @@ class Renderer {
856
882
  if ( targetScene === null ) targetScene = scene;
857
883
 
858
884
  const renderTarget = this._renderTarget;
859
- const renderContext = this._renderContexts.get( targetScene, camera, renderTarget, this._mrt );
885
+ const renderContext = this._renderContexts.get( renderTarget, this._mrt );
860
886
  const activeMipmapLevel = this._activeMipmapLevel;
861
887
 
862
888
  const compilationPromises = [];
@@ -930,7 +956,15 @@ class Renderer {
930
956
 
931
957
  //
932
958
 
933
- this._background.update( sceneRef, renderList, renderContext );
959
+ if ( targetScene !== scene ) {
960
+
961
+ this._background.update( targetScene, renderList, renderContext );
962
+
963
+ } else {
964
+
965
+ this._background.update( sceneRef, renderList, renderContext );
966
+
967
+ }
934
968
 
935
969
  // process render lists
936
970
 
@@ -948,10 +982,9 @@ class Renderer {
948
982
 
949
983
  this._currentRenderContext = previousRenderContext;
950
984
  this._currentRenderObjectFunction = previousRenderObjectFunction;
985
+ this._handleObjectFunction = previousHandleObjectFunction;
951
986
  this._compilationPromises = previousCompilationPromises;
952
987
 
953
- this._handleObjectFunction = this._renderObjectDirect;
954
-
955
988
  // wait for all promises setup by backends awaiting compilation/linking/pipeline creation to complete
956
989
 
957
990
  await Promise.all( compilationPromises );
@@ -1348,9 +1381,12 @@ class Renderer {
1348
1381
  const previousRenderId = nodeFrame.renderId;
1349
1382
  const previousRenderContext = this._currentRenderContext;
1350
1383
  const previousRenderObjectFunction = this._currentRenderObjectFunction;
1384
+ const previousHandleObjectFunction = this._handleObjectFunction;
1351
1385
 
1352
1386
  //
1353
1387
 
1388
+ this._callDepth ++;
1389
+
1354
1390
  const sceneRef = ( scene.isScene === true ) ? scene : _scene;
1355
1391
 
1356
1392
  const outputRenderTarget = this._renderTarget || this._outputRenderTarget;
@@ -1376,10 +1412,11 @@ class Renderer {
1376
1412
 
1377
1413
  //
1378
1414
 
1379
- const renderContext = this._renderContexts.get( scene, camera, renderTarget, this._mrt );
1415
+ const renderContext = this._renderContexts.get( renderTarget, this._mrt, this._callDepth );
1380
1416
 
1381
1417
  this._currentRenderContext = renderContext;
1382
1418
  this._currentRenderObjectFunction = this._renderObjectFunction || this.renderObject;
1419
+ this._handleObjectFunction = this._renderObjectDirect;
1383
1420
 
1384
1421
  //
1385
1422
 
@@ -1397,20 +1434,68 @@ class Renderer {
1397
1434
 
1398
1435
  //
1399
1436
 
1400
- const coordinateSystem = this.coordinateSystem;
1437
+
1401
1438
  const xr = this.xr;
1402
1439
 
1403
- if ( camera.coordinateSystem !== coordinateSystem && xr.isPresenting === false ) {
1440
+ if ( xr.isPresenting === false ) {
1441
+
1442
+ let projectionMatrixNeedsUpdate = false;
1404
1443
 
1405
- camera.coordinateSystem = coordinateSystem;
1406
- camera.updateProjectionMatrix();
1444
+ // reversed depth
1407
1445
 
1408
- if ( camera.isArrayCamera ) {
1446
+ if ( this.reversedDepthBuffer === true && camera.reversedDepth !== true ) {
1409
1447
 
1410
- for ( const subCamera of camera.cameras ) {
1448
+ camera._reversedDepth = true;
1411
1449
 
1412
- subCamera.coordinateSystem = coordinateSystem;
1413
- subCamera.updateProjectionMatrix();
1450
+ if ( camera.isArrayCamera ) {
1451
+
1452
+ for ( const subCamera of camera.cameras ) {
1453
+
1454
+ subCamera._reversedDepth = true;
1455
+
1456
+ }
1457
+
1458
+ }
1459
+
1460
+ projectionMatrixNeedsUpdate = true;
1461
+
1462
+ }
1463
+
1464
+ // WebGPU/WebGL coordinate system
1465
+
1466
+ const coordinateSystem = this.coordinateSystem;
1467
+
1468
+ if ( camera.coordinateSystem !== coordinateSystem ) {
1469
+
1470
+ camera.coordinateSystem = coordinateSystem;
1471
+
1472
+ if ( camera.isArrayCamera ) {
1473
+
1474
+ for ( const subCamera of camera.cameras ) {
1475
+
1476
+ subCamera.coordinateSystem = coordinateSystem;
1477
+
1478
+ }
1479
+
1480
+ }
1481
+
1482
+ projectionMatrixNeedsUpdate = true;
1483
+
1484
+ }
1485
+
1486
+ // camera update
1487
+
1488
+ if ( projectionMatrixNeedsUpdate === true ) {
1489
+
1490
+ camera.updateProjectionMatrix();
1491
+
1492
+ if ( camera.isArrayCamera ) {
1493
+
1494
+ for ( const subCamera of camera.cameras ) {
1495
+
1496
+ subCamera.updateProjectionMatrix();
1497
+
1498
+ }
1414
1499
 
1415
1500
  }
1416
1501
 
@@ -1579,9 +1664,12 @@ class Renderer {
1579
1664
 
1580
1665
  this._currentRenderContext = previousRenderContext;
1581
1666
  this._currentRenderObjectFunction = previousRenderObjectFunction;
1667
+ this._handleObjectFunction = previousHandleObjectFunction;
1582
1668
 
1583
1669
  //
1584
1670
 
1671
+ this._callDepth --;
1672
+
1585
1673
  if ( frameBufferTarget !== null ) {
1586
1674
 
1587
1675
  this.setRenderTarget( outputRenderTarget, activeCubeFace, activeMipmapLevel );
@@ -1977,7 +2065,7 @@ class Renderer {
1977
2065
  */
1978
2066
  getClearDepth() {
1979
2067
 
1980
- return this._clearDepth;
2068
+ return ( this.reversedDepthBuffer === true ) ? 1 - this._clearDepth : this._clearDepth;
1981
2069
 
1982
2070
  }
1983
2071
 
@@ -2055,7 +2143,7 @@ class Renderer {
2055
2143
 
2056
2144
  const renderTargetData = this._textures.get( renderTarget );
2057
2145
 
2058
- renderContext = this._renderContexts.getForClear( renderTarget );
2146
+ renderContext = this._renderContexts.get( renderTarget );
2059
2147
  renderContext.textures = renderTargetData.textures;
2060
2148
  renderContext.depthTexture = renderTargetData.depthTexture;
2061
2149
  renderContext.width = renderTargetData.width;
@@ -2064,7 +2152,13 @@ class Renderer {
2064
2152
  renderContext.depth = renderTarget.depthBuffer;
2065
2153
  renderContext.stencil = renderTarget.stencilBuffer;
2066
2154
  // #30329
2067
- renderContext.clearColorValue = this.backend.getClearColor();
2155
+ const color = this.backend.getClearColor();
2156
+ renderContext.clearColorValue.r = color.r;
2157
+ renderContext.clearColorValue.g = color.g;
2158
+ renderContext.clearColorValue.b = color.b;
2159
+ renderContext.clearColorValue.a = color.a;
2160
+ renderContext.clearDepthValue = this.getClearDepth();
2161
+ renderContext.clearStencilValue = this.getClearStencil();
2068
2162
  renderContext.activeCubeFace = this.getActiveCubeFace();
2069
2163
  renderContext.activeMipmapLevel = this.getActiveMipmapLevel();
2070
2164
 
@@ -2657,6 +2751,37 @@ class Renderer {
2657
2751
 
2658
2752
  }
2659
2753
 
2754
+ /**
2755
+ * Initializes the given render target.
2756
+ *
2757
+ * @param {RenderTarget} renderTarget - The render target to intialize.
2758
+ */
2759
+ initRenderTarget( renderTarget ) {
2760
+
2761
+ if ( this._initialized === false ) {
2762
+
2763
+ throw new Error( 'Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before before using this method.' );
2764
+
2765
+ }
2766
+
2767
+ this._textures.updateRenderTarget( renderTarget );
2768
+
2769
+ const renderTargetData = this._textures.get( renderTarget );
2770
+
2771
+ const renderContext = this._renderContexts.get( renderTarget );
2772
+
2773
+ renderContext.textures = renderTargetData.textures;
2774
+ renderContext.depthTexture = renderTargetData.depthTexture;
2775
+ renderContext.width = renderTargetData.width;
2776
+ renderContext.height = renderTargetData.height;
2777
+ renderContext.renderTarget = renderTarget;
2778
+ renderContext.depth = renderTarget.depthBuffer;
2779
+ renderContext.stencil = renderTarget.stencilBuffer;
2780
+
2781
+ this.backend.initRenderTarget( renderContext );
2782
+
2783
+ }
2784
+
2660
2785
  /**
2661
2786
  * Copies the current bound framebuffer into the given texture.
2662
2787
  *
@@ -3007,12 +3132,13 @@ class Renderer {
3007
3132
  const hasMap = material.map !== null;
3008
3133
  const hasColorNode = material.colorNode && material.colorNode.isNode;
3009
3134
  const hasCastShadowNode = material.castShadowNode && material.castShadowNode.isNode;
3135
+ const hasMaskNode = ( material.maskShadowNode && material.maskShadowNode.isNode ) || ( material.maskNode && material.maskNode.isNode );
3010
3136
 
3011
3137
  let positionNode = null;
3012
3138
  let colorNode = null;
3013
3139
  let depthNode = null;
3014
3140
 
3015
- if ( hasMap || hasColorNode || hasCastShadowNode ) {
3141
+ if ( hasMap || hasColorNode || hasCastShadowNode || hasMaskNode ) {
3016
3142
 
3017
3143
  let shadowRGB;
3018
3144
  let shadowAlpha;
@@ -3022,6 +3148,12 @@ class Renderer {
3022
3148
  shadowRGB = material.castShadowNode.rgb;
3023
3149
  shadowAlpha = material.castShadowNode.a;
3024
3150
 
3151
+ if ( this.shadowMap.transmitted !== true ) {
3152
+
3153
+ warnOnce( 'Renderer: `shadowMap.transmitted` needs to be set to `true` when using `material.castShadowNode`.' );
3154
+
3155
+ }
3156
+
3025
3157
  } else {
3026
3158
 
3027
3159
  shadowRGB = vec3( 0 );
@@ -3043,6 +3175,20 @@ class Renderer {
3043
3175
 
3044
3176
  colorNode = vec4( shadowRGB, shadowAlpha );
3045
3177
 
3178
+ if ( hasMaskNode ) {
3179
+
3180
+ const maskNode = material.maskShadowNode || material.maskNode;
3181
+
3182
+ colorNode = Fn( ( [ color ] ) => {
3183
+
3184
+ maskNode.not().discard();
3185
+
3186
+ return color;
3187
+
3188
+ } )( colorNode );
3189
+
3190
+ }
3191
+
3046
3192
  }
3047
3193
 
3048
3194
  if ( material.depthNode && material.depthNode.isNode ) {
@@ -3111,9 +3257,9 @@ class Renderer {
3111
3257
  materialOverride = true;
3112
3258
 
3113
3259
  // store original nodes
3114
- materialColorNode = scene.overrideMaterial.colorNode;
3115
- materialDepthNode = scene.overrideMaterial.depthNode;
3116
- materialPositionNode = scene.overrideMaterial.positionNode;
3260
+ materialColorNode = ( overrideMaterial.isNodeMaterial ) ? overrideMaterial.colorNode : null;
3261
+ materialDepthNode = ( overrideMaterial.isNodeMaterial ) ? overrideMaterial.depthNode : null;
3262
+ materialPositionNode = ( overrideMaterial.isNodeMaterial ) ? overrideMaterial.positionNode : null;
3117
3263
  materialSide = scene.overrideMaterial.side;
3118
3264
 
3119
3265
  if ( material.positionNode && material.positionNode.isNode ) {
@@ -3132,7 +3278,15 @@ class Renderer {
3132
3278
 
3133
3279
  const { colorNode, depthNode, positionNode } = this._getShadowNodes( material );
3134
3280
 
3135
- overrideMaterial.side = material.shadowSide === null ? material.side : material.shadowSide;
3281
+ if ( this.shadowMap.type === VSMShadowMap ) {
3282
+
3283
+ overrideMaterial.side = ( material.shadowSide !== null ) ? material.shadowSide : material.side;
3284
+
3285
+ } else {
3286
+
3287
+ overrideMaterial.side = ( material.shadowSide !== null ) ? material.shadowSide : _shadowSide[ material.side ];
3288
+
3289
+ }
3136
3290
 
3137
3291
  if ( colorNode !== null ) overrideMaterial.colorNode = colorNode;
3138
3292
  if ( depthNode !== null ) overrideMaterial.depthNode = depthNode;
@@ -3179,6 +3333,19 @@ class Renderer {
3179
3333
 
3180
3334
  }
3181
3335
 
3336
+ /**
3337
+ * Checks if the given compatibility is supported by the selected backend. If the
3338
+ * renderer has not been initialized, this method always returns `false`.
3339
+ *
3340
+ * @param {string} name - The compatibility's name.
3341
+ * @return {boolean} Whether the compatibility is supported or not.
3342
+ */
3343
+ hasCompatibility( name ) {
3344
+
3345
+ return this.backend.hasCompatibility( name );
3346
+
3347
+ }
3348
+
3182
3349
  /**
3183
3350
  * This method represents the default `_handleObjectFunction` implementation which creates
3184
3351
  * a render object from the given data and performs the draw command with the selected backend.
@@ -3199,6 +3366,16 @@ class Renderer {
3199
3366
  renderObject.drawRange = object.geometry.drawRange;
3200
3367
  renderObject.group = group;
3201
3368
 
3369
+ if ( this._currentRenderBundle !== null ) {
3370
+
3371
+ const renderBundleData = this.backend.get( this._currentRenderBundle );
3372
+
3373
+ renderBundleData.renderObjects.push( renderObject );
3374
+
3375
+ renderObject.bundle = this._currentRenderBundle.bundleGroup;
3376
+
3377
+ }
3378
+
3202
3379
  //
3203
3380
 
3204
3381
  const needsRefresh = this._nodes.needsRefresh( renderObject );
@@ -3218,16 +3395,6 @@ class Renderer {
3218
3395
 
3219
3396
  //
3220
3397
 
3221
- if ( this._currentRenderBundle !== null ) {
3222
-
3223
- const renderBundleData = this.backend.get( this._currentRenderBundle );
3224
-
3225
- renderBundleData.renderObjects.push( renderObject );
3226
-
3227
- renderObject.bundle = this._currentRenderBundle.bundleGroup;
3228
-
3229
- }
3230
-
3231
3398
  this.backend.draw( renderObject, this.info );
3232
3399
 
3233
3400
  if ( needsRefresh ) this._nodes.updateAfter( renderObject );
@@ -35,7 +35,7 @@ class Sampler extends Binding {
35
35
  this._onTextureDispose = () => {
36
36
 
37
37
  this.generation = null;
38
- this.version = 0;
38
+ this.version = - 1;
39
39
 
40
40
  };
41
41
 
@@ -47,7 +47,7 @@ class Sampler extends Binding {
47
47
  *
48
48
  * @type {number}
49
49
  */
50
- this.version = texture ? texture.version : 0;
50
+ this.version = texture ? texture.version : - 1;
51
51
 
52
52
  /**
53
53
  * The binding's generation which is an additional version
@@ -95,7 +95,7 @@ class Sampler extends Binding {
95
95
  this._texture = value;
96
96
 
97
97
  this.generation = null;
98
- this.version = 0;
98
+ this.version = - 1;
99
99
 
100
100
  if ( this._texture ) {
101
101
 
@@ -150,7 +150,7 @@ class Sampler extends Binding {
150
150
  clonedSampler._onTextureDispose = () => {
151
151
 
152
152
  clonedSampler.generation = null;
153
- clonedSampler.version = 0;
153
+ clonedSampler.version = - 1;
154
154
 
155
155
  };
156
156
 
@@ -21,9 +21,10 @@ class StorageBuffer extends Buffer {
21
21
  /**
22
22
  * This flag can be used for type testing.
23
23
  *
24
+ * @private
24
25
  * @type {BufferAttribute}
25
26
  */
26
- this.attribute = attribute;
27
+ this._attribute = attribute;
27
28
 
28
29
  /**
29
30
  * This flag can be used for type testing.
@@ -36,6 +37,17 @@ class StorageBuffer extends Buffer {
36
37
 
37
38
  }
38
39
 
40
+ /**
41
+ * The storage buffer attribute.
42
+ *
43
+ * @type {BufferAttribute}
44
+ */
45
+ get attribute() {
46
+
47
+ return this._attribute;
48
+
49
+ }
50
+
39
51
  }
40
52
 
41
53
  export default StorageBuffer;
@@ -318,6 +318,7 @@ class Textures extends DataMap {
318
318
 
319
319
  textureData.initialized = true;
320
320
  textureData.generation = texture.version;
321
+ textureData.bindGroups = new Set();
321
322
 
322
323
  //
323
324
 
@@ -531,6 +532,21 @@ class Textures extends DataMap {
531
532
  const isDefaultTexture = textureData.isDefaultTexture;
532
533
  this.backend.destroyTexture( texture, isDefaultTexture );
533
534
 
535
+ // delete cached bind groups so they don't point to destroyed textures
536
+
537
+ if ( textureData.bindGroups ) {
538
+
539
+ for ( const bindGroup of textureData.bindGroups ) {
540
+
541
+ const bindingsData = this.backend.get( bindGroup );
542
+
543
+ bindingsData.groups = undefined;
544
+ bindingsData.versions = undefined;
545
+
546
+ }
547
+
548
+ }
549
+
534
550
  this.delete( texture );
535
551
 
536
552
  this.info.memory.textures --;
@@ -54,7 +54,7 @@ class TimestampQueryPool {
54
54
  this.isDisposed = false;
55
55
 
56
56
  /**
57
- * TODO
57
+ * The total frame duration until the next update.
58
58
  *
59
59
  * @type {number}
60
60
  * @default 0
@@ -69,9 +69,11 @@ class TimestampQueryPool {
69
69
  this.frames = [];
70
70
 
71
71
  /**
72
- * TODO
72
+ * This property is used to avoid multiple concurrent resolve operations.
73
+ * The WebGL backend uses it as a boolean flag. In context of WebGPU, it holds
74
+ * the promise of the current resolve operation.
73
75
  *
74
- * @type {boolean}
76
+ * @type {boolean|Promise<number>}
75
77
  * @default false
76
78
  */
77
79
  this.pendingResolve = false;
@@ -61,6 +61,14 @@ class Uniform {
61
61
  */
62
62
  this.offset = 0;
63
63
 
64
+ /**
65
+ * This property is set by {@link UniformsGroup} and marks
66
+ * the index position in the uniform array.
67
+ *
68
+ * @type {number}
69
+ */
70
+ this.index = - 1;
71
+
64
72
  }
65
73
 
66
74
  /**