PhysicsObject Class

Extends Object3D
Module: Physics

Wrapper for cannon.js physics objects.

Physics coordinates are always calculated in local space, they should always be placed directly inside the scene or inside containers without any offset.

nunuStudio includes tools to create cannon shapes from three geometry objects.

Documentation for cannon.js physics available here http://schteppe.github.io/cannon.js/docs/

Constructor

PhysicsObject

()

Item Index

Attributes

Methods

addShape

(
  • shape
)

Add shape to physics object body.

Parameters:

  • shape CANNON.Shape

initialize

()

Intialize physics object and add it to the scene physics world.

Automatically called by the runtime.

toJSON

(
  • meta
)
Object

Create JSON for object. Need to backup material and geometry and set to undefined to avoid it being stored.

Parameters:

  • meta Object

Returns:

Object:

json

update

()

Update object position and rotation based on cannon.js body.

Automatically called by the runtime.

Attributes

body

CANNON.Body

Physics body contains the following attributes.

  • position Vec3
  • velocity Vec3
  • torque Vec3
  • angularVelocity Vec3
  • quaternion Quaternion
  • mass Number
  • material Material
  • type Number
  • linearDamping Number
  • angularDamping Number
  • allowSleep Boolean
  • sleepSpeedLimit Number
  • sleepTimeLimit Number
  • collisionFilterGroup Number
  • collisionFilterMask Number
  • fixedRotation Boolean
  • shape Array

world

CANNON.World

Physics world.