@@ -93,6 +93,10 @@ function rendererWebGPU(p5, fn) {
9393 this . finalCamera = new Camera ( this ) ;
9494 this . finalCamera . _computeCameraDefaultSettings ( ) ;
9595 this . finalCamera . _setDefaultCamera ( ) ;
96+
97+ this . depthFormat = 'depth24plus-stencil8' ;
98+ this . depthTexture = null ;
99+ this . depthTextureView = null ;
96100 }
97101
98102 async setupContext ( ) {
@@ -133,7 +137,6 @@ function rendererWebGPU(p5, fn) {
133137 } ) ;
134138
135139 // TODO disablable stencil
136- this . depthFormat = 'depth24plus-stencil8' ;
137140 this . mainFramebuffer = this . createFramebuffer ( { _useCanvasFormat : true } ) ;
138141 this . _updateSize ( ) ;
139142 this . _update ( ) ;
@@ -190,6 +193,7 @@ function rendererWebGPU(p5, fn) {
190193 }
191194
192195 _updateSize ( ) {
196+ if ( ! this . device || ! this . depthFormat ) return ;
193197 if ( this . depthTexture && this . depthTexture . destroy ) {
194198 this . flushDraw ( ) ;
195199 const textureToDestroy = this . depthTexture ;
@@ -284,6 +288,7 @@ function rendererWebGPU(p5, fn) {
284288 }
285289
286290 clear ( ...args ) {
291+ if ( ! this . device || ! this . drawingContext ) return ;
287292 const _r = args [ 0 ] || 0 ;
288293 const _g = args [ 1 ] || 0 ;
289294 const _b = args [ 2 ] || 0 ;
@@ -350,6 +355,7 @@ function rendererWebGPU(p5, fn) {
350355 * occlude anything subsequently drawn.
351356 */
352357 clearDepth ( depth = 1 ) {
358+ if ( ! this . device || ! this . depthTextureView ) return ;
353359 this . _finishActiveRenderPass ( ) ;
354360 const commandEncoder = this . device . createCommandEncoder ( ) ;
355361
0 commit comments