diff --git a/panther.js b/panther.js index 87637086f5b72eee9f610a775498847fff0f6cc8..378fd049d468d62fcc8aad14592c382034cec229 100644 --- a/panther.js +++ b/panther.js @@ -132,7 +132,7 @@ } window.bpmreference = bpm_reference; function updateBpm(data, facility) { - console.log('updateBpm(), data:', data, ', facility:', facility, ', bpmMesh', bpmMesh); + // console.log('updateBpm(), data:', data, ', facility:', facility, ', bpmMesh', bpmMesh); bpmData[facility] = data; bpmMesh[facility].geometry.dispose(); bpmIndex[facility] = lattice[facility].bpm.offset; @@ -164,22 +164,29 @@ }); } function readBpms() { - for (let facility in lattice) { if (lattice[facility].bpm) readBpm(facility);} + // for (let facility in lattice) { if (lattice[facility].bpm) readBpm(facility);} + fetch(conf.bpmUrl) + .then((response) => {return response.json();}) + .then((data) => { + for (let facility in data) { + updateBpm(data[facility], facility); + } + }); } function bpmPath(data, facility) { let len = lattice[facility].bpm.length - bpmSkip[facility].length; if (len>bpmPoints[facility].length) len = bpmPoints[facility].length; - // if (data!=-1) - console.log('bpmDbg', len, facility, data, bpmPoints[facility].length); + // if (data!=-1) console.log('bpmDbg', len, facility, data, bpmPoints[facility].length); const bpmCurve = []; + const bpmFactor = 0.000002; for (let i=0; i<len; i++) { const j = (i + 1) % len; - const tx = document.location.search.indexOf('radial')==-1? bpmPoints[facility][i][0].x + Math.sin(Math.atan(bpmPoints[facility][i][1])+Math.PI*0.5*bpmPoints[facility][i][2])*1000*(data[0]? data[0][j]: 1): bpmPoints[facility][i][0].x * (1+(data[0]? data[0][j]*0.02*params.bpmZoomX: 0)); - const ty = Ydefault + bpmPoints[facility][i][0].y + (data[1]? data[1][j]*1000*params.bpmZoomY: 0); - const tz = document.location.search.indexOf('radial')==-1? bpmPoints[facility][i][0].z + Math.cos(Math.atan(bpmPoints[facility][i][1])+Math.PI*0.5*bpmPoints[facility][i][2])*1000*(data[0]? data[0][j]: 1): bpmPoints[facility][i][0].z * (1+(data[0]? data[0][j]*0.02*params.bpmZoomX: 0)); - // console.log(i, facility, bpmCurve); + const tx = bpmPoints[facility][i][0].x * (1+(data.Hor? data.Hor[j]*0.02*bpmFactor*params.bpmZoomX: 0)); + const ty = Ydefault + bpmPoints[facility][i][0].y + (data.Ver? data.Ver[j]*1000*bpmFactor*params.bpmZoomY: 0); + const tz = bpmPoints[facility][i][0].z * (1+(data.Hor? data.Hor[j]*0.02*bpmFactor*params.bpmZoomX: 0)); bpmCurve.push(new THREE.Vector3(tx, ty, tz)); } + // console.log(facility, bpmCurve); return new THREE.CatmullRomCurve3(bpmCurve); } let bpmInited = false; @@ -193,7 +200,7 @@ const material = new THREE.MeshBasicMaterial({color: 0x8000ff, transparent: true, opacity: 0.5,}); bpmMesh[facility] = new THREE.Mesh(bpmGeometry, material); facilities[facility].add(bpmMesh[facility]); - if (!bpmInited) {bpmInited=true; readBpms(); if (document.location.search.indexOf('bpm=')==-1) setInterval(readBpms, 3000);} + if (!bpmInited) {bpmInited=true; readBpms(); if (document.location.search.indexOf('bpm=')==-1) setInterval(readBpms, 300);} } console.log('bpmDbg(), bpmMesh:', bpmMesh, bpmMesh[facility]); } @@ -312,7 +319,7 @@ } }); function showStatus(i, stat) { - if (stat == 0 || stat == 'null' || stat == '' || stat == 'ON' || stat == 'RUNNING') {status[i].visible = false;} + if (stat == 0 || stat == 'null' || stat == '' || stat == 'ON' || stat == 'RUNNING' || (!fel1 && status[i].facility=='fel1') || (!fel2 && status[i].facility=='fel2')) {status[i].visible = false;} else {status[i].visible = true; status[i].material.color.set(conf.stateLabelColor[stat]);} // console.log(i, status[i], stat); } @@ -323,7 +330,7 @@ } function updateStatus() { fetch(conf.stateUrl, {cache: "no-store"}).then((response) => {return response.text();}).then((data) => { - // console.log(data); + // console.log('updateStatus()', fel1, fel2, status); const statVal = data.split(';'); for (let i=0; i<status.length; i++) { if (status[i].statsrc==ps) { @@ -456,6 +463,7 @@ const sphere = new THREE.Mesh(sphereGeometry,normalMaterial.clone()); sphere.position.set(params.highlightScale*(lattice[facility].sections[i].start.x + tang*d / den), y+350, params.highlightScale*(lattice[facility].sections[i].start.z + d / den)); sphere.name = mycomp.name+'_status'; + sphere.facility = facility; sphere.visible = false; status.push(sphere); facilities[facility].add(sphere); @@ -725,8 +733,9 @@ document.getElementById('compdb').href = 'http://adam.elettra.trieste.it/projects/blcs/beamwatch/'; document.getElementById('compname').innerHTML = document.getElementById('compname').innerHTML + ' in ADAM Beamwatch'; } + document.getElementById('tooltipFrame').src.replace('s=dipolefermi', 's=bending'); } - // console.log('handleMouseMove()', intersects, document.getElementById('tooltipFrame').src); + console.log('handleMouseMove()', intersects, document.getElementById('tooltipFrame').src); if (selectedObject.parent && selectedObject.parent.type && selectedObject.parent.type == "Scene") return; // avoid selecting everything checkOutline(selectedObject); renderer.render(scene, camera);