Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/core/renderer/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// common
export { TilesRendererBase } from './tiles/TilesRendererBase.js';
export { LoaderBase } from './loaders/LoaderBase.js';
export * from './tiles/TilesRendererBase.js';
export * from './loaders/LoaderBase.js';
export * from './loaders/B3DMLoaderBase.js';
export * from './loaders/I3DMLoaderBase.js';
export * from './loaders/PNTSLoaderBase.js';
export * from './loaders/CMPTLoaderBase.js';
export * from './constants.js';

export { LRUCache } from './utilities/LRUCache.js';
export * from './utilities/LRUCache.js';
export * from './utilities/PriorityQueue.js';
export * as TraversalUtils from './utilities/TraversalUtils.js';
export * as LoaderUtils from './utilities/LoaderUtils.js';
export { BatchTable } from './utilities/BatchTable.js';
export { FeatureTable } from './utilities/FeatureTable.js';
export { Scheduler } from './utilities/Scheduler.js';
export * from './utilities/BatchTable.js';
export * from './utilities/FeatureTable.js';
export * from './utilities/Scheduler.js';
2 changes: 1 addition & 1 deletion src/core/renderer/tiles/TilesRendererBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const lruPriorityCallback = ( a, b ) => {
// Unified priority callback for shared queues — delegates to the appropriate per-tile callback
// based on each tile's renderer settings. Falls back to errorPriorityCallback for cross-renderer
// comparisons or when renderer settings differ.
const unifiedPriorityCallback = ( a, b ) => {
export const unifiedPriorityCallback = ( a, b ) => {

// handle non-tile cases
const aPriority = a.priority ?? Infinity;
Expand Down
58 changes: 32 additions & 26 deletions src/three/plugins/images/ImageOverlayPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/** @import { WMTSTileMatrix } from './WMTSImageSource.js' */
/** @import { VectorTileStyle } from './utils/VectorShapeCanvasRenderer.js' */
import { Color, BufferAttribute, Matrix4, Vector3, Box3, Triangle, CanvasTexture } from 'three';
import { PriorityQueue, PriorityQueueItemRemovedError } from '3d-tiles-renderer/core';
import { PriorityQueue, PriorityQueueItemRemovedError, unifiedPriorityCallback } from '3d-tiles-renderer/core';
import { CesiumIonAuth, GoogleCloudAuth } from '3d-tiles-renderer/core/plugins';
import { XYZImageSource } from './sources/XYZImageSource.js';
import { QuadKeyImageSource } from './sources/QuadKeyImageSource.js';
Expand All @@ -28,6 +28,32 @@ const SPLIT_TILE_DATA = Symbol( 'SPLIT_TILE_DATA' );
const SPLIT_HASH = Symbol( 'SPLIT_HASH' );
const ORIGINAL_REFINE = Symbol( 'ORIGINAL_REFINE' );

const PROCESS_QUEUE = /* @__PURE__ */ new PriorityQueue();
PROCESS_QUEUE.maxJobs = 10;
PROCESS_QUEUE.priorityCallback = ( a, b ) => {

const tileA = a.tile;
const tileB = b.tile;

const rendererA = tileA.internal.renderer;
const rendererB = tileB.internal.renderer;

const visibleA = rendererA.visibleTiles.has( tileA );
const visibleB = rendererB.visibleTiles.has( tileB );
if ( visibleA !== visibleB ) {

// load visible tiles first
return visibleA ? 1 : - 1;

} else {

// the fallback to the download queue tile priority
return unifiedPriorityCallback( tileA, tileB );

}

};

/**
* Plugin that composites one or more tiled image overlays onto 3D tile geometry by
* generating per-tile textures from image sources (XYZ, TMS, WMTS, WMS, GeoJSON, etc.).
Expand Down Expand Up @@ -103,33 +129,11 @@ export class ImageOverlayPlugin {
init( tiles ) {

const tileComposer = new TiledTextureComposer();
const processQueue = new PriorityQueue();
processQueue.maxJobs = 10;
processQueue.priorityCallback = ( a, b ) => {

const tileA = a.tile;
const tileB = b.tile;

const visibleA = tiles.visibleTiles.has( tileA );
const visibleB = tiles.visibleTiles.has( tileB );
if ( visibleA !== visibleB ) {

// load visible tiles first
return visibleA ? 1 : - 1;

} else {

// the fallback to the download queue tile priority
return tiles.downloadQueue.priorityCallback( tileA, tileB );

}

};

// save variables
this.tiles = tiles;
this.tileComposer = tileComposer;
this.processQueue = processQueue;
this.processQueue = PROCESS_QUEUE;

// init all existing tiles
tiles.forEachLoadedModel( ( scene, tile ) => {
Expand Down Expand Up @@ -163,6 +167,7 @@ export class ImageOverlayPlugin {
// trigger redraws for visible tiles if overlays updated
if ( overlayChanged ) {

const { processQueue } = this;
const maxJobs = processQueue.maxJobs;
let count = 0;
processQueue.items.forEach( info => {
Expand Down Expand Up @@ -897,10 +902,11 @@ export class ImageOverlayPlugin {
overlayInfo.delete( overlay );
controller.abort();

// Remove any items that reference the overlay being disposed
// Remove any items that reference the overlay being disposed - we check if the tiles
// is in this "processedTiles" map since the queue can be shared among plugin instances.
processQueue.removeByFilter( item => {

return item.overlay === overlay;
return item.overlay === overlay && processedTiles.has( item.tile );

} );

Expand Down
Loading