elation-engine 0.9.113 → 0.9.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/css/systems/render.css +5 -1
  2. package/package.json +1 -1
  3. package/scripts/assets.js +103 -20
  4. package/scripts/assetworker.js +18 -1
  5. package/scripts/external/holoplay.js +1494 -0
  6. package/scripts/external/octree.js +0 -0
  7. package/scripts/external/three/CSS3DRenderer.js +46 -43
  8. package/scripts/external/three/CubemapToEquirectangular.js +1 -1
  9. package/scripts/external/three/three-extras.js +1553 -392
  10. package/scripts/external/three/three-icosa.js +2575 -0
  11. package/scripts/external/three/three-loaders.js +925 -133
  12. package/scripts/external/three/three-postprocessing.js +3 -3
  13. package/scripts/external/three/three-r116dev.js +50930 -0
  14. package/scripts/external/three/three-spotlighttextures.js +50953 -0
  15. package/scripts/external/three/three-vrm.js +2 -2
  16. package/scripts/external/three/three-working.js +35968 -0
  17. package/scripts/external/three/three.js +38532 -24087
  18. package/scripts/external/three-mesh-bvh.js +5370 -0
  19. package/scripts/external/three-old/BVHLoader.js +406 -0
  20. package/scripts/external/three-old/ColladaLoader.js +5519 -0
  21. package/scripts/external/three-old/ColladaLoader2.js +1694 -0
  22. package/scripts/external/three-old/CubemapToEquirectangular.js +188 -0
  23. package/scripts/external/three-old/DDSLoader.js +269 -0
  24. package/scripts/external/three-old/FBXLoader-mine.js +5063 -0
  25. package/scripts/external/three-old/FBXLoader.js +5112 -0
  26. package/scripts/external/three-old/FlyControls.js +295 -0
  27. package/scripts/external/three-old/GLTF2Loader.js +2950 -0
  28. package/scripts/external/three-old/GLTFLoader.js +2213 -0
  29. package/scripts/external/three-old/JSONLoader.js +435 -0
  30. package/scripts/external/three-old/MTLLoader.js +533 -0
  31. package/scripts/external/three-old/OBJLoader-experimental.js +874 -0
  32. package/scripts/external/three-old/OBJLoader-working.js +727 -0
  33. package/scripts/external/three-old/OBJLoader.js +723 -0
  34. package/scripts/external/three-old/OBJMTLLoader.js +440 -0
  35. package/scripts/external/three-old/OrbitControls.js +592 -0
  36. package/scripts/external/three-old/PLYLoader.js +517 -0
  37. package/scripts/external/three-old/TransformControls.js +1100 -0
  38. package/scripts/external/three-old/VRMLLoader.js +1021 -0
  39. package/scripts/external/three-old/glTFLoader-combined.js +2513 -0
  40. package/scripts/external/three-old/nodethree.js +44018 -0
  41. package/scripts/external/three-old/render/BleachBypassShader.js +64 -0
  42. package/scripts/external/three-old/render/BloomPass.js +116 -0
  43. package/scripts/external/three-old/render/CSS3DRenderer.js +310 -0
  44. package/scripts/external/three-old/render/ClearPass.js +44 -0
  45. package/scripts/external/three-old/render/ConvolutionShader.js +101 -0
  46. package/scripts/external/three-old/render/CopyShader.js +46 -0
  47. package/scripts/external/three-old/render/EffectComposer.js +211 -0
  48. package/scripts/external/three-old/render/FXAAShader.js +88 -0
  49. package/scripts/external/three-old/render/FilmPass.js +60 -0
  50. package/scripts/external/three-old/render/FilmShader.js +104 -0
  51. package/scripts/external/three-old/render/ManualMSAARenderPass.js +168 -0
  52. package/scripts/external/three-old/render/MaskPass.js +97 -0
  53. package/scripts/external/three-old/render/OculusRenderPass.js +84 -0
  54. package/scripts/external/three-old/render/OculusRiftEffect.js +240 -0
  55. package/scripts/external/three-old/render/PortalRenderPass.js +166 -0
  56. package/scripts/external/three-old/render/RecordingPass.js +208 -0
  57. package/scripts/external/three-old/render/RenderPass.js +57 -0
  58. package/scripts/external/three-old/render/SSAOShader.js +259 -0
  59. package/scripts/external/three-old/render/SepiaShader.js +54 -0
  60. package/scripts/external/three-old/render/ShaderPass.js +66 -0
  61. package/scripts/external/three-old/render/VREffect.js +482 -0
  62. package/scripts/external/three-old/shimthree.js +23 -0
  63. package/scripts/external/three-old/stats.js +6 -0
  64. package/scripts/external/three-old/three-88dev.js +45004 -0
  65. package/scripts/external/three-old/three-backgroundoptimization.js +44432 -0
  66. package/scripts/external/three-old/three-updates.js +44735 -0
  67. package/scripts/external/three-old/three-working.js +44719 -0
  68. package/scripts/external/three-old/three.js +44431 -0
  69. package/scripts/external/three-old/threex.rendererstats.js +66 -0
  70. package/scripts/external/three-old/tween.js +13 -0
  71. package/scripts/external/webvr-polyfill-new.js +3497 -0
  72. package/scripts/external/webvr-polyfill-newest.js +3491 -0
  73. package/scripts/external/webvr-polyfill-old.js +6337 -0
  74. package/scripts/geometries.js +2 -2
  75. package/scripts/math.js +6 -6
  76. package/scripts/systems/admin.js +1 -1
  77. package/scripts/systems/controls.js +6 -4
  78. package/scripts/systems/physics.js +10 -10
  79. package/scripts/systems/render.js +58 -20
  80. package/scripts/systems/render2.js +38 -0
  81. package/scripts/things/camera.js +6 -1
  82. package/scripts/things/generic-trackedvectors.js +1875 -0
  83. package/scripts/things/generic.js +3 -4
  84. package/scripts/things/label2d.js +1 -1
  85. package/scripts/things/leapmotion.js +6 -6
  86. package/scripts/things/menu.js +1 -1
  87. package/scripts/things/player-bak.js +638 -0
  88. package/scripts/things/player.js +28 -10
  89. package/scripts/things/skysphere.js +1 -1
  90. package/scripts/things/terrain.js +1 -1
  91. package/scripts/things/text.js +1 -1
