Three.js repeat texture with THREE.TextureLoader
Asked Answered
M

1

6

I would like to ask you if you know how to repeat texture using THREE.TextureLoader(). I've found solutions just for using THREE.ImageUtils.loadTexture(). Here is part of my code:

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);
                    }
                );
Merriman answered 19/3, 2017 at 20:7 Comment(0)
R
8

Here is the pattern to follow if you want to repeat a texture:

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

Roan answered 19/3, 2017 at 20:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.