@operato/scene-visualizer 8.0.0-beta.0 → 8.0.0-beta.2

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 (95) hide show
  1. package/package.json +5 -5
  2. package/CHANGELOG.md +0 -640
  3. package/attachments/0d91a37d-c2d7-4c6d-88dc-a29e5bbea361.png +0 -0
  4. package/attachments/1b07c8d3-07d5-4007-b02e-031ee1755539.glb +0 -0
  5. package/attachments/226c6c23-c4fd-46c8-93e3-3d3d9c4bb8a9.glb +0 -0
  6. package/attachments/4425ca46-cf1d-476d-9185-dcb881ecad1f.glb +0 -0
  7. package/attachments/51e7c45d-6eae-4baf-a4e2-ba979b7e77cd.glb +0 -0
  8. package/attachments/54427925-c109-4499-875c-fb14207b95c5.glb +0 -0
  9. package/attachments/8cc70a65-e20f-4187-83c8-64deb3faf3d9.glb +0 -0
  10. package/attachments/964d004d-1fe7-4224-89a6-2b6e86db233c.glb +0 -0
  11. package/attachments/ff47fd63-6f1c-4a69-b965-9bb03797a415.png +0 -0
  12. package/db.sqlite +0 -0
  13. package/demo/index-modeller.html +0 -112
  14. package/demo/index.html +0 -109
  15. package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +0 -25
  16. package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +0 -25
  17. package/logs/application-2025-01-07-10.log +0 -106
  18. package/logs/application-2025-01-07-14.log +0 -4
  19. package/logs/application-2025-01-07-15.log +0 -4
  20. package/logs/connections-2025-01-07-10.log +0 -106
  21. package/logs/connections-2025-01-07-14.log +0 -53
  22. package/logs/connections-2025-01-07-15.log +0 -53
  23. package/schema.graphql +0 -4552
  24. package/src/banner.ts +0 -88
  25. package/src/camera.ts +0 -132
  26. package/src/component.d.ts +0 -10
  27. package/src/cube.ts +0 -39
  28. package/src/cylinder.ts +0 -39
  29. package/src/desk.ts +0 -135
  30. package/src/editors/index.ts +0 -13
  31. package/src/editors/property-editor-gltf-info.ts +0 -135
  32. package/src/editors/property-editor-location-increase-pattern.ts +0 -260
  33. package/src/effects/outline.ts +0 -54
  34. package/src/ellipse.ts +0 -37
  35. package/src/gltf-object.ts +0 -117
  36. package/src/html-overlay-element.ts +0 -13
  37. package/src/index.ts +0 -29
  38. package/src/light.ts +0 -155
  39. package/src/polygon.ts +0 -88
  40. package/src/rack-table-cell.ts +0 -386
  41. package/src/rack-table.ts +0 -1296
  42. package/src/rack.ts +0 -232
  43. package/src/rect.ts +0 -39
  44. package/src/scene/component.ts +0 -38
  45. package/src/sphere.ts +0 -39
  46. package/src/sprite.ts +0 -30
  47. package/src/stock.ts +0 -262
  48. package/src/templates/3d-container.ts +0 -21
  49. package/src/templates/banner.ts +0 -21
  50. package/src/templates/camera.ts +0 -25
  51. package/src/templates/cube.ts +0 -20
  52. package/src/templates/cylinder.ts +0 -20
  53. package/src/templates/desk.ts +0 -20
  54. package/src/templates/gltf-object.ts +0 -20
  55. package/src/templates/index.ts +0 -29
  56. package/src/templates/light.ts +0 -23
  57. package/src/templates/pallet.ts +0 -20
  58. package/src/templates/rack-table.ts +0 -21
  59. package/src/templates/sphere.ts +0 -20
  60. package/src/templates/sprite.ts +0 -21
  61. package/src/templates/visualizer.ts +0 -21
  62. package/src/templates/wall.ts +0 -20
  63. package/src/text.ts +0 -10
  64. package/src/three-container-editor.ts +0 -187
  65. package/src/three-container.ts +0 -724
  66. package/src/three-controls.ts +0 -778
  67. package/src/three-layout.ts +0 -25
  68. package/src/three-space.ts +0 -732
  69. package/src/threed/common.ts +0 -21
  70. package/src/threed/floor/floor.ts +0 -62
  71. package/src/threed/html/elements.ts +0 -27
  72. package/src/threed/index.ts +0 -15
  73. package/src/threed/real-object-camera-meshed.ts +0 -67
  74. package/src/threed/real-object-camera.ts +0 -41
  75. package/src/threed/real-object-dom-element.ts +0 -55
  76. package/src/threed/real-object-dummy.ts +0 -13
  77. package/src/threed/real-object-extrude.ts +0 -210
  78. package/src/threed/real-object-gltf.ts +0 -136
  79. package/src/threed/real-object-group.ts +0 -35
  80. package/src/threed/real-object-mesh.ts +0 -74
  81. package/src/threed/real-object-plane.ts +0 -27
  82. package/src/threed/real-object-scene.ts +0 -84
  83. package/src/threed/real-object-sprite-2d.ts +0 -54
  84. package/src/threed/real-object-sprite.ts +0 -64
  85. package/src/threed/real-object-text.ts +0 -86
  86. package/src/threed/real-object.ts +0 -326
  87. package/src/threed/texture/canvas-texture.ts +0 -67
  88. package/src/threed/texture/text-texture.ts +0 -100
  89. package/src/threed/three-dimensional-container.ts +0 -9
  90. package/src/threed/utils/bound-uv-generator.ts +0 -80
  91. package/src/visualizer.ts +0 -319
  92. package/src/wall.ts +0 -50
  93. package/tsconfig.json +0 -24
  94. package/tsconfig.tsbuildinfo +0 -1
  95. package/web-dev-server.config.mjs +0 -27
