Skip to content

Commit 76c8ca0

Browse files
committed
docs: adjust shoe configuration
1 parent 98a8db9 commit 76c8ca0

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

apps/examples/src/app/soba/shoe-configuration/scene.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
inject,
99
signal,
1010
} from '@angular/core';
11-
import { signalState } from 'angular-three';
11+
import { NgtArgs, signalState } from 'angular-three';
1212
import { NgtsOrbitControls } from 'angular-three-soba/controls';
1313
import { injectGLTF } from 'angular-three-soba/loaders';
1414
import { NgtsContactShadows, NgtsEnvironment, NgtsFloat } from 'angular-three-soba/staging';
@@ -17,7 +17,7 @@ import shoeGLB from './shoe-draco.glb' with { loader: 'file' };
1717

1818
injectGLTF.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
})
3948
export 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
})
179195
export class SceneGraph {
180196
protected readonly Math = Math;
Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
11
import { ChangeDetectionStrategy, Component } from '@angular/core';
22
import { NgtCanvas } from 'angular-three/dom';
3-
import { SceneGraph, state } from './scene';
3+
import { ColorPicker, SceneGraph } from './scene';
44

55
@Component({
66
template: `
77
<ngt-canvas shadows [camera]="{ position: [0, 0, 4], fov: 45 }">
88
<app-scene-graph *canvasContent />
99
</ngt-canvas>
10-
@let current = state.current();
11-
<div [class.block]="!!current" [class.hidden]="!current" class="absolute top-4 left-4">
12-
@if (current) {
13-
<input type="color" [value]="$any(state.items)[current]()" (input)="onChange($event, current)" />
14-
<h1 class="text-xl font-bold font-mono">{{ current }}</h1>
15-
}
16-
</div>
10+
<app-color-picker />
1711
`,
1812
changeDetection: ChangeDetectionStrategy.OnPush,
1913
host: { class: 'soba-shoe-configuration' },
20-
imports: [NgtCanvas, SceneGraph],
14+
imports: [NgtCanvas, SceneGraph, ColorPicker],
2115
})
22-
export default class ShoeConfiguration {
23-
protected readonly state = state;
24-
25-
onChange(event: Event, current: string) {
26-
const target = event.target as HTMLInputElement;
27-
this.state.update((state) => ({ items: { ...state.items, [current]: target.value } }));
28-
}
29-
}
16+
export default class ShoeConfiguration {}

0 commit comments

Comments
 (0)