UVs on a single object in my Three.js project are completely messed up

I've been working on a 3D house model and encountered another frustrating issue that seems to be common with three.js.

In Maya, I have created my scene with 9 ungrouped objects, each only a child of the world, with texture maps containing ambient occlusion and baked lighting assigned via shadingMaps. Despite having trouble using the mtl file, I managed to load the texture maps separately and create materials in three.js.

Everything looks fine in the browser except for the walls and floor object, which is simple in design but causing unexpected texture distortion. While exporting objects into obj files, I learned that only one UV channel is supported, so I copied my UVs into the default channel and deleted extras before export. But when I apply the material in the browser, the textures appear misplaced.

This issue perplexes me, especially since more complex objects display correctly. I've tried various approaches, including direct export to js from Maya and using a browser-based converter without success.

If anyone has insight on how to troubleshoot this problem, please share your expertise. I've included relevant code below:

scene = new THREE.Scene();
renderer = new THREE.WebGLRenderer({antialias: true} );

var wallTexture = THREE.ImageUtils.loadTexture("obj/final_walls.jpg");
var wallMaterial = new THREE.MeshLambertMaterial( {color: 0x929EAC, map:wallTexture} );

var manager = new THREE.LoadingManager();
var loader = new THREE.OBJMTLLoader( manager );
loader.load( 'obj/wallOnly.obj','obj/wallOnly.mtl', function ( object ) {
    object.children[2].material = wallMaterial; 
    floorplan.add(object);
    camera.lookAt( object );
} );

Please assist me in resolving this issue!

Answer №1

Oh my goodness! After countless attempts, I finally cracked the code!

I've come to realize that the issue wasn't really a texture distortion but rather a puzzling swapping of UV faces. Can you believe it? The webGL renderer decided to randomly switch some faces of the object with others.

By pure chance, I converted my mesh into quads instead of triangles and, voila!, everything fell into place. QUADS!!! Three whole days wasted on triangles had me pulling my hair out!

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

Guide on implementing an enum as a type by attaching it to a class as a static variable

// file1.ts enum Variant { Success = 'success', Error = 'error', } export class Example { static Variant = Variant; } // file2.ts import { Example } from './file1'; type Props = { variant: Example.Variant; // TS2 ...

Generating distinctive content within the confines of the Selenium WebDriver

Is there a way to generate a unique username value for the signup page username textbox using selenium webdriver instead of hardcoding it? For example: driver.findElement(By.id("username")).sendKeys("Pinklin") ; When "Pinklin" is hardcoded, running the ...

Update a particular class following an AJAX POST request in JavaScript

After conducting extensive research, I have come here seeking your assistance with a particular issue: I am using a comment system with multiple forms on the same page (utilizing FOSCommentBundle in Symfony). My goal is to be able to post comments via Aja ...

Preventing access to drives and desktop until the mandatory HTML form is completed

Looking to develop a webpage in JSP that will automatically open whenever my system is started. Users will be required to fill out a form on this page before proceeding further. If they attempt to bypass filling out the form, they should not have access ...

Do the dependencies in the devDependencies section impact the overall size of the

My search for a definitive answer to this question was fruitless. Are the packages I include as devDependencies included in the final production JS bundle, impacting its size? Or does only the dependencies list affect the bundle's content? ...

Utilize a WebAPI controller to serialize a complicated JSON object

Embarking on a new journey with AngularJS and ASP.NET WebAPI, I find myself faced with the challenge of working with base tables structured as follows: CurriculumID SubjectArea CourseNumber ------------ ----------- ------------ 303 GHIJ 1 ...

code shatters console.log()!

I'm confused about the output I'm seeing: let frenchWords; const fs = require('fs'); const data = fs.readFileSync('frenchVerbsList.txt', 'utf8'); frenchWords = data.split('\n'); console.log(Array.isA ...

Icon button not found

I have created a reusable hook component for input fields. The TextField renders perfectly, but the IconButton is not showing up. const InputHookComponent = (props) =>{ const [val, setval]=useState(""); const cmp = <TextField type={ ...

"Bridging the Gap: Establishing Communication Among Backbone Marionette Views

I recently started working as a junior javascript developer at a company that utilizes Backbone and Marionette. My first project involves implementing searching, filtering, and sorting capabilities in a collection based on user input. The challenge lies in ...

Does anyone know of a way to integrate a calendar feature into a React application using a library

Greetings to everyone, I trust you are all enjoying a fantastic day. I am in search of an interactive calendar similar to this one for one of my applications https://i.sstatic.net/D3S3a.png Does anyone know of a React library that could assist me in crea ...

Utilize and store images based on the individual user's preferences with PlayCanvas

Currently, I am immersed in a PlayCanvas endeavor where I am trying to render specific objects with textures of my choice. The main issue arises when I come across the config.json file in the PlayCanvas build. Within this file, there is a designated path ...

What is the process of exporting the app object in Express?

My application object is initialized in the app.js file: var app = express(); var reg = require('./routes/reg'); app.use('/reg',reg); ... ... module.exports = app; In reg.js, I use app.get(): var app = require("../app.js"); ... ... a ...

Static files fail to load in FastAPI

Recently, I decided to switch my project from using node.js to python FastAPI. While everything was running smoothly with node, I encountered an issue with my static files not being found in FastAPI. Here is the code snippet that I am using: from fastapi i ...

Leverage Angularjs ng-repeat to organize array data within a specific framework

I have an array of data that I need help turning into a table using AngularJS ng-repeat. Can anyone assist with this task? var data=[ {status:"open",year:2014,value:100.00}, {status:"open",year:2015,value:200.00}, ...

Step-by-step guide on replacing Express API routes with React Router

I am currently working on an application that utilizes React Routes and is served with an Express server. The Express server also contains routes for API calls. Server.js const express = require('express') const path = require('path') ...

A step-by-step guide to setting up a custom splash screen for React Native

Looking for assistance in setting up a splash screen in react-native specifically for Android devices. I've managed to successfully implement one for iOS, but I'm encountering difficulties when it comes to getting one to work on Android. I' ...

What is the optimal method for navigating through a complex nested object in Angular?

Looking to navigate through a nested object structure called purchase. Within this structure, there is a sub-array named purchaseProducts which contains another sub-array called products along with additional data. What methods do you suggest for efficien ...

JavaScript array displaying excess whitespace in its presentation

https://i.sstatic.net/5AdA7.png One issue I am facing is that when I use console.log(a), it adds extra spaces which then flow through to the backend. This leads to each element breaking after the first one. How can I resolve this problem and why does it o ...

The jQuery dialog function is not recognized

Based on the guidance provided in this resource: Resolving the issue with Jquery dialog not being recognized as a function Incorporated jQuery into my Electron-React-Typescript-Webpack application by implementing the following: import jQuery from 'jq ...

Angular Data not being updated as scheduled

I am facing a challenge with my AngularJS application. It displays data from a server in a specific view structure, as shown below: <table class="table table-striped"> <tr ng-repeat="query in saved_queries"> <td ng-click="fill()">& ...