commit 17d56551a4a412dfadbf2f6b433d357d3c3731f0
parent 73c42627af1117963b1cd58ffea3968cdc7c96df
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date: Fri, 12 Jul 2024 18:21:48 -0300
add checkbox to enable/disable shadows
Diffstat:
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/tp/src/scene.js b/tp/src/scene.js
@@ -43,6 +43,7 @@ let settings = {
showHelpers: false,
showFps: true,
camera: "topView",
+ shadows: false
};
let raycaster;
@@ -301,7 +302,7 @@ function setupThreeJs() {
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap
- renderer.shadowMap.enabled = true;
+ renderer.shadowMap.enabled = settings.shadows;
document.body.appendChild(renderer.domElement);
@@ -877,7 +878,19 @@ function createMenu() {
} else {
document.body.removeChild(stats.dom);
}
- });
+ }
+ );
+ gui.add(settings, 'shadows', true).name('Sombras').onChange(
+ function() {
+ console.log(settings.shadows);
+ renderer.shadowMap.enabled = settings.shadows;
+ scene.traverse(function (child) {
+ if (child.material) {
+ child.material.needsUpdate = true
+ }
+ })
+ }
+ );
gui.add(settings, "camera", camerasName).name('Camara').setValue(camerasName[settings.currCameraIndex]).onChange(
function() {
console.log(settings.camera);
@@ -895,7 +908,7 @@ function createMenu() {
function buildScene() {
console.log('Building scene');
buildTunnel();
- buildTrees(100);
+ buildTrees(200);
buildTerrain();
buildRailsFoundation();
buildRails();