super-three 0.168.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 (286) hide show
  1. package/build/three.cjs +369 -131
  2. package/build/three.module.js +369 -131
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +24644 -22406
  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 -6
  9. package/examples/jsm/controls/TrackballControls.js +32 -12
  10. package/examples/jsm/controls/TransformControls.js +97 -62
  11. package/examples/jsm/exporters/DRACOExporter.js +4 -2
  12. package/examples/jsm/exporters/EXRExporter.js +19 -11
  13. package/examples/jsm/exporters/KTX2Exporter.js +21 -13
  14. package/examples/jsm/exporters/OBJExporter.js +5 -1
  15. package/examples/jsm/exporters/PLYExporter.js +9 -7
  16. package/examples/jsm/geometries/DecalGeometry.js +4 -1
  17. package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
  18. package/examples/jsm/helpers/LightProbeHelper.js +1 -1
  19. package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
  20. package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
  21. package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
  22. package/examples/jsm/libs/ktx-parse.module.js +1 -1
  23. package/examples/jsm/lights/LightProbeGenerator.js +24 -10
  24. package/examples/jsm/loaders/ColladaLoader.js +9 -6
  25. package/examples/jsm/loaders/DRACOLoader.js +3 -1
  26. package/examples/jsm/loaders/FBXLoader.js +30 -20
  27. package/examples/jsm/loaders/GLTFLoader.js +5 -10
  28. package/examples/jsm/loaders/KTX2Loader.js +10 -7
  29. package/examples/jsm/loaders/MTLLoader.js +4 -3
  30. package/examples/jsm/loaders/MaterialXLoader.js +29 -10
  31. package/examples/jsm/loaders/OBJLoader.js +5 -3
  32. package/examples/jsm/loaders/PCDLoader.js +5 -4
  33. package/examples/jsm/loaders/PDBLoader.js +3 -2
  34. package/examples/jsm/loaders/PLYLoader.js +8 -5
  35. package/examples/jsm/loaders/STLLoader.js +3 -2
  36. package/examples/jsm/loaders/VRMLLoader.js +10 -10
  37. package/examples/jsm/loaders/VTKLoader.js +4 -3
  38. package/examples/jsm/loaders/XYZLoader.js +3 -2
  39. package/examples/jsm/misc/Timer.js +1 -1
  40. package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
  41. package/examples/jsm/objects/LensflareMesh.js +322 -0
  42. package/examples/jsm/objects/SkyMesh.js +1 -2
  43. package/examples/jsm/objects/Water2Mesh.js +2 -3
  44. package/examples/jsm/objects/WaterMesh.js +1 -2
  45. package/examples/jsm/physics/JoltPhysics.js +1 -1
  46. package/examples/jsm/physics/RapierPhysics.js +1 -1
  47. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  48. package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
  49. package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
  50. package/examples/jsm/utils/ShadowMapViewer.js +3 -8
  51. package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
  52. package/examples/jsm/utils/SkeletonUtils.js +84 -66
  53. package/examples/jsm/utils/TextureUtils.js +1 -0
  54. package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
  55. package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
  56. package/package.json +2 -2
  57. package/src/Three.WebGPU.Nodes.js +200 -0
  58. package/src/Three.WebGPU.js +2 -1
  59. package/src/audio/Audio.js +2 -2
  60. package/src/constants.js +1 -1
  61. package/src/core/BufferAttribute.js +0 -9
  62. package/src/core/Clock.js +1 -1
  63. package/src/core/InterleavedBuffer.js +0 -9
  64. package/src/extras/Controls.js +1 -1
  65. package/src/geometries/CylinderGeometry.js +11 -4
  66. package/src/loaders/MaterialLoader.js +7 -1
  67. package/src/loaders/nodes/NodeLoader.js +24 -4
  68. package/src/loaders/nodes/NodeMaterialLoader.js +21 -17
  69. package/src/loaders/nodes/NodeObjectLoader.js +19 -0
  70. package/src/materials/nodes/InstancedPointsNodeMaterial.js +19 -34
  71. package/src/materials/nodes/Line2NodeMaterial.js +26 -26
  72. package/src/materials/nodes/LineBasicNodeMaterial.js +7 -3
  73. package/src/materials/nodes/LineDashedNodeMaterial.js +7 -3
  74. package/src/materials/nodes/MeshBasicNodeMaterial.js +7 -3
  75. package/src/materials/nodes/MeshLambertNodeMaterial.js +7 -3
  76. package/src/materials/nodes/MeshMatcapNodeMaterial.js +7 -3
  77. package/src/materials/nodes/MeshNormalNodeMaterial.js +7 -3
  78. package/src/materials/nodes/MeshPhongNodeMaterial.js +7 -3
  79. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +6 -3
  80. package/src/materials/nodes/MeshSSSNodeMaterial.js +6 -3
  81. package/src/materials/nodes/MeshStandardNodeMaterial.js +7 -3
  82. package/src/materials/nodes/MeshToonNodeMaterial.js +7 -3
  83. package/src/materials/nodes/NodeMaterial.js +20 -45
  84. package/src/materials/nodes/NodeMaterials.js +2 -0
  85. package/src/materials/nodes/PointsNodeMaterial.js +7 -3
  86. package/src/materials/nodes/ShadowNodeMaterial.js +7 -3
  87. package/src/materials/nodes/SpriteNodeMaterial.js +39 -6
  88. package/src/materials/nodes/VolumeNodeMaterial.js +13 -9
  89. package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
  90. package/src/math/Triangle.js +24 -0
  91. package/src/nodes/Nodes.js +3 -3
  92. package/src/nodes/TSL.js +96 -93
  93. package/src/nodes/accessors/BatchNode.js +7 -3
  94. package/src/nodes/accessors/BufferAttributeNode.js +6 -3
  95. package/src/nodes/accessors/BufferNode.js +6 -3
  96. package/src/nodes/accessors/Camera.js +10 -16
  97. package/src/nodes/accessors/ClippingNode.js +7 -3
  98. package/src/nodes/accessors/CubeTextureNode.js +6 -3
  99. package/src/nodes/accessors/InstanceNode.js +11 -11
  100. package/src/nodes/accessors/InstancedPointsMaterialNode.js +6 -3
  101. package/src/nodes/accessors/Lights.js +51 -0
  102. package/src/nodes/accessors/MaterialNode.js +8 -4
  103. package/src/nodes/accessors/MaterialReferenceNode.js +6 -3
  104. package/src/nodes/accessors/ModelNode.js +42 -7
  105. package/src/nodes/accessors/ModelViewProjectionNode.js +9 -5
  106. package/src/nodes/accessors/MorphNode.js +7 -3
  107. package/src/nodes/accessors/Normal.js +32 -6
  108. package/src/nodes/accessors/Object3DNode.js +11 -27
  109. package/src/nodes/accessors/PointUVNode.js +7 -3
  110. package/src/nodes/accessors/ReferenceBaseNode.js +32 -4
  111. package/src/nodes/accessors/ReferenceNode.js +40 -3
  112. package/src/nodes/accessors/RendererReferenceNode.js +9 -3
  113. package/src/nodes/accessors/SceneNode.js +7 -3
  114. package/src/nodes/accessors/SkinningNode.js +7 -3
  115. package/src/nodes/accessors/StorageBufferNode.js +21 -3
  116. package/src/nodes/accessors/StorageTextureNode.js +7 -4
  117. package/src/nodes/accessors/Texture3DNode.js +7 -4
  118. package/src/nodes/accessors/TextureNode.js +19 -8
  119. package/src/nodes/accessors/TextureSizeNode.js +8 -5
  120. package/src/nodes/accessors/UniformArrayNode.js +12 -9
  121. package/src/nodes/accessors/UserDataNode.js +9 -6
  122. package/src/nodes/accessors/VelocityNode.js +74 -23
  123. package/src/nodes/accessors/VertexColorNode.js +6 -3
  124. package/src/nodes/code/CodeNode.js +7 -3
  125. package/src/nodes/code/ExpressionNode.js +8 -4
  126. package/src/nodes/code/FunctionCallNode.js +6 -3
  127. package/src/nodes/code/FunctionNode.js +6 -3
  128. package/src/nodes/code/ScriptableNode.js +11 -6
  129. package/src/nodes/code/ScriptableValueNode.js +7 -3
  130. package/src/nodes/core/AssignNode.js +9 -6
  131. package/src/nodes/core/AttributeNode.js +7 -3
  132. package/src/nodes/core/BypassNode.js +8 -4
  133. package/src/nodes/core/CacheNode.js +8 -4
  134. package/src/nodes/core/ConstNode.js +6 -3
  135. package/src/nodes/core/ContextNode.js +7 -3
  136. package/src/nodes/core/IndexNode.js +25 -3
  137. package/src/nodes/core/InputNode.js +7 -3
  138. package/src/nodes/core/MRTNode.js +6 -3
  139. package/src/nodes/core/Node.js +10 -51
  140. package/src/nodes/core/NodeBuilder.js +71 -5
  141. package/src/nodes/core/NodeUtils.js +48 -6
  142. package/src/nodes/core/OutputStructNode.js +8 -4
  143. package/src/nodes/core/ParameterNode.js +6 -3
  144. package/src/nodes/core/PropertyNode.js +7 -3
  145. package/src/nodes/core/StackNode.js +7 -3
  146. package/src/nodes/core/StructTypeNode.js +7 -3
  147. package/src/nodes/core/TempNode.js +8 -4
  148. package/src/nodes/core/UniformGroupNode.js +10 -6
  149. package/src/nodes/core/UniformNode.js +6 -3
  150. package/src/nodes/core/VarNode.js +8 -4
  151. package/src/nodes/core/VaryingNode.js +7 -3
  152. package/src/nodes/display/AfterImageNode.js +6 -0
  153. package/src/nodes/display/AnaglyphPassNode.js +6 -0
  154. package/src/nodes/display/AnamorphicNode.js +6 -0
  155. package/src/nodes/display/BloomNode.js +6 -0
  156. package/src/nodes/display/BumpMapNode.js +6 -0
  157. package/src/nodes/display/ColorSpaceFunctions.js +4 -4
  158. package/src/nodes/display/ColorSpaceNode.js +43 -14
  159. package/src/nodes/display/DenoiseNode.js +6 -3
  160. package/src/nodes/display/DepthOfFieldNode.js +6 -3
  161. package/src/nodes/display/DotScreenNode.js +8 -5
  162. package/src/nodes/display/FXAANode.js +6 -3
  163. package/src/nodes/display/FilmNode.js +6 -3
  164. package/src/nodes/display/FrontFacingNode.js +7 -3
  165. package/src/nodes/display/GTAONode.js +6 -3
  166. package/src/nodes/display/GaussianBlurNode.js +6 -3
  167. package/src/nodes/display/Lut3DNode.js +6 -3
  168. package/src/nodes/display/NormalMapNode.js +8 -6
  169. package/src/nodes/display/ParallaxBarrierPassNode.js +8 -5
  170. package/src/nodes/display/PassNode.js +18 -7
  171. package/src/nodes/display/PixelationPassNode.js +12 -5
  172. package/src/nodes/display/PosterizeNode.js +6 -3
  173. package/src/nodes/display/RGBShiftNode.js +6 -3
  174. package/src/nodes/display/RenderOutputNode.js +12 -8
  175. package/src/nodes/display/SSAAPassNode.js +6 -3
  176. package/src/nodes/display/ScreenNode.js +181 -0
  177. package/src/nodes/display/SobelOperatorNode.js +6 -3
  178. package/src/nodes/display/StereoCompositePassNode.js +6 -3
  179. package/src/nodes/display/StereoPassNode.js +6 -3
  180. package/src/nodes/display/ToneMappingFunctions.js +12 -12
  181. package/src/nodes/display/ToneMappingNode.js +8 -7
  182. package/src/nodes/display/ToonOutlinePassNode.js +111 -0
  183. package/src/nodes/display/TransitionNode.js +6 -3
  184. package/src/nodes/display/ViewportDepthNode.js +7 -3
  185. package/src/nodes/display/ViewportDepthTextureNode.js +8 -5
  186. package/src/nodes/display/ViewportSharedTextureNode.js +8 -5
  187. package/src/nodes/display/ViewportTextureNode.js +8 -5
  188. package/src/nodes/fog/FogExp2Node.js +6 -3
  189. package/src/nodes/fog/FogNode.js +7 -3
  190. package/src/nodes/fog/FogRangeNode.js +6 -3
  191. package/src/nodes/functions/PhysicalLightingModel.js +2 -2
  192. package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
  193. package/src/nodes/geometry/RangeNode.js +7 -3
  194. package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
  195. package/src/nodes/gpgpu/BarrierNode.js +40 -0
  196. package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
  197. package/src/nodes/gpgpu/ComputeNode.js +8 -4
  198. package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
  199. package/src/nodes/lighting/AONode.js +6 -3
  200. package/src/nodes/lighting/AmbientLightNode.js +6 -3
  201. package/src/nodes/lighting/AnalyticLightNode.js +198 -30
  202. package/src/nodes/lighting/BasicEnvironmentNode.js +6 -3
  203. package/src/nodes/lighting/BasicLightMapNode.js +6 -3
  204. package/src/nodes/lighting/DirectionalLightNode.js +7 -4
  205. package/src/nodes/lighting/EnvironmentNode.js +6 -3
  206. package/src/nodes/lighting/HemisphereLightNode.js +10 -6
  207. package/src/nodes/lighting/IESSpotLightNode.js +6 -3
  208. package/src/nodes/lighting/IrradianceNode.js +6 -3
  209. package/src/nodes/lighting/LightProbeNode.js +8 -31
  210. package/src/nodes/lighting/LightingContextNode.js +6 -3
  211. package/src/nodes/lighting/LightingNode.js +7 -3
  212. package/src/nodes/lighting/LightsNode.js +24 -5
  213. package/src/nodes/lighting/PointLightNode.js +11 -7
  214. package/src/nodes/lighting/RectAreaLightNode.js +11 -7
  215. package/src/nodes/lighting/SpotLightNode.js +13 -10
  216. package/src/nodes/math/ConditionalNode.js +23 -6
  217. package/src/nodes/math/MathNode.js +6 -3
  218. package/src/nodes/math/OperatorNode.js +6 -3
  219. package/src/nodes/pmrem/PMREMNode.js +6 -3
  220. package/src/nodes/utils/ArrayElementNode.js +8 -4
  221. package/src/nodes/utils/ConvertNode.js +7 -3
  222. package/src/nodes/utils/CubeMapNode.js +6 -3
  223. package/src/nodes/utils/EquirectUVNode.js +6 -3
  224. package/src/nodes/utils/FlipNode.js +7 -4
  225. package/src/nodes/utils/FunctionOverloadingNode.js +7 -3
  226. package/src/nodes/utils/JoinNode.js +6 -3
  227. package/src/nodes/utils/LoopNode.js +7 -3
  228. package/src/nodes/utils/MatcapUVNode.js +6 -3
  229. package/src/nodes/utils/MaxMipLevelNode.js +6 -3
  230. package/src/nodes/utils/OscNode.js +7 -3
  231. package/src/nodes/utils/RTTNode.js +6 -3
  232. package/src/nodes/utils/ReflectorNode.js +8 -5
  233. package/src/nodes/utils/RemapNode.js +7 -3
  234. package/src/nodes/utils/RotateNode.js +6 -3
  235. package/src/nodes/utils/SetNode.js +7 -4
  236. package/src/nodes/utils/SplitNode.js +7 -3
  237. package/src/nodes/utils/SpriteSheetUVNode.js +7 -3
  238. package/src/nodes/utils/StorageArrayElementNode.js +9 -8
  239. package/src/nodes/utils/TimerNode.js +6 -3
  240. package/src/nodes/utils/TriplanarTexturesNode.js +7 -3
  241. package/src/nodes/utils/ViewportUtils.js +2 -2
  242. package/src/objects/BatchedMesh.js +76 -10
  243. package/src/objects/LOD.js +21 -0
  244. package/src/objects/Line.js +1 -0
  245. package/src/objects/Mesh.js +7 -23
  246. package/src/objects/Points.js +2 -0
  247. package/src/renderers/WebGLRenderer.js +64 -41
  248. package/src/renderers/common/BundleGroup.js +26 -0
  249. package/src/renderers/common/ClippingContext.js +4 -3
  250. package/src/renderers/common/RenderContext.js +4 -5
  251. package/src/renderers/common/RenderObject.js +116 -5
  252. package/src/renderers/common/RenderObjects.js +8 -1
  253. package/src/renderers/common/Renderer.js +57 -49
  254. package/src/renderers/common/extras/PMREMGenerator.js +7 -9
  255. package/src/renderers/common/nodes/NodeBuilderState.js +3 -3
  256. package/src/renderers/common/nodes/Nodes.js +33 -14
  257. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
  258. package/src/renderers/webgl/WebGLAttributes.js +45 -14
  259. package/src/renderers/webgl/WebGLCapabilities.js +9 -0
  260. package/src/renderers/webgl/WebGLProgram.js +2 -0
  261. package/src/renderers/webgl/WebGLPrograms.js +21 -17
  262. package/src/renderers/webgl/WebGLState.js +21 -0
  263. package/src/renderers/webgl/WebGLTextures.js +22 -0
  264. package/src/renderers/webgl-fallback/WebGLBackend.js +50 -45
  265. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +4 -4
  266. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
  267. package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -4
  268. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +61 -16
  269. package/src/renderers/webgpu/WebGPUBackend.js +33 -25
  270. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
  271. package/src/renderers/webgpu/WebGPURenderer.js +5 -2
  272. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
  273. package/src/renderers/{common → webgpu}/nodes/StandardNodeLibrary.js +11 -11
  274. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +91 -11
  275. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
  276. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1 -1
  277. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +7 -5
  278. package/src/renderers/webgpu/utils/WebGPUUtils.js +1 -1
  279. package/src/utils.js +33 -1
  280. package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
  281. package/examples/jsm/loaders/TiltLoader.js +0 -520
  282. package/examples/jsm/utils/GPUStatsPanel.js +0 -95
  283. package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
  284. package/src/nodes/display/ViewportNode.js +0 -138
  285. package/src/nodes/lighting/LightNode.js +0 -57
  286. package/src/renderers/common/StandardRenderer.js +0 -18
