Skip to content

Commit 5838c86

Browse files
committed
Editor: Avoid initializing Pathtracer when moving the camera.
1 parent 3d07bac commit 5838c86

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

editor/js/Viewport.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ function Viewport( editor ) {
266266
controls.center.set( 0, 0, 0 );
267267
pathtracer.reset();
268268

269+
initPT();
269270
render();
270271

271272
} );
@@ -362,6 +363,7 @@ function Viewport( editor ) {
362363

363364
signals.sceneGraphChanged.add( function () {
364365

366+
initPT();
365367
render();
366368

367369
} );
@@ -411,6 +413,7 @@ function Viewport( editor ) {
411413

412414
}
413415

416+
initPT();
414417
render();
415418

416419
} );
@@ -437,13 +440,15 @@ function Viewport( editor ) {
437440

438441
}
439442

443+
initPT();
440444
render();
441445

442446
} );
443447

444448
signals.objectRemoved.add( function ( object ) {
445449

446450
controls.enabled = true; // see #14180
451+
447452
if ( object === transformControls.object ) {
448453

449454
transformControls.detach();
@@ -454,6 +459,7 @@ function Viewport( editor ) {
454459

455460
signals.materialChanged.add( function () {
456461

462+
initPT();
457463
render();
458464

459465
} );
@@ -507,6 +513,7 @@ function Viewport( editor ) {
507513

508514
}
509515

516+
initPT();
510517
render();
511518

512519
} );
@@ -529,6 +536,7 @@ function Viewport( editor ) {
529536
useBackgroundAsEnvironment = true;
530537

531538
scene.environment = scene.background;
539+
scene.environment.mapping = THREE.EquirectangularReflectionMapping;
532540
scene.environmentRotation.y = scene.backgroundRotation.y;
533541

534542
break;
@@ -537,8 +545,8 @@ function Viewport( editor ) {
537545

538546
if ( environmentEquirectangularTexture ) {
539547

540-
environmentEquirectangularTexture.mapping = THREE.EquirectangularReflectionMapping;
541548
scene.environment = environmentEquirectangularTexture;
549+
scene.environment.mapping = THREE.EquirectangularReflectionMapping;
542550

543551
}
544552

@@ -552,6 +560,7 @@ function Viewport( editor ) {
552560

553561
}
554562

563+
initPT();
555564
render();
556565

557566
} );
@@ -731,6 +740,22 @@ function Viewport( editor ) {
731740

732741
if ( needsUpdate === true ) render();
733742

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+
734759
if ( editor.viewportShading === 'realistic' ) {
735760

736761
pathtracer.update();
@@ -746,12 +771,6 @@ function Viewport( editor ) {
746771

747772
function render() {
748773

749-
if ( editor.viewportShading === 'realistic' ) {
750-
751-
pathtracer.init( scene, camera );
752-
753-
}
754-
755774
startTime = performance.now();
756775

757776
renderer.setViewport( 0, 0, container.dom.offsetWidth, container.dom.offsetHeight );

0 commit comments

Comments
 (0)