@aura3d/controls 1.0.6

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 (76) hide show
  1. package/dist/ControlState.d.ts +14 -0
  2. package/dist/ControlState.d.ts.map +1 -0
  3. package/dist/ControlState.js +11 -0
  4. package/dist/ControlState.js.map +1 -0
  5. package/dist/DragControls.d.ts +8 -0
  6. package/dist/DragControls.d.ts.map +1 -0
  7. package/dist/DragControls.js +14 -0
  8. package/dist/DragControls.js.map +1 -0
  9. package/dist/FirstPersonControls.d.ts +5 -0
  10. package/dist/FirstPersonControls.d.ts.map +1 -0
  11. package/dist/FirstPersonControls.js +8 -0
  12. package/dist/FirstPersonControls.js.map +1 -0
  13. package/dist/FlyControls.d.ts +8 -0
  14. package/dist/FlyControls.d.ts.map +1 -0
  15. package/dist/FlyControls.js +12 -0
  16. package/dist/FlyControls.js.map +1 -0
  17. package/dist/InteractionControls.d.ts +83 -0
  18. package/dist/InteractionControls.d.ts.map +1 -0
  19. package/dist/InteractionControls.js +163 -0
  20. package/dist/InteractionControls.js.map +1 -0
  21. package/dist/MapControls.d.ts +6 -0
  22. package/dist/MapControls.d.ts.map +1 -0
  23. package/dist/MapControls.js +9 -0
  24. package/dist/MapControls.js.map +1 -0
  25. package/dist/NativeControlTypes.d.ts +49 -0
  26. package/dist/NativeControlTypes.d.ts.map +1 -0
  27. package/dist/NativeControlTypes.js +58 -0
  28. package/dist/NativeControlTypes.js.map +1 -0
  29. package/dist/OrbitControls.d.ts +11 -0
  30. package/dist/OrbitControls.d.ts.map +1 -0
  31. package/dist/OrbitControls.js +25 -0
  32. package/dist/OrbitControls.js.map +1 -0
  33. package/dist/Picking.d.ts +41 -0
  34. package/dist/Picking.d.ts.map +1 -0
  35. package/dist/Picking.js +149 -0
  36. package/dist/Picking.js.map +1 -0
  37. package/dist/PickingAnnotations.d.ts +134 -0
  38. package/dist/PickingAnnotations.d.ts.map +1 -0
  39. package/dist/PickingAnnotations.js +221 -0
  40. package/dist/PickingAnnotations.js.map +1 -0
  41. package/dist/PointerLockControls.d.ts +9 -0
  42. package/dist/PointerLockControls.d.ts.map +1 -0
  43. package/dist/PointerLockControls.js +14 -0
  44. package/dist/PointerLockControls.js.map +1 -0
  45. package/dist/SelectionManager.d.ts +8 -0
  46. package/dist/SelectionManager.d.ts.map +1 -0
  47. package/dist/SelectionManager.js +15 -0
  48. package/dist/SelectionManager.js.map +1 -0
  49. package/dist/TrackballControls.d.ts +18 -0
  50. package/dist/TrackballControls.d.ts.map +1 -0
  51. package/dist/TrackballControls.js +99 -0
  52. package/dist/TrackballControls.js.map +1 -0
  53. package/dist/TransformControls.d.ts +11 -0
  54. package/dist/TransformControls.d.ts.map +1 -0
  55. package/dist/TransformControls.js +19 -0
  56. package/dist/TransformControls.js.map +1 -0
  57. package/dist/index.d.ts +21 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +15 -0
  60. package/dist/index.js.map +1 -0
  61. package/package.json +16 -0
  62. package/src/ControlState.ts +24 -0
  63. package/src/DragControls.ts +17 -0
  64. package/src/FirstPersonControls.ts +8 -0
  65. package/src/FlyControls.ts +14 -0
  66. package/src/InteractionControls.ts +224 -0
  67. package/src/MapControls.ts +10 -0
  68. package/src/NativeControlTypes.ts +93 -0
  69. package/src/OrbitControls.ts +25 -0
  70. package/src/Picking.ts +234 -0
  71. package/src/PickingAnnotations.ts +391 -0
  72. package/src/PointerLockControls.ts +15 -0
  73. package/src/SelectionManager.ts +18 -0
  74. package/src/TrackballControls.ts +116 -0
  75. package/src/TransformControls.ts +19 -0
  76. package/src/index.ts +58 -0
