Skip to content

Commit e96d62f

Browse files
committed
Add notes and warnings
1 parent daf5048 commit e96d62f

8 files changed

Lines changed: 118 additions & 18 deletions

File tree

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export default [
110110
},
111111
settings: {
112112
jsdoc: {
113+
definedTags: [ 'warn', 'note' ],
113114
preferredTypes: {
114115
Any: 'any',
115116
Boolean: 'boolean',

src/core/renderer/tiles/TilesRendererBase.js

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -445,24 +445,28 @@ export class TilesRendererBase {
445445

446446
/**
447447
* LRU cache managing loaded tile lifecycle and memory eviction.
448+
* @note Cannot be replaced once `update()` has been called for the first time.
448449
* @type {LRUCache}
449450
*/
450451
this.lruCache = lruCache;
451452

452453
/**
453-
* Priority queue controlling concurrent tile downloads.
454+
* Priority queue controlling concurrent tile downloads. Max jobs defaults to `25`.
455+
* @note Cannot be replaced once `update()` has been called for the first time.
454456
* @type {PriorityQueue}
455457
*/
456458
this.downloadQueue = downloadQueue;
457459

458460
/**
459-
* Priority queue controlling concurrent tile parsing.
461+
* Priority queue controlling concurrent tile parsing. Max jobs defaults to `5`.
462+
* @note Cannot be modified once `update()` has been called for the first time.
460463
* @type {PriorityQueue}
461464
*/
462465
this.parseQueue = parseQueue;
463466

464467
/**
465-
* Priority queue controlling deferred tile child preprocessing.
468+
* Priority queue for expanding and initializing tiles for traversal. Max jobs defaults to `25`.
469+
* @note Cannot be replaced once `update()` has been called for the first time.
466470
* @type {PriorityQueue}
467471
*/
468472
this.processNodeQueue = processNodeQueue;
@@ -510,15 +514,21 @@ export class TilesRendererBase {
510514
// options
511515

512516
/**
513-
* Target screen-space error in pixels. Tiles with a higher SSE are subdivided.
517+
* Target screen-space error in pixels to aim for when updating the geometry. Tiles will
518+
* not render if they are below this level of screen-space error. See the
519+
* [geometric error section](https://github.com/CesiumGS/3d-tiles/tree/master/specification#geometric-error)
520+
* of the 3D Tiles specification for more information.
514521
* @type {number}
515522
*/
516523
this.errorTarget = 16.0;
517524
this._errorThreshold = Infinity;
518525

519526
/**
520-
* If true, tiles are displayed at their current LOD while waiting for higher-detail
521-
* children to finish loading, rather than hiding them.
527+
* "Active tiles" are those that are loaded and available but not necessarily visible.
528+
* These tiles are useful for raycasting off-camera or for casting shadows. Active tiles
529+
* not currently in a camera frustum are removed from the scene as an optimization.
530+
* Setting this to `true` keeps them in the scene so they can be rendered from an outside
531+
* camera view not accounted for by the tiles renderer.
522532
* @type {boolean}
523533
*/
524534
this.displayActiveTiles = false;
@@ -530,20 +540,38 @@ export class TilesRendererBase {
530540
this.maxDepth = Infinity;
531541

532542
/**
533-
* If true, uses an optimized traversal strategy that prioritizes distance over error.
543+
* **Experimental.** Enables an optimized tile loading strategy that loads only the tiles
544+
* needed for the current view, reducing memory usage and improving initial load times.
545+
* Tiles are loaded independently based on screen-space error without requiring all parent
546+
* tiles to load first. Prevents visual gaps and flashing during camera movement.
547+
*
548+
* Based in part on [Cesium Native tile selection](https://cesium.com/learn/cesium-native/ref-doc/selection-algorithm-details.html).
549+
*
550+
* Default is `false`, which uses the previous approach of loading all parent and sibling
551+
* tiles for guaranteed smooth transitions.
552+
* @warn Setting is currently incompatible with plugins that split tiles and on-the-fly generate and
553+
* dispose of child tiles including the `ImageOverlayPlugin` `enableTileSplitting` setting,
554+
* `QuantizedMeshPlugin`, & `ImageFormatPlugin` subclasses (XYZ, TMS, etc). Any tile sets
555+
* that share caches or queues must also use the same setting.
534556
* @type {boolean}
535557
*/
536558
this.optimizedLoadStrategy = false;
537559

538560
/**
539-
* If true, sibling tiles of visible tiles are also loaded to reduce pop-in during camera movement.
561+
* **Experimental.** When `true`, sibling tiles are loaded together to prevent gaps during
562+
* camera movement. When `false`, only visible tiles are loaded, minimizing memory but
563+
* potentially causing brief gaps during rapid movement.
564+
*
565+
* Only applies when `optimizedLoadStrategy` is enabled.
540566
* @type {boolean}
541567
*/
542568
this.loadSiblings = true;
543569

544570
/**
545-
* Maximum number of tile children to preprocess per `update` call. Excess tiles are deferred
546-
* to `processNodeQueue`.
571+
* The number of tiles to process immediately when traversing the tile set to determine
572+
* what to render. Lower numbers prevent frame hiccups caused by processing too many tiles
573+
* at once when a new tile set is available, while higher values process more tiles
574+
* immediately so data can be downloaded and displayed sooner.
547575
* @type {number}
548576
*/
549577
this.maxTilesProcessed = 250;

src/core/renderer/utilities/BatchTable.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ export class BatchTable extends FeatureTable {
6767
}
6868

6969
/**
70-
* Returns all batch table properties for the given feature id as an object.
70+
* Returns an object with all properties of the batch table and its extensions for the
71+
* given feature id. A `target` object can be specified to store the result. Throws if
72+
* `id` is out of bounds.
7173
* @param {number} id - Feature index (0 to count - 1)
7274
* @param {Object} [target={}] - Optional object to write properties into
7375
* @returns {Object}
@@ -104,9 +106,10 @@ export class BatchTable extends FeatureTable {
104106
}
105107

106108
/**
107-
* Returns the full typed array of values for the given property key across all features.
109+
* Returns the array of values for the given property key across all features. Returns
110+
* `null` if the key is not in the table.
108111
* @param {string} key
109-
* @returns {number | string | ArrayBufferView}
112+
* @returns {Array | TypedArray | null}
110113
*/
111114
getPropertyArray( key ) {
112115

src/core/renderer/utilities/LRUCache.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ class LRUCache {
6969

7070
/**
7171
* Minimum total bytes to retain after eviction.
72+
* @note Only works with three.js r166 or higher.
7273
* @type {number}
7374
*/
7475
this.minBytesSize = 0.3 * GIGABYTE_BYTES;
7576

7677
/**
7778
* Maximum total bytes before eviction is triggered.
79+
* @note Only works with three.js r166 or higher.
7880
* @type {number}
7981
*/
8082
this.maxBytesSize = 0.4 * GIGABYTE_BYTES;

src/core/renderer/utilities/PriorityQueue.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ export class PriorityQueue {
7979
this.priorityCallback = null;
8080

8181
/**
82-
* Callback used to schedule a deferred job run. Defaults to `requestAnimationFrame`.
82+
* Callback used to schedule when to run jobs next, so more work doesn't happen in a
83+
* single frame than there is time for. Defaults to `requestAnimationFrame`. Should be
84+
* overridden in scenarios where `requestAnimationFrame` is not reliable, such as when
85+
* running in WebXR.
8386
* @type {SchedulingCallback}
8487
*/
8588
this.schedulingCallback = func => {

src/three/plugins/batched/BatchedTilesPlugin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ _whiteTex.needsUpdate = true;
1313
* and optimized as new geometry is added and removed. Note that the `renderer` field is
1414
* required. Requires Three.js r170 or later.
1515
*
16-
* **Warning:** All tile geometry rendered with `BatchedMesh` will use the same material and
17-
* only a single material map is supported. Only tile geometry containing a single mesh is
18-
* supported. Not compatible with plugins that modify mesh materials or rely on bespoke mesh
19-
* data (e.g. `TilesFadePlugin`, `DebugTilesPlugin`, GLTF Metadata extensions).
16+
* @warn All tile geometry rendered with `BatchedMesh` will use the same material and only a single
17+
* material map is supported. Only tile geometry containing a single mesh is supported. Not
18+
* compatible with plugins that modify mesh materials or rely on bespoke mesh data (e.g.
19+
* `TilesFadePlugin`, `DebugTilesPlugin`, GLTF Metadata extensions).
2020
* @param {Object} options
2121
* @param {WebGLRenderer} options.renderer The renderer used to generate a `WebGLArrayRenderTarget`.
2222
* @param {number} [options.instanceCount=500] Initial number of instances in the batched mesh.

src/three/renderer/tiles/TilesRenderer.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,19 @@ function updateFrustumCulled( object, toInitialValue ) {
4242

4343
}
4444

45+
/**
46+
* Three.js implementation of a 3D Tiles renderer. Extends `TilesRendererBase` with
47+
* camera management, three.js scene integration, and GPU-accelerated tile loading.
48+
* Add `tiles.group` to your scene and call `tiles.update()` each frame.
49+
*/
4550
export class TilesRenderer extends TilesRendererBase {
4651

52+
/**
53+
* If `true`, all tile meshes automatically have `frustumCulled` set to `false` since the
54+
* tiles renderer performs its own frustum culling. If `displayActiveTiles` is `true` or
55+
* multiple cameras are being used, consider setting this to `false`.
56+
* @type {boolean}
57+
*/
4758
get autoDisableRendererCulling() {
4859

4960
return this._autoDisableRendererCulling;
@@ -81,7 +92,21 @@ export class TilesRenderer extends TilesRendererBase {
8192
constructor( ...args ) {
8293

8394
super( ...args );
95+
96+
/**
97+
* The container `Group` for the 3D tiles. Add this to the three.js scene. The group
98+
* also exposes a `matrixWorldInverse` field for transforming objects into the local
99+
* tileset frame.
100+
* @type {Group}
101+
*/
84102
this.group = new TilesGroup( this );
103+
104+
/**
105+
* The ellipsoid definition used for the tileset. Defaults to WGS84 and may be
106+
* overridden by the `3DTILES_ellipsoid` extension. Specified in the local frame of
107+
* `TilesRenderer.group`.
108+
* @type {Ellipsoid}
109+
*/
85110
this.ellipsoid = WGS84_ELLIPSOID.clone();
86111
this.cameras = [];
87112
this.cameraMap = new Map();
@@ -93,6 +118,10 @@ export class TilesRenderer extends TilesRendererBase {
93118
// flag indicating whether frustum culling should be disabled
94119
this._autoDisableRendererCulling = true;
95120

121+
/**
122+
* The `LoadingManager` used when loading tile geometry.
123+
* @type {LoadingManager}
124+
*/
96125
this.manager = new LoadingManager();
97126

98127
// saved for event dispatcher functions

utils/docs/RenderDocsUtils.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
// Renders any @warn / @note custom tags from a doclet as GFM alert blocks.
2+
function renderAlertTags( doc ) {
3+
4+
const lines = [];
5+
for ( const tag of ( doc.tags || [] ) ) {
6+
7+
if ( tag.title === 'warn' || tag.title === 'note' ) {
8+
9+
const type = tag.title === 'warn' ? 'WARN' : 'NOTE';
10+
lines.push( `> [!${ type }]` );
11+
for ( const line of tag.value.split( '\n' ) ) {
12+
13+
lines.push( `> ${ line }` );
14+
15+
}
16+
17+
lines.push( '' );
18+
19+
}
20+
21+
}
22+
23+
return lines.join( '\n' );
24+
25+
}
26+
127
// Converts a heading name to its GitHub Markdown anchor id.
228
export function toAnchor( name ) {
329

@@ -147,6 +173,8 @@ export function renderMember( doc, callbackMap = {} ) {
147173

148174
}
149175

176+
lines.push( renderAlertTags( doc ) );
177+
150178
return lines.join( '\n' );
151179

152180
}
@@ -195,6 +223,8 @@ export function renderMethod( doc, callbackMap = {} ) {
195223

196224
}
197225

226+
lines.push( renderAlertTags( doc ) );
227+
198228
return lines.join( '\n' );
199229

200230
}
@@ -256,6 +286,8 @@ export function renderTypedef( typeDoc, callbackMap = {}, resolveLink = null ) {
256286

257287
}
258288

289+
lines.push( renderAlertTags( typeDoc ) );
290+
259291
for ( const prop of ( typeDoc.properties || [] ) ) {
260292

261293
const type = formatType( prop.type, callbackMap );
@@ -421,6 +453,8 @@ export function renderClass( classDoc, members, callbackMap = {}, resolveLink =
421453

422454
}
423455

456+
lines.push( renderAlertTags( classDoc ) );
457+
424458
const visible = members.filter( m => m.access !== 'private' );
425459
// Treat function doclets that carry an explicit @type tag as properties
426460
// (e.g. arrow-function assignments like `this.schedulingCallback = func => ...`)

0 commit comments

Comments
 (0)