The pointLight feature in Three.js appears to be malfunctioning

I am a beginner in the world of WebGL and Three.js, so forgive me if this is a basic question that has been asked before.

Recently, I've been experimenting with my code to create a mini solar system.

I utilized SpotLight with SpotLightHelper, as well as PointLight and PointLightHelper. I used BoxGeometry and SphereGeometry for the shapes. Interestingly, BoxGeometry seems to receive light from PointLight just fine, but SphereGeometry does not.

Could you help me pinpoint what mistake I might have made? Thank you in advance for your assistance.

var width, height;
    var camera, renderer, scene;

    var position = {
        earth: {
            x: 200,
            y: 1,
            z: 0,
            theta: 0,
            traceRadius: 200
        }
    };

    width = window.innerWidth;
    height = window.innerHeight;

    scene = new THREE.Scene();
    camera = new THREE.PerspectiveCamera(45,        // Field of view
        400 / 400,  // Aspect ratio
        .1,         // Near
        10000       // Far);
    );
    camera.lookAt(scene.position);
    camera.position.set(0, 0, 1000);
    scene.add(camera);

    renderer = new THREE.WebGLRenderer();
    renderer.setClearColor(0x000000, 1);
    renderer.setSize(width, height);
    renderer.shadowMapEnabled = false;

    var sunGeo = new THREE.SphereGeometry(70, 128, 128);
    var sunMat = new THREE.MeshLambertMaterial({color: 0x00ff00});
    var sunMesh = new THREE.Mesh(sunGeo, sunMat);
    sunMesh.position.set(0, 0, 0);
    sunMesh.castShadow = true;
    sunMesh.receiveShadow = false;
    scene.add(sunMesh);

    var boxGeo = new THREE.BoxGeometry(50, 50, 50);
    var boxMat = new THREE.MeshLambertMaterial({color: 0xfff0f0});
    var boxMesh = new THREE.Mesh(boxGeo, boxMat);
    boxMesh.position.set(-100, 100, 0);
    boxMesh.castShadow = true;
    scene.add(boxMesh);

    var earthTraceGeo = new THREE.CircleGeometry(position.earth.traceRadius, 128, 128);
    var edges = new THREE.EdgesGeometry(earthTraceGeo);
    var line = new THREE.LineSegments(edges, new THREE.LineBasicMate...

To see the complete code, click on this link: https://jsfiddle.net/ne7gjdnq/623/

Answer №1

The brightness emanating from the point light source remains hidden, as the glow is a shade of red 0xff0000, contrasting with the green hue 0x00ff00 of the spherical shape.
The crimson luminosity of the light does not impact the emerald sphere. However, it does have an effect on the box due to its color being 0xfff0f0.

It's worth mentioning that in the light model, colors undergo a type of multiplication process. If one part of the color equation results in 0, the outcome will be 0 as well.

To address this issue, consider altering either the color of the light source

var pointLight = new THREE.PointLight(0xffff00, 1000, lightSize, 2);

or modify the color of the sphere

var sunGeo = new THREE.SphereGeometry(70, 128, 128);
var sunMat = new THREE.MeshLambertMaterial({color: 0xffff00});
var sunMesh = new THREE.Mesh(sunGeo, sunMat);

This adjustment should help resolve the challenge at hand.

Observe the outcome in the Example:

... (JavaScript code excerpt)
... (CSS snippet)
... (HTML script inclusion)

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

What is the process for sending text messages in a local dialect using node.js?

Having an issue with sending bulk SMS using the textlocal.in API. Whenever I try to type a message in a regional language, it displays an error: {"errors":[{"code":204,"message":"Invalid message content"}],"status":"failure"} Is there a workaround for se ...

Whenever I run "npm run build-dev" in Webpack with JavaScript, the browser continuously refreshes

I've been working on familiarizing myself with webpack lately. I've managed to convert everything to load modules and plugins, and it's all working fine when I use "npm run build-prod". Even when I use liveServer, the HTML loads properly. Ho ...

Navigating to a different URL in a remoteMethod with Loopback and Express

Can anyone provide any guidance on how to redirect to a URL within a model function or remoteMethod? I've been struggling to find documentation on this. Here is the code snippet for reference: Model Function (Exposes /catch endpoint) Form.catch = func ...

Issues encountered when trying to retrieve data from an Express server

I have set up a NodeJS server with Express.js and I am attempting to send a request to it using fetch. fetch("http://localhost:3001/api", { method: "POST", headers: { "Content-Type": "application/json", ...

Tips for transferring information from the isolate scope to the parent scope

As a newcomer to AngularJS, I am exploring the creation of directives and how to invoke functions from the parent scope within them. While I have successfully achieved this, I am now grappling with the challenge of passing data from the isolate scope via a ...

Different ways to add a new property using the JavaScript spread operator

Looking to enhance an existing array of objects by adding a new object: const oldArray = [{ name: 'First', value: 'one' }, { name: 'Second', value: 'two' }, { name: 'Third', value: 'three' }] cons ...

jquery makes it easy to create interactive hide and show effects

The main concept is to display the element upon clicking and hide it when there is any mouse click event. Below is the HTML code I'm using: <ul> <li> <span class="name">Author 1</span> <span class="affiliation"&g ...

Using JavaScript to dynamically hide an ASP ComboBox based on the selected value in another ASP ComboBox in an ASP.NET application

I am facing an issue with two asp comboboxes. One is named cmb_stocktype, and the other is named cmb_tagno. My requirement is that when I select cmb_stocktype with the value of WithStock, then cmb_tagno should be displayed; otherwise, it should be hidden u ...

Sending various types of data to an MVC C# controller using AJAX

Currently, I am utilizing AJAX to retrieve information from a Razor View and forward it to the controller. Although everything is functioning as expected, I now face the challenge of passing an array along with a string as the data: // View - JavaScript v ...

PHP - Implementing a Submit Button and Modal Pop-up AJAX across multiple browsers in PHP

As a newbie in PHP AJAX coding, I'm facing a challenge with having two browsers. My goal is to click the submit button on one browser and have a modal popup on the other browser simultaneously. Essentially creating a chat system where only a button an ...

Monitor a user's activity and restrict the use of multiple windows or tabs using a combination of PHP and

I am looking to create a system that restricts visitors to view only one webpage at a time, allowing only one browser window or tab to be open. To achieve this, I have utilized a session variable named "is_viewing". When set to true, access to additional ...

Creating a specialized filter for AngularJS or customizing an existing one

AngularJS filters are great, but I want to enhance them by adding a function that can check if a value is in an array. For example, let's say we have the following data: Queue = [ {'Name':'John','Tier':'Gold&ap ...

Arranging containers in a fixed position relative to their original placement

A unique challenge presents itself in the following code. I am attempting to keep panel-right in a fixed position similar to position: relative; however, changing from position: relative to position: fixed causes it to move to the right side while the left ...

Looking to automate the clicking of a JavaScript URL upon loading the page

I am currently utilizing the following JavaScript function for a link on the homepage. The requirement is for the link to be automatically clicked upon page load. Link- document.writeln("<a href=\"javascript: live_chat_link(m_sTicketType ...

Oops! A JSON parsing error occurred due to the presence of an unexpected token '}'

I encountered an issue while trying to develop a registration route using passportjs. When sending a request via Postman, I received the following error message: SyntaxError: Unexpected token } in JSON at position 119    at JS ...

Combining two meshes, one using ShaderMaterial

Having two meshes created from the same geometry and running the same animation, I noticed an issue. When left unchanged, both meshes remain synchronized perfectly, as desired. However, if I adjust their position or rotation even slightly, they become out ...

Using JSF to make AJAX calls to PrimeFaces components

Hey, I'm looking to periodically call a back bean from a JavaScript function in order to refresh a panel on my page without refreshing the entire page. Here's the script I've written: $('#submitbutton').click(); <h:commandButt ...

Troubleshooting: Issues with jQuery's clone() function

I'm facing an issue with the code below. It works correctly when I use td instead of p. $(document).ready(function() { $("button").click(function() { $("th:contains('2G Band') ~ p").clone().appendTo("#2g"); }); }); <script src= ...

Encountering null values in IE8/IE7 JavaScript code

Although I am not a JavaScript expert, I have a simple function that works perfectly in all browsers except for IE8 and 7. function setSelected() { var backgroundPos = $('div.eventJumpToContainer').find('.selected').css('backg ...

What are the steps to reinitialize Grunt in a Yeoman project?

My Grunt installation seems to be causing a lot of errors out of nowhere. I'm using Yeoman to scaffold my app, but today when I run Grunt Test, I get the following error messages: Loading "autoprefixer.js" tasks...ERROR >> Error: Cannot find mo ...