三.js sizeAttenuation 到 Sprite 材质 [英] three.js sizeAttenuation to Sprite material

查看:24
本文介绍了三.js sizeAttenuation 到 Sprite 材质的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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.

我目前使用 ParticleSystem 只包含一个顶点,每个顶点对应一个 ParticleSystem,所以我的场景中大约有 800+ 个 ParticleSystem,这可以工作,但消耗很多.

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.

显然,我不能在three.js源中使用HUD"作为示例,因为精灵都是3D场景.

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

谁能帮帮我.或者将 sizeAttenuation 添加到 Sprite Material 中!谢谢!

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

推荐答案

如果你想防止精灵的尺寸衰减,并且你使用的是透视相机,你可以设置你的 sizeAttenuation 属性材料为假:

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

} );

此功能是在three.js r.96中添加的.

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

更新为three.js r.96

Updated to three.js r.96

这篇关于三.js sizeAttenuation 到 Sprite 材质的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