Neglecting a light source in the Three.js framework

Currently, I am in the process of constructing a 3D hex grid and my goal is to integrate a fog of war feature.

This is a glimpse of what the grid looks like at present:

The lighting setup I have arranged is as follows:

// Setting up hemisphere light
var hemisphereLight = new THREE.HemisphereLight(0xffffff, 0.3);
scene.add(hemisphereLight);

// Configuring point light
var pointLight = new THREE.PointLight(0xffffff, 0.7);
pointLight.position = camera.position;
pointLight.rotation.y = Math.PI/2;
scene.add(pointLight);

I am aiming to create tiles within the fog of war that do not react to the pointLight, instead only receiving the subtle illumination from the hemisphereLight. However, I am encountering difficulty in achieving this. Modifying the tiles to utilize

MeshBasicMaterial</code, which disregards any form of lighting, is not an option because I desire the "fog of war" tiles to still reflect the lighting from the <code>hemisphereLight
.

I am open to suggestions on alternative approaches for implementing the fog of war concept.

UPDATE:

I managed to resolve the issue by utilizing a custom shader.

Answer №1

I really like the idea, in my opinion.

Your best option is to custom create a ShaderMaterial specifically for the tiles representing the "fog of war". Within this shader, you'll need to ensure that only HemisphereLights are considered while ignoring all others.

Don't forget, if you opt for using ShaderMaterial and want to have access to the scene lights, make sure to include the material parameter lights: true. There are several examples within the three.js library showcasing how to achieve this functionality.

Using three.js version r.58

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

How to confirm the parent state in Angular's UI router?

In summary, I am seeking a function similar to state.is() that can verify a state with multiple child states from one of those child states? This is the structure I have: Parent 1 Child 1.1 Child 1.2 Child 1.3 Parent 2 Child 2.1 ...

What is the best way to create shapes in Three.js using the mouse?

I'm searching for a way to enable users to draw their own cube, similar to the example here (try drawing a cube on a grid): Screenshot: Shapesmith has efficiently solved this using Three.js, but it relies on Backbone.js. I'm wondering if it&apo ...

Is it possible for Javascript to manipulate the DOM of an Ajax text/html response?

My goal is to implement Ajax to retrieve an HTML page and extract a specific div by its ID, then insert that div into the current page. This involves loading a second page via Ajax, extracting the specified div from the response, and placing it within th ...

Node.js is being utilized to send an abundance of requests to the server

Here is my setup: var tempServer=require("./myHttp"); tempServer.startServer(8008,{'/fun1':fun1 , '/fun2': fun2 , '/fun3':fun3 , '/fun4':fun4},"www"); This code creates a server on localhost:8008. If I enter th ...

Concealing a Column within a Hierarchical HTML Table

Can anyone guide me on how to hide multiple columns using jQuery with the ID tag? I've tried implementing it but it doesn't seem to work. I also attempted to switch to using Class instead of IDs, but that didn't solve the issue either. Any h ...

Mastering the art of linking asynchronous callbacks based on conditions

I have a node.js express project where I need to create a switch-to-user feature for admin users. The admin should be able to enter either a username or user-id in a box. Below is the code snippet that handles this functionality. The issue arises when th ...

The jQuery each function in combination with the index function allows for

I'm struggling to make this jQuery script work properly: $(document).on('knack-scene-render.scene_126', function() { $('#view_498 > div.kn-list-content.columns.is-multiline').each(function(index) { if ($(this).eq(inde ...

Refreshed page causing hide/show div to reset

Hello there, I'm currently working on a web application and I need to implement some JavaScript code. The application consists of three sections, each with its own title and button. When the button is clicked, a hidden div tag is displayed. Clicking t ...

Utilizing HTML's multiple input type color feature to save selected colors directly to the database

I am currently using the input type color to select colors for customizing my site. I save the selected color to a database and then retrieve it to apply it to different areas of the site. This works well for a single input type color, but now I have mul ...

What is the process for locating the src value of an image that has been uploaded utilizing fileReader?

I am currently working on a program that empowers the user to select an image for uploading. Once the user chooses an image, it activates the previewFile() function, which makes use of FileReader to display the selected image. Now, I'm in the process ...

Not all divs are triggering the hover event as expected

I am facing an issue while creating a webpage with overlapping background and content divs. The hover event works properly on the div with the class "content," but not on the div with the class "background." There is no interference with the event in the J ...

Styling is applied by Bootstrap to inputs in a form that are not required

I am currently working on validating a form for empty fields using Bootstrap. When submitting and validating the form with the form.checkValidity() method, I noticed that even the non-required fields are being styled as if they are required. Is this normal ...

Deleting a character creates an error

I am conducting a small experiment with a simple goal: to filter and search for users whose names match the current value typed into an input text field. To implement this functionality, I am using RegExp(). Everything works well except when I delete a cha ...

Issue: Query is not re-executing after navigatingDescription: The query is

On my screen, I have implemented a query as follows: export const AllFriends: React.FunctionComponent = () => { const navigation = useNavigation(); const { data, error } = useGetMyProfileQuery({ onCompleted: () => { console.log('h ...

Error: selenium web driver java cannot locate tinyMCE

driver.switchTo().frame("tinymce_iframe"); String script="var editor=tinyMCE.get('tinymce_textarea');"; JavascriptExecutor js=(JavascriptExecutor) driver; js.executeScript(script); I'm encountering a WebDriverException while try ...

The inner workings of Virtual DOM in React and Vue disclosed

I am a student experimenting with creating my own Virtual DOM for a college project in JavaScript, keeping it simple without advanced features like props or events found in popular frameworks like React and Vue. I'm curious about code splitting. If I ...

"Exploring the possibilities of Sketchfab through an AJAX JSON

Currently, I am on a quest to gather the URL for the thumbnail of a Sketchfab model. To access this information, you can visit: Upon visiting the above URL, all the necessary details are visible to me. My next step involves making an AJAX call to dynami ...

Fading text that gradually vanishes depending on the viewport width... with ellipses!

I currently have a two-item unordered list positioned absolutely to the top right of the viewport. <header id="top-bar"> <ul> <li> <a href="#">David Bowie</a> </li> <li> ...

Storing Boolean values in MongoDB with Express JS: A Step-by-Step Guide

I am encountering an issue where a Boolean value that I am trying to store in Mongodb always returns false. Below is the schema of my database: const UserSchema = new Schema({ name: String, password: { type: String, required: true }, isAdmi ...

Developing a breakout-style game using three.js: finding the end of the game board

As I dive into learning Three.js by creating a game, I've encountered a challenge with outdated resources and the constantly changing library. Currently, I can move my paddle with my mouse and launch the ball on click, but I'm struggling to preve ...