super-three 0.170.1 → 0.172.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 (413) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +157 -49
  3. package/build/three.core.js +104 -42
  4. package/build/three.core.min.js +1 -1
  5. package/build/three.module.js +53 -8
  6. package/build/three.module.min.js +1 -1
  7. package/build/three.tsl.js +10 -5
  8. package/build/three.tsl.min.js +1 -1
  9. package/build/three.webgpu.js +21191 -1008
  10. package/build/three.webgpu.min.js +1 -1
  11. package/build/three.webgpu.nodes.js +21189 -1008
  12. package/build/three.webgpu.nodes.min.js +1 -1
  13. package/examples/jsm/Addons.js +0 -5
  14. package/examples/jsm/animation/CCDIKSolver.js +3 -2
  15. package/examples/jsm/controls/ArcballControls.js +28 -19
  16. package/examples/jsm/controls/OrbitControls.js +5 -4
  17. package/examples/jsm/csm/CSMShadowNode.js +16 -11
  18. package/examples/jsm/curves/NURBSCurve.js +1 -1
  19. package/examples/jsm/curves/NURBSUtils.js +3 -0
  20. package/examples/jsm/effects/OutlineEffect.js +1 -1
  21. package/examples/jsm/exporters/GLTFExporter.js +11 -7
  22. package/examples/jsm/exporters/KTX2Exporter.js +1 -1
  23. package/examples/jsm/exporters/PLYExporter.js +2 -2
  24. package/examples/jsm/helpers/TextureHelperGPU.js +15 -5
  25. package/examples/jsm/helpers/VertexNormalsHelper.js +2 -0
  26. package/examples/jsm/lights/LightProbeGenerator.js +3 -3
  27. package/examples/jsm/lines/webgpu/LineSegments2.js +15 -6
  28. package/examples/jsm/loaders/3MFLoader.js +6 -3
  29. package/examples/jsm/loaders/BVHLoader.js +1 -1
  30. package/examples/jsm/loaders/ColladaLoader.js +5 -5
  31. package/examples/jsm/loaders/DDSLoader.js +42 -0
  32. package/examples/jsm/loaders/GCodeLoader.js +1 -1
  33. package/examples/jsm/loaders/GLTFLoader.js +22 -2
  34. package/examples/jsm/loaders/KTX2Loader.js +6 -1
  35. package/examples/jsm/loaders/KTXLoader.js +4 -4
  36. package/examples/jsm/loaders/LDrawLoader.js +1 -1
  37. package/examples/jsm/loaders/LottieLoader.js +1 -1
  38. package/examples/jsm/loaders/MTLLoader.js +1 -0
  39. package/examples/jsm/loaders/NRRDLoader.js +1 -1
  40. package/examples/jsm/loaders/PLYLoader.js +7 -7
  41. package/examples/jsm/loaders/PVRLoader.js +1 -1
  42. package/examples/jsm/loaders/SVGLoader.js +2 -2
  43. package/examples/jsm/loaders/TDSLoader.js +1 -1
  44. package/examples/jsm/loaders/VRMLLoader.js +7 -7
  45. package/examples/jsm/loaders/lwo/IFFParser.js +4 -4
  46. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
  47. package/examples/jsm/math/ConvexHull.js +1 -1
  48. package/examples/jsm/math/OBB.js +17 -0
  49. package/examples/jsm/misc/ProgressiveLightMapGPU.js +10 -10
  50. package/examples/jsm/misc/Volume.js +20 -12
  51. package/examples/jsm/misc/VolumeSlice.js +2 -2
  52. package/examples/jsm/modifiers/CurveModifier.js +10 -8
  53. package/examples/jsm/modifiers/CurveModifierGPU.js +9 -7
  54. package/examples/jsm/modifiers/SimplifyModifier.js +2 -2
  55. package/examples/jsm/objects/GroundedSkybox.js +4 -4
  56. package/examples/jsm/objects/Sky.js +2 -2
  57. package/examples/jsm/objects/SkyMesh.js +3 -3
  58. package/examples/jsm/objects/Water2.js +1 -1
  59. package/examples/jsm/objects/Water2Mesh.js +2 -2
  60. package/examples/jsm/objects/WaterMesh.js +4 -4
  61. package/examples/jsm/postprocessing/BloomPass.js +2 -2
  62. package/examples/jsm/postprocessing/EffectComposer.js +1 -2
  63. package/examples/jsm/postprocessing/OutlinePass.js +4 -4
  64. package/examples/jsm/postprocessing/SAOPass.js +1 -2
  65. package/examples/jsm/postprocessing/SMAAPass.js +1 -3
  66. package/examples/jsm/postprocessing/SSAOPass.js +2 -4
  67. package/examples/jsm/postprocessing/SSRPass.js +2 -4
  68. package/examples/jsm/postprocessing/UnrealBloomPass.js +2 -2
  69. package/examples/jsm/renderers/SVGRenderer.js +6 -4
  70. package/examples/jsm/shaders/BokehShader2.js +1 -1
  71. package/examples/jsm/shaders/GodRaysShader.js +3 -3
  72. package/examples/jsm/shaders/SobelOperatorShader.js +1 -1
  73. package/examples/jsm/tsl/display/AfterImageNode.js +93 -4
  74. package/examples/jsm/tsl/display/AnaglyphPassNode.js +46 -2
  75. package/examples/jsm/tsl/display/AnamorphicNode.js +118 -5
  76. package/examples/jsm/tsl/display/BleachBypass.js +10 -0
  77. package/examples/jsm/tsl/display/BloomNode.js +233 -26
  78. package/examples/jsm/tsl/display/DenoiseNode.js +141 -25
  79. package/examples/jsm/tsl/display/DepthOfFieldNode.js +80 -1
  80. package/examples/jsm/tsl/display/DotScreenNode.js +50 -5
  81. package/examples/jsm/tsl/display/FXAANode.js +52 -3
  82. package/examples/jsm/tsl/display/FilmNode.js +47 -1
  83. package/examples/jsm/tsl/display/GTAONode.js +210 -14
  84. package/examples/jsm/tsl/display/GaussianBlurNode.js +152 -8
  85. package/examples/jsm/tsl/display/LensflareNode.js +131 -13
  86. package/examples/jsm/tsl/display/Lut3DNode.js +55 -1
  87. package/examples/jsm/tsl/display/MotionBlur.js +12 -2
  88. package/examples/jsm/tsl/display/OutlineNode.js +343 -26
  89. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +36 -2
  90. package/examples/jsm/tsl/display/PixelationPassNode.js +142 -9
  91. package/examples/jsm/tsl/display/RGBShiftNode.js +49 -2
  92. package/examples/jsm/tsl/display/SMAANode.js +187 -46
  93. package/examples/jsm/tsl/display/SSAAPassNode.js +110 -25
  94. package/examples/jsm/tsl/display/SSRNode.js +194 -21
  95. package/examples/jsm/tsl/display/Sepia.js +9 -0
  96. package/examples/jsm/tsl/display/SobelOperatorNode.js +54 -4
  97. package/examples/jsm/tsl/display/StereoCompositePassNode.js +79 -3
  98. package/examples/jsm/tsl/display/StereoPassNode.js +41 -3
  99. package/examples/jsm/tsl/display/TRAAPassNode.js +116 -21
  100. package/examples/jsm/tsl/display/TransitionNode.js +71 -6
  101. package/examples/jsm/tsl/display/hashBlur.js +14 -3
  102. package/examples/jsm/tsl/lighting/TiledLightsNode.js +40 -34
  103. package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
  104. package/examples/jsm/utils/CameraUtils.js +4 -1
  105. package/examples/jsm/utils/GeometryUtils.js +22 -19
  106. package/examples/jsm/utils/SceneUtils.js +2 -2
  107. package/examples/jsm/webxr/XRControllerModelFactory.js +6 -1
  108. package/examples/jsm/webxr/XREstimatedLight.js +1 -1
  109. package/package.json +8 -3
  110. package/src/Three.Core.js +2 -0
  111. package/src/Three.Legacy.js +0 -21
  112. package/src/Three.TSL.js +9 -4
  113. package/src/Three.WebGPU.Nodes.js +2 -2
  114. package/src/Three.WebGPU.js +2 -2
  115. package/src/animation/PropertyBinding.js +2 -2
  116. package/src/cameras/PerspectiveCamera.js +18 -2
  117. package/src/constants.js +1 -1
  118. package/src/core/RenderTarget.js +18 -0
  119. package/src/core/RenderTarget3D.js +22 -0
  120. package/src/core/RenderTargetArray.js +22 -0
  121. package/src/extras/Earcut.js +1 -1
  122. package/src/extras/PMREMGenerator.js +20 -0
  123. package/src/extras/TextureUtils.js +6 -0
  124. package/src/helpers/CameraHelper.js +16 -13
  125. package/src/loaders/nodes/NodeLoader.js +59 -0
  126. package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
  127. package/src/loaders/nodes/NodeObjectLoader.js +61 -0
  128. package/src/materials/nodes/InstancedPointsNodeMaterial.js +72 -19
  129. package/src/materials/nodes/Line2NodeMaterial.js +128 -34
  130. package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
  131. package/src/materials/nodes/LineDashedNodeMaterial.js +78 -5
  132. package/src/materials/nodes/MeshBasicNodeMaterial.js +56 -0
  133. package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
  134. package/src/materials/nodes/MeshMatcapNodeMaterial.js +22 -2
  135. package/src/materials/nodes/MeshNormalNodeMaterial.js +21 -2
  136. package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
  137. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +269 -0
  138. package/src/materials/nodes/MeshSSSNodeMaterial.js +97 -6
  139. package/src/materials/nodes/MeshStandardNodeMaterial.js +78 -0
  140. package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
  141. package/src/materials/nodes/NodeMaterial.js +474 -21
  142. package/src/materials/nodes/PointsNodeMaterial.js +22 -13
  143. package/src/materials/nodes/ShadowNodeMaterial.js +29 -0
  144. package/src/materials/nodes/SpriteNodeMaterial.js +77 -19
  145. package/src/materials/nodes/VolumeNodeMaterial.js +80 -4
  146. package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -0
  147. package/src/nodes/Nodes.js +1 -6
  148. package/src/nodes/TSL.js +2 -3
  149. package/src/nodes/accessors/AccessorsUtils.js +27 -0
  150. package/src/nodes/accessors/Arrays.js +24 -5
  151. package/src/nodes/accessors/BatchNode.js +39 -3
  152. package/src/nodes/accessors/Bitangent.js +37 -0
  153. package/src/nodes/accessors/BufferAttributeNode.js +178 -5
  154. package/src/nodes/accessors/BufferNode.js +63 -0
  155. package/src/nodes/accessors/BuiltinNode.js +38 -0
  156. package/src/nodes/accessors/Camera.js +49 -0
  157. package/src/nodes/accessors/ClippingNode.js +71 -2
  158. package/src/nodes/accessors/CubeTextureNode.js +64 -0
  159. package/src/nodes/accessors/InstanceNode.js +85 -2
  160. package/src/nodes/accessors/InstancedMeshNode.js +28 -3
  161. package/src/nodes/accessors/InstancedPointsMaterialNode.js +13 -0
  162. package/src/nodes/accessors/Lights.js +50 -1
  163. package/src/nodes/accessors/MaterialNode.js +302 -8
  164. package/src/nodes/accessors/MaterialProperties.js +7 -0
  165. package/src/nodes/accessors/MaterialReferenceNode.js +53 -13
  166. package/src/nodes/accessors/ModelNode.js +100 -5
  167. package/src/nodes/accessors/ModelViewProjectionNode.js +10 -38
  168. package/src/nodes/accessors/MorphNode.js +48 -4
  169. package/src/nodes/accessors/Normal.js +59 -3
  170. package/src/nodes/accessors/Object3DNode.js +102 -1
  171. package/src/nodes/accessors/PointUVNode.js +26 -0
  172. package/src/nodes/accessors/Position.js +53 -4
  173. package/src/nodes/accessors/ReferenceBaseNode.js +188 -0
  174. package/src/nodes/accessors/ReferenceNode.js +202 -2
  175. package/src/nodes/accessors/ReflectVector.js +24 -0
  176. package/src/nodes/accessors/RendererReferenceNode.js +46 -1
  177. package/src/nodes/accessors/SceneNode.js +54 -0
  178. package/src/nodes/accessors/SkinningNode.js +127 -1
  179. package/src/nodes/accessors/StorageBufferNode.js +168 -4
  180. package/src/nodes/accessors/StorageTextureNode.js +118 -0
  181. package/src/nodes/accessors/Tangent.js +36 -0
  182. package/src/nodes/accessors/Texture3DNode.js +89 -5
  183. package/src/nodes/accessors/TextureBicubic.js +12 -2
  184. package/src/nodes/accessors/TextureNode.js +309 -10
  185. package/src/nodes/accessors/TextureSizeNode.js +42 -0
  186. package/src/nodes/accessors/UV.js +10 -1
  187. package/src/nodes/accessors/UniformArrayNode.js +223 -23
  188. package/src/nodes/accessors/UserDataNode.js +46 -0
  189. package/src/nodes/accessors/VelocityNode.js +82 -0
  190. package/src/nodes/accessors/VertexColorNode.js +39 -2
  191. package/src/nodes/code/CodeNode.js +95 -1
  192. package/src/nodes/code/ExpressionNode.js +28 -0
  193. package/src/nodes/code/FunctionCallNode.js +37 -0
  194. package/src/nodes/code/FunctionNode.js +45 -0
  195. package/src/nodes/code/ScriptableNode.js +223 -1
  196. package/src/nodes/code/ScriptableValueNode.js +85 -1
  197. package/src/nodes/core/AssignNode.js +48 -2
  198. package/src/nodes/core/AttributeNode.js +43 -0
  199. package/src/nodes/core/BypassNode.js +47 -2
  200. package/src/nodes/core/CacheNode.js +53 -2
  201. package/src/nodes/core/ConstNode.js +24 -0
  202. package/src/nodes/core/ContextNode.js +65 -0
  203. package/src/nodes/core/IndexNode.js +68 -7
  204. package/src/nodes/core/InputNode.js +48 -0
  205. package/src/nodes/core/LightingModel.js +60 -0
  206. package/src/nodes/core/MRTNode.js +66 -0
  207. package/src/nodes/core/Node.js +337 -12
  208. package/src/nodes/core/NodeAttribute.js +38 -0
  209. package/src/nodes/core/NodeBuilder.js +945 -15
  210. package/src/nodes/core/NodeCache.js +41 -2
  211. package/src/nodes/core/NodeCode.js +31 -0
  212. package/src/nodes/core/NodeFrame.js +123 -2
  213. package/src/nodes/core/NodeFunction.js +46 -0
  214. package/src/nodes/core/NodeFunctionInput.js +44 -0
  215. package/src/nodes/core/NodeParser.js +11 -0
  216. package/src/nodes/core/NodeUniform.js +52 -0
  217. package/src/nodes/core/NodeUtils.js +141 -0
  218. package/src/nodes/core/NodeVar.js +30 -0
  219. package/src/nodes/core/NodeVarying.js +28 -0
  220. package/src/nodes/core/OutputStructNode.js +33 -2
  221. package/src/nodes/core/ParameterNode.js +28 -0
  222. package/src/nodes/core/PropertyNode.js +232 -0
  223. package/src/nodes/core/StackNode.js +78 -0
  224. package/src/nodes/core/StructTypeNode.js +39 -1
  225. package/src/nodes/core/TempNode.js +30 -4
  226. package/src/nodes/core/UniformGroupNode.js +82 -7
  227. package/src/nodes/core/UniformNode.js +66 -0
  228. package/src/nodes/core/VarNode.js +52 -0
  229. package/src/nodes/core/VaryingNode.js +83 -2
  230. package/src/nodes/core/constants.js +36 -0
  231. package/src/nodes/display/BumpMapNode.js +37 -0
  232. package/src/nodes/display/ColorAdjustment.js +53 -11
  233. package/src/nodes/display/ColorSpaceFunctions.js +16 -0
  234. package/src/nodes/display/ColorSpaceNode.js +82 -0
  235. package/src/nodes/display/FrontFacingNode.js +29 -0
  236. package/src/nodes/display/NormalMapNode.js +43 -0
  237. package/src/nodes/display/PassNode.js +298 -7
  238. package/src/nodes/display/PosterizeNode.js +33 -0
  239. package/src/nodes/display/RenderOutputNode.js +66 -1
  240. package/src/nodes/display/ScreenNode.js +87 -0
  241. package/src/nodes/display/ToneMappingFunctions.js +58 -10
  242. package/src/nodes/display/ToneMappingNode.js +55 -2
  243. package/src/nodes/display/ToonOutlinePassNode.js +73 -0
  244. package/src/nodes/display/ViewportDepthNode.js +122 -8
  245. package/src/nodes/display/ViewportDepthTextureNode.js +23 -0
  246. package/src/nodes/display/ViewportSharedTextureNode.js +23 -0
  247. package/src/nodes/display/ViewportTextureNode.js +57 -0
  248. package/src/nodes/fog/Fog.js +93 -0
  249. package/src/nodes/functions/BasicLightingModel.js +24 -0
  250. package/src/nodes/functions/PhongLightingModel.js +34 -2
  251. package/src/nodes/functions/PhysicalLightingModel.js +167 -8
  252. package/src/nodes/functions/ShadowMaskModel.js +23 -0
  253. package/src/nodes/functions/ToonLightingModel.js +20 -0
  254. package/src/nodes/functions/material/getAlphaHashThreshold.js +1 -3
  255. package/src/nodes/functions/material/getParallaxCorrectNormal.js +16 -1
  256. package/src/nodes/geometry/RangeNode.js +54 -2
  257. package/src/nodes/gpgpu/AtomicFunctionNode.js +157 -1
  258. package/src/nodes/gpgpu/BarrierNode.js +47 -0
  259. package/src/nodes/gpgpu/ComputeBuiltinNode.js +126 -0
  260. package/src/nodes/gpgpu/ComputeNode.js +106 -2
  261. package/src/nodes/gpgpu/WorkgroupInfoNode.js +115 -6
  262. package/src/nodes/lighting/AONode.js +18 -0
  263. package/src/nodes/lighting/AmbientLightNode.js +10 -0
  264. package/src/nodes/lighting/AnalyticLightNode.js +97 -2
  265. package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
  266. package/src/nodes/lighting/BasicLightMapNode.js +17 -0
  267. package/src/nodes/lighting/DirectionalLightNode.js +10 -0
  268. package/src/nodes/lighting/EnvironmentNode.js +18 -0
  269. package/src/nodes/lighting/HemisphereLightNode.js +31 -0
  270. package/src/nodes/lighting/IESSpotLightNode.js +11 -0
  271. package/src/nodes/lighting/IrradianceNode.js +17 -0
  272. package/src/nodes/lighting/LightProbeNode.js +20 -0
  273. package/src/nodes/lighting/LightUtils.js +12 -0
  274. package/src/nodes/lighting/LightingContextNode.js +48 -0
  275. package/src/nodes/lighting/LightingNode.js +15 -6
  276. package/src/nodes/lighting/LightsNode.js +132 -1
  277. package/src/nodes/lighting/PointLightNode.js +32 -1
  278. package/src/nodes/lighting/PointShadowNode.js +54 -1
  279. package/src/nodes/lighting/RectAreaLightNode.js +44 -6
  280. package/src/nodes/lighting/ShadowBaseNode.js +93 -0
  281. package/src/nodes/lighting/ShadowNode.js +240 -34
  282. package/src/nodes/lighting/SpotLightNode.js +43 -0
  283. package/src/nodes/math/ConditionalNode.js +70 -3
  284. package/src/nodes/math/Hash.js +9 -0
  285. package/src/nodes/math/MathNode.js +614 -11
  286. package/src/nodes/math/MathUtils.js +45 -1
  287. package/src/nodes/math/OperatorNode.js +233 -0
  288. package/src/nodes/math/TriNoise3D.js +18 -7
  289. package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
  290. package/src/nodes/parsers/GLSLNodeParser.js +11 -0
  291. package/src/nodes/pmrem/PMREMNode.js +133 -0
  292. package/src/nodes/pmrem/PMREMUtils.js +1 -1
  293. package/src/nodes/procedural/Checker.js +9 -0
  294. package/src/nodes/tsl/TSLBase.js +2 -2
  295. package/src/nodes/utils/ArrayElementNode.js +38 -2
  296. package/src/nodes/utils/ConvertNode.js +31 -0
  297. package/src/nodes/utils/CubeMapNode.js +78 -0
  298. package/src/nodes/utils/Discard.js +16 -0
  299. package/src/nodes/utils/EquirectUVNode.js +31 -1
  300. package/src/nodes/utils/FlipNode.js +38 -0
  301. package/src/nodes/utils/FunctionOverloadingNode.js +53 -1
  302. package/src/nodes/utils/JoinNode.js +25 -0
  303. package/src/nodes/utils/LoopNode.js +74 -1
  304. package/src/nodes/utils/MatcapUVNode.js +17 -0
  305. package/src/nodes/utils/MaxMipLevelNode.js +49 -0
  306. package/src/nodes/utils/Oscillators.js +33 -0
  307. package/src/nodes/utils/Packing.js +17 -0
  308. package/src/nodes/utils/PostProcessingUtils.js +28 -23
  309. package/src/nodes/utils/RTTNode.js +123 -2
  310. package/src/nodes/utils/ReflectorNode.js +174 -4
  311. package/src/nodes/utils/RemapNode.js +79 -0
  312. package/src/nodes/utils/RotateNode.js +41 -0
  313. package/src/nodes/utils/SetNode.js +44 -1
  314. package/src/nodes/utils/SplitNode.js +55 -3
  315. package/src/nodes/utils/SpriteSheetUVNode.js +46 -0
  316. package/src/nodes/utils/SpriteUtils.js +17 -0
  317. package/src/nodes/utils/StorageArrayElementNode.js +40 -0
  318. package/src/nodes/utils/Timer.js +19 -0
  319. package/src/nodes/utils/TriplanarTexturesNode.js +84 -0
  320. package/src/nodes/utils/UVUtils.js +20 -0
  321. package/src/nodes/utils/ViewportUtils.js +13 -0
  322. package/src/objects/BatchedMesh.js +1 -2
  323. package/src/objects/ClippingGroup.js +49 -0
  324. package/src/renderers/WebGLRenderer.js +23 -4
  325. package/src/renderers/common/Animation.js +63 -0
  326. package/src/renderers/common/Attributes.js +36 -0
  327. package/src/renderers/common/Backend.js +467 -52
  328. package/src/renderers/common/Background.js +34 -1
  329. package/src/renderers/common/BindGroup.js +43 -0
  330. package/src/renderers/common/Binding.js +35 -0
  331. package/src/renderers/common/Bindings.js +93 -1
  332. package/src/renderers/common/Buffer.js +49 -0
  333. package/src/renderers/common/BufferUtils.js +27 -0
  334. package/src/renderers/common/BundleGroup.js +57 -0
  335. package/src/renderers/common/ChainMap.js +38 -1
  336. package/src/renderers/common/ClippingContext.js +107 -14
  337. package/src/renderers/common/Color4.js +36 -0
  338. package/src/renderers/common/ComputePipeline.js +24 -0
  339. package/src/renderers/common/CubeRenderTarget.js +13 -0
  340. package/src/renderers/common/DataMap.js +37 -1
  341. package/src/renderers/common/Geometries.js +98 -0
  342. package/src/renderers/common/IndirectStorageBufferAttribute.js +25 -2
  343. package/src/renderers/common/Info.js +87 -0
  344. package/src/renderers/common/Lighting.js +26 -0
  345. package/src/renderers/common/Pipeline.js +22 -0
  346. package/src/renderers/common/Pipelines.js +148 -5
  347. package/src/renderers/common/PostProcessing.js +75 -3
  348. package/src/renderers/common/ProgrammableStage.js +60 -2
  349. package/src/renderers/common/QuadMesh.js +54 -5
  350. package/src/renderers/common/RenderBundle.js +14 -8
  351. package/src/renderers/common/RenderBundles.js +33 -10
  352. package/src/renderers/common/RenderContext.js +169 -4
  353. package/src/renderers/common/RenderContexts.js +42 -2
  354. package/src/renderers/common/RenderList.js +178 -0
  355. package/src/renderers/common/RenderLists.js +31 -0
  356. package/src/renderers/common/RenderObject.js +328 -4
  357. package/src/renderers/common/RenderObjects.js +101 -7
  358. package/src/renderers/common/RenderPipeline.js +24 -0
  359. package/src/renderers/common/Renderer.js +1096 -31
  360. package/src/renderers/common/RendererUtils.js +193 -0
  361. package/src/renderers/common/SampledTexture.js +121 -0
  362. package/src/renderers/common/Sampler.js +30 -0
  363. package/src/renderers/common/StorageBuffer.js +24 -0
  364. package/src/renderers/common/StorageBufferAttribute.js +31 -2
  365. package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
  366. package/src/renderers/common/StorageTexture.js +38 -0
  367. package/src/renderers/common/Textures.js +83 -0
  368. package/src/renderers/common/Uniform.js +188 -2
  369. package/src/renderers/common/UniformBuffer.js +19 -0
  370. package/src/renderers/common/UniformsGroup.js +139 -2
  371. package/src/renderers/common/extras/PMREMGenerator.js +24 -3
  372. package/src/renderers/common/nodes/NodeBuilderState.js +95 -1
  373. package/src/renderers/common/nodes/NodeLibrary.js +89 -0
  374. package/src/renderers/common/nodes/NodeSampledTexture.js +91 -2
  375. package/src/renderers/common/nodes/NodeSampler.js +28 -0
  376. package/src/renderers/common/nodes/NodeStorageBuffer.js +35 -0
  377. package/src/renderers/common/nodes/NodeUniform.js +189 -0
  378. package/src/renderers/common/nodes/NodeUniformBuffer.js +29 -0
  379. package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
  380. package/src/renderers/common/nodes/Nodes.js +327 -60
  381. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +2 -2
  382. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
  383. package/src/renderers/webgl-fallback/WebGLBackend.js +547 -29
  384. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +0 -1
  385. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +1 -1
  386. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +1 -1
  387. package/src/renderers/webgpu/WebGPUBackend.js +480 -49
  388. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +34 -0
  389. package/src/renderers/webgpu/WebGPURenderer.js +35 -0
  390. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +20 -8
  391. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +21 -8
  392. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +59 -11
  393. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +17 -0
  394. package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
  395. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +10 -8
  396. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +9 -1
  397. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +5 -9
  398. package/src/renderers/webgpu/utils/WebGPUUtils.js +30 -0
  399. package/src/renderers/webxr/WebXRDepthSensing.js +1 -1
  400. package/src/renderers/webxr/WebXRManager.js +7 -1
  401. package/src/textures/Data3DTexture.js +2 -2
  402. package/src/textures/Texture.js +4 -0
  403. package/examples/jsm/animation/MMDAnimationHelper.js +0 -1209
  404. package/examples/jsm/animation/MMDPhysics.js +0 -1408
  405. package/examples/jsm/exporters/MMDExporter.js +0 -223
  406. package/examples/jsm/libs/mmdparser.module.js +0 -11530
  407. package/examples/jsm/loaders/MMDLoader.js +0 -2298
  408. package/examples/jsm/shaders/MMDToonShader.js +0 -134
  409. package/src/nodes/core/UniformGroup.js +0 -13
  410. package/src/nodes/fog/FogExp2Node.js +0 -35
  411. package/src/nodes/fog/FogNode.js +0 -50
  412. package/src/nodes/fog/FogRangeNode.js +0 -36
  413. package/src/renderers/common/PostProcessingUtils.js +0 -86
