@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
|
@@ -7,7 +7,7 @@ import { Point2 } from '../models/points';
|
|
|
7
7
|
* canvas?: Canvas element. If not provided, mouse events will be listened on the whole window
|
|
8
8
|
* pointerLock: The flag to enable pointer lock when clicking on canvas
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type MouseInputOptions = {
|
|
11
11
|
canvas?: HTMLCanvasElement;
|
|
12
12
|
pointerLock: boolean;
|
|
13
13
|
};
|
|
@@ -59,6 +59,7 @@ export declare class MouseInput extends IInput<[], [unlockPointer?: boolean]> {
|
|
|
59
59
|
private _wheel$;
|
|
60
60
|
get wheel$(): Observable<number>;
|
|
61
61
|
get isPointerLocked(): boolean;
|
|
62
|
+
get isPointerLocked$(): Observable<boolean>;
|
|
62
63
|
private readonly options;
|
|
63
64
|
private _delta$;
|
|
64
65
|
private _position$;
|
|
@@ -35,24 +35,6 @@ export var MouseInputState;
|
|
|
35
35
|
* A class representing mouse input.
|
|
36
36
|
*/
|
|
37
37
|
export class MouseInput extends IInput {
|
|
38
|
-
/**
|
|
39
|
-
Creates an instance of MouseInput.
|
|
40
|
-
@param {MouseInputOptions} options - The options for the MouseInput.
|
|
41
|
-
*/
|
|
42
|
-
constructor(options = {}) {
|
|
43
|
-
super();
|
|
44
|
-
/**
|
|
45
|
-
An observable of the wheel scrolling.
|
|
46
|
-
*/
|
|
47
|
-
this._wheel$ = null;
|
|
48
|
-
this._delta$ = new Subject();
|
|
49
|
-
this._position$ = new BehaviorSubject(Pnt2.O);
|
|
50
|
-
this._multiTouchPositions$ = new BehaviorSubject([]);
|
|
51
|
-
this.stopped$ = new Subject();
|
|
52
|
-
this._state$ = new BehaviorSubject(MouseInputState.NONE);
|
|
53
|
-
this.options = Object.assign(Object.assign({}, DEFAULT_MOUSE_INPUT_OPTIONS), options);
|
|
54
|
-
this.canvasClickListener = this.canvasClickListener.bind(this);
|
|
55
|
-
}
|
|
56
38
|
static isTouchDevice() {
|
|
57
39
|
return ('createTouch' in document ||
|
|
58
40
|
!!navigator.userAgent.match(/(iPhone|iPod|iPad)/) ||
|
|
@@ -85,6 +67,9 @@ export class MouseInput extends IInput {
|
|
|
85
67
|
get isPointerLocked() {
|
|
86
68
|
return !!document.pointerLockElement;
|
|
87
69
|
}
|
|
70
|
+
get isPointerLocked$() {
|
|
71
|
+
return fromEvent(document, 'pointerlockchange').pipe(map(() => this.isPointerLocked));
|
|
72
|
+
}
|
|
88
73
|
get state() {
|
|
89
74
|
return this._state$.getValue();
|
|
90
75
|
}
|
|
@@ -104,6 +89,24 @@ export class MouseInput extends IInput {
|
|
|
104
89
|
get _element() {
|
|
105
90
|
return this.options.canvas || window;
|
|
106
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
Creates an instance of MouseInput.
|
|
94
|
+
@param {MouseInputOptions} options - The options for the MouseInput.
|
|
95
|
+
*/
|
|
96
|
+
constructor(options = {}) {
|
|
97
|
+
super();
|
|
98
|
+
/**
|
|
99
|
+
An observable of the wheel scrolling.
|
|
100
|
+
*/
|
|
101
|
+
this._wheel$ = null;
|
|
102
|
+
this._delta$ = new Subject();
|
|
103
|
+
this._position$ = new BehaviorSubject(Pnt2.O);
|
|
104
|
+
this._multiTouchPositions$ = new BehaviorSubject([]);
|
|
105
|
+
this.stopped$ = new Subject();
|
|
106
|
+
this._state$ = new BehaviorSubject(MouseInputState.NONE);
|
|
107
|
+
this.options = Object.assign(Object.assign({}, DEFAULT_MOUSE_INPUT_OPTIONS), options);
|
|
108
|
+
this.canvasClickListener = this.canvasClickListener.bind(this);
|
|
109
|
+
}
|
|
107
110
|
startInternal() {
|
|
108
111
|
if (this.options.canvas) {
|
|
109
112
|
this.options.canvas.style.touchAction = 'none';
|
|
File without changes
|
|
File without changes
|
package/dist/base/math/box.d.ts
CHANGED
|
File without changes
|
package/dist/base/math/box.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/base/math/point2.js
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/base/math/point3.js
CHANGED
|
File without changes
|
|
@@ -88,6 +88,12 @@ export declare class Qtrn {
|
|
|
88
88
|
* @returns a quaternion representing the rotation
|
|
89
89
|
*/
|
|
90
90
|
static fromMatrix4(m: number[]): Point4;
|
|
91
|
+
/**
|
|
92
|
+
* Converts a 3x3 rotation matrix into a quaternion
|
|
93
|
+
* @param m the matrix representing the rotation
|
|
94
|
+
* @returns a quaternion representing the rotation
|
|
95
|
+
*/
|
|
96
|
+
static fromMatrix3(m: number[][]): Point4;
|
|
91
97
|
/**
|
|
92
98
|
* Creates a quaternion from euler
|
|
93
99
|
* @param e the euler vector
|
|
@@ -178,6 +178,44 @@ export class Qtrn {
|
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Converts a 3x3 rotation matrix into a quaternion
|
|
183
|
+
* @param m the matrix representing the rotation
|
|
184
|
+
* @returns a quaternion representing the rotation
|
|
185
|
+
*/
|
|
186
|
+
static fromMatrix3(m) {
|
|
187
|
+
const trace = m[0][0] + m[1][1] + m[2][2];
|
|
188
|
+
let w, x, y, z;
|
|
189
|
+
if (trace > 0) {
|
|
190
|
+
const s = 0.5 / Math.sqrt(trace + 1);
|
|
191
|
+
w = 0.25 / s;
|
|
192
|
+
x = (m[2][1] - m[1][2]) * s;
|
|
193
|
+
y = (m[0][2] - m[2][0]) * s;
|
|
194
|
+
z = (m[1][0] - m[0][1]) * s;
|
|
195
|
+
}
|
|
196
|
+
else if (m[0][0] > m[1][1] && m[0][0] > m[2][2]) {
|
|
197
|
+
const s = 2 * Math.sqrt(1 + m[0][0] - m[1][1] - m[2][2]);
|
|
198
|
+
w = (m[2][1] - m[1][2]) / s;
|
|
199
|
+
x = 0.25 * s;
|
|
200
|
+
y = (m[0][1] + m[1][0]) / s;
|
|
201
|
+
z = (m[0][2] + m[2][0]) / s;
|
|
202
|
+
}
|
|
203
|
+
else if (m[1][1] > m[2][2]) {
|
|
204
|
+
const s = 2 * Math.sqrt(1 + m[1][1] - m[0][0] - m[2][2]);
|
|
205
|
+
w = (m[0][2] - m[2][0]) / s;
|
|
206
|
+
x = (m[0][1] + m[1][0]) / s;
|
|
207
|
+
y = 0.25 * s;
|
|
208
|
+
z = (m[1][2] + m[2][1]) / s;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
const s = 2 * Math.sqrt(1 + m[2][2] - m[0][0] - m[1][1]);
|
|
212
|
+
w = (m[1][0] - m[0][1]) / s;
|
|
213
|
+
x = (m[0][2] + m[2][0]) / s;
|
|
214
|
+
y = (m[1][2] + m[2][1]) / s;
|
|
215
|
+
z = 0.25 * s;
|
|
216
|
+
}
|
|
217
|
+
return { w, x, y, z };
|
|
218
|
+
}
|
|
181
219
|
/**
|
|
182
220
|
* Creates a quaternion from euler
|
|
183
221
|
* @param e the euler vector
|
|
File without changes
|
|
File without changes
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export type AxisDirection2 = 'x' | 'y' | '-x' | '-y';
|
|
2
|
+
export type AxisDirection3 = AxisDirection2 | 'z' | '-z';
|
|
3
|
+
export type AxisDirection4 = AxisDirection3 | 'w' | '-w';
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type CollisionGroup = number;
|
|
2
2
|
export interface BodyOptions {
|
|
3
3
|
dynamic: boolean;
|
|
4
4
|
mass: number;
|
|
@@ -7,7 +7,7 @@ export interface BodyOptions {
|
|
|
7
7
|
ownCollisionGroups: CollisionGroup[] | 'all';
|
|
8
8
|
interactWithCollisionGroups: CollisionGroup[] | 'all';
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export type DebugBodySettings = {
|
|
11
11
|
shape: any;
|
|
12
12
|
ignoreTransform?: boolean;
|
|
13
13
|
} & ({
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Point2, Point3 } from './points';
|
|
2
|
-
export
|
|
2
|
+
export type GgBox<T> = {
|
|
3
3
|
min: T;
|
|
4
4
|
max: T;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
7
|
-
export
|
|
6
|
+
export type GgBox2d = GgBox<Point2>;
|
|
7
|
+
export type GgBox3d = GgBox<Point3>;
|
|
File without changes
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Point2 = {
|
|
2
2
|
readonly x: number;
|
|
3
3
|
readonly y: number;
|
|
4
4
|
};
|
|
5
|
-
export
|
|
5
|
+
export type Point3 = {
|
|
6
6
|
readonly x: number;
|
|
7
7
|
readonly y: number;
|
|
8
8
|
readonly z: number;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type Point4 = {
|
|
11
11
|
readonly x: number;
|
|
12
12
|
readonly y: number;
|
|
13
13
|
readonly z: number;
|
|
14
14
|
readonly w: number;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type Spherical = {
|
|
17
17
|
readonly radius: number;
|
|
18
18
|
readonly phi: number;
|
|
19
19
|
readonly theta: number;
|
|
20
20
|
};
|
|
21
|
-
export
|
|
21
|
+
export type MutableSpherical = {
|
|
22
22
|
radius: number;
|
|
23
23
|
phi: number;
|
|
24
24
|
theta: number;
|
|
File without changes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Observable, OperatorFunction } from 'rxjs';
|
|
2
|
+
export declare function ggElastic<T>(tick$: Observable<[number, number]>, // [elapsed, delta]
|
|
3
|
+
elasticity: number, // Elasticity parameter
|
|
4
|
+
mix: (a: T, b: T, factor: number) => T, // Mixing function
|
|
5
|
+
equals: (a: T, b: T) => boolean): OperatorFunction<T, T>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { filter, map, scan, switchMap } from 'rxjs';
|
|
2
|
+
export function ggElastic(tick$, // [elapsed, delta]
|
|
3
|
+
elasticity, // Elasticity parameter
|
|
4
|
+
mix, // Mixing function
|
|
5
|
+
equals) {
|
|
6
|
+
return (source$) => {
|
|
7
|
+
return source$.pipe(
|
|
8
|
+
// Track the target value
|
|
9
|
+
scan((acc, newValue) => {
|
|
10
|
+
var _a;
|
|
11
|
+
return ({
|
|
12
|
+
targetValue: newValue,
|
|
13
|
+
currentValue: (_a = acc.currentValue) !== null && _a !== void 0 ? _a : newValue, // Initialize to the first value on startup
|
|
14
|
+
hasReachedTarget: false, // Reset reach status on new target
|
|
15
|
+
});
|
|
16
|
+
}, { targetValue: null, currentValue: null, hasReachedTarget: false }),
|
|
17
|
+
// Switch to using tick$ for timing, emitting interpolated values with each tick
|
|
18
|
+
switchMap(state => tick$.pipe(map(([_, delta]) => {
|
|
19
|
+
if (state.targetValue === null || state.currentValue === null) {
|
|
20
|
+
return state.currentValue; // If we have no values, output nothing
|
|
21
|
+
}
|
|
22
|
+
// Skip processing if we’ve reached the target and stop emitting
|
|
23
|
+
if (state.hasReachedTarget) {
|
|
24
|
+
return undefined; // Stop emitting by returning `undefined`
|
|
25
|
+
}
|
|
26
|
+
// Adjust factor based on elasticity and delta time
|
|
27
|
+
const factor = 1 - Math.exp(-delta / elasticity);
|
|
28
|
+
// Blend halfway towards the target on each tick
|
|
29
|
+
const newInterpolatedValue = mix(state.currentValue, state.targetValue, factor);
|
|
30
|
+
// Update the currentValue to the new interpolated position
|
|
31
|
+
state.currentValue = newInterpolatedValue;
|
|
32
|
+
// Check if the interpolated value is "close enough" to the target
|
|
33
|
+
if (equals(newInterpolatedValue, state.targetValue)) {
|
|
34
|
+
state.hasReachedTarget = true; // Mark as reached
|
|
35
|
+
return state.targetValue; // Emit exact target value
|
|
36
|
+
}
|
|
37
|
+
return newInterpolatedValue;
|
|
38
|
+
}))),
|
|
39
|
+
// Filter out `undefined` emissions (to stop emitting when settled)
|
|
40
|
+
map(value => (value !== undefined ? value : null)),
|
|
41
|
+
// Remove `null` values (after stopping)
|
|
42
|
+
filter(value => value !== null));
|
|
43
|
+
};
|
|
44
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/dev/gg-static.d.ts
CHANGED
|
File without changes
|
package/dist/dev/gg-static.js
CHANGED
|
@@ -11,6 +11,52 @@ import { GgWorld } from '../base';
|
|
|
11
11
|
import { GgConsoleUI } from './gg-console.ui';
|
|
12
12
|
import { GgDebuggerUI } from './gg-debugger.ui';
|
|
13
13
|
export class GgStatic {
|
|
14
|
+
static get instance() {
|
|
15
|
+
if (!window.ggstatic) {
|
|
16
|
+
window.ggstatic = new GgStatic();
|
|
17
|
+
}
|
|
18
|
+
return window.ggstatic;
|
|
19
|
+
}
|
|
20
|
+
get devConsoleEnabled() {
|
|
21
|
+
return this._devConsoleEnabled;
|
|
22
|
+
}
|
|
23
|
+
set devConsoleEnabled(value) {
|
|
24
|
+
if (this._devConsoleEnabled === value) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this._devConsoleEnabled = value;
|
|
28
|
+
if (value) {
|
|
29
|
+
addEventListener('keypress', this.consoleKeyPressEventListener);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
removeEventListener('keypress', this.consoleKeyPressEventListener);
|
|
33
|
+
if (this.consoleUI.isUIShown) {
|
|
34
|
+
this.consoleUI.destroyUI();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
get showStats() {
|
|
39
|
+
return this.debuggerUI.showStats;
|
|
40
|
+
}
|
|
41
|
+
set showStats(value) {
|
|
42
|
+
this.debuggerUI.setShowStats(this.selectedWorld, value);
|
|
43
|
+
}
|
|
44
|
+
get showDebugControls() {
|
|
45
|
+
return this.debuggerUI.showDebugControls;
|
|
46
|
+
}
|
|
47
|
+
set showDebugControls(value) {
|
|
48
|
+
this.debuggerUI.setShowDebugControls(this.selectedWorld, value);
|
|
49
|
+
}
|
|
50
|
+
get selectedWorld() {
|
|
51
|
+
return this._selectedWorld || GgWorld.documentWorlds[0] || null;
|
|
52
|
+
}
|
|
53
|
+
get availableCommands() {
|
|
54
|
+
let commands = this.consoleCommands.get(null) || {};
|
|
55
|
+
if (this.selectedWorld) {
|
|
56
|
+
commands = Object.assign(Object.assign({}, (this.consoleCommands.get(this.selectedWorld) || {})), commands);
|
|
57
|
+
}
|
|
58
|
+
return Object.entries(commands);
|
|
59
|
+
}
|
|
14
60
|
constructor() {
|
|
15
61
|
this.debuggerUI = new GgDebuggerUI();
|
|
16
62
|
this.consoleUI = new GgConsoleUI();
|
|
@@ -58,52 +104,6 @@ export class GgStatic {
|
|
|
58
104
|
return '' + this.showStats;
|
|
59
105
|
}), 'args: [0 or 1]; turn on/off stats. Default value is 0');
|
|
60
106
|
}
|
|
61
|
-
static get instance() {
|
|
62
|
-
if (!window.ggstatic) {
|
|
63
|
-
window.ggstatic = new GgStatic();
|
|
64
|
-
}
|
|
65
|
-
return window.ggstatic;
|
|
66
|
-
}
|
|
67
|
-
get devConsoleEnabled() {
|
|
68
|
-
return this._devConsoleEnabled;
|
|
69
|
-
}
|
|
70
|
-
set devConsoleEnabled(value) {
|
|
71
|
-
if (this._devConsoleEnabled === value) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
this._devConsoleEnabled = value;
|
|
75
|
-
if (value) {
|
|
76
|
-
addEventListener('keypress', this.consoleKeyPressEventListener);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
removeEventListener('keypress', this.consoleKeyPressEventListener);
|
|
80
|
-
if (this.consoleUI.isUIShown) {
|
|
81
|
-
this.consoleUI.destroyUI();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
get showStats() {
|
|
86
|
-
return this.debuggerUI.showStats;
|
|
87
|
-
}
|
|
88
|
-
set showStats(value) {
|
|
89
|
-
this.debuggerUI.setShowStats(this.selectedWorld, value);
|
|
90
|
-
}
|
|
91
|
-
get showDebugControls() {
|
|
92
|
-
return this.debuggerUI.showDebugControls;
|
|
93
|
-
}
|
|
94
|
-
set showDebugControls(value) {
|
|
95
|
-
this.debuggerUI.setShowDebugControls(this.selectedWorld, value);
|
|
96
|
-
}
|
|
97
|
-
get selectedWorld() {
|
|
98
|
-
return this._selectedWorld || GgWorld.documentWorlds[0] || null;
|
|
99
|
-
}
|
|
100
|
-
get availableCommands() {
|
|
101
|
-
let commands = this.consoleCommands.get(null) || {};
|
|
102
|
-
if (this.selectedWorld) {
|
|
103
|
-
commands = Object.assign(Object.assign({}, (this.consoleCommands.get(this.selectedWorld) || {})), commands);
|
|
104
|
-
}
|
|
105
|
-
return Object.entries(commands);
|
|
106
|
-
}
|
|
107
107
|
registerConsoleCommand(world, command, handler, doc) {
|
|
108
108
|
let commands = {};
|
|
109
109
|
if (!this.consoleCommands.has(world)) {
|
package/dist/dev/index.d.ts
CHANGED
|
File without changes
|
package/dist/dev/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { IEntity } from '../base';
|
|
2
2
|
import { takeUntil } from 'rxjs';
|
|
3
3
|
export class PerformanceMeterEntity extends IEntity {
|
|
4
|
+
get avgReport() {
|
|
5
|
+
return this._avgReport;
|
|
6
|
+
}
|
|
7
|
+
get peakReport() {
|
|
8
|
+
return this._peakReport;
|
|
9
|
+
}
|
|
4
10
|
constructor(maxSamples = 60, maxRows = 15) {
|
|
5
11
|
super();
|
|
6
12
|
this.maxSamples = maxSamples;
|
|
@@ -11,12 +17,6 @@ export class PerformanceMeterEntity extends IEntity {
|
|
|
11
17
|
this._avgReport = { totalTime: 0, entries: [] };
|
|
12
18
|
this._peakReport = { totalTime: 0, entries: [] };
|
|
13
19
|
}
|
|
14
|
-
get avgReport() {
|
|
15
|
-
return this._avgReport;
|
|
16
|
-
}
|
|
17
|
-
get peakReport() {
|
|
18
|
-
return this._peakReport;
|
|
19
|
-
}
|
|
20
20
|
onSpawned(world) {
|
|
21
21
|
super.onSpawned(world);
|
|
22
22
|
this.sampleIndex = 0;
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gg-web-engine/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.49",
|
|
4
4
|
"description": "An attempt to create open source game engine for browser",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/jest": "^29.5.12",
|
|
35
|
-
"@types/stats.js": "^0.17.
|
|
36
|
-
"jest": "^29.
|
|
37
|
-
"jest-environment-jsdom": "^29.
|
|
38
|
-
"prettier": "^
|
|
39
|
-
"ts-jest": "^29.
|
|
40
|
-
"typescript": "~
|
|
35
|
+
"@types/stats.js": "^0.17.3",
|
|
36
|
+
"jest": "^29.7.0",
|
|
37
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
38
|
+
"prettier": "^3.3.3",
|
|
39
|
+
"ts-jest": "^29.2.4",
|
|
40
|
+
"typescript": "~5.5.4"
|
|
41
41
|
},
|
|
42
42
|
"jest": {
|
|
43
43
|
"moduleFileExtensions": [
|
package/tsconfig.json
CHANGED
|
File without changes
|