@@ -277,18 +277,21 @@ const ExportCanvas = ({show}:{show: boolean}) => {
277277
278278 const originalSize = gl . getSize ( new THREE . Vector2 ( ) )
279279 let originalCameraSettings : any = { } ;
280+
281+
280282
281- function SetCamera ( ) {
283+ function SetCamera ( set = false ) {
282284 if ( camera instanceof THREE . PerspectiveCamera ) {
283- originalCameraSettings = { aspect : camera . aspect }
285+ if ( set ) { originalCameraSettings = { aspect : camera . aspect } }
286+
284287 camera . aspect = docWidth / docHeight
285288 } else if ( camera instanceof THREE . OrthographicCamera ) {
286- originalCameraSettings = {
289+ if ( set ) { originalCameraSettings = {
287290 left : camera . left ,
288291 right : camera . right ,
289292 top : camera . top ,
290293 bottom : camera . bottom
291- }
294+ } }
292295 const newAspect = docWidth / docHeight
293296 const currentAspect = ( camera . right - camera . left ) / ( camera . top - camera . bottom )
294297 if ( newAspect > currentAspect ) {
@@ -310,7 +313,7 @@ const ExportCanvas = ({show}:{show: boolean}) => {
310313 camera . updateProjectionMatrix ( )
311314 invalidate ( ) ;
312315 }
313-
316+ SetCamera ( true ) ;
314317 if ( animate ) {
315318 async function Animate ( ) {
316319 setStatus ( "Loading Module" )
@@ -444,7 +447,7 @@ const ExportCanvas = ({show}:{show: boolean}) => {
444447 camera . right = originalCameraSettings . right ;
445448 camera . top = originalCameraSettings . top ;
446449 camera . bottom = originalCameraSettings . bottom ;
447- }
450+ }
448451 gl . setSize ( originalSize . x , originalSize . y ) ;
449452 camera . updateProjectionMatrix ( ) ;
450453 invalidate ( ) ;
0 commit comments