@@ -14,18 +14,184 @@ import { WebGLBufferRenderer } from './WebGLBufferRenderer.js';
14
14
  import { warnOnce } from '../../utils.js';
15
15
  import { WebGLCoordinateSystem } from '../../constants.js';
16
16
 
17
- //
18
-
17
+ /**
18
+ * A backend implementation targeting WebGL 2.
19
+ *
20
+ * @private
21
+ * @augments Backend
22
+ */
19
23
  class WebGLBackend extends Backend {
20
24
 
25
+ /**
26
+ * Constructs a new WebGPU backend.
27
+ *
28
+ * @param {Object} parameters - The configuration parameter.
29
+ * @param {Boolean} [parameters.logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
30
+ * @param {Boolean} [parameters.alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
31
+ * @param {Boolean} [parameters.depth=true] - Whether the default framebuffer should have a depth buffer or not.
32
+ * @param {Boolean} [parameters.stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
33
+ * @param {Boolean} [parameters.antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
34
+ * @param {Number} [parameters.samples=0] - When `antialias` is `true`, `4` samples are used by default. Set this parameter to any other integer value than 0 to overwrite the default.
35
+ * @param {Boolean} [parameters.forceWebGL=false] - If set to `true`, the renderer uses it WebGL 2 backend no matter if WebGPU is supported or not.
36
+ * @param {WebGL2RenderingContext} [parameters.context=undefined] - A WebGL 2 rendering context.
37
+ */
21
38
  constructor( parameters = {} ) {
22
39
 
23
40
  super( parameters );
24
41
 
42
+ /**
43
+ * This flag can be used for type testing.
44
+ *
45
+ * @type {Boolean}
46
+ * @readonly
47
+ * @default true
48
+ */
25
49
  this.isWebGLBackend = true;
26
50
 
51
+ /**
52
+ * A reference to a backend module holding shader attribute-related
53
+ * utility functions.
54
+ *
55
+ * @type {WebGLAttributeUtils?}
56
+ * @default null
57
+ */
58
+ this.attributeUtils = null;
59
+
60
+ /**
61
+ * A reference to a backend module holding extension-related
62
+ * utility functions.
63
+ *
64
+ * @type {WebGLExtensions?}
65
+ * @default null
66
+ */
67
+ this.extensions = null;
68
+
69
+ /**
70
+ * A reference to a backend module holding capability-related
71
+ * utility functions.
72
+ *
73
+ * @type {WebGLCapabilities?}
74
+ * @default null
75
+ */
76
+ this.capabilities = null;
77
+
78
+ /**
79
+ * A reference to a backend module holding texture-related
80
+ * utility functions.
81
+ *
82
+ * @type {WebGLTextureUtils?}
83
+ * @default null
84
+ */
85
+ this.textureUtils = null;
86
+
87
+ /**
88
+ * A reference to a backend module holding renderer-related
89
+ * utility functions.
90
+ *
91
+ * @type {WebGLBufferRenderer?}
92
+ * @default null
93
+ */
94
+ this.bufferRenderer = null;
95
+
96
+ /**
97
+ * A reference to the rendering context.
98
+ *
99
+ * @type {WebGL2RenderingContext?}
100
+ * @default null
101
+ */
102
+ this.gl = null;
103
+
104
+ /**
105
+ * A reference to a backend module holding state-related
106
+ * utility functions.
107
+ *
108
+ * @type {WebGLState?}
109
+ * @default null
110
+ */
111
+ this.state = null;
112
+
113
+ /**
114
+ * A reference to a backend module holding common
115
+ * utility functions.
116
+ *
117
+ * @type {WebGLUtils?}
118
+ * @default null
119
+ */
120
+ this.utils = null;
121
+
122
+ /**
123
+ * Dictionary for caching VAOs.
124
+ *
125
+ * @type {Object<String,WebGLVertexArrayObject>}
126
+ */
127
+ this.vaoCache = {};
128
+
129
+ /**
130
+ * Dictionary for caching transform feedback objects.
131
+ *
132
+ * @type {Object<String,WebGLTransformFeedback>}
133
+ */
134
+ this.transformFeedbackCache = {};
135
+
136
+ /**
137
+ * Controls if `gl.RASTERIZER_DISCARD` should be enabled or not.
138
+ * Only relevant when using compute shaders.
139
+ *
140
+ * @type {Boolean}
141
+ * @default false
142
+ */
143
+ this.discard = false;
144
+
145
+ /**
146
+ * A reference to the `EXT_disjoint_timer_query_webgl2` extension. `null` if the
147
+ * device does not support the extension.
148
+ *
149
+ * @type {EXTDisjointTimerQueryWebGL2?}
150
+ * @default null
151
+ */
152
+ this.disjoint = null;
153
+
154
+ /**
155
+ * A reference to the `KHR_parallel_shader_compile` extension. `null` if the
156
+ * device does not support the extension.
157
+ *
158
+ * @type {KHRParallelShaderCompile?}
159
+ * @default null
160
+ */
161
+ this.parallel = null;
162
+
163
+ /**
164
+ * Whether to track timestamps with a Timestamp Query API or not.
165
+ *
166
+ * @type {Boolean}
167
+ * @default false
168
+ */
169
+ this.trackTimestamp = ( parameters.trackTimestamp === true );
170
+
171
+ /**
172
+ * A reference to the current render context.
173
+ *
174
+ * @private
175
+ * @type {RenderContext}
176
+ * @default null
177
+ */
178
+ this._currentContext = null;
179
+
180
+ /**
181
+ * A unique collection of bindings.
182
+ *
183
+ * @private
184
+ * @type {WeakSet}
185
+ */
186
+ this._knownBindings = new WeakSet();
187
+
27
188
  }
28
189
 
190
+ /**
191
+ * Initializes the backend so it is ready for usage.
192
+ *
193
+ * @param {Renderer} renderer - The renderer.
194
+ */
29
195
  init( renderer ) {
30
196
 
31
197
  super.init( renderer );
@@ -66,11 +232,6 @@ class WebGLBackend extends Backend {
66
232
  this.state = new WebGLState( this );
67
233
  this.utils = new WebGLUtils( this );
68
234
 
69
- this.vaoCache = {};
70
- this.transformFeedbackCache = {};
71
- this.discard = false;
72
- this.trackTimestamp = ( parameters.trackTimestamp === true );
73
-
74
235
  this.extensions.get( 'EXT_color_buffer_float' );
75
236
  this.extensions.get( 'WEBGL_clip_cull_distance' );
76
237
  this.extensions.get( 'OES_texture_float_linear' );
@@ -82,30 +243,52 @@ class WebGLBackend extends Backend {
82
243
  this.disjoint = this.extensions.get( 'EXT_disjoint_timer_query_webgl2' );
83
244
  this.parallel = this.extensions.get( 'KHR_parallel_shader_compile' );
84
245
 
85
- this._knownBindings = new WeakSet();
86
-
87
- this._currentContext = null;
88
-
89
246
  }
90
247
 
248
+ /**
249
+ * The coordinate system of the backend.
250
+ *
251
+ * @type {Number}
252
+ * @readonly
253
+ */
91
254
  get coordinateSystem() {
92
255
 
93
256
  return WebGLCoordinateSystem;
94
257
 
95
258
  }
96
259
 
260
+ /**
261
+ * Transfers buffer data from a storage buffer attribute
262
+ * from the GPU to the CPU in context of compute shaders.
263
+ *
264
+ * @async
265
+ * @param {StorageBufferAttribute} attribute - The storage buffer attribute.
266
+ * @return {Promise<ArrayBuffer>} A promise that resolves with the buffer data when the data are ready.
267
+ */
97
268
  async getArrayBufferAsync( attribute ) {
98
269
 
99
270
  return await this.attributeUtils.getArrayBufferAsync( attribute );
100
271
 
101
272
  }
102
273
 
274
+ /**
275
+ * Can be used to synchronize CPU operations with GPU tasks. So when this method is called,
276
+ * the CPU waits for the GPU to complete its operation (e.g. a compute task).
277
+ *
278
+ * @async
279
+ * @return {Promise} A Promise that resolves when synchronization has been finished.
280
+ */
103
281
  async waitForGPU() {
104
282
 
105
283
  await this.utils._clientWaitAsync();
106
284
 
107
285
  }
108
286
 
287
+ /**
288
+ * Inits a time stamp query for the given render context.
289
+ *
290
+ * @param {RenderContext} renderContext - The render context.
291
+ */
109
292
  initTimestampQuery( renderContext ) {
110
293
 
111
294
  if ( ! this.disjoint || ! this.trackTimestamp ) return;
@@ -140,6 +323,11 @@ class WebGLBackend extends Backend {
140
323
 
141
324
  // timestamp utils
142
325
 
326
+ /**
327
+ * Prepares the timestamp buffer.
328
+ *
329
+ * @param {RenderContext} renderContext - The render context.
330
+ */
143
331
  prepareTimestampBuffer( renderContext ) {
144
332
 
145
333
  if ( ! this.disjoint || ! this.trackTimestamp ) return;
@@ -166,6 +354,14 @@ class WebGLBackend extends Backend {
166
354
 
167
355
  }
168
356
 
357
+ /**
358
+ * Resolves the time stamp for the given render context and type.
359
+ *
360
+ * @async
361
+ * @param {RenderContext} renderContext - The render context.
362
+ * @param {String} type - The render context.
363
+ * @return {Promise} A Promise that resolves when the time stamp has been computed.
364
+ */
169
365
  async resolveTimestampAsync( renderContext, type = 'render' ) {
170
366
 
171
367
  if ( ! this.disjoint || ! this.trackTimestamp ) return;
@@ -195,12 +391,23 @@ class WebGLBackend extends Backend {
195
391
 
196
392
  }
197
393
 
394
+ /**
395
+ * Returns the backend's rendering context.
396
+ *
397
+ * @return {WebGL2RenderingContext} The rendering context.
398
+ */
198
399
  getContext() {
199
400
 
200
401
  return this.gl;
201
402
 
202
403
  }
203
404
 
405
+ /**
406
+ * This method is executed at the beginning of a render call and prepares
407
+ * the WebGL state for upcoming render calls
408
+ *
409
+ * @param {RenderContext} renderContext - The render context.
410
+ */
204
411
  beginRender( renderContext ) {
205
412
 
206
413
  const { gl } = this;
@@ -256,6 +463,12 @@ class WebGLBackend extends Backend {
256
463
 
257
464
  }
258
465
 
466
+ /**
467
+ * This method is executed at the end of a render call and finalizes work
468
+ * after draw calls.
469
+ *
470
+ * @param {RenderContext} renderContext - The render context.
471
+ */
259
472
  finishRender( renderContext ) {
260
473
 
261
474
  const { gl, state } = this;
@@ -362,6 +575,13 @@ class WebGLBackend extends Backend {
362
575
 
363
576
  }
364
577
 
578
+ /**
579
+ * This method processes the result of occlusion queries and writes it
580
+ * into render context data.
581
+ *
582
+ * @async
583
+ * @param {RenderContext} renderContext - The render context.
584
+ */
365
585
  resolveOccludedAsync( renderContext ) {
366
586
 
367
587
  const renderContextData = this.get( renderContext );
@@ -420,6 +640,14 @@ class WebGLBackend extends Backend {
420
640
 
421
641
  }
422
642
 
643
+ /**
644
+ * Returns `true` if the given 3D object is fully occluded by other
645
+ * 3D objects in the scene.
646
+ *
647
+ * @param {RenderContext} renderContext - The render context.
648
+ * @param {Object3D} object - The 3D object to test.
649
+ * @return {Boolean} Whether the 3D object is fully occluded or not.
650
+ */
423
651
  isOccluded( renderContext, object ) {
424
652
 
425
653
  const renderContextData = this.get( renderContext );
@@ -428,6 +656,11 @@ class WebGLBackend extends Backend {
428
656
 
429
657
  }
430
658
 
659
+ /**
660
+ * Updates the viewport with the values from the given render context.
661
+ *
662
+ * @param {RenderContext} renderContext - The render context.
663
+ */
431
664
  updateViewport( renderContext ) {
432
665
 
433
666
  const gl = this.gl;
@@ -437,6 +670,11 @@ class WebGLBackend extends Backend {
437
670
 
438
671
  }
439
672
 
673
+ /**
674
+ * Defines the scissor test.
675
+ *
676
+ * @param {Boolean} boolean - Whether the scissor test should be enabled or not.
677
+ */
440
678
  setScissorTest( boolean ) {
441
679
 
442
680
  const gl = this.gl;
@@ -453,6 +691,15 @@ class WebGLBackend extends Backend {
453
691
 
454
692
  }
455
693
 
694
+ /**
695
+ * Performs a clear operation.
696
+ *
697
+ * @param {Boolean} color - Whether the color buffer should be cleared or not.
698
+ * @param {Boolean} depth - Whether the depth buffer should be cleared or not.
699
+ * @param {Boolean} stencil - Whether the stencil buffer should be cleared or not.
700
+ * @param {Object?} [descriptor=null] - The render context of the current set render target.
701
+ * @param {Boolean} [setFrameBuffer=true] - TODO.
702
+ */
456
703
  clear( color, depth, stencil, descriptor = null, setFrameBuffer = true ) {
457
704
 
458
705
  const { gl } = this;
@@ -543,6 +790,12 @@ class WebGLBackend extends Backend {
543
790
 
544
791
  }
545
792
 
793
+ /**
794
+ * This method is executed at the beginning of a compute call and
795
+ * prepares the state for upcoming compute tasks.
796
+ *
797
+ * @param {Node|Array<Node>} computeGroup - The compute node(s).
798
+ */
546
799
  beginCompute( computeGroup ) {
547
800
 
548
801
  const { state, gl } = this;
@@ -552,11 +805,19 @@ class WebGLBackend extends Backend {
552
805
 
553
806
  }
554
807
 
808
+ /**
809
+ * Executes a compute command for the given compute node.
810
+ *
811
+ * @param {Node|Array<Node>} computeGroup - The group of compute nodes of a compute call. Can be a single compute node.
812
+ * @param {Node} computeNode - The compute node.
813
+ * @param {Array<BindGroup>} bindings - The bindings.
814
+ * @param {ComputePipeline} pipeline - The compute pipeline.
815
+ */
555
816
  compute( computeGroup, computeNode, bindings, pipeline ) {
556
817
 
557
818
  const { state, gl } = this;
558
819
 
559
- if ( ! this.discard ) {
820
+ if ( this.discard === false ) {
560
821
 
561
822
  // required here to handle async behaviour of render.compute()
562
823
  gl.enable( gl.RASTERIZER_DISCARD );
@@ -621,6 +882,12 @@ class WebGLBackend extends Backend {
621
882
 
622
883
  }
623
884
 
885
+ /**
886
+ * This method is executed at the end of a compute call and
887
+ * finalizes work after compute tasks.
888
+ *
889
+ * @param {Node|Array<Node>} computeGroup - The compute node(s).
890
+ */
624
891
  finishCompute( computeGroup ) {
625
892
 
626
893
  const gl = this.gl;
@@ -639,6 +906,12 @@ class WebGLBackend extends Backend {
639
906
 
640
907
  }
641
908
 
909
+ /**
910
+ * Executes a draw command for the given render object.
911
+ *
912
+ * @param {RenderObject} renderObject - The render object to draw.
913
+ * @param {Info} info - Holds a series of statistical information about the GPU memory and the rendering process.
914
+ */
642
915
  draw( renderObject/*, info*/ ) {
643
916
 
644
917
  const { object, pipeline, material, context, hardwareClippingPlanes } = renderObject;
@@ -801,12 +1074,24 @@ class WebGLBackend extends Backend {
801
1074
 
802
1075
  }
803
1076
 
1077
+ /**
1078
+ * Explain why always null is returned.
1079
+ *
1080
+ * @param {RenderObject} renderObject - The render object.
1081
+ * @return {Boolean} Whether the render pipeline requires an update or not.
1082
+ */
804
1083
  needsRenderUpdate( /*renderObject*/ ) {
805
1084
 
806
1085
  return false;
807
1086
 
808
1087
  }
809
1088
 
1089
+ /**
1090
+ * Explain why no cache key is computed.
1091
+ *
1092
+ * @param {RenderObject} renderObject - The render object.
1093
+ * @return {String} The cache key.
1094
+ */
810
1095
  getRenderCacheKey( /*renderObject*/ ) {
811
1096
 
812
1097
  return '';
@@ -815,53 +1100,108 @@ class WebGLBackend extends Backend {
815
1100
 
816
1101
  // textures
817
1102
 
1103
+ /**
1104
+ * Creates a default texture for the given texture that can be used
1105
+ * as a placeholder until the actual texture is ready for usage.
1106
+ *
1107
+ * @param {Texture} texture - The texture to create a default texture for.
1108
+ */
818
1109
  createDefaultTexture( texture ) {
819
1110
 
820
1111
  this.textureUtils.createDefaultTexture( texture );
821
1112
 
822
1113
  }
823
1114
 
1115
+ /**
1116
+ * Defines a texture on the GPU for the given texture object.
1117
+ *
1118
+ * @param {Texture} texture - The texture.
1119
+ * @param {Object} [options={}] - Optional configuration parameter.
1120
+ */
824
1121
  createTexture( texture, options ) {
825
1122
 
826
1123
  this.textureUtils.createTexture( texture, options );
827
1124
 
828
1125
  }
829
1126
 
1127
+ /**
1128
+ * Uploads the updated texture data to the GPU.
1129
+ *
1130
+ * @param {Texture} texture - The texture.
1131
+ * @param {Object} [options={}] - Optional configuration parameter.
1132
+ */
830
1133
  updateTexture( texture, options ) {
831
1134
 
832
1135
  this.textureUtils.updateTexture( texture, options );
833
1136
 
834
1137
  }
835
1138
 
1139
+ /**
1140
+ * Generates mipmaps for the given texture
1141
+ *
1142
+ * @param {Texture} texture - The texture.
1143
+ */
836
1144
  generateMipmaps( texture ) {
837
1145
 
838
1146
  this.textureUtils.generateMipmaps( texture );
839
1147
 
840
1148
  }
841
1149
 
842
-
1150
+ /**
1151
+ * Destroys the GPU data for the given texture object.
1152
+ *
1153
+ * @param {Texture} texture - The texture.
1154
+ */
843
1155
  destroyTexture( texture ) {
844
1156
 
845
1157
  this.textureUtils.destroyTexture( texture );
846
1158
 
847
1159
  }
848
1160
 
1161
+ /**
1162
+ * Returns texture data as a typed array.
1163
+ *
1164
+ * @param {Texture} texture - The texture to copy.
1165
+ * @param {Number} x - The x coordinate of the copy origin.
1166
+ * @param {Number} y - The y coordinate of the copy origin.
1167
+ * @param {Number} width - The width of the copy.
1168
+ * @param {Number} height - The height of the copy.
1169
+ * @param {Number} faceIndex - The face index.
1170
+ * @return {TypedArray} The texture data as a typed array.
1171
+ */
849
1172
  copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
850
1173
 
851
1174
  return this.textureUtils.copyTextureToBuffer( texture, x, y, width, height, faceIndex );
852
1175
 
853
1176
  }
854
1177
 
1178
+ /**
1179
+ * This method does nothing since WebGL 2 has no concept of samplers.
1180
+ *
1181
+ * @param {Texture} texture - The texture to create the sampler for.
1182
+ */
855
1183
  createSampler( /*texture*/ ) {
856
1184
 
857
1185
  //console.warn( 'Abstract class.' );
858
1186
 
859
1187
  }
860
1188
 
861
- destroySampler() {}
1189
+ /**
1190
+ * This method does nothing since WebGL 2 has no concept of samplers.
1191
+ *
1192
+ * @param {Texture} texture - The texture to destroy the sampler for.
1193
+ */
1194
+ destroySampler( /*texture*/ ) {}
862
1195
 
863
1196
  // node builder
864
1197
 
1198
+ /**
1199
+ * Returns a node builder for the given render object.
1200
+ *
1201
+ * @param {RenderObject} object - The render object.
1202
+ * @param {Renderer} renderer - The renderer.
1203
+ * @return {GLSLNodeBuilder} The node builder.
1204
+ */
865
1205
  createNodeBuilder( object, renderer ) {
866
1206
 
867
1207
  return new GLSLNodeBuilder( object, renderer );
@@ -870,6 +1210,11 @@ class WebGLBackend extends Backend {
870
1210
 
871
1211
  // program
872
1212
 
1213
+ /**
1214
+ * Creates a shader program from the given programmable stage.
1215
+ *
1216
+ * @param {ProgrammableStage} program - The programmable stage.
1217
+ */
873
1218
  createProgram( program ) {
874
1219
 
875
1220
  const gl = this.gl;
@@ -886,12 +1231,23 @@ class WebGLBackend extends Backend {
886
1231
 
887
1232
  }
888
1233
 
889
- destroyProgram( /*program*/ ) {
1234
+ /**
1235
+ * Destroys the shader program of the given programmable stage.
1236
+ *
1237
+ * @param {ProgrammableStage} program - The programmable stage.
1238
+ */
1239
+ destroyProgram( program ) {
890
1240
 
891
- console.warn( 'Abstract class.' );
1241
+ this.delete( program );
892
1242
 
893
1243
  }
894
1244
 
1245
+ /**
1246
+ * Creates a render pipeline for the given render object.
1247
+ *
1248
+ * @param {RenderObject} renderObject - The render object.
1249
+ * @param {Array<Promise>} promises - An array of compilation promises which are used in `compileAsync()`.
1250
+ */
895
1251
  createRenderPipeline( renderObject, promises ) {
896
1252
 
897
1253
  const gl = this.gl;
@@ -950,6 +1306,14 @@ class WebGLBackend extends Backend {
950
1306
 
951
1307
  }
952
1308
 
1309
+ /**
1310
+ * Formats the source code of error messages.
1311
+ *
1312
+ * @private
1313
+ * @param {String} string - The code.
1314
+ * @param {Number} errorLine - The error line.
1315
+ * @return {String} The formatted code.
1316
+ */
953
1317
  _handleSource( string, errorLine ) {
954
1318
 
955
1319
  const lines = string.split( '\n' );
@@ -969,6 +1333,15 @@ class WebGLBackend extends Backend {
969
1333
 
970
1334
  }
971
1335
 
1336
+ /**
1337
+ * Gets the shader compilation errors from the info log.
1338
+ *
1339
+ * @private
1340
+ * @param {WebGL2RenderingContext} gl - The rendering context.
1341
+ * @param {WebGLShader} shader - The WebGL shader object.
1342
+ * @param {String} type - The shader type.
1343
+ * @return {String} The shader errors.
1344
+ */
972
1345
  _getShaderErrors( gl, shader, type ) {
973
1346
 
974
1347
  const status = gl.getShaderParameter( shader, gl.COMPILE_STATUS );
@@ -990,6 +1363,14 @@ class WebGLBackend extends Backend {
990
1363
 
991
1364
  }
992
1365
 
1366
+ /**
1367
+ * Logs shader compilation errors.
1368
+ *
1369
+ * @private
1370
+ * @param {WebGLProgram} programGPU - The WebGL program.
1371
+ * @param {WebGLShader} glFragmentShader - The fragment shader as a native WebGL shader object.
1372
+ * @param {WebGLShader} glVertexShader - The vertex shader as a native WebGL shader object.
1373
+ */
993
1374
  _logProgramError( programGPU, glFragmentShader, glVertexShader ) {
994
1375
 
995
1376
  if ( this.renderer.debug.checkShaderErrors ) {
@@ -1032,6 +1413,13 @@ class WebGLBackend extends Backend {
1032
1413
 
1033
1414
  }
1034
1415
 
1416
+ /**
1417
+ * Completes the shader program setup for the given render object.
1418
+ *
1419
+ * @private
1420
+ * @param {RenderObject} renderObject - The render object.
1421
+ * @param {RenderPipeline} pipeline - The render pipeline.
1422
+ */
1035
1423
  _completeCompile( renderObject, pipeline ) {
1036
1424
 
1037
1425
  const { state, gl } = this;
@@ -1060,6 +1448,12 @@ class WebGLBackend extends Backend {
1060
1448
 
1061
1449
  }
1062
1450
 
1451
+ /**
1452
+ * Creates a compute pipeline for the given compute node.
1453
+ *
1454
+ * @param {ComputePipeline} computePipeline - The compute pipeline.
1455
+ * @param {Array<BindGroup>} bindings - The bindings.
1456
+ */
1063
1457
  createComputePipeline( computePipeline, bindings ) {
1064
1458
 
1065
1459
  const { state, gl } = this;
@@ -1154,7 +1548,15 @@ class WebGLBackend extends Backend {
1154
1548
 
1155
1549
  }
1156
1550
 
1157
- createBindings( bindGroup, bindings ) {
1551
+ /**
1552
+ * Creates bindings from the given bind group definition.
1553
+ *
1554
+ * @param {BindGroup} bindGroup - The bind group.
1555
+ * @param {Array<BindGroup>} bindings - Array of bind groups.
1556
+ * @param {Number} cacheIndex - The cache index.
1557
+ * @param {Number} version - The version.
1558
+ */
1559
+ createBindings( bindGroup, bindings /*, cacheIndex, version*/ ) {
1158
1560
 
1159
1561
  if ( this._knownBindings.has( bindings ) === false ) {
1160
1562
 
@@ -1185,7 +1587,15 @@ class WebGLBackend extends Backend {
1185
1587
 
1186
1588
  }
1187
1589
 
1188
- updateBindings( bindGroup /*, bindings*/ ) {
1590
+ /**
1591
+ * Updates the given bind group definition.
1592
+ *
1593
+ * @param {BindGroup} bindGroup - The bind group.
1594
+ * @param {Array<BindGroup>} bindings - Array of bind groups.
1595
+ * @param {Number} cacheIndex - The cache index.
1596
+ * @param {Number} version - The version.
1597
+ */
1598
+ updateBindings( bindGroup /*, bindings, cacheIndex, version*/ ) {
1189
1599
 
1190
1600
  const { gl } = this;
1191
1601
 
@@ -1225,6 +1635,11 @@ class WebGLBackend extends Backend {
1225
1635
 
1226
1636
  }
1227
1637
 
1638
+ /**
1639
+ * Updates a buffer binding.
1640
+ *
1641
+ * @param {Buffer} binding - The buffer binding to update.
1642
+ */
1228
1643
  updateBinding( binding ) {
1229
1644
 
1230
1645
  const gl = this.gl;
@@ -1244,6 +1659,11 @@ class WebGLBackend extends Backend {
1244
1659
 
1245
1660
  // attributes
1246
1661
 
1662
+ /**
1663
+ * Creates the buffer of an indexed shader attribute.
1664
+ *
1665
+ * @param {BufferAttribute} attribute - The indexed buffer attribute.
1666
+ */
1247
1667
  createIndexAttribute( attribute ) {
1248
1668
 
1249
1669
  const gl = this.gl;
@@ -1252,6 +1672,11 @@ class WebGLBackend extends Backend {
1252
1672
 
1253
1673
  }
1254
1674
 
1675
+ /**
1676
+ * Creates the buffer of a shader attribute.
1677
+ *
1678
+ * @param {BufferAttribute} attribute - The buffer attribute.
1679
+ */
1255
1680
  createAttribute( attribute ) {
1256
1681
 
1257
1682
  if ( this.has( attribute ) ) return;
@@ -1262,6 +1687,11 @@ class WebGLBackend extends Backend {
1262
1687
 
1263
1688
  }
1264
1689
 
1690
+ /**
1691
+ * Creates the buffer of a storage attribute.
1692
+ *
1693
+ * @param {BufferAttribute} attribute - The buffer attribute.
1694
+ */
1265
1695
  createStorageAttribute( attribute ) {
1266
1696
 
1267
1697
  if ( this.has( attribute ) ) return;
@@ -1272,24 +1702,34 @@ class WebGLBackend extends Backend {
1272
1702
 
1273
1703
  }
1274
1704
 
1705
+ /**
1706
+ * Updates the buffer of a shader attribute.
1707
+ *
1708
+ * @param {BufferAttribute} attribute - The buffer attribute to update.
1709
+ */
1275
1710
  updateAttribute( attribute ) {
1276
1711
 
1277
1712
  this.attributeUtils.updateAttribute( attribute );
1278
1713
 
1279
1714
  }
1280
1715
 
1716
+ /**
1717
+ * Destroys the buffer of a shader attribute.
1718
+ *
1719
+ * @param {BufferAttribute} attribute - The buffer attribute to destroy.
1720
+ */
1281
1721
  destroyAttribute( attribute ) {
1282
1722
 
1283
1723
  this.attributeUtils.destroyAttribute( attribute );
1284
1724
 
1285
1725
  }
1286
1726
 
1287
- updateSize() {
1288
-
1289
- //console.warn( 'Abstract class.' );
1290
-
1291
- }
1292
-
1727
+ /**
1728
+ * Checks if the given feature is supported by the backend.
1729
+ *
1730
+ * @param {String} name - The feature's name.
1731
+ * @return {Boolean} Whether the feature is supported or not.
1732
+ */
1293
1733
  hasFeature( name ) {
1294
1734
 
1295
1735
  const keysMatching = Object.keys( GLFeatureName ).filter( key => GLFeatureName[ key ] === name );
@@ -1306,24 +1746,51 @@ class WebGLBackend extends Backend {
1306
1746
 
1307
1747
  }
1308
1748
 
1749
+ /**
1750
+ * Returns the maximum anisotropy texture filtering value.
1751
+ *
1752
+ * @return {Number} The maximum anisotropy texture filtering value.
1753
+ */
1309
1754
  getMaxAnisotropy() {
1310
1755
 
1311
1756
  return this.capabilities.getMaxAnisotropy();
1312
1757
 
1313
1758
  }
1314
1759
 
1315
- copyTextureToTexture( srcTexture, dstTexture, srcRegion, dstPosition, level ) {
1760
+ /**
1761
+ * Copies data of the given source texture to the given destination texture.
1762
+ *
1763
+ * @param {Texture} srcTexture - The source texture.
1764
+ * @param {Texture} dstTexture - The destination texture.
1765
+ * @param {Vector4?} [srcRegion=null] - The region of the source texture to copy.
1766
+ * @param {(Vector2|Vector3)?} [dstPosition=null] - The destination position of the copy.
1767
+ * @param {Number} [level=0] - The mip level to copy.
1768
+ */
1769
+ copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
1316
1770
 
1317
1771
  this.textureUtils.copyTextureToTexture( srcTexture, dstTexture, srcRegion, dstPosition, level );
1318
1772
 
1319
1773
  }
1320
1774
 
1775
+ /**
1776
+ * Copies the current bound framebuffer to the given texture.
1777
+ *
1778
+ * @param {Texture} texture - The destination texture.
1779
+ * @param {RenderContext} renderContext - The render context.
1780
+ * @param {Vector4} rectangle - A four dimensional vector defining the origin and dimension of the copy.
1781
+ */
1321
1782
  copyFramebufferToTexture( texture, renderContext, rectangle ) {
1322
1783
 
1323
1784
  this.textureUtils.copyFramebufferToTexture( texture, renderContext, rectangle );
1324
1785
 
1325
1786
  }
1326
1787
 
1788
+ /**
1789
+ * Configures the active framebuffer from the given render context.
1790
+ *
1791
+ * @private
1792
+ * @param {RenderContext} descriptor - The render context.
1793
+ */
1327
1794
  _setFramebuffer( descriptor ) {
1328
1795
 
1329
1796
  const { gl, state } = this;
@@ -1337,6 +1804,8 @@ class WebGLBackend extends Backend {
1337
1804
  const { samples, depthBuffer, stencilBuffer } = renderTarget;
1338
1805
 
1339
1806
  const isCube = renderTarget.isWebGLCubeRenderTarget === true;
1807
+ const isRenderTarget3D = renderTarget.isRenderTarget3D === true;
1808
+ const isRenderTargetArray = renderTarget.isRenderTargetArray === true;
1340
1809
 
1341
1810
  let msaaFb = renderTargetContextData.msaaFrameBuffer;
1342
1811
  let depthRenderbuffer = renderTargetContextData.depthRenderbuffer;
@@ -1390,7 +1859,19 @@ class WebGLBackend extends Backend {
1390
1859
 
1391
1860
  const attachment = gl.COLOR_ATTACHMENT0 + i;
1392
1861
 
1393
- gl.framebufferTexture2D( gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureData.textureGPU, 0 );
1862
+ if ( isRenderTarget3D || isRenderTargetArray ) {
1863
+
1864
+ const layer = this.renderer._activeCubeFace;
1865
+
1866
+ gl.framebufferTextureLayer( gl.FRAMEBUFFER, attachment, textureData.textureGPU, 0, layer );
1867
+
1868
+ } else {
1869
+
1870
+ gl.framebufferTexture2D( gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureData.textureGPU, 0 );
1871
+
1872
+ }
1873
+
1874
+
1394
1875
 
1395
1876
  }
1396
1877
 
@@ -1482,10 +1963,17 @@ class WebGLBackend extends Backend {
1482
1963
 
1483
1964
  }
1484
1965
 
1485
-
1966
+ /**
1967
+ * Computes the VAO key for the given index and attributes.
1968
+ *
1969
+ * @private
1970
+ * @param {BufferAttribute?} index - The index. `null` for non-indexed geometries.
1971
+ * @param {Array<BufferAttribute>} attributes - An array of buffer attributes.
1972
+ * @return {String} The VAO key.
1973
+ */
1486
1974
  _getVaoKey( index, attributes ) {
1487
1975
 
1488
- let key = [];
1976
+ let key = '';
1489
1977
 
1490
1978
  if ( index !== null ) {
1491
1979
 
@@ -1507,6 +1995,14 @@ class WebGLBackend extends Backend {
1507
1995
 
1508
1996
  }
1509
1997
 
1998
+ /**
1999
+ * Creates a VAO from the index and attributes.
2000
+ *
2001
+ * @private
2002
+ * @param {BufferAttribute?} index - The index. `null` for non-indexed geometries.
2003
+ * @param {Array<BufferAttribute>} attributes - An array of buffer attributes.
2004
+ * @return {Object} The VAO data.
2005
+ */
1510
2006
  _createVao( index, attributes ) {
1511
2007
 
1512
2008
  const { gl } = this;
@@ -1584,6 +2080,13 @@ class WebGLBackend extends Backend {
1584
2080
 
1585
2081
  }
1586
2082
 
2083
+ /**
2084
+ * Creates a tranform feedback from the given transform buffers.
2085
+ *
2086
+ * @private
2087
+ * @param {Array<DualAttributeData>} transformBuffers - The tranform buffers.
2088
+ * @return {WebGLTransformFeedback} The tranform feedback.
2089
+ */
1587
2090
  _getTransformFeedback( transformBuffers ) {
1588
2091
 
1589
2092
  let key = '';
@@ -1624,7 +2127,13 @@ class WebGLBackend extends Backend {
1624
2127
 
1625
2128
  }
1626
2129
 
1627
-
2130
+ /**
2131
+ * Setups the given bindings.
2132
+ *
2133
+ * @private
2134
+ * @param {Array<BindGroup>} bindings - The bindings.
2135
+ * @param {WebGLProgram} programGPU - The WebGL program.
2136
+ */
1628
2137
  _setupBindings( bindings, programGPU ) {
1629
2138
 
1630
2139
  const gl = this.gl;
@@ -1654,6 +2163,12 @@ class WebGLBackend extends Backend {
1654
2163
 
1655
2164
  }
1656
2165
 
2166
+ /**
2167
+ * Binds the given uniforms.
2168
+ *
2169
+ * @private
2170
+ * @param {Array<BindGroup>} bindings - The bindings.
2171
+ */
1657
2172
  _bindUniforms( bindings ) {
1658
2173
 
1659
2174
  const { gl, state } = this;
@@ -1682,6 +2197,9 @@ class WebGLBackend extends Backend {
1682
2197
 
1683
2198
  }
1684
2199
 
2200
+ /**
2201
+ * Frees internal resources.
2202
+ */
1685
2203
  dispose() {
1686
2204
 
1687
2205
  this.renderer.domElement.removeEventListener( 'webglcontextlost', this._onContextLost );