feat(editor): allow laser-pointing in view mode (#10802)
* feat(editor): allow laser pointing in view mode * feat: allow switching between laser/hand in view mode * fix lint * factor out to utils * fix: only handle primary clicks with the selection/laser tools
This commit is contained in:
@@ -8,6 +8,8 @@ import type {
|
||||
Radians,
|
||||
Degrees,
|
||||
Vector,
|
||||
GlobalCoord,
|
||||
LocalCoord,
|
||||
} from "./types";
|
||||
|
||||
/**
|
||||
@@ -20,8 +22,23 @@ import type {
|
||||
export function pointFrom<Point extends GlobalPoint | LocalPoint>(
|
||||
x: number,
|
||||
y: number,
|
||||
): Point;
|
||||
// TODO remove the overload once we migrate to using Point tuples everywhere
|
||||
export function pointFrom<Coord extends GlobalCoord | LocalCoord>(
|
||||
coords: Coord,
|
||||
): Coord extends GlobalCoord ? GlobalPoint : LocalPoint;
|
||||
// TODO remove the overload once we migrate to using Point tuples everywhere
|
||||
export function pointFrom<Point extends GlobalPoint | LocalPoint>(coords: {
|
||||
x: number;
|
||||
y: number;
|
||||
}): Point;
|
||||
export function pointFrom<Point extends GlobalPoint | LocalPoint>(
|
||||
xOrCoords: number | { x: number; y: number },
|
||||
y?: number,
|
||||
): Point {
|
||||
return [x, y] as Point;
|
||||
return typeof xOrCoords === "object"
|
||||
? ([xOrCoords.x, xOrCoords.y] as Point)
|
||||
: ([xOrCoords, y!] as Point);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,13 +28,23 @@ export type InclusiveRange = [number, number] & { _brand: "excalimath_degree" };
|
||||
//
|
||||
|
||||
/**
|
||||
* Represents a 2D position in world or canvas space. A
|
||||
* Represents a 2D position in world/canvas/scene space. A
|
||||
* global coordinate.
|
||||
*/
|
||||
export type GlobalPoint = [x: number, y: number] & {
|
||||
_brand: "excalimath__globalpoint";
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a 2D position in world/canvas/scene space. A
|
||||
* global coordinate.
|
||||
*
|
||||
* TODO remove this once we migrate the codebase to use Point tuples everywhere
|
||||
*/
|
||||
export type GlobalCoord = { x: number; y: number } & {
|
||||
_brand: "excalimath__globalcoord";
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a 2D position in whatever local space it's
|
||||
* needed. A local coordinate.
|
||||
@@ -43,6 +53,16 @@ export type LocalPoint = [x: number, y: number] & {
|
||||
_brand: "excalimath__localpoint";
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a 2D position in whatever local space it's needed.
|
||||
* A local coordinate.
|
||||
*
|
||||
* TODO remove this once we migrate the codebase to use Point tuples everywhere
|
||||
*/
|
||||
export type LocalCoord = { x: number; y: number } & {
|
||||
_brand: "excalimath__localcoord";
|
||||
};
|
||||
|
||||
// Line
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user