The item I possess fails to catch the light in Three.js

I have a situation where CubeGeometry based meshes in a three.js scene are reflecting the PointLight I'm using globally, except for one particular mesh. This specific mesh was created "by hand" using just THREE.Geometry (adding vertices and faces through code) and does not reflect the light like the others. It doesn't even have color; the only way to give it some color is by setting a THREE.Color to the "emissive" key on the MeshPhongMaterial.

The geometry is generated dynamically by a JavaScript function. The lights I am using are:

    pointLight = new THREE.PointLight(0xFFFEF0, 1, 100000)
    pointLight.position = camera.position;
    scene.add(
        pointLight
    );  

And the mentioned mesh is created with this code:

        var floor = new THREE.Mesh(
            ShelfArchitect.Utils.getFloorGeometry(walls), 
            new THREE.MeshPhongMaterial(materialParams)
        );

Should I be adding something to materialParams? Or what could possibly be the issue here?

Answer №1

Seems like there's an issue with the geometry created manually, probably due to missing or inaccurate vertex normals.

To address this problem, try the following:

geometry.calculateFaceNormals();
geometry.calculateVertexNormals();

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

Unable to set a value for the variable

const readline = require('readline'); let favoriteFood; const rl = readline.createInterface(process.stdin, process.stdout); rl.question('What is your favorite food?', function(answer) { console.log('Oh, so your favorite food is &a ...

Leverage PHP to integrate JSON data for consumption by JavaScript

I've been exploring the integration of React (JavaScript) within a WordPress plugin, but I need to fetch some data from the database for my plugin. While I could retrieve this data in JavaScript using jQuery or an API call, because the data will remai ...

Make sure to include all enum type values within the function's body to ensure comprehensive coverage

I am defining an enumeration called ApiFunctions with values like "HIDE", "SET_READ_ONLY", and "DESCRIPTION". Also, I have a type ValueOfApiFunction that should include all values of ApiFunctions. Additionally, I have a logic that listens for messages on ...

Error: The route cannot be established within an asynchronous function

The following code snippet is from the api.js module, responsible for creating a test route: 'use strict'; module.exports = function (app) { console.log("before route creation"); app.get("/api/test", (req, res) => { ...

Determine the sum of all the values entered into the text fields

On my ASP.Net page, there is a screen where users can select between 1 and 5 text boxes to input an amount. Depending on certain criteria, a specific number of these edit boxes are displayed - no hiding involved. So if I choose to display 3 boxes, only 3 w ...

Executing a C# function from an HTML hyperlink

I am in the process of developing a website using ASP.NET C#. The site will feature a GridView with data that can be exported, such as to Excel or other formats. To handle the export functionality, I plan to utilize code from this resource. When a user c ...

What is the best way to assign the variable using Firebase data?

Having trouble setting a variable with data retrieved using a get() function on Firebase. export default { name: "customer-navigation", mixins: [navigationMixin], components:{AppSnackBar, authModule,AuthForm}, data () { return { drawer: fa ...

"Error encountered when attempting to upload directory due to file size

Utilizing the webkit directory to upload a folder on the server has been successful, however, an issue arises when there are more than 20 files in the folder. In this scenario, only the first 20 files get uploaded. The PHP code used for uploading the fold ...

Enhancing the performance of jquery selection speed

I am currently working on a code that manipulates the HTML code of an asp.net treeview. Since this code runs frequently, I need to ensure that it executes with maximum speed. I am interested in expanding my knowledge on jQuery selectors and optimizing th ...

Restrict the camera's ability to move within the boundaries of a designated 3D object

Is there a way to restrict camera movements to specific areas defined by 3D object/objects children? For instance, if there is a walkway object by the ocean and the intention is to limit camera movement to just forward and backward along that walkway. This ...

What purpose does the by.js locator serve in Protractor/WebDriverJS?

Recently, I've come across a new feature in the Protractor documentation - the by.js(): This feature allows you to locate elements by evaluating a JavaScript expression, which can be either a function or a string. While I understand how this locat ...

How can I redirect applications from a web browser to Safari?

Is there a way to redirect applications from a browser to Safari? For Android devices, I have implemented a feature where if a user opens my site through a browser built-in within apps like Facebook or Telegram, they are automatically redirected to Google ...

ngAnimate removeClass behaving unexpectedly

Recently, I've been delving into the ngAnimate module for AngularJS version 1.2.14 When employing $animate.addClass, everything seems to function as expected with the ng-animate, -add, and -add-active classes seamlessly added. However, my struggle a ...

Hidden checkboxes do not send their input values :(

There is a group of check-boxes that are contained within a DIV element. In some cases, this DIV container may be hidden. The issue arises when the values of these check-boxes are not being transmitted through $_POST if they are hidden. Is there a way to ...

Is transforming lengthy code into a function the way to go?

I have successfully implemented this code on my page without any errors, but I am wondering if there is a more concise way to achieve the same result. Currently, there is a lot of repeated code with only minor changes in class names. Is it possible to sh ...

Interactive <li></li> element for news ticker

Hello there! I am currently retrieving JSON data from a Wordpress site and converting the titles into list items as shown below: <?php $get=file_get_contents("https://www.thekashmirmonitor.net/wp-json/wp/v2/posts?categories=192"); $var=json_decode($get ...

Improving the form fields and Stimulus JS by eliminating the need to repeat the :data-action attribute for each individual field

I'm working with the following form <%= form_for( model, html: { :'data-controller' => 'enable-submit-button-if-fields-changed' } ) do |form| %> <%= form.text_field(:title, :'data-action&ap ...

Creating a running text (marquee) with CSS is a simple and efficient way to make

I encountered a significant challenge while delving into CSS animation. My goal is to create a "transform: translate" animation that displays text overflowing the content width as depicted in the image below. https://i.stack.imgur.com/sRF6C.png See it i ...

Tips for retrieving the total duration of the currently playing file in Media Player

Is it possible to use a media player control to play mp3 files in an asp.net application? I am curious about how I can determine when the playing process ends and the total time required to finish the file using javascript. Here is a sample code snippet: ...

Display the contents of an HTML Object tag without relying on any external packages

Is there a way to print a PDF without opening it in a new tab? In my project, I have embedded a PDF using the HTML Object tag: <> <object id="documentObject" data={fileSrc} type={fileType} height="100%" width="100%" ...