Test Failed
Push — master ( def0c6...dd5863 )
by
unknown
06:55
created

docs/plugin/projector/TrackballControls.js   F

Complexity

Total Complexity 82
Complexity/F 3.9

Size

Lines of Code 533
Function Count 21

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 4096
dl 0
loc 533
rs 3.12
wmc 82
mnd 4
bc 55
fnc 21
bpm 2.619
cpm 3.9047
noi 19

How to fix   Complexity   

Complexity

Complex classes like docs/plugin/projector/TrackballControls.js often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
/**
2
 * @author Eberhard Graether / http://egraether.com/
3
 */
4
5
THREE.TrackballControls = function ( object, domElement ) {
0 ignored issues
show
Bug introduced by
The variable THREE seems to be never declared. If this is a global, consider adding a /** global: THREE */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
6
7
	var _this = this;
8
	var STATE = { NONE: -1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM: 4, TOUCH_PAN: 5 };
9
10
	this.object = object;
11
	this.domElement = ( domElement !== undefined ) ? domElement : document;
12
13
	// API
14
15
	this.enabled = true;
16
17
	this.screen = { width: 0, height: 0, offsetLeft: 0, offsetTop: 0 };
18
	this.radius = ( this.screen.width + this.screen.height ) / 4;
19
20
	this.rotateSpeed = 1.0;
21
	this.zoomSpeed = 1.2;
22
	this.panSpeed = 0.3;
23
24
	this.noRotate = false;
25
	this.noZoom = false;
26
	this.noPan = false;
27
28
	this.staticMoving = false;
29
	this.dynamicDampingFactor = 0.2;
30
31
	this.minDistance = 0;
32
	this.maxDistance = Infinity;
33
34
	this.keys = [ 65 /*A*/, 83 /*S*/, 68 /*D*/ ];
35
36
	// internals
37
38
	this.target = new THREE.Vector3();
0 ignored issues
show
Bug introduced by
The variable THREE seems to be never declared. If this is a global, consider adding a /** global: THREE */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
39
40
	var lastPosition = new THREE.Vector3();
41
42
	var _state = STATE.NONE,
43
	_prevState = STATE.NONE,
44
45
	_eye = new THREE.Vector3(),
46
47
	_rotateStart = new THREE.Vector3(),
48
	_rotateEnd = new THREE.Vector3(),
49
50
	_zoomStart = new THREE.Vector2(),
51
	_zoomEnd = new THREE.Vector2(),
52
53
	_touchZoomDistanceStart = 0,
54
	_touchZoomDistanceEnd = 0,
55
56
	_panStart = new THREE.Vector2(),
57
	_panEnd = new THREE.Vector2();
58
59
	// for reset
60
61
	this.target0 = this.target.clone();
62
	this.position0 = this.object.position.clone();
63
	this.up0 = this.object.up.clone();
64
65
	// events
66
67
	var changeEvent = { type: 'change' };
68
69
70
	// methods
71
72
	this.handleResize = function () {
73
74
		this.screen.width = window.innerWidth;
75
		this.screen.height = window.innerHeight;
76
77
		this.screen.offsetLeft = 0;
78
		this.screen.offsetTop = 0;
79
80
		this.radius = ( this.screen.width + this.screen.height ) / 4;
81
82
	};
83
84
	this.handleEvent = function ( event ) {
85
86
		if ( typeof this[ event.type ] == 'function' ) {
87
88
			this[ event.type ]( event );
89
90
		}
91
92
	};
93
94
	this.getMouseOnScreen = function ( clientX, clientY ) {
95
96
		return new THREE.Vector2(
0 ignored issues
show
Bug introduced by
The variable THREE seems to be never declared. If this is a global, consider adding a /** global: THREE */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
97
			( clientX - _this.screen.offsetLeft ) / _this.radius * 0.5,
98
			( clientY - _this.screen.offsetTop ) / _this.radius * 0.5
99
		);
100
101
	};
102
103
	this.getMouseProjectionOnBall = function ( clientX, clientY ) {
104
105
		var mouseOnBall = new THREE.Vector3(
0 ignored issues
show
Bug introduced by
The variable THREE seems to be never declared. If this is a global, consider adding a /** global: THREE */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
106
			( clientX - _this.screen.width * 0.5 - _this.screen.offsetLeft ) / _this.radius,
107
			( _this.screen.height * 0.5 + _this.screen.offsetTop - clientY ) / _this.radius,
108
			0.0
109
		);
110
111
		var length = mouseOnBall.length();
112
113
		if ( length > 1.0 ) {
114
115
			mouseOnBall.normalize();
116
117
		} else {
118
119
			mouseOnBall.z = Math.sqrt( 1.0 - length * length );
120
121
		}
122
123
		_eye.copy( _this.object.position ).sub( _this.target );
124
125
		var projection = _this.object.up.clone().setLength( mouseOnBall.y );
126
		projection.add( _this.object.up.clone().cross( _eye ).setLength( mouseOnBall.x ) );
127
		projection.add( _eye.setLength( mouseOnBall.z ) );
128
129
		return projection;
130
131
	};
132
133
	this.rotateCamera = function () {
134
135
		var angle = Math.acos( _rotateStart.dot( _rotateEnd ) / _rotateStart.length() / _rotateEnd.length() );
136
137
		if ( angle ) {
138
139
			var axis = ( new THREE.Vector3() ).crossVectors( _rotateStart, _rotateEnd ).normalize(),
0 ignored issues
show
Bug introduced by
The variable THREE seems to be never declared. If this is a global, consider adding a /** global: THREE */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
140
				quaternion = new THREE.Quaternion();
141
142
			angle *= _this.rotateSpeed;
143
144
			quaternion.setFromAxisAngle( axis, -angle );
145
146
			_eye.applyQuaternion( quaternion );
147
			_this.object.up.applyQuaternion( quaternion );
148
149
			_rotateEnd.applyQuaternion( quaternion );
150
151
			if ( _this.staticMoving ) {
152
153
				_rotateStart.copy( _rotateEnd );
154
155
			} else {
156
157
				quaternion.setFromAxisAngle( axis, angle * ( _this.dynamicDampingFactor - 1.0 ) );
158
				_rotateStart.applyQuaternion( quaternion );
159
160
			}
161
162
		}
163
164
	};
165
166
	this.zoomCamera = function () {
167
168
		if ( _state === STATE.TOUCH_ZOOM ) {
169
170
			var factor = _touchZoomDistanceStart / _touchZoomDistanceEnd;
171
			_touchZoomDistanceStart = _touchZoomDistanceEnd;
172
			_eye.multiplyScalar( factor );
173
174
		} else {
175
176
			var factor = 1.0 + ( _zoomEnd.y - _zoomStart.y ) * _this.zoomSpeed;
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable factor already seems to be declared on line 170. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
177
178
			if ( factor !== 1.0 && factor > 0.0 ) {
179
180
				_eye.multiplyScalar( factor );
181
182
				if ( _this.staticMoving ) {
183
184
					_zoomStart.copy( _zoomEnd );
185
186
				} else {
187
188
					_zoomStart.y += ( _zoomEnd.y - _zoomStart.y ) * this.dynamicDampingFactor;
189
190
				}
191
192
			}
193
194
		}
195
196
	};
197
198
	this.panCamera = function () {
199
200
		var mouseChange = _panEnd.clone().sub( _panStart );
201
202
		if ( mouseChange.lengthSq() ) {
203
204
			mouseChange.multiplyScalar( _eye.length() * _this.panSpeed );
205
206
			var pan = _eye.clone().cross( _this.object.up ).setLength( mouseChange.x );
207
			pan.add( _this.object.up.clone().setLength( mouseChange.y ) );
208
209
			_this.object.position.add( pan );
210
			_this.target.add( pan );
211
212
			if ( _this.staticMoving ) {
213
214
				_panStart = _panEnd;
215
216
			} else {
217
218
				_panStart.add( mouseChange.subVectors( _panEnd, _panStart ).multiplyScalar( _this.dynamicDampingFactor ) );
219
220
			}
221
222
		}
223
224
	};
225
226
	this.checkDistances = function () {
227
228
		if ( !_this.noZoom || !_this.noPan ) {
229
230
			if ( _this.object.position.lengthSq() > _this.maxDistance * _this.maxDistance ) {
231
232
				_this.object.position.setLength( _this.maxDistance );
233
234
			}
235
236
			if ( _eye.lengthSq() < _this.minDistance * _this.minDistance ) {
237
238
				_this.object.position.addVectors( _this.target, _eye.setLength( _this.minDistance ) );
239
240
			}
241
242
		}
243
244
	};
245
246
	this.update = function () {
247
248
		_eye.subVectors( _this.object.position, _this.target );
249
250
		if ( !_this.noRotate ) {
251
252
			_this.rotateCamera();
253
254
		}
255
256
		if ( !_this.noZoom ) {
257
258
			_this.zoomCamera();
259
260
		}
261
262
		if ( !_this.noPan ) {
263
264
			_this.panCamera();
265
266
		}
267
268
		_this.object.position.addVectors( _this.target, _eye );
269
270
		_this.checkDistances();
271
272
		_this.object.lookAt( _this.target );
273
274
		if ( lastPosition.distanceToSquared( _this.object.position ) > 0 ) {
275
276
			_this.dispatchEvent( changeEvent );
277
278
			lastPosition.copy( _this.object.position );
279
280
		}
281
282
	};
283
284
	this.reset = function () {
285
286
		_state = STATE.NONE;
287
		_prevState = STATE.NONE;
288
289
		_this.target.copy( _this.target0 );
290
		_this.object.position.copy( _this.position0 );
291
		_this.object.up.copy( _this.up0 );
292
293
		_eye.subVectors( _this.object.position, _this.target );
294
295
		_this.object.lookAt( _this.target );
296
297
		_this.dispatchEvent( changeEvent );
298
299
		lastPosition.copy( _this.object.position );
300
301
	};
302
303
	// listeners
304
305
	function keydown( event ) {
306
307
		if ( _this.enabled === false ) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
308
309
		window.removeEventListener( 'keydown', keydown );
310
311
		_prevState = _state;
312
313
		if ( _state !== STATE.NONE ) {
314
315
			return;
0 ignored issues
show
Unused Code introduced by
This return has no effect and can be removed.
Loading history...
316
317
		} else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && !_this.noRotate ) {
318
319
			_state = STATE.ROTATE;
320
321
		} else if ( event.keyCode === _this.keys[ STATE.ZOOM ] && !_this.noZoom ) {
322
323
			_state = STATE.ZOOM;
324
325
		} else if ( event.keyCode === _this.keys[ STATE.PAN ] && !_this.noPan ) {
326
327
			_state = STATE.PAN;
328
329
		}
330
331
	}
