Skip to main content

Function: addLinearSpringComponent()

addLinearSpringComponent(world, entity, options): LinearSpringEcsComponent

Defined in: physics/components/linear-spring-component.ts:93

Attaches a LinearSpringEcsComponent to entity.

Parameters

world

EcsWorld

The ECS world entity belongs to.

entity

number

The entity to attach the component to.

options

LinearSpringOptions

Options for configuring the spring. Neither bodyA, bodyB, nor stiffness has a sensible default and all three must always be provided.

Returns

LinearSpringEcsComponent

The attached component, for further tuning or runtime changes.

Throws

An error if stiffness is negative.