@gg-web-engine/core 0.0.57 → 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/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 +3 -3
- package/dist/3d/entities/surface-following.entity.js +3 -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/loader.d.ts +12 -12
- package/dist/3d/loader.js +6 -5
- package/dist/3d/loaders.d.ts +4 -4
- package/dist/base/components/i-world-component.d.ts +5 -5
- package/dist/base/components/physics/i-body.component.d.ts +5 -5
- package/dist/base/components/physics/i-physics-world.component.d.ts +13 -5
- 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/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 +29 -5
- package/dist/base/gg-world.js +22 -9
- 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 +17 -1
- package/dist/base/math/point2.js +35 -0
- package/dist/base/math/point3.d.ts +2 -0
- package/dist/base/math/point3.js +15 -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/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/base/gg-world.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
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,13 +12,33 @@ 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;
|
|
@@ -29,7 +50,10 @@ export declare abstract class GgWorld<D, R, VTypeDoc extends VisualTypeDocRepo<D
|
|
|
29
50
|
readonly tickForwardedTo$: Subject<IEntity | 'PHYSICS_WORLD'>;
|
|
30
51
|
readonly paused$: Subject<boolean>;
|
|
31
52
|
readonly disposed$: Subject<void>;
|
|
32
|
-
protected constructor(
|
|
53
|
+
protected constructor(args: {
|
|
54
|
+
visualScene?: SceneTypeDoc['visualScene'];
|
|
55
|
+
physicsWorld?: SceneTypeDoc['physicsWorld'];
|
|
56
|
+
});
|
|
33
57
|
init(): Promise<void>;
|
|
34
58
|
start(): void;
|
|
35
59
|
pauseWorld(): void;
|
|
@@ -40,7 +64,7 @@ export declare abstract class GgWorld<D, R, VTypeDoc extends VisualTypeDocRepo<D
|
|
|
40
64
|
createClock(autoStart: boolean): PausableClock;
|
|
41
65
|
dispose(): void;
|
|
42
66
|
abstract addPrimitiveRigidBody(descr: unknown, // type defined in subclasses
|
|
43
|
-
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>;
|
|
44
68
|
addEntity(entity: IEntity): void;
|
|
45
69
|
removeEntity(entity: IEntity, dispose?: boolean): void;
|
|
46
70
|
private onGgStaticInitialized;
|
package/dist/base/gg-world.js
CHANGED
|
@@ -17,9 +17,7 @@ export class GgWorld {
|
|
|
17
17
|
get renderers() {
|
|
18
18
|
return this.tickListeners.filter(e => e instanceof IRendererEntity);
|
|
19
19
|
}
|
|
20
|
-
constructor(
|
|
21
|
-
this.visualScene = visualScene;
|
|
22
|
-
this.physicsWorld = physicsWorld;
|
|
20
|
+
constructor(args) {
|
|
23
21
|
this.worldClock = new PausableClock(false);
|
|
24
22
|
this.keyboardInput = new KeyboardInput();
|
|
25
23
|
this.name = 'w0x' + (GgWorld.default_name_counter++).toString(16);
|
|
@@ -32,6 +30,8 @@ export class GgWorld {
|
|
|
32
30
|
this.tickForwardedTo$ = new Subject();
|
|
33
31
|
this.paused$ = new Subject();
|
|
34
32
|
this.disposed$ = new Subject();
|
|
33
|
+
this.visualScene = args.visualScene || null;
|
|
34
|
+
this.physicsWorld = args.physicsWorld || null;
|
|
35
35
|
this.keyboardInput.start();
|
|
36
36
|
if (window.ggstatic) {
|
|
37
37
|
this.registerConsoleCommands(window.ggstatic);
|
|
@@ -46,7 +46,14 @@ export class GgWorld {
|
|
|
46
46
|
}
|
|
47
47
|
init() {
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
|
|
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);
|
|
50
57
|
const forwardTick = (listener, elapsed, delta) => {
|
|
51
58
|
if (listener.active) {
|
|
52
59
|
this.tickForwardTo$.next(listener);
|
|
@@ -65,9 +72,11 @@ export class GgWorld {
|
|
|
65
72
|
forwardTick(this.tickListeners[i], elapsed, delta);
|
|
66
73
|
}
|
|
67
74
|
// run physics simulation
|
|
68
|
-
this.
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
if (this.physicsWorld) {
|
|
76
|
+
this.tickForwardTo$.next('PHYSICS_WORLD');
|
|
77
|
+
this.physicsWorld.simulate(delta);
|
|
78
|
+
this.tickForwardedTo$.next('PHYSICS_WORLD');
|
|
79
|
+
}
|
|
71
80
|
// emit tick to all remained entities
|
|
72
81
|
for (i; i < this.tickListeners.length; i++) {
|
|
73
82
|
forwardTick(this.tickListeners[i], elapsed, delta);
|
|
@@ -114,8 +123,12 @@ export class GgWorld {
|
|
|
114
123
|
}
|
|
115
124
|
this.children.splice(0, this.children.length);
|
|
116
125
|
this.tickListeners.splice(0, this.tickListeners.length);
|
|
117
|
-
this.physicsWorld
|
|
118
|
-
|
|
126
|
+
if (this.physicsWorld) {
|
|
127
|
+
this.physicsWorld.dispose();
|
|
128
|
+
}
|
|
129
|
+
if (this.visualScene) {
|
|
130
|
+
this.visualScene.dispose();
|
|
131
|
+
}
|
|
119
132
|
GgWorld._documentWorlds.splice(GgWorld._documentWorlds.indexOf(this), 1);
|
|
120
133
|
this.disposed$.next();
|
|
121
134
|
this.disposed$.complete();
|
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;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
export const averageAngle = (angleA, angleB
|
|
1
|
+
export const averageAngle = (angleA, angleB) => {
|
|
2
|
+
while (Math.abs(angleA - angleB) > Math.PI) {
|
|
3
|
+
angleB += Math.PI * (angleA > angleB ? 2 : -2);
|
|
4
|
+
}
|
|
5
|
+
return (angleA + angleB) / 2;
|
|
6
|
+
};
|
|
7
|
+
export const lerpAngle = (angleA, angleB, factor) => {
|
|
2
8
|
while (Math.abs(angleA - angleB) > Math.PI) {
|
|
3
9
|
angleB += Math.PI * (angleA > angleB ? 2 : -2);
|
|
4
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Point2 } from '../models/points';
|
|
1
|
+
import { Point2, Polar } from '../models/points';
|
|
2
2
|
export declare class Pnt2 {
|
|
3
3
|
/** empty vector */
|
|
4
4
|
static get O(): Point2;
|
|
@@ -40,10 +40,26 @@ export declare class Pnt2 {
|
|
|
40
40
|
static dot(a: Point2, b: Point2): number;
|
|
41
41
|
/** linear interpolation */
|
|
42
42
|
static lerp(a: Point2, b: Point2, t: number): Point2;
|
|
43
|
+
/** linear interpolation (spherical/polar) */
|
|
44
|
+
static slerp(a: Point2, b: Point2, t: number): Point2;
|
|
43
45
|
/** angle between vectors in radians */
|
|
44
46
|
static angle(a: Point2, b: Point2): number;
|
|
45
47
|
/** rotate point around zero by provided angle */
|
|
46
48
|
static rot(p: Point2, angle: number): Point2;
|
|
47
49
|
/** rotate point around pivot by provided angle */
|
|
48
50
|
static rotAround(p: Point2, pivot: Point2, angle: number): Point2;
|
|
51
|
+
/**
|
|
52
|
+
* Converts a cartesian 2D point to a polar coordinate system,
|
|
53
|
+
* phi == 0 is faced towards X axis direction
|
|
54
|
+
* @param p - The cartesian 2D point.
|
|
55
|
+
* @returns The polar coordinates as an object with radius and phi properties.
|
|
56
|
+
*/
|
|
57
|
+
static toPolar(p: Point2): Polar;
|
|
58
|
+
/**
|
|
59
|
+
* Converts a polar coordinate system to a cartesian 2D point. Used polar coordinates,
|
|
60
|
+
* where phi == 0 is faced towards X axis direction
|
|
61
|
+
* @param p - The polar coordinate system.
|
|
62
|
+
* @returns The cartesian 2D point as an object with x and y properties.
|
|
63
|
+
*/
|
|
64
|
+
static fromPolar(p: Polar): Point2;
|
|
49
65
|
}
|
package/dist/base/math/point2.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lerpAngle } from './numbers';
|
|
1
2
|
export class Pnt2 {
|
|
2
3
|
/** empty vector */
|
|
3
4
|
static get O() {
|
|
@@ -89,6 +90,15 @@ export class Pnt2 {
|
|
|
89
90
|
y: a.y + t * (b.y - a.y),
|
|
90
91
|
};
|
|
91
92
|
}
|
|
93
|
+
/** linear interpolation (spherical/polar) */
|
|
94
|
+
static slerp(a, b, t) {
|
|
95
|
+
const as = Pnt2.toPolar(a);
|
|
96
|
+
const bs = Pnt2.toPolar(b);
|
|
97
|
+
return Pnt2.fromPolar({
|
|
98
|
+
radius: as.radius + t * (bs.radius - as.radius),
|
|
99
|
+
phi: lerpAngle(as.phi, bs.phi, t),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
92
102
|
/** angle between vectors in radians */
|
|
93
103
|
static angle(a, b) {
|
|
94
104
|
const magnitudeProduct = Pnt2.len(a) * Pnt2.len(b);
|
|
@@ -113,4 +123,29 @@ export class Pnt2 {
|
|
|
113
123
|
y: p0.x * sin + p0.y * cos + pivot.y,
|
|
114
124
|
};
|
|
115
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Converts a cartesian 2D point to a polar coordinate system,
|
|
128
|
+
* phi == 0 is faced towards X axis direction
|
|
129
|
+
* @param p - The cartesian 2D point.
|
|
130
|
+
* @returns The polar coordinates as an object with radius and phi properties.
|
|
131
|
+
*/
|
|
132
|
+
static toPolar(p) {
|
|
133
|
+
const radius = Math.sqrt(p.x * p.x + p.y * p.y);
|
|
134
|
+
return {
|
|
135
|
+
radius,
|
|
136
|
+
phi: radius == 0 ? 0 : Math.atan2(p.y, p.x),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Converts a polar coordinate system to a cartesian 2D point. Used polar coordinates,
|
|
141
|
+
* where phi == 0 is faced towards X axis direction
|
|
142
|
+
* @param p - The polar coordinate system.
|
|
143
|
+
* @returns The cartesian 2D point as an object with x and y properties.
|
|
144
|
+
*/
|
|
145
|
+
static fromPolar(p) {
|
|
146
|
+
return {
|
|
147
|
+
x: p.radius * Math.cos(p.phi),
|
|
148
|
+
y: p.radius * Math.sin(p.phi),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
116
151
|
}
|
|
@@ -46,6 +46,8 @@ export declare class Pnt3 {
|
|
|
46
46
|
static dot(a: Point3, b: Point3): number;
|
|
47
47
|
/** linear interpolation */
|
|
48
48
|
static lerp(a: Point3, b: Point3, t: number): Point3;
|
|
49
|
+
/** linear interpolation (spherical) */
|
|
50
|
+
static slerp(a: Point3, b: Point3, t: number): Point3;
|
|
49
51
|
/** angle between vectors in radians */
|
|
50
52
|
static angle(a: Point3, b: Point3): number;
|
|
51
53
|
/** rotate point a with quaternion q */
|
package/dist/base/math/point3.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Qtrn } from './quaternion';
|
|
2
|
+
import { lerpAngle } from './numbers';
|
|
2
3
|
export class Pnt3 {
|
|
3
4
|
/** empty vector */
|
|
4
5
|
static get O() {
|
|
@@ -114,10 +115,23 @@ export class Pnt3 {
|
|
|
114
115
|
z: a.z + t * (b.z - a.z),
|
|
115
116
|
};
|
|
116
117
|
}
|
|
118
|
+
/** linear interpolation (spherical) */
|
|
119
|
+
static slerp(a, b, t) {
|
|
120
|
+
const as = Pnt3.toSpherical(a);
|
|
121
|
+
const bs = Pnt3.toSpherical(b);
|
|
122
|
+
return Pnt3.fromSpherical({
|
|
123
|
+
radius: as.radius + t * (bs.radius - as.radius),
|
|
124
|
+
phi: lerpAngle(as.phi, bs.phi, t),
|
|
125
|
+
theta: lerpAngle(as.theta, bs.theta, t),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
117
128
|
/** angle between vectors in radians */
|
|
118
129
|
static angle(a, b) {
|
|
119
130
|
const magnitudeProduct = Pnt3.len(a) * Pnt3.len(b);
|
|
120
|
-
|
|
131
|
+
let cos = Pnt3.dot(a, b) / magnitudeProduct;
|
|
132
|
+
// this can happen due to precision error
|
|
133
|
+
cos = Math.min(1, Math.max(cos, -1));
|
|
134
|
+
return Math.acos(cos);
|
|
121
135
|
}
|
|
122
136
|
/** rotate point a with quaternion q */
|
|
123
137
|
static rot(p, q) {
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export type MutablePoint2 = {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
4
|
};
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export type MutablePoint3 = {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
z: number;
|
|
9
9
|
};
|
|
10
|
-
export type
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
export type MutablePoint4 = {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
z: number;
|
|
14
|
+
w: number;
|
|
15
15
|
};
|
|
16
|
-
export type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
readonly theta: number;
|
|
16
|
+
export type MutablePolar = {
|
|
17
|
+
radius: number;
|
|
18
|
+
phi: number;
|
|
20
19
|
};
|
|
21
20
|
export type MutableSpherical = {
|
|
22
21
|
radius: number;
|
|
23
22
|
phi: number;
|
|
24
23
|
theta: number;
|
|
25
24
|
};
|
|
25
|
+
export type Point2 = Readonly<MutablePoint2>;
|
|
26
|
+
export type Point3 = Readonly<MutablePoint3>;
|
|
27
|
+
export type Point4 = Readonly<MutablePoint4>;
|
|
28
|
+
export type Polar = Readonly<MutablePolar>;
|
|
29
|
+
export type Spherical = Readonly<MutableSpherical>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CollisionGroup } from './body-options';
|
|
2
|
+
/**
|
|
3
|
+
* Interface representing the result of a raycast operation.
|
|
4
|
+
*
|
|
5
|
+
* @template D - Data type used for representing physics properties (Point3 for 3D, Point2 for 2D).
|
|
6
|
+
* @template B - Type representing the physics engine's body object.
|
|
7
|
+
*/
|
|
8
|
+
export interface RaycastResult<D, B> {
|
|
9
|
+
/**
|
|
10
|
+
* Whether the ray hit something.
|
|
11
|
+
*/
|
|
12
|
+
hasHit: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The hit body, if any.
|
|
15
|
+
*/
|
|
16
|
+
hitBody?: B;
|
|
17
|
+
/**
|
|
18
|
+
* The hit point in world space, if any.
|
|
19
|
+
*/
|
|
20
|
+
hitPoint?: D;
|
|
21
|
+
/**
|
|
22
|
+
* The hit normal in world space, if any.
|
|
23
|
+
*/
|
|
24
|
+
hitNormal?: D;
|
|
25
|
+
/**
|
|
26
|
+
* The distance from the ray origin to the hit point, if any.
|
|
27
|
+
*/
|
|
28
|
+
hitDistance?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Interface representing options for a raycast operation.
|
|
32
|
+
*
|
|
33
|
+
* @template D - Data type used for representing physics properties (typically Point3 for 3D).
|
|
34
|
+
*/
|
|
35
|
+
export interface RaycastOptions<D> {
|
|
36
|
+
/**
|
|
37
|
+
* The starting point of the ray.
|
|
38
|
+
*/
|
|
39
|
+
from: D;
|
|
40
|
+
/**
|
|
41
|
+
* The end point of the ray.
|
|
42
|
+
*/
|
|
43
|
+
to: D;
|
|
44
|
+
/**
|
|
45
|
+
* Optional collision filter groups for the ray.
|
|
46
|
+
*/
|
|
47
|
+
collisionFilterGroups?: CollisionGroup[];
|
|
48
|
+
/**
|
|
49
|
+
* Optional collision filter mask for the ray.
|
|
50
|
+
*/
|
|
51
|
+
collisionFilterMask?: CollisionGroup[];
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.0.
|
|
1
|
+
export declare const VERSION = "0.0.58";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.0.
|
|
1
|
+
export const VERSION = '0.0.58';
|