#12 initial commit
This commit is contained in:
@@ -17,6 +17,7 @@ import { DashBoard } from './Dashboard.js';
|
||||
import { MotionEngine } from './MotionEngine.js';
|
||||
import { Draggable } from './Draggable.js';
|
||||
import { EventManager } from "./EventManager";
|
||||
import { Telemetry } from './Telemetry.js';
|
||||
|
||||
THREE.Cache.enabled = true
|
||||
|
||||
@@ -130,6 +131,10 @@ class GameEngine extends EventManager{
|
||||
this.gizmo = gizmo;
|
||||
}
|
||||
|
||||
if (opts.telemetry){
|
||||
this.tm = new Telemetry(opts.telemetry, opts.mode);
|
||||
}
|
||||
|
||||
this.orbitControls = controls;
|
||||
controls.enableZoom = false;
|
||||
//const controls = new MapControls( camera, renderer.domElement );
|
||||
@@ -588,6 +593,7 @@ class GameEngine extends EventManager{
|
||||
this.clickable.removeAll();
|
||||
this.motionQueue.clearAll();
|
||||
this.ambientSound.stop();
|
||||
this.tm?.setScene(null);
|
||||
}
|
||||
|
||||
async playAmbientSound(source, path){
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
class Telemetry {
|
||||
game = null;
|
||||
scene = null;
|
||||
gameObject = null;
|
||||
#af = null;
|
||||
|
||||
constructor(apiFunction, mode){
|
||||
this.events = [];
|
||||
this.#af = apiFunction;
|
||||
}
|
||||
setGame(game){
|
||||
if (this.game == game) { return; }
|
||||
if (this.game){
|
||||
this.#af('game:leave', this.game, {game: this.game, duration: Math.round(performance.now()/1000) - this.gameStart});
|
||||
}
|
||||
if (game){
|
||||
this.#af('game:enter', game, {game});
|
||||
}
|
||||
this.game = game;
|
||||
this.gameStart = Math.round(performance.now()/1000);
|
||||
}
|
||||
setScene(scene){
|
||||
if (this.scene == scene) { return; }
|
||||
if (this.scene){
|
||||
this.#af('scene:leave', this.scene, {
|
||||
duration: Math.round(performance.now()/1000) - this.sceneStart,
|
||||
game: this.game, scene: this.scene
|
||||
});
|
||||
}
|
||||
if (scene){
|
||||
this.#af('scene:enter', scene, {game: this.game, scene});
|
||||
}
|
||||
this.scene = scene;
|
||||
this.sceneStart = Math.round(performance.now()/1000);
|
||||
}
|
||||
setGameObject(gameObject){
|
||||
if (this.gameObject == gameObject) { return; }
|
||||
if (this.gameObject){
|
||||
this.#af('gameobject:leave', this.gameObject, {
|
||||
duration: Math.round(performance.now()/1000) - this.gameObjectStart,
|
||||
game: this.game, scene: this.scene, gameObject: this.gameObject
|
||||
});
|
||||
}
|
||||
if (gameObject){
|
||||
this.#af('gameobject:enter', gameObject, {game: this.game, scene: this.scene, gameObject});
|
||||
}
|
||||
this.gameObject = gameObject;
|
||||
this.gameObjectStart = Math.round(performance.now()/1000);
|
||||
}
|
||||
post(action, object, data){
|
||||
this.#af('gameobject:' + action, object, {game: this.game, scene: this.scene, gameObject: this.gameObject, data});
|
||||
}
|
||||
}
|
||||
|
||||
export { Telemetry }
|
||||
Reference in New Issue
Block a user