Modify the form and store the updated data in a JSON format

I have successfully implemented a prompt box to change values, but now I am looking to make those changes permanent by updating the JSON file. Additionally, I want the shape to be automatically updated after changing the value in the prompt box. My current code snippet is as follows:

var leength = INTERSECTED.parent.children[0].geometry.vertices.length / 2;
for (var pu = 0; pu < leength; pu++) {
    var mesx = INTERSECTED.parent.children[0].geometry.vertices[pu].x;
    var mesy = INTERSECTED.parent.children[0].geometry.vertices[pu].y;

    var showx = prompt("Usage: Business  Punkt x" + (pu + 1), mesx);
    var showy = prompt("Usage: Business  Punkt y" + (pu + 1), mesy);

    if (prompt != null) {
        alert(" Punkt x" + (pu + 1) + " : " + showx + " Punkt y" + (pu + 1) + " : " + showy);
    }
    INTERSECTED.parent.children[0].geometry.vertices[pu].x = showx;
    INTERSECTED.parent.children[0].geometry.vertices[pu].y = showy;

Answer №1

For automatic updating of the values, it is necessary to specify that the vertices have been modified.

INTERSECTED.parent.children[0].geometry.verticesNeedUpdate = true;

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

Make sure to keep Vue-Cookies intact even when closing the browser or tab

I have integrated vue-cookies into my Vue application. The code I'm using to store a cookie is as follows: $cookies.set('authUser', authUserObj); The object authUserObj contains the access_token. However, when I close and reopen the ta ...

Store a replica into an array

In my database, there is a function that adds ledger entries. Entries that meet specific criteria are saved to an array. However, when it comes to saving records in the 'if' block, only the second part gets saved successfully. How can I modify th ...

Dynamically update a dropdown menu with options based on the user's selection from a prior dropdown list using ajax and JSP Servlet

I am working on creating a real-time project for a consultancy and could use some assistance with developing a JSP page. Specifically, I need to allow the user to select a Client (Company name) from a dropdown list. Once a Client is selected, the HR list ...

Encountered an issue in AWS Lambda console with writing JSON data

While attempting to follow a tutorial on Creating an API with Lambdas and API Gateway, I encountered some errors: I've been struggling with this for quite some time. Can anyone shed light on the errors that arise when adding JSON into the code editor ...

Encountering an issue in Next.js when using getStaticProps: reading 'map' of undefined properties

The Image above shows the error and the code I have attempted.Server Error TypeError: Cannot read properties of undefined (reading 'map') This particular error occurred during the page generation process. Any console logs will appear in the term ...

Silhouettes dancing across handcrafted designs

I have been trying to create a custom geometry using vertices and faces, but I am facing an issue where the geometry does not cast shadows on itself and the faces all have the same color as it rotates. I have attempted various solutions but haven't ha ...

Checking if a string is present in an array object with Angular.js using a filter function

In my Angular and Firebase app, users can create new discussion topics and vote on existing ones. When a user is logged in, their username is stored in currentUser.username. If they've upvoted a topic, their username will also be added to the array of ...

Recurly.js: Enhancing PHP Integration with Advanced Digital Signatures

I've been working on setting up forms for a recurly implementation and using PHP to generate the signature. Despite following the documentation, searching for examples, and testing various combinations, I'm facing an issue where part of the PHP c ...

Delay in Javascript confirm popup box opening causing issues

I am facing an issue with a Javascript popup box that should appear when a user clicks on an action button within a gridview. Currently, the popup only opens after the code in the sub has executed entirely, leading to a variable not getting assigned values ...

DiscordJS: updating specific segment of JSON object

I am currently working on a Discord bot using discord.JS that involves creating a JSON database with specific values. I'm wondering how I can modify the code to edit a particular object within the JSON instead of completely replacing it. if (message.c ...

Is there a potential impact on performance when utilizing local variables instead of repeatedly accessing properties?

Examining JavaScript code optimized for a performance-sensitive environment, specifically a game engine in mobile settings. Oftentimes, this code avoids using local variables and instead relies on explicit chains, such as: if (this.x.y[z].i) { this.x ...

C# - Implementing JavaScript Object manipulation in .NET Core

As I was browsing, I noticed many similar questions from years ago. Let's kick off this discussion with a simple JavaScript example showcasing how easy it is to modify, read, and write properties in objects using this language. Take a look at the cod ...

How can we stop the constant fluctuation of the last number on a number input field with a maxLength restriction

In my ReactJS code, I have an input field that looks like this: <input type="number" onKeyPress={handleKeyPress} maxLength={3} min="0" max="999" step=".1" onPaste={handlePaste} /> Below are the functions associated w ...

Apply a dynamic function to assign a background color to a specific class

Currently, I have a function called getBackground(items) that returns a background color from a JSON file list. Within my application, there is a component that automatically adds a class name (.item-radio-checked) when a user clicks on an item in the list ...

Transferring data from SocketIO to Vue.js

Is there a way to effectively transfer data results received from socketIO to the Vue instance? Below is my current code implementation: let socket = io(); let users; socket.on('user-connected', (data) => { users = data.count; }); socket ...

Tips on creating a button that, upon clicking, triggers the download of an Excel file using PHPSpreadsheet

I am trying to figure out how to create a button that, when clicked, will download an Excel file named b1b5.xls with some specified values added. Here is the code I have so far: <html> <head> </head> <body> <center> < ...

Enhance the Lambert Shader in ThreeJS by incorporating a personalized VertexShader

I am looking to modify the Shader found at the following link: to make it compatible with both Lambert and Phong lighting models in my Scene. Currently, I am enhancing the Lambert shader with the following code: var attributes = { displacement: ...

Struggling to organize and paginate numbers in angularjs and facing filtering and sorting issues

I'm running into some issues with getting the paging feature to work properly while applying filters. Currently, when the filters are active, the paging numbers do not display correctly and only filter the first page of results. What I'm aiming ...

Is it possible to use jQuery animation to smoothly transition the background color?

I'm currently working on a function to dynamically change the background color of a div based on an array of colors. Here's what I have so far: HTML: <div class="bg-color"> CSS: .bg-color { width: 500px; height: 500p ...

Determining the necessary z-distance of a camera to view an image at 100% of its original scale in a 3D environment

Is it feasible to determine the distance of a camera from an object in 3D space (an image, in this scenario) so that the image retains its original pixel width? Could it be accurate to say that this can be achieved by considering the aspect ratio of the c ...