Skip to content

Commit

Permalink
Cleaning up and extending sample for lightMapMode
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Naumann committed Dec 10, 2014
1 parent 4e866b2 commit e2d916c
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions examples/webgl_materials_lightmapmode.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
<script>

var camera, scene, renderer, stats;
var geometry, material, material2, material3, mesh, mesh2, mesh3;
var materials = [];
var geometry;

function setup() {

Expand All @@ -49,31 +50,38 @@

// Setting up geometry, materials and meshes

geometry = new THREE.BoxGeometry(200,200,200);
material = new THREE.MeshPhongMaterial({color: 0xffffff});
geometry = new THREE.BoxGeometry( 200, 200, 200 );

// Material 1: The default multiply blending
var material = new THREE.MeshPhongMaterial( { color: 0xffffff } );
material.map = THREE.ImageUtils.loadTexture( "textures/brick_diffuse.jpg" );
material.lightMap = THREE.ImageUtils.loadTexture( "textures/enhanced_lightmap.jpg" );
materials.push( material );

material.map = THREE.ImageUtils.loadTexture("textures/brick_diffuse.jpg");
material.lightMap = THREE.ImageUtils.loadTexture("textures/enhanced_lightmap.jpg");

material2 = material.clone();
// Material 2: The overlay blending
var material2 = material.clone();
material2.lightMapMode = THREE.OverlayOperation;

material3 = material.clone();
material3.lightMapMode = THREE.AddOperation;

materials.push( material2 );

// Material 3: Modulate2X blending
var material3 = material.clone();
material3.lightMapMode = THREE.Modulate2XOperation;
materials.push( material3 );

// Material 4: Additive blending
var material4 = material.clone();
material4.lightMapMode = THREE.AddOperation;
materials.push( material4 );

geometry.faceVertexUvs[1] = geometry.faceVertexUvs[0];

mesh = new THREE.Mesh(geometry, material);
mesh2 = new THREE.Mesh(geometry, material2);
mesh3 = new THREE.Mesh(geometry, material3);

mesh.position.x = -250;
mesh3.position.x = 250;

scene.add(mesh);
scene.add(mesh2);
scene.add(mesh3);
for ( var i=0; i < materials.length; i++ ) {

var mesh = new THREE.Mesh( geometry, materials[i] );
mesh.position.set( 250 * i - 375, 0, 0 )
scene.add( mesh );
}

// Some lights

var directionalLight = new THREE.DirectionalLight( 0xffffff, 1.475 );
Expand Down

0 comments on commit e2d916c

Please sign in to comment.