Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add window displaying control instructions #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { SidenavMenuComponent } from './components/sidenav-menu/sidenav-menu.com
import { SidenavComponent } from './components/sidenav/sidenav.component';
import { MediaTypePipe } from './pipes/media-type.pipe';
import { MarkdownPreviewComponent } from './components/markdown-preview/markdown-preview.component';
import { GuideComponent } from './components/guide/guide.component';

@NgModule({
declarations: [
Expand Down Expand Up @@ -86,6 +87,7 @@ import { MarkdownPreviewComponent } from './components/markdown-preview/markdown
EntityFeatureSettingsLightsComponent,
EntityFeatureSettingsMeshComponent,
MarkdownPreviewComponent,
GuideComponent,
],
imports: [
BrowserModule,
Expand Down
7 changes: 7 additions & 0 deletions src/app/components/guide/guide.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<img src="/assets/icons/guide/left_click_move.svg" alt="left click" />
<img src="/assets/icons/guide/scroll_wheel.svg" alt="scroll" />
<img src="/assets/icons/guide/right_click_move.svg" alt="right click" />
<p>click & hold with 1 finger or left mouse button to rotate</p>
<p>scroll mouse wheel or pinch to zoom in and out</p>
<p>click & hold with 2 fingers or right mouse button to pan</p>
<p class="dismiss">click to dismiss</p>
47 changes: 47 additions & 0 deletions src/app/components/guide/guide.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
:host {
position: absolute;
top: 50%;
left: 50%;
translate: -50% -50%;
pointer-events: none;

display: grid;
grid-template-columns: repeat(3, min(25vw, 25ch));
grid-template-rows: 1fr auto;
grid-column-gap: 1rem;
grid-row-gap: 2rem;
background-color: rgba(0, 0, 0, 0.7);
border-radius: 0.75rem;
padding: 1rem;
column-gap: 1rem;

color: white;

align-items: center;
justify-items: center;
text-align: center;

img {
max-height: 8rem;
max-width: 4rem;
}

transition-property: transform, filter, backdrop-filter;
transition-duration: 500ms;
transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
filter: opacity(0);
transform: translateY(1rem);
&.visible {
filter: opacity(1);
transform: translateY(0%);
}

p {
margin: 0;
}

p.dismiss {
grid-column: span 3;
font-weight: bold;
}
}
23 changes: 23 additions & 0 deletions src/app/components/guide/guide.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { GuideComponent } from './guide.component';

describe('GuideComponent', () => {
let component: GuideComponent;
let fixture: ComponentFixture<GuideComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ GuideComponent ]
})
.compileComponents();

fixture = TestBed.createComponent(GuideComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
33 changes: 33 additions & 0 deletions src/app/components/guide/guide.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { AfterViewInit, Component, HostBinding } from '@angular/core';
import { fromEvent } from 'rxjs';
import { LoadingscreenhandlerService } from 'src/app/services/babylon/loadingscreen';

@Component({
selector: 'app-guide',
templateUrl: './guide.component.html',
styleUrls: ['./guide.component.scss'],
})
export class GuideComponent implements AfterViewInit {
@HostBinding('class.visible')
get visible() {
return this.isVisible;
}

private isVisible = false;

constructor(private loadingScreenHandler: LoadingscreenhandlerService) {}

ngAfterViewInit(): void {
this.loadingScreenHandler.isLoading$.subscribe(isLoading => {
if (isLoading) return;

setTimeout(() => {
this.isVisible = true;
}, 1_000);
});

fromEvent(document, 'click').subscribe(() => {
this.isVisible = false;
});
}
}
1 change: 1 addition & 0 deletions src/app/components/scene/scene.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<app-annotation [annotation]="annotation"></app-annotation>
</div>
<app-annotationwalkthrough></app-annotationwalkthrough>
<app-guide></app-guide>
<app-menu *ngIf="processing.showMenu$ | async"></app-menu>
<app-sidenav-menu *ngIf="processing.showSidenav$ | async"></app-sidenav-menu>
<app-sidenav></app-sidenav>
Expand Down
21 changes: 8 additions & 13 deletions src/app/services/babylon/loadingscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ export class LoadingScreen implements ILoadingScreen {
/**
* Function called to display the loading screen
*/
public displayLoadingUI(): void {
if (!this.loadingScreenHandler.isLoading) {
public async displayLoadingUI() {
if (!(await firstValueFrom(this.loadingScreenHandler.isLoading$))) {
this.loadingScreenHandler.updateOpacity('1');
}
}

/**
* Function called to hide the loading screen
*/
public hideLoadingUI(): void {
if (this.loadingScreenHandler.isLoading) {
public async hideLoadingUI() {
if (await firstValueFrom(this.loadingScreenHandler.isLoading$)) {
// setTimeout of half a second to prevent pop-in
// of some bigger meshes
setTimeout(() => this.loadingScreenHandler.updateOpacity('0'), 500);
Expand Down Expand Up @@ -82,7 +82,7 @@ export class LoadingScreen implements ILoadingScreen {
}

import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { BehaviorSubject, firstValueFrom } from 'rxjs';

@Injectable({
providedIn: 'root',
Expand All @@ -92,6 +92,8 @@ export class LoadingscreenhandlerService {
public opacity = this.OpacitySubject.asObservable();
private TextSubject = new BehaviorSubject<string>('Loading');
public loadingText = this.TextSubject.asObservable();
private isLoading = new BehaviorSubject<boolean>(false);
public isLoading$ = this.isLoading.asObservable();

private StyleSubject = new BehaviorSubject<any>({
left: '0px',
Expand All @@ -102,18 +104,11 @@ export class LoadingscreenhandlerService {

public loadingStyle = this.StyleSubject.asObservable();

public isLoading = false;
public backgroundColor = '#111111';
public logo = 'assets/img/kompakkt-icon.png';

constructor() {}

public updateOpacity(newOpacity: string): void {
if (parseFloat(newOpacity) > 0.5) {
this.isLoading = true;
} else {
this.isLoading = false;
}
this.isLoading.next(parseFloat(newOpacity) > 0.5);
this.OpacitySubject.next(newOpacity);
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/services/processing/processing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ export class ProcessingService {

public async loadEntity(newEntity: IEntity, overrideUrl?: string) {
const baseURL = overrideUrl ?? this.baseUrl;
if (!this.loadingScreenHandler.isLoading && newEntity.processed && newEntity.mediaType) {
const isLoading = await firstValueFrom(this.loadingScreenHandler.isLoading$);
if (!isLoading && newEntity.processed && newEntity.mediaType) {
if (!newEntity.dataSource.isExternal) {
this.entityMediaType = newEntity.mediaType;
await this.initialiseEntitySettingsData(newEntity);
Expand Down
8 changes: 8 additions & 0 deletions src/assets/icons/guide/left_click_move.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/assets/icons/guide/right_click_move.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/assets/icons/guide/scroll_wheel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.