132 lines
3.8 KiB
JavaScript
132 lines
3.8 KiB
JavaScript
'use strict';
|
|
|
|
var Point = require('../maths/point/Point.js');
|
|
var FederatedEvent = require('./FederatedEvent.js');
|
|
|
|
"use strict";
|
|
class FederatedMouseEvent extends FederatedEvent.FederatedEvent {
|
|
constructor() {
|
|
super(...arguments);
|
|
/** The coordinates of the mouse event relative to the canvas. */
|
|
this.client = new Point.Point();
|
|
/** The movement in this pointer relative to the last `mousemove` event. */
|
|
this.movement = new Point.Point();
|
|
/** The offset of the pointer coordinates w.r.t. target Container in world space. This is not supported at the moment. */
|
|
this.offset = new Point.Point();
|
|
/** The pointer coordinates in world space. */
|
|
this.global = new Point.Point();
|
|
/**
|
|
* The pointer coordinates in the renderer's {@link Renderer.screen screen}. This has slightly
|
|
* different semantics than native PointerEvent screenX/screenY.
|
|
*/
|
|
this.screen = new Point.Point();
|
|
}
|
|
/** @readonly */
|
|
get clientX() {
|
|
return this.client.x;
|
|
}
|
|
/** @readonly */
|
|
get clientY() {
|
|
return this.client.y;
|
|
}
|
|
/**
|
|
* Alias for {@link FederatedMouseEvent.clientX this.clientX}.
|
|
* @readonly
|
|
*/
|
|
get x() {
|
|
return this.clientX;
|
|
}
|
|
/**
|
|
* Alias for {@link FederatedMouseEvent.clientY this.clientY}.
|
|
* @readonly
|
|
*/
|
|
get y() {
|
|
return this.clientY;
|
|
}
|
|
/** @readonly */
|
|
get movementX() {
|
|
return this.movement.x;
|
|
}
|
|
/** @readonly */
|
|
get movementY() {
|
|
return this.movement.y;
|
|
}
|
|
/** @readonly */
|
|
get offsetX() {
|
|
return this.offset.x;
|
|
}
|
|
/** @readonly */
|
|
get offsetY() {
|
|
return this.offset.y;
|
|
}
|
|
/** @readonly */
|
|
get globalX() {
|
|
return this.global.x;
|
|
}
|
|
/** @readonly */
|
|
get globalY() {
|
|
return this.global.y;
|
|
}
|
|
/**
|
|
* The pointer coordinates in the renderer's screen. Alias for {@code screen.x}.
|
|
* @readonly
|
|
*/
|
|
get screenX() {
|
|
return this.screen.x;
|
|
}
|
|
/**
|
|
* The pointer coordinates in the renderer's screen. Alias for {@code screen.y}.
|
|
* @readonly
|
|
*/
|
|
get screenY() {
|
|
return this.screen.y;
|
|
}
|
|
/**
|
|
* This will return the local coordinates of the specified container for this InteractionData
|
|
* @param {Container} container - The Container that you would like the local
|
|
* coords off
|
|
* @param {PointData} point - A Point object in which to store the value, optional (otherwise
|
|
* will create a new point)
|
|
* @param {PointData} globalPos - A Point object containing your custom global coords, optional
|
|
* (otherwise will use the current global coords)
|
|
* @returns - A point containing the coordinates of the InteractionData position relative
|
|
* to the Container
|
|
*/
|
|
getLocalPosition(container, point, globalPos) {
|
|
return container.worldTransform.applyInverse(globalPos || this.global, point);
|
|
}
|
|
/**
|
|
* Whether the modifier key was pressed when this event natively occurred.
|
|
* @param key - The modifier key.
|
|
*/
|
|
getModifierState(key) {
|
|
return "getModifierState" in this.nativeEvent && this.nativeEvent.getModifierState(key);
|
|
}
|
|
/**
|
|
* Not supported.
|
|
* @param _typeArg
|
|
* @param _canBubbleArg
|
|
* @param _cancelableArg
|
|
* @param _viewArg
|
|
* @param _detailArg
|
|
* @param _screenXArg
|
|
* @param _screenYArg
|
|
* @param _clientXArg
|
|
* @param _clientYArg
|
|
* @param _ctrlKeyArg
|
|
* @param _altKeyArg
|
|
* @param _shiftKeyArg
|
|
* @param _metaKeyArg
|
|
* @param _buttonArg
|
|
* @param _relatedTargetArg
|
|
* @deprecated since 7.0.0
|
|
*/
|
|
// eslint-disable-next-line max-params
|
|
initMouseEvent(_typeArg, _canBubbleArg, _cancelableArg, _viewArg, _detailArg, _screenXArg, _screenYArg, _clientXArg, _clientYArg, _ctrlKeyArg, _altKeyArg, _shiftKeyArg, _metaKeyArg, _buttonArg, _relatedTargetArg) {
|
|
throw new Error("Method not implemented.");
|
|
}
|
|
}
|
|
|
|
exports.FederatedMouseEvent = FederatedMouseEvent;
|
|
//# sourceMappingURL=FederatedMouseEvent.js.map
|