@gnsx/three 0.185.16 → 0.186.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 (417) hide show
  1. package/build/three.cjs +10 -82600
  2. package/build/three.core.js +1303 -728
  3. package/build/three.module.js +439 -338
  4. package/build/three.tsl.js +74 -44
  5. package/build/three.webgpu.js +6036 -2184
  6. package/build/three.webgpu.nodes.js +6020 -2184
  7. package/examples/jsm/Addons.js +6 -6
  8. package/examples/jsm/controls/ArcballControls.js +1 -1
  9. package/examples/jsm/controls/FirstPersonControls.js +44 -20
  10. package/examples/jsm/controls/OrbitControls.js +9 -0
  11. package/examples/jsm/controls/TrackballControls.js +109 -4
  12. package/examples/jsm/csm/CSMShadowNode.js +13 -0
  13. package/examples/jsm/exporters/GLTFExporter.js +23 -7
  14. package/examples/jsm/exporters/USDZExporter.js +2 -2
  15. package/examples/jsm/generators/CityGenerator.js +377 -45
  16. package/examples/jsm/generators/ForestGenerator.js +12 -12
  17. package/examples/jsm/generators/TerrainGenerator.js +49 -37
  18. package/examples/jsm/generators/TreeGenerator.js +70 -76
  19. package/examples/jsm/generators/city/BenchGenerator.js +127 -0
  20. package/examples/jsm/generators/city/CarGenerator.js +479 -0
  21. package/examples/jsm/generators/city/CityGeneratorUtils.js +31 -0
  22. package/examples/jsm/generators/city/HydrantGenerator.js +106 -0
  23. package/examples/jsm/generators/city/InstancedMeshGenerator.js +86 -0
  24. package/examples/jsm/generators/city/PersonGenerator.js +447 -0
  25. package/examples/jsm/generators/city/SidewalkGenerator.js +33 -38
  26. package/examples/jsm/generators/city/SkyscraperGenerator.js +448 -48
  27. package/examples/jsm/generators/city/StreetTreeGenerator.js +231 -0
  28. package/examples/jsm/generators/city/StreetlightGenerator.js +100 -0
  29. package/examples/jsm/generators/city/TrafficlightGenerator.js +106 -0
  30. package/examples/jsm/generators/city/TrashcanGenerator.js +100 -0
  31. package/examples/jsm/geometries/BoxLineGeometry.js +1 -1
  32. package/examples/jsm/geometries/ParametricGeometry.js +1 -1
  33. package/examples/jsm/geometries/RoundedBoxGeometry.js +1 -1
  34. package/examples/jsm/gpgpu/CountingSort.js +271 -0
  35. package/examples/jsm/helpers/LightProbeGridHelper.js +60 -239
  36. package/examples/jsm/helpers/LightProbeGridHelperWebGL.js +221 -0
  37. package/examples/jsm/inspector/Extension.js +94 -0
  38. package/examples/jsm/inspector/Inspector.js +145 -41
  39. package/examples/jsm/inspector/RendererInspector.js +100 -52
  40. package/examples/jsm/inspector/extensions/color-grading/ColorGrading.js +2609 -0
  41. package/examples/jsm/inspector/extensions/color-grading/ColorWheel.js +352 -0
  42. package/examples/jsm/inspector/extensions/color-grading/CurveEditor.js +599 -0
  43. package/examples/jsm/inspector/extensions/color-grading/LUT3DStyle.js +1201 -0
  44. package/examples/jsm/inspector/extensions/color-grading/LUTMath.js +788 -0
  45. package/examples/jsm/inspector/extensions/color-grading/modules/BrightnessModule.js +72 -0
  46. package/examples/jsm/inspector/extensions/color-grading/modules/ColorWheelModule.js +112 -0
  47. package/examples/jsm/inspector/extensions/color-grading/modules/ContrastModule.js +82 -0
  48. package/examples/jsm/inspector/extensions/color-grading/modules/CurvesModule.js +109 -0
  49. package/examples/jsm/inspector/extensions/color-grading/modules/ExposureHueModule.js +110 -0
  50. package/examples/jsm/inspector/extensions/color-grading/modules/ExposureModule.js +73 -0
  51. package/examples/jsm/inspector/extensions/color-grading/modules/HueModule.js +78 -0
  52. package/examples/jsm/inspector/extensions/color-grading/modules/ImportedCubeModule.js +89 -0
  53. package/examples/jsm/inspector/extensions/color-grading/modules/Module.js +285 -0
  54. package/examples/jsm/inspector/extensions/color-grading/modules/OutputModule.js +101 -0
  55. package/examples/jsm/inspector/extensions/color-grading/modules/RendererModule.js +225 -0
  56. package/examples/jsm/inspector/extensions/color-grading/modules/SatVibranceModule.js +102 -0
  57. package/examples/jsm/inspector/extensions/color-grading/modules/SaturationModule.js +76 -0
  58. package/examples/jsm/inspector/extensions/color-grading/modules/VibranceModule.js +76 -0
  59. package/examples/jsm/inspector/extensions/color-grading/modules/WhiteBalanceModule.js +86 -0
  60. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +26 -31
  61. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -0
  62. package/examples/jsm/inspector/tabs/Memory.js +0 -2
  63. package/examples/jsm/inspector/tabs/Settings.js +4 -0
  64. package/examples/jsm/inspector/tabs/Timeline.js +223 -171
  65. package/examples/jsm/inspector/tabs/Viewer.js +515 -21
  66. package/examples/jsm/inspector/ui/List.js +15 -9
  67. package/examples/jsm/inspector/ui/Profiler.js +170 -14
  68. package/examples/jsm/inspector/ui/Style.js +269 -23
  69. package/examples/jsm/inspector/ui/Tab.js +2 -0
  70. package/examples/jsm/inspector/ui/Values.js +14 -2
  71. package/examples/jsm/interactive/HTMLMesh.js +19 -3
  72. package/examples/jsm/lighting/LightProbeGrid.js +484 -889
  73. package/examples/jsm/lighting/LightProbeGridUtils.js +107 -0
  74. package/examples/jsm/lighting/LightProbeGridWebGL.js +841 -0
  75. package/examples/jsm/lighting/vxgi/VXGIConeTracer.js +194 -0
  76. package/examples/jsm/lighting/vxgi/VXGINode.js +660 -0
  77. package/examples/jsm/lighting/vxgi/VXGISceneCollector.js +478 -0
  78. package/examples/jsm/lighting/vxgi/VXGIVolume.js +1430 -0
  79. package/examples/jsm/lights/SunLight.js +95 -0
  80. package/examples/jsm/lights/SunLightNode.js +56 -0
  81. package/examples/jsm/lights/SunLightShadow.js +319 -0
  82. package/examples/jsm/lights/SunShadowNode.js +312 -0
  83. package/examples/jsm/loaders/3DMLoader.js +150 -49
  84. package/examples/jsm/loaders/3MFLoader.js +202 -1
  85. package/examples/jsm/loaders/FBXLoader.js +81 -5
  86. package/examples/jsm/loaders/GLTFGaussianSplatLoaderExtension.js +330 -0
  87. package/examples/jsm/loaders/GLTFLoader.js +79 -14
  88. package/examples/jsm/loaders/GaussianSplatPLYLoader.js +386 -0
  89. package/examples/jsm/loaders/KSPLATLoader.js +463 -0
  90. package/examples/jsm/loaders/MaterialXLoader.js +111 -1010
  91. package/examples/jsm/loaders/PCDLoader.js +1 -1
  92. package/examples/jsm/loaders/SPLATLoader.js +139 -0
  93. package/examples/jsm/loaders/SPZLoader.js +561 -0
  94. package/examples/jsm/loaders/materialx/MaterialXArchive.js +108 -0
  95. package/examples/jsm/loaders/materialx/MaterialXDocument.js +878 -0
  96. package/examples/jsm/loaders/materialx/MaterialXHextile.js +183 -0
  97. package/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.js +376 -0
  98. package/examples/jsm/loaders/materialx/MaterialXLog.js +75 -0
  99. package/examples/jsm/loaders/materialx/MaterialXNodeInterfaceRegistry.js +4 -0
  100. package/examples/jsm/loaders/materialx/MaterialXNodeLibrary.js +1021 -0
  101. package/examples/jsm/loaders/materialx/MaterialXSurfaceMappings.js +661 -0
  102. package/examples/jsm/loaders/materialx/MaterialXUtils.js +57 -0
  103. package/examples/jsm/loaders/materialx/compile/MaterialXCompileRegistry.js +997 -0
  104. package/examples/jsm/loaders/materialx/parse/MaterialXParser.js +28 -0
  105. package/examples/jsm/loaders/usd/USDAParser.js +15 -2
  106. package/examples/jsm/loaders/usd/USDCParser.js +1 -4
  107. package/examples/jsm/loaders/usd/USDComposer.js +80 -42
  108. package/examples/jsm/materials/WoodNodeMaterial.js +6 -108
  109. package/examples/jsm/misc/RollerCoaster.js +2 -2
  110. package/examples/jsm/misc/SculptGL.LICENSE.txt +21 -0
  111. package/examples/jsm/misc/Sculptor.js +1679 -0
  112. package/examples/jsm/misc/SculptorMesh.js +1504 -0
  113. package/examples/jsm/misc/SculptorTools.js +1180 -0
  114. package/examples/jsm/misc/SculptorUtils.js +345 -0
  115. package/examples/jsm/misc/TubePainter.js +28 -16
  116. package/examples/jsm/misc/VolumeSlice.js +24 -24
  117. package/examples/jsm/modifiers/SimplifyModifier.js +63 -556
  118. package/examples/jsm/objects/GaussianSplat.js +1039 -0
  119. package/examples/jsm/objects/Sky.js +66 -45
  120. package/examples/jsm/objects/SkyMesh.js +70 -51
  121. package/examples/jsm/physics/JoltPhysics.js +1 -1
  122. package/examples/jsm/postprocessing/AfterimagePass.js +4 -2
  123. package/examples/jsm/postprocessing/BloomPass.js +2 -2
  124. package/examples/jsm/postprocessing/GTAOPass.js +1 -1
  125. package/examples/jsm/postprocessing/OutlinePass.js +5 -5
  126. package/examples/jsm/postprocessing/SAOPass.js +1 -1
  127. package/examples/jsm/postprocessing/SSAOPass.js +1 -1
  128. package/examples/jsm/postprocessing/SSRPass.js +4 -2
  129. package/examples/jsm/postprocessing/SavePass.js +1 -1
  130. package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
  131. package/examples/jsm/postprocessing/UnrealBloomPass.js +30 -13
  132. package/examples/jsm/renderers/CSS2DRenderer.js +29 -5
  133. package/examples/jsm/shaders/DepthLimitedBlurShader.js +4 -1
  134. package/examples/jsm/shaders/ExposureShader.js +1 -1
  135. package/examples/jsm/shaders/FilmShader.js +2 -1
  136. package/examples/jsm/transpiler/AST.js +21 -2
  137. package/examples/jsm/transpiler/GLSLDecoder.js +498 -8
  138. package/examples/jsm/transpiler/TSLEncoder.js +82 -10
  139. package/examples/jsm/transpiler/WGSLEncoder.js +33 -4
  140. package/examples/jsm/tsl/WebGLNodesHandler.js +29 -39
  141. package/examples/jsm/tsl/display/AfterImageNode.js +2 -0
  142. package/examples/jsm/tsl/display/AnaglyphPassNode.js +3 -2
  143. package/examples/jsm/tsl/display/BilateralBlurNode.js +5 -2
  144. package/examples/jsm/tsl/display/BloomNode.js +55 -30
  145. package/examples/jsm/tsl/display/DenoiseNode.js +21 -1
  146. package/examples/jsm/tsl/display/DepthOfFieldNode.js +24 -6
  147. package/examples/jsm/tsl/display/DotScreenNode.js +11 -11
  148. package/examples/jsm/tsl/display/FSR1Node.js +8 -4
  149. package/examples/jsm/tsl/display/GTAONode.js +199 -86
  150. package/examples/jsm/tsl/display/GaussianBlurNode.js +65 -52
  151. package/examples/jsm/tsl/display/GodraysNode.js +5 -2
  152. package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +2 -2
  153. package/examples/jsm/tsl/display/LensflareNode.js +5 -2
  154. package/examples/jsm/tsl/display/OITPassNode.js +352 -0
  155. package/examples/jsm/tsl/display/OutlineNode.js +2 -0
  156. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +3 -2
  157. package/examples/jsm/tsl/display/RGBShiftNode.js +9 -9
  158. package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +7 -4
  159. package/examples/jsm/tsl/display/RetroPassNode.js +1 -1
  160. package/examples/jsm/tsl/display/SMAANode.js +22 -61
  161. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -4
  162. package/examples/jsm/tsl/display/SSAONode.js +436 -0
  163. package/examples/jsm/tsl/display/SSGINode.js +5 -2
  164. package/examples/jsm/tsl/display/SSRNode.js +7 -2
  165. package/examples/jsm/tsl/display/SSSNode.js +5 -2
  166. package/examples/jsm/tsl/display/SharpenNode.js +5 -4
  167. package/examples/jsm/tsl/display/StereoCompositePassNode.js +1 -3
  168. package/examples/jsm/tsl/display/StereoPassNode.js +1 -3
  169. package/examples/jsm/tsl/display/TAAUNode.js +22 -125
  170. package/examples/jsm/tsl/display/TRAANode.js +16 -142
  171. package/examples/jsm/tsl/display/TemporalReprojectNode.js +21 -15
  172. package/examples/jsm/tsl/display/depthAwareBlur.js +63 -0
  173. package/examples/jsm/tsl/display/hashBlur.js +3 -2
  174. package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +38 -27
  175. package/examples/jsm/tsl/lighting/LightProbeGridNode.js +136 -0
  176. package/examples/jsm/tsl/math/voronoiNoise.js +112 -0
  177. package/examples/jsm/tsl/shadows/TileShadowNode.js +4 -6
  178. package/examples/jsm/tsl/utils/Raymarching.js +5 -5
  179. package/examples/jsm/tsl/utils/SoftParticles.js +60 -0
  180. package/examples/jsm/tsl/utils/TAAUtils.js +195 -0
  181. package/examples/jsm/utils/BufferGeometryUtils.js +14 -14
  182. package/examples/jsm/utils/GaussianSplatUtils.js +229 -0
  183. package/examples/jsm/utils/WebGLTextureUtils.js +1 -1
  184. package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
  185. package/examples/jsm/webxr/WebGLXRFallback.js +2 -16
  186. package/examples/jsm/webxr/XRControllerModelFactory.js +16 -4
  187. package/package.json +9 -16
  188. package/src/Three.Core.js +2 -1
  189. package/src/Three.TSL.js +73 -43
  190. package/src/Three.WebGPU.Nodes.js +1 -0
  191. package/src/Three.WebGPU.js +1 -0
  192. package/src/animation/AnimationClip.js +15 -2
  193. package/src/animation/AnimationObjectGroup.js +18 -6
  194. package/src/animation/AnimationUtils.js +26 -0
  195. package/src/animation/KeyframeTrack.js +37 -0
  196. package/src/constants.js +23 -1
  197. package/src/core/BufferAttribute.js +3 -2
  198. package/src/core/BufferGeometry.js +1 -1
  199. package/src/core/InterleavedBuffer.js +5 -1
  200. package/src/core/Object3D.js +40 -12
  201. package/src/core/Raycaster.js +4 -0
  202. package/src/core/RenderTarget.js +99 -9
  203. package/src/core/RenderTarget3D.js +12 -8
  204. package/src/extras/Controls.js +0 -8
  205. package/src/extras/PMREMGenerator.js +99 -205
  206. package/src/geometries/TorusGeometry.js +1 -1
  207. package/src/helpers/ArrowHelper.js +2 -0
  208. package/src/helpers/AxesHelper.js +2 -0
  209. package/src/helpers/Box3Helper.js +2 -0
  210. package/src/helpers/BoxHelper.js +2 -0
  211. package/src/helpers/CameraHelper.js +2 -0
  212. package/src/helpers/DirectionalLightHelper.js +2 -0
  213. package/src/helpers/GridHelper.js +2 -0
  214. package/src/helpers/HemisphereLightHelper.js +2 -0
  215. package/src/helpers/PlaneHelper.js +2 -0
  216. package/src/helpers/PointLightHelper.js +2 -0
  217. package/src/helpers/PolarGridHelper.js +2 -0
  218. package/src/helpers/SkeletonHelper.js +2 -0
  219. package/src/helpers/SpotLightHelper.js +2 -0
  220. package/src/lights/Light.js +0 -10
  221. package/src/lights/LightShadow.js +43 -12
  222. package/src/lights/SpotLightShadow.js +18 -0
  223. package/src/loaders/BufferGeometryLoader.js +5 -0
  224. package/src/loaders/ImageBitmapLoader.js +3 -1
  225. package/src/loaders/ObjectLoader.js +8 -5
  226. package/src/materials/Material.js +80 -57
  227. package/src/materials/MeshPhysicalMaterial.js +32 -0
  228. package/src/materials/nodes/Line2NodeMaterial.js +17 -8
  229. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +42 -5
  230. package/src/materials/nodes/NodeMaterial.js +19 -13
  231. package/src/materials/nodes/PointsNodeMaterial.js +2 -1
  232. package/src/materials/nodes/manager/NodeMaterialObserver.js +282 -55
  233. package/src/math/Frustum.js +9 -0
  234. package/src/math/FrustumArray.js +1 -1
  235. package/src/math/MathUtils.js +5 -3
  236. package/src/math/Matrix4.js +2 -9
  237. package/src/math/Plane.js +30 -1
  238. package/src/math/Quaternion.js +0 -10
  239. package/src/math/Ray.js +95 -45
  240. package/src/math/Triangle.js +0 -2
  241. package/src/math/Vector3.js +2 -2
  242. package/src/math/Vector4.js +0 -4
  243. package/src/math/interpolants/BezierInterpolant.js +36 -23
  244. package/src/nodes/Nodes.js +2 -0
  245. package/src/nodes/TSL.js +11 -3
  246. package/src/nodes/accessors/Batch.js +85 -13
  247. package/src/nodes/accessors/BufferAttributeNode.js +1 -1
  248. package/src/nodes/accessors/BuiltinNode.js +1 -1
  249. package/src/nodes/accessors/Instance.js +19 -18
  250. package/src/nodes/accessors/MaterialNode.js +9 -0
  251. package/src/nodes/accessors/ModelNode.js +85 -9
  252. package/src/nodes/accessors/ReferenceBaseNode.js +1 -70
  253. package/src/nodes/accessors/ReferenceElementNode.js +72 -0
  254. package/src/nodes/accessors/ReferenceNode.js +1 -70
  255. package/src/nodes/accessors/Skinning.js +124 -12
  256. package/src/nodes/accessors/StorageTextureNode.js +7 -3
  257. package/src/nodes/accessors/Texture3DNode.js +1 -1
  258. package/src/nodes/accessors/TextureNode.js +51 -21
  259. package/src/nodes/accessors/TextureSizeNode.js +4 -2
  260. package/src/nodes/accessors/UniformArrayNode.js +30 -5
  261. package/src/nodes/code/CodeNode.js +1 -1
  262. package/src/nodes/code/FunctionNode.js +12 -2
  263. package/src/nodes/core/ArrayNode.js +2 -2
  264. package/src/nodes/core/ContextNode.js +57 -4
  265. package/src/nodes/core/IndexNode.js +69 -4
  266. package/src/nodes/core/InspectorNode.js +2 -2
  267. package/src/nodes/core/MRTNode.js +44 -2
  268. package/src/nodes/core/Node.js +6 -3
  269. package/src/nodes/core/NodeBuilder.js +65 -50
  270. package/src/nodes/core/NodeFrame.js +11 -3
  271. package/src/nodes/core/NodeUtils.js +88 -0
  272. package/src/nodes/core/PropertyNode.js +8 -0
  273. package/src/nodes/core/StackNode.js +0 -1
  274. package/src/nodes/core/StructNode.js +4 -3
  275. package/src/nodes/core/UniformGroupNode.js +3 -2
  276. package/src/nodes/core/UniformNode.js +26 -12
  277. package/src/nodes/core/VarNode.js +0 -1
  278. package/src/nodes/display/BumpMapNode.js +2 -2
  279. package/src/nodes/display/ColorAdjustment.js +1 -1
  280. package/src/nodes/display/PassNode.js +76 -15
  281. package/src/nodes/display/ScreenNode.js +22 -65
  282. package/src/nodes/fog/Fog.js +4 -4
  283. package/src/nodes/functions/BSDF/BRDF_GGX.js +6 -6
  284. package/src/nodes/functions/BSDF/BRDF_Sheen.js +1 -1
  285. package/src/nodes/functions/BSDF/DFGLUT.js +2 -1
  286. package/src/nodes/functions/BSDF/LTC.js +1 -1
  287. package/src/nodes/functions/PhongLightingModel.js +1 -1
  288. package/src/nodes/functions/PhysicalLightingModel.js +83 -25
  289. package/src/nodes/functions/ToonLightingModel.js +2 -2
  290. package/src/nodes/functions/material/getParallaxCorrectNormal.js +3 -3
  291. package/src/nodes/gpgpu/AtomicFunctionNode.js +64 -13
  292. package/src/nodes/gpgpu/BarrierNode.js +13 -4
  293. package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
  294. package/src/nodes/gpgpu/ComputeNode.js +20 -17
  295. package/src/nodes/gpgpu/SubgroupFunctionNode.js +165 -37
  296. package/src/nodes/gpgpu/WorkgroupInfoNode.js +44 -6
  297. package/src/nodes/lighting/EnvironmentNode.js +40 -4
  298. package/src/nodes/lighting/LightsNode.js +20 -4
  299. package/src/nodes/lighting/ShadowBaseNode.js +158 -1
  300. package/src/nodes/lighting/ShadowFilterNode.js +2 -106
  301. package/src/nodes/lighting/ShadowNode.js +22 -91
  302. package/src/nodes/materialx/{lib/mx_hsv.js → MaterialXColor.js} +3 -6
  303. package/src/nodes/materialx/{lib/mx_transform_color.js → MaterialXColorTransform.js} +3 -6
  304. package/src/nodes/materialx/MaterialXCore.js +37 -0
  305. package/src/nodes/materialx/MaterialXNodes.js +64 -72
  306. package/src/nodes/materialx/{lib/mx_noise.js → MaterialXNoise.js} +426 -197
  307. package/src/nodes/math/BitcountNode.js +24 -4
  308. package/src/nodes/math/MathNode.js +4 -4
  309. package/src/nodes/math/MathUtils.js +15 -4
  310. package/src/nodes/math/OperatorNode.js +2 -2
  311. package/src/nodes/math/PackFloatNode.js +29 -1
  312. package/src/nodes/math/Packed4x8IntegerNode.js +433 -0
  313. package/src/nodes/math/UnpackFloatNode.js +30 -2
  314. package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
  315. package/src/nodes/pmrem/PMREMNode.js +1 -1
  316. package/src/nodes/pmrem/PMREMUtils.js +31 -74
  317. package/src/nodes/shapes/Shapes.js +1 -1
  318. package/src/nodes/tsl/TSLCore.js +1 -31
  319. package/src/nodes/utils/EventNode.js +75 -0
  320. package/src/nodes/utils/LoopNode.js +54 -13
  321. package/src/nodes/utils/PostProcessingUtils.js +23 -2
  322. package/src/nodes/utils/RTTNode.js +97 -32
  323. package/src/nodes/utils/ReflectorNode.js +8 -4
  324. package/src/nodes/utils/RotateNode.js +85 -8
  325. package/src/nodes/utils/SpriteUtils.js +58 -23
  326. package/src/objects/BatchedMesh.js +6 -0
  327. package/src/objects/InstancedMesh.js +1 -1
  328. package/src/objects/LOD.js +1 -1
  329. package/src/objects/Line.js +12 -0
  330. package/src/objects/Mesh.js +12 -0
  331. package/src/objects/Points.js +12 -0
  332. package/src/objects/Sprite.js +12 -0
  333. package/src/renderers/WebGLRenderer.js +93 -27
  334. package/src/renderers/common/Animation.js +12 -2
  335. package/src/renderers/common/Backend.js +38 -10
  336. package/src/renderers/common/BindGroup.js +0 -1
  337. package/src/renderers/common/Bindings.js +50 -4
  338. package/src/renderers/common/BundleGroup.js +4 -0
  339. package/src/renderers/common/ClippingContext.js +11 -1
  340. package/src/renderers/common/Color4.js +9 -0
  341. package/src/renderers/common/Constants.js +0 -5
  342. package/src/renderers/common/DirectRenderPipeline.js +233 -0
  343. package/src/renderers/common/Geometries.js +24 -3
  344. package/src/renderers/common/Info.js +3 -3
  345. package/src/renderers/common/InspectorBase.js +37 -8
  346. package/src/renderers/common/Lighting.js +11 -4
  347. package/src/renderers/common/Pipelines.js +6 -4
  348. package/src/renderers/common/QuadMesh.js +16 -2
  349. package/src/renderers/common/RenderContext.js +8 -0
  350. package/src/renderers/common/RenderList.js +53 -19
  351. package/src/renderers/common/RenderLists.js +58 -11
  352. package/src/renderers/common/RenderObject.js +14 -0
  353. package/src/renderers/common/RenderObjects.js +14 -9
  354. package/src/renderers/common/RenderPipeline.js +52 -44
  355. package/src/renderers/common/Renderer.js +226 -55
  356. package/src/renderers/common/Storage3DTexture.js +16 -0
  357. package/src/renderers/common/Textures.js +3 -3
  358. package/src/renderers/common/XRManager.js +79 -72
  359. package/src/renderers/common/extras/PMREMGenerator.js +76 -144
  360. package/src/renderers/common/nodes/NodeManager.js +144 -6
  361. package/src/renderers/common/nodes/NodeStorageBuffer.js +3 -1
  362. package/src/renderers/common/nodes/NodeUniformBuffer.js +3 -1
  363. package/src/renderers/shaders/DFGLUTData.js +2 -1
  364. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +4 -2
  365. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +48 -0
  366. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +53 -4
  367. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +20 -2
  368. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +20 -0
  369. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
  370. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +61 -57
  371. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +82 -0
  372. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +9 -0
  373. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +8 -1
  374. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +15 -0
  375. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
  376. package/src/renderers/shaders/ShaderLib.js +1 -0
  377. package/src/renderers/shaders/UniformsLib.js +16 -0
  378. package/src/renderers/webgl/WebGLAnimation.js +2 -2
  379. package/src/renderers/webgl/WebGLCapabilities.js +2 -2
  380. package/src/renderers/webgl/WebGLLights.js +74 -4
  381. package/src/renderers/webgl/WebGLMaterials.js +6 -0
  382. package/src/renderers/webgl/WebGLOutput.js +36 -24
  383. package/src/renderers/webgl/WebGLProgram.js +3 -0
  384. package/src/renderers/webgl/WebGLPrograms.js +8 -0
  385. package/src/renderers/webgl/WebGLRenderLists.js +6 -10
  386. package/src/renderers/webgl/WebGLShadowMap.js +47 -44
  387. package/src/renderers/webgl/WebGLTextures.js +7 -7
  388. package/src/renderers/webgl-fallback/WebGLBackend.js +153 -45
  389. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +83 -29
  390. package/src/renderers/webgl-fallback/utils/WebGLState.js +163 -17
  391. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +32 -5
  392. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +11 -4
  393. package/src/renderers/webgpu/WebGPUBackend.js +513 -145
  394. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -20
  395. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -1
  396. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +3 -12
  397. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +24 -14
  398. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +80 -14
  399. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -7
  400. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +9 -3
  401. package/src/renderers/webgpu/utils/WebGPUUtils.js +16 -4
  402. package/src/renderers/webxr/WebXRManager.js +25 -2
  403. package/src/scenes/Scene.js +3 -3
  404. package/src/textures/CompressedArrayTexture.js +16 -0
  405. package/src/textures/Data3DTexture.js +16 -0
  406. package/src/textures/DataArrayTexture.js +16 -0
  407. package/src/textures/DepthTexture.js +3 -3
  408. package/src/textures/Texture.js +3 -3
  409. package/src/textures/{Source.js → TextureSource.js} +39 -8
  410. package/build/three.core.min.js +0 -6
  411. package/build/three.module.min.js +0 -6
  412. package/build/three.tsl.min.js +0 -6
  413. package/build/three.webgpu.min.js +0 -6
  414. package/build/three.webgpu.nodes.min.js +0 -6
  415. package/examples/jsm/libs/ecsy.module.js +0 -1792
  416. package/examples/jsm/loaders/LottieLoader.js +0 -130
  417. package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +0 -52
