How to use the LinearFilter function from three
Find comprehensive JavaScript three.LinearFilter code examples handpicked from public code repositorys.
three.LinearFilter is a type of texture filtering used in Three.js that takes the four nearest texels and linearly interpolates between them to determine the pixel color.
118 119 120 121 122 123 124 125 126 127
image.onload = function () { material.map = texture; texture.image = image; texture.flipY = false; texture.minFilter = THREE.LinearFilter; texture.needsUpdate = true; material.needsUpdate = true; finish(); };
52 53 54 55 56 57 58 59 60
texture.format = THREE.RedFormat; texture.type = typedArrayToThree(config.volume.data.constructor); texture.generateMipmaps = false; texture.minFilter = THREE.LinearFilter; texture.magFilter = THREE.LinearFilter; texture.wrapT = THREE.ClampToEdgeWrapping; texture.wrapS = THREE.ClampToEdgeWrapping; texture.needsUpdate = true;
+ 3 other calls in file
How does three.LinearFilter work?
three.LinearFilter is a type of texture filtering method used in three.js, where texels (texture pixels) are interpolated using linear interpolation to determine the color of the pixel at the sampling point, producing a smooth texture image. This filtering method is optimized for textures that are displayed smaller or larger than their actual size.
GitHub: K3D-tools/K3D-jupyter
72 73 74 75 76 77 78 79 80 81
64, 64, THREE.RedFormat, THREE.UnsignedByteType, ); jitterTexture.minFilter = THREE.LinearFilter; jitterTexture.magFilter = THREE.LinearFilter; jitterTexture.wrapS = THREE.MirroredRepeatWrapping; jitterTexture.wrapT = THREE.MirroredRepeatWrapping; jitterTexture.generateMipmaps = false;
+ 7 other calls in file
GitHub: tentone/geo-three
84 85 86 87 88 89 90 91 92 93
const context = canvas.getContext('2d'); context.fillStyle = color; context.fillRect(0, 0, width, height); const texture = new three.Texture(canvas); texture.format = three.RGBAFormat; texture.magFilter = three.LinearFilter; texture.minFilter = three.LinearFilter; texture.generateMipmaps = false; texture.needsUpdate = true; return texture;
+ 7 other calls in file
Ai Example
1 2 3 4 5
// create a texture object and load an image const texture = new THREE.TextureLoader().load("texture.jpg"); // set the magnification filter to linear interpolation texture.magFilter = THREE.LinearFilter;
In this example, THREE.LinearFilter is assigned to the magFilter property of the texture object to specify that linear interpolation should be used when magnifying the texture.
180 181 182 183 184 185 186 187 188 189
internal.canvasdata.data[3]=0.0; //background transparent internal.canvas.getContext("2d").putImageData(internal.canvasdata,0,0); internal.cmtexture = new THREE.Texture(internal.canvas); internal.cmtexture.flipY=false; internal.cmtexture.needsUpdate = true; internal.cmtexture.minFilter = internal.cmtexture.magFilter = THREE.LinearFilter; // Material Properties
GitHub: mattdesl/filmic-gl
136 137 138 139 140 141 142 143 144
fragmentShader: fxaaShader.fragment }); var lookupTexture = THREE.ImageUtils.loadTexture("img/lookup_film.png"); lookupTexture.genMipmaps = false; lookupTexture.minFilter = THREE.LinearFilter; lookupTexture.magFilter = THREE.LinearFilter; lookupTexture.wrapS = THREE.ClampToEdgeWrapping; lookupTexture.wrapT = THREE.ClampToEdgeWrapping;
+ 3 other calls in file
GitHub: mattdesl/xmas
21 22 23 24 25 26 27 28 29 30
nrm.minFilter = nrm.magFilter = THREE.LinearFilter nrm.generateMipmaps = false var tex = THREE.ImageUtils.loadTexture(matCapUrl) //mcap1, mcap4 tex.wrapS = tex.wrapT = THREE.ClampToEdgeWrapping tex.minFilter = tex.magFilter = THREE.LinearFilter tex.generateMipmaps = false var mat = material(tex, nrm, reflectionCube, 1.0) var capMat = material(tex, nrm, reflectionCube, 0.0)
+ 7 other calls in file
GitHub: peter-hutsul/h5tiny
0 1 2 3 4 5 6 7 8 9 10
var THREE = require("three"), Sprite = THREE.Sprite, SpriteMaterial = THREE.SpriteMaterial, CanvasTexture = THREE.CanvasTexture, sRGBEncoding = THREE.sRGBEncoding, LinearFilter = THREE.LinearFilter; class Canvas2D extends Sprite { constructor(width, height) { const renderer = new Tiny.CanvasRenderer(width, height, { transparent: true });
1798 1799 1800 1801 1802 1803 1804 1805 1806 1807
var samplers = json.samplers || {}; var sampler = samplers[textureDef.sampler] || {}; texture.magFilter = WEBGL_FILTERS[sampler.magFilter] || THREE.LinearFilter; texture.minFilter = WEBGL_FILTERS[sampler.minFilter] || THREE.LinearMipmapLinearFilter; texture.wrapS = WEBGL_WRAPPINGS[sampler.wrapS] || THREE.RepeatWrapping;
+ 14 other calls in file
19 20 21 22 23 24 25 26 27 28
near: 0.0001, position: new THREE.Vector3(0, 0, -0.1) }) var texture = new THREE.Texture() texture.minFilter = THREE.LinearFilter texture.generateMipmap = false // transparent canvas to start (white) var canvas = document.createElement('canvas')
2749 2750 2751 2752 2753 2754 2755 2756 2757 2758
texture.flipY = false; if ( textureDef.name ) texture.name = textureDef.name; const samplers = json.samplers || {}; const sampler = samplers[ textureDef.sampler ] || {}; texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ] || THREE.LinearFilter; texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || THREE.LinearMipmapLinearFilter; texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || THREE.RepeatWrapping; texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || THREE.RepeatWrapping; parser.associations.set( texture, {
1812 1813 1814 1815 1816 1817 1818 1819 1820 1821
texture.flipY = false; if (textureDef.name) texture.name = textureDef.name; const samplers = json.samplers || {}; const sampler = samplers[textureDef.sampler] || {}; texture.magFilter = WEBGL_FILTERS[sampler.magFilter] || three.LinearFilter; texture.minFilter = WEBGL_FILTERS[sampler.minFilter] || three.LinearMipmapLinearFilter; texture.wrapS = WEBGL_WRAPPINGS[sampler.wrapS] || three.RepeatWrapping; texture.wrapT = WEBGL_WRAPPINGS[sampler.wrapT] || three.RepeatWrapping; parser.associations.set(texture, { textures: textureIndex });
GitHub: amatelus/paintcoin
65 66 67 68 69 70 71 72 73 74
'posy.jpg', 'negy.jpg', 'posz.jpg', 'negz.jpg', ]); textureCube.minFilter = THREE.LinearFilter; this.material = new THREE.MeshStandardMaterial({ roughness: 0.8, metalness: 1,
+ 5 other calls in file
26 27 28 29 30 31 32 33 34
this.worldGrid = worldGrid; this.cubeCamera = new THREE.CubeCamera(1, 1000, 128); this.cubeCamera.renderTarget.texture.generateMipmaps = true; this.cubeCamera.renderTarget.texture.minFilter = THREE.LinearMipMapLinearFilter; // this.cubeCamera.renderTarget.texture.magFilter = THREE.LinearFilter; this.cubeCamera.renderTarget.texture.mapping = THREE.CubeReflectionMapping; this.scene.add(this.cubeCamera);
+ 3 other calls in file
GitHub: JordanMachado/fluctus
138 139 140 141 142 143 144 145 146
var loader = new THREE.TextureLoader(); loader.load('images/displace.jpg',(texture)=> { let textureDisplacement = texture; textureDisplacement.minFilter = textureDisplacement.magFilter = THREE.LinearFilter; textureDisplacement.wrapS = textureDisplacement.wrapT = THREE.RepeatWrapping; this.displacementPass.params.uDisplacement = textureDisplacement; });
+ 3 other calls in file
129 130 131 132 133 134 135 136 137 138
const { mipmaps, width, height, format, type, error, dfdTransferFn, dfdFlags } = transcodeResult; if (type === 'error') return Promise.reject(error); const texture = new three_1.CompressedTexture(mipmaps, width, height, format, three_1.UnsignedByteType); texture.minFilter = mipmaps.length === 1 ? three_1.LinearFilter : three_1.LinearMipmapLinearFilter; texture.magFilter = three_1.LinearFilter; texture.generateMipmaps = false; texture.needsUpdate = true; texture.encoding = dfdTransferFn === KTX2TransferSRGB ? three_1.sRGBEncoding : three_1.LinearEncoding; texture.premultiplyAlpha = !!(dfdFlags & KTX2_ALPHA_PREMULTIPLIED);
+ 8 other calls in file
79 80 81 82 83 84 85 86 87 88
texture.image.data = data; texture.image.width = size; texture.image.height = size * size; texture.type = three_1.UnsignedByteType; texture.magFilter = three_1.LinearFilter; texture.minFilter = three_1.LinearFilter; texture.wrapS = three_1.ClampToEdgeWrapping; texture.wrapT = three_1.ClampToEdgeWrapping; texture.generateMipmaps = false; texture.needsUpdate = true;
+ 7 other calls in file
GitHub: star8ks/sketch
36 37 38 39 40 41 42 43 44 45 46 47 48
}]).then(ready); function ready() { const tex = assets.get('tex-id'); tex.minFilter = THREE.LinearFilter; const audioBuffer = assets.get('audio-boing'); // a global audio source const audioListener = new THREE.AudioListener();
824 825 826 827 828 829 830 831 832 833
_texture.type = texture.type !== undefined ? WEBGL_TEXTURE_DATATYPES[texture.type] : THREE.UnsignedByteType; if (texture.sampler) { var sampler = json.samplers[texture.sampler]; _texture.magFilter = WEBGL_FILTERS[sampler.magFilter] || THREE.LinearFilter; _texture.minFilter = WEBGL_FILTERS[sampler.minFilter] || THREE.NearestMipmapLinearFilter; _texture.wrapS = WEBGL_WRAPPINGS[sampler.wrapS] || THREE.RepeatWrapping; _texture.wrapT = WEBGL_WRAPPINGS[sampler.wrapT] || THREE.RepeatWrapping; }
+ 9 other calls in file
GitHub: VeinKowal/veins
67 68 69 70 71 72 73 74 75 76
this.width = viewerDiv.clientWidth; this.height = viewerDiv.clientHeight; this.positionBuffer = null; this._nextThreejsLayer = 1; this.fullSizeRenderTarget = new THREE.WebGLRenderTarget(this.width, this.height); this.fullSizeRenderTarget.texture.minFilter = THREE.LinearFilter; this.fullSizeRenderTarget.texture.magFilter = THREE.NearestFilter; this.fullSizeRenderTarget.depthBuffer = true; this.fullSizeRenderTarget.depthTexture = new THREE.DepthTexture(); this.fullSizeRenderTarget.depthTexture.type = THREE.UnsignedShortType;
three.Vector3 is the most popular function in three (22341 examples)