|
@@ -28,7 +28,6 @@
|
|
|
<div id="container"></div>
|
|
|
<div id="info"><a href="http://threejs.org" target="_blank">three.js</a> - Phong Material Variantions by <a href="http://clara.io/" target="_blank">Ben Houston</a>.</div>
|
|
|
|
|
|
-
|
|
|
<script src="../build/three.js"></script>
|
|
|
<script src="js/controls/OrbitControls.js"></script>
|
|
|
|
|
@@ -41,7 +40,7 @@
|
|
|
|
|
|
var container, stats;
|
|
|
|
|
|
- var camera, scene, renderer, controls, objects = [];
|
|
|
+ var camera, scene, renderer, controls;
|
|
|
var particleLight;
|
|
|
|
|
|
var loader = new THREE.FontLoader();
|
|
@@ -88,31 +87,30 @@
|
|
|
|
|
|
var geometry = new THREE.SphereBufferGeometry( sphereRadius, 32, 16 );
|
|
|
|
|
|
-
|
|
|
- var localReflectionCube;
|
|
|
-
|
|
|
- for( var alpha = 0, alphaIndex = 0; alpha <= 1.0; alpha += stepSize, alphaIndex ++ ) {
|
|
|
-
|
|
|
- if( alphaIndex % 2 === 0 ) {
|
|
|
- localReflectionCube = null;
|
|
|
- }
|
|
|
- else {
|
|
|
- localReflectionCube = reflectionCube;
|
|
|
- }
|
|
|
+ for ( var alpha = 0, alphaIndex = 0; alpha <= 1.0; alpha += stepSize, alphaIndex ++ ) {
|
|
|
|
|
|
var specularShininess = Math.pow( 2, alpha * 10 );
|
|
|
|
|
|
- for( var beta = 0; beta <= 1.0; beta += stepSize ) {
|
|
|
+ for ( var beta = 0; beta <= 1.0; beta += stepSize ) {
|
|
|
|
|
|
var specularColor = new THREE.Color( beta * 0.2, beta * 0.2, beta * 0.2 );
|
|
|
- var reflectivity = beta;
|
|
|
|
|
|
- for( var gamma = 0; gamma <= 1.0; gamma += stepSize ) {
|
|
|
+ for ( var gamma = 0; gamma <= 1.0; gamma += stepSize ) {
|
|
|
|
|
|
// basic monochromatic energy preservation
|
|
|
- var diffuseColor = new THREE.Color( 0, 0, gamma ).multiplyScalar( 1 - beta * 0.2 );
|
|
|
-
|
|
|
- var material = new THREE.MeshPhongMaterial( { map: imgTexture, bumpMap: imgTexture, bumpScale: bumpScale, color: diffuseColor, specular: specularColor, reflectivity: reflectivity, shininess: specularShininess, shading: THREE.SmoothShading, envMap: localReflectionCube } )
|
|
|
+ var diffuseColor = new THREE.Color().setHSL( alpha, 0.5, gamma * 0.5 ).multiplyScalar( 1 - beta * 0.2 );
|
|
|
+
|
|
|
+ var material = new THREE.MeshPhongMaterial( {
|
|
|
+ map: imgTexture,
|
|
|
+ bumpMap: imgTexture,
|
|
|
+ bumpScale: bumpScale,
|
|
|
+ color: diffuseColor,
|
|
|
+ specular: specularColor,
|
|
|
+ reflectivity: beta,
|
|
|
+ shininess: specularShininess,
|
|
|
+ shading: THREE.SmoothShading,
|
|
|
+ envMap: alphaIndex % 2 === 0 ? null : reflectionCube
|
|
|
+ } );
|
|
|
|
|
|
var mesh = new THREE.Mesh( geometry, material );
|
|
|
|
|
@@ -120,15 +118,16 @@
|
|
|
mesh.position.y = beta * 400 - 200;
|
|
|
mesh.position.z = gamma * 400 - 200;
|
|
|
|
|
|
- objects.push( mesh );
|
|
|
-
|
|
|
scene.add( mesh );
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
function addLabel( name, location ) {
|
|
|
+
|
|
|
var textGeo = new THREE.TextGeometry( name, {
|
|
|
|
|
|
font: font,
|
|
@@ -143,6 +142,7 @@
|
|
|
var textMesh = new THREE.Mesh( textGeo, textMaterial );
|
|
|
textMesh.position.copy( location );
|
|
|
scene.add( textMesh );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
addLabel( "-shininess", new THREE.Vector3( -350, 0, 0 ) );
|
|
@@ -221,14 +221,6 @@
|
|
|
|
|
|
camera.lookAt( scene.position );
|
|
|
|
|
|
- for ( var i = 0, l = objects.length; i < l; i ++ ) {
|
|
|
-
|
|
|
- var object = objects[ i ];
|
|
|
-
|
|
|
- object.rotation.y += 0.005;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
particleLight.position.x = Math.sin( timer * 7 ) * 300;
|
|
|
particleLight.position.y = Math.cos( timer * 5 ) * 400;
|
|
|
particleLight.position.z = Math.cos( timer * 3 ) * 300;
|