Skip to content

Commit

Permalink
fix(types): three r160 breaking changes (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett authored Jan 5, 2024
1 parent 45e22a1 commit 6033736
Show file tree
Hide file tree
Showing 20 changed files with 155 additions and 52 deletions.
48 changes: 48 additions & 0 deletions src/controls/ArcballControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ class ArcballControls extends EventDispatcher {
child.geometry = curveGeometry
}

// @ts-ignore
this.dispatchEvent(_changeEvent)
}

Expand Down Expand Up @@ -630,6 +631,7 @@ class ArcballControls extends EventDispatcher {

if (mouseOp) {
event.preventDefault()
// @ts-ignore
this.dispatchEvent(_startEvent)

const notchDeltaY = 125 //distance of one notch of mouse wheel
Expand Down Expand Up @@ -681,7 +683,9 @@ class ArcballControls extends EventDispatcher {

this.updateTbState(STATE.IDLE, false)

// @ts-ignore
this.dispatchEvent(_changeEvent)
// @ts-ignore
this.dispatchEvent(_endEvent)

break
Expand Down Expand Up @@ -748,7 +752,9 @@ class ArcballControls extends EventDispatcher {

this.updateTbState(STATE.IDLE, false)

// @ts-ignore
this.dispatchEvent(_changeEvent)
// @ts-ignore
this.dispatchEvent(_endEvent)

break
Expand All @@ -759,6 +765,7 @@ class ArcballControls extends EventDispatcher {

private onSinglePanStart = (event: PointerEvent, operation: Operation): void => {
if (this.enabled && this.domElement) {
// @ts-ignore
this.dispatchEvent(_startEvent)

this.setCenter(event.clientX, event.clientY)
Expand All @@ -773,6 +780,7 @@ class ArcballControls extends EventDispatcher {
this._timeStart = -1

this.activateGizmos(false)
// @ts-ignore
this.dispatchEvent(_changeEvent)
}

Expand All @@ -784,6 +792,7 @@ class ArcballControls extends EventDispatcher {
}
if (this.enableGrid) {
this.drawGrid()
// @ts-ignore
this.dispatchEvent(_changeEvent)
}
}
Expand Down Expand Up @@ -816,6 +825,7 @@ class ArcballControls extends EventDispatcher {
}
}

// @ts-ignore
this.dispatchEvent(_changeEvent)
break

Expand All @@ -829,6 +839,7 @@ class ArcballControls extends EventDispatcher {
this._timeStart = -1

this.activateGizmos(false)
// @ts-ignore
this.dispatchEvent(_changeEvent)
}

Expand All @@ -847,6 +858,7 @@ class ArcballControls extends EventDispatcher {
this._timeStart = -1

this.activateGizmos(false)
// @ts-ignore
this.dispatchEvent(_changeEvent)
}

Expand All @@ -869,7 +881,9 @@ class ArcballControls extends EventDispatcher {
if (restart) {
//switch to pan operation

// @ts-ignore
this.dispatchEvent(_endEvent)
// @ts-ignore
this.dispatchEvent(_startEvent)

this.updateTbState(opState, true)
Expand Down Expand Up @@ -899,7 +913,9 @@ class ArcballControls extends EventDispatcher {
if (restart) {
//switch to rotate operation

// @ts-ignore
this.dispatchEvent(_endEvent)
// @ts-ignore
this.dispatchEvent(_startEvent)

this.updateTbState(opState, true)
Expand Down Expand Up @@ -965,7 +981,9 @@ class ArcballControls extends EventDispatcher {
if (restart) {
//switch to zoom operation

// @ts-ignore
this.dispatchEvent(_endEvent)
// @ts-ignore
this.dispatchEvent(_startEvent)

this.updateTbState(opState, true)
Expand Down Expand Up @@ -1003,7 +1021,9 @@ class ArcballControls extends EventDispatcher {
if (restart) {
//switch to fov operation

// @ts-ignore
this.dispatchEvent(_endEvent)
// @ts-ignore
this.dispatchEvent(_startEvent)

this.updateTbState(opState, true)
Expand Down Expand Up @@ -1065,6 +1085,7 @@ class ArcballControls extends EventDispatcher {
break
}

// @ts-ignore
this.dispatchEvent(_changeEvent)
}
}
Expand Down Expand Up @@ -1092,11 +1113,13 @@ class ArcballControls extends EventDispatcher {
//cursor has been standing still for over 120 ms since last movement
this.updateTbState(STATE.IDLE, false)
this.activateGizmos(false)
// @ts-ignore
this.dispatchEvent(_changeEvent)
}
} else {
this.updateTbState(STATE.IDLE, false)
this.activateGizmos(false)
// @ts-ignore
this.dispatchEvent(_changeEvent)
}
} else if (this._state == STATE.PAN || this._state == STATE.IDLE) {
Expand All @@ -1107,14 +1130,17 @@ class ArcballControls extends EventDispatcher {
}

this.activateGizmos(false)
// @ts-ignore
this.dispatchEvent(_changeEvent)
}

// @ts-ignore
this.dispatchEvent(_endEvent)
}

private onDoubleTap = (event: PointerEvent): void => {
if (this.enabled && this.enablePan && this.scene && this.camera && this.domElement) {
// @ts-ignore
this.dispatchEvent(_startEvent)

this.setCenter(event.clientX, event.clientY)
Expand All @@ -1135,15 +1161,18 @@ class ArcballControls extends EventDispatcher {
this.updateTbState(STATE.FOCUS, true)
this.focus(hitP, this.scaleFactor)
this.updateTbState(STATE.IDLE, false)
// @ts-ignore
this.dispatchEvent(_changeEvent)
}
}

// @ts-ignore
this.dispatchEvent(_endEvent)
}

private onDoublePanStart = (): void => {
if (this.enabled && this.enablePan && this.camera && this.domElement) {
// @ts-ignore
this.dispatchEvent(_startEvent)

this.updateTbState(STATE.PAN, true)
Expand Down Expand Up @@ -1178,17 +1207,20 @@ class ArcballControls extends EventDispatcher {
const rayDir = this.unprojectOnTbPlane(this.camera, _center.x, _center.y, this.domElement, true)
if (rayDir !== undefined) this._currentCursorPosition.copy(rayDir)
this.applyTransformMatrix(this.pan(this._startCursorPosition, this._currentCursorPosition, true))
// @ts-ignore
this.dispatchEvent(_changeEvent)
}
}

private onDoublePanEnd = (): void => {
this.updateTbState(STATE.IDLE, false)
// @ts-ignore
this.dispatchEvent(_endEvent)
}

private onRotateStart = (): void => {
if (this.enabled && this.enableRotate) {
// @ts-ignore
this.dispatchEvent(_startEvent)

this.updateTbState(STATE.ZROTATE, true)
Expand Down Expand Up @@ -1241,18 +1273,21 @@ class ArcballControls extends EventDispatcher {
if (rotationPoint !== undefined) {
this.applyTransformMatrix(this.zRotate(rotationPoint, amount))
}
// @ts-ignore
this.dispatchEvent(_changeEvent)
}
}

private onRotateEnd = (): void => {
this.updateTbState(STATE.IDLE, false)
this.activateGizmos(false)
// @ts-ignore
this.dispatchEvent(_endEvent)
}

private onPinchStart = (): void => {
if (this.enabled && this.enableZoom) {
// @ts-ignore
this.dispatchEvent(_startEvent)
this.updateTbState(STATE.SCALE, true)

Expand Down Expand Up @@ -1302,17 +1337,20 @@ class ArcballControls extends EventDispatcher {
if (scalePoint !== undefined) {
this.applyTransformMatrix(this.applyScale(amount, scalePoint))
}
// @ts-ignore
this.dispatchEvent(_changeEvent)
}
}

private onPinchEnd = (): void => {
this.updateTbState(STATE.IDLE, false)
// @ts-ignore
this.dispatchEvent(_endEvent)
}

private onTriplePanStart = (): void => {
if (this.enabled && this.enableZoom && this.domElement) {
// @ts-ignore
this.dispatchEvent(_startEvent)

this.updateTbState(STATE.SCALE, true)
Expand Down Expand Up @@ -1401,12 +1439,14 @@ class ArcballControls extends EventDispatcher {
.multiplyScalar(newDistance / x)
this._m4_1.makeTranslation(direction.x, direction.y, direction.z)

// @ts-ignore
this.dispatchEvent(_changeEvent)
}
}

private onTriplePanEnd = (): void => {
this.updateTbState(STATE.IDLE, false)
// @ts-ignore
this.dispatchEvent(_endEvent)
//this.dispatchEvent( _changeEvent );
}
Expand Down Expand Up @@ -1933,6 +1973,7 @@ class ArcballControls extends EventDispatcher {
*/
public setGizmosVisible(value: boolean): void {
this._gizmos.visible = value
// @ts-ignore
this.dispatchEvent(_changeEvent)
}

Expand Down Expand Up @@ -2017,6 +2058,7 @@ class ArcballControls extends EventDispatcher {
this.updateTbState(STATE.IDLE, false)
this.activateGizmos(false)

// @ts-ignore
this.dispatchEvent(_changeEvent)
} else {
const amount = this.easeOutCubic(animTime)
Expand All @@ -2025,6 +2067,7 @@ class ArcballControls extends EventDispatcher {
this._gizmoMatrixState.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale)
this.focus(point, size, amount)

// @ts-ignore
this.dispatchEvent(_changeEvent)
const self = this
this._animationId = window.requestAnimationFrame(function (t) {
Expand Down Expand Up @@ -2062,6 +2105,7 @@ class ArcballControls extends EventDispatcher {
//tetha = 0.5 * alpha * t^2 + w0 * t + tetha0
this._angleCurrent = 0.5 * -this.dampingFactor * Math.pow(deltaTime, 2) + w0 * deltaTime + 0
this.applyTransformMatrix(this.rotate(rotationAxis, this._angleCurrent))
// @ts-ignore
this.dispatchEvent(_changeEvent)
const self = this
this._animationId = window.requestAnimationFrame(function (t) {
Expand All @@ -2074,6 +2118,7 @@ class ArcballControls extends EventDispatcher {
this.updateTbState(STATE.IDLE, false)
this.activateGizmos(false)

// @ts-ignore
this.dispatchEvent(_changeEvent)
}
} else {
Expand All @@ -2084,6 +2129,7 @@ class ArcballControls extends EventDispatcher {

if (this._state != STATE.ROTATE) {
this.activateGizmos(false)
// @ts-ignore
this.dispatchEvent(_changeEvent)
}
}
Expand Down Expand Up @@ -2156,6 +2202,7 @@ class ArcballControls extends EventDispatcher {

this.updateTbState(STATE.IDLE, false)

// @ts-ignore
this.dispatchEvent(_changeEvent)
}
}
Expand Down Expand Up @@ -2774,6 +2821,7 @@ class ArcballControls extends EventDispatcher {
this.camera.lookAt(this._gizmos.position)
this.updateTbState(STATE.IDLE, false)

// @ts-ignore
this.dispatchEvent(_changeEvent)
}
}
Expand Down
1 change: 1 addition & 0 deletions src/controls/DeviceOrientationControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class DeviceOrientationControls extends EventDispatcher {

if (8 * (1 - this.lastQuaternion.dot(this.object.quaternion)) > this.EPS) {
this.lastQuaternion.copy(this.object.quaternion)
// @ts-ignore
this.dispatchEvent(this.changeEvent)
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/controls/DragControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class DragControls extends EventDispatcher {
this._selected.position.copy(this._intersection.sub(this._offset).applyMatrix4(this._inverseMatrix))
}

// @ts-ignore
this.dispatchEvent({ type: 'drag', object: this._selected })

return
Expand All @@ -91,13 +92,15 @@ class DragControls extends EventDispatcher {
)

if (this._hovered !== object) {
// @ts-ignore
this.dispatchEvent({ type: 'hoveron', object })

this._domElement.style.cursor = 'pointer'
this._hovered = object
}
} else {
if (this._hovered !== null) {
// @ts-ignore
this.dispatchEvent({ type: 'hoveroff', object: this._hovered })

this._domElement.style.cursor = 'auto'
Expand All @@ -122,12 +125,14 @@ class DragControls extends EventDispatcher {

this._domElement.style.cursor = 'move'

// @ts-ignore
this.dispatchEvent({ type: 'dragstart', object: this._selected })
}
}

private onMouseCancel = (): void => {
if (this._selected) {
// @ts-ignore
this.dispatchEvent({ type: 'dragend', object: this._selected })

this._selected = null
Expand Down Expand Up @@ -185,6 +190,7 @@ class DragControls extends EventDispatcher {
this._selected.position.copy(this._intersection.sub(this._offset).applyMatrix4(this._inverseMatrix))
}

// @ts-ignore
this.dispatchEvent({ type: 'drag', object: this._selected })

return
Expand Down Expand Up @@ -220,6 +226,7 @@ class DragControls extends EventDispatcher {

this._domElement.style.cursor = 'move'

// @ts-ignore
this.dispatchEvent({ type: 'dragstart', object: this._selected })
}
}
Expand All @@ -228,6 +235,7 @@ class DragControls extends EventDispatcher {
event.preventDefault()

if (this._selected) {
// @ts-ignore
this.dispatchEvent({ type: 'dragend', object: this._selected })

this._selected = null
Expand Down
Loading

0 comments on commit 6033736

Please sign in to comment.