super-three 0.177.0 → 0.179.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 (211) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +959 -231
  3. package/build/three.core.js +751 -170
  4. package/build/three.core.min.js +1 -1
  5. package/build/three.module.js +210 -64
  6. package/build/three.module.min.js +1 -1
  7. package/build/three.tsl.js +78 -29
  8. package/build/three.tsl.min.js +1 -1
  9. package/build/three.webgpu.js +3269 -1545
  10. package/build/three.webgpu.min.js +1 -1
  11. package/build/three.webgpu.nodes.js +3093 -1545
  12. package/build/three.webgpu.nodes.min.js +1 -1
  13. package/examples/jsm/Addons.js +1 -2
  14. package/examples/jsm/capabilities/WebGL.js +0 -27
  15. package/examples/jsm/capabilities/WebGPU.js +1 -1
  16. package/examples/jsm/controls/ArcballControls.js +1 -1
  17. package/examples/jsm/controls/TransformControls.js +61 -14
  18. package/examples/jsm/csm/CSMShadowNode.js +4 -4
  19. package/examples/jsm/environments/RoomEnvironment.js +8 -3
  20. package/examples/jsm/exporters/USDZExporter.js +676 -299
  21. package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
  22. package/examples/jsm/interactive/HTMLMesh.js +5 -3
  23. package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
  24. package/examples/jsm/lights/LightProbeGenerator.js +14 -3
  25. package/examples/jsm/loaders/ColladaLoader.js +1 -1
  26. package/examples/jsm/loaders/EXRLoader.js +210 -22
  27. package/examples/jsm/loaders/FBXLoader.js +2 -2
  28. package/examples/jsm/loaders/MaterialXLoader.js +212 -30
  29. package/examples/jsm/loaders/TTFLoader.js +13 -1
  30. package/examples/jsm/loaders/USDLoader.js +219 -0
  31. package/examples/jsm/loaders/USDZLoader.js +4 -892
  32. package/examples/jsm/loaders/usd/USDAParser.js +741 -0
  33. package/examples/jsm/loaders/usd/USDCParser.js +17 -0
  34. package/examples/jsm/objects/LensflareMesh.js +3 -3
  35. package/examples/jsm/objects/SkyMesh.js +2 -2
  36. package/examples/jsm/physics/RapierPhysics.js +95 -16
  37. package/examples/jsm/postprocessing/GTAOPass.js +10 -9
  38. package/examples/jsm/postprocessing/OutlinePass.js +17 -17
  39. package/examples/jsm/postprocessing/SSAOPass.js +10 -9
  40. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
  41. package/examples/jsm/transpiler/AST.js +381 -30
  42. package/examples/jsm/transpiler/GLSLDecoder.js +226 -86
  43. package/examples/jsm/transpiler/Linker.js +327 -0
  44. package/examples/jsm/transpiler/TSLEncoder.js +197 -92
  45. package/examples/jsm/transpiler/Transpiler.js +17 -1
  46. package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
  47. package/examples/jsm/transpiler/WGSLEncoder.js +788 -0
  48. package/examples/jsm/tsl/display/BloomNode.js +8 -7
  49. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +206 -0
  50. package/examples/jsm/tsl/display/GaussianBlurNode.js +8 -10
  51. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
  52. package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
  53. package/examples/jsm/tsl/display/hashBlur.js +3 -3
  54. package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
  55. package/package.json +1 -1
  56. package/src/Three.Core.js +1 -0
  57. package/src/Three.TSL.js +77 -28
  58. package/src/Three.WebGPU.js +2 -0
  59. package/src/animation/KeyframeTrack.js +1 -1
  60. package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
  61. package/src/animation/tracks/StringKeyframeTrack.js +1 -1
  62. package/src/cameras/Camera.js +14 -0
  63. package/src/cameras/OrthographicCamera.js +1 -1
  64. package/src/cameras/PerspectiveCamera.js +1 -1
  65. package/src/constants.js +3 -3
  66. package/src/core/BufferAttribute.js +3 -3
  67. package/src/core/Clock.js +2 -8
  68. package/src/core/GLBufferAttribute.js +13 -1
  69. package/src/core/Object3D.js +1 -1
  70. package/{examples/jsm/misc → src/core}/Timer.js +4 -42
  71. package/src/extras/PMREMGenerator.js +11 -0
  72. package/src/extras/core/Path.js +22 -22
  73. package/src/helpers/CameraHelper.js +41 -11
  74. package/src/helpers/SkeletonHelper.js +35 -6
  75. package/src/lights/LightShadow.js +21 -8
  76. package/src/lights/PointLightShadow.js +1 -1
  77. package/src/loaders/FileLoader.js +27 -4
  78. package/src/loaders/ImageBitmapLoader.js +27 -4
  79. package/src/loaders/ImageLoader.js +55 -8
  80. package/src/loaders/Loader.js +14 -0
  81. package/src/loaders/LoadingManager.js +23 -0
  82. package/src/materials/MeshBasicMaterial.js +1 -1
  83. package/src/materials/nodes/Line2NodeMaterial.js +0 -8
  84. package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
  85. package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
  86. package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
  87. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
  88. package/src/materials/nodes/MeshSSSNodeMaterial.js +2 -2
  89. package/src/materials/nodes/NodeMaterial.js +28 -5
  90. package/src/materials/nodes/PointsNodeMaterial.js +5 -0
  91. package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
  92. package/src/math/Frustum.js +25 -9
  93. package/src/math/FrustumArray.js +10 -5
  94. package/src/math/Line3.js +129 -2
  95. package/src/math/Matrix4.js +48 -27
  96. package/src/math/Quaternion.js +1 -1
  97. package/src/math/Spherical.js +2 -2
  98. package/src/nodes/Nodes.js +2 -3
  99. package/src/nodes/TSL.js +5 -3
  100. package/src/nodes/accessors/AccessorsUtils.js +7 -8
  101. package/src/nodes/accessors/Bitangent.js +31 -25
  102. package/src/nodes/accessors/Camera.js +12 -12
  103. package/src/nodes/accessors/Normal.js +95 -29
  104. package/src/nodes/accessors/Object3DNode.js +1 -1
  105. package/src/nodes/accessors/Position.js +7 -7
  106. package/src/nodes/accessors/ReferenceNode.js +18 -3
  107. package/src/nodes/accessors/ReflectVector.js +3 -3
  108. package/src/nodes/accessors/SceneNode.js +1 -1
  109. package/src/nodes/accessors/StorageTextureNode.js +1 -1
  110. package/src/nodes/accessors/Tangent.js +25 -17
  111. package/src/nodes/accessors/TangentUtils.js +46 -0
  112. package/src/nodes/accessors/TextureBicubic.js +21 -3
  113. package/src/nodes/accessors/TextureNode.js +12 -0
  114. package/src/nodes/accessors/UniformArrayNode.js +0 -16
  115. package/src/nodes/core/ArrayNode.js +12 -0
  116. package/src/nodes/core/AssignNode.js +3 -0
  117. package/src/nodes/core/CacheNode.js +0 -14
  118. package/src/nodes/core/ContextNode.js +20 -1
  119. package/src/nodes/core/Node.js +15 -3
  120. package/src/nodes/core/NodeBuilder.js +228 -92
  121. package/src/nodes/core/NodeUtils.js +4 -1
  122. package/src/nodes/core/StackNode.js +49 -29
  123. package/src/nodes/core/SubBuildNode.js +89 -0
  124. package/src/nodes/core/UniformNode.js +63 -5
  125. package/src/nodes/core/VarNode.js +91 -2
  126. package/src/nodes/core/VaryingNode.js +6 -4
  127. package/src/nodes/display/BlendModes.js +2 -2
  128. package/src/nodes/display/FrontFacingNode.js +34 -2
  129. package/src/nodes/display/NormalMapNode.js +19 -50
  130. package/src/nodes/display/PassNode.js +157 -9
  131. package/src/nodes/display/ScreenNode.js +0 -26
  132. package/src/nodes/display/ViewportTextureNode.js +67 -7
  133. package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
  134. package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
  135. package/src/nodes/functions/PhongLightingModel.js +3 -3
  136. package/src/nodes/functions/PhysicalLightingModel.js +16 -16
  137. package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
  138. package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
  139. package/src/nodes/gpgpu/ComputeNode.js +67 -23
  140. package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
  141. package/src/nodes/lighting/EnvironmentNode.js +5 -5
  142. package/src/nodes/lighting/LightsNode.js +4 -4
  143. package/src/nodes/lighting/ProjectorLightNode.js +19 -6
  144. package/src/nodes/lighting/ShadowFilterNode.js +1 -1
  145. package/src/nodes/lighting/ShadowNode.js +2 -2
  146. package/src/nodes/materialx/MaterialXNodes.js +131 -2
  147. package/src/nodes/materialx/lib/mx_noise.js +165 -1
  148. package/src/nodes/math/ConditionalNode.js +1 -20
  149. package/src/nodes/math/MathNode.js +90 -55
  150. package/src/nodes/math/OperatorNode.js +22 -39
  151. package/src/nodes/tsl/TSLBase.js +1 -0
  152. package/src/nodes/tsl/TSLCore.js +114 -55
  153. package/src/nodes/utils/DebugNode.js +1 -1
  154. package/src/nodes/utils/EquirectUV.js +27 -0
  155. package/src/nodes/utils/EventNode.js +83 -0
  156. package/src/nodes/utils/LoopNode.js +0 -17
  157. package/src/nodes/utils/MatcapUV.js +22 -0
  158. package/src/nodes/utils/RTTNode.js +22 -5
  159. package/src/nodes/utils/ReflectorNode.js +11 -4
  160. package/src/nodes/utils/SampleNode.js +81 -0
  161. package/src/nodes/utils/TriplanarTextures.js +65 -0
  162. package/src/objects/BatchedMesh.js +4 -2
  163. package/src/renderers/WebGLRenderer.js +26 -24
  164. package/src/renderers/common/Background.js +2 -2
  165. package/src/renderers/common/Bindings.js +19 -18
  166. package/src/renderers/common/Color4.js +2 -2
  167. package/src/renderers/common/CubeRenderTarget.js +1 -1
  168. package/src/renderers/common/PostProcessing.js +60 -5
  169. package/src/renderers/common/RenderObject.js +68 -3
  170. package/src/renderers/common/Renderer.js +19 -16
  171. package/src/renderers/common/SampledTexture.js +3 -71
  172. package/src/renderers/common/Sampler.js +79 -0
  173. package/src/renderers/common/Storage3DTexture.js +100 -0
  174. package/src/renderers/common/StorageArrayTexture.js +84 -0
  175. package/src/renderers/common/StorageTexture.js +19 -0
  176. package/src/renderers/common/Textures.js +19 -3
  177. package/src/renderers/common/XRManager.js +31 -12
  178. package/src/renderers/common/XRRenderTarget.js +21 -4
  179. package/src/renderers/common/extras/PMREMGenerator.js +1 -1
  180. package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
  181. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
  182. package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
  183. package/src/renderers/webgl/WebGLAttributes.js +4 -0
  184. package/src/renderers/webgl/WebGLCapabilities.js +2 -2
  185. package/src/renderers/webgl/WebGLProgram.js +12 -6
  186. package/src/renderers/webgl/WebGLPrograms.js +6 -4
  187. package/src/renderers/webgl/WebGLShadowMap.js +11 -1
  188. package/src/renderers/webgl/WebGLState.js +4 -4
  189. package/src/renderers/webgl/WebGLTextures.js +19 -7
  190. package/src/renderers/webgl-fallback/WebGLBackend.js +103 -72
  191. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -5
  192. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
  193. package/src/renderers/webgl-fallback/utils/WebGLState.js +4 -4
  194. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +2 -0
  195. package/src/renderers/webgpu/WebGPUBackend.js +63 -16
  196. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +64 -79
  197. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -0
  198. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -31
  199. package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -1
  200. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
  201. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +12 -65
  202. package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
  203. package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
  204. package/src/renderers/webxr/WebXRManager.js +68 -6
  205. package/src/textures/ExternalTexture.js +45 -0
  206. package/src/textures/FramebufferTexture.js +2 -2
  207. package/src/textures/Source.js +11 -1
  208. package/src/textures/VideoTexture.js +30 -2
  209. package/src/nodes/utils/EquirectUVNode.js +0 -65
  210. package/src/nodes/utils/MatcapUVNode.js +0 -49
  211. package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
