2025-06-22 17:23:54 +00:00
|
|
|
import {Component, ElementRef, ViewChild} from '@angular/core';
|
2025-06-21 22:40:16 +00:00
|
|
|
import {CommonModule} from '@angular/common';
|
|
|
|
|
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
|
|
|
|
import {MatButtonModule} from '@angular/material/button';
|
|
|
|
|
import {MatInputModule} from '@angular/material/input';
|
|
|
|
|
import {MatFormFieldModule} from '@angular/material/form-field';
|
|
|
|
|
import {MatSelectModule} from '@angular/material/select';
|
|
|
|
|
import {MatSliderModule} from '@angular/material/slider';
|
|
|
|
|
import {MatCheckboxModule} from '@angular/material/checkbox';
|
|
|
|
|
import {MatTabsModule} from '@angular/material/tabs';
|
|
|
|
|
import {MatCardModule} from '@angular/material/card';
|
|
|
|
|
import {MatIconModule} from '@angular/material/icon';
|
|
|
|
|
import {HeaderComponent} from '../header/header.component';
|
|
|
|
|
|
2025-06-22 15:26:10 +00:00
|
|
|
// Services
|
2025-06-22 17:23:54 +00:00
|
|
|
import {IntersectionPlaneService} from './services/intersection-plane.service';
|
2025-06-22 15:59:29 +00:00
|
|
|
import {ParticleManagerService} from './services/particle-manager.service';
|
2025-06-21 22:40:16 +00:00
|
|
|
|
2025-06-22 15:26:10 +00:00
|
|
|
// Models
|
2025-06-22 17:06:52 +00:00
|
|
|
import {PropertiesComponent} from './components/properties/properties.component';
|
|
|
|
|
import {ParticleComponent} from './components/particle/particle.component';
|
|
|
|
|
import {FramesComponent} from './components/frames/frames.component';
|
|
|
|
|
import {MatSnackBar} from '@angular/material/snack-bar';
|
2025-06-22 17:23:54 +00:00
|
|
|
import {RenderContainerComponent} from './components/render-container/render-container.component';
|
2025-06-21 22:40:16 +00:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-particles',
|
|
|
|
|
standalone: true,
|
|
|
|
|
imports: [
|
|
|
|
|
CommonModule,
|
|
|
|
|
FormsModule,
|
|
|
|
|
ReactiveFormsModule,
|
|
|
|
|
MatButtonModule,
|
|
|
|
|
MatInputModule,
|
|
|
|
|
MatFormFieldModule,
|
|
|
|
|
MatSelectModule,
|
|
|
|
|
MatSliderModule,
|
|
|
|
|
MatCheckboxModule,
|
|
|
|
|
MatTabsModule,
|
|
|
|
|
MatCardModule,
|
|
|
|
|
MatIconModule,
|
2025-06-22 17:06:52 +00:00
|
|
|
HeaderComponent,
|
|
|
|
|
PropertiesComponent,
|
|
|
|
|
ParticleComponent,
|
|
|
|
|
FramesComponent,
|
2025-06-22 17:23:54 +00:00
|
|
|
RenderContainerComponent,
|
2025-06-21 22:40:16 +00:00
|
|
|
],
|
|
|
|
|
templateUrl: './particles.component.html',
|
|
|
|
|
styleUrl: './particles.component.scss'
|
|
|
|
|
})
|
2025-06-22 17:23:54 +00:00
|
|
|
export class ParticlesComponent {
|
2025-06-21 22:40:16 +00:00
|
|
|
@ViewChild('planeSlider') planeSlider!: ElementRef;
|
|
|
|
|
|
2025-06-22 15:26:10 +00:00
|
|
|
constructor(
|
|
|
|
|
private intersectionPlaneService: IntersectionPlaneService,
|
|
|
|
|
private particleManagerService: ParticleManagerService,
|
2025-06-22 17:06:52 +00:00
|
|
|
private matSnackBar: MatSnackBar,
|
2025-06-22 15:26:10 +00:00
|
|
|
) {
|
2025-06-21 22:40:16 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-22 15:26:10 +00:00
|
|
|
/**
|
|
|
|
|
* Update plane position based on slider
|
|
|
|
|
*/
|
2025-06-21 22:40:16 +00:00
|
|
|
public updatePlanePosition(event: Event): void {
|
|
|
|
|
const slider = event.target as HTMLInputElement;
|
2025-06-22 15:26:10 +00:00
|
|
|
const value = Number(slider.value);
|
|
|
|
|
this.intersectionPlaneService.updatePlanePosition(value);
|
2025-06-21 22:40:16 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-22 15:26:10 +00:00
|
|
|
/**
|
|
|
|
|
* Get the current plane position
|
|
|
|
|
*/
|
|
|
|
|
public get planePosition(): number {
|
|
|
|
|
return this.intersectionPlaneService.getPlanePosition();
|
2025-06-21 22:55:38 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-22 15:59:29 +00:00
|
|
|
public set planePosition(newPlanePosition: number) {
|
|
|
|
|
this.intersectionPlaneService.updatePlanePosition(newPlanePosition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public get maxOffset(): number {
|
|
|
|
|
return this.intersectionPlaneService.getMaxOffset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public get minOffset(): number {
|
|
|
|
|
return this.intersectionPlaneService.getMinOffset();
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-22 15:26:10 +00:00
|
|
|
/**
|
|
|
|
|
* Generate JSON output
|
|
|
|
|
*/
|
2025-06-21 22:40:16 +00:00
|
|
|
public generateJson(): string {
|
2025-06-22 15:26:10 +00:00
|
|
|
return this.particleManagerService.generateJson();
|
2025-06-21 22:40:16 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-22 17:06:52 +00:00
|
|
|
public copyJson() {
|
|
|
|
|
navigator.clipboard.writeText(this.generateJson()).then(() => {
|
|
|
|
|
this.matSnackBar.open('Copied to clipboard', '', {duration: 2000})
|
|
|
|
|
});
|
2025-06-21 22:40:16 +00:00
|
|
|
}
|
|
|
|
|
}
|