super-three 0.167.0 → 0.169.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 (387) hide show
  1. package/build/three.cjs +532 -173
  2. package/build/three.module.js +532 -174
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +18173 -14266
  5. package/build/three.webgpu.min.js +1 -1
  6. package/build/three.webgpu.nodes.js +79941 -0
  7. package/build/three.webgpu.nodes.min.js +6 -0
  8. package/examples/jsm/Addons.js +0 -4
  9. package/examples/jsm/animation/AnimationClipCreator.js +1 -1
  10. package/examples/jsm/capabilities/WebGL.js +27 -21
  11. package/examples/jsm/controls/ArcballControls.js +174 -158
  12. package/examples/jsm/controls/DragControls.js +260 -132
  13. package/examples/jsm/controls/FirstPersonControls.js +175 -163
  14. package/examples/jsm/controls/FlyControls.js +194 -188
  15. package/examples/jsm/controls/OrbitControls.js +777 -786
  16. package/examples/jsm/controls/PointerLockControls.js +24 -15
  17. package/examples/jsm/controls/TrackballControls.js +469 -448
  18. package/examples/jsm/controls/TransformControls.js +97 -62
  19. package/examples/jsm/effects/AnaglyphEffect.js +6 -13
  20. package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
  21. package/examples/jsm/effects/StereoEffect.js +6 -1
  22. package/examples/jsm/environments/RoomEnvironment.js +1 -1
  23. package/examples/jsm/exporters/DRACOExporter.js +4 -2
  24. package/examples/jsm/exporters/EXRExporter.js +19 -11
  25. package/examples/jsm/exporters/GLTFExporter.js +6 -1
  26. package/examples/jsm/exporters/KTX2Exporter.js +21 -13
  27. package/examples/jsm/exporters/OBJExporter.js +5 -1
  28. package/examples/jsm/exporters/PLYExporter.js +9 -7
  29. package/examples/jsm/exporters/USDZExporter.js +29 -8
  30. package/examples/jsm/geometries/DecalGeometry.js +4 -1
  31. package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
  32. package/examples/jsm/helpers/LightProbeHelper.js +43 -44
  33. package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
  34. package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
  35. package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
  36. package/examples/jsm/libs/ktx-parse.module.js +1 -1
  37. package/examples/jsm/lights/LightProbeGenerator.js +24 -10
  38. package/examples/jsm/loaders/ColladaLoader.js +9 -6
  39. package/examples/jsm/loaders/DRACOLoader.js +3 -1
  40. package/examples/jsm/loaders/FBXLoader.js +30 -20
  41. package/examples/jsm/loaders/GLTFLoader.js +5 -10
  42. package/examples/jsm/loaders/KTX2Loader.js +27 -12
  43. package/examples/jsm/loaders/MTLLoader.js +4 -3
  44. package/examples/jsm/loaders/MaterialXLoader.js +40 -14
  45. package/examples/jsm/loaders/OBJLoader.js +5 -3
  46. package/examples/jsm/loaders/PCDLoader.js +14 -13
  47. package/examples/jsm/loaders/PDBLoader.js +3 -2
  48. package/examples/jsm/loaders/PLYLoader.js +8 -5
  49. package/examples/jsm/loaders/STLLoader.js +3 -2
  50. package/examples/jsm/loaders/VRMLLoader.js +10 -10
  51. package/examples/jsm/loaders/VTKLoader.js +4 -3
  52. package/examples/jsm/loaders/XYZLoader.js +3 -2
  53. package/examples/jsm/misc/Timer.js +1 -1
  54. package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
  55. package/examples/jsm/objects/LensflareMesh.js +322 -0
  56. package/examples/jsm/objects/SkyMesh.js +187 -0
  57. package/examples/jsm/objects/Water2Mesh.js +158 -0
  58. package/examples/jsm/objects/WaterMesh.js +101 -0
  59. package/examples/jsm/physics/JoltPhysics.js +1 -1
  60. package/examples/jsm/physics/RapierPhysics.js +21 -1
  61. package/examples/jsm/postprocessing/OutlinePass.js +31 -46
  62. package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
  63. package/examples/jsm/shaders/BleachBypassShader.js +1 -2
  64. package/examples/jsm/shaders/OutputShader.js +1 -1
  65. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  66. package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
  67. package/examples/jsm/transpiler/TSLEncoder.js +8 -8
  68. package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
  69. package/examples/jsm/utils/ShadowMapViewer.js +3 -8
  70. package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
  71. package/examples/jsm/utils/SkeletonUtils.js +84 -66
  72. package/examples/jsm/utils/TextureUtils.js +2 -1
  73. package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
  74. package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
  75. package/package.json +3 -2
  76. package/src/Three.WebGPU.Nodes.js +200 -0
  77. package/src/Three.WebGPU.js +7 -0
  78. package/src/Three.js +1 -0
  79. package/src/audio/Audio.js +2 -2
  80. package/src/constants.js +1 -1
  81. package/src/core/BufferAttribute.js +0 -9
  82. package/src/core/Clock.js +1 -1
  83. package/src/core/InterleavedBuffer.js +0 -9
  84. package/src/extras/Controls.js +32 -0
  85. package/src/geometries/CylinderGeometry.js +11 -4
  86. package/src/loaders/MaterialLoader.js +7 -1
  87. package/src/loaders/ObjectLoader.js +3 -3
  88. package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +25 -5
  89. package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +21 -18
  90. package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +19 -0
  91. package/src/materials/Material.js +4 -7
  92. package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
  93. package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +56 -59
  94. package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +8 -5
  95. package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +12 -10
  96. package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +16 -12
  97. package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +10 -6
  98. package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +13 -9
  99. package/src/{nodes/materials → materials/nodes}/MeshNormalNodeMaterial.js +13 -9
  100. package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +14 -9
  101. package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +22 -18
  102. package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +10 -7
  103. package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +22 -12
  104. package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +9 -5
  105. package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +71 -115
  106. package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +3 -1
  107. package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +8 -5
  108. package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +9 -5
  109. package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +47 -14
  110. package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +24 -22
  111. package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
  112. package/src/math/Triangle.js +24 -0
  113. package/src/nodes/Nodes.js +103 -159
  114. package/src/nodes/TSL.js +179 -0
  115. package/src/nodes/accessors/AccessorsUtils.js +8 -8
  116. package/src/nodes/accessors/BatchNode.js +53 -21
  117. package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
  118. package/src/nodes/accessors/BufferAttributeNode.js +8 -5
  119. package/src/nodes/accessors/BufferNode.js +7 -4
  120. package/src/nodes/accessors/Camera.js +13 -0
  121. package/src/nodes/accessors/ClippingNode.js +19 -13
  122. package/src/nodes/accessors/CubeTextureNode.js +9 -8
  123. package/src/nodes/accessors/InstanceNode.js +19 -15
  124. package/src/nodes/accessors/InstancedPointsMaterialNode.js +8 -5
  125. package/src/nodes/accessors/Lights.js +51 -0
  126. package/src/nodes/accessors/MaterialNode.js +56 -55
  127. package/src/nodes/accessors/MaterialProperties.js +3 -0
  128. package/src/nodes/accessors/MaterialReferenceNode.js +9 -4
  129. package/src/nodes/accessors/ModelNode.js +47 -12
  130. package/src/nodes/accessors/ModelViewProjectionNode.js +12 -9
  131. package/src/nodes/accessors/MorphNode.js +17 -13
  132. package/src/nodes/accessors/Normal.js +88 -0
  133. package/src/nodes/accessors/Object3DNode.js +17 -33
  134. package/src/nodes/accessors/PointUVNode.js +9 -5
  135. package/src/nodes/accessors/Position.js +10 -0
  136. package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
  137. package/src/nodes/accessors/ReferenceNode.js +50 -7
  138. package/src/nodes/accessors/ReflectVector.js +10 -0
  139. package/src/nodes/accessors/RendererReferenceNode.js +12 -6
  140. package/src/nodes/accessors/SceneNode.js +9 -6
  141. package/src/nodes/accessors/SkinningNode.js +88 -21
  142. package/src/nodes/accessors/StorageBufferNode.js +22 -5
  143. package/src/nodes/accessors/StorageTextureNode.js +9 -6
  144. package/src/nodes/accessors/Tangent.js +22 -0
  145. package/src/nodes/accessors/Texture3DNode.js +16 -13
  146. package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
  147. package/src/nodes/accessors/TextureNode.js +29 -23
  148. package/src/nodes/accessors/TextureSizeNode.js +10 -9
  149. package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +26 -14
  150. package/src/nodes/accessors/UserDataNode.js +10 -7
  151. package/src/nodes/accessors/VelocityNode.js +134 -0
  152. package/src/nodes/accessors/VertexColorNode.js +7 -4
  153. package/src/nodes/code/CodeNode.js +9 -5
  154. package/src/nodes/code/ExpressionNode.js +10 -6
  155. package/src/nodes/code/FunctionCallNode.js +8 -5
  156. package/src/nodes/code/FunctionNode.js +8 -23
  157. package/src/nodes/code/ScriptableNode.js +13 -10
  158. package/src/nodes/code/ScriptableValueNode.js +9 -7
  159. package/src/nodes/core/AssignNode.js +12 -9
  160. package/src/nodes/core/AttributeNode.js +12 -21
  161. package/src/nodes/core/BypassNode.js +11 -7
  162. package/src/nodes/core/CacheNode.js +10 -6
  163. package/src/nodes/core/ConstNode.js +6 -3
  164. package/src/nodes/core/ContextNode.js +21 -11
  165. package/src/nodes/core/IndexNode.js +35 -8
  166. package/src/nodes/core/InputNode.js +7 -3
  167. package/src/nodes/core/MRTNode.js +16 -7
  168. package/src/nodes/core/Node.js +19 -40
  169. package/src/nodes/core/NodeBuilder.js +117 -38
  170. package/src/nodes/core/NodeUtils.js +49 -6
  171. package/src/nodes/core/OutputStructNode.js +10 -6
  172. package/src/nodes/core/ParameterNode.js +7 -4
  173. package/src/nodes/core/PropertyNode.js +36 -32
  174. package/src/nodes/core/StackNode.js +31 -11
  175. package/src/nodes/core/StructTypeNode.js +7 -3
  176. package/src/nodes/core/TempNode.js +8 -4
  177. package/src/nodes/core/UniformGroupNode.js +14 -11
  178. package/src/nodes/core/UniformNode.js +7 -4
  179. package/src/nodes/core/VarNode.js +12 -8
  180. package/src/nodes/core/VaryingNode.js +10 -6
  181. package/src/nodes/display/AfterImageNode.js +15 -9
  182. package/src/nodes/display/AnaglyphPassNode.js +67 -0
  183. package/src/nodes/display/AnamorphicNode.js +17 -11
  184. package/src/nodes/display/BleachBypass.js +26 -0
  185. package/src/nodes/display/BlendMode.js +54 -0
  186. package/src/nodes/display/BloomNode.js +27 -19
  187. package/src/nodes/display/BumpMapNode.js +13 -12
  188. package/src/nodes/display/ColorAdjustment.js +46 -0
  189. package/src/nodes/display/ColorSpaceFunctions.js +38 -0
  190. package/src/nodes/display/ColorSpaceNode.js +67 -61
  191. package/src/nodes/display/DenoiseNode.js +23 -17
  192. package/src/nodes/display/DepthOfFieldNode.js +12 -7
  193. package/src/nodes/display/DotScreenNode.js +13 -22
  194. package/src/nodes/display/FXAANode.js +21 -16
  195. package/src/nodes/display/FilmNode.js +11 -7
  196. package/src/nodes/display/FrontFacingNode.js +10 -6
  197. package/src/nodes/display/GTAONode.js +22 -15
  198. package/src/nodes/display/GaussianBlurNode.js +14 -8
  199. package/src/nodes/display/Lut3DNode.js +10 -6
  200. package/src/nodes/display/MotionBlur.js +25 -0
  201. package/src/nodes/display/NormalMapNode.js +13 -13
  202. package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
  203. package/src/nodes/display/PassNode.js +95 -8
  204. package/src/nodes/display/PixelationPassNode.js +20 -8
  205. package/src/nodes/display/PosterizeNode.js +8 -7
  206. package/src/nodes/display/RGBShiftNode.js +11 -7
  207. package/src/nodes/display/RenderOutputNode.js +15 -11
  208. package/src/nodes/display/SSAAPassNode.js +287 -0
  209. package/src/nodes/display/ScreenNode.js +181 -0
  210. package/src/nodes/display/Sepia.js +17 -0
  211. package/src/nodes/display/SobelOperatorNode.js +13 -8
  212. package/src/nodes/display/StereoCompositePassNode.js +110 -0
  213. package/src/nodes/display/StereoPassNode.js +83 -0
  214. package/src/nodes/display/ToneMappingFunctions.js +190 -0
  215. package/src/nodes/display/ToneMappingNode.js +15 -175
  216. package/src/nodes/display/ToonOutlinePassNode.js +111 -0
  217. package/src/nodes/display/TransitionNode.js +12 -8
  218. package/src/nodes/display/ViewportDepthNode.js +34 -29
  219. package/src/nodes/display/ViewportDepthTextureNode.js +10 -9
  220. package/src/nodes/display/ViewportSharedTextureNode.js +10 -9
  221. package/src/nodes/display/ViewportTextureNode.js +11 -11
  222. package/src/nodes/fog/FogExp2Node.js +8 -7
  223. package/src/nodes/fog/FogNode.js +10 -8
  224. package/src/nodes/fog/FogRangeNode.js +8 -7
  225. package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
  226. package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  227. package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
  228. package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
  229. package/src/nodes/functions/BSDF/D_GGX.js +2 -2
  230. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
  231. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
  232. package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
  233. package/src/nodes/functions/BSDF/LTC.js +6 -6
  234. package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
  235. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
  236. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
  237. package/src/nodes/functions/BasicLightingModel.js +1 -1
  238. package/src/nodes/functions/PhongLightingModel.js +5 -5
  239. package/src/nodes/functions/PhysicalLightingModel.js +34 -33
  240. package/src/nodes/functions/ShadowMaskModel.js +1 -1
  241. package/src/nodes/functions/ToonLightingModel.js +3 -3
  242. package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
  243. package/src/nodes/functions/material/getRoughness.js +2 -2
  244. package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
  245. package/src/nodes/geometry/RangeNode.js +9 -5
  246. package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
  247. package/src/nodes/gpgpu/BarrierNode.js +40 -0
  248. package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
  249. package/src/nodes/gpgpu/ComputeNode.js +10 -6
  250. package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
  251. package/src/nodes/lighting/AONode.js +6 -3
  252. package/src/nodes/lighting/AmbientLightNode.js +6 -8
  253. package/src/nodes/lighting/AnalyticLightNode.js +225 -36
  254. package/src/nodes/lighting/BasicEnvironmentNode.js +8 -4
  255. package/src/nodes/lighting/BasicLightMapNode.js +7 -4
  256. package/src/nodes/lighting/DirectionalLightNode.js +7 -9
  257. package/src/nodes/lighting/EnvironmentNode.js +23 -19
  258. package/src/nodes/lighting/HemisphereLightNode.js +11 -11
  259. package/src/nodes/lighting/IESSpotLightNode.js +7 -9
  260. package/src/nodes/lighting/IrradianceNode.js +6 -3
  261. package/src/nodes/lighting/LightProbeNode.js +53 -0
  262. package/src/nodes/lighting/LightUtils.js +3 -3
  263. package/src/nodes/lighting/LightingContextNode.js +19 -18
  264. package/src/nodes/lighting/LightingNode.js +7 -3
  265. package/src/nodes/lighting/LightsNode.js +112 -75
  266. package/src/nodes/lighting/PointLightNode.js +12 -13
  267. package/src/nodes/lighting/RectAreaLightNode.js +11 -11
  268. package/src/nodes/lighting/SpotLightNode.js +14 -16
  269. package/src/nodes/materialx/MaterialXNodes.js +2 -2
  270. package/src/nodes/materialx/lib/mx_hsv.js +36 -31
  271. package/src/nodes/materialx/lib/mx_noise.js +96 -96
  272. package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
  273. package/src/nodes/math/{CondNode.js → ConditionalNode.js} +38 -10
  274. package/src/nodes/math/Hash.js +13 -0
  275. package/src/nodes/math/MathNode.js +127 -124
  276. package/src/nodes/math/MathUtils.js +0 -7
  277. package/src/nodes/math/OperatorNode.js +97 -52
  278. package/src/nodes/math/TriNoise3D.js +19 -29
  279. package/src/nodes/pmrem/PMREMNode.js +61 -15
  280. package/src/nodes/pmrem/PMREMUtils.js +46 -46
  281. package/src/nodes/procedural/Checker.js +14 -0
  282. package/src/nodes/tsl/TSLBase.js +30 -0
  283. package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
  284. package/src/nodes/utils/ArrayElementNode.js +8 -4
  285. package/src/nodes/utils/ConvertNode.js +7 -3
  286. package/src/nodes/utils/CubeMapNode.js +160 -0
  287. package/src/nodes/utils/Discard.js +8 -0
  288. package/src/nodes/utils/EquirectUVNode.js +9 -6
  289. package/src/nodes/utils/FlipNode.js +68 -0
  290. package/src/nodes/utils/FunctionOverloadingNode.js +9 -5
  291. package/src/nodes/utils/JoinNode.js +6 -3
  292. package/src/nodes/utils/LoopNode.js +16 -6
  293. package/src/nodes/utils/MatcapUVNode.js +10 -7
  294. package/src/nodes/utils/MaxMipLevelNode.js +8 -5
  295. package/src/nodes/utils/OscNode.js +12 -8
  296. package/src/nodes/utils/Packing.js +4 -0
  297. package/src/nodes/utils/RTTNode.js +11 -8
  298. package/src/nodes/utils/ReflectorNode.js +12 -4
  299. package/src/nodes/utils/RemapNode.js +12 -8
  300. package/src/nodes/utils/RotateNode.js +8 -13
  301. package/src/nodes/utils/SetNode.js +7 -4
  302. package/src/nodes/utils/SplitNode.js +7 -3
  303. package/src/nodes/utils/SpriteSheetUVNode.js +10 -6
  304. package/src/nodes/utils/SpriteUtils.js +47 -0
  305. package/src/nodes/utils/StorageArrayElementNode.js +11 -12
  306. package/src/nodes/utils/TimerNode.js +8 -5
  307. package/src/nodes/utils/TriplanarTexturesNode.js +11 -9
  308. package/src/nodes/utils/UVUtils.js +19 -0
  309. package/src/nodes/utils/ViewportUtils.js +14 -0
  310. package/src/objects/BatchedMesh.js +78 -13
  311. package/src/objects/LOD.js +21 -0
  312. package/src/objects/Line.js +1 -0
  313. package/src/objects/Mesh.js +7 -23
  314. package/src/objects/Points.js +2 -0
  315. package/src/renderers/WebGLRenderer.js +88 -41
  316. package/src/renderers/common/Backend.js +2 -2
  317. package/src/renderers/common/Background.js +3 -1
  318. package/src/renderers/common/BindGroup.js +3 -1
  319. package/src/renderers/common/Bindings.js +13 -15
  320. package/src/renderers/common/BundleGroup.js +26 -0
  321. package/src/renderers/common/ClippingContext.js +15 -5
  322. package/src/renderers/common/CubeRenderTarget.js +9 -3
  323. package/src/renderers/common/PostProcessing.js +4 -1
  324. package/src/renderers/common/QuadMesh.js +2 -0
  325. package/src/renderers/common/RenderContext.js +23 -0
  326. package/src/renderers/common/RenderList.js +1 -1
  327. package/src/renderers/common/RenderObject.js +117 -6
  328. package/src/renderers/common/RenderObjects.js +8 -1
  329. package/src/renderers/common/Renderer.js +128 -94
  330. package/src/renderers/common/SampledTexture.js +12 -3
  331. package/src/renderers/common/Textures.js +8 -12
  332. package/src/renderers/common/extras/PMREMGenerator.js +19 -22
  333. package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
  334. package/src/renderers/common/nodes/NodeLibrary.js +118 -0
  335. package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
  336. package/src/renderers/common/nodes/Nodes.js +65 -19
  337. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
  338. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
  339. package/src/renderers/webgl/WebGLAttributes.js +45 -14
  340. package/src/renderers/webgl/WebGLCapabilities.js +9 -0
  341. package/src/renderers/webgl/WebGLProgram.js +3 -1
  342. package/src/renderers/webgl/WebGLPrograms.js +21 -17
  343. package/src/renderers/webgl/WebGLProperties.js +7 -0
  344. package/src/renderers/webgl/WebGLState.js +21 -0
  345. package/src/renderers/webgl/WebGLTextures.js +83 -4
  346. package/src/renderers/webgl-fallback/WebGLBackend.js +135 -110
  347. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +60 -12
  348. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
  349. package/src/renderers/webgl-fallback/utils/WebGLState.js +20 -2
  350. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +89 -37
  351. package/src/renderers/webgpu/WebGPUBackend.js +112 -86
  352. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
  353. package/src/renderers/webgpu/WebGPURenderer.js +9 -6
  354. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
  355. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
  356. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +189 -73
  357. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
  358. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
  359. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
  360. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +7 -16
  361. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
  362. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +43 -26
  363. package/src/renderers/webgpu/utils/WebGPUUtils.js +19 -2
  364. package/src/renderers/webxr/WebXRManager.js +32 -25
  365. package/src/utils.js +33 -1
  366. package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
  367. package/examples/jsm/loaders/LogLuvLoader.js +0 -606
  368. package/examples/jsm/loaders/TiltLoader.js +0 -520
  369. package/examples/jsm/utils/GPUStatsPanel.js +0 -95
  370. package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
  371. package/src/nodes/accessors/CameraNode.js +0 -19
  372. package/src/nodes/accessors/NormalNode.js +0 -14
  373. package/src/nodes/accessors/PositionNode.js +0 -10
  374. package/src/nodes/accessors/ReflectVectorNode.js +0 -10
  375. package/src/nodes/accessors/TangentNode.js +0 -23
  376. package/src/nodes/core/NodeKeywords.js +0 -80
  377. package/src/nodes/display/BlendModeNode.js +0 -128
  378. package/src/nodes/display/ColorAdjustmentNode.js +0 -104
  379. package/src/nodes/display/ViewportNode.js +0 -137
  380. package/src/nodes/lighting/LightNode.js +0 -57
  381. package/src/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
  382. package/src/nodes/math/HashNode.js +0 -34
  383. package/src/nodes/procedural/CheckerNode.js +0 -42
  384. package/src/nodes/utils/DiscardNode.js +0 -28
  385. package/src/nodes/utils/PackingNode.js +0 -55
  386. package/src/nodes/utils/RotateUVNode.js +0 -35
  387. /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
