Control color changes through animation with Three.js

I'm having difficulty adjusting the tint color for this animation in Three.js. No matter what color I apply, such as #008080 for green, the actual color appears as blue or something else. It seems like there is a calculation affecting the highlight color. How can I disable it or have more control over it?

  const PARTICLE_SIZE = 1;
  const textureAttr = {
    resolution: 64,
    radius: 32,
    color: '#008080'
  };

Check out a working example here:

https://jsfiddle.net/6cq1re9o/

Answer №1

The fragment shader altered the color:

// adjusting RGB values with noise
float r = 1. - 2.0 * noise;
float g = 0.0;
float b = 1. - 1.0 * noise;
vec3 foo = vec3(r*2.0, g, b*1.5);

// create a new color using the noisy values
gl_FragColor = vec4( foo, 1.0 ) * texture2D( texture, gl_PointCoord );


For the specific hex color provided, uncomment and use this section:

// get the texture pixel
gl_FragColor = texture2D(texture, vec2(pos.x, pos.y));
// or simply use the noisy part without additional noise
// gl_FragColor = texture2D(texture, gl_PointCoord);

Read about texture2D function here. It retrieves the color of a point on a texture.

Try it out in this fiddle.


To "control" it, adjust the foo RGB color used as noise.


Personal preference, but the webpack blob is quite hard to read. Consider providing a minimal example focusing solely on the issue next time.

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

The img-wrapper is failing to show the PNG image

I'm having an issue with my code where it displays jpg images but not png. How can I make the img-wrapper show png files as well? In my example, the first image in the array is a jpg while the second is a png. However, I only see the title of the imag ...

When an Ajax POST request is made, the PHP script is executed only upon refreshing the page

I am attempting to collect a user's signature using a canvas element and then save it to the server by clicking a button which triggers an AJAX POST request to a PHP file. The issue I am encountering is that although the data is being saved, I have to ...

Every time I attempt to reuse my components, they keep piling up on top of each other

I'm facing an issue where I need to reuse components I've created multiple times while rendering dynamic content. However, when I attempt to render them, they end up stacking on top of each other in the same position. Each time I render ...

Capturing Screenshots with Ionic Framework

I am currently working on an Ionic application that utilizes geolocation via the Google API. However, I am facing a challenge with implementing a feature where a button in the upper right corner should take a screenshot and trigger a popover with options t ...

CSS media query to target specific viewport width

In my JavaScript code, I am dynamically creating a meta viewport. I set the value of this viewport to be 980px using the following script: var customViewPort=document.createElement('meta'); customViewPort.id="viewport"; customViewPort.name = "vie ...

Is there a way to make a button on a single div only affect that specific div

I have a PHP query that echoes a div for each row in the table. I want the div to slide up and then, when the user clicks the "read more" button, the div slides down. However, since it is echoed in a loop, all the divs have the same IDs and classes. I wo ...

How to bind array elements in Vue.js

I am currently working with an array that contains various arrays and properties within it. My goal is to iterate through the array and generate new rows for each item in it. Here is a snippet of what I have been working on: var orderDetails = [ ...

Tips on adding TypeScript annotations to an already existing global function

I'm contemplating enhancing an existing project by incorporating TypeScript type annotations. Struggling to supply an external declaration file for a straightforward example: app.ts: /// <reference path="types.d.ts"/> function welcome (person ...

Ways to verify if a string contains a specific template literal in javascript

I attempted to verify this by using the str.includes('${') method as a straightforward approach, but it did not produce the expected results. I found that it also returned strings that didn't contain the specified characters. For instance, ...

Preventing data duplication when refreshing a webpage using Node.js

I am currently utilizing Mustache and Nodejs to populate a dropdown menu with a list of options on my website. However, every time the page is refreshed, I encounter duplicate entries in the dropdown. How can this issue be resolved? I trust that my inquiry ...

My mongoose record is properly saved but does not reflect any updates

let updateNoteForUser = await UserRecords.findOne({userid: message.author.id}) updateNoteForUser.content[1].note = `SWAMISHREEJI` updateNoteForUser.save().then((doc) => { console.log(doc); }).catch(err => console.log(err)) schema ...

Unraveling based on changing values in es6

Trying to retrieve query parameters from the frontend in my express endpoint. const { filterType1, filterType2 } = req.query However, the issue is that the filterType values are coming from a predefined list of array elements. const list = ['priceF ...

Divide a string into various text boxes

Is there a way to allow users to edit the value of a field that is Vertex 3D? The stored value is in string format, but I want to present it to the user as three separate input fields for easier editing. I am looking for a method to split the string by sp ...

Reactive form allows you to easily format dates

Currently, the date displayed is 1/4/2022. We need it to display in the format 01/04/2022. Can we achieve this formatting using reactive forms with the sample Model form provided below? Thank you. How can we format it when starting from transactionStartD ...

Is it possible to modify CSS animations using a variable passed from typescript?

Looking for a way to streamline my animations in the .ts file so that I can use a single block of code to change the hardcoded RGB values with a variable called this.fillColor. Each animation is currently set up separately for different elements, but the ...

The array's value was altered without any direct modification

In an attempt to prepend an element to a new array and return the modified array, I wrote the following code. Although it works, returning the original 'arr' instead of the modified 'newArr' results in changes to the 'arr'. f ...

When navigating to a new route in VueJS with parameters, the browser displays the previously used

Scenario In my app, I am using vue.js 2.6 and vue-router 3.0. Within the app, there are links to detail pages set up like this: <div v-for="item in items"> <router-link :to="{name: 'details', params: {key: item.shortKey}}"> &l ...

update the element that acts as the divider in a web address (Angular)

Is it possible to modify the separator character used when obtaining the URL parameters with route.queryParams.subscribe? Currently, Object.keys(params) separates the parameters using "&" as the separator. Is there a way to change this to use a differe ...

The 'Subscription' type does not contain the properties _isScalar, source, operator, lift, and several others that are found in the 'Observable<any>' type

Looking to retrieve data from two APIs in Angular 8. I have created a resolver like this: export class AccessLevelResolve implements Resolve<any>{ constructor(private accessLevel: AccessLevelService) { } resolve(route: ActivatedRouteSnapshot, sta ...

Angular's UI Modal: utilizing inline template and controller functionality

I am looking to create a simple confirmation box using UI-modal, which I have used successfully for more complex modals in the past that load their template and controller from external files. However, this time I want something even simpler - just a basi ...