Some models showcase crisp textures with Thee.js, while others appear hazy (especially custom designs)

As a beginner in the realm of Three.js, I have been following a tutorial on texturing custom geometric shapes. The tutorial used a classic head OBJ file as a test case, which worked perfectly fine. However, when I tried to tweak the script to render my own custom geometry, the textures turned out to be extremely blurry and pixelated. Even though I placed my geometry and textures in the same paths as the example head file, it didn't resolve the issue. Is there something else that needs to be adjusted? Below is the snippet that calls the material properties:

// load external geometry
var loader = new THREE.OBJLoader();
var textureLoader = new THREE.TextureLoader();

loader.load('/assets/model/Terrain/Terrain.obj', function (object) {
var colorMap = textureLoader.load('/assets/model/Terrain/Terrain_Color.jpg');
var bumpMap = textureLoader.load('/assets/model/Terrain/Terrain_Disp.jpg');
var faceMaterial = getMaterial('phong', 'rgb(255, 255, 255)');

object.traverse(function(child) {
if (child.name == 'Plane') {
child.visible = false;
}
if (child.name == 'Infinite') {
child.material = faceMaterial;
faceMaterial.roughness = 0.875;
faceMaterial.map = colorMap;
faceMaterial.bumpMap = bumpMap;
faceMaterial.roughnessMap = bumpMap;
faceMaterial.metalness = 0;
faceMaterial.bumpScale = 0.175;
}
} );

object.scale.x = 20;
object.scale.y = 20;
object.scale.z = 20;

object.position.z = 0;
object.position.y = -2;
scene.add(object);
});

// renderer
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;

var controls = new THREE.OrbitControls( camera, renderer.domElement );

document.getElementById('webgl').appendChild(renderer.domElement);

update(renderer, scene, camera, controls);

return scene;
}

function getMaterial(type, color) {
var selectedMaterial;
var materialOptions = {
color: color === undefined ? 'rgb(255, 255, 255)' : color,
};

https://i.sstatic.net/IhcYe.jpg

Answer №1

Instead of using the custom geometry, I decided to take a different approach and placed my maps onto a cube with an array. To create a displacement map effect, I increased the divisions of the cubes. This turned out really well considering the custom geometry was already similar to a box.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring the Differences Between NPM Jquery on the Client Side and Server

I'm still getting the hang of node and npm, so this question is more theoretical in nature. Recently, I decided to incorporate jQuery into my website by running npm install jquery, which placed a node_modules directory in my webpage's root along ...

Troubleshooting base href issues in AngularJS routing

For a demonstration, I decided to try out this plunker from a tutorial that showcases tab routing across different pages. After downloading the entire zip file and running it as is (e.g. with all files in the same directory and utilizing CDN links), I enco ...

Selenium, scrolling through web pages

I have been attempting to scroll through a webpage using Selenium at "https://jobsearch.az/vacancies". However, when you open the page and click on a job vacancy, there are two side-by-side pages that need to be scrolled. The challenge is to scroll the one ...

Sending a prop to a handler causes issues with navigation paths

I'm facing an issue with my handler and button component setup. Here's my handler: const addToCartHandler = (id) => { navigate(`/cart/${brand}/${id}?qty=${qty}`)}; And here's the button component using the handler: <Button onClick={a ...

The search results from the autocomplete feature of the Spotify API appear to be missing

Exploring the Spotify API - I am attempting to implement an autocompletion feature using jQuery for a field that suggests artists as users type. Here is what I have so far: HTML: <input type="text" class="text-box" placeholder="Enter Artist" id="artis ...

What is the best way to convert API data into a currency format?

Hello, I need assistance with formatting data retrieved from an API into a currency format. The code below successfully retrieves the data but lacks formatting. For instance, if the data displays as 100000000, I would like it to be formatted as IDR100.000. ...

In Node.js, the module.exports function does not return anything

After creating a custom function called module.exports, const mongoose = require("mongoose"); const Loan = require("../models/loan_model"); function unpaidList() { Loan.aggregate([ { $group: { _id: "$ePaidunpaid", data: { $pus ...

Updating information dynamically in a controller based on an ng-repeat from a different controller in AngularJS

To enhance comprehension, I've created a straightforward example. For this scenario, ng-repeat is used to call a template that has its own controller. However, the controller of the template requires injected data from a service for each ng-repeat it ...

Is the information not displayed in its entirety on the FullCalendar?

I'm currently working with the following code: $('#calendar_1').fullCalendar({ header : { left : 'prev,next today', center : 'title', right : 'month,agendaWeek,agendaDay' ...

The process of exporting and utilizing models in Sequelize

When working on my node.js project with sequelize, I encountered a challenge of exporting and using table models in another file. I typically save table models in a folder, for instance Profile.js. module.exports = (sequelize, DataTypes) => sequelize.d ...

Sorting the order of items for display through the Dropdown menu feature in Bootstrap

I'm working on an app that showcases recipes on the main page (mywebsite.com/recipes). I'd like to give users the option to sort the recipes by either date or popularity, with a button right on the page for easy selection. Currently, I'm usi ...

Verify that JavaScript is capable of performing mathematical operations such as addition and multiplication successfully

When dealing with a specific set of "Strings" that represent integers in an addition operation, how can one determine if the calculation is feasible in javascript? For example: 2 + 2 (certainly possible) 20000000000000000 - 1 (impossible) 2e50 + 2e60 (i ...

Can the CSS color of struts2-jquery-grid-tags be modified?

Is there a way to customize the CSS style of my Struts2 jQuery grid tags? I'm having trouble adjusting the font size of the header layer. Can someone please advise on how to change the style, color, and other formatting of the grid similar to regular ...

Mastering Backbone views and router functionality is essential for building scalable and efficient web

In my code, I have a series of page states that mimic the steps of a shopping cart checkout process. The first set of code sets up the ItemsCollection, ItemsView, and ItemsApp in Backbone.js. var ItemsCollection = Backbone.Collection.extend({ model: I ...

What is the advantage of using multiple states compared to a single state object in React?

When working with a functional component that requires the use and manipulation of multiple state items, I often find myself in a dilemma. Should I group all the states together in one object and set them with one method, or should I declare and set each s ...

What is the best way to transform a GET request with a query string into a promise?

After successfully making a request with querystring params, I encountered an issue while trying to promisify my request: // Works var Promise = require("bluebird"); var request = Promise.promisifyAll(require("request")); request.get({ url: 'htt ...

Tips on accessing a specific element that has been mapped in React?

TL;DR - I'm struggling to target and open a specific menu from a list generated using map() on an array without a reference. I've encountered an issue with my React.js code that I need assistance with to resolve. The main concept behind this lo ...

The Link tag in the Hero.jsx file of Next.js is malfunctioning and failing to redirect to the intended URL

Having a problem with the button in my Hero.jsx component, part of the Page.js implementation. The button uses a Link tag to redirect to the url.js page, but it's not working as expected and showing an Error 404 page instead. I'm new to Next.js s ...

Is there a way to adjust the padding temporarily?

Important Note: Despite the misleading title of my question, it doesn't accurately reflect my actual query (sort of). Below is the code snippet in question: .one{ background-color: gray; } .two{ padding: 20px; } <div class = "one"> < ...

Flask app facing compatibility issues with jQuery .getJSON

I am encountering an issue with my flask application where I am attempting to send JSON data to the browser and render it. However, the line containing $.getJSON() is not executing as expected. Here is a breakdown of the relevant code: app.py from flask ...