Three.js - How to make my text sprite clearer?

断了今生、忘了曾经 提交于 2019-12-23 02:04:39

问题


i need my text sprite to look more clear/strong (easiest to read), here is the code where i create it:

var canvas1 = document.createElement('canvas');
var context1 = canvas1.getContext('2d');
context1.font = "Bold 8px Arial";
context1.fillStyle = "rgba(255,0,0,0.95)";
context1.fillText(text, 170, 60);

var texture1 = new THREE.Texture(canvas1);
texture1.needsUpdate = true;

var spriteMaterial = new THREE.SpriteMaterial( { map: texture1, color: 0xffffff, fog: true } );
var sprite = new THREE.Sprite( spriteMaterial );
sprite.scale.set(window.innerWidth/5, window.innerHeight/5, 1);
var positionsT = positions.split(",");
sprite.position.set(positionsT[0]-20, positionsT[1]-80, positionsT[2]-40);
scene.add(sprite); 

Could anybody give me some advice? this is how it looks at this moment: http://postimg.org/image/uqke1k35h/


回答1:


One thing you can do is to turn off mip-mapping so that no texture filtering is applied texture1.generateMipmaps = false;

The other thing you can do is not scale the texture to an aspect ratio too much different from your canvas aspect ratio which of course depends on the size of your text.



来源:https://stackoverflow.com/questions/28591858/three-js-how-to-make-my-text-sprite-clearer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!