@matematrolii/sketchbook
Version:
3D matematrolii playground built on three.js and cannon.js
36 lines (29 loc) • 868 B
text/typescript
import
{
CharacterStateBase,
} from './_stateLibrary';
import { ICharacterState } from '../../interfaces/ICharacterState';
import { Character } from '../Character';
export class Falling extends CharacterStateBase implements ICharacterState
{
constructor(character: Character)
{
super(character);
this.character.velocitySimulator.mass = 100;
this.character.rotationSimulator.damping = 0.3;
this.character.arcadeVelocityIsAdditive = true;
this.character.setArcadeVelocityInfluence(0.05, 0, 0.05);
//this.playAnimation('falling', 0.3);
this.playAnimation('jump', 0.3);
}
public update(timeStep: number): void
{
super.update(timeStep);
this.character.setCameraRelativeOrientationTarget();
this.character.setArcadeVelocityTarget(this.anyDirection() ? 0.8 : 0);
if (this.character.rayHasHit)
{
this.setAppropriateDropState();
}
}
}