@@ -35,35 +35,34 @@ The function also has static methods for preloading and setting the decoder path
3535
3636``` ts
3737@Component ({
38- selector: ' app-suzi' ,
39- standalone: true ,
40- template: `
41- <ngt-primitive *args="[scene()]" [rotation]="[-0.63, 0, 0]" [scale]="2" [position]="[0, -1.175, 0]" />
42- ` ,
43- imports: [NgtArgs ],
44- schemas: [CUSTOM_ELEMENTS_SCHEMA ],
45- changeDetection: ChangeDetectionStrategy .OnPush ,
38+ selector: ' app-suzi' ,
39+ template: `
40+ <ngt-primitive *args="[scene()]" [rotation]="[-0.63, 0, 0]" [scale]="2" [position]="[0, -1.175, 0]" />
41+ ` ,
42+ imports: [NgtArgs ],
43+ schemas: [CUSTOM_ELEMENTS_SCHEMA ],
44+ changeDetection: ChangeDetectionStrategy .OnPush ,
4645})
4746class Suzi {
48- gltf = injectGLTF (() => ' ./suzanne-high-poly.gltf' );
47+ gltf = injectGLTF (() => ' ./suzanne-high-poly.gltf' );
4948
50- scene = computed (() => {
51- const gltf = this .gltf ();
52- if (! gltf ) return null ;
53- const { scene, materials } = gltf ;
54- scene .traverse ((obj ) => (obj as any ).isMesh && (obj .receiveShadow = obj .castShadow = true ));
49+ scene = computed (() => {
50+ const gltf = this .gltf ();
51+ if (! gltf ) return null ;
52+ const { scene, materials } = gltf ;
53+ scene .traverse ((obj ) => (obj as any ).isMesh && (obj .receiveShadow = obj .castShadow = true ));
5554
56- const material = materials [' default' ] as MeshStandardMaterial ;
55+ const material = materials [' default' ] as MeshStandardMaterial ;
5756
58- material .color .set (' orange' );
59- material .roughness = 0 ;
60- material .normalMap = new CanvasTexture (new FlakesTexture (), UVMapping , RepeatWrapping , RepeatWrapping );
61- material .normalMap .flipY = false ;
62- material .normalMap .repeat .set (40 , 40 );
63- material .normalScale .set (0.05 , 0.05 );
57+ material .color .set (' orange' );
58+ material .roughness = 0 ;
59+ material .normalMap = new CanvasTexture (new FlakesTexture (), UVMapping , RepeatWrapping , RepeatWrapping );
60+ material .normalMap .flipY = false ;
61+ material .normalMap .repeat .set (40 , 40 );
62+ material .normalScale .set (0.05 , 0.05 );
6463
65- return scene ;
66- });
64+ return scene ;
65+ });
6766}
6867```
6968
@@ -77,32 +76,32 @@ The function also has a static method for preloading textures:
7776
7877``` ts
7978@Component ({
80- template: `
81- <ngt-mesh>
82- <ngt-mesh-physical-material [normalMap]="normalMap()" [roughnessMap]="roughnessMap()" />
83- </ngt-mesh>
84- ` ,
79+ template: `
80+ <ngt-mesh>
81+ <ngt-mesh-physical-material [normalMap]="normalMap()" [roughnessMap]="roughnessMap()" />
82+ </ngt-mesh>
83+ ` ,
8584})
8685export class MyCmp {
87- private textures = injectTexture (() => ({
88- roughnessMap: ' roughness_floor.jpeg' ,
89- normalMap: ' NORM.jpg' ,
90- }));
91- roughnessMap = computed (() => this .textures ()?.roughnessMap || null );
92- normalMap = computed (() => this .textures ()?.normalMap || null );
86+ private textures = injectTexture (() => ({
87+ roughnessMap: ' roughness_floor.jpeg' ,
88+ normalMap: ' NORM.jpg' ,
89+ }));
90+ roughnessMap = computed (() => this .textures ()?.roughnessMap || null );
91+ normalMap = computed (() => this .textures ()?.normalMap || null );
9392}
9493```
9594
9695## ` injectProgress `
9796
9897``` ts
9998function injectProgress(injector ? : Injector ): Signal <{
100- errors: string [];
101- active: boolean ;
102- progress: number ;
103- item: string ;
104- loaded: number ;
105- total: number ;
99+ errors: string [];
100+ active: boolean ;
101+ progress: number ;
102+ item: string ;
103+ loaded: number ;
104+ total: number ;
106105}>;
107106```
108107
0 commit comments