@@ -23,6 +23,7 @@ function UniformsCache() {
23
23
 
24
24
  switch ( light.type ) {
25
25
 
26
+ case 'SunLight':
26
27
  case 'DirectionalLight':
27
28
  uniforms = {
28
29
  direction: new Vector3(),
@@ -98,6 +99,7 @@ function ShadowUniformsCache() {
98
99
 
99
100
  switch ( light.type ) {
100
101
 
102
+ case 'SunLight':
101
103
  case 'DirectionalLight':
102
104
  uniforms = {
103
105
  shadowIntensity: 1,
@@ -165,12 +167,14 @@ function WebGLLights( extensions ) {
165
167
  version: 0,
166
168
 
167
169
  hash: {
170
+ sunLength: - 1,
168
171
  directionalLength: - 1,
169
172
  pointLength: - 1,
170
173
  spotLength: - 1,
171
174
  rectAreaLength: - 1,
172
175
  hemiLength: - 1,
173
176
 
177
+ numSunShadows: - 1,
174
178
  numDirectionalShadows: - 1,
175
179
  numPointShadows: - 1,
176
180
  numSpotShadows: - 1,
@@ -181,6 +185,11 @@ function WebGLLights( extensions ) {
181
185
 
182
186
  ambient: [ 0, 0, 0 ],
183
187
  probe: [],
188
+ sun: [],
189
+ sunShadow: [],
190
+ sunShadowMap: [],
191
+ sunShadowMatrix: [],
192
+ sunShadowCascade: [],
184
193
  directional: [],
185
194
  directionalShadow: [],
186
195
  directionalShadowMap: [],
@@ -215,6 +224,9 @@ function WebGLLights( extensions ) {
215
224
 
216
225
  for ( let i = 0; i < 9; i ++ ) state.probe[ i ].set( 0, 0, 0 );
217
226
 
227
+ let sunLength = 0;
228
+ let numSunShadows = 0;
229
+ let numSunShadowCascades = 0;
218
230
  let directionalLength = 0;
219
231
  let pointLength = 0;
220
232
  let spotLength = 0;
@@ -274,6 +286,45 @@ function WebGLLights( extensions ) {
274
286
 
275
287
  numLightProbes ++;
276
288
 
289
+ } else if ( light.isSunLight ) {
290
+
291
+ const uniforms = cache.get( light );
292
+
293
+ uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
294
+
295
+ if ( light.castShadow ) {
296
+
297
+ const shadow = light.shadow;
298
+
299
+ const shadowUniforms = shadowCache.get( light );
300
+
301
+ shadowUniforms.shadowIntensity = shadow.intensity;
302
+ shadowUniforms.shadowBias = shadow.bias;
303
+ shadowUniforms.shadowNormalBias = shadow.normalBias;
304
+ shadowUniforms.shadowRadius = shadow.radius;
305
+ shadowUniforms.shadowMapSize.copy( shadow.mapSize ).multiply( shadow.getFrameExtents() );
306
+
307
+ state.sunShadow[ numSunShadows ] = shadowUniforms;
308
+ state.sunShadowMap[ numSunShadows ] = shadowMap;
309
+
310
+ const cascadeCount = shadow.getViewportCount();
311
+
312
+ for ( let j = 0; j < cascadeCount; j ++ ) {
313
+
314
+ state.sunShadowMatrix[ numSunShadowCascades + j ] = shadow.getMatrix( j );
315
+ state.sunShadowCascade[ numSunShadowCascades + j ] = shadow._cascadeData[ j ];
316
+
317
+ }
318
+
319
+ numSunShadowCascades += cascadeCount;
320
+ numSunShadows ++;
321
+
322
+ }
323
+
324
+ state.sun[ sunLength ] = uniforms;
325
+
326
+ sunLength ++;
327
+
277
328
  } else if ( light.isDirectionalLight ) {
278
329
 
279
330
  const uniforms = cache.get( light );
@@ -439,42 +490,51 @@ function WebGLLights( extensions ) {
439
490
 
440
491
  const hash = state.hash;
441
492
 
442
- if ( hash.directionalLength !== directionalLength ||
493
+ if ( hash.sunLength !== sunLength ||
494
+ hash.directionalLength !== directionalLength ||
443
495
  hash.pointLength !== pointLength ||
444
496
  hash.spotLength !== spotLength ||
445
497
  hash.rectAreaLength !== rectAreaLength ||
446
498
  hash.hemiLength !== hemiLength ||
499
+ hash.numSunShadows !== numSunShadows ||
447
500
  hash.numDirectionalShadows !== numDirectionalShadows ||
448
501
  hash.numPointShadows !== numPointShadows ||
449
502
  hash.numSpotShadows !== numSpotShadows ||
450
503
  hash.numSpotMaps !== numSpotMaps ||
451
504
  hash.numLightProbes !== numLightProbes ) {
452
505
 
506
+ state.sun.length = sunLength;
453
507
  state.directional.length = directionalLength;
454
508
  state.spot.length = spotLength;
455
509
  state.rectArea.length = rectAreaLength;
456
510
  state.point.length = pointLength;
457
511
  state.hemi.length = hemiLength;
458
512
 
513
+ state.sunShadow.length = numSunShadows;
514
+ state.sunShadowMap.length = numSunShadows;
515
+ state.sunShadowMatrix.length = numSunShadowCascades;
516
+ state.sunShadowCascade.length = numSunShadowCascades;
459
517
  state.directionalShadow.length = numDirectionalShadows;
460
518
  state.directionalShadowMap.length = numDirectionalShadows;
519
+ state.directionalShadowMatrix.length = numDirectionalShadows;
461
520
  state.pointShadow.length = numPointShadows;
462
521
  state.pointShadowMap.length = numPointShadows;
522
+ state.pointShadowMatrix.length = numPointShadows;
463
523
  state.spotShadow.length = numSpotShadows;
464
524
  state.spotShadowMap.length = numSpotShadows;
465
- state.directionalShadowMatrix.length = numDirectionalShadows;
466
- state.pointShadowMatrix.length = numPointShadows;
467
525
  state.spotLightMatrix.length = numSpotShadows + numSpotMaps - numSpotShadowsWithMaps;
468
526
  state.spotLightMap.length = numSpotMaps;
469
527
  state.numSpotLightShadowsWithMaps = numSpotShadowsWithMaps;
470
528
  state.numLightProbes = numLightProbes;
471
529
 
530
+ hash.sunLength = sunLength;
472
531
  hash.directionalLength = directionalLength;
473
532
  hash.pointLength = pointLength;
474
533
  hash.spotLength = spotLength;
475
534
  hash.rectAreaLength = rectAreaLength;
476
535
  hash.hemiLength = hemiLength;
477
536
 
537
+ hash.numSunShadows = numSunShadows;
478
538
  hash.numDirectionalShadows = numDirectionalShadows;
479
539
  hash.numPointShadows = numPointShadows;
480
540
  hash.numSpotShadows = numSpotShadows;
@@ -490,6 +550,7 @@ function WebGLLights( extensions ) {
490
550
 
491
551
  function setupView( lights, camera ) {
492
552
 
553
+ let sunLength = 0;
493
554
  let directionalLength = 0;
494
555
  let pointLength = 0;
495
556
  let spotLength = 0;
@@ -502,7 +563,16 @@ function WebGLLights( extensions ) {
502
563
 
503
564
  const light = lights[ i ];
504
565
 
505
- if ( light.isDirectionalLight ) {
566
+ if ( light.isSunLight ) {
567
+
568
+ const uniforms = state.sun[ sunLength ];
569
+
570
+ uniforms.direction.setFromMatrixPosition( light.matrixWorld );
571
+ uniforms.direction.transformDirection( viewMatrix );
572
+
573
+ sunLength ++;
574
+
575
+ } else if ( light.isDirectionalLight ) {
506
576
 
507
577
  const uniforms = state.directional[ directionalLength ];
508
578
 
@@ -483,6 +483,12 @@ function WebGLMaterials( renderer, properties ) {
483
483
 
484
484
  }
485
485
 
486
+ if ( material.retroreflectivity > 0 ) {
487
+
488
+ uniforms.retroreflectivity.value = material.retroreflectivity;
489
+
490
+ }
491
+
486
492
  if ( material.iridescence > 0 ) {
487
493
 
488
494
  uniforms.iridescence.value = material.iridescence;
@@ -15,7 +15,6 @@ import { Float32BufferAttribute } from '../../core/BufferAttribute.js';
15
15
  import { RawShaderMaterial } from '../../materials/RawShaderMaterial.js';
16
16
  import { Mesh } from '../../objects/Mesh.js';
17
17
  import { OrthographicCamera } from '../../cameras/OrthographicCamera.js';
18
- import { DepthTexture } from '../../textures/DepthTexture.js';
19
18
  import { WebGLRenderTarget } from '../WebGLRenderTarget.js';
20
19
  import { ColorManagement } from '../../math/ColorManagement.js';
21
20
 
@@ -31,20 +30,21 @@ const toneMappingMap = {
31
30
 
32
31
  function WebGLOutput( type, width, height, antialias, depth, stencil ) {
33
32
 
34
- // render targets for scene and post-processing
35
- const targetA = new WebGLRenderTarget( width, height, {
33
+ // render target for the scene pass (potentially multisampled)
34
+ const targetScene = new WebGLRenderTarget( width, height, {
36
35
  type: type,
37
36
  depthBuffer: depth,
38
37
  stencilBuffer: stencil,
39
38
  samples: antialias ? 4 : 0,
40
- depthTexture: depth ? new DepthTexture( width, height ) : undefined
39
+ storeMultisampledDepthBuffer: false,
40
+ storeMultisampledStencilBuffer: false,
41
+ resolveDepthBuffer: false,
42
+ resolveStencilBuffer: false
41
43
  } );
42
44
 
43
- const targetB = new WebGLRenderTarget( width, height, {
44
- type: HalfFloatType,
45
- depthBuffer: false,
46
- stencilBuffer: false
47
- } );
45
+ // single-sampled ping-pong buffers for post-processing effects, allocated on demand
46
+ let targetA = null;
47
+ let targetB = null;
48
48
 
49
49
  // create fullscreen triangle geometry
50
50
  const geometry = new BufferGeometry();
@@ -121,8 +121,10 @@ function WebGLOutput( type, width, height, antialias, depth, stencil ) {
121
121
 
122
122
  this.setSize = function ( width, height ) {
123
123
 
124
- targetA.setSize( width, height );
125
- targetB.setSize( width, height );
124
+ targetScene.setSize( width, height );
125
+
126
+ if ( targetA !== null ) targetA.setSize( width, height );
127
+ if ( targetB !== null ) targetB.setSize( width, height );
126
128
 
127
129
  for ( let i = 0; i < _effects.length; i ++ ) {
128
130
 
@@ -138,8 +140,15 @@ function WebGLOutput( type, width, height, antialias, depth, stencil ) {
138
140
  _effects = effects;
139
141
  _hasRenderPass = _effects.length > 0 && _effects[ 0 ].isRenderPass === true;
140
142
 
141
- const width = targetA.width;
142
- const height = targetA.height;
143
+ const width = targetScene.width;
144
+ const height = targetScene.height;
145
+
146
+ if ( _effects.length > 0 && targetA === null ) {
147
+
148
+ targetA = new WebGLRenderTarget( width, height, { type: HalfFloatType, depthBuffer: false, stencilBuffer: false } );
149
+ targetB = new WebGLRenderTarget( width, height, { type: HalfFloatType, depthBuffer: false, stencilBuffer: false } );
150
+
151
+ }
143
152
 
144
153
  for ( let i = 0; i < _effects.length; i ++ ) {
145
154
 
@@ -165,7 +174,7 @@ function WebGLOutput( type, width, height, antialias, depth, stencil ) {
165
174
  const width = renderTarget.width;
166
175
  const height = renderTarget.height;
167
176
 
168
- if ( targetA.width !== width || targetA.height !== height ) {
177
+ if ( targetScene.width !== width || targetScene.height !== height ) {
169
178
 
170
179
  this.setSize( width, height );
171
180
 
@@ -173,10 +182,10 @@ function WebGLOutput( type, width, height, antialias, depth, stencil ) {
173
182
 
174
183
  }
175
184
 
176
- // if first effect is a RenderPass, it will set its own render target
185
+ // if the first effect is a RenderPass, it renders the scene itself (see end())
177
186
  if ( _hasRenderPass === false ) {
178
187
 
179
- renderer.setRenderTarget( targetA );
188
+ renderer.setRenderTarget( targetScene );
180
189
 
181
190
  }
182
191
 
@@ -201,9 +210,10 @@ function WebGLOutput( type, width, height, antialias, depth, stencil ) {
201
210
 
202
211
  _isCompositing = true;
203
212
 
204
- // run post-processing effects
205
- let readBuffer = targetA;
206
- let writeBuffer = targetB;
213
+ // run post-processing effects - the scene lives in the multisampled targetScene,
214
+ // effects ping-pong between the single-sampled targetA and targetB
215
+ let readBuffer = targetScene;
216
+ let writeBuffer = targetA;
207
217
 
208
218
  for ( let i = 0; i < _effects.length; i ++ ) {
209
219
 
@@ -215,9 +225,9 @@ function WebGLOutput( type, width, height, antialias, depth, stencil ) {
215
225
 
216
226
  if ( effect.needsSwap !== false ) {
217
227
 
218
- const temp = readBuffer;
228
+ // keep targetScene out of the rotation so only the scene pass is multisampled
219
229
  readBuffer = writeBuffer;
220
- writeBuffer = temp;
230
+ writeBuffer = ( writeBuffer === targetA ) ? targetB : targetA;
221
231
 
222
232
  }
223
233
 
@@ -258,9 +268,11 @@ function WebGLOutput( type, width, height, antialias, depth, stencil ) {
258
268
 
259
269
  this.dispose = function () {
260
270
 
261
- if ( targetA.depthTexture ) targetA.depthTexture.dispose();
262
- targetA.dispose();
263
- targetB.dispose();
271
+ targetScene.dispose();
272
+
273
+ if ( targetA !== null ) targetA.dispose();
274
+ if ( targetB !== null ) targetB.dispose();
275
+
264
276
  geometry.dispose();
265
277
  material.dispose();
266
278
 
@@ -216,6 +216,7 @@ function replaceLightNums( string, parameters ) {
216
216
  const numSpotLightCoords = parameters.numSpotLightShadows + parameters.numSpotLightMaps - parameters.numSpotLightShadowsWithMaps;
217
217
 
218
218
  return string
219
+ .replace( /NUM_SUN_LIGHTS/g, parameters.numSunLights )
219
220
  .replace( /NUM_DIR_LIGHTS/g, parameters.numDirLights )
220
221
  .replace( /NUM_SPOT_LIGHTS/g, parameters.numSpotLights )
221
222
  .replace( /NUM_SPOT_LIGHT_MAPS/g, parameters.numSpotLightMaps )
@@ -223,6 +224,7 @@ function replaceLightNums( string, parameters ) {
223
224
  .replace( /NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights )
224
225
  .replace( /NUM_POINT_LIGHTS/g, parameters.numPointLights )
225
226
  .replace( /NUM_HEMI_LIGHTS/g, parameters.numHemiLights )
227
+ .replace( /NUM_SUN_LIGHT_SHADOWS/g, parameters.numSunLightShadows )
226
228
  .replace( /NUM_DIR_LIGHT_SHADOWS/g, parameters.numDirLightShadows )
227
229
  .replace( /NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, parameters.numSpotLightShadowsWithMaps )
228
230
  .replace( /NUM_SPOT_LIGHT_SHADOWS/g, parameters.numSpotLightShadows )
@@ -709,6 +711,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
709
711
  parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',
710
712
 
711
713
  parameters.dispersion ? '#define USE_DISPERSION' : '',
714
+ parameters.retroreflection ? '#define USE_RETROREFLECTION' : '',
712
715
 
713
716
  parameters.iridescence ? '#define USE_IRIDESCENCE' : '',
714
717
  parameters.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '',
@@ -140,6 +140,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
140
140
  const HAS_ANISOTROPY = material.anisotropy > 0;
141
141
  const HAS_CLEARCOAT = material.clearcoat > 0;
142
142
  const HAS_DISPERSION = material.dispersion > 0;
143
+ const HAS_RETROREFLECTION = material.retroreflectivity > 0;
143
144
  const HAS_IRIDESCENCE = material.iridescence > 0;
144
145
  const HAS_SHEEN = material.sheen > 0;
145
146
  const HAS_TRANSMISSION = material.transmission > 0;
@@ -240,6 +241,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
240
241
  clearcoatRoughnessMap: HAS_CLEARCOAT_ROUGHNESSMAP,
241
242
 
242
243
  dispersion: HAS_DISPERSION,
244
+ retroreflection: HAS_RETROREFLECTION,
243
245
 
244
246
  iridescence: HAS_IRIDESCENCE,
245
247
  iridescenceMap: HAS_IRIDESCENCEMAP,
@@ -335,6 +337,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
335
337
  morphTargetsCount: morphTargetsCount,
336
338
  morphTextureStride: morphTextureStride,
337
339
 
340
+ numSunLights: lights.sun.length,
338
341
  numDirLights: lights.directional.length,
339
342
  numPointLights: lights.point.length,
340
343
  numSpotLights: lights.spot.length,
@@ -342,6 +345,7 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
342
345
  numRectAreaLights: lights.rectArea.length,
343
346
  numHemiLights: lights.hemi.length,
344
347
 
348
+ numSunLightShadows: lights.sunShadowMap.length,
345
349
  numDirLightShadows: lights.directionalShadowMap.length,
346
350
  numPointLightShadows: lights.pointShadowMap.length,
347
351
  numSpotLightShadows: lights.spotShadowMap.length,
@@ -469,12 +473,14 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
469
473
  array.push( parameters.sizeAttenuation );
470
474
  array.push( parameters.morphTargetsCount );
471
475
  array.push( parameters.morphAttributeCount );
476
+ array.push( parameters.numSunLights );
472
477
  array.push( parameters.numDirLights );
473
478
  array.push( parameters.numPointLights );
474
479
  array.push( parameters.numSpotLights );
475
480
  array.push( parameters.numSpotLightMaps );
476
481
  array.push( parameters.numHemiLights );
477
482
  array.push( parameters.numRectAreaLights );
483
+ array.push( parameters.numSunLightShadows );
478
484
  array.push( parameters.numDirLightShadows );
479
485
  array.push( parameters.numPointLightShadows );
480
486
  array.push( parameters.numSpotLightShadows );
@@ -532,6 +538,8 @@ function WebGLPrograms( renderer, environments, extensions, capabilities, bindin
532
538
  _programLayers.enable( 18 );
533
539
  if ( parameters.dispersion )
534
540
  _programLayers.enable( 19 );
541
+ if ( parameters.retroreflection )
542
+ _programLayers.enable( 24 );
535
543
  if ( parameters.batchingColor )
536
544
  _programLayers.enable( 20 );
537
545
  if ( parameters.gradientMap )
@@ -119,7 +119,11 @@ function WebGLRenderList() {
119
119
 
120
120
  }
121
121
 
122
- function push( object, geometry, material, groupOrder, z, group ) {
122
+ function push( object, geometry, material, groupOrder, z, group, camera ) {
123
+
124
+ // with a reversed depth buffer the projected z is inverted
125
+
126
+ if ( camera.reversedDepth === true ) z = - z;
123
127
 
124
128
  const renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group );
125
129
 
@@ -159,20 +163,12 @@ function WebGLRenderList() {
159
163
 
160
164
  }
161
165
 
162
- function sort( customOpaqueSort, customTransparentSort, reversedDepth ) {
166
+ function sort( customOpaqueSort, customTransparentSort ) {
163
167
 
164
168
  if ( opaque.length > 1 ) opaque.sort( customOpaqueSort || painterSortStable );
165
169
  if ( transmissive.length > 1 ) transmissive.sort( customTransparentSort || reversePainterSortStable );
166
170
  if ( transparent.length > 1 ) transparent.sort( customTransparentSort || reversePainterSortStable );
167
171
 
168
- if ( reversedDepth ) {
169
-
170
- opaque.reverse();
171
- transmissive.reverse();
172
- transparent.reverse();
173
-
174
- }
175
-
176
172
  }
177
173
 
178
174
  function finish() {
@@ -101,7 +101,7 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
101
101
 
102
102
  if ( this.type === PCFSoftShadowMap ) {
103
103
 
104
- warn( 'WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead.' );
104
+ warn( 'WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead.' );
105
105
  this.type = PCFShadowMap;
106
106
 
107
107
  }
@@ -316,48 +316,26 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
316
316
 
317
317
  }
318
318
 
319
- // For cube render targets (PointLights), render all 6 faces. Otherwise, render once.
320
- const faceCount = shadow.map.isWebGLCubeRenderTarget ? 6 : 1;
319
+ if ( shadow.map.isWebGLCubeRenderTarget !== true && ( shadow.map.width !== _shadowMapSize.x || shadow.map.height !== _shadowMapSize.y ) ) {
321
320
 
322
- for ( let face = 0; face < faceCount; face ++ ) {
323
-
324
- // WITH_GENESYS
325
- const faceLabel = faceCount > 1 ? `shadowMap.render.depthPass (face ${face})` : 'shadowMap.render.depthPass';
326
- // !WITH_GENESYS
321
+ shadow.map.setSize( _shadowMapSize.x, _shadowMapSize.y );
327
322
 
328
- // For cube render targets, render to each face separately
329
- if ( shadow.map.isWebGLCubeRenderTarget ) {
330
-
331
- renderer.setRenderTarget( shadow.map, face );
332
- renderer.clear();
333
-
334
- } else {
335
-
336
- // For 2D render targets, use viewports
337
- if ( face === 0 ) {
338
-
339
- renderer.setRenderTarget( shadow.map );
340
- renderer.clear();
341
-
342
- }
343
-
344
- const viewport = shadow.getViewport( face );
323
+ }
345
324
 
346
- _viewport.set(
347
- _viewportSize.x * viewport.x,
348
- _viewportSize.y * viewport.y,
349
- _viewportSize.x * viewport.z,
350
- _viewportSize.y * viewport.w
351
- );
325
+ // For cube render targets (PointLights), render all 6 faces. Sun lights
326
+ // render one atlas viewport per cascade.
327
+ const faceCount = shadow.map.isWebGLCubeRenderTarget ? 6 : shadow.getViewportCount();
352
328
 
353
- _state.viewport( _viewport );
329
+ if ( light.isPointLight !== true ) shadow.updateMatrices( light, camera );
354
330
 
355
- }
331
+ for ( let face = 0; face < faceCount; face ++ ) {
356
332
 
357
333
  // WITH_GENESYS
358
- ProfilerService.begin( 'shadowMap.render.updateMatrices' );
334
+ const faceLabel = faceCount > 1 ? `shadowMap.render.depthPass (face ${face})` : 'shadowMap.render.depthPass';
359
335
  // !WITH_GENESYS
360
336
 
337
+ const shadowCamera = shadow.getCamera( face );
338
+
361
339
  if ( light.isPointLight ) {
362
340
 
363
341
  const camera = shadow.camera;
@@ -386,22 +364,43 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
386
364
  _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
387
365
  shadow._frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );
388
366
 
367
+ }
368
+
369
+ // For cube render targets, render to each face separately
370
+ if ( shadow.map.isWebGLCubeRenderTarget ) {
371
+
372
+ renderer.setRenderTarget( shadow.map, face );
373
+ renderer.clear();
374
+
389
375
  } else {
390
376
 
391
- shadow.updateMatrices( light );
377
+ // For 2D render targets, use viewports
378
+ if ( face === 0 ) {
392
379
 
393
- }
380
+ renderer.setRenderTarget( shadow.map );
381
+ renderer.clear();
394
382
 
395
- // WITH_GENESYS
396
- ProfilerService.end( 'shadowMap.render.updateMatrices' );
397
- // !WITH_GENESYS
383
+ }
384
+
385
+ const viewport = shadow.getViewport( face );
386
+
387
+ _viewport.set(
388
+ _viewportSize.x * viewport.x,
389
+ _viewportSize.y * viewport.y,
390
+ _viewportSize.x * viewport.z,
391
+ _viewportSize.y * viewport.w
392
+ );
393
+
394
+ _state.viewport( _viewport );
398
395
 
399
- _frustum = shadow.getFrustum();
396
+ }
397
+
398
+ _frustum = shadow.getFrustum( face );
400
399
 
401
400
  // WITH_GENESYS
402
401
  ProfilerService.begin( faceLabel );
403
402
  // !WITH_GENESYS
404
- renderObject( scene, camera, shadow.camera, light, this.type );
403
+ renderObject( scene, camera, shadowCamera, light, this.type );
405
404
  // WITH_GENESYS
406
405
  ProfilerService.end( faceLabel );
407
406
  // !WITH_GENESYS
@@ -459,6 +458,10 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
459
458
  type: HalfFloatType
460
459
  } );
461
460
 
461
+ } else if ( shadow.mapPass.width !== shadow.map.width || shadow.mapPass.height !== shadow.map.height ) {
462
+
463
+ shadow.mapPass.setSize( shadow.map.width, shadow.map.height );
464
+
462
465
  }
463
466
 
464
467
  // vertical pass - read from native depth texture
@@ -467,7 +470,7 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
467
470
  ProfilerService.begin( 'shadowMap.vsmPass.vertical' );
468
471
  // !WITH_GENESYS
469
472
  shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.depthTexture;
470
- shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;
473
+ shadowMaterialVertical.uniforms.resolution.value.set( shadow.map.width, shadow.map.height );
471
474
  shadowMaterialVertical.uniforms.radius.value = shadow.radius;
472
475
  renderer.setRenderTarget( shadow.mapPass );
473
476
  renderer.clear();
@@ -482,7 +485,7 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
482
485
  ProfilerService.begin( 'shadowMap.vsmPass.horizontal' );
483
486
  // !WITH_GENESYS
484
487
  shadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture;
485
- shadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize;
488
+ shadowMaterialHorizontal.uniforms.resolution.value.set( shadow.map.width, shadow.map.height );
486
489
  shadowMaterialHorizontal.uniforms.radius.value = shadow.radius;
487
490
  renderer.setRenderTarget( shadow.map );
488
491
  renderer.clear();
@@ -590,7 +593,7 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
590
593
 
591
594
  if ( visible && ( object.isMesh || object.isLine || object.isPoints ) ) {
592
595
 
593
- if ( ( object.castShadow || ( object.receiveShadow && type === VSMShadowMap ) ) && ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) ) {
596
+ if ( ( object.castShadow || ( object.receiveShadow && type === VSMShadowMap ) ) && ( ! object.frustumCulled || object.intersectsFrustum( _frustum ) ) ) {
594
597
 
595
598
  object.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );
596
599
 
@@ -14,7 +14,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
14
14
  const _htmlTextures = new Set();
15
15
  let _canvas;
16
16
 
17
- const _sources = new WeakMap(); // maps WebglTexture objects to instances of Source
17
+ const _sources = new WeakMap(); // maps WebglTexture objects to instances of TextureSource
18
18
 
19
19
  // cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,
20
20
  // also OffscreenCanvas.getContext("webgl"), but not OffscreenCanvas.getContext("2d")!
@@ -515,7 +515,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
515
515
 
516
516
  if ( textureUnit >= capabilities.maxTextures ) {
517
517
 
518
- warn( 'WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );
518
+ warn( 'WebGLTextures: Trying to use ' + ( textureUnit + 1 ) + ' texture units while this GPU supports only ' + capabilities.maxTextures );
519
519
 
520
520
  }
521
521
 
@@ -720,7 +720,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
720
720
 
721
721
  }
722
722
 
723
- // create Source <-> WebGLTextures mapping if necessary
723
+ // create TextureSource <-> WebGLTextures mapping if necessary
724
724
 
725
725
  const source = texture.source;
726
726
  let webglTextures = _sources.get( source );
@@ -1065,8 +1065,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1065
1065
 
1066
1066
  }
1067
1067
 
1068
- texture.clearLayerUpdates();
1069
-
1070
1068
  } else {
1071
1069
 
1072
1070
  state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data );
@@ -1107,6 +1105,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1107
1105
 
1108
1106
  }
1109
1107
 
1108
+ if ( texture.layerUpdates.size > 0 ) texture.clearLayerUpdates();
1109
+
1110
1110
  } else {
1111
1111
 
1112
1112
  if ( useTexStorage && allocateMemory ) {
@@ -2348,7 +2348,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2348
2348
 
2349
2349
  invalidationArrayRead.push( _gl.COLOR_ATTACHMENT0 + i );
2350
2350
 
2351
- if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false ) {
2351
+ if ( renderTarget.depthBuffer && renderTarget.storeMultisampledDepthBuffer === false ) {
2352
2352
 
2353
2353
  invalidationArrayRead.push( depthStyle );
2354
2354
  invalidationArrayDraw.push( depthStyle );
@@ -2387,7 +2387,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2387
2387
 
2388
2388
  } else {
2389
2389
 
2390
- if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false && supportsInvalidateFramebuffer ) {
2390
+ if ( renderTarget.depthBuffer && renderTarget.storeMultisampledDepthBuffer === false && supportsInvalidateFramebuffer ) {
2391
2391
 
2392
2392
  const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
2393
2393