| OLD | NEW |
| 1 // The ray tracer code in this file is written by Adam Burmister. It | 1 // The ray tracer code in this file is written by Adam Burmister. It |
| 2 // is available in its original form from: | 2 // is available in its original form from: |
| 3 // | 3 // |
| 4 // http://labs.flog.nz.co/raytracer/ | 4 // http://labs.flog.nz.co/raytracer/ |
| 5 // | 5 // |
| 6 // It has been modified slightly by Google to work as a standalone | 6 // It has been modified slightly by Google to work as a standalone |
| 7 // benchmark, but the all the computational code remains | 7 // benchmark, but the all the computational code remains |
| 8 // untouched. This file also contains a copy of parts of the Prototype | 8 // untouched. This file also contains a copy of parts of the Prototype |
| 9 // JavaScript framework which is used by the ray tracer. | 9 // JavaScript framework which is used by the ray tracer. |
| 10 | 10 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 position: null, | 198 position: null, |
| 199 color: null, | 199 color: null, |
| 200 intensity: 10.0, | 200 intensity: 10.0, |
| 201 | 201 |
| 202 initialize : function(pos, color, intensity) { | 202 initialize : function(pos, color, intensity) { |
| 203 this.position = pos; | 203 this.position = pos; |
| 204 this.color = color; | 204 this.color = color; |
| 205 this.intensity = (intensity ? intensity : 10.0); | 205 this.intensity = (intensity ? intensity : 10.0); |
| 206 }, | 206 }, |
| 207 | 207 |
| 208 getIntensity: function(distance){ | |
| 209 if(distance >= intensity) return 0; | |
| 210 | |
| 211 return Math.pow((intensity - distance) / strength, 0.2); | |
| 212 }, | |
| 213 | |
| 214 toString : function () { | 208 toString : function () { |
| 215 return 'Light [' + this.position.x + ',' + this.position.y + ',' + this.
position.z + ']'; | 209 return 'Light [' + this.position.x + ',' + this.position.y + ',' + this.
position.z + ']'; |
| 216 } | 210 } |
| 217 } | 211 } |
| 218 /* Fake a Flog.* namespace */ | 212 /* Fake a Flog.* namespace */ |
| 219 if(typeof(Flog) == 'undefined') var Flog = {}; | 213 if(typeof(Flog) == 'undefined') var Flog = {}; |
| 220 if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; | 214 if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; |
| 221 | 215 |
| 222 Flog.RayTracer.Vector = Class.create(); | 216 Flog.RayTracer.Vector = Class.create(); |
| 223 | 217 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 toString : function () { | 407 toString : function () { |
| 414 return 'ChessMaterial [gloss=' + this.gloss + ', transparency=' + th
is.transparency + ', hasTexture=' + this.hasTexture +']'; | 408 return 'ChessMaterial [gloss=' + this.gloss + ', transparency=' + th
is.transparency + ', hasTexture=' + this.hasTexture +']'; |
| 415 } | 409 } |
| 416 } | 410 } |
| 417 ); | 411 ); |
| 418 /* Fake a Flog.* namespace */ | 412 /* Fake a Flog.* namespace */ |
| 419 if(typeof(Flog) == 'undefined') var Flog = {}; | 413 if(typeof(Flog) == 'undefined') var Flog = {}; |
| 420 if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; | 414 if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; |
| 421 if(typeof(Flog.RayTracer.Shape) == 'undefined') Flog.RayTracer.Shape = {}; | 415 if(typeof(Flog.RayTracer.Shape) == 'undefined') Flog.RayTracer.Shape = {}; |
| 422 | 416 |
| 423 Flog.RayTracer.Shape.BaseShape = Class.create(); | |
| 424 | |
| 425 Flog.RayTracer.Shape.BaseShape.prototype = { | |
| 426 position: null, | |
| 427 material: null, | |
| 428 | |
| 429 initialize : function() { | |
| 430 this.position = new Vector(0,0,0); | |
| 431 this.material = new Flog.RayTracer.Material.SolidMaterial( | |
| 432 new Flog.RayTracer.Color(1,0,1), | |
| 433 0, | |
| 434 0, | |
| 435 0 | |
| 436 ); | |
| 437 }, | |
| 438 | |
| 439 toString : function () { | |
| 440 return 'Material [gloss=' + this.gloss + ', transparency=' + this.transp
arency + ', hasTexture=' + this.hasTexture +']'; | |
| 441 } | |
| 442 } | |
| 443 /* Fake a Flog.* namespace */ | |
| 444 if(typeof(Flog) == 'undefined') var Flog = {}; | |
| 445 if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; | |
| 446 if(typeof(Flog.RayTracer.Shape) == 'undefined') Flog.RayTracer.Shape = {}; | |
| 447 | |
| 448 Flog.RayTracer.Shape.Sphere = Class.create(); | 417 Flog.RayTracer.Shape.Sphere = Class.create(); |
| 449 | 418 |
| 450 Flog.RayTracer.Shape.Sphere.prototype = { | 419 Flog.RayTracer.Shape.Sphere.prototype = { |
| 451 initialize : function(pos, radius, material) { | 420 initialize : function(pos, radius, material) { |
| 452 this.radius = radius; | 421 this.radius = radius; |
| 453 this.position = pos; | 422 this.position = pos; |
| 454 this.material = material; | 423 this.material = material; |
| 455 }, | 424 }, |
| 456 | 425 |
| 457 intersect: function(ray){ | 426 intersect: function(ray){ |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 "renderDiffuse": renderDiffuse, | 895 "renderDiffuse": renderDiffuse, |
| 927 "renderHighlights": renderHighlights, | 896 "renderHighlights": renderHighlights, |
| 928 "renderShadows": renderShadows, | 897 "renderShadows": renderShadows, |
| 929 "renderReflections": renderReflections, | 898 "renderReflections": renderReflections, |
| 930 "rayDepth": rayDepth | 899 "rayDepth": rayDepth |
| 931 } | 900 } |
| 932 ); | 901 ); |
| 933 | 902 |
| 934 raytracer.renderScene(scene, null, 0); | 903 raytracer.renderScene(scene, null, 0); |
| 935 } | 904 } |
| OLD | NEW |