@gg-web-engine/core 0.0.37 → 0.0.39
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/2d/components/physics/i-rigid-body-2d.component.d.ts +3 -0
- package/dist/2d/components/physics/i-trigger-2d.component.d.ts +3 -0
- package/dist/2d/models/body-options.d.ts +5 -1
- package/dist/3d/components/physics/i-physics-world-3d.component.d.ts +7 -0
- package/dist/3d/components/physics/i-rigid-body-3d.component.d.ts +3 -0
- package/dist/3d/components/physics/i-trigger-3d.component.d.ts +3 -0
- package/dist/3d/entities/controllers/input/car-keyboard-handling.controller.js +2 -2
- package/dist/3d/entities/controllers/input/gg-car-keyboard-handling.controller.js +3 -3
- package/dist/3d/entities/gg-car/gg-car.entity.js +4 -2
- package/dist/3d/entities/map-graph-3d.entity.d.ts +1 -1
- package/dist/3d/entities/map-graph-3d.entity.js +3 -4
- package/dist/3d/entities/raycast-vehicle-3d.entity.d.ts +8 -5
- package/dist/3d/entities/raycast-vehicle-3d.entity.js +41 -25
- package/dist/3d/factories.d.ts +3 -3
- package/dist/3d/models/body-options.d.ts +5 -1
- package/dist/3d/models/shapes.d.ts +41 -1
- package/dist/base/clock/pausable-clock.d.ts +56 -1
- package/dist/base/clock/pausable-clock.js +88 -5
- package/dist/base/components/physics/i-body.component.d.ts +3 -1
- package/dist/base/components/physics/i-physics-world.component.d.ts +8 -6
- package/dist/base/components/rendering/i-renderer.component.d.ts +4 -0
- package/dist/base/components/rendering/i-visual-scene.component.d.ts +0 -4
- package/dist/base/entities/i-entity.d.ts +4 -2
- package/dist/base/entities/i-entity.js +9 -3
- package/dist/base/entities/i-renderer.entity.d.ts +4 -0
- package/dist/base/entities/i-renderer.entity.js +8 -0
- package/dist/base/gg-world.d.ts +0 -2
- package/dist/base/gg-world.js +26 -25
- package/dist/base/index.d.ts +0 -1
- package/dist/base/index.js +0 -1
- package/dist/base/math/point2.d.ts +12 -0
- package/dist/base/math/point2.js +35 -0
- package/dist/base/math/point3.d.ts +8 -0
- package/dist/base/math/point3.js +16 -0
- package/dist/base/math/quaternion.d.ts +2 -0
- package/dist/base/math/quaternion.js +4 -0
- package/dist/base/models/body-options.d.ts +9 -0
- package/dist/dev/gg-console.ui.js +16 -8
- package/dist/dev/gg-debugger.ui.d.ts +4 -0
- package/dist/dev/gg-debugger.ui.js +83 -32
- package/dist/dev/gg-static.d.ts +0 -1
- package/dist/dev/gg-static.js +3 -4
- package/package.json +3 -3
- package/dist/base/interfaces/i-debug-physics-drawer.d.ts +0 -8
- package/dist/base/interfaces/i-debug-physics-drawer.js +0 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { IRigidBodyComponent, Point2 } from '../../../base';
|
|
2
2
|
import { PhysicsTypeDocRepo2D } from '../../gg-2d-world';
|
|
3
|
+
import { DebugBody2DSettings } from '../../models/body-options';
|
|
3
4
|
export interface IRigidBody2dComponent<TypeDoc extends PhysicsTypeDocRepo2D = PhysicsTypeDocRepo2D> extends IRigidBodyComponent<Point2, number, TypeDoc> {
|
|
4
5
|
angularVelocity: number;
|
|
6
|
+
/** body info for physics debugger view */
|
|
7
|
+
readonly debugBodySettings: DebugBody2DSettings;
|
|
5
8
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { ITriggerComponent, Point2 } from '../../../base';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { PhysicsTypeDocRepo2D } from '../../gg-2d-world';
|
|
4
|
+
import { DebugBody2DSettings } from '../../models/body-options';
|
|
4
5
|
export interface ITrigger2dComponent<TypeDoc extends PhysicsTypeDocRepo2D = PhysicsTypeDocRepo2D> extends ITriggerComponent<Point2, number, TypeDoc> {
|
|
6
|
+
/** body info for physics debugger view */
|
|
7
|
+
readonly debugBodySettings: DebugBody2DSettings;
|
|
5
8
|
get onEntityEntered(): Observable<TypeDoc['rigidBody']>;
|
|
6
9
|
get onEntityLeft(): Observable<TypeDoc['rigidBody'] | null>;
|
|
7
10
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import { BodyOptions } from '../../base';
|
|
1
|
+
import { BodyOptions, DebugBodySettings } from '../../base';
|
|
2
|
+
import { Shape2DDescriptor } from './shapes';
|
|
2
3
|
export interface Body2DOptions extends BodyOptions {
|
|
3
4
|
}
|
|
5
|
+
export declare type DebugBody2DSettings = DebugBodySettings & {
|
|
6
|
+
shape: Shape2DDescriptor;
|
|
7
|
+
};
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { IPhysicsWorldComponent, Point3, Point4 } from '../../../base';
|
|
2
2
|
import { PhysicsTypeDocRepo3D } from '../../gg-3d-world';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
3
4
|
export interface IPhysicsWorld3dComponent<TypeDoc extends PhysicsTypeDocRepo3D = PhysicsTypeDocRepo3D> extends IPhysicsWorldComponent<Point3, Point4, TypeDoc> {
|
|
4
5
|
readonly loader: TypeDoc['loader'];
|
|
6
|
+
/** event emitter, emits newly added physics components */
|
|
7
|
+
readonly added$: Subject<TypeDoc['trigger'] | TypeDoc['rigidBody'] | TypeDoc['raycastVehicle'] | any>;
|
|
8
|
+
/** event emitter, emits just removed physics components */
|
|
9
|
+
readonly removed$: Subject<TypeDoc['trigger'] | TypeDoc['rigidBody'] | TypeDoc['raycastVehicle'] | any>;
|
|
10
|
+
/** list of currently added to world physics components */
|
|
11
|
+
readonly children: (TypeDoc['trigger'] | TypeDoc['rigidBody'] | TypeDoc['raycastVehicle'] | any)[];
|
|
5
12
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { IRigidBodyComponent, Point3, Point4 } from '../../../base';
|
|
2
2
|
import { PhysicsTypeDocRepo3D } from '../../gg-3d-world';
|
|
3
|
+
import { DebugBody3DSettings } from '../../models/body-options';
|
|
3
4
|
export interface IRigidBody3dComponent<TypeDoc extends PhysicsTypeDocRepo3D = PhysicsTypeDocRepo3D> extends IRigidBodyComponent<Point3, Point4, TypeDoc> {
|
|
4
5
|
angularVelocity: Point3;
|
|
6
|
+
/** body info for physics debugger view */
|
|
7
|
+
readonly debugBodySettings: DebugBody3DSettings;
|
|
5
8
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { ITriggerComponent, Point3, Point4 } from '../../../base';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { PhysicsTypeDocRepo3D } from '../../gg-3d-world';
|
|
4
|
+
import { DebugBody3DSettings } from '../../models/body-options';
|
|
4
5
|
export interface ITrigger3dComponent<TypeDoc extends PhysicsTypeDocRepo3D = PhysicsTypeDocRepo3D> extends ITriggerComponent<Point3, Point4, TypeDoc> {
|
|
6
|
+
/** body info for physics debugger view */
|
|
7
|
+
readonly debugBodySettings: DebugBody3DSettings;
|
|
5
8
|
get onEntityEntered(): Observable<TypeDoc['rigidBody']>;
|
|
6
9
|
get onEntityLeft(): Observable<TypeDoc['rigidBody'] | null>;
|
|
7
10
|
}
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { combineLatest, Subject, takeUntil } from 'rxjs';
|
|
10
|
+
import { combineLatest, filter, Subject, takeUntil } from 'rxjs';
|
|
11
11
|
import { DirectionKeyboardInput, IEntity, TickOrder, } from '../../../../base';
|
|
12
12
|
export class CarKeyboardHandlingController extends IEntity {
|
|
13
13
|
constructor(keyboard, options = {
|
|
@@ -32,7 +32,7 @@ export class CarKeyboardHandlingController extends IEntity {
|
|
|
32
32
|
_super.onSpawned.call(this, world);
|
|
33
33
|
let input = { upDown: 0, leftRight: 0 };
|
|
34
34
|
combineLatest([this.directionsInput.output$, this.tick$])
|
|
35
|
-
.pipe(takeUntil(this._onRemoved$))
|
|
35
|
+
.pipe(filter(() => this.active), takeUntil(this._onRemoved$))
|
|
36
36
|
.subscribe(([d, [_, dt]]) => {
|
|
37
37
|
const direction = { upDown: 0, leftRight: 0 };
|
|
38
38
|
if (d.leftRight !== undefined)
|
|
@@ -64,7 +64,7 @@ export class GgCarKeyboardHandlingController extends IEntity {
|
|
|
64
64
|
});
|
|
65
65
|
this.keyboard
|
|
66
66
|
.bind(this.options.gearUpDownKeys[0])
|
|
67
|
-
.pipe(takeUntil(this._onRemoved$), filter(x => this.switchingGearsEnabled && !!x))
|
|
67
|
+
.pipe(takeUntil(this._onRemoved$), filter(x => this.active && this.switchingGearsEnabled && !!x))
|
|
68
68
|
.subscribe(() => {
|
|
69
69
|
if (this.car && (!this.car.carProperties.transmission.isAuto || this.car.gear <= 0)) {
|
|
70
70
|
this.car.gear++;
|
|
@@ -72,7 +72,7 @@ export class GgCarKeyboardHandlingController extends IEntity {
|
|
|
72
72
|
});
|
|
73
73
|
this.keyboard
|
|
74
74
|
.bind(this.options.gearUpDownKeys[1])
|
|
75
|
-
.pipe(takeUntil(this._onRemoved$), filter(x => this.switchingGearsEnabled && !!x))
|
|
75
|
+
.pipe(takeUntil(this._onRemoved$), filter(x => this.active && this.switchingGearsEnabled && !!x))
|
|
76
76
|
.subscribe(() => {
|
|
77
77
|
if (this.car) {
|
|
78
78
|
if (this.car.carProperties.transmission.isAuto && this.car.gear > 1) {
|
|
@@ -85,7 +85,7 @@ export class GgCarKeyboardHandlingController extends IEntity {
|
|
|
85
85
|
});
|
|
86
86
|
this.keyboard
|
|
87
87
|
.bind(this.options.handbrakeKey)
|
|
88
|
-
.pipe(takeUntil(this._onRemoved$))
|
|
88
|
+
.pipe(takeUntil(this._onRemoved$), filter(() => this.active))
|
|
89
89
|
.subscribe(isKeyDown => {
|
|
90
90
|
if (this.car) {
|
|
91
91
|
this.car.handBrake = isKeyDown;
|
|
@@ -163,15 +163,17 @@ export class GgCarEntity extends IRenderable3dEntity {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
if (brake === 0) {
|
|
166
|
-
this.raycastVehicle.
|
|
166
|
+
this.raycastVehicle.applyTraction('front', force * this.carProperties.tractionBias);
|
|
167
|
+
this.raycastVehicle.applyTraction('rear', force * (1 - this.carProperties.tractionBias));
|
|
167
168
|
this.raycastVehicle.applyBrake('both', 0);
|
|
168
169
|
}
|
|
169
170
|
else {
|
|
170
|
-
this.raycastVehicle.
|
|
171
|
+
this.raycastVehicle.applyTraction('both', 0);
|
|
171
172
|
this.raycastVehicle.applyBrake('front', brake * this.carProperties.brake.frontAxleForce);
|
|
172
173
|
this.raycastVehicle.applyBrake('rear', brake * this.carProperties.brake.rearAxleForce);
|
|
173
174
|
}
|
|
174
175
|
if (this.handBrake) {
|
|
176
|
+
this.raycastVehicle.applyTraction('rear', 0);
|
|
175
177
|
this.raycastVehicle.applyBrake('rear', this.carProperties.brake.handbrakeForce);
|
|
176
178
|
}
|
|
177
179
|
}
|
|
@@ -40,7 +40,7 @@ export declare type Gg3dMapGraphEntityOptions = {
|
|
|
40
40
|
export declare class MapGraph3dEntity<VTypeDoc extends VisualTypeDocRepo3D = VisualTypeDocRepo3D, PTypeDoc extends PhysicsTypeDocRepo3D = PhysicsTypeDocRepo3D> extends IRenderable3dEntity<VTypeDoc, PTypeDoc> {
|
|
41
41
|
readonly mapGraph: MapGraph;
|
|
42
42
|
readonly tickOrder = TickOrder.POST_RENDERING;
|
|
43
|
-
readonly loaderCursorEntity$: BehaviorSubject<IPositionable3d | null>;
|
|
43
|
+
readonly loaderCursorEntity$: BehaviorSubject<(IEntity & IPositionable3d) | null>;
|
|
44
44
|
readonly loaded: Map<MapGraphNodeType, (IEntity & IPositionable3d)[]>;
|
|
45
45
|
private _initialLoadComplete$;
|
|
46
46
|
get initialLoadComplete$(): Observable<boolean>;
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { BehaviorSubject, NEVER, startWith, Subject, switchMap } from 'rxjs';
|
|
10
|
+
import { BehaviorSubject, NEVER, startWith, Subject, switchMap, takeUntil } from 'rxjs';
|
|
11
11
|
import { distinctUntilChanged, map, tap, throttleTime } from 'rxjs/operators';
|
|
12
12
|
import { Graph, Qtrn, TickOrder } from '../../base';
|
|
13
13
|
import { IRenderable3dEntity } from './i-renderable-3d.entity';
|
|
@@ -108,11 +108,10 @@ export class MapGraph3dEntity extends IRenderable3dEntity {
|
|
|
108
108
|
}
|
|
109
109
|
onSpawned(world) {
|
|
110
110
|
super.onSpawned(world);
|
|
111
|
-
// TODO takeUntil removed from world?
|
|
112
111
|
this.loaderCursorEntity$
|
|
113
|
-
.pipe(switchMap(entity => entity
|
|
112
|
+
.pipe(takeUntil(this._onRemoved$), switchMap(entity => entity
|
|
114
113
|
? this.tick$.pipe(startWith(null), // map will perform initial loading even if world not started yet. Handy to preload map
|
|
115
|
-
throttleTime(1000), map(() => entity.position))
|
|
114
|
+
takeUntil(entity.onRemoved$), throttleTime(1000), map(() => entity.position))
|
|
116
115
|
: NEVER), map(pos => this.mapGraph.getNearestDummy(this.mapGraphNodes, pos)), tap(node => this._nearestDummy$.next(node)), distinctUntilChanged())
|
|
117
116
|
.subscribe(currentChunk => {
|
|
118
117
|
let haveToBeLoaded = new Set();
|
|
@@ -22,8 +22,12 @@ export declare type RVEntityAxleOptions = {
|
|
|
22
22
|
axlePosition: number;
|
|
23
23
|
axleHeight: number;
|
|
24
24
|
} & RVEntitySharedWheelOptions;
|
|
25
|
+
export declare enum RVEntityTractionBias {
|
|
26
|
+
FWD = 1,
|
|
27
|
+
RWD = 0
|
|
28
|
+
}
|
|
25
29
|
export declare type RVEntityProperties = {
|
|
26
|
-
|
|
30
|
+
tractionBias: RVEntityTractionBias | number;
|
|
27
31
|
suspension: SuspensionOptions;
|
|
28
32
|
} & ({
|
|
29
33
|
wheelBase: {
|
|
@@ -42,21 +46,20 @@ export declare type RVEntityProperties = {
|
|
|
42
46
|
export declare class RaycastVehicle3dEntity<VTypeDoc extends VisualTypeDocRepo3D = VisualTypeDocRepo3D, PTypeDoc extends PhysicsTypeDocRepo3D = PhysicsTypeDocRepo3D> extends Entity3d<VTypeDoc, PTypeDoc> {
|
|
43
47
|
readonly carProperties: RVEntityProperties;
|
|
44
48
|
readonly chassis3D: IDisplayObject3dComponent | null;
|
|
45
|
-
readonly
|
|
49
|
+
readonly vehicleComponent: IRaycastVehicleComponent;
|
|
46
50
|
protected readonly wheels: (Entity3d<VTypeDoc, PTypeDoc> | null)[];
|
|
47
51
|
protected readonly wheelLocalRotation: (Point4 | null)[];
|
|
48
52
|
protected readonly frontWheelsIndices: number[];
|
|
49
53
|
protected readonly rearWheelsIndices: number[];
|
|
50
|
-
protected readonly tractionWheelIndices: number[];
|
|
51
54
|
getSpeed(): number;
|
|
52
55
|
readonly tractionWheelRadius: number;
|
|
53
56
|
private _steeringAngle;
|
|
54
57
|
get steeringAngle(): number;
|
|
55
58
|
set steeringAngle(value: number);
|
|
56
|
-
|
|
59
|
+
applyTraction(axle: 'front' | 'rear' | 'both', force: number): void;
|
|
57
60
|
applyBrake(axle: 'front' | 'rear' | 'both', force: number): void;
|
|
58
61
|
/** car mesh and physics body direction has to be pointing: y front, z up*/
|
|
59
|
-
constructor(carProperties: RVEntityProperties, chassis3D: IDisplayObject3dComponent | null,
|
|
62
|
+
constructor(carProperties: RVEntityProperties, chassis3D: IDisplayObject3dComponent | null, vehicleComponent: IRaycastVehicleComponent);
|
|
60
63
|
protected runTransformBinding(objectBody: IRigidBody3dComponent, object3D: IDisplayObject3dComponent): void;
|
|
61
64
|
get isTouchingGround(): boolean;
|
|
62
65
|
resetTo(options?: {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Box, Pnt3, Qtrn } from '../../base';
|
|
2
2
|
import { Entity3d } from './entity-3d';
|
|
3
|
+
export var RVEntityTractionBias;
|
|
4
|
+
(function (RVEntityTractionBias) {
|
|
5
|
+
RVEntityTractionBias[RVEntityTractionBias["FWD"] = 1] = "FWD";
|
|
6
|
+
RVEntityTractionBias[RVEntityTractionBias["RWD"] = 0] = "RWD";
|
|
7
|
+
})(RVEntityTractionBias || (RVEntityTractionBias = {}));
|
|
3
8
|
const wheeelDefaults = {
|
|
4
9
|
tyreWidth: 0.3,
|
|
5
10
|
tyreRadius: 0.4,
|
|
@@ -9,16 +14,15 @@ const wheeelDefaults = {
|
|
|
9
14
|
};
|
|
10
15
|
export class RaycastVehicle3dEntity extends Entity3d {
|
|
11
16
|
/** car mesh and physics body direction has to be pointing: y front, z up*/
|
|
12
|
-
constructor(carProperties, chassis3D,
|
|
13
|
-
super(chassis3D,
|
|
17
|
+
constructor(carProperties, chassis3D, vehicleComponent) {
|
|
18
|
+
super(chassis3D, vehicleComponent);
|
|
14
19
|
this.carProperties = carProperties;
|
|
15
20
|
this.chassis3D = chassis3D;
|
|
16
|
-
this.
|
|
21
|
+
this.vehicleComponent = vehicleComponent;
|
|
17
22
|
this.wheels = [];
|
|
18
23
|
this.wheelLocalRotation = [];
|
|
19
24
|
this.frontWheelsIndices = [];
|
|
20
25
|
this.rearWheelsIndices = [];
|
|
21
|
-
this.tractionWheelIndices = [];
|
|
22
26
|
this._steeringAngle = 0;
|
|
23
27
|
let wheelFullOptions = 'wheelBase' in carProperties
|
|
24
28
|
? [
|
|
@@ -47,15 +51,11 @@ export class RaycastVehicle3dEntity extends Entity3d {
|
|
|
47
51
|
else {
|
|
48
52
|
this.rearWheelsIndices.push(i);
|
|
49
53
|
}
|
|
50
|
-
|
|
51
|
-
this.tractionWheelIndices.push(i);
|
|
52
|
-
}
|
|
53
|
-
if (!wheelOpts.isFront && this.carProperties.typeOfDrive != 'FWD') {
|
|
54
|
-
this.tractionWheelIndices.push(i);
|
|
55
|
-
}
|
|
56
|
-
this.chassisBody.addWheel(wheelOpts, this.carProperties.suspension);
|
|
54
|
+
this.vehicleComponent.addWheel(wheelOpts, this.carProperties.suspension);
|
|
57
55
|
});
|
|
58
|
-
this.tractionWheelRadius =
|
|
56
|
+
this.tractionWheelRadius =
|
|
57
|
+
wheelFullOptions[this.frontWheelsIndices[0]].tyreRadius * this.carProperties.tractionBias +
|
|
58
|
+
wheelFullOptions[this.rearWheelsIndices[0]].tyreRadius * (1 - this.carProperties.tractionBias);
|
|
59
59
|
for (const options of wheelFullOptions) {
|
|
60
60
|
const display = options.display || {};
|
|
61
61
|
if (!display.displayObject) {
|
|
@@ -96,11 +96,11 @@ export class RaycastVehicle3dEntity extends Entity3d {
|
|
|
96
96
|
this.wheels.push(new Entity3d(entity));
|
|
97
97
|
}
|
|
98
98
|
this.addChildren(...this.wheels.filter(x => !!x));
|
|
99
|
-
this.
|
|
99
|
+
this.vehicleComponent.entity = this;
|
|
100
100
|
}
|
|
101
101
|
// m/s
|
|
102
102
|
getSpeed() {
|
|
103
|
-
return this.
|
|
103
|
+
return this.vehicleComponent.wheelSpeed;
|
|
104
104
|
}
|
|
105
105
|
get steeringAngle() {
|
|
106
106
|
return this._steeringAngle;
|
|
@@ -109,17 +109,22 @@ export class RaycastVehicle3dEntity extends Entity3d {
|
|
|
109
109
|
if (this._steeringAngle != value) {
|
|
110
110
|
this._steeringAngle = value;
|
|
111
111
|
}
|
|
112
|
-
this.frontWheelsIndices.forEach(index => this.
|
|
112
|
+
this.frontWheelsIndices.forEach(index => this.vehicleComponent.setSteering(index, value));
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
applyTraction(axle, force) {
|
|
115
|
+
if (axle != 'rear') {
|
|
116
|
+
this.frontWheelsIndices.forEach(index => this.vehicleComponent.applyEngineForce(index, force));
|
|
117
|
+
}
|
|
118
|
+
if (axle != 'front') {
|
|
119
|
+
this.rearWheelsIndices.forEach(index => this.vehicleComponent.applyEngineForce(index, force));
|
|
120
|
+
}
|
|
116
121
|
}
|
|
117
122
|
applyBrake(axle, force) {
|
|
118
123
|
if (axle != 'rear') {
|
|
119
|
-
this.frontWheelsIndices.forEach(index => this.
|
|
124
|
+
this.frontWheelsIndices.forEach(index => this.vehicleComponent.applyBrake(index, force));
|
|
120
125
|
}
|
|
121
126
|
if (axle != 'front') {
|
|
122
|
-
this.rearWheelsIndices.forEach(index => this.
|
|
127
|
+
this.rearWheelsIndices.forEach(index => this.vehicleComponent.applyBrake(index, force));
|
|
123
128
|
}
|
|
124
129
|
}
|
|
125
130
|
runTransformBinding(objectBody, object3D) {
|
|
@@ -128,7 +133,7 @@ export class RaycastVehicle3dEntity extends Entity3d {
|
|
|
128
133
|
if (!wheel) {
|
|
129
134
|
continue;
|
|
130
135
|
}
|
|
131
|
-
let { position, rotation } = this.
|
|
136
|
+
let { position, rotation } = this.vehicleComponent.getWheelTransform(i);
|
|
132
137
|
if (this.wheelLocalRotation[i]) {
|
|
133
138
|
rotation = Qtrn.combineRotations(rotation, this.wheelLocalRotation[i]);
|
|
134
139
|
}
|
|
@@ -138,14 +143,24 @@ export class RaycastVehicle3dEntity extends Entity3d {
|
|
|
138
143
|
}
|
|
139
144
|
get isTouchingGround() {
|
|
140
145
|
// is at least one traction wheel touches the ground
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
146
|
+
if (this.carProperties.tractionBias != RVEntityTractionBias.RWD) {
|
|
147
|
+
if (this.frontWheelsIndices
|
|
148
|
+
.map(i => this.vehicleComponent.isWheelTouchesGround(i))
|
|
149
|
+
.reduce((prev, cur) => cur || prev, false)) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (this.carProperties.tractionBias != RVEntityTractionBias.FWD) {
|
|
154
|
+
if (this.rearWheelsIndices
|
|
155
|
+
.map(i => this.vehicleComponent.isWheelTouchesGround(i))
|
|
156
|
+
.reduce((prev, cur) => cur || prev, false)) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
144
161
|
}
|
|
145
162
|
// TODO delete and let game application do all the steps
|
|
146
163
|
resetTo(options = {}) {
|
|
147
|
-
this.chassisBody.resetMotion();
|
|
148
|
-
this.chassisBody.resetSuspension();
|
|
149
164
|
if (options.position) {
|
|
150
165
|
this.position = options.position;
|
|
151
166
|
}
|
|
@@ -153,5 +168,6 @@ export class RaycastVehicle3dEntity extends Entity3d {
|
|
|
153
168
|
this.rotation = options.rotation;
|
|
154
169
|
}
|
|
155
170
|
this.steeringAngle = 0;
|
|
171
|
+
this.vehicleComponent.resetMotion();
|
|
156
172
|
}
|
|
157
173
|
}
|
package/dist/3d/factories.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { BodyShape3DDescriptor, Shape3DDescriptor } from './models/shapes';
|
|
1
|
+
import { BodyShape3DDescriptor, Shape3DDescriptor, Shape3DMeshDescriptor } from './models/shapes';
|
|
2
2
|
import { Point3, Point4 } from '../base';
|
|
3
3
|
import { PhysicsTypeDocRepo3D, VisualTypeDocRepo3D } from './gg-3d-world';
|
|
4
4
|
export declare type DisplayObject3dOpts<Tex> = {
|
|
5
5
|
color?: number;
|
|
6
|
-
shading?: 'unlit' | 'standart' | 'phong';
|
|
6
|
+
shading?: 'unlit' | 'standart' | 'phong' | 'wireframe';
|
|
7
7
|
diffuse?: Tex;
|
|
8
8
|
castShadow?: boolean;
|
|
9
9
|
receiveShadow?: boolean;
|
|
10
10
|
};
|
|
11
11
|
export declare abstract class IDisplayObject3dComponentFactory<TypeDoc extends VisualTypeDocRepo3D = VisualTypeDocRepo3D> {
|
|
12
|
-
abstract createPrimitive(descriptor:
|
|
12
|
+
abstract createPrimitive(descriptor: Shape3DMeshDescriptor, material?: DisplayObject3dOpts<TypeDoc['texture']>): TypeDoc['displayObject'];
|
|
13
13
|
abstract createPerspectiveCamera(settings: {
|
|
14
14
|
fov?: number;
|
|
15
15
|
aspectRatio?: number;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import { BodyOptions } from '../../base';
|
|
1
|
+
import { BodyOptions, DebugBodySettings } from '../../base';
|
|
2
|
+
import { Shape3DDescriptor } from './shapes';
|
|
2
3
|
export interface Body3DOptions extends BodyOptions {
|
|
3
4
|
}
|
|
5
|
+
export declare type DebugBody3DSettings = DebugBodySettings & {
|
|
6
|
+
shape: Shape3DDescriptor;
|
|
7
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Point3, Point4 } from '../../base';
|
|
1
|
+
import { Point2, Point3, Point4 } from '../../base';
|
|
2
2
|
import { Body3DOptions } from './body-options';
|
|
3
3
|
export declare type Shape3DDescriptor = {
|
|
4
4
|
shape: 'PLANE';
|
|
@@ -31,6 +31,46 @@ export declare type Shape3DDescriptor = {
|
|
|
31
31
|
vertices: Point3[];
|
|
32
32
|
faces: [number, number, number][];
|
|
33
33
|
};
|
|
34
|
+
export declare type Shape3DMeshDescriptor = {
|
|
35
|
+
shape: 'PLANE';
|
|
36
|
+
dimensions?: Point2;
|
|
37
|
+
segments?: Point2;
|
|
38
|
+
} | {
|
|
39
|
+
shape: 'BOX';
|
|
40
|
+
dimensions: Point3;
|
|
41
|
+
segments?: Point3;
|
|
42
|
+
} | {
|
|
43
|
+
shape: 'CONE' | 'CYLINDER';
|
|
44
|
+
radius: number;
|
|
45
|
+
height: number;
|
|
46
|
+
radialSegments?: number;
|
|
47
|
+
heightSegments?: number;
|
|
48
|
+
} | {
|
|
49
|
+
shape: 'CAPSULE';
|
|
50
|
+
radius: number;
|
|
51
|
+
centersDistance: number;
|
|
52
|
+
capSegments?: number;
|
|
53
|
+
radialSegments?: number;
|
|
54
|
+
} | {
|
|
55
|
+
shape: 'SPHERE';
|
|
56
|
+
radius: number;
|
|
57
|
+
widthSegments?: number;
|
|
58
|
+
heightSegments?: number;
|
|
59
|
+
} | {
|
|
60
|
+
shape: 'COMPOUND';
|
|
61
|
+
children: {
|
|
62
|
+
position?: Point3;
|
|
63
|
+
rotation?: Point4;
|
|
64
|
+
shape: Shape3DMeshDescriptor;
|
|
65
|
+
}[];
|
|
66
|
+
} | {
|
|
67
|
+
shape: 'CONVEX_HULL';
|
|
68
|
+
vertices: Point3[];
|
|
69
|
+
} | {
|
|
70
|
+
shape: 'MESH';
|
|
71
|
+
vertices: Point3[];
|
|
72
|
+
faces: [number, number, number][];
|
|
73
|
+
};
|
|
34
74
|
export declare type BodyShape3DDescriptor = {
|
|
35
75
|
shape: Shape3DDescriptor;
|
|
36
76
|
body: Partial<Body3DOptions>;
|
|
@@ -1,25 +1,80 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { IClock } from './i-clock';
|
|
3
3
|
/**
|
|
4
|
-
* A class
|
|
4
|
+
* A class providing the ability to track time, fire ticks, provide time elapsed, and tick delta with the ability to suspend/resume it.
|
|
5
5
|
*/
|
|
6
6
|
export declare class PausableClock implements IClock {
|
|
7
7
|
protected readonly parentClock: IClock;
|
|
8
8
|
private tickSub;
|
|
9
9
|
private readonly _tick$;
|
|
10
|
+
/**
|
|
11
|
+
* Observable stream of ticks, emitting an array containing the current time and the tick delta.
|
|
12
|
+
*/
|
|
10
13
|
get tick$(): Observable<[number, number]>;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if the clock is currently running.
|
|
16
|
+
*/
|
|
11
17
|
get isRunning(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if the clock is currently paused.
|
|
20
|
+
*/
|
|
12
21
|
get isPaused(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if the clock is stopped.
|
|
24
|
+
*/
|
|
25
|
+
get isStopped(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the time scale of the clock.
|
|
28
|
+
*/
|
|
29
|
+
get timeScale(): number;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the time scale of the clock.
|
|
32
|
+
*/
|
|
33
|
+
set timeScale(value: number);
|
|
34
|
+
/**
|
|
35
|
+
* Gets the elapsed time since the clock started.
|
|
36
|
+
*/
|
|
13
37
|
get elapsedTime(): number;
|
|
14
38
|
private startedAt;
|
|
15
39
|
private oldRelativeTime;
|
|
16
40
|
private pausedAt;
|
|
41
|
+
private lastStopElapsed;
|
|
42
|
+
private _timeScale;
|
|
43
|
+
private pausedByTimescale;
|
|
44
|
+
/**
|
|
45
|
+
* Constructs a new PausableClock instance.
|
|
46
|
+
* @param autoStart Indicates whether the clock should start automatically upon creation.
|
|
47
|
+
* @param parentClock The parent clock to synchronize with. Defaults to GgGlobalClock instance.
|
|
48
|
+
*/
|
|
17
49
|
constructor(autoStart?: boolean, parentClock?: IClock);
|
|
50
|
+
/**
|
|
51
|
+
* Creates a child clock.
|
|
52
|
+
* @param autoStart Indicates whether the child clock should start automatically.
|
|
53
|
+
* @returns A new instance of PausableClock.
|
|
54
|
+
*/
|
|
18
55
|
createChildClock(autoStart: boolean): PausableClock;
|
|
56
|
+
/**
|
|
57
|
+
* Starts the clock.
|
|
58
|
+
*/
|
|
19
59
|
start(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Stops the clock.
|
|
62
|
+
*/
|
|
20
63
|
stop(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Pauses the clock.
|
|
66
|
+
*/
|
|
21
67
|
pause(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Resumes the clock.
|
|
70
|
+
*/
|
|
22
71
|
resume(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Starts listening for ticks from the parent clock.
|
|
74
|
+
*/
|
|
23
75
|
protected startListeningTicks(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Stops listening for ticks from the parent clock.
|
|
78
|
+
*/
|
|
24
79
|
protected stopListeningTicks(): void;
|
|
25
80
|
}
|