@react-three/p2
Version:
2D physics based hooks for react-three-fiber
79 lines (78 loc) • 5.9 kB
TypeScript
/// <reference types="node" />
import EventEmitter from 'events';
import type { Broadphase, CannonMessageBody, Duplet, StepProps, WorldProps } from './setup';
export declare type CannonWorkerProps = Partial<WorldProps> & {
size?: number;
};
export declare class CannonWorkerAPI extends EventEmitter {
get axisIndex(): 0 | 1 | 2;
set axisIndex(value: 0 | 1 | 2);
get broadphase(): Broadphase;
set broadphase(value: Broadphase);
get gravity(): Duplet;
set gravity(value: Duplet);
get iterations(): number;
set iterations(value: number);
get tolerance(): number;
set tolerance(value: number);
private buffers;
private config;
private worker;
constructor({ allowSleep, axisIndex, broadphase, defaultContactMaterial, gravity, iterations, normalIndex, quatNormalizeFast, quatNormalizeSkip, size, solver, tolerance, }: CannonWorkerProps);
addBodies({ props, type, uuid }: CannonMessageBody<'addBodies'>): void;
addConstraint({ props: [refA, refB, optns], type, uuid }: CannonMessageBody<'addConstraint'>): void;
addContactMaterial({ props, uuid }: CannonMessageBody<'addContactMaterial'>): void;
addKinematicCharacterController({ props: [accelerationTimeAirborne, accelerationTimeGrounded, body, collisionMask, dstBetweenRays, maxClimbAngle, maxDescendAngle, maxJumpHeight, minJumpHeight, moveSpeed, skinWidth, timeToJumpApex, velocityXMin, velocityXSmoothing, wallJumpClimb, wallJumpOff, wallLeap, wallSlideSpeedMax, wallStickTime,], uuid, }: CannonMessageBody<'addKinematicCharacterController'>): void;
addPlatformController({ props: [body, passengerMask, localWaypoints, speed, skinWidth, dstBetweenRays], uuid, }: CannonMessageBody<'addPlatformController'>): void;
addRay({ props, uuid }: CannonMessageBody<'addRay'>): void;
addSpring({ props: [refA, refB, optns], uuid }: CannonMessageBody<'addSpring'>): void;
addTopDownVehicle({ props: [chassisBodyUUID, wheelInfos], uuid, }: CannonMessageBody<'addTopDownVehicle'>): void;
applyForce({ props, uuid }: CannonMessageBody<'applyForce'>): void;
applyImpulse({ props, uuid }: CannonMessageBody<'applyImpulse'>): void;
applyLocalForce({ props, uuid }: CannonMessageBody<'applyLocalForce'>): void;
applyLocalImpulse({ props, uuid }: CannonMessageBody<'applyLocalImpulse'>): void;
applyTopDownVehicleEngineForce({ props, uuid }: CannonMessageBody<'applyTopDownVehicleEngineForce'>): void;
applyTorque({ props, uuid }: CannonMessageBody<'applyTorque'>): void;
disableConstraintMotor({ uuid }: CannonMessageBody<'disableConstraintMotor'>): void;
enableConstraintMotor({ uuid }: CannonMessageBody<'enableConstraintMotor'>): void;
init(): void;
removeBodies({ uuid }: CannonMessageBody<'removeBodies'>): void;
removeConstraint({ uuid }: CannonMessageBody<'removeConstraint'>): void;
removeContactMaterial({ uuid }: CannonMessageBody<'removeContactMaterial'>): void;
removeKinematicCharacterController({ uuid, }: CannonMessageBody<'removeKinematicCharacterController'>): void;
removePlatformController({ uuid }: CannonMessageBody<'removePlatformController'>): void;
removeRay({ uuid }: CannonMessageBody<'removeRay'>): void;
removeSpring({ uuid }: CannonMessageBody<'removeSpring'>): void;
removeTopDownVehicle({ uuid }: CannonMessageBody<'removeTopDownVehicle'>): void;
setAllowSleep({ props, uuid }: CannonMessageBody<'setAllowSleep'>): void;
setAngle({ props, uuid }: CannonMessageBody<'setAngle'>): void;
setAngularDamping({ props, uuid }: CannonMessageBody<'setAngularDamping'>): void;
setAngularVelocity({ props, uuid }: CannonMessageBody<'setAngularVelocity'>): void;
setCollisionFilterGroup({ props, uuid }: CannonMessageBody<'setCollisionFilterGroup'>): void;
setCollisionFilterMask({ props, uuid }: CannonMessageBody<'setCollisionFilterMask'>): void;
setCollisionResponse({ props, uuid }: CannonMessageBody<'setCollisionResponse'>): void;
setConstraintMotorSpeed({ props, uuid }: CannonMessageBody<'setConstraintMotorSpeed'>): void;
setFixedRotation({ props, uuid }: CannonMessageBody<'setFixedRotation'>): void;
setIsTrigger({ props, uuid }: CannonMessageBody<'setIsTrigger'>): void;
setKinematicCharacterControllerInput({ props, uuid, }: CannonMessageBody<'setKinematicCharacterControllerInput'>): void;
setKinematicCharacterControllerJump({ props, uuid, }: CannonMessageBody<'setKinematicCharacterControllerJump'>): void;
setLinearDamping({ props, uuid }: CannonMessageBody<'setLinearDamping'>): void;
setMass({ props, uuid }: CannonMessageBody<'setMass'>): void;
setMaterial({ props, uuid }: CannonMessageBody<'setMaterial'>): void;
setPosition({ props, uuid }: CannonMessageBody<'setPosition'>): void;
setSleepSpeedLimit({ props, uuid }: CannonMessageBody<'setSleepSpeedLimit'>): void;
setSleepTimeLimit({ props, uuid }: CannonMessageBody<'setSleepTimeLimit'>): void;
setSpringDamping({ props, uuid }: CannonMessageBody<'setSpringDamping'>): void;
setSpringRestLength({ props, uuid }: CannonMessageBody<'setSpringRestLength'>): void;
setSpringStiffness({ props, uuid }: CannonMessageBody<'setSpringStiffness'>): void;
setTopDownVehicleBrake({ props, uuid }: CannonMessageBody<'setTopDownVehicleBrake'>): void;
setTopDownVehicleSteeringValue({ props, uuid }: CannonMessageBody<'setTopDownVehicleSteeringValue'>): void;
setUserData({ props, uuid }: CannonMessageBody<'setUserData'>): void;
setVelocity({ props, uuid }: CannonMessageBody<'setVelocity'>): void;
sleep({ uuid }: CannonMessageBody<'sleep'>): void;
step(props: StepProps): void;
subscribe({ props: { id, target, type }, uuid }: CannonMessageBody<'subscribe'>): void;
terminate(): void;
unsubscribe({ props }: CannonMessageBody<'unsubscribe'>): void;
wakeUp({ uuid }: CannonMessageBody<'wakeUp'>): void;
}