@gg-web-engine/core 0.0.30 → 0.0.37
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.
|
@@ -36,8 +36,8 @@ export declare type FreeCameraControllerOptions = {
|
|
|
36
36
|
export declare class FreeCameraController extends IEntity {
|
|
37
37
|
protected readonly keyboard: KeyboardInput;
|
|
38
38
|
protected readonly camera: Renderer3dEntity;
|
|
39
|
-
protected readonly options: FreeCameraControllerOptions;
|
|
40
39
|
readonly tickOrder = TickOrder.INPUT_CONTROLLERS;
|
|
40
|
+
protected readonly options: FreeCameraControllerOptions;
|
|
41
41
|
/**
|
|
42
42
|
* The mouse input controller used for camera rotation.
|
|
43
43
|
*/
|
|
@@ -52,7 +52,7 @@ export declare class FreeCameraController extends IEntity {
|
|
|
52
52
|
* @param camera The camera entity to control.
|
|
53
53
|
* @param options Optional configuration options for the controller.
|
|
54
54
|
*/
|
|
55
|
-
constructor(keyboard: KeyboardInput, camera: Renderer3dEntity, options?: FreeCameraControllerOptions);
|
|
55
|
+
constructor(keyboard: KeyboardInput, camera: Renderer3dEntity, options?: Partial<FreeCameraControllerOptions>);
|
|
56
56
|
onSpawned(world: GgWorld<any, any>): Promise<void>;
|
|
57
57
|
onRemoved(): Promise<void>;
|
|
58
58
|
}
|
|
@@ -9,6 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { combineLatest, filter, takeUntil } from 'rxjs';
|
|
11
11
|
import { DirectionKeyboardInput, IEntity, MouseInput, Pnt2, Pnt3, Qtrn, TickOrder, } from '../../../../base';
|
|
12
|
+
const DEFAULT_FREE_CAMERA_CONTROLLER_OPTIONS = {
|
|
13
|
+
keymap: 'wasd',
|
|
14
|
+
movementOptions: { speed: 0.5 },
|
|
15
|
+
mouseOptions: {},
|
|
16
|
+
ignoreMouseUnlessPointerLocked: false,
|
|
17
|
+
ignoreKeyboardUnlessPointerLocked: false,
|
|
18
|
+
};
|
|
12
19
|
/**
|
|
13
20
|
* A controller for a free-moving camera.
|
|
14
21
|
*/
|
|
@@ -19,20 +26,17 @@ export class FreeCameraController extends IEntity {
|
|
|
19
26
|
* @param camera The camera entity to control.
|
|
20
27
|
* @param options Optional configuration options for the controller.
|
|
21
28
|
*/
|
|
22
|
-
constructor(keyboard, camera, options = {
|
|
23
|
-
keymap: 'wasd',
|
|
24
|
-
movementOptions: { speed: 0.5 },
|
|
25
|
-
mouseOptions: {},
|
|
26
|
-
ignoreMouseUnlessPointerLocked: false,
|
|
27
|
-
ignoreKeyboardUnlessPointerLocked: false,
|
|
28
|
-
}) {
|
|
29
|
+
constructor(keyboard, camera, options = {}) {
|
|
29
30
|
super();
|
|
30
31
|
this.keyboard = keyboard;
|
|
31
32
|
this.camera = camera;
|
|
32
|
-
this.options = options;
|
|
33
33
|
this.tickOrder = TickOrder.INPUT_CONTROLLERS;
|
|
34
|
+
this.options = Object.assign(Object.assign({}, DEFAULT_FREE_CAMERA_CONTROLLER_OPTIONS), options);
|
|
35
|
+
if (options.mouseOptions) {
|
|
36
|
+
this.options.movementOptions = Object.assign(Object.assign({}, DEFAULT_FREE_CAMERA_CONTROLLER_OPTIONS.movementOptions), options.mouseOptions);
|
|
37
|
+
}
|
|
34
38
|
this.mouseInput = new MouseInput(options.mouseOptions);
|
|
35
|
-
this.directionsInput = new DirectionKeyboardInput(keyboard, options.keymap);
|
|
39
|
+
this.directionsInput = new DirectionKeyboardInput(keyboard, this.options.keymap);
|
|
36
40
|
}
|
|
37
41
|
onSpawned(world) {
|
|
38
42
|
const _super = Object.create(null, {
|
|
@@ -77,10 +77,10 @@ export class RaycastVehicle3dEntity extends Entity3d {
|
|
|
77
77
|
entity.scale = scale;
|
|
78
78
|
}
|
|
79
79
|
const direction = display.wheelObjectDirection || 'x';
|
|
80
|
-
const flip = direction.includes('-') ?
|
|
80
|
+
const flip = direction.includes('-') ? options.isLeft : !options.isLeft;
|
|
81
81
|
let localRotation = null;
|
|
82
82
|
if (direction.includes('x')) {
|
|
83
|
-
// rotate PI around Z if opposite position (x is correct for
|
|
83
|
+
// rotate PI around Z if opposite position (x is correct for left wheel, -x is correct for right wheel)
|
|
84
84
|
if (flip)
|
|
85
85
|
localRotation = { x: 0, y: 0, z: 1, w: 0 };
|
|
86
86
|
}
|
|
@@ -90,7 +90,7 @@ export class RaycastVehicle3dEntity extends Entity3d {
|
|
|
90
90
|
}
|
|
91
91
|
else if (direction.includes('z')) {
|
|
92
92
|
// rotate PI/2 around Y
|
|
93
|
-
localRotation = { x: 0, y: 0.707107 * (flip ?
|
|
93
|
+
localRotation = { x: 0, y: 0.707107 * (flip ? 1 : -1), z: 0, w: 0.707107 };
|
|
94
94
|
}
|
|
95
95
|
this.wheelLocalRotation.push(localRotation);
|
|
96
96
|
this.wheels.push(new Entity3d(entity));
|