diff --git a/src/Converter/convertToTile.js b/src/Converter/convertToTile.js index 5791761ca9..fc503ceb67 100644 --- a/src/Converter/convertToTile.js +++ b/src/Converter/convertToTile.js @@ -78,7 +78,7 @@ export default { tile.geoidHeight = parent.geoidHeight; const geoidHeight = geoidLayerIsVisible(layer) ? tile.geoidHeight : 0; tile.setBBoxZ({ min: parent.obb.z.min, max: parent.obb.z.max, geoidHeight }); - tile.material.geoidHeight = geoidHeight; + tile.material.setUniform('geoidHeight', geoidHeight); } return tile; diff --git a/src/Layer/GeoidLayer.js b/src/Layer/GeoidLayer.js index 8d37cab8b3..a7e61d6161 100644 --- a/src/Layer/GeoidLayer.js +++ b/src/Layer/GeoidLayer.js @@ -44,8 +44,8 @@ class GeoidLayer extends Layer { } updateNodeZ(node) { - node.material.geoidHeight = this.visible ? node.geoidHeight : 0; - node.obb.updateZ({ geoidHeight: node.material.geoidHeight }); + node.material.setUniform('geoidHeight', this.visible ? node.geoidHeight : 0); + node.obb.updateZ({ geoidHeight: node.material.getUniform('geoidHeight') }); } update(context, layer, node, parent) { diff --git a/src/Renderer/ColorLayersOrdering.js b/src/Renderer/ColorLayersOrdering.js index f91955d278..639788ac8a 100644 --- a/src/Renderer/ColorLayersOrdering.js +++ b/src/Renderer/ColorLayersOrdering.js @@ -3,8 +3,8 @@ import { ImageryLayers } from 'Layer/Layer'; function updateLayersOrdering(geometryLayer, imageryLayers) { const sequence = ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers); const cO = function cO(object) { - if (object.material?.setSequence) { - object.material.setSequence(sequence); + if (object.material?.setColorLayerIds) { + object.material.setColorLayerIds(sequence); } }; @@ -38,7 +38,8 @@ export default { const previousSequence = ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers); ImageryLayers.moveLayerUp(layer, imageryLayers); updateLayersOrdering(view.tileLayer, imageryLayers); - view.dispatchEvent({ type: COLOR_LAYERS_ORDER_CHANGED, + view.dispatchEvent({ + type: COLOR_LAYERS_ORDER_CHANGED, previous: { sequence: previousSequence }, new: { sequence: ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers) }, }); @@ -64,7 +65,8 @@ export default { const previousSequence = ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers); ImageryLayers.moveLayerDown(layer, imageryLayers); updateLayersOrdering(view.tileLayer, imageryLayers); - view.dispatchEvent({ type: COLOR_LAYERS_ORDER_CHANGED, + view.dispatchEvent({ + type: COLOR_LAYERS_ORDER_CHANGED, previous: { sequence: previousSequence }, new: { sequence: ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers) }, }); @@ -91,7 +93,8 @@ export default { const previousSequence = ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers); ImageryLayers.moveLayerToIndex(layer, index, imageryLayers); updateLayersOrdering(view.tileLayer, imageryLayers); - view.dispatchEvent({ type: COLOR_LAYERS_ORDER_CHANGED, + view.dispatchEvent({ + type: COLOR_LAYERS_ORDER_CHANGED, previous: { sequence: previousSequence }, new: { sequence: ImageryLayers.getColorLayersIdOrderedBySequence(imageryLayers) }, }); diff --git a/src/Renderer/LayeredMaterial.ts b/src/Renderer/LayeredMaterial.ts index 1fcbb25df0..03edc41b76 100644 --- a/src/Renderer/LayeredMaterial.ts +++ b/src/Renderer/LayeredMaterial.ts @@ -359,6 +359,8 @@ export class LayeredMaterial extends THREE.ShaderMaterial { } }, }); + + // setTimeout(() => console.log(this), 2); } public get mode(): number { @@ -533,4 +535,16 @@ export class LayeredMaterial extends THREE.ShaderMaterial { return this.elevationTile?.id === id ? this.elevationTile : this.colorTiles.find(l => l.id === id); } + + public getLayers(ids: string[]): RasterTile[] { + // NOTE: this could instead be a mapping with an undefined in place of + // unfound IDs. Need to identify a use case for it though as it would + // probably have a performance cost (albeit minor in the grand scheme of + // things). + const res: RasterTile[] = this.colorTiles.filter(l => ids.includes(l.id)); + if (this.elevationTile !== undefined && ids.includes(this.elevationTile?.id)) { + res.push(this.elevationTile); + } + return res; + } }