File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -728,6 +728,35 @@ export class Renderer3D extends Renderer {
728728 }
729729
730730 background ( ...args ) {
731+ const a0 = args [ 0 ] ;
732+
733+ const isImageLike =
734+ a0 instanceof p5 . Image ||
735+ a0 instanceof p5 . Graphics ||
736+ a0 instanceof p5 . MediaElement ||
737+ ( typeof HTMLImageElement !== 'undefined' && a0 instanceof HTMLImageElement ) ||
738+ ( typeof HTMLVideoElement !== 'undefined' && a0 instanceof HTMLVideoElement ) ||
739+ ( typeof HTMLCanvasElement !== 'undefined' && a0 instanceof HTMLCanvasElement ) ;
740+
741+ // WEBGL / 3D: support background(image)
742+ if ( args . length > 0 && isImageLike ) {
743+ this . _pInst . clear ( ) ;
744+ this . _pInst . push ( ) ;
745+ this . _pInst . resetMatrix ( ) ;
746+ this . _pInst . imageMode ( constants . CORNER ) ;
747+ this . _pInst . image (
748+ a0 ,
749+ - this . _pInst . width / 2 ,
750+ - this . _pInst . height / 2 ,
751+ this . _pInst . width ,
752+ this . _pInst . height
753+ ) ;
754+
755+ this . _pInst . pop ( ) ;
756+ return ;
757+ }
758+
759+ // Default: background(color)
731760 const _col = this . _pInst . color ( ...args ) ;
732761 this . clear ( ..._col . _getRGBA ( ) ) ;
733762 }
You can’t perform that action at this time.
0 commit comments