@@ -266,6 +266,7 @@ function Viewport( editor ) {
266
266
controls . center . set ( 0 , 0 , 0 ) ;
267
267
pathtracer . reset ( ) ;
268
268
269
+ initPT ( ) ;
269
270
render ( ) ;
270
271
271
272
} ) ;
@@ -362,6 +363,7 @@ function Viewport( editor ) {
362
363
363
364
signals . sceneGraphChanged . add ( function ( ) {
364
365
366
+ initPT ( ) ;
365
367
render ( ) ;
366
368
367
369
} ) ;
@@ -411,6 +413,7 @@ function Viewport( editor ) {
411
413
412
414
}
413
415
416
+ initPT ( ) ;
414
417
render ( ) ;
415
418
416
419
} ) ;
@@ -437,13 +440,15 @@ function Viewport( editor ) {
437
440
438
441
}
439
442
443
+ initPT ( ) ;
440
444
render ( ) ;
441
445
442
446
} ) ;
443
447
444
448
signals . objectRemoved . add ( function ( object ) {
445
449
446
450
controls . enabled = true ; // see #14180
451
+
447
452
if ( object === transformControls . object ) {
448
453
449
454
transformControls . detach ( ) ;
@@ -454,6 +459,7 @@ function Viewport( editor ) {
454
459
455
460
signals . materialChanged . add ( function ( ) {
456
461
462
+ initPT ( ) ;
457
463
render ( ) ;
458
464
459
465
} ) ;
@@ -507,6 +513,7 @@ function Viewport( editor ) {
507
513
508
514
}
509
515
516
+ initPT ( ) ;
510
517
render ( ) ;
511
518
512
519
} ) ;
@@ -529,6 +536,7 @@ function Viewport( editor ) {
529
536
useBackgroundAsEnvironment = true ;
530
537
531
538
scene . environment = scene . background ;
539
+ scene . environment . mapping = THREE . EquirectangularReflectionMapping ;
532
540
scene . environmentRotation . y = scene . backgroundRotation . y ;
533
541
534
542
break ;
@@ -537,8 +545,8 @@ function Viewport( editor ) {
537
545
538
546
if ( environmentEquirectangularTexture ) {
539
547
540
- environmentEquirectangularTexture . mapping = THREE . EquirectangularReflectionMapping ;
541
548
scene . environment = environmentEquirectangularTexture ;
549
+ scene . environment . mapping = THREE . EquirectangularReflectionMapping ;
542
550
543
551
}
544
552
@@ -552,6 +560,7 @@ function Viewport( editor ) {
552
560
553
561
}
554
562
563
+ initPT ( ) ;
555
564
render ( ) ;
556
565
557
566
} ) ;
@@ -731,6 +740,22 @@ function Viewport( editor ) {
731
740
732
741
if ( needsUpdate === true ) render ( ) ;
733
742
743
+ updatePT ( ) ;
744
+
745
+ }
746
+
747
+ function initPT ( ) {
748
+
749
+ if ( editor . viewportShading === 'realistic' ) {
750
+
751
+ pathtracer . init ( scene , camera ) ;
752
+
753
+ }
754
+
755
+ }
756
+
757
+ function updatePT ( ) {
758
+
734
759
if ( editor . viewportShading === 'realistic' ) {
735
760
736
761
pathtracer . update ( ) ;
@@ -746,12 +771,6 @@ function Viewport( editor ) {
746
771
747
772
function render ( ) {
748
773
749
- if ( editor . viewportShading === 'realistic' ) {
750
-
751
- pathtracer . init ( scene , camera ) ;
752
-
753
- }
754
-
755
774
startTime = performance . now ( ) ;
756
775
757
776
renderer . setViewport ( 0 , 0 , container . dom . offsetWidth , container . dom . offsetHeight ) ;
0 commit comments