Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Cylinder

Cylinder class.

example
const radiusTop = 0.5
const radiusBottom = 0.5
const height = 2
const numSegments = 12
const cylinderShape = new CANNON.Cylinder(radiusTop, radiusBottom, height, numSegments)
const cylinderBody = new CANNON.Body({ mass: 1, shape: cylinderShape })
world.addBody(cylinderBody)

Hierarchy

Index

Constructors

constructor

  • new Cylinder(radiusTop?: number, radiusBottom?: number, height?: number, numSegments?: number): Cylinder
  • Parameters

    • radiusTop: number = 1

      The radius of the top of the Cylinder.

    • radiusBottom: number = 1

      The radius of the bottom of the Cylinder.

    • height: number = 1

      The height of the Cylinder.

    • numSegments: number = 8

      The number of segments to build the cylinder out of.

    Returns Cylinder

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

faceNormals

faceNormals: Vec3[]

faceNormals

faces

faces: number[][]

Array of integer arrays, indicating which vertices each face consists of

height

height: number

The height of the Cylinder.

id

id: number

Identifier of the Shape.

material

material: null | Material

Optional material of the shape that regulates contact properties.

numSegments

numSegments: number

The number of segments to build the cylinder out of.

radiusBottom

radiusBottom: number

The radius of the bottom of the Cylinder.

radiusTop

radiusTop: number

The radius of the top of the Cylinder.

type

type: 0 | ShapeType

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

uniqueAxes

uniqueAxes: null | Vec3[]

If given, these locally defined, normalized axes are the only ones being checked when doing separating axis check.

uniqueEdges

uniqueEdges: Vec3[]

uniqueEdges

vertices

vertices: Vec3[]

vertices

worldFaceNormals

worldFaceNormals: Vec3[]

worldFaceNormals

worldFaceNormalsNeedsUpdate

worldFaceNormalsNeedsUpdate: boolean

worldFaceNormalsNeedsUpdate

worldVertices

worldVertices: Vec3[]

worldVertices

worldVerticesNeedsUpdate

worldVerticesNeedsUpdate: boolean

worldVerticesNeedsUpdate

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): void

calculateWorldAABB

clipFaceAgainstHull

clipFaceAgainstPlane

  • clipFaceAgainstPlane(inVertices: Vec3[], outVertices: Vec3[], planeNormal: Vec3, planeConstant: number): Vec3[]

computeEdges

  • computeEdges(): void

computeNormals

  • computeNormals(): void

computeWorldFaceNormals

computeWorldVertices

findSeparatingAxis

getAveragePointLocal

  • getAveragePointLocal(target?: Vec3): Vec3

getFaceNormal

  • getFaceNormal(i: number, target: Vec3): void

pointIsInside

  • pointIsInside(p: Vec3): false | 1 | -1
  • Checks whether p is inside the polyhedra. Must be in local coords. The point lies outside of the convex hull of the other points if and only if the direction of all the vectors from it to those other points are on less than one half of a sphere around it.

    Parameters

    • p: Vec3

      A point given in local coordinates

    Returns false | 1 | -1

testSepAxis

transformAllPoints

updateBoundingSphereRadius

  • updateBoundingSphereRadius(): void

volume

  • volume(): number

Static computeNormal

Static project