@3dsource/angular-unreal-module 0.0.84-dev.0 → 0.0.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,7 +3,7 @@ import { InjectionToken, inject, Injectable, signal, makeEnvironmentProviders, p
|
|
|
3
3
|
import { filter, withLatestFrom, distinctUntilChanged, switchMap, catchError, timeout, tap, map as map$1, takeUntil, exhaustMap, debounceTime, takeWhile, delay, skip as skip$1 } from 'rxjs/operators';
|
|
4
4
|
import { createAction, props, Store, provideState, createReducer, on, createFeature, createSelector } from '@ngrx/store';
|
|
5
5
|
import { Actions, ofType, provideEffects, createEffect } from '@ngrx/effects';
|
|
6
|
-
import { skip, share, merge, Subject, interval, of, map, from, take, fromEvent, timer, throwError, defer, Observable, switchMap as switchMap$1, retry, timeout as timeout$1, tap as tap$1, startWith,
|
|
6
|
+
import { skip, share, merge, Subject, interval, of, map, from, take, fromEvent, timer, throwError, defer, Observable, switchMap as switchMap$1, retry, timeout as timeout$1, tap as tap$1, startWith, takeUntil as takeUntil$1, auditTime, EMPTY, debounceTime as debounceTime$1, mergeMap, scan, concatMap, animationFrameScheduler, BehaviorSubject, combineLatestWith, distinctUntilChanged as distinctUntilChanged$1, concat } from 'rxjs';
|
|
7
7
|
import { Falsy, Truthy, Logger, calculateMedian, clampf, Signal, tapLog, generateUuid, COLOR_CODES, where, KeyboardNumericCode, InvertedKeyMap, Semaphore, lerp, getCanvasCached, getSnapshot, whereNot, HEXtoRGB, RGBtoHSV, inverseLerp, HSVtoRGB, RGBtoHEX, fpIsASameAsB, fitIntoRectangle } from '@3dsource/utils';
|
|
8
8
|
import { HttpClient } from '@angular/common/http';
|
|
9
9
|
import { DialogRef, DIALOG_DATA, Dialog } from '@angular/cdk/dialog';
|
|
@@ -1626,8 +1626,7 @@ class WebRtcPlayerService extends SubService {
|
|
|
1626
1626
|
this.dcClient?.send(data);
|
|
1627
1627
|
}
|
|
1628
1628
|
else {
|
|
1629
|
-
|
|
1630
|
-
throw new Error(error);
|
|
1629
|
+
Logger.colored('black', 'yellow', `DataChannel connection not prepared or in state: ${this.dcClient?.readyState}`);
|
|
1631
1630
|
}
|
|
1632
1631
|
}
|
|
1633
1632
|
setConfig(parOptions = {}) {
|
|
@@ -2339,6 +2338,9 @@ class TouchEmulator {
|
|
|
2339
2338
|
this.host.emitMouseWheel(this.delta, center.x, center.y);
|
|
2340
2339
|
}
|
|
2341
2340
|
registerTouchEvents(playerElement) {
|
|
2341
|
+
if (!playerElement) {
|
|
2342
|
+
return;
|
|
2343
|
+
}
|
|
2342
2344
|
let finger;
|
|
2343
2345
|
fromEvent(playerElement, 'touchstart', {
|
|
2344
2346
|
passive: false,
|
|
@@ -2426,14 +2428,12 @@ class UnrealCommunicatorService {
|
|
|
2426
2428
|
this.commandTelemetryService = inject(CommandTelemetryService);
|
|
2427
2429
|
this.freezeFrameService = inject(FreezeFrameService);
|
|
2428
2430
|
this.webRtcPlayerService = inject(WebRtcPlayerService);
|
|
2429
|
-
this.inputService = inject(InputService);
|
|
2430
2431
|
this.videoService = inject(VideoService);
|
|
2431
2432
|
this.destroy$ = new Subject();
|
|
2432
2433
|
this.cirrusConnected = this.store.selectSignal(unrealFeature.selectCirrusConnected);
|
|
2433
2434
|
this.init();
|
|
2434
2435
|
}
|
|
2435
2436
|
init() {
|
|
2436
|
-
this.inputService.useKeyboardKeys(this.inputService.defaultKeys);
|
|
2437
2437
|
this.emitUIInteraction = this.commandTelemetryService.decorate(this.emitUIInteraction.bind(this));
|
|
2438
2438
|
this.listenVideo();
|
|
2439
2439
|
this.store
|
|
@@ -2541,6 +2541,7 @@ class InputService extends SubService {
|
|
|
2541
2541
|
super();
|
|
2542
2542
|
this.commandsSender = inject(UnrealCommunicatorService);
|
|
2543
2543
|
this.isDevMode = inject(DevModeService).isDevMode;
|
|
2544
|
+
this.videoService = inject(VideoService);
|
|
2544
2545
|
this.defaultKeys = [
|
|
2545
2546
|
KeyboardNumericCode.KeyW,
|
|
2546
2547
|
KeyboardNumericCode.KeyS,
|
|
@@ -2577,18 +2578,21 @@ class InputService extends SubService {
|
|
|
2577
2578
|
const visibilityHiddenTrigger$ = fromEvent(document, 'visibilitychange').pipe(map$1(() => document.visibilityState === 'hidden'), filter(Truthy));
|
|
2578
2579
|
const visibilityVisibleTrigger$ = fromEvent(document, 'visibilitychange').pipe(map$1(() => document.visibilityState === 'visible'), filter(Truthy), startWith(true));
|
|
2579
2580
|
this.deactivatedVideoTrigger$ = merge(this.disconnect$, this.reInit$, visibilityHiddenTrigger$);
|
|
2580
|
-
|
|
2581
|
-
.pipe(combineLatestWith(visibilityVisibleTrigger$, this.store
|
|
2582
|
-
.select(unrealFeature.selectViewportReady)
|
|
2583
|
-
.pipe(filter(Truthy), startWith(true))), filter(([video]) => !!video))
|
|
2584
|
-
.subscribe(([video]) => this.setup(video));
|
|
2581
|
+
merge(visibilityVisibleTrigger$, this.store.select(unrealFeature.selectViewportReady).pipe(filter(Truthy))).subscribe(() => this.setup());
|
|
2585
2582
|
}
|
|
2586
2583
|
useKeyboardKeys(keys) {
|
|
2587
2584
|
this.availableKeys = keys || [];
|
|
2588
2585
|
}
|
|
2589
|
-
|
|
2586
|
+
get video() {
|
|
2587
|
+
return this.videoService.video;
|
|
2588
|
+
}
|
|
2589
|
+
setup() {
|
|
2590
|
+
const video = this.video;
|
|
2591
|
+
if (!video) {
|
|
2592
|
+
return;
|
|
2593
|
+
}
|
|
2594
|
+
Logger.log('DEBUG: video initialized: ', video);
|
|
2590
2595
|
this.options = InputOptions;
|
|
2591
|
-
this.video = video;
|
|
2592
2596
|
this.reInit$.next();
|
|
2593
2597
|
merge(fromResizeObserver(video), fromSignal(UnrealInternalSignalEvents.VideoAdaptedToContainer))
|
|
2594
2598
|
.pipe(debounceTime(300), takeUntil$1(this.deactivatedVideoTrigger$))
|
|
@@ -2596,7 +2600,7 @@ class InputService extends SubService {
|
|
|
2596
2600
|
this.setupNormalizeAndQuantize(video);
|
|
2597
2601
|
});
|
|
2598
2602
|
this.setupNormalizeAndQuantize(video);
|
|
2599
|
-
this.registerInputs();
|
|
2603
|
+
this.registerInputs(video);
|
|
2600
2604
|
}
|
|
2601
2605
|
/**
|
|
2602
2606
|
* We use `object-fit: cover` on the video element. Since the video can have
|
|
@@ -2694,20 +2698,20 @@ class InputService extends SubService {
|
|
|
2694
2698
|
sendInputData(data) {
|
|
2695
2699
|
this.commandsSender.sendInputData(data);
|
|
2696
2700
|
}
|
|
2697
|
-
registerInputs() {
|
|
2701
|
+
registerInputs(video) {
|
|
2698
2702
|
merge(this.store
|
|
2699
2703
|
.select(unrealFeature.selectLowBandwidth)
|
|
2700
2704
|
.pipe(distinctUntilChanged(), filter(Truthy)), fromEvent(window, 'blur'))
|
|
2701
|
-
.pipe(filter(() => !!
|
|
2705
|
+
.pipe(filter(() => !!video), takeUntil$1(this.deactivatedVideoTrigger$))
|
|
2702
2706
|
.subscribe(() => this.releaseMouseButtons(255, 0, 0));
|
|
2703
|
-
this.registerMouseEnterAndLeaveEvents(
|
|
2704
|
-
this.registerHoveringMouseEvents(
|
|
2707
|
+
this.registerMouseEnterAndLeaveEvents(video);
|
|
2708
|
+
this.registerHoveringMouseEvents(video);
|
|
2705
2709
|
this.registerKeyboardEvents(this.availableKeys);
|
|
2706
2710
|
if (InputOptions.fakeMouseWithTouches) {
|
|
2707
2711
|
new TouchEmulator(this);
|
|
2708
2712
|
}
|
|
2709
2713
|
else {
|
|
2710
|
-
this.registerTouchEvents(
|
|
2714
|
+
this.registerTouchEvents(video);
|
|
2711
2715
|
}
|
|
2712
2716
|
}
|
|
2713
2717
|
getTouchPositionWithOffset({ clientX, clientY }) {
|
|
@@ -2730,7 +2734,7 @@ class InputService extends SubService {
|
|
|
2730
2734
|
const rememberTouch = (touch) => {
|
|
2731
2735
|
const finger = this.fingers.pop();
|
|
2732
2736
|
if (finger === undefined) {
|
|
2733
|
-
Logger.info('exhausted touch
|
|
2737
|
+
Logger.info('exhausted touch identifiers');
|
|
2734
2738
|
return;
|
|
2735
2739
|
}
|
|
2736
2740
|
this.fingerIds.set(touch.identifier, finger);
|
|
@@ -2761,7 +2765,7 @@ class InputService extends SubService {
|
|
|
2761
2765
|
byte += 2;
|
|
2762
2766
|
data.setUint8(byte, this.fingerIds.get(touch.identifier));
|
|
2763
2767
|
byte += 1;
|
|
2764
|
-
// force is between 0.0 and 1.0 so quantize into byte.
|
|
2768
|
+
// force is between 0.0 and 1.0, so quantize into byte.
|
|
2765
2769
|
// iOs bug: Forced to be always 0.5 on all devices as we do not use forced touch any way;/
|
|
2766
2770
|
data.setUint8(byte, this.maxByteValue * 0.5);
|
|
2767
2771
|
byte += 1;
|
|
@@ -2899,9 +2903,9 @@ class InputService extends SubService {
|
|
|
2899
2903
|
this.emitMouseUp(e.button, x, y);
|
|
2900
2904
|
e.preventDefault();
|
|
2901
2905
|
};
|
|
2902
|
-
// When the context menu is shown then it is safest to release the button
|
|
2903
|
-
//
|
|
2904
|
-
// get at least one mouse up corresponding to a mouse down event. Otherwise
|
|
2906
|
+
// When the context menu is shown, then it is safest to release the button
|
|
2907
|
+
// pressed when the event happened. This will guarantee we will
|
|
2908
|
+
// get at least one mouse up corresponding to a mouse down event. Otherwise,
|
|
2905
2909
|
// the mouse can get stuck.
|
|
2906
2910
|
// https://github.com/facebook/react/issues/5531
|
|
2907
2911
|
// playerElement.oncontextmenu = (e) => {
|
|
@@ -2984,7 +2988,7 @@ class InputService extends SubService {
|
|
|
2984
2988
|
this.getKeyCode(e),
|
|
2985
2989
|
Number(e.repeat),
|
|
2986
2990
|
]).buffer);
|
|
2987
|
-
// Backspace is not considered a keypress in JavaScript but we need it
|
|
2991
|
+
// Backspace is not considered a keypress in JavaScript, but we need it
|
|
2988
2992
|
// to be so characters may be deleted in a UE4 text entry field.
|
|
2989
2993
|
if (e.keyCode === SpecialKeyCodes.BackSpace) {
|
|
2990
2994
|
document.onkeypress({
|
|
@@ -3395,6 +3399,7 @@ function provideAngularUnrealModule(config) {
|
|
|
3395
3399
|
},
|
|
3396
3400
|
provideEnvironmentInitializer(() => {
|
|
3397
3401
|
inject(AggregatorService);
|
|
3402
|
+
inject(InputService);
|
|
3398
3403
|
inject(StreamStatusTelemetryService);
|
|
3399
3404
|
inject(ConsoleExtensionsService);
|
|
3400
3405
|
inject(AFKService);
|