Created
October 20, 2020 19:54
-
-
Save mcallegari10/1947ac928eafb23ad837b6b4653b293f to your computer and use it in GitHub Desktop.
Particle Material
This file contains 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
export function createPointMaterial(size, opacity = 1) { | |
const matCanvas = document.createElement('canvas') | |
matCanvas.width = size | |
matCanvas.height = size | |
const matContext = matCanvas.getContext('2d') | |
const texture = new CanvasTexture(matCanvas) | |
const center = size / 2 | |
matContext.beginPath() | |
matContext.arc(center, center, size / 2, 0, 2 * Math.PI, false) | |
matContext.closePath() | |
matContext.fillStyle = `rgba(255, 255, 255, ${opacity})` | |
matContext.fill() | |
texture.needsUpdate = true | |
return texture | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment