local-knowledge-graph 1.5.0
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.
- package/.opencode/skill/kg-triples/SKILL.md +55 -0
- package/HELP.md +112 -0
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/bin/cli.js +86 -0
- package/lib/agent.js +211 -0
- package/lib/ask.js +290 -0
- package/lib/db.js +613 -0
- package/lib/embeddings.js +166 -0
- package/lib/git.js +175 -0
- package/lib/importer.js +54 -0
- package/lib/inference.js +123 -0
- package/lib/paths.js +53 -0
- package/lib/rdf.js +64 -0
- package/lib/updater.js +144 -0
- package/lib/validator.js +146 -0
- package/lib/vectors.js +68 -0
- package/lib/viewer.js +33 -0
- package/lib/viewer_template.html +283 -0
- package/mcp/server.js +262 -0
- package/package.json +44 -0
- package/public/app.js +1761 -0
- package/public/index.html +238 -0
- package/public/style.css +374 -0
- package/public/vendor/OrbitControls.js +1045 -0
- package/public/vendor/three.min.js +6 -0
- package/server.js +625 -0
- package/tools/ego.js +122 -0
- package/tools/search.js +101 -0
|
@@ -0,0 +1,1045 @@
|
|
|
1
|
+
( function () {
|
|
2
|
+
|
|
3
|
+
// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
|
|
4
|
+
//
|
|
5
|
+
// Orbit - left mouse / touch: one-finger move
|
|
6
|
+
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
|
|
7
|
+
// Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move
|
|
8
|
+
|
|
9
|
+
const _changeEvent = {
|
|
10
|
+
type: 'change'
|
|
11
|
+
};
|
|
12
|
+
const _startEvent = {
|
|
13
|
+
type: 'start'
|
|
14
|
+
};
|
|
15
|
+
const _endEvent = {
|
|
16
|
+
type: 'end'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
class OrbitControls extends THREE.EventDispatcher {
|
|
20
|
+
|
|
21
|
+
constructor( object, domElement ) {
|
|
22
|
+
|
|
23
|
+
super();
|
|
24
|
+
if ( domElement === undefined ) console.warn( 'THREE.OrbitControls: The second parameter "domElement" is now mandatory.' );
|
|
25
|
+
if ( domElement === document ) console.error( 'THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.' );
|
|
26
|
+
this.object = object;
|
|
27
|
+
this.domElement = domElement; // Set to false to disable this control
|
|
28
|
+
|
|
29
|
+
this.enabled = true; // "target" sets the location of focus, where the object orbits around
|
|
30
|
+
|
|
31
|
+
this.target = new THREE.Vector3(); // How far you can dolly in and out ( PerspectiveCamera only )
|
|
32
|
+
|
|
33
|
+
this.minDistance = 0;
|
|
34
|
+
this.maxDistance = Infinity; // How far you can zoom in and out ( OrthographicCamera only )
|
|
35
|
+
|
|
36
|
+
this.minZoom = 0;
|
|
37
|
+
this.maxZoom = Infinity; // How far you can orbit vertically, upper and lower limits.
|
|
38
|
+
// Range is 0 to Math.PI radians.
|
|
39
|
+
|
|
40
|
+
this.minPolarAngle = 0; // radians
|
|
41
|
+
|
|
42
|
+
this.maxPolarAngle = Math.PI; // radians
|
|
43
|
+
// How far you can orbit horizontally, upper and lower limits.
|
|
44
|
+
// If set, the interval [ min, max ] must be a sub-interval of [ - 2 PI, 2 PI ], with ( max - min < 2 PI )
|
|
45
|
+
|
|
46
|
+
this.minAzimuthAngle = - Infinity; // radians
|
|
47
|
+
|
|
48
|
+
this.maxAzimuthAngle = Infinity; // radians
|
|
49
|
+
// Set to true to enable damping (inertia)
|
|
50
|
+
// If damping is enabled, you must call controls.update() in your animation loop
|
|
51
|
+
|
|
52
|
+
this.enableDamping = false;
|
|
53
|
+
this.dampingFactor = 0.05; // This option actually enables dollying in and out; left as "zoom" for backwards compatibility.
|
|
54
|
+
// Set to false to disable zooming
|
|
55
|
+
|
|
56
|
+
this.enableZoom = true;
|
|
57
|
+
this.zoomSpeed = 1.0; // Set to false to disable rotating
|
|
58
|
+
|
|
59
|
+
this.enableRotate = true;
|
|
60
|
+
this.rotateSpeed = 1.0; // Set to false to disable panning
|
|
61
|
+
|
|
62
|
+
this.enablePan = true;
|
|
63
|
+
this.panSpeed = 1.0;
|
|
64
|
+
this.screenSpacePanning = true; // if false, pan orthogonal to world-space direction camera.up
|
|
65
|
+
|
|
66
|
+
this.keyPanSpeed = 7.0; // pixels moved per arrow key push
|
|
67
|
+
// Set to true to automatically rotate around the target
|
|
68
|
+
// If auto-rotate is enabled, you must call controls.update() in your animation loop
|
|
69
|
+
|
|
70
|
+
this.autoRotate = false;
|
|
71
|
+
this.autoRotateSpeed = 2.0; // 30 seconds per orbit when fps is 60
|
|
72
|
+
// The four arrow keys
|
|
73
|
+
|
|
74
|
+
this.keys = {
|
|
75
|
+
LEFT: 'ArrowLeft',
|
|
76
|
+
UP: 'ArrowUp',
|
|
77
|
+
RIGHT: 'ArrowRight',
|
|
78
|
+
BOTTOM: 'ArrowDown'
|
|
79
|
+
}; // Mouse buttons
|
|
80
|
+
|
|
81
|
+
this.mouseButtons = {
|
|
82
|
+
LEFT: THREE.MOUSE.ROTATE,
|
|
83
|
+
MIDDLE: THREE.MOUSE.DOLLY,
|
|
84
|
+
RIGHT: THREE.MOUSE.PAN
|
|
85
|
+
}; // Touch fingers
|
|
86
|
+
|
|
87
|
+
this.touches = {
|
|
88
|
+
ONE: THREE.TOUCH.ROTATE,
|
|
89
|
+
TWO: THREE.TOUCH.DOLLY_PAN
|
|
90
|
+
}; // for reset
|
|
91
|
+
|
|
92
|
+
this.target0 = this.target.clone();
|
|
93
|
+
this.position0 = this.object.position.clone();
|
|
94
|
+
this.zoom0 = this.object.zoom; // the target DOM element for key events
|
|
95
|
+
|
|
96
|
+
this._domElementKeyEvents = null; //
|
|
97
|
+
// public methods
|
|
98
|
+
//
|
|
99
|
+
|
|
100
|
+
this.getPolarAngle = function () {
|
|
101
|
+
|
|
102
|
+
return spherical.phi;
|
|
103
|
+
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
this.getAzimuthalAngle = function () {
|
|
107
|
+
|
|
108
|
+
return spherical.theta;
|
|
109
|
+
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
this.listenToKeyEvents = function ( domElement ) {
|
|
113
|
+
|
|
114
|
+
domElement.addEventListener( 'keydown', onKeyDown );
|
|
115
|
+
this._domElementKeyEvents = domElement;
|
|
116
|
+
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
this.saveState = function () {
|
|
120
|
+
|
|
121
|
+
scope.target0.copy( scope.target );
|
|
122
|
+
scope.position0.copy( scope.object.position );
|
|
123
|
+
scope.zoom0 = scope.object.zoom;
|
|
124
|
+
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
this.reset = function () {
|
|
128
|
+
|
|
129
|
+
scope.target.copy( scope.target0 );
|
|
130
|
+
scope.object.position.copy( scope.position0 );
|
|
131
|
+
scope.object.zoom = scope.zoom0;
|
|
132
|
+
scope.object.updateProjectionMatrix();
|
|
133
|
+
scope.dispatchEvent( _changeEvent );
|
|
134
|
+
scope.update();
|
|
135
|
+
state = STATE.NONE;
|
|
136
|
+
|
|
137
|
+
}; // this method is exposed, but perhaps it would be better if we can make it private...
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
this.update = function () {
|
|
141
|
+
|
|
142
|
+
const offset = new THREE.Vector3(); // so camera.up is the orbit axis
|
|
143
|
+
|
|
144
|
+
const quat = new THREE.Quaternion().setFromUnitVectors( object.up, new THREE.Vector3( 0, 1, 0 ) );
|
|
145
|
+
const quatInverse = quat.clone().invert();
|
|
146
|
+
const lastPosition = new THREE.Vector3();
|
|
147
|
+
const lastQuaternion = new THREE.Quaternion();
|
|
148
|
+
const twoPI = 2 * Math.PI;
|
|
149
|
+
return function update() {
|
|
150
|
+
|
|
151
|
+
const position = scope.object.position;
|
|
152
|
+
offset.copy( position ).sub( scope.target ); // rotate offset to "y-axis-is-up" space
|
|
153
|
+
|
|
154
|
+
offset.applyQuaternion( quat ); // angle from z-axis around y-axis
|
|
155
|
+
|
|
156
|
+
spherical.setFromVector3( offset );
|
|
157
|
+
|
|
158
|
+
if ( scope.autoRotate && state === STATE.NONE ) {
|
|
159
|
+
|
|
160
|
+
rotateLeft( getAutoRotationAngle() );
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if ( scope.enableDamping ) {
|
|
165
|
+
|
|
166
|
+
spherical.theta += sphericalDelta.theta * scope.dampingFactor;
|
|
167
|
+
spherical.phi += sphericalDelta.phi * scope.dampingFactor;
|
|
168
|
+
|
|
169
|
+
} else {
|
|
170
|
+
|
|
171
|
+
spherical.theta += sphericalDelta.theta;
|
|
172
|
+
spherical.phi += sphericalDelta.phi;
|
|
173
|
+
|
|
174
|
+
} // restrict theta to be between desired limits
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
let min = scope.minAzimuthAngle;
|
|
178
|
+
let max = scope.maxAzimuthAngle;
|
|
179
|
+
|
|
180
|
+
if ( isFinite( min ) && isFinite( max ) ) {
|
|
181
|
+
|
|
182
|
+
if ( min < - Math.PI ) min += twoPI; else if ( min > Math.PI ) min -= twoPI;
|
|
183
|
+
if ( max < - Math.PI ) max += twoPI; else if ( max > Math.PI ) max -= twoPI;
|
|
184
|
+
|
|
185
|
+
if ( min <= max ) {
|
|
186
|
+
|
|
187
|
+
spherical.theta = Math.max( min, Math.min( max, spherical.theta ) );
|
|
188
|
+
|
|
189
|
+
} else {
|
|
190
|
+
|
|
191
|
+
spherical.theta = spherical.theta > ( min + max ) / 2 ? Math.max( min, spherical.theta ) : Math.min( max, spherical.theta );
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
} // restrict phi to be between desired limits
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) );
|
|
199
|
+
spherical.makeSafe();
|
|
200
|
+
spherical.radius *= scale; // restrict radius to be between desired limits
|
|
201
|
+
|
|
202
|
+
spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) ); // move target to panned location
|
|
203
|
+
|
|
204
|
+
if ( scope.enableDamping === true ) {
|
|
205
|
+
|
|
206
|
+
scope.target.addScaledVector( panOffset, scope.dampingFactor );
|
|
207
|
+
|
|
208
|
+
} else {
|
|
209
|
+
|
|
210
|
+
scope.target.add( panOffset );
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
offset.setFromSpherical( spherical ); // rotate offset back to "camera-up-vector-is-up" space
|
|
215
|
+
|
|
216
|
+
offset.applyQuaternion( quatInverse );
|
|
217
|
+
position.copy( scope.target ).add( offset );
|
|
218
|
+
scope.object.lookAt( scope.target );
|
|
219
|
+
|
|
220
|
+
if ( scope.enableDamping === true ) {
|
|
221
|
+
|
|
222
|
+
sphericalDelta.theta *= 1 - scope.dampingFactor;
|
|
223
|
+
sphericalDelta.phi *= 1 - scope.dampingFactor;
|
|
224
|
+
panOffset.multiplyScalar( 1 - scope.dampingFactor );
|
|
225
|
+
|
|
226
|
+
} else {
|
|
227
|
+
|
|
228
|
+
sphericalDelta.set( 0, 0, 0 );
|
|
229
|
+
panOffset.set( 0, 0, 0 );
|
|
230
|
+
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
scale = 1; // update condition is:
|
|
234
|
+
// min(camera displacement, camera rotation in radians)^2 > EPS
|
|
235
|
+
// using small-angle approximation cos(x/2) = 1 - x^2 / 8
|
|
236
|
+
|
|
237
|
+
if ( zoomChanged || lastPosition.distanceToSquared( scope.object.position ) > EPS || 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
|
|
238
|
+
|
|
239
|
+
scope.dispatchEvent( _changeEvent );
|
|
240
|
+
lastPosition.copy( scope.object.position );
|
|
241
|
+
lastQuaternion.copy( scope.object.quaternion );
|
|
242
|
+
zoomChanged = false;
|
|
243
|
+
return true;
|
|
244
|
+
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return false;
|
|
248
|
+
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
}();
|
|
252
|
+
|
|
253
|
+
this.dispose = function () {
|
|
254
|
+
|
|
255
|
+
scope.domElement.removeEventListener( 'contextmenu', onContextMenu );
|
|
256
|
+
scope.domElement.removeEventListener( 'pointerdown', onPointerDown );
|
|
257
|
+
scope.domElement.removeEventListener( 'wheel', onMouseWheel );
|
|
258
|
+
scope.domElement.removeEventListener( 'touchstart', onTouchStart );
|
|
259
|
+
scope.domElement.removeEventListener( 'touchend', onTouchEnd );
|
|
260
|
+
scope.domElement.removeEventListener( 'touchmove', onTouchMove );
|
|
261
|
+
scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove );
|
|
262
|
+
scope.domElement.ownerDocument.removeEventListener( 'pointerup', onPointerUp );
|
|
263
|
+
|
|
264
|
+
if ( scope._domElementKeyEvents !== null ) {
|
|
265
|
+
|
|
266
|
+
scope._domElementKeyEvents.removeEventListener( 'keydown', onKeyDown );
|
|
267
|
+
|
|
268
|
+
} //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here?
|
|
269
|
+
|
|
270
|
+
}; //
|
|
271
|
+
// internals
|
|
272
|
+
//
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
const scope = this;
|
|
276
|
+
const STATE = {
|
|
277
|
+
NONE: - 1,
|
|
278
|
+
ROTATE: 0,
|
|
279
|
+
DOLLY: 1,
|
|
280
|
+
PAN: 2,
|
|
281
|
+
TOUCH_ROTATE: 3,
|
|
282
|
+
TOUCH_PAN: 4,
|
|
283
|
+
TOUCH_DOLLY_PAN: 5,
|
|
284
|
+
TOUCH_DOLLY_ROTATE: 6
|
|
285
|
+
};
|
|
286
|
+
let state = STATE.NONE;
|
|
287
|
+
const EPS = 0.000001; // current position in spherical coordinates
|
|
288
|
+
|
|
289
|
+
const spherical = new THREE.Spherical();
|
|
290
|
+
const sphericalDelta = new THREE.Spherical();
|
|
291
|
+
let scale = 1;
|
|
292
|
+
const panOffset = new THREE.Vector3();
|
|
293
|
+
let zoomChanged = false;
|
|
294
|
+
const rotateStart = new THREE.Vector2();
|
|
295
|
+
const rotateEnd = new THREE.Vector2();
|
|
296
|
+
const rotateDelta = new THREE.Vector2();
|
|
297
|
+
const panStart = new THREE.Vector2();
|
|
298
|
+
const panEnd = new THREE.Vector2();
|
|
299
|
+
const panDelta = new THREE.Vector2();
|
|
300
|
+
const dollyStart = new THREE.Vector2();
|
|
301
|
+
const dollyEnd = new THREE.Vector2();
|
|
302
|
+
const dollyDelta = new THREE.Vector2();
|
|
303
|
+
|
|
304
|
+
function getAutoRotationAngle() {
|
|
305
|
+
|
|
306
|
+
return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function getZoomScale() {
|
|
311
|
+
|
|
312
|
+
return Math.pow( 0.95, scope.zoomSpeed );
|
|
313
|
+
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function rotateLeft( angle ) {
|
|
317
|
+
|
|
318
|
+
sphericalDelta.theta -= angle;
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function rotateUp( angle ) {
|
|
323
|
+
|
|
324
|
+
sphericalDelta.phi -= angle;
|
|
325
|
+
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const panLeft = function () {
|
|
329
|
+
|
|
330
|
+
const v = new THREE.Vector3();
|
|
331
|
+
return function panLeft( distance, objectMatrix ) {
|
|
332
|
+
|
|
333
|
+
v.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix
|
|
334
|
+
|
|
335
|
+
v.multiplyScalar( - distance );
|
|
336
|
+
panOffset.add( v );
|
|
337
|
+
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
}();
|
|
341
|
+
|
|
342
|
+
const panUp = function () {
|
|
343
|
+
|
|
344
|
+
const v = new THREE.Vector3();
|
|
345
|
+
return function panUp( distance, objectMatrix ) {
|
|
346
|
+
|
|
347
|
+
if ( scope.screenSpacePanning === true ) {
|
|
348
|
+
|
|
349
|
+
v.setFromMatrixColumn( objectMatrix, 1 );
|
|
350
|
+
|
|
351
|
+
} else {
|
|
352
|
+
|
|
353
|
+
v.setFromMatrixColumn( objectMatrix, 0 );
|
|
354
|
+
v.crossVectors( scope.object.up, v );
|
|
355
|
+
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
v.multiplyScalar( distance );
|
|
359
|
+
panOffset.add( v );
|
|
360
|
+
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
}(); // deltaX and deltaY are in pixels; right and down are positive
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
const pan = function () {
|
|
367
|
+
|
|
368
|
+
const offset = new THREE.Vector3();
|
|
369
|
+
return function pan( deltaX, deltaY ) {
|
|
370
|
+
|
|
371
|
+
const element = scope.domElement;
|
|
372
|
+
|
|
373
|
+
if ( scope.object.isPerspectiveCamera ) {
|
|
374
|
+
|
|
375
|
+
// perspective
|
|
376
|
+
const position = scope.object.position;
|
|
377
|
+
offset.copy( position ).sub( scope.target );
|
|
378
|
+
let targetDistance = offset.length(); // half of the fov is center to top of screen
|
|
379
|
+
|
|
380
|
+
targetDistance *= Math.tan( scope.object.fov / 2 * Math.PI / 180.0 ); // we use only clientHeight here so aspect ratio does not distort speed
|
|
381
|
+
|
|
382
|
+
panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix );
|
|
383
|
+
panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix );
|
|
384
|
+
|
|
385
|
+
} else if ( scope.object.isOrthographicCamera ) {
|
|
386
|
+
|
|
387
|
+
// orthographic
|
|
388
|
+
panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix );
|
|
389
|
+
panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix );
|
|
390
|
+
|
|
391
|
+
} else {
|
|
392
|
+
|
|
393
|
+
// camera neither orthographic nor perspective
|
|
394
|
+
console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );
|
|
395
|
+
scope.enablePan = false;
|
|
396
|
+
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
}();
|
|
402
|
+
|
|
403
|
+
function dollyOut( dollyScale ) {
|
|
404
|
+
|
|
405
|
+
if ( scope.object.isPerspectiveCamera ) {
|
|
406
|
+
|
|
407
|
+
scale /= dollyScale;
|
|
408
|
+
|
|
409
|
+
} else if ( scope.object.isOrthographicCamera ) {
|
|
410
|
+
|
|
411
|
+
scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) );
|
|
412
|
+
scope.object.updateProjectionMatrix();
|
|
413
|
+
zoomChanged = true;
|
|
414
|
+
|
|
415
|
+
} else {
|
|
416
|
+
|
|
417
|
+
console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
|
|
418
|
+
scope.enableZoom = false;
|
|
419
|
+
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function dollyIn( dollyScale ) {
|
|
425
|
+
|
|
426
|
+
if ( scope.object.isPerspectiveCamera ) {
|
|
427
|
+
|
|
428
|
+
scale *= dollyScale;
|
|
429
|
+
|
|
430
|
+
} else if ( scope.object.isOrthographicCamera ) {
|
|
431
|
+
|
|
432
|
+
scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) );
|
|
433
|
+
scope.object.updateProjectionMatrix();
|
|
434
|
+
zoomChanged = true;
|
|
435
|
+
|
|
436
|
+
} else {
|
|
437
|
+
|
|
438
|
+
console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
|
|
439
|
+
scope.enableZoom = false;
|
|
440
|
+
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
} //
|
|
444
|
+
// event callbacks - update the object state
|
|
445
|
+
//
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
function handleMouseDownRotate( event ) {
|
|
449
|
+
|
|
450
|
+
rotateStart.set( event.clientX, event.clientY );
|
|
451
|
+
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function handleMouseDownDolly( event ) {
|
|
455
|
+
|
|
456
|
+
dollyStart.set( event.clientX, event.clientY );
|
|
457
|
+
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function handleMouseDownPan( event ) {
|
|
461
|
+
|
|
462
|
+
panStart.set( event.clientX, event.clientY );
|
|
463
|
+
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function handleMouseMoveRotate( event ) {
|
|
467
|
+
|
|
468
|
+
rotateEnd.set( event.clientX, event.clientY );
|
|
469
|
+
rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed );
|
|
470
|
+
const element = scope.domElement;
|
|
471
|
+
rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height
|
|
472
|
+
|
|
473
|
+
rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight );
|
|
474
|
+
rotateStart.copy( rotateEnd );
|
|
475
|
+
scope.update();
|
|
476
|
+
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function handleMouseMoveDolly( event ) {
|
|
480
|
+
|
|
481
|
+
dollyEnd.set( event.clientX, event.clientY );
|
|
482
|
+
dollyDelta.subVectors( dollyEnd, dollyStart );
|
|
483
|
+
|
|
484
|
+
if ( dollyDelta.y > 0 ) {
|
|
485
|
+
|
|
486
|
+
dollyOut( getZoomScale() );
|
|
487
|
+
|
|
488
|
+
} else if ( dollyDelta.y < 0 ) {
|
|
489
|
+
|
|
490
|
+
dollyIn( getZoomScale() );
|
|
491
|
+
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
dollyStart.copy( dollyEnd );
|
|
495
|
+
scope.update();
|
|
496
|
+
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function handleMouseMovePan( event ) {
|
|
500
|
+
|
|
501
|
+
panEnd.set( event.clientX, event.clientY );
|
|
502
|
+
panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed );
|
|
503
|
+
pan( panDelta.x, panDelta.y );
|
|
504
|
+
panStart.copy( panEnd );
|
|
505
|
+
scope.update();
|
|
506
|
+
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function handleMouseUp( ) { // no-op
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function handleMouseWheel( event ) {
|
|
513
|
+
|
|
514
|
+
if ( event.deltaY < 0 ) {
|
|
515
|
+
|
|
516
|
+
dollyIn( getZoomScale() );
|
|
517
|
+
|
|
518
|
+
} else if ( event.deltaY > 0 ) {
|
|
519
|
+
|
|
520
|
+
dollyOut( getZoomScale() );
|
|
521
|
+
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
scope.update();
|
|
525
|
+
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function handleKeyDown( event ) {
|
|
529
|
+
|
|
530
|
+
let needsUpdate = false;
|
|
531
|
+
|
|
532
|
+
switch ( event.code ) {
|
|
533
|
+
|
|
534
|
+
case scope.keys.UP:
|
|
535
|
+
pan( 0, scope.keyPanSpeed );
|
|
536
|
+
needsUpdate = true;
|
|
537
|
+
break;
|
|
538
|
+
|
|
539
|
+
case scope.keys.BOTTOM:
|
|
540
|
+
pan( 0, - scope.keyPanSpeed );
|
|
541
|
+
needsUpdate = true;
|
|
542
|
+
break;
|
|
543
|
+
|
|
544
|
+
case scope.keys.LEFT:
|
|
545
|
+
pan( scope.keyPanSpeed, 0 );
|
|
546
|
+
needsUpdate = true;
|
|
547
|
+
break;
|
|
548
|
+
|
|
549
|
+
case scope.keys.RIGHT:
|
|
550
|
+
pan( - scope.keyPanSpeed, 0 );
|
|
551
|
+
needsUpdate = true;
|
|
552
|
+
break;
|
|
553
|
+
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
if ( needsUpdate ) {
|
|
557
|
+
|
|
558
|
+
// prevent the browser from scrolling on cursor keys
|
|
559
|
+
event.preventDefault();
|
|
560
|
+
scope.update();
|
|
561
|
+
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function handleTouchStartRotate( event ) {
|
|
567
|
+
|
|
568
|
+
if ( event.touches.length == 1 ) {
|
|
569
|
+
|
|
570
|
+
rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
|
571
|
+
|
|
572
|
+
} else {
|
|
573
|
+
|
|
574
|
+
const x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
|
|
575
|
+
const y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
|
|
576
|
+
rotateStart.set( x, y );
|
|
577
|
+
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function handleTouchStartPan( event ) {
|
|
583
|
+
|
|
584
|
+
if ( event.touches.length == 1 ) {
|
|
585
|
+
|
|
586
|
+
panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
|
587
|
+
|
|
588
|
+
} else {
|
|
589
|
+
|
|
590
|
+
const x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
|
|
591
|
+
const y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
|
|
592
|
+
panStart.set( x, y );
|
|
593
|
+
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function handleTouchStartDolly( event ) {
|
|
599
|
+
|
|
600
|
+
const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
|
601
|
+
const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
|
602
|
+
const distance = Math.sqrt( dx * dx + dy * dy );
|
|
603
|
+
dollyStart.set( 0, distance );
|
|
604
|
+
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function handleTouchStartDollyPan( event ) {
|
|
608
|
+
|
|
609
|
+
if ( scope.enableZoom ) handleTouchStartDolly( event );
|
|
610
|
+
if ( scope.enablePan ) handleTouchStartPan( event );
|
|
611
|
+
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
function handleTouchStartDollyRotate( event ) {
|
|
615
|
+
|
|
616
|
+
if ( scope.enableZoom ) handleTouchStartDolly( event );
|
|
617
|
+
if ( scope.enableRotate ) handleTouchStartRotate( event );
|
|
618
|
+
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function handleTouchMoveRotate( event ) {
|
|
622
|
+
|
|
623
|
+
if ( event.touches.length == 1 ) {
|
|
624
|
+
|
|
625
|
+
rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
|
626
|
+
|
|
627
|
+
} else {
|
|
628
|
+
|
|
629
|
+
const x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
|
|
630
|
+
const y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
|
|
631
|
+
rotateEnd.set( x, y );
|
|
632
|
+
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed );
|
|
636
|
+
const element = scope.domElement;
|
|
637
|
+
rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height
|
|
638
|
+
|
|
639
|
+
rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight );
|
|
640
|
+
rotateStart.copy( rotateEnd );
|
|
641
|
+
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function handleTouchMovePan( event ) {
|
|
645
|
+
|
|
646
|
+
if ( event.touches.length == 1 ) {
|
|
647
|
+
|
|
648
|
+
panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
|
649
|
+
|
|
650
|
+
} else {
|
|
651
|
+
|
|
652
|
+
const x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
|
|
653
|
+
const y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
|
|
654
|
+
panEnd.set( x, y );
|
|
655
|
+
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed );
|
|
659
|
+
pan( panDelta.x, panDelta.y );
|
|
660
|
+
panStart.copy( panEnd );
|
|
661
|
+
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function handleTouchMoveDolly( event ) {
|
|
665
|
+
|
|
666
|
+
const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
|
667
|
+
const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
|
668
|
+
const distance = Math.sqrt( dx * dx + dy * dy );
|
|
669
|
+
dollyEnd.set( 0, distance );
|
|
670
|
+
dollyDelta.set( 0, Math.pow( dollyEnd.y / dollyStart.y, scope.zoomSpeed ) );
|
|
671
|
+
dollyOut( dollyDelta.y );
|
|
672
|
+
dollyStart.copy( dollyEnd );
|
|
673
|
+
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
function handleTouchMoveDollyPan( event ) {
|
|
677
|
+
|
|
678
|
+
if ( scope.enableZoom ) handleTouchMoveDolly( event );
|
|
679
|
+
if ( scope.enablePan ) handleTouchMovePan( event );
|
|
680
|
+
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
function handleTouchMoveDollyRotate( event ) {
|
|
684
|
+
|
|
685
|
+
if ( scope.enableZoom ) handleTouchMoveDolly( event );
|
|
686
|
+
if ( scope.enableRotate ) handleTouchMoveRotate( event );
|
|
687
|
+
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
function handleTouchEnd( ) { // no-op
|
|
691
|
+
} //
|
|
692
|
+
// event handlers - FSM: listen for events and reset state
|
|
693
|
+
//
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
function onPointerDown( event ) {
|
|
697
|
+
|
|
698
|
+
if ( scope.enabled === false ) return;
|
|
699
|
+
|
|
700
|
+
switch ( event.pointerType ) {
|
|
701
|
+
|
|
702
|
+
case 'mouse':
|
|
703
|
+
case 'pen':
|
|
704
|
+
onMouseDown( event );
|
|
705
|
+
break;
|
|
706
|
+
// TODO touch
|
|
707
|
+
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
function onPointerMove( event ) {
|
|
713
|
+
|
|
714
|
+
if ( scope.enabled === false ) return;
|
|
715
|
+
|
|
716
|
+
switch ( event.pointerType ) {
|
|
717
|
+
|
|
718
|
+
case 'mouse':
|
|
719
|
+
case 'pen':
|
|
720
|
+
onMouseMove( event );
|
|
721
|
+
break;
|
|
722
|
+
// TODO touch
|
|
723
|
+
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function onPointerUp( event ) {
|
|
729
|
+
|
|
730
|
+
switch ( event.pointerType ) {
|
|
731
|
+
|
|
732
|
+
case 'mouse':
|
|
733
|
+
case 'pen':
|
|
734
|
+
onMouseUp( event );
|
|
735
|
+
break;
|
|
736
|
+
// TODO touch
|
|
737
|
+
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
function onMouseDown( event ) {
|
|
743
|
+
|
|
744
|
+
// Prevent the browser from scrolling.
|
|
745
|
+
event.preventDefault(); // Manually set the focus since calling preventDefault above
|
|
746
|
+
// prevents the browser from setting it automatically.
|
|
747
|
+
|
|
748
|
+
scope.domElement.focus ? scope.domElement.focus() : window.focus();
|
|
749
|
+
let mouseAction;
|
|
750
|
+
|
|
751
|
+
switch ( event.button ) {
|
|
752
|
+
|
|
753
|
+
case 0:
|
|
754
|
+
mouseAction = scope.mouseButtons.LEFT;
|
|
755
|
+
break;
|
|
756
|
+
|
|
757
|
+
case 1:
|
|
758
|
+
mouseAction = scope.mouseButtons.MIDDLE;
|
|
759
|
+
break;
|
|
760
|
+
|
|
761
|
+
case 2:
|
|
762
|
+
mouseAction = scope.mouseButtons.RIGHT;
|
|
763
|
+
break;
|
|
764
|
+
|
|
765
|
+
default:
|
|
766
|
+
mouseAction = - 1;
|
|
767
|
+
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
switch ( mouseAction ) {
|
|
771
|
+
|
|
772
|
+
case THREE.MOUSE.DOLLY:
|
|
773
|
+
if ( scope.enableZoom === false ) return;
|
|
774
|
+
handleMouseDownDolly( event );
|
|
775
|
+
state = STATE.DOLLY;
|
|
776
|
+
break;
|
|
777
|
+
|
|
778
|
+
case THREE.MOUSE.ROTATE:
|
|
779
|
+
if ( event.ctrlKey || event.metaKey || event.shiftKey ) {
|
|
780
|
+
|
|
781
|
+
if ( scope.enablePan === false ) return;
|
|
782
|
+
handleMouseDownPan( event );
|
|
783
|
+
state = STATE.PAN;
|
|
784
|
+
|
|
785
|
+
} else {
|
|
786
|
+
|
|
787
|
+
if ( scope.enableRotate === false ) return;
|
|
788
|
+
handleMouseDownRotate( event );
|
|
789
|
+
state = STATE.ROTATE;
|
|
790
|
+
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
break;
|
|
794
|
+
|
|
795
|
+
case THREE.MOUSE.PAN:
|
|
796
|
+
if ( event.ctrlKey || event.metaKey || event.shiftKey ) {
|
|
797
|
+
|
|
798
|
+
if ( scope.enableRotate === false ) return;
|
|
799
|
+
handleMouseDownRotate( event );
|
|
800
|
+
state = STATE.ROTATE;
|
|
801
|
+
|
|
802
|
+
} else {
|
|
803
|
+
|
|
804
|
+
if ( scope.enablePan === false ) return;
|
|
805
|
+
handleMouseDownPan( event );
|
|
806
|
+
state = STATE.PAN;
|
|
807
|
+
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
break;
|
|
811
|
+
|
|
812
|
+
default:
|
|
813
|
+
state = STATE.NONE;
|
|
814
|
+
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
if ( state !== STATE.NONE ) {
|
|
818
|
+
|
|
819
|
+
scope.domElement.ownerDocument.addEventListener( 'pointermove', onPointerMove );
|
|
820
|
+
scope.domElement.ownerDocument.addEventListener( 'pointerup', onPointerUp );
|
|
821
|
+
scope.dispatchEvent( _startEvent );
|
|
822
|
+
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
function onMouseMove( event ) {
|
|
828
|
+
|
|
829
|
+
if ( scope.enabled === false ) return;
|
|
830
|
+
event.preventDefault();
|
|
831
|
+
|
|
832
|
+
switch ( state ) {
|
|
833
|
+
|
|
834
|
+
case STATE.ROTATE:
|
|
835
|
+
if ( scope.enableRotate === false ) return;
|
|
836
|
+
handleMouseMoveRotate( event );
|
|
837
|
+
break;
|
|
838
|
+
|
|
839
|
+
case STATE.DOLLY:
|
|
840
|
+
if ( scope.enableZoom === false ) return;
|
|
841
|
+
handleMouseMoveDolly( event );
|
|
842
|
+
break;
|
|
843
|
+
|
|
844
|
+
case STATE.PAN:
|
|
845
|
+
if ( scope.enablePan === false ) return;
|
|
846
|
+
handleMouseMovePan( event );
|
|
847
|
+
break;
|
|
848
|
+
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
function onMouseUp( event ) {
|
|
854
|
+
|
|
855
|
+
scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove );
|
|
856
|
+
scope.domElement.ownerDocument.removeEventListener( 'pointerup', onPointerUp );
|
|
857
|
+
if ( scope.enabled === false ) return;
|
|
858
|
+
handleMouseUp( event );
|
|
859
|
+
scope.dispatchEvent( _endEvent );
|
|
860
|
+
state = STATE.NONE;
|
|
861
|
+
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
function onMouseWheel( event ) {
|
|
865
|
+
|
|
866
|
+
if ( scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE && state !== STATE.ROTATE ) return;
|
|
867
|
+
event.preventDefault();
|
|
868
|
+
scope.dispatchEvent( _startEvent );
|
|
869
|
+
handleMouseWheel( event );
|
|
870
|
+
scope.dispatchEvent( _endEvent );
|
|
871
|
+
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
function onKeyDown( event ) {
|
|
875
|
+
|
|
876
|
+
if ( scope.enabled === false || scope.enablePan === false ) return;
|
|
877
|
+
handleKeyDown( event );
|
|
878
|
+
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
function onTouchStart( event ) {
|
|
882
|
+
|
|
883
|
+
if ( scope.enabled === false ) return;
|
|
884
|
+
event.preventDefault(); // prevent scrolling
|
|
885
|
+
|
|
886
|
+
switch ( event.touches.length ) {
|
|
887
|
+
|
|
888
|
+
case 1:
|
|
889
|
+
switch ( scope.touches.ONE ) {
|
|
890
|
+
|
|
891
|
+
case THREE.TOUCH.ROTATE:
|
|
892
|
+
if ( scope.enableRotate === false ) return;
|
|
893
|
+
handleTouchStartRotate( event );
|
|
894
|
+
state = STATE.TOUCH_ROTATE;
|
|
895
|
+
break;
|
|
896
|
+
|
|
897
|
+
case THREE.TOUCH.PAN:
|
|
898
|
+
if ( scope.enablePan === false ) return;
|
|
899
|
+
handleTouchStartPan( event );
|
|
900
|
+
state = STATE.TOUCH_PAN;
|
|
901
|
+
break;
|
|
902
|
+
|
|
903
|
+
default:
|
|
904
|
+
state = STATE.NONE;
|
|
905
|
+
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
break;
|
|
909
|
+
|
|
910
|
+
case 2:
|
|
911
|
+
switch ( scope.touches.TWO ) {
|
|
912
|
+
|
|
913
|
+
case THREE.TOUCH.DOLLY_PAN:
|
|
914
|
+
if ( scope.enableZoom === false && scope.enablePan === false ) return;
|
|
915
|
+
handleTouchStartDollyPan( event );
|
|
916
|
+
state = STATE.TOUCH_DOLLY_PAN;
|
|
917
|
+
break;
|
|
918
|
+
|
|
919
|
+
case THREE.TOUCH.DOLLY_ROTATE:
|
|
920
|
+
if ( scope.enableZoom === false && scope.enableRotate === false ) return;
|
|
921
|
+
handleTouchStartDollyRotate( event );
|
|
922
|
+
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
923
|
+
break;
|
|
924
|
+
|
|
925
|
+
default:
|
|
926
|
+
state = STATE.NONE;
|
|
927
|
+
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
break;
|
|
931
|
+
|
|
932
|
+
default:
|
|
933
|
+
state = STATE.NONE;
|
|
934
|
+
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
if ( state !== STATE.NONE ) {
|
|
938
|
+
|
|
939
|
+
scope.dispatchEvent( _startEvent );
|
|
940
|
+
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
function onTouchMove( event ) {
|
|
946
|
+
|
|
947
|
+
if ( scope.enabled === false ) return;
|
|
948
|
+
event.preventDefault(); // prevent scrolling
|
|
949
|
+
|
|
950
|
+
switch ( state ) {
|
|
951
|
+
|
|
952
|
+
case STATE.TOUCH_ROTATE:
|
|
953
|
+
if ( scope.enableRotate === false ) return;
|
|
954
|
+
handleTouchMoveRotate( event );
|
|
955
|
+
scope.update();
|
|
956
|
+
break;
|
|
957
|
+
|
|
958
|
+
case STATE.TOUCH_PAN:
|
|
959
|
+
if ( scope.enablePan === false ) return;
|
|
960
|
+
handleTouchMovePan( event );
|
|
961
|
+
scope.update();
|
|
962
|
+
break;
|
|
963
|
+
|
|
964
|
+
case STATE.TOUCH_DOLLY_PAN:
|
|
965
|
+
if ( scope.enableZoom === false && scope.enablePan === false ) return;
|
|
966
|
+
handleTouchMoveDollyPan( event );
|
|
967
|
+
scope.update();
|
|
968
|
+
break;
|
|
969
|
+
|
|
970
|
+
case STATE.TOUCH_DOLLY_ROTATE:
|
|
971
|
+
if ( scope.enableZoom === false && scope.enableRotate === false ) return;
|
|
972
|
+
handleTouchMoveDollyRotate( event );
|
|
973
|
+
scope.update();
|
|
974
|
+
break;
|
|
975
|
+
|
|
976
|
+
default:
|
|
977
|
+
state = STATE.NONE;
|
|
978
|
+
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
function onTouchEnd( event ) {
|
|
984
|
+
|
|
985
|
+
if ( scope.enabled === false ) return;
|
|
986
|
+
handleTouchEnd( event );
|
|
987
|
+
scope.dispatchEvent( _endEvent );
|
|
988
|
+
state = STATE.NONE;
|
|
989
|
+
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
function onContextMenu( event ) {
|
|
993
|
+
|
|
994
|
+
if ( scope.enabled === false ) return;
|
|
995
|
+
event.preventDefault();
|
|
996
|
+
|
|
997
|
+
} //
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
scope.domElement.addEventListener( 'contextmenu', onContextMenu );
|
|
1001
|
+
scope.domElement.addEventListener( 'pointerdown', onPointerDown );
|
|
1002
|
+
scope.domElement.addEventListener( 'wheel', onMouseWheel, {
|
|
1003
|
+
passive: false
|
|
1004
|
+
} );
|
|
1005
|
+
scope.domElement.addEventListener( 'touchstart', onTouchStart, {
|
|
1006
|
+
passive: false
|
|
1007
|
+
} );
|
|
1008
|
+
scope.domElement.addEventListener( 'touchend', onTouchEnd );
|
|
1009
|
+
scope.domElement.addEventListener( 'touchmove', onTouchMove, {
|
|
1010
|
+
passive: false
|
|
1011
|
+
} ); // force an update at start
|
|
1012
|
+
|
|
1013
|
+
this.update();
|
|
1014
|
+
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
} // This set of controls performs orbiting, dollying (zooming), and panning.
|
|
1018
|
+
// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
|
|
1019
|
+
// This is very similar to OrbitControls, another set of touch behavior
|
|
1020
|
+
//
|
|
1021
|
+
// Orbit - right mouse, or left mouse + ctrl/meta/shiftKey / touch: two-finger rotate
|
|
1022
|
+
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
|
|
1023
|
+
// Pan - left mouse, or arrow keys / touch: one-finger move
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
class MapControls extends OrbitControls {
|
|
1027
|
+
|
|
1028
|
+
constructor( object, domElement ) {
|
|
1029
|
+
|
|
1030
|
+
super( object, domElement );
|
|
1031
|
+
this.screenSpacePanning = false; // pan orthogonal to world-space direction camera.up
|
|
1032
|
+
|
|
1033
|
+
this.mouseButtons.LEFT = THREE.MOUSE.PAN;
|
|
1034
|
+
this.mouseButtons.RIGHT = THREE.MOUSE.ROTATE;
|
|
1035
|
+
this.touches.ONE = THREE.TOUCH.PAN;
|
|
1036
|
+
this.touches.TWO = THREE.TOUCH.DOLLY_ROTATE;
|
|
1037
|
+
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
THREE.MapControls = MapControls;
|
|
1043
|
+
THREE.OrbitControls = OrbitControls;
|
|
1044
|
+
|
|
1045
|
+
} )();
|