Skip to content

Commit

Permalink
Add control to show/hide floor
Browse files Browse the repository at this point in the history
  • Loading branch information
Rockfan121 committed Jun 6, 2017
1 parent 2e20d9a commit 827cbd1
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions RainyScene.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

<script>

var scene, camera, renderer, container, curentMaterials, boxNr;
var scene, camera, renderer, container, curentMaterials, boxNr, floor, isFloorVisible;
var rainEngines = [];
var cloudEngines = [];
var clock = new THREE.Clock();
Expand Down Expand Up @@ -148,12 +148,13 @@
scene.add(skyBox);

// add floor - just for now, later can be replaced with skyBox
isFloorVisible = true;
var floorTexture = new THREE.ImageUtils.loadTexture('images/checkerboard.jpg');
floorTexture.wrapS = floorTexture.wrapT = THREE.RepeatWrapping;
floorTexture.repeat.set( 10, 10 );
var floorMaterial = new THREE.MeshBasicMaterial( { color: 0x444444, map: floorTexture, side: THREE.DoubleSide } );
var floorGeometry = new THREE.PlaneGeometry(100, 100, 10, 10);
var floor = new THREE.Mesh(floorGeometry, floorMaterial);
var floorGeometry = new THREE.PlaneGeometry(200, 200, 10, 10);
floor = new THREE.Mesh(floorGeometry, floorMaterial);
floor.position.y = -10.5;
floor.rotation.x = Math.PI / 2;
scene.add(floor);
Expand Down Expand Up @@ -193,7 +194,8 @@
windSpeedX: 0.0,
windSpeedZ: 0.0,
currentScene: "lake",
reset: function() { reset() }
reset: function() { reset() },
showHideFloor: function() { showHideFloor() }
};

var dir1 = gui.addFolder('Rain');
Expand Down Expand Up @@ -338,6 +340,8 @@
skyBox.scale.set(-1,1,1);
scene.add(skyBox);
});

gui.add(parameters, 'showHideFloor').name("Show/hide floor");
}

function animate(){
Expand Down Expand Up @@ -415,6 +419,18 @@
parameters.windSpeedZ = 0.0;
}

function showHideFloor(){
if(isFloorVisible){
isFloorVisible = false;
scene.remove(floor);
}
else {
isFloorVisible = true;
scene.add(floor);
}
}


</script>
</body>
</html>

0 comments on commit 827cbd1

Please sign in to comment.