UNPKG

@react-three/p2

Version:

2D physics based hooks for react-three-fiber

92 lines (91 loc) 2.79 kB
import type { ContactMaterial, Shape } from 'p2-es'; import type { PropsWithChildren } from 'react'; import type { Duplet } from './hooks'; export declare type Broadphase = 'Naive' | 'SAP'; export declare type Solver = 'GS' | 'Split'; export declare type DefaultContactMaterial = Partial<Pick<ContactMaterial, 'friction' | 'restitution' | 'stiffness' | 'relaxation' | 'frictionStiffness' | 'frictionRelaxation'>>; export declare type ProviderProps = PropsWithChildren<{ allowSleep?: boolean; axisIndex?: number; normalIndex?: number; broadphase?: Broadphase; defaultContactMaterial?: DefaultContactMaterial; gravity?: Duplet; iterations?: number; quatNormalizeFast?: boolean; quatNormalizeSkip?: number; shouldInvalidate?: boolean; size?: number; solver?: Solver; step?: number; tolerance?: number; }>; export declare type WorkerCollideEvent = { data: { op: 'event'; type: 'impact'; target: string; body: string; contact: { id: string; ni: number[]; ri: number[]; rj: number[]; impactVelocity: number; bi: string; bj: string; contactPoint: number[]; contactNormal: number[]; }; collisionFilters: { bodyFilterGroup: number; bodyFilterMask: number; targetFilterGroup: number; targetFilterMask: number; }; }; }; export declare type WorkerRayhitEvent = { data: { op: 'event'; type: 'rayhit'; ray: { from: number[]; to: number[]; direction: number[]; collisionFilterGroup: number; collisionFilterMask: number; uuid: string; }; hasHit: boolean; body: string | null; shape: (Omit<Shape, 'body'> & { body: string; }) | null; rayFromWorld: number[]; rayToWorld: number[]; hitNormalWorld: number[]; hitPointWorld: number[]; hitFaceIndex: number; distance: number; shouldStop: boolean; }; }; export declare type WorkerCollideBeginEvent = { data: { op: 'event'; type: 'collideBegin'; bodyA: string; bodyB: string; contacts: []; }; }; export declare type WorkerCollideEndEvent = { data: { op: 'event'; type: 'collideEnd'; bodyA: string; bodyB: string; }; }; export declare function Provider({ allowSleep, axisIndex, normalIndex, broadphase, children, defaultContactMaterial, gravity, iterations, quatNormalizeFast, quatNormalizeSkip, shouldInvalidate, size, solver, step, tolerance, }: ProviderProps): JSX.Element;