Skip to content

Commit abcc175

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 11b9af4 + 661d59d commit abcc175

File tree

12 files changed

+866
-738
lines changed

12 files changed

+866
-738
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3232
- Loaders: ".load" function has been renamed to ".loadAsync".
3333
- Deprecated `onLoadTileset`, `onLoadModel`, `onDisposeModel`, and `onTileVisibilityChange` in favor of their event equivalents.
3434
- LRUCache: "unloadPriorityCallback" has been changted to take two tile arguments to sort instead of one.
35+
- DebugTilesRenderer has been derecated in favor of the "DebugTilesPlugin".
3536

3637
## [0.3.35] - 2024.06.25
3738
### Fixed

PLUGINS.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,119 @@ tiles.registerPlugin( new TilesCompressionPlugin() );
198198
tiles.registerPlugin( new TilesFadePlugin() );
199199
```
200200

201+
## DebugTilesPlugin
202+
203+
Plugin TilesRenderer that includes helpers for debugging and visualizing the various tiles in the tile set. Material overrides will not work as expected with this plugin. The plugin includes additional logic and initialization code which can cause performance loss so it's recommended to only use this when needed.
204+
205+
### .colorMode
206+
207+
```js
208+
colorMode = NONE : ColorMode
209+
```
210+
211+
Which color mode to use when rendering the tile set. The following exported enumerations can be used:
212+
213+
```js
214+
// No special color mode. Uses the default materials.
215+
NONE
216+
217+
// Render the screenspace error from black to white with errorTarget
218+
// being the maximum value.
219+
SCREEN_ERROR
220+
221+
// Render the geometric error from black to white with maxDebugError
222+
// being the maximum value.
223+
GEOMETRIC_ERROR
224+
225+
// Render the distance from the camera to the tile as black to white
226+
// with maxDebugDistance being the maximum value.
227+
DISTANCE
228+
229+
// Render the depth of the tile relative to the root as black to white
230+
// with maxDebugDepth being the maximum value.
231+
DEPTH
232+
233+
// Render the depth of the tile relative to the nearest rendered parent
234+
// as black to white with maxDebugDepth being the maximum value.
235+
RELATIVE_DEPTH
236+
237+
// Render leaf nodes as white and parent nodes as black.
238+
IS_LEAF
239+
240+
// Render the tiles with a random color to show tile edges clearly.
241+
RANDOM_COLOR
242+
243+
// Render every individual mesh in the scene with a random color.
244+
RANDOM_NODE_COLOR
245+
246+
// Sets a custom color using the customColorCallback call back.
247+
CUSTOM_COLOR
248+
```
249+
250+
### .customColorCallback
251+
252+
```js
253+
customColorCallback: (tile: Tile, child: Object3D) => void
254+
```
255+
256+
The callback used if `debugColor` is set to `CUSTOM_COLOR`. Value defaults to `null` and must be set explicitly.
257+
258+
### .displayBoxBounds
259+
260+
```js
261+
displayBoxBounds = false : Boolean
262+
```
263+
264+
Display wireframe bounding boxes from the tiles `boundingVolume.box` (or derived from the region bounds) for every visible tile.
265+
266+
### .displaySphereBounds
267+
268+
```js
269+
displaySphereBounds = false : Boolean
270+
```
271+
272+
Display wireframe bounding boxes from the tiles `boundingVolume.sphere` (or derived from the bounding box / region bounds) for every visible tile.
273+
274+
### .displayRegionBounds
275+
276+
```js
277+
displayRegionBounds = false : Boolean
278+
```
279+
280+
Display wireframe bounding rgions from the tiles `boundingVolume.region` for every visible tile if it exists.
281+
282+
### .maxDebugDepth
283+
284+
```js
285+
maxDebugDepth = - 1 : Number
286+
```
287+
288+
The depth value that represents white when rendering with `DEPTH` or `RELATIVE_DEPTH` [colorMode](#colorMode). If `maxDebugDepth` is `-1` then the maximum depth of the tile set is used.
289+
290+
### .maxDebugError
291+
292+
```js
293+
maxDebugError = - 1 : Number
294+
```
295+
296+
The error value that represents white when rendering with `GEOMETRIC_ERROR` [colorMode](#colorMode). If `maxDebugError` is `-1` then the maximum geometric error in the tile set is used.
297+
298+
### .maxDebugDistance
299+
300+
```js
301+
maxDebugDistance = - 1 : Number
302+
```
303+
304+
The distance value that represents white when rendering with `DISTANCE` [colorMode](#colorMode). If `maxDebugDistance` is `-1` then the radius of the tile set is used.
305+
306+
### .getDebugColor
307+
308+
```js
309+
getDebugColor : ( val : Number, target : Color ) => void
310+
```
311+
312+
The function used to map a [0, 1] value to a color for debug visualizations. By default the color is mapped from black to white.
313+
201314
## GoogleCloudAuthPlugin
202315

203316
### constructor

README.md

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -565,120 +565,6 @@ dispose() : void
565565

566566
Disposes of all the tiles in the renderer. Calls dispose on all materials, textures, and geometries that were loaded by the renderer and subsequently calls [onDisposeModel](#onDisposeModel) for any loaded tile model.
567567

568-
## DebugTilesRenderer
569-
570-
_extends [TilesRenderer](#TilesRenderer)_
571-
572-
Special variant of TilesRenderer that includes helpers for debugging and visualizing the various tiles in the tile set. Material overrides will not work as expected with this renderer. The debug renderer includes additional logic and initialization code which can cause performance loss so it's recommended to only use this when needed.
573-
574-
### .colorMode
575-
576-
```js
577-
colorMode = NONE : ColorMode
578-
```
579-
580-
Which color mode to use when rendering the tile set. The following exported enumerations can be used:
581-
582-
```js
583-
// No special color mode. Uses the default materials.
584-
NONE
585-
586-
// Render the screenspace error from black to white with errorTarget
587-
// being the maximum value.
588-
SCREEN_ERROR
589-
590-
// Render the geometric error from black to white with maxDebugError
591-
// being the maximum value.
592-
GEOMETRIC_ERROR
593-
594-
// Render the distance from the camera to the tile as black to white
595-
// with maxDebugDistance being the maximum value.
596-
DISTANCE
597-
598-
// Render the depth of the tile relative to the root as black to white
599-
// with maxDebugDepth being the maximum value.
600-
DEPTH
601-
602-
// Render the depth of the tile relative to the nearest rendered parent
603-
// as black to white with maxDebugDepth being the maximum value.
604-
RELATIVE_DEPTH
605-
606-
// Render leaf nodes as white and parent nodes as black.
607-
IS_LEAF
608-
609-
// Render the tiles with a random color to show tile edges clearly.
610-
RANDOM_COLOR
611-
612-
// Render every individual mesh in the scene with a random color.
613-
RANDOM_NODE_COLOR
614-
615-
// Sets a custom color using the customColorCallback call back.
616-
CUSTOM_COLOR
617-
```
618-
### .customColorCallback
619-
620-
```js
621-
customColorCallback: (tile: Tile, child: Object3D) => void
622-
```
623-
624-
The callback used if `debugColor` is set to `CUSTOM_COLOR`. Value defaults to `null` and must be set explicitly.
625-
626-
### .displayBoxBounds
627-
628-
```js
629-
displayBoxBounds = false : Boolean
630-
```
631-
632-
Display wireframe bounding boxes from the tiles `boundingVolume.box` (or derived from the region bounds) for every visible tile.
633-
634-
### .displaySphereBounds
635-
636-
```js
637-
displaySphereBounds = false : Boolean
638-
```
639-
640-
Display wireframe bounding boxes from the tiles `boundingVolume.sphere` (or derived from the bounding box / region bounds) for every visible tile.
641-
642-
### .displayRegionBounds
643-
644-
```js
645-
displayRegionBounds = false : Boolean
646-
```
647-
648-
Display wireframe bounding rgions from the tiles `boundingVolume.region` for every visible tile if it exists.
649-
650-
### .maxDebugDepth
651-
652-
```js
653-
maxDebugDepth = - 1 : Number
654-
```
655-
656-
The depth value that represents white when rendering with `DEPTH` or `RELATIVE_DEPTH` [colorMode](#colorMode). If `maxDebugDepth` is `-1` then the maximum depth of the tile set is used.
657-
658-
### .maxDebugError
659-
660-
```js
661-
maxDebugError = - 1 : Number
662-
```
663-
664-
The error value that represents white when rendering with `GEOMETRIC_ERROR` [colorMode](#colorMode). If `maxDebugError` is `-1` then the maximum geometric error in the tile set is used.
665-
666-
### .maxDebugDistance
667-
668-
```js
669-
maxDebugDistance = - 1 : Number
670-
```
671-
672-
The distance value that represents white when rendering with `DISTANCE` [colorMode](#colorMode). If `maxDebugDistance` is `-1` then the radius of the tile set is used.
673-
674-
### .getDebugColor
675-
676-
```js
677-
getDebugColor : ( val : Number, target : Color ) => void
678-
```
679-
680-
The function used to map a [0, 1] value to a color for debug visualizations. By default the color is mapped from black to white.
681-
682568
## PriorityQueue
683569

684570
Piority-sorted queue to prioritize file downloads and parsing.

example/index.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {
2-
DebugTilesRenderer as TilesRenderer,
2+
TilesRenderer,
3+
DebugTilesPlugin,
4+
GLTFCesiumRTCExtension,
35
NONE,
46
SCREEN_ERROR,
57
GEOMETRIC_ERROR,
@@ -11,7 +13,6 @@ import {
1113
RANDOM_NODE_COLOR,
1214
CUSTOM_COLOR,
1315
LOAD_ORDER,
14-
GLTFCesiumRTCExtension,
1516
} from '../src/index.js';
1617
import {
1718
Scene,
@@ -95,6 +96,7 @@ function reinstantiateTiles() {
9596
}
9697

9798
tiles = new TilesRenderer( url );
99+
tiles.registerPlugin( new DebugTilesPlugin() );
98100

99101
// Note the DRACO compression files need to be supplied via an explicit source.
100102
// We use unpkg here but in practice should be provided by the application.
@@ -484,10 +486,13 @@ function animate() {
484486
tiles.stopAtEmptyTiles = params.stopAtEmptyTiles;
485487
tiles.displayActiveTiles = params.displayActiveTiles;
486488
tiles.maxDepth = params.maxDepth;
487-
tiles.displayBoxBounds = params.displayBoxBounds;
488-
tiles.displaySphereBounds = params.displaySphereBounds;
489-
tiles.displayRegionBounds = params.displayRegionBounds;
490-
tiles.colorMode = parseFloat( params.colorMode );
489+
490+
// update plugin
491+
const plugin = tiles.getPluginByName( 'DEBUG_TILES_PLUGIN' );
492+
plugin.displayBoxBounds = params.displayBoxBounds;
493+
plugin.displaySphereBounds = params.displaySphereBounds;
494+
plugin.displayRegionBounds = params.displayRegionBounds;
495+
plugin.colorMode = parseFloat( params.colorMode );
491496

492497
if ( params.orthographic ) {
493498

example/mars.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
2-
DebugTilesRenderer as TilesRenderer,
2+
TilesRenderer,
3+
DebugTilesPlugin,
34
} from '../src/index.js';
45
import {
56
Scene,
@@ -66,12 +67,14 @@ function init() {
6667
scene.add( tilesParent );
6768

6869
groundTiles = new TilesRenderer( 'https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize_tileset.json' );
70+
groundTiles.registerPlugin( new DebugTilesPlugin() );
6971
groundTiles.fetchOptions.mode = 'cors';
7072
groundTiles.lruCache.minSize = 900;
7173
groundTiles.lruCache.maxSize = 1300;
7274
groundTiles.errorTarget = 12;
7375

7476
skyTiles = new TilesRenderer( 'https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_sky/0528_0260184_to_s64o256_sky_tileset.json' );
77+
skyTiles.registerPlugin( new DebugTilesPlugin() );
7578
skyTiles.fetchOptions.mode = 'cors';
7679
skyTiles.lruCache = groundTiles.lruCache;
7780

@@ -109,8 +112,8 @@ function render() {
109112
camera.updateMatrixWorld();
110113

111114
groundTiles.errorTarget = params.errorTarget;
112-
groundTiles.displayBoxBounds = params.displayBoxBounds;
113-
skyTiles.displayBoxBounds = params.displayBoxBounds;
115+
groundTiles.getPluginByName( 'DEBUG_TILES_PLUGIN' ).displayBoxBounds = params.displayBoxBounds;
116+
skyTiles.getPluginByName( 'DEBUG_TILES_PLUGIN' ).displayBoxBounds = params.displayBoxBounds;
114117

115118
groundTiles.setCamera( camera );
116119
groundTiles.setResolutionFromRenderer( camera, renderer );

example/vr.js

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
import {
2-
DebugTilesRenderer as TilesRenderer,
3-
NONE,
4-
SCREEN_ERROR,
5-
GEOMETRIC_ERROR,
6-
DISTANCE,
7-
DEPTH,
8-
RELATIVE_DEPTH,
9-
IS_LEAF,
10-
RANDOM_COLOR,
11-
} from '../src/index.js';
1+
import { TilesRenderer } from '../src/index.js';
122
import {
133
Scene,
144
DirectionalLight,
@@ -47,8 +37,6 @@ const upVector = new Vector3( 0, 1, 0 );
4737

4838
const params = {
4939

50-
'displayBoxBounds': false,
51-
'colorMode': 0,
5240
'displayGrid': true,
5341

5442
};
@@ -174,19 +162,6 @@ function init() {
174162
const gui = new GUI();
175163
gui.width = 300;
176164
gui.add( params, 'displayGrid' );
177-
gui.add( params, 'displayBoxBounds' );
178-
gui.add( params, 'colorMode', {
179-
180-
NONE,
181-
SCREEN_ERROR,
182-
GEOMETRIC_ERROR,
183-
DISTANCE,
184-
DEPTH,
185-
RELATIVE_DEPTH,
186-
IS_LEAF,
187-
RANDOM_COLOR,
188-
189-
} );
190165
gui.open();
191166

192167
}
@@ -292,10 +267,6 @@ function animate() {
292267

293268
grid.visible = params.displayGrid;
294269

295-
// update options
296-
tiles.displayBoxBounds = params.displayBoxBounds;
297-
tiles.colorMode = parseFloat( params.colorMode );
298-
299270
// update tiles center
300271
if ( tiles.getBoundingBox( box ) ) {
301272

src/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// three.js
2-
export * from './three/DebugTilesRenderer';
2+
export { DebugTilesRenderer } from './three/DebugTilesRenderer';
33
export { TilesRenderer } from './three/TilesRenderer';
44
export { TilesGroup } from './three/TilesGroup';
55
export { B3DMLoader } from './three/loaders/B3DMLoader';
@@ -18,6 +18,7 @@ export * from './three/renderers/CesiumIonTilesRenderer';
1818
// three.js plugins
1919
export { CesiumIonAuthPlugin } from './three/plugins/CesiumIonAuthPlugin';
2020
export { GoogleCloudAuthPlugin } from './three/plugins/GoogleCloudAuthPlugin';
21+
export * from './three/plugins/DebugTilesPlugin';
2122

2223
// common
2324
export { TilesRendererBase } from './base/TilesRendererBase';

0 commit comments

Comments
 (0)