@gg-web-engine/core 0.0.48 → 0.0.56
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/entities/entity-2d.d.ts +6 -3
- package/dist/2d/entities/entity-2d.js +20 -17
- package/dist/2d/gg-2d-world.d.ts +3 -0
- package/dist/2d/gg-2d-world.js +21 -13
- package/dist/2d/models/shapes.d.ts +3 -1
- package/dist/3d/entities/controllers/input/car-keyboard-handling.controller.d.ts +1 -1
- package/dist/3d/entities/controllers/input/free-camera.controller.d.ts +32 -13
- package/dist/3d/entities/controllers/input/free-camera.controller.js +99 -45
- package/dist/3d/entities/controllers/input/gg-car-keyboard-handling.controller.d.ts +1 -1
- package/dist/3d/entities/controllers/input/orbit-camera.controller.d.ts +29 -9
- package/dist/3d/entities/controllers/input/orbit-camera.controller.js +64 -33
- package/dist/3d/entities/entity-3d.d.ts +6 -3
- package/dist/3d/entities/entity-3d.js +20 -17
- package/dist/3d/entities/raycast-vehicle-3d.entity.js +5 -5
- package/dist/3d/gg-3d-world.d.ts +3 -0
- package/dist/3d/gg-3d-world.js +21 -13
- package/dist/3d/loader.js +1 -1
- package/dist/3d/models/shapes.d.ts +3 -1
- package/dist/base/clock/global-clock.d.ts +2 -6
- package/dist/base/clock/global-clock.js +16 -16
- package/dist/base/clock/i-clock.d.ts +14 -5
- package/dist/base/clock/i-clock.js +43 -1
- package/dist/base/clock/pausable-clock.d.ts +3 -13
- package/dist/base/clock/pausable-clock.js +8 -16
- package/dist/base/gg-world.d.ts +6 -0
- package/dist/base/gg-world.js +102 -65
- package/dist/base/index.d.ts +1 -0
- package/dist/base/index.js +1 -0
- package/dist/base/inputs/keyboard.input.d.ts +1 -1
- package/dist/base/inputs/keyboard.input.js +10 -10
- package/dist/base/inputs/mouse.input.d.ts +1 -0
- package/dist/base/inputs/mouse.input.js +6 -2
- 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.js +14 -4
- package/dist/dev/gg-debugger.ui.d.ts +2 -2
- package/dist/dev/gg-debugger.ui.js +13 -10
- package/dist/dev/gg-static.d.ts +6 -1
- package/dist/dev/gg-static.js +104 -25
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/package.json +4 -3
package/dist/dev/gg-static.js
CHANGED
|
@@ -7,13 +7,14 @@ 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 { GgWorld } from '../base';
|
|
10
|
+
import { GgWorld, KeyboardInput } from '../base';
|
|
11
11
|
import { GgConsoleUI } from './gg-console.ui';
|
|
12
12
|
import { GgDebuggerUI } from './gg-debugger.ui';
|
|
13
|
+
import { BehaviorSubject, combineLatest, filter, fromEvent, NEVER, Subject, switchMap, take, takeUntil, takeWhile, } from 'rxjs';
|
|
13
14
|
export class GgStatic {
|
|
14
15
|
static get instance() {
|
|
15
16
|
if (!window.ggstatic) {
|
|
16
|
-
|
|
17
|
+
return new GgStatic();
|
|
17
18
|
}
|
|
18
19
|
return window.ggstatic;
|
|
19
20
|
}
|
|
@@ -35,25 +36,52 @@ export class GgStatic {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
}
|
|
39
|
+
toggleDevConsole(value) {
|
|
40
|
+
if (value === this.consoleUI.isUIShown)
|
|
41
|
+
return;
|
|
42
|
+
if (this.consoleUI.isUIShown) {
|
|
43
|
+
this.consoleUI.destroyUI();
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.consoleUI.createUI();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
38
49
|
get showStats() {
|
|
39
|
-
return this.
|
|
50
|
+
return this.showStats$.getValue();
|
|
40
51
|
}
|
|
41
52
|
set showStats(value) {
|
|
42
|
-
|
|
53
|
+
if (value === this.showStats)
|
|
54
|
+
return;
|
|
55
|
+
this.showStats$.next(value);
|
|
43
56
|
}
|
|
44
57
|
get showDebugControls() {
|
|
45
|
-
return this.
|
|
58
|
+
return this.showDebugControls$.getValue();
|
|
46
59
|
}
|
|
47
60
|
set showDebugControls(value) {
|
|
48
|
-
|
|
61
|
+
if (value === this.showDebugControls)
|
|
62
|
+
return;
|
|
63
|
+
this.showDebugControls$.next(value);
|
|
49
64
|
}
|
|
50
65
|
get selectedWorld() {
|
|
51
|
-
return this._selectedWorld
|
|
66
|
+
return this._selectedWorld$.getValue();
|
|
67
|
+
}
|
|
68
|
+
set selectedWorld(w) {
|
|
69
|
+
this._selectedWorld$.next(w);
|
|
70
|
+
}
|
|
71
|
+
autoAssignSelectedWorld() {
|
|
72
|
+
if (GgWorld.documentWorlds.length > 0) {
|
|
73
|
+
this.selectedWorld = GgWorld.documentWorlds[0];
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
GgWorld.worldCreated$
|
|
77
|
+
.pipe(takeWhile(() => !this.selectedWorld), take(1))
|
|
78
|
+
.subscribe(w => (this.selectedWorld = w));
|
|
79
|
+
}
|
|
52
80
|
}
|
|
53
81
|
get availableCommands() {
|
|
54
82
|
let commands = this.consoleCommands.get(null) || {};
|
|
55
83
|
if (this.selectedWorld) {
|
|
56
|
-
commands = Object.assign(Object.assign({}, (this.consoleCommands.get(this.selectedWorld) || {}))
|
|
84
|
+
commands = Object.assign(Object.assign({}, commands), (this.consoleCommands.get(this.selectedWorld) || {}));
|
|
57
85
|
}
|
|
58
86
|
return Object.entries(commands);
|
|
59
87
|
}
|
|
@@ -72,37 +100,88 @@ export class GgStatic {
|
|
|
72
100
|
}
|
|
73
101
|
}
|
|
74
102
|
};
|
|
75
|
-
this.
|
|
103
|
+
this.showStats$ = new BehaviorSubject(false);
|
|
104
|
+
this.showDebugControls$ = new BehaviorSubject(false);
|
|
105
|
+
this._selectedWorld$ = new BehaviorSubject(null);
|
|
76
106
|
this.consoleCommands = new Map();
|
|
77
|
-
this.registerConsoleCommand(null, '
|
|
107
|
+
this.registerConsoleCommand(null, 'commands', () => __awaiter(this, void 0, void 0, function* () {
|
|
78
108
|
return this.availableCommands
|
|
79
109
|
.map(([key, value]) => `<span style='color:yellow'>${key}</span>${value.doc ? '\t<span style="color:#aaa">// ' + value.doc + '</span>' : ''}`)
|
|
80
|
-
.sort()
|
|
81
110
|
.join('\n\n');
|
|
82
|
-
}), 'no args;
|
|
83
|
-
|
|
111
|
+
}), 'no args; Print all available commands. List includes global commands and commands, ' +
|
|
112
|
+
'specific to currently selected world. Run "world" to check which world is currently ' +
|
|
113
|
+
'selected and "world {world_name}" to select desired world');
|
|
114
|
+
this.registerConsoleCommand(null, 'help', (keyword) => __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
var _a;
|
|
116
|
+
const command = (_a = this.availableCommands.find(([key]) => key === keyword)) === null || _a === void 0 ? void 0 : _a[1];
|
|
117
|
+
if (!command) {
|
|
118
|
+
throw new Error(`Unrecognized command: ${keyword}`);
|
|
119
|
+
}
|
|
120
|
+
return `<span style='color:#aaa'>${command.doc || 'No doc string given'}</span>`;
|
|
121
|
+
}), 'args: [ string ]; Print doc string of provided command');
|
|
122
|
+
this.registerConsoleCommand(null, 'worlds', () => __awaiter(this, void 0, void 0, function* () {
|
|
84
123
|
return GgWorld.documentWorlds
|
|
85
124
|
.map(w => (w === this.selectedWorld ? `<span style='color:lightgreen;'>* ${w.name}</span>` : ` ${w.name}`))
|
|
86
125
|
.join('\n');
|
|
87
|
-
}), 'no args;
|
|
88
|
-
this.registerConsoleCommand(null, '
|
|
126
|
+
}), 'no args; Print all currently available worlds');
|
|
127
|
+
this.registerConsoleCommand(null, 'world', (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
89
128
|
var _a;
|
|
90
129
|
for (const w of GgWorld.documentWorlds) {
|
|
91
130
|
if (w.name === args[0]) {
|
|
92
|
-
this.
|
|
131
|
+
this.selectedWorld = w;
|
|
93
132
|
break;
|
|
94
133
|
}
|
|
95
134
|
}
|
|
96
135
|
return ((_a = this.selectedWorld) === null || _a === void 0 ? void 0 : _a.name) || 'null';
|
|
97
|
-
}), 'args: [string]; select world by name'
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
136
|
+
}), 'args: [ string? ]; Get name of selected world or select world by name. Use ' +
|
|
137
|
+
'"worlds" to get list of currently available worlds');
|
|
138
|
+
this.registerConsoleCommand(null, 'stats_panel', (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
this.showStats = args[0] === undefined ? !this.showStats : args[0] === '1';
|
|
140
|
+
return this.showStats ? '1' : '0';
|
|
141
|
+
}), 'args: [ 0|1? ]; Turn on/off stats panel, skip argument to toggle value');
|
|
142
|
+
this.registerConsoleCommand(null, 'debug_panel', (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
this.showDebugControls = args[0] === undefined ? !this.showDebugControls : args[0] === '1';
|
|
144
|
+
return this.showDebugControls ? '1' : '0';
|
|
145
|
+
}), 'args: [ 0|1? ]; Turn on/off debug panel, skip argument to toggle value');
|
|
146
|
+
let unbindKey$ = new Subject();
|
|
147
|
+
this.registerConsoleCommand(null, 'bind_key', (keyCode, command, ...args) => __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
fromEvent(window, 'keydown')
|
|
149
|
+
.pipe(takeUntil(unbindKey$.pipe(filter(x => x === keyCode))), filter(e => {
|
|
150
|
+
if (e.code !== keyCode) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
if (document.activeElement) {
|
|
154
|
+
for (const k of KeyboardInput.externalFocusBlacklist) {
|
|
155
|
+
if (document.activeElement instanceof k) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return true;
|
|
161
|
+
}))
|
|
162
|
+
.subscribe(() => {
|
|
163
|
+
this.runConsoleCommand(command, args);
|
|
164
|
+
});
|
|
165
|
+
return 'Ok';
|
|
166
|
+
}), 'args: [ string, ...string ]; Bind a keyboard key by code to console command. Check key codes' +
|
|
167
|
+
' <a target="_blank" rel="noopener noreferrer" href="https://www.toptal.com/developers/keycode">here</a>. Use "unbind_key" command to unbind it');
|
|
168
|
+
this.registerConsoleCommand(null, 'unbind_key', (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
unbindKey$.next(args[0]);
|
|
170
|
+
return 'Ok';
|
|
171
|
+
}), 'args: [ string ]; Unbind a keyboard key from console command');
|
|
172
|
+
window.ggstatic = this;
|
|
173
|
+
this.autoAssignSelectedWorld();
|
|
174
|
+
this._selectedWorld$.pipe(switchMap(w => (w ? w.disposed$ : NEVER))).subscribe(() => {
|
|
175
|
+
this.selectedWorld = null;
|
|
176
|
+
this.autoAssignSelectedWorld();
|
|
177
|
+
});
|
|
178
|
+
window.dispatchEvent(new Event('ggstatic_added'));
|
|
179
|
+
combineLatest([this._selectedWorld$, this.showDebugControls$]).subscribe(([world, showControls]) => {
|
|
180
|
+
this.debuggerUI.setShowDebugControls(world, !!world && showControls);
|
|
181
|
+
});
|
|
182
|
+
combineLatest([this._selectedWorld$, this.showStats$]).subscribe(([world, showStats]) => {
|
|
183
|
+
this.debuggerUI.setShowStats(world, !!world && showStats);
|
|
184
|
+
});
|
|
106
185
|
}
|
|
107
186
|
registerConsoleCommand(world, command, handler, doc) {
|
|
108
187
|
let commands = {};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "0.0.56";
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const VERSION = '0.0.56';
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gg-web-engine/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.56",
|
|
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",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "jest",
|
|
9
9
|
"prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
|
|
10
|
-
"prepublish": "rm -rf ./dist/ &&
|
|
11
|
-
"
|
|
10
|
+
"prepublish": "rm -rf ./dist/ && npm run build",
|
|
11
|
+
"update-version": "VERSION=$(grep '\"version\":' package.json | sed -E 's/.*\"version\": *\"([^\"]+)\".*/\\1/') && echo \"export const VERSION = '$VERSION';\" > src/version.ts",
|
|
12
|
+
"build": "npm run update-version && tsc"
|
|
12
13
|
},
|
|
13
14
|
"repository": {
|
|
14
15
|
"type": "git",
|