diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-02-12 20:23:41 -0800 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-02-12 20:23:41 -0800 |
| commit | 32785e06cd47fc6c5c64c7e9c077769a462ae5ea (patch) | |
| tree | 9fcd27d4b702f248639f58aec151b2f61946c006 | |
| parent | 57ad852b6e7e337b7a86d2f85ac95b480898b057 (diff) | |
moving over...adding cgi
| -rw-r--r-- | img/generating_background.gif | bin | 393647 -> 389693 bytes | |||
| -rw-r--r-- | index.html | 13 | ||||
| -rw-r--r-- | js/3D_Landscape.js | 60 | ||||
| -rw-r--r-- | js/generating.js | 8 | ||||
| -rw-r--r-- | js/pb.js | 2 | ||||
| -rw-r--r-- | js/username.js | 30 |
6 files changed, 81 insertions, 32 deletions
diff --git a/img/generating_background.gif b/img/generating_background.gif Binary files differindex 99c5b99..b228123 100644 --- a/img/generating_background.gif +++ b/img/generating_background.gif @@ -45,6 +45,7 @@ body { </style> </head> <body> + <script src="js/generating.js"></script> <script src="js/jquery.min.js"></script> <script src="js/Three.js"></script> <script src="js/Detector.js"></script> @@ -52,6 +53,7 @@ body { <script src="js/3D_Landscape.js"></script> <script src="js/shortcuts.js"></script> <script src="js/pb.js"></script> + <script src="js/username.js"></script> <table border="0" cellpadding="10"> <tr> <td> @@ -73,18 +75,15 @@ body { <table id="form_table" border="0"> <tr> <td>Texture URL:</td> - <td colspan="2"><input type="text" id="texture" size="35" value="http://someurl.jpg" /></td> + <td colspan="2"><input type="text" id="texture" size="35" value="http://someurl.biz/someimage.jpg" /></td> </tr> <tr> <td>Heightmap URL:</td> - <td colspan="2"><input type="text" id="heightmap" size="35" - value="http://someurl.jpg" /><br /></td> + <td colspan="2"><input type="text" id="heightmap" size="35" value="http://someurl.biz/someimage.jpg" /><br /></td> </tr> <tr> - <td><input type="button" value="Load New" id="change" - onClick="loadNew()" /></td> - <td><input type="button" value="Save as Image" id="save" - onClick="saveScene()" /></td> + <td><input type="button" value="Save as Image" id="save" onClick="saveScene()" /></td> + <td><input type="button" value="Load New" id="change" onClick="loadNew()" /></td> </tr> </table> </form> diff --git a/js/3D_Landscape.js b/js/3D_Landscape.js index ca71ea6..1619de5 100644 --- a/js/3D_Landscape.js +++ b/js/3D_Landscape.js @@ -42,6 +42,11 @@ function initGraphics(textureFile, heightmapFile, cb) { var img = new Image();
img.src = heightmapFile;
+ img.onerror = function() {
+ alert("The following url did not work: "+heightmapFile.slice(14));
+ is_generating = false;
+ toggle_background();
+ };
img.onload = function(){
context.drawImage(img, 0, 0);
@@ -99,6 +104,35 @@ function initGraphics(textureFile, heightmapFile, cb) { rot_x = mesh.rotation.x;
rot_y = mesh.rotation.y;
rot_z = mesh.rotation.z;
+ is_generating = false;
+ toggle_background();
+ cb();
+ };
+}
+
+var requestId;
+function loop() {
+ render();
+ requestId = window.requestAnimationFrame(loop);
+}
+function animate() {
+ if (!requestId) {
+ loop();
+ }
+}
+function stop_animating() {
+ if (requestId) {
+ window.cancelAnimationFrame(requestId);
+ requestId = undefined;
+ }
+}
+
+
+function render() {
+ renderer.render(scene, camera);
+}
+
+function init_controls(){
//{{{init controls
//Controls
@@ -169,32 +203,8 @@ function initGraphics(textureFile, heightmapFile, cb) { });
//}}}
- cb();
- };
-}
-
-var requestId;
-function loop() {
- render();
- requestId = window.requestAnimationFrame(loop);
-}
-function animate() {
- if (!requestId) {
- loop();
- }
-}
-function stop_animating() {
- if (requestId) {
- window.cancelAnimationFrame(requestId);
- requestId = undefined;
- }
}
-
-
-function render() {
- renderer.render(scene, camera);
-}
-
window.onload= function(e){
runWebGLSimulation();
+ init_controls();
}
diff --git a/js/generating.js b/js/generating.js new file mode 100644 index 0000000..1b1cf03 --- /dev/null +++ b/js/generating.js @@ -0,0 +1,8 @@ +var is_generating = false; +function toggle_background(){ + if (is_generating){ + $('body').css("background", "url(img/generating_background.gif)"); + }else{ + $('body').css("background", "whitesmoke"); + } +} @@ -53,6 +53,8 @@ function loadNew() { textureURL = document.getElementById("texture").value.replace(/\s/,""); heightmapURL = document.getElementById("heightmap").value.replace(/\s/,""); + is_generating = true; + toggle_background(); console.log(textureURL); console.log(heightmapURL); stop_animating(); diff --git a/js/username.js b/js/username.js new file mode 100644 index 0000000..1222127 --- /dev/null +++ b/js/username.js @@ -0,0 +1,30 @@ +$(document).ready(function(){ + var name = get_name_from_cookie() + $("#username").val(name) +}); + +function get_name_from_cookie() + { + if (document.cookie) + { + var cookies = document.cookie.split(";") + for (i in cookies) + { + var cookie = cookies[i].split("=") + if (cookie[0].indexOf("imname") !== -1) + { + if (cookie[1] !== 'false' && cookie[1] !== 'undefined' && cookie[1].length) + { + return cookie[1] + } + } + } + } + return "" +}; + +function update_username(data){ + if (data.username.length > 0){ + document.cookie = "imname="+data.username+";path=/;domain=.asdf.us;max-age=1086400" + } +} |
