From 7665edf20996af1c73d71c5723284945177ec6f4 Mon Sep 17 00:00:00 2001 From: Dmitry Romanov Date: Tue, 14 May 2024 20:07:18 -0400 Subject: [PATCH] [ng] More optimized central detector geometry --- .../src/app/app-config.service.spec.ts | 16 ++++ firebird-ng/src/app/app-config.service.ts | 9 +++ firebird-ng/src/app/app.routes.ts | 9 ++- firebird-ng/src/app/geometry.service.ts | 2 +- .../input-config/input-config.component.html | 74 +++++++++++++++++++ .../input-config/input-config.component.scss | 0 .../input-config.component.spec.ts | 26 +++++++ .../input-config/input-config.component.ts | 40 ++++++++++ .../main-display/main-display.component.ts | 57 +++++++++++++- 9 files changed, 229 insertions(+), 4 deletions(-) create mode 100644 firebird-ng/src/app/app-config.service.spec.ts create mode 100644 firebird-ng/src/app/app-config.service.ts create mode 100644 firebird-ng/src/app/input-config/input-config.component.html create mode 100644 firebird-ng/src/app/input-config/input-config.component.scss create mode 100644 firebird-ng/src/app/input-config/input-config.component.spec.ts create mode 100644 firebird-ng/src/app/input-config/input-config.component.ts diff --git a/firebird-ng/src/app/app-config.service.spec.ts b/firebird-ng/src/app/app-config.service.spec.ts new file mode 100644 index 0000000..ee08175 --- /dev/null +++ b/firebird-ng/src/app/app-config.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { AppConfigService } from './app-config.service'; + +describe('AppConfigService', () => { + let service: AppConfigService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(AppConfigService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/firebird-ng/src/app/app-config.service.ts b/firebird-ng/src/app/app-config.service.ts new file mode 100644 index 0000000..0e9d145 --- /dev/null +++ b/firebird-ng/src/app/app-config.service.ts @@ -0,0 +1,9 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class AppConfigService { + + constructor() { } +} diff --git a/firebird-ng/src/app/app.routes.ts b/firebird-ng/src/app/app.routes.ts index 2a73356..c103874 100644 --- a/firebird-ng/src/app/app.routes.ts +++ b/firebird-ng/src/app/app.routes.ts @@ -1,12 +1,17 @@ import { Routes } from '@angular/router'; import {MainDisplayComponent} from "./main-display/main-display.component"; import {FileBrowserComponent} from "./file-browser/file-browser.component"; +import {InputConfigComponent} from "./input-config/input-config.component"; export const routes: Routes = [ + { path: '', redirectTo: '/config', pathMatch: 'full' }, + { path: 'config', component: InputConfigComponent }, { path: 'display', loadComponent: () => import('./main-display/main-display.component').then(m => m.MainDisplayComponent) }, - { path: '', component: FileBrowserComponent } - + { + path: 'files', + loadComponent: () => import('./file-browser/file-browser.component').then(m => m.FileBrowserComponent) + }, ]; diff --git a/firebird-ng/src/app/geometry.service.ts b/firebird-ng/src/app/geometry.service.ts index 77d0b3e..ac4bd27 100644 --- a/firebird-ng/src/app/geometry.service.ts +++ b/firebird-ng/src/app/geometry.service.ts @@ -174,7 +174,7 @@ export class GeometryService { // console.time('Build geometry'); - let rootObject3d = build(rootGeoManager, { numfaces: 500000000, numnodes: 50000000, dflt_colors: false, vislevel: 100, doubleside:true, transparency:false}); + let rootObject3d = build(rootGeoManager, { numfaces: 500000000, numnodes: 50000000, instancing:1, dflt_colors: false, vislevel: 100, doubleside:false, transparency:true}); console.timeEnd('Build geometry'); // >oO console.log(geo); diff --git a/firebird-ng/src/app/input-config/input-config.component.html b/firebird-ng/src/app/input-config/input-config.component.html new file mode 100644 index 0000000..68e6b98 --- /dev/null +++ b/firebird-ng/src/app/input-config/input-config.component.html @@ -0,0 +1,74 @@ + +
+

Event display source control

+ +
+
+
Geometry source
+ +
+ +
+
Geometry optimization
+
+ + +
+ +
+ +
+
Geometry postprocessing
+
+ + +
+
+ +
+ +
+
+ +
+ +
+
diff --git a/firebird-ng/src/app/input-config/input-config.component.scss b/firebird-ng/src/app/input-config/input-config.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/firebird-ng/src/app/input-config/input-config.component.spec.ts b/firebird-ng/src/app/input-config/input-config.component.spec.ts new file mode 100644 index 0000000..b5f19fe --- /dev/null +++ b/firebird-ng/src/app/input-config/input-config.component.spec.ts @@ -0,0 +1,26 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { BrowserModule } from '@angular/platform-browser'; +import { ReactiveFormsModule } from '@angular/forms'; +import { InputConfigComponent } from './input-config.component'; + + + +describe('InputConfigComponent', () => { + let component: InputConfigComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [InputConfigComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(InputConfigComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/firebird-ng/src/app/input-config/input-config.component.ts b/firebird-ng/src/app/input-config/input-config.component.ts new file mode 100644 index 0000000..16e3f1f --- /dev/null +++ b/firebird-ng/src/app/input-config/input-config.component.ts @@ -0,0 +1,40 @@ +// event-display-source.component.ts +import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup } from '@angular/forms'; +import { GeometryService } from '../geometry.service'; +import { ReactiveFormsModule } from '@angular/forms'; +import {RouterLink} from '@angular/router'; + +@Component({ + selector: 'app-input-config', + standalone: true, + imports: [ReactiveFormsModule, RouterLink], + templateUrl: './input-config.component.html', + styleUrl: './input-config.component.scss' +}) +export class InputConfigComponent implements OnInit { + + geoForm: FormGroup; + + constructor(private fb: FormBuilder, private geometryService: GeometryService) { + this.geoForm = this.fb.group({ + selectedGeometry: ['eic geometry'], + geoOptEnabled: [false], + selectedGeoCutoff: ['Central detector'], + geoPostEnabled: [false] + }); + + this.geoForm.valueChanges.subscribe(value => { + //this.geometryService.save(value); + console.log(value); + }); + } + + ngOnInit(): void { + // const savedSettings = this.geometryService.load(); + // if (savedSettings) { + // this.geoForm.setValue(savedSettings); + // } + } + +} diff --git a/firebird-ng/src/app/main-display/main-display.component.ts b/firebird-ng/src/app/main-display/main-display.component.ts index 4a07979..f3b7ce8 100644 --- a/firebird-ng/src/app/main-display/main-display.component.ts +++ b/firebird-ng/src/app/main-display/main-display.component.ts @@ -1,13 +1,29 @@ import { Component, OnInit } from '@angular/core'; import { EventDisplayService } from 'phoenix-ui-components'; import { Configuration, PhoenixLoader, PresetView, ClippingSetting, PhoenixMenuNode } from 'phoenix-event-display'; -import { Color, DoubleSide, Mesh, LineSegments, LineBasicMaterial, MeshPhongMaterial, Material, ObjectLoader, FrontSide, Vector3, Matrix4, REVISION, } from "three"; +import { + Color, + DoubleSide, + Mesh, + LineSegments, + LineBasicMaterial, + MeshPhongMaterial, + Material, + ObjectLoader, + FrontSide, + Vector3, + Matrix4, + REVISION, + MeshPhysicalMaterial, +} from "three"; import { PhoenixUIModule } from 'phoenix-ui-components'; import { GeometryService} from '../geometry.service'; import { Edm4hepRootEventLoader } from '../edm4hep-root-event-loader'; import { ActivatedRoute } from '@angular/router'; import {color} from "three/examples/jsm/nodes/shadernode/ShaderNode"; import {getGeoNodesByLevel} from "../utils/cern-root.utils"; +import {produceRenderOrder} from "jsrootdi/geom"; +import {wildCardCheck} from "../utils/wildcard"; interface Colorable { color: Color; @@ -72,6 +88,7 @@ export class MainDisplayComponent implements OnInit { rootObject3d.scale.setScalar(scale); } sceneGeometry.add(rootObject3d); + console.log("CERN ROOT converted to Object3d: ", rootObject3d); //rootGeometry.visible = initiallyVisible; //sceneGeometry.add(rootGeometry); @@ -93,6 +110,20 @@ export class MainDisplayComponent implements OnInit { } } + let renderer = openThreeManager.rendererManager; + + const glassMaterial = new MeshPhysicalMaterial({ + color: 0xffff00, // Yellow color + metalness: 0, + roughness: 0, + transmission: 0.7, // High transparency + opacity: 1, + transparent: true, + reflectivity: 0.5 + }); + + + // Now we want to change the materials sceneGeometry.traverse( (child: any) => { @@ -128,6 +159,26 @@ export class MainDisplayComponent implements OnInit { clipShadows: false }); + // Material + let name:string = child.name; + + + if(name.startsWith("bar_") || name.startsWith("prism_")) { + child.material = glassMaterial; + } + + if(! child.material?.clippingPlanes !== undefined) { + child.material.clippingPlanes = openThreeManager.clipPlanes; + } + + if(! child.material?.clipIntersection !== undefined) { + child.material.clipIntersection = true; + } + + if(! child.material?.clipShadows !== undefined) { + child.material.clipShadows = false; + } + // if (!(child instanceof Mesh)) { // return; // } @@ -156,6 +207,10 @@ export class MainDisplayComponent implements OnInit { // child.material.clipShadows = false; }); + let scene = threeManager.getSceneManager().getScene(); + let camera = openThreeManager.controlsManager.getMainCamera(); + produceRenderOrder(scene, camera.position, 'dflt'); + } ngOnInit() {