@netless/window-manager 0.4.0-canary.32 → 0.4.0-canary.33
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.
- package/dist/AppListener.d.ts +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/index.es.js +3 -3
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/AppListener.ts +13 -2
- package/src/constants.ts +1 -0
- package/src/index.ts +9 -2
package/package.json
CHANGED
package/src/AppListener.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import { callbacks, emitter } from "./index";
|
2
2
|
import { Events, MagixEventName } from "./constants";
|
3
|
+
import { isEqual, omit } from "lodash";
|
3
4
|
import { setViewFocusScenePath } from "./Utils/Common";
|
4
|
-
import type { Event } from "white-web-sdk";
|
5
|
+
import type { AnimationMode, Camera, Event } from "white-web-sdk";
|
5
6
|
import type { AppManager } from "./AppManager";
|
6
7
|
import type { TeleBoxState } from "@netless/telebox-insider";
|
7
|
-
|
8
8
|
export class AppListeners {
|
9
9
|
private displayer = this.manager.displayer;
|
10
10
|
|
@@ -42,6 +42,10 @@ export class AppListeners {
|
|
42
42
|
this.setMainViewScenePathHandler(data.payload);
|
43
43
|
break;
|
44
44
|
}
|
45
|
+
case Events.MoveCamera: {
|
46
|
+
this.moveCameraHandler(data.payload);
|
47
|
+
break;
|
48
|
+
}
|
45
49
|
case Events.MoveCameraToContain: {
|
46
50
|
this.moveCameraToContainHandler(data.payload);
|
47
51
|
break;
|
@@ -74,6 +78,13 @@ export class AppListeners {
|
|
74
78
|
callbacks.emit("mainViewScenePathChange", nextScenePath);
|
75
79
|
};
|
76
80
|
|
81
|
+
private moveCameraHandler = (
|
82
|
+
payload: Camera & { animationMode?: AnimationMode | undefined }
|
83
|
+
) => {
|
84
|
+
if (isEqual(omit(payload, ["animationMode"]), { ...this.manager.mainView.camera })) return;
|
85
|
+
this.manager.mainView.moveCamera(payload);
|
86
|
+
};
|
87
|
+
|
77
88
|
private moveCameraToContainHandler = (payload: any) => {
|
78
89
|
this.manager.mainView.moveCameraToContain(payload);
|
79
90
|
};
|
package/src/constants.ts
CHANGED
@@ -10,6 +10,7 @@ export enum Events {
|
|
10
10
|
SetMainViewScenePath = "SetMainViewScenePath",
|
11
11
|
SetMainViewSceneIndex = "SetMainViewSceneIndex",
|
12
12
|
SwitchViewsToFreedom = "SwitchViewsToFreedom",
|
13
|
+
MoveCamera = "MoveCamera",
|
13
14
|
MoveCameraToContain = "MoveCameraToContain",
|
14
15
|
CursorMove = "CursorMove",
|
15
16
|
}
|
package/src/index.ts
CHANGED
@@ -10,7 +10,7 @@ import { DEFAULT_CONTAINER_RATIO, Events } from "./constants";
|
|
10
10
|
import { Fields } from "./AttributesDelegate";
|
11
11
|
import { initDb } from "./Register/storage";
|
12
12
|
import { InvisiblePlugin, isPlayer, isRoom, RoomPhase, ViewMode } from "white-web-sdk";
|
13
|
-
import { isNull, isObject } from "lodash";
|
13
|
+
import { isEqual, isNull, isObject, omit } from "lodash";
|
14
14
|
import { log } from "./Utils/log";
|
15
15
|
import { ReconnectRefresher } from "./ReconnectRefresher";
|
16
16
|
import { replaceRoomFunction } from "./Utils/RoomHacker";
|
@@ -674,7 +674,14 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
674
674
|
public moveCamera(
|
675
675
|
camera: Partial<Camera> & { animationMode?: AnimationMode | undefined }
|
676
676
|
): void {
|
677
|
+
const pureCamera = omit(camera, ["animationMode"]);
|
678
|
+
const mainViewCamera = { ...this.mainView.camera };
|
679
|
+
if (isEqual({ ...mainViewCamera, ...pureCamera }, mainViewCamera)) return;
|
677
680
|
this.mainView.moveCamera(camera);
|
681
|
+
this.appManager?.dispatchInternalEvent(Events.MoveCamera, camera);
|
682
|
+
setTimeout(() => {
|
683
|
+
this.appManager?.mainViewProxy.setCameraAndSize();
|
684
|
+
}, 100);
|
678
685
|
}
|
679
686
|
|
680
687
|
public moveCameraToContain(
|
@@ -687,7 +694,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
687
694
|
this.appManager?.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
|
688
695
|
setTimeout(() => {
|
689
696
|
this.appManager?.mainViewProxy.setCameraAndSize();
|
690
|
-
},
|
697
|
+
}, 100);
|
691
698
|
}
|
692
699
|
|
693
700
|
public convertToPointInWorld(point: Point): Point {
|