three.js sizeAttenuation to Sprite material

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 03:39:59

问题


I want the sprite in the scene don't change the size when the camera zoom in or out. and the sprites use different canvas texture as the material.

I found that the sizeAttenuation in ParticleBasicMatierial can work for me. But if I use the WenGLRenderer, I must use ParticleSystem instead of the Particle with the CanvasRenderer.

I currently use ParticleSystem to contain only one vertex, and every vertex correspond to one ParticleSystem, so there are about 800+ ParticleSystem in my scene, this can work, but consume a lot.

Obviously, I can't use "HUD" as the example in three.js source, because the sprites are all in 3D scene.

Can some one help me. Or add the sizeAttenuation to Sprite Material! Thanks!


回答1:


If you want to prevent size attenuation with sprites, and you are using a perspective camera, you can set the sizeAttenuation property of your material to false:

var material = new THREE.SpriteMaterial( {

    color: 0xffffff,
    map: texture,
    sizeAttenuation: false

} );

This feature was added in three.js r.96.

EDIT: Updated to three.js r.96



来源:https://stackoverflow.com/questions/24246632/three-js-sizeattenuation-to-sprite-material

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