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.
Summary
Syntax
var physicsManager = PhysicsManager.create(mathsDevice, physicsDevice, dynamicsWorld);
Summary
Add a SceneNode and its relevant physics object to the manager.
Syntax
physicsManager.addNode(sceneNode, physicsObject, origin, triangleArray);
Note
This method calls enableHierarchy.
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();
Summary
Called to enable or disable physics simulation of a SceneNode and its descendants.
Syntax
physicsManager.enableHierarchy(sceneNode, enabled);
Summary
Called to enable or disable physics simulation of a SceneNode.
Syntax
physicsManager.enableNode(sceneNode, enabled);
Summary
Called to remove physics objects from a SceneNode and its descendants.
Syntax
physicsManager.deleteHierarchy(sceneNode);
Summary
Called to remove physics objects from a SceneNode.
Syntax
physicsManager.deleteNode(sceneNode);
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);
Returns an extents object.
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);
Returns an extents object.
Summary
Create a snapshot of the state of all the dynamic physic objects.
Syntax
var snapshot = physicsManager.createSnapshot();
Returns a snapshot object.
Summary
Restore the state of all the dynamic physic objects from the snapshot object.
Syntax
physicsManager.restoreSnapshot(snapshot);