332
333
	function keyup( event ) {
0 ignored issues
show
Unused Code introduced by
The parameter event is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
334
335
		if ( _this.enabled === false ) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
336
337
		_state = _prevState;
338
339
		window.addEventListener( 'keydown', keydown, false );
340
341
	}
342
343
	function mousedown( event ) {
344
345
		if ( _this.enabled === false ) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
346
347
		event.preventDefault();
348
		event.stopPropagation();
349
350
		if ( _state === STATE.NONE ) {
351
352
			_state = event.button;
353
354
		}
355
356
		if ( _state === STATE.ROTATE && !_this.noRotate ) {
357
358
			_rotateStart = _rotateEnd = _this.getMouseProjectionOnBall( event.clientX, event.clientY );
359
360
		} else if ( _state === STATE.ZOOM && !_this.noZoom ) {
361
362
			_zoomStart = _zoomEnd = _this.getMouseOnScreen( event.clientX, event.clientY );
363
364
		} else if ( _state === STATE.PAN && !_this.noPan ) {
365
366
			_panStart = _panEnd = _this.getMouseOnScreen( event.clientX, event.clientY );
367
368
		}
369
370
		document.addEventListener( 'mousemove', mousemove, false );
371
		document.addEventListener( 'mouseup', mouseup, false );
372
373
	}
