Detalhes do pacote

@react-three/cannon

pmndrs45.6kMIT6.6.0

physics based hooks for react-three-fiber

cannon, three, react, react-three-fiber

readme (leia-me)

Build Status Version Downloads Discord Shield

Imgur

yarn add @react-three/cannon

React hooks for cannon-es. Use this in combination with react-three-fiber.

  • [x] Doesn't block the main thread, runs in a web worker
  • [x] Supports instancing out of the box
  • [x] Least amount of friction you'll ever experience with a physics rig ... 🙈

Demos

Check out all of our examples at https://cannon.pmnd.rs

The code for the examples lives in ../react-three-cannon-examples

How it works

  1. Get all the imports that you need.
import { Physics, useBox, ... } from '@react-three/cannon'
  1. Create a physics world.
<Physics>{/* Physics related objects in here please */}</Physics>
  1. Pick a shape that suits your objects contact surface, it could be a box, plane, sphere, etc. Give it a mass, too.
const [ref, api] = useBox(() => ({ mass: 1 }))
  1. Take your object, it could be a mesh, line, gltf, anything, and tie it to the reference you have just received. Et voilà, it will now be affected by gravity and other objects inside the physics world.
<mesh ref={ref} geometry={...} material={...} />
  1. You can interact with it by using the api, which lets you apply positions, rotations, velocities, forces and impulses.
useFrame(({ clock }) => api.position.set(Math.sin(clock.getElapsedTime()) * 5, 0, 0))
  1. You can use the body api to subscribe to properties to get updates on each frame.
const velocity = useRef([0, 0, 0])
useEffect(() => {
  const unsubscribe = api.velocity.subscribe((v) => (velocity.current = v))
  return unsubscribe
}, [])

Simple example

Let's make a cube falling onto a plane. You can play with a sandbox here.

import { Canvas } from '@react-three/fiber'
import { Physics, usePlane, useBox } from '@react-three/cannon'

function Plane(props) {
  const [ref] = usePlane(() => ({ rotation: [-Math.PI / 2, 0, 0], ...props }))
  return (
    <mesh ref={ref}>
      <planeGeometry args={[100, 100]} />
    </mesh>
  )
}

function Cube(props) {
  const [ref] = useBox(() => ({ mass: 1, position: [0, 5, 0], ...props }))
  return (
    <mesh ref={ref}>
      <boxGeometry />
    </mesh>
  )
}

ReactDOM.render(
  <Canvas>
    <Physics>
      <Plane />
      <Cube />
    </Physics>
  </Canvas>,
  document.getElementById('root'),
)

Debug

You can debug your scene using the cannon-es-debugger. This will show you how cannon "sees" your scene. Do not use this in production as it will pull in cannon-es a second time!

import { Physics, Debug } from '@react-three/cannon'

ReactDOM.render(
  <Canvas>
    <Physics>
      <Debug color="black" scale={1.1}>
        {/* children */}
      </Debug>
    </Physics>
  </Canvas>,
  document.getElementById('root'),
)

Api

Exports

function Physics({
  allowSleep = false,
  axisIndex = 0,
  broadphase = 'Naive',
  defaultContactMaterial = { contactEquationStiffness: 1e6 },
  gravity = [0, -9.81, 0],
  isPaused = false,
  iterations = 5,
  maxSubSteps = 10,
  quatNormalizeFast = false,
  quatNormalizeSkip = 0,
  shouldInvalidate = true,
  // Maximum amount of physics objects inside your scene
  // Lower this value to save memory, increase if 1000 isn't enough
  size = 1000,
  solver = 'GS',
  stepSize = 1 / 60,
  tolerance = 0.001,
}: React.PropsWithChildren<ProviderProps>): JSX.Element

function Debug({ color = 'black', scale = 1 }: DebugProps): JSX.Element

function usePlane(
  fn: GetByIndex<PlaneProps>,
  fwdRef?: React.Ref<THREE.Object3D>,
  deps?: React.DependencyList,
): Api

function useBox(
  fn: GetByIndex<BoxProps>,
  fwdRef?: React.Ref<THREE.Object3D>,
  deps?: React.DependencyList,
): Api

function useCylinder(
  fn: GetByIndex<CylinderProps>,
  fwdRef?: React.Ref<THREE.Object3D>,
  deps?: React.DependencyList,
): Api

