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.
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);
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.
Or in the script:
// Add particle material
const material = new ParticleMaterial(engine);
particleRenderer.setMaterial(material);
Property | Description |
---|---|
baseColor | Base Color |
baseTexture | Base Texture |
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.
Preview Playback Options | Description |
---|---|
Replay | Stops the current particle effect playback and immediately starts playing from the beginning |
Stop | Stops the particle effect playback and resets to the initial state |
Pause / Play | Pauses / Starts playing the particle effect |
Selected / Global | Plays the currently selected particle or all particles in the scene |
Bounding Box | Bounding box of the currently selected particle |
Or in the code,
// 播放
particleRenderer.generator.play();
// 停止
particleRenderer.generator.stop();
// 调整播放速度
particleRenderer.generator.main.simulationSpeed = 2;
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.
Property | Description |
---|---|
velocityScale | Specifies the extent to which particles stretch based on their speed |
lengthScale | Defines the extent to which particles stretch in their direction of motion, defined as the ratio of the particle's length to its width |
pivot | The pivot of the particle |
renderMode | The rendering mode of the particle |
mesh | The mesh of the particle, effective when renderMode is Mesh |