Adds the camera to available APIs with retrieving of the worldView
This commit is contained in:
parent
d672a2dead
commit
4356767739
9 changed files with 86 additions and 7 deletions
29
front/src/Api/iframe/camera.ts
Normal file
29
front/src/Api/iframe/camera.ts
Normal 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();
|
Loading…
Add table
Add a link
Reference in a new issue