Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Sphere

Spherical shape

example
const radius = 1
const sphereShape = new CANNON.Sphere(radius)
const sphereBody = new CANNON.Body({ mass: 1, shape: sphereShape })
world.addBody(sphereBody)

Hierarchy

Index

Constructors

constructor

  • new Sphere(radius: number): Sphere

Properties

body

body: null | Body

The body to which the shape is added to.

boundingSphereRadius

boundingSphereRadius: number

The local bounding sphere radius of this shape.

collisionResponse

collisionResponse: boolean

Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled.

default

true

id

id: number

Identifier of the Shape.

material

material: null | Material

Optional material of the shape that regulates contact properties.

radius

radius: number

The radius of the sphere.

type

type: 0 | ShapeType

The type of this shape. Must be set to an int > 0 by subclasses.

Static types

types: { BOX: 4; COMPOUND: 8; CONVEXPOLYHEDRON: 16; CYLINDER: 128; HEIGHTFIELD: 32; PARTICLE: 64; PLANE: 2; SPHERE: 1; TRIMESH: 256 } = SHAPE_TYPES

All the Shape types.

Type declaration

  • BOX: 4
  • COMPOUND: 8
  • CONVEXPOLYHEDRON: 16
  • CYLINDER: 128
  • HEIGHTFIELD: 32
  • PARTICLE: 64
  • PLANE: 2
  • SPHERE: 1
  • TRIMESH: 256

Methods

calculateLocalInertia

  • calculateLocalInertia(mass: number, target?: Vec3): Vec3

updateBoundingSphereRadius

  • updateBoundingSphereRadius(): void

volume

  • volume(): number