我遇到了均匀纹理和重复的问题,因为:
tex.wrapS = THREE.RepeatWrapping;
tex.wrapT = THREE.RepeatWrapping;
tex.repeat.x=100;
tex.repeat.y=100;
它不起作用。所以我在网上搜索了一个解决方案,我在giuthub上找到了以下帖子: https://github.com/mrdoob/three.js/issues/787 threadstarter和我有同样的问题,但不幸的是,带有答案的链接不再起作用了。
当我想要重复均匀纹理时,我该怎么做?
答案 0 :(得分:2)
您在编写自己的片段着色器吗?如果是这样,您需要将UV坐标乘以重复值,例如
uniform sampler2D baseTexture;
varying vec2 vUv;
void main()
{
gl_FragColor = texture2D( baseTexture, vUv * 100 );
}
如果没有,http://stemkoski.github.io/Three.js/Texture-Repeat.html包含纹理重复的示例,例如
// texture repeated twice in each direction
var lavaTexture = THREE.ImageUtils.loadTexture( 'images/lava.jpg' );
lavaTexture.wrapS = lavaTexture.wrapT = THREE.RepeatWrapping;
lavaTexture.repeat.set( 2, 2 );
var lavaMaterial = new THREE.MeshBasicMaterial( { map: lavaTexture } );