@@ -0,0 +1,592 @@
1
+ /**
2
+ * @author qiao / https://github.com/qiao
3
+ * @author mrdoob / http://mrdoob.com
4
+ * @author alteredq / http://alteredqualia.com/
5
+ * @author WestLangley / http://github.com/WestLangley
6
+ * @author erich666 / http://erichaines.com
7
+ */
8
+ /*global THREE, console */
9
+
10
+ // This set of controls performs orbiting, dollying (zooming), and panning. It maintains
11
+ // the "up" direction as +Y, unlike the TrackballControls. Touch on tablet and phones is
12
+ // supported.
13
+ //
14
+ // Orbit - left mouse / touch: one finger move
15
+ // Zoom - middle mouse, or mousewheel / touch: two finger spread or squish
16
+ // Pan - right mouse, or arrow keys / touch: three finter swipe
17
+ //
18
+ // This is a drop-in replacement for (most) TrackballControls used in examples.
19
+ // That is, include this js file and wherever you see:
20
+ // controls = new THREE.TrackballControls( camera );
21
+ // controls.target.z = 150;
22
+ // Simple substitute "OrbitControls" and the control should work as-is.
23
+
24
+ THREE.OrbitControls = function ( object, domElement ) {
25
+
26
+ this.object = object;
27
+ this.domElement = ( domElement !== undefined ) ? domElement : document;
28
+
29
+ // API
30
+
31
+ // Set to false to disable this control
32
+ this.enabled = true;
33
+
34
+ // "target" sets the location of focus, where the control orbits around
35
+ // and where it pans with respect to.
36
+ this.target = new THREE.Vector3();
37
+ // center is old, deprecated; use "target" instead
38
+ this.center = this.target;
39
+
40
+ // This option actually enables dollying in and out; left as "zoom" for
41
+ // backwards compatibility
42
+ this.noZoom = false;
43
+ this.zoomSpeed = 1.0;
44
+ // Limits to how far you can dolly in and out
45
+ this.minDistance = 0;
46
+ this.maxDistance = Infinity;
47
+
48
+ // Set to true to disable this control
49
+ this.noRotate = false;
50
+ this.rotateSpeed = 1.0;
51
+
52
+ // Set to true to disable this control
53
+ this.noPan = false;
54
+ this.keyPanSpeed = 7.0; // pixels moved per arrow key push
55
+
56
+ // Set to true to automatically rotate around the target
57
+ this.autoRotate = false;
58
+ this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60
59
+
60
+ // How far you can orbit vertically, upper and lower limits.
61
+ // Range is 0 to Math.PI radians.
62
+ this.minPolarAngle = 0; // radians
63
+ this.maxPolarAngle = Math.PI; // radians
64
+
65
+ // Set to true to disable use of the keys
66
+ this.noKeys = false;
67
+ // The four arrow keys
68
+ this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40, W: 87, A: 65, S: 83, D: 68, Q: 81, E: 69 };
69
+
70
+ ////////////
71
+ // internals
72
+
73
+ var scope = this;
74
+
75
+ var EPS = 0.000001;
76
+
77
+ var rotateStart = new THREE.Vector2();
78
+ var rotateEnd = new THREE.Vector2();
79
+ var rotateDelta = new THREE.Vector2();
80
+
81
+ var panStart = new THREE.Vector2();
82
+ var panEnd = new THREE.Vector2();
83
+ var panDelta = new THREE.Vector2();
84
+
85
+ var dollyStart = new THREE.Vector2();
86
+ var dollyEnd = new THREE.Vector2();
87
+ var dollyDelta = new THREE.Vector2();
88
+
89
+ var phiDelta = 0;
90
+ var thetaDelta = 0;
91
+ var scale = 1;
92
+ var pan = new THREE.Vector3();
93
+
94
+ var lastPosition = new THREE.Vector3();
95
+
96
+ var STATE = { NONE : -1, ROTATE : 0, DOLLY : 1, PAN : 2, TOUCH_ROTATE : 3, TOUCH_DOLLY : 4, TOUCH_PAN : 5 };
97
+ var state = STATE.NONE;
98
+
99
+ // events
100
+
101
+ var changeEvent = { type: 'change' };
102
+
103
+
104
+ this.rotateLeft = function ( angle ) {
105
+
106
+ if ( angle === undefined ) {
107
+
108
+ angle = getAutoRotationAngle();
109
+
110
+ }
111
+
112
+ thetaDelta -= angle;
113
+
114
+ };
115
+
116
+ this.rotateUp = function ( angle ) {
117
+
118
+ if ( angle === undefined ) {
119
+
120
+ angle = getAutoRotationAngle();
121
+
122
+ }
123
+
124
+ phiDelta -= angle;
125
+
126
+ };
127
+
128
+ // pass in distance in world space to move left
129
+ this.panLeft = function ( distance ) {
130
+
131
+ var panOffset = new THREE.Vector3();
132
+ var te = this.object.matrix.elements;
133
+ // get X column of matrix
134
+ panOffset.set( te[0], te[1], te[2] );
135
+ panOffset.multiplyScalar(-distance);
136
+
137
+ pan.add( panOffset );
138
+
139
+ };
140
+
141
+ // pass in distance in world space to move up
142
+ this.panUp = function ( distance ) {
143
+
144
+ var panOffset = new THREE.Vector3();
145
+ var te = this.object.matrix.elements;
146
+ // get Y column of matrix
147
+ panOffset.set( te[4], te[5], te[6] );
148
+ panOffset.multiplyScalar(distance);
149
+
150
+ pan.add( panOffset );
151
+ };
152
+
153
+ // main entry point; pass in Vector2 of change desired in pixel space,
154
+ // right and down are positive
155
+ this.pan = function ( delta ) {
156
+
157
+ var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
158
+
159
+ if ( scope.object.fov !== undefined ) {
160
+
161
+ // perspective
162
+ var position = scope.object.position;
163
+ var offset = position.clone().sub( scope.target );
164
+ var targetDistance = offset.length();
165
+
166
+ // half of the fov is center to top of screen
167
+ targetDistance *= Math.tan( (scope.object.fov/2) * Math.PI / 180.0 );
168
+ // we actually don't use screenWidth, since perspective camera is fixed to screen height
169
+ scope.panLeft( 2 * delta.x * targetDistance / element.clientHeight );
170
+ scope.panUp( 2 * delta.y * targetDistance / element.clientHeight );
171
+
172
+ } else if ( scope.object.top !== undefined ) {
173
+
174
+ // orthographic
175
+ scope.panLeft( delta.x * (scope.object.right - scope.object.left) / element.clientWidth );
176
+ scope.panUp( delta.y * (scope.object.top - scope.object.bottom) / element.clientHeight );
177
+
178
+ } else {
179
+
180
+ // camera neither orthographic or perspective - warn user
181
+ console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );
182
+
183
+ }
184
+
185
+ };
186
+
187
+ this.dollyIn = function ( dollyScale ) {
188
+
189
+ if ( dollyScale === undefined ) {
190
+
191
+ dollyScale = getZoomScale();
192
+
193
+ }
194
+
195
+ scale /= dollyScale;
196
+
197
+ scope.update();
198
+
199
+ };
200
+
201
+ this.dollyOut = function ( dollyScale ) {
202
+
203
+ if ( dollyScale === undefined ) {
204
+
205
+ dollyScale = getZoomScale();
206
+
207
+ }
208
+
209
+ scale *= dollyScale;
210
+
211
+ scope.update();
212
+
213
+ };
214
+
215
+ this.update = function () {
216
+
217
+ var position = this.object.position;
218
+ var offset = position.clone().sub( this.target );
219
+
220
+ // angle from z-axis around y-axis
221
+
222
+ var theta = Math.atan2( offset.x, offset.z );
223
+
224
+ // angle from y-axis
225
+
226
+ var phi = Math.atan2( Math.sqrt( offset.x * offset.x + offset.z * offset.z ), offset.y );
227
+
228
+ if ( this.autoRotate ) {
229
+
230
+ this.rotateLeft( getAutoRotationAngle() );
231
+
232
+ }
233
+
234
+ theta += thetaDelta;
235
+ phi += phiDelta;
236
+
237
+ // restrict phi to be between desired limits
238
+ phi = Math.max( this.minPolarAngle, Math.min( this.maxPolarAngle, phi ) );
239
+
240
+ // restrict phi to be betwee EPS and PI-EPS
241
+ phi = Math.max( EPS, Math.min( Math.PI - EPS, phi ) );
242
+
243
+ var radius = offset.length() * scale;
244
+
245
+ // restrict radius to be between desired limits
246
+ radius = Math.max( this.minDistance, Math.min( this.maxDistance, radius ) );
247
+
248
+ // move target to panned location
249
+ this.target.add( pan );
250
+
251
+ offset.x = radius * Math.sin( phi ) * Math.sin( theta );
252
+ offset.y = radius * Math.cos( phi );
253
+ offset.z = radius * Math.sin( phi ) * Math.cos( theta );
254
+
255
+ position.copy( this.target ).add( offset );
256
+
257
+ this.object.lookAt( this.target );
258
+
259
+ thetaDelta = 0;
260
+ phiDelta = 0;
261
+ scale = 1;
262
+ pan.set(0,0,0);
263
+
264
+ if ( lastPosition.distanceTo( this.object.position ) > EPS ) {
265
+
266
+ changeEvent.data = { lastPosition: lastPosition.toArray(), position: this.object.position.toArray(), distance: lastPosition.distanceTo( this.object.position ) };
267
+ this.dispatchEvent( changeEvent );
268
+
269
+ lastPosition.copy( this.object.position );
270
+
271
+ }
272
+
273
+ };
274
+
275
+
276
+ function getAutoRotationAngle() {
277
+
278
+ return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
279
+
280
+ }
281
+
282
+ function getZoomScale() {
283
+
284
+ return Math.pow( 0.95, scope.zoomSpeed );
285
+
286
+ }
287
+
288
+ function onMouseDown( event ) {
289
+
290
+ if ( scope.enabled === false ) { return; }
291
+ event.preventDefault();
292
+
293
+ if ( event.button === 0 ) {
294
+ if ( scope.noRotate === true ) { return; }
295
+
296
+ state = STATE.ROTATE;
297
+
298
+ rotateStart.set( event.clientX, event.clientY );
299
+
300
+ } else if ( event.button === 1 ) {
301
+ if ( scope.noZoom === true ) { return; }
302
+
303
+ state = STATE.DOLLY;
304
+
305
+ dollyStart.set( event.clientX, event.clientY );
306
+
307
+ } else if ( event.button === 2 ) {
308
+ if ( scope.noPan === true ) { return; }
309
+
310
+ state = STATE.PAN;
311
+
312
+ panStart.set( event.clientX, event.clientY );
313
+
314
+ }
315
+
316
+ // Greggman fix: https://github.com/greggman/three.js/commit/fde9f9917d6d8381f06bf22cdff766029d1761be
317
+ document.addEventListener( 'mousemove', onMouseMove, false );
318
+ document.addEventListener( 'mouseup', onMouseUp, false );
319
+
320
+ }
321
+
322
+ function onMouseMove( event ) {
323
+
324
+ if ( scope.enabled === false ) return;
325
+
326
+ //event.preventDefault();
327
+
328
+ var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
329
+
330
+ if ( state === STATE.ROTATE ) {
331
+
332
+ if ( scope.noRotate === true ) return;
333
+
334
+ rotateEnd.set( event.clientX, event.clientY );
335
+ rotateDelta.subVectors( rotateEnd, rotateStart );
336
+
337
+ // rotating across whole screen goes 360 degrees around
338
+ scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
339
+ // rotating up and down along whole screen attempts to go 360, but limited to 180
340
+ scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
341
+
342
+ rotateStart.copy( rotateEnd );
343
+
344
+ } else if ( state === STATE.DOLLY ) {
345
+
346
+ if ( scope.noZoom === true ) return;
347
+
348
+ dollyEnd.set( event.clientX, event.clientY );
349
+ dollyDelta.subVectors( dollyEnd, dollyStart );
350
+
351
+ if ( dollyDelta.y > 0 ) {
352
+
353
+ scope.dollyIn();
354
+
355
+ } else {
356
+
357
+ scope.dollyOut();
358
+
359
+ }
360
+
361
+ dollyStart.copy( dollyEnd );
362
+
363
+ } else if ( state === STATE.PAN ) {
364
+
365
+ if ( scope.noPan === true ) return;
366
+
367
+ panEnd.set( event.clientX, event.clientY );
368
+ panDelta.subVectors( panEnd, panStart );
369
+
370
+ scope.pan( panDelta );
371
+
372
+ panStart.copy( panEnd );
373
+
374
+ }
375
+
376
+ // Greggman fix: https://github.com/greggman/three.js/commit/fde9f9917d6d8381f06bf22cdff766029d1761be
377
+ scope.update();
378
+
379
+ }
380
+
381
+ function onMouseUp( /* event */ ) {
382
+
383
+ if ( scope.enabled === false ) return;
384
+
385
+ // Greggman fix: https://github.com/greggman/three.js/commit/fde9f9917d6d8381f06bf22cdff766029d1761be
386
+ scope.domElement.removeEventListener( 'mousemove', onMouseMove, false );
387
+ scope.domElement.removeEventListener( 'mouseup', onMouseUp, false );
388
+
389
+ state = STATE.NONE;
390
+
391
+ }
392
+
393
+ function onMouseWheel( event ) {
394
+
395
+ if ( scope.enabled === false || scope.noZoom === true ) return;
396
+
397
+ var delta = 0;
398
+
399
+ if ( event.wheelDelta ) { // WebKit / Opera / Explorer 9
400
+
401
+ delta = event.wheelDelta;
402
+
403
+ } else if ( event.detail ) { // Firefox
404
+
405
+ delta = - event.detail;
406
+
407
+ }
408
+
409
+ if ( delta > 0 ) {
410
+
411
+ scope.dollyOut();
412
+
413
+ } else {
414
+
415
+ scope.dollyIn();
416
+
417
+ }
418
+
419
+ }
420
+
421
+ function onKeyDown( event ) {
422
+
423
+ if ( scope.enabled === false ) { return; }
424
+ if ( scope.noKeys === true ) { return; }
425
+ if ( scope.noPan === true ) { return; }
426
+
427
+ // pan a pixel - I guess for precise positioning?
428
+ // Greggman fix: https://github.com/greggman/three.js/commit/fde9f9917d6d8381f06bf22cdff766029d1761be
429
+ var needUpdate = false;
430
+
431
+ switch ( event.keyCode ) {
432
+
433
+ case scope.keys.UP:
434
+ case scope.keys.W:
435
+ scope.pan( new THREE.Vector2( 0, scope.keyPanSpeed ) );
436
+ needUpdate = true;
437
+ break;
438
+ case scope.keys.BOTTOM:
439
+ case scope.keys.S:
440
+ scope.pan( new THREE.Vector2( 0, -scope.keyPanSpeed ) );
441
+ needUpdate = true;
442
+ break;
443
+ case scope.keys.LEFT:
444
+ case scope.keys.A:
445
+ scope.pan( new THREE.Vector2( scope.keyPanSpeed, 0 ) );
446
+ needUpdate = true;
447
+ break;
448
+ case scope.keys.RIGHT:
449
+ case scope.keys.D:
450
+ scope.pan( new THREE.Vector2( -scope.keyPanSpeed, 0 ) );
451
+ needUpdate = true;
452
+ break;
453
+ }
454
+
455
+ // Greggman fix: https://github.com/greggman/three.js/commit/fde9f9917d6d8381f06bf22cdff766029d1761be
456
+ if ( needUpdate ) {
457
+
458
+ scope.update();
459
+
460
+ }
461
+
462
+ }
463
+
464
+ function touchstart( event ) {
465
+
466
+ if ( scope.enabled === false ) { return; }
467
+
468
+ switch ( event.touches.length ) {
469
+
470
+ case 1: // one-fingered touch: rotate
471
+ if ( scope.noRotate === true ) { return; }
472
+
473
+ state = STATE.TOUCH_ROTATE;
474
+
475
+ rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
476
+ break;
477
+
478
+ case 2: // two-fingered touch: dolly
479
+ if ( scope.noZoom === true ) { return; }
480
+
481
+ state = STATE.TOUCH_DOLLY;
482
+
483
+ var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
484
+ var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
485
+ var distance = Math.sqrt( dx * dx + dy * dy );
486
+ dollyStart.set( 0, distance );
487
+ break;
488
+
489
+ case 3: // three-fingered touch: pan
490
+ if ( scope.noPan === true ) { return; }
491
+
492
+ state = STATE.TOUCH_PAN;
493
+
494
+ panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
495
+ break;
496
+
497
+ default:
498
+ state = STATE.NONE;
499
+
500
+ }
501
+ }
502
+
503
+ function touchmove( event ) {
504
+
505
+ if ( scope.enabled === false ) { return; }
506
+
507
+ event.preventDefault();
508
+ event.stopPropagation();
509
+
510
+ var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
511
+
512
+ switch ( event.touches.length ) {
513
+
514
+ case 1: // one-fingered touch: rotate
515
+ if ( scope.noRotate === true ) { return; }
516
+ if ( state !== STATE.TOUCH_ROTATE ) { return; }
517
+
518
+ rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
519
+ rotateDelta.subVectors( rotateEnd, rotateStart );
520
+
521
+ // rotating across whole screen goes 360 degrees around
522
+ scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
523
+ // rotating up and down along whole screen attempts to go 360, but limited to 180
524
+ scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
525
+
526
+ rotateStart.copy( rotateEnd );
527
+ break;
528
+
529
+ case 2: // two-fingered touch: dolly
530
+ if ( scope.noZoom === true ) { return; }
531
+ if ( state !== STATE.TOUCH_DOLLY ) { return; }
532
+
533
+ var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
534
+ var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
535
+ var distance = Math.sqrt( dx * dx + dy * dy );
536
+
537
+ dollyEnd.set( 0, distance );
538
+ dollyDelta.subVectors( dollyEnd, dollyStart );
539
+
540
+ if ( dollyDelta.y > 0 ) {
541
+
542
+ scope.dollyOut();
543
+
544
+ } else {
545
+
546
+ scope.dollyIn();
547
+
548
+ }
549
+
550
+ dollyStart.copy( dollyEnd );
551
+ break;
552
+
553
+ case 3: // three-fingered touch: pan
554
+ if ( scope.noPan === true ) { return; }
555
+ if ( state !== STATE.TOUCH_PAN ) { return; }
556
+
557
+ panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
558
+ panDelta.subVectors( panEnd, panStart );
559
+
560
+ scope.pan( panDelta );
561
+
562
+ panStart.copy( panEnd );
563
+ break;
564
+
565
+ default:
566
+ state = STATE.NONE;
567
+
568
+ }
569
+
570
+ }
571
+
572
+ function touchend( /* event */ ) {
573
+
574
+ if ( scope.enabled === false ) { return; }
575
+
576
+ state = STATE.NONE;
577
+ }
578
+
579
+ this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
580
+ this.domElement.addEventListener( 'mousedown', onMouseDown, false );
581
+ this.domElement.addEventListener( 'mousewheel', onMouseWheel, false );
582
+ this.domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox
583
+
584
+ window.addEventListener( 'keydown', onKeyDown, false );
585
+
586
+ this.domElement.addEventListener( 'touchstart', touchstart, false );
587
+ this.domElement.addEventListener( 'touchend', touchend, false );
588
+ this.domElement.addEventListener( 'touchmove', touchmove, false );
589
+
590
+ };
591
+
592
+ THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );