What is the significance of rendering models with a blade-colored using Three.js?

https://i.sstatic.net/BlZ6E.png

Hey there, I've imported my model (obj + mtl + texture) but it appears with a different color.

It's supposed to look like this:

https://i.sstatic.net/9BwS9.png

Currently, here's the scene configuration code:

loadModel()

    scene.current.background = new THREE.Color( 'transparent' );

    scene.current.add(new THREE.AxesHelper( 5 ));

    const mesh = new THREE.Mesh( new THREE.PlaneGeometry( 100, 100 ), new THREE.MeshPhongMaterial( { color: 0xffffff, depthWrite: false } ) );
    mesh.rotation.x = - Math.PI / 2;
    mesh.receiveShadow = true;
    scene.current.add( mesh );

    controls.current.enableDamping = true; // an animation loop is required when either damping or auto-rotation are enabled
    controls.current.dampingFactor = 0.2;
    controls.current.screenSpacePanning = false;
    controls.current.maxPolarAngle = Math.PI / 2;
    controls.current.maxDistance = 200
    controls.current.minDistance = 20
    controls.current.target = new THREE.Vector3(0, 16, 0)

    camera.current.position.set(-3, 17, 8);
    camera.current.lookAt(new THREE.Vector3(0, 15, 0));
    controls.current.update();

    scene.current.background = new THREE.Color(0xFFFFFF);

    const ambilentLight = new THREE.AmbientLight(0xffffff, 0.5)
    scene.current.add(ambilentLight)

    const hemiLight = new THREE.HemisphereLight(0xffffff, 0xffffff);
    hemiLight.position.set(0, 500, 30);
    hemiLight.castShadow = true
    scene.current.add(hemiLight);

    scene.current.add(new THREE.HemisphereLightHelper(hemiLight, 5));

    const dirLight = new THREE.DirectionalLight(0xffffff, 0.5);
    dirLight.position.set(-10, 50, 50);
    dirLight.castShadow = true;
    scene.current.add(dirLight);

    scene.current.add(new THREE.DirectionalLightHelper(dirLight, 5));

    renderer.current.shadowMap.enabled = true;
    renderer.current.setPixelRatio(window.devicePixelRatio);
    renderer.current.setSize(window.innerWidth, window.innerHeight);
    renderer.current.outputEncoding = THREE.sRGBEncoding;
    renderer.current.toneMapping = THREE.ACESFilmicToneMapping;
    renderer.current.toneMappingExposure = 1;
    renderer.current.physicallyCorrectLights = true;
    container.current.appendChild(renderer.current.domElement);

    window.addEventListener('resize', onWindowResize);

    animate();

I'm not entirely sure if it's a lighting issue or something else. Does anyone have insight into this problem?

Answer №1

If you're dealing with OBJ/MTL files and adjust WebGLRenderer.outputEncoding to THREE.sRGBEncoding;, it's likely that the problem stems from an incomplete color space setup. There are two ways to resolve this:

  1. Leave outputEncoding untouched.
  2. Update the encoding property of all color textures to THREE.sRGBEncoding;.

Because OBJLoader provides a THREE.Group instance, you can modify the textures like this:

group.traverse( function( object ) {

    if ( object.isMesh === true && object.material.map !== null ) {

        object.material.map.encoding = THREE.sRGBEncoding;

    }

} );

By the way, tone mapping is typically used when applying HDR textures to your scene.

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

Equivalent of ResolveUrl for loading scripts without the need for server technology

I am in the process of converting an ASP.NET web page into a plain HTML web page. Most of the work is done, however, I am having trouble replacing the ASP.NET Page.ResolveUrl function when setting a reference to a javascript file: <script src="<%= ...

Using a render target causes certain elements of my visual graphics to become hidden

