Unseen faces rendered by Three.js

When I load my OBJ file with a JPG texture onto a page, the faces are visible from one side but invisible from the other.

The faces are visible on one side (albeit a little dark - apologies for that!)

However, on the other side, the faces are not visible at all.

I attempted to fix this by adding model.doubleSided = true;, but it doesn't seem to have any effect.

Answer №1

To incorporate a double-sided flag onto the material, you can follow these steps:

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

Add the following line of code:

material.side = THREE.DoubleSide;

Alternatively, you can include it when creating the material like this:

material = new THREE.MeshLambertMaterial ({ color: 0xFF00FF, side: THREE.DoubleSide });

UPDATE: When using the OBJMTL loader that returns an Object3D, you will need to traverse the object to set the appropriate flag:

if (object instanceof THREE.Object3D)
{
    object.traverse (function (mesh)
    {
        if (! (mesh instanceof THREE.Mesh)) return;

        mesh.material.side = THREE.DoubleSide;
    });
}

Answer №2

To improve your model rendering, consider implementing

renderer.setFaceCulling( THREE.CullFaceNone );

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

Unveiling the steps to automatically conceal a submitted form in React, no longer requiring the manual activation of a toggle button

Currently, I have a list of songs and a toggle button that reveals a form to add a new song. However, I want the form to hide automatically after submission without requiring another button click. I tried using useEffect but couldn't get it to work. A ...

What is the method for implementing an Inset FAB with Material UI in a React project?

Currently, I am working on a project that requires an "Inset Fab" button to be placed between containers. After referencing the Material Design documentation, I discovered that the component is officially named "Inset FAB". While I was able to find some tu ...

The information displayed in Postman contains a few extra characters added to the response data

I am currently working on developing a CRUD application using PostgreSQL and Node.js. However, I have encountered an issue with sending POST requests to the server. When testing the response data in Postman, I noticed that the JSON data contains some unexp ...

Having trouble with react-bootstrap Navbar not displaying correctly in React JS?

I am currently working with ReactJS and Bootstrap 4. I am using the react-bootstrap module to render the Navbar, but I am encountering issues with the rendering. I suspect that there may be a conflict between Bootstrap 4 syntax and another Bootstrap 3 synt ...

Redirecting with VueJS Router to a specific path on the server

I have set up my router with the following configurations: export default new Router({ mode: 'hash', linkActiveClass: 'open active', scrollBehavior: () => ({ y: 0 }), routes: [ { path: '/', .... In ...

The use of the 'v-on' directive with the 'KeyboardEvent.keyCode' modifier is no longer recommended in Vue. It is now recommended to use 'KeyboardEvent.key' instead

I am currently in the process of upgrading my Vue 2 application to Vue 3. However, when I run the application, I encounter some deprecation errors. Previously, I used numbers and "key" in my keyboard event modifiers. This approach is now deprecated in Vue ...

Testing a React component to ensure that it correctly handles clicks occurring outside

Utilizing the solution found in this particular answer to address clicking outside of a component: componentDidMount() { document.addEventListener('mousedown', this.handleClickOutside); } componentWillUnmount() { document.removeEventLis ...

Navigating Assets within NodeJS Module

I'm facing a challenge with my NodeJS module that is designed to translate XML to HTML using an XSL file. The issue arises when I try to package the XSL file along with the rest of the module. Currently, the XSL file is located inside the source fold ...

What is the best way to effectively expand React Bootstrap components?

In order to add sizing functionality to a badge component, I have developed the following approach: import React from 'react'; import Badge from 'react-bootstrap/Badge'; import classNames from 'classnames'; const CustomBadge ...

Is there a way to navigate to a newly created document?

Is there a way to automatically redirect a user to the show action of a document or post they have just created using express.js? Take a look at the following code snippet, which outlines how I am creating the document: app.post('/document/create&ap ...

At what stage in the code does the loop conclude?

While researching Selenium Webdriver framework best practices on GitHub, I came across the following code snippet: async function waitForVisible(driver, locator, retries = 3) { try { const element = await driver.findElement(locator); ...

Unable to utilize arrow function in ReactJs + Electron: Encountering an unexpected token error

Previously, I utilized arrow functions in JavaScript for my React Native project and had no issues. However, now that I'm working on a ReactJS App with Electron, I am unable to use any arrow function. For instance: export default class App extends R ...

Bringing in SVGLoader from three.js opens up new possibilities on Vite Gateway

Currently working on a project using vite / vue 3 with typescript and attempting to import an SVG via three.js. However, a specific error occurs when importing the SVGLoader: http://localhost:3000/node_modules/.vite/deps/three_examples_jsm_loaders_SVGLoa ...

Verify whether a loss of focus event was triggered by a tab switch

Is there a way to detect when an input loses focus due to a tab switch or window losing focus? Scenario: I need to reset a form on blur, but I want the data to persist if a user switches tabs or the window loses focus. I know I could simply check for a c ...

How to toggle a class using ng-click in AngularJS

Currently, I am working on a project using AngularJS for my website. One specific feature involves having a form that is initially hidden with "display:none" set deliberately. There's also a button labeled create. My goal is to have the form toggle b ...

What is the best method for retrieving the current value of an RxJS Subject or Observable?

I am dealing with an Angular 2 service: import {Storage} from './storage'; import {Injectable} from 'angular2/core'; import {Subject} from 'rxjs/Subject'; @Injectable() export class SessionStorage extends Storage { priv ...

Utilize PHP SVG images to trigger internal JavaScript code through the <img> tag

Here is a php function that generates an SVG image. public function actionJsTest() { header('Content-Type: image/svg+xml'); $svg = ''; $svg .= '<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/ ...

How can you transform a variable into an HTML element using Angular?

Currently, I am working on parsing a JSON file that contains information about various articles. The structure of the JSON file is as follows: { "articles": [ { "id": 1, "title": "<h1>How to install Atom</h1>" }, { ...

Can you identify the HTML table format and suggest effective web scraping methods?

I have been attempting to retrieve data from the following link, http://www.rchsd.org/doctors/index.htm? strt = 0 & ln = & fn = & sp = & grp = & loc = & lng = & gen = , using R but finding it quite challenging. I have observed that the URL remains constan ...

Utilizing a d.ts Typescript Definition file for enhanced javascript intellisene within projects not using Typescript

I am currently working on a TypeScript project where I have set "declaration": true in tsconfig.json to generate a d.ts file. The generated d.ts file looks like this: /// <reference types="jquery" /> declare class KatApp implements IKatApp ...