function useHeightfield(
  fn: GetByIndex<HeightfieldProps>,
  fwdRef?: React.Ref<THREE.Object3D>,
  deps?: React.DependencyList,
): Api

function useParticle(
  fn: GetByIndex<ParticleProps>,
  fwdRef?: React.Ref<THREE.Object3D>,
  deps?: React.DependencyList,
): Api

function useSphere(
  fn: GetByIndex<SphereProps>,
  fwdRef?: React.Ref<THREE.Object3D>,
  deps?: React.DependencyList,
): Api

function useTrimesh(
  fn: GetByIndex<TrimeshProps>,
  fwdRef?: React.Ref<THREE.Object3D>,
  deps?: React.DependencyList,
): Api

function useConvexPolyhedron(
  fn: GetByIndex<ConvexPolyhedronProps>,
  fwdRef?: React.Ref<THREE.Object3D>,
  deps?: React.DependencyList,
): Api

function useCompoundBody(
  fn: GetByIndex<CompoundBodyProps>,
  fwdRef?: React.Ref<THREE.Object3D>,
  deps?: React.DependencyList,
): Api

function useRaycastVehicle(
  fn: () => RaycastVehicleProps,
  fwdRef?: React.Ref<THREE.Object3D>,
  deps: React.DependencyList[] = [],
): [React.RefObject<THREE.Object3D>, RaycastVehiclePublicApi]

function usePointToPointConstraint(
  bodyA: React.Ref<THREE.Object3D>,
  bodyB: React.Ref<THREE.Object3D>,
  optns: PointToPointConstraintOpts,
  deps: React.DependencyList = [],
): ConstraintApi

function useConeTwistConstraint(
  bodyA: React.Ref<THREE.Object3D>,
  bodyB: React.Ref<THREE.Object3D>,
  optns: ConeTwistConstraintOpts,
  deps: React.DependencyList = [],
): ConstraintApi

function useDistanceConstraint(
  bodyA: React.Ref<THREE.Object3D>,
  bodyB: React.Ref<THREE.Object3D>,
  optns: DistanceConstraintOpts,
  deps: React.DependencyList = [],
): ConstraintApi

function useHingeConstraint(
  bodyA: React.Ref<THREE.Object3D>,
  bodyB: React.Ref<THREE.Object3D>,
  optns: HingeConstraintOpts,
  deps: React.DependencyList = [],
): ConstraintApi

function useLockConstraint(
  bodyA: React.Ref<THREE.Object3D>,
  bodyB: React.Ref<THREE.Object3D>,
  optns: LockConstraintOpts,
  deps: React.DependencyList = [],
): ConstraintApi

function useSpring(
  bodyA: React.Ref<THREE.Object3D>,
  bodyB: React.Ref<THREE.Object3D>,
  optns: SpringOptns,
  deps: React.DependencyList = [],
): void

function useRaycastClosest(
  options: RayOptions,
  callback: (e: RayhitEvent) => void,
  deps: React.DependencyList = [],
): void

function useRaycastAny(
  options: RayOptions,
  callback: (e: RayhitEvent) => void,
  deps: React.DependencyList = [],
): void

function useRaycastAll(
  options: RayOptions,
  callback: (e: RayhitEvent) => void,
  deps: React.DependencyList = [],
): void

function useContactMaterial(
  materialA: MaterialOptions,
  materialB: MaterialOptions,
  options: ContactMaterialOptions,
  deps: React.DependencyList = [],
): void

Returned api

type WorkerApi = {
  [K in AtomicName]: AtomicApi<K>
} & {
  [K in VectorName]: VectorApi
} & {
  applyForce: (force: Triplet, worldPoint: Triplet) => void
  applyImpulse: (impulse: Triplet, worldPoint: Triplet) => void
  applyLocalForce: (force: Triplet, localPoint: Triplet) => void
  applyLocalImpulse: (impulse: Triplet, localPoint: Triplet) => void
  applyTorque: (torque: Triplet) => void
  quaternion: QuaternionApi
  rotation: VectorApi
  scaleOverride: (scale: Triplet) => void
  sleep: () => void
  wakeUp: () => void
}

interface PublicApi extends WorkerApi {
  at: (index: number) => WorkerApi
}

