Skip to content
Snippets Groups Projects
Commit 2c28e693 authored by 42loop's avatar 42loop
Browse files

new branch experimental

parent 75810e04
Branches experimental
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@
<script type="text/javascript">
var mqtt;
var reconnectTimeout = 2000;
mqtt_tries=0;
var light_state=[]
var last_light_state=[]
......@@ -83,9 +84,12 @@
onSuccess: onConnect,
onFailure: function (message) {
$('#status').val("Connection failed: " + message.errorMessage + "Retrying");
if (mqtt_tries<3)
{
mqtt_tries+=1;
setTimeout(MQTTconnect, reconnectTimeout);
}
};
}};
mqtt.onConnectionLost = onConnectionLost;
mqtt.onMessageArrived = onMessageArrived;
......@@ -614,6 +618,100 @@ function run()
var all_planes=document.querySelector('#waende-obj').data; //.object3D.children[0].children; // THREE.Group
var a_scene = document.getElementById('building_rot');
lines=all_planes.split("\n");
console.log(lines.length);
w=0;
while (w<lines.length)
{
w+=1;
if (lines[w].startsWith("o"))
{ console.log(lines[w]);
w+=1;
min_x=1000;min_y=1000;min_z=1000;
max_x=-1000;max_y=-1000;max_z=-1000;
while (lines[w].startsWith("v "))
{
vals=lines[w].split(' ');
vx=parseFloat(vals[1]);
vy=parseFloat(vals[2]);
vz=parseFloat(vals[3]);
if (vx<min_x) min_x=vx;
if (vx>max_x) max_x=vx;
if (vy<min_y) min_y=vy;
if (vy>max_y) max_y=vy;
if (vz<min_z) min_z=vz;
if (vz>max_z) max_z=vz;
w+=1;
}
console.log(min_x,max_x,min_y,max_y,min_z,max_z);
if (Math.abs(min_x)<Math.abs(max_x))
h_x=Math.min(min_x,max_x)
else h_x=Math.max(min_x,max_x);
if (Math.abs(min_z)<Math.abs(max_z))
h_z=Math.min(min_z,max_z)
else h_z=Math.max(min_z,max_z);
handle=h_x+' '+min_y+' '+h_z;
handle_ox=h_x+.75;
handle_o=handle_ox+' '+min_y+' '+h_z;
handle_ocx=h_x+.375;
handle_oc=handle_ocx+' '+min_y+' '+h_z;
console.log(handle);
var a_handle=document.createElement('a-sphere');
a_handle.setAttribute('position',handle);
a_handle.setAttribute('radius','.3');
a_handle.addEventListener('click', function (event) {
var xdist=prompt("enter horizontal distance","0");
var ydist=prompt("enter vertical distance","0");
});
a_scene.appendChild(a_handle);
var a_handle_c=document.createElement('a-cylinder');
a_handle_c.setAttribute('rotation','0 0 -90');
a_handle_c.setAttribute('position',handle_oc);
a_handle_c.setAttribute('radius','.05');
a_handle_c.setAttribute('height','.5');
a_handle_c.setAttribute('color','#f11');
a_scene.appendChild(a_handle_c);
var a_handle_o=document.createElement('a-cone');
a_handle_o.setAttribute('rotation','0 0 -90');
a_handle_o.setAttribute('position',handle_o);
a_handle_o.setAttribute('radius-bottom','.2');
a_handle_o.setAttribute('radius-top','0');
a_handle_o.setAttribute('height','0.25');
a_handle_o.setAttribute('color','#f11');
a_scene.appendChild(a_handle_o);
}
}
console.log("initialisation done !")
};
......@@ -718,8 +816,8 @@ function getlights()
{
sortlights();
console.log("lights sorted");
for (var i=0;i<22;i++)
sendsonoffstaterequest(i);
// for (var i=0;i<22;i++)
// sendsonoffstaterequest(i);
}
catch(error)
......@@ -802,7 +900,7 @@ function sortlights()
-->
<!--building rotation:-->
<a-entity rotation="0 -18.4 0">
<a-entity id="building_rot" rotation="0 -18.4 0">
<a-entity position="-6.072466370226408 5.08254868927047 -5.349" id="fenster" geometry="depth:0.01;width:30;height:3" material="opacity:0.47"></a-entity>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment