@plastic-software/three 0.167.1 → 0.167.2

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 (94) hide show
  1. package/build/three.cjs +6 -16
  2. package/build/three.module.js +6 -16
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +510 -354
  5. package/build/three.webgpu.min.js +1 -1
  6. package/examples/jsm/controls/Controls.js +32 -0
  7. package/examples/jsm/controls/DragControls.js +260 -132
  8. package/examples/jsm/transpiler/TSLEncoder.js +8 -8
  9. package/package.json +1 -1
  10. package/src/loaders/ObjectLoader.js +3 -3
  11. package/src/nodes/Nodes.js +3 -2
  12. package/src/nodes/accessors/BatchNode.js +2 -2
  13. package/src/nodes/accessors/ClippingNode.js +8 -8
  14. package/src/nodes/accessors/MorphNode.js +4 -4
  15. package/src/nodes/accessors/TangentNode.js +2 -2
  16. package/src/nodes/accessors/Texture3DNode.js +8 -8
  17. package/src/nodes/accessors/UniformArrayNode.js +5 -3
  18. package/src/nodes/core/StackNode.js +22 -6
  19. package/src/nodes/display/AfterImageNode.js +3 -3
  20. package/src/nodes/display/AnamorphicNode.js +4 -4
  21. package/src/nodes/display/BleachBypassNode.js +2 -2
  22. package/src/nodes/display/BlendModeNode.js +8 -8
  23. package/src/nodes/display/BloomNode.js +9 -9
  24. package/src/nodes/display/BumpMapNode.js +3 -3
  25. package/src/nodes/display/ColorAdjustmentNode.js +4 -4
  26. package/src/nodes/display/ColorSpaceNode.js +3 -3
  27. package/src/nodes/display/DenoiseNode.js +8 -8
  28. package/src/nodes/display/DepthOfFieldNode.js +2 -2
  29. package/src/nodes/display/DotScreenNode.js +3 -3
  30. package/src/nodes/display/FXAANode.js +11 -11
  31. package/src/nodes/display/FilmNode.js +2 -2
  32. package/src/nodes/display/GTAONode.js +9 -9
  33. package/src/nodes/display/GaussianBlurNode.js +2 -2
  34. package/src/nodes/display/Lut3DNode.js +2 -2
  35. package/src/nodes/display/NormalMapNode.js +2 -2
  36. package/src/nodes/display/PassNode.js +71 -3
  37. package/src/nodes/display/PixelationPassNode.js +3 -3
  38. package/src/nodes/display/RGBShiftNode.js +2 -2
  39. package/src/nodes/display/SepiaNode.js +2 -2
  40. package/src/nodes/display/SobelOperatorNode.js +2 -2
  41. package/src/nodes/display/ToneMappingNode.js +13 -13
  42. package/src/nodes/display/TransitionNode.js +3 -3
  43. package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -2
  44. package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  45. package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
  46. package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
  47. package/src/nodes/functions/BSDF/D_GGX.js +2 -2
  48. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +2 -2
  49. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
  50. package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
  51. package/src/nodes/functions/BSDF/LTC.js +6 -6
  52. package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
  53. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
  54. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
  55. package/src/nodes/functions/PhongLightingModel.js +3 -3
  56. package/src/nodes/functions/PhysicalLightingModel.js +18 -18
  57. package/src/nodes/functions/ToonLightingModel.js +2 -2
  58. package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
  59. package/src/nodes/functions/material/getRoughness.js +2 -2
  60. package/src/nodes/lighting/AnalyticLightNode.js +5 -5
  61. package/src/nodes/lighting/BasicEnvironmentNode.js +2 -1
  62. package/src/nodes/lighting/LightProbeNode.js +80 -0
  63. package/src/nodes/lighting/LightUtils.js +3 -3
  64. package/src/nodes/materials/InstancedPointsNodeMaterial.js +3 -3
  65. package/src/nodes/materials/Line2NodeMaterial.js +17 -17
  66. package/src/nodes/materials/MeshPhysicalNodeMaterial.js +1 -1
  67. package/src/nodes/materials/VolumeNodeMaterial.js +5 -5
  68. package/src/nodes/materialx/lib/mx_hsv.js +12 -12
  69. package/src/nodes/materialx/lib/mx_noise.js +80 -80
  70. package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
  71. package/src/nodes/math/CondNode.js +13 -2
  72. package/src/nodes/math/MathNode.js +2 -2
  73. package/src/nodes/math/TriNoise3D.js +6 -6
  74. package/src/nodes/pmrem/PMREMUtils.js +34 -34
  75. package/src/nodes/procedural/CheckerNode.js +2 -2
  76. package/src/nodes/shadernode/ShaderNode.js +11 -4
  77. package/src/nodes/utils/CubeMapNode.js +157 -0
  78. package/src/nodes/utils/LoopNode.js +10 -4
  79. package/src/nodes/utils/SpriteUtils.js +2 -2
  80. package/src/nodes/utils/UVUtils.js +3 -3
  81. package/src/nodes/utils/ViewportUtils.js +3 -3
  82. package/src/renderers/WebGLRenderer.js +8 -0
  83. package/src/renderers/common/RenderContext.js +24 -0
  84. package/src/renderers/common/RenderObject.js +1 -1
  85. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +1 -1
  86. package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
  87. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +0 -2
  88. package/src/renderers/shaders/ShaderLib/points.glsl.js +0 -2
  89. package/src/renderers/webgl/WebGLPrograms.js +2 -1
  90. package/src/renderers/webgl-fallback/WebGLBackend.js +31 -27
  91. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +12 -8
  92. package/src/renderers/webgpu/WebGPUBackend.js +10 -14
  93. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +30 -2
  94. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
@@ -42,7 +42,7 @@ export { NodeUtils };
42
42
  export { default as MathNode, PI, PI2, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, lengthSq, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, bitcast, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward, cbrt, transpose, all, any, equals, rand } from './math/MathNode.js';
43
43
 
44
44
  export { default as OperatorNode, add, sub, mul, div, remainder, equal, lessThan, greaterThan, lessThanEqual, greaterThanEqual, and, or, not, xor, bitAnd, bitNot, bitOr, bitXor, shiftLeft, shiftRight } from './math/OperatorNode.js';
45
- export { default as CondNode, cond } from './math/CondNode.js';
45
+ export { default as CondNode, select, cond } from './math/CondNode.js';
46
46
  export { default as HashNode, hash } from './math/HashNode.js';
47
47
 
48
48
  // math utils
@@ -56,7 +56,7 @@ export { default as DiscardNode, discard, Return } from './utils/DiscardNode.js'
56
56
  export { default as EquirectUVNode, equirectUV } from './utils/EquirectUVNode.js';
57
57
  export { default as FunctionOverloadingNode, overloadingFn } from './utils/FunctionOverloadingNode.js';
58
58
  export { default as JoinNode } from './utils/JoinNode.js';
59
- export { default as LoopNode, loop, Continue, Break } from './utils/LoopNode.js';
59
+ export { default as LoopNode, Loop, Continue, Break } from './utils/LoopNode.js';
60
60
  export { default as MatcapUVNode, matcapUV } from './utils/MatcapUVNode.js';
61
61
  export { default as MaxMipLevelNode, maxMipLevel } from './utils/MaxMipLevelNode.js';
62
62
  export { default as OscNode, oscSine, oscSquare, oscTriangle, oscSawtooth } from './utils/OscNode.js';
@@ -180,6 +180,7 @@ export { default as LightsNode, lights, lightsNode, addLightNode } from './light
180
180
  export { default as LightingNode /* @TODO: lighting (abstract), light */ } from './lighting/LightingNode.js';
181
181
  export { default as LightingContextNode, lightingContext } from './lighting/LightingContextNode.js';
182
182
  export { default as HemisphereLightNode } from './lighting/HemisphereLightNode.js';
183
+ export { default as LightProbeNode } from './lighting/LightProbeNode.js';
183
184
  export { default as EnvironmentNode } from './lighting/EnvironmentNode.js';
184
185
  export { default as BasicEnvironmentNode } from './lighting/BasicEnvironmentNode.js';
185
186
  export { default as IrradianceNode } from './lighting/IrradianceNode.js';
@@ -1,7 +1,7 @@
1
1
  import Node, { addNodeClass } from '../core/Node.js';
2
2
  import { normalLocal } from './NormalNode.js';
3
3
  import { positionLocal } from './PositionNode.js';
4
- import { nodeProxy, vec3, mat3, mat4, int, ivec2, float, tslFn } from '../shadernode/ShaderNode.js';
4
+ import { nodeProxy, vec3, mat3, mat4, int, ivec2, float, Fn } from '../shadernode/ShaderNode.js';
5
5
  import { textureLoad } from './TextureNode.js';
6
6
  import { textureSize } from './TextureSizeNode.js';
7
7
  import { tangentLocal } from './TangentNode.js';
@@ -40,7 +40,7 @@ class BatchNode extends Node {
40
40
 
41
41
  }
42
42
 
