@operato/scene-visualizer 9.1.1 → 10.0.0-beta.1

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 (181) hide show
  1. package/dist/banner.d.ts +232 -3
  2. package/dist/banner.js +1 -2
  3. package/dist/banner.js.map +1 -1
  4. package/dist/camera.d.ts +232 -3
  5. package/dist/camera.js +1 -2
  6. package/dist/camera.js.map +1 -1
  7. package/dist/carrier.d.ts +263 -0
  8. package/dist/carrier.js +272 -0
  9. package/dist/carrier.js.map +1 -0
  10. package/dist/cube.d.ts +232 -4
  11. package/dist/cube.js +1 -2
  12. package/dist/cube.js.map +1 -1
  13. package/dist/cylinder.d.ts +1 -3
  14. package/dist/cylinder.js +1 -2
  15. package/dist/cylinder.js.map +1 -1
  16. package/dist/desk.d.ts +238 -3
  17. package/dist/desk.js +1 -2
  18. package/dist/desk.js.map +1 -1
  19. package/dist/editors/index.d.ts +1 -0
  20. package/dist/editors/index.js +5 -0
  21. package/dist/editors/index.js.map +1 -1
  22. package/dist/editors/property-editor-gltf-fill-targets.d.ts +17 -0
  23. package/dist/editors/property-editor-gltf-fill-targets.js +211 -0
  24. package/dist/editors/property-editor-gltf-fill-targets.js.map +1 -0
  25. package/dist/editors/property-editor-gltf-info.js +38 -29
  26. package/dist/editors/property-editor-gltf-info.js.map +1 -1
  27. package/dist/editors/property-editor-location-increase-pattern.js +91 -95
  28. package/dist/editors/property-editor-location-increase-pattern.js.map +1 -1
  29. package/dist/effects/outline.js +1 -1
  30. package/dist/effects/outline.js.map +1 -1
  31. package/dist/ellipse.js +2 -4
  32. package/dist/ellipse.js.map +1 -1
  33. package/dist/gltf-object.d.ts +232 -3
  34. package/dist/gltf-object.js +1 -2
  35. package/dist/gltf-object.js.map +1 -1
  36. package/dist/html-overlay-element.js +3 -7
  37. package/dist/html-overlay-element.js.map +1 -1
  38. package/dist/index.d.ts +5 -17
  39. package/dist/index.js +7 -17
  40. package/dist/index.js.map +1 -1
  41. package/dist/light.d.ts +1 -2
  42. package/dist/light.js +1 -2
  43. package/dist/light.js.map +1 -1
  44. package/dist/polygon.js +2 -4
  45. package/dist/polygon.js.map +1 -1
  46. package/dist/rack-table-3d.d.ts +16 -0
  47. package/dist/rack-table-3d.js +94 -0
  48. package/dist/rack-table-3d.js.map +1 -0
  49. package/dist/rack-table-cell.d.ts +238 -3
  50. package/dist/rack-table-cell.js +44 -51
  51. package/dist/rack-table-cell.js.map +1 -1
  52. package/dist/rack-table-location.d.ts +37 -0
  53. package/dist/rack-table-location.js +227 -0
  54. package/dist/rack-table-location.js.map +1 -0
  55. package/dist/rack-table.d.ts +13 -29
  56. package/dist/rack-table.js +108 -380
  57. package/dist/rack-table.js.map +1 -1
  58. package/dist/rack.d.ts +3 -5
  59. package/dist/rack.js +7 -9
  60. package/dist/rack.js.map +1 -1
  61. package/dist/rect.js +2 -4
  62. package/dist/rect.js.map +1 -1
  63. package/dist/signal-tower.d.ts +492 -0
  64. package/dist/signal-tower.js +275 -0
  65. package/dist/signal-tower.js.map +1 -0
  66. package/dist/sphere.d.ts +1 -3
  67. package/dist/sphere.js +1 -2
  68. package/dist/sphere.js.map +1 -1
  69. package/dist/sprite.d.ts +232 -3
  70. package/dist/sprite.js +1 -2
  71. package/dist/sprite.js.map +1 -1
  72. package/dist/stock.d.ts +22 -10
  73. package/dist/stock.js +130 -109
  74. package/dist/stock.js.map +1 -1
  75. package/dist/tank.d.ts +492 -0
  76. package/dist/tank.js +312 -0
  77. package/dist/tank.js.map +1 -0
  78. package/dist/templates/carrier.d.ts +19 -0
  79. package/dist/templates/carrier.js +20 -0
  80. package/dist/templates/carrier.js.map +1 -0
  81. package/dist/templates/cube.js +1 -1
  82. package/dist/templates/cube.js.map +1 -1
  83. package/dist/templates/cylinder.js +3 -3
  84. package/dist/templates/cylinder.js.map +1 -1
  85. package/dist/templates/index.d.ts +1 -0
  86. package/dist/templates/index.js +9 -1
  87. package/dist/templates/index.js.map +1 -1
  88. package/dist/templates/signal-tower.d.ts +21 -0
  89. package/dist/templates/signal-tower.js +22 -0
  90. package/dist/templates/signal-tower.js.map +1 -0
  91. package/dist/templates/sphere.d.ts +1 -0
  92. package/dist/templates/sphere.js +5 -4
  93. package/dist/templates/sphere.js.map +1 -1
  94. package/dist/templates/tank.d.ts +21 -0
  95. package/dist/templates/tank.js +22 -0
  96. package/dist/templates/tank.js.map +1 -0
  97. package/dist/templates/vehicle.d.ts +19 -0
  98. package/dist/templates/vehicle.js +20 -0
  99. package/dist/templates/vehicle.js.map +1 -0
  100. package/dist/text.js +2 -4
  101. package/dist/text.js.map +1 -1
  102. package/dist/three-container.d.ts +11 -35
  103. package/dist/three-container.js +128 -322
  104. package/dist/three-container.js.map +1 -1
  105. package/dist/three-controls.d.ts +101 -1
  106. package/dist/three-controls.js +339 -541
  107. package/dist/three-controls.js.map +1 -1
  108. package/dist/three-space.d.ts +6 -83
  109. package/dist/three-space.js +25 -537
  110. package/dist/three-space.js.map +1 -1
  111. package/dist/threed/index.d.ts +1 -0
  112. package/dist/threed/index.js +1 -0
  113. package/dist/threed/index.js.map +1 -1
  114. package/dist/threed/interfaces.d.ts +15 -0
  115. package/dist/threed/interfaces.js +5 -0
  116. package/dist/threed/interfaces.js.map +1 -0
  117. package/dist/threed/managers/camera-manager.d.ts +14 -0
  118. package/dist/threed/managers/camera-manager.js +60 -0
  119. package/dist/threed/managers/camera-manager.js.map +1 -0
  120. package/dist/threed/managers/controls-manager.d.ts +50 -0
  121. package/dist/threed/managers/controls-manager.js +249 -0
  122. package/dist/threed/managers/controls-manager.js.map +1 -0
  123. package/dist/threed/managers/event-manager3d.d.ts +19 -0
  124. package/dist/threed/managers/event-manager3d.js +76 -0
  125. package/dist/threed/managers/event-manager3d.js.map +1 -0
  126. package/dist/threed/managers/index.d.ts +7 -0
  127. package/dist/threed/managers/index.js +7 -0
  128. package/dist/threed/managers/index.js.map +1 -0
  129. package/dist/threed/managers/light-manager.d.ts +7 -0
  130. package/dist/threed/managers/light-manager.js +37 -0
  131. package/dist/threed/managers/light-manager.js.map +1 -0
  132. package/dist/threed/managers/renderer-manager.d.ts +30 -0
  133. package/dist/threed/managers/renderer-manager.js +120 -0
  134. package/dist/threed/managers/renderer-manager.js.map +1 -0
  135. package/dist/threed/managers/scene-manager.d.ts +15 -0
  136. package/dist/threed/managers/scene-manager.js +48 -0
  137. package/dist/threed/managers/scene-manager.js.map +1 -0
  138. package/dist/threed/managers/types.d.ts +36 -0
  139. package/dist/threed/managers/types.js +2 -0
  140. package/dist/threed/managers/types.js.map +1 -0
  141. package/dist/threed/real-object-dom-element.js +11 -3
  142. package/dist/threed/real-object-dom-element.js.map +1 -1
  143. package/dist/threed/real-object-extrude.d.ts +1 -0
  144. package/dist/threed/real-object-extrude.js +7 -0
  145. package/dist/threed/real-object-extrude.js.map +1 -1
  146. package/dist/threed/real-object-gltf.js +6 -2
  147. package/dist/threed/real-object-gltf.js.map +1 -1
  148. package/dist/threed/real-object-mesh.js +4 -6
  149. package/dist/threed/real-object-mesh.js.map +1 -1
  150. package/dist/threed/real-object-registry.d.ts +7 -0
  151. package/dist/threed/real-object-registry.js +32 -0
  152. package/dist/threed/real-object-registry.js.map +1 -0
  153. package/dist/threed/real-object-scene.js +10 -5
  154. package/dist/threed/real-object-scene.js.map +1 -1
  155. package/dist/threed/real-object-sprite-2d.js.map +1 -1
  156. package/dist/threed/real-object-sprite.js +2 -0
  157. package/dist/threed/real-object-sprite.js.map +1 -1
  158. package/dist/threed/real-object-text.js +2 -0
  159. package/dist/threed/real-object-text.js.map +1 -1
  160. package/dist/threed/real-object.d.ts +3 -2
  161. package/dist/threed/real-object.js +7 -16
  162. package/dist/threed/real-object.js.map +1 -1
  163. package/dist/threed/three-dimensional-container.d.ts +1 -2
  164. package/dist/threed/three-dimensional-container.js.map +1 -1
  165. package/dist/threed/utils/dispose.d.ts +2 -0
  166. package/dist/threed/utils/dispose.js +32 -0
  167. package/dist/threed/utils/dispose.js.map +1 -0
  168. package/dist/vehicle.d.ts +248 -0
  169. package/dist/vehicle.js +133 -0
  170. package/dist/vehicle.js.map +1 -0
  171. package/dist/visualizer.d.ts +4 -5
  172. package/dist/visualizer.js +15 -28
  173. package/dist/visualizer.js.map +1 -1
  174. package/dist/wall.d.ts +232 -4
  175. package/dist/wall.js +1 -2
  176. package/dist/wall.js.map +1 -1
  177. package/icons/carrier.png +0 -0
  178. package/icons/signal-tower.png +0 -0
  179. package/icons/tank.png +0 -0
  180. package/icons/vehicle.png +0 -0
  181. package/package.json +16 -18
