import {Factory, ParentEvent, GframeModule} from '@g.frame/core'; import {Object3D} from 'three'; import {InputComponent} from './InputComponent'; import {IInputComponentOptions} from './interfaces'; import {InputManager} from '@g.frame/input'; import {ActionController} from '@g.frame/common.action_controller'; export class InputComponentFactory extends Factory { __constructor: typeof InputComponent = InputComponent; private components: Array; private actionController: ActionController; private inputManager: InputManager; constructor() { super(); this.components = []; } setActionController(actionController: ActionController) { this.actionController = actionController; } setInputManager(inputManager: InputManager) { this.inputManager = inputManager; } get(params: IInputComponentOptions): InputComponent { const component = new InputComponent(params, this.actionController, this.inputManager); this.components.push(component); component.on('dispose', (event: ParentEvent) => this.onDispose(component, event.data.disposedObject)); return component; } onDispose(component: InputComponent, disposedObject: Object3D | GframeModule) { if (disposedObject === component) this.components.splice(this.components.indexOf(component), 1); } update(params: any): any { } }