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

154
Visualizações
Can I set texture filtering for uploaded texture?

The Challenge

The goal is to display the uploaded image pixelated, with NEAREST texture filtering.

What I tried so far

  1. Using CSS' image-rendering property.
  2. Setting the .glb model filters to NEAREST.

What I think the problem is

I think the issue is that the images that come with the model are properly filtered, but the new uploaded one isn't.

Interesting Links I've Found

Model Viewer Materials API

Example

document.getElementById("urlA").addEventListener("change", function() {
  const file = this.files[0];
  const viewer = document.getElementById("modelA");

  if (!file) return;

  const reader = new FileReader();
  reader.addEventListener('load', async function() {
    const texture = await viewer.createTexture(reader.result);
    viewer.model.materials[0].pbrMetallicRoughness.baseColorTexture.setTexture(texture);
  });
  reader.readAsDataURL(file);
})
body {
  background-color: rgba(255, 255, 255, 0.85)
}

h1 {
  margin: 0;
  font-size: 16pt;
  font-family: Arial, Helvetica, sans-serif;
  color: #4a5a8a
}

model-viewer {
  width: 256px;
  height: 256px;
  border: 2px solid black;
  background-color: #484E61
}

input[type="file"] {
  margin: 15px auto
}
<script src="https://unpkg.com/@google/model-viewer@1.12.0/dist/model-viewer-umd.js"></script>
<h1>Upload an image to preview it in the model</h1>
<input type="file" id="urlA">
<model-viewer id="modelA" camera-controls src="https://modelviewer.dev/shared-assets/models/Astronaut.glb" shadow-intensity="0" environment-image="neutral" exposure="0.5"></model-viewer>

about 4 years ago · Juan Pablo Isaza
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