43
- const getIndirectIndex = tslFn( ( [ id ] ) => {
43
+ const getIndirectIndex = Fn( ( [ id ] ) => {
44
44
 
45
45
  const size = textureSize( textureLoad( this.batchMesh._indirectTexture ), 0 );
46
46
  const x = int( id ).remainder( int( size ) );
@@ -3,8 +3,8 @@ import Node from '../core/Node.js';
3
3
  import { nodeObject } from '../shadernode/ShaderNode.js';
4
4
  import { positionView } from './PositionNode.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 '../shadernode/ShaderNode.js';
7
+ import { Loop } from '../utils/LoopNode.js';
8
8
  import { smoothstep } from '../math/MathNode.js';
9
9
  import { uniformArray } from './UniformArrayNode.js';
10
10
 
@@ -42,7 +42,7 @@ class ClippingNode extends Node {
42
42
 
43
43
  setupAlphaToCoverage( planes, numClippingPlanes, numUnionClippingPlanes ) {
44
44
 
45
- return tslFn( () => {
45
+ return Fn( () => {
46
46
 
47
47
  const clippingPlanes = uniformArray( planes );
48
48
 
@@ -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
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 ) );
@@ -1,6 +1,6 @@
1
1
  import Node, { addNodeClass } from '../core/Node.js';
2
2
  import { NodeUpdateType } from '../core/constants.js';
3
- import { float, nodeProxy, tslFn } from '../shadernode/ShaderNode.js';
3
+ import { float, nodeProxy, Fn } from '../shadernode/ShaderNode.js';
4
4
  import { uniform } from '../core/UniformNode.js';
5
5
  import { reference } from './ReferenceNode.js';
6
6
  import { positionLocal } from './PositionNode.js';
@@ -8,7 +8,7 @@ import { normalLocal } from './NormalNode.js';
8
8
  import { textureLoad } from './TextureNode.js';
9
9
  import { instanceIndex, vertexIndex } from '../core/IndexNode.js';
10
10
  import { ivec2, int } from '../shadernode/ShaderNode.js';
11
- import { loop } from '../utils/LoopNode.js';
11
+ import { Loop } from '../utils/LoopNode.js';
12
12
 
13
13
  import { DataArrayTexture } from '../../textures/DataArrayTexture.js';
14
14
  import { Vector2 } from '../../math/Vector2.js';
@@ -18,7 +18,7 @@ import { FloatType } from '../../constants.js';
18
18
  const _morphTextures = new WeakMap();
19
19
  const _morphVec4 = /*@__PURE__*/ new Vector4();
20
20
 
21
- const getMorph = tslFn( ( { bufferMap, influence, stride, width, depth, offset } ) => {
21
+ const getMorph = Fn( ( { bufferMap, influence, stride, width, depth, offset } ) => {
22
22
 
23
23
  const texelIndex = int( vertexIndex ).mul( stride ).add( offset );
24
24
 
@@ -190,7 +190,7 @@ class MorphNode extends Node {
190
190
 
191
191
  const width = int( size.width );
192
192
 
193
- loop( morphTargetsCount, ( { i } ) => {
193
+ Loop( morphTargetsCount, ( { i } ) => {
194
194
 
195
195
  const influence = float( 0 ).toVar();
196
196
 
@@ -2,9 +2,9 @@ import { attribute } from '../core/AttributeNode.js';
2
2
  import { varying } from '../core/VaryingNode.js';
3
3
  import { cameraViewMatrix } from './CameraNode.js';
4
4
  import { modelViewMatrix } from './ModelNode.js';
5
- import { tslFn, vec4 } from '../shadernode/ShaderNode.js';
5
+ import { Fn, vec4 } from '../shadernode/ShaderNode.js';
6
6
 
7
- export const tangentGeometry = /*#__PURE__*/ tslFn( ( stack, builder ) => {
7
+ export const tangentGeometry = /*#__PURE__*/ Fn( ( builder ) => {
8
8
 
9
9
  if ( builder.geometry.hasAttribute( 'tangent' ) === false ) {
10
10
 
@@ -1,8 +1,8 @@
1
1
  import TextureNode from './TextureNode.js';
2
2
  import { addNodeClass } from '../core/Node.js';
3
- import { nodeProxy, vec3, tslFn, If } from '../shadernode/ShaderNode.js';
3
+ import { nodeProxy, vec3, Fn, If } from '../shadernode/ShaderNode.js';
4
4
 
5
- const normal = tslFn( ( { texture, uv } ) => {
5
+ const normal = Fn( ( { texture, uv } ) => {
6
6
 
7
7
  const epsilon = 0.0001;
8
8
 
@@ -12,27 +12,27 @@ const normal = tslFn( ( { texture, uv } ) => {
12
12
 
13
13
  ret.assign( vec3( 1, 0, 0 ) );
14
14
 
15
- } ).elseif( uv.y.lessThan( epsilon ), () => {
15
+ } ).ElseIf( uv.y.lessThan( epsilon ), () => {
16
16
 
17
17
  ret.assign( vec3( 0, 1, 0 ) );
18
18
 
19
- } ).elseif( uv.z.lessThan( epsilon ), () => {
19
+ } ).ElseIf( uv.z.lessThan( epsilon ), () => {
20
20
 
21
21
  ret.assign( vec3( 0, 0, 1 ) );
22
22
 
23
- } ).elseif( uv.x.greaterThan( 1 - epsilon ), () => {
23
+ } ).ElseIf( uv.x.greaterThan( 1 - epsilon ), () => {
24
24
 
25
25
  ret.assign( vec3( - 1, 0, 0 ) );
26
26
 
27
- } ).elseif( uv.y.greaterThan( 1 - epsilon ), () => {
27
+ } ).ElseIf( uv.y.greaterThan( 1 - epsilon ), () => {
28
28
 
29
29
  ret.assign( vec3( 0, - 1, 0 ) );
30
30
 
31
- } ).elseif( uv.z.greaterThan( 1 - epsilon ), () => {
31
+ } ).ElseIf( uv.z.greaterThan( 1 - epsilon ), () => {
32
32
 
33
33
  ret.assign( vec3( 0, 0, - 1 ) );
34
34
 
35
- } ).else( () => {
35
+ } ).Else( () => {
36
36
 
37
37
  const step = 0.01;
38
38
 
@@ -143,11 +143,13 @@ export default UniformArrayNode;
143
143
 
144
144
  export const uniformArray = ( values, nodeType ) => nodeObject( new UniformArrayNode( values, nodeType ) );
145
145
 
146
+ addNodeClass( 'UniformArrayNode', UniformArrayNode );
147
+
148
+ //
149
+
146
150
  export const uniforms = ( values, nodeType ) => { // @deprecated, r168
147
151
 
148
- console.warn( 'THREE.UniformArrayNode: uniforms() has been renamed to uniformArray().' );
152
+ console.warn( 'TSL.UniformArrayNode: uniforms() has been renamed to uniformArray().' );
149
153
  return nodeObject( new UniformArrayNode( values, nodeType ) );
150
154
 
151
155
  };
152
-
153
- addNodeClass( 'UniformArrayNode', UniformArrayNode );
@@ -1,5 +1,5 @@
1
1
  import Node, { addNodeClass } from './Node.js';
2
- import { cond } from '../math/CondNode.js';
2
+ import { select } from '../math/CondNode.js';
3
3
  import { ShaderNode, nodeProxy, getCurrentStack, setCurrentStack } from '../shadernode/ShaderNode.js';
4
4
 
5
5
  class StackNode extends Node {
@@ -33,19 +33,19 @@ class StackNode extends Node {
33
33
 
34
34
  }
35
35
 
36
- if( boolNode, method ) {
36
+ If( boolNode, method ) {
37
37
 
38
38
  const methodNode = new ShaderNode( method );
39
- this._currentCond = cond( boolNode, methodNode );
39
+ this._currentCond = select( boolNode, methodNode );
40
40
 
41
41
  return this.add( this._currentCond );
42
42
 
43
43
  }
44
44
 
45
- elseif( boolNode, method ) {
45
+ ElseIf( boolNode, method ) {
46
46
 
47
47
  const methodNode = new ShaderNode( method );
48
- const ifNode = cond( boolNode, methodNode );
48
+ const ifNode = select( boolNode, methodNode );
49
49
 
50
50
  this._currentCond.elseNode = ifNode;
51
51
  this._currentCond = ifNode;
@@ -54,7 +54,7 @@ class StackNode extends Node {
54
54
 
55
55
  }
56
56
 
57
- else( method ) {
57
+ Else( method ) {
58
58
 
59
59
  this._currentCond.elseNode = new ShaderNode( method );
60
60
 
@@ -80,6 +80,22 @@ class StackNode extends Node {
80
80
 
81
81
  }
82
82
 
83
+ //
84
+
85
+ else( ...params ) { // @deprecated, r168
86
+
87
+ console.warn( 'TSL.StackNode: .else() has been renamed to .Else().' );
88
+ return this.Else( ...params );
89
+
90
+ }
91
+
92
+ elseif( ...params ) { // @deprecated, r168
93
+
94
+ console.warn( 'TSL.StackNode: .elseif() has been renamed to .ElseIf().' );
95
+ return this.ElseIf( ...params );
96
+
97
+ }
98
+
83
99
  }
84
100
 
85
101
  export default StackNode;
@@ -1,5 +1,5 @@
1
1
  import TempNode from '../core/TempNode.js';
2
- import { nodeObject, addNodeElement, tslFn, float, vec4 } from '../shadernode/ShaderNode.js';
2
+ import { nodeObject, addNodeElement, Fn, float, vec4 } from '../shadernode/ShaderNode.js';
3
3
  import { NodeUpdateType } from '../core/constants.js';
4
4
  import { uv } from '../accessors/UVNode.js';
5
5
  import { texture } from '../accessors/TextureNode.js';
@@ -98,7 +98,7 @@ class AfterImageNode extends TempNode {
98
98
 
99
99
  const sampleTexture = ( uv ) => textureNode.uv( uv );
100
100
 
101
- const when_gt = tslFn( ( [ x_immutable, y_immutable ] ) => {
101
+ const when_gt = Fn( ( [ x_immutable, y_immutable ] ) => {
102
102
 
103
103
  const y = float( y_immutable ).toVar();
104
104
  const x = vec4( x_immutable ).toVar();
@@ -107,7 +107,7 @@ class AfterImageNode extends TempNode {
107
107
 
108
108
  } );
109
109
 
110
- const afterImg = tslFn( () => {
110
+ const afterImg = Fn( () => {
111
111
 
112
112
  const texelOld = vec4( textureNodeOld );
113
113
  const texelNew = vec4( sampleTexture( uvNode ) );
@@ -1,6 +1,6 @@
1
1
  import TempNode from '../core/TempNode.js';
2
- import { nodeObject, addNodeElement, tslFn, float, vec2, vec3 } from '../shadernode/ShaderNode.js';
3
- import { loop } from '../utils/LoopNode.js';
2
+ import { nodeObject, addNodeElement, Fn, float, vec2, vec3 } from '../shadernode/ShaderNode.js';
3
+ import { Loop } from '../utils/LoopNode.js';
4
4
  import { uniform } from '../core/UniformNode.js';
5
5
  import { NodeUpdateType } from '../core/constants.js';
6
6
  import { threshold } from './ColorAdjustmentNode.js';
@@ -90,14 +90,14 @@ class AnamorphicNode extends TempNode {
90
90
 
91
91
  const sampleTexture = ( uv ) => textureNode.uv( uv );
92
92
 
93
- const anamorph = tslFn( () => {
93
+ const anamorph = Fn( () => {
94
94
 
95
95
  const samples = this.samples;
96
96
  const halfSamples = Math.floor( samples / 2 );
97
97
 
98
98
  const total = vec3( 0 ).toVar();
99
99
 
100
- loop( { start: - halfSamples, end: halfSamples }, ( { i } ) => {
100
+ Loop( { start: - halfSamples, end: halfSamples }, ( { i } ) => {
101
101
 
102
102
  const softness = float( i ).abs().div( halfSamples ).oneMinus();
103
103
 
@@ -1,8 +1,8 @@
1
- import { addNodeElement, float, tslFn, vec3, vec4 } from '../shadernode/ShaderNode.js';
1
+ import { addNodeElement, float, Fn, vec3, vec4 } from '../shadernode/ShaderNode.js';
2
2
  import { min, max, mix } from '../math/MathNode.js';
3
3
  import { luminance } from './ColorAdjustmentNode.js';
4
4
 
5
- export const bleach = /*@__PURE__*/ tslFn( ( [ color, opacity = 1 ] ) => {
5
+ export const bleach = /*@__PURE__*/ Fn( ( [ color, opacity = 1 ] ) => {
6
6
 
7
7
  const base = color;
8
8
  const lum = luminance( base.rgb );
@@ -1,11 +1,11 @@
1
1
  import TempNode from '../core/TempNode.js';
2
2
  import { /*mix, step,*/ EPSILON } from '../math/MathNode.js';
3
3
  import { addNodeClass } from '../core/Node.js';
4
- import { addNodeElement, tslFn, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
4
+ import { addNodeElement, Fn, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
5
5
 
6
- export const BurnNode = tslFn( ( { base, blend } ) => {
6
+ export const BurnNode = Fn( ( { base, blend } ) => {
7
7
 
8
- const fn = ( c ) => blend[ c ].lessThan( EPSILON ).cond( blend[ c ], base[ c ].oneMinus().div( blend[ c ] ).oneMinus().max( 0 ) );
8
+ const fn = ( c ) => blend[ c ].lessThan( EPSILON ).select( blend[ c ], base[ c ].oneMinus().div( blend[ c ] ).oneMinus().max( 0 ) );
9
9
 
10
10
  return vec3( fn( 'x' ), fn( 'y' ), fn( 'z' ) );
11
11
 
@@ -18,9 +18,9 @@ export const BurnNode = tslFn( ( { base, blend } ) => {
18
18
  ]
19
19
  } );
20
20
 
21
- export const DodgeNode = tslFn( ( { base, blend } ) => {
21
+ export const DodgeNode = Fn( ( { base, blend } ) => {
22
22
 
23
- const fn = ( c ) => blend[ c ].equal( 1.0 ).cond( blend[ c ], base[ c ].div( blend[ c ].oneMinus() ).max( 0 ) );
23
+ const fn = ( c ) => blend[ c ].equal( 1.0 ).select( blend[ c ], base[ c ].div( blend[ c ].oneMinus() ).max( 0 ) );
24
24
 
25
25
  return vec3( fn( 'x' ), fn( 'y' ), fn( 'z' ) );
26
26
 
@@ -33,7 +33,7 @@ export const DodgeNode = tslFn( ( { base, blend } ) => {
33
33
  ]
34
34
  } );
35
35
 
36
- export const ScreenNode = tslFn( ( { base, blend } ) => {
36
+ export const ScreenNode = Fn( ( { base, blend } ) => {
37
37
 
38
38
  const fn = ( c ) => base[ c ].oneMinus().mul( blend[ c ].oneMinus() ).oneMinus();
39
39
 
@@ -48,9 +48,9 @@ export const ScreenNode = tslFn( ( { base, blend } ) => {
48
48
  ]
49
49
  } );
50
50
 
51
- export const OverlayNode = tslFn( ( { base, blend } ) => {
51
+ export const OverlayNode = Fn( ( { base, blend } ) => {
52
52
 
53
- const fn = ( c ) => base[ c ].lessThan( 0.5 ).cond( base[ c ].mul( blend[ c ], 2.0 ), base[ c ].oneMinus().mul( blend[ c ].oneMinus() ).oneMinus() );
53
+ const fn = ( c ) => base[ c ].lessThan( 0.5 ).select( base[ c ].mul( blend[ c ], 2.0 ), base[ c ].oneMinus().mul( blend[ c ].oneMinus() ).oneMinus() );
54
54
  //const fn = ( c ) => mix( base[ c ].oneMinus().mul( blend[ c ].oneMinus() ).oneMinus(), base[ c ].mul( blend[ c ], 2.0 ), step( base[ c ], 0.5 ) );
55
55
 
56
56
  return vec3( fn( 'x' ), fn( 'y' ), fn( 'z' ) );
@@ -1,5 +1,5 @@
1
1
  import TempNode from '../core/TempNode.js';
2
- import { addNodeElement, tslFn, nodeObject, float, vec4, int } from '../shadernode/ShaderNode.js';
2
+ import { addNodeElement, Fn, nodeObject, float, vec4, int } from '../shadernode/ShaderNode.js';
3
3
  import { mix, smoothstep } from '../math/MathNode.js';
4
4
  import { luminance } from './ColorAdjustmentNode.js';
5
5
  import { uniform } from '../core/UniformNode.js';
@@ -11,7 +11,7 @@ import { RenderTarget } from '../../core/RenderTarget.js';
11
11
  import { HalfFloatType } from '../../constants.js';
12
12
  import { NodeUpdateType } from '../core/constants.js';
13
13
  import { Vector2 } from '../../math/Vector2.js';
14
- import { loop } from '../utils/LoopNode.js';
14
+ import { Loop } from '../utils/LoopNode.js';
15
15
  import { add } from '../math/OperatorNode.js';
16
16
  import QuadMesh from '../../renderers/common/QuadMesh.js';
17
17
  import { texture } from '../accessors/TextureNode.js';
@@ -183,7 +183,7 @@ class BloomNode extends TempNode {
183
183
 
184
184
  // luminosity high pass material
185
185
 
186
- const luminosityHighPass = tslFn( () => {
186
+ const luminosityHighPass = Fn( () => {
187
187
 
188
188
  const texel = this.inputNode;
189
189
  const v = luminance( texel.rgb );
@@ -194,7 +194,7 @@ class BloomNode extends TempNode {
194
194
 
195
195
  } );
196
196
 
197
- this._highPassFilterMaterial = this._highPassFilterMaterial || builder.createNodeMaterial();
197
+ this._highPassFilterMaterial = this._highPassFilterMaterial || builder.createNodeMaterial();
198
198
  this._highPassFilterMaterial.fragmentNode = luminosityHighPass().context( builder.getSharedContext() );
199
199
  this._highPassFilterMaterial.needsUpdate = true;
200
200
 
@@ -213,7 +213,7 @@ class BloomNode extends TempNode {
213
213
  const bloomFactors = uniformArray( [ 1.0, 0.8, 0.6, 0.4, 0.2 ] );
214
214
  const bloomTintColors = uniformArray( [ new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ) ] );
215
215
 
216
- const lerpBloomFactor = tslFn( ( [ factor, radius ] ) => {
216
+ const lerpBloomFactor = Fn( ( [ factor, radius ] ) => {
217
217
 
218
218
  const mirrorFactor = float( 1.2 ).sub( factor );
219
219
  return mix( factor, mirrorFactor, radius );
@@ -228,7 +228,7 @@ class BloomNode extends TempNode {
228
228
  } );
229
229
 
230
230
 
231
- const compositePass = tslFn( () => {
231
+ const compositePass = Fn( () => {
232
232
 
233
233
  const color0 = lerpBloomFactor( bloomFactors.element( 0 ), this.radius ).mul( vec4( bloomTintColors.element( 0 ), 1.0 ) ).mul( this._textureNodeBlur0 );
234
234
  const color1 = lerpBloomFactor( bloomFactors.element( 1 ), this.radius ).mul( vec4( bloomTintColors.element( 1 ), 1.0 ) ).mul( this._textureNodeBlur1 );
@@ -242,7 +242,7 @@ class BloomNode extends TempNode {
242
242
 
243
243
  } );
244
244
 
245
- this._compositeMaterial = this._compositeMaterial || builder.createNodeMaterial();
245
+ this._compositeMaterial = this._compositeMaterial || builder.createNodeMaterial();
246
246
  this._compositeMaterial.fragmentNode = compositePass().context( builder.getSharedContext() );
247
247
  this._compositeMaterial.needsUpdate = true;
248
248
 
@@ -290,12 +290,12 @@ class BloomNode extends TempNode {
290
290
  const uvNode = uv();
291
291
  const sampleTexel = ( uv ) => colorTexture.uv( uv );
292
292
 
293
- const seperableBlurPass = tslFn( () => {
293
+ const seperableBlurPass = Fn( () => {
294
294
 
295
295
  const weightSum = gaussianCoefficients.element( 0 ).toVar();
296
296
  const diffuseSum = sampleTexel( uvNode ).rgb.mul( weightSum ).toVar();
297
297
 
298
- loop( { start: int( 1 ), end: int( kernelRadius ), type: 'int', condition: '<' }, ( { i } ) => {
298
+ Loop( { start: int( 1 ), end: int( kernelRadius ), type: 'int', condition: '<' }, ( { i } ) => {
299
299
 
300
300
  const x = float( i );
301
301
  const w = gaussianCoefficients.element( i );
@@ -4,12 +4,12 @@ import { uv } from '../accessors/UVNode.js';
4
4
  import { normalView } from '../accessors/NormalNode.js';
5
5
  import { positionView } from '../accessors/PositionNode.js';
6
6
  import { faceDirection } from './FrontFacingNode.js';
7
- import { addNodeElement, tslFn, nodeProxy, float, vec2 } from '../shadernode/ShaderNode.js';
7
+ import { addNodeElement, Fn, nodeProxy, float, vec2 } from '../shadernode/ShaderNode.js';
8
8
 
9
9
  // Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen
10
10
  // https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf
11
11
 
12
- const dHdxy_fwd = tslFn( ( { textureNode, bumpScale } ) => {
12
+ const dHdxy_fwd = Fn( ( { textureNode, bumpScale } ) => {
13
13
 
14
14
  // It's used to preserve the same TextureNode instance
15
15
  const sampleTexture = ( callback ) => textureNode.cache().context( { getUV: ( texNode ) => callback( texNode.uvNode || uv() ), forceUVContext: true } );
@@ -25,7 +25,7 @@ const dHdxy_fwd = tslFn( ( { textureNode, bumpScale } ) => {
25
25
 
26
26
  // Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)
27
27
 
28
- const perturbNormalArb = tslFn( ( inputs ) => {
28
+ const perturbNormalArb = Fn( ( inputs ) => {
29
29
 
30
30
  const { surf_pos, surf_norm, dHdxy } = inputs;
31
31
 
@@ -2,17 +2,17 @@ import TempNode from '../core/TempNode.js';
2
2
  import { dot, mix } from '../math/MathNode.js';
3
3
  import { add } from '../math/OperatorNode.js';
4
4
  import { addNodeClass } from '../core/Node.js';
5
- import { addNodeElement, tslFn, nodeProxy, float, vec3 } from '../shadernode/ShaderNode.js';
5
+ import { addNodeElement, Fn, nodeProxy, float, vec3 } from '../shadernode/ShaderNode.js';
6
6
  import { ColorManagement } from '../../math/ColorManagement.js';
7
7
  import { Vector3 } from '../../math/Vector3.js';
8
8
 
9
- const saturationNode = tslFn( ( { color, adjustment } ) => {
9
+ const saturationNode = Fn( ( { color, adjustment } ) => {
10
10
 
11
11
  return adjustment.mix( luminance( color.rgb ), color.rgb );
12
12
 
13
13
  } );
14
14
 
15
- const vibranceNode = tslFn( ( { color, adjustment } ) => {
15
+ const vibranceNode = Fn( ( { color, adjustment } ) => {
16
16
 
17
17
  const average = add( color.r, color.g, color.b ).div( 3.0 );
18
18
 
@@ -23,7 +23,7 @@ const vibranceNode = tslFn( ( { color, adjustment } ) => {
23
23
 
24
24
  } );
25
25
 
26
- const hueNode = tslFn( ( { color, adjustment } ) => {
26
+ const hueNode = Fn( ( { color, adjustment } ) => {
27
27
 
28
28
  const k = vec3( 0.57735, 0.57735, 0.57735 );
29
29
 
@@ -1,11 +1,11 @@
1
1
  import TempNode from '../core/TempNode.js';
2
2
  import { mix } from '../math/MathNode.js';
3
3
  import { addNodeClass } from '../core/Node.js';
4
- import { addNodeElement, tslFn, nodeObject, nodeProxy, vec4 } from '../shadernode/ShaderNode.js';
4
+ import { addNodeElement, Fn, nodeObject, nodeProxy, vec4 } from '../shadernode/ShaderNode.js';
5
5
 
6
6
  import { LinearSRGBColorSpace, SRGBColorSpace } from '../../constants.js';
7
7
 
8
- const sRGBToLinearShader = tslFn( ( inputs ) => {
8
+ const sRGBToLinearShader = Fn( ( inputs ) => {
9
9
 
10
10
  const { value } = inputs;
11
11
  const { rgb } = value;
@@ -20,7 +20,7 @@ const sRGBToLinearShader = tslFn( ( inputs ) => {
20
20
 
21
21
  } );
22
22
 
23
- const LinearTosRGBShader = tslFn( ( inputs ) => {
23
+ const LinearTosRGBShader = Fn( ( inputs ) => {
24
24
 
25
25
  const { value } = inputs;
26
26
  const { rgb } = value;
@@ -1,11 +1,11 @@
1
1
  import TempNode from '../core/TempNode.js';
2
2
  import { uv } from '../accessors/UVNode.js';
3
- import { addNodeElement, tslFn, nodeObject, float, int, vec2, vec3, vec4, mat2, If } from '../shadernode/ShaderNode.js';
3
+ import { addNodeElement, Fn, nodeObject, float, int, vec2, vec3, vec4, mat2, If } from '../shadernode/ShaderNode.js';
4
4
  import { NodeUpdateType } from '../core/constants.js';
5
5
  import { uniform } from '../core/UniformNode.js';
6
6
  import { uniformArray } from '../accessors/UniformArrayNode.js';
7
7
  import { abs, dot, sin, cos, PI, pow, max } from '../math/MathNode.js';
8
- import { loop } from '../utils/LoopNode.js';
8
+ import { Loop } from '../utils/LoopNode.js';
9
9
  import { luminance } from './ColorAdjustmentNode.js';
10
10
  import { textureSize } from '../accessors/TextureSizeNode.js';
11
11
  import { Vector2 } from '../../math/Vector2.js';
@@ -53,7 +53,7 @@ class DenoiseNode extends TempNode {
53
53
  const sampleNormal = ( uv ) => this.normalNode.uv( uv );
54
54
  const sampleNoise = ( uv ) => this.noiseNode.uv( uv );
55
55
 
56
- const getViewPosition = tslFn( ( [ screenPosition, depth ] ) => {
56
+ const getViewPosition = Fn( ( [ screenPosition, depth ] ) => {
57
57
 
58
58
  screenPosition = vec2( screenPosition.x, screenPosition.y.oneMinus() ).mul( 2.0 ).sub( 1.0 );
59
59
 
@@ -64,7 +64,7 @@ class DenoiseNode extends TempNode {
64
64
 
65
65
  } );
66
66
 
67
- const denoiseSample = tslFn( ( [ center, viewNormal, viewPosition, sampleUv ] ) => {
67
+ const denoiseSample = Fn( ( [ center, viewNormal, viewPosition, sampleUv ] ) => {
68
68
 
69
69
  const texel = sampleTexture( sampleUv );
70
70
  const depth = sampleDepth( sampleUv );
@@ -84,7 +84,7 @@ class DenoiseNode extends TempNode {
84
84
 
85
85
  } );
86
86
 
87
- const denoise = tslFn( ( [ uvNode ] ) => {
87
+ const denoise = Fn( ( [ uvNode ] ) => {
88
88
 
89
89
  const depth = sampleDepth( uvNode );
90
90
  const viewNormal = sampleNormal( uvNode ).rgb.normalize();
@@ -115,7 +115,7 @@ class DenoiseNode extends TempNode {
115
115
  const totalWeight = float( 1.0 ).toVar();
116
116
  const denoised = vec3( texel.rgb ).toVar();
117
117
 
118
- loop( { start: int( 0 ), end: int( 16 ), type: 'int', condition: '<' }, ( { i } ) => {
118
+ Loop( { start: int( 0 ), end: int( 16 ), type: 'int', condition: '<' }, ( { i } ) => {
119
119
 
120
120
  const sampleDir = this._sampleVectors.element( i ).toVar();
121
121
  const offset = rotationMatrix.mul( sampleDir.xy.mul( float( 1.0 ).add( sampleDir.z.mul( this.radius.sub( 1 ) ) ) ) ).div( this._resolution ).toVar();
@@ -126,7 +126,7 @@ class DenoiseNode extends TempNode {
126
126
  denoised.addAssign( result.xyz );
127
127
  totalWeight.addAssign( result.w );
128
128
 
129
- } );
129
+ } );
130
130
 
131
131
  If( totalWeight.greaterThan( float( 0 ) ), () => {
132
132
 
@@ -144,7 +144,7 @@ class DenoiseNode extends TempNode {
144
144
  ]
145
145
  } );
146
146
 
147
- const output = tslFn( () => {
147
+ const output = Fn( () => {
148
148
 
149
149
  return denoise( uvNode );
150
150
 
@@ -1,6 +1,6 @@
1
1
  import TempNode from '../core/TempNode.js';
2
2
  import { uv } from '../accessors/UVNode.js';
3
- import { addNodeElement, tslFn, nodeObject, vec2, vec4 } from '../shadernode/ShaderNode.js';
3
+ import { addNodeElement, Fn, nodeObject, vec2, vec4 } from '../shadernode/ShaderNode.js';
4
4
  import { NodeUpdateType } from '../core/constants.js';
5
5
  import { uniform } from '../core/UniformNode.js';
6
6
  import { clamp } from '../math/MathNode.js';
@@ -39,7 +39,7 @@ class DepthOfFieldNode extends TempNode {
39
39
 
40
40
  const sampleTexture = ( uv ) => textureNode.uv( uv );
41
41
 
42
- const dof = tslFn( () => {
42
+ const dof = Fn( () => {
43
43
 
44
44
  const aspectcorrect = vec2( 1.0, this._aspect );
45
45
 
@@ -1,5 +1,5 @@
1
1
  import TempNode from '../core/TempNode.js';
2
- import { nodeObject, addNodeElement, tslFn, vec2, vec3, vec4 } from '../shadernode/ShaderNode.js';
2
+ import { nodeObject, addNodeElement, Fn, vec2, vec3, vec4 } from '../shadernode/ShaderNode.js';
3
3
  import { uniform } from '../core/UniformNode.js';
4
4
  import { NodeUpdateType } from '../core/constants.js';
5
5
  import { uv } from '../accessors/UVNode.js';
@@ -37,7 +37,7 @@ class DotScreenNode extends TempNode {
37
37
 
38
38
  const inputNode = this.inputNode;
39
39
 
40
- const pattern = tslFn( () => {
40
+ const pattern = Fn( () => {
41
41
 
42
42
  const s = sin( this.angle );
43
43
  const c = cos( this.angle );
@@ -49,7 +49,7 @@ class DotScreenNode extends TempNode {
49
49
 
50
50
  } );
51
51
 
52
- const dotScreen = tslFn( () => {
52
+ const dotScreen = Fn( () => {
53
53
 
54
54
  const color = inputNode;
55
55