Browse Source

Fixed a shader error due to refactoring a light attenuation function and also cleaned up formatting (spaces to tabs) and deprecation warnings.

michael 9 years ago
parent
commit
969268b3c5
1 changed files with 15 additions and 15 deletions
  1. 15 15
      examples/webgl_particles_general.html

+ 15 - 15
examples/webgl_particles_general.html

@@ -1,9 +1,9 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
 <head>
 <head>
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 
 
-    <script src="../build/three.js"></script>
+	<script src="../build/three.js"></script>
 	<script src="js/Detector.js"></script>
 	<script src="js/Detector.js"></script>
 	<script src="js/libs/stats.min.js"></script>
 	<script src="js/libs/stats.min.js"></script>
 	<script src="js/controls/OrbitControls.js"></script>
 	<script src="js/controls/OrbitControls.js"></script>
@@ -11,7 +11,7 @@
 	<script src='js/libs/dat.gui.min.js'></script>
 	<script src='js/libs/dat.gui.min.js'></script>
 	<script src="js/libs/photons.min.js"></script>
 	<script src="js/libs/photons.min.js"></script>
 
 
-    <style>
+	<style>
 		body {
 		body {
 			font-family: Monospace;
 			font-family: Monospace;
 			background-color: #000;
 			background-color: #000;
@@ -29,7 +29,7 @@
 		}
 		}
 		#info a { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer }
 		#info a { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer }
 	</style>
 	</style>
-    <title>Three.js Particle System</title>
+	<title>Three.js Particle System</title>
 </head>
 </head>
 <body>
 <body>
 
 
@@ -113,7 +113,7 @@
 
 
 		smokeType = ParticleSystemIDs.Smoke1;
 		smokeType = ParticleSystemIDs.Smoke1;
 
 
-    var textureLoader = new THREE.TextureLoader();
+		var textureLoader = new THREE.TextureLoader();
 
 
 		var smoke1Atlas = new PHOTONS.Atlas( textureLoader.load( 'textures/campfire/smokeparticle.png' ), true );
 		var smoke1Atlas = new PHOTONS.Atlas( textureLoader.load( 'textures/campfire/smokeparticle.png' ), true );
 		var smoke2Atlas = PHOTONS.Atlas.createGridAtlas( textureLoader.load( 'textures/campfire/smokeparticles.png' ), 0.0, 1.0, 1.0, 0.0, 4.0, 4.0, false, true );
 		var smoke2Atlas = PHOTONS.Atlas.createGridAtlas( textureLoader.load( 'textures/campfire/smokeparticles.png' ), 0.0, 1.0, 1.0, 0.0, 4.0, 4.0, false, true );
@@ -161,7 +161,7 @@
 						"vec3 lightPosition = pointLights[ i ].position;",
 						"vec3 lightPosition = pointLights[ i ].position;",
 						"vec3 lVector = lightPosition + viewPosition.xyz;",
 						"vec3 lVector = lightPosition + viewPosition.xyz;",
 						"vec3 lightDir = normalize( lVector );",
 						"vec3 lightDir = normalize( lVector );",
-						"float attenuation = calcLightAttenuation( length( lVector ), pointLights[ i ].distance, pointLights[ i ].decay );",
+						"float attenuation = punctualLightIntensityToIrradianceFactor( length( lVector ), pointLights[ i ].distance, pointLights[ i ].decay );",
 						"totalDiffuseLight += lightColor * attenuation;",
 						"totalDiffuseLight += lightColor * attenuation;",
 					"}",
 					"}",
 				"#endif",
 				"#endif",
@@ -489,7 +489,7 @@
 
 
 		window.addEventListener( 'resize', onWindowResize, false );
 		window.addEventListener( 'resize', onWindowResize, false );
 
 
-	    }
+	}
 
 
 	function initRenderer() {
 	function initRenderer() {
 
 
@@ -511,11 +511,11 @@
 		pointLight = new THREE.PointLight( 0xffffff, 2, 1000, 1 );
 		pointLight = new THREE.PointLight( 0xffffff, 2, 1000, 1 );
 		pointLight.position.set( 0, 40, 0 );
 		pointLight.position.set( 0, 40, 0 );
 		pointLight.castShadow = true;
 		pointLight.castShadow = true;
-		pointLight.shadowCameraNear = 1;
-		pointLight.shadowCameraFar = 1000;
-		pointLight.shadowMapWidth = 4096;
-		pointLight.shadowMapHeight = 2048;
-		pointLight.shadowBias = - 0.5;
+		pointLight.shadow.camera.near = 1;
+		pointLight.shadow.camera.far = 1000;
+		pointLight.shadow.mapSize.width = 4096;
+		pointLight.shadow.mapSize.height = 2048;
+		pointLight.shadow.bias = - 0.5;
 		scene.add( pointLight );
 		scene.add( pointLight );
 
 
 	}
 	}
@@ -715,7 +715,7 @@
 		controls.target.set( 0, 0, 0 );
 		controls.target.set( 0, 0, 0 );
 		controls.update();
 		controls.update();
 
 
-	    }
+	}
 
 
 	function onWindowResize() {
 	function onWindowResize() {
 
 
@@ -860,8 +860,8 @@
 
 
 	function animate() {
 	function animate() {
 
 
-		    requestAnimationFrame( animate );
-		    update();
+		requestAnimationFrame( animate );
+		update();
 		render();
 		render();
 
 
 	}
 	}