@react-three/p2
Version:
2D physics based hooks for react-three-fiber
35 lines (34 loc) • 1.52 kB
TypeScript
import { Ray, RaycastResult } from 'p2-es';
import type { KinematicCharacterControllerOptns } from './KinematicCharacterController';
import RaycastController from './RaycastController';
import type { Duplet } from './';
export default class Controller extends RaycastController {
maxClimbAngle: number;
maxDescendAngle: number;
collisions: {
above: boolean;
below: boolean;
left: boolean;
right: boolean;
climbingSlope: boolean;
descendingSlope: boolean;
slopeAngle: number;
slopeAngleOld: number;
velocityOld: Duplet;
faceDir: number;
fallingThroughPlatform: boolean;
};
ray: Ray;
raycastResult: RaycastResult;
raysData: [from: Duplet, to: Duplet, hitPoint: [number, number]][];
constructor({ world, body, collisionMask, skinWidth, dstBetweenRays, maxClimbAngle, maxDescendAngle }: Pick<KinematicCharacterControllerOptns, 'world' | 'body' | 'collisionMask' | 'skinWidth' | 'dstBetweenRays' | 'maxClimbAngle' | 'maxDescendAngle'>);
resetCollisions(velocity: Duplet): void;
moveWithZeroInput(velocity: Duplet, standingOnPlatform: boolean): void;
move(velocity: Duplet, input: Duplet, standingOnPlatform?: boolean): void;
horizontalCollisions(velocity: Duplet): void;
verticalCollisions(velocity: Duplet): void;
climbSlope(velocity: Duplet, slopeAngle: number): void;
descendSlope(velocity: Duplet): void;
resetFallingThroughPlatform(): void;
emitRayCastEvent(): void;
}