Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reproduce a bug example, (Model disappeared when same 3 models pathtraced) #671

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions example/primitives.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Scene, SphereGeometry, MeshStandardMaterial, Mesh, BoxGeometry, PerspectiveCamera, ACESFilmicToneMapping, WebGLRenderer } from 'three';

Check warning on line 1 in example/primitives.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'BoxGeometry' is defined but never used
import { WebGLPathTracer, GradientEquirectTexture } from '..';
import { getScaledSettings } from './utils/getScaledSettings.js';
import GUI from 'three/examples/jsm/libs/lil-gui.module.min.js';

// init scene, renderer, camera, controls, etc
const scene = new Scene();
Expand All @@ -14,30 +15,26 @@
} )
);
const ball2 = new Mesh(
sphereGeom,
sphereGeom.clone(),
new MeshStandardMaterial( {
color: '#ff9800',
roughness: 0.1,
metalness: 1,
} )
);
const ball3 = new Mesh(
sphereGeom,
sphereGeom.clone(),
new MeshStandardMaterial( {
color: '#2196f3',
roughness: 0.2,
metalness: 1,
} )
);
const ground = new Mesh(
new BoxGeometry( 3.5, 0.1, 1.5 ),
new MeshStandardMaterial(),
);

ball1.position.x = - 1;
ball3.position.x = 1;
ground.position.y = - 0.54;
scene.add( ball1, ball2, ball3, ground );

scene.add( ball1 );

// set the environment map
const texture = new GradientEquirectTexture();
Expand All @@ -61,6 +58,23 @@
pathTracer.tiles.setScalar( settings.tiles );
pathTracer.setScene( scene, camera );

let gui = new GUI();

Check failure on line 61 in example/primitives.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'gui' is never reassigned. Use 'const' instead
const params = {
'enable' : false,

Check failure on line 63 in example/primitives.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Extra space after key 'enable'
'addedModel' : false

Check failure on line 64 in example/primitives.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Extra space after key 'addedModel'
}

Check failure on line 65 in example/primitives.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing semicolon
Fixed Show fixed Hide fixed
gui.add(params, 'enable').name('Enable');

Check failure on line 66 in example/primitives.js

View workflow job for this annotation

GitHub Actions / build (16.x)

There must be a space after this paren

Check failure on line 66 in example/primitives.js

View workflow job for this annotation

GitHub Actions / build (16.x)

There must be a space before this paren

Check failure on line 66 in example/primitives.js

View workflow job for this annotation

GitHub Actions / build (16.x)

There must be a space after this paren

Check failure on line 66 in example/primitives.js

View workflow job for this annotation

GitHub Actions / build (16.x)

There must be a space before this paren

gui.add(params, 'addedModel').name('Add model').onChange(() => {

Check failure on line 68 in example/primitives.js

View workflow job for this annotation

GitHub Actions / build (16.x)

There must be a space after this paren

Check failure on line 68 in example/primitives.js

View workflow job for this annotation

GitHub Actions / build (16.x)

There must be a space before this paren
if( params.addedModel ) {
scene.add( ball2, ball3 );
pathTracer.setScene( scene, camera );
} else {
scene.remove( ball2, ball3 );
pathTracer.setScene( scene, camera );
}
});

onResize();

animate();
Expand All @@ -73,7 +87,15 @@
requestAnimationFrame( animate );

// update the camera and render one sample
pathTracer.renderSample();
if( params.enable ) {

pathTracer.renderSample();

} else {

renderer.render( scene, camera );

}

}

Expand Down
Loading