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:
David Luzar
2026-02-20 22:49:46 +01:00
committed by GitHub
parent 4c3d037f9c
commit eb959128ac
12 changed files with 287 additions and 147 deletions
+18 -1
View File
@@ -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);
}
/**
+21 -1
View File
@@ -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
/**