|
@@ -105,6 +105,8 @@
|
|
var windowHalfX = window.innerWidth / 2;
|
|
var windowHalfX = window.innerWidth / 2;
|
|
var windowHalfY = window.innerHeight / 2;
|
|
var windowHalfY = window.innerHeight / 2;
|
|
|
|
|
|
|
|
+ var r = 0.0;
|
|
|
|
+
|
|
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
|
|
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
|
|
|
|
|
|
init();
|
|
init();
|
|
@@ -122,55 +124,65 @@
|
|
|
|
|
|
// LIGHTS
|
|
// LIGHTS
|
|
|
|
|
|
- ambientLight = new THREE.AmbientLight( 0x444444 );
|
|
|
|
|
|
+ ambientLight = new THREE.AmbientLight( 0x050505 );
|
|
scene.addLight( ambientLight );
|
|
scene.addLight( ambientLight );
|
|
|
|
|
|
- pointLight = new THREE.PointLight( 0xffffff );
|
|
|
|
- pointLight.position.z = 600;
|
|
|
|
-
|
|
|
|
|
|
+ pointLight = new THREE.PointLight( 0x999999 );
|
|
|
|
+ pointLight.position.z = 10000;
|
|
scene.addLight( pointLight );
|
|
scene.addLight( pointLight );
|
|
|
|
|
|
- directionalLight = new THREE.DirectionalLight( 0xffffff );
|
|
|
|
- directionalLight.position.x = 1;
|
|
|
|
- directionalLight.position.y = 1;
|
|
|
|
- directionalLight.position.z = - 1;
|
|
|
|
|
|
+ directionalLight = new THREE.DirectionalLight( 0xbbbbbb );
|
|
|
|
+ directionalLight.position.x = 0;
|
|
|
|
+ directionalLight.position.y = 0;
|
|
|
|
+ directionalLight.position.z = 1;
|
|
directionalLight.position.normalize();
|
|
directionalLight.position.normalize();
|
|
scene.addLight( directionalLight );
|
|
scene.addLight( directionalLight );
|
|
|
|
|
|
- // material parameters
|
|
|
|
|
|
+ // light representation
|
|
|
|
|
|
- var ambient = 0x444444, diffuse = 0x555555, specular = 0x181820, shininess = 2;
|
|
|
|
|
|
+ var sphere = new Sphere( 100, 16, 8 );
|
|
|
|
+ lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color:0xffaa00 } ) );
|
|
|
|
+ lightMesh.position = pointLight.position;
|
|
|
|
+ lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05;
|
|
|
|
+ scene.addObject(lightMesh);
|
|
|
|
+
|
|
|
|
+ // material parameters
|
|
|
|
+
|
|
|
|
+ var ambient = 0x020202, diffuse = 0x666666, specular = 0x444444, shininess = 2;
|
|
|
|
|
|
var fragment_shader = ShaderUtils.lib[ "normal" ].fragment_shader;
|
|
var fragment_shader = ShaderUtils.lib[ "normal" ].fragment_shader;
|
|
var vertex_shader = ShaderUtils.lib[ "normal" ].vertex_shader;
|
|
var vertex_shader = ShaderUtils.lib[ "normal" ].vertex_shader;
|
|
var uniforms = ShaderUtils.lib[ "normal" ].uniforms;
|
|
var uniforms = ShaderUtils.lib[ "normal" ].uniforms;
|
|
|
|
|
|
uniforms[ "tNormal" ].texture = ImageUtils.loadTexture( "obj/leeperrysmith/Infinite-Level_02_Tangent_SmoothUV.jpg" );
|
|
uniforms[ "tNormal" ].texture = ImageUtils.loadTexture( "obj/leeperrysmith/Infinite-Level_02_Tangent_SmoothUV.jpg" );
|
|
- uniforms[ "uNormalScale" ].value = - 0.75;
|
|
|
|
-
|
|
|
|
uniforms[ "tDiffuse" ].texture = ImageUtils.loadTexture( "obj/leeperrysmith/Map-COL.jpg" );
|
|
uniforms[ "tDiffuse" ].texture = ImageUtils.loadTexture( "obj/leeperrysmith/Map-COL.jpg" );
|
|
-
|
|
|
|
|
|
+
|
|
uniforms[ "enableAO" ].value = false;
|
|
uniforms[ "enableAO" ].value = false;
|
|
uniforms[ "enableDiffuse" ].value = true;
|
|
uniforms[ "enableDiffuse" ].value = true;
|
|
-
|
|
|
|
|
|
+
|
|
uniforms[ "uPointLightPos" ].value = pointLight.position;
|
|
uniforms[ "uPointLightPos" ].value = pointLight.position;
|
|
uniforms[ "uPointLightColor" ].value = pointLight.color;
|
|
uniforms[ "uPointLightColor" ].value = pointLight.color;
|
|
|
|
|
|
uniforms[ "uDirLightPos" ].value = directionalLight.position;
|
|
uniforms[ "uDirLightPos" ].value = directionalLight.position;
|
|
uniforms[ "uDirLightColor" ].value = directionalLight.color;
|
|
uniforms[ "uDirLightColor" ].value = directionalLight.color;
|
|
-
|
|
|
|
|
|
+
|
|
uniforms[ "uAmbientLightColor" ].value = ambientLight.color;
|
|
uniforms[ "uAmbientLightColor" ].value = ambientLight.color;
|
|
-
|
|
|
|
|
|
+
|
|
uniforms[ "uDiffuseColor" ].value.setHex( diffuse );
|
|
uniforms[ "uDiffuseColor" ].value.setHex( diffuse );
|
|
uniforms[ "uSpecularColor" ].value.setHex( specular );
|
|
uniforms[ "uSpecularColor" ].value.setHex( specular );
|
|
uniforms[ "uAmbientColor" ].value.setHex( ambient );
|
|
uniforms[ "uAmbientColor" ].value.setHex( ambient );
|
|
-
|
|
|
|
|
|
+
|
|
uniforms[ "uShininess" ].value = shininess;
|
|
uniforms[ "uShininess" ].value = shininess;
|
|
|
|
|
|
|
|
+
|
|
var material = new THREE.MeshShaderMaterial( { fragment_shader: fragment_shader,
|
|
var material = new THREE.MeshShaderMaterial( { fragment_shader: fragment_shader,
|
|
- vertex_shader: vertex_shader,
|
|
|
|
- uniforms: uniforms
|
|
|
|
- } );
|
|
|
|
|
|
+ vertex_shader: vertex_shader,
|
|
|
|
+ uniforms: uniforms
|
|
|
|
+ } );
|
|
|
|
+
|
|
|
|
+ //var material = new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( "obj/leeperrysmith/Map-COL.jpg" ) } );
|
|
|
|
+
|
|
|
|
+ //var material = new THREE.MeshPhongMaterial( { color: diffuse, specular: specular, ambient: ambient, shininess: shininess, map: ImageUtils.loadTexture( "obj/leeperrysmith/Map-COL.jpg" ) } );
|
|
|
|
|
|
loader = new THREE.Loader( true );
|
|
loader = new THREE.Loader( true );
|
|
document.body.appendChild( loader.statusDomElement );
|
|
document.body.appendChild( loader.statusDomElement );
|
|
@@ -221,6 +233,11 @@
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ lightMesh.position.x = 500 * Math.cos( r );
|
|
|
|
+ lightMesh.position.z = 500 * Math.sin( r );
|
|
|
|
+
|
|
|
|
+ r += 0.01;
|
|
|
|
+
|
|
webglRenderer.render( scene, camera );
|
|
webglRenderer.render( scene, camera );
|
|
|
|
|
|
if ( statsEnabled ) stats.update();
|
|
if ( statsEnabled ) stats.update();
|