@@ -2,7 +2,7 @@ import ShadowBaseNode, { shadowPositionWorld } from './ShadowBaseNode.js';
2
2
  import { float, vec2, vec3, int, Fn, nodeObject } from '../tsl/TSLBase.js';
3
3
  import { reference } from '../accessors/ReferenceNode.js';
4
4
  import { texture } from '../accessors/TextureNode.js';
5
- import { transformedNormalWorld } from '../accessors/Normal.js';
5
+ import { normalWorld } from '../accessors/Normal.js';
6
6
  import { mix, sqrt } from '../math/MathNode.js';
7
7
  import { add } from '../math/OperatorNode.js';
8
8
  import { DepthTexture } from '../../textures/DepthTexture.js';
@@ -484,7 +484,7 @@ class ShadowNode extends ShadowBaseNode {
484
484
  const shadowIntensity = reference( 'intensity', 'float', shadow ).setGroup( renderGroup );
485
485
  const normalBias = reference( 'normalBias', 'float', shadow ).setGroup( renderGroup );
486
486
 
487
- const shadowPosition = lightShadowMatrix( light ).mul( shadowPositionWorld.add( transformedNormalWorld.mul( normalBias ) ) );
487
+ const shadowPosition = lightShadowMatrix( light ).mul( shadowPositionWorld.add( normalWorld.mul( normalBias ) ) );
488
488
  const shadowCoord = this.setupShadowCoord( builder, shadowPosition );
489
489
 
490
490
  //
@@ -2,13 +2,17 @@ import {
2
2
  mx_perlin_noise_float, mx_perlin_noise_vec3,
3
3
  mx_worley_noise_float as worley_noise_float, mx_worley_noise_vec2 as worley_noise_vec2, mx_worley_noise_vec3 as worley_noise_vec3,
4
4
  mx_cell_noise_float as cell_noise_float,
5
+ mx_unifiednoise2d as unifiednoise2d, mx_unifiednoise3d as unifiednoise3d,
5
6
  mx_fractal_noise_float as fractal_noise_float, mx_fractal_noise_vec2 as fractal_noise_vec2, mx_fractal_noise_vec3 as fractal_noise_vec3, mx_fractal_noise_vec4 as fractal_noise_vec4
6
7
  } from './lib/mx_noise.js';
7
8
  import { mx_hsvtorgb, mx_rgbtohsv } from './lib/mx_hsv.js';
8
9
  import { mx_srgb_texture_to_lin_rec709 } from './lib/mx_transform_color.js';
9
- import { mix, smoothstep } from '../math/MathNode.js';
10
+
11
+ import { float, vec2, vec3, vec4, int, add, sub, mul, div, mod, atan, mix, pow, smoothstep } from '../tsl/TSLBase.js';
10
12
  import { uv } from '../accessors/UV.js';
11
- import { float, vec2, vec4, int } from '../tsl/TSLBase.js';
13
+ import { bumpMap } from '../display/BumpMapNode.js';
14
+ import { rotate } from '../utils/RotateNode.js';
15
+ import { frameId, time } from '../utils/Timer.js';
12
16
 
13
17
  export const mx_aastep = ( threshold, value ) => {
14
18
 
@@ -25,6 +29,19 @@ const _ramp = ( a, b, uv, p ) => mix( a, b, uv[ p ].clamp() );
25
29
  export const mx_ramplr = ( valuel, valuer, texcoord = uv() ) => _ramp( valuel, valuer, texcoord, 'x' );
26
30
  export const mx_ramptb = ( valuet, valueb, texcoord = uv() ) => _ramp( valuet, valueb, texcoord, 'y' );
27
31
 
32
+ // Bilinear ramp: interpolate between four corners (tl, tr, bl, br) using texcoord.x and texcoord.y
33
+ export const mx_ramp4 = (
34
+ valuetl, valuetr, valuebl, valuebr, texcoord = uv()
35
+ ) => {
36
+
37
+ const u = texcoord.x.clamp();
38
+ const v = texcoord.y.clamp();
39
+ const top = mix( valuetl, valuetr, u );
40
+ const bottom = mix( valuebl, valuebr, u );
41
+ return mix( top, bottom, v );
42
+
43
+ };
44
+
28
45
  const _split = ( a, b, center, uv, p ) => mix( a, b, mx_aastep( center, uv[ p ] ) );
29
46
  export const mx_splitlr = ( valuel, valuer, center, texcoord = uv() ) => _split( valuel, valuer, center, texcoord, 'x' );
30
47
  export const mx_splittb = ( valuet, valueb, center, texcoord = uv() ) => _split( valuet, valueb, center, texcoord, 'y' );
@@ -54,6 +71,9 @@ export const mx_noise_vec4 = ( texcoord = uv(), amplitude = 1, pivot = 0 ) => {
54
71
 
55
72
  };
56
73
 
74
+ export const mx_unifiednoise2d = ( noiseType, texcoord = uv(), freq = vec2( 1, 1 ), offset = vec2( 0, 0 ), jitter = 1, outmin = 0, outmax = 1, clampoutput = false, octaves = 1, lacunarity = 2, diminish = .5 ) => unifiednoise2d( noiseType, texcoord.convert( 'vec2|vec3' ), freq, offset, jitter, outmin, outmax, clampoutput, octaves, lacunarity, diminish );
75
+ export const mx_unifiednoise3d = ( noiseType, texcoord = uv(), freq = vec2( 1, 1 ), offset = vec2( 0, 0 ), jitter = 1, outmin = 0, outmax = 1, clampoutput = false, octaves = 1, lacunarity = 2, diminish = .5 ) => unifiednoise3d( noiseType, texcoord.convert( 'vec2|vec3' ), freq, offset, jitter, outmin, outmax, clampoutput, octaves, lacunarity, diminish );
76
+
57
77
  export const mx_worley_noise_float = ( texcoord = uv(), jitter = 1 ) => worley_noise_float( texcoord.convert( 'vec2|vec3' ), jitter, int( 1 ) );
58
78
  export const mx_worley_noise_vec2 = ( texcoord = uv(), jitter = 1 ) => worley_noise_vec2( texcoord.convert( 'vec2|vec3' ), jitter, int( 1 ) );
59
79
  export const mx_worley_noise_vec3 = ( texcoord = uv(), jitter = 1 ) => worley_noise_vec3( texcoord.convert( 'vec2|vec3' ), jitter, int( 1 ) );
@@ -66,3 +86,112 @@ export const mx_fractal_noise_vec3 = ( position = uv(), octaves = 3, lacunarity
66
86
  export const mx_fractal_noise_vec4 = ( position = uv(), octaves = 3, lacunarity = 2, diminish = .5, amplitude = 1 ) => fractal_noise_vec4( position, int( octaves ), lacunarity, diminish ).mul( amplitude );
67
87
 
68
88
  export { mx_hsvtorgb, mx_rgbtohsv, mx_srgb_texture_to_lin_rec709 };
89
+
90
+ // === Moved from MaterialXLoader.js ===
91
+
92
+ // Math ops
93
+ export const mx_add = ( in1, in2 = float( 0 ) ) => add( in1, in2 );
94
+ export const mx_subtract = ( in1, in2 = float( 0 ) ) => sub( in1, in2 );
95
+ export const mx_multiply = ( in1, in2 = float( 1 ) ) => mul( in1, in2 );
96
+ export const mx_divide = ( in1, in2 = float( 1 ) ) => div( in1, in2 );
97
+ export const mx_modulo = ( in1, in2 = float( 1 ) ) => mod( in1, in2 );
98
+ export const mx_power = ( in1, in2 = float( 1 ) ) => pow( in1, in2 );
99
+ export const mx_atan2 = ( in1 = float( 0 ), in2 = float( 1 ) ) => atan( in1, in2 );
100
+ export const mx_timer = () => time;
101
+ export const mx_frame = () => frameId;
102
+ export const mx_invert = ( in1, amount = float( 1 ) ) => sub( amount, in1 );
103
+ export const mx_ifgreater = ( value1, value2, in1, in2 ) => value1.greaterThan( value2 ).mix( in1, in2 );
104
+ export const mx_ifgreatereq = ( value1, value2, in1, in2 ) => value1.greaterThanEqual( value2 ).mix( in1, in2 );
105
+ export const mx_ifequal = ( value1, value2, in1, in2 ) => value1.equal( value2 ).mix( in1, in2 );
106
+
107
+ // Enhanced separate node to support multi-output referencing (outx, outy, outz, outw)
108
+ export const mx_separate = ( in1, channelOrOut = null ) => {
109
+
110
+ if ( typeof channelOrOut === 'string' ) {
111
+
112
+ const map = { x: 0, r: 0, y: 1, g: 1, z: 2, b: 2, w: 3, a: 3 };
113
+ const c = channelOrOut.replace( /^out/, '' ).toLowerCase();
114
+ if ( map[ c ] !== undefined ) return in1.element( map[ c ] );
115
+
116
+ }
117
+
118
+ if ( typeof channelOrOut === 'number' ) {
119
+
120
+ return in1.element( channelOrOut );
121
+
122
+ }
123
+
124
+ if ( typeof channelOrOut === 'string' && channelOrOut.length === 1 ) {
125
+
126
+ const map = { x: 0, r: 0, y: 1, g: 1, z: 2, b: 2, w: 3, a: 3 };
127
+ if ( map[ channelOrOut ] !== undefined ) return in1.element( map[ channelOrOut ] );
128
+
129
+ }
130
+
131
+ return in1;
132
+
133
+ };
134
+
135
+ export const mx_place2d = (
136
+ texcoord, pivot = vec2( 0.5, 0.5 ), scale = vec2( 1, 1 ), rotate = float( 0 ), offset = vec2( 0, 0 )/*, operationorder = int( 0 )*/
137
+ ) => {
138
+
139
+ let uv = texcoord;
140
+ if ( pivot ) uv = uv.sub( pivot );
141
+ if ( scale ) uv = uv.mul( scale );
142
+ if ( rotate ) {
143
+
144
+ const rad = rotate.mul( Math.PI / 180.0 );
145
+ const cosR = rad.cos();
146
+ const sinR = rad.sin();
147
+ uv = vec2(
148
+ uv.x.mul( cosR ).sub( uv.y.mul( sinR ) ),
149
+ uv.x.mul( sinR ).add( uv.y.mul( cosR ) )
150
+ );
151
+
152
+ }
153
+
154
+ if ( pivot ) uv = uv.add( pivot );
155
+ if ( offset ) uv = uv.add( offset );
156
+ return uv;
157
+
158
+ };
159
+
160
+ export const mx_rotate2d = ( input, amount ) => {
161
+
162
+ input = vec2( input );
163
+ amount = float( amount );
164
+
165
+ const radians = amount.mul( Math.PI / 180.0 );
166
+ return rotate( input, radians );
167
+
168
+ };
169
+
170
+ export const mx_rotate3d = ( input, amount, axis ) => {
171
+
172
+ input = vec3( input );
173
+ amount = float( amount );
174
+ axis = vec3( axis );
175
+
176
+
177
+ const radians = amount.mul( Math.PI / 180.0 );
178
+ const nAxis = axis.normalize();
179
+ const cosA = radians.cos();
180
+ const sinA = radians.sin();
181
+ const oneMinusCosA = float( 1 ).sub( cosA );
182
+ const rot =
183
+ input.mul( cosA )
184
+ .add( nAxis.cross( input ).mul( sinA ) )
185
+ .add( nAxis.mul( nAxis.dot( input ) ).mul( oneMinusCosA ) );
186
+ return rot;
187
+
188
+ };
189
+
190
+ export const mx_heighttonormal = ( input, scale/*, texcoord*/ ) => {
191
+
192
+ input = vec3( input );
193
+ scale = float( scale );
194
+
195
+ return bumpMap( input, scale );
196
+
197
+ };
@@ -4,7 +4,7 @@
4
4
  import { int, uint, float, vec3, bool, uvec3, vec2, vec4, If, Fn } from '../../tsl/TSLBase.js';
5
5
  import { select } from '../../math/ConditionalNode.js';
6
6
  import { sub, mul } from '../../math/OperatorNode.js';
7
- import { floor, abs, max, dot, min, sqrt } from '../../math/MathNode.js';
7
+ import { floor, abs, max, dot, min, sqrt, clamp } from '../../math/MathNode.js';
8
8
  import { overloadingFn } from '../../utils/FunctionOverloadingNode.js';
9
9
  import { Loop } from '../../utils/LoopNode.js';
10
10
 
@@ -1325,3 +1325,167 @@ export const mx_worley_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_
1325
1325
  } );
1326
1326
 
1327
1327
  export const mx_worley_noise_vec3 = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_vec3_0, mx_worley_noise_vec3_1 ] );
