super-three 0.168.0 → 0.169.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/build/three.cjs +384 -700
  2. package/build/three.module.js +384 -700
  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 +65 -50
  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
  287. package/src/renderers/webvr/WebVRManager.js +0 -495
  288. package/src/renderers/webvr/WebVRUtils.js +0 -66
@@ -4,12 +4,16 @@ import { getNodeChildren, getCacheKey } from './NodeUtils.js';
4
4
  import { EventDispatcher } from '../../core/EventDispatcher.js';
5
5
  import { MathUtils } from '../../math/MathUtils.js';
6
6
 
7
- const Nodes = new Map();
8
-
9
7
  let _nodeId = 0;
10
8
 
11
9
  class Node extends EventDispatcher {
12
10
 
11
+ static get type() {
12
+
13
+ return 'Node';
14
+
15
+ }
16
+
13
17
  constructor( nodeType = null ) {
14
18
 
15
19
  super();
@@ -357,6 +361,10 @@ class Node extends EventDispatcher {
357
361
 
358
362
  nodeData.snippet = result;
359
363
 
364
+ } else if ( nodeData.flowCodes !== undefined && builder.context.nodeBlock !== undefined ) {
365
+
366
+ builder.addFlowCodeHierarchy( this, builder.context.nodeBlock );
367
+
360
368
  }
361
369
 
362
370
  result = builder.format( result, type, output );
@@ -540,52 +548,3 @@ class Node extends EventDispatcher {
540
548
  }
541
549
 
542
550
  export default Node;
543
-
544
- Node.type = /*@__PURE__*/ registerNode( '', Node );
545
-
546
- export function registerNode( type, nodeClass ) {
547
-
548
- const suffix = 'Node';
549
- const nodeType = type + suffix;
550
-
551
- if ( typeof nodeClass !== 'function' ) throw new Error( `TSL.Node: Node class ${ type } is not a class` );
552
-
553
- if ( Nodes.has( nodeType ) ) {
554
-
555
- console.warn( `TSL.Node: Redefinition of node class ${ nodeType }` );
556
- return;
557
-
558
- }
559
-
560
- if ( type.slice( - suffix.length ) === suffix ) {
561
-
562
- console.warn( `TSL.Node: Node class ${ nodeType } should not have '${ suffix }' suffix.` );
563
- return;
564
-
565
- }
566
-
567
- Nodes.set( nodeType, nodeClass );
568
- nodeClass.type = nodeType;
569
-
570
- return nodeType;
571
-
572
- }
573
-
574
- export function createNodeFromType( type ) {
575
-
576
- const Class = Nodes.get( type );
577
-
578
- if ( Class !== undefined ) {
579
-
580
- return new Class();
581
-
582
- }
583
-
584
- }
585
-
586
- export function addNodeClass( type, nodeClass ) {
587
-
588
- console.warn( 'TSL.Node: Function addNodeClass() is deprecated. Use /*@__PURE__*/ registerNode() instead.' );
589
- /*@__PURE__*/ registerNode( type.slice( 0, - 4 ), nodeClass );
590
-
591
- }
@@ -79,6 +79,8 @@ class NodeBuilder {
79
79
  this.updateAfterNodes = [];
80
80
  this.hashNodes = {};
81
81
 
82
+ this.monitor = null;
83
+
82
84
  this.lightsNode = null;
83
85
  this.environmentNode = null;
84
86
  this.fogNode = null;
@@ -107,8 +109,6 @@ class NodeBuilder {
107
109
  this.stacks = [];
108
110
  this.tab = '\t';
109
111
 
110
- this.instanceBindGroups = true;
111
-
112
112
  this.currentFunctionNode = null;
113
113
 
114
114
  this.context = {
@@ -277,6 +277,23 @@ class NodeBuilder {
277
277
 
278
278
  }
279
279
 
280
+ sortBindingGroups() {
281
+
282
+ const bindingsGroups = this.getBindings();
283
+
284
+ bindingsGroups.sort( ( a, b ) => ( a.bindings[ 0 ].groupNode.order - b.bindings[ 0 ].groupNode.order ) );
285
+
286
+ for ( let i = 0; i < bindingsGroups.length; i ++ ) {
287
+
288
+ const bindingGroup = bindingsGroups[ i ];
289
+ this.bindingsIndexes[ bindingGroup.name ].group = i;
290
+
291
+ bindingGroup.index = i;
292
+
293
+ }
294
+
295
+ }
296
+
280
297
  setHashNode( node, hash ) {
281
298
 
282
299
  this.hashNodes[ hash ] = node;
@@ -311,13 +328,13 @@ class NodeBuilder {
311
328
 
312
329
  if ( updateBeforeType !== NodeUpdateType.NONE ) {
313
330
 
314
- this.updateBeforeNodes.push( node );
331
+ this.updateBeforeNodes.push( node.getSelf() );
315
332
 
316
333
  }
317
334
 
318
335
  if ( updateAfterType !== NodeUpdateType.NONE ) {
319
336
 
320
- this.updateAfterNodes.push( node );
337
+ this.updateAfterNodes.push( node.getSelf() );
321
338
 
322
339
  }
323
340
 
@@ -924,10 +941,59 @@ class NodeBuilder {
924
941
 
925
942
  }
926
943
 
927
- addLineFlowCode( code ) {
944
+ addFlowCodeHierarchy( node, nodeBlock ) {
945
+
946
+ const { flowCodes, flowCodeBlock } = this.getDataFromNode( node );
947
+
948
+ let needsFlowCode = true;
949
+ let nodeBlockHierarchy = nodeBlock;
950
+
951
+ while ( nodeBlockHierarchy ) {
952
+
953
+ if ( flowCodeBlock.get( nodeBlockHierarchy ) === true ) {
954
+
955
+ needsFlowCode = false;
956
+ break;
957
+
958
+ }
959
+
960
+ nodeBlockHierarchy = this.getDataFromNode( nodeBlockHierarchy ).parentNodeBlock;
961
+
962
+ }
963
+
964
+ if ( needsFlowCode ) {
965
+
966
+ for ( const flowCode of flowCodes ) {
967
+
968
+ this.addLineFlowCode( flowCode );
969
+
970
+ }
971
+
972
+ }
973
+
974
+ }
975
+
976
+ addLineFlowCodeBlock( node, code, nodeBlock ) {
977
+
978
+ const nodeData = this.getDataFromNode( node );
979
+ const flowCodes = nodeData.flowCodes || ( nodeData.flowCodes = [] );
980
+ const codeBlock = nodeData.flowCodeBlock || ( nodeData.flowCodeBlock = new WeakMap() );
981
+
982
+ flowCodes.push( code );
983
+ codeBlock.set( nodeBlock, true );
984
+
985
+ }
986
+
987
+ addLineFlowCode( code, node = null ) {
928
988
 
929
989
  if ( code === '' ) return this;
930
990
 
991
+ if ( node !== null && this.context.nodeBlock ) {
992
+
993
+ this.addLineFlowCodeBlock( node, code, this.context.nodeBlock );
994
+
995
+ }
996
+
931
997
  code = this.tab + code;
932
998
 
933
999
  if ( ! /;\s*$/.test( code ) ) {
@@ -5,26 +5,68 @@ import { Vector2 } from '../../math/Vector2.js';
5
5
  import { Vector3 } from '../../math/Vector3.js';
6
6
  import { Vector4 } from '../../math/Vector4.js';
7
7
 
8
+ // cyrb53 (c) 2018 bryc (github.com/bryc). License: Public domain. Attribution appreciated.
9
+ // A fast and simple 64-bit (or 53-bit) string hash function with decent collision resistance.
10
+ // Largely inspired by MurmurHash2/3, but with a focus on speed/simplicity.
11
+ // See https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript/52171480#52171480
12
+ // https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
13
+ function cyrb53( value, seed = 0 ) {
14
+
15
+ let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
16
+
17
+ if ( value instanceof Array ) {
18
+
19
+ for ( let i = 0, val; i < value.length; i ++ ) {
20
+
21
+ val = value[ i ];
22
+ h1 = Math.imul( h1 ^ val, 2654435761 );
23
+ h2 = Math.imul( h2 ^ val, 1597334677 );
24
+
25
+ }
26
+
27
+ } else {
28
+
29
+ for ( let i = 0, ch; i < value.length; i ++ ) {
30
+
31
+ ch = value.charCodeAt( i );
32
+ h1 = Math.imul( h1 ^ ch, 2654435761 );
33
+ h2 = Math.imul( h2 ^ ch, 1597334677 );
34
+
35
+ }
36
+
37
+ }
38
+
39
+ h1 = Math.imul( h1 ^ ( h1 >>> 16 ), 2246822507 );
40
+ h1 ^= Math.imul( h2 ^ ( h2 >>> 13 ), 3266489909 );
41
+ h2 = Math.imul( h2 ^ ( h2 >>> 16 ), 2246822507 );
42
+ h2 ^= Math.imul( h1 ^ ( h1 >>> 13 ), 3266489909 );
43
+
44
+ return 4294967296 * ( 2097151 & h2 ) + ( h1 >>> 0 );
45
+
46
+ }
47
+
48
+ export const hashString = ( str ) => cyrb53( str );
49
+ export const hashArray = ( array ) => cyrb53( array );
50
+ export const hash = ( ...params ) => cyrb53( params );
51
+
8
52
  export function getCacheKey( object, force = false ) {
9
53
 
10
- let cacheKey = '{';
54
+ const values = [];
11
55
 
12
56
  if ( object.isNode === true ) {
13
57
 
14
- cacheKey += object.id;
58
+ values.push( object.id );
15
59
  object = object.getSelf();
16
60
 
17
61
  }
18
62
 
19
63
  for ( const { property, childNode } of getNodeChildren( object ) ) {
20
64
 
21
- cacheKey += ',' + property.slice( 0, - 4 ) + ':' + childNode.getCacheKey( force );
65
+ values.push( values, cyrb53( property.slice( 0, - 4 ) ), childNode.getCacheKey( force ) );
22
66
 
23
67
  }
24
68
 
25
- cacheKey += '}';
26
-
27
- return cacheKey;
69
+ return cyrb53( values );
28
70
 
29
71
  }
30
72
 
@@ -1,9 +1,15 @@
1
- import Node, { registerNode } from './Node.js';
1
+ import Node from './Node.js';
2
2
  import StructTypeNode from './StructTypeNode.js';
3
3
  import { nodeProxy } from '../tsl/TSLBase.js';
4
4
 
5
5
  class OutputStructNode extends Node {
6
6
 
7
+ static get type() {
8
+
9
+ return 'OutputStructNode';
10
+
11
+ }
12
+
7
13
  constructor( ...members ) {
8
14
 
9
15
  super();
@@ -42,7 +48,7 @@ class OutputStructNode extends Node {
42
48
 
43
49
  const snippet = members[ i ].build( builder, output );
44
50
 
45
- builder.addLineFlowCode( `${ structPrefix }m${ i } = ${ snippet }` );
51
+ builder.addLineFlowCode( `${ structPrefix }m${ i } = ${ snippet }`, this );
46
52
 
47
53
  }
48
54
 
@@ -54,6 +60,4 @@ class OutputStructNode extends Node {
54
60
 
55
61
  export default OutputStructNode;
56
62
 
57
- OutputStructNode.type = /*@__PURE__*/ registerNode( 'OutputStruct', OutputStructNode );
58
-
59
63
  export const outputStruct = /*@__PURE__*/ nodeProxy( OutputStructNode );
@@ -1,9 +1,14 @@
1
- import { registerNode } from './Node.js';
2
1
  import { nodeObject } from '../tsl/TSLBase.js';
3
2
  import PropertyNode from './PropertyNode.js';
4
3
 
5
4
  class ParameterNode extends PropertyNode {
6
5
 
6
+ static get type() {
7
+
8
+ return 'ParameterNode';
9
+
10
+ }
11
+
7
12
  constructor( nodeType, name = null ) {
8
13
 
9
14
  super( nodeType, name );
@@ -28,6 +33,4 @@ class ParameterNode extends PropertyNode {
28
33
 
29
34
  export default ParameterNode;
30
35
 
31
- ParameterNode.type = /*@__PURE__*/ registerNode( 'Parameter', ParameterNode );
32
-
33
36
  export const parameter = ( type, name ) => nodeObject( new ParameterNode( type, name ) );
@@ -1,8 +1,14 @@
1
- import Node, { registerNode } from './Node.js';
1
+ import Node from './Node.js';
2
2
  import { nodeImmutable, nodeObject } from '../tsl/TSLCore.js';
3
3
 
4
4
  class PropertyNode extends Node {
5
5
 
6
+ static get type() {
7
+
8
+ return 'PropertyNode';
9
+
10
+ }
11
+
6
12
  constructor( nodeType, name = null, varying = false ) {
7
13
 
8
14
  super( nodeType );
@@ -49,8 +55,6 @@ class PropertyNode extends Node {
49
55
 
50
56
  export default PropertyNode;
51
57
 
52
- PropertyNode.type = /*@__PURE__*/ registerNode( 'Property', PropertyNode );
53
-
54
58
  export const property = ( type, name ) => nodeObject( new PropertyNode( type, name ) );
55
59
  export const varyingProperty = ( type, name ) => nodeObject( new PropertyNode( type, name, true ) );
56
60
 
@@ -1,9 +1,15 @@
1
- import Node, { registerNode } from './Node.js';
1
+ import Node from './Node.js';
2
2
  import { select } from '../math/ConditionalNode.js';
3
3
  import { ShaderNode, nodeProxy, getCurrentStack, setCurrentStack } from '../tsl/TSLBase.js';
4
4
 
5
5
  class StackNode extends Node {
6
6
 
7
+ static get type() {
8
+
9
+ return 'StackNode';
10
+
11
+ }
12
+
7
13
  constructor( parent = null ) {
8
14
 
9
15
  super();
@@ -100,6 +106,4 @@ class StackNode extends Node {
100
106
 
101
107
  export default StackNode;
102
108
 
103
- StackNode.type = /*@__PURE__*/ registerNode( 'Stack', StackNode );
104
-
105
109
  export const stack = /*@__PURE__*/ nodeProxy( StackNode );
@@ -1,7 +1,13 @@
1
- import Node, { registerNode } from './Node.js';
1
+ import Node from './Node.js';
2
2
 
3
3
  class StructTypeNode extends Node {
4
4
 
5
+ static get type() {
6
+
7
+ return 'StructTypeNode';
8
+
9
+ }
10
+
5
11
  constructor( types ) {
6
12
 
7
13
  super();
@@ -20,5 +26,3 @@ class StructTypeNode extends Node {
20
26
  }
21
27
 
22
28
  export default StructTypeNode;
23
-
24
- StructTypeNode.type = /*@__PURE__*/ registerNode( 'StructType', StructTypeNode );
@@ -1,7 +1,13 @@
1
- import Node, { registerNode } from './Node.js';
1
+ import Node from './Node.js';
2
2
 
3
3
  class TempNode extends Node {
4
4
 
5
+ static get type() {
6
+
7
+ return 'TempNode';
8
+
9
+ }
10
+
5
11
  constructor( type ) {
6
12
 
7
13
  super( type );
@@ -36,7 +42,7 @@ class TempNode extends Node {
36
42
  const nodeVar = builder.getVarFromNode( this, null, type );
37
43
  const propertyName = builder.getPropertyName( nodeVar );
38
44
 
39
- builder.addLineFlowCode( `${propertyName} = ${snippet}` );
45
+ builder.addLineFlowCode( `${propertyName} = ${snippet}`, this );
40
46
 
41
47
  nodeData.snippet = snippet;
42
48
  nodeData.propertyName = propertyName;
@@ -54,5 +60,3 @@ class TempNode extends Node {
54
60
  }
55
61
 
56
62
  export default TempNode;
57
-
58
- TempNode.type = /*@__PURE__*/ registerNode( 'Temp', TempNode );
@@ -1,8 +1,14 @@
1
- import Node, { registerNode } from './Node.js';
1
+ import Node from './Node.js';
2
2
 
3
3
  class UniformGroupNode extends Node {
4
4
 
5
- constructor( name, shared = false ) {
5
+ static get type() {
6
+
7
+ return 'UniformGroupNode';
8
+
9
+ }
10
+
11
+ constructor( name, shared = false, order = 1 ) {
6
12
 
7
13
  super( 'string' );
8
14
 
@@ -10,7 +16,7 @@ class UniformGroupNode extends Node {
10
16
  this.version = 0;
11
17
 
12
18
  this.shared = shared;
13
-
19
+ this.order = order;
14
20
  this.isUniformGroup = true;
15
21
 
16
22
  }
@@ -45,10 +51,8 @@ class UniformGroupNode extends Node {
45
51
 
46
52
  export default UniformGroupNode;
47
53
 
48
- UniformGroupNode.type = /*@__PURE__*/ registerNode( 'UniformGroup', UniformGroupNode );
49
-
50
54
  export const uniformGroup = ( name ) => new UniformGroupNode( name );
51
- export const sharedUniformGroup = ( name ) => new UniformGroupNode( name, true );
55
+ export const sharedUniformGroup = ( name, order = 0 ) => new UniformGroupNode( name, true, order );
52
56
 
53
57
  export const frameGroup = /*@__PURE__*/ sharedUniformGroup( 'frame' );
54
58
  export const renderGroup = /*@__PURE__*/ sharedUniformGroup( 'render' );
@@ -1,10 +1,15 @@
1
- import { registerNode } from './Node.js';
2
1
  import InputNode from './InputNode.js';
3
2
  import { objectGroup } from './UniformGroupNode.js';
4
3
  import { nodeObject, getConstNodeType } from '../tsl/TSLCore.js';
5
4
 
6
5
  class UniformNode extends InputNode {
7
6
 
7
+ static get type() {
8
+
9
+ return 'UniformNode';
10
+
11
+ }
12
+
8
13
  constructor( value, nodeType = null ) {
9
14
 
10
15
  super( value, nodeType );
@@ -95,8 +100,6 @@ class UniformNode extends InputNode {
95
100
 
96
101
  export default UniformNode;
97
102
 
98
- UniformNode.type = /*@__PURE__*/ registerNode( 'Uniform', UniformNode );
99
-
100
103
  export const uniform = ( arg1, arg2 ) => {
101
104
 
102
105
  const nodeType = getConstNodeType( arg2 || arg1 );
@@ -1,8 +1,14 @@
1
- import Node, { registerNode } from './Node.js';
1
+ import Node from './Node.js';
2
2
  import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
3
3
 
4
4
  class VarNode extends Node {
5
5
 
6
+ static get type() {
7
+
8
+ return 'VarNode';
9
+
10
+ }
11
+
6
12
  constructor( node, name = null ) {
7
13
 
8
14
  super();
@@ -38,7 +44,7 @@ class VarNode extends Node {
38
44
 
39
45
  const snippet = node.build( builder, nodeVar.type );
40
46
 
41
- builder.addLineFlowCode( `${propertyName} = ${snippet}` );
47
+ builder.addLineFlowCode( `${propertyName} = ${snippet}`, this );
42
48
 
43
49
  return propertyName;
44
50
 
@@ -48,8 +54,6 @@ class VarNode extends Node {
48
54
 
49
55
  export default VarNode;
50
56
 
51
- VarNode.type = /*@__PURE__*/ registerNode( 'Var', VarNode );
52
-
53
57
  export const temp = /*@__PURE__*/ nodeProxy( VarNode );
54
58
 
55
59
  addMethodChaining( 'temp', temp ); // @TODO: Will be removed in the future
@@ -1,9 +1,15 @@
1
- import Node, { registerNode } from './Node.js';
1
+ import Node from './Node.js';
2
2
  import { NodeShaderStage } from './constants.js';
3
3
  import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
4
4
 
5
5
  class VaryingNode extends Node {
6
6
 
7
+ static get type() {
8
+
9
+ return 'VaryingNode';
10
+
11
+ }
12
+
7
13
  constructor( node, name = null ) {
8
14
 
9
15
  super();
@@ -97,8 +103,6 @@ class VaryingNode extends Node {
97
103
 
98
104
  export default VaryingNode;
99
105
 
100
- VaryingNode.type = /*@__PURE__*/ registerNode( 'Varying', VaryingNode );
101
-
102
106
  export const varying = /*@__PURE__*/ nodeProxy( VaryingNode );
103
107
 
104
108
  addMethodChaining( 'varying', varying );
@@ -19,6 +19,12 @@ const _quadMeshComp = /*@__PURE__*/ new QuadMesh();
19
19
 
20
20
  class AfterImageNode extends TempNode {
21
21
 
22
+ static get type() {
23
+
24
+ return 'AfterImageNode';
25
+
26
+ }
27
+
22
28
  constructor( textureNode, damp = 0.96 ) {
23
29
 
24
30
  super( textureNode );
@@ -8,6 +8,12 @@ import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
8
8
 
9
9
  class AnaglyphPassNode extends StereoCompositePassNode {
10
10
 
11
+ static get type() {
12
+
13
+ return 'AnaglyphPassNode';
14
+
15
+ }
16
+
11
17
  constructor( scene, camera ) {
12
18
 
13
19
  super( scene, camera );
@@ -17,6 +17,12 @@ const _quadMesh = /*@__PURE__*/ new QuadMesh();
17
17
 
18
18
  class AnamorphicNode extends TempNode {
19
19
 
20
+ static get type() {
21
+
22
+ return 'AnamorphicNode';
23
+
24
+ }
25
+
20
26
  constructor( textureNode, tresholdNode, scaleNode, samples ) {
21
27
 
22
28
  super( 'vec4' );
@@ -29,6 +29,12 @@ const _BlurDirectionY = /*@__PURE__*/ new Vector2( 0.0, 1.0 );
29
29
 
30
30
  class BloomNode extends TempNode {
31
31
 
32
+ static get type() {
33
+
34
+ return 'BloomNode';
35
+
36
+ }
37
+
32
38
  constructor( inputNode, strength = 1, radius = 0, threshold = 0 ) {
33
39
 
34
40
  super();
@@ -46,6 +46,12 @@ const perturbNormalArb = Fn( ( inputs ) => {
46
46
 
47
47
  class BumpMapNode extends TempNode {
48
48
 
49
+ static get type() {
50
+
51
+ return 'BumpMapNode';
52
+
53
+ }
54
+
49
55
  constructor( textureNode, scaleNode = null ) {
50
56
 
51
57
  super( 'vec3' );
@@ -1,7 +1,7 @@
1
1
  import { mix } from '../math/MathNode.js';
2
2
  import { Fn } from '../tsl/TSLBase.js';
3
3
 
4
- export const sRGBToLinear = /*@__PURE__*/ Fn( ( [ color ] ) => {
4
+ export const sRGBToLinearSRGB = /*@__PURE__*/ Fn( ( [ color ] ) => {
5
5
 
6
6
  const a = color.mul( 0.9478672986 ).add( 0.0521327014 ).pow( 2.4 );
7
7
  const b = color.mul( 0.0773993808 );
@@ -12,14 +12,14 @@ export const sRGBToLinear = /*@__PURE__*/ Fn( ( [ color ] ) => {
12
12
  return rgbResult;
13
13
 
14
14
  } ).setLayout( {
15
- name: 'sRGBToLinear',
15
+ name: 'sRGBToLinearSRGB',
16
16
  type: 'vec3',
17
17
  inputs: [
18
18
  { name: 'color', type: 'vec3' }
19
19
  ]
20
20
  } );
21
21
 
22
- export const LinearTosRGB = /*@__PURE__*/ Fn( ( [ color ] ) => {
22
+ export const linearSRGBTosRGB = /*@__PURE__*/ Fn( ( [ color ] ) => {
23
23
 
24
24
  const a = color.pow( 0.41666 ).mul( 1.055 ).sub( 0.055 );
25
25
  const b = color.mul( 12.92 );
@@ -30,7 +30,7 @@ export const LinearTosRGB = /*@__PURE__*/ Fn( ( [ color ] ) => {
30
30
  return rgbResult;
31
31
 
32
32
  } ).setLayout( {
33
- name: 'LinearTosRGB',
33
+ name: 'linearSRGBTosRGB',
34
34
  type: 'vec3',
35
35
  inputs: [
36
36
  { name: 'color', type: 'vec3' }