0

I am trying to render a sphere with a texture wrapped on it, i am using a png texture with 1920px1080p resolution but the resulted texture is always very blurry,

here is my sample code :

      var scene = new THREE.Scene();
      var camera = new THREE.PerspectiveCamera(60, 1, 1, 1000);
      camera.position.set(0, 0, 20);
      var renderer = new THREE.WebGLRenderer({
        antialias: true,
      });
      var canvas = renderer.domElement;
      this.$refs.threeCanvas.appendChild(canvas);
      renderer.setSize(104, 104);

      // Load textures
      var textureLoader = new THREE.TextureLoader();
      var wrappingTexture = textureLoader.load(this.texture, () => {
        // Create the main sphere with the wrapping texture
        wrappingTexture.magFilter = THREE.LinearFilter; // <-- i tried adding these mag and min Filters but to no result
        wrappingTexture.minFilter = THREE.LinearMipMapLinearFilter;
        var sphereGeometry = new THREE.SphereGeometry(10, 256, 256);
        var wrappingMaterial = new THREE.MeshBasicMaterial({
          map: wrappingTexture,
          transparent: true, // Make the material transparent
          opacity: 0.5, // Set opacity for see-through effect
        });
        var sphere = new THREE.Mesh(sphereGeometry, wrappingMaterial);
        scene.add(sphere);
      })

Should i try a different texture ? Like SVG and with lower dimensions ?

0

1 Answer 1

0

renderer.setSize(104, 104); you are setting the resolution of the renderer too low.

try something like:

var canvas = renderer.domElement;
renderer.setSize(this.$refs.threeCanvas.offsetWidth, this.$refs.threeCanvas.offsetHeight);
this.$refs.threeCanvas.appendChild(canvas);

Maybe add renderer.setPixelRatio(2); if needed too as Lukaz said.

2
  • who's Lukaz ? you are mentioning ? Commented Jul 15 at 21:08
  • there was another answer mentioning setPixelRatio, but it was deleted by the author. Please accept the answer if it does fix your issue.
    – 2pha
    Commented Jul 15 at 23:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.