@gg-web-engine/core 0.0.40 → 0.0.49
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/README.md +0 -0
- package/blender_exporter/build_blender_scene.py +0 -1
- package/blender_exporter/spherical_to_cube_texture.py +0 -0
- package/dist/2d/components/physics/i-physics-world-2d.component.d.ts +0 -0
- package/dist/2d/components/physics/i-physics-world-2d.component.js +0 -0
- package/dist/2d/components/physics/i-rigid-body-2d.component.d.ts +0 -0
- package/dist/2d/components/physics/i-rigid-body-2d.component.js +0 -0
- package/dist/2d/components/physics/i-trigger-2d.component.d.ts +0 -0
- package/dist/2d/components/physics/i-trigger-2d.component.js +0 -0
- package/dist/2d/components/rendering/i-display-object-2d.component.d.ts +0 -0
- package/dist/2d/components/rendering/i-display-object-2d.component.js +0 -0
- package/dist/2d/components/rendering/i-renderer-2d.component.d.ts +0 -0
- package/dist/2d/components/rendering/i-renderer-2d.component.js +0 -0
- package/dist/2d/components/rendering/i-visual-scene-2d.component.d.ts +0 -0
- package/dist/2d/components/rendering/i-visual-scene-2d.component.js +0 -0
- package/dist/2d/entities/controllers/entity-2d-positioning.animator.d.ts +1 -1
- package/dist/2d/entities/controllers/entity-2d-positioning.animator.js +0 -0
- package/dist/2d/entities/entity-2d.d.ts +0 -0
- package/dist/2d/entities/entity-2d.js +25 -25
- package/dist/2d/entities/i-renderable-2d.entity.d.ts +0 -0
- package/dist/2d/entities/i-renderable-2d.entity.js +0 -0
- package/dist/2d/entities/renderer-2d.entity.d.ts +0 -0
- package/dist/2d/entities/renderer-2d.entity.js +0 -0
- package/dist/2d/entities/trigger-2d.entity.d.ts +0 -0
- package/dist/2d/entities/trigger-2d.entity.js +11 -11
- package/dist/2d/factories.d.ts +1 -1
- package/dist/2d/factories.js +0 -0
- package/dist/2d/gg-2d-world.d.ts +3 -3
- package/dist/2d/gg-2d-world.js +0 -0
- package/dist/2d/index.d.ts +0 -0
- package/dist/2d/index.js +0 -0
- package/dist/2d/interfaces/i-positionable-2d.d.ts +0 -0
- package/dist/2d/interfaces/i-positionable-2d.js +0 -0
- package/dist/2d/models/body-options.d.ts +1 -1
- package/dist/2d/models/body-options.js +0 -0
- package/dist/2d/models/shapes.d.ts +5 -3
- package/dist/2d/models/shapes.js +0 -0
- package/dist/3d/components/physics/i-physics-world-3d.component.d.ts +0 -0
- package/dist/3d/components/physics/i-physics-world-3d.component.js +0 -0
- package/dist/3d/components/physics/i-raycast-vehicle.component.d.ts +2 -2
- package/dist/3d/components/physics/i-raycast-vehicle.component.js +0 -0
- package/dist/3d/components/physics/i-rigid-body-3d.component.d.ts +0 -0
- package/dist/3d/components/physics/i-rigid-body-3d.component.js +0 -0
- package/dist/3d/components/physics/i-trigger-3d.component.d.ts +0 -0
- package/dist/3d/components/physics/i-trigger-3d.component.js +0 -0
- package/dist/3d/components/rendering/i-camera.component.d.ts +0 -0
- package/dist/3d/components/rendering/i-camera.component.js +0 -0
- package/dist/3d/components/rendering/i-display-object-3d.component.d.ts +0 -0
- package/dist/3d/components/rendering/i-display-object-3d.component.js +0 -0
- package/dist/3d/components/rendering/i-renderer-3d.component.d.ts +0 -0
- package/dist/3d/components/rendering/i-renderer-3d.component.js +0 -0
- package/dist/3d/components/rendering/i-visual-scene-3d.component.d.ts +0 -0
- package/dist/3d/components/rendering/i-visual-scene-3d.component.js +0 -0
- package/dist/3d/entities/controllers/animators/camera-3d.animator.d.ts +1 -1
- package/dist/3d/entities/controllers/animators/camera-3d.animator.js +0 -0
- package/dist/3d/entities/controllers/animators/entity-3d-positioning.animator.d.ts +1 -1
- package/dist/3d/entities/controllers/animators/entity-3d-positioning.animator.js +0 -0
- package/dist/3d/entities/controllers/input/car-keyboard-handling.controller.d.ts +3 -3
- package/dist/3d/entities/controllers/input/car-keyboard-handling.controller.js +3 -3
- package/dist/3d/entities/controllers/input/free-camera.controller.d.ts +24 -13
- package/dist/3d/entities/controllers/input/free-camera.controller.js +65 -44
- package/dist/3d/entities/controllers/input/gg-car-keyboard-handling.controller.d.ts +2 -2
- package/dist/3d/entities/controllers/input/gg-car-keyboard-handling.controller.js +0 -0
- package/dist/3d/entities/controllers/input/orbit-camera.controller.d.ts +21 -2
- package/dist/3d/entities/controllers/input/orbit-camera.controller.js +35 -18
- package/dist/3d/entities/entity-3d.d.ts +0 -0
- package/dist/3d/entities/entity-3d.js +25 -25
- package/dist/3d/entities/gg-car/gg-car.entity.d.ts +1 -1
- package/dist/3d/entities/gg-car/gg-car.entity.js +16 -16
- package/dist/3d/entities/i-renderable-3d.entity.d.ts +0 -0
- package/dist/3d/entities/i-renderable-3d.entity.js +0 -0
- package/dist/3d/entities/map-graph-3d.entity.d.ts +7 -3
- package/dist/3d/entities/map-graph-3d.entity.js +63 -22
- package/dist/3d/entities/raycast-vehicle-3d.entity.d.ts +4 -4
- package/dist/3d/entities/raycast-vehicle-3d.entity.js +41 -41
- package/dist/3d/entities/renderer-3d.entity.d.ts +0 -0
- package/dist/3d/entities/renderer-3d.entity.js +0 -0
- package/dist/3d/entities/trigger-3d.entity.d.ts +0 -0
- package/dist/3d/entities/trigger-3d.entity.js +11 -11
- package/dist/3d/factories.d.ts +1 -1
- package/dist/3d/factories.js +0 -0
- package/dist/3d/gg-3d-world.d.ts +3 -3
- package/dist/3d/gg-3d-world.js +0 -0
- package/dist/3d/index.d.ts +0 -0
- package/dist/3d/index.js +0 -0
- package/dist/3d/interfaces/i-positionable-3d.d.ts +0 -0
- package/dist/3d/interfaces/i-positionable-3d.js +0 -0
- package/dist/3d/loader.d.ts +4 -4
- package/dist/3d/loader.js +7 -7
- package/dist/3d/loaders.d.ts +0 -0
- package/dist/3d/loaders.js +0 -0
- package/dist/3d/models/body-options.d.ts +1 -1
- package/dist/3d/models/body-options.js +0 -0
- package/dist/3d/models/gg-meta.d.ts +4 -4
- package/dist/3d/models/gg-meta.js +0 -0
- package/dist/3d/models/shapes.d.ts +6 -4
- package/dist/3d/models/shapes.js +0 -0
- package/dist/base/clock/global-clock.d.ts +0 -0
- package/dist/base/clock/global-clock.js +8 -8
- package/dist/base/clock/i-clock.d.ts +0 -0
- package/dist/base/clock/i-clock.js +0 -0
- package/dist/base/clock/pausable-clock.d.ts +2 -1
- package/dist/base/clock/pausable-clock.js +35 -31
- package/dist/base/components/i-component.d.ts +0 -0
- package/dist/base/components/i-component.js +0 -0
- package/dist/base/components/i-world-component.d.ts +0 -0
- package/dist/base/components/i-world-component.js +0 -0
- package/dist/base/components/physics/i-body.component.d.ts +0 -0
- package/dist/base/components/physics/i-body.component.js +0 -0
- package/dist/base/components/physics/i-physics-world.component.d.ts +0 -0
- package/dist/base/components/physics/i-physics-world.component.js +0 -0
- package/dist/base/components/physics/i-rigid-body.component.d.ts +0 -0
- package/dist/base/components/physics/i-rigid-body.component.js +0 -0
- package/dist/base/components/physics/i-trigger.component.d.ts +0 -0
- package/dist/base/components/physics/i-trigger.component.js +0 -0
- package/dist/base/components/rendering/i-display-object.component.d.ts +0 -0
- package/dist/base/components/rendering/i-display-object.component.js +0 -0
- package/dist/base/components/rendering/i-renderer.component.d.ts +1 -1
- package/dist/base/components/rendering/i-renderer.component.js +0 -0
- package/dist/base/components/rendering/i-visual-scene.component.d.ts +0 -0
- package/dist/base/components/rendering/i-visual-scene.component.js +0 -0
- package/dist/base/data-structures/bitmask.d.ts +0 -0
- package/dist/base/data-structures/bitmask.js +0 -0
- package/dist/base/data-structures/graph.d.ts +0 -0
- package/dist/base/data-structures/graph.js +4 -4
- package/dist/base/entities/controllers/animation-mixer.d.ts +1 -1
- package/dist/base/entities/controllers/animation-mixer.js +27 -27
- package/dist/base/entities/controllers/inline-controller.d.ts +0 -0
- package/dist/base/entities/controllers/inline-controller.js +0 -0
- package/dist/base/entities/i-entity.d.ts +0 -0
- package/dist/base/entities/i-entity.js +0 -0
- package/dist/base/entities/i-renderable.entity.d.ts +0 -0
- package/dist/base/entities/i-renderable.entity.js +0 -0
- package/dist/base/entities/i-renderer.entity.d.ts +0 -0
- package/dist/base/entities/i-renderer.entity.js +15 -15
- package/dist/base/gg-world.d.ts +3 -2
- package/dist/base/gg-world.js +5 -3
- package/dist/base/index.d.ts +1 -0
- package/dist/base/index.js +1 -0
- package/dist/base/inputs/direction.keyboard.input.d.ts +2 -2
- package/dist/base/inputs/direction.keyboard.input.js +6 -6
- package/dist/base/inputs/i-input.d.ts +0 -0
- package/dist/base/inputs/i-input.js +0 -0
- package/dist/base/inputs/keyboard.input.d.ts +0 -0
- package/dist/base/inputs/keyboard.input.js +0 -0
- package/dist/base/inputs/mouse.input.d.ts +2 -1
- package/dist/base/inputs/mouse.input.js +21 -18
- package/dist/base/interfaces/i-positionable.d.ts +0 -0
- package/dist/base/interfaces/i-positionable.js +0 -0
- package/dist/base/math/box.d.ts +0 -0
- package/dist/base/math/box.js +0 -0
- package/dist/base/math/matrix4.d.ts +0 -0
- package/dist/base/math/matrix4.js +0 -0
- package/dist/base/math/numbers.d.ts +0 -0
- package/dist/base/math/numbers.js +0 -0
- package/dist/base/math/point2.d.ts +0 -0
- package/dist/base/math/point2.js +0 -0
- package/dist/base/math/point3.d.ts +0 -0
- package/dist/base/math/point3.js +0 -0
- package/dist/base/math/quaternion.d.ts +6 -0
- package/dist/base/math/quaternion.js +38 -0
- package/dist/base/math/splines.d.ts +0 -0
- package/dist/base/math/splines.js +0 -0
- package/dist/base/models/axis-directions.d.ts +3 -3
- package/dist/base/models/axis-directions.js +0 -0
- package/dist/base/models/body-options.d.ts +2 -2
- package/dist/base/models/body-options.js +0 -0
- package/dist/base/models/geometry-nodes.d.ts +3 -3
- package/dist/base/models/geometry-nodes.js +0 -0
- package/dist/base/models/points.d.ts +5 -5
- package/dist/base/models/points.js +0 -0
- package/dist/base/pipes/gg-elastic.pipe.d.ts +5 -0
- package/dist/base/pipes/gg-elastic.pipe.js +44 -0
- package/dist/dev/gg-console.ui.d.ts +0 -0
- package/dist/dev/gg-console.ui.js +0 -0
- package/dist/dev/gg-debugger.ui.d.ts +0 -0
- package/dist/dev/gg-debugger.ui.js +0 -0
- package/dist/dev/gg-static.d.ts +0 -0
- package/dist/dev/gg-static.js +46 -46
- package/dist/dev/index.d.ts +0 -0
- package/dist/dev/index.js +0 -0
- package/dist/dev/performance-meter.entity.d.ts +0 -0
- package/dist/dev/performance-meter.entity.js +6 -6
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/package.json +7 -7
- package/tsconfig.json +0 -0
package/README.md
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnimationFunction, AnimationMixer, Point2 } from '../../../base';
|
|
2
2
|
import { Gg2dWorld, PhysicsTypeDocRepo2D, VisualTypeDocRepo2D } from '../../gg-2d-world';
|
|
3
3
|
import { Entity2d } from '../entity-2d';
|
|
4
|
-
|
|
4
|
+
type Positioning2d = {
|
|
5
5
|
position: Point2;
|
|
6
6
|
rotation: number;
|
|
7
7
|
};
|
|
File without changes
|
|
File without changes
|
|
@@ -1,31 +1,6 @@
|
|
|
1
1
|
import { Pnt2, TickOrder } from '../../base';
|
|
2
2
|
import { IRenderable2dEntity } from './i-renderable-2d.entity';
|
|
3
3
|
export class Entity2d extends IRenderable2dEntity {
|
|
4
|
-
constructor(object2D, objectBody) {
|
|
5
|
-
super();
|
|
6
|
-
this.object2D = object2D;
|
|
7
|
-
this.objectBody = objectBody;
|
|
8
|
-
this.tickOrder = TickOrder.OBJECTS_BINDING;
|
|
9
|
-
this._position = Pnt2.O;
|
|
10
|
-
this._rotation = 0;
|
|
11
|
-
if (objectBody) {
|
|
12
|
-
this.tick$.subscribe(() => {
|
|
13
|
-
this.runTransformBinding(objectBody, object2D);
|
|
14
|
-
});
|
|
15
|
-
this.runTransformBinding(objectBody, object2D);
|
|
16
|
-
this.name = objectBody.name;
|
|
17
|
-
}
|
|
18
|
-
else if (object2D) {
|
|
19
|
-
this._position = object2D.position;
|
|
20
|
-
this._rotation = object2D.rotation;
|
|
21
|
-
this.name = object2D.name;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
throw new Error('Cannot create entity without an object2D and a body');
|
|
25
|
-
}
|
|
26
|
-
objectBody && this.addComponents(objectBody);
|
|
27
|
-
object2D && this.addComponents(object2D);
|
|
28
|
-
}
|
|
29
4
|
get position() {
|
|
30
5
|
return this._position;
|
|
31
6
|
}
|
|
@@ -69,4 +44,29 @@ export class Entity2d extends IRenderable2dEntity {
|
|
|
69
44
|
this._position = pos;
|
|
70
45
|
this._rotation = quat;
|
|
71
46
|
}
|
|
47
|
+
constructor(object2D, objectBody) {
|
|
48
|
+
super();
|
|
49
|
+
this.object2D = object2D;
|
|
50
|
+
this.objectBody = objectBody;
|
|
51
|
+
this.tickOrder = TickOrder.OBJECTS_BINDING;
|
|
52
|
+
this._position = Pnt2.O;
|
|
53
|
+
this._rotation = 0;
|
|
54
|
+
if (objectBody) {
|
|
55
|
+
this.tick$.subscribe(() => {
|
|
56
|
+
this.runTransformBinding(objectBody, object2D);
|
|
57
|
+
});
|
|
58
|
+
this.runTransformBinding(objectBody, object2D);
|
|
59
|
+
this.name = objectBody.name;
|
|
60
|
+
}
|
|
61
|
+
else if (object2D) {
|
|
62
|
+
this._position = object2D.position;
|
|
63
|
+
this._rotation = object2D.rotation;
|
|
64
|
+
this.name = object2D.name;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
throw new Error('Cannot create entity without an object2D and a body');
|
|
68
|
+
}
|
|
69
|
+
objectBody && this.addComponents(objectBody);
|
|
70
|
+
object2D && this.addComponents(object2D);
|
|
71
|
+
}
|
|
72
72
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { IEntity, Pnt2, TickOrder } from '../../base';
|
|
2
2
|
import { map } from 'rxjs/operators';
|
|
3
3
|
export class Trigger2dEntity extends IEntity {
|
|
4
|
-
constructor(objectBody) {
|
|
5
|
-
super();
|
|
6
|
-
this.objectBody = objectBody;
|
|
7
|
-
this.tickOrder = TickOrder.OBJECTS_BINDING;
|
|
8
|
-
this._position = Pnt2.O;
|
|
9
|
-
this._rotation = 0;
|
|
10
|
-
this.tick$.subscribe(() => {
|
|
11
|
-
this.objectBody.checkOverlaps();
|
|
12
|
-
});
|
|
13
|
-
this.addComponents(this.objectBody);
|
|
14
|
-
}
|
|
15
4
|
get onEntityEntered() {
|
|
16
5
|
return this.objectBody.onEntityEntered.pipe(map(c => c.entity));
|
|
17
6
|
}
|
|
@@ -32,4 +21,15 @@ export class Trigger2dEntity extends IEntity {
|
|
|
32
21
|
this.objectBody.rotation = value;
|
|
33
22
|
this._rotation = value;
|
|
34
23
|
}
|
|
24
|
+
constructor(objectBody) {
|
|
25
|
+
super();
|
|
26
|
+
this.objectBody = objectBody;
|
|
27
|
+
this.tickOrder = TickOrder.OBJECTS_BINDING;
|
|
28
|
+
this._position = Pnt2.O;
|
|
29
|
+
this._rotation = 0;
|
|
30
|
+
this.tick$.subscribe(() => {
|
|
31
|
+
this.objectBody.checkOverlaps();
|
|
32
|
+
});
|
|
33
|
+
this.addComponents(this.objectBody);
|
|
34
|
+
}
|
|
35
35
|
}
|
package/dist/2d/factories.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Point2 } from '../base';
|
|
2
2
|
import { BodyShape2DDescriptor, Shape2DDescriptor } from './models/shapes';
|
|
3
3
|
import { PhysicsTypeDocRepo2D, VisualTypeDocRepo2D } from './gg-2d-world';
|
|
4
|
-
export
|
|
4
|
+
export type DisplayObject2dOpts<Tex> = {
|
|
5
5
|
color?: number;
|
|
6
6
|
texture?: Tex;
|
|
7
7
|
};
|
package/dist/2d/factories.js
CHANGED
|
File without changes
|
package/dist/2d/gg-2d-world.d.ts
CHANGED
|
@@ -9,14 +9,14 @@ import { IRenderer2dComponent } from './components/rendering/i-renderer-2d.compo
|
|
|
9
9
|
import { IDisplayObject2dComponent } from './components/rendering/i-display-object-2d.component';
|
|
10
10
|
import { ITrigger2dComponent } from './components/physics/i-trigger-2d.component';
|
|
11
11
|
import { IRigidBody2dComponent } from './components/physics/i-rigid-body-2d.component';
|
|
12
|
-
export
|
|
12
|
+
export type VisualTypeDocRepo2D = {
|
|
13
13
|
factory: IDisplayObject2dComponentFactory;
|
|
14
14
|
displayObject: IDisplayObject2dComponent;
|
|
15
15
|
renderer: IRenderer2dComponent;
|
|
16
16
|
rendererExtraOpts: {};
|
|
17
17
|
texture: unknown;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type PhysicsTypeDocRepo2D = {
|
|
20
20
|
factory: IPhysicsBody2dComponentFactory;
|
|
21
21
|
rigidBody: IRigidBody2dComponent;
|
|
22
22
|
trigger: ITrigger2dComponent;
|
|
@@ -26,5 +26,5 @@ export declare class Gg2dWorld<VTypeDoc extends VisualTypeDocRepo2D = VisualType
|
|
|
26
26
|
readonly physicsWorld: PW;
|
|
27
27
|
constructor(visualScene: VS, physicsWorld: PW);
|
|
28
28
|
addPrimitiveRigidBody(descr: BodyShape2DDescriptor, position?: Point2, rotation?: number, material?: DisplayObject2dOpts<VTypeDoc['texture']>): Entity2d<VTypeDoc, PTypeDoc>;
|
|
29
|
-
addRenderer(canvas?: HTMLCanvasElement, rendererOptions?: Partial<RendererOptions>): Renderer2dEntity<VTypeDoc>;
|
|
29
|
+
addRenderer(canvas?: HTMLCanvasElement, rendererOptions?: Partial<RendererOptions & VTypeDoc['rendererExtraOpts']>): Renderer2dEntity<VTypeDoc>;
|
|
30
30
|
}
|
package/dist/2d/gg-2d-world.js
CHANGED
|
File without changes
|
package/dist/2d/index.d.ts
CHANGED
|
File without changes
|
package/dist/2d/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -2,6 +2,6 @@ import { BodyOptions, DebugBodySettings } from '../../base';
|
|
|
2
2
|
import { Shape2DDescriptor } from './shapes';
|
|
3
3
|
export interface Body2DOptions extends BodyOptions {
|
|
4
4
|
}
|
|
5
|
-
export
|
|
5
|
+
export type DebugBody2DSettings = DebugBodySettings & {
|
|
6
6
|
shape: Shape2DDescriptor;
|
|
7
7
|
};
|
|
File without changes
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Point2 } from '../../base';
|
|
2
2
|
import { Body2DOptions } from './body-options';
|
|
3
|
-
export
|
|
3
|
+
export type Shape2DDescriptor = {
|
|
4
|
+
collisionMargin?: number;
|
|
5
|
+
} & ({
|
|
4
6
|
shape: 'SQUARE';
|
|
5
7
|
dimensions: Point2;
|
|
6
8
|
} | {
|
|
7
9
|
shape: 'CIRCLE';
|
|
8
10
|
radius: number;
|
|
9
|
-
};
|
|
10
|
-
export
|
|
11
|
+
});
|
|
12
|
+
export type BodyShape2DDescriptor = {
|
|
11
13
|
shape: Shape2DDescriptor;
|
|
12
14
|
body: Partial<Body2DOptions>;
|
|
13
15
|
};
|
package/dist/2d/models/shapes.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Point3, Point4 } from '../../../base';
|
|
2
2
|
import { IRigidBody3dComponent } from './i-rigid-body-3d.component';
|
|
3
3
|
import { PhysicsTypeDocRepo3D } from '../../gg-3d-world';
|
|
4
|
-
export
|
|
4
|
+
export type SuspensionOptions = {
|
|
5
5
|
stiffness: number;
|
|
6
6
|
damping: number;
|
|
7
7
|
compression: number;
|
|
8
8
|
restLength: number;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type WheelOptions = {
|
|
11
11
|
isLeft: boolean;
|
|
12
12
|
isFront: boolean;
|
|
13
13
|
tyreWidth: number;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnimationFunction, AnimationMixer, Point3, Point4 } from '../../../../base';
|
|
2
2
|
import { Gg3dWorld, VisualTypeDocRepo3D } from '../../../gg-3d-world';
|
|
3
3
|
import { Renderer3dEntity } from '../../renderer-3d.entity';
|
|
4
|
-
export
|
|
4
|
+
export type Camera3dAnimationArgs = {
|
|
5
5
|
position: Point3;
|
|
6
6
|
target: Point3;
|
|
7
7
|
up?: Point3;
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnimationFunction, AnimationMixer, Point3, Point4 } from '../../../../base';
|
|
2
2
|
import { Gg3dWorld, PhysicsTypeDocRepo3D, VisualTypeDocRepo3D } from '../../../gg-3d-world';
|
|
3
3
|
import { IPositionable3d } from '../../../interfaces/i-positionable-3d';
|
|
4
|
-
|
|
4
|
+
type Positioning3d = {
|
|
5
5
|
position: Point3;
|
|
6
6
|
rotation: Point4;
|
|
7
7
|
};
|
|
File without changes
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { DirectionKeyboardInput, DirectionKeyboardKeymap, GgWorld, IEntity, KeyboardInput, TickOrder } from '../../../../base';
|
|
3
|
-
export
|
|
3
|
+
export type CarKeyboardControllerOptions = {
|
|
4
4
|
readonly keymap: DirectionKeyboardKeymap;
|
|
5
5
|
readonly maxSteerDeltaPerSecond: number;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type CarHandlingOutput = {
|
|
8
8
|
upDown: number;
|
|
9
9
|
leftRight: number;
|
|
10
10
|
};
|
|
@@ -12,7 +12,7 @@ export declare class CarKeyboardHandlingController extends IEntity {
|
|
|
12
12
|
protected readonly keyboard: KeyboardInput;
|
|
13
13
|
protected readonly options: CarKeyboardControllerOptions;
|
|
14
14
|
readonly tickOrder = TickOrder.INPUT_CONTROLLERS;
|
|
15
|
-
|
|
15
|
+
readonly directionsInput: DirectionKeyboardInput;
|
|
16
16
|
private _output$;
|
|
17
17
|
get output$(): Observable<CarHandlingOutput>;
|
|
18
18
|
constructor(keyboard: KeyboardInput, options?: CarKeyboardControllerOptions);
|
|
@@ -10,6 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { combineLatest, filter, Subject, takeUntil } from 'rxjs';
|
|
11
11
|
import { DirectionKeyboardInput, IEntity, TickOrder, } from '../../../../base';
|
|
12
12
|
export class CarKeyboardHandlingController extends IEntity {
|
|
13
|
+
get output$() {
|
|
14
|
+
return this._output$.asObservable();
|
|
15
|
+
}
|
|
13
16
|
constructor(keyboard, options = {
|
|
14
17
|
keymap: 'arrows',
|
|
15
18
|
maxSteerDeltaPerSecond: 12,
|
|
@@ -21,9 +24,6 @@ export class CarKeyboardHandlingController extends IEntity {
|
|
|
21
24
|
this._output$ = new Subject();
|
|
22
25
|
this.directionsInput = new DirectionKeyboardInput(keyboard, options.keymap);
|
|
23
26
|
}
|
|
24
|
-
get output$() {
|
|
25
|
-
return this._output$.asObservable();
|
|
26
|
-
}
|
|
27
27
|
onSpawned(world) {
|
|
28
28
|
const _super = Object.create(null, {
|
|
29
29
|
onSpawned: { get: () => super.onSpawned }
|
|
@@ -3,26 +3,37 @@ import { Renderer3dEntity } from '../../renderer-3d.entity';
|
|
|
3
3
|
/**
|
|
4
4
|
* Options for configuring a FreeCameraInput controller.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type FreeCameraControllerOptions = {
|
|
7
7
|
/**
|
|
8
|
-
* A keymap for controlling camera movement, where each key corresponds to a movement direction.
|
|
8
|
+
* A keymap for controlling camera movement, where each key corresponds to a movement direction. 'wasd' by default
|
|
9
9
|
*/
|
|
10
10
|
keymap: DirectionKeyboardKeymap;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* The speed of camera movement in meters per second. 20 by default
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The speed of camera movement.
|
|
17
|
-
*/
|
|
18
|
-
speed: number;
|
|
19
|
-
};
|
|
14
|
+
cameraLinearSpeed: number;
|
|
20
15
|
/**
|
|
21
|
-
*
|
|
16
|
+
* An elasticity factor for camera movement. 0 by default (no elastic motion)
|
|
17
|
+
*/
|
|
18
|
+
cameraMovementElasticity: number;
|
|
19
|
+
/**
|
|
20
|
+
* A linear speed multiplier when user holds shift key. 2.5 by default
|
|
21
|
+
*/
|
|
22
|
+
cameraBoostMultiplier: number;
|
|
23
|
+
/**
|
|
24
|
+
* The speed of camera rotation in radians per 1000px mouse movement. 1 by default
|
|
25
|
+
*/
|
|
26
|
+
cameraRotationSensitivity: number;
|
|
27
|
+
/**
|
|
28
|
+
* An elasticity factor for camera rotation. 0 by default (no elastic motion)
|
|
29
|
+
*/
|
|
30
|
+
cameraRotationElasticity: number;
|
|
31
|
+
/**
|
|
32
|
+
* Flag to ignore cursor movement if pointer was not locked. false by default
|
|
22
33
|
*/
|
|
23
34
|
ignoreMouseUnlessPointerLocked: boolean;
|
|
24
35
|
/**
|
|
25
|
-
* Flag to ignore keyboard events if pointer was not locked.
|
|
36
|
+
* Flag to ignore keyboard events if pointer was not locked. false by default
|
|
26
37
|
*/
|
|
27
38
|
ignoreKeyboardUnlessPointerLocked: boolean;
|
|
28
39
|
/**
|
|
@@ -41,11 +52,11 @@ export declare class FreeCameraController extends IEntity {
|
|
|
41
52
|
/**
|
|
42
53
|
* The mouse input controller used for camera rotation.
|
|
43
54
|
*/
|
|
44
|
-
|
|
55
|
+
readonly mouseInput: MouseInput;
|
|
45
56
|
/**
|
|
46
57
|
* The keyboard input controller used for camera movement.
|
|
47
58
|
*/
|
|
48
|
-
|
|
59
|
+
readonly directionsInput: DirectionKeyboardInput;
|
|
49
60
|
/**
|
|
50
61
|
* Creates a new FreeCameraInput instance.
|
|
51
62
|
* @param keyboard The keyboard input controller to use for camera movement.
|
|
@@ -7,11 +7,16 @@ 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, filter, takeUntil } from 'rxjs';
|
|
11
|
-
import { DirectionKeyboardInput, IEntity, MouseInput, Pnt2, Pnt3, Qtrn, TickOrder, } from '../../../../base';
|
|
10
|
+
import { BehaviorSubject, combineLatest, filter, takeUntil } from 'rxjs';
|
|
11
|
+
import { DirectionKeyboardInput, ggElastic, IEntity, MouseInput, Pnt2, Pnt3, Qtrn, TickOrder, } from '../../../../base';
|
|
12
|
+
import { map } from 'rxjs/operators';
|
|
12
13
|
const DEFAULT_FREE_CAMERA_CONTROLLER_OPTIONS = {
|
|
13
14
|
keymap: 'wasd',
|
|
14
|
-
|
|
15
|
+
cameraLinearSpeed: 20,
|
|
16
|
+
cameraMovementElasticity: 0,
|
|
17
|
+
cameraBoostMultiplier: 2.5,
|
|
18
|
+
cameraRotationSensitivity: 1,
|
|
19
|
+
cameraRotationElasticity: 0,
|
|
15
20
|
mouseOptions: {},
|
|
16
21
|
ignoreMouseUnlessPointerLocked: false,
|
|
17
22
|
ignoreKeyboardUnlessPointerLocked: false,
|
|
@@ -33,9 +38,9 @@ export class FreeCameraController extends IEntity {
|
|
|
33
38
|
this.tickOrder = TickOrder.INPUT_CONTROLLERS;
|
|
34
39
|
this.options = Object.assign(Object.assign({}, DEFAULT_FREE_CAMERA_CONTROLLER_OPTIONS), options);
|
|
35
40
|
if (options.mouseOptions) {
|
|
36
|
-
this.options.
|
|
41
|
+
this.options.mouseOptions = Object.assign(Object.assign({}, DEFAULT_FREE_CAMERA_CONTROLLER_OPTIONS.mouseOptions), options.mouseOptions);
|
|
37
42
|
}
|
|
38
|
-
this.mouseInput = new MouseInput(options.mouseOptions);
|
|
43
|
+
this.mouseInput = new MouseInput(this.options.mouseOptions);
|
|
39
44
|
this.directionsInput = new DirectionKeyboardInput(keyboard, this.options.keymap);
|
|
40
45
|
}
|
|
41
46
|
onSpawned(world) {
|
|
@@ -45,61 +50,77 @@ export class FreeCameraController extends IEntity {
|
|
|
45
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
51
|
yield _super.onSpawned.call(this, world);
|
|
47
52
|
// Subscribe to keyboard input for movement controls
|
|
48
|
-
let controls = { direction: {}, rest: [] };
|
|
49
53
|
const keys = ['KeyE', 'KeyQ'];
|
|
50
54
|
if (this.camera.camera.supportsFov) {
|
|
51
55
|
keys.push('KeyZ', 'KeyC');
|
|
52
56
|
}
|
|
53
57
|
keys.push('ShiftLeft');
|
|
54
|
-
this.directionsInput.output
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
.pipe(takeUntil(this._onRemoved$))
|
|
59
|
-
.subscribe((d) => {
|
|
60
|
-
controls.rest = d;
|
|
61
|
-
});
|
|
62
|
-
// Subscribe to mouse input for camera rotation
|
|
63
|
-
let rotationDelta = Pnt2.O;
|
|
64
|
-
let isTouchScreen = MouseInput.isTouchDevice();
|
|
65
|
-
this.mouseInput.delta$
|
|
66
|
-
.pipe(takeUntil(this._onRemoved$), filter(() => isTouchScreen || !this.options.ignoreMouseUnlessPointerLocked || this.mouseInput.isPointerLocked))
|
|
67
|
-
.subscribe(delta => {
|
|
68
|
-
rotationDelta = Pnt2.add(rotationDelta, delta);
|
|
69
|
-
});
|
|
70
|
-
// Setup updating camera position and rotation based on input
|
|
71
|
-
this.camera.tick$.pipe(takeUntil(this._onRemoved$)).subscribe(() => {
|
|
72
|
-
let c = controls;
|
|
73
|
-
if (this.options.ignoreKeyboardUnlessPointerLocked && !this.mouseInput.isPointerLocked) {
|
|
74
|
-
c = { direction: {}, rest: [false, false, false, false, false] };
|
|
58
|
+
let controlsObs = combineLatest([this.directionsInput.output$, ...keys.map(c => this.keyboard.bind(c))]).pipe(takeUntil(this._onRemoved$), map(([direction, ...rest]) => {
|
|
59
|
+
let c = { direction: {}, rest: [] };
|
|
60
|
+
if (!this.options.ignoreKeyboardUnlessPointerLocked || this.mouseInput.isPointerLocked) {
|
|
61
|
+
c = { direction, rest };
|
|
75
62
|
}
|
|
76
|
-
let
|
|
63
|
+
let translate = Object.assign({}, Pnt3.O);
|
|
77
64
|
const [u, d, zo, zi, speedBoost] = c.rest;
|
|
78
65
|
if (c.direction.upDown !== undefined)
|
|
79
|
-
|
|
66
|
+
translate.z = c.direction.upDown ? -1 : 1;
|
|
80
67
|
if (c.direction.leftRight !== undefined)
|
|
81
|
-
|
|
68
|
+
translate.x = c.direction.leftRight ? -1 : 1;
|
|
82
69
|
if (u != d)
|
|
83
|
-
|
|
70
|
+
translate.y = d ? -1 : 1;
|
|
71
|
+
let cameraFovInc = 0;
|
|
84
72
|
if (zo != zi)
|
|
85
|
-
|
|
86
|
-
|
|
73
|
+
cameraFovInc = zo ? 1 : -1;
|
|
74
|
+
translate = Pnt3.norm(translate);
|
|
87
75
|
if (speedBoost) {
|
|
88
|
-
|
|
76
|
+
translate = Pnt3.scalarMult(translate, this.options.cameraBoostMultiplier);
|
|
89
77
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
78
|
+
return [translate, cameraFovInc];
|
|
79
|
+
}));
|
|
80
|
+
if (this.options.cameraMovementElasticity > 0) {
|
|
81
|
+
controlsObs = controlsObs.pipe(ggElastic(this.camera.tick$, this.options.cameraMovementElasticity, ([at, _], [bt, bf], f) => [Pnt3.lerp(at, bt, f), bf], ([at, af], [bt, bf]) => af == bf && Pnt3.dist(at, bt) < 0.001));
|
|
82
|
+
}
|
|
83
|
+
let translateVector = Pnt3.O;
|
|
84
|
+
let cameraFovInc = 0;
|
|
85
|
+
controlsObs.subscribe(([t, f]) => {
|
|
86
|
+
translateVector = t;
|
|
87
|
+
cameraFovInc = f;
|
|
88
|
+
});
|
|
89
|
+
// Subscribe to mouse input for camera rotation
|
|
90
|
+
const spherical = Pnt3.toSpherical(Pnt3.rot({ x: 0, y: 0, z: -1 }, this.camera.rotation));
|
|
91
|
+
let isTouchScreen = MouseInput.isTouchDevice();
|
|
92
|
+
let mouseDelta$ = this.mouseInput.delta$.pipe(takeUntil(this._onRemoved$), filter(() => isTouchScreen || !this.options.ignoreMouseUnlessPointerLocked || this.mouseInput.isPointerLocked));
|
|
93
|
+
if (this.options.cameraRotationElasticity > 0) {
|
|
94
|
+
const s$ = new BehaviorSubject(spherical);
|
|
95
|
+
mouseDelta$.subscribe(delta => {
|
|
96
|
+
const s = s$.getValue();
|
|
97
|
+
s$.next({
|
|
98
|
+
phi: Math.max(0.000001, Math.min(Math.PI - 0.000001, s.phi + (delta.y * this.options.cameraRotationSensitivity) / 1000)),
|
|
99
|
+
theta: s.theta - (delta.x * this.options.cameraRotationSensitivity) / 1000,
|
|
100
|
+
radius: 1,
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
s$.pipe(takeUntil(this._onRemoved$), ggElastic(this.tick$, this.options.cameraRotationElasticity, (a, b, f) => ({ phi: a.phi + f * (b.phi - a.phi), theta: a.theta + f * (b.theta - a.theta), radius: 1 }), (a, b) => Pnt2.dist({ x: a.phi, y: a.theta }, { x: b.phi, y: b.theta }) < 0.0001)).subscribe(s => {
|
|
104
|
+
spherical.theta = s.theta;
|
|
105
|
+
spherical.phi = s.phi;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
mouseDelta$.subscribe(delta => {
|
|
110
|
+
spherical.theta -= (delta.x * this.options.cameraRotationSensitivity) / 1000;
|
|
111
|
+
spherical.phi += (delta.y * this.options.cameraRotationSensitivity) / 1000;
|
|
95
112
|
spherical.phi = Math.max(0.000001, Math.min(Math.PI - 0.000001, spherical.phi));
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
// Setup updating camera position and rotation based on input
|
|
116
|
+
this.camera.tick$.pipe(takeUntil(this._onRemoved$)).subscribe(([_, delta]) => {
|
|
117
|
+
this.camera.camera.fov += cameraFovInc;
|
|
118
|
+
this.camera.position = Pnt3.add(this.camera.position, Pnt3.rot(Pnt3.scalarMult(translateVector, (this.options.cameraLinearSpeed * delta) / 1000), this.camera.rotation));
|
|
119
|
+
this.camera.rotation = Qtrn.lookAt(this.camera.position, Pnt3.add(this.camera.position, Pnt3.fromSpherical(spherical)));
|
|
99
120
|
});
|
|
100
121
|
// start input
|
|
101
|
-
|
|
102
|
-
|
|
122
|
+
this.mouseInput.start();
|
|
123
|
+
this.directionsInput.start();
|
|
103
124
|
});
|
|
104
125
|
}
|
|
105
126
|
onRemoved() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GgWorld, IEntity, KeyboardInput, TickOrder } from '../../../../base';
|
|
2
2
|
import { GgCarEntity } from '../../gg-car/gg-car.entity';
|
|
3
3
|
import { CarKeyboardControllerOptions, CarKeyboardHandlingController } from './car-keyboard-handling.controller';
|
|
4
|
-
export
|
|
4
|
+
export type GgCarKeyboardControllerOptions = CarKeyboardControllerOptions & {
|
|
5
5
|
gearUpDownKeys: [string, string];
|
|
6
6
|
autoReverse: boolean;
|
|
7
7
|
handbrakeKey: string;
|
|
@@ -11,7 +11,7 @@ export declare class GgCarKeyboardHandlingController extends IEntity {
|
|
|
11
11
|
car: GgCarEntity | null;
|
|
12
12
|
protected readonly options: GgCarKeyboardControllerOptions;
|
|
13
13
|
readonly tickOrder = TickOrder.INPUT_CONTROLLERS;
|
|
14
|
-
|
|
14
|
+
readonly carHandlingInput: CarKeyboardHandlingController;
|
|
15
15
|
switchingGearsEnabled: boolean;
|
|
16
16
|
constructor(keyboard: KeyboardInput, car: GgCarEntity | null, options?: GgCarKeyboardControllerOptions);
|
|
17
17
|
onSpawned(world: GgWorld<any, any>): Promise<void>;
|
|
File without changes
|