From f1e9a298ac2823150631dfeaabe347947d683297 Mon Sep 17 00:00:00 2001 From: Lucio Zambon <lucio.zambon@elettra.eu> Date: Tue, 1 Apr 2025 05:51:11 +0000 Subject: [PATCH] Update panther.js --- panther.js | 50 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/panther.js b/panther.js index 9721d33..5cf6400 100644 --- a/panther.js +++ b/panther.js @@ -89,8 +89,9 @@ const loader = new GLTFLoader(); let fast = document.location.search.indexOf('fast')>-1? document.location.search.split('fast')[1].split('&')[0].split(','): false; let premium = document.location.search.indexOf('premium')>-1? document.location.search.split('premium')[1].split('&')[0].split(','): false; - const real = (document.location.search.indexOf('real')>-1 || (machine=='elettra2' && premium)) && document.location.search.indexOf('stl')==-1 && document.location.search.indexOf('high')==-1; - const stl = document.location.search.indexOf('stl')>-1; + // const real = (document.location.search.indexOf('real')>-1 || (machine=='elettra2' && premium)) && document.location.search.indexOf('stl')==-1 && document.location.search.indexOf('high')==-1; + const real = document.location.search.indexOf('real')>-1; + const stl = (document.location.search.indexOf('stl')>-1 || (machine=='elettra2' && premium)) && document.location.search.indexOf('real')==-1 && document.location.search.indexOf('high')==-1; const high = document.location.search.indexOf('high')>-1; const blm = {oldIndex: null, reader: false, acqTime: null}; let latticenodes = 0; @@ -124,8 +125,10 @@ 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, 500).onChange(function() {setFar(params.far);}); - params.tour = document.location.search.indexOf('tour=')>-1; - gui.add(params, 'tour').onChange(function() {switchTour();}); + // if (machine.indexOf('elettra')>-1) { + params.tour = document.location.search.indexOf('tour=')>-1; + gui.add(params, 'tour').onChange(function() {switchTour();}); + //} const debugcamera = document.location.search.indexOf('debugcamera')>-1; if (debugcamera) $('body').append('<div class="debug" style="top: 0; position: fixed;"> x: <input size="5" id="x"/>, y: <input size="5" id="y"/>, z: <input size="5" id="z"/>, cx: <input size="5" id="cx"/>, cy: <input size="5" id="cy"/>, cz: <input size="5" id="cz"/>'); const highlight = document.location.search.indexOf('highlight=')==-1? []: document.location.search.split('highlight=')[1].split('&')[0].split(','); @@ -842,9 +845,10 @@ function initVar(name, defaultVal) { return document.location.search.indexOf(name)>-1? document.location.search.split(name+'=')[1].split('&')[0]: defaultVal; } + // https://pwma-dev.elettra.eu/panther/panther.php?machine=fermi&facility=linac:0:8:0.1,fel1&tourSpeed=100&tourHight=10000 const tourSpeed = initVar('tourSpeed', 10); // speed [m/s] let tourPeriod = initVar('tourPeriod', 10); - let alphaPerPeriod = 0.009; + let alphaPerPeriod = 0.0085; const tourBackets = initVar('tourBackets', 15); const tourBacketSize = initVar('tourBacketSize', 0.1); const tourBacketsDistance = initVar('tourBacketsDistance', 1500); @@ -915,7 +919,8 @@ camera.position.set(cameraPos[0] + (steps-step+1)*(bx-cameraPos[0])/steps, cameraPos[1] + (steps-step+1)*(tourHight-cameraPos[1])/steps, cameraPos[2] + (steps-step+1)*(bz-cameraPos[2])/steps); camera.rotateY(Math.PI/steps/preFactor); // camera.rotateX(2.21/steps); camera.rotateZ(-2.41/steps); - setTimeout(preTour, tourPeriod*(step<10? 10/step: (step==steps? 100: 1)), step-1, steps, facility, section, cameraPos, preFactor); + if (step<200) camera.rotateY(Math.PI*0.001); + setTimeout(preTour, tourPeriod*(step<20? 50/step: (step==steps? 100: 1)), step-1, steps, facility, section, cameraPos, preFactor); } else if (params.tour) { const nodes = []; @@ -942,7 +947,8 @@ else { for (let i=0; i<lattice[facility].sections.length; i++) {nodes.push(lattice[facility].sections[i].start);} } - setTimeout(tour, tourPeriod*2, nodes, section, pos, 0, 0, maxSteps); + const alpha = typeof facility.split(',')[0].split(':')[3]=='undefined'? 0: facility.split(',')[0].split(':')[3]; + setTimeout(tour, tourPeriod, nodes, section, pos, alpha, 0, maxSteps); } } function switchTour() { @@ -973,7 +979,7 @@ // const cameraPos = [51010,30171,-33995,0,0.73,0]; camera.position.set(cameraPos[0]*params.highlightScale, cameraPos[1]*params.highlightScale, cameraPos[2]*params.highlightScale); camera.rotation.set(cameraPos[3],cameraPos[4],cameraPos[5]); - if (params.tour) preTour(100, 100, facility, section, cameraPos, preFactor); + if (params.tour) setTimeout(preTour, 3000, 200, 200, facility, section, cameraPos, preFactor); // camera.rotateY(-Math.PI*1); // if (params.tour) tour(facility, 0, 0, 0); } @@ -1202,7 +1208,7 @@ window.setFar = setFar; scene.background = new THREE.Color(document.location.search.indexOf('background=')>-1? document.location.search.split('background=')[1].split('&')[0]: 0x777777); const canvas = document.querySelector('#c'); - renderer = new THREE.WebGLRenderer({antialias: false, canvas, logarithmicDepthBuffer: true}); + renderer = new THREE.WebGLRenderer({antialias: true, canvas, logarithmicDepthBuffer: true}); renderer.shadowMap.enabled = false; // global shadow disable // renderer = new WebGPURenderer(); @@ -1235,12 +1241,12 @@ window.setFar = setFar; window.addEventListener('resize', onWindowResize); camera.updateMatrixWorld(true); setFar(params.far); - + /**/ const dirLight1 = new THREE.DirectionalLight(0xffffff, 5); dirLight1.position.set(0, 10, 0); // zenith light scene.add(dirLight1); - /*const dirLight2 = new THREE.DirectionalLight(0xffffff, 5); + const dirLight2 = new THREE.DirectionalLight(0xffffff, 2); dirLight2.position.set(0, -10, 0); // nadir light scene.add(dirLight2); const dirLight3 = new THREE.DirectionalLight(0xffffff, 2); @@ -1248,15 +1254,25 @@ window.setFar = setFar; scene.add(dirLight3); const dirLight4 = new THREE.DirectionalLight(0xffffff, 2); dirLight4.position.set(-10, 5, 0); // left light - scene.add(dirLight4);*/ - const dirLight5 = new THREE.DirectionalLight(0xffffff, 5); + scene.add(dirLight4); + const dirLight5 = new THREE.DirectionalLight(0xffffff, 4); dirLight5.position.set(0, 5, 10); // front light scene.add(dirLight5); - /*const ambientLight = new THREE.AmbientLight(0xffffff, 1); - scene.add(ambientLight);*/ - - + const ambientLight = new THREE.AmbientLight(0xffffff, 2); + scene.add(ambientLight); + + /* + + const dirLight1 = new THREE.DirectionalLight(0xffffff, 5); + dirLight1.position.set(1, 1, 1); + const dirLight2 = new THREE.DirectionalLight(0x888888, 5); + dirLight2.position.set(-1, -1, -1); + const ambientLight = new THREE.AmbientLight(0xffffff, 5); + + */ + + // postprocessing (derived from https://github.com/mrdoob/three.js/blob/master/examples/webgl_postprocessing_outline.html) composer = new EffectComposer(renderer); const renderPass = new RenderPass(scene, camera); -- GitLab