@@ -153,10 +153,11 @@ export class WebGLPreview {
153153 private _toolColors : Record < number , Color > = { } ;
154154
155155 // debug
156- private devMode ?: boolean | DevModeOptions = true ;
156+ private devMode ?: boolean | DevModeOptions = false ;
157157 private _lastRenderTime = 0 ;
158158 private _wireframe = false ;
159- private stats : Stats = new Stats ( ) ;
159+ private stats ?: Stats ;
160+ private statsContainer ?: HTMLElement ;
160161 private devGui ?: DevGUI ;
161162
162163 constructor ( opts : GCodePreviewOptions ) {
@@ -181,6 +182,7 @@ export class WebGLPreview {
181182 this . renderTubes = opts . renderTubes ?? this . renderTubes ;
182183 this . extrusionWidth = opts . extrusionWidth ?? this . extrusionWidth ;
183184 this . devMode = opts . devMode ?? this . devMode ;
185+ this . stats = this . devMode ? new Stats ( ) : undefined ;
184186
185187 if ( opts . extrusionColor !== undefined ) {
186188 this . extrusionColor = opts . extrusionColor ;
@@ -245,10 +247,7 @@ export class WebGLPreview {
245247
246248 if ( opts . allowDragNDrop ) this . _enableDropHandler ( ) ;
247249
248- if ( this . devMode ) {
249- document . body . appendChild ( this . stats . dom ) ;
250- this . initGui ( ) ;
251- }
250+ this . initStats ( ) ;
252251 }
253252
254253 get extrusionColor ( ) : Color | Color [ ] {
@@ -857,6 +856,17 @@ export class WebGLPreview {
857856 this . devGui = new DevGUI ( this , this . devMode ) ;
858857 }
859858 }
859+
860+ private initStats ( ) {
861+ if ( this . stats ) {
862+ if ( typeof this . devMode === 'object' ) {
863+ this . statsContainer = this . devMode . statsContainer ;
864+ }
865+ ( this . statsContainer ?? document . body ) . appendChild ( this . stats . dom ) ;
866+ this . stats . dom . classList . add ( 'stats' ) ;
867+ this . initGui ( ) ;
868+ }
869+ }
860870}
861871
862872function decode ( uint8array : Uint8Array ) {
0 commit comments