Back to home page

EIC code displayed by LXR

 
 

    


Warning, /firebird/firebird-ng/src/app/data-pipelines/calorimetry.prettifier.ts is written in an unsupported language. File is not indexed.

0001 import * as THREE from "three";
0002 import {
0003   createOutline,
0004   disposeNode,
0005   disposeOriginalMeshesAfterMerge,
0006   findObject3DNodes,
0007   pruneEmptyNodes
0008 } from "../utils/three.utils";
0009 import {mergeMeshList, MergeResult} from "../utils/three-geometry-merge";
0010 import {ColorRepresentation} from "three/src/math/Color";
0011 
0012 
0013 export class CalorimetryGeometryPrettifier {
0014 
0015   doEndcapEcalN(node: THREE.Mesh) {
0016     let crystals = findObject3DNodes(node, "**/crystal_vol_0", "Mesh").nodes;
0017     //console.log(crystals);
0018 
0019     // Merge crystals together
0020 
0021 
0022     let mergeResult = mergeMeshList(crystals, node, "crystals");
0023 
0024     if(!mergeResult) {
0025       console.warn("didn't find crystals")
0026       return;
0027     }
0028     disposeOriginalMeshesAfterMerge(mergeResult)
0029 
0030     // outline crystals
0031     createOutline(mergeResult.mergedMesh);
0032 
0033     // Support
0034     let innerSupport = findObject3DNodes(node, "**/inner_support*", "Mesh").nodes[0];
0035     let ring = findObject3DNodes(node, "**/ring*", "Mesh").nodes[0];
0036     const supportMaterial = new THREE.MeshStandardMaterial({
0037       color: 0x19a5f5,
0038       roughness: 0.7,
0039       metalness: 0.869,
0040       transparent: true,
0041       opacity: 1,
0042       side: THREE.DoubleSide
0043     });
0044 
0045     mergeResult = mergeMeshList([innerSupport, ring], node, "support", supportMaterial);
0046     if(!mergeResult) {
0047       console.warn("didn't find crystals")
0048       return;
0049     }
0050     disposeOriginalMeshesAfterMerge(mergeResult);
0051 
0052 
0053     // Cleanup. Removing useless nodes that were left without geometries speeds up overall rendering
0054     pruneEmptyNodes(node);
0055   }
0056 
0057   /**
0058    * DRICH
0059    *
0060    * ----------------------------------------------------
0061    * */
0062   doDRICH(node: THREE.Mesh) {
0063 
0064     let sensors = findObject3DNodes(node, "**/*cooling*", "Mesh").nodes;
0065     let aeroGel = findObject3DNodes(node, "**/*aerogel*", "Mesh").nodes[0];
0066     sensors.push(aeroGel);
0067     let mergeResult = mergeMeshList(sensors, node, "sensors");
0068     if(!mergeResult) {
0069       console.warn("didn't find aerogel & cooling")
0070       return;
0071     }
0072     disposeOriginalMeshesAfterMerge(mergeResult)
0073 
0074     let filter = findObject3DNodes(node, "**/*filter*", "Mesh").nodes[0];
0075     filter.visible = false;
0076     let airGap = findObject3DNodes(node, "**/*airgap*", "Mesh").nodes[0];
0077     airGap.visible = false;
0078 
0079 
0080     let mirrors = findObject3DNodes(node, "**/*mirror*", "Mesh").nodes;
0081     const mirrorsMaterial = new THREE.MeshPhysicalMaterial({
0082       color: 0xfafafa,
0083       roughness: 0.1,
0084       metalness: 0.2,
0085       reflectivity: 1.5,
0086       clearcoat: 1,
0087       depthTest: true,
0088       depthWrite: true,
0089       transparent: true,
0090       envMapIntensity: 0.8,
0091       opacity: 1,
0092       side: THREE.DoubleSide
0093     });
0094 
0095     // Merge crystals together
0096     mergeResult = mergeMeshList(mirrors, node, "mirrors", mirrorsMaterial);
0097     if(!mergeResult) {
0098       console.warn("didn't find mirrors")
0099       return;
0100     }
0101     disposeOriginalMeshesAfterMerge(mergeResult)
0102 
0103     // Cleanup. Removing useless nodes that were left without geometries speeds up overall rendering
0104     pruneEmptyNodes(node);
0105   }
0106 
0107   /**
0108    * DIRC
0109    *
0110    * ----------------------------------------------------
0111    * */
0112   doDIRC(node: THREE.Mesh) {
0113 
0114     let bars = findObject3DNodes(node, "**/*box*", "Mesh").nodes;
0115     let prisms = findObject3DNodes(node, "**/*prism*", "Mesh").nodes;
0116     const barsPrisms = bars.concat(prisms);
0117 
0118     const barMat = new THREE.MeshPhysicalMaterial({
0119       color: 0xe5ba5d,
0120       metalness: .9,
0121       roughness: .05,
0122       envMapIntensity: 0.9,
0123       clearcoat: 1,
0124       transparent: true,
0125       //transmission: .60,
0126       opacity: .6,
0127       reflectivity: 0.2,
0128       //refr: 0.985,
0129       ior: 0.9,
0130       side: THREE.DoubleSide,
0131     });
0132 
0133 
0134     let mergeResult = mergeMeshList(barsPrisms, node, "barsPrisms", barMat);
0135     if(!mergeResult) {
0136       console.warn("didn't find barPrisms")
0137       return;
0138     }
0139     disposeOriginalMeshesAfterMerge(mergeResult);
0140 
0141     createOutline(mergeResult.mergedMesh);
0142 
0143     // Rails
0144     let rails = findObject3DNodes(node, "**/*rail*", "Mesh").nodes;
0145     mergeResult = mergeMeshList(rails, node, "rails");
0146     if(!mergeResult) {
0147       console.warn("didn't find rails")
0148       return;
0149     }
0150     disposeOriginalMeshesAfterMerge(mergeResult);
0151     createOutline(mergeResult.mergedMesh);
0152 
0153     // MCPs
0154     let mcps = findObject3DNodes(node, "**/*mcp*", "Mesh").nodes;
0155     mergeResult = mergeMeshList(mcps, node, "mcps");
0156     if(!mergeResult) {
0157       console.warn("didn't find mcps")
0158       return;
0159     }
0160     disposeOriginalMeshesAfterMerge(mergeResult);
0161 
0162     // Cleanup. Removing useless nodes that were left without geometries speeds up overall rendering
0163     pruneEmptyNodes(node);
0164   }
0165 }