Skip to content

Commit

Permalink
fix: correct timestep update
Browse files Browse the repository at this point in the history
  • Loading branch information
Neosoulink committed Apr 24, 2024
1 parent 8636675 commit 5a2d9fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions examples/jsm/physics/RapierPhysics.js
Expand Up @@ -349,10 +349,11 @@ export class Physic {
/**
* @description Update the physic world.
*
* @param {number | undefined} delta
* @param {number | undefined} timestep The timestep length, in seconds.
*/
step(delta = undefined) {
this.world.step(delta);
step(timestep = undefined) {
if (typeof timestep === "number") this.world.timestep = timestep;
this.world.step();

for (let i = 0, l = this.dynamicObjects.length; i < l; i++) {
const object = this.dynamicObjects[i];
Expand Down
6 changes: 4 additions & 2 deletions examples/physics_rapier_instancing.html
Expand Up @@ -173,9 +173,11 @@

}

function animate() {
const clock = new THREE.Clock();

physics.step();
function animate() {

physics.step( clock.getDelta() );

controls.update();

Expand Down

0 comments on commit 5a2d9fb

Please sign in to comment.