Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
HoloTheDrunk committed Jan 7, 2025
1 parent c46772f commit 9149811
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Converter/convertToTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Layer/GeoidLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
13 changes: 8 additions & 5 deletions src/Renderer/ColorLayersOrdering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down Expand Up @@ -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) },
});
Expand All @@ -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) },
});
Expand All @@ -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) },
});
Expand Down
14 changes: 14 additions & 0 deletions src/Renderer/LayeredMaterial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ export class LayeredMaterial extends THREE.ShaderMaterial {
}
},
});

// setTimeout(() => console.log(this), 2);
}

public get mode(): number {
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 9149811

Please sign in to comment.