Skip to content

Commit

Permalink
chore: Add explicit member accessibility in eslint (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
disambiguator authored Mar 19, 2021
1 parent 88dcf38 commit 028fb4f
Show file tree
Hide file tree
Showing 23 changed files with 182 additions and 187 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"import/namespace": "off",
"import/default": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/explicit-member-accessibility": ["error", { "overrides": { "constructors": "no-public" } }],
"no-unused-vars": ["off"],
"no-var": "error",
"react/jsx-uses-react": "error",
Expand Down
18 changes: 9 additions & 9 deletions src/controls/DeviceOrientationControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { Camera, Euler, EventDispatcher, MathUtils, Quaternion, Vector3 } from '
*/

class DeviceOrientationControls extends EventDispatcher {
object: Camera
public object: Camera

private changeEvent = { type: 'change' }
private EPS = 0.000001

enabled = true
deviceOrientation: Partial<DeviceOrientationEvent> = { alpha: 0, beta: 0, gamma: 0 }
screenOrientation: string | number = 0
alphaOffset = 0 // radians
public enabled = true
public deviceOrientation: Partial<DeviceOrientationEvent> = { alpha: 0, beta: 0, gamma: 0 }
public screenOrientation: string | number = 0
public alphaOffset = 0 // radians

constructor(object: Camera) {
super()
Expand Down Expand Up @@ -51,7 +51,7 @@ class DeviceOrientationControls extends EventDispatcher {
quaternion.multiply(this.q0.setFromAxisAngle(this.zee, -orient)) // adjust for screen orientation
}

connect = (): void => {
public connect = (): void => {
this.onScreenOrientationChangeEvent() // run once on load

// iOS 13+
Expand All @@ -78,15 +78,15 @@ class DeviceOrientationControls extends EventDispatcher {
this.enabled = true
}

disconnect = (): void => {
public disconnect = (): void => {
window.removeEventListener('orientationchange', this.onScreenOrientationChangeEvent)
window.removeEventListener('deviceorientation', this.onDeviceOrientationChangeEvent)

this.enabled = false
}

private lastQuaternion = new Quaternion()
update = (): void => {
public update = (): void => {
if (this.enabled === false) return

const device = this.deviceOrientation
Expand All @@ -106,7 +106,7 @@ class DeviceOrientationControls extends EventDispatcher {
}
}

dispose = (): void => this.disconnect()
public dispose = (): void => this.disconnect()
}

export { DeviceOrientationControls }
12 changes: 6 additions & 6 deletions src/controls/DragControls.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Camera, EventDispatcher, Intersection, Matrix4, Object3D, Plane, Raycaster, Vector2, Vector3 } from 'three'

class DragControls extends EventDispatcher {
enabled = true
transformGroup = false
public enabled = true
public transformGroup = false

private _objects: Object3D[]
private _camera: Camera
Expand Down Expand Up @@ -30,7 +30,7 @@ class DragControls extends EventDispatcher {
this.activate()
}

activate = (): void => {
public activate = (): void => {
this._domElement.addEventListener('pointermove', this.onPointerMove)
this._domElement.addEventListener('pointerdown', this.onPointerDown)
this._domElement.addEventListener('pointerup', this.onPointerCancel)
Expand All @@ -40,7 +40,7 @@ class DragControls extends EventDispatcher {
this._domElement.addEventListener('touchend', this.onTouchEnd)
}

deactivate = (): void => {
public deactivate = (): void => {
this._domElement.removeEventListener('pointermove', this.onPointerMove)
this._domElement.removeEventListener('pointerdown', this.onPointerDown)
this._domElement.removeEventListener('pointerup', this.onPointerCancel)
Expand All @@ -53,9 +53,9 @@ class DragControls extends EventDispatcher {
}

// TODO: confirm if this can be removed?
dispose = (): void => this.deactivate()
public dispose = (): void => this.deactivate()

getObjects = (): Object3D[] => this._objects
public getObjects = (): Object3D[] => this._objects

private onMouseMove = (event: MouseEvent): void => {
const rect = this._domElement.getBoundingClientRect()
Expand Down
40 changes: 20 additions & 20 deletions src/controls/FirstPersonControls.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { MathUtils, Spherical, Vector3, EventDispatcher, Camera } from 'three'

class FirstPersonControls extends EventDispatcher {
object: Camera
domElement: HTMLElement | Document
public object: Camera
public domElement: HTMLElement | Document

enabled = true
public enabled = true

movementSpeed = 1.0
lookSpeed = 0.005
public movementSpeed = 1.0
public lookSpeed = 0.005

lookVertical = true
autoForward = false
public lookVertical = true
public autoForward = false

activeLook = true
public activeLook = true

heightSpeed = false
heightCoef = 1.0
heightMin = 0.0
heightMax = 1.0
public heightSpeed = false
public heightCoef = 1.0
public heightMin = 0.0
public heightMax = 1.0

constrainVertical = false
verticalMin = 0
verticalMax = Math.PI
public constrainVertical = false
public verticalMin = 0
public verticalMax = Math.PI

mouseDragOn = false
public mouseDragOn = false

// internals

Expand Down Expand Up @@ -77,7 +77,7 @@ class FirstPersonControls extends EventDispatcher {
window.addEventListener('keyup', this.onKeyUp)
}

dispose = (): void => {
public dispose = (): void => {
this.domElement.removeEventListener('contextmenu', this.contextmenu)
;(this.domElement as HTMLElement).removeEventListener('mousedown', this.onMouseDown)
;(this.domElement as HTMLElement).removeEventListener('mousemove', this.onMouseMove)
Expand All @@ -87,7 +87,7 @@ class FirstPersonControls extends EventDispatcher {
window.removeEventListener('keyup', this.onKeyUp)
}

handleResize = (): void => {
public handleResize = (): void => {
if (this.domElement instanceof Document) {
this.viewHalfX = window.innerWidth / 2
this.viewHalfY = window.innerHeight / 2
Expand Down Expand Up @@ -209,7 +209,7 @@ class FirstPersonControls extends EventDispatcher {
}
}

lookAt = (x: Vector3 | number, y?: number, z?: number): this => {
public lookAt = (x: Vector3 | number, y?: number, z?: number): this => {
if (x instanceof Vector3) {
this.target.copy(x)
} else if (y && z) {
Expand All @@ -225,7 +225,7 @@ class FirstPersonControls extends EventDispatcher {

private targetPosition = new Vector3()

update = (delta: number): void => {
public update = (delta: number): void => {
if (this.enabled === false) return

if (this.heightSpeed) {
Expand Down
12 changes: 6 additions & 6 deletions src/controls/FlyControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ function contextmenu(event: Event): void {
}

class FlyControls extends EventDispatcher {
object: Camera
domElement: HTMLElement | Document
public object: Camera
public domElement: HTMLElement | Document

movementSpeed = 1.0
rollSpeed = 0.005
public movementSpeed = 1.0
public rollSpeed = 0.005

dragToLook = false
autoForward = false
public dragToLook = false
public autoForward = false

private changeEvent = { type: 'change' }
private EPS = 0.000001
Expand Down
24 changes: 12 additions & 12 deletions src/controls/PointerLockControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Camera, Euler, EventDispatcher, Vector3 } from 'three'

class PointerLockControls extends EventDispatcher {
private camera: Camera
domElement: HTMLElement
public domElement: HTMLElement

isLocked = false
public isLocked = false

// Set to constrain the pitch of the camera
// Range is 0 to Math.PI radians
minPolarAngle = 0 // radians
maxPolarAngle = Math.PI // radians
public minPolarAngle = 0 // radians
public maxPolarAngle = Math.PI // radians

private changeEvent = { type: 'change' }
private lockEvent = { type: 'lock' }
Expand Down Expand Up @@ -69,19 +69,19 @@ class PointerLockControls extends EventDispatcher {
console.error('THREE.PointerLockControls: Unable to use Pointer Lock API')
}

connect = (): void => {
public connect = (): void => {
this.domElement.ownerDocument.addEventListener('mousemove', this.onMouseMove)
this.domElement.ownerDocument.addEventListener('pointerlockchange', this.onPointerlockChange)
this.domElement.ownerDocument.addEventListener('pointerlockerror', this.onPointerlockError)
}

disconnect = (): void => {
public disconnect = (): void => {
this.domElement.ownerDocument.removeEventListener('mousemove', this.onMouseMove)
this.domElement.ownerDocument.removeEventListener('pointerlockchange', this.onPointerlockChange)
this.domElement.ownerDocument.removeEventListener('pointerlockerror', this.onPointerlockError)
}

dispose = (): void => {
public dispose = (): void => {
this.disconnect()
}

Expand All @@ -90,9 +90,9 @@ class PointerLockControls extends EventDispatcher {
this.camera

private direction = new Vector3(0, 0, -1)
getDirection = (v: Vector3): Vector3 => v.copy(this.direction).applyQuaternion(this.camera.quaternion)
public getDirection = (v: Vector3): Vector3 => v.copy(this.direction).applyQuaternion(this.camera.quaternion)

moveForward = (distance: number): void => {
public moveForward = (distance: number): void => {
// move forward parallel to the xz-plane
// assumes this.camera.up is y-up

Expand All @@ -103,17 +103,17 @@ class PointerLockControls extends EventDispatcher {
this.camera.position.addScaledVector(this.vec, distance)
}

moveRight = (distance: number): void => {
public moveRight = (distance: number): void => {
this.vec.setFromMatrixColumn(this.camera.matrix, 0)

this.camera.position.addScaledVector(this.vec, distance)
}

lock = (): void => {
public lock = (): void => {
this.domElement.requestPointerLock()
}

unlock = (): void => {
public unlock = (): void => {
this.domElement.ownerDocument.exitPointerLock()
}
}
Expand Down
32 changes: 16 additions & 16 deletions src/controls/TrackballControls.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import { EventDispatcher, MOUSE, Quaternion, Vector2, Vector3, PerspectiveCamera, OrthographicCamera } from 'three'

class TrackballControls extends EventDispatcher {
enabled = true
public enabled = true

screen = { left: 0, top: 0, width: 0, height: 0 }
public screen = { left: 0, top: 0, width: 0, height: 0 }

rotateSpeed = 1.0
zoomSpeed = 1.2
panSpeed = 0.3
public rotateSpeed = 1.0
public zoomSpeed = 1.2
public panSpeed = 0.3

noRotate = false
noZoom = false
noPan = false
public noRotate = false
public noZoom = false
public noPan = false

staticMoving = false
dynamicDampingFactor = 0.2
public staticMoving = false
public dynamicDampingFactor = 0.2

minDistance = 0
maxDistance = Infinity
public minDistance = 0
public maxDistance = Infinity

keys: [number, number, number] = [65 /*A*/, 83 /*S*/, 68 /*D*/]
public keys: [number, number, number] = [65 /*A*/, 83 /*S*/, 68 /*D*/]

mouseButtons = {
public mouseButtons = {
LEFT: MOUSE.ROTATE,
MIDDLE: MOUSE.DOLLY,
RIGHT: MOUSE.PAN,
}

object: PerspectiveCamera | OrthographicCamera
domElement: HTMLElement
public object: PerspectiveCamera | OrthographicCamera
public domElement: HTMLElement

private target = new Vector3()

Expand Down
Loading

1 comment on commit 028fb4f

@vercel
Copy link

@vercel vercel bot commented on 028fb4f Mar 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.