Skip to content

Commit a4e9621

Browse files
authored
Fix debug tile features not being initialized correctly, reorganize constructor (#1273)
1 parent 5bf028a commit a4e9621

File tree

1 file changed

+51
-63
lines changed

1 file changed

+51
-63
lines changed

src/three/plugins/DebugTilesPlugin.js

Lines changed: 51 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -98,57 +98,6 @@ export class DebugTilesPlugin {
9898

9999
}
100100

101-
constructor( options ) {
102-
103-
options = {
104-
displayParentBounds: false,
105-
displayBoxBounds: false,
106-
displaySphereBounds: false,
107-
displayRegionBounds: false,
108-
colorMode: NONE,
109-
maxDebugDepth: - 1,
110-
maxDebugDistance: - 1,
111-
maxDebugError: - 1,
112-
customColorCallback: null,
113-
unlit: false,
114-
enabled: true,
115-
...options,
116-
};
117-
118-
this.name = 'DEBUG_TILES_PLUGIN';
119-
this.tiles = null;
120-
121-
this._colorMode = null;
122-
this._unlit = null;
123-
this.materialsNeedUpdate = false;
124-
125-
this.extremeDebugDepth = - 1;
126-
this.extremeDebugError = - 1;
127-
this.boxGroup = null;
128-
this.sphereGroup = null;
129-
this.regionGroup = null;
130-
131-
// options
132-
this._enabled = options.enabled;
133-
this._displayParentBounds = options.displayParentBounds;
134-
this.displayBoxBounds = options.displayBoxBounds;
135-
this.displaySphereBounds = options.displaySphereBounds;
136-
this.displayRegionBounds = options.displayRegionBounds;
137-
this.colorMode = options.colorMode;
138-
this.maxDebugDepth = options.maxDebugDepth;
139-
this.maxDebugDistance = options.maxDebugDistance;
140-
this.maxDebugError = options.maxDebugError;
141-
this.customColorCallback = options.customColorCallback;
142-
this.unlit = options.unlit;
143-
144-
this.getDebugColor = ( value, target ) => {
145-
146-
target.setRGB( value, value, value );
147-
148-
};
149-
150-
}
151-
152101
get enabled() {
153102

154103
return this._enabled;
@@ -216,16 +165,61 @@ export class DebugTilesPlugin {
216165

217166
}
218167

219-
// initialize the groups for displaying helpers, register events, and initialize existing tiles
220-
init( tiles ) {
168+
constructor( options ) {
221169

222-
this.tiles = tiles;
170+
options = {
171+
displayParentBounds: false,
172+
displayBoxBounds: false,
173+
displaySphereBounds: false,
174+
displayRegionBounds: false,
175+
colorMode: NONE,
176+
maxDebugDepth: - 1,
177+
maxDebugDistance: - 1,
178+
maxDebugError: - 1,
179+
customColorCallback: null,
180+
unlit: false,
181+
enabled: true,
182+
...options,
183+
};
184+
185+
this.name = 'DEBUG_TILES_PLUGIN';
186+
this.tiles = null;
223187

224-
if ( ! this.enabled ) {
188+
this._colorMode = null;
189+
this._unlit = null;
190+
this.materialsNeedUpdate = false;
225191

226-
return;
192+
this.extremeDebugDepth = - 1;
193+
this.extremeDebugError = - 1;
194+
this.boxGroup = null;
195+
this.sphereGroup = null;
196+
this.regionGroup = null;
227197

228-
}
198+
// options
199+
this._enabled = options.enabled;
200+
this._displayParentBounds = options.displayParentBounds;
201+
this.displayBoxBounds = options.displayBoxBounds;
202+
this.displaySphereBounds = options.displaySphereBounds;
203+
this.displayRegionBounds = options.displayRegionBounds;
204+
this.colorMode = options.colorMode;
205+
this.maxDebugDepth = options.maxDebugDepth;
206+
this.maxDebugDistance = options.maxDebugDistance;
207+
this.maxDebugError = options.maxDebugError;
208+
this.customColorCallback = options.customColorCallback;
209+
this.unlit = options.unlit;
210+
211+
this.getDebugColor = ( value, target ) => {
212+
213+
target.setRGB( value, value, value );
214+
215+
};
216+
217+
}
218+
219+
// initialize the groups for displaying helpers, register events, and initialize existing tiles
220+
init( tiles ) {
221+
222+
this.tiles = tiles;
229223

230224
// initialize groups
231225
const tilesGroup = tiles.group;
@@ -926,12 +920,6 @@ export class DebugTilesPlugin {
926920

927921
dispose() {
928922

929-
if ( ! this.enabled ) {
930-
931-
return;
932-
933-
}
934-
935923
const tiles = this.tiles;
936924

937925
tiles.removeEventListener( 'load-tile-set', this._onLoadTileSetCB );

0 commit comments

Comments
 (0)