File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -940,21 +940,25 @@ class RendererGL extends Renderer {
940940 } ;
941941
942942 if ( isPGraphics ) {
943+ // Handle PGraphics: remove and recreate the canvas
943944 const pg = this . _pInst ;
944945 pg . canvas . parentNode . removeChild ( pg . canvas ) ;
945946 pg . canvas = document . createElement ( "canvas" ) ;
946947 const node = pg . _pInst . _userNode || document . body ;
947948 node . appendChild ( pg . canvas ) ;
948949 Element . call ( pg , pg . canvas , pg . _pInst ) ;
950+ // Restore previous width and height
949951 pg . width = w ;
950952 pg . height = h ;
951953 } else {
954+ // Handle main canvas: remove and recreate it
952955 let c = this . canvas ;
953956 if ( c ) {
954957 c . parentNode . removeChild ( c ) ;
955958 }
956959 c = document . createElement ( "canvas" ) ;
957960 c . id = defaultId ;
961+ // Attach the new canvas to the correct parent node
958962 if ( this . _pInst . _userNode ) {
959963 this . _pInst . _userNode . appendChild ( c ) ;
960964 } else {
You can’t perform that action at this time.
0 commit comments