The appearance and cleanliness of Three.js 3D models leaves much to be desired

Currently, I am working on 3D Modeling with Three.js and I am facing an issue in displaying a clean and neat product after reading a .DAE file. Despite adding light sources, my product display is not up to the mark. Here is the actual product that should be shown.

Here is a screenshot of my product image render screen, where no leather is shown and the overall appearance is dull.

I have provided the following code snippet:

<script>
var renderer, scene, camera, controls, light;
var geometry, material, mesh;

init();
animate();

function init() {

    document.body.style.cssText = 'margin: 0; overflow: hidden' ;
    renderer = new THREE.WebGLRenderer( { alpha: 1, antialias: true, clearColor: 0xffffff }  );
    renderer.setSize( window.innerWidth, window.innerHeight );
    document.body.appendChild( renderer.domElement );

    scene = new THREE.Scene();

    camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 50000 );
    camera.position.set( 100, 100, 100 );
    //camera.position.set(-15, 10, 15);
    controls = new THREE.TrackballControls( camera, renderer.domElement );
    scene.add(camera);

    light = new THREE.AmbientLight(0xffffff, 10);
    light.position.set(100,100, 100).normalize();
    scene.add(light);

    light = new THREE.DirectionalLight(0xffffff, 1);
    light.position.set(10, 10, 10).normalize();
    scene.add(light);

    var pointlight = new THREE.PointLight(0xffffff, 1, 0);
    pointlight.position.set(50, 100, 50)
    camera.add(pointlight);
    scene.add(pointlight);
    var spotLight = new THREE.SpotLight(0xffffff);
    spotLight.position.set(10,10,10);
    scene.add(spotLight);

    var pointHelper = new THREE.PointLightHelper(pointlight, 0.1);
    scene.add(pointHelper);
    this.renderer.render(this.scene, this.camera);
    geometry = new THREE.BoxGeometry( 10, 10, 10 );
    material = new THREE.MeshLambertMaterial( { ambient: 0x333333, color: 0x888888, opacity: 0.000001, transparent: true } );
   // material = new THREE.MeshLambertMaterial({ color: 0xffffff, vertexColors: THREE.FaceColors });
    mesh = new THREE.Mesh( geometry, material );
    mesh.name = 'basic template mesh';
    mesh.visible = false;
    scene.add( mesh );

}

function animate() {
    requestAnimationFrame( animate );
    renderer.render( scene, camera );
    controls.update();
}``

Using this code, I am encountering issues with displaying a dull product. Can someone assist me in resolving this problem?

Answer №1

The current material you are using is not suitable for the surfaces in your model. The MeshLambertMaterial is best for diffuse surfaces like paper, raw wood, and cloth, while the MeshPhongMaterial is more appropriate for surfaces with specular highlights like the ones on your leather and wood surfaces. Since your model has both types of surfaces, you will need to define separate materials for each. However, since you have a single object in your model, this may be challenging. You can try using a single MeshPhongMaterial and tweaking the parameters to achieve the desired effect for both surfaces.

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

Creating an array of objects in Node.js can be achieved by simply declaring an array

Here's the structure of my class: var Coin = { _id: null, createGame: function(id) { this._id = id; }, start: function() { } }; My issue is that I am unable to create an array of objects, as I can only create one. Can someo ...

Oops, seems like there was a problem with parsing the

