Skip to content

Commit dae7c32

Browse files
authored
Fade cleanup (#898)
* Rearrange functions * clean up * More cleanup * rearrangement * batch tiles plugin rename * Updates * comment * Add display for batched mesh instances * Fix frustum addition * Small updates
1 parent 2baf3ef commit dae7c32

File tree

4 files changed

+196
-147
lines changed

4 files changed

+196
-147
lines changed

example/googleMapsExample.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,28 @@ function updateHtml() {
349349
const programCount = renderer.info.programs.length;
350350
str += `Geometries: ${ memory.geometries } Textures: ${ memory.textures } Programs: ${ programCount } Draw Calls: ${ render.calls }`;
351351

352+
const batchPlugin = tiles.getPluginByName( 'BATCHED_TILES_PLUGIN' );
353+
const fadePlugin = tiles.getPluginByName( 'FADE_TILES_PLUGIN' );
354+
if ( batchPlugin ) {
355+
356+
let tot = 0;
357+
let totFade = 0;
358+
batchPlugin.batchedMesh._instanceInfo.forEach( info => {
359+
360+
if ( info.visible && info.active ) tot ++;
361+
362+
} );
363+
364+
fadePlugin.batchedMesh._instanceInfo.forEach( info => {
365+
366+
if ( info.visible && info.active ) totFade ++;
367+
368+
} );
369+
370+
str += ', Batched: ' + tot + ', Fade Batched: ' + totFade;
371+
372+
}
373+
352374
}
353375

354376
if ( statsContainer.innerHTML !== str ) {

example/src/plugins/batched/BatchedTilesPlugin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class BatchedTilesPlugin {
3030
...options
3131
};
3232

33-
this.name = 'BATCHED_MESH_PLUGIN';
33+
this.name = 'BATCHED_TILES_PLUGIN';
3434
this.priority = - 1;
3535

3636
// limit the amount of instances to the size of a 3d texture to avoid over flowing the
@@ -388,4 +388,10 @@ export class BatchedTilesPlugin {
388388

389389
}
390390

391+
getTileBatchIds( tile ) {
392+
393+
return this._tileToInstanceId.get( tile );
394+
395+
}
396+
391397
}

src/plugins/three/fade/FadeBatchedMesh.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { PassThroughBatchedMesh } from './PassThroughBatchedMesh.js';
22
import { RGFormat, UnsignedByteType, DataTexture } from 'three';
33
import { wrapFadeMaterial } from './wrapFadeMaterial.js';
44

5+
// BatchedMesh instance that can fade materials
56
export class FadeBatchedMesh extends PassThroughBatchedMesh {
67

78
constructor( ...args ) {
@@ -68,7 +69,11 @@ export class FadeBatchedMesh extends PassThroughBatchedMesh {
6869
// dispose the fade texture. Super cannot be used here due to proxy
6970
dispose() {
7071

71-
this.fadeTexture.dispose();
72+
if ( this.fadeTexture ) {
73+
74+
this.fadeTexture.dispose();
75+
76+
}
7277

7378
}
7479

0 commit comments

Comments
 (0)