Skip to content

Commit

Permalink
feature(ColorLayer): add option to filtering textures Layer.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchoqueux committed May 12, 2021
1 parent bdf50ab commit da245f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Converter/textureConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import CRS from 'Core/Geographic/Crs';

const extentTexture = new Extent('EPSG:4326', [0, 0, 0, 0]);

const textureLayer = (texture) => {
const textureLayer = (texture, layer) => {
texture.generateMipmaps = false;
texture.magFilter = THREE.LinearFilter;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = layer.magFilter || THREE.LinearFilter;
texture.minFilter = layer.minFilter || THREE.LinearFilter;
return texture;
};

function textureColorLayer(texture, transparent) {
function textureColorLayer(texture, layer) {
texture.anisotropy = 16;
texture.premultiplyAlpha = transparent;
return textureLayer(texture);
texture.premultiplyAlpha = layer.transparent;
return textureLayer(texture, layer);
}

export default {
Expand All @@ -38,15 +38,15 @@ export default {
}

if (layer.isColorLayer) {
return textureColorLayer(texture, layer.transparent);
return textureColorLayer(texture, layer);
} else if (layer.isElevationLayer) {
if (texture.flipY) {
// DataTexture default to false, so make sure other Texture types
// do the same (eg image texture)
// See UV construction for more details
texture.flipY = false;
}
return textureLayer(texture);
return textureLayer(texture, layer);
}
},
};
2 changes: 2 additions & 0 deletions src/Layer/ColorLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class ColorLayer extends RasterLayer {
* available using `layer.name` or something else depending on the property
* name.
* @param {Source} [config.source] - Description and options of the source.
* @param {number} [config.magFilter] - How the texture is sampled when a texel covers more than one pixel. [see](https://threejs.org/docs/?q=texture#api/en/textures/Texture.magFilter)
* @param {number} [config.minFilter] - How the texture is sampled when a texel covers less than one pixel. [see](https://threejs.org/docs/?q=texture#api/en/textures/Texture.minFilter)
*
* @example
* // Create a ColorLayer
Expand Down

0 comments on commit da245f9

Please sign in to comment.