Add particle type selection, size control, and enhance particle property handling
This commit is contained in:
@@ -42,7 +42,7 @@ export class ParticleManagerService {
|
||||
*/
|
||||
addParticle(x: number, y: number, z: number): void {
|
||||
// Create a visual representation of the particle
|
||||
const particleGeometry = new THREE.SphereGeometry(0.03, 16, 16);
|
||||
const particleGeometry = new THREE.SphereGeometry(0.03 * this.selectedSize, 16, 16);
|
||||
const particleMaterial = new THREE.MeshBasicMaterial({color: this.selectedColor});
|
||||
const particleMesh = new THREE.Mesh(particleGeometry, particleMaterial);
|
||||
|
||||
@@ -89,7 +89,7 @@ export class ParticleManagerService {
|
||||
if (!this.particleData.frames[frameId]) return;
|
||||
|
||||
for (const particleInfo of this.particleData.frames[frameId]) {
|
||||
const particleGeometry = new THREE.SphereGeometry(0.03, 16, 16);
|
||||
const particleGeometry = new THREE.SphereGeometry(0.03 * (particleInfo.size ?? 1), 16, 16);
|
||||
|
||||
const color = this.getColor(particleInfo);
|
||||
const particleMaterial = new THREE.MeshBasicMaterial({color});
|
||||
@@ -123,7 +123,7 @@ export class ParticleManagerService {
|
||||
const particleInfo = this.particleData.frames[frameId][index];
|
||||
const color = this.getColor(particleInfo);
|
||||
const particleMaterial = new THREE.MeshBasicMaterial({color});
|
||||
const particleGeometry = new THREE.SphereGeometry(0.03, 16, 16);
|
||||
const particleGeometry = new THREE.SphereGeometry(0.03 * (particleInfo.size ?? 1), 16, 16);
|
||||
const particleMesh = new THREE.Mesh(particleGeometry, particleMaterial);
|
||||
particleMesh.position.set(particleInfo.x, particleInfo.y, particleInfo.z);
|
||||
this.rendererService.scene.add(particleMesh);
|
||||
@@ -135,17 +135,6 @@ export class ParticleManagerService {
|
||||
});
|
||||
}
|
||||
|
||||
private getColor(particleInfo: ParticleInfo) {
|
||||
if (particleInfo.color) {
|
||||
const r = parseInt(particleInfo.color.substring(0, 2), 16) / 255;
|
||||
const g = parseInt(particleInfo.color.substring(2, 4), 16) / 255;
|
||||
const b = parseInt(particleInfo.color.substring(4, 6), 16) / 255;
|
||||
return new THREE.Color(r, g, b);
|
||||
} else {
|
||||
return new THREE.Color(255, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private animatePulse(mesh: THREE.Mesh, cycles: number, onComplete: () => void): void {
|
||||
const duration = 300;
|
||||
const maxScale = 0.08 / 0.03;
|
||||
@@ -167,6 +156,17 @@ export class ParticleManagerService {
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
private getColor(particleInfo: ParticleInfo) {
|
||||
if (particleInfo.color) {
|
||||
const r = parseInt(particleInfo.color.substring(0, 2), 16) / 255;
|
||||
const g = parseInt(particleInfo.color.substring(2, 4), 16) / 255;
|
||||
const b = parseInt(particleInfo.color.substring(4, 6), 16) / 255;
|
||||
return new THREE.Color(r, g, b);
|
||||
} else {
|
||||
return new THREE.Color(255, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the selected color for new particles
|
||||
*/
|
||||
@@ -181,6 +181,22 @@ export class ParticleManagerService {
|
||||
return this.selectedColor;
|
||||
}
|
||||
|
||||
public get particle(): Particle {
|
||||
return this.selectedParticle;
|
||||
}
|
||||
|
||||
public set particle(selectedParticle: Particle) {
|
||||
this.selectedParticle = selectedParticle;
|
||||
}
|
||||
|
||||
public get size(): number {
|
||||
return this.selectedSize;
|
||||
}
|
||||
|
||||
public set size(selectedSize: number) {
|
||||
this.selectedSize = selectedSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the particle data
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user