@@ -9,608 +9,406 @@
9
9
  * @author erich666 / http://erichaines.com
10
10
  */
11
11
  import * as THREE from 'three';
12
- var ThreeControls = function (object, component) {
13
- this.object = object;
14
- this.component = component;
15
- // Set to false to disable this control
16
- this.enabled = true;
17
- // "target" sets the location of focus, where the object orbits around
18
- this.target = new THREE.Vector3();
19
- // How far you can dolly in and out ( PerspectiveCamera only )
20
- this.minDistance = 0;
21
- this.maxDistance = Infinity;
22
- // How far you can zoom in and out ( OrthographicCamera only )
23
- this.minZoom = 0;
24
- this.maxZoom = Infinity;
25
- // How far you can orbit vertically, upper and lower limits.
26
- // Range is 0 to Math.PI radians.
27
- this.minPolarAngle = 0; // radians
28
- this.maxPolarAngle = Math.PI; // radians
29
- // How far you can orbit horizontally, upper and lower limits.
30
- // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
31
- this.minAzimuthAngle = -Infinity; // radians
32
- this.maxAzimuthAngle = Infinity; // radians
33
- // Set to true to enable damping (inertia)
34
- // If damping is enabled, you must call controls.update() in your animation loop
35
- this.enableDamping = false;
36
- this.dampingFactor = 0.25;
37
- // This option actually enables dollying in and out; left as "zoom" for backwards compatibility.
38
- // Set to false to disable zooming
39
- this.enableZoom = true;
40
- this.zoomSpeed = 1.0;
41
- // Set to false to disable rotating
42
- this.enableRotate = true;
43
- this.rotateSpeed = 1.0;
44
- // Set to false to disable panning
45
- this.enablePan = true;
46
- this.keyPanSpeed = 7.0; // pixels moved per arrow key push
47
- // Set to true to automatically rotate around the target
48
- // If auto-rotate is enabled, you must call controls.update() in your animation loop
49
- this.autoRotate = (this.component.app && !this.component.app.isEditMode && this.component.state.autoRotate) || false;
50
- this.autoRotateSpeed = this.component.state.rotationSpeed || 2.0; // 30 seconds per round when fps is 60
51
- // Set to false to disable use of the keys
52
- this.enableKeys = true;
53
- // The four arrow keys
54
- this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
55
- // Mouse buttons
56
- this.mouseButtons = { ORBIT: THREE.MOUSE.LEFT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT };
57
- // for reset
58
- this.target0 = this.target.clone();
59
- this.position0 = this.object.position.clone();
60
- this.zoom0 = this.object.zoom;
61
- // flags
62
- this.cameraChanged = false;
63
- //
64
- // public methods
65
- //
66
- this.getPolarAngle = function () {
67
- return spherical.phi;
68
- };
69
- this.getAzimuthalAngle = function () {
70
- return spherical.theta;
71
- };
72
- this.saveState = function () {
73
- scope.target0.copy(scope.target);
74
- scope.position0.copy(scope.object.position);
75
- scope.zoom0 = scope.object.zoom;
76
- };
77
- this.reset = function () {
78
- scope.target.copy(scope.target0);
79
- scope.object.position.copy(scope.position0);
80
- scope.object.zoom = scope.zoom0;
81
- scope.object.updateProjectionMatrix();
82
- // scope.dispatchEvent( changeEvent );
83
- scope.update();
84
- state = STATE.NONE;
85
- };
86
- // this method is exposed, but perhaps it would be better if we can make it private...
87
- this.update = (function () {
88
- var offset = new THREE.Vector3();
89
- // so camera.up is the orbit axis
90
- var quat = new THREE.Quaternion().setFromUnitVectors(object.up, new THREE.Vector3(0, 1, 0));
91
- var quatInverse = quat.clone().invert();
92
- var lastPosition = new THREE.Vector3();
93
- var lastQuaternion = new THREE.Quaternion();
94
- return function update() {
95
- // if (!(scope.cameraChanged || scope.autoRotate))
96
- // return false;
97
- var position = scope.object.position;
98
- offset.copy(position).sub(scope.target);
99
- // rotate offset to "y-axis-is-up" space
100
- offset.applyQuaternion(quat);
101
- // angle from z-axis around y-axis
102
- spherical.setFromVector3(offset);
103
- if (scope.autoRotate && state === STATE.NONE) {
104
- rotateLeft(getAutoRotationAngle());
105
- }
106
- spherical.theta += sphericalDelta.theta;
107
- spherical.phi += sphericalDelta.phi;
108
- // restrict theta to be between desired limits
109
- spherical.theta = Math.max(scope.minAzimuthAngle, Math.min(scope.maxAzimuthAngle, spherical.theta));
110
- // restrict phi to be between desired limits
111
- spherical.phi = Math.max(scope.minPolarAngle, Math.min(scope.maxPolarAngle, spherical.phi));
112
- spherical.makeSafe();
113
- spherical.radius *= scale;
114
- // restrict radius to be between desired limits
115
- spherical.radius = Math.max(scope.minDistance, Math.min(scope.maxDistance, spherical.radius));
116
- // move target to panned location
117
- scope.target.add(panOffset);
118
- offset.setFromSpherical(spherical);
119
- // rotate offset back to "camera-up-vector-is-up" space
120
- offset.applyQuaternion(quatInverse);
121
- position.copy(scope.target).add(offset);
122
- scope.object.lookAt(scope.target);
123
- if (scope.enableDamping === true) {
124
- sphericalDelta.theta *= 1 - scope.dampingFactor;
125
- sphericalDelta.phi *= 1 - scope.dampingFactor;
126
- }
127
- else {
128
- sphericalDelta.set(0, 0, 0);
129
- }
130
- scale = 1;
131
- panOffset.set(0, 0, 0);
132
- // update condition is:
133
- // min(camera displacement, camera rotation in radians)^2 > EPS
134
- // using small-angle approximation cos(x/2) = 1 - x^2 / 8
135
- // if ((scope.cameraChanged || zoomChanged) && (
136
- // lastPosition.distanceToSquared(scope.object.position) > EPS ||
137
- // 8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS)) {
138
- if (zoomChanged ||
139
- lastPosition.distanceToSquared(scope.object.position) > EPS ||
140
- 8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS) {
141
- lastPosition.copy(scope.object.position);
142
- lastQuaternion.copy(scope.object.quaternion);
143
- scope.component.invalidate();
144
- scope.cameraChanged = false;
145
- zoomChanged = false;
146
- return true;
147
- }
148
- return false;
149
- };
150
- })();
151
- this.dispose = function () { };
152
- //
153
- // event handlers - FSM: listen for events and reset state
154
- //
155
- this.onMouseDown = function (event) { };
156
- this.onMouseMove = function (event) { };
157
- this.onMouseUp = function (event) { };
158
- this.onDragStart = function (event) {
159
- if (this.enabled === false || this.enableRotate === false)
12
+ const EPS = 0.000001;
13
+ export class ThreeControls {
14
+ constructor(object, component) {
15
+ this.enabled = true;
16
+ this.target = new THREE.Vector3();
17
+ // How far you can dolly in and out (PerspectiveCamera only)
18
+ this.minDistance = 0;
19
+ this.maxDistance = Infinity;
20
+ // How far you can zoom in and out (OrthographicCamera only)
21
+ this.minZoom = 0;
22
+ this.maxZoom = Infinity;
23
+ // How far you can orbit vertically, upper and lower limits (0 to Math.PI radians)
24
+ this.minPolarAngle = 0;
25
+ this.maxPolarAngle = Math.PI;
26
+ // How far you can orbit horizontally (sub-interval of [-Math.PI, Math.PI])
27
+ this.minAzimuthAngle = -Infinity;
28
+ this.maxAzimuthAngle = Infinity;
29
+ this.enableDamping = false;
30
+ this.dampingFactor = 0.25;
31
+ this.enableZoom = true;
32
+ this.zoomSpeed = 1.0;
33
+ this.enableRotate = true;
34
+ this.rotateSpeed = 1.0;
35
+ this.enablePan = true;
36
+ this.keyPanSpeed = 7.0;
37
+ this.enableKeys = true;
38
+ this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
39
+ this.mouseButtons = { ORBIT: THREE.MOUSE.LEFT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT };
40
+ this.cameraChanged = false;
41
+ this.lastScale = 1;
42
+ // Internal state
43
+ this._state = -1 /* State.NONE */;
44
+ this._spherical = new THREE.Spherical();
45
+ this._sphericalDelta = new THREE.Spherical();
46
+ this._scale = 1;
47
+ this._panOffset = new THREE.Vector3();
48
+ this._zoomChanged = false;
49
+ this._rotateStart = new THREE.Vector2();
50
+ this._rotateEnd = new THREE.Vector2();
51
+ this._rotateDelta = new THREE.Vector2();
52
+ this._panStart = new THREE.Vector2();
53
+ this._panEnd = new THREE.Vector2();
54
+ this._panDelta = new THREE.Vector2();
55
+ this._dollyStart = new THREE.Vector2();
56
+ this._dollyEnd = new THREE.Vector2();
57
+ this._dollyDelta = new THREE.Vector2();
58
+ this._startTime = null;
59
+ this._offsetTheta = 0;
60
+ // Cached objects for update()
61
+ this._offset = new THREE.Vector3();
62
+ this._lastPosition = new THREE.Vector3();
63
+ this._lastQuaternion = new THREE.Quaternion();
64
+ // Cached vectors for pan helpers
65
+ this._panLeftV = new THREE.Vector3();
66
+ this._panUpV = new THREE.Vector3();
67
+ this._panCalcOffset = new THREE.Vector3();
68
+ this.object = object;
69
+ this.component = component;
70
+ this.autoRotate =
71
+ (component.app && !component.app.isEditMode && component.state.autoRotate) || false;
72
+ this.autoRotateSpeed = component.state.rotationSpeed || 2.0;
73
+ this.target0 = this.target.clone();
74
+ this.position0 = object.position.clone();
75
+ this.zoom0 = object.zoom;
76
+ this._quat = new THREE.Quaternion().setFromUnitVectors(object.up, new THREE.Vector3(0, 1, 0));
77
+ this._quatInverse = this._quat.clone().invert();
78
+ this.update();
79
+ }
80
+ getPolarAngle() {
81
+ return this._spherical.phi;
82
+ }
83
+ getAzimuthalAngle() {
84
+ return this._spherical.theta;
85
+ }
86
+ saveState() {
87
+ this.target0.copy(this.target);
88
+ this.position0.copy(this.object.position);
89
+ this.zoom0 = this.object.zoom;
90
+ }
91
+ reset() {
92
+ this.target.copy(this.target0);
93
+ this.object.position.copy(this.position0);
94
+ this.object.zoom = this.zoom0;
95
+ this.object.updateProjectionMatrix();
96
+ this.update();
97
+ this._state = -1 /* State.NONE */;
98
+ }
99
+ update() {
100
+ const position = this.object.position;
101
+ this._offset.copy(position).sub(this.target);
102
+ this._offset.applyQuaternion(this._quat);
103
+ this._spherical.setFromVector3(this._offset);
104
+ if (this.autoRotate && this._state === -1 /* State.NONE */) {
105
+ this._rotateLeft(this._getAutoRotationAngle());
106
+ }
107
+ this._spherical.theta += this._sphericalDelta.theta;
108
+ this._spherical.phi += this._sphericalDelta.phi;
109
+ this._spherical.theta = Math.max(this.minAzimuthAngle, Math.min(this.maxAzimuthAngle, this._spherical.theta));
110
+ this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi));
111
+ this._spherical.makeSafe();
112
+ this._spherical.radius *= this._scale;
113
+ this._spherical.radius = Math.max(this.minDistance, Math.min(this.maxDistance, this._spherical.radius));
114
+ this.target.add(this._panOffset);
115
+ this._offset.setFromSpherical(this._spherical);
116
+ this._offset.applyQuaternion(this._quatInverse);
117
+ position.copy(this.target).add(this._offset);
118
+ this.object.lookAt(this.target);
119
+ if (this.enableDamping) {
120
+ this._sphericalDelta.theta *= 1 - this.dampingFactor;
121
+ this._sphericalDelta.phi *= 1 - this.dampingFactor;
122
+ }
123
+ else {
124
+ this._sphericalDelta.set(0, 0, 0);
125
+ }
126
+ this._scale = 1;
127
+ this._panOffset.set(0, 0, 0);
128
+ if (this._zoomChanged ||
129
+ this._lastPosition.distanceToSquared(this.object.position) > EPS ||
130
+ 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > EPS) {
131
+ this._lastPosition.copy(this.object.position);
132
+ this._lastQuaternion.copy(this.object.quaternion);
133
+ this.component.invalidate();
134
+ this.cameraChanged = false;
135
+ this._zoomChanged = false;
136
+ return true;
137
+ }
138
+ return false;
139
+ }
140
+ dispose() { }
141
+ // Event handlers
142
+ onDragStart(event) {
143
+ if (!this.enabled || !this.enableRotate)
160
144
  return;
161
- scope.component.stop();
145
+ this.component.stop();
162
146
  this.autoRotate = false;
163
- if (event.altKey === true)
164
- state = STATE.PAN;
165
- else
166
- state = STATE.ROTATE;
167
- switch (state) {
168
- case STATE.ROTATE:
147
+ this._state = event.altKey ? 2 /* State.PAN */ : 0 /* State.ROTATE */;
148
+ switch (this._state) {
149
+ case 0 /* State.ROTATE */:
169
150
  if (this.enableRotate)
170
- handleDragStartRotate(event);
151
+ this._handleDragStartRotate(event);
171
152
  break;
172
- case STATE.DOLLY:
173
- if (this.enableZoom)
174
- handleDragStartDolly(event);
175
- break;
176
- case STATE.PAN:
153
+ case 2 /* State.PAN */:
177
154
  if (this.enablePan)
178
- handleDragStartPan(event);
155
+ this._handleDragStartPan(event);
179
156
  break;
180
157
  }
181
- };
182
- this.onDragMove = function (event) {
158
+ }
159
+ onDragMove(event) {
183
160
  if (!this.enabled)
184
161
  return;
185
- if (event.altKey === true)
186
- state = STATE.PAN;
187
- else
188
- state = STATE.ROTATE;
189
- switch (state) {
190
- case STATE.ROTATE:
162
+ this._state = event.altKey ? 2 /* State.PAN */ : 0 /* State.ROTATE */;
163
+ switch (this._state) {
164
+ case 0 /* State.ROTATE */:
191
165
  if (this.enableRotate)
192
- handleDragMoveRotate(event);
166
+ this._handleDragMoveRotate(event);
193
167
  break;
194
- case STATE.DOLLY:
195
- if (this.enableZoom)
196
- handleDragMoveDolly(event);
197
- break;
198
- case STATE.PAN:
168
+ case 2 /* State.PAN */:
199
169
  if (this.enablePan)
200
- handleDragMovePan(event);
170
+ this._handleDragMovePan(event);
201
171
  break;
202
172
  }
203
- };
204
- this.onDragEnd = function (event) {
205
- if (this.enabled === false || this.enableRotate === false)
173
+ }
174
+ onDragEnd(event) {
175
+ if (!this.enabled || !this.enableRotate)
206
176
  return;
207
- state = STATE.NONE;
208
- START_TIME = null;
177
+ this._state = -1 /* State.NONE */;
178
+ this._startTime = null;
209
179
  this.autoRotate = this.component.state.autoRotate || false;
210
- scope.component.threed_animate();
211
- // scope.update();
212
- };
213
- this.onKeyDown = function (event) {
214
- if (this.enabled === false || this.enableKeys === false || this.enablePan === false)
180
+ this.component.threed_animate();
181
+ }
182
+ onKeyDown(event) {
183
+ if (!this.enabled || !this.enableKeys || !this.enablePan)
215
184
  return;
216
- handleKeyDown(event);
217
- };
218
- this.onTouchStart = function (event) {
219
- if (this.enabled === false)
185
+ this._handleKeyDown(event);
186
+ }
187
+ onTouchStart(event) {
188
+ if (!this.enabled)
220
189
  return;
221
190
  switch (event.touches.length) {
222
- case 1: // one-fingered touch: rotate
223
- if (this.enableRotate === false)
191
+ case 1:
192
+ if (!this.enableRotate)
224
193
  return;
225
- handleTouchStartRotate(event);
226
- state = STATE.TOUCH_ROTATE;
194
+ this._handleTouchStartRotate(event);
195
+ this._state = 3 /* State.TOUCH_ROTATE */;
227
196
  break;
228
- case 2: // two-fingered touch: pan
197
+ case 2:
229
198
  this.lastScale = event.scale || 1;
230
- if (this.enablePan === false)
199
+ if (!this.enablePan)
231
200
  return;
232
- handleTouchStartPan(event);
233
- state = STATE.TOUCH_PAN;
201
+ this._handleTouchStartPan(event);
202
+ this._state = 5 /* State.TOUCH_PAN */;
234
203
  break;
235
- // case 2: // two-fingered touch: dolly
236
- // if ( this.enableZoom === false ) return;
237
- // handleTouchStartDolly( event );
238
- // state = STATE.TOUCH_DOLLY;
239
- // break;
240
- // case 3: // three-fingered touch: pan
241
- // if ( this.enablePan === false ) return;
242
- // handleTouchStartPan( event );
243
- // state = STATE.TOUCH_PAN;
244
- // break;
245
204
  default:
246
- state = STATE.NONE;
205
+ this._state = -1 /* State.NONE */;
247
206
  }
248
- };
249
- this.onTouchMove = function (event) {
250
- if (this.enabled === false)
207
+ }
208
+ onTouchMove(event) {
209
+ if (!this.enabled)
251
210
  return;
252
211
  switch (event.touches.length) {
253
- case 1: // one-fingered touch: rotate
254
- if (this.enableRotate === false)
212
+ case 1:
213
+ if (!this.enableRotate)
214
+ return;
215
+ if (this._state !== 3 /* State.TOUCH_ROTATE */)
255
216
  return;
256
- if (state !== STATE.TOUCH_ROTATE)
257
- return; // is this needed?...
258
- handleTouchMoveRotate(event);
217
+ this._handleTouchMoveRotate(event);
259
218
  break;
260
- case 2: // two-fingered touch: pan
261
- if (Math.abs(this.lastScale - event.scale || 1) > 0.05) {
219
+ case 2:
220
+ if (Math.abs(this.lastScale - (event.scale || 1)) > 0.05)
262
221
  return;
263
- }
264
- if (this.enablePan === false)
222
+ if (!this.enablePan)
265
223
  return;
266
- if (state !== STATE.TOUCH_PAN)
267
- return; // is this needed?...
268
- handleTouchMovePan(event);
224
+ if (this._state !== 5 /* State.TOUCH_PAN */)
225
+ return;
226
+ this._handleTouchMovePan(event);
269
227
  break;
270
- // case 2: // two-fingered touch: dolly
271
- // if ( this.enableZoom === false ) return;
272
- // if ( state !== STATE.TOUCH_DOLLY ) return; // is this needed?...
273
- // handleTouchMoveDolly( event );
274
- // break;
275
- // case 3: // three-fingered touch: pan
276
- // if ( this.enablePan === false ) return;
277
- // if ( state !== STATE.TOUCH_PAN ) return; // is this needed?...
278
- // handleTouchMovePan( event );
279
- // break;
280
228
  default:
281
- state = STATE.NONE;
229
+ this._state = -1 /* State.NONE */;
282
230
  }
283
- };
284
- this.onTouchEnd = function (event) {
285
- if (this.enabled === false)
231
+ }
232
+ onTouchEnd(event) {
233
+ if (!this.enabled)
286
234
  return;
287
235
  this.lastScale = 1;
288
- handleTouchEnd(event);
289
- // this.dispatchEvent( endEvent );
290
- state = STATE.NONE;
291
- };
292
- this.doAutoRotate = function (autoRotate) {
293
- START_TIME = null;
236
+ this._state = -1 /* State.NONE */;
237
+ }
238
+ doAutoRotate(autoRotate) {
239
+ this._startTime = null;
294
240
  this.cameraChanged = true;
295
241
  this.autoRotate = autoRotate;
296
242
  this.update();
297
- };
298
- //
299
- // internals
300
- //
301
- var scope = this;
302
- var changeEvent = { type: 'change' };
303
- var startEvent = { type: 'start' };
304
- var endEvent = { type: 'end' };
305
- var STATE = { NONE: -1, ROTATE: 0, DOLLY: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_DOLLY: 4, TOUCH_PAN: 5 };
306
- var state = STATE.NONE;
307
- var EPS = 0.000001;
308
- // current position in spherical coordinates
309
- var spherical = new THREE.Spherical();
310
- var sphericalDelta = new THREE.Spherical();
311
- var scale = 1;
312
- var panOffset = new THREE.Vector3();
313
- var zoomChanged = false;
314
- var rotateStart = new THREE.Vector2();
315
- var rotateEnd = new THREE.Vector2();
316
- var rotateDelta = new THREE.Vector2();
317
- var panStart = new THREE.Vector2();
318
- var panEnd = new THREE.Vector2();
319
- var panDelta = new THREE.Vector2();
320
- var dollyStart = new THREE.Vector2();
321
- var dollyEnd = new THREE.Vector2();
322
- var dollyDelta = new THREE.Vector2();
323
- var START_TIME = null;
324
- var offsetTheta = 0;
325
- function getAutoRotationAngle() {
326
- if (!START_TIME) {
327
- START_TIME = performance.now();
328
- offsetTheta = spherical.theta;
243
+ }
244
+ // Private helpers
245
+ _getAutoRotationAngle() {
246
+ if (!this._startTime) {
247
+ this._startTime = performance.now();
248
+ this._offsetTheta = this._spherical.theta;
329
249
  return 0;
330
250
  }
331
- var lastTime = performance.now() - START_TIME;
332
- var progress = lastTime / (60000 / scope.autoRotateSpeed);
333
- // return - 2 * Math.PI * progress;
334
- return 2 * Math.PI * progress + spherical.theta - offsetTheta;
335
- // return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
336
- }
337
- function getZoomScale() {
338
- return Math.pow(0.95, scope.zoomSpeed);
339
- }
340
- function rotateLeft(angle) {
341
- sphericalDelta.theta -= angle;
342
- }
343
- function rotateUp(angle) {
344
- sphericalDelta.phi -= angle;
345
- }
346
- var panLeft = (function () {
347
- var v = new THREE.Vector3();
348
- return function panLeft(distance, objectMatrix) {
349
- v.setFromMatrixColumn(objectMatrix, 0); // get X column of objectMatrix
350
- v.multiplyScalar(-distance);
351
- panOffset.add(v);
352
- };
353
- })();
354
- var panUp = (function () {
355
- var v = new THREE.Vector3();
356
- return function panUp(distance, objectMatrix) {
357
- v.setFromMatrixColumn(objectMatrix, 1); // get Y column of objectMatrix
358
- v.multiplyScalar(distance);
359
- panOffset.add(v);
360
- };
361
- })();
362
- // deltaX and deltaY are in pixels; right and down are positive
363
- var pan = (function () {
364
- var offset = new THREE.Vector3();
365
- return function pan(deltaX, deltaY) {
366
- // var element = scope.component === document ? scope.component.body : scope.component
367
- const { width, height } = scope.component.bounds;
368
- if (scope.object.isPerspectiveCamera) {
369
- // perspective
370
- var position = scope.object.position;
371
- offset.copy(position).sub(scope.target);
372
- var targetDistance = offset.length();
373
- // half of the fov is center to top of screen
374
- targetDistance *= Math.tan(((scope.object.fov / 2) * Math.PI) / 180.0);
375
- // we actually don't use screenWidth, since perspective camera is fixed to screen height
376
- panLeft((2 * deltaX * targetDistance) / height, scope.object.matrix);
377
- // panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix );
378
- panUp((2 * deltaY * targetDistance) / height, scope.object.matrix);
379
- // panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix );
380
- }
381
- else if (scope.object.isOrthographicCamera) {
382
- // orthographic
383
- panLeft((deltaX * (scope.object.right - scope.object.left)) / scope.object.zoom / width, scope.object.matrix);
384
- // panLeft( deltaX * ( scope.object.right - scope.object.left ) / element.clientWidth, scope.object.matrix );
385
- panUp((deltaY * (scope.object.top - scope.object.bottom)) / scope.object.zoom / height, scope.object.matrix);
386
- // panUp( deltaY * ( scope.object.top - scope.object.bottom ) / element.clientHeight, scope.object.matrix );
387
- }
388
- else {
389
- // camera neither orthographic nor perspective
390
- console.warn('WARNING: ThreeControls.js encountered an unknown camera type - pan disabled.');
391
- scope.enablePan = false;
392
- }
393
- };
394
- })();
395
- function dollyIn(dollyScale) {
396
- if (scope.object.isPerspectiveCamera) {
397
- scale /= dollyScale;
251
+ const elapsed = performance.now() - this._startTime;
252
+ const progress = elapsed / (60000 / this.autoRotateSpeed);
253
+ return 2 * Math.PI * progress + this._spherical.theta - this._offsetTheta;
254
+ }
255
+ _getZoomScale() {
256
+ return Math.pow(0.95, this.zoomSpeed);
257
+ }
258
+ _rotateLeft(angle) {
259
+ this._sphericalDelta.theta -= angle;
260
+ }
261
+ _rotateUp(angle) {
262
+ this._sphericalDelta.phi -= angle;
263
+ }
264
+ _panLeft(distance, objectMatrix) {
265
+ this._panLeftV.setFromMatrixColumn(objectMatrix, 0);
266
+ this._panLeftV.multiplyScalar(-distance);
267
+ this._panOffset.add(this._panLeftV);
268
+ }
269
+ _panUp(distance, objectMatrix) {
270
+ this._panUpV.setFromMatrixColumn(objectMatrix, 1);
271
+ this._panUpV.multiplyScalar(distance);
272
+ this._panOffset.add(this._panUpV);
273
+ }
274
+ _pan(deltaX, deltaY) {
275
+ const { width, height } = this.component.bounds;
276
+ const cam = this.object;
277
+ if (cam.isPerspectiveCamera) {
278
+ this._panCalcOffset.copy(cam.position).sub(this.target);
279
+ let targetDistance = this._panCalcOffset.length();
280
+ targetDistance *= Math.tan(((cam.fov / 2) * Math.PI) / 180.0);
281
+ this._panLeft((2 * deltaX * targetDistance) / height, cam.matrix);
282
+ this._panUp((2 * deltaY * targetDistance) / height, cam.matrix);
283
+ }
284
+ else if (cam.isOrthographicCamera) {
285
+ this._panLeft((deltaX * (cam.right - cam.left)) / cam.zoom / width, cam.matrix);
286
+ this._panUp((deltaY * (cam.top - cam.bottom)) / cam.zoom / height, cam.matrix);
287
+ }
288
+ else {
289
+ console.warn('WARNING: ThreeControls encountered an unknown camera type - pan disabled.');
290
+ this.enablePan = false;
291
+ }
292
+ }
293
+ _dollyIn(dollyScale) {
294
+ const cam = this.object;
295
+ if (cam.isPerspectiveCamera) {
296
+ this._scale /= dollyScale;
398
297
  }
399
- else if (scope.object.isOrthographicCamera) {
400
- scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom * dollyScale));
401
- scope.object.updateProjectionMatrix();
402
- zoomChanged = true;
298
+ else if (cam.isOrthographicCamera) {
299
+ cam.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, cam.zoom * dollyScale));
300
+ cam.updateProjectionMatrix();
301
+ this._zoomChanged = true;
403
302
  }
404
303
  else {
405
- console.warn('WARNING: ThreeControls.js encountered an unknown camera type - dolly/zoom disabled.');
406
- scope.enableZoom = false;
304
+ console.warn('WARNING: ThreeControls encountered an unknown camera type - dolly/zoom disabled.');
305
+ this.enableZoom = false;
407
306
  }
408
307
  }
409
- function dollyOut(dollyScale) {
410
- if (scope.object.isPerspectiveCamera) {
411
- scale *= dollyScale;
308
+ _dollyOut(dollyScale) {
309
+ const cam = this.object;
310
+ if (cam.isPerspectiveCamera) {
311
+ this._scale *= dollyScale;
412
312
  }
413
- else if (scope.object.isOrthographicCamera) {
414
- scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom / dollyScale));
415
- scope.object.updateProjectionMatrix();
416
- zoomChanged = true;
313
+ else if (cam.isOrthographicCamera) {
314
+ cam.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, cam.zoom / dollyScale));
315
+ cam.updateProjectionMatrix();
316
+ this._zoomChanged = true;
417
317
  }
418
318
  else {
419
- console.warn('WARNING: ThreeControls.js encountered an unknown camera type - dolly/zoom disabled.');
420
- scope.enableZoom = false;
319
+ console.warn('WARNING: ThreeControls encountered an unknown camera type - dolly/zoom disabled.');
320
+ this.enableZoom = false;
421
321
  }
422
322
  }
423
- //
424
- // event callbacks - update the object state
425
- //
426
- function handleDragStartRotate(event) {
427
- rotateStart.set(event.offsetX, event.offsetY);
428
- }
429
- function handleDragStartDolly(event) {
430
- dollyStart.set(event.offsetX, event.offsetY);
431
- }
432
- function handleDragStartPan(event) {
433
- panStart.set(event.offsetX, event.offsetY);
434
- }
435
- function handleDragMoveRotate(event) {
436
- rotateEnd.set(event.offsetX, event.offsetY);
437
- rotateDelta.subVectors(rotateEnd, rotateStart);
438
- var element = scope.component;
439
- // rotating across whole screen goes 360 degrees around
440
- rotateLeft(((2 * Math.PI * rotateDelta.x) / element.getState('width')) * scope.rotateSpeed);
441
- // rotating up and down along whole screen attempts to go 360, but limited to 180
442
- rotateUp(((2 * Math.PI * rotateDelta.y) / element.getState('height')) * scope.rotateSpeed);
443
- rotateStart.copy(rotateEnd);
444
- scope.update();
445
- }
446
- function handleDragMoveDolly(event) {
447
- dollyEnd.set(event.offsetX, event.offsetY);
448
- dollyDelta.subVectors(dollyEnd, dollyStart);
449
- if (dollyDelta.y > 0) {
450
- dollyIn(getZoomScale());
323
+ // Drag handlers
324
+ _handleDragStartRotate(event) {
325
+ this._rotateStart.set(event.offsetX, event.offsetY);
326
+ }
327
+ _handleDragStartDolly(event) {
328
+ this._dollyStart.set(event.offsetX, event.offsetY);
329
+ }
330
+ _handleDragStartPan(event) {
331
+ this._panStart.set(event.offsetX, event.offsetY);
332
+ }
333
+ _handleDragMoveRotate(event) {
334
+ this._rotateEnd.set(event.offsetX, event.offsetY);
335
+ this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart);
336
+ const element = this.component;
337
+ this._rotateLeft(((2 * Math.PI * this._rotateDelta.x) / element.getState('width')) * this.rotateSpeed);
338
+ this._rotateUp(((2 * Math.PI * this._rotateDelta.y) / element.getState('height')) * this.rotateSpeed);
339
+ this._rotateStart.copy(this._rotateEnd);
340
+ this.update();
341
+ }
342
+ _handleDragMoveDolly(event) {
343
+ this._dollyEnd.set(event.offsetX, event.offsetY);
344
+ this._dollyDelta.subVectors(this._dollyEnd, this._dollyStart);
345
+ if (this._dollyDelta.y > 0) {
346
+ this._dollyIn(this._getZoomScale());
451
347
  }
452
- else if (dollyDelta.y < 0) {
453
- dollyOut(getZoomScale());
348
+ else if (this._dollyDelta.y < 0) {
349
+ this._dollyOut(this._getZoomScale());
454
350
  }
455
- dollyStart.copy(dollyEnd);
456
- scope.update();
457
- }
458
- function handleDragMovePan(event) {
459
- panEnd.set(event.offsetX, event.offsetY);
460
- panDelta.subVectors(panEnd, panStart);
461
- pan(panDelta.x, panDelta.y);
462
- panStart.copy(panEnd);
463
- scope.update();
464
- }
465
- function handleMouseUp(event) { }
466
- function handleKeyDown(event) {
351
+ this._dollyStart.copy(this._dollyEnd);
352
+ this.update();
353
+ }
354
+ _handleDragMovePan(event) {
355
+ this._panEnd.set(event.offsetX, event.offsetY);
356
+ this._panDelta.subVectors(this._panEnd, this._panStart);
357
+ this._pan(this._panDelta.x, this._panDelta.y);
358
+ this._panStart.copy(this._panEnd);
359
+ this.update();
360
+ }
361
+ _handleKeyDown(event) {
467
362
  switch (event.keyCode) {
468
- case scope.keys.UP:
469
- pan(0, scope.keyPanSpeed);
470
- scope.update();
363
+ case this.keys.UP:
364
+ this._pan(0, this.keyPanSpeed);
365
+ this.update();
471
366
  break;
472
- case scope.keys.BOTTOM:
473
- pan(0, -scope.keyPanSpeed);
474
- scope.update();
367
+ case this.keys.BOTTOM:
368
+ this._pan(0, -this.keyPanSpeed);
369
+ this.update();
475
370
  break;
476
- case scope.keys.LEFT:
477
- pan(scope.keyPanSpeed, 0);
478
- scope.update();
371
+ case this.keys.LEFT:
372
+ this._pan(this.keyPanSpeed, 0);
373
+ this.update();
479
374
  break;
480
- case scope.keys.RIGHT:
481
- pan(-scope.keyPanSpeed, 0);
482
- scope.update();
375
+ case this.keys.RIGHT:
376
+ this._pan(-this.keyPanSpeed, 0);
377
+ this.update();
483
378
  break;
484
379
  }
485
380
  }
486
- function handleTouchStartRotate(event) {
487
- var x = event.touches[0].offsetX || event.touches[0].pageX;
488
- var y = event.touches[0].offsetY || event.touches[0].pageY;
489
- rotateStart.set(x, y);
490
- }
491
- function handleTouchStartDolly(event) {
492
- var dx = event.touches[0].pageX - event.touches[1].pageX;
493
- var dy = event.touches[0].pageY - event.touches[1].pageY;
494
- var distance = Math.sqrt(dx * dx + dy * dy);
495
- dollyStart.set(0, distance);
496
- }
497
- function handleTouchStartPan(event) {
498
- var x = event.touches[0].offsetX || event.touches[0].pageX;
499
- var y = event.touches[0].offsetY || event.touches[0].pageY;
500
- panStart.set(x, y);
501
- }
502
- function handleTouchMoveRotate(event) {
503
- var x = event.touches[0].offsetX || event.touches[0].pageX;
504
- var y = event.touches[0].offsetY || event.touches[0].pageY;
505
- rotateEnd.set(x, y);
506
- rotateDelta.subVectors(rotateEnd, rotateStart);
507
- var element = scope.component === document ? scope.component.body : scope.component;
508
- // rotating across whole screen goes 360 degrees around
509
- rotateLeft(((2 * Math.PI * rotateDelta.x) / element.model.width) * scope.rotateSpeed);
510
- // rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
511
- // rotating up and down along whole screen attempts to go 360, but limited to 180
512
- rotateUp(((2 * Math.PI * rotateDelta.y) / element.model.height) * scope.rotateSpeed);
513
- // rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
514
- rotateStart.copy(rotateEnd);
515
- scope.update();
516
- }
517
- function handleTouchMoveDolly(event) {
518
- var dx = event.touches[0].pageX - event.touches[1].pageX;
519
- var dy = event.touches[0].pageY - event.touches[1].pageY;
520
- var distance = Math.sqrt(dx * dx + dy * dy);
521
- dollyEnd.set(0, distance);
522
- dollyDelta.subVectors(dollyEnd, dollyStart);
523
- if (dollyDelta.y > 0) {
524
- dollyOut(getZoomScale());
525
- }
526
- else if (dollyDelta.y < 0) {
527
- dollyIn(getZoomScale());
528
- }
529
- dollyStart.copy(dollyEnd);
530
- scope.update();
531
- }
532
- function handleTouchMovePan(event) {
533
- var x = event.touches[0].offsetX || event.touches[0].pageX;
534
- var y = event.touches[0].offsetY || event.touches[0].pageY;
535
- panEnd.set(x, y);
536
- panDelta.subVectors(panEnd, panStart);
537
- pan(panDelta.x, panDelta.y);
538
- panStart.copy(panEnd);
539
- scope.update();
540
- }
541
- function handleTouchEnd(event) { }
542
- this.update();
543
- };
544
- ThreeControls.prototype = {}; //Object.create( THREE.EventDispatcher.prototype );
545
- ThreeControls.prototype.constructor = ThreeControls;
546
- Object.defineProperties(ThreeControls.prototype, {
547
- center: {
548
- get: function () {
549
- console.warn('THREE.OrbitControls: .center has been renamed to .target');
550
- return this.target;
551
- }
552
- },
553
- // backward compatibility
554
- noZoom: {
555
- get: function () {
556
- console.warn('THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.');
557
- return !this.enableZoom;
558
- },
559
- set: function (value) {
560
- console.warn('THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.');
561
- this.enableZoom = !value;
562
- }
563
- },
564
- noRotate: {
565
- get: function () {
566
- console.warn('THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.');
567
- return !this.enableRotate;
568
- },
569
- set: function (value) {
570
- console.warn('THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.');
571
- this.enableRotate = !value;
572
- }
573
- },
574
- noPan: {
575
- get: function () {
576
- console.warn('THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.');
577
- return !this.enablePan;
578
- },
579
- set: function (value) {
580
- console.warn('THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.');
581
- this.enablePan = !value;
582
- }
583
- },
584
- noKeys: {
585
- get: function () {
586
- console.warn('THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.');
587
- return !this.enableKeys;
588
- },
589
- set: function (value) {
590
- console.warn('THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.');
591
- this.enableKeys = !value;
592
- }
593
- },
594
- staticMoving: {
595
- get: function () {
596
- console.warn('THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.');
597
- return !this.enableDamping;
598
- },
599
- set: function (value) {
600
- console.warn('THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.');
601
- this.enableDamping = !value;
602
- }
603
- },
604
- dynamicDampingFactor: {
605
- get: function () {
606
- console.warn('THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.');
607
- return this.dampingFactor;
608
- },
609
- set: function (value) {
610
- console.warn('THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.');
611
- this.dampingFactor = value;
612
- }
381
+ // Touch handlers
382
+ _handleTouchStartRotate(event) {
383
+ const x = event.touches[0].offsetX || event.touches[0].pageX;
384
+ const y = event.touches[0].offsetY || event.touches[0].pageY;
385
+ this._rotateStart.set(x, y);
386
+ }
387
+ _handleTouchStartPan(event) {
388
+ const x = event.touches[0].offsetX || event.touches[0].pageX;
389
+ const y = event.touches[0].offsetY || event.touches[0].pageY;
390
+ this._panStart.set(x, y);
391
+ }
392
+ _handleTouchMoveRotate(event) {
393
+ const x = event.touches[0].offsetX || event.touches[0].pageX;
394
+ const y = event.touches[0].offsetY || event.touches[0].pageY;
395
+ this._rotateEnd.set(x, y);
396
+ this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart);
397
+ const model = this.component.model;
398
+ this._rotateLeft(((2 * Math.PI * this._rotateDelta.x) / model.width) * this.rotateSpeed);
399
+ this._rotateUp(((2 * Math.PI * this._rotateDelta.y) / model.height) * this.rotateSpeed);
400
+ this._rotateStart.copy(this._rotateEnd);
401
+ this.update();
402
+ }
403
+ _handleTouchMovePan(event) {
404
+ const x = event.touches[0].offsetX || event.touches[0].pageX;
405
+ const y = event.touches[0].offsetY || event.touches[0].pageY;
406
+ this._panEnd.set(x, y);
407
+ this._panDelta.subVectors(this._panEnd, this._panStart);
408
+ this._pan(this._panDelta.x, this._panDelta.y);
409
+ this._panStart.copy(this._panEnd);
410
+ this.update();
613
411
  }
614
- });
412
+ }
615
413
  export default ThreeControls;
616
414
  //# sourceMappingURL=three-controls.js.map