@@ -1,9 +1,15 @@
1
- import Node, { registerNode } from '../core/Node.js';
1
+ import Node from '../core/Node.js';
2
2
  import { positionView } from '../accessors/Position.js';
3
3
  import { nodeProxy } from '../tsl/TSLBase.js';
4
4
 
5
5
  class FogNode extends Node {
6
6
 
7
+ static get type() {
8
+
9
+ return 'FogNode';
10
+
11
+ }
12
+
7
13
  constructor( colorNode, factorNode ) {
8
14
 
9
15
  super( 'float' );
@@ -41,6 +47,4 @@ class FogNode extends Node {
41
47
 
42
48
  export default FogNode;
43
49
 
44
- FogNode.type = /*@__PURE__*/ registerNode( 'Fog', FogNode );
45
-
46
50
  export const fog = /*@__PURE__*/ nodeProxy( FogNode );
@@ -1,10 +1,15 @@
1
- import { registerNode } from '../core/Node.js';
2
1
  import FogNode from './FogNode.js';
3
2
  import { smoothstep } from '../math/MathNode.js';
4
3
  import { nodeProxy } from '../tsl/TSLBase.js';
5
4
 
6
5
  class FogRangeNode extends FogNode {
7
6
 
7
+ static get type() {
8
+
9
+ return 'FogRangeNode';
10
+
11
+ }
12
+
8
13
  constructor( colorNode, nearNode, farNode ) {
9
14
 
10
15
  super( colorNode );
@@ -28,6 +33,4 @@ class FogRangeNode extends FogNode {
28
33
 
29
34
  export default FogRangeNode;
30
35
 
31
- FogRangeNode.type = /*@__PURE__*/ registerNode( 'FogRange', FogRangeNode );
32
-
33
36
  export const rangeFog = /*@__PURE__*/ nodeProxy( FogRangeNode );
@@ -16,7 +16,7 @@ import { mix, normalize, refract, length, clamp, log2, log, exp, smoothstep } fr
16
16
  import { div } from '../math/OperatorNode.js';
17
17
  import { cameraPosition, cameraProjectionMatrix, cameraViewMatrix } from '../accessors/Camera.js';
18
18
  import { modelWorldMatrix } from '../accessors/ModelNode.js';
19
- import { viewportResolution } from '../display/ViewportNode.js';
19
+ import { screenSize } from '../display/ScreenNode.js';
20
20
  import { viewportMipTexture } from '../display/ViewportTextureNode.js';
21
21
  import { textureBicubic } from '../accessors/TextureBicubic.js';
22
22
  import { Loop } from '../utils/LoopNode.js';
@@ -74,7 +74,7 @@ const getTransmissionSample = /*@__PURE__*/ Fn( ( [ fragCoord, roughness, ior ]
74
74
  const transmissionSample = singleViewportMipTexture.uv( fragCoord );
75
75
  //const transmissionSample = viewportMipTexture( fragCoord );
76
76
 
77
- const lod = log2( float( viewportResolution.x ) ).mul( applyIorToRoughness( roughness, ior ) );
77
+ const lod = log2( float( screenSize.x ) ).mul( applyIorToRoughness( roughness, ior ) );
78
78
 
79
79
  return textureBicubic( transmissionSample, lod );
80
80
 
@@ -0,0 +1,28 @@
1
+ import { Fn, mul } from '../../tsl/TSLBase.js';
2
+
3
+ const getShIrradianceAt = /*@__PURE__*/ Fn( ( [ normal, shCoefficients ] ) => {
4
+
5
+ // normal is assumed to have unit length
6
+
7
+ const x = normal.x, y = normal.y, z = normal.z;
8
+
9
+ // band 0
10
+ let result = shCoefficients.element( 0 ).mul( 0.886227 );
11
+
12
+ // band 1
13
+ result = result.add( shCoefficients.element( 1 ).mul( 2.0 * 0.511664 ).mul( y ) );
14
+ result = result.add( shCoefficients.element( 2 ).mul( 2.0 * 0.511664 ).mul( z ) );
15
+ result = result.add( shCoefficients.element( 3 ).mul( 2.0 * 0.511664 ).mul( x ) );
16
+
17
+ // band 2
18
+ result = result.add( shCoefficients.element( 4 ).mul( 2.0 * 0.429043 ).mul( x ).mul( y ) );
19
+ result = result.add( shCoefficients.element( 5 ).mul( 2.0 * 0.429043 ).mul( y ).mul( z ) );
20
+ result = result.add( shCoefficients.element( 6 ).mul( z.mul( z ).mul( 0.743125 ).sub( 0.247708 ) ) );
21
+ result = result.add( shCoefficients.element( 7 ).mul( 2.0 * 0.429043 ).mul( x ).mul( z ) );
22
+ result = result.add( shCoefficients.element( 8 ).mul( 0.429043 ).mul( mul( x, x ).sub( mul( y, y ) ) ) );
23
+
24
+ return result;
25
+
26
+ } );
27
+
28
+ export default getShIrradianceAt;
@@ -1,4 +1,4 @@
1
- import Node, { registerNode } from '../core/Node.js';
1
+ import Node from '../core/Node.js';
2
2
  import { getValueType } from '../core/NodeUtils.js';
3
3
  import { buffer } from '../accessors/BufferNode.js';
4
4
  import { instancedBufferAttribute } from '../accessors/BufferAttributeNode.js';
@@ -14,6 +14,12 @@ let max = null;
14
14
 
15
15
  class RangeNode extends Node {
16
16
 
17
+ static get type() {
18
+
19
+ return 'RangeNode';
20
+
21
+ }
22
+
17
23
  constructor( minNode = float(), maxNode = float() ) {
18
24
 
19
25
  super();
@@ -112,6 +118,4 @@ class RangeNode extends Node {
112
118
 
113
119
  export default RangeNode;
114
120
 
115
- RangeNode.type = /*@__PURE__*/ registerNode( 'Range', RangeNode );
116
-
117
121
  export const range = /*@__PURE__*/ nodeProxy( RangeNode );
@@ -0,0 +1,99 @@
1
+ import TempNode from '../core/TempNode.js';
2
+ import { nodeProxy } from '../tsl/TSLCore.js';
3
+
4
+ class AtomicFunctionNode extends TempNode {
5
+
6
+ static get type() {
7
+
8
+ return 'AtomicFunctionNode';
9
+
10
+ }
11
+
12
+ constructor( method, pointerNode, valueNode, storeNode = null ) {
13
+
14
+ super( 'uint' );
15
+
16
+ this.method = method;
17
+
18
+ this.pointerNode = pointerNode;
19
+ this.valueNode = valueNode;
20
+ this.storeNode = storeNode;
21
+
22
+ }
23
+
24
+ getInputType( builder ) {
25
+
26
+ return this.pointerNode.getNodeType( builder );
27
+
28
+ }
29
+
30
+ getNodeType( builder ) {
31
+
32
+ return this.getInputType( builder );
33
+
34
+ }
35
+
36
+ generate( builder ) {
37
+
38
+ const method = this.method;
39
+
40
+ const type = this.getNodeType( builder );
41
+ const inputType = this.getInputType( builder );
42
+
43
+ const a = this.pointerNode;
44
+ const b = this.valueNode;
45
+
46
+ const params = [];
47
+
48
+ params.push( `&${ a.build( builder, inputType ) }` );
49
+ params.push( b.build( builder, inputType ) );
50
+
51
+ const methodSnippet = `${ builder.getMethod( method, type ) }( ${params.join( ', ' )} )`;
52
+
53
+ if ( this.storeNode !== null ) {
54
+
55
+ const varSnippet = this.storeNode.build( builder, inputType );
56
+
57
+ builder.addLineFlowCode( `${varSnippet} = ${methodSnippet}`, this );
58
+
59
+ } else {
60
+
61
+ builder.addLineFlowCode( methodSnippet, this );
62
+
63
+ }
64
+
65
+ }
66
+
67
+ }
68
+
69
+ AtomicFunctionNode.ATOMIC_LOAD = 'atomicLoad';
70
+ AtomicFunctionNode.ATOMIC_STORE = 'atomicStore';
71
+ AtomicFunctionNode.ATOMIC_ADD = 'atomicAdd';
72
+ AtomicFunctionNode.ATOMIC_SUB = 'atomicSub';
73
+ AtomicFunctionNode.ATOMIC_MAX = 'atomicMax';
74
+ AtomicFunctionNode.ATOMIC_MIN = 'atomicMin';
75
+ AtomicFunctionNode.ATOMIC_AND = 'atomicAnd';
76
+ AtomicFunctionNode.ATOMIC_OR = 'atomicOr';
77
+ AtomicFunctionNode.ATOMIC_XOR = 'atomicXor';
78
+
79
+ export default AtomicFunctionNode;
80
+
81
+ const atomicNode = nodeProxy( AtomicFunctionNode );
82
+
83
+ export const atomicFunc = ( method, pointerNode, valueNode, storeNode ) => {
84
+
85
+ const node = atomicNode( method, pointerNode, valueNode, storeNode );
86
+ node.append();
87
+
88
+ return node;
89
+
90
+ };
91
+
92
+ export const atomicStore = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_STORE, pointerNode, valueNode, storeNode );
93
+ export const atomicAdd = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_ADD, pointerNode, valueNode, storeNode );
94
+ export const atomicSub = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_SUB, pointerNode, valueNode, storeNode );
95
+ export const atomicMax = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_MAX, pointerNode, valueNode, storeNode );
96
+ export const atomicMin = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_MIN, pointerNode, valueNode, storeNode );
97
+ export const atomicAnd = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_AND, pointerNode, valueNode, storeNode );
98
+ export const atomicOr = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_OR, pointerNode, valueNode, storeNode );
99
+ export const atomicXor = ( pointerNode, valueNode, storeNode = null ) => atomicFunc( AtomicFunctionNode.ATOMIC_XOR, pointerNode, valueNode, storeNode );
@@ -0,0 +1,40 @@
1
+ import Node from '../core/Node.js';
2
+ import { nodeProxy } from '../tsl/TSLCore.js';
3
+
4
+ class BarrierNode extends Node {
5
+
6
+ constructor( scope ) {
7
+
8
+ super();
9
+
10
+ this.scope = scope;
11
+
12
+ }
13
+
14
+ generate( builder ) {
15
+
16
+ const { scope } = this;
17
+ const { renderer } = builder;
18
+
19
+ if ( renderer.backend.isWebGLBackend === true ) {
20
+
21
+ builder.addFlowCode( `\t// ${scope}Barrier \n` );
22
+
23
+ } else {
24
+
25
+ builder.addLineFlowCode( `${scope}Barrier()`, this );
26
+
27
+ }
28
+
29
+ }
30
+
31
+ }
32
+
33
+ export default BarrierNode;
34
+
35
+ const barrier = nodeProxy( BarrierNode );
36
+
37
+ export const workgroupBarrier = () => barrier( 'workgroup' ).append();
38
+ export const storageBarrier = () => barrier( 'storage' ).append();
39
+ export const textureBarrier = () => barrier( 'texture' ).append();
40
+
@@ -0,0 +1,98 @@
1
+ import Node from '../core/Node.js';
2
+ import { nodeObject } from '../tsl/TSLBase.js';
3
+
4
+ class ComputeBuiltinNode extends Node {
5
+
6
+ static get type() {
7
+
8
+ return 'ComputeBuiltinNode';
9
+
10
+ }
11
+
12
+ constructor( builtinName, nodeType ) {
13
+
14
+ super( nodeType );
15
+
16
+ this._builtinName = builtinName;
17
+
18
+ }
19
+
20
+ getHash( builder ) {
21
+
22
+ return this.getBuiltinName( builder );
23
+
24
+ }
25
+
26
+ getNodeType( /*builder*/ ) {
27
+
28
+ return this.nodeType;
29
+
30
+ }
31
+
32
+ setBuiltinName( builtinName ) {
33
+
34
+ this._builtinName = builtinName;
35
+
36
+ return this;
37
+
38
+ }
39
+
40
+ getBuiltinName( /*builder*/ ) {
41
+
42
+ return this._builtinName;
43
+
44
+ }
45
+
46
+ hasBuiltin( builder ) {
47
+
48
+ builder.hasBuiltin( this._builtinName );
49
+
50
+ }
51
+
52
+ generate( builder, output ) {
53
+
54
+ const builtinName = this.getBuiltinName( builder );
55
+ const nodeType = this.getNodeType( builder );
56
+
57
+ if ( builder.shaderStage === 'compute' ) {
58
+
59
+ return builder.format( builtinName, nodeType, output );
60
+
61
+ } else {
62
+
63
+ console.warn( `ComputeBuiltinNode: Compute built-in value ${builtinName} can not be accessed in the ${builder.shaderStage} stage` );
64
+ return builder.generateConst( nodeType );
65
+
66
+ }
67
+
68
+ }
69
+
70
+ serialize( data ) {
71
+
72
+ super.serialize( data );
73
+
74
+ data.global = this.global;
75
+ data._builtinName = this._builtinName;
76
+
77
+ }
78
+
79
+ deserialize( data ) {
80
+
81
+ super.deserialize( data );
82
+
83
+ this.global = data.global;
84
+ this._builtinName = data._builtinName;
85
+
86
+ }
87
+
88
+ }
89
+
90
+ export default ComputeBuiltinNode;
91
+
92
+ const computeBuiltin = ( name, nodeType ) => nodeObject( new ComputeBuiltinNode( name, nodeType ) );
93
+
94
+ export const numWorkgroups = /*@__PURE__*/ computeBuiltin( 'numWorkgroups', 'uvec3' );
95
+ export const workgroupId = /*@__PURE__*/ computeBuiltin( 'workgroupId', 'uvec3' );
96
+ export const localId = /*@__PURE__*/ computeBuiltin( 'localId', 'uvec3' );
97
+ export const subgroupSize = /*@__PURE__*/ computeBuiltin( 'subgroupSize', 'uint' );
98
+
@@ -1,9 +1,15 @@
1
- import Node, { registerNode } from '../core/Node.js';
1
+ import Node from '../core/Node.js';
2
2
  import { NodeUpdateType } from '../core/constants.js';
3
3
  import { addMethodChaining, nodeObject } from '../tsl/TSLCore.js';
4
4
 
5
5
  class ComputeNode extends Node {
6
6
 
7
+ static get type() {
8
+
9
+ return 'ComputeNode';
10
+
11
+ }
12
+
7
13
  constructor( computeNode, count, workgroupSize = [ 64 ] ) {
8
14
 
9
15
  super( 'void' );
@@ -66,7 +72,7 @@ class ComputeNode extends Node {
66
72
 
67
73
  if ( snippet !== '' ) {
68
74
 
69
- builder.addLineFlowCode( snippet );
75
+ builder.addLineFlowCode( snippet, this );
70
76
 
71
77
  }
72
78
 
@@ -78,8 +84,6 @@ class ComputeNode extends Node {
78
84
 
79
85
  export default ComputeNode;
80
86
 
81
- ComputeNode.type = /*@__PURE__*/ registerNode( 'Compute', ComputeNode );
82
-
83
87
  export const compute = ( node, count, workgroupSize ) => nodeObject( new ComputeNode( nodeObject( node ), count, workgroupSize ) );
84
88
 
85
89
  addMethodChaining( 'compute', compute );
@@ -0,0 +1,100 @@
1
+ import ArrayElementNode from '../utils/ArrayElementNode.js';
2
+ import { nodeObject } from '../tsl/TSLCore.js';
3
+ import Node from '../core/Node.js';
4
+
5
+ class WorkgroupInfoElementNode extends ArrayElementNode {
6
+
7
+ constructor( workgroupInfoNode, indexNode ) {
8
+
9
+ super( workgroupInfoNode, indexNode );
10
+
11
+ this.isWorkgroupInfoElementNode = true;
12
+
13
+ }
14
+
15
+ generate( builder, output ) {
16
+
17
+ let snippet;
18
+
19
+ const isAssignContext = builder.context.assign;
20
+ snippet = super.generate( builder );
21
+
22
+ if ( isAssignContext !== true ) {
23
+
24
+ const type = this.getNodeType( builder );
25
+
26
+ snippet = builder.format( snippet, type, output );
27
+
28
+ }
29
+
30
+ // TODO: Possibly activate clip distance index on index access rather than from clipping context
31
+
32
+ return snippet;
33
+
34
+ }
35
+
36
+ }
37
+
38
+
39
+ class WorkgroupInfoNode extends Node {
40
+
41
+ constructor( scope, bufferType, bufferCount = 0 ) {
42
+
43
+ super( bufferType );
44
+
45
+ this.bufferType = bufferType;
46
+ this.bufferCount = bufferCount;
47
+
48
+ this.isWorkgroupInfoNode = true;
49
+
50
+ this.scope = scope;
51
+
52
+ }
53
+
54
+ label( name ) {
55
+
56
+ this.name = name;
57
+
58
+ return this;
59
+
60
+ }
61
+
62
+ getHash() {
63
+
64
+ return this.uuid;
65
+
66
+ }
67
+
68
+ setScope( scope ) {
69
+
70
+ this.scope = scope;
71
+
72
+ return this;
73
+
74
+ }
75
+
76
+ getInputType( /*builder*/ ) {
77
+
78
+ return `${this.scope}Array`;
79
+
80
+ }
81
+
82
+ element( indexNode ) {
83
+
84
+ return nodeObject( new WorkgroupInfoElementNode( this, indexNode ) );
85
+
86
+ }
87
+
88
+ generate( builder ) {
89
+
90
+ return builder.getScopedArray( this.name || `${this.scope}Array_${this.id}`, this.scope.toLowerCase(), this.bufferType, this.bufferCount );
91
+
92
+ }
93
+
94
+ }
95
+
96
+ export default WorkgroupInfoNode;
97
+
98
+ export const workgroupArray = ( type, count ) => nodeObject( new WorkgroupInfoNode( 'Workgroup', type, count ) );
99
+
100
+
@@ -1,8 +1,13 @@
1
- import { registerNode } from '../core/Node.js';
2
1
  import LightingNode from './LightingNode.js';
3
2
 
4
3
  class AONode extends LightingNode {
5
4
 
5
+ static get type() {
6
+
7
+ return 'AONode';
8
+
9
+ }
10
+
6
11
  constructor( aoNode = null ) {
7
12
 
8
13
  super();
@@ -20,5 +25,3 @@ class AONode extends LightingNode {
20
25
  }
21
26
 
22
27
  export default AONode;
23
-
24
- AONode.type = /*@__PURE__*/ registerNode( 'AO', AONode );
@@ -1,8 +1,13 @@
1
- import { registerNode } from '../core/Node.js';
2
1
  import AnalyticLightNode from './AnalyticLightNode.js';
3
2
 
4
3
  class AmbientLightNode extends AnalyticLightNode {
5
4
 
5
+ static get type() {
6
+
7
+ return 'AmbientLightNode';
8
+
9
+ }
10
+
6
11
  constructor( light = null ) {
7
12
 
8
13
  super( light );
@@ -18,5 +23,3 @@ class AmbientLightNode extends AnalyticLightNode {
18
23
  }
19
24
 
20
25
  export default AmbientLightNode;
21
-
22
- AmbientLightNode.type = /*@__PURE__*/ registerNode( 'AmbientLight', AmbientLightNode );