374
375
	function mousemove( event ) {
376
377
		if ( _this.enabled === false ) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
378
379
		event.preventDefault();
380
		event.stopPropagation();
381
382
		if ( _state === STATE.ROTATE && !_this.noRotate ) {
383
384
			_rotateEnd = _this.getMouseProjectionOnBall( event.clientX, event.clientY );
385
386
		} else if ( _state === STATE.ZOOM && !_this.noZoom ) {
387
388
			_zoomEnd = _this.getMouseOnScreen( event.clientX, event.clientY );
389
390
		} else if ( _state === STATE.PAN && !_this.noPan ) {
391
392
			_panEnd = _this.getMouseOnScreen( event.clientX, event.clientY );
393
394
		}
395
396
	}
397
398
	function mouseup( event ) {
399
400
		if ( _this.enabled === false ) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
401
402
		event.preventDefault();
403
		event.stopPropagation();
404
405
		_state = STATE.NONE;
406
407
		document.removeEventListener( 'mousemove', mousemove );
408
		document.removeEventListener( 'mouseup', mouseup );
409
410
	}
411
412
	function mousewheel( event ) {
413
414
		if ( _this.enabled === false ) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
415
416
		event.preventDefault();
417
		event.stopPropagation();
418
419
		var delta = 0;
420
421
		if ( event.wheelDelta ) { // WebKit / Opera / Explorer 9
422
423
			delta = event.wheelDelta / 40;
424
425
		} else if ( event.detail ) { // Firefox
426
427
			delta = - event.detail / 3;
428
429
		}
430
431
		_zoomStart.y += delta * 0.01;
432
433
	}
