Adds the camera to available APIs with retrieving of the worldView

This commit is contained in:
Benedicte Quimbert 2021-11-23 16:51:39 +01:00
parent 99dfd77600
commit 5b6a8ca4d7
9 changed files with 86 additions and 7 deletions

View file

@ -0,0 +1,29 @@
import { IframeApiContribution, sendToWorkadventure } from "./IframeApiContribution";
import { Subject } from "rxjs";
import type { HasCameraMovedEvent, HasCameraMovedEventCallback } from "../Events/HasCameraMovedEvent";
import { apiCallback } from "./registeredCallbacks";
import { isHasCameraMovedEvent } from "../Events/HasCameraMovedEvent";
const moveStream = new Subject<HasCameraMovedEvent>();
export class WorkAdventureCameraCommands extends IframeApiContribution<WorkAdventureCameraCommands> {
callbacks = [
apiCallback({
type: "hasCameraMoved",
typeChecker: isHasCameraMovedEvent,
callback: (payloadData) => {
moveStream.next(payloadData);
},
}),
];
onCameraMove(callback: HasCameraMovedEventCallback): void {
moveStream.subscribe(callback);
sendToWorkadventure({
type: "onCameraMove",
data: null,
});
}
}
export default new WorkAdventureCameraCommands();