简体   繁体   中英

THREEJS Sprite repeat texture

I've got a sprite and i'm trying to make the texture repeat over and over.

I think I have the right settings but it doesn't seem to be doing what I expect, am I doing something wrong?

Here's my result: 在此处输入图片说明

And this is my code:

    var bgTexture = new THREE.TextureLoader().load('/bg.png');
    var spriteMaterial = new THREE.SpriteMaterial({ map: bgTexture });

    spriteMaterial.wrapS = spriteMaterial.wrapT = THREE.RepeatWrapping;
    spriteMaterial.map.offset.set( 0, 0 );
    spriteMaterial.map.repeat.set( 10, 1 );

    var sprite = new THREE.Sprite(spriteMaterial);
    sprite.position.y = 0;
    sprite.position.y = 0;
    sprite.scale.x = 10;
    sprite.scale.y = 1;
    this.scene.add(sprite);

必须将.wrapS.wrapT属性设置为Texture而不是SpriteMaterial

spriteMaterial.wrapS = spriteMaterial.wrapT = THREE.RepeatWrapping;

spriteMaterial.map.wrapS = spriteMaterial.map.wrapT = THREE.RepeatWrapping;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM