When working with three.js, I have been experimenting with the concept of cutting out a window from a box geometry, which represents a wall. I came across a helpful csg (constructive solid geometry) extension on this GitHub repository.
After successfully cutting out the window, I noticed that the surface of the resulting geometry reflects light in a peculiar manner, as shown below.
var leftWallGeometry = new THREE.BoxGeometry( $scope.wall.width, $scope.room.height, $scope.room.depth);
var leftWallMesh = new THREE.Mesh( leftWallGeometry );
var leftWallBSP = new ThreeBSP( leftWallMesh );
var leftWindowGeometry = new THREE.BoxGeometry($scope.wall.width +10, 100, 100 );
var leftWindowMesh = new THREE.Mesh( leftWindowGeometry)
var leftWindowBSP = new ThreeBSP( leftWindowMesh );
var windowWallBSP = leftWallBSP.subtract( leftWindowBSP );
var result = windowWallBSP.toMesh( wallMaterial );
result.geometry.computeVertexNormals();
result.position.x = $scope.room.width / -2
result.position.y = $scope.room.height / 2
$scope.scene.add( result );
The material used for the wall is a MeshPhongMaterial with a repeated texture and bump map applied to it.
var wallTexture = new THREE.ImageUtils.loadTexture('img/wall_diffuse_0.jpg')
// wall bump texture
var wallBumpTexture = new THREE.ImageUtils.loadTexture('img/bump_1.jpg')
// repeate wall texture and wall bump texture
wallTexture.wrapS = wallTexture.wrapT = THREE.RepeatWrapping;
wallTexture.repeat.set( 10, 10 );
wallBumpTexture.wrapS = wallBumpTexture.wrapT = THREE.RepeatWrapping;
wallBumpTexture.repeat.set( 10, 10 );
var wallMaterial = new THREE.MeshPhongMaterial( { map: wallTexture, bumpMap: wallBumpTexture, bumpScale: 0.2} );
I am seeking advice on how to resolve this unusual light reflection issue or alternative methods to effectively cut windows from walls/boxes in three.js. Any suggestions would be greatly appreciated.