Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fade cleanup #898

Merged
merged 10 commits into from
Dec 25, 2024
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
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
Loading