1- import { ChangeDetectionStrategy , Component , CUSTOM_ELEMENTS_SCHEMA , ElementRef , viewChild } from '@angular/core' ;
1+ import {
2+ ChangeDetectionStrategy ,
3+ Component ,
4+ CUSTOM_ELEMENTS_SCHEMA ,
5+ ElementRef ,
6+ input ,
7+ signal ,
8+ viewChild ,
9+ } from '@angular/core' ;
210import { extend , injectBeforeRender , NgtArgs , NgtPortal } from 'angular-three' ;
311import { NgtpBloom , NgtpEffectComposer } from 'angular-three-postprocessing' ;
412import { NgtsPerspectiveCamera } from 'angular-three-soba/cameras' ;
@@ -8,6 +16,7 @@ import * as THREE from 'three';
816
917import { SimulationMaterial } from './simulation-material' ;
1018
19+ import { NgtTweakNumber , NgtTweakPane } from 'angular-three-tweakpane' ;
1120import fragmentShader from './fragment.glsl' with { loader : 'text' } ;
1221import vertexShader from './vertex.glsl' with { loader : 'text' } ;
1322
@@ -66,6 +75,9 @@ export class FBOParticles {
6675 protected readonly fragmentShader = fragmentShader ;
6776 protected readonly AdditiveBlending = THREE . AdditiveBlending ;
6877
78+ frequency = input . required < number > ( ) ;
79+ timeScale = input . required < number > ( ) ;
80+
6981 protected size = 128 ;
7082 protected virtualScene = new THREE . Scene ( ) ;
7183 protected virtualCamera = new THREE . OrthographicCamera ( - 1 , 1 , 1 , - 1 , 1 / Math . pow ( 2 , 53 ) , 1 ) ;
@@ -124,7 +136,8 @@ export class FBOParticles {
124136 if ( ! simulationMaterial ) return ;
125137
126138 this . uniforms [ 'uPositions' ] . value = this . renderTarget ( ) . texture ;
127- simulationMaterial . uniforms [ 'uTime' ] . value = clock . elapsedTime ;
139+ simulationMaterial . uniforms [ 'uFrequency' ] . value = this . frequency ( ) ;
140+ simulationMaterial . uniforms [ 'uTime' ] . value = clock . elapsedTime * this . timeScale ( ) ;
128141 } ) ;
129142 }
130143}
@@ -137,18 +150,35 @@ export class FBOParticles {
137150 <ngt-color *args="['black']" attach="background" />
138151 <ngt-ambient-light [intensity]="Math.PI * 0.5" />
139152
140- <app-fbo-particles />
153+ <app-fbo-particles [frequency]="frequency()" [timeScale]="timeScale()" />
141154
142155 <ngtp-effect-composer>
143156 <ngtp-bloom [options]="{ luminanceThreshold: 0, intensity: 4 }" />
144157 </ngtp-effect-composer>
145158
146159 <ngts-orbit-controls [options]="{ enablePan: false }" />
160+
161+ <ngt-tweak-pane title="Particles" [top]="48" [expanded]="true">
162+ <ngt-tweak-number [(value)]="frequency" label="frequency" [params]="{ min: 0.25, max: 1, step: 0.01 }" />
163+ <ngt-tweak-number [(value)]="timeScale" label="timeScale" [params]="{ min: 0.5, max: 1.5, step: 0.01 }" />
164+ </ngt-tweak-pane>
147165 ` ,
148- imports : [ NgtsPerspectiveCamera , NgtsOrbitControls , NgtArgs , FBOParticles , NgtpEffectComposer , NgtpBloom ] ,
166+ imports : [
167+ NgtsPerspectiveCamera ,
168+ NgtsOrbitControls ,
169+ NgtArgs ,
170+ FBOParticles ,
171+ NgtpEffectComposer ,
172+ NgtpBloom ,
173+ NgtTweakPane ,
174+ NgtTweakNumber ,
175+ ] ,
149176 changeDetection : ChangeDetectionStrategy . OnPush ,
150177 schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
151178} )
152179export class SceneGraph {
153180 protected readonly Math = Math ;
181+
182+ protected frequency = signal ( 0.5 ) ;
183+ protected timeScale = signal ( 1 ) ;
154184}
0 commit comments