Hey there, I've been experimenting with render targets lately and encountered some issues. I've put together a simplified example below: init = function() { // RENDERER canvas = document.getElementById("mycanvas"); renderer = new THREE ...

Error encountered when serving tiles using Node JS and Leaflet from the same domain

I have been utilizing the script found at: to run my web application that overlays tile layers from: However, for the past two days, I have been experiencing an issue where tiles are being called in places where they were not previously, causing slow til ...

JavaScript: Iterating over the characters of items in an array

I'm currently facing an issue with the following task: Create a function that accepts a list of words and returns an object indicating how many times each letter appears. For example: var data = ['hat', 'cat', 'dog']; ...

Responsive design with Flexbox, interactive graphics using canvas, and dynamic content resizing

I'm having difficulties with my canvas-based application. I have multiple canvases, each wrapped in a div container alongside other content. These containers are then wrapped in an "hbox" container. The objective is to create a dynamic grid of canvas ...

What is the best way to organize a data tree in JavaScript for easy parsing on the frontend?

I'm struggling with a unique tree data structure in my code. Each node is represented by an object, and I need to transfer the entire tree to the front-end. Unfortunately, JavaScript's limitation on using objects as keys prevents me from implemen ...

Checkbox remains selected even after navigating back

I am currently working on a code that involves using checkboxes. When I click on them, the checkbox value is appended to the URL with a hash. However, when I go back or press the back button, the URL changes but the checkboxes remain checked. Below is the ...

align all items centrally and customize Excel columns based on the length of the data

Is there a way to dynamically adjust the column width based on the length of data in an Excel report using PHPexcel? Additionally, how can I center all the data in the Excel sheet? Here is the current code snippet: <?php if (!isset($_POST['send&a ...

Guide on updating individual rows in Google App Script using data from a different sheet

I am trying to create a script that will pull a value from column[3] in the ZONE sheet to the active sheet, specifically in column 56 of the job sheet when the zonelist value matches the zone value in different sheets. The script should check the range fro ...

How can I retrieve the current session's username when passport.js is returning a promise containing `{false}` for `req.user`?

While working in Node.js, I implemented the passportJS LocalStrategy to handle user authentication. One of the functionalities I used was req.getAuthenticated() This function allows me to check if the current session is authenticated. Next, I needed to r ...

Ways to stop the react-router from causing the page to refresh

Need assistance with React Router issue I'm working on a project in reactJs using react-router-dom v5. I have set up a default route for routing. <Redirect to={"someComponent"}/> The problem is that when I refresh the page, it auto ...

Issue with Electron Remote process failing to take user-defined width and height inputs

I'm currently facing an issue with utilizing remote windows in electron. I am attempting to process user input and use that input to generate a new window with specific width and height. However, when I hit submit, nothing happens. I can't figur ...

The API call is successful, however the data is empty when returned in the callback function

Utilizing npm Express and Request modules, I am retrieving movie information through an API: var express = require("express"); var app = express(); var request = require("request"); app.get("/results", function(req, res){ console.log(getBody("http:// ...

An option selection component for Vue.js

I'm attempting to design a component like the following: <template> <option v-for="(text, value) in options" :value="value"> {{ text }} </option> </template> Unfortunately, I encountered an error me ...

Extracting a floating picture from an Excel spreadsheet using ReactJS

Is it possible to extract an image from an Excel sheet that is not contained within a cell, but instead appears to be floating above the cells? The XLSX library only gathers cell information and does not provide a solution. Are there alternative methods su ...

What is the process for retrieving a function value from a JavaScript file and displaying it in an ASP.NET MVC view?

I am in the process of separating my view from JavaScript. In my view, I call a function in a JavaScript file to create a chart. Below is the JavaScript file and the function: function createPieChart(chartID, pieChartData) { chartID.kendoChart({ da ...

Is it possible to transfer an HTML table to a PowerPoint presentation directly from the client

Is there a specific jquery or javascript solution available for converting an HTML table directly into a PowerPoint presentation? So far, the only solution I have come across is html table export, which provides export options for various file formats. H ...

Modifying the content in one form field based on the information entered in another input field

I have a scheduling application that includes a form for selecting both the departure city and arrival city. The app is designed for international travel only, so when a user selects a city from Hungary as the departure city, I want to exclude all Hungaria ...

Utilizing ReactJS to Display Data in Double Columns

I have a Component that looks like this: export const RenderDetail = props => { const createRows = props.content.reduce(function (rows, key, index) { console.log('rows, key, index', rows, key, index); return (index % 2 === 0 ? rows.p ...

Display a single item using Jquery when clicking on an element with the same class

I'm relatively new to JQuery/Javascript scripting and I'm having some difficulty. How can I display one item with the same class without affecting the other items? Here is my code: $(function() { $('.embedContainer > .myPosterImage& ...