434
435
	function touchstart( event ) {
436
437
		if ( _this.enabled === false ) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
438
439
		switch ( event.touches.length ) {
440
441
			case 1:
442
				_state = STATE.TOUCH_ROTATE;
443
				_rotateStart = _rotateEnd = _this.getMouseProjectionOnBall( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
444
				break;
445
446
			case 2:
447
				_state = STATE.TOUCH_ZOOM;
448
				var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
449
				var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
450
				_touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt( dx * dx + dy * dy );
451
				break;
452
453
			case 3:
454
				_state = STATE.TOUCH_PAN;
455
				_panStart = _panEnd = _this.getMouseOnScreen( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
456
				break;
457
458
			default:
459
				_state = STATE.NONE;
460
461
		}
462
463
	}
464
465
	function touchmove( event ) {
466
467
		if ( _this.enabled === false ) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
468
469
		event.preventDefault();
470
		event.stopPropagation();
471
472
		switch ( event.touches.length ) {
473
474
			case 1:
475
				_rotateEnd = _this.getMouseProjectionOnBall( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
476
				break;
477
478
			case 2:
479
				var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
480
				var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
481
				_touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy )
482
				break;
483
484
			case 3:
485
				_panEnd = _this.getMouseOnScreen( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
486
				break;
487
488
			default:
489
				_state = STATE.NONE;
490
491
		}
492
493
	}
494
495
	function touchend( event ) {
496
497
		if ( _this.enabled === false ) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
498
499
		switch ( event.touches.length ) {
0 ignored issues
show
Coding Style introduced by
As per coding-style, switch statements should have a default case.
Loading history...
500
501
			case 1:
502
				_rotateStart = _rotateEnd = _this.getMouseProjectionOnBall( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
503
				break;
504
505
			case 2:
506
				_touchZoomDistanceStart = _touchZoomDistanceEnd = 0;
507
				break;
508
509
			case 3:
510
				_panStart = _panEnd = _this.getMouseOnScreen( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
511
				break;
512
513
		}
514
515
		_state = STATE.NONE;
516
517
	}
518
519
	this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
520
521
	this.domElement.addEventListener( 'mousedown', mousedown, false );
522
523
	this.domElement.addEventListener( 'mousewheel', mousewheel, false );
524
	this.domElement.addEventListener( 'DOMMouseScroll', mousewheel, false ); // firefox
525
526
	this.domElement.addEventListener( 'touchstart', touchstart, false );
527
	this.domElement.addEventListener( 'touchend', touchend, false );
528
	this.domElement.addEventListener( 'touchmove', touchmove, false );
529
530
	window.addEventListener( 'keydown', keydown, false );
531
	window.addEventListener( 'keyup', keyup, false );
532
533
	this.handleResize();
534
535
};
536
537
THREE.TrackballControls.prototype = Object.create( THREE.EventDispatcher.prototype );
0 ignored issues
show
Bug introduced by
The variable THREE seems to be never declared. If this is a global, consider adding a /** global: THREE */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
538