From 8540049b2bd1f07303bf43aa8ca447ba54b443f6 Mon Sep 17 00:00:00 2001 From: Lucio Zambon <lucio.zambon@elettra.eu> Date: Wed, 2 Oct 2024 00:38:08 +0000 Subject: [PATCH] Update panther.js --- panther.js | 65 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/panther.js b/panther.js index 0f8d990..991a4bc 100644 --- a/panther.js +++ b/panther.js @@ -7,7 +7,6 @@ import {EffectComposer} from 'three/addons/postprocessing/EffectComposer.js'; import {RenderPass} from 'three/addons/postprocessing/RenderPass.js'; import {OutlinePass} from 'three/addons/postprocessing/OutlinePass.js'; - // import {GLTFLoader} from 'three/addons/loaders/GLTFLoader.js'; import {ellipticaltubeGeometry} from 'components/ellipticaltube.js'; @@ -108,6 +107,12 @@ gui.add(params, 'ps').onChange(function() {toggleParam('ps');}); gui.title('PAnTHer - controls'); gui.add(params, 'search'); // .onKeyup(function() {console.log('search');}); + + const sstring = $('.controller.string').children().eq(1).children().eq(0); + sstring.attr('id', 'sname'); + sstring.attr('name', 'sname'); + sstring.addClass("form-control sname"); + gui.addColor(params, 'backgroundColor').onChange(function() {toggleParam('backgroundColor');}); params.far = typeof conf.default_far[machine]!='undefined'? conf.default_far[machine]: conf.default_far.default; gui.add(params, 'far', 50, 400).onChange(function() {setFar(params.far);}); @@ -123,21 +128,23 @@ document.body.appendChild(stats.dom); } export function bpm_reference(action) { - const name = $('.name:contains("bpmReference")').parent().select('.widget').children().eq(1).children('input').val(); - if (action=='save') fetch(bpm.srv+'?save='+name+'&content='+JSON.stringify(bpmData)).then((response) => {return response.text();}).then((res) =>{alert(res=='OK'? 'BPM reference saved': res);}).catch(error => {console.log("Fetch error", error);}); - else fetch(bpm.srv+'?open='+name).then((response) => {return response.json();}).then((res) =>{ - for (let facility in res) { - // if (facility=='bts') use https://puma-01.elettra.eu/rchan.php?json&valueOnly&src=srv-tango-sre-01.ecs.elettra.trieste.it:20000/fb/bts/traj/SensorReferenceValues - bpmIndex[facility] = lattice[facility].bpm.offset; - const path = bpmPath(res[facility], facility); - const skiplen = lattice[facility].bpm.skip? lattice[facility].bpm.skip.length: 0; - const bpmGeometry = new THREE.TubeGeometry(path, lattice[facility].bpm.length-1-skiplen, bpm.radius, 16, (typeof lattice[facility].sections[0].chamber)!='undefined'); - const material = new THREE.MeshBasicMaterial({color: 0x00ff80, transparent: true, opacity: 0.5,}); - bpmReferenceMesh[facility] = new THREE.Mesh(bpmGeometry, material); - facilities[facility].add(bpmReferenceMesh[facility]); - } - }) - .catch(error => {console.log("Fetch error", error);}); + if ($('.name:contains("bpmReference")') && $('.name:contains("bpmReference")').parent()) { + const name = $('.name:contains("bpmReference")').parent().select('.widget').children().eq(1).children('input').val(); + if (action=='save') fetch(bpm.srv+'?save='+name+'&content='+JSON.stringify(bpmData)).then((response) => {return response.text();}).then((res) =>{alert(res=='OK'? 'BPM reference saved': res);}).catch(error => {console.log("Fetch error", error);}); + else fetch(bpm.srv+'?open='+name).then((response) => {return response.json();}).then((res) =>{ + for (let facility in res) { + // if (facility=='bts') use https://puma-01.elettra.eu/rchan.php?json&valueOnly&src=srv-tango-sre-01.ecs.elettra.trieste.it:20000/fb/bts/traj/SensorReferenceValues + bpmIndex[facility] = lattice[facility].bpm.offset; + const path = bpmPath(res[facility], facility); + const skiplen = lattice[facility].bpm.skip? lattice[facility].bpm.skip.length: 0; + const bpmGeometry = new THREE.TubeGeometry(path, lattice[facility].bpm.length-1-skiplen, bpm.radius, 16, (typeof lattice[facility].sections[0].chamber)!='undefined'); + const material = new THREE.MeshBasicMaterial({color: 0x00ff80, transparent: true, opacity: 0.5,}); + bpmReferenceMesh[facility] = new THREE.Mesh(bpmGeometry, material); + facilities[facility].add(bpmReferenceMesh[facility]); + } + }) + .catch(error => {console.log("Fetch error", error);}); + } } window.bpmreference = bpm_reference; function updateBpm(data, facility) { @@ -260,10 +267,12 @@ params.bpmZoomV = 1; gui.add(params, 'bpmZoomV', 0.01, 100); params.bpmReference = '2GeV'; - gui.add(params, 'bpmReference'); - const ref = $('.name:contains("bpmReference")').parent().select('.widget').children().eq(1); - ref.append("<img src='./save.svg' style='height:20px; margin: 2px; cursor: pointer;' onClick='window.bpmreference(\"save\")'>"); - ref.append("<img src='./open.svg' style='height:20px; margin: 2px; cursor: pointer;' onClick='window.bpmreference(\"open\")'>"); + gui.add(params, 'bpmReference'); + if ($('.name:contains("bpmReference")') && $('.name:contains("bpmReference")').parent()) { + const ref = $('.name:contains("bpmReference")').parent().select('.widget').children().eq(1); + ref.append("<img src='./save.svg' style='height:20px; margin: 2px; cursor: pointer;' onClick='window.bpmreference(\"save\")'>"); + ref.append("<img src='./open.svg' style='height:20px; margin: 2px; cursor: pointer;' onClick='window.bpmreference(\"open\")'>"); + } } } if (lattice[i].envelope) {envelopeMenu(params, gui, i);} @@ -763,7 +772,7 @@ window.tooltipObject = tooltipObject = null; document.getElementById('tooltipFrame').src = document.getElementById('compdb').href = ''; document.getElementById('compdb').style.display = 'inline'; - document.getElementById('tooltip').style.display = 'none'; + if (document.location.pathname.indexOf('ff63')==-1) document.getElementById('tooltip').style.display = 'none'; document.getElementById('tooltipFrame').width = '500px'; if (debug.indexOf(''+j++)>-1) console.log('handleMouseMove(), tooltipObject',tooltipObject); if (!found) outlinePass.selectedObjects = selectedObjects = []; @@ -853,7 +862,7 @@ window.tooltipObject = tooltipObject = null; document.getElementById('tooltipFrame').src = document.getElementById('compdb').href = ''; document.getElementById('compdb').style.display = 'inline'; - document.getElementById('tooltip').style.display = 'none'; + if (document.location.pathname.indexOf('ff63')==-1) document.getElementById('tooltip').style.display = 'none'; document.getElementById('tooltipFrame').width = '500px'; if (debug.indexOf(''+j++)>-1) console.log('handleMouseMove(), tooltipObject',tooltipObject); if (!found) outlinePass.selectedObjects = selectedObjects = []; @@ -1076,11 +1085,13 @@ window.setFar = setFar; const frustum = new THREE.Frustum(); const matrix = new THREE.Matrix4().multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse); frustum.setFromProjectionMatrix(matrix); - document.getElementById('tooltip').style.display = (frustum.containsPoint(tooltipObject.position))? 'block': 'none'; let top = (-(pos2.y * heightHalf) + heightHalf ); if (window.innerHeight - top < 400) top = window.innerHeight - 400; - document.getElementById('tooltip').style.top = top+'px'; - document.getElementById('tooltip').style.left = ((pos2.x * widthHalf ) + widthHalf + 25)+'px'; + if (document.location.pathname.indexOf('ff63')==-1) { + document.getElementById('tooltip').style.top = top+'px'; + document.getElementById('tooltip').style.left = ((pos2.x * widthHalf ) + widthHalf + 25)+'px'; + document.getElementById('tooltip').style.display = (frustum.containsPoint(tooltipObject.position))? 'block': 'none'; + } } } function updateUrl(param, value) { @@ -1151,8 +1162,4 @@ window.setFar = setFar; $('.lil-gui').css({'top': '120px', 'right': '1px'}); $( "body" ).append('<div class="lil-gui allow-touch-styles root autoPlace" style="top: 0px;right: 1px;height: 120px;background-color: black;"></div>'); } - const sstring = $('.controller.string').children().eq(1).children().eq(0); - sstring.attr('id', 'sname'); - sstring.attr('name', 'sname'); - sstring.addClass("form-control sname"); if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) gui.close(); -- GitLab