Skip to content

Commit

Permalink
Release 1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
shivanmodha committed Sep 2, 2017
1 parent efe8e9c commit 7e31ef7
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 90 deletions.
4 changes: 2 additions & 2 deletions release/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"main.css": "static/css/main.0a762989.css",
"main.css.map": "static/css/main.0a762989.css.map",
"main.js": "static/js/main.920eb94a.js",
"main.js.map": "static/js/main.920eb94a.js.map",
"main.js": "static/js/main.d382308c.js",
"main.js.map": "static/js/main.d382308c.js.map",
"static\\media\\logo.svg": "static/media/logo.5d5d9eef.svg"
}
53 changes: 48 additions & 5 deletions release/component/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ let cursor_default = new Image;
let cursor_move = new Image;
let c = 0;

let cinj = "";

let RenderedFloor = 1;

function Main()
{
graph = new Graph();
Expand All @@ -47,6 +51,8 @@ function Main()
window.addEventListener("_event_element_executeindexcode_", _event_modal_onElementExecuteIndex);
window.addEventListener("_event_modal_element_delete_", _event_modal_onElementDelete);
window.addEventListener("_event_modal_bindtonode_", _event_modal_onBindToNode);
window.addEventListener("_event_onInjectChange", _event_onInjectChange);
window.addEventListener("_event_onSignalFloorChange", _event_onSignalFloorChange);
RC2.addEventListener("mousedown", _event_onMouseDown);
RC2.addEventListener("touchstart", _event_onTouchDown);
RC2.addEventListener("mouseup", _event_onMouseUp);
Expand All @@ -67,9 +73,14 @@ function Main()
MainLoop();
UpdateURL();
}
function EnableCodeInjection()
{
window.dispatchEvent(new CustomEvent("_event_onSignalCodeInjection"), {});
return 0;
}
function UpdateURL()
{
let url = "?@" + round(ME.Camera.Location.X, 2) + "," + round(ME.Camera.Location.Y, 2) + "," + round(ME.Camera.Location.Z, 2) + "z" + ((RenderedFloor / 2) + 1);
let url = "?@" + round(ME.Camera.Location.X, 2) + "," + round(ME.Camera.Location.Y, 2) + "," + round(ME.Camera.Location.Z, 2) + "z" + RenderedFloor;
//url += "&graph=" + JSON.stringify(graph.ToJson());

window.dispatchEvent(new CustomEvent("_event_onURLChange", {
Expand Down Expand Up @@ -105,20 +116,20 @@ function ParseURL()
{
tmp_location = new Vertex(parseFloat(param[0]), parseFloat(param[1]), parseFloat(param[2].substring(0, param[2].indexOf("z"))));
tmp_rotation = new Vertex(0, 0, 0);
RenderedFloor = (parseInt(param[2].substring(param[2].indexOf("z") + 1)) - 1) * 2;
RenderedFloor = (parseInt(param[2].substring(param[2].indexOf("z") + 1)));
}
else
{
tmp_location = new Vertex(0, 0, 5);
tmp_rotation = new Vertex(0, 0, 0);
RenderedFloor = 0;
RenderedFloor = 1;
}
}
else
{
tmp_location = new Vertex(0, 0, 5);
tmp_rotation = new Vertex(0, 0, 0);
RenderedFloor = 0;
RenderedFloor = 1;
}
let url_search = new URL(url);
json = url_search.searchParams.get("graph");
Expand Down Expand Up @@ -307,6 +318,7 @@ function _event_onNavigationSelect(event)
else if (navigation === "_navigation_view_resetcamera")
{
ME.Camera.Location = new Vertex(0, 0, 5);
ME.Camera.Rotation = new Vertex(0, 0, 0);
UpdateURL();
}
else if (navigation === "_navigation_path_start")
Expand Down Expand Up @@ -368,14 +380,26 @@ function _event_onNavigationSelect(event)
{
console.log(window.location);
let url = window.location.origin;
url += "/bench/?@" + round(ME.Camera.Location.X, 2) + "," + round(ME.Camera.Location.Y, 2) + "," + round(ME.Camera.Location.Z, 2) + "z" + ((RenderedFloor / 2) + 1);
url += "/bench/?@" + round(ME.Camera.Location.X, 2) + "," + round(ME.Camera.Location.Y, 2) + "," + round(ME.Camera.Location.Z, 2) + "z" + RenderedFloor;
url += "&graph=" + JSON.stringify(graph.ToJson());
window.dispatchEvent(new CustomEvent("_event_onSignalURL", { detail: { url: url } }));
}
else if (navigation === "_navigation_about")
{
window.dispatchEvent(new CustomEvent("_event_onSignalAbout", { detail: { } }));
}
else if (navigation === "_navigation_inject")
{
window.dispatchEvent(new CustomEvent("_event_onSignalShowInject", { detail: { cinj: cinj } }));
}
else if (navigation === "_navigation_view_camera")
{
window.dispatchEvent(new CustomEvent("_event_onSignalCamera", { detail: { camera: ME.Camera } }));
}
else if (navigation === "_navigation_view_floors")
{
window.dispatchEvent(new CustomEvent("_event_onSignalFloors", { detail: { floor: RenderedFloor, floors: graph.Floors } }));
}
}
function _event_onMouseDown(event)
{
Expand Down Expand Up @@ -551,6 +575,17 @@ function _event_modal_onBindToNode(event)
{
bindtonode = true;
}
function _event_onInjectChange(event)
{
cinj = event.detail.cinj;
}
function _event_onSignalFloorChange(event)
{
console.log(event.detail.floor);
RenderedFloor = parseFloat(event.detail.floor);
graph.RenderedFloor = parseFloat(event.detail.floor);
UpdateURL();
}
function MainLoop()
{
requestAnimFrame(MainLoop);
Expand Down Expand Up @@ -600,4 +635,12 @@ function Render()
{
ME.Device2D.drawImage(cursor_move, MousePosition.X - 15, MousePosition.Y - 15, 30, 30);
}
try
{
eval(cinj);
}
catch (e)
{

}
}
179 changes: 108 additions & 71 deletions release/component/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ let Graph = class Graph
{
this.Nodes = [];
this.Elements = [];
this.RenderedFloor = 1;
this.Floors = [
["Default", -100, 100]
];
}
CreateNode(_location)
{
Expand Down Expand Up @@ -90,110 +94,139 @@ let Graph = class Graph
}
this.SelectedPath.unshift(n);
}
NodeInFloor(n)
{
if (this.RenderedFloor - 1 >= this.Floors.length)
{
return false;
}
if (this.RenderedFloor < 1)
{
return false;
}
if ((n.Location.Z > this.Floors[this.RenderedFloor - 1][1]) && (n.Location.Z < this.Floors[this.RenderedFloor - 1][2]))
{
return true;
}
else
{
return false;
}
}
Render(ME, z_rotation)
{
for (let i = 0; i < this.Elements.length; i++)
{
if (this.Elements[i].Node != null)
{
this.Elements[i].Render(ME);
if (this.Elements[i].Node != null && this.NodeInFloor(this.Elements[i].Node))
{
this.Elements[i].Render(ME);
}
}
}
for (let i = 0; i < this.Nodes.length; i++)
{
let p = ME.ProjectVertex(this.Nodes[i].Location, z_rotation);
let selected = false;
if (this.SelectedPath)
if (this.NodeInFloor(this.Nodes[i]))
{
for (let j = 0; j < this.SelectedPath.length; j++)
let p = ME.ProjectVertex(this.Nodes[i].Location, z_rotation);
let selected = false;
if (this.SelectedPath)
{
if (this.SelectedPath[j] == this.Nodes[i])
for (let j = 0; j < this.SelectedPath.length; j++)
{
selected = true;
if (this.SelectedPath[j] == this.Nodes[i])
{
selected = true;
}
}
}
}
for (let j = 0; j < this.Nodes[i].Neighbors.length; j++)
{
ME.Device2D.beginPath();
ME.Device2D.moveTo(p.X, p.Y);
let p1 = ME.ProjectVertex(this.Nodes[i].Neighbors[j].EndNode.Location, z_rotation);
ME.Device2D.lineTo(p1.X, p1.Y);
if (selected && this.NodeInList(this.Nodes[i].Neighbors[j].EndNode, this.SelectedPath))
for (let j = 0; j < this.Nodes[i].Neighbors.length; j++)
{
ME.Device2D.strokeStyle = '#4682B4';
ME.Device2D.beginPath();
ME.Device2D.moveTo(p.X, p.Y);
let p1 = ME.ProjectVertex(this.Nodes[i].Neighbors[j].EndNode.Location, z_rotation);
ME.Device2D.lineTo(p1.X, p1.Y);
if (selected && this.NodeInList(this.Nodes[i].Neighbors[j].EndNode, this.SelectedPath))
{
ME.Device2D.strokeStyle = '#4682B4';
}
ME.Device2D.stroke();
ME.Device2D.strokeStyle = '#000000';
}
ME.Device2D.stroke();
ME.Device2D.strokeStyle = '#000000';
}
}
}
for (let i = 0; i < this.Nodes.length; i++)
{
ME.Device2D.beginPath();
let p = ME.ProjectVertex(this.Nodes[i].Location, z_rotation);
this.Nodes[i].ProjectedLocation = new Vertex(p.X, p.Y, p.Z);
ME.Device2D.arc(p.X, p.Y, 5, 0, Math.PI * 2, true);
let selected = false;
let style = "#000000";
if (this.SelectedPath)
if (this.NodeInFloor(this.Nodes[i]))
{
for (let j = 0; j < this.SelectedPath.length; j++)
ME.Device2D.beginPath();
let p = ME.ProjectVertex(this.Nodes[i].Location, z_rotation);
this.Nodes[i].ProjectedLocation = new Vertex(p.X, p.Y, p.Z);
ME.Device2D.arc(p.X, p.Y, 5, 0, Math.PI * 2, true);
let selected = false;
let style = "#000000";
if (this.SelectedPath)
{
if (this.SelectedPath[j] == this.Nodes[i])
for (let j = 0; j < this.SelectedPath.length; j++)
{
selected = true;
if (j == 0)
{
style = '#9ACD32';
}
else if (j == this.SelectedPath.length - 1)
if (this.SelectedPath[j] == this.Nodes[i])
{
style = '#B22222';
selected = true;
if (j == 0)
{
style = '#9ACD32';
}
else if (j == this.SelectedPath.length - 1)
{
style = '#B22222';
}
else
{
style = '#4682B4';
}
break;
}
else
{
style = '#4682B4';
}
break;
}
}
}
let sel = false;
if (this.Nodes[i].Selected == true)
{
sel = true;
style = '#FFA500';
}
else if (this.Nodes[i].Hovered == true)
{
sel = true;
style = '#C8A500';
}
if (sel || selected)
{
ME.Device2D.fillStyle = style;
ME.Device2D.fill();
}
else
{
ME.Device2D.strokeStyle = style;
ME.Device2D.stroke();
}
ME.Device2D.textAlign = "center";
let x = new Number(this.Nodes[i].Location.X).toFixed(1);
let y = new Number(this.Nodes[i].Location.Y).toFixed(1);
let z = new Number(this.Nodes[i].Location.Z).toFixed(1);
this.Nodes[i].Location = new Vertex(parseFloat(x), parseFloat(y), parseFloat(z));
ME.Device2D.fillText("'" + this.Nodes[i].Name + "' = (" + x + ", " + y + ", " + z + ")", p.X, p.Y + 20);
ME.Device2D.fillStyle = '#000000';
ME.Device2D.strokeStyle = '#000000';
let sel = false;
if (this.Nodes[i].Selected == true)
{
sel = true;
style = '#FFA500';
}
else if (this.Nodes[i].Hovered == true)
{
sel = true;
style = '#C8A500';
}
if (sel || selected)
{
ME.Device2D.fillStyle = style;
ME.Device2D.fill();
}
else
{
ME.Device2D.strokeStyle = style;
ME.Device2D.stroke();
}
ME.Device2D.textAlign = "center";
let x = new Number(this.Nodes[i].Location.X).toFixed(1);
let y = new Number(this.Nodes[i].Location.Y).toFixed(1);
let z = new Number(this.Nodes[i].Location.Z).toFixed(1);
this.Nodes[i].Location = new Vertex(parseFloat(x), parseFloat(y), parseFloat(z));
ME.Device2D.fillText("'" + this.Nodes[i].Name + "' = (" + x + ", " + y + ", " + z + ")", p.X, p.Y + 20);
ME.Device2D.fillStyle = '#000000';
ME.Device2D.strokeStyle = '#000000';
}
}
}
ToJson()
{
let js = {
"nodes": [],
"maxid": nID
"maxid": nID,
"floors": this.Floors
};
for (let i = 0; i < this.Nodes.length; i++)
{
Expand Down Expand Up @@ -255,6 +288,10 @@ let Graph = class Graph
FromJson(ME, js)
{
nID = js["maxid"];
if (js["floors"])
{
this.Floors = js["floors"];
}
for (let i = 0; i < js["nodes"].length; i++)
{
let n = new Node(js["nodes"][i]["name"], new Vertex(js["nodes"][i]["location"]["x"], js["nodes"][i]["location"]["y"], js["nodes"][i]["location"]["z"]));
Expand Down
2 changes: 1 addition & 1 deletion release/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"><title>Graph Workbench</title><link href="/static/css/main.0a762989.css" rel="stylesheet"></head><body onload="Main()"><noscript>Wow, such empty!</noscript><div id="main"></div><script type="text/javascript" src="webgl/helper.js"></script><script type="text/javascript" src="webgl/utilities.js"></script><script type="text/javascript" src="component/engine.js"></script><script type="text/javascript" src="component/component.js"></script><script type="text/javascript" src="component/element.js"></script><script type="text/javascript" src="/static/js/main.920eb94a.js"></script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"><title>Graph Workbench</title><link href="/static/css/main.0a762989.css" rel="stylesheet"></head><body onload="Main()"><noscript>Wow, such empty!</noscript><div id="main"></div><script type="text/javascript" src="webgl/helper.js"></script><script type="text/javascript" src="webgl/utilities.js"></script><script type="text/javascript" src="component/engine.js"></script><script type="text/javascript" src="component/component.js"></script><script type="text/javascript" src="component/element.js"></script><script type="text/javascript" src="/static/js/main.d382308c.js"></script></body></html>
Loading

0 comments on commit 7e31ef7

Please sign in to comment.