-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Adding a fixedUpdate for full control over physics. #7754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This PR introduces some new APIs and changes some existing internals.
// pc.XrManager
xr.meshDetection // XrMeshDetection interface that provides an access to XrMeshe's
xr.start(camera, pc.XRTYPE_AR, pc.XRSPACE_LOCALFLOOR, {
meshDetection: true // new option to request mesh detection features
});
The naming conventions and style for the code, please refer to contributors doc, more specifically the event names, they need to follow a camelCase naming convention, as the rest of the codebase. |
There are no breaking changes in this PR, as the main modifications relate to physics, to activate the new features, you need to explicitly set usePostFixedUpdateForPhysicsSim to true. Essentially, this PR adds a fixed update event, the step size of which can be adjusted in real time. |
This PR adds two new events — fixedUpdate and postFixedUpdate — to the engine, allowing for more flexible update management. It also introduces the ability to dynamically change the fixed timestep via app.fixedTimeStep (in seconds), providing greater control over update frequency.
A fixedUpdate method has also been added for scripts, which will be called on the fixedUpdate event with a fixed timestep of app.fixedTimeStep (in seconds), regardless of whether the usePostFixedUpdateForPhysicsSim flag is set to false.
Additionally, a new parameter usePostFixedUpdateForPhysicsSim has been added, which controls the physics simulation mode. If set to false, physics will continue to run via the standard Ammo stepSimulation call, with no changes for existing projects. If set to true, the simulation will be executed strictly after fixedUpdate with the fixedTimeStep, enabling more precise and predictable physics behavior without inaccuracies.
This will also mark the beginning of the integration of the Jolt Physics engine into the playcanvas ecosystem. PR data is coming soon.
Cycle application:
PhysicsExampleScript.mjs
: