Leveraging UInt8Array information within a WebGL fragment shader

An HTML FFT audio analyzer is set up to output data into a UInt32Array(64) type.

The three.js documentation states that this data type is not supported: https://github.com/mrdoob/three.js/wiki/Uniforms-types

How can I efficiently pass my per frame FFT buffer data into the vertex shader?

I've encountered compatibility issues while trying to compile the shader.

Any help or suggestions would be greatly appreciated.

        attributes = {
            customColor:  { type: "c", value: [] },
            tick:      { type: "f", value: 1.0 }
        };

        uniforms = {
            amplitude: { type: "f", value: 5.0 },
            opacity:   { type: "f", value: 0.3 },
            color:     { type: "c", value: new THREE.Color( 0xff0000 ) },
            fftSize:   { type: "i", value: 63 },
            freqData:  { type: "fv1", value: freqByteData }
        };

...

In the render() loop:

        freqByteData = new Uint8Array(analyser.frequencyBinCount);
        analyser.getByteFrequencyData(freqByteData)

        uniforms.freqData = freqByteData;

And in the GLSL vertex shader:

        uniform float freqData[64]; // Unable to work properly due to primitive type conflict
        uniform int fftSize;
        uniform float amplitude;

        attribute vec3 customColor;
        attribute int tick;

        varying vec3 vColor;

        void main() {

            vec3 norm = normalize(position);

            vec3 newPosition = position * freqData[tick % fftSize] + amplitude;

            vColor = customColor;

            gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

        }

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 render Google map on Vue CLI component

I am currently using the google map api to develop a basic application with vue.js. Interestingly, when I utilize a simple html and javascript setup with the api key, everything runs smoothly. However, once I transition the same process to vue, the map fai ...

setTimeout is only effective for durations less than 1000 milliseconds

I am trying to implement a timeout function that displays an alert two seconds after a form is submitted. The code I have tried using does not seem to be working as expected: $(document).ready(function() { $("#newsletter").submit(function() { setTi ...

How can I locate ThreeJS coordinates within the Panoramic GUI?

While I've dabbled with ThreeJS in the past, I'm currently working on a new project that involves setting up hotspots in a panoramic view. I vaguely recall using the camera dolly tool from this link to visualize camera locations. However, I' ...

Choosing a String and Performing a Double Click in Selenium with Java

My textbox is disabled, and it includes the following attributes: <div id="writingactivityId2" class="boxSize ng-pristine ng-untouched ng-valid ng-valid-required redactor_editor writingActivityDisabled" ng-focus="editing()" redactor="" readonly="" ng- ...

JavaScript - Functions in objects losing reference to previously created object properties

Having trouble with my Candy function. When I create an object of the Candy function, all attributes are created correctly. However, when I try to run the draw function, it always uses the properties of the second object created instead of the one I want. ...

Run a JavaScript function on a webpage loaded through an AJAX response

I need to trigger a function through an AJAX request sent from the server. The function itself is not located on the calling page. Here's an example of what I am trying to achieve: 1. PHP script being called: <script> function execute() { ...

Utilizing Web Worker to Load Textures in Three.js

When a large texture image is applied to a Mesh in Three.js for a substantial amount of time, it causes the browser's main thread to freeze. Consider the following scenario: var texLoader = new THREE.TextureLoader(); texLoader.load('someLargeTe ...

Click on the buttons to choose the data, then merge the corresponding CSV files into a single array

I'm currently developing a user interface where individuals can select CSV names by clicking on corresponding buttons to visualize the combined data in a chart. The setup involves adding the selected CSV names to an array (referred to as chosenData) ...

Tips for enhancing the appearance of a React component

I have a redux form that doesn't look great, and I would like to style it. However, my project uses modular CSS loaders. The styling currently looks like this: import styled from 'styled-components'; const Input = styled.input` color: #4 ...

What is the best way to adjust the size of a button using CSS within a ReactJS

I am facing an issue where I need to create a button with a specific width, but the template I'm using already has predefined styles for buttons. When I try to customize the button's style, nothing seems to change. Below is the code snippet: Her ...

automatically closing bootstrap alerts upon form submission

I'm working on an ajax form that sends data to a database and utilizes bootstrap alerts to notify the user when the process is successful. I want these alerts to automatically close after a certain period of time, consistently. Here's the issue: ...

Stopping the automatic drag-and-drop of images in web browsers

After spending a considerable amount of time searching, I have come to realize that most resources only cover how to start drag and drop functions or how to prevent it in specific libraries. Although my dropzone is functioning perfectly, the problem arise ...

Expanding Text Area in AngularJS

I came across this directive and I want to integrate it into my project, but I need the text area to expand as soon as the content is loaded. Angular-Autogrow.js: (function(){ 'use strict'; angular.module('angular-autogrow', [ ...

Track the number of times a button is clicked to generate a prominent "Main Event" section

Currently, I am working on a Tourism website that showcases numerous tours. Utilizing WordPress, I have established a custom post type titled Tours. Each tour is equipped with a Book Now button, which has been generated as a custom meta box. This button d ...

What is the process of setting a function as a property value in the Vuex State of an object from a component?

Can someone assist me with incorporating a function into the property of an object as a value for the state in my Vuex store? I am currently restructuring some code for a website using vue.js and fullpage.js. I have moved my fullpage options to the vuex s ...

Creating a virtual whiteboard using a captured screen shot

Can anyone suggest a tool that can enhance my ability to create a feature allowing users to capture screenshots of my website and annotate them with drawings or notes? Are there any existing browser technologies or plugins that offer similar functionality ...

Transitioning between different hues using specific fraction values

On my website, there is a variable called 'x' which represents a percentage. I am looking for a way to assign colors based on this percentage - with 0% being red and 100% being blue. For example, if 'x' is 50%, the color should be a mix ...

Protractor unexpectedly giving back a promise instead of the expected attribute value

I'm facing a challenge where I am attempting to extract the value of an HTML attribute and store it in a variable named url_extension. However, instead of getting the desired value, I keep receiving a Promise object. Below is my code snippet: (Please ...

Display all information associated with the class that matches the clicked ID

Can anyone help me with a Jquery question? I am trying to display all data with the same class when I click on it. I have created a list of clickable items. When I click on an item, the corresponding data should be shown. However, the code I wrote is not ...

After redirection to a new page, the Ionic-vue menu malfunctioned

I have developed a reusable header component named Header, which contains an IonMenu component for consistency across pages. The menu is associated with the IonRouterOutlet as per the documentation, but I am encountering an issue when navigating between pa ...