1328
+
1329
+ // Unified Noise 2D
1330
+ export const mx_unifiednoise2d = /*@__PURE__*/ Fn( ( [
1331
+ noiseType_immutable, texcoord_immutable, freq_immutable, offset_immutable,
1332
+ jitter_immutable, outmin_immutable, outmax_immutable, clampoutput_immutable,
1333
+ octaves_immutable, lacunarity_immutable, diminish_immutable
1334
+ ] ) => {
1335
+
1336
+ const noiseType = int( noiseType_immutable ).toVar();
1337
+ const texcoord = vec2( texcoord_immutable ).toVar();
1338
+ const freq = vec2( freq_immutable ).toVar();
1339
+ const offset = vec2( offset_immutable ).toVar();
1340
+ const jitter = float( jitter_immutable ).toVar();
1341
+ const outmin = float( outmin_immutable ).toVar();
1342
+ const outmax = float( outmax_immutable ).toVar();
1343
+ const clampoutput = bool( clampoutput_immutable ).toVar();
1344
+ const octaves = int( octaves_immutable ).toVar();
1345
+ const lacunarity = float( lacunarity_immutable ).toVar();
1346
+ const diminish = float( diminish_immutable ).toVar();
1347
+
1348
+ // Compute input position
1349
+ const p = texcoord.mul( freq ).add( offset );
1350
+
1351
+ const result = float( 0.0 ).toVar();
1352
+
1353
+ // Perlin
1354
+ If( noiseType.equal( int( 0 ) ), () => {
1355
+
1356
+ result.assign( mx_perlin_noise_vec3( p ) );
1357
+
1358
+ } );
1359
+
1360
+ // Cell
1361
+ If( noiseType.equal( int( 1 ) ), () => {
1362
+
1363
+ result.assign( mx_cell_noise_vec3( p ) );
1364
+
1365
+ } );
1366
+
1367
+ // Worley (metric=0 = euclidean)
1368
+ If( noiseType.equal( int( 2 ) ), () => {
1369
+
1370
+ result.assign( mx_worley_noise_vec3( p, jitter, int( 0 ) ) );
1371
+
1372
+ } );
1373
+
1374
+ // Fractal (use vec3(p, 0.0) for 2D input)
1375
+ If( noiseType.equal( int( 3 ) ), () => {
1376
+
1377
+ result.assign( mx_fractal_noise_vec3( vec3( p, 0.0 ), octaves, lacunarity, diminish ) );
1378
+
1379
+ } );
1380
+
1381
+ // Remap output to [outmin, outmax]
1382
+ result.assign( result.mul( outmax.sub( outmin ) ).add( outmin ) );
1383
+
1384
+ // Clamp if requested
1385
+ If( clampoutput, () => {
1386
+
1387
+ result.assign( clamp( result, outmin, outmax ) );
1388
+
1389
+ } );
1390
+
1391
+ return result;
1392
+
1393
+ } ).setLayout( {
1394
+ name: 'mx_unifiednoise2d',
1395
+ type: 'float',
1396
+ inputs: [
1397
+ { name: 'noiseType', type: 'int' },
1398
+ { name: 'texcoord', type: 'vec2' },
1399
+ { name: 'freq', type: 'vec2' },
1400
+ { name: 'offset', type: 'vec2' },
1401
+ { name: 'jitter', type: 'float' },
1402
+ { name: 'outmin', type: 'float' },
1403
+ { name: 'outmax', type: 'float' },
1404
+ { name: 'clampoutput', type: 'bool' },
1405
+ { name: 'octaves', type: 'int' },
1406
+ { name: 'lacunarity', type: 'float' },
1407
+ { name: 'diminish', type: 'float' }
1408
+ ]
1409
+ } );
1410
+
1411
+ // Unified Noise 3D
1412
+ export const mx_unifiednoise3d = /*@__PURE__*/ Fn( ( [
1413
+ noiseType_immutable, position_immutable, freq_immutable, offset_immutable,
1414
+ jitter_immutable, outmin_immutable, outmax_immutable, clampoutput_immutable,
1415
+ octaves_immutable, lacunarity_immutable, diminish_immutable
1416
+ ] ) => {
1417
+
1418
+ const noiseType = int( noiseType_immutable ).toVar();
1419
+ const position = vec3( position_immutable ).toVar();
1420
+ const freq = vec3( freq_immutable ).toVar();
1421
+ const offset = vec3( offset_immutable ).toVar();
1422
+ const jitter = float( jitter_immutable ).toVar();
1423
+ const outmin = float( outmin_immutable ).toVar();
1424
+ const outmax = float( outmax_immutable ).toVar();
1425
+ const clampoutput = bool( clampoutput_immutable ).toVar();
1426
+ const octaves = int( octaves_immutable ).toVar();
1427
+ const lacunarity = float( lacunarity_immutable ).toVar();
1428
+ const diminish = float( diminish_immutable ).toVar();
1429
+
1430
+ // Compute input position
1431
+ const p = position.mul( freq ).add( offset );
1432
+
1433
+ const result = float( 0.0 ).toVar();
1434
+
1435
+ // Perlin
1436
+ If( noiseType.equal( int( 0 ) ), () => {
1437
+
1438
+ result.assign( mx_perlin_noise_vec3( p ) );
1439
+
1440
+ } );
1441
+
1442
+ // Cell
1443
+ If( noiseType.equal( int( 1 ) ), () => {
1444
+
1445
+ result.assign( mx_cell_noise_vec3( p ) );
1446
+
1447
+ } );
1448
+
1449
+ // Worley (metric=0 = euclidean)
1450
+ If( noiseType.equal( int( 2 ) ), () => {
1451
+
1452
+ result.assign( mx_worley_noise_vec3( p, jitter, int( 0 ) ) );
1453
+
1454
+ } );
1455
+
1456
+ // Fractal
1457
+ If( noiseType.equal( int( 3 ) ), () => {
1458
+
1459
+ result.assign( mx_fractal_noise_vec3( p, octaves, lacunarity, diminish ) );
1460
+
1461
+ } );
1462
+
1463
+ // Remap output to [outmin, outmax]
1464
+ result.assign( result.mul( outmax.sub( outmin ) ).add( outmin ) );
1465
+
1466
+ // Clamp if requested
1467
+ If( clampoutput, () => {
1468
+
1469
+ result.assign( clamp( result, outmin, outmax ) );
1470
+
1471
+ } );
1472
+
1473
+ return result;
1474
+
1475
+ } ).setLayout( {
1476
+ name: 'mx_unifiednoise3d',
1477
+ type: 'float',
1478
+ inputs: [
1479
+ { name: 'noiseType', type: 'int' },
1480
+ { name: 'position', type: 'vec3' },
1481
+ { name: 'freq', type: 'vec3' },
1482
+ { name: 'offset', type: 'vec3' },
1483
+ { name: 'jitter', type: 'float' },
1484
+ { name: 'outmin', type: 'float' },
1485
+ { name: 'outmax', type: 'float' },
1486
+ { name: 'clampoutput', type: 'bool' },
1487
+ { name: 'octaves', type: 'int' },
1488
+ { name: 'lacunarity', type: 'float' },
1489
+ { name: 'diminish', type: 'float' }
1490
+ ]
1491
+ } );
@@ -73,7 +73,7 @@ class ConditionalNode extends Node {
73
73
 
74
74
  // fallback setup
75
75
 
76
- this.setup( builder );
76
+ builder.flowBuildStage( this, 'setup' );
77
77
 
78
78
  return this.getNodeType( builder );
79
79
 
@@ -226,22 +226,3 @@ export default ConditionalNode;
226
226
  export const select = /*@__PURE__*/ nodeProxy( ConditionalNode ).setParameterLength( 2, 3 );
227
227
 
228
228
  addMethodChaining( 'select', select );
229
-
230
- // Deprecated
231
-
232
- /**
233
- * @tsl
234
- * @function
235
- * @deprecated since r168. Use {@link select} instead.
236
- *
237
- * @param {...any} params
238
- * @returns {ConditionalNode}
239
- */
240
- export const cond = ( ...params ) => { // @deprecated, r168
241
-
242
- console.warn( 'THREE.TSL: cond() has been renamed to select().' );
243
- return select( ...params );
244
-
245
- };
246
-
247
- addMethodChaining( 'cond', cond );