A-Frame Visual Illumination

In my A-Frame AR scene, there is an image (transparent png) that can be moved and resized using gestures.

My goal now is to adjust the brightness of this image based on the light estimated from the camera input. I have successfully implemented the light estimation feature and initially thought of applying a CSS filter: brightness(x.x) to the image using the light estimation value.

Unfortunately, applying CSS directly to the <a-image> element does not seem to yield any effect.

As a result, I believe this effect can be achieved using materials and shaders, but I am unsure about how to proceed. I attempted to use a flat shader and adjust its opacity, but this resulted in the entire image becoming slightly opaque with a black tint.

Below is an example of the shading approach I experimented with:

<a-scene>
      <a-image src="http://assets.stickpng.com/thumbs/580b57fcd9996e24bc43c52d.png" 
         position="0 2 -3"
         rotation="0 0 0"
         height="5" 
         width="5"
         material="shader:flat;color:black;opacity: 0.5; transparent: true">
      </a-image>
    </a-scene>
    

I also experimented with a standard shader using emissiveIntensity, but had difficulty achieving full darkness with black. Other colors come close to the desired effect, yet a completely dark image remains out of reach:

//when set emissive to black, the image remains unchanged
    material="shader:standard;color:white;emissive:red;emissiveIntensity:0.5; 
    
    //using this approach results in complete blackness, but the image becomes invisible
    material="shader:standard;color:black;emissive:white;emissiveIntensity:0.5"
    

jsfiddle

Any suggestions on how to achieve this effect?

Answer №1

After some experimentation, I figured out the solution to my problem. Simply setting the material to a standard shader with no additional modifications and adjusting the ambient light intensity manually did the trick perfectly. This replaced the default settings that A-Frame includes.

material="shader:standard"

If anyone knows of a more efficient method for achieving this, please share your insights in a response.

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

Effortlessly Achieving Full Height Section Scrolling in Vue3

I have two sections, named One and Two, each taking up full-screen height and width (ignoring the top navbar in the video). As a user scrolls through my page, I want to prevent the sections from being partially scrolled. The window should display either ...

Creating a new row in a Tabulator component in React and retrieving the data

I have incorporated the react-tabulator library into my project and I am looking for guidance on how to dynamically add new rows once the tabulator has been rendered. Ideally, I would like to include a button below the tabulator that enables users to add a ...

Why aren't the kittens loading in Next Js?

Following the guidance in the Next Js documentation, I created a next.config.js file to inform Next Js that I want to incorporate kittens into my app. The resource for the kittens can be found at: This is how the next.config.js file appears: module.expor ...

Guide to changing the class of a particular child element when the parent element is clicked with vanilla JavaScript

Upon clicking the parent button, a class within its child element will toggle to show or hide. If the child element is selected, a loading animation will appear for a brief moment before reverting back to its original hidden state. I attempted to achieve ...

Modifying Props in Reactjs: Ways to update data passed from parent component to child component

Currently, I am working on a project where I have multiple components on a page and pass data between them using props. The issue arises when I update the data in the parent component but the child component still uses the old data. Let me illustrate with ...

Tips for aligning 2 columns when both table cells contain inner tables

Concerning my HTML table, cells #3 and #4 contain inner tables. I am facing an issue with aligning the rows within each table in cell #3 and cell #4 properly. Sometimes, the length of text in a row exceeds a single line, causing misalignment with the othe ...

Top of screen not showing NAV menu

Is there a way to keep my main navigation menu fixed at the top of the page? I have both a hamburger nav menu that pops up when clicked and an embedded page nav menu. I want the hamburger nav menu to always stay on top, but for some reason, the embedded n ...

Submitting a form with JQuery and Ajax technology

I am encountering an issue where I need to submit a form within Ajax and I keep getting a 'form.submit is not a function' error in jQuery. $("#form").validate({ // Define validation rules rules: { type: "required", group ...

What steps should I take to ensure that my table is positioned above my ContentPlaceHolder?

I'm currently working on setting up a menu in the MasterPage that will appear when a hyperlink is clicked. The YardimDokumaniMenuAHREF hyperlink triggers the display of the menu. Upon clicking it, a JavaScript function is invoked. However, I am facing ...

Why is there a discrepancy in the time between the client and server?

I am working on a small script to test the delay for a post request locally and online. After comparing both dates, I noticed that the time difference was quite unusual. The client side time appears to be slightly ahead of what it should be. //server// a ...

GitHub Pages images not loading properly

I am currently sharing some basic webpages (HTML, CSS, and a bit of JS) from my GitHub repository. However, I have encountered an interesting issue when viewing the index.html page in Chrome (55.0.2883.95, 64 bit) by clicking on the URL provided in the rep ...

Struggling to choose an element within $(this) despite being able to view it in the $(this) outerHTML

I have a question regarding jQuery 1.12. I am attempting to target an element within $(this). $(".select").bind('keydown', function(event) { elt = $(this)[0]; console.log(elt.outerHTML); elt = $(this)[0].search("li") console.log ...

Display an Open Dialog window when a Button is clicked

On a button click, I need to display an Open Dialog box. To achieve this, I am utilizing the FileUpload control for file uploading purposes, however, I prefer not to expose it to the user and would rather display a Button instead. ...

Fade in the background of table row clips using jQuery's fadeIn() method

When using the fadeIn() function to change the dimensions of a table, Firefox is clipping the background of the newly shown rows. If I click away from the tab and then return, the background is restored. This issue does not occur in Chrome. I am using Fi ...

Tips for increasing efficiency in Javascript development by leveraging the power of the computer to automate tasks and minimize manual work

When working with JavaScript, what techniques can be used to develop and test efficiently and accurately while focusing on algorithms rather than mechanics? Are there any useful tools that can be utilized in batch or command line mode (outside of an integr ...

What is the best way to set up an on-change listener for material-ui's <CustomInput...>?

I'm currently utilizing the React dashboard created by Creative Tim. I have a question regarding how to set up an onChange listener for a Here is the code snippet for the custom input class: import React from "react"; import classNames from "classna ...

Load styles in Nuxt asynchronously to improve performance

Is there a way to load styles asynchronously on the website or insert them in the footer? I am currently using Nuxt version 2.0.0 Here's what I have tried so far: Adding a plugin in webpack called async-stylesheet-webpack-plugin. However, this res ...

disable caching for xmlhttp request

One issue I am facing is with a JavaScript function that retrieves JSON data via an Ajax request. The problem I'm encountering is that the browser starts caching the response to this request, which means I am not getting the most recent data from the ...

Uncovering the entire list of results with NodeJS RegExp

I'm experiencing difficulties accessing the complete list of results when using .exec() on a regular expression in Node. Below is the code I am working with: var p = /(aaa)/g; var t = "someaaa textaaa toaaa testaaa aaagainst"; p.exec(t); > [ &apos ...

Adjusting Transparency using jQuery

I have a grid with 9 items, and I want each item to have an opacity of 0.5 initially. When the user hovers over an item, I want it and its contents to have an opacity of 1.0. Check out the JavaScript code below: $('.gallery-single').css({ opaci ...