Skip to content

Commit 14a533e

Browse files
authored
Add support for variable tiles splitting (#1447)
1 parent 6b448ee commit 14a533e

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/three/plugins/DebugTilesPlugin.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ export class DebugTilesPlugin {
223223

224224
this.tiles = tiles;
225225

226+
if ( ! this.enabled ) {
227+
228+
return;
229+
230+
}
231+
226232
// initialize groups
227233
const tilesGroup = tiles.group;
228234
this.boxGroup = new Group();

src/three/plugins/images/ImageFormatPlugin.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,12 @@ export class ImageFormatPlugin {
316316
const x = tile[ TILE_X ];
317317
const y = tile[ TILE_Y ];
318318

319-
for ( let cx = 0; cx < 2; cx ++ ) {
319+
const { tileSplitX, tileSplitY } = this.tiling.getLevel( level );
320+
for ( let cx = 0; cx < tileSplitX; cx ++ ) {
320321

321-
for ( let cy = 0; cy < 2; cy ++ ) {
322+
for ( let cy = 0; cy < tileSplitY; cy ++ ) {
322323

323-
const child = this.createChild( 2 * x + cx, 2 * y + cy, level + 1 );
324+
const child = this.createChild( tileSplitX * x + cx, tileSplitY * y + cy, level + 1 );
324325
if ( child ) {
325326

326327
tile.children.push( child );

src/three/plugins/images/utils/TilingScheme.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,16 @@ export class TilingScheme {
8585

8686
}
8787

88+
const {
89+
tileSplitX = 2,
90+
tileSplitY = 2,
91+
} = options;
92+
8893
const {
8994
tilePixelWidth = 256,
9095
tilePixelHeight = 256,
91-
tileCountX = 2 ** level,
92-
tileCountY = 2 ** level,
96+
tileCountX = tileSplitX ** level,
97+
tileCountY = tileSplitY ** level,
9398
tileBounds = null,
9499
} = options;
95100

@@ -112,6 +117,10 @@ export class TilingScheme {
112117
tileCountX,
113118
tileCountY,
114119

120+
// The number of tiles that the tiles at this layer split in to
121+
tileSplitX,
122+
tileSplitY,
123+
115124
// The bounds covered by the extent of the tiles at this loaded. The actual content covered by the overall tileset
116125
// may be a subset of this range (eg there may be unused space).
117126
tileBounds,

0 commit comments

Comments
 (0)