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
@@ -1,17 +1,22 @@
1
1
  import UniformNode, { uniform } from '../core/UniformNode.js';
2
- import { uv } from './UVNode.js';
2
+ import { uv } from './UV.js';
3
3
  import { textureSize } from './TextureSizeNode.js';
4
- import { colorSpaceToLinear } from '../display/ColorSpaceNode.js';
4
+ import { colorSpaceToWorking } from '../display/ColorSpaceNode.js';
5
5
  import { expression } from '../code/ExpressionNode.js';
6
- import { addNodeClass } from '../core/Node.js';
7
6
  import { maxMipLevel } from '../utils/MaxMipLevelNode.js';
8
- import { addNodeElement, nodeProxy, vec3, nodeObject } from '../shadernode/ShaderNode.js';
7
+ import { nodeProxy, vec3, nodeObject, int } from '../tsl/TSLBase.js';
9
8
  import { NodeUpdateType } from '../core/constants.js';
10
9
 
11
10
  import { IntType, UnsignedIntType } from '../../constants.js';
12
11
 
13
12
  class TextureNode extends UniformNode {
14
13
 
14
+ static get type() {
15
+
16
+ return 'TextureNode';
17
+
18
+ }
19
+
15
20
  constructor( value, uvNode = null, levelNode = null, biasNode = null ) {
16
21
 
17
22
  super( value );
@@ -106,7 +111,6 @@ class TextureNode extends UniformNode {
106
111
 
107
112
  return this._matrixUniform.mul( vec3( uvNode, 1 ) ).xy;
108
113
 
109
-
110
114
  }
111
115
 
112
116
  setUpdateMatrix( value ) {
@@ -124,7 +128,15 @@ class TextureNode extends UniformNode {
124
128
 
125
129
  if ( builder.isFlipY() && ( texture.isRenderTargetTexture === true || texture.isFramebufferTexture === true || texture.isDepthTexture === true ) ) {
126
130
 
127
- uvNode = uvNode.setY( uvNode.y.oneMinus() );
131
+ if ( this.sampler ) {
132
+
133
+ uvNode = uvNode.flipY();
134
+
135
+ } else {
136
+
137
+ uvNode = uvNode.setY( int( textureSize( this, this.levelNode ).y ).sub( uvNode.y ).sub( 1 ) );
138
+
139
+ }
128
140
 
129
141
  }
130
142
 
@@ -265,7 +277,7 @@ class TextureNode extends UniformNode {
265
277
 
266
278
  const snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, depthSnippet, compareSnippet, gradSnippet );
267
279
 
268
- builder.addLineFlowCode( `${propertyName} = ${snippet}` );
280
+ builder.addLineFlowCode( `${propertyName} = ${snippet}`, this );
269
281
 
270
282
  nodeData.snippet = snippet;
271
283
  nodeData.propertyName = propertyName;
@@ -275,9 +287,9 @@ class TextureNode extends UniformNode {
275
287
  let snippet = propertyName;
276
288
  const nodeType = this.getNodeType( builder );
277
289
 
278
- if ( builder.needsColorSpaceToLinear( texture ) ) {
290
+ if ( builder.needsToWorkingColorSpace( texture ) ) {
279
291
 
280
- snippet = colorSpaceToLinear( expression( snippet, nodeType ), texture.colorSpace ).setup( builder ).build( builder, nodeType );
292
+ snippet = colorSpaceToWorking( expression( snippet, nodeType ), texture.colorSpace ).setup( builder ).build( builder, nodeType );
281
293
 
282
294
  }
283
295
 
@@ -307,7 +319,7 @@ class TextureNode extends UniformNode {
307
319
 
308
320
  const textureNode = this.clone();
309
321
  textureNode.uvNode = nodeObject( uvNode );
310
- textureNode.referenceNode = this;
322
+ textureNode.referenceNode = this.getSelf();
311
323
 
312
324
  return nodeObject( textureNode );
313
325
 
@@ -317,7 +329,7 @@ class TextureNode extends UniformNode {
317
329
 
318
330
  const textureNode = this.clone();
319
331
  textureNode.biasNode = nodeObject( amountNode ).mul( maxMipLevel( textureNode ) );
320
- textureNode.referenceNode = this;
332
+ textureNode.referenceNode = this.getSelf();
321
333
 
322
334
  return nodeObject( textureNode );
323
335
 
@@ -327,7 +339,7 @@ class TextureNode extends UniformNode {
327
339
 
328
340
  const textureNode = this.clone();
329
341
  textureNode.levelNode = nodeObject( levelNode );
330
- textureNode.referenceNode = this;
342
+ textureNode.referenceNode = this.getSelf();
331
343
 
332
344
  return nodeObject( textureNode );
333
345
 
@@ -343,7 +355,7 @@ class TextureNode extends UniformNode {
343
355
 
344
356
  const textureNode = this.clone();
345
357
  textureNode.biasNode = nodeObject( biasNode );
346
- textureNode.referenceNode = this;
358
+ textureNode.referenceNode = this.getSelf();
347
359
 
348
360
  return nodeObject( textureNode );
349
361
 
@@ -353,7 +365,7 @@ class TextureNode extends UniformNode {
353
365
 
354
366
  const textureNode = this.clone();
355
367
  textureNode.compareNode = nodeObject( compareNode );
356
- textureNode.referenceNode = this;
368
+ textureNode.referenceNode = this.getSelf();
357
369
 
358
370
  return nodeObject( textureNode );
359
371
 
@@ -363,8 +375,7 @@ class TextureNode extends UniformNode {
363
375
 
364
376
  const textureNode = this.clone();
365
377
  textureNode.gradNode = [ nodeObject( gradNodeX ), nodeObject( gradNodeY ) ];
366
-
367
- textureNode.referenceNode = this;
378
+ textureNode.referenceNode = this.getSelf();
368
379
 
369
380
  return nodeObject( textureNode );
370
381
 
@@ -374,7 +385,7 @@ class TextureNode extends UniformNode {
374
385
 
375
386
  const textureNode = this.clone();
376
387
  textureNode.depthNode = nodeObject( depthNode );
377
- textureNode.referenceNode = this;
388
+ textureNode.referenceNode = this.getSelf();
378
389
 
379
390
  return nodeObject( textureNode );
380
391
 
@@ -432,14 +443,9 @@ class TextureNode extends UniformNode {
432
443
 
433
444
  export default TextureNode;
434
445
 
435
- export const texture = nodeProxy( TextureNode );
446
+ export const texture = /*@__PURE__*/ nodeProxy( TextureNode );
436
447
  export const textureLoad = ( ...params ) => texture( ...params ).setSampler( false );
437
448
 
438
449
  //export const textureLevel = ( value, uv, level ) => texture( value, uv ).level( level );
439
450
 
440
451
  export const sampler = ( aTexture ) => ( aTexture.isNode === true ? aTexture : texture( aTexture ) ).convert( 'sampler' );
441
-
442
- addNodeElement( 'texture', texture );
443
- //addNodeElement( 'textureLevel', textureLevel );
444
-
445
- addNodeClass( 'TextureNode', TextureNode );
@@ -1,9 +1,14 @@
1
1
  import Node from '../core/Node.js';
2
- import { addNodeClass } from '../core/Node.js';
3
- import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
2
+ import { nodeProxy } from '../tsl/TSLBase.js';
4
3
 
5
4
  class TextureSizeNode extends Node {
6
5
 
6
+ static get type() {
7
+
8
+ return 'TextureSizeNode';
9
+
10
+ }
11
+
7
12
  constructor( textureNode, levelNode = null ) {
8
13
 
9
14
  super( 'uvec2' );
@@ -18,9 +23,9 @@ class TextureSizeNode extends Node {
18
23
  generate( builder, output ) {
19
24
 
20
25
  const textureProperty = this.textureNode.build( builder, 'property' );
21
- const levelNode = this.levelNode.build( builder, 'int' );
26
+ const level = this.levelNode === null ? '0' : this.levelNode.build( builder, 'int' );
22
27
 
23
- return builder.format( `${ builder.getMethod( 'textureDimensions' ) }( ${ textureProperty }, ${ levelNode } )`, this.getNodeType( builder ), output );
28
+ return builder.format( `${ builder.getMethod( 'textureDimensions' ) }( ${ textureProperty }, ${ level } )`, this.getNodeType( builder ), output );
24
29
 
25
30
  }
26
31
 
@@ -28,8 +33,4 @@ class TextureSizeNode extends Node {
28
33
 
29
34
  export default TextureSizeNode;
30
35
 
31
- export const textureSize = nodeProxy( TextureSizeNode );
32
-
33
- addNodeElement( 'textureSize', textureSize );
34
-
35
- addNodeClass( 'TextureSizeNode', TextureSizeNode );
36
+ export const textureSize = /*@__PURE__*/ nodeProxy( TextureSizeNode );
@@ -1,23 +1,22 @@
1
- import { addNodeClass } from '../core/Node.js';
2
- import { nodeObject } from '../shadernode/ShaderNode.js';
1
+ import { nodeObject } from '../tsl/TSLBase.js';
3
2
  import { NodeUpdateType } from '../core/constants.js';
4
3
  import { getValueType } from '../core/NodeUtils.js';
5
4
  import ArrayElementNode from '../utils/ArrayElementNode.js';
6
5
  import BufferNode from './BufferNode.js';
7
6
 
8
- class UniformsElementNode extends ArrayElementNode {
7
+ class UniformArrayElementNode extends ArrayElementNode {
9
8
 
10
- constructor( arrayBuffer, indexNode ) {
11
-
12
- super( arrayBuffer, indexNode );
9
+ static get type() {
13
10
 
14
- this.isArrayBufferElementNode = true;
11
+ return 'UniformArrayElementNode';
15
12
 
16
13
  }
17
14
 
18
- getNodeType( builder ) {
15
+ constructor( arrayBuffer, indexNode ) {
16
+
17
+ super( arrayBuffer, indexNode );
19
18
 
20
- return this.node.getElementType( builder );
19
+ this.isArrayBufferElementNode = true;
21
20
 
22
21
  }
23
22
 
@@ -32,7 +31,13 @@ class UniformsElementNode extends ArrayElementNode {
32
31
 
33
32
  }
34
33
 
35
- class UniformsNode extends BufferNode {
34
+ class UniformArrayNode extends BufferNode {
35
+
36
+ static get type() {
37
+
38
+ return 'UniformArrayNode';
39
+
40
+ }
36
41
 
37
42
  constructor( value, elementType = null ) {
38
43
 
@@ -133,14 +138,21 @@ class UniformsNode extends BufferNode {
133
138
 
134
139
  element( indexNode ) {
135
140
 
136
- return nodeObject( new UniformsElementNode( this, nodeObject( indexNode ) ) );
141
+ return nodeObject( new UniformArrayElementNode( this, nodeObject( indexNode ) ) );
137
142
 
138
143
  }
139
144
 
140
145
  }
141
146
 
142
- export default UniformsNode;
147
+ export default UniformArrayNode;
148
+
149
+ export const uniformArray = ( values, nodeType ) => nodeObject( new UniformArrayNode( values, nodeType ) );
150
+
151
+ //
152
+
153
+ export const uniforms = ( values, nodeType ) => { // @deprecated, r168
143
154
 
144
- export const uniforms = ( values, nodeType ) => nodeObject( new UniformsNode( values, nodeType ) );
155
+ console.warn( 'TSL.UniformArrayNode: uniforms() has been renamed to uniformArray().' );
156
+ return nodeObject( new UniformArrayNode( values, nodeType ) );
145
157
 
146
- addNodeClass( 'UniformsNode', UniformsNode );
158
+ };
@@ -1,9 +1,14 @@
1
1
  import ReferenceNode from './ReferenceNode.js';
2
- import { addNodeClass } from '../core/Node.js';
3
- import { nodeObject } from '../shadernode/ShaderNode.js';
2
+ import { nodeObject } from '../tsl/TSLBase.js';
4
3
 
5
4
  class UserDataNode extends ReferenceNode {
6
5
 
6
+ static get type() {
7
+
8
+ return 'UserDataNode';
9
+
10
+ }
11
+
7
12
  constructor( property, inputType, userData = null ) {
8
13
 
9
14
  super( property, inputType, userData );
@@ -12,11 +17,11 @@ class UserDataNode extends ReferenceNode {
12
17
 
13
18
  }
14
19
 
15
- update( frame ) {
20
+ updateReference( state ) {
16
21
 
17
- this.reference = this.userData !== null ? this.userData : frame.object.userData;
22
+ this.reference = this.userData !== null ? this.userData : state.object.userData;
18
23
 
19
- super.update( frame );
24
+ return this.reference;
20
25
 
21
26
  }
22
27
 
@@ -25,5 +30,3 @@ class UserDataNode extends ReferenceNode {
25
30
  export default UserDataNode;
26
31
 
27
32
  export const userData = ( name, inputType, userData ) => nodeObject( new UserDataNode( name, inputType, userData ) );
28
-
29
- addNodeClass( 'UserDataNode', UserDataNode );
@@ -0,0 +1,134 @@
1
+ import TempNode from '../core/TempNode.js';
2
+ import { modelViewMatrix } from './ModelNode.js';
3
+ import { positionLocal, positionPrevious } from './Position.js';
4
+ import { nodeImmutable } from '../tsl/TSLBase.js';
5
+ import { NodeUpdateType } from '../core/constants.js';
6
+ import { Matrix4 } from '../../math/Matrix4.js';
7
+ import { uniform } from '../core/UniformNode.js';
8
+ import { sub } from '../math/OperatorNode.js';
9
+ import { cameraProjectionMatrix } from './Camera.js';
10
+ import { renderGroup } from '../core/UniformGroupNode.js';
11
+
12
+ const _objectData = new WeakMap();
13
+
14
+ class VelocityNode extends TempNode {
15
+
16
+ static get type() {
17
+
18
+ return 'VelocityNode';
19
+
20
+ }
21
+
22
+ constructor() {
23
+
24
+ super( 'vec2' );
25
+
26
+ this.updateType = NodeUpdateType.OBJECT;
27
+ this.updateAfterType = NodeUpdateType.OBJECT;
28
+
29
+ this.previousModelWorldMatrix = uniform( new Matrix4() );
30
+ this.previousProjectionMatrix = uniform( new Matrix4() ).setGroup( renderGroup );
31
+ this.previousCameraViewMatrix = uniform( new Matrix4() );
32
+
33
+ }
34
+
35
+ update( { frameId, camera, object } ) {
36
+
37
+ const previousModelMatrix = getPreviousMatrix( object );
38
+
39
+ this.previousModelWorldMatrix.value.copy( previousModelMatrix );
40
+
41
+ //
42
+
43
+ const cameraData = getData( camera );
44
+
45
+ if ( cameraData.frameId !== frameId ) {
46
+
47
+ cameraData.frameId = frameId;
48
+
49
+ if ( cameraData.previousProjectionMatrix === undefined ) {
50
+
51
+ cameraData.previousProjectionMatrix = new Matrix4();
52
+ cameraData.previousCameraViewMatrix = new Matrix4();
53
+
54
+ cameraData.currentProjectionMatrix = new Matrix4();
55
+ cameraData.currentCameraViewMatrix = new Matrix4();
56
+
57
+ cameraData.previousProjectionMatrix.copy( camera.projectionMatrix );
58
+ cameraData.previousCameraViewMatrix.copy( camera.matrixWorldInverse );
59
+
60
+ } else {
61
+
62
+ cameraData.previousProjectionMatrix.copy( cameraData.currentProjectionMatrix );
63
+ cameraData.previousCameraViewMatrix.copy( cameraData.currentCameraViewMatrix );
64
+
65
+ }
66
+
67
+ cameraData.currentProjectionMatrix.copy( camera.projectionMatrix );
68
+ cameraData.currentCameraViewMatrix.copy( camera.matrixWorldInverse );
69
+
70
+ this.previousProjectionMatrix.value.copy( cameraData.previousProjectionMatrix );
71
+ this.previousCameraViewMatrix.value.copy( cameraData.previousCameraViewMatrix );
72
+
73
+ }
74
+
75
+ }
76
+
77
+ updateAfter( { object } ) {
78
+
79
+ getPreviousMatrix( object ).copy( object.matrixWorld );
80
+
81
+ }
82
+
83
+ setup( /*builder*/ ) {
84
+
85
+ const previousModelViewMatrix = this.previousCameraViewMatrix.mul( this.previousModelWorldMatrix );
86
+
87
+ const clipPositionCurrent = cameraProjectionMatrix.mul( modelViewMatrix ).mul( positionLocal );
88
+ const clipPositionPrevious = this.previousProjectionMatrix.mul( previousModelViewMatrix ).mul( positionPrevious );
89
+
90
+ const ndcPositionCurrent = clipPositionCurrent.xy.div( clipPositionCurrent.w );
91
+ const ndcPositionPrevious = clipPositionPrevious.xy.div( clipPositionPrevious.w );
92
+
93
+ const velocity = sub( ndcPositionCurrent, ndcPositionPrevious );
94
+
95
+ return velocity;
96
+
97
+ }
98
+
99
+ }
100
+
101
+ function getData( object ) {
102
+
103
+ let objectData = _objectData.get( object );
104
+
105
+ if ( objectData === undefined ) {
106
+
107
+ objectData = {};
108
+ _objectData.set( object, objectData );
109
+
110
+ }
111
+
112
+ return objectData;
113
+
114
+ }
115
+
116
+ function getPreviousMatrix( object, index = 0 ) {
117
+
118
+ const objectData = getData( object );
119
+
120
+ let matrix = objectData[ index ];
121
+
122
+ if ( matrix === undefined ) {
123
+
124
+ objectData[ index ] = matrix = new Matrix4();
125
+
126
+ }
127
+
128
+ return matrix;
129
+
130
+ }
131
+
132
+ export default VelocityNode;
133
+
134
+ export const velocity = /*@__PURE__*/ nodeImmutable( VelocityNode );
@@ -1,11 +1,16 @@
1
- import { addNodeClass } from '../core/Node.js';
2
1
  import AttributeNode from '../core/AttributeNode.js';
3
- import { nodeObject } from '../shadernode/ShaderNode.js';
2
+ import { nodeObject } from '../tsl/TSLBase.js';
4
3
 
5
4
  import { Vector4 } from '../../math/Vector4.js';
6
5
 
7
6
  class VertexColorNode extends AttributeNode {
8
7
 
8
+ static get type() {
9
+
10
+ return 'VertexColorNode';
11
+
12
+ }
13
+
9
14
  constructor( index = 0 ) {
10
15
 
11
16
  super( null, 'vec4' );
@@ -67,5 +72,3 @@ class VertexColorNode extends AttributeNode {
67
72
  export default VertexColorNode;
68
73
 
69
74
  export const vertexColor = ( ...params ) => nodeObject( new VertexColorNode( ...params ) );
70
-
71
- addNodeClass( 'VertexColorNode', VertexColorNode );
@@ -1,8 +1,14 @@
1
- import Node, { addNodeClass } from '../core/Node.js';
2
- import { nodeProxy } from '../shadernode/ShaderNode.js';
1
+ import Node from '../core/Node.js';
2
+ import { nodeProxy } from '../tsl/TSLBase.js';
3
3
 
4
4
  class CodeNode extends Node {
5
5
 
6
+ static get type() {
7
+
8
+ return 'CodeNode';
9
+
10
+ }
11
+
6
12
  constructor( code = '', includes = [], language = '' ) {
7
13
 
8
14
  super( 'code' );
@@ -75,10 +81,8 @@ class CodeNode extends Node {
75
81
 
76
82
  export default CodeNode;
77
83
 
78
- export const code = nodeProxy( CodeNode );
84
+ export const code = /*@__PURE__*/ nodeProxy( CodeNode );
79
85
 
80
86
  export const js = ( src, includes ) => code( src, includes, 'js' );
81
87
  export const wgsl = ( src, includes ) => code( src, includes, 'wgsl' );
82
88
  export const glsl = ( src, includes ) => code( src, includes, 'glsl' );
83
-
84
- addNodeClass( 'CodeNode', CodeNode );
@@ -1,8 +1,14 @@
1
- import Node, { addNodeClass } from '../core/Node.js';
2
- import { nodeProxy } from '../shadernode/ShaderNode.js';
1
+ import Node from '../core/Node.js';
2
+ import { nodeProxy } from '../tsl/TSLCore.js';
3
3
 
4
4
  class ExpressionNode extends Node {
5
5
 
6
+ static get type() {
7
+
8
+ return 'ExpressionNode';
9
+
10
+ }
11
+
6
12
  constructor( snippet = '', nodeType = 'void' ) {
7
13
 
8
14
  super( nodeType );
@@ -18,7 +24,7 @@ class ExpressionNode extends Node {
18
24
 
19
25
  if ( type === 'void' ) {
20
26
 
21
- builder.addLineFlowCode( snippet );
27
+ builder.addLineFlowCode( snippet, this );
22
28
 
23
29
  } else {
24
30
 
@@ -32,6 +38,4 @@ class ExpressionNode extends Node {
32
38
 
33
39
  export default ExpressionNode;
34
40
 
35
- export const expression = nodeProxy( ExpressionNode );
36
-
37
- addNodeClass( 'ExpressionNode', ExpressionNode );
41
+ export const expression = /*@__PURE__*/ nodeProxy( ExpressionNode );
@@ -1,9 +1,14 @@
1
1
  import TempNode from '../core/TempNode.js';
2
- import { addNodeClass } from '../core/Node.js';
3
- import { addNodeElement, nodeArray, nodeObject, nodeObjects } from '../shadernode/ShaderNode.js';
2
+ import { addMethodChaining, nodeArray, nodeObject, nodeObjects } from '../tsl/TSLCore.js';
4
3
 
5
4
  class FunctionCallNode extends TempNode {
6
5
 
6
+ static get type() {
7
+
8
+ return 'FunctionCallNode';
9
+
10
+ }
11
+
7
12
  constructor( functionNode = null, parameters = {} ) {
8
13
 
9
14
  super();
@@ -91,6 +96,4 @@ export const call = ( func, ...params ) => {
91
96
 
92
97
  };
93
98
 
94
- addNodeElement( 'call', call );
95
-
96
- addNodeClass( 'FunctionCallNode', FunctionCallNode );
99
+ addMethodChaining( 'call', call );
@@ -1,15 +1,18 @@
1
1
  import CodeNode from './CodeNode.js';
2
- import { addNodeClass } from '../core/Node.js';
3
- import { nodeObject } from '../shadernode/ShaderNode.js';
2
+ import { nodeObject } from '../tsl/TSLBase.js';
4
3
 
5
4
  class FunctionNode extends CodeNode {
6
5
 
6
+ static get type() {
7
+
8
+ return 'FunctionNode';
9
+
10
+ }
11
+
7
12
  constructor( code = '', includes = [], language = '' ) {
8
13
 
9
14
  super( code, includes, language );
10
15
 
11
- this.keywords = {};
12
-
13
16
  }
14
17
 
15
18
  getNodeType( builder ) {
@@ -63,23 +66,7 @@ class FunctionNode extends CodeNode {
63
66
 
64
67
  const propertyName = builder.getPropertyName( nodeCode );
65
68
 
66
- let code = this.getNodeFunction( builder ).getCode( propertyName );
67
-
68
- const keywords = this.keywords;
69
- const keywordsProperties = Object.keys( keywords );
70
-
71
- if ( keywordsProperties.length > 0 ) {
72
-
73
- for ( const property of keywordsProperties ) {
74
-
75
- const propertyRegExp = new RegExp( `\\b${property}\\b`, 'g' );
76
- const nodeProperty = keywords[ property ].build( builder, 'property' );
77
-
78
- code = code.replace( propertyRegExp, nodeProperty );
79
-
80
- }
81
-
82
- }
69
+ const code = this.getNodeFunction( builder ).getCode( propertyName );
83
70
 
84
71
  nodeCode.code = code + '\n';
85
72
 
@@ -126,5 +113,3 @@ const nativeFn = ( code, includes = [], language = '' ) => {
126
113
 
127
114
  export const glslFn = ( code, includes ) => nativeFn( code, includes, 'glsl' );
128
115
  export const wgslFn = ( code, includes ) => nativeFn( code, includes, 'wgsl' );
129
-
130
- addNodeClass( 'FunctionNode', FunctionNode );
@@ -1,6 +1,7 @@
1
- import Node, { addNodeClass } from '../core/Node.js';
1
+ import Node from '../core/Node.js';
2
2
  import { scriptableValue } from './ScriptableValueNode.js';
3
- import { addNodeElement, nodeProxy, float } from '../shadernode/ShaderNode.js';
3
+ import { nodeProxy, float } from '../tsl/TSLBase.js';
4
+ import { hashArray, hashString } from '../core/NodeUtils.js';
4
5
 
5
6
  class Resources extends Map {
6
7
 
@@ -61,6 +62,12 @@ export const global = new Resources();
61
62
 
62
63
  class ScriptableNode extends Node {
63
64
 
65
+ static get type() {
66
+
67
+ return 'ScriptableNode';
68
+
69
+ }
70
+
64
71
  constructor( codeNode = null, parameters = {} ) {
65
72
 
66
73
  super();
@@ -439,15 +446,15 @@ class ScriptableNode extends Node {
439
446
 
440
447
  getCacheKey( force ) {
441
448
 
442
- const cacheKey = [ this.source, this.getDefaultOutputNode().getCacheKey( force ) ];
449
+ const values = [ hashString( this.source ), this.getDefaultOutputNode().getCacheKey( force ) ];
443
450
 
444
451
  for ( const param in this.parameters ) {
445
452
 
446
- cacheKey.push( this.parameters[ param ].getCacheKey( force ) );
453
+ values.push( this.parameters[ param ].getCacheKey( force ) );
447
454
 
448
455
  }
449
456
 
450
- return cacheKey.join( ',' );
457
+ return hashArray( values );
451
458
 
452
459
  }
453
460
 
@@ -495,8 +502,4 @@ class ScriptableNode extends Node {
495
502
 
496
503
  export default ScriptableNode;
497
504
 
498
- export const scriptable = nodeProxy( ScriptableNode );
499
-
500
- addNodeElement( 'scriptable', scriptable );
501
-
502
- addNodeClass( 'ScriptableNode', ScriptableNode );
505
+ export const scriptable = /*@__PURE__*/ nodeProxy( ScriptableNode );
@@ -1,11 +1,17 @@
1
- import Node, { addNodeClass } from '../core/Node.js';
1
+ import Node from '../core/Node.js';
2
2
  import { arrayBufferToBase64, base64ToArrayBuffer } from '../core/NodeUtils.js';
3
- import { addNodeElement, nodeProxy, float } from '../shadernode/ShaderNode.js';
3
+ import { nodeProxy, float } from '../tsl/TSLBase.js';
4
4
 
5
5
  import { EventDispatcher } from '../../core/EventDispatcher.js';
6
6
 
7
7
  class ScriptableValueNode extends Node {
8
8
 
9
+ static get type() {
10
+
11
+ return 'ScriptableValueNode';
12
+
13
+ }
14
+
9
15
  constructor( value = null ) {
10
16
 
11
17
  super();
@@ -161,8 +167,4 @@ class ScriptableValueNode extends Node {
161
167
 
162
168
  export default ScriptableValueNode;
163
169
 
164
- export const scriptableValue = nodeProxy( ScriptableValueNode );
165
-
166
- addNodeElement( 'scriptableValue', scriptableValue );
167
-
168
- addNodeClass( 'ScriptableValueNode', ScriptableValueNode );
170
+ export const scriptableValue = /*@__PURE__*/ nodeProxy( ScriptableValueNode );