File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -274,6 +274,16 @@ function shadergenerator(p5, fn) {
274
274
}
275
275
}
276
276
277
+ toFloat ( ) {
278
+ if ( isFloatNode ( this ) ) {
279
+ return this ;
280
+ } else if ( isIntNode ( this ) ) {
281
+ return new FloatNode ( this ) ;
282
+ } else {
283
+ throw new TypeError ( `Can't convert from type '${ this . type } ' to 'float'.` )
284
+ }
285
+ }
286
+
277
287
toGLSL ( context ) {
278
288
throw new TypeError ( "Not supposed to call this function on BaseNode, which is an abstract class." ) ;
279
289
}
@@ -373,11 +383,13 @@ function shadergenerator(p5, fn) {
373
383
}
374
384
375
385
deconstructArgs ( context ) {
376
- if ( Array . isArray ( this . args ) ) {
377
- return this . args . map ( ( argNode ) => argNode . toGLSLBase ( context ) ) . join ( ', ' ) ;
378
- } else {
379
- return `${ this . args . toGLSLBase ( context ) } ` ;
380
- }
386
+ let argsString = this . args . map ( ( argNode , i ) => {
387
+ if ( isIntNode ( argNode ) && this . argumentTypes [ i ] != 'float' ) {
388
+ argNode = argNode . toFloat ( ) ;
389
+ }
390
+ return argNode . toGLSLBase ( context ) ;
391
+ } ) . join ( ', ' ) ;
392
+ return argsString ;
381
393
}
382
394
383
395
toGLSL ( context ) {
You can’t perform that action at this time.
0 commit comments