@@ -125,6 +125,20 @@ export function initGlobalStrandsAPI(p5, fn, strandsContext) {
125125
126126 // Add noise function with backend-agnostic implementation
127127 const originalNoise = fn . noise ;
128+ const originalNoiseDetail = fn . noiseDetail ;
129+
130+ strandsContext . _noiseOctaves = null ;
131+ strandsContext . _noiseAmpFalloff = null ;
132+
133+ fn . noiseDetail = function ( lod , falloff ) {
134+ if ( ! strandsContext . active ) {
135+ return originalNoiseDetail . apply ( this , arguments ) ;
136+ }
137+
138+ strandsContext . _noiseOctaves = lod ;
139+ strandsContext . _noiseAmpFalloff = falloff ;
140+ } ;
141+
128142 fn . noise = function ( ...args ) {
129143 if ( ! strandsContext . active ) {
130144 return originalNoise . apply ( this , args ) ; // fallback to regular p5.js noise
@@ -154,9 +168,20 @@ export function initGlobalStrandsAPI(p5, fn, strandsContext) {
154168 `It looks like you've called noise() with ${ args . length } arguments. It only supports 1D to 3D input.`
155169 ) ;
156170 }
171+
172+ const octaves = strandsContext . _noiseOctaves !== null
173+ ? strandsContext . _noiseOctaves
174+ : fn . _getNoiseOctaves ( ) ;
175+ const falloff = strandsContext . _noiseAmpFalloff !== null
176+ ? strandsContext . _noiseAmpFalloff
177+ : fn . _getNoiseAmpFalloff ( ) ;
178+
179+ nodeArgs . push ( octaves ) ;
180+ nodeArgs . push ( falloff ) ;
181+
157182 const { id, dimension } = build . functionCallNode ( strandsContext , 'noise' , nodeArgs , {
158183 overloads : [ {
159- params : [ DataType . float3 ] ,
184+ params : [ DataType . float3 , DataType . int1 , DataType . float1 ] ,
160185 returnType : DataType . float1 ,
161186 } ]
162187 } ) ;
0 commit comments