super-three 0.133.5 → 0.135.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 (246) hide show
  1. package/build/three.js +617 -536
  2. package/build/three.min.js +1 -1
  3. package/build/three.module.js +760 -613
  4. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
  5. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
  6. package/examples/fonts/open-sans/open-sans.css +9 -0
  7. package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
  8. package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
  9. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
  10. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
  11. package/examples/fonts/tabler-icons/tabler-icons.min.css +4 -0
  12. package/examples/js/controls/ArcballControls.js +68 -27
  13. package/examples/js/controls/DragControls.js +7 -0
  14. package/examples/js/controls/OrbitControls.js +5 -36
  15. package/examples/js/controls/TrackballControls.js +3 -2
  16. package/examples/js/csm/CSM.js +2 -2
  17. package/examples/js/csm/CSMFrustum.js +133 -0
  18. package/examples/js/exporters/GLTFExporter.js +147 -63
  19. package/examples/js/exporters/USDZExporter.js +45 -26
  20. package/examples/js/lines/LineMaterial.js +58 -20
  21. package/examples/js/lines/LineSegments2.js +29 -24
  22. package/examples/js/loaders/3DMLoader.js +24 -11
  23. package/examples/js/loaders/3MFLoader.js +2 -2
  24. package/examples/js/loaders/ColladaLoader.js +61 -3
  25. package/examples/js/loaders/FBXLoader.js +1 -1
  26. package/examples/js/loaders/GLTFLoader.js +94 -31
  27. package/examples/js/loaders/KTX2Loader.js +12 -0
  28. package/examples/js/loaders/LWOLoader.js +8 -6
  29. package/examples/js/loaders/LogLuvLoader.js +766 -0
  30. package/examples/js/loaders/PLYLoader.js +32 -7
  31. package/examples/js/loaders/RGBELoader.js +2 -1
  32. package/examples/js/loaders/SVGLoader.js +7 -3
  33. package/examples/js/loaders/TDSLoader.js +237 -271
  34. package/examples/js/loaders/lwo/LWO2Parser.js +1 -0
  35. package/examples/js/loaders/lwo/LWO3Parser.js +4 -2
  36. package/examples/js/objects/MarchingCubes.js +42 -128
  37. package/examples/js/renderers/CSS2DRenderer.js +4 -4
  38. package/examples/js/renderers/CSS3DRenderer.js +4 -4
  39. package/examples/js/utils/RoughnessMipmapper.js +1 -0
  40. package/examples/jsm/controls/ArcballControls.js +61 -29
  41. package/examples/jsm/controls/DragControls.js +7 -0
  42. package/examples/jsm/controls/OrbitControls.js +9 -51
  43. package/examples/jsm/controls/TrackballControls.js +1 -1
  44. package/examples/jsm/csm/CSM.js +3 -3
  45. package/examples/jsm/csm/{Frustum.js → CSMFrustum.js} +3 -3
  46. package/examples/jsm/exporters/GLTFExporter.js +160 -74
  47. package/examples/jsm/exporters/USDZExporter.js +47 -26
  48. package/examples/jsm/libs/flow.module.js +3218 -0
  49. package/examples/jsm/libs/lil-gui.module.min.js +8 -0
  50. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  51. package/examples/jsm/lines/LineMaterial.js +59 -23
  52. package/examples/jsm/lines/LineSegments2.js +22 -18
  53. package/examples/jsm/loaders/3DMLoader.js +18 -12
  54. package/examples/jsm/loaders/3MFLoader.js +2 -2
  55. package/examples/jsm/loaders/ColladaLoader.js +61 -3
  56. package/examples/jsm/loaders/FBXLoader.js +1 -1
  57. package/examples/jsm/loaders/GLTFLoader.js +99 -35
  58. package/examples/jsm/loaders/KTX2Loader.js +19 -0
  59. package/examples/jsm/loaders/LWOLoader.js +8 -6
  60. package/examples/jsm/loaders/LogLuvLoader.js +606 -0
  61. package/examples/jsm/loaders/PLYLoader.js +33 -7
  62. package/examples/jsm/loaders/SVGLoader.js +7 -4
  63. package/examples/jsm/loaders/TDSLoader.js +225 -285
  64. package/examples/jsm/loaders/lwo/LWO2Parser.js +1 -0
  65. package/examples/jsm/loaders/lwo/LWO3Parser.js +2 -2
  66. package/examples/jsm/node-editor/NodeEditor.js +455 -0
  67. package/examples/jsm/node-editor/accessors/NormalEditor.js +30 -0
  68. package/examples/jsm/node-editor/accessors/PositionEditor.js +30 -0
  69. package/examples/jsm/node-editor/accessors/UVEditor.js +26 -0
  70. package/examples/jsm/node-editor/display/BlendEditor.js +43 -0
  71. package/examples/jsm/node-editor/examples/animate-uv.json +1 -0
  72. package/examples/jsm/node-editor/examples/fake-top-light.json +1 -0
  73. package/examples/jsm/node-editor/examples/oscillator-color.json +1 -0
  74. package/examples/jsm/node-editor/examples/rim.json +1 -0
  75. package/examples/jsm/node-editor/inputs/ColorEditor.js +91 -0
  76. package/examples/jsm/node-editor/inputs/FloatEditor.js +24 -0
  77. package/examples/jsm/node-editor/inputs/SliderEditor.js +68 -0
  78. package/examples/jsm/node-editor/inputs/Vector2Editor.js +28 -0
  79. package/examples/jsm/node-editor/inputs/Vector3Editor.js +30 -0
  80. package/examples/jsm/node-editor/inputs/Vector4Editor.js +37 -0
  81. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +69 -0
  82. package/examples/jsm/node-editor/math/DotEditor.js +36 -0
  83. package/examples/jsm/node-editor/math/InvertEditor.js +38 -0
  84. package/examples/jsm/node-editor/math/LimiterEditor.js +48 -0
  85. package/examples/jsm/node-editor/math/NormalizeEditor.js +26 -0
  86. package/examples/jsm/node-editor/math/OperatorEditor.js +50 -0
  87. package/examples/jsm/node-editor/math/PowerEditor.js +34 -0
  88. package/examples/jsm/node-editor/math/TrigonometryEditor.js +39 -0
  89. package/examples/jsm/node-editor/procedural/CheckerEditor.js +26 -0
  90. package/examples/jsm/node-editor/utils/OscillatorEditor.js +42 -0
  91. package/examples/jsm/node-editor/utils/TimerEditor.js +57 -0
  92. package/examples/jsm/nodes/materials/StandardNodeMaterial.js +1 -1
  93. package/examples/jsm/nodes/materials/nodes/StandardNode.js +6 -6
  94. package/examples/jsm/nodes/utils/ColorSpaceNode.js +1 -49
  95. package/examples/jsm/objects/MarchingCubes.js +46 -152
  96. package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +1 -1
  97. package/examples/jsm/postprocessing/AfterimagePass.js +1 -1
  98. package/examples/jsm/postprocessing/BloomPass.js +1 -1
  99. package/examples/jsm/postprocessing/BokehPass.js +1 -1
  100. package/examples/jsm/postprocessing/ClearPass.js +1 -1
  101. package/examples/jsm/postprocessing/CubeTexturePass.js +1 -1
  102. package/examples/jsm/postprocessing/DotScreenPass.js +1 -1
  103. package/examples/jsm/postprocessing/EffectComposer.js +3 -3
  104. package/examples/jsm/postprocessing/FilmPass.js +1 -1
  105. package/examples/jsm/postprocessing/GlitchPass.js +1 -1
  106. package/examples/jsm/postprocessing/HalftonePass.js +1 -1
  107. package/examples/jsm/postprocessing/MaskPass.js +1 -1
  108. package/examples/jsm/postprocessing/OutlinePass.js +1 -1
  109. package/examples/jsm/postprocessing/RenderPass.js +1 -1
  110. package/examples/jsm/postprocessing/SAOPass.js +1 -1
  111. package/examples/jsm/postprocessing/SMAAPass.js +1 -1
  112. package/examples/jsm/postprocessing/SSAARenderPass.js +1 -1
  113. package/examples/jsm/postprocessing/SSAOPass.js +1 -1
  114. package/examples/jsm/postprocessing/SSRPass.js +1 -1
  115. package/examples/jsm/postprocessing/SSRrPass.js +1 -1
  116. package/examples/jsm/postprocessing/SavePass.js +1 -1
  117. package/examples/jsm/postprocessing/ShaderPass.js +1 -1
  118. package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
  119. package/examples/jsm/postprocessing/TexturePass.js +1 -1
  120. package/examples/jsm/postprocessing/UnrealBloomPass.js +1 -1
  121. package/examples/jsm/renderers/CSS2DRenderer.js +5 -4
  122. package/examples/jsm/renderers/CSS3DRenderer.js +5 -4
  123. package/examples/jsm/renderers/nodes/Nodes.js +14 -13
  124. package/examples/jsm/renderers/nodes/ShaderNode.js +193 -41
  125. package/examples/jsm/renderers/nodes/accessors/MaterialNode.js +6 -6
  126. package/examples/jsm/renderers/nodes/accessors/ModelViewProjectionNode.js +5 -5
  127. package/examples/jsm/renderers/nodes/accessors/NormalNode.js +14 -3
  128. package/examples/jsm/renderers/nodes/accessors/PointUVNode.js +3 -3
  129. package/examples/jsm/renderers/nodes/accessors/PositionNode.js +15 -5
  130. package/examples/jsm/renderers/nodes/accessors/SkinningNode.js +107 -0
  131. package/examples/jsm/renderers/nodes/accessors/UVNode.js +7 -5
  132. package/examples/jsm/renderers/nodes/core/ArrayInputNode.js +3 -3
  133. package/examples/jsm/renderers/nodes/core/AttributeNode.js +6 -0
  134. package/examples/jsm/renderers/nodes/core/BypassNode.js +38 -0
  135. package/examples/jsm/renderers/nodes/core/CodeNode.js +3 -3
  136. package/examples/jsm/renderers/nodes/core/ContextNode.js +4 -19
  137. package/examples/jsm/renderers/nodes/core/ExpressionNode.js +13 -2
  138. package/examples/jsm/renderers/nodes/core/FunctionNode.js +19 -132
  139. package/examples/jsm/renderers/nodes/core/InputNode.js +13 -3
  140. package/examples/jsm/renderers/nodes/core/Node.js +32 -10
  141. package/examples/jsm/renderers/nodes/core/NodeBuilder.js +146 -128
  142. package/examples/jsm/renderers/nodes/core/NodeFunction.js +22 -0
  143. package/examples/jsm/renderers/nodes/core/NodeFunctionInput.js +4 -4
  144. package/examples/jsm/renderers/nodes/core/NodeKeywords.js +18 -179
  145. package/examples/jsm/renderers/nodes/core/NodeParser.js +11 -0
  146. package/examples/jsm/renderers/nodes/core/NodeVar.js +2 -2
  147. package/examples/jsm/renderers/nodes/core/PropertyNode.js +14 -2
  148. package/examples/jsm/renderers/nodes/core/TempNode.js +10 -13
  149. package/examples/jsm/renderers/nodes/core/VarNode.js +12 -7
  150. package/examples/jsm/renderers/nodes/core/VaryNode.js +23 -8
  151. package/examples/jsm/renderers/nodes/core/constants.js +2 -0
  152. package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +47 -25
  153. package/examples/jsm/renderers/nodes/display/NormalMapNode.js +21 -22
  154. package/examples/jsm/renderers/nodes/functions/BSDFs.js +64 -101
  155. package/examples/jsm/renderers/nodes/inputs/BufferNode.js +25 -0
  156. package/examples/jsm/renderers/nodes/inputs/IntNode.js +17 -0
  157. package/examples/jsm/renderers/nodes/inputs/TextureNode.js +10 -2
  158. package/examples/jsm/renderers/nodes/lights/LightContextNode.js +20 -14
  159. package/examples/jsm/renderers/nodes/lights/LightNode.js +32 -36
  160. package/examples/jsm/renderers/nodes/math/CondNode.js +60 -0
  161. package/examples/jsm/renderers/nodes/math/MathNode.js +87 -36
  162. package/examples/jsm/renderers/nodes/math/OperatorNode.js +124 -31
  163. package/examples/jsm/renderers/nodes/parsers/GLSLNodeFunction.js +137 -0
  164. package/examples/jsm/renderers/nodes/parsers/GLSLNodeParser.js +14 -0
  165. package/examples/jsm/renderers/nodes/parsers/WGSLNodeFunction.js +89 -0
  166. package/examples/jsm/renderers/nodes/parsers/WGSLNodeParser.js +14 -0
  167. package/examples/jsm/renderers/nodes/procedural/CheckerNode.js +7 -9
  168. package/examples/jsm/renderers/nodes/utils/ArrayElementNode.js +31 -0
  169. package/examples/jsm/renderers/nodes/utils/ConvertNode.js +33 -0
  170. package/examples/jsm/renderers/nodes/utils/JoinNode.js +7 -7
  171. package/examples/jsm/renderers/nodes/utils/OscNode.js +58 -0
  172. package/examples/jsm/renderers/nodes/utils/SplitNode.js +18 -8
  173. package/examples/jsm/renderers/nodes/utils/SpriteSheetUVNode.js +7 -7
  174. package/examples/jsm/renderers/webgl/nodes/SlotNode.js +22 -0
  175. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +191 -94
  176. package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +2 -2
  177. package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +2 -2
  178. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +1 -1
  179. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +3 -3
  180. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +2 -4
  181. package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +2 -4
  182. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +15 -23
  183. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +3 -5
  184. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +11 -27
  185. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +62 -28
  186. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +34 -27
  187. package/examples/jsm/renderers/webgpu/constants.js +2 -2
  188. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +430 -98
  189. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
  190. package/examples/jsm/utils/RoughnessMipmapper.js +1 -0
  191. package/examples/jsm/webxr/OculusHandPointerModel.js +6 -6
  192. package/package.json +10 -10
  193. package/src/Three.Legacy.js +6 -0
  194. package/src/Three.js +0 -1
  195. package/src/cameras/StereoCamera.js +8 -7
  196. package/src/constants.js +1 -2
  197. package/src/core/Layers.js +7 -1
  198. package/src/core/Object3D.js +2 -0
  199. package/src/extras/PMREMGenerator.js +11 -6
  200. package/src/loaders/FileLoader.js +89 -152
  201. package/src/loaders/ImageLoader.js +9 -4
  202. package/src/loaders/LoaderUtils.js +26 -0
  203. package/src/loaders/MaterialLoader.js +7 -4
  204. package/src/loaders/ObjectLoader.js +2 -0
  205. package/src/materials/Material.js +4 -4
  206. package/src/materials/MeshPhysicalMaterial.js +20 -14
  207. package/src/math/MathUtils.js +5 -16
  208. package/src/renderers/WebGLMultisampleRenderTarget.js +7 -1
  209. package/src/renderers/WebGLRenderer.js +83 -117
  210. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +2 -2
  211. package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -27
  212. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
  213. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +19 -6
  214. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +2 -2
  215. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
  216. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +1 -1
  217. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +13 -5
  218. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +2 -1
  219. package/src/renderers/shaders/ShaderLib.js +6 -4
  220. package/src/renderers/shaders/UniformsLib.js +1 -2
  221. package/src/renderers/webgl/WebGLExtensions.js +1 -0
  222. package/src/renderers/webgl/WebGLMaterials.js +27 -15
  223. package/src/renderers/webgl/WebGLProgram.js +10 -6
  224. package/src/renderers/webgl/WebGLPrograms.js +17 -12
  225. package/src/renderers/webgl/WebGLShadowMap.js +14 -5
  226. package/src/renderers/webgl/WebGLState.js +31 -17
  227. package/src/renderers/webgl/WebGLTextures.js +188 -51
  228. package/src/renderers/webgl/WebGLUniforms.js +45 -1
  229. package/src/renderers/webxr/WebXRManager.js +68 -107
  230. package/src/textures/Texture.js +6 -0
  231. package/src/utils.js +37 -1
  232. package/examples/js/controls/DeviceOrientationControls.js +0 -147
  233. package/examples/js/libs/dat.gui.min.js +0 -14
  234. package/examples/jsm/controls/DeviceOrientationControls.js +0 -153
  235. package/examples/jsm/libs/dat.gui.module.js +0 -3575
  236. package/examples/jsm/libs/glslang.js +0 -78
  237. package/examples/jsm/libs/glslang.wasm +0 -0
  238. package/examples/jsm/renderers/nodes/consts/MathConsts.js +0 -7
  239. package/examples/jsm/renderers/nodes/core/ConstNode.js +0 -39
  240. package/examples/jsm/renderers/nodes/core/NodeSlot.js +0 -13
  241. package/examples/jsm/renderers/nodes/core/StructNode.js +0 -80
  242. package/examples/jsm/renderers/nodes/core/StructVarNode.js +0 -75
  243. package/examples/jsm/renderers/nodes/functions/EncodingFunctions.js +0 -99
  244. package/examples/jsm/renderers/nodes/functions/MathFunctions.js +0 -47
  245. package/examples/jsm/renderers/webgpu/nodes/ShaderLib.js +0 -152
  246. package/src/extras/objects/ImmediateRenderObject.js +0 -31
