added basic WA.camera commands

This commit is contained in:
Hanusiak Piotr 2021-12-16 13:41:28 +01:00
parent 99ffb7b450
commit 5f26a39a5d
9 changed files with 112 additions and 4 deletions

View file

@ -17,6 +17,27 @@ export class WorkAdventureCameraCommands extends IframeApiContribution<WorkAdven
}),
];
public setPosition(x: number, y: number, width: number, height: number, smooth: boolean = false): void {
sendToWorkadventure({
type: "cameraSetPosition",
data: { x, y, width, height, smooth },
});
}
public focusOn(x: number, y: number, width: number, height: number, smooth: boolean = false): void {
sendToWorkadventure({
type: "cameraFocusOn",
data: { x, y, width, height, smooth },
});
}
public followPlayer(smooth: boolean = false): void {
sendToWorkadventure({
type: "cameraFollowPlayer",
data: { smooth },
});
}
onCameraUpdate(callback: WasCameraUpdatedEventCallback): void {
moveStream.subscribe(callback);
sendToWorkadventure({