Material appears abnormally shiny and reflective

I've been working on rendering an object with materials using Three.js, but I've noticed that the final result looks different from what I see in other online viewers, such as , which also utilizes Three.js under the hood.

I've attempted to increase the level of details (LOD) and have experimented with NearestFilter / LinearFilter, but to no avail.

Here is a screenshot of how it should look when rendered by 3dviewer.

However, this is how it appears in my application

The object looks more natural in the 3dviewer version, while in mine, it appears too shiny and glossy.

Should I consider applying a specific filter (although I have not found it in the 3dviewer sources) or perhaps adjust the lighting?

Here is the current code I'm using:

... (code block unchanged) ...

For access to the object, materials, and textures, you can download them from this dropbox link.

Answer №1

Accessing the materials associated with your object is a straightforward process.

objLoader.load('b.obj', function (object) {
    // Retrieve material
    var mat = object.material;

    // Adjust material properties
    mat.metalness = 0;
    mat.roughness = 1;

    scene.add(object);
    object.position.y -= 100;

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

    let boundingBox = new THREE.Box3().setFromObject(object)
    let size = boundingBox.getSize()
});

The method of accessing the material varies based on the organization of your object. It may involve object.children[0].material or

object.children[0].children[0].material
, depending on the nested structure.

Answer №2

Encountering the same issue led me to implement a filter across all my materials:

function collectAllMaterials( object ) {
 var result = [];
 object.traverse( function( node ) {
  if ( node instanceof THREE.Mesh ) { result.push( node.material ) }
 } );
 return result;
}

collectAllMaterials( <your-3D-Object-Here> ).forEach( function ( mat ) {
 if ( Array.isArray( mat ) ) {
  mat.forEach( function( cmat ) { cmat.shininess /= 19; } )
 }
 else { mat.shininess /= 19 }
} );

You may need to adjust the static value of 19 in the code based on your specific requirements. Feel free to reach out if you need further clarification, I can provide a live demo for you.

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

Using Vue.js: Execute a function with a delay, but start the delay over if there is any user input

Imagine a scenario where I have a form that is connected to an API and displays information based on user input. Whenever the user makes changes, such as adjusting the number of results per page, the component should react dynamically by loading new data. ...

Encase the event handler within JQuery

Here's an example of inputs with OnBlur event handlers: <input name="abc" tabIndex="5" class="datetime" onblur="if (CheckMode(this))__doPostBack('abc',''); else return false;" /> Now, in JQuery Form ready function, I want ...

Using Node.js await function results in an undefined response

One issue arises when a POST call is made to /login; the const user variable ends up being assigned as undefined even though getUser() consistently returns the expected value. Interestingly, the call console.log(getUser()); located at the end of the file e ...

The absence of jasmine-node assertions in promises goes unnoticed

Everything seems to be running smoothly with the code below, except for the assertion part. Whenever I run the test using Jasmine, it reports 0 assertions. Is there a way to include my assertions within promises so they are recognized? it("should open sav ...

Top tips for handling HTML data in JSON format

I'm looking to fetch HTML content via JSON and I'm wondering if my current method is the most efficient... Here's a sample of what I'm doing: jsonRequest = [ { "id": "123", "template": '<div class=\"container\"&g ...

Using the Selenium webdriver to reach the bottom of the page by scrolling vertically

Is there a way to determine if I have scrolled to the bottom of the page vertically? I have been using Webdriver and pressing the page down key repeatedly within a for loop, like so: for(int di=0; di<40; di++) { driver.findElement(By.tagName("body ...

Is there a way to retrieve all "a" tags with an "href" attribute that contains the term "youtube"?

My goal is to capture all a tags that have the href attribute containing the word youtube. This task requires the use of jquery. ...

I am working on customizing my WordPress website using three.js to add a background with a wireframe effect. However, I am facing difficulties in placing a sphere at the end of each line

I have a beautiful turquoise diamond and I want to incorporate a directional camera view in the background of a WordPress section. However, I am unsure how to achieve this. The issue I'm facing is that I created a wireframe over the diamond, but when ...

Tool for controlling the layout of the viewport with Javascript

I have experience using ExtJS in the past to create dashboards, and one of my favorite features is the full-screen viewport with a border layout. This allows for easy splitting of a dashboard into panels on different sides without creating excessive scroll ...

Opting to utilize a multidimensional JavaScript array or object is a more efficient method

Here is a breakdown in JSON format: jsonResponse Folder 01 Product 01 - Folder 01 Product 02 - Folder 01 Product 03 - Folder 01 Folder 02 Product 01 - Folder 02 Product 02 - Folder 02 Product 03 - Fo ...

How can one create a walking person animation using Blender, and what are the necessary coding procedures to export it as a JSON file?

I am in need of displaying a walking person animation on a web page using a character model created in Blender and saved as a JSON file. Can you provide me with detailed steps on how to achieve this? Thank you, ASH ...

Tips for handling a JSON payload retrieved through a POST request

I'm currently working on a button that triggers a POST call to retrieve a json response from the server. My goal is to display this json response in a new (chrome) browser tab. Here's what I have so far using Angular: $http.post(url, data) .t ...

Set an attribute without replacing any existing class attributes

I have developed a script that updates the class attribute of the body element on my website when an option is selected from a dropdown menu. However, I am facing an issue where it overrides the existing dark mode attribute. The purpose of this script is ...

Guidelines for setting the Id and value for a Hidden field

I am working with a gridview that has a few rows and columns, each containing ListBox Controls. Markup: <asp:GridView ID="gvDataEntry" runat="server" AutoGenerateColumns="False" <Columns> <ItemTemplate> <asp:ListBox ID="lst ...

What is the best way to choose a specific JSON element?

Seeking information from an API, my goal is to extract specific data using JavaScript selectors. I am specifically interested in two objects from the JSON below: [ { "symbol": { "tickerSymbol": "@CH20", "vendor": "DTN", "marketName ...

The issue arises when the d3 startAngle and endAngle values are set to NaN, resulting in an

I am working with a dataset that includes the following information: { current: 5 expected: 8 gap: -3 id: 3924 name: "Forhandlingsevne" progress: "0" type: 2 } Now, I have implemented the ...

Is it possible to dynamically retrieve an element's style from @ViewChild in an Angular 2 component without needing an active approach?

For instance, there's an element in the template that uses a local variable #targetElement to retrieve its current width whenever needed. However, I prefer not to calculate the style programmatically. I attempted using a setter with the @ViewChild ann ...

The dynamic loading of an HTML/JavaScript input range object within a div is not functioning properly

Hey there, I have a hidden div containing a range input: <div id="hiddencontainer" style="display:none;"> <input id="range1" type="range" min="1" max="10" step="1" name="rating" value="1" onmousemove="showrangevalue()"/> </div> The ...

Having difficulty arranging the material ui components in a left-to-right alignment

Hello, I need assistance with my bilingual website that supports English and Arabic. I am looking to align the MUI text fields and dropdowns in a right-to-left direction. The labels of the text fields and dropdowns are not styled properly. Currently, I am ...

Switch between different react components

When a component is opened, I want all other components to close. Whenever they are clicked, they will display a list. class ParentComponent extends Component{ constructor(props){ super(props) this.state= {...} } render(){ return( ...