type Api = [React.RefObject<THREE.Object3D>, PublicApi]

type AtomicName =
  | 'allowSleep'
  | 'angularDamping'
  | 'collisionFilterGroup'
  | 'collisionFilterMask'
  | 'collisionResponse'
  | 'fixedRotation'
  | 'isTrigger'
  | 'linearDamping'
  | 'mass'
  | 'material'
  | 'sleepSpeedLimit'
  | 'sleepTimeLimit'
  | 'userData'

type AtomicApi<K extends AtomicName> = {
  set: (value: AtomicProps[K]) => void
  subscribe: (callback: (value: AtomicProps[K]) => void) => () => void
}

type QuaternionApi = {
  set: (x: number, y: number, z: number, w: number) => void
  copy: ({ w, x, y, z }: Quaternion) => void
  subscribe: (callback: (value: Quad) => void) => () => void
}

type VectorName = 'angularFactor' | 'angularVelocity' | 'linearFactor' | 'position' | 'velocity'

type VectorApi = {
  set: (x: number, y: number, z: number) => void
  copy: ({ x, y, z }: Vector3 | Euler) => void
  subscribe: (callback: (value: Triplet) => void) => () => void
}

type ConstraintApi = [
  React.RefObject<THREE.Object3D>,
  React.RefObject<THREE.Object3D>,
  {
    enable: () => void
    disable: () => void
  },
]

type HingeConstraintApi = [
  React.RefObject<THREE.Object3D>,
  React.RefObject<THREE.Object3D>,
  {
    enable: () => void
    disable: () => void
    enableMotor: () => void
    disableMotor: () => void
    setMotorSpeed: (value: number) => void
    setMotorMaxForce: (value: number) => void
  },
]

type SpringApi = [
  React.RefObject<THREE.Object3D>,
  React.RefObject<THREE.Object3D>,
  {
    setStiffness: (value: number) => void
    setRestLength: (value: number) => void
    setDamping: (value: number) => void
  },
]

interface RaycastVehiclePublicApi {
  applyEngineForce: (value: number, wheelIndex: number) => void
  setBrake: (brake: number, wheelIndex: number) => void
  setSteeringValue: (value: number, wheelIndex: number) => void
  sliding: {
    subscribe: (callback: (sliding: boolean) => void) => void
  }
}

Props

type InitProps = {
  allowSleep?: boolean
  axisIndex?: 0 | 1 | 2
  broadphase?: Broadphase
  defaultContactMaterial?: ContactMaterialOptions
  gravity?: Triplet
  iterations?: number
  quatNormalizeFast?: boolean
  quatNormalizeSkip?: number
  solver?: Solver
  tolerance?: number
}

type ProviderProps = InitProps & {
  isPaused?: boolean
  maxSubSteps?: number
  shouldInvalidate?: boolean
  size?: number
  stepSize?: number
}

type AtomicProps = {
  allowSleep: boolean
  angularDamping: number
  collisionFilterGroup: number
  collisionFilterMask: number
  collisionResponse: number
  fixedRotation: boolean
  isTrigger: boolean
  linearDamping: number
  mass: number
  material: MaterialOptions
  sleepSpeedLimit: number
  sleepTimeLimit: number
  userData: {}
}

type Broadphase = 'Naive' | 'SAP'
type Triplet = [x: number, y: number, z: number]
type Quad = [x: number, y: number, z: number, w: number]

type VectorProps = Record<VectorName, Triplet>

type BodyProps<T extends any[] = unknown[]> = Partial<AtomicProps> &
  Partial<VectorProps> & {
    args?: T
    onCollide?: (e: CollideEvent) => void
    onCollideBegin?: (e: CollideBeginEvent) => void
    onCollideEnd?: (e: CollideEndEvent) => void
    quaternion?: Quad
    rotation?: Triplet
    type?: 'Dynamic' | 'Static' | 'Kinematic'
  }

