Skip to content

Commit bf38ff1

Browse files
committed
simple reproduce a bug
1 parent 46b395e commit bf38ff1

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

example/primitives.js

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Scene, SphereGeometry, MeshStandardMaterial, Mesh, BoxGeometry, PerspectiveCamera, ACESFilmicToneMapping, WebGLRenderer } from 'three';
22
import { WebGLPathTracer, GradientEquirectTexture } from '..';
33
import { getScaledSettings } from './utils/getScaledSettings.js';
4+
import GUI from 'three/examples/jsm/libs/lil-gui.module.min.js';
45

56
// init scene, renderer, camera, controls, etc
67
const scene = new Scene();
@@ -14,30 +15,26 @@ const ball1 = new Mesh(
1415
} )
1516
);
1617
const ball2 = new Mesh(
17-
sphereGeom,
18+
sphereGeom.clone(),
1819
new MeshStandardMaterial( {
1920
color: '#ff9800',
2021
roughness: 0.1,
2122
metalness: 1,
2223
} )
2324
);
2425
const ball3 = new Mesh(
25-
sphereGeom,
26+
sphereGeom.clone(),
2627
new MeshStandardMaterial( {
2728
color: '#2196f3',
2829
roughness: 0.2,
2930
metalness: 1,
3031
} )
3132
);
32-
const ground = new Mesh(
33-
new BoxGeometry( 3.5, 0.1, 1.5 ),
34-
new MeshStandardMaterial(),
35-
);
3633

3734
ball1.position.x = - 1;
3835
ball3.position.x = 1;
39-
ground.position.y = - 0.54;
40-
scene.add( ball1, ball2, ball3, ground );
36+
37+
scene.add( ball1 );
4138

4239
// set the environment map
4340
const texture = new GradientEquirectTexture();
@@ -61,6 +58,23 @@ pathTracer.renderScale = settings.renderScale;
6158
pathTracer.tiles.setScalar( settings.tiles );
6259
pathTracer.setScene( scene, camera );
6360

61+
let gui = new GUI();
62+
const params = {
63+
'enable' : false,
64+
'addedModel' : false
65+
}
66+
gui.add(params, 'enable').name('Enable');
67+
68+
gui.add(params, 'addedModel').name('Add model').onChange(() => {
69+
if( params.addedModel ) {
70+
scene.add( ball2, ball3 );
71+
pathTracer.setScene( scene, camera );
72+
} else {
73+
scene.remove( ball2, ball3 );
74+
pathTracer.setScene( scene, camera );
75+
}
76+
});
77+
6478
onResize();
6579

6680
animate();
@@ -73,7 +87,15 @@ function animate() {
7387
requestAnimationFrame( animate );
7488

7589
// update the camera and render one sample
76-
pathTracer.renderSample();
90+
if( params.enable ) {
91+
92+
pathTracer.renderSample();
93+
94+
} else {
95+
96+
renderer.render( scene, camera );
97+
98+
}
7799

78100
}
79101

0 commit comments

Comments
 (0)