Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

345
Visualizações
Changing the way three.js projects a texture onto a halfsphere

I am currently trying to project an image onto the inside of a halfsphere in a three.js project. The half sphere is created via

const geometry = new THREE.SphereGeometry(Component.radius, this.resolution, this.resolution,
        Math.PI, Math.PI, 0, Math.PI);
this.material = new THREE.MeshStandardMaterial({color: 0xffffff});
this.material.side = THREE.DoubleSide;

this.sphere = new THREE.Mesh(geometry, this.material);

// The image of the texture is set later dynamically via 
// this.material.map = textureLoader.load(...); 

With radius and resolution being constants. This works fine, except for one issue: The image becomes distorted around the "top" and "bottom" of the sphere, like this: Simple example of distorted texture:

enter image description here

The texture originally had the value "0,0" in the bottom left and "0,1" in the bottom right, and with the camera facing down from the center of the demisphere the bottom left and bottom right corner are squished onto the "bottom" point of the sphere.

I want to change this behavior so the texture corners are instead on where they would be if you place the square texture into a sphere, with the corners touching the circle, then stretching the lines between the corners to match the circle. Simple mock of what i mean:

enter image description here

I have tried playing with the mapping Attribute of my texture, but that doesn't change the behaviour from my understanding.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

After changing the UV coordinates, my half sphere texture is't stretching on border as well:

Texture issue visualised

this.sphereGeometry = new THREE.SphereGeometry(
  10,
  32,
  24,
  0,
  Math.PI,
  0,
  Math.PI
);

const {
  uv: uvAttribute,
  normal
} = this.sphereGeometry.attributes;

for (let i = 0; i < normal.count; i += 1) {
  let u = normal.getX(i);
  let v = normal.getY(i);

  u = u / 2 + 0.5;
  v = v / 2 + 0.5;

  uvAttribute.setXY(i, u, v);
}

const texture = new THREE.TextureLoader().load(
  'https://i.imgur.com/CslEXIS.jpg'
);

texture.flipY = false;
texture.mapping = THREE.CubeUVRefractionMapping;
texture.needsUpdate = true;

const basicMaterial = new THREE.MeshBasicMaterial({
  map: texture,
  side: THREE.DoubleSide,
});

this.sphere = new THREE.Mesh(this.sphereGeometry, basicMaterial);
this.scene.add(this.sphere);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda