Can someone explain the issue with the particle system's positioning?

This unique formation of sprite particles should be positioned to the right of the x-axis and above the y-axis. However, upon viewing this demo, you'll notice they curiously hang just below the y-axis. Despite my numerous attempts at editing and rearranging, I'm stumped as to what's causing this issue. Any fresh perspectives on the matter would be greatly appreciated. Thank you!

For those interested, the mathematical foundation behind this elliptical cloud can be found here.

function pointInEllipticalCloud(radiusA, radiusB, pZ) {
    var pX = Math.random() * (radiusA * 2);
    var rightBisector = Math.abs( radiusA - pX );
    var chord = (2 * radiusB) * Math.sqrt(1 - Math.pow((rightBisector / radiusA), 2));
    var pY = (Math.random() * chord) + ((radiusB - chord) / 2);
    return new THREE.Vector3(pX, pY, pZ);
}

var pZ = 1;
var particleGroup = new THREE.Object3D();
for( var i = 0; i < 300; i++ ) {
    var radiusA = 200;
    var radiusB = 50;
    var particle = new THREE.Sprite( spriteMaterial );
    particle.scale.set( 20, 20, 1 );

    var spritePoint = pointInEllipticalCloud(radiusA, radiusB, pZ);
    // *** Why are the resulting sprites hanging below the y axis?

    particle.position = spritePoint ;
    particleGroup.add( particle );
    pZ += 0.1;
}

particleGroup.position.set(0,0,0);
scene.add( particleGroup );

Answer №1

Eureka! Discovered it. The issue was located within the calculation of pointInEllipticalCloud(). Instead of pY, it should be replaced with the following:

var pY = (Math.random() * chord) + (((diameterB * 2) - chord) / 2);

...where diameterB is doubled to represent the vertical dimension of the ellipse.

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

Use two fingers to scroll up and down on the screen

I am currently developing a sketch web application (using angular) that utilizes one finger gestures for drawing. My goal is to enable vertical scrolling in the sketch content by using two fingers. However, when attempting to scroll with two fingers, Safa ...

Is there a way to alter the format of a URL?

I'm utilizing the ytdl-core library to access a URL for audio content. The provided URL is: https://r2---sn-gwpa-w5py.googlevideo.com/videoplayback?expire=1612552132&ei=ZEMdYNnJDumPz7sPyrSLmAw&ip=49.36.246.217&id=o-AFQLS1cSUJ6_bXBjMOIiWk1N ...

Next.js is like Gatsby but with the power of GraphQL

I'm curious if it's possible to set up GraphQL in Next.js similar to how it's done in Gatsby, allowing me to query pages and retrieve data from them. Are there any plugins available for Next.js that work like Gatsby-file-source and gatsby-ma ...

guide to importing svg file with absolute path

I have been attempting to load SVG files from my LocalDrive using an absolute path. Despite successfully achieving this with a relative path, the same method does not work when utilizing an absolute path. <script> $(document).ready(functio ...

fetching foreign key information for drop down selection is taking too much time

I'm facing an issue with displaying foreign key data in a drop-down list due to a large amount of data, causing the page to load slowly. Is there a way to load this data gradually instead of all at once? Here is my models.py: class Vistor(models.Model ...

The JavaScript code is receiving an "undefined" response from the WebService method, despite expecting a valid return value

One of my WebService's methods is designed to return a boolean: [WebMethod(EnableSession = true), ScriptMethod(UseHttpGet = true)] public bool StartMonitoring() { return Schedule.StartMonitoring(); } The method within the Schedule class looks li ...

Node.js server utilizing Jade template variables

My goal is to display a contacts list using Jade code. I have transformed each contact div into Jade code, but now I need to populate the relevant fields. Can this be done on the server side? My server code is written in Node.js. Here is an example of the ...

Despite setting allowHalfOpen to True, Node.js: Client still disconnects from Server

I've been working on a Node.js script that involves creating a server if a specific port is available, or connecting to an existing server if the port is already in use. To achieve this, I am using a recursive approach based on a reference from this l ...

Maximizing JavaScript efficiency: Returning a value within an if statement in an AJAX call

In my function, I have a condition that checks the idType. If it is 1, an ajax call is made to a php file to retrieve the name associated with the specific idName and return it. Otherwise, another example value is returned. function obtainName(idName, idTy ...

Creating an Angular directive that handles asynchronous attribute interpolation

I am facing an issue with my custom directive. In the link function attributes, I am trying to access the value of attributes.user. Here is how the directive is used in my view page: <div my-directive user="{{user.name}}"></div> The user obje ...

How to locate and adjust the camera's position in three.js?

I am utilizing THREE.OrbitalControl.js Control = new THREE.OrbitControls(Camera, Renderer.domElement); As I rotate and move the mesh to locate the camera position, I print out the values of Camera.position and Camera.rotation in the animate function. Ho ...

Guide on transforming UTC time from the server to the local time of users during a GET request

I am currently facing a challenge where I need to verify if the date of the last time an element was clicked matches the current date. Due to my server generating the current date which is 5 hours ahead of my local time, there is a discrepancy causing the ...

Obtain the Week Input's Value

Is there a way to store the value of a week input in a variable and then display it in a span? I attempted the following code: <input type="week" name="week" id="week-selector"> <span id="kalenderwoche"> ...

Unable to delete touchmove event - Vue watching system

Preventing scrolling on mobile devices: const stopScroll = function(e) { e.preventDefault() } Adding the listener: document.body.addEventListener('touchmove', stopScroll, { passive: false }) Removing the listener: document.body.removeEvent ...

What is the best way to trigger the ajax request with the same post parameter upon pressing the browser's back button?

Is there a way to remember the post parameters and resend an AJAX request when the browser back button is pressed? I have searched online and found a couple of methods: Using localsotrage or document.location.hash when the page unloads. Using cookie ...

Manage form submission seamlessly without redirecting. Capture information without needing to prevent the default action, then proceed with redirection. Avoid redirecting when using preventDefault, but be aware that data may not

Currently stuck in a tricky situation. I've implemented a custom form submission to prevent redirecting when an express route is triggered by form submission. However, the issue arises when I lose the data being sent without redirection. document.get ...

Struggling with updating an array using React's setState

My issue lies with setState not properly updating my todoItems array. After reviewing similar posts on this forum, I made changes to my addTodoItem() function by utilizing a function and the spread operator. While a new item is successfully added to the ar ...

Adonis.js Creating a RESTFUL API Solution

I recently embarked on a new project using the adonisjs framework. I had the option to utilize expressjs, but I was drawn to adonisjs due to its structured nature, especially reminiscent of Laravel. My current challenge revolves around building a RESTful ...

JS - Activate the ghost element feature by using the preventDefault function

I am currently working on a project where I need to drag elements from a list of img tags to various svg:rect containers. The process involves using mousedown and mouseup events to track which img is being picked from the list and where it is dropped with ...

What could be causing the service method in the controller not to be called by Node JS?

In my current Node JS project, the folder structure of my app is as follows: src │ index.js # Main entry point for application └───config # Contains application environment variables and secrets └───controllers # Hou ...