File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -166,19 +166,18 @@ class GSplatInstance {
166166 }
167167 }
168168
169- updateViewport ( ) {
170- // TODO: improve, needs to handle render targets of different sizes
171- const device = this . splat . device ;
172- viewport [ 0 ] = device . width ;
173- viewport [ 1 ] = device . height ;
169+ updateViewport ( cameraNode ) {
170+ const camera = cameraNode ?. camera ;
171+ const renderTarget = camera ?. renderTarget ;
172+ const { width, height } = renderTarget ?? this . splat . device ;
173+
174+ viewport [ 0 ] = width ;
175+ viewport [ 1 ] = height ;
174176
175177 // adjust viewport for stereoscopic VR sessions
176- if ( this . cameras . length > 0 ) {
177- const camera = this . cameras [ 0 ] ;
178- const xr = camera . xr ;
179- if ( xr && xr . active && xr . views . list . length === 2 ) {
180- viewport [ 0 ] /= 2 ;
181- }
178+ const xr = camera ?. xr ;
179+ if ( xr ?. active && xr . views . list . length === 2 ) {
180+ viewport [ 0 ] *= 0.5 ;
182181 }
183182
184183 this . material . setParameter ( 'viewport' , viewport ) ;
@@ -207,7 +206,7 @@ class GSplatInstance {
207206 }
208207 }
209208
210- this . updateViewport ( ) ;
209+ this . updateViewport ( cameraNode ) ;
211210 }
212211
213212 update ( ) {
You can’t perform that action at this time.
0 commit comments