From 028fb4f6dcd9cd87e3751e4ba5a7947e5f34e4e4 Mon Sep 17 00:00:00 2001 From: Paras Sanghavi Date: Fri, 19 Mar 2021 01:17:01 -0700 Subject: [PATCH] chore: Add explicit member accessibility in eslint (#36) --- .eslintrc.json | 1 + src/controls/DeviceOrientationControls.ts | 18 +++++----- src/controls/DragControls.ts | 12 +++---- src/controls/FirstPersonControls.ts | 40 ++++++++++----------- src/controls/FlyControls.ts | 12 +++---- src/controls/PointerLockControls.ts | 24 ++++++------- src/controls/TrackballControls.ts | 32 ++++++++--------- src/controls/TransformControls.ts | 44 +++++++++++------------ src/lines/Line2.ts | 4 +-- src/lines/LineGeometry.ts | 12 +++---- src/lines/LineMaterial.ts | 32 ++++++++--------- src/lines/LineSegments2.ts | 8 ++--- src/lines/LineSegmentsGeometry.ts | 34 ++++++++---------- src/math/SimplexNoise.ts | 22 ++++++------ src/modifiers/CurveModifier.ts | 24 ++++++------- src/modifiers/EdgeSplitModifier.ts | 20 +++++------ src/modifiers/SimplifyModifier.ts | 12 +++---- src/modifiers/TessellateModifier.ts | 4 +-- src/objects/Sky.ts | 4 +-- src/postprocessing/EffectComposer.ts | 2 +- src/postprocessing/MaskPass.ts | 4 +-- src/postprocessing/Pass.ts | 2 +- src/postprocessing/ShaderPass.ts | 2 +- 23 files changed, 182 insertions(+), 187 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 1c60b238..2dec70fe 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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", diff --git a/src/controls/DeviceOrientationControls.ts b/src/controls/DeviceOrientationControls.ts index 83e2418f..bcf96b9e 100644 --- a/src/controls/DeviceOrientationControls.ts +++ b/src/controls/DeviceOrientationControls.ts @@ -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 = { alpha: 0, beta: 0, gamma: 0 } - screenOrientation: string | number = 0 - alphaOffset = 0 // radians + public enabled = true + public deviceOrientation: Partial = { alpha: 0, beta: 0, gamma: 0 } + public screenOrientation: string | number = 0 + public alphaOffset = 0 // radians constructor(object: Camera) { super() @@ -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+ @@ -78,7 +78,7 @@ class DeviceOrientationControls extends EventDispatcher { this.enabled = true } - disconnect = (): void => { + public disconnect = (): void => { window.removeEventListener('orientationchange', this.onScreenOrientationChangeEvent) window.removeEventListener('deviceorientation', this.onDeviceOrientationChangeEvent) @@ -86,7 +86,7 @@ class DeviceOrientationControls extends EventDispatcher { } private lastQuaternion = new Quaternion() - update = (): void => { + public update = (): void => { if (this.enabled === false) return const device = this.deviceOrientation @@ -106,7 +106,7 @@ class DeviceOrientationControls extends EventDispatcher { } } - dispose = (): void => this.disconnect() + public dispose = (): void => this.disconnect() } export { DeviceOrientationControls } diff --git a/src/controls/DragControls.ts b/src/controls/DragControls.ts index df051a88..755489a2 100644 --- a/src/controls/DragControls.ts +++ b/src/controls/DragControls.ts @@ -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 @@ -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) @@ -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) @@ -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() diff --git a/src/controls/FirstPersonControls.ts b/src/controls/FirstPersonControls.ts index ecd0e79d..8b99c24f 100644 --- a/src/controls/FirstPersonControls.ts +++ b/src/controls/FirstPersonControls.ts @@ -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 @@ -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) @@ -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 @@ -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) { @@ -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) { diff --git a/src/controls/FlyControls.ts b/src/controls/FlyControls.ts index e256f4b4..cac7bbe1 100644 --- a/src/controls/FlyControls.ts +++ b/src/controls/FlyControls.ts @@ -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 diff --git a/src/controls/PointerLockControls.ts b/src/controls/PointerLockControls.ts index b2d55e2f..1a884453 100644 --- a/src/controls/PointerLockControls.ts +++ b/src/controls/PointerLockControls.ts @@ -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' } @@ -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() } @@ -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 @@ -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() } } diff --git a/src/controls/TrackballControls.ts b/src/controls/TrackballControls.ts index f1b26b49..134334e4 100644 --- a/src/controls/TrackballControls.ts +++ b/src/controls/TrackballControls.ts @@ -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() diff --git a/src/controls/TransformControls.ts b/src/controls/TransformControls.ts index b34de91f..355d804f 100644 --- a/src/controls/TransformControls.ts +++ b/src/controls/TransformControls.ts @@ -32,11 +32,11 @@ export interface TransformControlsPointerObject { } class TransformControls extends Object3D { - isTransformControls = true + public readonly isTransformControls = true - visible = false + public visible = false - domElement: HTMLElement | Document + private domElement: HTMLElement | Document private raycaster = new Raycaster() @@ -100,10 +100,10 @@ class TransformControls extends Object3D { private _showZ = true // events - changeEvent = { type: 'change' } - mouseDownEvent = { type: 'mouseDown' } - mouseUpEvent = { type: 'mouseUp', mode: this._mode } - objectChangeEvent = { type: 'objectChange' } + private changeEvent = { type: 'change' } + private mouseDownEvent = { type: 'mouseDown' } + private mouseUpEvent = { type: 'mouseUp', mode: this._mode } + private objectChangeEvent = { type: 'objectChange' } constructor(camera: PerspectiveCamera | OrthographicCamera, domElement: HTMLElement) { super() @@ -545,29 +545,29 @@ class TransformControls extends Object3D { this.pointerUp(this.getPointer(event)) } - getMode = (): TransformControls['_mode'] => this._mode + public getMode = (): TransformControls['_mode'] => this._mode - setMode = (mode: TransformControls['_mode']): void => { + public setMode = (mode: TransformControls['_mode']): void => { this._mode = mode } - setTranslationSnap = (translationSnap: number): void => { + public setTranslationSnap = (translationSnap: number): void => { this._translationSnap = translationSnap } - setRotationSnap = (rotationSnap: number): void => { + public setRotationSnap = (rotationSnap: number): void => { this._rotationSnap = rotationSnap } - setScaleSnap = (scaleSnap: number): void => { + public setScaleSnap = (scaleSnap: number): void => { this._scaleSnap = scaleSnap } - setSize = (size: number): void => { + public setSize = (size: number): void => { this._size = size } - setSpace = (space: string): void => { + public setSpace = (space: string): void => { this._space = space } @@ -603,8 +603,8 @@ type TransformControlsGizmoPrivateGizmos = { } class TransformControlsGizmo extends Object3D { - isTransformControlsGizmo = true - type = 'TransformControlsGizmo' + private isTransformControlsGizmo = true + public type = 'TransformControlsGizmo' private tempVector = new Vector3(0, 0, 0) private tempEuler = new Euler() @@ -619,9 +619,9 @@ class TransformControlsGizmo extends Object3D { private unitY = new Vector3(0, 1, 0) private unitZ = new Vector3(0, 0, 1) - gizmo: TransformControlsGizmoPrivateGizmos - picker: TransformControlsGizmoPrivateGizmos - helper: TransformControlsGizmoPrivateGizmos + private gizmo: TransformControlsGizmoPrivateGizmos + public picker: TransformControlsGizmoPrivateGizmos + private helper: TransformControlsGizmoPrivateGizmos // these are set from parent class TransformControls private _rotationAxis = new Vector3() @@ -1284,8 +1284,8 @@ class TransformControlsGizmo extends Object3D { } class TransformControlsPlane extends Mesh { - isTransformControlsPlane = true - type = 'TransformControlsPlane' + private isTransformControlsPlane = true + public type = 'TransformControlsPlane' constructor() { super( @@ -1323,7 +1323,7 @@ class TransformControlsPlane extends Mesh { private _mode: 'translate' | 'rotate' | 'scale' = 'translate' private _space = 'world' - updateMatrixWorld = (): void => { + public updateMatrixWorld = (): void => { let space = this._space this.position.copy(this._worldPosition) diff --git a/src/lines/Line2.ts b/src/lines/Line2.ts index ba1999c6..1e86bfd8 100644 --- a/src/lines/Line2.ts +++ b/src/lines/Line2.ts @@ -3,8 +3,8 @@ import { LineGeometry } from './LineGeometry' import { LineMaterial } from './LineMaterial' class Line2 extends LineSegments2 { - type = 'Line2' - isLine2 = true + public type = 'Line2' + public readonly isLine2 = true constructor(geometry = new LineGeometry(), material = new LineMaterial({ color: Math.random() * 0xffffff })) { super(geometry, material) diff --git a/src/lines/LineGeometry.ts b/src/lines/LineGeometry.ts index 7820cea4..a08df4c4 100644 --- a/src/lines/LineGeometry.ts +++ b/src/lines/LineGeometry.ts @@ -2,14 +2,14 @@ import { Line } from 'three' import { LineSegmentsGeometry } from './LineSegmentsGeometry' class LineGeometry extends LineSegmentsGeometry { - type = 'LineGeometry' - isLineGeometry = true + public type = 'LineGeometry' + private isLineGeometry = true constructor() { super() } - setPositions = (array: number[] | Float32Array): this => { + public setPositions = (array: number[] | Float32Array): this => { // converts [ x1, y1, z1, x2, y2, z2, ... ] to pairs format const length = array.length - 3 @@ -30,7 +30,7 @@ class LineGeometry extends LineSegmentsGeometry { return this } - setColors = (array: number[] | Float32Array): this => { + public setColors = (array: number[] | Float32Array): this => { // converts [ r1, g1, b1, r2, g2, b2, ... ] to pairs format const length = array.length - 3 @@ -51,7 +51,7 @@ class LineGeometry extends LineSegmentsGeometry { return this } - fromLine = (line: Line): this => { + public fromLine = (line: Line): this => { const geometry = line.geometry if (geometry.isBufferGeometry) { @@ -63,7 +63,7 @@ class LineGeometry extends LineSegmentsGeometry { return this } - copy = (/* source */): this => { + public copy = (/* source */): this => { // todo return this diff --git a/src/lines/LineMaterial.ts b/src/lines/LineMaterial.ts index 6069e588..345aadab 100644 --- a/src/lines/LineMaterial.ts +++ b/src/lines/LineMaterial.ts @@ -233,55 +233,55 @@ ShaderLib['line'] = { } class LineMaterial extends ShaderMaterial { - dashed: boolean + public dashed: boolean - isLineMaterial = true + private isLineMaterial = true - get color(): any { + public get color(): any { return this.uniforms.diffuse.value } - set color(value: any) { + public set color(value: any) { this.uniforms.diffuse.value = value } - get dashScale(): number { + public get dashScale(): number { return this.uniforms.dashScale.value } - set dashScale(value: number) { + public set dashScale(value: number) { this.uniforms.dashScale.value = value } - get dashSize(): number { + public get dashSize(): number { return this.uniforms.dashSize.value } - set dashSize(value: number) { + public set dashSize(value: number) { this.uniforms.dashSize.value = value } - get dashOffset(): number { + public get dashOffset(): number { return this.uniforms.dashOffset.value } - set dashOffset(value: number) { + public set dashOffset(value: number) { this.uniforms.dashOffset.value = value } - get gapSize(): number { + public get gapSize(): number { return this.uniforms.gapSize.value } - set gapSize(value: number) { + public set gapSize(value: number) { this.uniforms.gapSize.value = value } - get resolution(): Vector2 { + public get resolution(): Vector2 { return this.uniforms.gapSize.value } - set resolution(value: Vector2) { + public set resolution(value: Vector2) { this.uniforms.gapSize.value = value } @@ -304,7 +304,7 @@ class LineMaterial extends ShaderMaterial { get: function (): number { return this.uniforms.linewidth.value }, - set: function (value: number) { + set: function (value: number): void { this.uniforms.linewidth.value = value }, }, @@ -325,7 +325,7 @@ class LineMaterial extends ShaderMaterial { get: function (): number { return this.uniforms.opacity.value }, - set: function (value: number) { + set: function (value: number): void { this.uniforms.opacity.value = value }, }, diff --git a/src/lines/LineSegments2.ts b/src/lines/LineSegments2.ts index 65802bac..432f7659 100644 --- a/src/lines/LineSegments2.ts +++ b/src/lines/LineSegments2.ts @@ -16,8 +16,8 @@ import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry' import { LineMaterial } from '../lines/LineMaterial' class LineSegments2 extends Mesh { - type = 'LineSegments2' - isLineSegments2 = true + public type = 'LineSegments2' + private isLineSegments2 = true constructor(geometry = new LineSegmentsGeometry(), material = new LineMaterial({ color: Math.random() * 0xffffff })) { super(geometry, material) @@ -26,7 +26,7 @@ class LineSegments2 extends Mesh { private distStart = new Vector3() private distEnd = new Vector3() - computeLineDistances = (): this => { + private computeLineDistances = (): this => { const geometry = this.geometry const instanceStart = geometry.attributes.instanceStart as InterleavedBufferAttribute @@ -58,7 +58,7 @@ class LineSegments2 extends Mesh { private line = new Line3() private closestPoint = new Vector3() - raycast = (raycaster: Raycaster, intersects: Array): void => { + public raycast = (raycaster: Raycaster, intersects: Array): void => { if (raycaster.camera === null) { console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.') } diff --git a/src/lines/LineSegmentsGeometry.ts b/src/lines/LineSegmentsGeometry.ts index 6cccc4c4..3bea3b2c 100644 --- a/src/lines/LineSegmentsGeometry.ts +++ b/src/lines/LineSegmentsGeometry.ts @@ -15,11 +15,11 @@ import { } from 'three' class LineSegmentsGeometry extends InstancedBufferGeometry { - isLineSegmentsGeometry = true - type = 'LineSegmentsGeometry' + public readonly isLineSegmentsGeometry = true + public type = 'LineSegmentsGeometry' - boundingBox: Box3 | null = null - boundingSphere: Sphere | null = null + public boundingBox: Box3 | null = null + public boundingSphere: Sphere | null = null constructor() { super() @@ -33,7 +33,7 @@ class LineSegmentsGeometry extends InstancedBufferGeometry { this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)) } - applyMatrix4 = (matrix: Matrix4): this => { + public applyMatrix4 = (matrix: Matrix4): this => { const start = this.attributes.instanceStart const end = this.attributes.instanceEnd @@ -56,7 +56,7 @@ class LineSegmentsGeometry extends InstancedBufferGeometry { return this } - setPositions = (array: number[] | Float32Array): this => { + public setPositions = (array: number[] | Float32Array): this => { let lineSegments if (array instanceof Float32Array) { @@ -81,7 +81,7 @@ class LineSegmentsGeometry extends InstancedBufferGeometry { return this } - setColors = (array: number[] | Float32Array): this => { + public setColors = (array: number[] | Float32Array): this => { let colors if (array instanceof Float32Array) { @@ -101,25 +101,25 @@ class LineSegmentsGeometry extends InstancedBufferGeometry { return this } - fromWireframeGeometry = (geometry: BufferGeometry): this => { + public fromWireframeGeometry = (geometry: BufferGeometry): this => { this.setPositions(Array.from(geometry.attributes.position.array)) return this } - fromEdgesGeometry = (geometry: BufferGeometry): this => { + public fromEdgesGeometry = (geometry: BufferGeometry): this => { this.setPositions(Array.from(geometry.attributes.position.array)) return this } - fromMesh = (mesh: Mesh): this => { + public fromMesh = (mesh: Mesh): this => { this.fromWireframeGeometry(new WireframeGeometry(mesh.geometry)) return this } - fromLineSegments = (lineSegments: LineSegments): this => { + public fromLineSegments = (lineSegments: LineSegments): this => { const geometry = lineSegments.geometry if (geometry.isBufferGeometry) { @@ -133,7 +133,7 @@ class LineSegmentsGeometry extends InstancedBufferGeometry { private box = new Box3() - computeBoundingBox = (): void => { + public computeBoundingBox = (): void => { if (this.boundingBox === null) { this.boundingBox = new Box3() } @@ -152,7 +152,7 @@ class LineSegmentsGeometry extends InstancedBufferGeometry { private vector = new Vector3() - computeBoundingSphere = (): void => { + public computeBoundingSphere = (): void => { if (this.boundingSphere === null) { this.boundingSphere = new Sphere() } @@ -192,15 +192,9 @@ class LineSegmentsGeometry extends InstancedBufferGeometry { } } - toJSON = (): void => { + public toJSON = (): void => { // todo } - - applyMatrix = (matrix: Matrix4): this => { - console.warn('THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().') - - return this.applyMatrix4(matrix) - } } export { LineSegmentsGeometry } diff --git a/src/math/SimplexNoise.ts b/src/math/SimplexNoise.ts index 5d67343c..c41c78c0 100644 --- a/src/math/SimplexNoise.ts +++ b/src/math/SimplexNoise.ts @@ -11,7 +11,7 @@ export interface NumberGenerator { // Added 4D noise export class SimplexNoise { - grad3 = [ + private grad3 = [ [1, 1, 0], [-1, 1, 0], [1, -1, 0], @@ -26,7 +26,7 @@ export class SimplexNoise { [0, -1, -1], ] - grad4 = [ + private grad4 = [ [0, 1, 1, 1], [0, 1, 1, -1], [0, 1, -1, 1], @@ -61,14 +61,14 @@ export class SimplexNoise { [-1, -1, -1, 0], ] - p: number[] = [] + private p: number[] = [] // To remove the need for index wrapping, double the permutation table length - perm: number[] = [] + private perm: number[] = [] // A lookup table to traverse the simplex around a given point in 4D. // Details can be found where this table is used, in the 4D noise method. - simplex = [ + private simplex = [ [0, 1, 2, 3], [0, 1, 3, 2], [0, 0, 0, 0], @@ -149,19 +149,19 @@ export class SimplexNoise { } } - dot = (g: number[], x: number, y: number): number => { + public dot = (g: number[], x: number, y: number): number => { return g[0] * x + g[1] * y } - dot3 = (g: number[], x: number, y: number, z: number): number => { + public dot3 = (g: number[], x: number, y: number, z: number): number => { return g[0] * x + g[1] * y + g[2] * z } - dot4 = (g: number[], x: number, y: number, z: number, w: number): number => { + public dot4 = (g: number[], x: number, y: number, z: number, w: number): number => { return g[0] * x + g[1] * y + g[2] * z + g[3] * w } - noise = (xin: number, yin: number): number => { + public noise = (xin: number, yin: number): number => { let n0 let n1 let n2 // Noise contributions from the three corners @@ -231,7 +231,7 @@ export class SimplexNoise { } // 3D simplex noise - noise3d = (xin: number, yin: number, zin: number): number => { + private noise3d = (xin: number, yin: number, zin: number): number => { // Noise contributions from the four corners let n0 let n1 @@ -377,7 +377,7 @@ export class SimplexNoise { } // 4D simplex noise - noise4d = (x: number, y: number, z: number, w: number): number => { + public noise4d = (x: number, y: number, z: number, w: number): number => { // For faster and easier lookups const grad4 = this.grad4 const simplex = this.simplex diff --git a/src/modifiers/CurveModifier.ts b/src/modifiers/CurveModifier.ts index dfb3a73e..f5e17858 100644 --- a/src/modifiers/CurveModifier.ts +++ b/src/modifiers/CurveModifier.ts @@ -204,12 +204,12 @@ export function modifyShader( * A helper class for making meshes bend aroudn curves */ export class Flow { - curveArray: Curve[] - curveLengthArray: number[] + public curveArray: Curve[] + public curveLengthArray: number[] - object3D: TMesh - splineTexure: DataTexture - uniforms: CurveModifierUniforms + public object3D: TMesh + public splineTexure: DataTexture + public uniforms: CurveModifierUniforms /** * @param {Mesh} mesh The mesh to clone and modify to bend around the curve @@ -235,7 +235,7 @@ export class Flow { this.uniforms = uniforms } - updateCurve>(index: number, curve: TCurve): void { + public updateCurve>(index: number, curve: TCurve): void { if (index >= this.curveArray.length) throw Error('Index out of range for Flow') const curveLength = curve.getLength() this.uniforms.spineLength.value = curveLength @@ -244,7 +244,7 @@ export class Flow { updateSplineTexture(this.splineTexure, curve, index) } - moveAlongCurve(amount: number): void { + public moveAlongCurve(amount: number): void { this.uniforms.pathOffset.value += amount } } @@ -257,8 +257,8 @@ export class InstancedFlow< TGeometry extends BufferGeometry = BufferGeometry, TMaterial extends Material = Material > extends Flow> { - offsets: number[] - whichCurve: number[] + public offsets: number[] + public whichCurve: number[] /** * @@ -282,7 +282,7 @@ export class InstancedFlow< * * @param {number} index of the instanced element to update */ - writeChanges(index: number): void { + private writeChanges(index: number): void { matrix.makeTranslation(this.curveLengthArray[this.whichCurve[index]], this.whichCurve[index], this.offsets[index]) this.object3D.setMatrixAt(index, matrix) this.object3D.instanceMatrix.needsUpdate = true @@ -294,7 +294,7 @@ export class InstancedFlow< * @param {number} index Which element to update * @param {number} offset Move by how much */ - moveIndividualAlongCurve(index: number, offset: number): void { + public moveIndividualAlongCurve(index: number, offset: number): void { this.offsets[index] += offset this.writeChanges(index) } @@ -305,7 +305,7 @@ export class InstancedFlow< * @param {number} index the index of the instanced element to update * @param {number} curveNo the index of the curve it should use */ - setCurve(index: number, curveNo: number): void { + public setCurve(index: number, curveNo: number): void { if (isNaN(curveNo)) throw Error('curve index being set is Not a Number (NaN)') this.whichCurve[index] = curveNo this.writeChanges(index) diff --git a/src/modifiers/EdgeSplitModifier.ts b/src/modifiers/EdgeSplitModifier.ts index be96a038..c23b05cc 100644 --- a/src/modifiers/EdgeSplitModifier.ts +++ b/src/modifiers/EdgeSplitModifier.ts @@ -14,16 +14,16 @@ interface SplitIndexes { } class EdgeSplitModifier { - A = new Vector3() - B = new Vector3() - C = new Vector3() - - positions: ArrayLike = [] - normals: Float32Array = new Float32Array() - indexes: ArrayLike = [] - pointToIndexMap: number[][] = [] - splitIndexes: SplitIndexes[] = [] - oldNormals: ArrayLike = [] + private A = new Vector3() + private B = new Vector3() + private C = new Vector3() + + private positions: ArrayLike = [] + private normals: Float32Array = new Float32Array() + private indexes: ArrayLike = [] + private pointToIndexMap: number[][] = [] + private splitIndexes: SplitIndexes[] = [] + private oldNormals: ArrayLike = [] constructor() {} diff --git a/src/modifiers/SimplifyModifier.ts b/src/modifiers/SimplifyModifier.ts index 6731f791..cf7a6956 100644 --- a/src/modifiers/SimplifyModifier.ts +++ b/src/modifiers/SimplifyModifier.ts @@ -39,11 +39,11 @@ class Vertex { this.collapseNeighbor = null // best candinate for collapsing } - addUniqueNeighbor(vertex: Vertex): void { + public addUniqueNeighbor(vertex: Vertex): void { pushIfUnique(this.neighbors, vertex) } - removeIfNonNeighbor(n: Vertex): void { + public removeIfNonNeighbor(n: Vertex): void { const neighbors = this.neighbors const faces = this.faces @@ -63,9 +63,9 @@ class Triangle { private b: number private c: Number - v1: Vertex - v2: Vertex - v3: Vertex + public v1: Vertex + public v2: Vertex + public v3: Vertex public normal = new Vector3() @@ -332,7 +332,7 @@ class SimplifyModifier { return least } - modify = (geometry: BufferGeometry, count: number): BufferGeometry => { + public modify = (geometry: BufferGeometry, count: number): BufferGeometry => { geometry = geometry.clone() const attributes = geometry.attributes diff --git a/src/modifiers/TessellateModifier.ts b/src/modifiers/TessellateModifier.ts index 02367d58..02a4b3aa 100644 --- a/src/modifiers/TessellateModifier.ts +++ b/src/modifiers/TessellateModifier.ts @@ -5,8 +5,8 @@ import { BufferGeometry, Color, Float32BufferAttribute, Vector2, Vector3 } from */ class TessellateModifier { - maxEdgeLength: number - maxIterations: number + public maxEdgeLength: number + public maxIterations: number constructor(maxEdgeLength = 0.1, maxIterations = 6) { this.maxEdgeLength = maxEdgeLength diff --git a/src/objects/Sky.ts b/src/objects/Sky.ts index e11de6e1..f7cace39 100644 --- a/src/objects/Sky.ts +++ b/src/objects/Sky.ts @@ -18,7 +18,7 @@ class Sky extends Mesh { super(new BoxGeometry(1, 1, 1), Sky.material) } - static SkyShader = { + public static SkyShader = { uniforms: { turbidity: { value: 2 }, rayleigh: { value: 1 }, @@ -190,7 +190,7 @@ class Sky extends Mesh { ].join('\n'), } - static material = new ShaderMaterial({ + public static material = new ShaderMaterial({ name: 'SkyShader', fragmentShader: Sky.SkyShader.fragmentShader, vertexShader: Sky.SkyShader.vertexShader, diff --git a/src/postprocessing/EffectComposer.ts b/src/postprocessing/EffectComposer.ts index d7915151..3f361330 100644 --- a/src/postprocessing/EffectComposer.ts +++ b/src/postprocessing/EffectComposer.ts @@ -18,7 +18,7 @@ class EffectComposer { public copyPass: Pass public clock: Clock - public constructor(renderer: WebGLRenderer, renderTarget: WebGLRenderTarget) { + constructor(renderer: WebGLRenderer, renderTarget: WebGLRenderTarget) { this.renderer = renderer if (renderTarget === undefined) { diff --git a/src/postprocessing/MaskPass.ts b/src/postprocessing/MaskPass.ts index f086dfbd..070d7c9f 100644 --- a/src/postprocessing/MaskPass.ts +++ b/src/postprocessing/MaskPass.ts @@ -6,7 +6,7 @@ class MaskPass extends Pass { public camera: Camera public inverse: boolean - public constructor(scene: Scene, camera: Camera) { + constructor(scene: Scene, camera: Camera) { super() this.scene = scene @@ -79,7 +79,7 @@ class MaskPass extends Pass { } class ClearMaskPass extends Pass { - public constructor() { + constructor() { super() this.needsSwap = false } diff --git a/src/postprocessing/Pass.ts b/src/postprocessing/Pass.ts index 13c95704..c9ec84de 100644 --- a/src/postprocessing/Pass.ts +++ b/src/postprocessing/Pass.ts @@ -39,7 +39,7 @@ class FullScreenQuad { public geometry = new PlaneGeometry(2, 2) private mesh: Mesh - public constructor(material: TMaterial) { + constructor(material: TMaterial) { this.mesh = new Mesh(this.geometry, material) } diff --git a/src/postprocessing/ShaderPass.ts b/src/postprocessing/ShaderPass.ts index 61bc522e..ec925f30 100644 --- a/src/postprocessing/ShaderPass.ts +++ b/src/postprocessing/ShaderPass.ts @@ -7,7 +7,7 @@ class ShaderPass extends Pass { public material: ShaderMaterial public fsQuad: FullScreenQuad - public constructor(shader: ShaderMaterial | (Shader & { defines?: Object }), textureID = 'tDiffuse') { + constructor(shader: ShaderMaterial | (Shader & { defines?: Object }), textureID = 'tDiffuse') { super() this.textureID = textureID