|
@@ -336,6 +336,8 @@
|
|
|
|
|
|
function initScene( object, y, scale ) {
|
|
function initScene( object, y, scale ) {
|
|
|
|
|
|
|
|
+ var black = new THREE.Color( 0x000000 );
|
|
|
|
+
|
|
object.traverse( function( node ) {
|
|
object.traverse( function( node ) {
|
|
|
|
|
|
if ( node.material ) {
|
|
if ( node.material ) {
|
|
@@ -354,7 +356,14 @@
|
|
|
|
|
|
} );
|
|
} );
|
|
|
|
|
|
- uniforms.diffuse.value.copy( node.material.color );
|
|
|
|
|
|
+ var diffuse = node.material.color;
|
|
|
|
+ var specular = node.material.specular !== undefined ? node.material.specular : black;
|
|
|
|
+ var shininess = node.material.shininess !== undefined ? node.material.shininess : 1;
|
|
|
|
+
|
|
|
|
+ uniforms.diffuse.value.copy( diffuse );
|
|
|
|
+ uniforms.specular.value.copy( specular );
|
|
|
|
+ uniforms.shininess.value = shininess;
|
|
|
|
+
|
|
uniforms.map.value = node.material.map;
|
|
uniforms.map.value = node.material.map;
|
|
|
|
|
|
if ( node.material.bumpMap ) {
|
|
if ( node.material.bumpMap ) {
|
|
@@ -669,51 +678,9 @@
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- // -----------------------------
|
|
|
|
- // entry point
|
|
|
|
- // -----------------------------
|
|
|
|
|
|
+ function generateBox() {
|
|
|
|
|
|
- bootstrap();
|
|
|
|
- initMaterials();
|
|
|
|
- initLights();
|
|
|
|
- createRenderTargets();
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- var loader = new THREE.UTF8Loader();
|
|
|
|
-
|
|
|
|
- loader.load( "models/utf8/ben_dds.js", function ( object ) {
|
|
|
|
-
|
|
|
|
- initScene( object, -75, 150 );
|
|
|
|
- animate();
|
|
|
|
-
|
|
|
|
- }, { normalizeRGB: true } );
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- loader.load( "models/utf8/WaltHi.js", function ( object ) {
|
|
|
|
-
|
|
|
|
- initScene( object, -35, 1 );
|
|
|
|
- animate();
|
|
|
|
-
|
|
|
|
- }, { normalizeRGB: true } );
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
- var loader = new THREE.JSONLoader();
|
|
|
|
- loader.load( "obj/leeperrysmith/LeePerrySmith.js", function( geometry, materials ) {
|
|
|
|
-
|
|
|
|
- var mapColor = THREE.ImageUtils.loadTexture( "obj/leeperrysmith/Map-COL.jpg" );
|
|
|
|
- var mapHeight = THREE.ImageUtils.loadTexture( "obj/leeperrysmith/Infinite-Level_02_Disp_NoSmoothUV-4096.jpg" );
|
|
|
|
- mapHeight.repeat.set( 0.998, 0.998 );
|
|
|
|
- mapHeight.offset.set( 0.001, 0.001 )
|
|
|
|
- mapHeight.wrapS = mapHeight.wrapT = THREE.RepeatWrapping;
|
|
|
|
- mapHeight.anisotropy = 4;
|
|
|
|
- mapHeight.format = THREE.RGBFormat;
|
|
|
|
-
|
|
|
|
- var material = new THREE.MeshPhongMaterial( { map: mapColor, bumpMap: mapHeight, bumpScale: 2.5 } );
|
|
|
|
-
|
|
|
|
- var object = new THREE.Mesh( geometry, material );
|
|
|
|
-
|
|
|
|
- // box
|
|
|
|
|
|
+ var object = new THREE.Object3D();
|
|
|
|
|
|
var mapHeight2 = THREE.ImageUtils.loadTexture( "obj/lightmap/rocks.jpg" );
|
|
var mapHeight2 = THREE.ImageUtils.loadTexture( "obj/lightmap/rocks.jpg" );
|
|
mapHeight2.repeat.set( 3, 1.5 );
|
|
mapHeight2.repeat.set( 3, 1.5 );
|
|
@@ -728,13 +695,15 @@
|
|
mapHeight3.format = THREE.RGBFormat;
|
|
mapHeight3.format = THREE.RGBFormat;
|
|
|
|
|
|
var geoPlane = new THREE.PlaneGeometry( 40, 20 );
|
|
var geoPlane = new THREE.PlaneGeometry( 40, 20 );
|
|
- var matPlane = new THREE.MeshPhongMaterial( { color: 0xffffff, bumpMap: mapHeight2, bumpScale: 0.5 } );
|
|
|
|
- var matPlane2 = new THREE.MeshPhongMaterial( { color: 0x331919, bumpMap: mapHeight2, bumpScale: 1 } );
|
|
|
|
- var matPlane3 = new THREE.MeshPhongMaterial( { color: 0xffffff, bumpMap: mapHeight3, bumpScale: 1 } );
|
|
|
|
|
|
+
|
|
|
|
+ var matPlane = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess: 50, bumpMap: mapHeight2, bumpScale: 0.5 } );
|
|
|
|
+ var matPlane2 = new THREE.MeshPhongMaterial( { color: 0x331919, specular: 0x111111, shininess: 50, bumpMap: mapHeight2, bumpScale: 1 } );
|
|
|
|
+ var matPlane3 = new THREE.MeshPhongMaterial( { color: 0x00aaff, specular: 0xffffff, shininess: 200, bumpMap: mapHeight3, bumpScale: 1.2 } );
|
|
|
|
+ var matPlane4 = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess: 50, bumpMap: mapHeight3, bumpScale: 1 } );
|
|
|
|
|
|
// bottom
|
|
// bottom
|
|
|
|
|
|
- var mesh = new THREE.Mesh( geoPlane, matPlane2 );
|
|
|
|
|
|
+ var mesh = new THREE.Mesh( geoPlane, matPlane3 );
|
|
mesh.position.z = -2;
|
|
mesh.position.z = -2;
|
|
mesh.position.y = -6;
|
|
mesh.position.y = -6;
|
|
mesh.rotation.x = -Math.PI/2;
|
|
mesh.rotation.x = -Math.PI/2;
|
|
@@ -742,7 +711,7 @@
|
|
|
|
|
|
// top
|
|
// top
|
|
|
|
|
|
- var mesh = new THREE.Mesh( geoPlane, matPlane3 );
|
|
|
|
|
|
+ var mesh = new THREE.Mesh( geoPlane, matPlane4 );
|
|
mesh.position.z = -2;
|
|
mesh.position.z = -2;
|
|
mesh.position.y = 6;
|
|
mesh.position.y = 6;
|
|
mesh.rotation.x = Math.PI/2;
|
|
mesh.rotation.x = Math.PI/2;
|
|
@@ -773,11 +742,64 @@
|
|
mesh.rotation.y = Math.PI/2;
|
|
mesh.rotation.y = Math.PI/2;
|
|
//object.add( mesh );
|
|
//object.add( mesh );
|
|
|
|
|
|
- initScene( object, 0, 8 );
|
|
|
|
|
|
+ return object;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // -----------------------------
|
|
|
|
+ // entry point
|
|
|
|
+ // -----------------------------
|
|
|
|
+
|
|
|
|
+ bootstrap();
|
|
|
|
+ initMaterials();
|
|
|
|
+ initLights();
|
|
|
|
+ createRenderTargets();
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ var loader = new THREE.UTF8Loader();
|
|
|
|
+
|
|
|
|
+ loader.load( "models/utf8/ben_dds.js", function ( object ) {
|
|
|
|
+
|
|
|
|
+ initScene( object, -75, 150 );
|
|
|
|
+ animate();
|
|
|
|
+
|
|
|
|
+ }, { normalizeRGB: true } );
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ loader.load( "models/utf8/WaltHi.js", function ( object ) {
|
|
|
|
+
|
|
|
|
+ initScene( object, -35, 1 );
|
|
animate();
|
|
animate();
|
|
|
|
|
|
|
|
+ }, { normalizeRGB: true } );
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ var loader = new THREE.JSONLoader();
|
|
|
|
+ loader.load( "obj/leeperrysmith/LeePerrySmith.js", function( geometry, materials ) {
|
|
|
|
+
|
|
|
|
+ var mapColor = THREE.ImageUtils.loadTexture( "obj/leeperrysmith/Map-COL.jpg" );
|
|
|
|
+ var mapHeight = THREE.ImageUtils.loadTexture( "obj/leeperrysmith/Infinite-Level_02_Disp_NoSmoothUV-4096.jpg" );
|
|
|
|
+ mapHeight.repeat.set( 0.998, 0.998 );
|
|
|
|
+ mapHeight.offset.set( 0.001, 0.001 )
|
|
|
|
+ mapHeight.wrapS = mapHeight.wrapT = THREE.RepeatWrapping;
|
|
|
|
+ mapHeight.anisotropy = 4;
|
|
|
|
+ mapHeight.format = THREE.RGBFormat;
|
|
|
|
+
|
|
|
|
+ var material = new THREE.MeshPhongMaterial( { map: mapColor, bumpMap: mapHeight, bumpScale: 2.5, shininess: 75, specular: 0x090909 } );
|
|
|
|
+
|
|
|
|
+ var object = new THREE.Mesh( geometry, material );
|
|
|
|
+ initScene( object, 0, 8 );
|
|
|
|
+
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
+ // create box
|
|
|
|
+
|
|
|
|
+ var object = generateBox();
|
|
|
|
+ initScene( object, 0, 8 );
|
|
|
|
+
|
|
|
|
+ animate();
|
|
|
|
+
|
|
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
|
|
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
|
|
|
|
|
|
</script>
|
|
</script>
|