@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
57 lines (39 loc) • 1.4 kB
JavaScript
import { makeOrbitalCameraController } from "../../src/engine/graphics/camera/makeOrbitalCameraController.js";
import TopDownCameraControllerSystem
from "../../src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js";
import EditorEntity from "../ecs/EditorEntity.js";
import Tool from './engine/Tool.js';
class TopDownCameraControlTool extends Tool {
constructor() {
super();
this.name = "camera_control";
this.system = null;
/**
*
* @type {Entity}
* @private
*/
this.__controller = null;
}
initialize() {
super.initialize();
const engine = this.engine;
const editor = this.editor;
const em = engine.entityManager;
this.system = em.getSystem(TopDownCameraControllerSystem);
this.system.enabled.set(true);
const ecd = em.dataset;
this.__controller = makeOrbitalCameraController({
ecd: ecd,
camera_entity: editor.cameraEntity.id,
dom_element: engine.graphics.domElement
});
this.__controller.add(new EditorEntity());
this.__controller.build(ecd);
}
finalize() {
this.system.enabled.set(false);
this.__controller.destroy();
}
}
export default TopDownCameraControlTool;