super-three 0.167.0 → 0.168.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 (311) hide show
  1. package/build/three.cjs +165 -44
  2. package/build/three.module.js +165 -45
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +23600 -21931
  5. package/build/three.webgpu.min.js +1 -1
  6. package/examples/jsm/Addons.js +3 -1
  7. package/examples/jsm/animation/AnimationClipCreator.js +1 -1
  8. package/examples/jsm/capabilities/WebGL.js +27 -21
  9. package/examples/jsm/controls/ArcballControls.js +174 -158
  10. package/examples/jsm/controls/DragControls.js +260 -132
  11. package/examples/jsm/controls/FirstPersonControls.js +175 -163
  12. package/examples/jsm/controls/FlyControls.js +194 -188
  13. package/examples/jsm/controls/OrbitControls.js +777 -786
  14. package/examples/jsm/controls/PointerLockControls.js +24 -15
  15. package/examples/jsm/controls/TrackballControls.js +453 -452
  16. package/examples/jsm/effects/AnaglyphEffect.js +6 -13
  17. package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
  18. package/examples/jsm/effects/StereoEffect.js +6 -1
  19. package/examples/jsm/environments/RoomEnvironment.js +1 -1
  20. package/examples/jsm/exporters/GLTFExporter.js +6 -1
  21. package/examples/jsm/exporters/USDZExporter.js +29 -8
  22. package/examples/jsm/helpers/LightProbeHelper.js +42 -43
  23. package/examples/jsm/loaders/KTX2Loader.js +19 -7
  24. package/examples/jsm/loaders/MaterialXLoader.js +11 -4
  25. package/examples/jsm/loaders/PCDLoader.js +9 -9
  26. package/examples/jsm/objects/SkyMesh.js +188 -0
  27. package/examples/jsm/objects/Water2Mesh.js +159 -0
  28. package/examples/jsm/objects/WaterMesh.js +102 -0
  29. package/examples/jsm/physics/RapierPhysics.js +20 -0
  30. package/examples/jsm/postprocessing/OutlinePass.js +31 -46
  31. package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
  32. package/examples/jsm/shaders/BleachBypassShader.js +1 -2
  33. package/examples/jsm/shaders/OutputShader.js +1 -1
  34. package/examples/jsm/transpiler/TSLEncoder.js +8 -8
  35. package/examples/jsm/utils/TextureUtils.js +1 -1
  36. package/package.json +2 -1
  37. package/src/Three.WebGPU.js +6 -0
  38. package/src/Three.js +1 -0
  39. package/src/constants.js +1 -1
  40. package/src/extras/Controls.js +32 -0
  41. package/src/loaders/ObjectLoader.js +3 -3
  42. package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
  43. package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
  44. package/src/materials/Material.js +4 -7
  45. package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
  46. package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
  47. package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
  48. package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
  49. package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
  50. package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
  51. package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
  52. package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
  53. package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
  54. package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
  55. package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
  56. package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
  57. package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
  58. package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
  59. package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
  60. package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
  61. package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
  62. package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
  63. package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
  64. package/src/nodes/Nodes.js +103 -159
  65. package/src/nodes/TSL.js +176 -0
  66. package/src/nodes/accessors/AccessorsUtils.js +8 -8
  67. package/src/nodes/accessors/BatchNode.js +48 -20
  68. package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
  69. package/src/nodes/accessors/BufferAttributeNode.js +5 -5
  70. package/src/nodes/accessors/BufferNode.js +4 -4
  71. package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
  72. package/src/nodes/accessors/ClippingNode.js +16 -14
  73. package/src/nodes/accessors/CubeTextureNode.js +5 -7
  74. package/src/nodes/accessors/InstanceNode.js +17 -13
  75. package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
  76. package/src/nodes/accessors/MaterialNode.js +52 -55
  77. package/src/nodes/accessors/MaterialProperties.js +3 -0
  78. package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
  79. package/src/nodes/accessors/ModelNode.js +11 -11
  80. package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
  81. package/src/nodes/accessors/MorphNode.js +12 -12
  82. package/src/nodes/accessors/Normal.js +62 -0
  83. package/src/nodes/accessors/Object3DNode.js +10 -10
  84. package/src/nodes/accessors/PointUVNode.js +4 -4
  85. package/src/nodes/accessors/Position.js +10 -0
  86. package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
  87. package/src/nodes/accessors/ReferenceNode.js +13 -7
  88. package/src/nodes/accessors/ReflectVector.js +10 -0
  89. package/src/nodes/accessors/RendererReferenceNode.js +6 -6
  90. package/src/nodes/accessors/SceneNode.js +5 -6
  91. package/src/nodes/accessors/SkinningNode.js +84 -21
  92. package/src/nodes/accessors/StorageBufferNode.js +4 -5
  93. package/src/nodes/accessors/StorageTextureNode.js +5 -5
  94. package/src/nodes/accessors/Tangent.js +22 -0
  95. package/src/nodes/accessors/Texture3DNode.js +11 -11
  96. package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
  97. package/src/nodes/accessors/TextureNode.js +16 -21
  98. package/src/nodes/accessors/TextureSizeNode.js +4 -6
  99. package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
  100. package/src/nodes/accessors/UserDataNode.js +4 -4
  101. package/src/nodes/accessors/VelocityNode.js +83 -0
  102. package/src/nodes/accessors/VertexColorNode.js +4 -4
  103. package/src/nodes/code/CodeNode.js +5 -5
  104. package/src/nodes/code/ExpressionNode.js +4 -4
  105. package/src/nodes/code/FunctionCallNode.js +5 -5
  106. package/src/nodes/code/FunctionNode.js +5 -23
  107. package/src/nodes/code/ScriptableNode.js +4 -6
  108. package/src/nodes/code/ScriptableValueNode.js +4 -6
  109. package/src/nodes/core/AssignNode.js +5 -5
  110. package/src/nodes/core/AttributeNode.js +7 -20
  111. package/src/nodes/core/BypassNode.js +5 -5
  112. package/src/nodes/core/CacheNode.js +5 -5
  113. package/src/nodes/core/ConstNode.js +2 -2
  114. package/src/nodes/core/ContextNode.js +17 -11
  115. package/src/nodes/core/IndexNode.js +12 -7
  116. package/src/nodes/core/InputNode.js +2 -2
  117. package/src/nodes/core/MRTNode.js +12 -6
  118. package/src/nodes/core/Node.js +39 -19
  119. package/src/nodes/core/NodeBuilder.js +46 -33
  120. package/src/nodes/core/NodeUtils.js +1 -0
  121. package/src/nodes/core/OutputStructNode.js +4 -4
  122. package/src/nodes/core/ParameterNode.js +4 -4
  123. package/src/nodes/core/PropertyNode.js +32 -32
  124. package/src/nodes/core/StackNode.js +26 -10
  125. package/src/nodes/core/StructTypeNode.js +2 -2
  126. package/src/nodes/core/TempNode.js +2 -2
  127. package/src/nodes/core/UniformGroupNode.js +8 -9
  128. package/src/nodes/core/UniformNode.js +4 -4
  129. package/src/nodes/core/VarNode.js +6 -6
  130. package/src/nodes/core/VaryingNode.js +5 -5
  131. package/src/nodes/display/AfterImageNode.js +9 -9
  132. package/src/nodes/display/AnaglyphPassNode.js +61 -0
  133. package/src/nodes/display/AnamorphicNode.js +11 -11
  134. package/src/nodes/display/BleachBypass.js +26 -0
  135. package/src/nodes/display/BlendMode.js +54 -0
  136. package/src/nodes/display/BloomNode.js +21 -19
  137. package/src/nodes/display/BumpMapNode.js +7 -12
  138. package/src/nodes/display/ColorAdjustment.js +46 -0
  139. package/src/nodes/display/ColorSpaceFunctions.js +38 -0
  140. package/src/nodes/display/ColorSpaceNode.js +40 -63
  141. package/src/nodes/display/DenoiseNode.js +20 -17
  142. package/src/nodes/display/DepthOfFieldNode.js +8 -6
  143. package/src/nodes/display/DotScreenNode.js +10 -22
  144. package/src/nodes/display/FXAANode.js +17 -15
  145. package/src/nodes/display/FilmNode.js +7 -6
  146. package/src/nodes/display/FrontFacingNode.js +5 -5
  147. package/src/nodes/display/GTAONode.js +19 -15
  148. package/src/nodes/display/GaussianBlurNode.js +11 -8
  149. package/src/nodes/display/Lut3DNode.js +6 -5
  150. package/src/nodes/display/MotionBlur.js +25 -0
  151. package/src/nodes/display/NormalMapNode.js +8 -10
  152. package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
  153. package/src/nodes/display/PassNode.js +84 -8
  154. package/src/nodes/display/PixelationPassNode.js +12 -7
  155. package/src/nodes/display/PosterizeNode.js +4 -6
  156. package/src/nodes/display/RGBShiftNode.js +8 -7
  157. package/src/nodes/display/RenderOutputNode.js +9 -9
  158. package/src/nodes/display/SSAAPassNode.js +284 -0
  159. package/src/nodes/display/Sepia.js +17 -0
  160. package/src/nodes/display/SobelOperatorNode.js +9 -7
  161. package/src/nodes/display/StereoCompositePassNode.js +107 -0
  162. package/src/nodes/display/StereoPassNode.js +80 -0
  163. package/src/nodes/display/ToneMappingFunctions.js +190 -0
  164. package/src/nodes/display/ToneMappingNode.js +12 -173
  165. package/src/nodes/display/TransitionNode.js +9 -8
  166. package/src/nodes/display/ViewportDepthNode.js +30 -29
  167. package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
  168. package/src/nodes/display/ViewportNode.js +26 -25
  169. package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
  170. package/src/nodes/display/ViewportTextureNode.js +7 -10
  171. package/src/nodes/fog/FogExp2Node.js +4 -6
  172. package/src/nodes/fog/FogNode.js +5 -7
  173. package/src/nodes/fog/FogRangeNode.js +4 -6
  174. package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
  175. package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  176. package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
  177. package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
  178. package/src/nodes/functions/BSDF/D_GGX.js +2 -2
  179. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
  180. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
  181. package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
  182. package/src/nodes/functions/BSDF/LTC.js +6 -6
  183. package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
  184. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
  185. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
  186. package/src/nodes/functions/BasicLightingModel.js +1 -1
  187. package/src/nodes/functions/PhongLightingModel.js +5 -5
  188. package/src/nodes/functions/PhysicalLightingModel.js +32 -31
  189. package/src/nodes/functions/ShadowMaskModel.js +1 -1
  190. package/src/nodes/functions/ToonLightingModel.js +3 -3
  191. package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
  192. package/src/nodes/functions/material/getRoughness.js +2 -2
  193. package/src/nodes/geometry/RangeNode.js +4 -4
  194. package/src/nodes/gpgpu/ComputeNode.js +5 -5
  195. package/src/nodes/lighting/AONode.js +2 -2
  196. package/src/nodes/lighting/AmbientLightNode.js +2 -7
  197. package/src/nodes/lighting/AnalyticLightNode.js +34 -13
  198. package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
  199. package/src/nodes/lighting/BasicLightMapNode.js +3 -3
  200. package/src/nodes/lighting/DirectionalLightNode.js +2 -7
  201. package/src/nodes/lighting/EnvironmentNode.js +20 -19
  202. package/src/nodes/lighting/HemisphereLightNode.js +3 -7
  203. package/src/nodes/lighting/IESSpotLightNode.js +3 -8
  204. package/src/nodes/lighting/IrradianceNode.js +2 -2
  205. package/src/nodes/lighting/LightNode.js +5 -5
  206. package/src/nodes/lighting/LightProbeNode.js +76 -0
  207. package/src/nodes/lighting/LightUtils.js +3 -3
  208. package/src/nodes/lighting/LightingContextNode.js +15 -17
  209. package/src/nodes/lighting/LightingNode.js +2 -2
  210. package/src/nodes/lighting/LightsNode.js +94 -76
  211. package/src/nodes/lighting/PointLightNode.js +3 -8
  212. package/src/nodes/lighting/RectAreaLightNode.js +2 -6
  213. package/src/nodes/lighting/SpotLightNode.js +3 -8
  214. package/src/nodes/materialx/MaterialXNodes.js +2 -2
  215. package/src/nodes/materialx/lib/mx_hsv.js +36 -31
  216. package/src/nodes/materialx/lib/mx_noise.js +96 -96
  217. package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
  218. package/src/nodes/math/{CondNode.js → ConditionalNode.js} +18 -7
  219. package/src/nodes/math/Hash.js +13 -0
  220. package/src/nodes/math/MathNode.js +124 -124
  221. package/src/nodes/math/MathUtils.js +0 -7
  222. package/src/nodes/math/OperatorNode.js +94 -52
  223. package/src/nodes/math/TriNoise3D.js +19 -29
  224. package/src/nodes/pmrem/PMREMNode.js +58 -15
  225. package/src/nodes/pmrem/PMREMUtils.js +46 -46
  226. package/src/nodes/procedural/Checker.js +14 -0
  227. package/src/nodes/tsl/TSLBase.js +30 -0
  228. package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
  229. package/src/nodes/utils/ArrayElementNode.js +2 -2
  230. package/src/nodes/utils/ConvertNode.js +2 -2
  231. package/src/nodes/utils/CubeMapNode.js +157 -0
  232. package/src/nodes/utils/Discard.js +8 -0
  233. package/src/nodes/utils/EquirectUVNode.js +5 -5
  234. package/src/nodes/utils/FlipNode.js +65 -0
  235. package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
  236. package/src/nodes/utils/JoinNode.js +2 -2
  237. package/src/nodes/utils/LoopNode.js +12 -6
  238. package/src/nodes/utils/MatcapUVNode.js +6 -6
  239. package/src/nodes/utils/MaxMipLevelNode.js +4 -4
  240. package/src/nodes/utils/OscNode.js +7 -7
  241. package/src/nodes/utils/Packing.js +4 -0
  242. package/src/nodes/utils/RTTNode.js +8 -8
  243. package/src/nodes/utils/ReflectorNode.js +8 -3
  244. package/src/nodes/utils/RemapNode.js +7 -7
  245. package/src/nodes/utils/RotateNode.js +4 -12
  246. package/src/nodes/utils/SetNode.js +2 -2
  247. package/src/nodes/utils/SplitNode.js +2 -2
  248. package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
  249. package/src/nodes/utils/SpriteUtils.js +47 -0
  250. package/src/nodes/utils/StorageArrayElementNode.js +4 -6
  251. package/src/nodes/utils/TimerNode.js +5 -5
  252. package/src/nodes/utils/TriplanarTexturesNode.js +7 -9
  253. package/src/nodes/utils/UVUtils.js +19 -0
  254. package/src/nodes/utils/ViewportUtils.js +14 -0
  255. package/src/objects/BatchedMesh.js +2 -3
  256. package/src/renderers/WebGLRenderer.js +24 -0
  257. package/src/renderers/common/Backend.js +2 -2
  258. package/src/renderers/common/Background.js +3 -1
  259. package/src/renderers/common/BindGroup.js +3 -1
  260. package/src/renderers/common/Bindings.js +13 -15
  261. package/src/renderers/common/ClippingContext.js +14 -5
  262. package/src/renderers/common/CubeRenderTarget.js +9 -3
  263. package/src/renderers/common/PostProcessing.js +4 -1
  264. package/src/renderers/common/QuadMesh.js +2 -0
  265. package/src/renderers/common/RenderContext.js +24 -0
  266. package/src/renderers/common/RenderList.js +1 -1
  267. package/src/renderers/common/RenderObject.js +2 -2
  268. package/src/renderers/common/Renderer.js +75 -49
  269. package/src/renderers/common/SampledTexture.js +12 -3
  270. package/src/renderers/common/StandardRenderer.js +18 -0
  271. package/src/renderers/common/Textures.js +8 -12
  272. package/src/renderers/common/extras/PMREMGenerator.js +12 -13
  273. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  274. package/src/renderers/common/nodes/NodeLibrary.js +118 -0
  275. package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
  276. package/src/renderers/common/nodes/Nodes.js +36 -9
  277. package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
  278. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
  279. package/src/renderers/webgl/WebGLProgram.js +1 -1
  280. package/src/renderers/webgl/WebGLProperties.js +7 -0
  281. package/src/renderers/webgl/WebGLTextures.js +61 -4
  282. package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
  283. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
  284. package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
  285. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
  286. package/src/renderers/webgpu/WebGPUBackend.js +86 -68
  287. package/src/renderers/webgpu/WebGPURenderer.js +8 -8
  288. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
  289. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
  290. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
  291. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +6 -15
  292. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
  293. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
  294. package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
  295. package/src/renderers/webxr/WebXRManager.js +32 -25
  296. package/examples/jsm/loaders/LogLuvLoader.js +0 -606
  297. package/src/nodes/accessors/NormalNode.js +0 -14
  298. package/src/nodes/accessors/PositionNode.js +0 -10
  299. package/src/nodes/accessors/ReflectVectorNode.js +0 -10
  300. package/src/nodes/accessors/TangentNode.js +0 -23
  301. package/src/nodes/core/NodeKeywords.js +0 -80
  302. package/src/nodes/display/BlendModeNode.js +0 -128
  303. package/src/nodes/display/ColorAdjustmentNode.js +0 -104
  304. package/src/nodes/materials/MeshNormalNodeMaterial.js +0 -40
  305. package/src/nodes/math/HashNode.js +0 -34
  306. package/src/nodes/procedural/CheckerNode.js +0 -42
  307. package/src/nodes/utils/DiscardNode.js +0 -28
  308. package/src/nodes/utils/PackingNode.js +0 -55
  309. package/src/nodes/utils/RotateUVNode.js +0 -35
  310. /package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
  311. /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
