@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.
- package/dist/ControlState.d.ts +14 -0
- package/dist/ControlState.d.ts.map +1 -0
- package/dist/ControlState.js +11 -0
- package/dist/ControlState.js.map +1 -0
- package/dist/DragControls.d.ts +8 -0
- package/dist/DragControls.d.ts.map +1 -0
- package/dist/DragControls.js +14 -0
- package/dist/DragControls.js.map +1 -0
- package/dist/FirstPersonControls.d.ts +5 -0
- package/dist/FirstPersonControls.d.ts.map +1 -0
- package/dist/FirstPersonControls.js +8 -0
- package/dist/FirstPersonControls.js.map +1 -0
- package/dist/FlyControls.d.ts +8 -0
- package/dist/FlyControls.d.ts.map +1 -0
- package/dist/FlyControls.js +12 -0
- package/dist/FlyControls.js.map +1 -0
- package/dist/InteractionControls.d.ts +83 -0
- package/dist/InteractionControls.d.ts.map +1 -0
- package/dist/InteractionControls.js +163 -0
- package/dist/InteractionControls.js.map +1 -0
- package/dist/MapControls.d.ts +6 -0
- package/dist/MapControls.d.ts.map +1 -0
- package/dist/MapControls.js +9 -0
- package/dist/MapControls.js.map +1 -0
- package/dist/NativeControlTypes.d.ts +49 -0
- package/dist/NativeControlTypes.d.ts.map +1 -0
- package/dist/NativeControlTypes.js +58 -0
- package/dist/NativeControlTypes.js.map +1 -0
- package/dist/OrbitControls.d.ts +11 -0
- package/dist/OrbitControls.d.ts.map +1 -0
- package/dist/OrbitControls.js +25 -0
- package/dist/OrbitControls.js.map +1 -0
- package/dist/Picking.d.ts +41 -0
- package/dist/Picking.d.ts.map +1 -0
- package/dist/Picking.js +149 -0
- package/dist/Picking.js.map +1 -0
- package/dist/PickingAnnotations.d.ts +134 -0
- package/dist/PickingAnnotations.d.ts.map +1 -0
- package/dist/PickingAnnotations.js +221 -0
- package/dist/PickingAnnotations.js.map +1 -0
- package/dist/PointerLockControls.d.ts +9 -0
- package/dist/PointerLockControls.d.ts.map +1 -0
- package/dist/PointerLockControls.js +14 -0
- package/dist/PointerLockControls.js.map +1 -0
- package/dist/SelectionManager.d.ts +8 -0
- package/dist/SelectionManager.d.ts.map +1 -0
- package/dist/SelectionManager.js +15 -0
- package/dist/SelectionManager.js.map +1 -0
- package/dist/TrackballControls.d.ts +18 -0
- package/dist/TrackballControls.d.ts.map +1 -0
- package/dist/TrackballControls.js +99 -0
- package/dist/TrackballControls.js.map +1 -0
- package/dist/TransformControls.d.ts +11 -0
- package/dist/TransformControls.d.ts.map +1 -0
- package/dist/TransformControls.js +19 -0
- package/dist/TransformControls.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/package.json +16 -0
- package/src/ControlState.ts +24 -0
- package/src/DragControls.ts +17 -0
- package/src/FirstPersonControls.ts +8 -0
- package/src/FlyControls.ts +14 -0
- package/src/InteractionControls.ts +224 -0
- package/src/MapControls.ts +10 -0
- package/src/NativeControlTypes.ts +93 -0
- package/src/OrbitControls.ts +25 -0
- package/src/Picking.ts +234 -0
- package/src/PickingAnnotations.ts +391 -0
- package/src/PointerLockControls.ts +15 -0
- package/src/SelectionManager.ts +18 -0
- package/src/TrackballControls.ts +116 -0
- package/src/TransformControls.ts +19 -0
- 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";
|