type Event = RayhitEvent | CollideEvent | CollideBeginEvent | CollideEndEvent
type CollideEvent = {
  op: string
  type: 'collide'
  body: THREE.Object3D
  target: THREE.Object3D
  contact: {
    // the world position of the point of contact
    contactPoint: number[]
    // the normal of the collision on the surface of
    // the colliding body
    contactNormal: number[]
    // velocity of impact along the contact normal
    impactVelocity: number
    // a unique ID for each contact event
    id: string
    // these are lower-level properties from cannon:
    // bi: one of the bodies involved in contact
    bi: THREE.Object3D
    // bj: the other body involved in contact
    bj: THREE.Object3D
    // ni: normal of contact relative to bi
    ni: number[]
    // ri: the point of contact relative to bi
    ri: number[]
    // rj: the point of contact relative to bj
    rj: number[]
  }
  collisionFilters: {
    bodyFilterGroup: number
    bodyFilterMask: number
    targetFilterGroup: number
    targetFilterMask: number
  }
}
type CollideBeginEvent = {
  op: 'event'
  type: 'collideBegin'
  target: Object3D
  body: Object3D
}
type CollideEndEvent = {
  op: 'event'
  type: 'collideEnd'
  target: Object3D
  body: Object3D
}
type RayhitEvent = {
  op: string
  type: 'rayhit'
  body: THREE.Object3D
  target: THREE.Object3D
}

type CylinderArgs = [radiusTop?: number, radiusBottom?: number, height?: number, numSegments?: number]
type SphereArgs = [radius: number]
type TrimeshArgs = [vertices: ArrayLike<number>, indices: ArrayLike<number>]
type HeightfieldArgs = [
  data: number[][],
  options: { elementSize?: number; maxValue?: number; minValue?: number },
]
type ConvexPolyhedronArgs<V extends VectorTypes = VectorTypes> = [
  vertices?: V[],
  faces?: number[][],
  normals?: V[],
  axes?: V[],
  boundingSphereRadius?: number,
]

interface PlaneProps extends BodyProps {}
interface BoxProps extends BodyProps<Triplet> {} // extents: [x, y, z]
interface CylinderProps extends BodyProps<CylinderArgs> {}
interface ParticleProps extends BodyProps {}
interface SphereProps extends BodyProps<SphereArgs> {}
interface TrimeshProps extends BodyPropsArgsRequired<TrimeshArgs> {}
interface HeightfieldProps extends BodyPropsArgsRequired<HeightfieldArgs> {}
interface ConvexPolyhedronProps extends BodyProps<ConvexPolyhedronArgs> {}
interface CompoundBodyProps extends BodyProps {
  shapes: BodyProps & { type: ShapeType }[]
}

interface ConstraintOptns {
  maxForce?: number
  maxMultiplier?: number
  collideConnected?: boolean
  wakeUpBodies?: boolean
}

interface PointToPointConstraintOpts extends ConstraintOptns {
  pivotA: Triplet
  pivotB: Triplet
}

interface ConeTwistConstraintOpts extends ConstraintOptns {
  pivotA?: Triplet
  axisA?: Triplet
  pivotB?: Triplet
  axisB?: Triplet
  angle?: number
  twistAngle?: number
}
interface DistanceConstraintOpts extends ConstraintOptns {
  distance?: number
}

interface HingeConstraintOpts extends ConstraintOptns {
  pivotA?: Triplet
  axisA?: Triplet
  pivotB?: Triplet
  axisB?: Triplet
}

interface LockConstraintOpts extends ConstraintOptns {}

interface SpringOptns {
  restLength?: number
  stiffness?: number
  damping?: number
  worldAnchorA?: Triplet
  worldAnchorB?: Triplet
  localAnchorA?: Triplet
  localAnchorB?: Triplet
}

interface WheelInfoOptions {
  radius?: number
  directionLocal?: Triplet
  suspensionStiffness?: number
  suspensionRestLength?: number
  maxSuspensionForce?: number
  maxSuspensionTravel?: number
  dampingRelaxation?: number
  dampingCompression?: number
  frictionSlip?: number
  rollInfluence?: number
  axleLocal?: Triplet
  chassisConnectionPointLocal?: Triplet
  isFrontWheel?: boolean
  useCustomSlidingRotationalSpeed?: boolean
  customSlidingRotationalSpeed?: number
}

interface RaycastVehicleProps {
  chassisBody: React.Ref<THREE.Object3D>
  wheels: React.Ref<THREE.Object3D>[]
  wheelInfos: WheelInfoOptions[]
  indexForwardAxis?: number
  indexRightAxis?: number
  indexUpAxis?: number
}