@@ -1,11 +1,12 @@
1
- import Node, { addNodeClass } from '../core/Node.js';
2
- import { normalLocal } from './NormalNode.js';
3
- import { positionLocal } from './PositionNode.js';
4
- import { nodeProxy, vec3, mat3, mat4, int, ivec2, float, tslFn } from '../shadernode/ShaderNode.js';
1
+ import Node, { registerNode } from '../core/Node.js';
2
+ import { normalLocal } from './Normal.js';
3
+ import { positionLocal } from './Position.js';
4
+ import { nodeProxy, vec3, mat3, mat4, int, ivec2, float, Fn } from '../tsl/TSLBase.js';
5
5
  import { textureLoad } from './TextureNode.js';
6
6
  import { textureSize } from './TextureSizeNode.js';
7
- import { tangentLocal } from './TangentNode.js';
7
+ import { tangentLocal } from './Tangent.js';
8
8
  import { instanceIndex, drawIndex } from '../core/IndexNode.js';
9
+ import { varyingProperty } from '../core/PropertyNode.js';
9
10
 
10
11
  class BatchNode extends Node {
11
12
 
@@ -16,8 +17,6 @@ class BatchNode extends Node {
16
17
  this.batchMesh = batchMesh;
17
18
 
18
19
 
19
- this.instanceColorNode = null;
20
-
21
20
  this.batchingIdNode = null;
22
21
 
23
22
  }
@@ -40,10 +39,10 @@ class BatchNode extends Node {
40
39
 
41
40
  }
42
41
 
43
- const getIndirectIndex = tslFn( ( [ id ] ) => {
42
+ const getIndirectIndex = Fn( ( [ id ] ) => {
44
43
 
45
44
  const size = textureSize( textureLoad( this.batchMesh._indirectTexture ), 0 );
46
- const x = int( id ).remainder( int( size ) );
45
+ const x = int( id ).modInt( int( size ) );
47
46
  const y = int( id ).div( int( size ) );
48
47
  return textureLoad( this.batchMesh._indirectTexture, ivec2( x, y ) ).x;
49
48
 
@@ -55,20 +54,49 @@ class BatchNode extends Node {
55
54
  ]
56
55
  } );
57
56
 
58
- const matriceTexture = this.batchMesh._matricesTexture;
57
+ const indirectId = getIndirectIndex( int( this.batchingIdNode ) );
58
+
59
+ const matricesTexture = this.batchMesh._matricesTexture;
59
60
 
60
- const size = textureSize( textureLoad( matriceTexture ), 0 );
61
- const j = float( getIndirectIndex( int( this.batchingIdNode ) ) ).mul( 4 ).toVar();
61
+ const size = textureSize( textureLoad( matricesTexture ), 0 );
62
+ const j = float( indirectId ).mul( 4 ).toInt().toVar();
62
63
 
63
- const x = int( j.mod( size ) );
64
- const y = int( j ).div( int( size ) );
64
+ const x = j.modInt( size );
65
+ const y = j.div( int( size ) );
65
66
  const batchingMatrix = mat4(
66
- textureLoad( matriceTexture, ivec2( x, y ) ),
67
- textureLoad( matriceTexture, ivec2( x.add( 1 ), y ) ),
68
- textureLoad( matriceTexture, ivec2( x.add( 2 ), y ) ),
69
- textureLoad( matriceTexture, ivec2( x.add( 3 ), y ) )
67
+ textureLoad( matricesTexture, ivec2( x, y ) ),
68
+ textureLoad( matricesTexture, ivec2( x.add( 1 ), y ) ),
69
+ textureLoad( matricesTexture, ivec2( x.add( 2 ), y ) ),
70
+ textureLoad( matricesTexture, ivec2( x.add( 3 ), y ) )
70
71
  );
71
72
 
73
+
74
+ const colorsTexture = this.batchMesh._colorsTexture;
75
+
76
+ if ( colorsTexture !== null ) {
77
+
78
+ const getBatchingColor = Fn( ( [ id ] ) => {
79
+
80
+ const size = textureSize( textureLoad( colorsTexture ), 0 ).x;
81
+ const j = id;
82
+ const x = j.modInt( size );
83
+ const y = j.div( size );
84
+ return textureLoad( colorsTexture, ivec2( x, y ) ).rgb;
85
+
86
+ } ).setLayout( {
87
+ name: 'getBatchingColor',
88
+ type: 'vec3',
89
+ inputs: [
90
+ { name: 'id', type: 'int' }
91
+ ]
92
+ } );
93
+
94
+ const color = getBatchingColor( indirectId );
95
+
96
+ varyingProperty( 'vec3', 'vBatchColor' ).assign( color );
97
+
98
+ }
99
+
72
100
  const bm = mat3( batchingMatrix );
73
101
 
74
102
  positionLocal.assign( batchingMatrix.mul( positionLocal ) );
@@ -91,6 +119,6 @@ class BatchNode extends Node {
91
119
 
92
120
  export default BatchNode;
93
121
 
94
- export const batch = nodeProxy( BatchNode );
122
+ BatchNode.type = /*@__PURE__*/ registerNode( 'Batch', BatchNode );
95
123
 
96
- addNodeClass( 'batch', BatchNode );
124
+ export const batch = /*@__PURE__*/ nodeProxy( BatchNode );
@@ -1,13 +1,13 @@
1
1
  import { varying } from '../core/VaryingNode.js';
2
- import { cameraViewMatrix } from './CameraNode.js';
3
- import { normalGeometry, normalLocal, normalView, normalWorld, transformedNormalView } from './NormalNode.js';
4
- import { tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView } from './TangentNode.js';
2
+ import { cameraViewMatrix } from './Camera.js';
3
+ import { normalGeometry, normalLocal, normalView, normalWorld, transformedNormalView } from './Normal.js';
4
+ import { tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView } from './Tangent.js';
5
5
 
6
6
  const getBitangent = ( crossNormalTangent ) => crossNormalTangent.mul( tangentGeometry.w ).xyz;
7
7
 
8
- export const bitangentGeometry = /*#__PURE__*/ varying( getBitangent( normalGeometry.cross( tangentGeometry ) ), 'v_bitangentGeometry' ).normalize().toVar( 'bitangentGeometry' );
9
- export const bitangentLocal = /*#__PURE__*/ varying( getBitangent( normalLocal.cross( tangentLocal ) ), 'v_bitangentLocal' ).normalize().toVar( 'bitangentLocal' );
10
- export const bitangentView = /*#__PURE__*/ varying( getBitangent( normalView.cross( tangentView ) ), 'v_bitangentView' ).normalize().toVar( 'bitangentView' );
11
- export const bitangentWorld = /*#__PURE__*/ varying( getBitangent( normalWorld.cross( tangentWorld ) ), 'v_bitangentWorld' ).normalize().toVar( 'bitangentWorld' );
12
- export const transformedBitangentView = /*#__PURE__*/ getBitangent( transformedNormalView.cross( transformedTangentView ) ).normalize().toVar( 'transformedBitangentView' );
13
- export const transformedBitangentWorld = /*#__PURE__*/ transformedBitangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedBitangentWorld' );
8
+ export const bitangentGeometry = /*@__PURE__*/ varying( getBitangent( normalGeometry.cross( tangentGeometry ) ), 'v_bitangentGeometry' ).normalize().toVar( 'bitangentGeometry' );
9
+ export const bitangentLocal = /*@__PURE__*/ varying( getBitangent( normalLocal.cross( tangentLocal ) ), 'v_bitangentLocal' ).normalize().toVar( 'bitangentLocal' );
10
+ export const bitangentView = /*@__PURE__*/ varying( getBitangent( normalView.cross( tangentView ) ), 'v_bitangentView' ).normalize().toVar( 'bitangentView' );
11
+ export const bitangentWorld = /*@__PURE__*/ varying( getBitangent( normalWorld.cross( tangentWorld ) ), 'v_bitangentWorld' ).normalize().toVar( 'bitangentWorld' );
12
+ export const transformedBitangentView = /*@__PURE__*/ getBitangent( transformedNormalView.cross( transformedTangentView ) ).normalize().toVar( 'transformedBitangentView' );
13
+ export const transformedBitangentWorld = /*@__PURE__*/ transformedBitangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedBitangentWorld' );
@@ -1,7 +1,7 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import InputNode from '../core/InputNode.js';
2
- import { addNodeClass } from '../core/Node.js';
3
+ import { nodeObject, addMethodChaining } from '../tsl/TSLCore.js';
3
4
  import { varying } from '../core/VaryingNode.js';
4
- import { nodeObject, addNodeElement } from '../shadernode/ShaderNode.js';
5
5
 
6
6
  import { InterleavedBufferAttribute } from '../../core/InterleavedBufferAttribute.js';
7
7
  import { InterleavedBuffer } from '../../core/InterleavedBuffer.js';
@@ -151,12 +151,12 @@ class BufferAttributeNode extends InputNode {
151
151
 
152
152
  export default BufferAttributeNode;
153
153
 
154
+ BufferAttributeNode.type = /*@__PURE__*/ registerNode( 'BufferAttribute', BufferAttributeNode );
155
+
154
156
  export const bufferAttribute = ( array, type, stride, offset ) => nodeObject( new BufferAttributeNode( array, type, stride, offset ) );
155
157
  export const dynamicBufferAttribute = ( array, type, stride, offset ) => bufferAttribute( array, type, stride, offset ).setUsage( DynamicDrawUsage );
156
158
 
157
159
  export const instancedBufferAttribute = ( array, type, stride, offset ) => bufferAttribute( array, type, stride, offset ).setInstanced( true );
158
160
  export const instancedDynamicBufferAttribute = ( array, type, stride, offset ) => dynamicBufferAttribute( array, type, stride, offset ).setInstanced( true );
159
161
 
160
- addNodeElement( 'toAttribute', ( bufferNode ) => bufferAttribute( bufferNode.value ) );
161
-
162
- addNodeClass( 'BufferAttributeNode', BufferAttributeNode );
162
+ addMethodChaining( 'toAttribute', ( bufferNode ) => bufferAttribute( bufferNode.value ) );
@@ -1,6 +1,6 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import UniformNode from '../core/UniformNode.js';
2
- import { addNodeClass } from '../core/Node.js';
3
- import { nodeObject } from '../shadernode/ShaderNode.js';
3
+ import { nodeObject } from '../tsl/TSLBase.js';
4
4
 
5
5
  class BufferNode extends UniformNode {
6
6
 
@@ -31,6 +31,6 @@ class BufferNode extends UniformNode {
31
31
 
32
32
  export default BufferNode;
33
33
 
34
- export const buffer = ( value, type, count ) => nodeObject( new BufferNode( value, type, count ) );
34
+ BufferNode.type = /*@__PURE__*/ registerNode( 'Buffer', BufferNode );
35
35
 
36
- addNodeClass( 'BufferNode', BufferNode );
36
+ export const buffer = ( value, type, count ) => nodeObject( new BufferNode( value, type, count ) );
@@ -2,18 +2,18 @@ import { uniform } from '../core/UniformNode.js';
2
2
  import { sharedUniformGroup } from '../core/UniformGroupNode.js';
3
3
  import { Vector3 } from '../../math/Vector3.js';
4
4
 
5
- const cameraGroup = /*#__PURE__*/ sharedUniformGroup( 'camera' ).onRenderUpdate( () => {
5
+ const cameraGroup = /*@__PURE__*/ sharedUniformGroup( 'camera' ).onRenderUpdate( () => {
6
6
 
7
7
  cameraGroup.needsUpdate = true;
8
8
 
9
9
  } );
10
10
 
11
- export const cameraNear = /*#__PURE__*/ uniform( 'float' ).label( 'cameraNear' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.near );
12
- export const cameraFar = /*#__PURE__*/ uniform( 'float' ).label( 'cameraFar' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.far );
13
- export const cameraLogDepth = /*#__PURE__*/ uniform( 'float' ).label( 'cameraLogDepth' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
14
- export const cameraProjectionMatrix = /*#__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrix );
15
- export const cameraProjectionMatrixInverse = /*#__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrixInverse' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrixInverse );
16
- export const cameraViewMatrix = /*#__PURE__*/ uniform( 'mat4' ).label( 'cameraViewMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorldInverse );
17
- export const cameraWorldMatrix = /*#__PURE__*/ uniform( 'mat4' ).label( 'cameraWorldMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorld );
18
- export const cameraNormalMatrix = /*#__PURE__*/ uniform( 'mat3' ).label( 'cameraNormalMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.normalMatrix );
19
- export const cameraPosition = /*#__PURE__*/ uniform( new Vector3() ).label( 'cameraPosition' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera }, self ) => self.value.setFromMatrixPosition( camera.matrixWorld ) );
11
+ export const cameraNear = /*@__PURE__*/ uniform( 'float' ).label( 'cameraNear' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.near );
12
+ export const cameraFar = /*@__PURE__*/ uniform( 'float' ).label( 'cameraFar' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.far );
13
+ export const cameraLogDepth = /*@__PURE__*/ uniform( 'float' ).label( 'cameraLogDepth' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
14
+ export const cameraProjectionMatrix = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrix );
15
+ export const cameraProjectionMatrixInverse = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrixInverse' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrixInverse );
16
+ export const cameraViewMatrix = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraViewMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorldInverse );
17
+ export const cameraWorldMatrix = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraWorldMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorld );
18
+ export const cameraNormalMatrix = /*@__PURE__*/ uniform( 'mat3' ).label( 'cameraNormalMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.normalMatrix );
19
+ export const cameraPosition = /*@__PURE__*/ uniform( new Vector3() ).label( 'cameraPosition' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera }, self ) => self.value.setFromMatrixPosition( camera.matrixWorld ) );
@@ -1,12 +1,12 @@
1
1
 
2
- import Node from '../core/Node.js';
3
- import { nodeObject } from '../shadernode/ShaderNode.js';
4
- import { positionView } from './PositionNode.js';
2
+ import Node, { registerNode } from '../core/Node.js';
3
+ import { nodeObject } from '../tsl/TSLBase.js';
4
+ import { positionView } from './Position.js';
5
5
  import { diffuseColor, property } from '../core/PropertyNode.js';
6
- import { tslFn } from '../shadernode/ShaderNode.js';
7
- import { loop } from '../utils/LoopNode.js';
6
+ import { Fn } from '../tsl/TSLBase.js';
7
+ import { Loop } from '../utils/LoopNode.js';
8
8
  import { smoothstep } from '../math/MathNode.js';
9
- import { uniforms } from './UniformsNode.js';
9
+ import { uniformArray } from './UniformArrayNode.js';
10
10
 
11
11
  class ClippingNode extends Node {
12
12
 
@@ -42,9 +42,9 @@ class ClippingNode extends Node {
42
42
 
43
43
  setupAlphaToCoverage( planes, numClippingPlanes, numUnionClippingPlanes ) {
44
44
 
45
- return tslFn( () => {
45
+ return Fn( () => {
46
46
 
47
- const clippingPlanes = uniforms( planes );
47
+ const clippingPlanes = uniformArray( planes );
48
48
 
49
49
  const distanceToPlane = property( 'float', 'distanceToPlane' );
50
50
  const distanceGradient = property( 'float', 'distanceToGradient' );
@@ -55,7 +55,7 @@ class ClippingNode extends Node {
55
55
 
56
56
  let plane;
57
57
 
58
- loop( numUnionClippingPlanes, ( { i } ) => {
58
+ Loop( numUnionClippingPlanes, ( { i } ) => {
59
59
 
60
60
  plane = clippingPlanes.element( i );
61
61
 
@@ -74,7 +74,7 @@ class ClippingNode extends Node {
74
74
 
75
75
  unionClipOpacity.assign( 1 );
76
76
 
77
- loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
77
+ Loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
78
78
 
79
79
  plane = clippingPlanes.element( i );
80
80
 
@@ -99,13 +99,13 @@ class ClippingNode extends Node {
99
99
 
100
100
  setupDefault( planes, numClippingPlanes, numUnionClippingPlanes ) {
101
101
 
102
- return tslFn( () => {
102
+ return Fn( () => {
103
103
 
104
- const clippingPlanes = uniforms( planes );
104
+ const clippingPlanes = uniformArray( planes );
105
105
 
106
106
  let plane;
107
107
 
108
- loop( numUnionClippingPlanes, ( { i } ) => {
108
+ Loop( numUnionClippingPlanes, ( { i } ) => {
109
109
 
110
110
  plane = clippingPlanes.element( i );
111
111
  positionView.dot( plane.xyz ).greaterThan( plane.w ).discard();
@@ -118,7 +118,7 @@ class ClippingNode extends Node {
118
118
 
119
119
  clipped.assign( true );
120
120
 
121
- loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
121
+ Loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
122
122
 
123
123
  plane = clippingPlanes.element( i );
124
124
  clipped.assign( positionView.dot( plane.xyz ).greaterThan( plane.w ).and( clipped ) );
@@ -140,6 +140,8 @@ ClippingNode.DEFAULT = 'default';
140
140
 
141
141
  export default ClippingNode;
142
142
 
143
+ ClippingNode.type = /*@__PURE__*/ registerNode( 'Clipping', ClippingNode );
144
+
143
145
  export const clipping = () => nodeObject( new ClippingNode() );
144
146
 
145
147
  export const clippingAlpha = () => nodeObject( new ClippingNode( ClippingNode.ALPHA_TO_COVERAGE ) );
@@ -1,7 +1,7 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import TextureNode from './TextureNode.js';
2
- import { reflectVector, refractVector } from './ReflectVectorNode.js';
3
- import { addNodeClass } from '../core/Node.js';
4
- import { addNodeElement, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
3
+ import { reflectVector, refractVector } from './ReflectVector.js';
4
+ import { nodeProxy, vec3 } from '../tsl/TSLBase.js';
5
5
 
6
6
  import { CubeReflectionMapping, CubeRefractionMapping, WebGPUCoordinateSystem } from '../../constants.js';
7
7
 
@@ -71,8 +71,6 @@ class CubeTextureNode extends TextureNode {
71
71
 
72
72
  export default CubeTextureNode;
73
73
 
74
- export const cubeTexture = nodeProxy( CubeTextureNode );
74
+ CubeTextureNode.type = /*@__PURE__*/ registerNode( 'CubeTexture', CubeTextureNode );
75
75
 
76
- addNodeElement( 'cubeTexture', cubeTexture );
77
-
78
- addNodeClass( 'CubeTextureNode', CubeTextureNode );
76
+ export const cubeTexture = /*@__PURE__*/ nodeProxy( CubeTextureNode );
@@ -1,9 +1,9 @@
1
- import Node, { addNodeClass } from '../core/Node.js';
1
+ import Node, { registerNode } from '../core/Node.js';
2
2
  import { varyingProperty } from '../core/PropertyNode.js';
3
3
  import { instancedBufferAttribute, instancedDynamicBufferAttribute } from './BufferAttributeNode.js';
4
- import { normalLocal } from './NormalNode.js';
5
- import { positionLocal } from './PositionNode.js';
6
- import { nodeProxy, vec3, mat3, mat4 } from '../shadernode/ShaderNode.js';
4
+ import { normalLocal } from './Normal.js';
5
+ import { positionLocal } from './Position.js';
6
+ import { nodeProxy, vec3, mat3, mat4 } from '../tsl/TSLBase.js';
7
7
  import { NodeUpdateType } from '../core/constants.js';
8
8
  import { buffer } from '../accessors/BufferNode.js';
9
9
  import { instanceIndex } from '../core/IndexNode.js';
@@ -31,7 +31,7 @@ class InstanceNode extends Node {
31
31
 
32
32
  }
33
33
 
34
- setup( /*builder*/ ) {
34
+ setup( builder ) {
35
35
 
36
36
  let instanceMatrixNode = this.instanceMatrixNode;
37
37
  let instanceColorNode = this.instanceColorNode;
@@ -91,19 +91,23 @@ class InstanceNode extends Node {
91
91
  // POSITION
92
92
 
93
93
  const instancePosition = instanceMatrixNode.mul( positionLocal ).xyz;
94
+ positionLocal.assign( instancePosition );
94
95
 
95
96
  // NORMAL
96
97
 
97
- const m = mat3( instanceMatrixNode );
98
+ if ( builder.hasGeometryAttribute( 'normal' ) ) {
98
99
 
99
- const transformedNormal = normalLocal.div( vec3( m[ 0 ].dot( m[ 0 ] ), m[ 1 ].dot( m[ 1 ] ), m[ 2 ].dot( m[ 2 ] ) ) );
100
+ const m = mat3( instanceMatrixNode );
100
101
 
101
- const instanceNormal = m.mul( transformedNormal ).xyz;
102
+ const transformedNormal = normalLocal.div( vec3( m[ 0 ].dot( m[ 0 ] ), m[ 1 ].dot( m[ 1 ] ), m[ 2 ].dot( m[ 2 ] ) ) );
102
103
 
103
- // ASSIGNS
104
+ const instanceNormal = m.mul( transformedNormal ).xyz;
104
105
 
105
- positionLocal.assign( instancePosition );
106
- normalLocal.assign( instanceNormal );
106
+ // ASSIGNS
107
+
108
+ normalLocal.assign( instanceNormal );
109
+
110
+ }
107
111
 
108
112
  // COLOR
109
113
 
@@ -135,6 +139,6 @@ class InstanceNode extends Node {
135
139
 
136
140
  export default InstanceNode;
137
141
 
138
- export const instance = nodeProxy( InstanceNode );
142
+ InstanceNode.type = /*@__PURE__*/ registerNode( 'Instance', InstanceNode );
139
143
 
140
- addNodeClass( 'InstanceNode', InstanceNode );
144
+ export const instance = /*@__PURE__*/ nodeProxy( InstanceNode );
@@ -1,6 +1,6 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import MaterialNode from './MaterialNode.js';
2
- import { addNodeClass } from '../core/Node.js';
3
- import { nodeImmutable } from '../shadernode/ShaderNode.js';
3
+ import { nodeImmutable } from '../tsl/TSLBase.js';
4
4
 
5
5
  class InstancedPointsMaterialNode extends MaterialNode {
6
6
 
@@ -16,6 +16,6 @@ InstancedPointsMaterialNode.POINT_WIDTH = 'pointWidth';
16
16
 
17
17
  export default InstancedPointsMaterialNode;
18
18
 
19
- export const materialPointWidth = nodeImmutable( InstancedPointsMaterialNode, InstancedPointsMaterialNode.POINT_WIDTH );
19
+ InstancedPointsMaterialNode.type = /*@__PURE__*/ registerNode( 'InstancedPointsMaterial', InstancedPointsMaterialNode );
20
20
 
21
- addNodeClass( 'InstancedPointsMaterialNode', InstancedPointsMaterialNode );
21
+ export const materialPointWidth = /*@__PURE__*/ nodeImmutable( InstancedPointsMaterialNode, InstancedPointsMaterialNode.POINT_WIDTH );
@@ -1,9 +1,11 @@
1
- import Node, { addNodeClass } from '../core/Node.js';
1
+ import Node, { registerNode } from '../core/Node.js';
2
2
  import { reference } from './ReferenceNode.js';
3
3
  import { materialReference } from './MaterialReferenceNode.js';
4
- import { normalView } from './NormalNode.js';
5
- import { nodeImmutable, float, vec2, mat2 } from '../shadernode/ShaderNode.js';
4
+ import { normalView } from './Normal.js';
5
+ import { nodeImmutable, float, vec2, vec3, mat2 } from '../tsl/TSLBase.js';
6
6
  import { uniform } from '../core/UniformNode.js';
7
+ import { normalMap } from '../display/NormalMapNode.js';
8
+ import { bumpMap } from '../display/BumpMapNode.js';
7
9
 
8
10
  import { Vector2 } from '../../math/Vector2.js';
9
11
 
@@ -62,7 +64,7 @@ class MaterialNode extends Node {
62
64
 
63
65
  if ( scope === MaterialNode.COLOR ) {
64
66
 
65
- const colorNode = this.getColor( scope );
67
+ const colorNode = material.color !== undefined ? this.getColor( scope ) : vec3();
66
68
 
67
69
  if ( material.map && material.map.isTexture === true ) {
68
70
 
@@ -175,11 +177,11 @@ class MaterialNode extends Node {
175
177
 
176
178
  if ( material.normalMap ) {
177
179
 
178
- node = this.getTexture( 'normal' ).normalMap( this.getCache( 'normalScale', 'vec2' ) );
180
+ node = normalMap( this.getTexture( 'normal' ), this.getCache( 'normalScale', 'vec2' ) );
179
181
 
180
182
  } else if ( material.bumpMap ) {
181
183
 
182
- node = this.getTexture( 'bump' ).r.bumpMap( this.getFloat( 'bumpScale' ) );
184
+ node = bumpMap( this.getTexture( 'bump' ).r, this.getFloat( 'bumpScale' ) );
183
185
 
184
186
  } else {
185
187
 
@@ -219,7 +221,7 @@ class MaterialNode extends Node {
219
221
 
220
222
  if ( material.clearcoatNormalMap ) {
221
223
 
222
- node = this.getTexture( scope ).normalMap( this.getCache( scope + 'Scale', 'vec2' ) );
224
+ node = normalMap( this.getTexture( scope ), this.getCache( scope + 'Scale', 'vec2' ) );
223
225
 
224
226
  } else {
225
227
 
@@ -320,10 +322,6 @@ class MaterialNode extends Node {
320
322
 
321
323
  node = this.getFloat( scope );
322
324
 
323
- } else if ( scope === MaterialNode.REFRACTION_RATIO ) {
324
-
325
- node = this.getFloat( scope );
326
-
327
325
  } else if ( scope === MaterialNode.LIGHT_MAP ) {
328
326
 
329
327
  node = this.getTexture( scope ).rgb.mul( this.getFloat( 'lightMapIntensity' ) );
@@ -383,51 +381,52 @@ MaterialNode.POINT_WIDTH = 'pointWidth';
383
381
  MaterialNode.DISPERSION = 'dispersion';
384
382
  MaterialNode.LIGHT_MAP = 'light';
385
383
  MaterialNode.AO_MAP = 'ao';
386
- MaterialNode.REFRACTION_RATIO = 'refractionRatio';
387
384
 
388
385
  export default MaterialNode;
389
386
 
390
- export const materialAlphaTest = nodeImmutable( MaterialNode, MaterialNode.ALPHA_TEST );
391
- export const materialColor = nodeImmutable( MaterialNode, MaterialNode.COLOR );
392
- export const materialShininess = nodeImmutable( MaterialNode, MaterialNode.SHININESS );
393
- export const materialEmissive = nodeImmutable( MaterialNode, MaterialNode.EMISSIVE );
394
- export const materialOpacity = nodeImmutable( MaterialNode, MaterialNode.OPACITY );
395
- export const materialSpecular = nodeImmutable( MaterialNode, MaterialNode.SPECULAR );
396
-
397
- export const materialSpecularIntensity = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_INTENSITY );
398
- export const materialSpecularColor = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_COLOR );
399
-
400
- export const materialSpecularStrength = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_STRENGTH );
401
- export const materialReflectivity = nodeImmutable( MaterialNode, MaterialNode.REFLECTIVITY );
402
- export const materialRoughness = nodeImmutable( MaterialNode, MaterialNode.ROUGHNESS );
403
- export const materialMetalness = nodeImmutable( MaterialNode, MaterialNode.METALNESS );
404
- export const materialNormal = nodeImmutable( MaterialNode, MaterialNode.NORMAL );
405
- export const materialClearcoat = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT );
406
- export const materialClearcoatRoughness = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_ROUGHNESS );
407
- export const materialClearcoatNormal = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_NORMAL );
408
- export const materialRotation = nodeImmutable( MaterialNode, MaterialNode.ROTATION );
409
- export const materialSheen = nodeImmutable( MaterialNode, MaterialNode.SHEEN );
410
- export const materialSheenRoughness = nodeImmutable( MaterialNode, MaterialNode.SHEEN_ROUGHNESS );
411
- export const materialAnisotropy = nodeImmutable( MaterialNode, MaterialNode.ANISOTROPY );
412
- export const materialIridescence = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE );
413
- export const materialIridescenceIOR = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_IOR );
414
- export const materialIridescenceThickness = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_THICKNESS );
415
- export const materialTransmission = nodeImmutable( MaterialNode, MaterialNode.TRANSMISSION );
416
- export const materialThickness = nodeImmutable( MaterialNode, MaterialNode.THICKNESS );
417
- export const materialIOR = nodeImmutable( MaterialNode, MaterialNode.IOR );
418
- export const materialAttenuationDistance = nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_DISTANCE );
419
- export const materialAttenuationColor = nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_COLOR );
420
- export const materialLineScale = nodeImmutable( MaterialNode, MaterialNode.LINE_SCALE );
421
- export const materialLineDashSize = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_SIZE );
422
- export const materialLineGapSize = nodeImmutable( MaterialNode, MaterialNode.LINE_GAP_SIZE );
423
- export const materialLineWidth = nodeImmutable( MaterialNode, MaterialNode.LINE_WIDTH );
424
- export const materialLineDashOffset = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_OFFSET );
425
- export const materialPointWidth = nodeImmutable( MaterialNode, MaterialNode.POINT_WIDTH );
426
- export const materialDispersion = nodeImmutable( MaterialNode, MaterialNode.DISPERSION );
427
- export const materialLightMap = nodeImmutable( MaterialNode, MaterialNode.LIGHT_MAP );
428
- export const materialAOMap = nodeImmutable( MaterialNode, MaterialNode.AO_MAP );
429
- export const materialRefractionRatio = nodeImmutable( MaterialNode, MaterialNode.REFRACTION_RATIO );
430
- export const materialAnisotropyVector = uniform( new Vector2() ).onReference( function ( frame ) {
387
+ MaterialNode.type = /*@__PURE__*/ registerNode( 'Material', MaterialNode );
388
+
389
+ export const materialAlphaTest = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ALPHA_TEST );
390
+ export const materialColor = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.COLOR );
391
+ export const materialShininess = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SHININESS );
392
+ export const materialEmissive = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.EMISSIVE );
393
+ export const materialOpacity = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.OPACITY );
394
+ export const materialSpecular = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SPECULAR );
395
+
396
+ export const materialSpecularIntensity = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SPECULAR_INTENSITY );
397
+ export const materialSpecularColor = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SPECULAR_COLOR );
398
+
399
+ export const materialSpecularStrength = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SPECULAR_STRENGTH );
400
+ export const materialReflectivity = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.REFLECTIVITY );
401
+ export const materialRoughness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ROUGHNESS );
402
+ export const materialMetalness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.METALNESS );
403
+ export const materialNormal = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.NORMAL ).context( { getUV: null } );
404
+ export const materialClearcoat = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT );
405
+ export const materialClearcoatRoughness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_ROUGHNESS );
406
+ export const materialClearcoatNormal = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_NORMAL ).context( { getUV: null } );
407
+ export const materialRotation = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ROTATION );
408
+ export const materialSheen = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SHEEN );
409
+ export const materialSheenRoughness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SHEEN_ROUGHNESS );
410
+ export const materialAnisotropy = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ANISOTROPY );
411
+ export const materialIridescence = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE );
412
+ export const materialIridescenceIOR = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_IOR );
413
+ export const materialIridescenceThickness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_THICKNESS );
414
+ export const materialTransmission = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.TRANSMISSION );
415
+ export const materialThickness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.THICKNESS );
416
+ export const materialIOR = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.IOR );
417
+ export const materialAttenuationDistance = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_DISTANCE );
418
+ export const materialAttenuationColor = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_COLOR );
419
+ export const materialLineScale = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_SCALE );
420
+ export const materialLineDashSize = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_SIZE );
421
+ export const materialLineGapSize = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_GAP_SIZE );
422
+ export const materialLineWidth = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_WIDTH );
423
+ export const materialLineDashOffset = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_OFFSET );
424
+ export const materialPointWidth = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.POINT_WIDTH );
425
+ export const materialDispersion = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.DISPERSION );
426
+ export const materialLightMap = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LIGHT_MAP );
427
+ export const materialAOMap = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.AO_MAP );
428
+ export const materialRefractionRatio = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.REFRACTION_RATIO );
429
+ export const materialAnisotropyVector = /*@__PURE__*/ uniform( new Vector2() ).onReference( function ( frame ) {
431
430
 
432
431
  return frame.material;
433
432
 
@@ -436,5 +435,3 @@ export const materialAnisotropyVector = uniform( new Vector2() ).onReference( fu
436
435
  this.value.set( material.anisotropy * Math.cos( material.anisotropyRotation ), material.anisotropy * Math.sin( material.anisotropyRotation ) );
437
436
 
438
437
  } );
439
-
440
- addNodeClass( 'MaterialNode', MaterialNode );
@@ -0,0 +1,3 @@
1
+ import { uniform } from '../core/UniformNode.js';
2
+
3
+ export const materialRefractionRatio = /*@__PURE__*/ uniform( 0 ).onReference( ( { material } ) => material ).onRenderUpdate( ( { material } ) => material.refractionRatio );
@@ -1,8 +1,8 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import ReferenceNode from './ReferenceNode.js';
2
3
  //import { renderGroup } from '../core/UniformGroupNode.js';
3
4
  //import { NodeUpdateType } from '../core/constants.js';
4
- import { addNodeClass } from '../core/Node.js';
5
- import { nodeObject } from '../shadernode/ShaderNode.js';
5
+ import { nodeObject } from '../tsl/TSLBase.js';
6
6
 
7
7
  class MaterialReferenceNode extends ReferenceNode {
8
8
 
@@ -14,6 +14,8 @@ class MaterialReferenceNode extends ReferenceNode {
14
14
 
15
15
  //this.updateType = NodeUpdateType.RENDER;
16
16
 
17
+ this.isMaterialReferenceNode = true;
18
+
17
19
  }
18
20
 
19
21
  /*setNodeType( node ) {
@@ -36,6 +38,6 @@ class MaterialReferenceNode extends ReferenceNode {
36
38
 
37
39
  export default MaterialReferenceNode;
38
40
 
39
- export const materialReference = ( name, type, material ) => nodeObject( new MaterialReferenceNode( name, type, material ) );
41
+ MaterialReferenceNode.type = /*@__PURE__*/ registerNode( 'MaterialReference', MaterialReferenceNode );
40
42
 
41
- addNodeClass( 'MaterialReferenceNode', MaterialReferenceNode );
43
+ export const materialReference = ( name, type, material ) => nodeObject( new MaterialReferenceNode( name, type, material ) );
@@ -1,6 +1,6 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import Object3DNode from './Object3DNode.js';
2
- import { addNodeClass } from '../core/Node.js';
3
- import { nodeImmutable } from '../shadernode/ShaderNode.js';
3
+ import { nodeImmutable } from '../tsl/TSLBase.js';
4
4
  import { uniform } from '../core/UniformNode.js';
5
5
 
6
6
  import { Matrix4 } from '../../math/Matrix4.js';
@@ -25,13 +25,13 @@ class ModelNode extends Object3DNode {
25
25
 
26
26
  export default ModelNode;
27
27
 
28
- export const modelDirection = nodeImmutable( ModelNode, ModelNode.DIRECTION );
29
- export const modelViewMatrix = nodeImmutable( ModelNode, ModelNode.VIEW_MATRIX ).label( 'modelViewMatrix' ).temp( 'ModelViewMatrix' );
30
- export const modelNormalMatrix = nodeImmutable( ModelNode, ModelNode.NORMAL_MATRIX );
31
- export const modelWorldMatrix = nodeImmutable( ModelNode, ModelNode.WORLD_MATRIX );
32
- export const modelPosition = nodeImmutable( ModelNode, ModelNode.POSITION );
33
- export const modelScale = nodeImmutable( ModelNode, ModelNode.SCALE );
34
- export const modelViewPosition = nodeImmutable( ModelNode, ModelNode.VIEW_POSITION );
35
- export const modelWorldMatrixInverse = uniform( new Matrix4() ).onObjectUpdate( ( { object }, self ) => self.value.copy( object.matrixWorld ).invert() );
28
+ ModelNode.type = /*@__PURE__*/ registerNode( 'Model', ModelNode );
36
29
 
37
- addNodeClass( 'ModelNode', ModelNode );
30
+ export const modelDirection = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.DIRECTION );
31
+ export const modelViewMatrix = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.VIEW_MATRIX ).label( 'modelViewMatrix' ).toVar( 'ModelViewMatrix' );
32
+ export const modelNormalMatrix = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.NORMAL_MATRIX );
33
+ export const modelWorldMatrix = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.WORLD_MATRIX );
34
+ export const modelPosition = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.POSITION );
35
+ export const modelScale = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.SCALE );
36
+ export const modelViewPosition = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.VIEW_POSITION );
37
+ export const modelWorldMatrixInverse = /*@__PURE__*/ uniform( new Matrix4() ).onObjectUpdate( ( { object }, self ) => self.value.copy( object.matrixWorld ).invert() );