Doodle3D-Core/src/d2/tools/TextTool.js
2017-11-15 15:13:49 +01:00

20 lines
598 B
JavaScript

import BaseTool from './BaseTool.js';
import * as actions from '../../actions/index.js';
export default class TextTool extends BaseTool {
constructor(dispatch, sceneSpaceContainer, renderRequest) {
super(dispatch, sceneSpaceContainer, renderRequest);
this.enableHitDetection = true;
}
tap({ position, intersections }) {
const textId = intersections.find(id => this.state.objectsById[id].type === 'TEXT');
this._dispatch(actions.d2textInit, position, textId);
}
update(state) {
if (state === this.state) return;
super.update(state);
this.state = state;
}
}