@@ -2,7 +2,7 @@
2
2
  import 'https://greggman.github.io/webgpu-avoid-redundant-state-setting/webgpu-check-redundant-state-setting.js';
3
3
  //*/
4
4
 
5
- import { GPUFeatureName, GPUTextureFormat, GPULoadOp, GPUStoreOp, GPUIndexFormat, GPUTextureViewDimension } from './utils/WebGPUConstants.js';
5
+ import { GPUFeatureName, GPULoadOp, GPUStoreOp, GPUIndexFormat, GPUTextureViewDimension } from './utils/WebGPUConstants.js';
6
6
 
7
7
  import WGSLNodeBuilder from './nodes/WGSLNodeBuilder.js';
8
8
  import Backend from '../common/Backend.js';
@@ -108,9 +108,11 @@ class WebGPUBackend extends Backend {
108
108
 
109
109
  const alphaMode = parameters.alpha ? 'premultiplied' : 'opaque';
110
110
 
111
+ this.trackTimestamp = this.trackTimestamp && this.hasFeature( GPUFeatureName.TimestampQuery );
112
+
111
113
  this.context.configure( {
112
114
  device: this.device,
113
- format: GPUTextureFormat.BGRA8Unorm,
115
+ format: this.utils.getPreferredCanvasFormat(),
114
116
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
115
117
  alphaMode: alphaMode
116
118
  } );
@@ -193,22 +195,16 @@ class WebGPUBackend extends Backend {
193
195
 
194
196
  let descriptors = renderTargetData.descriptors;
195
197
 
196
- if ( descriptors === undefined ) {
197
-
198
- descriptors = [];
199
-
200
- renderTargetData.descriptors = descriptors;
201
-
202
- }
203
-
204
- if ( renderTargetData.width !== renderTarget.width ||
198
+ if ( descriptors === undefined ||
199
+ renderTargetData.width !== renderTarget.width ||
205
200
  renderTargetData.height !== renderTarget.height ||
206
201
  renderTargetData.activeMipmapLevel !== renderTarget.activeMipmapLevel ||
207
- renderTargetData.samples !== renderTarget.samples ||
208
- descriptors.length !== renderTarget.textures.length
202
+ renderTargetData.samples !== renderTarget.samples
209
203
  ) {
210
204
 
211
- descriptors.length = 0;
205
+ descriptors = {};
206
+
207
+ renderTargetData.descriptors = descriptors;
212
208
 
213
209
  // dispose
214
210
 
@@ -224,7 +220,9 @@ class WebGPUBackend extends Backend {
224
220
 
225
221
  }
226
222
 
227
- let descriptor = descriptors[ renderContext.activeCubeFace ];
223
+ const cacheKey = renderContext.getCacheKey();
224
+
225
+ let descriptor = descriptors[ cacheKey ];
228
226
 
229
227
  if ( descriptor === undefined ) {
230
228
 
@@ -276,7 +274,7 @@ class WebGPUBackend extends Backend {
276
274
  depthStencilAttachment
277
275
  };
278
276
 
279
- descriptors[ renderContext.activeCubeFace ] = descriptor;
277
+ descriptors[ cacheKey ] = descriptor;
280
278
 
281
279
  renderTargetData.width = renderTarget.width;
282
280
  renderTargetData.height = renderTarget.height;
@@ -349,7 +347,7 @@ class WebGPUBackend extends Backend {
349
347
 
350
348
  if ( renderContext.clearColor ) {
351
349
 
352
- colorAttachment.clearValue = renderContext.clearColorValue;
350
+ colorAttachment.clearValue = i === 0 ? renderContext.clearColorValue : { r: 0, g: 0, b: 0, a: 1 };
353
351
  colorAttachment.loadOp = GPULoadOp.Clear;
354
352
  colorAttachment.storeOp = GPUStoreOp.Store;
355
353
 
@@ -427,7 +425,8 @@ class WebGPUBackend extends Backend {
427
425
  renderContextData.descriptor = descriptor;
428
426
  renderContextData.encoder = encoder;
429
427
  renderContextData.currentPass = currentPass;
430
- renderContextData.currentSets = { attributes: {} };
428
+ renderContextData.currentSets = { attributes: {}, bindingGroups: [], pipeline: null, index: null };
429
+ renderContextData.renderBundles = [];
431
430
 
432
431
  //
433
432
 
@@ -441,7 +440,7 @@ class WebGPUBackend extends Backend {
441
440
 
442
441
  const { x, y, width, height } = renderContext.scissorValue;
443
442
 
444
- currentPass.setScissorRect( x, renderContext.height - height - y, width, height );
443
+ currentPass.setScissorRect( x, y, width, height );
445
444
 
446
445
  }
447
446
 
@@ -452,9 +451,8 @@ class WebGPUBackend extends Backend {
452
451
  const renderContextData = this.get( renderContext );
453
452
  const occlusionQueryCount = renderContext.occlusionQueryCount;
454
453
 
455
- if ( renderContextData.renderBundles !== undefined && renderContextData.renderBundles.length > 0 ) {
454
+ if ( renderContextData.renderBundles.length > 0 ) {
456
455
 
457
- renderContextData.registerBundlesPhase = false;
458
456
  renderContextData.currentPass.executeBundles( renderContextData.renderBundles );
459
457
 
460
458
  }
@@ -587,7 +585,7 @@ class WebGPUBackend extends Backend {
587
585
  const { currentPass } = this.get( renderContext );
588
586
  const { x, y, width, height, minDepth, maxDepth } = renderContext.viewportValue;
589
587
 
590
- currentPass.setViewport( x, renderContext.height - height - y, width, height, minDepth, maxDepth );
588
+ currentPass.setViewport( x, y, width, height, minDepth, maxDepth );
591
589
 
592
590
  }
593
591
 
@@ -608,7 +606,19 @@ class WebGPUBackend extends Backend {
608
606
 
609
607
  const clearColor = this.getClearColor();
610
608
 
611
- clearValue = { r: clearColor.r, g: clearColor.g, b: clearColor.b, a: clearColor.a };
609
+ if ( this.renderer.alpha === true ) {
610
+
611
+ // premultiply alpha
612
+
613
+ const a = clearColor.a;
614
+
615
+ clearValue = { r: clearColor.r * a, g: clearColor.g * a, b: clearColor.b * a, a: a };
616
+
617
+ } else {
618
+
619
+ clearValue = { r: clearColor.r, g: clearColor.g, b: clearColor.b, a: clearColor.a };
620
+
621
+ }
612
622
 
613
623
  }
614
624
 
@@ -819,27 +829,16 @@ class WebGPUBackend extends Backend {
819
829
 
820
830
  draw( renderObject, info ) {
821
831
 
822
- const { object, geometry, context, pipeline } = renderObject;
823
-
832
+ const { object, context, pipeline } = renderObject;
824
833
  const bindings = renderObject.getBindings();
825
- const contextData = this.get( context );
826
- const pipelineGPU = this.get( pipeline ).pipeline;
827
- const currentSets = contextData.currentSets;
828
-
829
- const renderObjectData = this.get( renderObject );
830
-
831
- const { bundleEncoder, renderBundle, lastPipelineGPU } = renderObjectData;
832
-
833
834
  const renderContextData = this.get( context );
835
+ const pipelineGPU = this.get( pipeline ).pipeline;
836
+ const currentSets = renderContextData.currentSets;
837
+ const passEncoderGPU = renderContextData.currentPass;
834
838
 
835
- if ( renderContextData.registerBundlesPhase === true && bundleEncoder !== undefined && lastPipelineGPU === pipelineGPU ) {
836
-
837
- renderContextData.renderBundles.push( renderBundle );
838
- return;
839
-
840
- }
839
+ const drawParms = renderObject.getDrawParameters();
841
840
 
842
- const passEncoderGPU = this.renderer._currentRenderBundle ? this.createBundleEncoder( context, renderObject ) : contextData.currentPass;
841
+ if ( drawParms === null ) return;
843
842
 
844
843
  // pipeline
845
844
 
@@ -853,12 +852,19 @@ class WebGPUBackend extends Backend {
853
852
 
854
853
  // bind groups
855
854
 
855
+ const currentBindingGroups = currentSets.bindingGroups;
856
+
856
857
  for ( let i = 0, l = bindings.length; i < l; i ++ ) {
857
858
 
858
859
  const bindGroup = bindings[ i ];
859
860
  const bindingsData = this.get( bindGroup );
860
861
 
861
- passEncoderGPU.setBindGroup( i, bindingsData.group );
862
+ if ( currentBindingGroups[ bindGroup.index ] !== bindGroup.id ) {
863
+
864
+ passEncoderGPU.setBindGroup( bindGroup.index, bindingsData.group );
865
+ currentBindingGroups[ bindGroup.index ] = bindGroup.id;
866
+
867
+ }
862
868
 
863
869
  }
864
870
 
@@ -906,27 +912,27 @@ class WebGPUBackend extends Backend {
906
912
 
907
913
  // occlusion queries - handle multiple consecutive draw calls for an object
908
914
 
909
- if ( contextData.occlusionQuerySet !== undefined ) {
915
+ if ( renderContextData.occlusionQuerySet !== undefined ) {
910
916
 
911
- const lastObject = contextData.lastOcclusionObject;
917
+ const lastObject = renderContextData.lastOcclusionObject;
912
918
 
913
919
  if ( lastObject !== object ) {
914
920
 
915
921
  if ( lastObject !== null && lastObject.occlusionTest === true ) {
916
922
 
917
923
  passEncoderGPU.endOcclusionQuery();
918
- contextData.occlusionQueryIndex ++;
924
+ renderContextData.occlusionQueryIndex ++;
919
925
 
920
926
  }
921
927
 
922
928
  if ( object.occlusionTest === true ) {
923
929
 
924
- passEncoderGPU.beginOcclusionQuery( contextData.occlusionQueryIndex );
925
- contextData.occlusionQueryObjects[ contextData.occlusionQueryIndex ] = object;
930
+ passEncoderGPU.beginOcclusionQuery( renderContextData.occlusionQueryIndex );
931
+ renderContextData.occlusionQueryObjects[ renderContextData.occlusionQueryIndex ] = object;
926
932
 
927
933
  }
928
934
 
929
- contextData.lastOcclusionObject = object;
935
+ renderContextData.lastOcclusionObject = object;
930
936
 
931
937
  }
932
938
 
@@ -934,12 +940,6 @@ class WebGPUBackend extends Backend {
934
940
 
935
941
  // draw
936
942
 
937
- const drawRange = renderObject.drawRange;
938
- const firstVertex = drawRange.start;
939
-
940
- const instanceCount = this.getInstanceCount( renderObject );
941
- if ( instanceCount === 0 ) return;
942
-
943
943
  if ( object.isBatchedMesh === true ) {
944
944
 
945
945
  const starts = object._multiDrawStarts;
@@ -947,29 +947,28 @@ class WebGPUBackend extends Backend {
947
947
  const drawCount = object._multiDrawCount;
948
948
  const drawInstances = object._multiDrawInstances;
949
949
 
950
- const bytesPerElement = index.bytesPerElement || 1;
950
+ const bytesPerElement = hasIndex ? index.array.BYTES_PER_ELEMENT : 1;
951
951
 
952
952
  for ( let i = 0; i < drawCount; i ++ ) {
953
953
 
954
954
  const count = drawInstances ? drawInstances[ i ] : 1;
955
955
  const firstInstance = count > 1 ? 0 : i;
956
956
 
957
- passEncoderGPU.drawIndexed( counts[ i ] / bytesPerElement, count, starts[ i ] / 4, 0, firstInstance );
957
+ passEncoderGPU.drawIndexed( counts[ i ], count, starts[ i ] / bytesPerElement, 0, firstInstance );
958
958
 
959
959
  }
960
960
 
961
961
  } else if ( hasIndex === true ) {
962
962
 
963
- const indexCount = ( drawRange.count !== Infinity ) ? drawRange.count : index.count;
963
+ const { vertexCount: indexCount, instanceCount, firstVertex: firstIndex } = drawParms;
964
964
 
965
- passEncoderGPU.drawIndexed( indexCount, instanceCount, firstVertex, 0, 0 );
965
+ passEncoderGPU.drawIndexed( indexCount, instanceCount, firstIndex, 0, 0 );
966
966
 
967
967
  info.update( object, indexCount, instanceCount );
968
968
 
969
969
  } else {
970
970
 
971
- const positionAttribute = geometry.attributes.position;
972
- const vertexCount = ( drawRange.count !== Infinity ) ? drawRange.count : positionAttribute.count;
971
+ const { vertexCount, instanceCount, firstVertex } = drawParms;
973
972
 
974
973
  passEncoderGPU.draw( vertexCount, instanceCount, firstVertex, 0 );
975
974
 
@@ -977,15 +976,6 @@ class WebGPUBackend extends Backend {
977
976
 
978
977
  }
979
978
 
980
- if ( this.renderer._currentRenderBundle ) {
981
-
982
- const renderBundle = passEncoderGPU.finish();
983
- renderObjectData.lastPipelineGPU = pipelineGPU;
984
- renderObjectData.renderBundle = renderBundle;
985
- renderObjectData.bundleEncoder = passEncoderGPU;
986
-
987
- }
988
-
989
979
  }
990
980
 
991
981
  // cache key
@@ -1018,7 +1008,7 @@ class WebGPUBackend extends Backend {
1018
1008
  data.sampleCount !== sampleCount || data.colorSpace !== colorSpace ||
1019
1009
  data.colorFormat !== colorFormat || data.depthStencilFormat !== depthStencilFormat ||
1020
1010
  data.primitiveTopology !== primitiveTopology ||
1021
- data.clippingContextVersion !== renderObject.clippingContextVersion
1011
+ data.clippingContextCacheKey !== renderObject.clippingContext.cacheKey
1022
1012
  ) {
1023
1013
 
1024
1014
  data.material = material; data.materialVersion = material.version;
@@ -1036,7 +1026,7 @@ class WebGPUBackend extends Backend {
1036
1026
  data.colorFormat = colorFormat;
1037
1027
  data.depthStencilFormat = depthStencilFormat;
1038
1028
  data.primitiveTopology = primitiveTopology;
1039
- data.clippingContextVersion = renderObject.clippingContextVersion;
1029
+ data.clippingContextCacheKey = renderObject.clippingContext.cacheKey;
1040
1030
 
1041
1031
  needsUpdate = true;
1042
1032
 
@@ -1066,7 +1056,7 @@ class WebGPUBackend extends Backend {
1066
1056
  utils.getSampleCountRenderContext( renderContext ),
1067
1057
  utils.getCurrentColorSpace( renderContext ), utils.getCurrentColorFormat( renderContext ), utils.getCurrentDepthStencilFormat( renderContext ),
1068
1058
  utils.getPrimitiveTopology( object, material ),
1069
- renderObject.clippingContextVersion
1059
+ renderObject.clippingContext.cacheKey
1070
1060
  ].join();
1071
1061
 
1072
1062
  }
@@ -1115,16 +1105,16 @@ class WebGPUBackend extends Backend {
1115
1105
 
1116
1106
  }
1117
1107
 
1118
- copyTextureToBuffer( texture, x, y, width, height ) {
1108
+ copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
1119
1109
 
1120
- return this.textureUtils.copyTextureToBuffer( texture, x, y, width, height );
1110
+ return this.textureUtils.copyTextureToBuffer( texture, x, y, width, height, faceIndex );
1121
1111
 
1122
1112
  }
1123
1113
 
1124
1114
 
1125
1115
  initTimestampQuery( renderContext, descriptor ) {
1126
1116
 
1127
- if ( ! this.hasFeature( GPUFeatureName.TimestampQuery ) || ! this.trackTimestamp ) return;
1117
+ if ( ! this.trackTimestamp ) return;
1128
1118
 
1129
1119
  const renderContextData = this.get( renderContext );
1130
1120
 
@@ -1154,10 +1144,11 @@ class WebGPUBackend extends Backend {
1154
1144
 
1155
1145
  prepareTimestampBuffer( renderContext, encoder ) {
1156
1146
 
1157
- if ( ! this.hasFeature( GPUFeatureName.TimestampQuery ) || ! this.trackTimestamp ) return;
1147
+ if ( ! this.trackTimestamp ) return;
1158
1148
 
1159
1149
  const renderContextData = this.get( renderContext );
1160
1150
 
1151
+
1161
1152
  const size = 2 * BigInt64Array.BYTES_PER_ELEMENT;
1162
1153
 
1163
1154
  if ( renderContextData.currentTimestampQueryBuffers === undefined ) {
@@ -1189,7 +1180,7 @@ class WebGPUBackend extends Backend {
1189
1180
 
1190
1181
  async resolveTimestampAsync( renderContext, type = 'render' ) {
1191
1182
 
1192
- if ( ! this.hasFeature( GPUFeatureName.TimestampQuery ) || ! this.trackTimestamp ) return;
1183
+ if ( ! this.trackTimestamp ) return;
1193
1184
 
1194
1185
  const renderContextData = this.get( renderContext );
1195
1186
 
@@ -1258,9 +1249,39 @@ class WebGPUBackend extends Backend {
1258
1249
 
1259
1250
  }
1260
1251
 
1261
- createBundleEncoder( renderContext, renderObject ) {
1252
+ beginBundle( renderContext ) {
1253
+
1254
+ const renderContextData = this.get( renderContext );
1255
+
1256
+ renderContextData._currentPass = renderContextData.currentPass;
1257
+ renderContextData._currentSets = renderContextData.currentSets;
1258
+
1259
+ renderContextData.currentSets = { attributes: {}, bindingGroups: [], pipeline: null, index: null };
1260
+ renderContextData.currentPass = this.pipelineUtils.createBundleEncoder( renderContext );
1261
+
1262
+ }
1263
+
1264
+ finishBundle( renderContext, bundle ) {
1265
+
1266
+ const renderContextData = this.get( renderContext );
1267
+
1268
+ const bundleEncoder = renderContextData.currentPass;
1269
+ const bundleGPU = bundleEncoder.finish();
1270
+
1271
+ this.get( bundle ).bundleGPU = bundleGPU;
1272
+
1273
+ // restore render pass state
1274
+
1275
+ renderContextData.currentSets = renderContextData._currentSets;
1276
+ renderContextData.currentPass = renderContextData._currentPass;
1277
+
1278
+ }
1279
+
1280
+ addBundle( renderContext, bundle ) {
1281
+
1282
+ const renderContextData = this.get( renderContext );
1262
1283
 
1263
- return this.pipelineUtils.createBundleEncoder( renderContext, renderObject );
1284
+ renderContextData.renderBundles.push( this.get( bundle ).bundleGPU );
1264
1285
 
1265
1286
  }
1266
1287
 
@@ -1343,9 +1364,11 @@ class WebGPUBackend extends Backend {
1343
1364
 
1344
1365
  let dstX = 0;
1345
1366
  let dstY = 0;
1367
+ let dstLayer = 0;
1346
1368
 
1347
1369
  let srcX = 0;
1348
1370
  let srcY = 0;
1371
+ let srcLayer = 0;
1349
1372
 
1350
1373
  let srcWidth = srcTexture.image.width;
1351
1374
  let srcHeight = srcTexture.image.height;
@@ -1354,6 +1377,7 @@ class WebGPUBackend extends Backend {
1354
1377
 
1355
1378
  srcX = srcRegion.x;
1356
1379
  srcY = srcRegion.y;
1380
+ srcLayer = srcRegion.z || 0;
1357
1381
  srcWidth = srcRegion.width;
1358
1382
  srcHeight = srcRegion.height;
1359
1383
 
@@ -1363,6 +1387,7 @@ class WebGPUBackend extends Backend {
1363
1387
 
1364
1388
  dstX = dstPosition.x;
1365
1389
  dstY = dstPosition.y;
1390
+ dstLayer = dstPosition.z || 0;
1366
1391
 
1367
1392
  }
1368
1393
 
@@ -1375,16 +1400,17 @@ class WebGPUBackend extends Backend {
1375
1400
  {
1376
1401
  texture: sourceGPU,
1377
1402
  mipLevel: level,
1378
- origin: { x: srcX, y: srcY, z: 0 }
1403
+ origin: { x: srcX, y: srcY, z: srcLayer }
1379
1404
  },
1380
1405
  {
1381
1406
  texture: destinationGPU,
1382
1407
  mipLevel: level,
1383
- origin: { x: dstX, y: dstY, z: 0 }
1408
+ origin: { x: dstX, y: dstY, z: dstLayer }
1384
1409
  },
1385
1410
  [
1386
1411
  srcWidth,
1387
- srcHeight
1412
+ srcHeight,
1413
+ 1
1388
1414
  ]
1389
1415
  );
1390
1416
 
@@ -1392,7 +1418,7 @@ class WebGPUBackend extends Backend {
1392
1418
 
1393
1419
  }
1394
1420
 
1395
- copyFramebufferToTexture( texture, renderContext ) {
1421
+ copyFramebufferToTexture( texture, renderContext, rectangle ) {
1396
1422
 
1397
1423
  const renderContextData = this.get( renderContext );
1398
1424
 
@@ -1441,14 +1467,14 @@ class WebGPUBackend extends Backend {
1441
1467
  encoder.copyTextureToTexture(
1442
1468
  {
1443
1469
  texture: sourceGPU,
1444
- origin: { x: 0, y: 0, z: 0 }
1470
+ origin: { x: rectangle.x, y: rectangle.y, z: 0 }
1445
1471
  },
1446
1472
  {
1447
1473
  texture: destinationGPU
1448
1474
  },
1449
1475
  [
1450
- texture.image.width,
1451
- texture.image.height
1476
+ rectangle.z,
1477
+ rectangle.w
1452
1478
  ]
1453
1479
  );
1454
1480
 
@@ -1464,7 +1490,7 @@ class WebGPUBackend extends Backend {
1464
1490
  if ( renderContext.stencil ) descriptor.depthStencilAttachment.stencilLoadOp = GPULoadOp.Load;
1465
1491
 
1466
1492
  renderContextData.currentPass = encoder.beginRenderPass( descriptor );
1467
- renderContextData.currentSets = { attributes: {} };
1493
+ renderContextData.currentSets = { attributes: {}, bindingGroups: [], pipeline: null, index: null };
1468
1494
 
1469
1495
  }
1470
1496
 
@@ -0,0 +1,42 @@
1
+ import Renderer from '../common/Renderer.js';
2
+ import WebGLBackend from '../webgl-fallback/WebGLBackend.js';
3
+ import WebGPUBackend from './WebGPUBackend.js';
4
+ import BasicNodeLibrary from './nodes/BasicNodeLibrary.js';
5
+
6
+ class WebGPURenderer extends Renderer {
7
+
8
+ constructor( parameters = {} ) {
9
+
10
+ let BackendClass;
11
+
12
+ if ( parameters.forceWebGL ) {
13
+
14
+ BackendClass = WebGLBackend;
15
+
16
+ } else {
17
+
18
+ BackendClass = WebGPUBackend;
19
+
20
+ parameters.getFallback = () => {
21
+
22
+ console.warn( 'THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.' );
23
+
24
+ return new WebGLBackend( parameters );
25
+
26
+ };
27
+
28
+ }
29
+
30
+ const backend = new BackendClass( parameters );
31
+
32
+ super( backend, parameters );
33
+
34
+ this.nodes.library = new BasicNodeLibrary();
35
+
36
+ this.isWebGPURenderer = true;
37
+
38
+ }
39
+
40
+ }
41
+
42
+ export default WebGPURenderer;
@@ -1,8 +1,7 @@
1
- import WebGPU from '../../../examples/jsm/capabilities/WebGPU.js';
2
-
3
1
  import Renderer from '../common/Renderer.js';
4
2
  import WebGLBackend from '../webgl-fallback/WebGLBackend.js';
5
3
  import WebGPUBackend from './WebGPUBackend.js';
4
+ import StandardNodeLibrary from './nodes/StandardNodeLibrary.js';
6
5
  /*
7
6
  const debugHandler = {
8
7
 
@@ -27,15 +26,17 @@ class WebGPURenderer extends Renderer {
27
26
 
28
27
  BackendClass = WebGLBackend;
29
28
 
30
- } else if ( WebGPU.isAvailable() ) {
29
+ } else {
31
30
 
32
31
  BackendClass = WebGPUBackend;
33
32
 
34
- } else {
33
+ parameters.getFallback = () => {
35
34
 
36
- BackendClass = WebGLBackend;
35
+ console.warn( 'THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.' );
36
+
37
+ return new WebGLBackend( parameters );
37
38
 
38
- console.warn( 'THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.' );
39
+ };
39
40
 
40
41
  }
41
42
 
@@ -44,6 +45,8 @@ class WebGPURenderer extends Renderer {
44
45
  //super( new Proxy( backend, debugHandler ) );
45
46
  super( backend, parameters );
46
47
 
48
+ this.nodes.library = new StandardNodeLibrary();
49
+
47
50
  this.isWebGPURenderer = true;
48
51
 
49
52
  }
@@ -0,0 +1,59 @@
1
+ import NodeLibrary from '../../common/nodes/NodeLibrary.js';
2
+
3
+ // Lights
4
+ import { PointLight } from '../../../lights/PointLight.js';
5
+ import { PointLightNode } from '../../../nodes/Nodes.js';
6
+ import { DirectionalLight } from '../../../lights/DirectionalLight.js';
7
+ import { DirectionalLightNode } from '../../../nodes/Nodes.js';
8
+ import { RectAreaLight } from '../../../lights/RectAreaLight.js';
9
+ import { RectAreaLightNode } from '../../../nodes/Nodes.js';
10
+ import { SpotLight } from '../../../lights/SpotLight.js';
11
+ import { SpotLightNode } from '../../../nodes/Nodes.js';
12
+ import { AmbientLight } from '../../../lights/AmbientLight.js';
13
+ import { AmbientLightNode } from '../../../nodes/Nodes.js';
14
+ import { HemisphereLight } from '../../../lights/HemisphereLight.js';
15
+ import { HemisphereLightNode } from '../../../nodes/Nodes.js';
16
+ import { LightProbe } from '../../../lights/LightProbe.js';
17
+ import { LightProbeNode } from '../../../nodes/Nodes.js';
18
+ import IESSpotLight from '../../../lights/webgpu/IESSpotLight.js';
19
+ import { IESSpotLightNode } from '../../../nodes/Nodes.js';
20
+
21
+ // Tone Mapping
22
+ import { LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, AgXToneMapping, NeutralToneMapping } from '../../../constants.js';
23
+ import { linearToneMapping, reinhardToneMapping, cineonToneMapping, acesFilmicToneMapping, agxToneMapping, neutralToneMapping } from '../../../nodes/display/ToneMappingFunctions.js';
24
+
25
+ // Color Space
26
+ import { LinearSRGBColorSpace, SRGBColorSpace } from '../../../constants.js';
27
+ import { linearSRGBTosRGB, sRGBToLinearSRGB } from '../../../nodes/display/ColorSpaceFunctions.js';
28
+ import { getColorSpaceMethod } from '../../../nodes/display/ColorSpaceNode.js';
29
+
30
+ class BasicNodeLibrary extends NodeLibrary {
31
+
32
+ constructor() {
33
+
34
+ super();
35
+
36
+ this.addLight( PointLightNode, PointLight );
37
+ this.addLight( DirectionalLightNode, DirectionalLight );
38
+ this.addLight( RectAreaLightNode, RectAreaLight );
39
+ this.addLight( SpotLightNode, SpotLight );
40
+ this.addLight( AmbientLightNode, AmbientLight );
41
+ this.addLight( HemisphereLightNode, HemisphereLight );
42
+ this.addLight( LightProbeNode, LightProbe );
43
+ this.addLight( IESSpotLightNode, IESSpotLight );
44
+
45
+ this.addToneMapping( linearToneMapping, LinearToneMapping );
46
+ this.addToneMapping( reinhardToneMapping, ReinhardToneMapping );
47
+ this.addToneMapping( cineonToneMapping, CineonToneMapping );
48
+ this.addToneMapping( acesFilmicToneMapping, ACESFilmicToneMapping );
49
+ this.addToneMapping( agxToneMapping, AgXToneMapping );
50
+ this.addToneMapping( neutralToneMapping, NeutralToneMapping );
51
+
52
+ this.addColorSpace( linearSRGBTosRGB, getColorSpaceMethod( LinearSRGBColorSpace, SRGBColorSpace ) );
53
+ this.addColorSpace( sRGBToLinearSRGB, getColorSpaceMethod( SRGBColorSpace, LinearSRGBColorSpace ) );
54
+
55
+ }
56
+
57
+ }
58
+
59
+ export default BasicNodeLibrary;