UNPKG

cursor-style-manager-wle

Version:

Shared cursor styles for Wonderland Engine

48 lines 1.46 kB
import { Component, Type } from '@wonderlandengine/api'; /** * A Wonderland Engine component that uses a cursor style manager */ class CSMComponent extends Component { init() { if (this.cursorStyleManagerObject) { this.cursorStyleManager = this.cursorStyleManagerObject.getComponent(this.cursorStyleManagerName); } else { this.cursorStyleManager = null; } } setCursorStyle(style, key) { if (this.cursorStyleManager) { if (key === undefined) { key = this; } if (style) { this.cursorStyleManager.setStyle(this, style); } else { this.cursorStyleManager.clearStyle(this); } } else { if (style) { this.engine.canvas.style.cursor = style; } else { this.engine.canvas.style.cursor = 'default'; } } } onDeactivate() { if (this.cursorStyleManager) { this.cursorStyleManager.clearStyle(this); } } } CSMComponent.Properties = { /** Object with cursor style manager */ cursorStyleManagerObject: { type: Type.Object }, /** Component name for cursor style manager */ cursorStyleManagerName: { type: Type.String, default: 'cursor-style-manager' }, }; export { CSMComponent }; //# sourceMappingURL=CSMComponent.js.map