Why is my texture repeating?

So this is my code to assign image texture to material:

    var trimmedUrl = url.replace('~/', '/');
    var tex = new BABYLON.Texture(trimmedUrl, $scope.scene, false, false);
    tex.hasAlpha = true;
    material.albedoTexture = tex;
    material.useAlphaFromAlbedoTexture = true;

The problem is the image texture is repeating. I do not want to be repeated. How can I fix this?

Hi. I think you should try to replicate the issue in the playground. Basically, nothing in your code suggests that texture should repeat, so it’s kinda impossible to say what exactly the problem.

I think repeat (==wrap) is the default address mode for a texture. Try changing the address mode for material.albedoTexture.wrapU / wrapV to BABYLON.Constants.TEXTURE_CLAMP_ADDRESSMODE for eg.

1 Like