#

API Docs for: 0.6.1
Show: Inherited Protected Private Deprecated

# Spring Class

Defined in: `src/objects/Spring.js:5`

A spring, connecting two bodies.

## Constructor

### `Spring`

(

- `bodyA`
- `bodyB`
- `[options]`

)

Defined in `src/objects/Spring.js:5`

#### Parameters:

- `bodyA` Body
- `bodyB` Body
- `[options]` Object optional
  - `[restLength]` Number optional

    A number > 0. Default: 1

  - `[stiffness]` Number optional

    A number >= 0. Default: 100

  - `[damping]` Number optional

    A number >= 0. Default: 1

  - `[worldAnchorA]` Vec3 optional

    Where to hook the spring to body A, in world coordinates.

  - `[worldAnchorB]` Vec3 optional
  - `[localAnchorA]` Vec3 optional

    Where to hook the spring to body A, in local body coordinates.

  - `[localAnchorB]` Vec3 optional

- Index
- Methods
- Properties

## Item Index

### Methods

- applyForce
- getWorldAnchorA
- getWorldAnchorB
- setWorldAnchorA
- setWorldAnchorB

### Properties

- bodyA
- bodyB
- damping
- localAnchorA
- localAnchorB
- restLength
- stiffness

## Methods

### `applyForce`

()

Defined in `src/objects/Spring.js:135`

Apply the spring force to the connected bodies.

### `getWorldAnchorA`

(

- `result`

)

Defined in `src/objects/Spring.js:105`

Get the anchor point on body A, in world coordinates.

#### Parameters:

- `result` Vec3

  The vector to store the result in.

### `getWorldAnchorB`

(

- `result`

)

Defined in `src/objects/Spring.js:114`

Get the anchor point on body B, in world coordinates.

#### Parameters:

- `result` Vec3

  The vector to store the result in.

### `setWorldAnchorA`

(

- `worldAnchorA`

)

Defined in `src/objects/Spring.js:87`

Set the anchor point on body A, using world coordinates.

#### Parameters:

- `worldAnchorA` Vec3

### `setWorldAnchorB`

(

- `worldAnchorB`

)

Defined in `src/objects/Spring.js:96`

Set the anchor point on body B, using world coordinates.

#### Parameters:

- `worldAnchorB` Vec3

## Properties

### `bodyA`

Body

Defined in `src/objects/Spring.js:45`

First connected body.

### `bodyB`

Body

Defined in `src/objects/Spring.js:52`

Second connected body.

### `damping`

Number

Defined in `src/objects/Spring.js:38`

Damping of the spring.

### `localAnchorA`

Vec3

Defined in `src/objects/Spring.js:59`

Anchor for bodyA in local bodyA coordinates.

### `localAnchorB`

Vec3

Defined in `src/objects/Spring.js:66`

Anchor for bodyB in local bodyB coordinates.

### `restLength`

Number

Defined in `src/objects/Spring.js:24`

Rest length of the spring.

### `stiffness`

Number

Defined in `src/objects/Spring.js:31`

Stiffness of the spring.