最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Three.js repeat texture with THREE.TextureLoader - Stack Overflow

programmeradmin4浏览0评论

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);
                    }
                );

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);
                    }
                );
Share Improve this question asked Mar 19, 2017 at 20:07 xmigasxmigas 1316 silver badges19 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 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

发布评论

评论列表(0)

  1. 暂无评论