refactored logging.
This commit is contained in:
parent
2c03ad1123
commit
c87472b722
@ -1,7 +1,6 @@
|
|||||||
import {Angle, Mesh, Quaternion, Scene, Vector3, WebXRDefaultExperience} from "@babylonjs/core";
|
import {Angle, Mesh, Quaternion, Scene, Vector3, WebXRDefaultExperience} from "@babylonjs/core";
|
||||||
import {Right} from "./right";
|
import {Right} from "./right";
|
||||||
import {Left} from "./left";
|
import {Left} from "./left";
|
||||||
import {EditMenu} from "../menus/editMenu";
|
|
||||||
import {ControllerEvent, ControllerEventType, Controllers} from "./controllers";
|
import {ControllerEvent, ControllerEventType, Controllers} from "./controllers";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import {DiagramManager} from "../diagram/diagramManager";
|
import {DiagramManager} from "../diagram/diagramManager";
|
||||||
@ -10,16 +9,29 @@ import {buildRig} from "./functions/buildRig";
|
|||||||
const RIGHT = "right";
|
const RIGHT = "right";
|
||||||
const LEFT = "left";
|
const LEFT = "left";
|
||||||
|
|
||||||
|
const logger = log.getLogger('Rigplatform');
|
||||||
|
|
||||||
export class Rigplatform {
|
export class Rigplatform {
|
||||||
private velocityIndex = 2;
|
private readonly controllers: Controllers;
|
||||||
private readonly velocityArray = [0.01, 0.1, 1, 2, 5];
|
private readonly diagramManager: DiagramManager;
|
||||||
public bMenu: EditMenu;
|
|
||||||
private readonly scene: Scene;
|
private readonly scene: Scene;
|
||||||
public static instance: Rigplatform;
|
private readonly velocityArray = [0.01, 0.1, 1, 2, 5];
|
||||||
|
private readonly xr: WebXRDefaultExperience;
|
||||||
|
|
||||||
private rightController: Right;
|
private rightController: Right;
|
||||||
private leftController: Left;
|
private leftController: Left;
|
||||||
private readonly xr: WebXRDefaultExperience;
|
private turning: boolean = false;
|
||||||
|
private velocity: Vector3 = Vector3.Zero();
|
||||||
|
private velocityIndex: number = 2;
|
||||||
|
private turnVelocity: number = 0;
|
||||||
|
|
||||||
|
private registered = false;
|
||||||
private yRotation: number = 0;
|
private yRotation: number = 0;
|
||||||
|
|
||||||
|
private _flyMode: boolean = true;
|
||||||
|
|
||||||
|
public static instance: Rigplatform;
|
||||||
|
|
||||||
public turnSnap: number = 0;
|
public turnSnap: number = 0;
|
||||||
public rigMesh: Mesh;
|
public rigMesh: Mesh;
|
||||||
|
|
||||||
@ -38,32 +50,26 @@ export class Rigplatform {
|
|||||||
this.registerVelocityObserver();
|
this.registerVelocityObserver();
|
||||||
|
|
||||||
}
|
}
|
||||||
private turning: boolean = false;
|
|
||||||
private velocity: Vector3 = Vector3.Zero();
|
|
||||||
private turnVelocity: number = 0;
|
|
||||||
private logger = log.getLogger('Rigplatform');
|
|
||||||
private readonly diagramManager: DiagramManager;
|
|
||||||
private readonly controllers: Controllers;
|
|
||||||
private registered = false;
|
|
||||||
|
|
||||||
private _flyMode: boolean = true;
|
|
||||||
|
|
||||||
public set flyMode(value: boolean) {
|
public set flyMode(value: boolean) {
|
||||||
this._flyMode = value;
|
this._flyMode = value;
|
||||||
if (this._flyMode) {
|
if (this._flyMode) {
|
||||||
this.rigMesh.physicsBody.setGravityFactor(.01);
|
this.rigMesh.physicsBody.setGravityFactor(.01);
|
||||||
console.log('flymode');
|
logger.debug('flymode');
|
||||||
} else {
|
} else {
|
||||||
this.rigMesh.physicsBody.setGravityFactor(1);
|
this.rigMesh.physicsBody.setGravityFactor(1);
|
||||||
console.log('walkmode');
|
logger.debug('walkmode');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public forwardback(val: number) {
|
public forwardback(val: number) {
|
||||||
this.velocity.z = (val * this.velocityArray[this.velocityIndex]) * -1;
|
this.velocity.z = (val * this.velocityArray[this.velocityIndex]) * -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public leftright(val: number) {
|
public leftright(val: number) {
|
||||||
this.velocity.x = (val * this.velocityArray[this.velocityIndex]);
|
this.velocity.x = (val * this.velocityArray[this.velocityIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public updown(val: number) {
|
public updown(val: number) {
|
||||||
this.velocity.y = (val * this.velocityArray[this.velocityIndex]) * -1;
|
this.velocity.y = (val * this.velocityArray[this.velocityIndex]) * -1;
|
||||||
}
|
}
|
||||||
@ -98,7 +104,7 @@ export class Rigplatform {
|
|||||||
vel.y = 0;
|
vel.y = 0;
|
||||||
}
|
}
|
||||||
if (vel.length() > 0) {
|
if (vel.length() > 0) {
|
||||||
this.logger.debug('Velocity', this.velocity, vel, this.scene.activeCamera.absoluteRotation);
|
logger.debug('Velocity', this.velocity, vel, this.scene.activeCamera.absoluteRotation);
|
||||||
}
|
}
|
||||||
this.rigMesh.physicsBody.setLinearVelocity(vel);
|
this.rigMesh.physicsBody.setLinearVelocity(vel);
|
||||||
});
|
});
|
||||||
@ -108,6 +114,7 @@ export class Rigplatform {
|
|||||||
if (!this.registered) {
|
if (!this.registered) {
|
||||||
this.registered = true;
|
this.registered = true;
|
||||||
this.controllers.controllerObserver.add((event: ControllerEvent) => {
|
this.controllers.controllerObserver.add((event: ControllerEvent) => {
|
||||||
|
logger.debug(event);
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case ControllerEventType.INCREASE_VELOCITY:
|
case ControllerEventType.INCREASE_VELOCITY:
|
||||||
if (this.velocityIndex < this.velocityArray.length - 1) {
|
if (this.velocityIndex < this.velocityArray.length - 1) {
|
||||||
@ -138,8 +145,7 @@ export class Rigplatform {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ControllerEventType.MOTION:
|
case ControllerEventType.MOTION:
|
||||||
this.logger.debug(JSON.stringify(event));
|
logger.debug(JSON.stringify(event));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -169,6 +175,7 @@ export class Rigplatform {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private fixRotation() {
|
private fixRotation() {
|
||||||
this.scene.onAfterPhysicsObservable.add(() => {
|
this.scene.onAfterPhysicsObservable.add(() => {
|
||||||
const turnSnap = this.turnSnap;
|
const turnSnap = this.turnSnap;
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
|
import log from "loglevel";
|
||||||
|
|
||||||
|
const logger = log.getLogger('syncDoc');
|
||||||
export function syncDoc(info) {
|
export function syncDoc(info) {
|
||||||
console.log(info);
|
logger.debug(info);
|
||||||
console.log(this);
|
|
||||||
if (info.direction == 'pull') {
|
if (info.direction == 'pull') {
|
||||||
const docs = info.change.docs;
|
const docs = info.change.docs;
|
||||||
for (const doc of docs) {
|
for (const doc of docs) {
|
||||||
|
logger.debug(doc);
|
||||||
if (doc._deleted) {
|
if (doc._deleted) {
|
||||||
console.log(doc);
|
logger.debug('Delete', doc);
|
||||||
this.removeObserver.notifyObservers({id: doc._id, template: doc.template}, 1);
|
this.removeObserver.notifyObservers({id: doc._id, template: doc.template}, 1);
|
||||||
} else {
|
} else {
|
||||||
this.updateObserver.notifyObservers(doc, 1);
|
this.updateObserver.notifyObservers(doc, 1);
|
||||||
|
|||||||
@ -137,7 +137,7 @@ export class SoccerMenu extends AbstractMenu {
|
|||||||
if (mesh) {
|
if (mesh) {
|
||||||
const meta = mesh?.parent?.parent?.parent
|
const meta = mesh?.parent?.parent?.parent
|
||||||
if (meta) {
|
if (meta) {
|
||||||
console.log(meta.id);
|
this.logger.debug(meta.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -7,12 +7,19 @@ export function addSceneInspector(scene) {
|
|||||||
//voiceManager.stopRecording();
|
//voiceManager.stopRecording();
|
||||||
}
|
}
|
||||||
if (ev.shiftKey && ev.ctrlKey && ev.altKey && ev.keyCode === 73) {
|
if (ev.shiftKey && ev.ctrlKey && ev.altKey && ev.keyCode === 73) {
|
||||||
import("@babylonjs/core/Debug/debugLayer").then(() => {
|
import("@babylonjs/core/Debug").then(() => {
|
||||||
import("@babylonjs/inspector").then(() => {
|
import("@babylonjs/inspector").then(() => {
|
||||||
|
const web = document.querySelector('#webApp');
|
||||||
if (scene.debugLayer.isVisible()) {
|
if (scene.debugLayer.isVisible()) {
|
||||||
|
if (web) {
|
||||||
|
(web as HTMLDivElement).style.display = 'block';
|
||||||
|
}
|
||||||
scene.debugLayer.hide();
|
scene.debugLayer.hide();
|
||||||
} else {
|
} else {
|
||||||
scene.debugLayer.show();
|
scene.debugLayer.show();
|
||||||
|
if (web) {
|
||||||
|
(web as HTMLDivElement).style.display = 'none';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
import {Scene, TransformNode, Vector3} from "@babylonjs/core";
|
import {Scene, TransformNode, Vector3} from "@babylonjs/core";
|
||||||
import {getFrontPosition} from "./getFrontPosition";
|
import {getFrontPosition} from "./getFrontPosition";
|
||||||
|
import log from "loglevel";
|
||||||
|
|
||||||
|
const logger = log.getLogger('setMenuPosition');
|
||||||
|
|
||||||
export function setMenuPosition(node: TransformNode, scene: Scene, offset: Vector3 = Vector3.Zero()) {
|
export function setMenuPosition(node: TransformNode, scene: Scene, offset: Vector3 = Vector3.Zero()) {
|
||||||
/*
|
/*
|
||||||
@ -42,7 +45,7 @@ export function setMenuPosition(node: TransformNode, scene: Scene, offset: Vecto
|
|||||||
scene.onActiveCameraChanged.add((scene: Scene) => {
|
scene.onActiveCameraChanged.add((scene: Scene) => {
|
||||||
setPosition(node, scene, offset);
|
setPosition(node, scene, offset);
|
||||||
});
|
});
|
||||||
console.error("No active camera");
|
logger.error("No active camera");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -77,6 +80,6 @@ function setPosition(node: TransformNode, scene: Scene, offset: Vector3 = Vector
|
|||||||
node.position.x = offset.x;
|
node.position.x = offset.x;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
console.log('menu position set');
|
logger.debug('menu position set');
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user