three.js - 带有 alphaMap 的 SpriteMaterial
问题描述
当我尝试将 alphaMap 与 THREE.SpriteMaterial 一起使用时:我收到此消息 THREE.SpriteMaterial: 'alphaMap' is not a property of this material。有没有办法用 alphaMap 剪辑 SpriteMaterial?谢谢
const imgTexture = new THREE.TextureLoader().load(`logo.jpg`);
const circleAlphaMap = new THREE.TextureLoader().load(`alpha.png`);
const material = new THREE.SpriteMaterial({ map: imgTexture, alphaMap: circleAlphaMap, alphaTest:0.5 });
const sprite = new THREE.Sprite(material);
sprite.scale.set(12, 12);
obj.add(sprite)
解决方案
为什么不使用.png
具有透明度的文件?你可以看到这就是他们在这个例子中采用的方法。
当您点击右下角 ( < >
) 图标时,您可以看到源代码,它只是一个透明的 png 设置到map
属性。
var mapB = textureLoader.load( "textures/sprite1.png" );
var materialB = new THREE.SpriteMaterial( {
map: mapB,
color: 0xffffff,
fog: true
} );
推荐阅读
- xslt - XSLT 帮助 - 将字段映射存储到变量中并根据该映射对输入有效负载进行分组
- c - 替代 isdigit 来读取大于 9 的数字?
- jmeter - 如何使用 Ultimate Thread Group 循环 CSV 文件值?
- android - 如何将列表放入数组
- excel - 从 VBA 函数写入工作表
- c - 如何在c中创建一个用0填充的整数数组?
- python - 还有另一种方法可以在这个递归序列中找到项目 n 吗?
- reactjs - 如何在打字稿中正确键入简单的 useReducer 和 Context-api
- pandas - Dask 数据帧 groupby 因类型错误而失败,但相同的 pandas groupby 成功
- docker - 如何在 docker alpine 映像中将非 root 用户设置为 sudo 用户?