@pmndrs/viverse 0.2.12 → 0.2.13
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.
|
@@ -7,5 +7,11 @@ export declare const MoveRightAction: StateAction<number>;
|
|
|
7
7
|
export declare const RunAction: StateAction<boolean>;
|
|
8
8
|
export declare const JumpAction: EventAction<unknown>;
|
|
9
9
|
export declare const ZoomAction: EventAction<number>;
|
|
10
|
+
/**
|
|
11
|
+
* yaw delta rotation in radians
|
|
12
|
+
*/
|
|
10
13
|
export declare const RotateYawAction: EventAction<number>;
|
|
14
|
+
/**
|
|
15
|
+
* yaw delta rotation in radians
|
|
16
|
+
*/
|
|
11
17
|
export declare const RotatePitchAction: EventAction<number>;
|
|
@@ -14,5 +14,11 @@ export const MoveRightAction = new StateAction(Math.max, 0);
|
|
|
14
14
|
export const RunAction = new StateAction(BooleanOr, false);
|
|
15
15
|
export const JumpAction = new EventAction();
|
|
16
16
|
export const ZoomAction = new EventAction(sum, 0);
|
|
17
|
+
/**
|
|
18
|
+
* yaw delta rotation in radians
|
|
19
|
+
*/
|
|
17
20
|
export const RotateYawAction = new EventAction(sum, 0);
|
|
21
|
+
/**
|
|
22
|
+
* yaw delta rotation in radians
|
|
23
|
+
*/
|
|
18
24
|
export const RotatePitchAction = new EventAction(sum, 0);
|
|
@@ -3,8 +3,8 @@ export class PointerCaptureRotateZoomActionBindings {
|
|
|
3
3
|
domElement;
|
|
4
4
|
activePointers = new Map();
|
|
5
5
|
lastPinchDist = null;
|
|
6
|
-
rotationSpeed; // default 0
|
|
7
|
-
zoomSpeed; // default 0.
|
|
6
|
+
rotationSpeed; // default 4.0
|
|
7
|
+
zoomSpeed; // default 0.001
|
|
8
8
|
constructor(domElement, abortSignal) {
|
|
9
9
|
this.domElement = domElement;
|
|
10
10
|
domElement.addEventListener('pointerdown', (event) => {
|
|
@@ -26,14 +26,14 @@ export class PointerCaptureRotateZoomActionBindings {
|
|
|
26
26
|
const pts = Array.from(this.activePointers.values());
|
|
27
27
|
if (this.lastPinchDist != null) {
|
|
28
28
|
const d = Math.hypot(pts[0].x - pts[1].x, pts[0].y - pts[1].y);
|
|
29
|
-
const zoomSpeed = this.zoomSpeed ?? 0.
|
|
30
|
-
ZoomAction.emit((this.lastPinchDist - d) * zoomSpeed);
|
|
29
|
+
const zoomSpeed = this.zoomSpeed ?? 0.001;
|
|
30
|
+
ZoomAction.emit((this.lastPinchDist - d) * zoomSpeed * 3);
|
|
31
31
|
this.lastPinchDist = d;
|
|
32
32
|
}
|
|
33
33
|
event.preventDefault();
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
const rotationSpeed = this.rotationSpeed ?? 0
|
|
36
|
+
const rotationSpeed = this.rotationSpeed ?? 4.0;
|
|
37
37
|
RotateYawAction.emit(-(event.movementX / window.innerHeight) * rotationSpeed);
|
|
38
38
|
RotatePitchAction.emit(-(event.movementY / window.innerHeight) * rotationSpeed);
|
|
39
39
|
}, {
|
|
@@ -59,7 +59,7 @@ export class PointerCaptureRotateZoomActionBindings {
|
|
|
59
59
|
});
|
|
60
60
|
domElement.addEventListener('wheel', (event) => {
|
|
61
61
|
event.preventDefault();
|
|
62
|
-
const zoomSpeed = this.zoomSpeed ?? 0.
|
|
62
|
+
const zoomSpeed = this.zoomSpeed ?? 0.001;
|
|
63
63
|
ZoomAction.emit(event.deltaY * zoomSpeed);
|
|
64
64
|
}, {
|
|
65
65
|
signal: abortSignal,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RotatePitchAction, RotateYawAction, ZoomAction } from './definitions.js';
|
|
2
2
|
export class PointerLockRotateZoomActionBindings {
|
|
3
|
-
rotationSpeed; // default 0
|
|
4
|
-
zoomSpeed; // default 0.
|
|
3
|
+
rotationSpeed; // default 4.0
|
|
4
|
+
zoomSpeed; // default 0.001
|
|
5
5
|
lockOnClick;
|
|
6
6
|
constructor(domElement, abortSignal) {
|
|
7
7
|
// lock on click (only left click)
|
|
@@ -29,7 +29,7 @@ export class PointerLockRotateZoomActionBindings {
|
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
const rect = domElement.getBoundingClientRect();
|
|
32
|
-
const rotationSpeed = this.rotationSpeed ?? 0
|
|
32
|
+
const rotationSpeed = this.rotationSpeed ?? 4.0;
|
|
33
33
|
RotateYawAction.emit(-(event.movementX / rect.height) * rotationSpeed);
|
|
34
34
|
RotatePitchAction.emit(-(event.movementY / rect.height) * rotationSpeed);
|
|
35
35
|
}, {
|
|
@@ -39,7 +39,7 @@ export class PointerLockRotateZoomActionBindings {
|
|
|
39
39
|
if (document.pointerLockElement != domElement) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
const zoomSpeed = this.zoomSpeed ?? 0.
|
|
42
|
+
const zoomSpeed = this.zoomSpeed ?? 0.001;
|
|
43
43
|
ZoomAction.emit(event.deltaY * zoomSpeed);
|
|
44
44
|
event.preventDefault();
|
|
45
45
|
}, {
|
package/dist/camera.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export type CharacterCameraBehaviorOptions = {
|
|
|
35
35
|
*/
|
|
36
36
|
maxYaw?: number;
|
|
37
37
|
/**
|
|
38
|
-
* @default
|
|
38
|
+
* @default 1.0
|
|
39
39
|
*/
|
|
40
40
|
speed?: number;
|
|
41
41
|
} | boolean;
|
|
@@ -43,6 +43,9 @@ export type CharacterCameraBehaviorOptions = {
|
|
|
43
43
|
* @default true
|
|
44
44
|
*/
|
|
45
45
|
zoom?: {
|
|
46
|
+
/**
|
|
47
|
+
* @default 1.0
|
|
48
|
+
*/
|
|
46
49
|
speed?: number;
|
|
47
50
|
/**
|
|
48
51
|
* @default 1
|
package/dist/camera.js
CHANGED
|
@@ -81,13 +81,13 @@ export class CharacterCameraBehavior {
|
|
|
81
81
|
let rotationOptions = options.rotation ?? true;
|
|
82
82
|
if (!this.firstUpdate && rotationOptions !== false) {
|
|
83
83
|
rotationOptions = rotationOptions === true ? {} : rotationOptions;
|
|
84
|
-
const rotationSpeed = rotationOptions.speed ??
|
|
84
|
+
const rotationSpeed = rotationOptions.speed ?? 1.0;
|
|
85
85
|
this.yawReader.update();
|
|
86
86
|
this.pitchReader.update();
|
|
87
87
|
const deltaYaw = this.yawReader.get();
|
|
88
88
|
const deltaPitch = this.pitchReader.get();
|
|
89
|
-
this.rotationYaw = this.clampYaw(this.rotationYaw + deltaYaw * rotationSpeed
|
|
90
|
-
this.rotationPitch = this.clampPitch(this.rotationPitch + deltaPitch * rotationSpeed
|
|
89
|
+
this.rotationYaw = this.clampYaw(this.rotationYaw + deltaYaw * rotationSpeed, rotationOptions);
|
|
90
|
+
this.rotationPitch = this.clampPitch(this.rotationPitch + deltaPitch * rotationSpeed, rotationOptions);
|
|
91
91
|
}
|
|
92
92
|
else {
|
|
93
93
|
this.setRotationFromDelta(camera, deltaHelper, typeof rotationOptions === 'boolean' ? {} : rotationOptions);
|
|
@@ -100,10 +100,10 @@ export class CharacterCameraBehavior {
|
|
|
100
100
|
let zoomOptions = options.zoom ?? true;
|
|
101
101
|
if (!this.firstUpdate && zoomOptions !== false) {
|
|
102
102
|
zoomOptions = zoomOptions === true ? {} : zoomOptions;
|
|
103
|
-
const zoomSpeed = zoomOptions.speed ??
|
|
103
|
+
const zoomSpeed = zoomOptions.speed ?? 1.0;
|
|
104
104
|
this.zoomReader.update();
|
|
105
105
|
const deltaZoom = this.zoomReader.get();
|
|
106
|
-
const zoomFactor = 1 + deltaZoom * zoomSpeed
|
|
106
|
+
const zoomFactor = 1 + deltaZoom * zoomSpeed;
|
|
107
107
|
if (deltaZoom >= 0) {
|
|
108
108
|
this.zoomDistance *= zoomFactor;
|
|
109
109
|
}
|