1- import { ChangeDetectionStrategy , Component , computed , CUSTOM_ELEMENTS_SCHEMA , input , signal } from '@angular/core' ;
1+ import { ChangeDetectionStrategy , Component , computed , CUSTOM_ELEMENTS_SCHEMA , input } from '@angular/core' ;
22import { injectLoader , NgtArgs } from 'angular-three' ;
33import { NgtsText3D } from 'angular-three-soba/abstractions' ;
44import { NgtsOrbitControls } from 'angular-three-soba/controls' ;
@@ -13,15 +13,8 @@ import {
1313 NgtsRandomizedLights ,
1414} from 'angular-three-soba/staging' ;
1515import { RGBELoader } from 'three-stdlib' ;
16+ import { Tweaks } from './tweaks' ;
1617
17- import {
18- NgtTweakCheckbox ,
19- NgtTweakColor ,
20- NgtTweakFolder ,
21- NgtTweakNumber ,
22- NgtTweakPane ,
23- NgtTweakText ,
24- } from 'angular-three-tweakpane' ;
2518import fontGlyphs from './inter_medium.json' ;
2619
2720@Component ( {
@@ -107,10 +100,7 @@ export class TextAndGrid {
107100 ( ) => 'https://dl.polyhaven.org/file/ph-assets/HDRIs/hdr/1k/aerodynamics_workshop_1k.hdr' ,
108101 ) ;
109102
110- protected materialOptions = computed ( ( ) => ( {
111- ...this . config ( ) ,
112- background : this . texture ( ) ,
113- } ) ) ;
103+ protected materialOptions = computed ( ( ) => ( { ...this . config ( ) , background : this . texture ( ) } ) ) ;
114104
115105 protected readonly Math = Math ;
116106}
@@ -119,11 +109,11 @@ export class TextAndGrid {
119109 selector : 'app-scene-graph' ,
120110 template : `
121111 <ngt-color *args="['#f0f0f0']" attach="background" />
122- <app-text-and-grid [text]="text()" [config]="materialConfig()" />
112+ <app-text-and-grid [text]="tweaks. text()" [config]="tweaks. materialConfig()" />
123113
124114 <ngts-orbit-controls
125115 [options]="{
126- autoRotate: autoRotate(),
116+ autoRotate: tweaks. autoRotate(),
127117 autoRotateSpeed: -0.1,
128118 zoomSpeed: 0.25,
129119 minZoom: 40,
@@ -184,7 +174,7 @@ export class TextAndGrid {
184174 [options]="{
185175 temporal: false,
186176 frames: 100,
187- color: shadow(),
177+ color: tweaks. shadow(),
188178 colorBlend: 5,
189179 toneMapped: true,
190180 alphaTest: 0.9,
@@ -207,53 +197,7 @@ export class TextAndGrid {
207197 />
208198 </ngts-accumulative-shadows>
209199
210- <ngt-tweak-pane title="Epoxy Resin" left="8px">
211- <ngt-tweak-text [(value)]="text" label="text" />
212- <ngt-tweak-color [(value)]="shadow" label="Shadow Color" />
213- <ngt-tweak-checkbox [(value)]="autoRotate" label="Auto Rotate" />
214- <ngt-tweak-folder title="Text Material">
215- <ngt-tweak-checkbox [(value)]="backside" label="Backside" />
216- <ngt-tweak-number
217- [(value)]="backsideThickness"
218- label="Backside Thickness"
219- [params]="{ min: 0, max: 2 }"
220- />
221- <ngt-tweak-number [(value)]="samples" label="Samples" [params]="{ min: 1, max: 32, step: 1 }" />
222- <ngt-tweak-number
223- [(value)]="resolution"
224- label="Resolution"
225- [params]="{ min: 64, max: 2048, step: 64 }"
226- />
227- <ngt-tweak-number [(value)]="transmission" label="Transmission" [params]="{ min: 0, max: 1 }" />
228- <ngt-tweak-number [(value)]="clearcoat" label="Clearcoat" [params]="{ min: 0.1, max: 1 }" />
229- <ngt-tweak-number
230- [(value)]="clearcoatRoughness"
231- label="Clearcoat Roughness"
232- [params]="{ min: 0, max: 1 }"
233- />
234- <ngt-tweak-number [(value)]="thickness" label="Thickness" [params]="{ min: 0, max: 5 }" />
235- <ngt-tweak-number
236- [(value)]="chromaticAberration"
237- label="Chromatic Aberration"
238- [params]="{ min: 0, max: 5 }"
239- />
240- <ngt-tweak-number [(value)]="anisotropy" label="Anisotropy" [params]="{ min: 0, max: 1, step: 0.01 }" />
241- <ngt-tweak-number [(value)]="roughness" label="Roughness" [params]="{ min: 0, max: 1, step: 0.01 }" />
242- <ngt-tweak-number [(value)]="distortion" label="Distortion" [params]="{ min: 0, max: 4, step: 0.01 }" />
243- <ngt-tweak-number
244- [(value)]="distortionScale"
245- label="Distortion Scale"
246- [params]="{ min: 0.01, max: 1, step: 0.01 }"
247- />
248- <ngt-tweak-number
249- [(value)]="temporalDistortion"
250- label="Temporal Distortion"
251- [params]="{ min: 0, max: 1, step: 0.01 }"
252- />
253- <ngt-tweak-number [(value)]="ior" label="IOR" [params]="{ min: 0, max: 2, step: 0.01 }" />
254- <ngt-tweak-color [(value)]="color" label="Color" />
255- </ngt-tweak-folder>
256- </ngt-tweak-pane>
200+ <app-tweaks #tweaks />
257201 ` ,
258202 schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
259203 changeDetection : ChangeDetectionStrategy . OnPush ,
@@ -265,53 +209,9 @@ export class TextAndGrid {
265209 NgtsLightformer ,
266210 NgtsAccumulativeShadows ,
267211 NgtsRandomizedLights ,
268- NgtTweakPane ,
269- NgtTweakText ,
270- NgtTweakFolder ,
271- NgtTweakCheckbox ,
272- NgtTweakNumber ,
273- NgtTweakColor ,
212+ Tweaks ,
274213 ] ,
275214} )
276215export class SceneGraph {
277216 protected readonly Math = Math ;
278-
279- protected text = signal ( 'Angular' ) ;
280- protected backside = signal ( true ) ;
281- protected backsideThickness = signal ( 0.3 ) ;
282- protected samples = signal ( 16 ) ;
283- protected resolution = signal ( 1024 ) ;
284- protected transmission = signal ( 1 ) ;
285- protected clearcoat = signal ( 0 ) ;
286- protected clearcoatRoughness = signal ( 0.0 ) ;
287- protected thickness = signal ( 0.3 ) ;
288- protected chromaticAberration = signal ( 5 ) ;
289- protected anisotropy = signal ( 0.3 ) ;
290- protected roughness = signal ( 0 ) ;
291- protected distortion = signal ( 0.5 ) ;
292- protected distortionScale = signal ( 0.1 ) ;
293- protected temporalDistortion = signal ( 0 ) ;
294- protected ior = signal ( 1.5 ) ;
295- protected color = signal ( '#ff9cf5' ) ;
296- protected shadow = signal ( '#750d57' ) ;
297- protected autoRotate = signal ( false ) ;
298-
299- protected materialConfig = computed ( ( ) => ( {
300- color : this . color ( ) ,
301- roughness : this . roughness ( ) ,
302- transmission : this . transmission ( ) ,
303- thickness : this . thickness ( ) ,
304- ior : this . ior ( ) ,
305- clearcoat : this . clearcoat ( ) ,
306- clearcoatRoughness : this . clearcoatRoughness ( ) ,
307- anisotropy : this . anisotropy ( ) ,
308- chromaticAberration : this . chromaticAberration ( ) ,
309- distortion : this . distortion ( ) ,
310- distortionScale : this . distortionScale ( ) ,
311- temporalDistortion : this . temporalDistortion ( ) ,
312- backside : this . backside ( ) ,
313- backsideThickness : this . backsideThickness ( ) ,
314- samples : this . samples ( ) ,
315- resolution : this . resolution ( ) ,
316- } ) ) ;
317217}
0 commit comments