@@ -1,778 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
- /**
5
- * @author qiao / https://github.com/qiao
6
- * @author mrdoob / http://mrdoob.com
7
- * @author alteredq / http://alteredqualia.com/
8
- * @author WestLangley / http://github.com/WestLangley
9
- * @author erich666 / http://erichaines.com
10
- */
11
-
12
- // This set of controls performs orbiting, dollying (zooming), and panning.
13
- // Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
14
- //
15
- // Orbit - left mouse / touch: one finger move
16
- // Zoom - middle mouse, or mousewheel / touch: two finger spread or squish
17
- // Pan - right mouse, or arrow keys / touch: three finger swipe
18
- import { Component } from '@hatiolab/things-scene'
19
- import * as THREE from 'three'
20
-
21
- var ThreeControls = function (this: any, object: THREE.Camera, component: Component) {
22
- this.object = object
23
-
24
- this.component = component
25
-
26
- // Set to false to disable this control
27
- this.enabled = true
28
-
29
- // "target" sets the location of focus, where the object orbits around
30
- this.target = new THREE.Vector3()
31
-
32
- // How far you can dolly in and out ( PerspectiveCamera only )
33
- this.minDistance = 0
34
- this.maxDistance = Infinity
35
-
36
- // How far you can zoom in and out ( OrthographicCamera only )
37
- this.minZoom = 0
38
- this.maxZoom = Infinity
39
-
40
- // How far you can orbit vertically, upper and lower limits.
41
- // Range is 0 to Math.PI radians.
42
- this.minPolarAngle = 0 // radians
43
- this.maxPolarAngle = Math.PI // radians
44
-
45
- // How far you can orbit horizontally, upper and lower limits.
46
- // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
47
- this.minAzimuthAngle = -Infinity // radians
48
- this.maxAzimuthAngle = Infinity // radians
49
-
50
- // Set to true to enable damping (inertia)
51
- // If damping is enabled, you must call controls.update() in your animation loop
52
- this.enableDamping = false
53
- this.dampingFactor = 0.25
54
-
55
- // This option actually enables dollying in and out; left as "zoom" for backwards compatibility.
56
- // Set to false to disable zooming
57
- this.enableZoom = true
58
- this.zoomSpeed = 1.0
59
-
60
- // Set to false to disable rotating
61
- this.enableRotate = true
62
- this.rotateSpeed = 1.0
63
-
64
- // Set to false to disable panning
65
- this.enablePan = true
66
- this.keyPanSpeed = 7.0 // pixels moved per arrow key push
67
-
68
- // Set to true to automatically rotate around the target
69
- // If auto-rotate is enabled, you must call controls.update() in your animation loop
70
- this.autoRotate = (this.component.app && !this.component.app.isEditMode && this.component.state.autoRotate) || false
71
- this.autoRotateSpeed = this.component.state.rotationSpeed || 2.0 // 30 seconds per round when fps is 60
72
-
73
- // Set to false to disable use of the keys
74
- this.enableKeys = true
75
-
76
- // The four arrow keys
77
- this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 }
78
-
79
- // Mouse buttons
80
- this.mouseButtons = { ORBIT: THREE.MOUSE.LEFT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT }
81
-
82
- // for reset
83
- this.target0 = this.target.clone()
84
- this.position0 = this.object.position.clone()
85
- this.zoom0 = this.object.zoom
86
-
87
- // flags
88
- this.cameraChanged = false
89
-
90
- //
91
- // public methods
92
- //
93
-
94
- this.getPolarAngle = function () {
95
- return spherical.phi
96
- }
97
-
98
- this.getAzimuthalAngle = function () {
99
- return spherical.theta
100
- }
101
-
102
- this.saveState = function () {
103
- scope.target0.copy(scope.target)
104
- scope.position0.copy(scope.object.position)
105
- scope.zoom0 = scope.object.zoom
106
- }
107
-
108
- this.reset = function () {
109
- scope.target.copy(scope.target0)
110
- scope.object.position.copy(scope.position0)
111
- scope.object.zoom = scope.zoom0
112
-
113
- scope.object.updateProjectionMatrix()
114
- // scope.dispatchEvent( changeEvent );
115
-
116
- scope.update()
117
-
118
- state = STATE.NONE
119
- }
120
-
121
- // this method is exposed, but perhaps it would be better if we can make it private...
122
- this.update = (function () {
123
- var offset = new THREE.Vector3()
124
-
125
- // so camera.up is the orbit axis
126
- var quat = new THREE.Quaternion().setFromUnitVectors(object.up, new THREE.Vector3(0, 1, 0))
127
- var quatInverse = quat.clone().invert()
128
-
129
- var lastPosition = new THREE.Vector3()
130
- var lastQuaternion = new THREE.Quaternion()
131
-
132
- return function update() {
133
- // if (!(scope.cameraChanged || scope.autoRotate))
134
- // return false;
135
-
136
- var position = scope.object.position
137
-
138
- offset.copy(position).sub(scope.target)
139
-
140
- // rotate offset to "y-axis-is-up" space
141
- offset.applyQuaternion(quat)
142
-
143
- // angle from z-axis around y-axis
144
- spherical.setFromVector3(offset)
145
-
146
- if (scope.autoRotate && state === STATE.NONE) {
147
- rotateLeft(getAutoRotationAngle())
148
- }
149
-
150
- spherical.theta += sphericalDelta.theta
151
- spherical.phi += sphericalDelta.phi
152
-
153
- // restrict theta to be between desired limits
154
- spherical.theta = Math.max(scope.minAzimuthAngle, Math.min(scope.maxAzimuthAngle, spherical.theta))
155
-
156
- // restrict phi to be between desired limits
157
- spherical.phi = Math.max(scope.minPolarAngle, Math.min(scope.maxPolarAngle, spherical.phi))
158
-
159
- spherical.makeSafe()
160
-
161
- spherical.radius *= scale
162
-
163
- // restrict radius to be between desired limits
164
- spherical.radius = Math.max(scope.minDistance, Math.min(scope.maxDistance, spherical.radius))
165
-
166
- // move target to panned location
167
- scope.target.add(panOffset)
168
-
169
- offset.setFromSpherical(spherical)
170
-
171
- // rotate offset back to "camera-up-vector-is-up" space
172
- offset.applyQuaternion(quatInverse)
173
-
174
- position.copy(scope.target).add(offset)
175
-
176
- scope.object.lookAt(scope.target)
177
-
178
- if (scope.enableDamping === true) {
179
- sphericalDelta.theta *= 1 - scope.dampingFactor
180
- sphericalDelta.phi *= 1 - scope.dampingFactor
181
- } else {
182
- sphericalDelta.set(0, 0, 0)
183
- }
184
-
185
- scale = 1
186
- panOffset.set(0, 0, 0)
187
-
188
- // update condition is:
189
- // min(camera displacement, camera rotation in radians)^2 > EPS
190
- // using small-angle approximation cos(x/2) = 1 - x^2 / 8
191
-
192
- // if ((scope.cameraChanged || zoomChanged) && (
193
- // lastPosition.distanceToSquared(scope.object.position) > EPS ||
194
- // 8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS)) {
195
- if (
196
- zoomChanged ||
197
- lastPosition.distanceToSquared(scope.object.position) > EPS ||
198
- 8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS
199
- ) {
200
- lastPosition.copy(scope.object.position)
201
- lastQuaternion.copy(scope.object.quaternion)
202
-
203
- scope.component.invalidate()
204
- scope.cameraChanged = false
205
- zoomChanged = false
206
-
207
- return true
208
- }
209
-
210
- return false
211
- }
212
- })()
213
-
214
- this.dispose = function () {}
215
-
216
- //
217
- // event handlers - FSM: listen for events and reset state
218
- //
219
-
220
- this.onMouseDown = function (event: MouseEvent) {}
221
-
222
- this.onMouseMove = function (event: MouseEvent) {}
223
-
224
- this.onMouseUp = function (event: MouseEvent) {}
225
-
226
- this.onDragStart = function (event: DragEvent) {
227
- if (this.enabled === false || this.enableRotate === false) return
228
-
229
- scope.component.stop()
230
- this.autoRotate = false
231
-
232
- if (event.altKey === true) state = STATE.PAN
233
- else state = STATE.ROTATE
234
-
235
- switch (state) {
236
- case STATE.ROTATE:
237
- if (this.enableRotate) handleDragStartRotate(event)
238
- break
239
-
240
- case STATE.DOLLY:
241
- if (this.enableZoom) handleDragStartDolly(event)
242
- break
243
-
244
- case STATE.PAN:
245
- if (this.enablePan) handleDragStartPan(event)
246
- break
247
- }
248
- }
249
-
250
- this.onDragMove = function (event: DragEvent) {
251
- if (!this.enabled) return
252
-
253
- if (event.altKey === true) state = STATE.PAN
254
- else state = STATE.ROTATE
255
-
256
- switch (state) {
257
- case STATE.ROTATE:
258
- if (this.enableRotate) handleDragMoveRotate(event)
259
- break
260
-
261
- case STATE.DOLLY:
262
- if (this.enableZoom) handleDragMoveDolly(event)
263
- break
264
-
265
- case STATE.PAN:
266
- if (this.enablePan) handleDragMovePan(event)
267
- break
268
- }
269
- }
270
-
271
- this.onDragEnd = function (event: DragEvent) {
272
- if (this.enabled === false || this.enableRotate === false) return
273
-
274
- state = STATE.NONE
275
-
276
- START_TIME = null
277
- this.autoRotate = this.component.state.autoRotate || false
278
-
279
- scope.component.threed_animate()
280
- // scope.update();
281
- }
282
-
283
- this.onKeyDown = function (event: KeyboardEvent) {
284
- if (this.enabled === false || this.enableKeys === false || this.enablePan === false) return
285
-
286
- handleKeyDown(event)
287
- }
288
-
289
- this.onTouchStart = function (event: TouchEvent) {
290
- if (this.enabled === false) return
291
-
292
- switch (event.touches.length) {
293
- case 1: // one-fingered touch: rotate
294
- if (this.enableRotate === false) return
295
- handleTouchStartRotate(event)
296
- state = STATE.TOUCH_ROTATE
297
- break
298
-
299
- case 2: // two-fingered touch: pan
300
- this.lastScale = (event as any).scale || 1
301
- if (this.enablePan === false) return
302
- handleTouchStartPan(event)
303
- state = STATE.TOUCH_PAN
304
- break
305
- // case 2: // two-fingered touch: dolly
306
- // if ( this.enableZoom === false ) return;
307
- // handleTouchStartDolly( event );
308
- // state = STATE.TOUCH_DOLLY;
309
- // break;
310
-
311
- // case 3: // three-fingered touch: pan
312
- // if ( this.enablePan === false ) return;
313
- // handleTouchStartPan( event );
314
- // state = STATE.TOUCH_PAN;
315
- // break;
316
-
317
- default:
318
- state = STATE.NONE
319
- }
320
- }
321
-
322
- this.onTouchMove = function (event: TouchEvent) {
323
- if (this.enabled === false) return
324
-
325
- switch (event.touches.length) {
326
- case 1: // one-fingered touch: rotate
327
- if (this.enableRotate === false) return
328
- if (state !== STATE.TOUCH_ROTATE) return // is this needed?...
329
- handleTouchMoveRotate(event)
330
- break
331
- case 2: // two-fingered touch: pan
332
- if (Math.abs(this.lastScale - (event as any).scale || 1) > 0.05) {
333
- return
334
- }
335
- if (this.enablePan === false) return
336
- if (state !== STATE.TOUCH_PAN) return // is this needed?...
337
- handleTouchMovePan(event)
338
- break
339
- // case 2: // two-fingered touch: dolly
340
- // if ( this.enableZoom === false ) return;
341
- // if ( state !== STATE.TOUCH_DOLLY ) return; // is this needed?...
342
- // handleTouchMoveDolly( event );
343
- // break;
344
- // case 3: // three-fingered touch: pan
345
- // if ( this.enablePan === false ) return;
346
- // if ( state !== STATE.TOUCH_PAN ) return; // is this needed?...
347
- // handleTouchMovePan( event );
348
- // break;
349
- default:
350
- state = STATE.NONE
351
- }
352
- }
353
-
354
- this.onTouchEnd = function (event: TouchEvent) {
355
- if (this.enabled === false) return
356
- this.lastScale = 1
357
-
358
- handleTouchEnd(event)
359
- // this.dispatchEvent( endEvent );
360
- state = STATE.NONE
361
- }
362
-
363
- this.doAutoRotate = function (autoRotate: boolean) {
364
- START_TIME = null
365
- this.cameraChanged = true
366
- this.autoRotate = autoRotate
367
- this.update()
368
- }
369
-
370
- //
371
- // internals
372
- //
373
-
374
- var scope = this
375
-
376
- var changeEvent = { type: 'change' }
377
- var startEvent = { type: 'start' }
378
- var endEvent = { type: 'end' }
379
-
380
- var STATE = { NONE: -1, ROTATE: 0, DOLLY: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_DOLLY: 4, TOUCH_PAN: 5 }
381
-
382
- var state = STATE.NONE
383
-
384
- var EPS = 0.000001
385
-
386
- // current position in spherical coordinates
387
- var spherical = new THREE.Spherical()
388
- var sphericalDelta = new THREE.Spherical()
389
-
390
- var scale = 1
391
- var panOffset = new THREE.Vector3()
392
- var zoomChanged = false
393
-
394
- var rotateStart = new THREE.Vector2()
395
- var rotateEnd = new THREE.Vector2()
396
- var rotateDelta = new THREE.Vector2()
397
-
398
- var panStart = new THREE.Vector2()
399
- var panEnd = new THREE.Vector2()
400
- var panDelta = new THREE.Vector2()
401
-
402
- var dollyStart = new THREE.Vector2()
403
- var dollyEnd = new THREE.Vector2()
404
- var dollyDelta = new THREE.Vector2()
405
-
406
- var START_TIME: number | null = null
407
- var offsetTheta = 0
408
-
409
- function getAutoRotationAngle() {
410
- if (!START_TIME) {
411
- START_TIME = performance.now()
412
- offsetTheta = spherical.theta
413
- return 0
414
- }
415
-
416
- var lastTime = performance.now() - START_TIME
417
- var progress = lastTime / (60000 / scope.autoRotateSpeed)
418
-
419
- // return - 2 * Math.PI * progress;
420
- return 2 * Math.PI * progress + spherical.theta - offsetTheta
421
- // return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
422
- }
423
-
424
- function getZoomScale() {
425
- return Math.pow(0.95, scope.zoomSpeed)
426
- }
427
-
428
- function rotateLeft(angle: number) {
429
- sphericalDelta.theta -= angle
430
- }
431
-
432
- function rotateUp(angle: number) {
433
- sphericalDelta.phi -= angle
434
- }
435
-
436
- var panLeft = (function () {
437
- var v = new THREE.Vector3()
438
-
439
- return function panLeft(distance: number, objectMatrix: any) {
440
- v.setFromMatrixColumn(objectMatrix, 0) // get X column of objectMatrix
441
- v.multiplyScalar(-distance)
442
-
443
- panOffset.add(v)
444
- }
445
- })()
446
-
447
- var panUp = (function () {
448
- var v = new THREE.Vector3()
449
-
450
- return function panUp(distance: number, objectMatrix: any) {
451
- v.setFromMatrixColumn(objectMatrix, 1) // get Y column of objectMatrix
452
- v.multiplyScalar(distance)
453
-
454
- panOffset.add(v)
455
- }
456
- })()
457
-
458
- // deltaX and deltaY are in pixels; right and down are positive
459
- var pan = (function () {
460
- var offset = new THREE.Vector3()
461
-
462
- return function pan(deltaX: number, deltaY: number) {
463
- // var element = scope.component === document ? scope.component.body : scope.component
464
- const { width, height } = scope.component.bounds
465
-
466
- if (scope.object.isPerspectiveCamera) {
467
- // perspective
468
- var position = scope.object.position
469
- offset.copy(position).sub(scope.target)
470
- var targetDistance = offset.length()
471
-
472
- // half of the fov is center to top of screen
473
- targetDistance *= Math.tan(((scope.object.fov / 2) * Math.PI) / 180.0)
474
-
475
- // we actually don't use screenWidth, since perspective camera is fixed to screen height
476
- panLeft((2 * deltaX * targetDistance) / height, scope.object.matrix)
477
- // panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix );
478
- panUp((2 * deltaY * targetDistance) / height, scope.object.matrix)
479
- // panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix );
480
- } else if (scope.object.isOrthographicCamera) {
481
- // orthographic
482
- panLeft((deltaX * (scope.object.right - scope.object.left)) / scope.object.zoom / width, scope.object.matrix)
483
- // panLeft( deltaX * ( scope.object.right - scope.object.left ) / element.clientWidth, scope.object.matrix );
484
- panUp((deltaY * (scope.object.top - scope.object.bottom)) / scope.object.zoom / height, scope.object.matrix)
485
- // panUp( deltaY * ( scope.object.top - scope.object.bottom ) / element.clientHeight, scope.object.matrix );
486
- } else {
487
- // camera neither orthographic nor perspective
488
- console.warn('WARNING: ThreeControls.js encountered an unknown camera type - pan disabled.')
489
- scope.enablePan = false
490
- }
491
- }
492
- })()
493
-
494
- function dollyIn(dollyScale: number) {
495
- if (scope.object.isPerspectiveCamera) {
496
- scale /= dollyScale
497
- } else if (scope.object.isOrthographicCamera) {
498
- scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom * dollyScale))
499
- scope.object.updateProjectionMatrix()
500
- zoomChanged = true
501
- } else {
502
- console.warn('WARNING: ThreeControls.js encountered an unknown camera type - dolly/zoom disabled.')
503
- scope.enableZoom = false
504
- }
505
- }
506
-
507
- function dollyOut(dollyScale: number) {
508
- if (scope.object.isPerspectiveCamera) {
509
- scale *= dollyScale
510
- } else if (scope.object.isOrthographicCamera) {
511
- scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom / dollyScale))
512
- scope.object.updateProjectionMatrix()
513
- zoomChanged = true
514
- } else {
515
- console.warn('WARNING: ThreeControls.js encountered an unknown camera type - dolly/zoom disabled.')
516
- scope.enableZoom = false
517
- }
518
- }
519
-
520
- //
521
- // event callbacks - update the object state
522
- //
523
-
524
- function handleDragStartRotate(event: DragEvent) {
525
- rotateStart.set(event.offsetX, event.offsetY)
526
- }
527
-
528
- function handleDragStartDolly(event: DragEvent) {
529
- dollyStart.set(event.offsetX, event.offsetY)
530
- }
531
-
532
- function handleDragStartPan(event: DragEvent) {
533
- panStart.set(event.offsetX, event.offsetY)
534
- }
535
-
536
- function handleDragMoveRotate(event: DragEvent) {
537
- rotateEnd.set(event.offsetX, event.offsetY)
538
- rotateDelta.subVectors(rotateEnd, rotateStart)
539
-
540
- var element = scope.component
541
-
542
- // rotating across whole screen goes 360 degrees around
543
- rotateLeft(((2 * Math.PI * rotateDelta.x) / element.getState('width')) * scope.rotateSpeed)
544
-
545
- // rotating up and down along whole screen attempts to go 360, but limited to 180
546
- rotateUp(((2 * Math.PI * rotateDelta.y) / element.getState('height')) * scope.rotateSpeed)
547
-
548
- rotateStart.copy(rotateEnd)
549
-
550
- scope.update()
551
- }
552
-
553
- function handleDragMoveDolly(event: DragEvent) {
554
- dollyEnd.set(event.offsetX, event.offsetY)
555
-
556
- dollyDelta.subVectors(dollyEnd, dollyStart)
557
-
558
- if (dollyDelta.y > 0) {
559
- dollyIn(getZoomScale())
560
- } else if (dollyDelta.y < 0) {
561
- dollyOut(getZoomScale())
562
- }
563
-
564
- dollyStart.copy(dollyEnd)
565
-
566
- scope.update()
567
- }
568
-
569
- function handleDragMovePan(event: DragEvent) {
570
- panEnd.set(event.offsetX, event.offsetY)
571
-
572
- panDelta.subVectors(panEnd, panStart)
573
-
574
- pan(panDelta.x, panDelta.y)
575
-
576
- panStart.copy(panEnd)
577
-
578
- scope.update()
579
- }
580
-
581
- function handleMouseUp(event: MouseEvent) {}
582
-
583
- function handleKeyDown(event: KeyboardEvent) {
584
- switch (event.keyCode) {
585
- case scope.keys.UP:
586
- pan(0, scope.keyPanSpeed)
587
- scope.update()
588
- break
589
-
590
- case scope.keys.BOTTOM:
591
- pan(0, -scope.keyPanSpeed)
592
- scope.update()
593
- break
594
-
595
- case scope.keys.LEFT:
596
- pan(scope.keyPanSpeed, 0)
597
- scope.update()
598
- break
599
-
600
- case scope.keys.RIGHT:
601
- pan(-scope.keyPanSpeed, 0)
602
- scope.update()
603
- break
604
- }
605
- }
606
-
607
- function handleTouchStartRotate(event: TouchEvent) {
608
- var x = (event.touches[0] as any).offsetX || event.touches[0].pageX
609
- var y = (event.touches[0] as any).offsetY || event.touches[0].pageY
610
-
611
- rotateStart.set(x, y)
612
- }
613
-
614
- function handleTouchStartDolly(event: TouchEvent) {
615
- var dx = event.touches[0].pageX - event.touches[1].pageX
616
- var dy = event.touches[0].pageY - event.touches[1].pageY
617
-
618
- var distance = Math.sqrt(dx * dx + dy * dy)
619
-
620
- dollyStart.set(0, distance)
621
- }
622
-
623
- function handleTouchStartPan(event: TouchEvent) {
624
- var x = (event.touches[0] as any).offsetX || event.touches[0].pageX
625
- var y = (event.touches[0] as any).offsetY || event.touches[0].pageY
626
-
627
- panStart.set(x, y)
628
- }
629
-
630
- function handleTouchMoveRotate(event: TouchEvent) {
631
- var x = (event.touches[0] as any).offsetX || event.touches[0].pageX
632
- var y = (event.touches[0] as any).offsetY || event.touches[0].pageY
633
-
634
- rotateEnd.set(x, y)
635
- rotateDelta.subVectors(rotateEnd, rotateStart)
636
-
637
- var element = scope.component === document ? scope.component.body : scope.component
638
-
639
- // rotating across whole screen goes 360 degrees around
640
- rotateLeft(((2 * Math.PI * rotateDelta.x) / element.model.width) * scope.rotateSpeed)
641
- // rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
642
-
643
- // rotating up and down along whole screen attempts to go 360, but limited to 180
644
- rotateUp(((2 * Math.PI * rotateDelta.y) / element.model.height) * scope.rotateSpeed)
645
- // rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
646
-
647
- rotateStart.copy(rotateEnd)
648
-
649
- scope.update()
650
- }
651
-
652
- function handleTouchMoveDolly(event: TouchEvent) {
653
- var dx = event.touches[0].pageX - event.touches[1].pageX
654
- var dy = event.touches[0].pageY - event.touches[1].pageY
655
-
656
- var distance = Math.sqrt(dx * dx + dy * dy)
657
-
658
- dollyEnd.set(0, distance)
659
-
660
- dollyDelta.subVectors(dollyEnd, dollyStart)
661
-
662
- if (dollyDelta.y > 0) {
663
- dollyOut(getZoomScale())
664
- } else if (dollyDelta.y < 0) {
665
- dollyIn(getZoomScale())
666
- }
667
-
668
- dollyStart.copy(dollyEnd)
669
-
670
- scope.update()
671
- }
672
-
673
- function handleTouchMovePan(event: TouchEvent) {
674
- var x = (event.touches[0] as any).offsetX || event.touches[0].pageX
675
- var y = (event.touches[0] as any).offsetY || event.touches[0].pageY
676
-
677
- panEnd.set(x, y)
678
-
679
- panDelta.subVectors(panEnd, panStart)
680
-
681
- pan(panDelta.x, panDelta.y)
682
-
683
- panStart.copy(panEnd)
684
-
685
- scope.update()
686
- }
687
-
688
- function handleTouchEnd(event: TouchEvent) {}
689
-
690
- this.update()
691
- }
692
-
693
- ThreeControls.prototype = {} //Object.create( THREE.EventDispatcher.prototype );
694
- ThreeControls.prototype.constructor = ThreeControls
695
- Object.defineProperties(ThreeControls.prototype, {
696
- center: {
697
- get: function () {
698
- console.warn('THREE.OrbitControls: .center has been renamed to .target')
699
- return this.target
700
- }
701
- },
702
-
703
- // backward compatibility
704
-
705
- noZoom: {
706
- get: function () {
707
- console.warn('THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.')
708
- return !this.enableZoom
709
- },
710
-
711
- set: function (value) {
712
- console.warn('THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.')
713
- this.enableZoom = !value
714
- }
715
- },
716
-
717
- noRotate: {
718
- get: function () {
719
- console.warn('THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.')
720
- return !this.enableRotate
721
- },
722
-
723
- set: function (value) {
724
- console.warn('THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.')
725
- this.enableRotate = !value
726
- }
727
- },
728
-
729
- noPan: {
730
- get: function () {
731
- console.warn('THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.')
732
- return !this.enablePan
733
- },
734
-
735
- set: function (value) {
736
- console.warn('THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.')
737
- this.enablePan = !value
738
- }
739
- },
740
-
741
- noKeys: {
742
- get: function () {
743
- console.warn('THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.')
744
- return !this.enableKeys
745
- },
746
-
747
- set: function (value) {
748
- console.warn('THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.')
749
- this.enableKeys = !value
750
- }
751
- },
752
-
753
- staticMoving: {
754
- get: function () {
755
- console.warn('THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.')
756
- return !this.enableDamping
757
- },
758
-
759
- set: function (value) {
760
- console.warn('THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.')
761
- this.enableDamping = !value
762
- }
763
- },
764
-
765
- dynamicDampingFactor: {
766
- get: function () {
767
- console.warn('THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.')
768
- return this.dampingFactor
769
- },
770
-
771
- set: function (value) {
772
- console.warn('THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.')
773
- this.dampingFactor = value
774
- }
775
- }
776
- })
777
-
778
- export default ThreeControls