three.js sizeAttenuation to Sprite material

时间:2014-06-16 15:00:25

标签: three.js webgl sprite material

我希望场景中的精灵在相机放大或缩小时不会改变大小。精灵使用不同的画布纹理作为材质。

我发现ParticleBasicMatierial中的sizeAttenuation对我有用。但是如果我使用WenGLRenderer,我必须使用ParticleSystem而不是使用CanvasRenderer的Particle。

我目前使用粒子系统只包含一个顶点,每个顶点对应一个粒子系统,因此我的场景中大约有800多个粒子系统,这可以工作,但消耗很多。

显然,我不能使用“HUD”作为three.js源代码中的例子,因为精灵都在3D场景中。

有人可以帮助我。或者将sizeAttenuation添加到Sprite材质!谢谢!

1 个答案:

答案 0 :(得分:5)

如果您想使用精灵来防止尺寸衰减,并且您使用的是透视相机,则可以将材质的sizeAttenuation属性设置为false:

var material = new THREE.SpriteMaterial( {

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

} );

此功能已在three.js r.96中添加。

编辑:更新为three.js r.96