FAQ

Broadphases

  • NaiveBroadphase is as simple as it gets. It considers every body to be a potential collider with every other body. This results in the maximum number of narrowphase checks.
  • SAPBroadphase sorts bodies along an axis and then moves down that list finding pairs by looking at body size and position of the next bodies. Control what axis to sort along by setting the axisIndex property.

Types

  • A dynamic body is fully simulated. Can be moved manually by the user, but normally they move according to forces. A dynamic body can collide with all body types. A dynamic body always has finite, non-zero mass.
  • A static body does not move during simulation and behaves as if it has infinite mass. Static bodies can be moved manually by setting the position of the body. The velocity of a static body is always zero. Static bodies do not collide with other static or kinematic bodies.
  • A kinematic body moves under simulation according to its velocity. They do not respond to forces. They can be moved manually, but normally a kinematic body is moved by setting its velocity. A kinematic body behaves as if it has infinite mass. Kinematic bodies do not collide with other static or kinematic bodies.

changelog (log de mudanças)

@react-three/cannon Changelog

6.6.0

Minor Changes

  • 22d49ef: chore: update @types/three dev dependency

Patch Changes

  • Updated dependencies [800a687]
  • Updated dependencies [22d49ef]
    • @pmndrs/cannon-worker-api@2.4.0

v6.5.2 - 2023-01-05

  • [README.md] Update shields badge to point to match their new route (@bjornstar)

v6.5.1 - 2022-11-11

  • Make sure to include dist in npm package (@bjornstar)

v6.5.0 - 2022-11-03

  • Update @pmndrs/cannon-worker-api to v2.3.0 (@bjornstar)

v6.4.0 - 2022-08-18

  • Add support for frictionGravity on WorldProps (@chnicoloso)

v6.3.0 - 2022-04-18

  • DebugProvider explicitly lists children as a prop (@bjornstar)
  • Prefer PropsWithChildren over FC (@bjornstar)
  • Prefer function declarations over const (@bjornstar)
  • [hooks] All hooks are now generic, they accept any Object3D and return refs of whatever type was passed in (@bjornstar)
  • Update @types/react to v18 (@bjornstar)

v6.2.0 - 2022-04-08

  • Add scaleOverride (@bjornstar)

v6.1.0 - 2022-04-02

  • Now calls connect before init in a useEffect (instead of useLayoutEffect)
  • Update @pmndrs/cannon-worker-api to v2.1.0

v6.0.0 - 2022-04-01

  • Removed the Suspense wrapper around Physics, you will need to provide your own suspense boundary from now on
  • react is now a peerDependency and requires v18 or higher
  • three.js is now a peerDependency and requires r139 or higher
  • @react-three/fiber is now a peerDependency and requires v8 or higher
  • @pmndrs/cannon-worker-api is now a dependency
  • cannon-es is now a dependency
  • cannon-es-debugger is now a dependency
  • Updated many devDependencies

v5.1.0 - 2022-03-19

  • Access the physics context with the usePhysicsContext hook, which immediately gives you a clear error message when trying to access physics components or hooks outside of a Physics provider (@bjornstar)
  • Renamed context to physicsContext (@bjornstar)
  • Added a useDebugContext hook for consistency (@bjornstar)
  • [Provider.tsx] Renamed to physics-provider.tsx (@bjornstar)
  • [Debug.tsx] Renamed to debug-provider.tsx (Still exported as Debug & DebugProps) (@bjornstar)
  • [physics-provider.tsx] One useState call that contains the whole context (@bjornstar)
  • [physics-provider.tsx] bodies is not a ref, no need to access current (@bjornstar)
  • [setup.ts] Removed, split into more appropriately named modules (@bjornstar)
  • [worker.d.ts] Removed, belongs in cannon-worker-api (@bjornstar)
  • [package.json] Use dependencies rather than peerDependencies (@bjornstar)
  • [.eslintrc.json] Clean up (@bjornstar)
  • [.eslintrc.json] Disallow non-null assertions (@bjornstar)

v5.0.1 - 2022-03-14

  • Bump @pmndrs/cannon-worker-api to v1.0.1 (@bjornstar)

