31 lines
678 B
TypeScript
31 lines
678 B
TypeScript
import { IMoveInput } from "../Input/MoveInput";
|
|
import { Vector3 } from "three";
|
|
|
|
export class MoveC {
|
|
private readonly input: IMoveInput;
|
|
private speed: number;
|
|
private readonly moveDirection = new Vector3();
|
|
|
|
constructor(input: IMoveInput, speed = 5) {
|
|
this.input = input;
|
|
this.speed = speed;
|
|
}
|
|
|
|
get Direction() {
|
|
return this.moveDirection;
|
|
}
|
|
|
|
get Weight() {
|
|
return this.moveDirection.length() / this.speed;
|
|
}
|
|
|
|
setSpeed(speed: number) {
|
|
this.speed = speed;
|
|
}
|
|
|
|
|
|
update(_delta: number) {
|
|
this.moveDirection.copy(this.input.CurrentDirection).multiplyScalar(this.speed);
|
|
}
|
|
}
|