I have encountered an issue when trying to decode the value of a PHP array sent as JSON format. Here is how I created the array: $ads = $atts['ads']; if (sizeof($ads) > 0) { foreach($ads as $social_item) { $sdbr = $social_ ...

Perform an AJAX call from the main file after inserting data using AJAX beforehand

I am in need of assistance with a question I have. On a page, an AJAX function is executed after the page finishes loading, creating a table in PHP that contains two buttons: one for changing passwords and the other for deleting. This table is then injecte ...

Attempting to automatically invoke the API every minute, rather than relying on the user to reload the page

I currently have fetchCoins() in my mounted() function, which calls the API whenever a user refreshes. My goal is to call the API once, store the data in local storage, and then retrieve the data every minute. methods: { async fetchCoins() { con ...

What procedures should I follow to transition from my pygame client to a browser-based game?

After developing a game server in Python to connect with multiple clients using Pygame via sockets, I realized that the turn-based card game I created doesn't require a lot of data flow since it's in JSON format. To avoid the need for clients to ...

Is there a way to automatically change the full screen background on refresh?

Is there a way to have the background image of this website change to different pictures every time the page is refreshed? I'm curious about how this can be achieved. I noticed that Offliberty is able to do this. I tried looking at the source code b ...

What is the best way to save a Firebase user's unique identifier in a React application?

In the process of developing a React web application, I am focusing on allowing users to register using their email and password. Once registered, each user will have access to their profile information. I have outlined my Firebase data structure below: ...

Encountering the error message "Unexpected token export" while attempting to implement the "framer-motion" package with Webpack

My experience with NextJS has been smooth sailing until now. I recently added the "framer-motion" module to animate some components, and it caused a major issue. Whenever I navigate to a page containing the import statement: import { motion } from "fr ...

I keep encountering an error that says "ReferenceError: localStorage is not defined" even though I have already included the "use

I have a unique app/components/organisms/Cookies.tsx modal window component that I integrate into my app/page.tsx. Despite including the 'use client' directive at the beginning of the component, I consistently encounter this error: ReferenceErr ...

Quirks of Emscripten Exported Functions in Visual Studio

As I start delving into Emscripten, I've encountered a puzzling issue with exporting functions for use in JavaScript. Working on a test project involving libsquish, the specific details aren't crucial to my question beyond the header/code filenam ...

Choose the initial p tag that includes an image, based on the content of another div

I am trying to figure out how to manipulate the code on my website: <div class="the-post-thumbnail"> <img src="" alt="" width="" height="" /> </div> <div class="post-body"> <p><img src="" alt="" width="" height="" ...

What is the method for configuring the URL of an ajax request to open in a separate window?

I am currently working on an ajax call where I need to open a URL in a new tab or window. Since I'm still learning about ajax, I would greatly appreciate any help and explanation that you can provide. Below is the code snippet: $.ajax({ url: &apo ...

I have encountered an issue where after declaring a JavaScript variable on a specific page, including the JavaScript file does not grant access to it

<script type="text/javascript"> $(document).ready(function () { var SOME_ID= 234; }); </script> <script type="text/javascript" src="<%= HtmlExtension.ScriptFile("~/somefile.js") %>"></script> ...

Dealing with errors when working with cross-domain JSONP requests in jQuery can be a

My attempts to capture a bad request error using my jquery code have been unsuccessful. $.get('http://example.com/', {}, function () {}, 'jsonp') .done(function () { // never fires }) .fail(function () { // never fires }) .a ...

Is the Angular Karma test failing to update the class properties with the method?

I am struggling to comprehend why my test is not passing. Snapshot of the Class: export class Viewer implements OnChanges { // ... selectedTimePeriod: number; timePeriods = [20, 30, 40]; constructor( /* ... */) { this.selectLa ...

Guide on changing the order of Vue sibling components when rendering a shared array within a parent component list

Currently facing a unique challenge and seeking input: Within the 'App', utilize 'TestListItem' for odd item indexes and 'TestListBetterItem' for even indexes. The same index must be used for both components. Initial attemp ...

Ways to boost heap capacity in Corb2 for MarkLogic

I encountered a challenge while running my custom deletion framework on a massive dataset. When attempting to execute Corb2, I started receiving the warning below and occasionally even encountered errors due to insufficient memory. WARNING: Slow receive! C ...

obtaining user information from API using the x-api-key

As a beginner JavaScript programmer, I'm attempting to fetch user information. Is there a simple way to search for a specific person like Laurel Gates with the USERID: 987654321? English is not my native language, so I apologize for any mistakes. Here ...

The alignment of the point on the Highchart line appears to be off

I've encountered a minor issue while using Highstock type Highchart for my statistics. I am utilizing the angular version of highchart. Take a look at the screenshot below: https://i.sstatic.net/HPCkw.png As evident from the image, the point is not ...

I need help figuring out how to retrieve the full path of an uploaded file in JavaScript. Currently, it only returns "c:fakepath" but I need

Is there a way to obtain the complete file path of an uploaded file in javascript? Currently, it only shows c:\fakepath. The file path is being directly sent to the controller through jquery, and I need the full path for my servlet. Are there any alte ...