Skip to content

Instantly share code, notes, and snippets.

@let-josh
Last active June 5, 2026 00:40
Show Gist options
  • Select an option

  • Save let-josh/5435d0fd8f3f53abdfc526fa1791f840 to your computer and use it in GitHub Desktop.

Select an option

Save let-josh/5435d0fd8f3f53abdfc526fa1791f840 to your computer and use it in GitHub Desktop.
threejs checkerboard canvas texture
import { CanvasTexture, NearestFilter } from 'three/webgpu'
const size = 4;
const canvas = new OffscreenCanvas(size, size);
const context = canvas.getContext('2d');
if (context === null) throw new Error('context is null');
context.fillStyle = 'white';
for (let j = 0; j < size; j += 1) {
for (let i = 0; i < size; i += 1) {
if ((i + j) % 2 === 0) {
context.fillRect(i, j, 1, 1);
}
}
}
const map = new CanvasTexture(canvas);
map.magFilter = map.minFilter = NearestFilter;
// map.generateMipmaps = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment