Skip to content

Commit

Permalink
Merge pull request #1303 from swisstopo/GSNGM-1166_fix_voxel_filtering
Browse files Browse the repository at this point in the history
Fix simple voxel filtering
  • Loading branch information
vladyslav-tk authored Jun 13, 2024
2 parents 8f4ea93 + 10b0a12 commit d9baa6c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
8 changes: 0 additions & 8 deletions ui/src/elements/ngm-voxel-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,6 @@ export class NgmVoxelFilter extends LitElementI18n {
shader.setUniform('u_filter_operator', parseInt(operator.value, 10));
shader.setUniform('u_filter_include_undefined_conductivity', this.includeUndefinedConductivity.checked);

console.log({
u_filter_conductivity_min: this.minConductivity,
u_filter_conductivity_max: this.maxConductivity,
u_filter_operator: operator.value,
u_filter_selected_lithology: lithologyInclude,
u_filter_include_undefined_conductivity: this.includeUndefinedConductivity.checked,
});

this.viewer.scene.requestRender();
}

Expand Down
22 changes: 10 additions & 12 deletions ui/src/elements/ngm-voxel-simple-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {LayerConfig} from '../layertree';
@customElement('ngm-voxel-simple-filter')
export class NgmVoxelSimpleFilter extends LitElementI18n {
@property({type: Object})
accessor config!: LayerConfig;
accessor config: LayerConfig | undefined;
@property({type: Object})
accessor viewer!: Viewer;

Expand All @@ -31,13 +31,16 @@ export class NgmVoxelSimpleFilter extends LitElementI18n {
}

willUpdate() {
this.minInitialValue = this.minValue = this.config.voxelColors!.range[0];
this.maxInitialValue = this.maxValue = this.config.voxelColors!.range[1];
if (this.config) {
this.minInitialValue = this.minValue = this.config.voxelColors!.range[0];
this.maxInitialValue = this.maxValue = this.config.voxelColors!.range[1];
}

this.hidden = false;
}

render() {
if (!this.config) return;
return html`
<div class="ngm-floating-window-header drag-handle">
${i18next.t('vox_filter_filtering_on')} ${i18next.t(this.config.label)}
Expand Down Expand Up @@ -88,21 +91,16 @@ export class NgmVoxelSimpleFilter extends LitElementI18n {

applyFilter() {
const shader = getVoxelShader(this.config);
shader.setUniform('u_filter_min', this.minValue);
shader.setUniform('u_filter_max', this.maxValue);

console.log({
u_filter_min: this.minValue,
u_filter_max: this.maxValue,
});
shader.setUniform('u_min', this.minValue);
shader.setUniform('u_max', this.maxValue);

this.viewer.scene.requestRender();
}

resetShader() {
const shader = getVoxelShader(this.config);
shader.setUniform('u_filter_min', this.minInitialValue);
shader.setUniform('u_filter_max', this.maxInitialValue);
shader.setUniform('u_min', this.minInitialValue);
shader.setUniform('u_max', this.maxInitialValue);
this.viewer.scene.requestRender();
}

Expand Down
1 change: 0 additions & 1 deletion ui/src/layers/voxels-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ function createColorIndex(colors: string[]): ColorConfig {
}

const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
console.log(canvas.toDataURL());
return {
image: new Uint8Array(imageData.data.buffer),
width: canvas.width,
Expand Down

0 comments on commit d9baa6c

Please sign in to comment.