What components and substances are needed for a particle system in Three.js?

After spending a few weeks working with particle systems in Three.js, I initially used an Object3D, incorporating my own Vector3s and various materials like MeshBasicMaterials, Phong, and Lambert. However, after discovering the built-in ParticleSystem object and BasicParticleMaterial, which offered sorting tagging and other advantages, I learned that these may now be deprecated in favor of PointCloud and PointCloudMaterial. This led me to realize that BasicParticleMaterial only supported one texture for all particles, prompting me to have several questions:

  1. What are the current Object and Material options for a particle system in Three.js?

  2. Can it handle multiple textures (different images for each particle)?

  3. If the current particle system does not support multiple textures, should I consider reverting back to using an Object3D with custom materials and geometry? Is there a better alternative available?

UPDATE

The specific project at hand involves creating numerous abstract figures, each consisting of multiple particle clouds (10+) with each cloud holding 400+ particles. These particles are unique hand-drawn sketch marks, aiming to create a hand-drawn appearance when combined. All marks gently pulsate from the center as if being moved by a light breeze.

I am seeking the most efficient material and object for this task that can also handle multiple textures so that different hatch marks can be utilized as particles. For instance, the image below shows a single particle cloud (each figure would feature various differently shaped clouds), but currently, this cloud displays only a single type of hatch mark. I hope to incorporate a variety of marks as particles.

Answer №1

To achieve the desired result, your code should follow a similar structure. Instead of using canvases, utilize the textureloader and callbacks to add sprites when they are loaded. Make sure to set texture.needsUpdate = true; if you encounter a black sprite.

var texture1 = new THREE.Texture( canvas1 );
var texture2 = new THREE.Texture( canvas2 );
var texture3 = new THREE.Texture( canvas3 );

var material1 = new THREE.SpriteMaterial({ map: texture1 });
var material2 = new THREE.SpriteMaterial({ map: texture2 });
var material3 = new THREE.SpriteMaterial({ map: texture3 });

var sprite1, sprite2, sprite3;

var particleCloud1 = new THREE.Object3D();
for ( var i = 0; i < 100; i += 1 ) {

   sprite1 = new THREE.Sprite( material1 );
   // specify position
   particleCloud.add( sprite1 );

   sprite2 = new THREE.Sprite( material2 );
   // specify position
   particleCloud.add( sprite2 );

   // repeat for additional sprites
}
scene.add( particleCloud1 );

This approach allows sharing textures and materials across all sprites, accommodating hundreds or even thousands of them. However, animating numerous sprites might impact performance significantly. Unfortunately, there is no workaround for this limitation at present.

If needed, you can consolidate various textures into a single texture atlas and manipulate parameters like texture.offset.x, texture.offset.y, texture.repeat.x, and texture.repeat.y to access specific textures within the atlas. Nevertheless, considering your use case, the benefits of doing so may be minimal.

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

Facing difficulties in Angular 8 while trying to import firestore and firebase for an authentication system

While attempting to implement Firestore/Firebase functionalities for Google OAuth signin, I encountered an error indicating that Firebase is not imported: https://i.sstatic.net/oL4rY.png CODE: ERROR in node_modules/@angular/fire/auth/auth.d.ts:4:28 - er ...

What is the best way to make multiple HTML tables sortable?

I recently implemented an open-source JavaScript table sorter in my project. You can find more information about it here: However, I encountered an issue where only the most recently added table on my page is sortable. When users press a button, new table ...

Is it acceptable to manipulate the prevState parameter of the setState function as mutable?

It is commonly known that directly modifying this.state is not recommended, and instead setState should be used. Following this logic, I assumed that prevState should also be treated as immutable, and setState should always involve creating a new object i ...

Error encountered: The Jquery-ui functionality ceases to operate upon the completion of content

I'm utilizing the jQuery UI library to rearrange the items on my list. Initially, everything works smoothly without any issues. However, when I navigate to another page and then return to the page with my list, I encounter difficulties. It's wor ...

Encountered a failure while loading modules in AngularJS

When I tried opening the index.html page using Chrome, I encountered an error stating that the correct modules could not be found. Uncaught SyntaxError: Unexpected token < angular.js:1 Uncaught SyntaxError: Unexpected token < controller.js:1 ...

Error encountered: DOMException - Prevented a frame originating from "domain_name" from accessing a different origin frame

Utilizing the Mautic newsletter for my website has been a great experience. Here is the js code I've been using: /** This section should only be included once per page if manually copying **/ if (typeof MauticSDKLoaded == 'undefined') { ...

Hover to stop menu movement

Can someone help me achieve a similar menu hover effect like this one? I'm trying to create a menu with a hold/pause effect on hover, specifically in the section titled "A programme for every vision". The goal is to navigate through the sub menus smo ...

Invoking a function that is declared in a fetch request from an external source beyond the confines of the fetch itself

I am currently struggling with calling a function that is defined inside an API Fetch response function. My code sends an API fetch request to the GitHub API to retrieve a repository tree in JSON format. The problem arises when I try to call a function def ...

What is the best way to locate every object based on its ID?

Currently, I am facing an issue where I have a list of IDs and I need to search for the corresponding object in the database. My tech stack includes Nodejs, Typescript, TypeORM, and Postgres as the database. The IDs that I am working with are UUIDs. ...

Sign up for your own personalized Express and HBS helper now!

As a newcomer to Node, I appreciate your patience with me. I recently utilized the express generator module with the -hbs flag to switch from the default templating engine to Handlebars. Currently, I am attempting to register a custom helper to enable me ...

The map failed to display any information

<div> {!props.isLoading && <div> {normalizedData.map((outerObj,index) => { { <p className="space_name"> {outerObj.space_name} </p> ...

The information being transferred from a jQuery Ajax request to an MVC ApiController Action is disappearing

Let me first mention that although there are similar questions to this one already posted here, I've tried all the solutions and have not had any success. I have an MVC ApiController Action with the following signature: public void Post([FromBody] E ...

The functionality of Bootstrap's Modal feature seems to be malfunctioning

I'm attempting to test the sample modals for my project, but even the codes from jfiddles are not working for me. When I click the button, it only gives me a dimmed window. I have also tried searching on Google for a solution, but to no avail. Below ...

Issue with jQuery's .height() method not updating

Here is the code I am working with: $(function() { $('#team-ch').click(function() { $('#team-camb-hert').height('auto'); }); }); I am trying to change the height of a div when a link is clicked. After adding an alert ...

Is it possible to display this code through printing rather than using an onclick event?

I have a puzzle website in the works where users select a puzzle to solve. I am looking for a way to display the puzzles directly on the website instead of using pop-up boxes. I am proficient in various coding languages, so any solution will work for me. ...

Verify whether the user is obstructing third-party domain

I've encountered a recurring issue where many of our support calls pertain to images not loading due to users blocking Amazon S3 or a similar third-party service. I rely on third-party services for hosting images, videos, and certain JavaScript elemen ...

Having trouble importing the module I developed in Node

I've been struggling to understand why this import is failing. Despite trying numerous approaches, modifying the export and import based on various tutorials online, it continues to result in failure every time. This should be a simple task in theory. ...

Add a PHP variable to a JavaScript array

Looking for assistance with pushing a PHP variable to JavaScript. Below is the code that I have tried, but it doesn't seem to work. Can someone please guide me on how to achieve this? ticks.push(<?php echo json_encode($new); ?>); ...

Having trouble with the AJAX request for retrieving image paths, parsing the JSON response into a JavaScript array, and attempting to render the images on the page

Struggling to implement a functionality that involves loading images from a PHP array into a JavaScript array using JSON messages and AJAX. The buildImage() function is used to display the first image in the array within the content div, with onclick event ...

Stripping HTML elements from the body of an HTML document using AJAX before transmitting it as data to the controller

My JSP page contains two buttons labeled "download" and "sendemail". When the "Sendmail" button is clicked, an ajax method is triggered to generate a PDF version of the HTML body and send it to the back-end controller. I attempted to utilize the following ...