Skip to content
Open
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
32 changes: 30 additions & 2 deletions src/three/plugins/images/ImageOverlayPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ export class ImageOverlayPlugin {

_updateLayers( tile ) {

const { overlayInfo, overlays, tileControllers } = this;
const { overlayInfo, overlays, tileControllers, meshParams } = this;
const tileController = tileControllers.get( tile );

// by this point all targets should be present and we can force the memory to update
Expand All @@ -1148,6 +1148,34 @@ export class ImageOverlayPlugin {

}

// handle the case where all overlays have been removed - we need to reset
// the materials to have no layers
if ( overlays.length === 0 ) {

const scene = tile.engineData && tile.engineData.scene;
if ( scene ) {

scene.traverse( c => {

if ( c.material && meshParams.has( c ) ) {

const params = meshParams.get( c );
params.layerMaps.length = 0;
params.layerInfo.length = 0;

c.material.defines.LAYER_COUNT = 0;
c.material.needsUpdate = true;

}

} );

}

return;

}

// update the uvs and texture overlays for each mesh
overlays.forEach( ( overlay, i ) => {

Expand All @@ -1156,7 +1184,7 @@ export class ImageOverlayPlugin {
meshInfo.forEach( ( { attribute }, mesh ) => {

const { geometry, material } = mesh;
const params = this.meshParams.get( mesh );
const params = meshParams.get( mesh );

// assign the new uvs
const key = `layer_uv_${ i }`;
Expand Down