@@ -0,0 +1,116 @@
1
+ import { OrbitControls } from "./OrbitControls";
2
+
3
+ export type TrackballKey =
4
+ | "ArrowUp"
5
+ | "ArrowDown"
6
+ | "ArrowLeft"
7
+ | "ArrowRight"
8
+ | "KeyQ"
9
+ | "KeyE"
10
+ | "NumpadAdd"
11
+ | "NumpadSubtract"
12
+ | "+"
13
+ | "-"
14
+ | "="
15
+ | "_";
16
+
17
+ export class TrackballControls extends OrbitControls {
18
+ enableDamping = false;
19
+ dampingFactor = 0.08;
20
+ keyPanSpeed = 0.12;
21
+ keyRollSpeed = 0.06;
22
+
23
+ private rotationVelocity = { x: 0, y: 0, z: 0 };
24
+ private panVelocity = { x: 0, y: 0 };
25
+ private dollyVelocity = 0;
26
+
27
+ roll(delta: number): void {
28
+ if (!this.state.enabled || !this.enableRotate) return;
29
+ this.state.rotation.z += delta;
30
+ this.rotationVelocity.z += delta;
31
+ }
32
+
33
+ override rotate(deltaX: number, deltaY: number): void {
34
+ if (!this.state.enabled || !this.enableRotate) return;
35
+ super.rotate(deltaX, deltaY);
36
+ this.rotationVelocity.x += deltaY;
37
+ this.rotationVelocity.y += deltaX;
38
+ }
39
+
40
+ override pan(deltaX: number, deltaY: number): void {
41
+ if (!this.state.enabled || !this.enablePan) return;
42
+ super.pan(deltaX, deltaY);
43
+ this.panVelocity.x += deltaX;
44
+ this.panVelocity.y += deltaY;
45
+ }
46
+
47
+ override dolly(scale: number): void {
48
+ if (!this.state.enabled || !this.enableZoom) return;
49
+ super.dolly(scale);
50
+ this.dollyVelocity += scale - 1;
51
+ }
52
+
53
+ handleKey(code: TrackballKey): void {
54
+ switch (code) {
55
+ case "ArrowUp":
56
+ this.pan(0, this.keyPanSpeed);
57
+ break;
58
+ case "ArrowDown":
59
+ this.pan(0, -this.keyPanSpeed);
60
+ break;
61
+ case "ArrowLeft":
62
+ this.pan(-this.keyPanSpeed, 0);
63
+ break;
64
+ case "ArrowRight":
65
+ this.pan(this.keyPanSpeed, 0);
66
+ break;
67
+ case "KeyQ":
68
+ this.roll(-this.keyRollSpeed);
69
+ break;
70
+ case "KeyE":
71
+ this.roll(this.keyRollSpeed);
72
+ break;
73
+ case "NumpadAdd":
74
+ case "+":
75
+ case "=":
76
+ this.dolly(0.95);
77
+ break;
78
+ case "NumpadSubtract":
79
+ case "-":
80
+ case "_":
81
+ this.dolly(1.05);
82
+ break;
83
+ }
84
+ }
85
+
86
+ update(deltaSeconds = 1 / 60): boolean {
87
+ if (!this.enableDamping) {
88
+ return false;
89
+ }
90
+ const damping = Math.max(0, Math.min(1, this.dampingFactor * deltaSeconds * 60));
91
+ const rotationStep = {
92
+ x: this.rotationVelocity.x * damping,
93
+ y: this.rotationVelocity.y * damping,
94
+ z: this.rotationVelocity.z * damping
95
+ };
96
+ const panStep = {
97
+ x: this.panVelocity.x * damping,
98
+ y: this.panVelocity.y * damping
99
+ };
100
+ const dollyStep = this.dollyVelocity * damping;
101
+ this.state.rotation.x += rotationStep.x;
102
+ this.state.rotation.y += rotationStep.y;
103
+ this.state.rotation.z += rotationStep.z;
104
+ this.state.target.x += panStep.x;
105
+ this.state.target.y += panStep.y;
106
+ this.state.position.z *= 1 + dollyStep;
107
+ this.rotationVelocity.x -= rotationStep.x;
108
+ this.rotationVelocity.y -= rotationStep.y;
109
+ this.rotationVelocity.z -= rotationStep.z;
110
+ this.panVelocity.x -= panStep.x;
111
+ this.panVelocity.y -= panStep.y;
112
+ this.dollyVelocity -= dollyStep;
113
+ return Math.abs(this.rotationVelocity.x) + Math.abs(this.rotationVelocity.y) + Math.abs(this.rotationVelocity.z) +
114
+ Math.abs(this.panVelocity.x) + Math.abs(this.panVelocity.y) + Math.abs(this.dollyVelocity) > 1e-6;
115
+ }
116
+ }
@@ -0,0 +1,19 @@
1
+ import { addVector3, type ControlObject3DLike, type Vector3Like } from "./NativeControlTypes";
2
+
3
+ export type TransformControlMode = "translate" | "rotate" | "scale";
4
+
5
+ export class TransformControls {
6
+ object: ControlObject3DLike | null = null;
7
+ mode: TransformControlMode = "translate";
8
+
9
+ attach(object: ControlObject3DLike): void { this.object = object; }
10
+ detach(): void { this.object = null; }
11
+ setMode(mode: TransformControlMode): void { this.mode = mode; }
12
+
13
+ apply(delta: Vector3Like): void {
14
+ if (!this.object) return;
15
+ if (this.mode === "translate") addVector3(this.object.position, delta);
16
+ if (this.mode === "rotate") addVector3(this.object.rotation, delta);
17
+ if (this.mode === "scale") addVector3(this.object.scale, delta);
18
+ }
19
+ }
package/src/index.ts ADDED
@@ -0,0 +1,58 @@
1
+ export { OrbitControls } from "./OrbitControls";
2
+ export { TrackballControls } from "./TrackballControls";
3
+ export { FlyControls } from "./FlyControls";
4
+ export { FirstPersonControls } from "./FirstPersonControls";
5
+ export { MapControls } from "./MapControls";
6
+ export { PointerLockControls } from "./PointerLockControls";
7
+ export { DragControls } from "./DragControls";
8
+ export { TransformControls } from "./TransformControls";
9
+ export type { TransformControlMode } from "./TransformControls";
10
+ export { SelectionManager } from "./SelectionManager";
11
+ export { InteractionControls } from "./InteractionControls";
12
+ export type {
13
+ HotspotHandler,
14
+ InteractionControlMode,
15
+ InteractionControlsEvent,
16
+ InteractionControlsEventType,
17
+ InteractionControlsListener,
18
+ InteractionControlsOptions,
19
+ InteractionControlsUpdate,
20
+ InteractionRay,
21
+ InteractionRayProvider,
22
+ InteractionRootProvider
23
+ } from "./InteractionControls";
24
+ export { Picking } from "./Picking";
25
+ export type { PickingDiagnostics, PickingOptions, PickingReport, ThreeCompatPickResult } from "./Picking";
26
+ export {
27
+ annotationFromPickHit,
28
+ createDistrictPickingAnnotations,
29
+ createEntityPickingAnnotations,
30
+ createImportedGlbHotspotAnnotations,
31
+ createPickingAnnotationObject,
32
+ createPickingAnnotationRoot,
33
+ createRobotPickingAnnotations,
34
+ pickAnnotation,
35
+ pickScreenSpaceAnnotation
36
+ } from "./PickingAnnotations";
37
+ export type {
38
+ BuildingPickingDescriptor,
39
+ DistrictPickingDescriptor,
40
+ EntityPickingDescriptor,
41
+ ImportedGlbHotspotDescriptor,
42
+ PickingAnnotation,
43
+ PickingAnnotationHitPolicy,
44
+ PickingAnnotationKind,
45
+ PickingAnnotationObject,
46
+ PickingAnnotationOptions,
47
+ PickingAnnotationReport,
48
+ PickingAnnotationRoot,
49
+ PickingAnnotationSource,
50
+ ScreenPickingAnnotation,
51
+ ScreenPickingHit,
52
+ ScreenPickingOptions,
53
+ ScreenPickingReport
54
+ } from "./PickingAnnotations";
55
+ export { ControlVector3 } from "./NativeControlTypes";
56
+ export type { ControlObject3DLike, ControlPickMetadata, Vector3Like } from "./NativeControlTypes";
57
+ export { createDefaultControlState } from "./ControlState";
58
+ export type { ThreeCompatControlEvent, ThreeCompatControlState } from "./ControlState";