v5.0.0 - 2022-03-13

  • Use newly isolated @pmndrs/cannon-worker-api (@isaac-mason)
  • Removed useUpdateWorldPropsEffect (@bjornstar)
  • [package.json] Added homepage property to go directly to the package (@bjornstar)
  • [rollup.config.js] Specify targetPlatform: 'browser' (@bjornstar)
  • [tsconfig.json] Alphabetize contents (@bjornstar)

v4.9.0 - 2022-03-03

  • [dependencies] Updated three & @types/three from r135 to r137 (@bjornstar)
  • [examples/dependencies] Updated @react-three/drei from v8.3.1 to v8.11.1 (@bjornstar)
  • [examples/dependencies] Updated @react-three/drei from v8.3.1 to v8.11.1 (@bjornstar)
  • [examples/dependencies] Updated three & @types/three from r135 to r137 (@bjornstar)
  • [examples/dependencies] Updated three-stdlib from 2.6.1 to v2.8.8 (@bjornstar)
  • [esmaples/dependencies] Removed postprocessing, it was unused (@bjornstar)
  • [examples] Updated GLTF types (@bjornstar)

v4.8.0 - 2022-02-28

  • Created CannonWorkerAPI (@isaac-mason)
  • Converted worker to typescript (@bjornstar)
  • [examples/RaycastVehicle] Use a single keyup/keydown event handler (@bjornstar) -

