Exploring the World of THREE.js: Particles and PointClouds

I am currently working on a project where I want to create orbiting objects with trails. To achieve this, I have set up a particle system using THREE Geometry, a THREE PointCloud, and a THREE PointCloudMaterial:

particleMaterial = new THREE.PointCloudMaterial({ 
  color: 0xFFFFFF, size: 1, sizeAttenuation: false 
});
particles = new THREE.Geometry;
particles.verticesNeedUpdate = true;
particles.dynamic = true;
particleSystem = new THREE.PointCloud( particles, particleMaterial );
scene.add( particleSystem );

In order to generate the vertices for the Geometry for the trail effect, I am updating them in the animate loop by copying the position information from the objects being orbited at that moment:

function animate() {
if ( nodesArray.length > 0 ) {
    for ( var i = 0; i < nodesArray.length; i++ ) {
        nodesArray[i].position.x = Math.sin( nodesArray[i].counterX ) * 50;
        nodesArray[i].position.z = Math.cos( nodesArray[i].counterZ ) * 50;
        nodesArray[i].position.y = Math.cos( nodesArray[i].counterY ) * 50;
        nodesArray[i].counterX += .01;
        nodesArray[i].counterZ += .01;
        nodesArray[i].counterY += .01;

        var particle = new THREE.Vector3();
        particle.copy( nodesArray[i].position );
        particles.vertices.push( particle );
        particles.verticesNeedUpdate = true;
    }
}

requestAnimationFrame( animate );
renderer.render( scene, camera );
}

For reference, you can view a jsfiddle of my code here: http://jsfiddle.net/jayfield1979/184kbyLr/

While the first vertex is placed correctly for each object, subsequent vertices are not registering as intended.

I would appreciate any feedback on whether my approach is correct and, if not, suggestions for improvement.

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

Invoke the designated JavaScript function within a subordinate <frame>

Below is an example of the standard HTML structure for a parent page named "index.html": <html> <head> <title>test title</title> </head> <frameset cols="150,*"> <frame name="left" src="testleft.html"> ...

How can you identify the resume of a web application once you return from opening the camera?

I'm working on a web application that utilizes the camera by following steps from this solution: How to access a mobile phone's camera using a web app? However, I am trying to figure out how to implement a callback function once the user return ...

Guide to dynamically binding two input fields in a table using Jquery

I'm looking for help with binding 2 input text fields that were dynamically added to a table inside a loop using JavaScript/JQuery Syntax. My goal is to automatically populate the second field with text from the first one. I was successful in achievin ...

Send data from HTML forms to PHP without needing to reload the page

I’m currently developing a website that showcases data retrieved from a database using PHP. The site includes checkboxes within a form, and based on the user's selections, I want the data displayed in a certain div to refresh when they click ‘appl ...

What is preventing me from using the JavaScript toggle button multiple times?

I am currently trying to implement a JavaScript toggle button in two different sections on the same page, but I am encountering difficulties. I attempted to change the IDs as well, but it didn't seem to work. Is it not possible to achieve this, or am ...

Observing and showing profound modifications in Vue

I need to show a distinct message for each category that the user selects <v-select multiple style="position: relative; top: 20px;" color="white" v-if="count == 3 && question" solo placeholder="Please Cho ...

Exploring AngularJS: the power of directives and the art of dependency

According to Angular documentation, the recommended way to add a dependency is by following these steps: Source //inject directives and services. var app = angular.module('fileUpload', ['ngFileUpload']); app.controller('MyCtrl&ap ...

Having difficulty accessing POST data through $.ajax request

I am currently working on a simple JavaScript code that is set up to send POST requests to my local server. The JavaScript and PHP files are both located on localhost, so I don't have to worry about any cross-site issues for now. Here is the JavaScrip ...

Tips for retrieving nested objects in a get request

A dilemma I'm facing involves a form that effectively sends and saves JSON data to MongoDB using mongoose. However, the issue arises when attempting to access this data as the nested objects display on the get route html page as: { synth: { patch_na ...

The variables in Next.js reset every time I navigate to a new page

Looking for a way to share a variable between pages in my Next.Js application, I have the following setup in my _app.js file: import { useState } from 'react'; const CustomApp = ({ Component, pageProps }) => { // Variables const [testVa ...

Efficiently search through CZML/JSON data

Utilizing Cesium, I have a czml file, similar to JSON format, and I am seeking a way to identify a specific element by specifying the desired tag: var czml = [{ "id" : "document", "name" : "Basic CZML billboard and label", "version" : "1.0" }, ...

Expectable JavaScript array shuffling

Is there a way to consistently shuffle javascript arrays with the same result every time the webpage is loaded? Even though I can shuffle the arrays randomly, each page reload yields a different sequence. I'm looking for a solution that will shuffle ...

Automatically populate dynamic fields with ajax response

Using auto-fill with an ajax request works well for static fields. For example: $this->registerJs("$(document).delegate('.form-control','change',function(event){ $.ajax({ url: '".yii\helpers\Url::toRoute( ...

Change a numeric value into a string within a collection of objects

Consider the following input array: const initialArray = [ { id: 1, name: 1 }, { id: 2, name: 2 }, { id: 3, name: 3 }, { id: 4, name: 4 } ]; The objective is to modify it ...

Using ReactJs to show a particular piece of information from an object within an array by clicking

My data consists of an array filled with objects, each of which includes an ID, title, job description, and salary. This data is stored in a separate file as shown below: export const CareerList = [ { id: 1, title: "Junior Accountant", sala ...

Version 1.x of Remix.run encountered issues when attempting to resolve paths containing the "$" symbol during both compilation and runtime, particularly when handling paths with dynamic segments

Attempting to deploy a Remix 1.x app on a Linux machine running Debian 12 (amd64) with Typescript, but encountering issues. The same code builds and runs successfully on a Mac OS Machine (M1). Seeking assistance to resolve the problem that arises during t ...

Choose the text by clicking on a button

I currently have: <span class="description">Description 1</span> <button class="select">Select!</button> <span class="description">Description 2</span> <button class="select">Select!</button> <span clas ...

React-Leaflet continuously updates the map with the "MouseMove" event

I'm looking to implement a feature in my React app that displays the geographic coordinates as the mouse moves. However, I've noticed that using "Mousemove" causes the map to be continually redrawn with all objects each time, resulting in poor pe ...

Set values for all variables that begin with a specific string

[WARNING! Proceed with caution] One of my most recent coding dilemmas involves creating a JavaScript script that can identify specific surveys. These surveys use variables that share a common string followed by a random number, like this: variableName_46 ...

The JavaScript forEach loop is compatible with every web browser except for Internet Explorer

All browsers are working with the loop except for Internet Explorer, which does not seem to support forEach. Here is the JavaScript code: function validate() { var msg = ''; var i = 0; arr.forEach( function validateinfo(){ ...