Last active
June 5, 2026 00:40
-
-
Save let-josh/5435d0fd8f3f53abdfc526fa1791f840 to your computer and use it in GitHub Desktop.
threejs checkerboard canvas texture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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