@@ -35,35 +35,34 @@ The function also has static methods for preloading and setting the decoder path
35
35
36
36
``` ts
37
37
@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 ,
46
45
})
47
46
class Suzi {
48
- gltf = injectGLTF (() => ' ./suzanne-high-poly.gltf' );
47
+ gltf = injectGLTF (() => ' ./suzanne-high-poly.gltf' );
49
48
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 ));
55
54
56
- const material = materials [' default' ] as MeshStandardMaterial ;
55
+ const material = materials [' default' ] as MeshStandardMaterial ;
57
56
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 );
64
63
65
- return scene ;
66
- });
64
+ return scene ;
65
+ });
67
66
}
68
67
```
69
68
@@ -77,32 +76,32 @@ The function also has a static method for preloading textures:
77
76
78
77
``` ts
79
78
@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
+ ` ,
85
84
})
86
85
export 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 );
93
92
}
94
93
```
95
94
96
95
## ` injectProgress `
97
96
98
97
``` ts
99
98
function 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 ;
106
105
}>;
107
106
```
108
107
0 commit comments