88 inject ,
99 signal ,
1010} from '@angular/core' ;
11- import { signalState } from 'angular-three' ;
11+ import { NgtArgs , signalState } from 'angular-three' ;
1212import { NgtsOrbitControls } from 'angular-three-soba/controls' ;
1313import { injectGLTF } from 'angular-three-soba/loaders' ;
1414import { NgtsContactShadows , NgtsEnvironment , NgtsFloat } from 'angular-three-soba/staging' ;
@@ -17,7 +17,7 @@ import shoeGLB from './shoe-draco.glb' with { loader: 'file' };
1717
1818injectGLTF . preload ( ( ) => shoeGLB ) ;
1919
20- export const state = signalState ( {
20+ const state = signalState ( {
2121 current : null as string | null ,
2222 items : {
2323 laces : '#ffffff' ,
@@ -33,11 +33,25 @@ export const state = signalState({
3333
3434@Component ( {
3535 selector : 'app-color-picker' ,
36- template : `` ,
36+ template : `
37+ @let current = state.current();
38+ <div class="absolute top-12 left-1/2 -translate-x-1/2" [class]="{ block: !!current, hidden: !current }">
39+ @if (current) {
40+ @let value = $any(state.items)[current]();
41+ <input type="color" [value]="value" (input)="onChange($event, current)" />
42+ <h1 class="text-xl font-bold font-mono">{{ current }}</h1>
43+ }
44+ </div>
45+ ` ,
3746 changeDetection : ChangeDetectionStrategy . OnPush ,
3847} )
3948export class ColorPicker {
4049 protected readonly state = state ;
50+
51+ protected onChange ( event : Event , current : string ) {
52+ const target = event . target as HTMLInputElement ;
53+ this . state . update ( ( state ) => ( { items : { ...state . items , [ current ] : target . value } } ) ) ;
54+ }
4155}
4256
4357@Component ( {
@@ -156,6 +170,8 @@ export class Shoe {
156170@Component ( {
157171 selector : 'app-scene-graph' ,
158172 template : `
173+ <ngt-color *args="['#c0c0c0']" attach="background" />
174+
159175 <ngt-ambient-light [intensity]="Math.PI * 0.7" />
160176 <ngt-spot-light
161177 [decay]="0"
@@ -174,7 +190,7 @@ export class Shoe {
174190 ` ,
175191 schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
176192 changeDetection : ChangeDetectionStrategy . OnPush ,
177- imports : [ Shoe , NgtsEnvironment , NgtsContactShadows , NgtsOrbitControls ] ,
193+ imports : [ Shoe , NgtsEnvironment , NgtsContactShadows , NgtsOrbitControls , NgtArgs ] ,
178194} )
179195export class SceneGraph {
180196 protected readonly Math = Math ;
0 commit comments