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' ;
2
10
import { extend , injectBeforeRender , NgtArgs , NgtPortal } from 'angular-three' ;
3
11
import { NgtpBloom , NgtpEffectComposer } from 'angular-three-postprocessing' ;
4
12
import { NgtsPerspectiveCamera } from 'angular-three-soba/cameras' ;
@@ -8,6 +16,7 @@ import * as THREE from 'three';
8
16
9
17
import { SimulationMaterial } from './simulation-material' ;
10
18
19
+ import { NgtTweakNumber , NgtTweakPane } from 'angular-three-tweakpane' ;
11
20
import fragmentShader from './fragment.glsl' with { loader : 'text' } ;
12
21
import vertexShader from './vertex.glsl' with { loader : 'text' } ;
13
22
@@ -66,6 +75,9 @@ export class FBOParticles {
66
75
protected readonly fragmentShader = fragmentShader ;
67
76
protected readonly AdditiveBlending = THREE . AdditiveBlending ;
68
77
78
+ frequency = input . required < number > ( ) ;
79
+ timeScale = input . required < number > ( ) ;
80
+
69
81
protected size = 128 ;
70
82
protected virtualScene = new THREE . Scene ( ) ;
71
83
protected virtualCamera = new THREE . OrthographicCamera ( - 1 , 1 , 1 , - 1 , 1 / Math . pow ( 2 , 53 ) , 1 ) ;
@@ -124,7 +136,8 @@ export class FBOParticles {
124
136
if ( ! simulationMaterial ) return ;
125
137
126
138
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 ( ) ;
128
141
} ) ;
129
142
}
130
143
}
@@ -137,18 +150,35 @@ export class FBOParticles {
137
150
<ngt-color *args="['black']" attach="background" />
138
151
<ngt-ambient-light [intensity]="Math.PI * 0.5" />
139
152
140
- <app-fbo-particles />
153
+ <app-fbo-particles [frequency]="frequency()" [timeScale]="timeScale()" />
141
154
142
155
<ngtp-effect-composer>
143
156
<ngtp-bloom [options]="{ luminanceThreshold: 0, intensity: 4 }" />
144
157
</ngtp-effect-composer>
145
158
146
159
<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>
147
165
` ,
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
+ ] ,
149
176
changeDetection : ChangeDetectionStrategy . OnPush ,
150
177
schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
151
178
} )
152
179
export class SceneGraph {
153
180
protected readonly Math = Math ;
181
+
182
+ protected frequency = signal ( 0.5 ) ;
183
+ protected timeScale = signal ( 1 ) ;
154
184
}
0 commit comments