diff --git a/client/src/util/camera.ts b/client/src/util/camera.ts index 6df7d644..d525024c 100644 --- a/client/src/util/camera.ts +++ b/client/src/util/camera.ts @@ -11,30 +11,28 @@ const panBound = 0.8; const scratch0 = new Float32Array(16); const scratch1 = new Float32Array(16); -// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS. -function clamp(val: any, rng: any) { +function clamp(val: number, rng: Array) { return Math.max(Math.min(val, rng[1]), rng[0]); } class Camera { - // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS. canvas: any; - // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS. - prevEvent: any; + prevEvent: { + clientX: number; + clientY: number; + type: string; + }; - // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS. - viewMatrix: any; + viewMatrix: mat3; - // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS. - viewMatrixInv: any; + viewMatrixInv: mat3; - // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS. - constructor(canvas: any) { + constructor(canvas: HTMLCanvasElement) { this.prevEvent = { clientX: 0, clientY: 0, - type: 0, + type: "", }; this.canvas = canvas; this.viewMatrix = mat3.create(); @@ -53,8 +51,7 @@ class Camera { return this.viewMatrix[0]; } - // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS. - pan(dx: any, dy: any) { + pan(dx: number, dy: number) { const m = this.viewMatrix; const dyRange = [ -panBound - (m[7] + 1) / m[4], @@ -74,8 +71,7 @@ class Camera { mat3.invert(this.viewMatrixInv, m); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS. - zoomAt(d: any, x = 0, y = 0) { + zoomAt(d: number, x = 0, y = 0) { /* Camera zoom at [x,y] */ @@ -98,15 +94,18 @@ class Camera { Event handling */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS. - flush(e: any) { + flush(e: MouseEvent) { this.prevEvent.type = e.type; this.prevEvent.clientX = e.clientX; this.prevEvent.clientY = e.clientY; } - // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS. - localPosition(target: any, canvasX: any, canvasY: any, projectionInvTF: any) { + localPosition( + target: HTMLCanvasElement, + canvasX: number, + canvasY: number, + projectionInvTF: mat3 + ) { /* Convert mouse position to local */ @@ -126,8 +125,7 @@ class Camera { return pos; } - // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS. - mousePan(e: any, projectionTF: any) { + mousePan(e: MouseEvent, projectionTF: mat3) { const projectionInvTF = mat3.invert(scratch0, projectionTF); const pos = this.localPosition( this.canvas, @@ -147,8 +145,7 @@ class Camera { return true; } - // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS. - wheelZoom(e: any, projectionTF: any) { + wheelZoom(e: WheelEvent, projectionTF: mat3) { const { height } = this.canvas; const { deltaY, deltaMode, clientX, clientY } = e; const scale = scaleSpeed * (deltaMode === 1 ? 12 : 1) * (deltaY || 0); @@ -164,8 +161,7 @@ class Camera { return true; } - // eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS. - handleEvent(e: any, projectionTF: any) { + handleEvent(e: MouseEvent, projectionTF: any) { /* process the event, and return true if camera view changed */ @@ -194,8 +190,7 @@ class Camera { } } -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS. -function attachCamera(canvas: any) { +function attachCamera(canvas: HTMLCanvasElement) { return new Camera(canvas); }