Styling particles with the HTML5 canvas
Three.js offers three different ways you can use an HTML5 canvas to style your particles. If you use THREE.CanvasRenderer
, you can directly reference an HTML5 canvas from THREE.SpriteCanvasMaterial
. When you use THREE.WebGLRenderer
, you need to take a couple of extra steps to use an HTML5 canvas to style your particles. In the following two sections, we'll show you the different approaches.
Using HTML5 canvas with THREE.CanvasRenderer
With
THREE.SpriteCanvasMaterial
, you can use the output from an HTML5 canvas as a texture for your particles. This material is specifically created for THREE.CanvasRenderer
and only works when you use this specific renderer. Before we look at how to use this material, let's ...
Get Learning Three.js – the JavaScript 3D Library for WebGL - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.