Particle

Particle

The particle (Particle Renderer) ParticleRenderer of the Galacean Engine is a commonly used rendering component with rich properties. By adjusting various property values, you can achieve colorful particle effects.

Components

The particle component can be mounted on an activated Entity in the scene through the shortcut at the top of the hierarchy panel or by adding a component in the inspector panel.

After adding, you can view the particle properties in the inspector panel. The particle panel at the bottom left corner of the view window can control the playback of particle effects in the view window.

You can also mount the particle component in the script.

// 创建实体
const entity = root.createChild("particleEntity");
// 创建粒子组件
let particleRenderer = particleEntity.addComponent(ParticleRenderer);

Rendering Material

ParticleMaterial is the default material for particles.

In the editor, create it by adding material - selecting particle material. After editing, go back to the particle inspector panel to select and use the material.

avatar

Or in the script:

// Add particle material
const material = new ParticleMaterial(engine);
particleRenderer.setMaterial(material);
PropertyDescription
baseColorBase Color
baseTextureBase Texture

Playback Control

The particle panel that appears when an entity with a particle component is selected allows you to control the playback of particle effects in the view window.

It should be noted that adjustments to particle playback on this panel are only for previewing in the view window and do not change the properties of the particle component. If you need to change the playback-related properties of the particle, you need to adjust them in the inspector panel.

avatar
Preview Playback OptionsDescription
ReplayStops the current particle effect playback and immediately starts playing from the beginning
StopStops the particle effect playback and resets to the initial state
Pause / PlayPauses / Starts playing the particle effect
Selected / GlobalPlays the currently selected particle or all particles in the scene
Bounding BoxBounding box of the currently selected particle

Or in the code,

// 播放
particleRenderer.generator.play();
// 停止
particleRenderer.generator.stop();
// 调整播放速度
particleRenderer.generator.main.simulationSpeed = 2;

Particle Generator

The generator property of ParticleRenderer is mainly responsible for the generation and playback of particles. The functions related to particle generation are composed of multiple modules, including the main module, emitter module, lifetime size module, lifetime color module, lifetime speed module, lifetime rotation module, and texture sheet animation module. In the editor's particle inspector panel, you can visually see each module and its options.

Other Parameters

avatar
PropertyDescription
velocityScaleSpecifies the extent to which particles stretch based on their speed
lengthScaleDefines the extent to which particles stretch in their direction of motion, defined as the ratio of the particle's length to its width
pivotThe pivot of the particle
renderModeThe rendering mode of the particle
meshThe mesh of the particle, effective when renderMode is Mesh

Was this page helpful?