@gg-web-engine/core 0.0.56 → 0.0.58
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-physics-world-2d.component.d.ts +1 -1
- package/dist/2d/components/physics/i-rigid-body-2d.component.d.ts +1 -1
- package/dist/2d/components/physics/i-trigger-2d.component.d.ts +3 -3
- package/dist/2d/components/rendering/i-display-object-2d.component.d.ts +1 -1
- package/dist/2d/components/rendering/i-renderer-2d.component.d.ts +1 -1
- package/dist/2d/components/rendering/i-visual-scene-2d.component.d.ts +2 -2
- package/dist/2d/entities/controllers/entity-2d-positioning.animator.d.ts +2 -2
- package/dist/2d/entities/entity-2d.d.ts +7 -7
- package/dist/2d/entities/i-renderable-2d.entity.d.ts +4 -4
- package/dist/2d/entities/renderer-2d.entity.d.ts +1 -1
- package/dist/2d/entities/trigger-2d.entity.d.ts +8 -4
- package/dist/2d/factories.d.ts +7 -7
- package/dist/2d/gg-2d-world.d.ts +34 -6
- package/dist/2d/gg-2d-world.js +23 -19
- package/dist/2d/models/body-options.d.ts +4 -4
- package/dist/2d/models/body-options.js +6 -1
- package/dist/3d/components/physics/i-physics-world-3d.component.d.ts +5 -5
- package/dist/3d/components/physics/i-raycast-vehicle.component.d.ts +1 -1
- package/dist/3d/components/physics/i-rigid-body-3d.component.d.ts +1 -1
- package/dist/3d/components/physics/i-trigger-3d.component.d.ts +3 -3
- package/dist/3d/components/rendering/i-camera.component.d.ts +1 -1
- package/dist/3d/components/rendering/i-display-object-3d.component.d.ts +1 -1
- package/dist/3d/components/rendering/i-renderer-3d.component.d.ts +2 -2
- package/dist/3d/components/rendering/i-visual-scene-3d.component.d.ts +3 -3
- package/dist/3d/entities/controllers/animators/camera-3d.animator.d.ts +3 -3
- package/dist/3d/entities/controllers/animators/entity-3d-positioning.animator.d.ts +2 -2
- package/dist/3d/entities/entity-3d.d.ts +6 -6
- package/dist/3d/entities/gg-car/gg-car.entity.d.ts +5 -5
- package/dist/3d/entities/i-renderable-3d.entity.d.ts +4 -4
- package/dist/3d/entities/map-graph-3d.entity.d.ts +6 -6
- package/dist/3d/entities/raycast-vehicle-3d.entity.d.ts +3 -3
- package/dist/3d/entities/renderer-3d.entity.d.ts +2 -2
- package/dist/3d/entities/surface-following.entity.d.ts +96 -0
- package/dist/3d/entities/surface-following.entity.js +299 -0
- package/dist/3d/entities/trigger-3d.entity.d.ts +8 -4
- package/dist/3d/factories.d.ts +14 -14
- package/dist/3d/gg-3d-world.d.ts +35 -7
- package/dist/3d/gg-3d-world.js +23 -19
- package/dist/3d/index.d.ts +1 -0
- package/dist/3d/index.js +1 -0
- package/dist/3d/loader.d.ts +12 -12
- package/dist/3d/loader.js +6 -5
- package/dist/3d/loaders.d.ts +4 -4
- package/dist/3d/models/body-options.d.ts +4 -4
- package/dist/3d/models/body-options.js +6 -1
- package/dist/base/components/i-world-component.d.ts +5 -5
- package/dist/base/components/physics/i-body.component.d.ts +10 -10
- package/dist/base/components/physics/i-physics-world.component.d.ts +56 -10
- package/dist/base/components/physics/i-rigid-body.component.d.ts +2 -2
- package/dist/base/components/physics/i-trigger.component.d.ts +4 -4
- package/dist/base/components/rendering/i-display-object.component.d.ts +6 -6
- package/dist/base/components/rendering/i-renderer.component.d.ts +4 -4
- package/dist/base/components/rendering/i-visual-scene.component.d.ts +2 -2
- package/dist/base/data-structures/bitmask.d.ts +5 -4
- package/dist/base/data-structures/bitmask.js +4 -3
- package/dist/base/entities/controllers/animation-mixer.d.ts +3 -3
- package/dist/base/entities/i-entity.d.ts +8 -8
- package/dist/base/entities/i-renderable.entity.d.ts +2 -2
- package/dist/base/entities/i-renderer.entity.d.ts +5 -5
- package/dist/base/gg-world.d.ts +31 -6
- package/dist/base/gg-world.js +27 -14
- package/dist/base/index.d.ts +1 -0
- package/dist/base/index.js +1 -0
- package/dist/base/math/numbers.d.ts +2 -1
- package/dist/base/math/numbers.js +7 -1
- package/dist/base/math/point2.d.ts +19 -1
- package/dist/base/math/point2.js +41 -3
- package/dist/base/math/point3.d.ts +4 -0
- package/dist/base/math/point3.js +20 -3
- package/dist/base/models/body-options.d.ts +27 -9
- package/dist/base/models/body-options.js +65 -1
- package/dist/base/models/points.d.ts +20 -16
- package/dist/base/models/raycasting.d.ts +52 -0
- package/dist/base/models/raycasting.js +1 -0
- package/dist/dev/gg-debugger.ui.js +5 -13
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/3d/loader.js
CHANGED
|
@@ -57,6 +57,7 @@ export class Gg3dLoader {
|
|
|
57
57
|
}
|
|
58
58
|
loadGgGlbResources(path_1) {
|
|
59
59
|
return __awaiter(this, arguments, void 0, function* (path, cachingStrategy = CachingStrategy.Nothing) {
|
|
60
|
+
var _a, _b;
|
|
60
61
|
if (cachingStrategy == CachingStrategy.Entities && this.loadResultCache.has(path)) {
|
|
61
62
|
const cached = this.loadResultCache.get(path);
|
|
62
63
|
const cachedResult = cached instanceof Promise ? yield cached : cached;
|
|
@@ -67,21 +68,21 @@ export class Gg3dLoader {
|
|
|
67
68
|
throw new Error('GLB not found');
|
|
68
69
|
}
|
|
69
70
|
const [object, bodies] = yield Promise.all([
|
|
70
|
-
this.world.visualScene.loader.loadFromGgGlb(glb, meta),
|
|
71
|
-
this.world.physicsWorld.loader.loadFromGgGlb(glb, meta),
|
|
71
|
+
(_a = this.world.visualScene) === null || _a === void 0 ? void 0 : _a.loader.loadFromGgGlb(glb, meta),
|
|
72
|
+
(_b = this.world.physicsWorld) === null || _b === void 0 ? void 0 : _b.loader.loadFromGgGlb(glb, meta),
|
|
72
73
|
]);
|
|
73
74
|
const result = { resources: [], meta };
|
|
74
75
|
if (!object) {
|
|
75
76
|
return result;
|
|
76
77
|
}
|
|
77
|
-
if (bodies.length == 0) {
|
|
78
|
+
if ((bodies === null || bodies === void 0 ? void 0 : bodies.length) == 0) {
|
|
78
79
|
result.resources.push({ object3D: object, body: null });
|
|
79
80
|
}
|
|
80
|
-
else if (bodies.length == 1) {
|
|
81
|
+
else if ((bodies === null || bodies === void 0 ? void 0 : bodies.length) == 1) {
|
|
81
82
|
result.resources.push({ object3D: object, body: bodies[0] });
|
|
82
83
|
}
|
|
83
84
|
else {
|
|
84
|
-
for (const body of bodies) {
|
|
85
|
+
for (const body of bodies || []) {
|
|
85
86
|
result.resources.push({ object3D: object.popChild(body.name), body });
|
|
86
87
|
}
|
|
87
88
|
if (!object.isEmpty()) {
|
package/dist/3d/loaders.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { GgMeta } from './models/gg-meta';
|
|
2
2
|
import { IPhysicsWorld3dComponent } from './components/physics/i-physics-world-3d.component';
|
|
3
3
|
import { PhysicsTypeDocRepo3D, VisualTypeDocRepo3D } from './gg-3d-world';
|
|
4
|
-
export declare abstract class IPhysicsBody3dComponentLoader<
|
|
4
|
+
export declare abstract class IPhysicsBody3dComponentLoader<PTypeDoc extends PhysicsTypeDocRepo3D = PhysicsTypeDocRepo3D> {
|
|
5
5
|
protected readonly world: IPhysicsWorld3dComponent;
|
|
6
6
|
protected constructor(world: IPhysicsWorld3dComponent);
|
|
7
|
-
loadFromGgGlb(glbFile: ArrayBuffer, meta: GgMeta): Promise<
|
|
7
|
+
loadFromGgGlb(glbFile: ArrayBuffer, meta: GgMeta): Promise<PTypeDoc['rigidBody'][]>;
|
|
8
8
|
}
|
|
9
|
-
export interface IDisplayObject3dComponentLoader<
|
|
10
|
-
loadFromGgGlb(glbFile: ArrayBuffer, meta: GgMeta): Promise<
|
|
9
|
+
export interface IDisplayObject3dComponentLoader<VTypeDoc extends VisualTypeDocRepo3D = VisualTypeDocRepo3D> {
|
|
10
|
+
loadFromGgGlb(glbFile: ArrayBuffer, meta: GgMeta): Promise<VTypeDoc['displayObject'] | null>;
|
|
11
11
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BodyOptions, DebugBodySettings } from '../../base';
|
|
1
|
+
import { BodyOptions, DebugBodySettings, DebugBodyType } from '../../base';
|
|
2
2
|
import { Shape3DDescriptor } from './shapes';
|
|
3
3
|
export interface Body3DOptions extends BodyOptions {
|
|
4
4
|
}
|
|
5
|
-
export
|
|
6
|
-
shape: Shape3DDescriptor;
|
|
7
|
-
}
|
|
5
|
+
export declare class DebugBody3DSettings extends DebugBodySettings<Shape3DDescriptor> {
|
|
6
|
+
constructor(type: DebugBodyType, shape: Shape3DDescriptor, ignoreTransform?: boolean, color?: number | undefined);
|
|
7
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IEntity } from '../entities/i-entity';
|
|
2
|
-
import { GgWorld,
|
|
3
|
-
|
|
2
|
+
import { GgWorld, GgWorldTypeDocRepo } from '../gg-world';
|
|
3
|
+
import { IComponent } from './i-component';
|
|
4
|
+
export interface IWorldComponent<D, R, TypeDoc extends GgWorldTypeDocRepo<D, R> = GgWorldTypeDocRepo<D, R>> extends IComponent {
|
|
4
5
|
entity: IEntity | null;
|
|
5
|
-
addToWorld(world: GgWorld<D, R,
|
|
6
|
-
removeFromWorld(world: GgWorld<D, R,
|
|
7
|
-
dispose(): void;
|
|
6
|
+
addToWorld(world: GgWorld<D, R, TypeDoc>): void;
|
|
7
|
+
removeFromWorld(world: GgWorld<D, R, TypeDoc>, dispose?: boolean): void;
|
|
8
8
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { IEntity } from '../../entities/i-entity';
|
|
2
2
|
import { IWorldComponent } from '../i-world-component';
|
|
3
|
-
import { GgWorld,
|
|
3
|
+
import { GgWorld, GgWorldTypeDocPPatch, PhysicsTypeDocRepo } from '../../gg-world';
|
|
4
4
|
import { CollisionGroup, DebugBodySettings } from '../../models/body-options';
|
|
5
|
-
export interface IBodyComponent<D, R,
|
|
5
|
+
export interface IBodyComponent<D, R, PTypeDoc extends PhysicsTypeDocRepo<D, R> = PhysicsTypeDocRepo<D, R>> extends IWorldComponent<D, R, GgWorldTypeDocPPatch<D, R, PTypeDoc>> {
|
|
6
6
|
entity: IEntity | null;
|
|
7
7
|
position: D;
|
|
8
8
|
rotation: R;
|
|
9
9
|
name: string;
|
|
10
|
-
get ownCollisionGroups(): CollisionGroup
|
|
11
|
-
set ownCollisionGroups(value: CollisionGroup
|
|
12
|
-
get interactWithCollisionGroups(): CollisionGroup
|
|
13
|
-
set interactWithCollisionGroups(value: CollisionGroup
|
|
10
|
+
get ownCollisionGroups(): ReadonlyArray<CollisionGroup>;
|
|
11
|
+
set ownCollisionGroups(value: ReadonlyArray<CollisionGroup> | 'all');
|
|
12
|
+
get interactWithCollisionGroups(): ReadonlyArray<CollisionGroup>;
|
|
13
|
+
set interactWithCollisionGroups(value: ReadonlyArray<CollisionGroup> | 'all');
|
|
14
14
|
/** body info for physics debugger view */
|
|
15
|
-
readonly debugBodySettings: DebugBodySettings
|
|
16
|
-
clone(): IBodyComponent<D, R,
|
|
17
|
-
addToWorld(world: GgWorld<D, R,
|
|
18
|
-
removeFromWorld(world: GgWorld<D, R,
|
|
15
|
+
readonly debugBodySettings: DebugBodySettings<any>;
|
|
16
|
+
clone(): IBodyComponent<D, R, PTypeDoc>;
|
|
17
|
+
addToWorld(world: GgWorld<D, R, GgWorldTypeDocPPatch<D, R, PTypeDoc>>): void;
|
|
18
|
+
removeFromWorld(world: GgWorld<D, R, GgWorldTypeDocPPatch<D, R, PTypeDoc>>): void;
|
|
19
19
|
}
|
|
@@ -2,22 +2,68 @@ import { PhysicsTypeDocRepo } from '../../gg-world';
|
|
|
2
2
|
import { IComponent } from '../i-component';
|
|
3
3
|
import { CollisionGroup } from '../../models/body-options';
|
|
4
4
|
import { Subject } from 'rxjs';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { RaycastOptions, RaycastResult } from '../../models/raycasting';
|
|
6
|
+
/**
|
|
7
|
+
* Interface representing a physics world component.
|
|
8
|
+
*
|
|
9
|
+
* @template D - Data type used for representing physics properties.
|
|
10
|
+
* @template R - Type representing the physics engine's rigid body.
|
|
11
|
+
* @template TypeDoc - Physics typings repository.
|
|
12
|
+
*/
|
|
13
|
+
export interface IPhysicsWorldComponent<D, R, PTypeDoc extends PhysicsTypeDocRepo<D, R> = PhysicsTypeDocRepo<D, R>> extends IComponent {
|
|
14
|
+
/**
|
|
15
|
+
* Factory function for creating physics-related objects.
|
|
16
|
+
*/
|
|
17
|
+
readonly factory: PTypeDoc['factory'];
|
|
18
|
+
/**
|
|
19
|
+
* The gravity vector affecting the physics world.
|
|
20
|
+
*/
|
|
7
21
|
gravity: D;
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readonly
|
|
12
|
-
/**
|
|
13
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Event emitter that emits newly added physics components.
|
|
24
|
+
*/
|
|
25
|
+
readonly added$: Subject<PTypeDoc['rigidBody'] | PTypeDoc['trigger'] | any>;
|
|
26
|
+
/**
|
|
27
|
+
* Event emitter that emits just removed physics components.
|
|
28
|
+
*/
|
|
29
|
+
readonly removed$: Subject<PTypeDoc['rigidBody'] | PTypeDoc['trigger'] | any>;
|
|
30
|
+
/**
|
|
31
|
+
* List of currently added physics components in the world.
|
|
32
|
+
*/
|
|
33
|
+
readonly children: (PTypeDoc['rigidBody'] | PTypeDoc['trigger'] | any)[];
|
|
34
|
+
/**
|
|
35
|
+
* The main collision group. All physics bodies have this collision group set by default.
|
|
36
|
+
*/
|
|
37
|
+
readonly mainCollisionGroup: CollisionGroup;
|
|
38
|
+
/**
|
|
39
|
+
* Initializes the physics world component.
|
|
40
|
+
*
|
|
41
|
+
* @returns A promise that resolves when initialization is complete.
|
|
42
|
+
*/
|
|
14
43
|
init(): Promise<void>;
|
|
15
44
|
/**
|
|
16
|
-
* Runs simulation of the physics world.
|
|
45
|
+
* Runs the simulation of the physics world for the given time step.
|
|
17
46
|
*
|
|
18
|
-
* @param delta
|
|
47
|
+
* @param delta - The time step in milliseconds since the last update.
|
|
19
48
|
*/
|
|
20
49
|
simulate(delta: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* Registers and returns a new collision group.
|
|
52
|
+
*
|
|
53
|
+
* @returns A newly registered collision group.
|
|
54
|
+
*/
|
|
21
55
|
registerCollisionGroup(): CollisionGroup;
|
|
56
|
+
/**
|
|
57
|
+
* Deregisters a previously registered collision group.
|
|
58
|
+
*
|
|
59
|
+
* @param group - The collision group to be removed.
|
|
60
|
+
*/
|
|
22
61
|
deregisterCollisionGroup(group: CollisionGroup): void;
|
|
62
|
+
/**
|
|
63
|
+
* Performs a raycast in the physics world.
|
|
64
|
+
*
|
|
65
|
+
* @param options - The options for the raycast.
|
|
66
|
+
* @returns The result of the raycast.
|
|
67
|
+
*/
|
|
68
|
+
raycast(options: RaycastOptions<D>): RaycastResult<D, PTypeDoc['rigidBody'] | PTypeDoc['trigger']>;
|
|
23
69
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IBodyComponent } from './i-body.component';
|
|
2
2
|
import { PhysicsTypeDocRepo } from '../../gg-world';
|
|
3
|
-
export interface IRigidBodyComponent<D, R,
|
|
3
|
+
export interface IRigidBodyComponent<D, R, PTypeDoc extends PhysicsTypeDocRepo<D, R> = PhysicsTypeDocRepo<D, R>> extends IBodyComponent<D, R, PTypeDoc> {
|
|
4
4
|
linearVelocity: D;
|
|
5
5
|
angularVelocity: R | D;
|
|
6
|
-
clone(): IRigidBodyComponent<D, R,
|
|
6
|
+
clone(): IRigidBodyComponent<D, R, PTypeDoc>;
|
|
7
7
|
/** clear velocities etc. */
|
|
8
8
|
resetMotion(): void;
|
|
9
9
|
}
|
|
@@ -2,9 +2,9 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
import { IRigidBodyComponent } from './i-rigid-body.component';
|
|
3
3
|
import { IBodyComponent } from './i-body.component';
|
|
4
4
|
import { PhysicsTypeDocRepo } from '../../gg-world';
|
|
5
|
-
export interface ITriggerComponent<D, R,
|
|
6
|
-
get onEntityEntered(): Observable<IRigidBodyComponent<D, R,
|
|
7
|
-
get onEntityLeft(): Observable<IRigidBodyComponent<D, R,
|
|
8
|
-
clone(): ITriggerComponent<D, R,
|
|
5
|
+
export interface ITriggerComponent<D, R, PTypeDoc extends PhysicsTypeDocRepo<D, R> = PhysicsTypeDocRepo<D, R>> extends IBodyComponent<D, R, PTypeDoc> {
|
|
6
|
+
get onEntityEntered(): Observable<IRigidBodyComponent<D, R, PTypeDoc>>;
|
|
7
|
+
get onEntityLeft(): Observable<IRigidBodyComponent<D, R, PTypeDoc> | null>;
|
|
8
|
+
clone(): ITriggerComponent<D, R, PTypeDoc>;
|
|
9
9
|
checkOverlaps(): void;
|
|
10
10
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { GgBox, GgWorld, VisualTypeDocRepo } from '../../../base';
|
|
1
|
+
import { GgBox, GgWorld, GgWorldTypeDocVPatch, VisualTypeDocRepo } from '../../../base';
|
|
2
2
|
import { IWorldComponent } from '../i-world-component';
|
|
3
|
-
export interface IDisplayObjectComponent<D, R,
|
|
3
|
+
export interface IDisplayObjectComponent<D, R, VTypeDoc extends VisualTypeDocRepo<D, R> = VisualTypeDocRepo<D, R>> extends IWorldComponent<D, R, GgWorldTypeDocVPatch<D, R, VTypeDoc>> {
|
|
4
4
|
position: D;
|
|
5
5
|
rotation: R;
|
|
6
6
|
scale: D;
|
|
7
7
|
visible: boolean;
|
|
8
8
|
name: string;
|
|
9
9
|
isEmpty(): boolean;
|
|
10
|
-
popChild(name: string): IDisplayObjectComponent<D, R,
|
|
10
|
+
popChild(name: string): IDisplayObjectComponent<D, R, VTypeDoc> | null;
|
|
11
11
|
getBoundings(): GgBox<D>;
|
|
12
|
-
clone(): IDisplayObjectComponent<D, R,
|
|
13
|
-
addToWorld(world: GgWorld<D, R,
|
|
14
|
-
removeFromWorld(world: GgWorld<D, R,
|
|
12
|
+
clone(): IDisplayObjectComponent<D, R, VTypeDoc>;
|
|
13
|
+
addToWorld(world: GgWorld<D, R, GgWorldTypeDocVPatch<D, R, VTypeDoc>>): void;
|
|
14
|
+
removeFromWorld(world: GgWorld<D, R, GgWorldTypeDocVPatch<D, R, VTypeDoc>>): void;
|
|
15
15
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Point2 } from '../../models/points';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { IWorldComponent } from '../i-world-component';
|
|
4
|
-
import { GgWorld, VisualTypeDocRepo } from '../../gg-world';
|
|
4
|
+
import { GgWorld, GgWorldTypeDocVPatch, VisualTypeDocRepo } from '../../gg-world';
|
|
5
5
|
import { IEntity } from '../../entities/i-entity';
|
|
6
6
|
import { IVisualSceneComponent } from './i-visual-scene.component';
|
|
7
7
|
/**
|
|
@@ -20,7 +20,7 @@ export type RendererOptions = {
|
|
|
20
20
|
forceResolution?: number;
|
|
21
21
|
antialias: boolean;
|
|
22
22
|
};
|
|
23
|
-
export declare abstract class IRendererComponent<D, R, VTypeDoc extends VisualTypeDocRepo<D, R> = VisualTypeDocRepo<D, R>> implements IWorldComponent<D, R, VTypeDoc
|
|
23
|
+
export declare abstract class IRendererComponent<D, R, VTypeDoc extends VisualTypeDocRepo<D, R> = VisualTypeDocRepo<D, R>> implements IWorldComponent<D, R, GgWorldTypeDocVPatch<D, R, VTypeDoc>> {
|
|
24
24
|
readonly scene: IVisualSceneComponent<D, R, VTypeDoc>;
|
|
25
25
|
readonly canvas?: HTMLCanvasElement | undefined;
|
|
26
26
|
entity: IEntity | null;
|
|
@@ -35,8 +35,8 @@ export declare abstract class IRendererComponent<D, R, VTypeDoc extends VisualTy
|
|
|
35
35
|
* Renders the scene.
|
|
36
36
|
*/
|
|
37
37
|
abstract render(): void;
|
|
38
|
-
abstract addToWorld(world: GgWorld<D, R, VTypeDoc
|
|
39
|
-
abstract removeFromWorld(world: GgWorld<D, R, VTypeDoc
|
|
38
|
+
abstract addToWorld(world: GgWorld<D, R, GgWorldTypeDocVPatch<D, R, VTypeDoc>>): void;
|
|
39
|
+
abstract removeFromWorld(world: GgWorld<D, R, GgWorldTypeDocVPatch<D, R, VTypeDoc>>): void;
|
|
40
40
|
/**
|
|
41
41
|
* Resizes the renderer to the specified size.
|
|
42
42
|
* @param {Point2} newSize - The new size of the renderer.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IComponent } from '../i-component';
|
|
2
2
|
import { VisualTypeDocRepo } from '../../gg-world';
|
|
3
|
-
export interface IVisualSceneComponent<D, R,
|
|
4
|
-
readonly factory:
|
|
3
|
+
export interface IVisualSceneComponent<D, R, VTypeDoc extends VisualTypeDocRepo<D, R> = VisualTypeDocRepo<D, R>> extends IComponent {
|
|
4
|
+
readonly factory: VTypeDoc['factory'];
|
|
5
5
|
init(): Promise<void>;
|
|
6
6
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BitMask class provides static methods to manipulate bits in a number.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* BitMask class provides static methods to manipulate bits in a number.
|
|
6
|
+
*/
|
|
6
7
|
export declare class BitMask {
|
|
7
8
|
/**
|
|
8
9
|
* Generates a bitmask with all bits set to 1 upto the provided bit count
|
|
@@ -20,7 +21,7 @@ export declare class BitMask {
|
|
|
20
21
|
* @param bits - The maximum bit index that can be used
|
|
21
22
|
* @throws Will throw an Error if a bit index in `value` is larger than `bits`
|
|
22
23
|
*/
|
|
23
|
-
static pack(value: number[]
|
|
24
|
+
static pack(value: number[] | ReadonlyArray<number>, bits: number): number;
|
|
24
25
|
/**
|
|
25
26
|
* Unpacks a bitmask into an array of bit indices
|
|
26
27
|
* @param mask - The bit mask to be unpacked
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BitMask class provides static methods to manipulate bits in a number.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* BitMask class provides static methods to manipulate bits in a number.
|
|
6
|
+
*/
|
|
6
7
|
export class BitMask {
|
|
7
8
|
/**
|
|
8
9
|
* Generates a bitmask with all bits set to 1 upto the provided bit count
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IEntity } from '../i-entity';
|
|
2
2
|
import { Observable, Subject } from 'rxjs';
|
|
3
|
-
import { GgWorld,
|
|
3
|
+
import { GgWorld, GgWorldTypeDocRepo } from '../../gg-world';
|
|
4
4
|
export type AnimationFunction<T> = (elapsed: number, delta: number) => T;
|
|
5
5
|
/**
|
|
6
6
|
* A class that performs property animations for a specific type `T` by using provided animation function.
|
|
@@ -8,7 +8,7 @@ export type AnimationFunction<T> = (elapsed: number, delta: number) => T;
|
|
|
8
8
|
* The current value of the animation can be subscribed to using the `subscribeToValue` property.
|
|
9
9
|
* The animation function can be changed with `transitAnimationFunction` or `transitFromStaticState`.
|
|
10
10
|
*/
|
|
11
|
-
export declare class AnimationMixer<T, D = any, R = any,
|
|
11
|
+
export declare class AnimationMixer<T, D = any, R = any, TypeDoc extends GgWorldTypeDocRepo<D, R> = GgWorldTypeDocRepo<D, R>> extends IEntity<D, R, TypeDoc> {
|
|
12
12
|
protected _animationFunction: AnimationFunction<T>;
|
|
13
13
|
protected _lerp: (a: T, b: T, t: number) => T;
|
|
14
14
|
readonly tickOrder: number;
|
|
@@ -71,6 +71,6 @@ export declare class AnimationMixer<T, D = any, R = any, VTypeDoc extends Visual
|
|
|
71
71
|
* @param easing an easing function for transition
|
|
72
72
|
*/
|
|
73
73
|
transitAnimationFunction(newFunc: AnimationFunction<T>, transitionDuration: number, easing?: (t: number) => number): void;
|
|
74
|
-
onSpawned(world: GgWorld<D, R,
|
|
74
|
+
onSpawned(world: GgWorld<D, R, TypeDoc>): void;
|
|
75
75
|
dispose(): void;
|
|
76
76
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GgWorld,
|
|
1
|
+
import { GgWorld, GgWorldTypeDocRepo } from '../gg-world';
|
|
2
2
|
import { Observable, Subject } from 'rxjs';
|
|
3
3
|
import { IWorldComponent } from '../components/i-world-component';
|
|
4
4
|
/**
|
|
@@ -13,7 +13,7 @@ export declare enum TickOrder {
|
|
|
13
13
|
RENDERING = 1000,
|
|
14
14
|
POST_RENDERING = 1200
|
|
15
15
|
}
|
|
16
|
-
export declare abstract class IEntity<D = any, R = any,
|
|
16
|
+
export declare abstract class IEntity<D = any, R = any, TypeDoc extends GgWorldTypeDocRepo<D, R> = GgWorldTypeDocRepo<D, R>> {
|
|
17
17
|
private static default_name_counter;
|
|
18
18
|
/**
|
|
19
19
|
* will receive [elapsed time, delta] of each world clock tick
|
|
@@ -26,8 +26,8 @@ export declare abstract class IEntity<D = any, R = any, VTypeDoc extends VisualT
|
|
|
26
26
|
/**
|
|
27
27
|
* a world reference, where this entity was added to
|
|
28
28
|
*/
|
|
29
|
-
protected _world: GgWorld<D, R,
|
|
30
|
-
get world(): GgWorld<D, R,
|
|
29
|
+
protected _world: GgWorld<D, R, TypeDoc> | null;
|
|
30
|
+
get world(): GgWorld<D, R, TypeDoc> | null;
|
|
31
31
|
protected _name: string;
|
|
32
32
|
get name(): string;
|
|
33
33
|
set name(value: string);
|
|
@@ -43,14 +43,14 @@ export declare abstract class IEntity<D = any, R = any, VTypeDoc extends VisualT
|
|
|
43
43
|
addChildren(...entities: IEntity[]): void;
|
|
44
44
|
removeChildren(entities: IEntity[], dispose?: boolean): void;
|
|
45
45
|
private _components;
|
|
46
|
-
get components(): IWorldComponent<D, R,
|
|
47
|
-
addComponents(...components: IWorldComponent<D, R,
|
|
48
|
-
removeComponents(components: IWorldComponent<D, R,
|
|
46
|
+
get components(): IWorldComponent<D, R, TypeDoc>[];
|
|
47
|
+
addComponents(...components: IWorldComponent<D, R, TypeDoc>[]): void;
|
|
48
|
+
removeComponents(components: IWorldComponent<D, R, TypeDoc>[], dispose?: boolean): void;
|
|
49
49
|
protected _onSpawned$: Subject<void>;
|
|
50
50
|
protected _onRemoved$: Subject<void>;
|
|
51
51
|
get onSpawned$(): Observable<void>;
|
|
52
52
|
get onRemoved$(): Observable<void>;
|
|
53
|
-
onSpawned(world: GgWorld<D, R,
|
|
53
|
+
onSpawned(world: GgWorld<D, R, TypeDoc>): void;
|
|
54
54
|
onRemoved(): void;
|
|
55
55
|
dispose(): void;
|
|
56
56
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IEntity } from './i-entity';
|
|
2
|
-
import {
|
|
3
|
-
export declare abstract class IRenderableEntity<D = any, R = any, TypeDoc extends
|
|
2
|
+
import { GgWorldTypeDocRepo } from '../gg-world';
|
|
3
|
+
export declare abstract class IRenderableEntity<D = any, R = any, TypeDoc extends GgWorldTypeDocRepo<D, R> = GgWorldTypeDocRepo<D, R>> extends IEntity<D, R, TypeDoc> {
|
|
4
4
|
private _visible;
|
|
5
5
|
get visible(): boolean;
|
|
6
6
|
get worldVisible(): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IEntity, TickOrder } from './i-entity';
|
|
2
|
-
import { GgWorld, VisualTypeDocRepo } from '../gg-world';
|
|
2
|
+
import { GgWorld, GgWorldTypeDocVPatch, VisualTypeDocRepo } from '../gg-world';
|
|
3
3
|
import { BehaviorSubject, Observable } from 'rxjs';
|
|
4
4
|
import { Point2 } from '../models/points';
|
|
5
5
|
import { RendererOptions } from '../components/rendering/i-renderer.component';
|
|
@@ -7,8 +7,8 @@ import { RendererOptions } from '../components/rendering/i-renderer.component';
|
|
|
7
7
|
* Represents a base class for a renderer entity.
|
|
8
8
|
* @class
|
|
9
9
|
*/
|
|
10
|
-
export declare abstract class IRendererEntity<D, R,
|
|
11
|
-
readonly renderer:
|
|
10
|
+
export declare abstract class IRendererEntity<D, R, VTypeDoc extends VisualTypeDocRepo<D, R> = VisualTypeDocRepo<D, R>> extends IEntity<D, R, GgWorldTypeDocVPatch<D, R, VTypeDoc>> {
|
|
11
|
+
readonly renderer: VTypeDoc['renderer'];
|
|
12
12
|
readonly tickOrder = TickOrder.RENDERING;
|
|
13
13
|
/** Represents the current size of the renderer. */
|
|
14
14
|
protected _rendererSize$: BehaviorSubject<Point2 | null>;
|
|
@@ -31,7 +31,7 @@ export declare abstract class IRendererEntity<D, R, TypeDoc extends VisualTypeDo
|
|
|
31
31
|
Initializes a new instance of the BaseGgRenderer class.
|
|
32
32
|
* @param renderer
|
|
33
33
|
*/
|
|
34
|
-
constructor(renderer:
|
|
35
|
-
onSpawned(world: GgWorld<D, R,
|
|
34
|
+
constructor(renderer: VTypeDoc['renderer']);
|
|
35
|
+
onSpawned(world: GgWorld<D, R, GgWorldTypeDocVPatch<D, R, VTypeDoc>>): void;
|
|
36
36
|
dispose(): void;
|
|
37
37
|
}
|
package/dist/base/gg-world.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IDisplayObjectComponent, IEntity, IPhysicsWorldComponent, IPositionable, IRenderableEntity, IRendererComponent, IRigidBodyComponent, ITriggerComponent, IVisualSceneComponent, KeyboardInput, PausableClock } from '../base';
|
|
1
|
+
import { IDisplayObjectComponent, IEntity, IPhysicsWorldComponent, IPositionable, IRenderableEntity, IRendererComponent, IRendererEntity, IRigidBodyComponent, ITriggerComponent, IVisualSceneComponent, KeyboardInput, PausableClock } from '../base';
|
|
2
2
|
import { Subject } from 'rxjs';
|
|
3
|
+
import { IVisualScene2dComponent, VisualTypeDocRepo2D } from '../2d';
|
|
3
4
|
export type VisualTypeDocRepo<D, R> = {
|
|
4
5
|
factory: unknown;
|
|
5
6
|
displayObject: IDisplayObjectComponent<D, R>;
|
|
@@ -11,24 +12,48 @@ export type PhysicsTypeDocRepo<D, R> = {
|
|
|
11
12
|
rigidBody: IRigidBodyComponent<D, R>;
|
|
12
13
|
trigger: ITriggerComponent<D, R>;
|
|
13
14
|
};
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
export type GgWorldTypeDocRepo<D, R> = {
|
|
16
|
+
vTypeDoc: VisualTypeDocRepo<D, R>;
|
|
17
|
+
pTypeDoc: PhysicsTypeDocRepo<D, R>;
|
|
18
|
+
};
|
|
19
|
+
export type GgWorldTypeDocVPatch<D, R, VTypeDoc extends VisualTypeDocRepo<D, R>> = Omit<GgWorldTypeDocRepo<D, R>, 'vTypeDoc'> & {
|
|
20
|
+
vTypeDoc: VTypeDoc;
|
|
21
|
+
};
|
|
22
|
+
export type GgWorldTypeDocPPatch<D, R, PTypeDoc extends PhysicsTypeDocRepo<D, R>> = Omit<GgWorldTypeDocRepo<D, R>, 'pTypeDoc'> & {
|
|
23
|
+
pTypeDoc: PTypeDoc;
|
|
24
|
+
};
|
|
25
|
+
export type GgWorldSceneTypeRepo<D, R, TypeDoc extends GgWorldTypeDocRepo<D, R> = GgWorldTypeDocRepo<D, R>> = {
|
|
26
|
+
visualScene: IVisualSceneComponent<D, R, TypeDoc['vTypeDoc']> | null;
|
|
27
|
+
physicsWorld: IPhysicsWorldComponent<D, R, TypeDoc['pTypeDoc']> | null;
|
|
28
|
+
};
|
|
29
|
+
export type GgWorldSceneTypeDocVPatch<D, R, VTypeDoc extends VisualTypeDocRepo2D, VS extends IVisualScene2dComponent<VTypeDoc> | null> = Omit<GgWorldSceneTypeRepo<D, R>, 'visualScene'> & {
|
|
30
|
+
visualScene: VS;
|
|
31
|
+
};
|
|
32
|
+
export type GgWorldSceneTypeDocPPatch<D, R, PTypeDoc extends PhysicsTypeDocRepo<D, R>, PW extends IPhysicsWorldComponent<D, R, PTypeDoc> | null> = Omit<GgWorldSceneTypeRepo<D, R>, 'physicsWorld'> & {
|
|
33
|
+
physicsWorld: PW;
|
|
34
|
+
};
|
|
35
|
+
export declare abstract class GgWorld<D, R, TypeDoc extends GgWorldTypeDocRepo<D, R> = GgWorldTypeDocRepo<D, R>, SceneTypeDoc extends GgWorldSceneTypeRepo<D, R, TypeDoc> = GgWorldSceneTypeRepo<D, R, TypeDoc>> {
|
|
17
36
|
private static default_name_counter;
|
|
18
37
|
private static _documentWorlds;
|
|
19
38
|
static readonly worldCreated$: Subject<GgWorld<any, any>>;
|
|
20
39
|
static get documentWorlds(): GgWorld<any, any>[];
|
|
40
|
+
readonly visualScene: SceneTypeDoc['visualScene'];
|
|
41
|
+
readonly physicsWorld: SceneTypeDoc['physicsWorld'];
|
|
21
42
|
readonly worldClock: PausableClock;
|
|
22
43
|
readonly keyboardInput: KeyboardInput;
|
|
23
44
|
name: string;
|
|
24
45
|
readonly children: IEntity[];
|
|
25
46
|
protected readonly tickListeners: IEntity[];
|
|
47
|
+
get renderers(): IRendererEntity<D, R>[];
|
|
26
48
|
readonly tickStarted$: Subject<void>;
|
|
27
49
|
readonly tickForwardTo$: Subject<IEntity | 'PHYSICS_WORLD'>;
|
|
28
50
|
readonly tickForwardedTo$: Subject<IEntity | 'PHYSICS_WORLD'>;
|
|
29
51
|
readonly paused$: Subject<boolean>;
|
|
30
52
|
readonly disposed$: Subject<void>;
|
|
31
|
-
protected constructor(
|
|
53
|
+
protected constructor(args: {
|
|
54
|
+
visualScene?: SceneTypeDoc['visualScene'];
|
|
55
|
+
physicsWorld?: SceneTypeDoc['physicsWorld'];
|
|
56
|
+
});
|
|
32
57
|
init(): Promise<void>;
|
|
33
58
|
start(): void;
|
|
34
59
|
pauseWorld(): void;
|
|
@@ -39,7 +64,7 @@ export declare abstract class GgWorld<D, R, VTypeDoc extends VisualTypeDocRepo<D
|
|
|
39
64
|
createClock(autoStart: boolean): PausableClock;
|
|
40
65
|
dispose(): void;
|
|
41
66
|
abstract addPrimitiveRigidBody(descr: unknown, // type defined in subclasses
|
|
42
|
-
position?: D, rotation?: R, material?: unknown): IPositionable<D, R> & IRenderableEntity<D, R,
|
|
67
|
+
position?: D, rotation?: R, material?: unknown): IPositionable<D, R> & IRenderableEntity<D, R, TypeDoc>;
|
|
43
68
|
addEntity(entity: IEntity): void;
|
|
44
69
|
removeEntity(entity: IEntity, dispose?: boolean): void;
|
|
45
70
|
private onGgStaticInitialized;
|
package/dist/base/gg-world.js
CHANGED
|
@@ -14,9 +14,10 @@ export class GgWorld {
|
|
|
14
14
|
static get documentWorlds() {
|
|
15
15
|
return [...GgWorld._documentWorlds];
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
|
|
17
|
+
get renderers() {
|
|
18
|
+
return this.tickListeners.filter(e => e instanceof IRendererEntity);
|
|
19
|
+
}
|
|
20
|
+
constructor(args) {
|
|
20
21
|
this.worldClock = new PausableClock(false);
|
|
21
22
|
this.keyboardInput = new KeyboardInput();
|
|
22
23
|
this.name = 'w0x' + (GgWorld.default_name_counter++).toString(16);
|
|
@@ -29,6 +30,8 @@ export class GgWorld {
|
|
|
29
30
|
this.tickForwardedTo$ = new Subject();
|
|
30
31
|
this.paused$ = new Subject();
|
|
31
32
|
this.disposed$ = new Subject();
|
|
33
|
+
this.visualScene = args.visualScene || null;
|
|
34
|
+
this.physicsWorld = args.physicsWorld || null;
|
|
32
35
|
this.keyboardInput.start();
|
|
33
36
|
if (window.ggstatic) {
|
|
34
37
|
this.registerConsoleCommands(window.ggstatic);
|
|
@@ -43,7 +46,14 @@ export class GgWorld {
|
|
|
43
46
|
}
|
|
44
47
|
init() {
|
|
45
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
|
|
49
|
+
const initPromises = [];
|
|
50
|
+
if (this.visualScene) {
|
|
51
|
+
initPromises.push(this.visualScene.init());
|
|
52
|
+
}
|
|
53
|
+
if (this.physicsWorld) {
|
|
54
|
+
initPromises.push(this.physicsWorld.init());
|
|
55
|
+
}
|
|
56
|
+
yield Promise.all(initPromises);
|
|
47
57
|
const forwardTick = (listener, elapsed, delta) => {
|
|
48
58
|
if (listener.active) {
|
|
49
59
|
this.tickForwardTo$.next(listener);
|
|
@@ -62,9 +72,11 @@ export class GgWorld {
|
|
|
62
72
|
forwardTick(this.tickListeners[i], elapsed, delta);
|
|
63
73
|
}
|
|
64
74
|
// run physics simulation
|
|
65
|
-
this.
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
if (this.physicsWorld) {
|
|
76
|
+
this.tickForwardTo$.next('PHYSICS_WORLD');
|
|
77
|
+
this.physicsWorld.simulate(delta);
|
|
78
|
+
this.tickForwardedTo$.next('PHYSICS_WORLD');
|
|
79
|
+
}
|
|
68
80
|
// emit tick to all remained entities
|
|
69
81
|
for (i; i < this.tickListeners.length; i++) {
|
|
70
82
|
forwardTick(this.tickListeners[i], elapsed, delta);
|
|
@@ -111,8 +123,12 @@ export class GgWorld {
|
|
|
111
123
|
}
|
|
112
124
|
this.children.splice(0, this.children.length);
|
|
113
125
|
this.tickListeners.splice(0, this.tickListeners.length);
|
|
114
|
-
this.physicsWorld
|
|
115
|
-
|
|
126
|
+
if (this.physicsWorld) {
|
|
127
|
+
this.physicsWorld.dispose();
|
|
128
|
+
}
|
|
129
|
+
if (this.visualScene) {
|
|
130
|
+
this.visualScene.dispose();
|
|
131
|
+
}
|
|
116
132
|
GgWorld._documentWorlds.splice(GgWorld._documentWorlds.indexOf(this), 1);
|
|
117
133
|
this.disposed$.next();
|
|
118
134
|
this.disposed$.complete();
|
|
@@ -159,10 +175,7 @@ export class GgWorld {
|
|
|
159
175
|
return this.worldClock.tickRateLimit.toString();
|
|
160
176
|
}), 'args: [ int? ]; Get current tick rate limit of selected world clock or set it. 0 means no limit applied');
|
|
161
177
|
ggstatic.registerConsoleCommand(this, 'renderers', () => __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
return this.
|
|
163
|
-
.filter(e => e instanceof IRendererEntity)
|
|
164
|
-
.map(r => r.name)
|
|
165
|
-
.join('\n');
|
|
178
|
+
return this.renderers.map(r => r.name).join('\n');
|
|
166
179
|
}), 'no args; Print all renderers in selected world');
|
|
167
180
|
ggstatic.registerConsoleCommand(this, 'debug_view', (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
168
181
|
let value = 'toggle';
|
|
@@ -175,7 +188,7 @@ export class GgWorld {
|
|
|
175
188
|
rendererName = arg;
|
|
176
189
|
}
|
|
177
190
|
}
|
|
178
|
-
let renderer = this.
|
|
191
|
+
let renderer = rendererName ? this.renderers.find(x => x.name === rendererName) : this.renderers[0];
|
|
179
192
|
if (renderer) {
|
|
180
193
|
renderer.physicsDebugViewActive = value === 'toggle' ? !renderer.physicsDebugViewActive : value;
|
|
181
194
|
return renderer.physicsDebugViewActive ? '1' : '0';
|
package/dist/base/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export * from './models/axis-directions';
|
|
|
26
26
|
export * from './models/body-options';
|
|
27
27
|
export * from './models/geometry-nodes';
|
|
28
28
|
export * from './models/points';
|
|
29
|
+
export * from './models/raycasting';
|
|
29
30
|
export * from './math/box';
|
|
30
31
|
export * from './math/point2';
|
|
31
32
|
export * from './math/point3';
|
package/dist/base/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export * from './models/axis-directions';
|
|
|
26
26
|
export * from './models/body-options';
|
|
27
27
|
export * from './models/geometry-nodes';
|
|
28
28
|
export * from './models/points';
|
|
29
|
+
export * from './models/raycasting';
|
|
29
30
|
export * from './math/box';
|
|
30
31
|
export * from './math/point2';
|
|
31
32
|
export * from './math/point3';
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export declare const averageAngle: (angleA: number, angleB: number
|
|
1
|
+
export declare const averageAngle: (angleA: number, angleB: number) => number;
|
|
2
|
+
export declare const lerpAngle: (angleA: number, angleB: number, factor: number) => number;
|
|
2
3
|
export declare const lerpNumber: (a: number, b: number, t: number) => number;
|