| 172 | const Common = new CommonClass(); |
| 173 | |
| 174 | class MouseClass { |
| 175 | mouseMoved = false; |
| 176 | coords = new THREE.Vector2(); |
| 177 | coords_old = new THREE.Vector2(); |
| 178 | diff = new THREE.Vector2(); |
| 179 | timer: number | null = null; |
| 180 | container: HTMLElement | null = null; |
| 181 | docTarget: Document | null = null; |
| 182 | listenerTarget: Window | null = null; |
| 183 | isHoverInside = false; |
| 184 | hasUserControl = false; |
| 185 | isAutoActive = false; |
| 186 | autoIntensity = 2.0; |
| 187 | takeoverActive = false; |
| 188 | takeoverStartTime = 0; |
| 189 | takeoverDuration = 0.25; |
| 190 | takeoverFrom = new THREE.Vector2(); |
| 191 | takeoverTo = new THREE.Vector2(); |
| 192 | onInteract: (() => void) | null = null; |
| 193 | private _onMouseMove = this.onDocumentMouseMove.bind(this); |
| 194 | private _onTouchStart = this.onDocumentTouchStart.bind(this); |
| 195 | private _onTouchMove = this.onDocumentTouchMove.bind(this); |
| 196 | private _onTouchEnd = this.onTouchEnd.bind(this); |
| 197 | private _onDocumentLeave = this.onDocumentLeave.bind(this); |
| 198 | init(container: HTMLElement) { |
| 199 | this.container = container; |
| 200 | this.docTarget = container.ownerDocument || null; |
| 201 | const defaultView = |
| 202 | this.docTarget?.defaultView || |
| 203 | (typeof window !== "undefined" ? window : null); |
| 204 | if (!defaultView) return; |
| 205 | this.listenerTarget = defaultView; |
| 206 | this.listenerTarget.addEventListener("mousemove", this._onMouseMove); |
| 207 | this.listenerTarget.addEventListener("touchstart", this._onTouchStart, { |
| 208 | passive: true, |
| 209 | }); |
| 210 | this.listenerTarget.addEventListener("touchmove", this._onTouchMove, { |
| 211 | passive: true, |
| 212 | }); |
| 213 | this.listenerTarget.addEventListener("touchend", this._onTouchEnd); |
| 214 | this.docTarget?.addEventListener("mouseleave", this._onDocumentLeave); |
| 215 | } |
| 216 | dispose() { |
| 217 | if (this.listenerTarget) { |
| 218 | this.listenerTarget.removeEventListener( |
| 219 | "mousemove", |
| 220 | this._onMouseMove |
| 221 | ); |
| 222 | this.listenerTarget.removeEventListener( |
| 223 | "touchstart", |
| 224 | this._onTouchStart |
| 225 | ); |
| 226 | this.listenerTarget.removeEventListener( |
| 227 | "touchmove", |
| 228 | this._onTouchMove |
| 229 | ); |
| 230 | this.listenerTarget.removeEventListener("touchend", this._onTouchEnd); |
| 231 | } |
nothing calls this directly
no outgoing calls
no test coverage detected