@@ -1,5 +1,6 @@
1
1
  import NodeBuilder from '../../nodes/core/NodeBuilder.js';
2
- import NodeSlot from '../../nodes/core/NodeSlot.js';
2
+ import SlotNode from './SlotNode.js';
3
+ import GLSLNodeParser from '../../nodes/parsers/GLSLNodeParser.js';
3
4
  import WebGLPhysicalContextNode from './WebGLPhysicalContextNode.js';
4
5
 
5
6
  import { ShaderChunk, LinearEncoding, RGBAFormat, UnsignedByteType, sRGBEncoding } from 'three';
@@ -20,17 +21,38 @@ function getShaderStageProperty( shaderStage ) {
20
21
 
21
22
  class WebGLNodeBuilder extends NodeBuilder {
22
23
 
23
- constructor( material, renderer, shader ) {
24
+ constructor( object, renderer, shader ) {
24
25
 
25
- super( material, renderer );
26
+ super( object, renderer, new GLSLNodeParser() );
26
27
 
27
28
  this.shader = shader;
29
+ this.slots = { vertex: [], fragment: [] };
28
30
 
29
- this._parseMaterial();
31
+ this._parseObject();
30
32
 
31
33
  }
32
34
 
33
- _parseMaterial() {
35
+ addSlot( shaderStage, slotNode ) {
36
+
37
+ this.slots[ shaderStage ].push( slotNode );
38
+
39
+ return this.addFlow( shaderStage, slotNode );
40
+
41
+ }
42
+
43
+ addFlowCode( code ) {
44
+
45
+ if ( ! /;\s*$/.test( code ) ) {
46
+
47
+ code += ';';
48
+
49
+ }
50
+
51
+ super.addFlowCode( code + '\n\t' );
52
+
53
+ }
54
+
55
+ _parseObject() {
34
56
 
35
57
  const material = this.material;
36
58
 
@@ -38,49 +60,49 @@ class WebGLNodeBuilder extends NodeBuilder {
38
60
 
39
61
  if ( material.colorNode && material.colorNode.isNode ) {
40
62
 
41
- this.addSlot( 'fragment', new NodeSlot( material.colorNode, 'COLOR', 'vec4' ) );
63
+ this.addSlot( 'fragment', new SlotNode( material.colorNode, 'COLOR', 'vec4' ) );
42
64
 
43
65
  }
44
66
 
45
67
  if ( material.opacityNode && material.opacityNode.isNode ) {
46
68
 
47
- this.addSlot( 'fragment', new NodeSlot( material.opacityNode, 'OPACITY', 'float' ) );
69
+ this.addSlot( 'fragment', new SlotNode( material.opacityNode, 'OPACITY', 'float' ) );
48
70
 
49
71
  }
50
72
 
51
73
  if ( material.normalNode && material.normalNode.isNode ) {
52
74
 
53
- this.addSlot( 'fragment', new NodeSlot( material.normalNode, 'NORMAL', 'vec3' ) );
75
+ this.addSlot( 'fragment', new SlotNode( material.normalNode, 'NORMAL', 'vec3' ) );
54
76
 
55
77
  }
56
78
 
57
79
  if ( material.emissiveNode && material.emissiveNode.isNode ) {
58
80
 
59
- this.addSlot( 'fragment', new NodeSlot( material.emissiveNode, 'EMISSIVE', 'vec3' ) );
81
+ this.addSlot( 'fragment', new SlotNode( material.emissiveNode, 'EMISSIVE', 'vec3' ) );
60
82
 
61
83
  }
62
84
 
63
85
  if ( material.metalnessNode && material.metalnessNode.isNode ) {
64
86
 
65
- this.addSlot( 'fragment', new NodeSlot( material.metalnessNode, 'METALNESS', 'float' ) );
87
+ this.addSlot( 'fragment', new SlotNode( material.metalnessNode, 'METALNESS', 'float' ) );
66
88
 
67
89
  }
68
90
 
69
91
  if ( material.roughnessNode && material.roughnessNode.isNode ) {
70
92
 
71
- this.addSlot( 'fragment', new NodeSlot( material.roughnessNode, 'ROUGHNESS', 'float' ) );
93
+ this.addSlot( 'fragment', new SlotNode( material.roughnessNode, 'ROUGHNESS', 'float' ) );
72
94
 
73
95
  }
74
96
 
75
97
  if ( material.clearcoatNode && material.clearcoatNode.isNode ) {
76
98
 
77
- this.addSlot( 'fragment', new NodeSlot( material.clearcoatNode, 'CLEARCOAT', 'float' ) );
99
+ this.addSlot( 'fragment', new SlotNode( material.clearcoatNode, 'CLEARCOAT', 'float' ) );
78
100
 
79
101
  }
80
102
 
81
103
  if ( material.clearcoatRoughnessNode && material.clearcoatRoughnessNode.isNode ) {
82
104
 
83
- this.addSlot( 'fragment', new NodeSlot( material.clearcoatRoughnessNode, 'CLEARCOAT_ROUGHNESS', 'float' ) );
105
+ this.addSlot( 'fragment', new SlotNode( material.clearcoatRoughnessNode, 'CLEARCOAT_ROUGHNESS', 'float' ) );
84
106
 
85
107
  }
86
108
 
@@ -89,20 +111,20 @@ class WebGLNodeBuilder extends NodeBuilder {
89
111
  const envRadianceNode = new WebGLPhysicalContextNode( WebGLPhysicalContextNode.RADIANCE, material.envNode );
90
112
  const envIrradianceNode = new WebGLPhysicalContextNode( WebGLPhysicalContextNode.IRRADIANCE, material.envNode );
91
113
 
92
- this.addSlot( 'fragment', new NodeSlot( envRadianceNode, 'RADIANCE', 'vec3' ) );
93
- this.addSlot( 'fragment', new NodeSlot( envIrradianceNode, 'IRRADIANCE', 'vec3' ) );
114
+ this.addSlot( 'fragment', new SlotNode( envRadianceNode, 'RADIANCE', 'vec3' ) );
115
+ this.addSlot( 'fragment', new SlotNode( envIrradianceNode, 'IRRADIANCE', 'vec3' ) );
94
116
 
95
117
  }
96
118
 
97
119
  if ( material.sizeNode && material.sizeNode.isNode ) {
98
120
 
99
- this.addSlot( 'vertex', new NodeSlot( material.sizeNode, 'SIZE', 'float' ) );
121
+ this.addSlot( 'vertex', new SlotNode( material.sizeNode, 'SIZE', 'float' ) );
100
122
 
101
123
  }
102
124
 
103
125
  if ( material.positionNode && material.positionNode.isNode ) {
104
126
 
105
- this.addSlot( 'vertex', new NodeSlot( material.positionNode, 'POSITION', 'vec3' ) );
127
+ this.addSlot( 'vertex', new SlotNode( material.positionNode, 'POSITION', 'vec3' ) );
106
128
 
107
129
  }
108
130
 
@@ -216,7 +238,7 @@ class WebGLNodeBuilder extends NodeBuilder {
216
238
 
217
239
  const shaderProperty = getShaderStageProperty( shaderStage );
218
240
 
219
- let source = this.shader[ shaderProperty ];
241
+ let source = this[ shaderProperty ];
220
242
 
221
243
  const index = source.indexOf( snippet );
222
244
 
@@ -229,7 +251,7 @@ class WebGLNodeBuilder extends NodeBuilder {
229
251
 
230
252
  }
231
253
 
232
- this.shader[ shaderProperty ] = source;
254
+ this[ shaderProperty ] = source;
233
255
 
234
256
  }
235
257
 
@@ -263,7 +285,7 @@ class WebGLNodeBuilder extends NodeBuilder {
263
285
  }
264
286
 
265
287
  getTextureEncodingFromMap( map ) {
266
-
288
+ /*
267
289
  const isWebGL2 = this.renderer.capabilities.isWebGL2;
268
290
 
269
291
  if ( isWebGL2 && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding ) {
@@ -271,130 +293,213 @@ class WebGLNodeBuilder extends NodeBuilder {
271
293
  return LinearEncoding; // disable inline decode for sRGB textures in WebGL 2
272
294
 
273
295
  }
274
-
296
+ */
275
297
  return super.getTextureEncodingFromMap( map );
276
298
 
277
299
  }
278
300
 
301
+ buildCode() {
302
+
303
+ const shaderData = {};
304
+
305
+ for ( const shaderStage of shaderStages ) {
306
+
307
+ const uniforms = this.getUniforms( shaderStage );
308
+ const attributes = this.getAttributes( shaderStage );
309
+ const varys = this.getVarys( shaderStage );
310
+ const vars = this.getVars( shaderStage );
311
+ const codes = this.getCodes( shaderStage );
312
+
313
+ shaderData[ shaderStage ] = `${this.getSignature()}
314
+ // <node_builder>
315
+
316
+ // uniforms
317
+ ${uniforms}
318
+
319
+ // attributes
320
+ ${attributes}
321
+
322
+ // varys
323
+ ${varys}
324
+
325
+ // vars
326
+ ${vars}
327
+
328
+ // codes
329
+ ${codes}
330
+
331
+ // </node_builder>
332
+
333
+ ${this.shader[ getShaderStageProperty( shaderStage ) ]}
334
+ `;
335
+
336
+ }
337
+
338
+ this.vertexShader = shaderData.vertex;
339
+ this.fragmentShader = shaderData.fragment;
340
+
341
+
342
+ }
343
+
279
344
  build() {
280
345
 
281
346
  super.build();
282
347
 
283
348
  this._addSnippets();
284
- this._buildShader();
349
+ this._addUniforms();
350
+
351
+ this.shader.vertexShader = this.vertexShader;
352
+ this.shader.fragmentShader = this.fragmentShader;
285
353
 
286
354
  return this;
287
355
 
288
356
  }
289
357
 
290
- _addSnippets() {
358
+ getSlot( shaderStage, name ) {
291
359
 
292
- this.parseInclude( 'fragment', 'lights_physical_fragment' );
360
+ const slots = this.slots[ shaderStage ];
293
361
 
294
- this.addCodeAfterInclude( 'fragment', 'normal_fragment_begin',
295
- `#ifdef NODE_NORMAL
362
+ for ( const node of slots ) {
296
363
 
297
- NODE_CODE_NORMAL
298
- normal = NODE_NORMAL;
364
+ if ( node.name === name ) {
299
365
 
300
- #endif` );
366
+ return this.getFlowData( shaderStage, node );
301
367
 
302
- this.addCodeAfterInclude( 'fragment', 'color_fragment',
303
- `#ifdef NODE_COLOR
368
+ }
304
369
 
305
- NODE_CODE_COLOR
306
- diffuseColor = NODE_COLOR;
370
+ }
307
371
 
308
- #endif` );
372
+ }
309
373
 
310
- this.addCodeAfterInclude( 'fragment', 'alphamap_fragment',
311
- `#ifdef NODE_OPACITY
374
+ _addSnippets() {
312
375
 
313
- NODE_CODE_OPACITY
314
- diffuseColor.a *= NODE_OPACITY;
376
+ this.parseInclude( 'fragment', 'lights_physical_fragment' );
315
377
 
316
- #endif` );
378
+ const colorSlot = this.getSlot( 'fragment', 'COLOR' );
379
+ const normalSlot = this.getSlot( 'fragment', 'NORMAL' );
380
+ const opacityNode = this.getSlot( 'fragment', 'OPACITY' );
381
+ const emissiveNode = this.getSlot( 'fragment', 'EMISSIVE' );
382
+ const roughnessNode = this.getSlot( 'fragment', 'ROUGHNESS' );
383
+ const metalnessNode = this.getSlot( 'fragment', 'METALNESS' );
384
+ const clearcoatNode = this.getSlot( 'fragment', 'CLEARCOAT' );
385
+ const clearcoatRoughnessNode = this.getSlot( 'fragment', 'CLEARCOAT_ROUGHNESS' );
317
386
 
318
- this.addCodeAfterInclude( 'fragment', 'emissivemap_fragment',
319
- `#ifdef NODE_EMISSIVE
387
+ const positionNode = this.getSlot( 'vertex', 'POSITION' );
388
+ const sizeNode = this.getSlot( 'vertex', 'SIZE' );
320
389
 
321
- NODE_CODE_EMISSIVE
322
- totalEmissiveRadiance = NODE_EMISSIVE;
390
+ if ( colorSlot !== undefined ) {
323
391
 
324
- #endif` );
392
+ this.addCodeAfterInclude(
393
+ 'fragment',
394
+ 'color_fragment',
395
+ `${colorSlot.code}\n\tdiffuseColor = ${colorSlot.result};`
396
+ );
325
397
 
326
- this.addCodeAfterInclude( 'fragment', 'roughnessmap_fragment',
327
- `#ifdef NODE_ROUGHNESS
398
+ }
328
399
 
329
- NODE_CODE_ROUGHNESS
330
- roughnessFactor = NODE_ROUGHNESS;
400
+ if ( normalSlot !== undefined ) {
331
401
 
332
- #endif` );
402
+ this.addCodeAfterInclude(
403
+ 'fragment',
404
+ 'normal_fragment_begin',
405
+ `${normalSlot.code}\n\tnormal = ${normalSlot.result};`
406
+ );
333
407
 
334
- this.addCodeAfterInclude( 'fragment', 'metalnessmap_fragment',
335
- `#ifdef NODE_METALNESS
408
+ }
336
409
 
337
- NODE_CODE_METALNESS
338
- metalnessFactor = NODE_METALNESS;
410
+ if ( opacityNode !== undefined ) {
339
411
 
340
- #endif` );
412
+ this.addCodeAfterInclude(
413
+ 'fragment',
414
+ 'alphamap_fragment',
415
+ `${opacityNode.code}\n\tdiffuseColor.a = ${opacityNode.result};`
416
+ );
341
417
 
342
- this.addCodeAfterSnippet( 'fragment', 'material.clearcoatRoughness = clearcoatRoughness;',
343
- `#ifdef NODE_CLEARCOAT
418
+ }
344
419
 
345
- NODE_CODE_CLEARCOAT
346
- material.clearcoat = NODE_CLEARCOAT;
420
+ if ( emissiveNode !== undefined ) {
347
421
 
348
- #endif
422
+ this.addCodeAfterInclude(
423
+ 'fragment',
424
+ 'emissivemap_fragment',
425
+ `${emissiveNode.code}\n\ttotalEmissiveRadiance = ${emissiveNode.result};`
426
+ );
349
427
 
350
- #ifdef NODE_CLEARCOAT_ROUGHNESS
428
+ }
351
429
 
352
- NODE_CODE_CLEARCOAT_ROUGHNESS
353
- material.clearcoatRoughness = NODE_CLEARCOAT_ROUGHNESS;
430
+ if ( roughnessNode !== undefined ) {
354
431
 
355
- #endif` );
432
+ this.addCodeAfterInclude(
433
+ 'fragment',
434
+ 'roughnessmap_fragment',
435
+ `${roughnessNode.code}\n\troughnessFactor = ${roughnessNode.result};`
436
+ );
356
437
 
357
- this.addCodeAfterInclude( 'fragment', 'lights_fragment_begin',
358
- `#ifdef NODE_RADIANCE
438
+ }
359
439
 
360
- NODE_CODE_RADIANCE
361
- radiance += NODE_RADIANCE;
440
+ if ( metalnessNode !== undefined ) {
362
441
 
363
- NODE_CODE_IRRADIANCE
364
- iblIrradiance += PI * NODE_IRRADIANCE;
442
+ this.addCodeAfterInclude(
443
+ 'fragment',
444
+ 'metalnessmap_fragment',
445
+ `${metalnessNode.code}\n\tmetalnessFactor = ${metalnessNode.result};`
446
+ );
365
447
 
366
- #endif` );
448
+ }
367
449
 
368
- this.addCodeAfterInclude( 'vertex', 'begin_vertex',
369
- `#ifdef NODE_POSITION
450
+ if ( clearcoatNode !== undefined ) {
370
451
 
371
- NODE_CODE_POSITION
372
- transformed = NODE_POSITION;
452
+ this.addCodeAfterSnippet(
453
+ 'fragment',
454
+ 'material.clearcoatRoughness = clearcoatRoughness;',
455
+ `${clearcoatNode.code}\n\tmaterial.clearcoat = ${clearcoatNode.result};`
456
+ );
373
457
 
374
- #endif` );
458
+ }
375
459
 
376
- this.addCodeAfterSnippet( 'vertex', 'gl_PointSize = size;',
377
- `#ifdef NODE_SIZE
460
+ if ( clearcoatRoughnessNode !== undefined ) {
378
461
 
379
- NODE_CODE_SIZE
380
- gl_PointSize = NODE_SIZE;
462
+ this.addCodeAfterSnippet(
463
+ 'fragment',
464
+ 'material.clearcoatRoughness = clearcoatRoughness;',
465
+ `${clearcoatRoughnessNode.code}\n\tmaterial.clearcoatRoughness = ${clearcoatRoughnessNode.result};`
466
+ );
381
467
 
382
- #endif` );
468
+ }
383
469
 
384
- for ( const shaderStage of shaderStages ) {
470
+ if ( positionNode !== undefined ) {
385
471
 
386
- this.addCodeAfterSnippet( shaderStage, 'main() {',
387
- `#ifdef NODE_CODE
472
+ this.addCodeAfterInclude(
473
+ 'vertex',
474
+ 'begin_vertex',
475
+ `${positionNode.code}\n\ttransformed = ${positionNode.result};`
476
+ );
388
477
 
389
- NODE_CODE
478
+ }
479
+
480
+ if ( sizeNode !== undefined ) {
390
481
 
391
- #endif` );
482
+ this.addCodeAfterSnippet(
483
+ 'vertex',
484
+ 'gl_PointSize = size;',
485
+ `${sizeNode.code}\n\tgl_PointSize = ${sizeNode.result};`
486
+ );
487
+
488
+ }
489
+
490
+ for ( const shaderStage of shaderStages ) {
491
+
492
+ this.addCodeAfterSnippet(
493
+ shaderStage,
494
+ 'main() {',
495
+ this.flowCode[ shaderStage ]
496
+ );
392
497
 
393
498
  }
394
499
 
395
500
  }
396
501
 
397
- _buildShader() {
502
+ _addUniforms() {
398
503
 
399
504
  for ( const shaderStage of shaderStages ) {
400
505
 
@@ -406,14 +511,6 @@ class WebGLNodeBuilder extends NodeBuilder {
406
511
 
407
512
  }
408
513
 
409
- // code
410
-
411
- const shaderProperty = getShaderStageProperty( shaderStage );
412
-
413
- const nodeCode = this[ shaderProperty ];
414
-
415
- this.shader[ shaderProperty ] = nodeCode + this.shader[ shaderProperty ];
416
-
417
514
  }
418
515
 
419
516
  }
@@ -6,9 +6,9 @@ import { Material } from 'three';
6
6
  const builders = new WeakMap();
7
7
  export const nodeFrame = new NodeFrame();
8
8
 
9
- Material.prototype.onBuild = function ( parameters, renderer ) {
9
+ Material.prototype.onBuild = function ( object, parameters, renderer ) {
10
10
 
11
- builders.set( this, new WebGLNodeBuilder( this, renderer, parameters ).build() );
11
+ builders.set( this, new WebGLNodeBuilder( object, renderer, parameters ).build() );
12
12
 
13
13
  };
14
14
 
@@ -30,11 +30,11 @@ class WebGLPhysicalContextNode extends ContextNode {
30
30
 
31
31
  roughness = new FloatNode( 1.0 ).setConst( true );
32
32
 
33
- this.setContextValue( 'uv', new NormalNode( NormalNode.WORLD ) );
33
+ this.context.uv = new NormalNode( NormalNode.WORLD );
34
34
 
35
35
  }
36
36
 
37
- this.setContextValue( 'roughness', roughness );
37
+ this.context.roughness = roughness;
38
38
 
39
39
  return super.generate( builder, output );
40
40
 
@@ -77,7 +77,7 @@ class WebGPUBackground {
77
77
 
78
78
  if ( renderer.autoClearStencil === true ) {
79
79
 
80
- depthStencilAttachment.stencilLoadValue = renderer._clearDepth;
80
+ depthStencilAttachment.stencilLoadValue = renderer._clearStencil;
81
81
 
82
82
  } else {
83
83
 
@@ -78,7 +78,7 @@ class WebGPUBindings {
78
78
 
79
79
  }
80
80
 
81
- update( object, camera ) {
81
+ update( object ) {
82
82
 
83
83
  const textures = this.textures;
84
84
 
@@ -141,10 +141,10 @@ class WebGPUBindings {
141
141
 
142
142
  const texture = binding.getTexture();
143
143
 
144
- const forceUpdate = textures.updateTexture( texture );
144
+ const needsTextureRefresh = textures.updateTexture( texture );
145
145
  const textureGPU = textures.getTextureGPU( texture );
146
146
 
147
- if ( binding.textureGPU !== textureGPU || forceUpdate === true ) {
147
+ if ( textureGPU !== undefined && binding.textureGPU !== textureGPU || needsTextureRefresh === true ) {
148
148
 
149
149
  binding.textureGPU = textureGPU;
150
150
  needsBindGroupRefresh = true;
@@ -2,10 +2,9 @@ import WebGPUProgrammableStage from './WebGPUProgrammableStage.js';
2
2
 
3
3
  class WebGPUComputePipelines {
4
4
 
5
- constructor( device, glslang ) {
5
+ constructor( device ) {
6
6
 
7
7
  this.device = device;
8
- this.glslang = glslang;
9
8
 
10
9
  this.pipelines = new WeakMap();
11
10
  this.stages = {
@@ -23,7 +22,6 @@ class WebGPUComputePipelines {
23
22
  if ( pipeline === undefined ) {
24
23
 
25
24
  const device = this.device;
26
- const glslang = this.glslang;
27
25
 
28
26
  const shader = {
29
27
  computeShader: param.shader
@@ -35,7 +33,7 @@ class WebGPUComputePipelines {
35
33
 
36
34
  if ( stageCompute === undefined ) {
37
35
 
38
- stageCompute = new WebGPUProgrammableStage( device, glslang, shader.computeShader, 'compute' );
36
+ stageCompute = new WebGPUProgrammableStage( device, shader.computeShader, 'compute' );
39
37
 
40
38
  this.stages.compute.set( shader, stageCompute );
41
39
 
@@ -2,7 +2,7 @@ let _id = 0;
2
2
 
3
3
  class WebGPUProgrammableStage {
4
4
 
5
- constructor( device, glslang, code, type ) {
5
+ constructor( device, code, type ) {
6
6
 
7
7
  this.id = _id ++;
8
8
 
@@ -10,10 +10,8 @@ class WebGPUProgrammableStage {
10
10
  this.type = type;
11
11
  this.usedTimes = 0;
12
12
 
13
- const byteCode = glslang.compileGLSL( code, type );
14
-
15
13
  this.stage = {
16
- module: device.createShaderModule( { code: byteCode } ),
14
+ module: device.createShaderModule( { code } ),
17
15
  entryPoint: 'main'
18
16
  };
19
17
 
@@ -32,7 +32,7 @@ class WebGPURenderPipeline {
32
32
 
33
33
  // determine shader attributes
34
34
 
35
- const shaderAttributes = this._parseShaderAttributes( nodeBuilder.vertexShader, geometry );
35
+ const shaderAttributes = this._getShaderAttributes( nodeBuilder, geometry );
36
36
 
37
37
  // vertex buffers
38
38
 
@@ -701,42 +701,34 @@ class WebGPURenderPipeline {
701
701
 
702
702
  }
703
703
 
704
- _parseShaderAttributes( shader, geometry ) {
705
-
706
- // find "layout (location = num) in type name" in vertex shader
707
-
708
- const regex = /\s*layout\s*\(\s*location\s*=\s*(?<location>[0-9]+)\s*\)\s*in\s+(?<type>\w+)\s+(?<name>\w+)\s*;/gmi;
709
- let shaderAttribute = null;
704
+ _getShaderAttributes( nodeBuilder, geometry ) {
710
705
 
706
+ const nodeAttributes = nodeBuilder.attributes;
711
707
  const attributes = [];
712
708
 
713
- while ( shaderAttribute = regex.exec( shader ) ) {
709
+ for ( let slot = 0; slot < nodeAttributes.length; slot++ ) {
714
710
 
715
- const name = shaderAttribute.groups.name;
711
+ const nodeAttribute = nodeAttributes[ slot ];
712
+
713
+ const name = nodeAttribute.name;
714
+ const type = nodeAttribute.type;
716
715
 
717
716
  const geometryAttribute = geometry.getAttribute( name );
718
717
  const bytesPerElement = ( geometryAttribute !== undefined ) ? geometryAttribute.array.BYTES_PER_ELEMENT : 4;
719
718
 
720
- const shaderLocation = parseInt( shaderAttribute.groups.location );
721
- const arrayStride = this._getArrayStride( shaderAttribute.groups.type, bytesPerElement );
722
- const vertexFormat = this._getVertexFormat( shaderAttribute.groups.type, bytesPerElement );
719
+ const arrayStride = this._getArrayStride( type, bytesPerElement );
720
+ const format = this._getVertexFormat( type, bytesPerElement );
723
721
 
724
722
  attributes.push( {
725
- name: name,
726
- arrayStride: arrayStride,
727
- slot: shaderLocation,
728
- format: vertexFormat
723
+ name,
724
+ arrayStride,
725
+ format,
726
+ slot
729
727
  } );
730
728
 
731
729
  }
732
730
 
733
- // the sort ensures to setup vertex buffers in the correct order
734
-
735
- return attributes.sort( function ( a, b ) {
736
-
737
- return a.slot - b.slot;
738
-
739
- } );
731
+ return attributes;
740
732
 
741
733
  }
742
734
 
@@ -3,12 +3,11 @@ import WebGPUProgrammableStage from './WebGPUProgrammableStage.js';
3
3
 
4
4
  class WebGPURenderPipelines {
5
5
 
6
- constructor( renderer, properties, device, glslang, sampleCount, nodes ) {
6
+ constructor( renderer, properties, device, sampleCount, nodes ) {
7
7
 
8
8
  this.renderer = renderer;
9
9
  this.properties = properties;
10
10
  this.device = device;
11
- this.glslang = glslang;
12
11
  this.sampleCount = sampleCount;
13
12
  this.nodes = nodes;
14
13
 
@@ -25,7 +24,6 @@ class WebGPURenderPipelines {
25
24
  get( object ) {
26
25
 
27
26
  const device = this.device;
28
- const glslang = this.glslang;
29
27
  const properties = this.properties;
30
28
 
31
29
  const material = object.material;
@@ -47,7 +45,7 @@ class WebGPURenderPipelines {
47
45
 
48
46
  if ( stageVertex === undefined ) {
49
47
 
50
- stageVertex = new WebGPUProgrammableStage( device, glslang, nodeBuilder.vertexShader, 'vertex' );
48
+ stageVertex = new WebGPUProgrammableStage( device, nodeBuilder.vertexShader, 'vertex' );
51
49
  this.stages.vertex.set( nodeBuilder.vertexShader, stageVertex );
52
50
 
53
51
  }
@@ -56,7 +54,7 @@ class WebGPURenderPipelines {
56
54
 
57
55
  if ( stageFragment === undefined ) {
58
56
 
59
- stageFragment = new WebGPUProgrammableStage( device, glslang, nodeBuilder.fragmentShader, 'fragment' );
57
+ stageFragment = new WebGPUProgrammableStage( device, nodeBuilder.fragmentShader, 'fragment' );
60
58
  this.stages.fragment.set( nodeBuilder.fragmentShader, stageFragment );
61
59
 
62
60
  }