Cleaned up console.log and remove commented code.

This commit is contained in:
Michael Mainguy 2023-09-19 07:42:34 -05:00
parent 0e54e15cb9
commit e1f27153df
2 changed files with 10 additions and 8 deletions

View File

@ -9,8 +9,10 @@ import {
Vector3
} from "@babylonjs/core";
import {ControllerEventType, Controllers} from "../controllers/controllers";
import log, {Logger} from "loglevel";
export class Ball {
private readonly logger: Logger = log.getLogger('Ball');
private readonly scene: Scene;
private transformNode: TransformNode;
private mesh: AbstractMesh;
@ -40,7 +42,7 @@ export class Ball {
private buildBall() {
SceneLoader.ImportMesh(null, "/assets/models/", "ball.gltf", this.scene,
(meshes, particleSystems, skeletons, animationGroups) => {
console.log('ball loaded');
this.logger.debug('ball loaded');
this.mesh = meshes[0];
this.parent = MeshBuilder.CreateSphere("ballParent", {diameter: .17}, this.scene);
@ -50,7 +52,7 @@ export class Ball {
this.scene.onBeforeRenderObservable.add(() => {
if (!this.physicsAggregate &&
this.scene?.getPhysicsEngine()?.getPhysicsPlugin()) {
console.log("creating physics aggregate");
this.logger.debug("creating physics aggregate");
this.physicsAggregate = new PhysicsAggregate(this.parent,
PhysicsShapeType.SPHERE, {mass: 1, restitution: .6, friction: .6}, this.scene);
this.physicsAggregate.body.setLinearDamping(.3);
@ -61,12 +63,6 @@ export class Ball {
}
}, -1, false, this, false);
//animationGroups[0].stop();
//this.animationGroup = animationGroups[6];
//this.animationGroup.start(false, 1, 266, 266);
});
}
}

View File

@ -14,8 +14,10 @@ import {
Vector2,
Vector3
} from "@babylonjs/core";
import log, {Logger} from "loglevel";
export class PlayerFactory {
private readonly logger: Logger = log.getLogger('PlayerFactory')
public onReadyObservable: Observable<any> = new Observable();
private readonly scene: Scene;
private container: AssetContainer;
@ -28,17 +30,20 @@ export class PlayerFactory {
(container: AssetContainer) => {
this.container = container;
this.onReadyObservable.notifyObservers(this);
this.logger.debug('Player Model Loaded');
});
}
public buildPlayer(position: Vector3, number: number, teamName: string = "team"): Player {
this.logger.debug(`Building player #${number}, for team ${teamName}`);
return new Player(this.scene, position, this.container, number, teamName);
}
}
export class Player {
private readonly logger: Logger = log.getLogger('Player');
public readonly onReadyObservable: Observable<any> = new Observable();
private readonly scene: Scene;
private position: Vector3;
@ -88,6 +93,7 @@ export class Player {
}
public runTo(location: Vector2) {
this.logger.debug(`Running to ${JSON.stringify(location)}`)
this.destination = location;
const body = this.physicsAggregate.transformNode.physicsBody;
body.setMotionType(PhysicsMotionType.ANIMATED);