three#NearestFilter TypeScript Examples
The following examples show how to use
three#NearestFilter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapHeightNodeShader.ts From geo-three with MIT License | 6 votes |
public async loadHeightGeometry(): Promise<void>
{
if (this.mapView.heightProvider === null)
{
throw new Error('GeoThree: MapView.heightProvider provider is null.');
}
const texture = new Texture();
texture.image = await this.mapView.heightProvider.fetchTile(this.level, this.x, this.y);
texture.generateMipmaps = false;
texture.format = RGBAFormat;
texture.magFilter = NearestFilter;
texture.minFilter = NearestFilter;
texture.needsUpdate = true;
// @ts-ignore
this.material.userData.heightMap.value = texture;
// @ts-ignore
this.material.map = texture;
// @ts-ignore
this.material.needsUpdate = true;
this.heightLoaded = true;
this.nodeReady();
}
Example #2
Source File: HDRI.tsx From spacesvr with MIT License | 5 votes |
export function HDRI(props: HDRIProps) {
const { src, size = 1204, disableBackground, disableEnvironment } = props;
const { gl, scene } = useThree();
const loader = useMemo(
() => new RGBELoader().setDataType(UnsignedByteType),
[]
);
useEffect(() => {
loader.load(src, (texture) => {
const opts = {
format: RGBAFormat,
generateMipmaps: false,
magFilter: NearestFilter,
minFilter: NearestFilter,
};
const envMap = new WebGLCubeRenderTarget(
size,
opts
).fromEquirectangularTexture(gl, texture).texture;
// sent envmap onto scene env and background
if (!disableBackground) {
scene.background = envMap;
}
if (!disableEnvironment) {
scene.environment = envMap;
}
texture.dispose();
return () => {
scene.background = null;
scene.environment = null;
envMap.dispose();
};
});
}, [src, scene, loader, disableBackground, disableEnvironment]);
return null;
}
Example #3
Source File: MapMartiniHeightNode.ts From geo-three with MIT License | 5 votes |
/**
* Process the height texture received from the tile data provider.
*
* @param image - Image element received by the tile provider.
*/
public async onHeightImage(image: HTMLImageElement): Promise<void>
{
const tileSize = image.width;
const gridSize = tileSize + 1;
var canvas = CanvasUtils.createOffscreenCanvas(tileSize, tileSize);
var context = canvas.getContext('2d');
context.imageSmoothingEnabled = false;
context.drawImage(image, 0, 0, tileSize, tileSize, 0, 0, canvas.width, canvas.height);
var imageData = context.getImageData(0, 0, canvas.width, canvas.height);
var data = imageData.data;
const terrain = MapMartiniHeightNode.getTerrain(data, tileSize, this.elevationDecoder);
const martini = new Martini(gridSize);
const tile = martini.createTile(terrain);
const {vertices, triangles} = tile.getMesh(typeof this.meshMaxError === 'function' ? this.meshMaxError(this.level) : this.meshMaxError);
const attributes = MapMartiniHeightNode.getMeshAttributes(vertices, terrain, tileSize, [-0.5, -0.5, 0.5, 0.5], this.exageration);
this.geometry = new BufferGeometry();
this.geometry.setIndex(new Uint32BufferAttribute(triangles, 1));
this.geometry.setAttribute('position', new Float32BufferAttribute( attributes.position.value, attributes.position.size));
this.geometry.setAttribute('uv', new Float32BufferAttribute( attributes.uv.value, attributes.uv.size));
this.geometry.rotateX(Math.PI);
var texture = new Texture(image);
texture.generateMipmaps = false;
texture.format = RGBAFormat;
texture.magFilter = NearestFilter;
texture.minFilter = NearestFilter;
texture.needsUpdate = true;
this.material.userData.heightMap.value = texture;
// @ts-ignore
this.material.map = texture;
// @ts-ignore
this.material.needsUpdate = true;
}