Table Of Contents

Previous topic

20.33. The Observer Object

Next topic

20.35. The PostEffects Object

This Page

20.34. The PhysicsManager Object

Provides loading and managing of physics nodes. Physics nodes are linked to target scene nodes which they update with the results of physics simulation, DynamicsWorld.update(), by calling the PhysicsManager.update() method. When the target SceneNode the physics object it bound to is destroyed the physics objects are destroyed too. If the SceneNode is removed from the scene the developer is responsible for disabling the physics objects, if they wish to do so. Rigid body nodes should not have a parent node.

Required scripts

The PhysicsManager object requires:

/*{{ javascript("jslib/physicsmanager.js") }}*/
/*{{ javascript("jslib/utilities.js") }}*/

As well as the SceneNode’s required scripts.

20.34.1. Constructor

20.34.1.1. create

Summary

Syntax

var physicsManager = PhysicsManager.create(mathsDevice, physicsDevice, dynamicsWorld);

20.34.2. Methods

20.34.2.1. update

Summary

Called once a frame after the physics simulation to write back the state from the physics nodes back to the target scene nodes.

This should be called after DynamicsWorld.update() but before Scene.update().

Syntax

physicsManager.update();

20.34.2.2. enableHierarchy

Summary

Called to enable or disable physics simulation of a SceneNode and its descendants.

Syntax

physicsManager.enableHierarchy(sceneNode, enabled);
SceneNode
The SceneNode object.
enabled
A JavaScript boolean.

20.34.2.3. enableNode

Summary

Called to enable or disable physics simulation of a SceneNode.

Syntax

physicsManager.enableNode(sceneNode, enabled);
SceneNode
A SceneNode object.
enabled
A JavaScript boolean.

20.34.2.4. deleteHierarchy

Summary

Called to remove physics objects from a SceneNode and its descendants.

Syntax

physicsManager.deleteHierarchy(sceneNode);
SceneNode
The SceneNode object.

20.34.2.5. deleteNode

Summary

Called to remove physics objects from a SceneNode.

Syntax

physicsManager.deleteNode(sceneNode);
SceneNode
A SceneNode object.

20.34.2.6. calculateHierarchyExtents

Summary

Called to calculate the extents of the physics objects of a SceneNode and its descendants.

Returns undefined if there are none.

Syntax

var physicsExtents = physicsManager.calculateHierarchyExtents(sceneNode);
SceneNode
The SceneNode object.

Returns an extents object.

20.34.2.7. calculateExtents

Summary

Called to calculate the extents of the physics objects of a SceneNode.

Returns undefined if there are none.

Syntax

var physicsExtents = physicsManager.calculateExtents(sceneNode);
SceneNode
The SceneNode object.

Returns an extents object.

20.34.2.8. createSnapshot

Summary

Create a snapshot of the state of all the dynamic physic objects.

Syntax

var snapshot = physicsManager.createSnapshot();

Returns a snapshot object.

20.34.2.9. restoreSnapshot

Summary

Restore the state of all the dynamic physic objects from the snapshot object.

Syntax

physicsManager.restoreSnapshot(snapshot);

20.34.3. Properties

20.34.3.1. version

Summary

The version number of the PhysicsManager implementation.

Syntax

var versionNumber = physicsManager.version;