Exporting from Blender as an OBJ file and importing it into Three.js seems to be causing issues with the mesh normals

I exported my model from blender to OBJ format and then imported it into Three.js.

  • The normals for the wheels appear to be facing inward.
  • As for the track, only the mesh is visible and it does not seem to be correctly mapped.

Upon reimporting the OBJ file back into Blender, everything appears to be displaying correctly, indicating that the issue lies within Three.js.

Here's an image from Blender showing the correct wheel normals and properly displayed track.

You can find the Three.js code and OBJ model in this Codepen link.

var material = new THREE.MeshLambertMaterial({ color: 0xcc8729 });

// Model loader
var loader = new THREE.OBJLoader();
var geometry = loader.parse(getObjFileAsString());
geometry.position.set(0, 0, 0);
geometry.castShadow = true;
geometry.receiveShadow = true;
geometry.traverse(child => {
  if (child instanceof THREE.Mesh) {
    child.material = material;
  }
});
scene.add(geometry);

Should I consider remodeling the wheels and track? Or is there a way to rectify this issue within Three.js?

Answer №1

What could be causing the issue of face normals flipping during the export to obj?

One possible explanation is that there is a negative scale applied to your objects. To fix this, try applying the scale and rotation using the shortcut shift-a. After doing so, make sure to double check that your normals are still facing outwards. For more details, refer to my response here.

In Three.js, another way to correct flipped normals is by adjusting the material.side value. Options include double sided, back, and front. Check out the documentation for more information here.

node.material.side = THREE.DoubleSide;

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

There seems to be a problem with completing the Axios post request in the Javascript Front

My front-end, built with React, is having trouble retrieving data from a third-party API through my Node.js backend. Despite using axios.post request, the response remains undefined and I'm stuck at handling the asynchronous request. It appears that t ...

I sought out a way to incorporate a hyperlink within the Material Data Grid

Take a look at this sample data grid for reference: here. I added an image like this: see here. However, I couldn't create a clickable link. ...

Encountering an Unexpected Error in Next.js When Revalidating Paths

I'm facing an issue with my Next app where, despite editing a resource through an API endpoint following the pages-based system, the changes aren't reflected when I try to view or re-edit the resource. After checking the documentation, I discover ...

Tips on choosing filters and leveraging the chosen value for searching in a Vue application

I am currently working on a Vue JS application that allows users to apply filters and search a database. The user can select or type in filters, such as "to" and "from", which are then used in a fetch URL to retrieve data from a json-server. Once the user ...

What is the method for enlarging an element without regard to surrounding elements?

I am working on a code where I want the element to zoom in when hovered, completely disregarding its normal flow. By "ignoring its flow," I mean that other elements like tags might obstruct parts of its content. https://i.sstatic.net/NBoez.png https:// ...

Exploring the possibility of utilizing the talks.js library to develop a chat feature within a React application

I'm currently working on integrating the talks.js library to set up a chat feature in my React project. I've followed all the instructions provided at , but unfortunately, it's not functioning as expected. I'm not quite sure what I migh ...

Function invoking React Hook

I'm a beginner to React JS and I've been learning by working on a project. I was creating a basic e-commerce UI with items and attempting to add items to a cart, but encountered an issue. The React Hook "useStateValue" is being called in the fun ...

Learn how to dynamically incorporate multiple Bootstrap collapse elements in PHP

I've encountered an issue with my code that contains both HTML and PHP. The problem arises when there are multiple elements in a collapse, as only the first element works properly. This is due to the fact that each element has the same id named "colla ...

Explore the extensive JSON link for redirecting

I have an issue with accessing the HATEOS link example on PayPal. My browser is showing a syntax error when I try to access the link. SyntaxError: missing ) after argument list [Break On This Error] alert(links.1.href); (line 32, col 15) The JSON d ...

Having trouble sending a function as a prop to a child component in React

Something odd is happening, I'm confident that the syntax is correct, but an error keeps popping up: Error: chooseMessage is not a function // MAIN COMPONENT import React, { useState } from 'react' export default function LayoutMain(prop ...

Implementing optimistic updates with React-query mutations

Hello everyone! I'm a newcomer to react-query and I've been experimenting with making an optimistic update using the mutation function. However, I've encountered a problem where I'm unable to retrieve the previous value from the query. ...

Issues with comparing dates

I'm attempting to compare two different dates: Start Date Thursday, October 29th, 2015 at 6:00 PM GMT End Date Friday, October 30th, 2015 at 12:00 AM GMT Simply put, if(end > start) { alert('It works'); } else { alert(&apo ...

What could be causing the issue of not being able to access an element visible in AngularJS Videogular?

I am currently working on integrating the videogular-subtitle-plugin with the most recent version of Videogular/AngularJS. As a newcomer to AngularJS, I believe there must be a simple solution that I am overlooking. My main challenge lies within a directi ...

Is it necessary to include my library dependencies in the devDependencies section if I am only planning to publish the library bundle?

When creating a bundle for a library, should the library dependencies be placed in devDependencies? I am developing an NPM library in TypeScript that relies on several dependencies, including React components. As part of the build process, we compile to J ...

Is there a more effective approach to managing an array of objects retrieved from an API call?

I'm attempting to extract an array of names from a JSON response that contains an array of objects, but I'm running into issues. When I try to print the array, it shows up empty. Is this the correct way to go about it? There don't seem to be ...

Obtaining the local IP address of my system with React JS

Is there a way to retrieve the local IP of my computer within a React JS application? I would appreciate any suggestions on how to accomplish this. ...

Ways to identify the moment jQuery datatable is initialized and populated with information

I am currently using the most recent version of jQuery datatables. I'm curious if there is a callback function available that triggers right after the data has been loaded and displayed in the table? While experimenting with a datatable in IE8, I hav ...

altering the directory for bower installations on specific repositories exclusively

Recently, I've been experimenting with Bower and at the same time exploring Polymer. If you want to download polymer elements using bower, you can use the following command: bower install --save PolymerElements/iron-image I assume there's a sp ...

Issues with fog in three.js on Chrome mobile device are not functioning properly

I encountered an issue where adding fog to my scene resulted in the fog filling my entire screen with a solid color, essentially creating a plain black background. Specifics of my setup: Chrome version: 39.0.2171.93 Mobile device: nexus 5 Android: lolipo ...

Node.js - Error: JSON.Parse and JSON.Stringify are not recognized as functions

Is it possible to convert a string to JSON and vice versa without any additional npm packages? I am currently using JSON.Stringfy in my router.js file. Are there any specific npm modules that need to be added to the project in order to use the JSON.Stringf ...