From d82d88ac511082d1ce1a019b0d8f53cc451ca560 Mon Sep 17 00:00:00 2001
From: Lucio Zambon <lucio.zambon@elettra.eu>
Date: Thu, 13 Mar 2025 00:39:01 +0000
Subject: [PATCH] Update panther.js

---
 panther.js | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/panther.js b/panther.js
index 653b32f..63bf01d 100644
--- a/panther.js
+++ b/panther.js
@@ -962,13 +962,13 @@
 				pos = pos+tourSpeed*tourPeriod - d;
 			}
 			else pos = pos+tourSpeed*tourPeriod;
-			const alphaFactor = facility=='sr'? 0.77: 9;
+			const alphaFactor = facility=='sr'? 0.77: 12;
 			if (params.tour) setTimeout(tour, tourPeriod, facility, section, pos, (alpha<0? 2*Math.PI+alpha: alpha)*alphaFactor, step, maxSteps);
 		}
 	}
 	function preTour(step, steps, facility, section, cameraPos, preFactor) {
 		console.log(step, facility, section, lattice);
-		const f0 = facility.split(',')[0];
+		const f0 = facility.split(',')[0].split(':')[0];
 		const pos = f0=='preinjector'? -20000: 0;
 		const maxSteps = f0=='preinjector'? 3: 10000;
 		const bx = (lattice[f0].sections[section].start.x-pos)*tourTransverse;
@@ -984,7 +984,20 @@
 			if (facility.indexOf(',')>-1) {
 				const f = facility.split(',');
 				for (let j=0; j<f.length; j++) {
-					for (let i=0; i<lattice[f[j]].sections.length; i++) {nodes.push(lattice[f[j]].sections[i].start);}
+					const start = f[j].indexOf(':')>-1? f[j].split(':')[1]: 0;
+					const stop = f[j].indexOf(':')>-1? f[j].split(':')[2]: lattice[f[j].split(':')[0]].sections.length;
+					for (let i=start; i<stop; i++) {nodes.push(lattice[f[j].split(':')[0]].sections[i % lattice[f[j].split(':')[0]].sections.length].start);}
+				}
+				if (1) {
+					const cMaterials = [new THREE.MeshBasicMaterial({ color: 0xff0000}),new THREE.MeshBasicMaterial({ color: 0x00ff00}),new THREE.MeshBasicMaterial({ color: 0x0000ff})];
+					for (let pi=0, k=0; pi<nodes.length; pi++, k++) {
+						const sphere = new THREE.Mesh(sphereGeometry,cMaterials[k % 3].clone());
+						sphere.position.set(nodes[pi].x, 1200, nodes[pi].z);
+						sphere.scale.x = 0.5;
+						sphere.scale.y = 0.5;
+						sphere.scale.z = 0.5;
+						facilities['sr'].add(sphere);
+					}
 				}
 			}
 			else {
@@ -996,7 +1009,7 @@
 	function switchTour() {
 		console.log(lattice);
 		const facility = initVar('facility', 'sr');
-		const f0 = facility.split(',')[0];
+		const f0 = facility.split(',')[0].split(':')[0];
 		const preFactor = f0 == 'sr'? 10: (f0 == 'preinjector'? 2.1: 1);
 		const section = f0 == 'sr'? 30: (f0 == 'preinjector'? 0: 0);
 		if (showBackets && backets.length==0) for (let pi=1; pi<=tourBackets; pi++) {
-- 
GitLab