-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
packages/phoenix-ng/projects/phoenix-app/src/assets/icons/ar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
packages/phoenix-ng/projects/phoenix-ui-components/src/assets/icons/ar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
.../projects/phoenix-ui-components/src/components/ui-menu/ar-toggle/ar-toggle.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<app-menu-toggle | ||
[disabled]="!arSupported" | ||
[active]="arActive" | ||
icon="ar" | ||
(click)="arSupported && toggleAr()" | ||
[tooltip]=" | ||
arSupported ? (arActive ? 'Exit AR' : 'Enter AR') : 'AR not supported' | ||
" | ||
> | ||
</app-menu-toggle> |
Empty file.
25 changes: 25 additions & 0 deletions
25
...ojects/phoenix-ui-components/src/components/ui-menu/ar-toggle/ar-toggle.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ArToggleComponent } from './ar-toggle.component'; | ||
|
||
describe('ArToggleComponent', () => { | ||
let component: ArToggleComponent; | ||
let fixture: ComponentFixture<ArToggleComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ ArToggleComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ArToggleComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
41 changes: 41 additions & 0 deletions
41
...ng/projects/phoenix-ui-components/src/components/ui-menu/ar-toggle/ar-toggle.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Component } from '@angular/core'; | ||
import { EventDisplayService } from '../../../services/event-display.service'; | ||
import { ARManager } from 'phoenix-event-display'; | ||
|
||
@Component({ | ||
selector: 'app-ar-toggle', | ||
templateUrl: './ar-toggle.component.html', | ||
styleUrls: ['./ar-toggle.component.scss'], | ||
}) | ||
export class ArToggleComponent { | ||
arSupported: boolean = false; | ||
arActive: boolean = false; | ||
|
||
constructor(private eventDisplay: EventDisplayService) { | ||
// NOTE: WebXR needs secure HTTPS context | ||
if ('xr' in navigator) { | ||
(navigator as any)?.xr | ||
?.isSessionSupported?.(ARManager.SESSION_TYPE) | ||
.then((supported: boolean) => { | ||
if (supported) { | ||
this.arSupported = true; | ||
} | ||
}); | ||
} // else AR not supported | ||
} | ||
|
||
toggleAr() { | ||
// If toggling AR on | ||
if (!this.arActive) { | ||
this.eventDisplay.initAR(() => { | ||
this.arActive = false; | ||
// Disable renderer XR and remove animation loop | ||
this.eventDisplay.endAR(); | ||
}); | ||
this.arActive = true; | ||
} else { | ||
this.eventDisplay.endAR(); | ||
this.arActive = false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters