Cleaned up console.log and remove commented code.
This commit is contained in:
parent
0e54e15cb9
commit
e1f27153df
@ -9,8 +9,10 @@ import {
|
|||||||
Vector3
|
Vector3
|
||||||
} from "@babylonjs/core";
|
} from "@babylonjs/core";
|
||||||
import {ControllerEventType, Controllers} from "../controllers/controllers";
|
import {ControllerEventType, Controllers} from "../controllers/controllers";
|
||||||
|
import log, {Logger} from "loglevel";
|
||||||
|
|
||||||
export class Ball {
|
export class Ball {
|
||||||
|
private readonly logger: Logger = log.getLogger('Ball');
|
||||||
private readonly scene: Scene;
|
private readonly scene: Scene;
|
||||||
private transformNode: TransformNode;
|
private transformNode: TransformNode;
|
||||||
private mesh: AbstractMesh;
|
private mesh: AbstractMesh;
|
||||||
@ -40,7 +42,7 @@ export class Ball {
|
|||||||
private buildBall() {
|
private buildBall() {
|
||||||
SceneLoader.ImportMesh(null, "/assets/models/", "ball.gltf", this.scene,
|
SceneLoader.ImportMesh(null, "/assets/models/", "ball.gltf", this.scene,
|
||||||
(meshes, particleSystems, skeletons, animationGroups) => {
|
(meshes, particleSystems, skeletons, animationGroups) => {
|
||||||
console.log('ball loaded');
|
this.logger.debug('ball loaded');
|
||||||
this.mesh = meshes[0];
|
this.mesh = meshes[0];
|
||||||
this.parent = MeshBuilder.CreateSphere("ballParent", {diameter: .17}, this.scene);
|
this.parent = MeshBuilder.CreateSphere("ballParent", {diameter: .17}, this.scene);
|
||||||
|
|
||||||
@ -50,7 +52,7 @@ export class Ball {
|
|||||||
this.scene.onBeforeRenderObservable.add(() => {
|
this.scene.onBeforeRenderObservable.add(() => {
|
||||||
if (!this.physicsAggregate &&
|
if (!this.physicsAggregate &&
|
||||||
this.scene?.getPhysicsEngine()?.getPhysicsPlugin()) {
|
this.scene?.getPhysicsEngine()?.getPhysicsPlugin()) {
|
||||||
console.log("creating physics aggregate");
|
this.logger.debug("creating physics aggregate");
|
||||||
this.physicsAggregate = new PhysicsAggregate(this.parent,
|
this.physicsAggregate = new PhysicsAggregate(this.parent,
|
||||||
PhysicsShapeType.SPHERE, {mass: 1, restitution: .6, friction: .6}, this.scene);
|
PhysicsShapeType.SPHERE, {mass: 1, restitution: .6, friction: .6}, this.scene);
|
||||||
this.physicsAggregate.body.setLinearDamping(.3);
|
this.physicsAggregate.body.setLinearDamping(.3);
|
||||||
@ -61,12 +63,6 @@ export class Ball {
|
|||||||
}
|
}
|
||||||
}, -1, false, this, false);
|
}, -1, false, this, false);
|
||||||
|
|
||||||
//animationGroups[0].stop();
|
|
||||||
|
|
||||||
//this.animationGroup = animationGroups[6];
|
|
||||||
//this.animationGroup.start(false, 1, 266, 266);
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14,8 +14,10 @@ import {
|
|||||||
Vector2,
|
Vector2,
|
||||||
Vector3
|
Vector3
|
||||||
} from "@babylonjs/core";
|
} from "@babylonjs/core";
|
||||||
|
import log, {Logger} from "loglevel";
|
||||||
|
|
||||||
export class PlayerFactory {
|
export class PlayerFactory {
|
||||||
|
private readonly logger: Logger = log.getLogger('PlayerFactory')
|
||||||
public onReadyObservable: Observable<any> = new Observable();
|
public onReadyObservable: Observable<any> = new Observable();
|
||||||
private readonly scene: Scene;
|
private readonly scene: Scene;
|
||||||
private container: AssetContainer;
|
private container: AssetContainer;
|
||||||
@ -28,17 +30,20 @@ export class PlayerFactory {
|
|||||||
(container: AssetContainer) => {
|
(container: AssetContainer) => {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.onReadyObservable.notifyObservers(this);
|
this.onReadyObservable.notifyObservers(this);
|
||||||
|
this.logger.debug('Player Model Loaded');
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public buildPlayer(position: Vector3, number: number, teamName: string = "team"): Player {
|
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);
|
return new Player(this.scene, position, this.container, number, teamName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Player {
|
export class Player {
|
||||||
|
private readonly logger: Logger = log.getLogger('Player');
|
||||||
public readonly onReadyObservable: Observable<any> = new Observable();
|
public readonly onReadyObservable: Observable<any> = new Observable();
|
||||||
private readonly scene: Scene;
|
private readonly scene: Scene;
|
||||||
private position: Vector3;
|
private position: Vector3;
|
||||||
@ -88,6 +93,7 @@ export class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public runTo(location: Vector2) {
|
public runTo(location: Vector2) {
|
||||||
|
this.logger.debug(`Running to ${JSON.stringify(location)}`)
|
||||||
this.destination = location;
|
this.destination = location;
|
||||||
const body = this.physicsAggregate.transformNode.physicsBody;
|
const body = this.physicsAggregate.transformNode.physicsBody;
|
||||||
body.setMotionType(PhysicsMotionType.ANIMATED);
|
body.setMotionType(PhysicsMotionType.ANIMATED);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user