What could be the reason behind the fact that setting `geometry.verticesNeedUpdate = true;` does not enable me to modify the vertices as

One issue I'm grappling with is a function that keeps getting called, but the vertices aren't updating as expected:

function showGraph() {
    requestAnimationFrame(showGraph);
    // Transfer frequency data to an array named frequencyData.
    analyser.getByteFrequencyData(frequencyData); // The values in frequencyData change over time.  

    var dat = 79600;  
    var step = dat/frequencyData.length
    var f = 0;  
    for(v=0; v<dat; v+=step){
        globe._baseGeometry.verticesNeedUpdate = true;
        globe.points.geometry.verticesNeedUpdate = true;
        globe._baseGeometry.vertices[v].z = globe._baseGeometry.vertices[v].z * frequencyData[f]
        globe._baseGeometry.vertices[v].y = globe._baseGeometry.vertices[v].y * frequencyData[f]
        globe._baseGeometry.vertices[v].x = globe._baseGeometry.vertices[v].x * frequencyData[f]
        f++; 
    }
}

// Execute the loop
showGraph();

If it's enclosed within a $(document).ready(function(){... block, it runs successfully once. What tweaks are required?

Answer №1

You can find the answer here:

It was mentioned in #1234 that modifying the vertices array directly is not possible. Use the copy() method instead."

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

Inadequate grid data retrieval (This problem arises randomly)

During the process of loading data in a grid on our production server, I encountered a script error at the bottom left corner of the page. Interestingly, this error only occurs on the production server and works perfectly fine on the local server. Here ar ...

Check the vuelidate required function in Vye.js for ensuring that all necessary fields

I am currently utilizing the vuelidate plugin for form validation. import { required, maxLength } from 'vuelidate/lib/validators'; In my Vue component, I have a method called isFinishedFill(): methods: { isFinishedFill() { return !!this. ...

`Adjusting video frame on canvas`

When I capture video from a user's camera and display it in a 1:1 square, I encounter an issue when trying to draw the picture to a canvas. The image is not drawn in the same location on the canvas. How can I resolve this problem? To see a live examp ...

Update the current value in array.prototype

Recently, I've noticed that the built-in JavaScript sort function can be unreliable at times. To address this issue, I decided to create my own sorting function. Consider the following scenario: Array.prototype.customSort = function(sortFunction, upd ...

What is the process for converting a string literal into raw JSON and then storing it?

When trying to edit object values using a text input element and JSON.stringify(txt, null, 2), everything seems fine initially. However, after submitting the input, I end up with unwanted characters like "/n" and "\" within the string literal. Despite ...

The ng-class directive is not functioning as I had anticipated

In my ng-grid setup, I have implemented a specific cell Template as shown below: cellTemplate: '<div class="ngCellText" ng-class="{\'red\': {{row.getProperty(col.field)}} > 15 , \'yellow\': {{row.getPrope ...

What is the most effective method for verifying a successful 200 OK response when making an Ajax call to retrieve table data?

I have a question regarding handling Ajax success responses. In previous scenarios, I returned specific data such as an ID, but now I need to return an entire table. Before retrieving this data, I want to ensure that the Ajax call was successful (status ...

Elements in ExtJS Tree panel not displaying properly

I am currently working on a tree panel that displays data from a JSON file. When I expand one category, the elements display correctly. However, when I expand another category, the previously opened elements disappear. This issue persists with all elements ...

AJAX loading footer content before images are fully loaded

I am a beginner when it comes to ajax and I'm facing an issue where the footer loads before the images, causing the images to overlap the footer. The problem is illustrated in the image below. <!doctype html> <html lang="en"> <head ...

Ensuring that localStorage objects continue to iterate when clear() is called within the same function

When a user completes the game loop or starts a new game, I want to clear all local storage while still keeping certain values intact. Currently, I am able to do this for sound volume values: // code inside a conditional statement triggered when starting ...

Determine the Z component of the point located on the plane

Using the coordinates of 3 black points, I determined the plane: const { Vector3, Plane } = require('three') const points = [new Vector3(0, 0, 0), new Vector3(1, 0, 1), new Vector3(1, 2, 0)] const plane = new Plane().setFromCoplanarPoints(...poi ...

I'm having difficulty mocking a function within the Jest NodeJS module

I have a module in NodeJS where I utilize a function called existsObject to validate the existence of a file in Google Storage. While testing my application with Jest 29.1.2, I am attempting to create a Mock to prevent the actual execution of this functio ...

Effectively eliminating elements from the DOM

I have a minor question about efficiency in regard to implementing an overlay and spinner over an element. Initially, I am adding the overlay and spinner, and then later I am removing them. I can approach this in two ways: addSpinner: function() { ...

What is the best way to transfer functions connected to an Object over to Object.prototype?

Imagine having this: var exampleObject = {age: 25, name: 'John'}; If you do this: Object.keys(exampleObject); // it will return ['age', 'name'] Now, what if you want to add this functionality to the object prototype? You c ...

Is requestAnimationFrame not supported in iOS UIWebView?

Is there a replacement for requestAnimationFrame that works in UIWebView, since it seems to be undefined? Or will I need to resort to using setTimeout instead? ...

Different ways to refresh a list rendered using .map()

I'm having trouble updating a list when I click a button that moves the first element of the array to the last position. Even though the console.log confirms that the array has been modified, the component does not rerender: codesandbox import React, ...

Creating an Express.js route that handles requests with various unique IDs

I am currently utilizing node.js with the express library. I have pages like localhost/page/1 and localhost/page/2 which are quite similar, but certain information needs to change based on the page ID. I am redirecting to these pages using a form submissio ...

"Utilizing the GET route in node.js with the express framework requires the use of a

As a newcomer to node + express, I'm facing challenges in configuring a get route. When utilizing a parameter within the specified route below, data is retrieved without any problems. However, when attempting to return an object without the parameter, ...

Sending data from middleware to a function in Node.js is a crucial step in the communication

While working with express, I have a requirement to develop a middleware for validation purposes. The code snippet I have looks like this: Code: app.use('/upload', formData) app.use('/upload', function firstUpload(req, res, next) { ...

Automatic Updates for Phonegap applications are now available on the Apple App Store

While I have come across similar inquiries, none of them precisely match my question. Currently, I am working on developing an app with Phonegap. I understand that Apple permits apps to request external JS (such as those using Google Maps) by including a ...