src/app/app.component.ts
changeDetection | ChangeDetectionStrategy.OnPush |
selector | ccf-root |
styleUrls | ./app.component.scss |
templateUrl | ./app.component.html |
Properties |
Outputs |
constructor(configState: GlobalConfigState<GlobalConfig>, sceneSource: FilteredSceneService, cdr: ChangeDetectorRef)
|
||||||||||||
Defined in src/app/app.component.ts:30
|
||||||||||||
Parameters :
|
onClick | |
Type : EventEmitter
|
|
Defined in src/app/app.component.ts:26
|
onMouseEnter | |
Type : EventEmitter
|
|
Defined in src/app/app.component.ts:24
|
onMouseLeave | |
Type : EventEmitter
|
|
Defined in src/app/app.component.ts:25
|
Readonly bodyUI |
Type : BodyUiComponent
|
Decorators :
@ViewChild('bodyUI', {static: true})
|
Defined in src/app/app.component.ts:22
|
Readonly data$ |
Default value : this.configState.getOption('data')
|
Defined in src/app/app.component.ts:28
|
organs$ |
Default value : this.sceneSource.filteredOrgans$
|
Defined in src/app/app.component.ts:29
|
scene$ |
Default value : this.sceneSource.filteredScene$.pipe(tap((_) => this.reset()))
|
Defined in src/app/app.component.ts:30
|
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Output, ViewChild } from '@angular/core';
import { BodyUiComponent, GlobalConfigState } from 'ccf-shared';
import { JsonLdObj } from 'jsonld/jsonld-spec';
import { lastValueFrom } from 'rxjs';
import { take, tap } from 'rxjs/operators';
import { FilteredSceneService } from './core/services/filtered-scene/filtered-scene.service';
export interface GlobalConfig {
highlightID?: string;
zoomToID?: string;
data?: JsonLdObj[];
}
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'ccf-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
@ViewChild('bodyUI', { static: true }) readonly bodyUI!: BodyUiComponent;
@Output() readonly onMouseEnter = new EventEmitter<string>();
@Output() readonly onMouseLeave = new EventEmitter<string>();
@Output() readonly onClick = new EventEmitter<string>();
readonly data$ = this.configState.getOption('data');
organs$ = this.sceneSource.filteredOrgans$;
scene$ = this.sceneSource.filteredScene$.pipe(tap((_) => this.reset()));
constructor(
private readonly configState: GlobalConfigState<GlobalConfig>,
private readonly sceneSource: FilteredSceneService,
private readonly cdr: ChangeDetectorRef,
) {}
private async reset(): Promise<void> {
const { bodyUI } = this;
await new Promise((resolve) => {
setTimeout(resolve, 200);
});
const organs = await lastValueFrom(this.organs$.pipe(take(1)));
const hasZoomingNode = !!bodyUI.scene?.find((node) => node.zoomToOnLoad) ?? false;
bodyUI.rotation = 0;
bodyUI.rotationX = 0;
if (!hasZoomingNode) {
if (organs && organs.length === 1) {
const { x_dimension: x, y_dimension: y, z_dimension: z } = organs[0];
bodyUI.bounds = {
x: (1.25 * x) / 1000,
y: (1.25 * y) / 1000,
z: (1.25 * z) / 1000,
};
bodyUI.target = [x / 1000 / 2, y / 1000 / 2, z / 1000 / 2];
} else {
bodyUI.bounds = { x: 2.2, y: 2, z: 0.4 };
bodyUI.target = [0, 0, 0];
}
}
this.cdr.detectChanges();
}
}
<ccf-body-ui
#bodyUI
[scene]="(scene$ | async) ?? []"
[interactive]="true"
camera="perspective"
class="body-ui"
(nodeClick)="onClick.emit($event)"
(nodeHoverStart)="onMouseEnter.emit($event)"
(nodeHoverStop)="onMouseLeave.emit($event)"
>
</ccf-body-ui>
./app.component.scss
.body-ui {
height: 100%;
width: 100%;
}