I am using a texture atlas to hold a sequence of images. When mapping to a mesh with MeshLambertMaterial
, using Texture.offset
and Texture.repeat
works beautifully to cut the subtexture out of the entire image.
However, using the exact same texture instance for a PointCloudMaterial
renders the particles with the entire atlas, not just the selected subimage.
I tried to follow the three.js source code, but the documentation is scarce.
Is there a workaround for this better than using canvases to chop up the image?
Edit: As requested, a work-in-progress is available at http://jnm2.com/minesweeper/.
THREE.PointCloudMaterial
has been renamedTHREE.PointsMaterial
.THREE.PointCloud
has been renamedTHREE.Points
.You want to use a sprite sheet with your point cloud.
Instead of using
PointsMaterial
with yourPoints
, you can create a customShaderMaterial
instead.The custom
ShaderMaterial
can access your sprite sheet and use a different sub-image for each particle.To do so, use a shader like this one:
Set your
BufferGeometry
like so:And your
ShaderMaterial
like so:fiddle: http://jsfiddle.net/myy7x4zd/10/
three.js r.84