88 OnInit ,
99 ViewChild ,
1010} from '@angular/core' ;
11- import { injectBeforeRender , NgtArgs , NgtCanvas , NgtRenderState , NgtState , NgtStore } from 'angular-three' ;
11+ import { injectBeforeRender , NgtArgs , NgtCanvas , NgtPush , NgtRenderState , NgtState , NgtStore } from 'angular-three' ;
1212import * as THREE from 'three' ;
1313
1414@Component ( {
@@ -17,15 +17,15 @@ import * as THREE from 'three';
1717 <ngt-group #cameras>
1818 <ngt-perspective-camera
1919 #perspectiveCamera
20- [aspect]="store.get('viewport', ' aspect' ) * 0.5"
20+ [aspect]="( aspect$ | ngtPush ) * 0.5"
2121 [near]="150"
2222 [far]="1000"
2323 [rotation]="[0, Math.PI, 0]"
2424 />
2525 <ngt-orthographic-camera
2626 #orthographicCamera
27- [left]="(300 * store.get('viewport', ' aspect' )) / -2"
28- [right]="(300 * store.get('viewport', ' aspect' )) / 2"
27+ [left]="(300 * ( aspect$ | ngtPush )) / -2"
28+ [right]="(300 * ( aspect$ | ngtPush )) / 2"
2929 [top]="300"
3030 [bottom]="-300"
3131 [near]="150"
@@ -57,13 +57,13 @@ import * as THREE from 'three';
5757 <ngt-points-material color="#888888" />
5858 </ngt-points>
5959 ` ,
60- imports : [ NgtArgs ] ,
60+ imports : [ NgtArgs , NgtPush ] ,
6161 schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
6262} )
6363export class Scene implements AfterViewInit , OnInit {
6464 readonly Math = Math ;
6565
66- readonly store = inject ( NgtStore ) ;
66+ readonly aspect$ = inject ( NgtStore ) . select ( 'viewport' , 'aspect' ) ;
6767
6868 @ViewChild ( 'perspectiveCamera' , { static : true } ) perspectiveCamera ! : ElementRef < THREE . PerspectiveCamera > ;
6969 @ViewChild ( 'orthographicCamera' , { static : true } ) orthographicCamera ! : ElementRef < THREE . OrthographicCamera > ;
0 commit comments