This commit is contained in:
barsdeveloper
2021-10-09 22:11:11 +02:00
parent 4406b4abe7
commit 84606486c4
15 changed files with 40 additions and 40 deletions

22
js/input/Pointing.js Normal file
View File

@@ -0,0 +1,22 @@
import Utility from "../Utility"
export default class Pointing {
constructor(target, blueprint, options) {
/** @type {HTMLElement} */
this.target = target
/** @type {import("../UEBlueprint").EBlueprint}" */
this.blueprint = blueprint
this.movementSpace = this.blueprint?.getGridDOMElement() ?? document.documentElement
}
getLocation(mouseEvent) {
const scaleCorrection = 1 / Utility.getScale(this.target)
const targetOffset = this.movementSpace.getBoundingClientRect()
let location = [
(mouseEvent.clientX - targetOffset.x) * scaleCorrection,
(mouseEvent.clientY - targetOffset.y) * scaleCorrection
]
return location
}
}