Three.js用THREE.TextureLoader重复纹理

时间:2017-03-19 20:07:08

标签: javascript three.js texture-mapping

我想问你是否知道如何使用THREE.TextureLoader()重复纹理。我找到了仅使用THREE.ImageUtils.loadTexture()的解决方案。这是我的代码的一部分:

var loader = new THREE.TextureLoader();
var wall;
loader.load('../images/concreteWall.jpg', function (texture) {
                        var wallMaterial = new THREE.MeshBasicMaterial({
                            map: texture
                        });
                        wall = new THREE.Mesh(sideWallsGeometry, wallMaterial);
                        scene.add(wall);
                    }
                );

1 个答案:

答案 0 :(得分:6)

如果要重复纹理,请遵循以下模式:

var loader = new THREE.TextureLoader();

var texture = loader.load( 'path.jpg', function ( texture ) {
    texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
    texture.offset.set( 0, 0 );
    texture.repeat.set( 1, 1 );

    // your code

} );

three.js r.84