So I am working on a demo to bring 2D characters into the 3D world. The problem I’m having is even though the sprite texture loads fine, and even though the image itself has no “colored-transparent” pixels, three.js still renders some pixels as transparent as well as discolors a few of the pixels. I have circled both the transparent pixel issue as well as the discolored issue in this photo. I have also uploaded the original sprite sheet for confirmation of discoloration & transparent pixels. Any help would be greatly appreciated!
Here’s the script :
// FLOOR
var floor = new THREE.Mesh
(
new THREE.PlaneBufferGeometry ( 1000, 1000, 32, 32 ),
new THREE.MeshBasicMaterial ( { color: 0x555555, wireframe: true } )
);
// ROTATE FLOOR
floor.rotation.x = ( - ( Math.PI / 2 ) );
// ADD FLOOR TO SCENE
this.scene.add ( floor );
// PLAYER
var playerTexture = new THREE.TextureLoader ( ).load ( "images/male.png" );
// TURN ON PIXELATION
playerTexture.magFilter = THREE.NearestFilter;
playerTexture.minFilter = THREE.LinearMipMapLinearFilter;
// PLAYER MATERIAL
var playerMaterial = new THREE.MeshBasicMaterial
(
{
map : playerTexture, transparent : true, opacity : 1.0,
side : THREE.DoubleSide, depthTest : false, depthWrite : false,
}
);
// PLAYER MESH
this.player = new THREE.Mesh
(
new THREE.PlaneBufferGeometry ( 64, 64 ), playerMaterial
);
// POSITION PLAYER
this.player.position.x = 25;
this.player.position.y = 25;
this.player.position.z = 25;
// ADD PLAYER TO SCENE
this.scene.add ( this.player );