Skip to content

Commit

Permalink
Fade cleanup (#898)
Browse files Browse the repository at this point in the history
* Rearrange functions

* clean up

* More cleanup

* rearrangement

* batch tiles plugin rename

* Updates

* comment

* Add display for batched mesh instances

* Fix frustum addition

* Small updates
  • Loading branch information
gkjohnson authored Dec 25, 2024
1 parent 2baf3ef commit dae7c32
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 147 deletions.
22 changes: 22 additions & 0 deletions example/googleMapsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,28 @@ function updateHtml() {
const programCount = renderer.info.programs.length;
str += `Geometries: ${ memory.geometries } Textures: ${ memory.textures } Programs: ${ programCount } Draw Calls: ${ render.calls }`;

const batchPlugin = tiles.getPluginByName( 'BATCHED_TILES_PLUGIN' );
const fadePlugin = tiles.getPluginByName( 'FADE_TILES_PLUGIN' );
if ( batchPlugin ) {

let tot = 0;
let totFade = 0;
batchPlugin.batchedMesh._instanceInfo.forEach( info => {

if ( info.visible && info.active ) tot ++;

} );

fadePlugin.batchedMesh._instanceInfo.forEach( info => {

if ( info.visible && info.active ) totFade ++;

} );

str += ', Batched: ' + tot + ', Fade Batched: ' + totFade;

}

}

if ( statsContainer.innerHTML !== str ) {
Expand Down
8 changes: 7 additions & 1 deletion example/src/plugins/batched/BatchedTilesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class BatchedTilesPlugin {
...options
};

this.name = 'BATCHED_MESH_PLUGIN';
this.name = 'BATCHED_TILES_PLUGIN';
this.priority = - 1;

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

}

getTileBatchIds( tile ) {

return this._tileToInstanceId.get( tile );

}

}
7 changes: 6 additions & 1 deletion src/plugins/three/fade/FadeBatchedMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { PassThroughBatchedMesh } from './PassThroughBatchedMesh.js';
import { RGFormat, UnsignedByteType, DataTexture } from 'three';
import { wrapFadeMaterial } from './wrapFadeMaterial.js';

// BatchedMesh instance that can fade materials
export class FadeBatchedMesh extends PassThroughBatchedMesh {

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

this.fadeTexture.dispose();
if ( this.fadeTexture ) {

this.fadeTexture.dispose();

}

}

Expand Down
Loading

0 comments on commit dae7c32

Please sign in to comment.