diff --git a/example/Tracer/dart/app.dart b/example/Tracer/dart/app.dart
new file mode 100644
index 0000000..f07f077
--- /dev/null
+++ b/example/Tracer/dart/app.dart
@@ -0,0 +1,29 @@
+library ray_trace;
+
+import 'dart:html';
+import 'dart:math';
+
+part 'color.dart';
+part 'engine.dart';
+part 'materials.dart';
+part 'scene.dart';
+part 'shapes.dart';
+part 'vector.dart';
+part 'renderscene.dart';
+
+// used to check if raytrace was correct (used by benchmarks)
+var checkNumber;
+
+main() {
+ var button = query('#render');
+ var canvas = query('#canvas');
+ var time = query('#time');
+ button.onClick.listen((e) {
+ canvas.width = int.parse(query('#imageWidth').value);
+ canvas.height = int.parse(query('#imageHeight').value);
+ var sw = new Stopwatch()..start();
+ renderScene(e);
+ sw.stop();
+ time.text = sw.elapsedMilliseconds.toString();
+ });
+}
\ No newline at end of file
diff --git a/example/Tracer/dart/index.html b/example/Tracer/dart/index.html
new file mode 100644
index 0000000..65568d2
--- /dev/null
+++ b/example/Tracer/dart/index.html
@@ -0,0 +1,40 @@
+
+
+
+
+ index
+
+
+
+
+
+
+ Width:
+
+
+ Height:
+
+
+ Pixel Size:
+
+
+ Diffuse:
+
+
+ Shadows:
+
+
+ Highlights:
+
+
+ Reflections:
+
+
+
+ Time (ms):
+
+
+
+
+
+
diff --git a/example/Tracer/dart/renderscene.dart b/example/Tracer/dart/renderscene.dart
index 12eb3dc..49324aa 100644
--- a/example/Tracer/dart/renderscene.dart
+++ b/example/Tracer/dart/renderscene.dart
@@ -109,6 +109,7 @@ void renderScene(event) {
renderDiffuse: renderDiffuse,
renderShadows: renderShadows,
renderReflections: renderReflections,
+ renderHighlights: renderHighlights,
rayDepth: rayDepth
);
diff --git a/example/Tracer/js/Tracer.js b/example/Tracer/js/Tracer.js
index 699c109..5800e28 100644
--- a/example/Tracer/js/Tracer.js
+++ b/example/Tracer/js/Tracer.js
@@ -558,7 +558,7 @@ Flog.RayTracer.Engine.prototype = {
this.setPixel(x, y, color);
}
}
- if (checkNumber !== 2321) {
+ if (canvas == null && checkNumber !== 2321) {
throw new Error("Scene rendered incorrectly");
}
},
@@ -702,8 +702,8 @@ Flog.RayTracer.Engine.prototype = {
}
};
-
-function renderScene(){
+// 'event' null means that we are benchmarking
+function renderScene(event){
var scene = new Flog.RayTracer.Scene();
scene.camera = new Flog.RayTracer.Camera(
@@ -771,22 +771,39 @@ function renderScene(){
scene.lights.push(light);
scene.lights.push(light1);
-
- var imageWidth = 100; // $F('imageWidth');
- var imageHeight = 100; // $F('imageHeight');
- var pixelSize = "5,5".split(','); // $F('pixelSize').split(',');
- var renderDiffuse = true; // $F('renderDiffuse');
- var renderShadows = true; // $F('renderShadows');
- var renderHighlights = true; // $F('renderHighlights');
- var renderReflections = true; // $F('renderReflections');
+
+ var imageWidth, imageHeight, pixelSize;
+ var renderDiffuse, renderShadows, renderHighlights, renderReflections;
+ var canvas;
+
+ if (typeof(event) == 'undefined' || event == null) {
+ imageWidth = 100;
+ imageHeight = 100;
+ pixelSize = "5,5".split(',');
+ renderDiffuse = true;
+ renderShadows = true;
+ renderHighlights = true;
+ renderReflections = true;
+ canvas = null;
+ } else {
+ imageWidth = parseInt(document.getElementById('imageWidth').value);
+ imageHeight = parseInt(document.getElementById('imageHeight').value);
+ pixelSize = document.getElementById('pixelSize').value.split(',');
+ renderDiffuse = document.getElementById('renderDiffuse').checked;
+ renderShadows = document.getElementById('renderShadows').checked;
+ renderHighlights = document.getElementById('renderHighlights').checked;
+ renderReflections = document.getElementById('renderReflections').checked;
+ canvas = document.getElementById("canvas");
+ }
+
var rayDepth = 2;//$F('rayDepth');
var raytracer = new Flog.RayTracer.Engine(
{
canvasWidth: imageWidth,
canvasHeight: imageHeight,
- pixelWidth: pixelSize[0],
- pixelHeight: pixelSize[1],
+ pixelWidth: parseInt(pixelSize[0]),
+ pixelHeight: parseInt(pixelSize[1]),
"renderDiffuse": renderDiffuse,
"renderHighlights": renderHighlights,
"renderShadows": renderShadows,
@@ -795,7 +812,5 @@ function renderScene(){
}
);
- raytracer.renderScene(scene, null, 0);
+ raytracer.renderScene(scene, canvas, 0);
}
-
-Benchmark.report("Tracer", renderScene, renderScene);
diff --git a/example/Tracer/js/app.js b/example/Tracer/js/app.js
new file mode 100644
index 0000000..ccead77
--- /dev/null
+++ b/example/Tracer/js/app.js
@@ -0,0 +1,12 @@
+ var button = document.getElementById('render');
+ var canvas = document.getElementById('canvas');
+ var time = document.getElementById('time');
+
+ button.addEventListener('click', function (e) {
+ canvas.width = parseInt(document.getElementById('imageWidth').value);
+ canvas.height = parseInt(document.getElementById('imageHeight').value);
+ var start = new Date();
+ renderScene(e);
+ var stop = new Date();
+ time.innerHTML = (stop - start).toString();
+ });
\ No newline at end of file
diff --git a/example/Tracer/js/benchmark_tracer.js b/example/Tracer/js/benchmark_tracer.js
new file mode 100644
index 0000000..3aac5b5
--- /dev/null
+++ b/example/Tracer/js/benchmark_tracer.js
@@ -0,0 +1 @@
+Benchmark.report("Tracer", renderScene, renderScene);
\ No newline at end of file
diff --git a/example/Tracer/js/index.html b/example/Tracer/js/index.html
new file mode 100644
index 0000000..6981f68
--- /dev/null
+++ b/example/Tracer/js/index.html
@@ -0,0 +1,39 @@
+
+
+
+
+ index
+
+
+
+
+
+
+ Width:
+
+
+ Height:
+
+
+ Pixel Size:
+
+
+ Diffuse:
+
+
+ Shadows:
+
+
+ Highlights:
+
+
+ Reflections:
+
+
+
+ Time (ms):
+
+
+
+
+
diff --git a/example/Tracer/js/run.sh b/example/Tracer/js/run.sh
index 1cb2c58..567a3c5 100755
--- a/example/Tracer/js/run.sh
+++ b/example/Tracer/js/run.sh
@@ -3,4 +3,4 @@
# d8 is a tool included with V8:
# https://code.google.com/p/v8/
-d8 bench.js Tracer.js
+d8 bench.js Tracer.js benchmark_tracer.js
diff --git a/pubspec.yaml b/pubspec.yaml
index ae2534a..0071458 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,7 @@
name: benchmark_harness
version: 1.0.2
-description: The official Dart project benchmark harness.
author: Dart Project
+description: The official Dart project benchmark harness.
homepage: http://www.dartlang.org
+dependencies:
+ browser: any