v4.7.0 - 2022-02-12

  • [ESLint] Disallow enums (@bjornstar)
  • Add missing worker 'setMaterial' op handler (@isaac-mason)
  • Add isPaused property (@grndctrl & @bjornstar)
    • BREAKING: step renamed to stepSize (default: 1 / 60)
    • NEW: maxSubSteps (default: 10)
    • NEW: isPaused (fixes Pause Simulation #212)
    • NEW: Paused demo
    • timeSinceLastCall not tracked in worker
    • prefer FC to PropsWithChildren
    • REMOVED: type DefaultContactMaterial

v4.6.1 - 2022-01-19

  • [createMaterialFactory] Do not use logical assignment operator (@bjornstar)
  • [eslint] Disallow logical assignment and nullish coalescing operators (@bjornstar)

v4.6.0 - 2022-01-15

  • [hooks] Add useContactMaterial (@Glavin001)
  • [examples] Add Friction example (@Glavin001)
  • [examples] Add title to links (@Glavin001)

v4.5.0 - 2022-01-08

  • [constraintOptns] Add maxMultiplier (@Glavin001)

v4.4.1 - 2022-01-04

  • [Hooks] Destructure and set defaults intead of using ?? (@bjornstar)
  • [useRaycastVehicle] Use correct ordering for arguments (@bjornstar)
  • [examples/RaycastVehicle] Reset restores the vehicle to it's initial angularVelocity, position, & rotation (@bjornstar)

v4.4.0 - 2022-01-01

  • Upgrade cannon-es-debugger to 1.0.0 (@marcofugaro)
  • [Debug] Improve implementation (@bjornstar)
  • [examples/RaycastVehicle] Press ? to debug (@bjornstar)

v4.3.1 - 2021-12-30

  • Fix RaycastVehicle example (@marcofugaro)

v4.3.0 - 2021-12-18

  • Add AtomicName & VectorName to the README (@bjornstar)
  • Update vite to v2.7.3, change vite.config.js to vite.config.ts (@bjornstar)
  • [examples] add missing peer dependency: react-is (@bjornstar)
  • Update all dependencies, fix example routes for react-router-dom v6 (@bjornstar)

v4.2.0 - 2021-12-01

  • [Types] Use PropsWithChildren from React instead of children: ReactNode (@bjornstar)
  • [README.md] Update default Physics prop values (@bjornstar)
  • export * from './setup' there are a lot of useful types in here (@bjornstar)
  • Build using jsx runtime instead of React runtime for a slightly smaller bundle (@bjornstar)
  • [CHANGELOG.md] Add details for v3.1.1 & v3.1.2 (@bjornstar)

v4.1.0 - 2021-11-21

  • Update default gravity value from -10 to -9.81 (@alexandernanberg)
  • [devDependencies] Update to latest versions (@bjornstar)
  • [CHANGELOG.md] Start writing a changelog (@bjornstar)
  • [README.md] Replace boxBufferGeometry with boxGeometry and planeBufferGeometry with planeGeometry (@drcmda)
  • [examples/devDependencies] Update to latest version (@bjornstar)

v4.0.1 - 2021-10-06

  • Fix an bug where multiple rotations shared an array (@bjornstar)

v4.0.0 - 2021-10-05

  • Add quaternion API, convert from quaternion to rotation correctly (@bjornstar)
  • useSphere args must be an array (@bjornstar)
  • [Typescript] Add types for world messages (like setGravity) (@bjornstar)
  • Prefer CannonEvent over global Event type name (@bjornstar)
  • [TypeScript] Improve set and subscribe API (@bjornstar)

v3.1.2 - 2021-09-02

  • Rebuild package (@stockHuman)

v3.1.1 - 2021-09-02

  • Fix useRaycastVehicle, getUUID was receiving unintended index values (@bjornstar)
  • [README.md] Update demos to point to cannon.pmnd.rs (@bjornstar)

v3.1.0 - 2021-09-01

  • [Examples] Convert Kinematic Cube to TypeScript (#262) (@bjornstar)
  • [Examples] Convert Heightmap to TypeScript (#264) (@bjornstar)
  • [Examples] Convert SphereDebug to TypeScript (#261) (@bjornstar)
  • [Examples] Convert Hinge Motor to TypeScript (#263) (@bjornstar)
  • [Examples] Convert Cube Heap to TypeScript (#265) (@bjornstar)
  • [Examples] Convert Convex Polyhedron to TypeScript (#266) (@bjornstar)
  • [Examples] Convert Compound Body to TypeScript (#268) (@bjornstar)
  • [Examples] Convert Constraints to TypeScript (#267) (@bjornstar)
  • [Examples] Convert Raycast Vehicle to TypeScript (#270) (@bjornstar)
  • [Examples] Convert Chain to TypeScript (#269) (@bjornstar)
  • [Examples] Convert Raycast to TypeScript (#271) (@bjornstar)
  • [Examples] Convert Ping Pong to TypeScript (@bjornstar)
  • [readme.md] Switch build badge from travis to github (@bjornstar)
  • Use Ref to allow for forwarded refs (@bjornstar)
  • Use React.DependencyList instead of any[] for deps (@bjornstar)
  • [CI] Test on node v14 as vercel doesn't support 16 yet (@bjornstar)

v3.0.1 - 2021-08-23

  • Resolve three ourselves to avoid multiple three instances and failed instanceof checks (@bjornstar)

v3.0.0 - 2021-08-21

  • Fix return type of subscribe function (@skuteli)
  • [types] mutableRefObject should default to null (@bjornstar)
  • Start converting examples to typescript (@bjornstar)
  • [CI] Try to build the examples (@bjornstar)
  • Fix getUUID (@bjornstar)
  • Specify all op strings (@bjornstar)
  • Remove .travis.yml, update ignores (@bjornstar)
  • [Examples] Readme & Usability Improvements (@bjornstar)
  • Convert Triggers example to typescript (@bjornstar)
  • Convert Trimesh Example to typescript (@bjornstar)

v2.6.1 - 2021-08-15

  • Rebuild package (@stockHuman)

v2.6.0 - 2021-08-11

  • Switch from CRA to vite (@bjornstar)
  • feat: add applyTorque API to body (@a-type)

v2.5.1 - 2021-07-29

  • Update readme.md (@kevinmcalear)
  • Improve readme (@bjornstar)
  • Wrap in canvas (@bjornstar)
  • support missing world attributes (@drcmda)

v2.5.0 - 2021-07-01

  • Add shouldInvalidate to readme code (@aunyks)
  • [Examples] CubeHeap, click to change to spheres (@bjornstar)
  • Expose WakeUp & Sleep API (stockHuman)

v2.4.0 - 2021-06-28

  • Remove dead code (@Gusted)
  • Setup automated hygiene (@bjornstar)
  • Add prepare script (@bjornstar)
  • Run CI on the master branch (@bjornstar)
  • Don't build examples (@bjornstar)
  • Add 'shouldInvalidate' prop to Physics provider component to allow for pausing the simulation (@aunyks)
  • Update bug_report.md (@stockHuman)
  • Integrate pausing functionality (@stockHuman)
  • Set printWidth to 110 (@bjornstar)