From 2c28e693dcac224c64b56f6a1b90fff28affc236 Mon Sep 17 00:00:00 2001 From: 42loop <ulf.freyhoff@gmx.net> Date: Wed, 7 Nov 2018 11:52:16 +0100 Subject: [PATCH] new branch experimental --- index.html | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 104 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index d13d735..4accc31 100644 --- a/index.html +++ b/index.html @@ -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"); - setTimeout(MQTTconnect, reconnectTimeout); - } - }; + 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> -- GitLab